Zooming camera?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Spartacus
Posts: 70
Joined: Fri Nov 21, 2003 11:56 pm

Zooming camera?

Post by Spartacus »

Is there any way i can make my camera "zoom in" on an object? And if possible make it look like your looking through a scope?
rt
Posts: 150
Joined: Sun Nov 30, 2003 6:54 am
Location: canada
Contact:

rodger

Post by rt »

That would be a use feature. Would it be possible to simply render from a second camera which is closer to whatever you want to look at to a viewport? Although moving a camera closer to the target would probably change the angles. Have you tried setting the camera's FOV to a number like 3.0f? that creates an effect like the camera zooming in. Please let us know if find a solution to this!
Spartacus
Posts: 70
Joined: Fri Nov 21, 2003 11:56 pm

Post by Spartacus »

yea i already tried chaing fov... and it would be kinda complicated to shoot a camera out to zoom and then shoot it back 0.o kinda ? 0.o
rt
Posts: 150
Joined: Sun Nov 30, 2003 6:54 am
Location: canada
Contact:

Post by rt »

Spartacus wrote:yea i already tried chaing fov... and it would be kinda complicated to shoot a camera out to zoom and then shoot it back 0.o kinda ? 0.o
if you derive your own camera class then you can create an function like:

Code: Select all

void MyCamera::UpdateZoom() {
  if ( zooming_in )
        this->setFOV ( this->getFOV() + 0.01f );
  else if ( zooming_out )
        this->setFOV ( this->getFOV() - 0.01f );

  //bounds check
  if ( this->getFOV() > 3.0f ) this->setFOV(3.0f);
  else if ( this->getFOV() < NOMINAL_ZOOM) this->setFOV(NOMINAL_ZOOM);
}
then you just need to set zooming_in = true when the user presses a key, and set it to false when the key is released to 'zoom in'.
Spartacus
Posts: 70
Joined: Fri Nov 21, 2003 11:56 pm

Post by Spartacus »

Ok i got a basic camera class setup that is used to kinda like add on to camera stuff i dont belive its derived but.. its not working >.<
rt
Posts: 150
Joined: Sun Nov 30, 2003 6:54 am
Location: canada
Contact:

Post by rt »

Spartacus wrote:Ok i got a basic camera class setup that is used to kinda like add on to camera stuff i dont belive its derived but.. its not working >.<
check out the code from this thread http://irrlicht.sourceforge.net/phpBB2/ ... .php?t=626 .. it should help you with setting up a derived camera class (somewhat :wink: )
Spartacus
Posts: 70
Joined: Fri Nov 21, 2003 11:56 pm

Post by Spartacus »

ok ima go look -.-
Spartacus
Posts: 70
Joined: Fri Nov 21, 2003 11:56 pm

Post by Spartacus »

i cant get it to compile now..
rt
Posts: 150
Joined: Sun Nov 30, 2003 6:54 am
Location: canada
Contact:

Post by rt »

Spartacus wrote:i cant get it to compile now..
what is the problem you are having?
Spartacus
Posts: 70
Joined: Fri Nov 21, 2003 11:56 pm

Post by Spartacus »

Well if you would check your messages you would know 0.o. Im having most problems getting the g_irr value to be "global" and the constructor is having lots of problems too :/
rt
Posts: 150
Joined: Sun Nov 30, 2003 6:54 am
Location: canada
Contact:

Post by rt »

Spartacus wrote:Well if you would check your messages you would know 0.o. Im having most problems getting the g_irr value to be "global" and the constructor is having lots of problems too :/
g_irr is an instance of the Irrlicht device. in the tutorials there is the line

Code: Select all

IrrlichtDevice *device =		createDevice(DT_SOFTWARE, dimension2d<s32>(512, 384),           16, false, false, 0);
you can use 'device' .. just save that pointer and then use it as your global pointer to the irrlicht engine. then the camera constructor would be

Code: Select all

MyCam::MyCam() : CCameraSceneNode(device->getSceneManager()->getRootSceneNode(),device->getSceneManager(),-1){
                //init the mycam variables
	down = up = left = right = zoomin = zoomout = false; //nice syntax :)
}
hope this helps!
Spartacus
Posts: 70
Joined: Fri Nov 21, 2003 11:56 pm

Post by Spartacus »

Well I already knew what you just said and ive done it before and it didnt work their are like 20 errors and 40 warnings.

Code: Select all

error C2512: 'ICameraSceneNode' : no appropriate default constructor available
error C2614: 'CMyCamera' : illegal member initialization: 'CCameraSceneNode' is not a base or member
error C2259: 'CMyCamera' : cannot instantiate abstract class due to following members:
warning C4259: 'const class irr::core::aabbox3d<float> &__thiscall irr::scene::ISceneNode::getBoundingBox(void) const' : pure virtual function was not defined
warning C4259: 'void __thiscall irr::scene::ISceneNode::render(void)' : pure virtual function was not defined
warning C4259: 'bool __thiscall irr::scene::ICameraSceneNode::isInputReceiverEnabled(void)' : pure virtual function was not defined
fatal error C1903: unable to recover from previous error(s); stopping compilation
.... ect
rt
Posts: 150
Joined: Sun Nov 30, 2003 6:54 am
Location: canada
Contact:

virtual disaster

Post by rt »

Spartacus wrote:Well I already knew what you just said and ive done it before and it didnt work their are like 20 errors and 40 warnings.
.... ect
sounds like you are not setting up your camera class properly. were you able to try out the code i sent you? if you use that code and replace the variable 'grr' with your own pointer to the irrlicht device then it should compile :?
Spartacus
Posts: 70
Joined: Fri Nov 21, 2003 11:56 pm

Post by Spartacus »

Yea i tried the exact code you sent me still not working so i gave up on it and just did it my own way lol.
stampsm
Posts: 142
Joined: Mon Nov 10, 2003 5:52 pm
Location: Las Vegas

Post by stampsm »

how did you do it?
Post Reply