Jump to content

  • Log In with Google      Sign In   
  • Create Account

Plane generation issue...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Migi0027   Crossbones+   -  Reputation: 1727

Like
0Likes
Like

Posted 03 July 2012 - 09:55 AM

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 itPosted Image

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, 03 July 2012 - 10:39 AM.

Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

Sponsor:

#2 Migi0027   Crossbones+   -  Reputation: 1727

Like
0Likes
Like

Posted 03 July 2012 - 01:10 PM

If you want pictures:

Posted Image
Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#3 gnomgrol   Members   -  Reputation: 584

Like
0Likes
Like

Posted 04 July 2012 - 06:03 AM

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, 04 July 2012 - 06:24 AM.


#4 Migi0027   Crossbones+   -  Reputation: 1727

Like
0Likes
Like

Posted 04 July 2012 - 07:14 AM

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/
Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS