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

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
lainegates
Gnoblar
Posts: 9
Joined: Thu Jun 12, 2014 3:16 am

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

Post 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 ?
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

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

Post 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!
lainegates
Gnoblar
Posts: 9
Joined: Thu Jun 12, 2014 3:16 am

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

Post 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.
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

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

Post 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
Post Reply