Newbie here! I probably have kind of a stupid question, but I can’t wrap my head around this…
First of all: This is not about a game! Just a project regadring a scenegraph!
So what I did so far:
I’m just loading geometries into a scenegraph. Nothing more.
The problem I have right now is:
Every geometry is loaded into the origin (0,0,0). But I want to display them in a row.
Does anybody know how to do that? Where does a geometry starts and ends and how do I use that knowlege so that the next geometry is placed right next to the other one?
getLocalTranslation() - local space position
getWorldTranslation() - global position (adding parent nodes positions)
getWorldBound() - casted for example to BoundingBox you can have extentX * 2 = width for example.
start position is getLocalTranslation() end position is getLocalTranslation() + ((BoundingBox)getWorldBound()).getXExtent() * 2 → if bounding is boundingBox type. (and X is width, not Y or Z)
Everything that extends Spatial (Node, Geometry, etc) will have a BoundingVolume - usually a BoundingBox - or for better explanation - an Axis Aligned Bounding Box (AABB).
The spatial’s AABB will probably work for this case.
In general, however, it’s not a reliable way to determine the size of a model. For one thing, it might not be the minimal AABB, particularly if the model is rotated. And for animated models, it’s usually calculated for the model’s “bind pose”; playing animations may cause a model to “poke out” of its AABB.
On a totally different note… Do you also happen to know, if I can move the internal coordinate system of a geometry? I mean, in a way that it is not in the centre of a geometry anymore?
The coordinate system of a Geometry is the one in which mesh vertices are positioned. So if the vertices are centered on some location other than (0,0,0), then the Mesh will be off-center with respect to that coordinate system.
However, it usually makes more sense to center the mesh vertices on (0,0,0) and use the geometry’s transform to position the Mesh where you want it using move() or setLocalTranslation(). This is much easier than modifying the Mesh.
That won’t do anything but fool the scene graph into thinking the bounds is somewhere it isn’t. It will mess up culling but won’t actually MOVE anything.
This is a scene graph problem. If you want some object to be somewhere other than its own center then you add it to a node and move it relative to that node… then treat the node as the thing. I reference the scene graph docs again.
Moving the bounds center just moves the bounds center. If you ask the bounds what it’s center is then it will lie to you. It affects absolutely nothing at all about the geometry. If you ask the geometry what it’s Mesh vertexes are then it will tell you the same thing it did before artificially moving the bounds center.
I can think of no other way to interpret “internal coordinate system” other than some kind of coordinate system… ie: where things are placed by coordinates.
Changing the center of the bounding shape will not affect that at all.
Thanks again for the help! Sorry for not replying sooner, but this is for a work project, meaning if I am not at work, I usually don’t check anything.
Which leads me to the problem: this was a project requirement. Like "We have a global coordiante system and a lot of local coordinate systems: I want to attach the geometries by their local cs, but they are not allowed to overlap. " I thought the local cs of a Geometry is alway in the centre of the Geometry and not moveable. Moveable in the sense, that it changes the possition inside the Geometry but not in the scene graph itself.
I didn’t even know if something like that was possible so I asked!
Thanks again for all the help! I think I found a solution! Although a little differently! (Project requirements change all the time after all!)
Unless I misunderstand what you are saying, you just described what a scene graph does. It’s just a hierarchy of local coordinate spaces each defined relative to the parent coordinate space. That’s it.