Jump to content

[SOLVED] Visualizer renderBoundBox


photo

Recommended Posts

I got a strange issue using Visualizer renderBoundBox method.

It's seems that the transformation from local bounding box to world bounding box is broked.

 

The above code will give an aligned axis when the rotation is about 45° for example.

 

 

I'm running SSE code though the plain code is :

vec3 center = (min + max) * 0.5f;
 vec3 axis = max - center;
 float x = Math::abs(transform.m00) * axis.x + Math::abs(transform.m01) * axis.y + Math::abs(transform.m02) * axis.z;
 float y = Math::abs(transform.m10) * axis.x + Math::abs(transform.m11) * axis.y + Math::abs(transform.m12) * axis.z;
 float z = Math::abs(transform.m20) * axis.x + Math::abs(transform.m21) * axis.y + Math::abs(transform.m22) * axis.z;
 center = transform * center;
 min = center - vec3(x,y,z);
 max = center + vec3(x,y,z);

 

The first picture is when the box is aligned about 15 degrees then second when it's aligned to 90*(int)

post-718-0-66607700-1350467451_thumb.png

post-718-0-23899500-1350467453_thumb.png

Link to comment

Can't reproduce.

 

#include <unigine.h>

ObjectMesh mesh;

/*
*/
int update() {

engine.visualizer.renderBoundBox(vec3(-0.5f),vec3(0.5f),mesh.getWorldTransform(),vec4_one);

return 1;
}

/*
*/
int init() {

Player player = new PlayerSpectator();
player.setDirection(vec3(0.755f,-1.0f,0.25f));
engine.game.setPlayer(player);

mesh = new ObjectMesh("box.mesh");
mesh.setMaterial("mesh_base","*");
mesh.setWorldTransform(rotateZ(15.0f));

return 1;
}

00001.png

Link to comment
×
×
  • Create New...