Bug or misuse of setLocalRotation

    protected void simpleInitGame() {
        Pyramid i=new Pyramid("pyramid",1,4);
        i.setModelBound(new BoundingBox());
        i.setLocalRotation(new Quaternion(0,0,1,FastMath.PI/4));
        i.setLocalScale(5);
        i.setLocalTranslation(new Vector3f(0,5,0));
        i.updateModelBound();
        rootNode.attachChild(i);
    }



The model's boundingBox seems to translate and scale with the Pyramid, but doesn't rotate at all. Is this purposefull (IE it is the programmer's responsibility to rotate the bounding box everytime I rotate a model) or is this a bug?

this isn’t a bug, nor can you rotate the boundingBox. The bounding box is AABB meaning is it an Axis Aligned Bounding Box. It is aligned to the major axis, not the model axis. Future versions will have a rotatable version, but that is harder to implement…etc



Cheers,

DP

As DP said it’s AABB, so it’s limited in that respect. However, the box should grow to encompass the whole pyramid as it rotates. And I’m not sure if it does or not (I haven’t tested that yet). That is, even thought it’s AABB, as the pyramid rotates, the box should alter its size to keep encompassing the entire pyramid. If not, that’s a bug that will have to be fixed.

I haven’t tried it for a pyramid, but I have for a model. Although the boundingBox isn’t redrawn, its still there, encompassing the whole model.



So it works :slight_smile:



DP

I doesn’t seem to work with pyramid or a few other cases of TriMesh including models. So something’s wacky.

ok, the problem is, when the bounding box is calculated for a trimesh it is using the vertices of the trimesh. (It doesn’t look at the rotation of the node). So, when you rotate, the vertices are actually not changed, so the bounding box is not altered. So, we’ll have to allow the bounding volumes to take the orientation of the node into account when calculating the volume.

Why does translation and scale work? They don’t alter the verticies either right (or does it)? I assume there’s special cases for those?