# Triangle fan

I have made some code to optimize a mesh to a set of triangle fans, and it works very well. But when I use textures it have problems…

I can realize why, but not realize how to solve (I think I can’t), so my question is: Can I solve? If I do make triangles strips, will I have the same problem?

Overall: If I am working with textures, the only way is to make just TRIANGLES? How can I optimize? HELP!

Well, we can’t really offer suggestions without knowing what problem you were having…

It’s certainly possible to use textures with triangle fans.

Well, I check the faces and find the vertex that appears more. With this vertex I build a fan with all of the faces that are attached to that vertex, so I can build, for example, 5 faces making 7 glVertex calls. The idea sounds well for me, and works fine too (without textures).

When I tested it with texures, I have founded that the same vertex can have different texture vertexes (I can have a vertex with 0,1 on a face and 1,1 on another face for the same vertex).

So, how can I fix it? Maybe mapping on a different way on the software modeller? Or checking if the vertex changed the texture (but with too small fans)…

What can I do?

Hi !

If your shared vertex has different texture coordinates for two adjacent faces, you can not use any triangle fan/strip.

When you are checking for shared vertices (i.e. X1=X2&&Y1=Y2&&Z1=Z2), you should also check that the texture coordinates are identical (add U1=U2&&V1=V2&&W1=W2).

Of course, it will optimize a lot less your model but it is your only solution.

Just a remark : you should try to build triangle strips instead of triangle fans. I believe that for most models, the result will be better.

See ya.

Eric

I know that strips are better, but I thought that beginning with fans would be easier.

Well, I was making some tests and I can’t believe on the results. Consider the following:

operation = glNormal3fv + glTexCoord2f + glVertex3fv

without fan (only triangles)
1103 operations to draw the mesh in 26 ms

With the fans
551 operations to draw the mesh in 46 ms

How could it took twice the time if it make a half of the operations? My display board accelerate triangles but not triangle fans? Is it possible?

Why is this happening to me?

I am almost giving up of that and getting just triangles… If anyone can help me, I appreciate! Thanks for the support!

it means that the application you wrote is spending more time to create triangle fans from the unstructured mesh than opengl to execute.

so creating fans for THAT model is not needed, instead is better to avoid.

probably, your model has too few primitives:
your fanner should be prove useful when you have more primitives.

again, what eric said is true, strips are better than fans for a generic model.
strips can cover wider areas than fans.

Dolo//\ightY

Originally posted by dmy:

it means that the application you wrote is spending more time to create triangle fans from the unstructured mesh than opengl to execute.

dmy, do you think he’d really done that??
I hope that his timing results don’t include
model conversion, as this is a one-time procedure. It’s evident that you call it before the main loop, in which rendering occurs. Why should you do differently?

i must admit i have no particular experience using structure optimizers… i was planning to build a realtime optimizer, but i didn’t read any paper yet.

i didn’t thought about that, i assumed he’s using the fanner in his heartbeat.
and well, if he’s not fanning in realtime yes, he have strange benchmarks !

are optimizers used only as preprocessors?

PS: paolom, about that specular map test, i have problems to route to the email you gave me.
have you an other address?

Dolo//\ightY

Of course the timing was not counting the conversion time…

Well, I can’t understand, I ran a test on my home computer and it took 20 ms to draw with FANS and 26ms without fans (I have a V550 in home and a TNT on work, where I ran the first test). Besides, a friend of mine ran on his computer (without an accelerator board) and it took twice the time without fans that with fans.

All this makes sense to me, cos my fans are making a good work, but I can’t understand the results of the first test, described before, cos the chipset of my boards are the same… Can the Viper do fans better that TNT? Shouldn’t…

Anyway, I am tired of fans, I think I will begin to think on strips, I just wanted to learn more about optimizations with fans…