TsMesh::render & players
by Luis Anton · in Torque Game Engine · 06/28/2004 (12:26 am) · 7 replies
Hi!
Is it possible to know, in tsMesh::render (tsMesh.cc) if the object being rendered is a player or a staticShape?
My idea is, knowing the kind of shapeBase I'm rendering, and its distance to the camera (I think I can get it from dglGetModelview(&mat), right?), I want to draw just a portion of its polygons. So, instead of:
for (S32 i=0; i
it would be i+=2 or i+=4 depending on the shape's distance. Something like an automatic LOD.
This may be a total nonsense... what do you think?
Is it possible to know, in tsMesh::render (tsMesh.cc) if the object being rendered is a player or a staticShape?
My idea is, knowing the kind of shapeBase I'm rendering, and its distance to the camera (I think I can get it from dglGetModelview(&mat), right?), I want to draw just a portion of its polygons. So, instead of:
for (S32 i=0; i
it would be i+=2 or i+=4 depending on the shape's distance. Something like an automatic LOD.
This may be a total nonsense... what do you think?
#2
Anyway, if there's no way to do it, there's no discussion :(
06/28/2004 (10:43 am)
Well, gaps are not a problem when the object is far away... but yes, it's not the best solution. However, it's quite a solution if you need some extra fps and you don't mind small gaps in small object.Anyway, if there's no way to do it, there's no discussion :(
#4
But for truely dynamic LOD, you should probably look into some of the better known methods for dynamic polygon reduction. You might even find that running the calculations (at model load time) to generate the levels of detail would be faster. The stencil shadow resource I wrote creates edge lists from meshes dynamically at load time. This might be somewhere to start to see how to get object information and determine what verts can be removed.
Ideally you'd want to look at angle between edges and determine if at a certain distance that the vertex between them can be removed. Then you'd store the newly generated mesh back into the structure as a new detail mesh. I just wouldn't suggest using the simple n+=2 or n+=4 to reduce polygons.
- Brett
06/29/2004 (5:26 am)
Real, automatic LOD would implement one of the quick polygon reduction methods available. Just skipping polygons (because of the way they are optimized into the mesh) would cause very noticeable rendering errors -- even at a small size. The engine currently employs pre-created LOD, and automatic rendering of objects to billboards. You might look at the billboarding code to see if you could make it happen closer than it does now.But for truely dynamic LOD, you should probably look into some of the better known methods for dynamic polygon reduction. You might even find that running the calculations (at model load time) to generate the levels of detail would be faster. The stencil shadow resource I wrote creates edge lists from meshes dynamically at load time. This might be somewhere to start to see how to get object information and determine what verts can be removed.
Ideally you'd want to look at angle between edges and determine if at a certain distance that the vertex between them can be removed. Then you'd store the newly generated mesh back into the structure as a new detail mesh. I just wouldn't suggest using the simple n+=2 or n+=4 to reduce polygons.
- Brett
#5
The n+=2 was just a quick hack, not a real good idea. The best thing would be using the proper reduction algorithm, something like what 3DStudio does, at load time, as you said. If I have some spare time I'll try to do something with this. Automatic LOD could save modellers quite a lot of time, if handled properly.
Why doesn't OpenGL include something like this? (does it?) It does automatic mipmap reduction, so why not some polygon reduction, giving the user the choice to use it? It would be useful, at least for test purposes...
Added: ... what happens with animations if you happily reduce the polygon mesh? Do they still work? vertexs are bound to bones, so if you eliminate edges... um It may work, I guess...
06/29/2004 (6:20 am)
Right, Brett, I'll take a look at the billboarding code.The n+=2 was just a quick hack, not a real good idea. The best thing would be using the proper reduction algorithm, something like what 3DStudio does, at load time, as you said. If I have some spare time I'll try to do something with this. Automatic LOD could save modellers quite a lot of time, if handled properly.
Why doesn't OpenGL include something like this? (does it?) It does automatic mipmap reduction, so why not some polygon reduction, giving the user the choice to use it? It would be useful, at least for test purposes...
Added: ... what happens with animations if you happily reduce the polygon mesh? Do they still work? vertexs are bound to bones, so if you eliminate edges... um It may work, I guess...
#6
I would think because it's a "nice thing to have" but not necessary. Although I could argue it either way. On one hand it would help with vertices on the pipeline and reduce bandwidth. Plus it would be nice if it were handled by hardware. But on the other hand, it's just a nice feature and with the ever increasing number of polys that can be pushed, why add it to hardware?
I think that animations would be fine as long as you maintain the structure. That would require some real digging tho to be sure.
- Brett
06/29/2004 (6:53 am)
Quote:
Why doesn't OpenGL include something like this? (does it?) It does automatic mipmap reduction, so why not some polygon reduction, giving the user the choice to use it? It would be useful, at least for test purposes...
I would think because it's a "nice thing to have" but not necessary. Although I could argue it either way. On one hand it would help with vertices on the pipeline and reduce bandwidth. Plus it would be nice if it were handled by hardware. But on the other hand, it's just a nice feature and with the ever increasing number of polys that can be pushed, why add it to hardware?
Quote:
Added: ... what happens with animations if you happily reduce the polygon mesh? Do they still work? vertexs are bound to bones, so if you eliminate edges... um It may work, I guess...
I think that animations would be fine as long as you maintain the structure. That would require some real digging tho to be sure.
- Brett
#7
06/29/2004 (11:41 am)
I see, thanks. As I said, I will give it a try if I have time. I have already seen some polygon reduction algorithms and some of them don't look too complex. I'll post if I get something :)
Associate Kyle Carter
As for the currently rendered object type, there's no convenient way to figure that out - you might make a workaround involving globals, but it's not going to be pretty.