Camera Maya with zoom limits

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
joelCañas
Competition winner
Posts: 7
Joined: Tue May 19, 2015 1:27 pm
Location: Mérida - Venezuela

Camera Maya with zoom limits

Post by joelCañas »

Hi!

I´m doing a game with a spherical world and Im using a camera maya for move around. But when I zoom in, the camera goes into the planet and I need to stop its movement in some point, the same for zooming out. I need some clues about how I could do this.

Image

I'm using this code for getting the animator and set the distance but this isn't work until I left up the button

Code: Select all

irr::core::list<irr::scene::ISceneNodeAnimator*> animList = cameraSim->getAnimators();
irr::core::list<irr::scene::ISceneNodeAnimator*>::Iterator iT;
iT = animList.begin();
anim = (irr::scene::ISceneNodeAnimatorCameraMaya*)(*iT);
   if (anim->getDistance() < limit)
        anim->setDistance(limit);
 
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Camera Maya with zoom limits

Post by CuteAlien »

Stopping is tricky. It zooms until it reached the target - so you could change the target constantly, but that's annoying. Maybe easier to copy CSceneNodeAnimatorCameraMaya.cpp to create your own animator. And then change targetMinDistance in animateNode to another value.

If you are using svn trunk - I can maybe make this parameter public later on. I think I have a little time for Irrlicht this afternoon.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Camera Maya with zoom limits

Post by CuteAlien »

OK, change needed to be a little different. But if you check out newest svn trunk (rev 5106) you have new functions which allow you to set a minimal distance. Can be used like:

Code: Select all

 
    irr::scene::ICameraSceneNode * camera = smgr->addCameraSceneNodeMaya();
 
    const core::list<scene::ISceneNodeAnimator*>& animatorList = camera->getAnimators();
    if ( !animatorList.empty() )
    {
        scene::ISceneNodeAnimatorCameraMaya* mayaAnimator = static_cast<scene::ISceneNodeAnimatorCameraMaya*>(*animatorList.begin());
        mayaAnimator->setTargetMinDistance(100.f);
    }
 
If you don't want to update to Irrlicht trunk then just copy the corresponding animator (CSceneNodeAnimatorCameraMaya.cpp) from trunk and add it to a normal camera.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
joelCañas
Competition winner
Posts: 7
Joined: Tue May 19, 2015 1:27 pm
Location: Mérida - Venezuela

Re: Camera Maya with zoom limits

Post by joelCañas »

That's worked for me. Thanks. I had to patch Irrlicht 1.8.1 because the IrrAI version 0.2 I'm using didn't work with the svn trunk directly. Thank you very much.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Camera Maya with zoom limits

Post by CuteAlien »

Do you have an idea why IrrAI is not working with trunk?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
joelCañas
Competition winner
Posts: 7
Joined: Tue May 19, 2015 1:27 pm
Location: Mérida - Venezuela

Re: Camera Maya with zoom limits

Post by joelCañas »

Well, the last version of IrrAI said it worked just with Irrlicht 1.6. It worked fine with 1.8.1 but with the trunk I got a segmentation fault in the astar pathfinding function. I don't know exactly why it crashed in that point
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Camera Maya with zoom limits

Post by CuteAlien »

Ah well, guess nothing I can do about that. Maybe the IrrAI author has an idea.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
joelCañas
Competition winner
Posts: 7
Joined: Tue May 19, 2015 1:27 pm
Location: Mérida - Venezuela

Re: Camera Maya with zoom limits

Post by joelCañas »

I compiled again the IrrAI with the trunk and the calmageddon example and I had this error:

Code: Select all

C:\Users\Administrator\Desktop\IrrAI 0.5 for Irrlicht 1.6\Bin>CalmageddonExample_Debug.exe
Irrlicht Engine version 1.9.0
 (Build 9200)
Using renderer: OpenGL 4.0.0
Intel(R) HD Graphics: Intel
OpenGL driver version is 1.2 or better.
GLSL version: 4.0
Resizing window (480 200)
Could not load font because the file does not exist: ./.MdaGlSn1.n
Could not open file of texture: ./.Mdairihirioopgìo
Could not open file of texture: ./.Mdasatbto.n
 
C:\Users\Administrator\Desktop\IrrAI 0.5 for Irrlicht 1.6\Bin>

And compilling the code, warnings like this:

Code: Select all

Compiling: Src\PedestrianCharacter.cpp
C:\Users\Administrador\Desktop\IrrAI 0.5 for Irrlicht 1.6\Examples\CalmageddonExample\Src\PedestrianCharacter.cpp: In constructor 'PedestrianCharacter::PedestrianCharacter(const CCharacter::SCharacterDesc&)':
C:\Users\Administrador\Desktop\IrrAI 0.5 for Irrlicht 1.6\Examples\CalmageddonExample\Src\PedestrianCharacter.cpp:57:141: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 PedestrianCharacter::PedestrianCharacter(const SCharacterDesc& desc) : CityCharacter(desc, ECT_PEDESTRIAN, "Zombie/zombie.b3d", 0.005f, 5.0f) {
                                                                                                                                             ^
I had to change "case scene::ESNT_OCT_TREE:" to "case irr::scene::ESNT_OCTREE:"

may be the problem with the segmentation fault in my code is in the irrAI library (it needs to be updated to irrlicht 1.9) and not in the trunk itself
Post Reply