GeometryBatchFactory.optimise changes scenegraph structure

Hello

as i load a single object file

i see the structure is lige this

Landscape
|_Node
|_Geometry
1_Mesh

but as i use GeometryBatchFactory.optimise on that node, it ends up like this

Landscape
|_Node
|_Geometry
|_Mesh

the Geometry becomes a child of Landscape instead of remaining child of Node

is this a bug ?

the point is to add other geometry(mesh) to the node and the optimize

but i dont see why the hierarchy is modified in such way, i thought optimize would merge all meshes, not change the overall hierarchy

help plz :frowning:

Sure it does, thats its purpose.

<cite>@normen said:</cite> Sure it does, thats its purpose.

i thought it was only about mesh merging
i mean i have to check in my code if the object has been optimised or not or i get a class cast error

[java]
Node [Ground.blend]
|___Node [Ground]
|___Geometry [Ground]
|___Mesh [3136]
|___Geometry [Box]
|___Mesh [12]

turns to

Node [Ground.blend]
|___Node [Ground]
|___Geometry [Ground]
|___Mesh [3148]
[/java]
so the original hierarchy is broken with one useless node that has no more geometry
why does it do that ?

Node is not useless, because it contains translation matrix. Based on it, some of the vertices of batch mesh will be transformed.

This is entire point of BatchNode - to be able to send one mesh instead of many. To achieve that, it needs to transform vertices manually inside composed geometry. You can think about it as a special case of skeleton-based animation, with bones being Nodes and each vertex having 100% weight of specific single node.

<cite>@abies said:</cite> Node is not useless, because it contains translation matrix. Based on it, some of the vertices of batch mesh will be transformed.

do you mean at runtime ? cos if the meshes are aglomerated together, why not transform all of them and get rid of the node (or set it as identity matrix)

and if not, then the mesh should still be a child of node so the engine put it at the right place

sorry to be a bugger, but i like to really understand the scenegraph, and here i realize i don’t get it

lol

There may be other reasons you have that Node there. JME can’t guess.

Edit: scratch all which I said below and above. I was under impression you are using BatchNode, but you are talking about GeometryBatchFactory. Sorry for confusion.

IGNORE BELOW:

Original usecase for BatchNode was to facilitate NWN models, as far as I’m aware. They have this one-part per bone approach, where there are multiple distinct geometries under moving hierarchical nodes, sharing material parameters. Using default handling, it meant sending 20 hundred-vertices objects to GPU separately. With batch node, they are group based on material (sometimes there is only one, sometimes there are more), some special things are omitted from batching (like true skin/skeleton nodes, emitters etc). Original nodes are still staying, because they represent ‘bones’ which are moving.

Thanks to that, it is completely transparent to user. You can still modify your transforms as in old way, it is just rendered faster

@abies said: Original usecase for BatchNode was to facilitate NWN models, as far as I'm aware.
shhhhhhhhh, dude...just you and me knew that until now...people will think I'm some kind of geek...
@nehon said: shhhhhhhhh, dude...just you and me knew that until now...people will think I'm some kind of geek...
Aahh finally.. revenge..!

FANBOY! :smiley:

1 Like