Jump to content
  • Advertisement
Sign in to follow this  
Migi0027

DX11 Plane generation issue...

This topic is 2203 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, im Miguel Petersen, and im currently having a problem with generating planes... I know that i did a stupid mistake, but unfortunately, i can't find itdry.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;
}
};


Best Regards
Miguel Petersen Edited by Migi0027

Share this post


Link to post
Share on other sites
Advertisement
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 Edited by gnomgrol

Share this post


Link to post
Share on other sites
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/

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!