abou.konate Posted October 17, 2012 Share Posted October 17, 2012 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) Link to comment
abou.konate Posted October 18, 2012 Author Share Posted October 18, 2012 May someone move this post onto Bug section since it's not belongs here. Link to comment
frustum Posted October 18, 2012 Share Posted October 18, 2012 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; } Link to comment
abou.konate Posted October 18, 2012 Author Share Posted October 18, 2012 Oh sorry, I'll investigate in my own code. Link to comment
Recommended Posts