# nvTriStrip

Has anybody worked with NVTristrip and Opengl (not directx)… if so, would it be possible for me to look at that section of code?

thanks

I have. It has proved extremely useful. I could show you my code, but that’s 2 lines of codes among 10,000 of my program, so you’d find it hard to read. If you have a question, I’ll try to answer, but to be honnest, nvtristrip is easy to use. You just call GenerateStrips and RemapIndices, and you can find some doc about them in the header file.

Thanks for answering, yes i have found it easy the only problem i had was with the concept of the indices in:

void GenerateStrips(const unsigned short* in_indices, const unsigned int in_numIndices,PrimitiveGroup** primGroups, unsigned short* numGroups);

MyVertex {
Vector pos;
Vector tex;
etc…
}
and that is stored in a vector<MyVertex> array.

I am having trouble with the first parameter, the rest are ok. It needs an unsigned short pointer, is this a pointer to an array of unsigned shorts that point to my individual vertex positions?

[This message has been edited by robert (edited 08-06-2002).]

It needs an unsigned short pointer, is this a pointer to an array of unsigned shorts that point to my individual vertex positions?

Yes! It would be like this:

USHORT indices[] =
{ 0, 1, 2 };

FLOAT vertices[] =
{ 0.0f, 1.0f, 0.0f,
-1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f };

So 0 points to the first vertex, 1 points to the 2nd vertex and so on.

-SirKnight

I thought that was what i did have, but there still seems to be problems

int vertBufferSize = (int)m_VertList.size();

unsigned short *tempArray = new unsigned short [m_VertList.size()];

Vector *vecPtr;
for (int i = 0; i < vertBufferSize; i++)
{
vecPtr = &m_VertList[i].vPosition;
tempArray[i] = (unsigned short)(&vecPtr->x);
}

GenerateStrips(tempArray,vertBufferSize*3,&pOldPG,&numGroups);

Does this seem right, or completely wrong ? I think i’m missing something simple.

[This message has been edited by robert (edited 08-07-2002).]

No, that’s wrong. Very wrong.
The unsigned short in question is an index into your vertex array - you don’t need to pass your vertices to tristrip (or pointers to individual vertices!), it doesn’t care about vertices, only indices.
Seeing as though you don’t seem to know about indices, you must be drawing your triangles using straight glDrawArrays calls, in which case you won’t be sharing any vertices, which means, I’m afraid, that tristrip will be of no use to you.

oh

That would explain it, i thought that at first but then i wondered how NVTriStrip would be able to optimize by only using the indices,… then i got lost in my own thoughts.

It wouldn’t be hard for me to convert to using indices, i do know what they are but just was thinking on the wrong wave length so to speak

Sorry, didn’t mean to sound condesending.
What you should do is ‘weld’ your vertices together when you generate an index array - ie. check to see if a vertex has roughly the same position/texcoord/normal etc. as any others in your array, and if it has, then just use that vertex once, and reference it with indices in whichever triangle the duplicate vertices are.

>Sorry, didn’t mean to sound condesending.

No you didn’t, you have helped me fix this problem, which is all that matters

On the subject of NVTriStrip…

I use display lists for my objects and the GL_TRIANGLES primitive. Will I benefit from using NVTriStip? Will the display list not perform this optimisation automatically? Could the drivers not be written to do so if they don’t already?

If you use indices, then yes you’d benefit from using nvtristrip.
As for the driver creating tristrips when you compile a display list - naaahhh…it can take a long time to tristrip a mesh, so it’s best done as a preprocessing step and the resultant tristrips dumped to a file. People won’t appreciate waiting 30 seconds for a display list to compile

robert, I also tried to use the NvTriStrip, but I met some problems…
could you send me your code???

Thanks!!!

email: celic733@yahoo.com

celic, i could send you my code but i haven’t fixed this bit that was mentioned on this topic. What problems are you having, maybe we can help? If not i can send you what i have done.

Hi,

NvTriStrip si great but it takes its own sweet time to process meshes! Sometimes it takes around 30-40 mins for a scene with around 200,000 faces.

-Sundar