Orbiting Camera
-
- Posts: 53
- Joined: Sun Aug 31, 2008 3:16 pm
- Location: Split, Croatia
Orbiting Camera
Hi everybody.
I want to make an Orbiting Camera (like the Maya one when you click left mouse button) but i want to have it react to keys WASD instead so I have free mouse cursor to click around the model.
Camera would orbit around the model in space like a planet or an atom.
I have three examples to work with,
WoW Camera
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24054
RTS Camera
http://www.irrlicht3d.org/wiki/index.ph ... ByCmdKewin
And current Maya camera from IrrLicht source code file
WoW like is really easy to implement with Events, but I would really like to share this with the community so I would like to make it inheritance style like RTS or Maya.
But is it better to inherit Camera interface (like RTS) or Make Animator (like Maya)?
-----------* EDIT *-------------
Oh, I found this thread
http://irrlicht.sourceforge.net/phpBB2/ ... m+animator
answering my question.
So I go with Animator interface, I thought that was the best idea anyway. Factory here I come.
Anyway, if i have any question and problems I'll post here
I want to make an Orbiting Camera (like the Maya one when you click left mouse button) but i want to have it react to keys WASD instead so I have free mouse cursor to click around the model.
Camera would orbit around the model in space like a planet or an atom.
I have three examples to work with,
WoW Camera
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24054
RTS Camera
http://www.irrlicht3d.org/wiki/index.ph ... ByCmdKewin
And current Maya camera from IrrLicht source code file
WoW like is really easy to implement with Events, but I would really like to share this with the community so I would like to make it inheritance style like RTS or Maya.
But is it better to inherit Camera interface (like RTS) or Make Animator (like Maya)?
-----------* EDIT *-------------
Oh, I found this thread
http://irrlicht.sourceforge.net/phpBB2/ ... m+animator
answering my question.
So I go with Animator interface, I thought that was the best idea anyway. Factory here I come.
Anyway, if i have any question and problems I'll post here
What now??? =_=''
-
- Posts: 53
- Joined: Sun Aug 31, 2008 3:16 pm
- Location: Split, Croatia
What is the benefit of implementing your own ISceneNodeAnimatorFactory?To be able to add custom scene node animators to Irrlicht and to make it possible for the scene manager to save and load those external animators, simply implement this interface and register it in you scene manager via ISceneManager::registerSceneNodeAnimatorFactory. Note: When implementing your own scene node factory, don't call ISceneNodeManager::grab() to increase the reference counter of the scene node manager. This is not necessary because the scene node manager will grab() the factory anyway, and otherwise cyclic references will be created and the scene manager and all its nodes won't get deallocated.
If I make my own ISceneNodeAnimator for my cam and register it like registerSceneNodeAnimatorFactory, does ISceneManager treat it like a factory after registering or?
What now??? =_=''
-
- Posts: 53
- Joined: Sun Aug 31, 2008 3:16 pm
- Location: Split, Croatia
I got that.hybrid wrote:This is necessary for deserializing your scene including the animators and later on reload them again. Actually, it's only necessary for the second step (the reload), at which point the scene manager has to be able to create the animator based on the name (a string).
But do I need to implement ISceneNodeAnimatorFactory that is createSceneNodeAnimator, getCreateableSceneNodeAnimatorType, getCreateableSceneNodeAnimatorTypeName methods?
Or with registerSceneNodeAnimatorFactory my ISceneNodeAnimator gets those methods default without me implementing them?
What now??? =_=''
-
- Posts: 53
- Joined: Sun Aug 31, 2008 3:16 pm
- Location: Split, Croatia
-
- Posts: 53
- Joined: Sun Aug 31, 2008 3:16 pm
- Location: Split, Croatia
So what is the most meaningful type value to return for custom camera animator?
As you can see from the code I return ESNAT_UNKNOWN since nothing I need is defined in enum ESCENE_NODE_ANIMATOR_TYPE.
What to do?
Maya and FPS camera have they own types ESNAT_CAMERA_MAYA & ESNAT_CAMERA_FPS defined.
As you can see from the code I return ESNAT_UNKNOWN since nothing I need is defined in enum ESCENE_NODE_ANIMATOR_TYPE.
Code: Select all
//! Returns type of the scene node
virtual ESCENE_NODE_ANIMATOR_TYPE getType() const {
return ESNAT_UNKNOWN; // TODO: Change this to some meaningful value
}
Maya and FPS camera have they own types ESNAT_CAMERA_MAYA & ESNAT_CAMERA_FPS defined.
What now??? =_=''
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
You shouldn't need to hack the engine to add your own type. You just need to return a value that doesn't collide with values used by the engine. It is perfectly valid to do something like this..
If I remember correctly, the value is only important for serialization, so if you don't provide a factory, it shouldn't matter much. That said, it would be nice if Irrlicht would set aside some set of values that it reserves for future use to avoid value collision.
Travis
Code: Select all
#define ESNAT_MY_ANIMATOR_TYPE ESCENE_NODE_ANIMATOR_TYPE(0x1000)
//! Returns type of the scene node
virtual ESCENE_NODE_ANIMATOR_TYPE getType() const {
return ESNAT_MY_ANIMATOR_TYPE;
}
Travis
-
- Posts: 53
- Joined: Sun Aug 31, 2008 3:16 pm
- Location: Split, Croatia
Thanks, I'll implement your proposal. momentarily I am not thinking of serialization, but you never know if I need a Factory in future.vitek wrote:You shouldn't need to hack the engine to add your own type. You just need to return a value that doesn't collide with values used by the engine.
Travis
What now??? =_=''
-
- Posts: 53
- Joined: Sun Aug 31, 2008 3:16 pm
- Location: Split, Croatia
I want to rotate the camera around an object (her target) telling camera how many degrees to rotate around specified target, so in animateNode I put:
The problem is that the camera is always looking in the same direction, and the camera's target is also moving even though I'm not changing it.
What could be the problem?
Code: Select all
RotX = 0.0f;
RotY = 0.0f;
core::vector3df target = camera->getTarget();
// Rotation ------------------------------------
if (CursorKeys[EKA_STRAFE_LEFT])
RotX += RotateSpeed;
if (CursorKeys[EKA_STRAFE_RIGHT])
RotX -= RotateSpeed;
if (CursorKeys[EKA_MOVE_FORWARD])
RotY += RotateSpeed;
if (CursorKeys[EKA_MOVE_BACKWARD])
RotY -= RotateSpeed;
// Set Pos ------------------------------------
Pos.rotateXYBy(RotY, target);
Pos.rotateXZBy(-RotX, target);
camera->setPosition(Pos);
What could be the problem?
What now??? =_=''