PDA

View Full Version : nvTriStrip



robert
08-05-2002, 03:24 AM
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 http://www.opengl.org/discussion_boards/ubb/smile.gif

Morglum
08-06-2002, 02:22 AM
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.

robert
08-06-2002, 05:56 PM
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).]

SirKnight
08-06-2002, 07:54 PM
It needs an unsigned short pointer, is this a pointer to an array of unsigned shorts that point to my individual vertex positions?


Yes! http://www.opengl.org/discussion_boards/ubb/smile.gif 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

robert
08-06-2002, 10:18 PM
I thought that was what i did have, but there still seems to be problems http://www.opengl.org/discussion_boards/ubb/frown.gif




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 = &amp;m_VertList[i].vPosition;
tempArray[i] = (unsigned short)(&amp;vecPtr->x);
}

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


Does this seem right, or completely wrong http://www.opengl.org/discussion_boards/ubb/wink.gif? I think i'm missing something simple.

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

knackered
08-06-2002, 11:07 PM
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.

robert
08-06-2002, 11:12 PM
oh http://www.opengl.org/discussion_boards/ubb/smile.gif..

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 http://www.opengl.org/discussion_boards/ubb/smile.gif

knackered
08-07-2002, 01:10 AM
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.

robert
08-07-2002, 01:20 AM
>Sorry, didn't mean to sound condesending.

No you didn't, you have helped me fix this problem, which is all that matters http://www.opengl.org/discussion_boards/ubb/smile.gif

Adrian
08-07-2002, 02:02 AM
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?

knackered
08-07-2002, 03:13 AM
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 http://www.opengl.org/discussion_boards/ubb/smile.gif

celic
08-08-2002, 10:55 AM
robert, I also tried to use the NvTriStrip, but I met some problems..
could you send me your code???

Thanks!!!

email: celic733@yahoo.com

robert
08-08-2002, 11:24 AM
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.

Sundy
08-08-2002, 11:50 AM
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