trying to make an LOD system

Started by MichaelJPCT, July 01, 2016, 10:14:25 AM

Previous topic - Next topic

MichaelJPCT

i plan to have an LOD system in my graphics module. basically in a class of mine there is an array of Object3D or Mesh, and i can choose which LOD should show up. the problem is , should i use an array of Object3D or Mesh?
i originally planned to use Mesh, and use setMesh() to switch Mesh when i need another LOD. but later i read the forum and saw that UV data were stored in Object3D, not Mesh.

on the other hand, the downside of using array of Object3D, is that:
i have an object tree, each object can have multiple children that inherit its transformation. when i switch LOD, i have to call Object3D.removeParent, Object3D.addParent, world.removeObject, world.addObject... on multiple Object3D's.
Java performance is quite good, and these calls should not cost much, but it just looks like some trouble.
i can also do it without the parent system from JPCT, meaning that i do all transformation in my code, and use setOrigin, setOrientation, setTranslationMatrix etc to position the Object3D's. then i don't need to call removeParent,addParent, but my code for transformation would grow large, that's some trouble too.

is there a simpler way to make an LOD system?

EgonOlsen

You have to use Object3D for this. Mesh alone won't cut it. If you worry about the parent/child calls...have you considered to make all the detail levels children of their parents and just switch visibility?

MichaelJPCT

your suggested way looks more simple on the app side.
but in JPCT engine, if an Object3D(a child) has multiple parents(which are also children of other Object3D's), would it do transformation only based on the visible parent(current LOD)?
and does JPCT do transformation to the invisible Object3D's ?

EgonOlsen

I don't see why it would have multiple parents... ???

MichaelJPCT

in my previous thought, when an instance of myObject (with an array of Object3D) is considered a parent, then each Object3D in the array is a parent of the child of this instance of myObject, so an Object3D in the child instance of myObject has an array of Object3D as parents.
or you were suggesting separate object trees for each LOD level? this should be a much simpler way, but then every part in the tree must have the same LOD level.
i think this is good enough in some cases.

EgonOlsen

I guess I expected the LOD to be applied per object and not per array of objects. If you want to do that, maybe adding some artifical dummy objects with no actual content can act as the glue between these arrays? To be honest, I wasn't quite able to follow your array-with-parents-of-children-of-arrays-or-whatnot-approach... ;)...but maybe that's just me on a friday.

MichaelJPCT

i will cancel the LOD system for now, to make the program simpler.

but i have another question:
if an Object3D is invisible (setVisibility or removed from world), but it has children and parent. would JPCT engine do translation to every object in the tree, in these 2 cases?
case 1: all objects in the tree are invisible
case 2: only one object in the tree is visible
because i don't like to waste CPU time doing translations on invisible objects, if the object quantity is large, doing translation would cost much CPU time.

EgonOlsen

If an object is invisible, nothing will be calculated for it regardless of its parent. If it's in the parent chain of some visible child object, the child object will inherit the invisible parent's transformations as normal.