# TriangleList

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

## Recommended Posts

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!

##### Share on other sites
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 :).

##### Share on other sites
hi sirob.
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 ;(

##### Share on other sites
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.

##### Share on other sites
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...

##### Share on other sites
You need to only duplicate the first and last vertex, not face.

Quote:
 // First 3 Vertices for 1 trianglevertsCube[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 :).

1. 1
Rutin
28
2. 2
3. 3
4. 4
5. 5

• 12
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632952
• Total Posts
3009440
• ### Who's Online (See full list)

There are no registered users currently online

×