Sign in to follow this  
n9ine

Render operation types & Index generation

Recommended Posts

Hi all; Where can I find algorithms for index generation for different render operation types (Triangle_fan, triangle_strip,...) I know the vertices positions and the render operation type, How can I generate indices.

Share this post


Link to post
Share on other sites
Thanks but I need just how indeces are generated:
Suppose I have those vertices :


Triangle Fan
v1(0.2,0.3,1.0)
v2(-0.8,0.3,-1.0)
v3(0.1,-0.5,1.0)

Triangle Fan
v4(-0.2,0.4,1.0)
v5(0.2,-0.3,1.0)
v6(0.4,0.3,1.0)
v7(0.7,-0.3,1.0)

what are the indexes I have to use here for this exemple.


Share this post


Link to post
Share on other sites
Sorry if I'm missing something, but isn't it just 0, 1, 2 for the first one and 4, 5, 6, 7 for the second one? (assuming they are in the same vertex buffer)

Also you'll need to render them in two separate draw calls.

Share this post


Link to post
Share on other sites
Quote:
Original post by n9ine
thanks , I still have a problem

Excuse me, but Gage64 is absolutely right: The example you've asked for is too obvious to let us recognize what exactly your problem is.

Can you describe it in more detail? E.g.
* finding duplicate vertex positions for building triangle lists?
* building tri-strips / tri-fans from a given triangle soup?
* optimizing a triangle soup for the post-T&L cache?
* ...

Or, more basically (but less likely, I think)
* allocating and writing to a VBO for indices in general?
* accessing arrays of vertex attributes, perhaps a vertex VBO itself, during the process of index generation?
* ...

Share this post


Link to post
Share on other sites
If I use Opengl I can draw using this code :

glBegin(GL_TRIANGLE_FAN)
glVertex3fv(0.000, 30.000, -30.000)
glVertex3fv(-30.000, 30.000, -30.000)
glVertex3fv(-30.000, 0.000, -30.000)
glEnd()
glBegin(GL_TRIANGLE_FAN)
glVertex3fv(0.000, -30.000, -30.000)
glVertex3fv(0.000, 30.000, -30.000)
glVertex3fv(-30.000, 0.000, -30.000)
glVertex3fv(-30.000, -30.000, -30.000)
glEnd()
glBegin(GL_TRIANGLE_FAN)
glVertex3fv(0.000, 30.000, -30.000)
glVertex3fv(30.000, 0.000, -30.000)
glVertex3fv(30.000, 30.000, -30.000)
glEnd()
glBegin(GL_TRIANGLE_FAN)
glVertex3fv(0.000, -30.000, -30.000)
glVertex3fv(30.000, -30.000, -30.000)
glVertex3fv(30.000, 0.000, -30.000)
glVertex3fv(0.000, 30.000, -30.000)
glEnd()



Ok

But If I will not use opengl to draw those vertices I am missing indexes.

What I can do to generate the oppropriate indexes.

[Edited by - n9ine on August 20, 2008 5:55:17 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by n9ine
...
But If I will not use opengl to draw those vertices I am missing indexes.

What I can do to generate the oppropriate indexes.

Err, what else will you use to draw the vertices? "I will not use opengl to draw those vertices" means you are looking for another graphics API or so. That is unlikely since you posted in the OpenGL forum.

However, it still left open a bunch of other possibilities. The fact that "glVertex3fv(0.000, 30.000, -30.000)" is an illegal invocation (at least in C/C++) doesn't help either, since it shows that you don't tell us something about your current implementation. But how the vertex data is available is an important aspect when computing indices! E.g. generating indices from implicit algebraic surfaces can be done on the fly when computing the vertex positions itself, but searching a generic mesh of triangles (or perhaps n-gons?) is something very different.

Do you want to store the vertex data in arrays on the heap, and invoke them correctly by glVertex3fv (i.e. with a vertex pointer computed by indexing the vertex data array)? Or do you want to switch to glDrawElements, so needing arrays of indices? Do you want to use VBOs? And are you aware of the pros & cons of using TRIANGLE_STRIP / TRIANGLE_FAN in conjunction with VBOs, compared to the normally favourable TRIANGLES list?

If you can't answer there things right now, thinking of index generation is probably too early.

Share this post


Link to post
Share on other sites
I am using a 3D engine to draw vertices that I extract from opengl with callback function (vertexCallback). I can not extaract indexes !

is there any way to get indexes from opengl using callback?

Share this post


Link to post
Share on other sites

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