TriangleList

Started by
4 comments, last by sirob 18 years, 4 months ago
Hi Guys. i wanted to generate a cube with a single triangle strip. right now i think this is not possible. am im right? anyway, here is my real Problem: i thought u can start a new strip by setting the same vertex twice. for example: // First 3 Vertices for 1 triangle vertsCube[0] = new PositionColored(-1f,1f,1f,Color.Blue); vertsCube[1] = new PositionColored(1f,1f,1f,Color.Blue); vertsCube[2] = new PositionColored(-1f,1f,-1f,Color.Blue); // Setting the next vertix to the vertex with index 2, to start a new triangle strip: vertsCube[3] = new PositionColored(-1f,1f,-1f,Color.Blue); // Vertex with index 4 starts a new strip (or should) vCube[4] = new PositionColored(1f,1f,-1f,Color.Blue); vCube[5] = new PositionColored(1f,1f,-1f,Color.Blue); vCube[6] = new Karpos.Graphics.PositionColored(-1f,-1f,-1f,Color.LightBlue); but if i try to render 2 triangles, i only get the first one rendered. Where is the problem? thx!
Advertisement
You need to place the last vertex of the old strip and the first vertex of the new strip twice, each. That is:

ABC
and DEF
turns into ABCCDDEF.

That should work :).
Sirob Yes.» - status: Work-O-Rama.
hi sirob.
thx for your fast reply.
i just did exactly what u told me to do:

// Up face
vCube[0] = new PositionColored(-1f,1f,1f,Color.Blue);
vCube[1] = new PositionColored(1f,1f,1f,Color.Blue);
vCube[2] = new PositionColored(-1f,1f,-1f,Color.Blue);
vCube[3] = new PositionColored(1f,1f,-1f,Color.Blue);

// front face
vCube[4] = new PositionColored(-1f,-1f,-1f,Color.LightBlue);
vCube[5] = new PositionColored(1f,-1f,-1f,Color.LightBlue);

// down face
vCube[6] = new PositionColored(-1f,-1f,1f,Color.Purple);
vCube[7] = new PositionColored(1f,-1f,1f,Color.Purple);

// start a new strip: vertex8 is the same as vertex 7 and vertex9 is equal
// to vertex 10
vCube[8] = new PositionColored(1f,-1f,1f,Color.Purple);
vCube[9] = new PositionColored(-1f,1f,-1f,Color.Blue);

// vertex 10 should now start a new strip...
vCube[10] = new PositionColored(-1f,1f,-1f,Color.Blue);
vCube[11] = new PositionColored(-1f,-1f,-1f,Color.LightBlue);
vCube[12] = new PositionColored(-1f,1f,1f,Color.Blue);
vCube[13] = new PositionColored(-1f,-1f,1f,Color.LightBlue);

if i render the cube i still only get 3 faces (up, front and down).
thats really frustrating ;(
Is there a compelling reason why you're trying to do this? Strips work well for continuous geometry which cubes really aren't. Using a triangle list is really easy.
Stay Casual,KenDrunken Hyena
i know that in this cause a triangle list would be the better choice. im just doing this for... educational purposes. i just want to know IF this is possible and how to do it...
You need to only duplicate the first and last vertex, not face.

Quote:
// First 3 Vertices for 1 triangle
vertsCube[0] = new PositionColored(-1f,1f,1f,Color.Blue);
vertsCube[1] = new PositionColored(1f,1f,1f,Color.Blue);
vertsCube[2] = new PositionColored(-1f,1f,-1f,Color.Blue);

// Setting the next vertix to the vertex with index 2, to start a new triangle strip:
vertsCube[3] = new PositionColored(-1f,1f,-1f,Color.Blue);

// Vertex with index 4 starts a new strip (or should)
vCube[4] = new PositionColored(1f,1f,-1f,Color.Blue);
vCube[5] = new PositionColored(1f,1f,-1f,Color.Blue);
vCube[6] = new Karpos.Graphics.PositionColored(-1f,-1f,-1f,Color.LightBlue);

In this code, you are already duplicating vertex 2 (the duplicate is vertex 3).
What you're missing is a duplicate of vertex 4. This should be place between the vertices currently numbered 3 and 4.

If this isn't clear enough, or you just want to read more, heres a link on Concatenating Triangle Strips.

Hope this helps :).
Sirob Yes.» - status: Work-O-Rama.

This topic is closed to new replies.

Advertisement