Author Topic: trying to make an LOD system  (Read 692 times)

Offline MichaelJPCT

  • long
  • ***
  • Posts: 136
    • View Profile
trying to make an LOD system
« on: July 01, 2016, 10:14:25 am »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: trying to make an LOD system
« Reply #1 on: July 01, 2016, 10:18:22 am »
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?

Offline MichaelJPCT

  • long
  • ***
  • Posts: 136
    • View Profile
Re: trying to make an LOD system
« Reply #2 on: July 01, 2016, 10:32:33 am »
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 ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: trying to make an LOD system
« Reply #3 on: July 01, 2016, 10:56:59 am »
I don't see why it would have multiple parents... ???

Offline MichaelJPCT

  • long
  • ***
  • Posts: 136
    • View Profile
Re: trying to make an LOD system
« Reply #4 on: July 01, 2016, 12:11:49 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: trying to make an LOD system
« Reply #5 on: July 01, 2016, 12:54:31 pm »
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.

Offline MichaelJPCT

  • long
  • ***
  • Posts: 136
    • View Profile
Re: trying to make an LOD system
« Reply #6 on: July 02, 2016, 12:43:37 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: trying to make an LOD system
« Reply #7 on: July 03, 2016, 05:33:33 pm »
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.