Skip to main content
GameDev.net gamedev.net
🔒 Locked

Plane generation issue...

Started by Veiled Glitch Jul 3, 2012 at 3:55 PM 2 replies 2.4k views
Original Post
Veiled Glitch
Veiled Glitch

Hi, and im currently having a problem with generating planes... I know that i did a stupid mistake, but unfortunately, i can't find it

dry.png





So, i would like to ask you for some help:





#include <d3d11.h>

#include <d3dx11.h>

#include <d3dx10.h>

struct PLANE {FLOAT X, Y, Z; D3DXVECTOR3 Normal; FLOAT U, V;};

class PlaneStruct

{

public:PLANE PlaneVertices[3];

public:DWORD PlaneIndices[5];

void CreatePlane(float size)

{

PLANE PlaneObject;

PlaneObject.X = 1.0f * size;

PlaneObject.Y = 0.0f;

PlaneObject.Z = 1.0f * size;

PlaneObject.Normal = D3DXVECTOR3(0.0f, 0.0f, 1.0f);

PlaneObject.U = 0.0f;

PlaneObject.V = 0.0f;

PLANE PlaneObject1;

PlaneObject.X = -1.0f * size;

PlaneObject.Y = 0.0f;

PlaneObject.Z = 1.0f * size;

PlaneObject.Normal = D3DXVECTOR3(0.0f, 0.0f, 1.0f);

PlaneObject.U = 0.0f;

PlaneObject.V = 1.0f;

PLANE PlaneObject2;

PlaneObject.X = -1.0f * size;

PlaneObject.Y = 0.0f;

PlaneObject.Z = -1.0f * size;

PlaneObject.Normal = D3DXVECTOR3(0.0f, 0.0f, 1.0f);

PlaneObject.U = 1.0f;

PlaneObject.V = 0.0f;

PLANE PlaneObject3;

PlaneObject.X = 1.0f * size;

PlaneObject.Y = 0.0f;

PlaneObject.Z = -1.0f * size;

PlaneObject.Normal = D3DXVECTOR3(0.0f, 0.0f, 1.0f);

PlaneObject.U = 1.0f;

PlaneObject.V = 1.0f;



PlaneVertices[0] = PlaneObject;

PlaneVertices[1] = PlaneObject1;

PlaneVertices[2] = PlaneObject2;

PlaneVertices[3] = PlaneObject3;

PlaneIndices[0] = 0;

PlaneIndices[1] = 2;

PlaneIndices[2] = 1;

PlaneIndices[3] = 0;

PlaneIndices[4] = 3;

PlaneIndices[5] = 2;

}

};

gnmgrl
gnmgrl
You are messing up pretty badly with the vertices/indices, a simple plane would simply look like this:
//4 vertices, 6 indices
[source lang="cpp"]
vertices[0].pos = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
vertices[1].pos = D3DXVECTOR3(10.0f, 0.0f, 0.0f);
vertices[2].pos = D3DXVECTOR3(0.0f, 0.0f, 10.0f);
vertices[3].pos = D3DXVECTOR3(10.0f, 0.0f, 10.0f);

vertices[0].normal = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
vertices[1].normal = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
vertices[2].normal = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
vertices[3].normal = D3DXVECTOR3(0.0f, 1.0f, 0.0f);


vertices[0].tex = D3DXVECTOR2(0.0f, 1.0f); // texcoords start left top corner!
vertices[1].tex = D3DXVECTOR2(1.0f, 1.0f);
vertices[2].tex = D3DXVECTOR2(0.0f, 0.0f);
vertices[3].tex = D3DXVECTOR2(1.0f, 0.0f);



indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
indices[3] = 0;
indices[4] = 2;
indices[5] = 3;

[/source]


I hope that helps
Veiled Glitch
Veiled Glitch
Thanks for replying, ill test if it works when i get another challange done:
http://www.gamedev.net/topic/627421-c-dx11-render-to-panel/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.