PDA

View Full Version : 3D Triangle.

Dire_Avenger
01-30-2001, 07:45 AM
Okay, changing cube to a 3D Triangle(What are they *called*???)

Can anyone tell me if this data works, and what order I should draw the triangles?(right now, it's not all joining together
http://www.opengl.org/discussion_boards/ubb/frown.gif )

typedef GLfloat Point3D[3];

Point3D BottomTri[3] =
{
{-1.75, -1.75, 1.0},
{1.75, -1.75, 1.0},
{0.0, -1.75, -1.0}
};

Point3D BackLeftTri[3] =
{
{0.0, -1.75, -1.0},
{0.0, 1.75, 0.0},
{-1.75, -1.75, 1.0}
};

Point3D BackRightTri[3] =
{
{0.0,-1.75, -1.0},
{0.0, 1.75, 0.0},
{1.75, -1.75, 1.0}
};

Point3D FrontTri[3] =
{
{-1.75, -1.75, 1.0},
{1.75, -1.75, 1.0},
{0.0, 1.75, 0.0}
};

I'm drawing the data in a display list that goes like:
glBegin(GL_TRIANGLES);
//Bottom Triangle display
//Back Left Triangle Display
//Back Right Triangle Display
//Front Triangle Display
glEnd();

billy
01-30-2001, 08:36 AM
A cube has 6 faces so you need 12 triangles.
2 triangles for each face.

I don't see this in your code.

chennes
01-30-2001, 10:15 AM
Perhaps I'm just misunderstanding you here: are you trying to draw a pyramid?

If so, your code looks fine to me. Also, it wouldn't really matter what order you drew the triangles in anyway, as long as you don't do transformations between draws.

Chris

billy
01-31-2001, 12:27 AM
I guess I did not understand what you meant by 3D triangle.

A pyramid is formed by a quad on the bottom and 4 lateral triangles. So to do this with you need two triangles on the bottom plus 4 triangles so thats 6 triangles for all.

However, if you want to do a tetrahedral solid. It is formed by four triangles.

I think you better explain what you mean by 3D triangle.

Dire_Avenger
01-31-2001, 04:19 AM
Found it! Tetrahedron http://www.opengl.org/discussion_boards/ubb/smile.gif
Four triangles, making a sort of 'half-pyramid' shape.

That is, half-pyramid as if cut diagonally.

[This message has been edited by Dire_Avenger (edited 01-31-2001).]

chennes
01-31-2001, 06:28 AM
And incindentally, according to Webster's, a pyramid can have any sort of poly as a base - squares are just the most common. http://www.opengl.org/discussion_boards/ubb/smile.gif

Chris