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.
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

FPSCameraSceneNode Frame independent?

Post by cookie »

Hello,

I've got a problem with my FPSCamerascene node.
The higher my framerate is the higher my player jumps. I don't know how I can fix this problem because I can't change the "Jump-speed" at runtime...

someone got an idea whats to do?

Maybe someone had written an own fps camera which is better than the "onboard" FPS camera node of irrlicht?


sorry for my bad english, I'm german.
DtD
Posts: 264
Joined: Mon Aug 11, 2008 7:05 am
Location: Kansas
Contact:

Post by DtD »

The two built-in camera in Irrlicht are primarily there for testing purposes, if you are making a game you are much better off making your own.

I have also noticed the frame dependence in the FPS camera.

~DtD
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Post by cookie »

Ok, thanks. But how can I write my own camera? Are there templates for doing this or some tutorials/examples?
PI
Posts: 176
Joined: Tue Oct 09, 2007 7:15 pm
Location: Hungary

Post by PI »

FunCollision gives you framerate independent movement (see my signature). Download the latest version, try out the demos. It knows as much as Irrlicht's collision system, plus a bit more.
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Post by cookie »

Yeah, thats what I need, thanks!

But could you explain me how I can include and use the FPS Camera of your engine in my project? I'm a bit confused atm...
PI
Posts: 176
Joined: Tue Oct 09, 2007 7:15 pm
Location: Hungary

Post by PI »

Please read the readme.txt and also you should get familiar with the tutorials I've provided. If you still don't know how to use it, even after all this, tell me and I'll help. By the way, what is confusing?
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Post by cookie »

I'm confused about the Include Files in each Example of your engine, because there are so different... I just want to add your camera of your engine into my project but I don't really know how to do this

thx for help
PI
Posts: 176
Joined: Tue Oct 09, 2007 7:15 pm
Location: Hungary

Post by PI »

There are .h and .cpp files that contains FunCollision itself. They are needed to be able to use my collision system.

The rest of the .h and .cpp files are not really needed, however, they can ease your life if you want to use FC.

And yes, these are a bit different from one tutorial to the other. For example, the CGameCamera files. Why?

Because in one of the tutorials, you can only fly around.
In the other one, there is gravity and you can jump, too.
In another one, you can do even more things.

All of them have many comments that explains everything.

Code: Select all

I just want to add your camera of your engine into my project but I don't really know how to do this 
Ah, now I see. You can only use these functions (and the camera) what I've been talking about, if you include FC in your project. Sorry. :)
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Post by cookie »

OK, at the moment I'm trying to include the CGameCamera.h into my project to use this camera class but I've got a problem with the Function

Code: Select all

CGameCamera* camera = new CGameCamera(device, cmgr, getEventReceiver(),
        core::vector3df(50, 70, -60),   // set it's position
        core::vector3df(30, 50, 30),    // set it's shape
        core::vector3df(0, 30, 0));     // set the "head" position
Everytime I compile my code, it shows me an "undefined reference" to this Function, I don't know what I have to do. I know, I replaced the CGameInput with a IEventReceiver but the error comes too when I replace my EventReceiver with the CGameInput...
PI
Posts: 176
Joined: Tue Oct 09, 2007 7:15 pm
Location: Hungary

Post by PI »

Hi!

A) Did you copy and include CGameCamera.h and CGameInput.h into your project? Undefined reference means that it cannot find the function or variable.

B) What does "getEventReceiver()" do in your project? I suggest to use CGameInput.h and .cpp first and swith to another event receiver later if it works.

C) Can you compile any of the tutorials I've made? If not, there must be some other error I haven't bumped into yet.

D) If your code is not too long, you can send it to me, I'll make it run. (But I use Code::Blocks with MinGW).

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

Post by cookie »

PI wrote:Hi!

A) Did you copy and include CGameCamera.h and CGameInput.h into your project? Undefined reference means that it cannot find the function or variable.


I copied the files in the right directory and Included them.
B) What does "getEventReceiver()" do in your project? I suggest to use CGameInput.h and .cpp first and swith to another event receiver later if it works.
With this function I get the pointer to the eventReceiver ( I use the MasterEventReceiver for my project)
C) Can you compile any of the tutorials I've made? If not, there must be some other error I haven't bumped into yet.
Yes, I can.
D) If your code is not too long, you can send it to me, I'll make it run. (But I use Code::Blocks with MinGW).
About 4000 Lines of code is much too long I think ;)
Cheers,
PI
cya ;)


[EDIT]

Ok, I found the "bug" I forgot to add the Includes into my project ;)
I decided to switch completely to you EventReceiver because you Receiver looks more dynamic and it's more compitable to your camera etc.
PI
Posts: 176
Joined: Tue Oct 09, 2007 7:15 pm
Location: Hungary

Post by PI »

So you've found the bug? Coolness :D

You can use any type of event receiver. As you can see, it's only needed when passing it's pointer to the camera, and the camera just checks if up/down/left/right is pressed or not.

Oh yeah and one more thing. It also locks the mouse to the center of the screen which is needed for relative mouse positions, so that you can rotate the view with the mouse.

This is the
"input->setLockMouse(true); // lock mouse to the center of the screen"
function.

But if your event receiver knows all of these, you can change to yours easily.
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Post by cookie »

Thanks for the informations.

I've got a new question: How can I add collision to more than one node? I'm looking for something like an metaTriangleSelector. And how can I create a triangle selector out of an bounding box of an animated mesh?

Thanks for your help :)
PI
Posts: 176
Joined: Tue Oct 09, 2007 7:15 pm
Location: Hungary

Post by PI »

Well, I might not understand you completely, so here's an example:


Say I have a terrain, a house, and a couple of crates outside, ok?

I create the terrain scene node, and then a terrain selector for it.
Then I add an object that is binded to this selector, and to this node.

I load the house model and create an octree selector for it.
Then I add an object that is binded to this selector, and to this node.

I load the crate model and create one box selector for it (bbselector). Then I clone the crate scene node e.g. 10 times (crateSceneNode), and in the meantime, I also add them as collision objects. Like here:
cmgr->addObject(bbselector, crateSceneNode);


Okay, now I want to add 3 characters (for example animated dwarfs). If they have the same size, mass, etc. etc. I create one sampler (dwarfSampler), and share between them.
cmgr->addEntity(core::vector3df(-150,-66, -40), dwarfSampler, dwarf1);
cmgr->addEntity(core::vector3df(-150,-66, -80), dwarfSampler, dwarf2);
cmgr->addEntity(core::vector3df(-150,-66, -120), dwarfSampler,dwarf3);

But if I also want to add an elf character (who's taller) I create an ellipsoid sampler for it (elfSampler), and cmgr->addEntity(pos, elfSampler, elfNode);


A meta triangle selector in Irrlicht is "multiple triangle selectors work as one big selector". Here, everything is automatic, you don't have to deal with meta triangle selectors.

Just use cmgr->addObject() and cmgr->addEntity() commands, and don't forget to call cmgr->update(elapsedTime); in your main loop every frame.


I hope I've answered your question :)
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Post by cookie »

Yes that helped me a lot! Thank you ^_^

Now I've got a bigger problem :D

When I run my program (with debugger) the debugger gives me the message: "SIGSEGV - Segmentation Fault" in the line:

Code: Select all

camPos = cam->getAbsolutePosition();
In the function

Code: Select all

CGameCamera::update()
I really don't know whats to do... segmentation fault is , if I'm right, an memory acess error, I hope you can help me ._.
Post Reply