Page 1 of 1

How to set camera manipulater for object defined with world coordinates ?

Posted: Tue Jun 05, 2018 2:06 pm
by lainegates
I want to visualize many objects defined with world coordinate.
For example, a cube (1X1X1) at position (1000, 0 , 0), then another cube (2X2X2) at position (0, 1000, 0)...
All the objects are defined only by world coordinates without any translations or rotations.

Now, I want to select an object and let the camera look at the object at any time.
How to do this?

I know Ogre provide OgreBites::CameraMan, but it is based on SceneNode::_getDerivedPosition() that is always (0,0,0) in my case.
Could anyone help me ?

Re: How to set camera manipulater for object defined with world coordinates ?

Posted: Tue Jun 05, 2018 3:45 pm
by xrgo
to look an object you can use SceneNode::lookAt or SceneNode::setDirection, call one of this methods from the scenenode of which the camera is attached to.

cheers!

Re: How to set camera manipulater for object defined with world coordinates ?

Posted: Wed Jun 06, 2018 2:52 am
by lainegates
thank you, xrgo.
I tried your advice. And it worked.

but if I draw mouse (try to watch object from another direction), camera goes back to look at targetNode->_getDerivedPosition().
In other words, the problem is still there.

Could you tell me how you solve the problem together with camera manipulation ?
Or code examples are also good.

Re: How to set camera manipulater for object defined with world coordinates ?

Posted: Wed Jun 06, 2018 3:57 pm
by xrgo
ohh I think you want something like an orbit mode? around the object.... that would be a whole different math... I haven't done it but it seems to be that OgreBites::CameraMan has an orbit mode:
https://ogrecave.github.io/ogre/api/1.1 ... a_man.html
https://stackoverflow.com/questions/234 ... on-in-ogre