FPSCameraSceneNode Frame independent?

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.
PI
Posts: 176
Joined: Tue Oct 09, 2007 7:15 pm
Location: Hungary

Post by PI »

I guess we both will be happy if we finally manage to get this work :D

So segmentation fault... I guess somewhere you've called "cam->drop();" or "delete cam;" or maybe it's not even created
"cam = smgr->addCameraSceneNode();" (in the constructor of CGameCamera).

Or, at when getting rid of the garbage. Watch the order! If you have created:
1. A device
2. A timer
3. A collision manager
4. An event receiver
5. A camera

Then you should release them in reverse order:
5. if (camera) delete camera;
4. if (input) delete input;
3. if (cmgr) delete cmgr;
2. if (timer) delete timer;
1. device->drop();
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Lol! PI`s such a patient guy... :lol:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
PI
Posts: 176
Joined: Tue Oct 09, 2007 7:15 pm
Location: Hungary

Post by PI »

It's a real challenge! :D Because I haven't seen a piece of code...
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Post by cookie »

You saw a piece of code (first post ) ;)


I think the problem is the class... it seems that some the private variables never get declared or they don't get a value... because for example the variables


Code: Select all

core::vector3df camPos;
        core::vector3df camRot;
        vector3df camForward;
        vector3df camLeft;
        float runSpeed;
        float jumpStrength;
        vector3df camUp;
Which are all privates out of your class aren't aviable in the CGameCamera::update() function but the compiler doesn't say something about it. But when one of the variables get changed or comething the whole game chrashes and the debugger shows me the Error Message which I wrote a few posts earlier.

Whats the problem? I didn't change anything on your class and I use the class same as in your examples...
PI
Posts: 176
Joined: Tue Oct 09, 2007 7:15 pm
Location: Hungary

Post by PI »

The short answer is: I don't know. :)

So you're sure you've got a collison manager created and passed it's pointer to the camera class, you've also created the camera and all the collision objects and entities has scene nodes associated with them, and you didn't delete any pointers until the end of your program, and blahblahblah...

See, if there would be something wrong in the tutorials, you wouldn't be able to compile or to run them without a crash, so I can only suggest you to go back to the tutorials, and see why they work and yours why not.

Edit: did you pass a valid pointer of your IrrlichtDevice to the collision manager?
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

I believe he`s getting trouble because he`s trying to extract only the camera and use some different collision system. Somehow not getting my sympathy. :lol:

By the way, PI, I`m sending you an email in a while- writing it right now.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Post by cookie »

-.- I forgot to Include the declarations-file of my global variables like the camera etc to "CGameCamera.h" and the "CCollManager.h".

Now - I think one of the last - problems is:

I get the error message :
Debugger wrote:expected initializer before "*" token
In the Lines

Code: Select all

extern CGameCamera* camera_class;

//and

extern CGameTimer* gameTimer;
The "CGameCamera.h" and the "CGameTimer.h" are same like in your examples.
PI
Posts: 176
Joined: Tue Oct 09, 2007 7:15 pm
Location: Hungary

Post by PI »

This should work:

Code: Select all

// to your globals.h
#include "FunCollision.h"
using namespace COLL; // did you wirte this line too?

#include "CGameTimer.h"
#include "CGameCamera.h"


CCollManager* cmgr;
CGameCamera* camera;
CGamerTimer* timer;
Or this:

Code: Select all

// to your globals.h
#include "FunCollision.h"

// Forward declaration:
class CGameCamera;
class CGameTimer;

COLL::CCollManager* cmgr;
CGameCamera* camera;
CGamerTimer* timer;
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Post by cookie »

Oh man :D YOU ARE MY HERO :D It works perfect :> thanks for your help!

But one more question: When I'm moving my mouse, the camera rotates, but when I stop moving the mouse the cam keep on turning around and don't stop. How can I avoid this?
PI
Posts: 176
Joined: Tue Oct 09, 2007 7:15 pm
Location: Hungary

Post by PI »

Somewhere (over the rainbow) the relative mouse positions are not set to zero.

This might happen if you've forgotten to call:
"input->setLockMouse(true); // lock mouse to the center of the screen"
before (or inside) your mail loop (in the very beginning of it).

Or, maybe, in your camera.update():
"
// ----- Camera rotation:
s32 rmx = 0, rmy = 0; // they should be zero, but it might not matter (?)
input->getRelMousePos(rmx, rmy);
"

Cheers,
PI da HERO :D
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Post by cookie »

Oh :D I forgot "eventReceiver->update()" in the Mainloop, now it works perfect :> thanks for your help mr. pi da hero :D
PI
Posts: 176
Joined: Tue Oct 09, 2007 7:15 pm
Location: Hungary

Post by PI »

You're welcome! Merry Xmas! :D
Post Reply