Sign in to follow this  

TriangleList

This topic is 4382 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 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 this post


Link to post
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 this post


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

Share this post


Link to post
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 this post


Link to post
Share on other sites
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 :).

Share this post


Link to post
Share on other sites

This topic is 4382 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this