rotate all vertices so mesh axis = camera axis

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
lumirion
Posts: 79
Joined: Tue Sep 13, 2011 7:35 am

rotate all vertices so mesh axis = camera axis

Post by lumirion »

How would I rotate all the vertices in a mesh in 3 dimensions so that the z axis would be = to a line drawn from the active camera to it's look at coordinate?
I want the camera looking down the new z axis.
Keziolio
Posts: 9
Joined: Sat Aug 10, 2013 12:09 pm

Re: rotate all vertices so mesh axis = camera axis

Post by Keziolio »

not sure if i understood what you want, but if you want fix an object to another you can use addChild

camera->setPosition(core::vector3df(0,0,0));
yourmesh->setPosition(core::vector3df(0,0,10));
camera->addChild(yourmesh);

to fix your mesh 10 units ahead from the camera in the z axis
lumirion
Posts: 79
Joined: Tue Sep 13, 2011 7:35 am

Re: rotate all vertices so mesh axis = camera axis

Post by lumirion »

normally a camera looks at a mesh from the front down the z axis. My camera sometimes looks from a side angle. For such meshes I want to modify the vertices so that z axis indicates depth relative to the active camera. Currently z and x axis's are both partly depth and partly width some times. Which makes it difficult to order decals so they render directly on top of a sub-mesh behind them in a way that works for all meshes.

I assume I need to find a way to calculate in degrees the deviation between the camera's depth axis in and the mesh's x, y, and z axis's, and then find a function that will change the meshes vertex values and the camera coordinates so that the camera looks down the meshes new z axis with x axis now indicating width but still rendering the same scene.
Post Reply