Jump to content

[SOLVED] getBoundBox() method, wrong transform matrix


photo

Recommended Posts

Hello,

I encountered something weird manipulating BoundingBox with UnigineScript, here's the code part reproducing the problem :

BoundBox bb = node.getBoundBox();
//bb.setTransform(mat4(node.getTransform()));
vec3 p1 = bb.getMin();
vec3 p2 = bb.getMax();
engine.visualizer.renderPoint3D(Vec3(p1), 0.1, vec4(1, 0, 0, 0.5), 0);
engine.visualizer.renderPoint3D(Vec3(p2), 0.1, vec4(1, 0, 0, 0.5), 0);
engine.visualizer.renderNodeBoundBox(node, vec4(0, 0, 1, 0.5));

(The code has to be run with engine.visualizer.setEnabled(1); called, and a valid node instance loaded).

The visualizer part shows on my program 2 random points (red ones), not matching with any of the bounding box points (rendered in blue).

The commented line solves the problem if uncommented., so I think the transform matrix of the node is not assigned by default to the bounding box, which might look like a bug.

Thank you.

 

EDIT : By the way, the setTransform() method is not referenced (but still usable) in the UnigineScript doc.

Edited by Coppel.Damien
Link to comment

Hello, thank you for your reply.

I am picking the bounding box of a node, then I display it and the 2 points obtained with getMin() and getMax() method. I was surprised to see that the rendered points do not match with any of ones from the bounding box. I noticed that adding the commenting line (setTransform(mat4(node.getTransform()))) solves the problem. It may be an intended behavior, but I prefer signaling it. Here are two screenshots showing the problem :

Expected result, obtained with setTransform.

with_setTransform.png

Result without setTransform :

without_setTransform.png

Edited by Coppel.Damien
Link to comment

Hello Damien,

Method getBoundBox returns bounding box in node's local coordinate system (and engine.visualizer.renderPoint3D expects world's coordinates). If you want to get bounding box in world's coordinates you should use getWorldBoundBox

Link to comment
  • silent changed the title to [SOLVED] getBoundBox() method, wrong transform matrix
×
×
  • Create New...