Page 1 of 1

Camera for RPG

Posted: Thu Jan 12, 2012 1:09 am
by JVr
Ok there's real working modern RPG camera done through animator - same way as FPS and Maya camera:

[maybe I overlooked it's somewere here but I guees.. if it would be here. Irrlicht developers would already add it to irrlicht]

(Animator source)
http://www.mediafire.com/?em3b9apzzlymois or direct http://www.mediafire.com/file/em3b9apzz ... camera.zip

Scene Manager interface:

Code: Select all

 
/**
 * @param rotateSpeed accelerator for rotation
 * @param zoomSpeed accelerator for zooming (depend pretty much on minDist and maxDist)
 * @param minDist minimal distance from parent
 * @param maxDist maximal distance from target
 * @param WorldOrientation orientation of world should be vector with one value specifying up down dimension (this piece of code is tested for 0,0,1)
 * @param ctrlMask binary mask for camera control button - 001b (left) 010b (mid) 100b (right) - 101b (right+left) etc...
 */
virtual ICameraSceneNode* addCameraSceneNodeRPG( ISceneNode* parent = 0, f32 rotateSpeed = 3.0f, f32 zoomSpeed = 1.f,
                        f32 minDist = 0.5f, f32 maxDist=30.f, core::vector3df WorldOrientation = core::vector3df(0,0,1), u8 ctrlMask = 1 );
 
Scene Manager source:

Code: Select all

 
ICameraSceneNode* CSceneManager::addCameraSceneNodeRPG( ISceneNode* parent, f32 rotateSpeed, f32 zoomSpeed,
                        f32 minDist, f32 maxDist, core::vector3df WorldOrientation, u8 ctrlMask)
{
        ICameraSceneNode* node = addCameraSceneNode( parent, core::vector3df(0,0,0), core::vector3df(0,3,2) );
        node->setUpVector(WorldOrientation);
        if (node)
        {
                ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraRPG( CursorControl , rotateSpeed, zoomSpeed,
                        minDist, maxDist, WorldOrientation, ctrlMask);
                node->addAnimator(anm);
                anm->drop();
        }
 
        return node;
}
 
It's not much tested but it seems to work well for me :P

It get's actually completly bound on it's parent -> it looks on it in specific angle (controlled by mouse). If there's no parent it's bound to 0,0,0.
(it's cool for model viewers and ofc all RPGs)

Re: Camera for RPG

Posted: Thu Jan 12, 2012 7:21 am
by Cube_
like the camera in rpgs such as neverwinter nights?

Re: Camera for RPG

Posted: Thu Jan 12, 2012 8:37 am
by JVr
ye

Re: Camera for RPG

Posted: Thu Jan 12, 2012 10:52 pm
by Cube_
awesome. will use this (and some camera switching action, I don't like the maya camera. ^^*)
anyway. + 1 internets to you!

Re: Camera for RPG

Posted: Tue Feb 14, 2012 4:21 pm
by Alx101
Soo. How do i use this? Any examples?

Re: Camera for RPG

Posted: Tue Feb 14, 2012 5:34 pm
by serengeor
Alx101 wrote:Soo. How do i use this? Any examples?
Get familiar with how things in irrlicht work (scene graph to be exact) and you'll know how to use it.

Re: Camera for RPG

Posted: Wed Feb 15, 2012 1:27 pm
by Alx101
Thanks!

Re: Camera for RPG

Posted: Fri Aug 16, 2013 12:07 pm
by taiBsu
I simply don't get it. I added the .cpp and the .h files to my project but when I enter

Code: Select all

 
CSceneNodeAnimatorCameraRPG* camera = new CSceneNodeAnimatorCameraRPG(device->getCursorControl(), 3.0f, 1.0f, 0.5f, 30.0f, vector3df(0, 0, 1), u8(001));
 
I simply get a black screen - why??

Re: Camera for RPG

Posted: Fri Sep 27, 2013 7:06 pm
by christianclavet
Humm. Not looked at the code, but since the author mention that it's an animator:
I think you need to create a "static" camera first, then apply this new animator to it.