GeorgeP Posted May 12, 2012 Share Posted May 12, 2012 Hello. I want to use the setTo function to make an agent stand in mesh_position and look at agent_direction. Using the following code: vec3 mesh_position = mesh.getWorldPosition(); Vec3 agent_direction = route.getPoint(1) - route.getPoint(0); mat4 mat = setTo( mesh_position , agent_direction , vec3(0.0f,0.0f,1.0f)); mesh.setWorldTransform(mat); //mesh is the agent I get this: route point 0 (where the agent stands) is 0,0,1 route point 1 is -44, -54, 1 Initial position without rotation (and without applying the setWorldTransform in the code above): I want it to be like this: What do i miss? Thank you for your time. Link to comment
Guest anet Posted May 16, 2012 Share Posted May 16, 2012 Hello GeorgeP, The problem is that agent mesh is exported faced into -Y direction. You can check it by loading this mesh in Resource editor. And when you load agent mesh into script you can get mesh.getDirection() and see that default direction for nodes is -Z. So you need to add extra constant rotation when applying new transformation. Here is a code sample: vec3 mesh_position = mesh.getPosition(); Vec3 agent_direction = route.getPoint(1) - route.getPoint(0); mat4 mat = setTo(mesh_position,agent_direction,vec3(0.0f,0.0f,1.0f)); mesh.setWorldTransform(mat * rotateX(-90) * rotateZ(180)); Link to comment
GeorgeP Posted May 19, 2012 Author Share Posted May 19, 2012 Hello. it worked fine. thnx. Link to comment
Recommended Posts