Triangle STRIP Question (DirectX)

Started by
12 comments, last by Add 16 years, 3 months ago
Hi THanks for that!

Also could i ask a question, cuz maybe this is causing all the problems. Can i fill in the vertices in horizontal order, and worry about creating the triangles later with the indices? Or do i have to at least place the vertices in say a 'triangle strip' like fashion, i.e. zig-zagging across the hypotenuse of the triangles i wish to draw and then work out the triangles with the indicies.

Thanks!
Advertisement
Quote:Original post by fuchi
Hi THanks for that!

Also could i ask a question, cuz maybe this is causing all the problems. Can i fill in the vertices in horizontal order, and worry about creating the triangles later with the indices? Or do i have to at least place the vertices in say a 'triangle strip' like fashion, i.e. zig-zagging across the hypotenuse of the triangles i wish to draw and then work out the triangles with the indicies.

Thanks!
Yup. Vertex order doesn't matter at all, only index order. However, it's usually best to try and keep similar vertices together for cache reasons.
OH MY GOD!!!

I hate myself!!!

Everything was right all along, it was just my stupid way of calculating the indexes for the arrays :|. Im the biggest dickhead, and I'm so sorry i wasted everyones time!!

What i had was

	index = -1;	int a;	for (int z = 0; z < mapHeight - 1; z++)	{		// Fill a quad at a time		for (x = 0; x < mapWidth - 1; x++)		{			// First triangle			a = x + (z * mapWidth);			indices[index++] = a;			indices[index++] = a + mapWidth + 1;			indices[index++] = a + 1;			// Second triangle			indices[index++] = a + mapWidth + 1;			indices[index++] = a;			indices[index++] = a + mapWidth;		}	}


I forgot that say indicies[a++] uses the current values for a, then increases it after! Duh... no wonder everything was all screwed up. I tried so many different methods of drawing the vertices.. changing all the orders.. trying both CW and CCW and CW/CWW even though it was supposed to be CW.... Oh well thanks alot everyone for your help... just yeah i hate myself.

Thanks again!
Quote:Original post by fuchi
Add:
YOu said that what i did wrong was layed out all the vertices in horizontal strips, so none of them would show up. I thought that when you use indicies, you can place the vertices in any order, and use the indices to form your triangles. Is this not true?

Yeah, sorry man, thought you were using indexes as labels in that ascii diagram.


Original post by fuchi
I said:
For example you'd need to generate a triangle with no area using verts 6, 7 & 8. You'd have further problems still if 6, 7, 8 were not inline (i.e. most 3D situations), and you'd have an extra unwanted tri being rendered as mentioned above, in which case you'd need... more degenerate triangles... messy.
End me.

Wouldn't you be able to solve hte problem by doing something like generating TWO triangles with no area, i.e. [6,6,7] and [7,8,8] or something like that? I read somewhere that yeah you overcome the degenerate triangles problem by doubling the vertices at the end of the strip.


Not checking that, but yeah, that's the kind of thing youd need to do, it's just an extra consideration (and something else to go worng, but i'm just lazy) if you're generating your terrain in a for loop.

Regarding the tri-strip/tri-list thing:
It appears to depend on what and how you're doing stuffs. I had a quick google on the topic, and i found this and a thread on this site too, both interesting discussions on the topic, check it out.

Good work on solving your problem though :o)

Cheers,
Add

Edit: Another discussion on the ogre3d forums on the topic. (This mentions tri-strips for older hardware) http://www.ogre3d.org/phpBB2/viewtopic.php?p=64554
"The FFT - an algorithm the whole family can use" ... and for my next joke...

This topic is closed to new replies.

Advertisement