Camera for RPG

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
JVr
Posts: 28
Joined: Wed Oct 19, 2011 2:32 pm

Camera for RPG

Post 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)
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: Camera for RPG

Post by Cube_ »

like the camera in rpgs such as neverwinter nights?
"this is not the bottleneck you are looking for"
JVr
Posts: 28
Joined: Wed Oct 19, 2011 2:32 pm

Re: Camera for RPG

Post by JVr »

ye
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: Camera for RPG

Post by Cube_ »

awesome. will use this (and some camera switching action, I don't like the maya camera. ^^*)
anyway. + 1 internets to you!
"this is not the bottleneck you are looking for"
Alx101
Posts: 15
Joined: Sat Feb 11, 2012 7:04 pm

Re: Camera for RPG

Post by Alx101 »

Soo. How do i use this? Any examples?
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Camera for RPG

Post 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.
Working on game: Marrbles (Currently stopped).
Alx101
Posts: 15
Joined: Sat Feb 11, 2012 7:04 pm

Re: Camera for RPG

Post by Alx101 »

Thanks!
taiBsu
Posts: 3
Joined: Tue Apr 30, 2013 8:19 am

Re: Camera for RPG

Post 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??
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: Camera for RPG

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