[SOLVED] collision detection in custom camera
-
Robin
[SOLVED] collision detection in custom camera
Hello, I'm not sure if this post belongs here, but ill take my chances for it.
I am working on a 2 player split screen game, with 2 mouses. I used for the 1st player cam the FPS camera, thats in the library, but for the second player I had to create my own camera movement control(from a normal camera). Weel I got everything up and running, but now I'm trying to invoke collision detection for movement(gravity and stuff, like in the example). At the 1st player it works perfectly, but with the second player, the movement goes totaly wrong.
When I walk its normal, but then I look up, and I'm constandly falling down, like I'm hopping very fast. And when I walk to fast into a wall, or look down I go trough the wall.
I think this is caused by the getposition which I use to move the cam, and when the collisiondetection responds to this movement. It sees it as the starting position, so when I look down, and press forward, I go trough the floor and the detector then animates my falling, while it should actually prevent me from going trough te floor in the first place.
I have looked troug the source to see how the engine prevents this, but I could not find it.
is there a simple solution for it, or should I do the colision detection myself, instead of the simple createCollisionResponseAnimator()?
Greets Robin
I am working on a 2 player split screen game, with 2 mouses. I used for the 1st player cam the FPS camera, thats in the library, but for the second player I had to create my own camera movement control(from a normal camera). Weel I got everything up and running, but now I'm trying to invoke collision detection for movement(gravity and stuff, like in the example). At the 1st player it works perfectly, but with the second player, the movement goes totaly wrong.
When I walk its normal, but then I look up, and I'm constandly falling down, like I'm hopping very fast. And when I walk to fast into a wall, or look down I go trough the wall.
I think this is caused by the getposition which I use to move the cam, and when the collisiondetection responds to this movement. It sees it as the starting position, so when I look down, and press forward, I go trough the floor and the detector then animates my falling, while it should actually prevent me from going trough te floor in the first place.
I have looked troug the source to see how the engine prevents this, but I could not find it.
is there a simple solution for it, or should I do the colision detection myself, instead of the simple createCollisionResponseAnimator()?
Greets Robin
You created the second camera because it doesn't work with the mouse input, right? I don't know where the bug with your second camera is, but you could try simply coping the FPS camera and disabling mouse input. Try out if col.det works with this. Then, modify the camera again and try if it still works. In this way you could find the problem easily by yourself.
-
Robin
thanks for the reply niko, but when I create a second FPS camera, it is not redered at all from version 0.4.1 . I just typed
camera2 = smgr->addCameraSceneNodeFPS();
instead of
camera2 = smgr->addCameraSceneNode();
when I do this, I get a black screen at the second player(wich is redered last in the while(device->run) code.) At 0.4 it would work, but then the (primary)mouse movement cannot be disabled for the second cam
If you could tell me how to solve this, I would be more than happy to use the FPS cam
Greets Robin
camera2 = smgr->addCameraSceneNodeFPS();
instead of
camera2 = smgr->addCameraSceneNode();
when I do this, I get a black screen at the second player(wich is redered last in the while(device->run) code.) At 0.4 it would work, but then the (primary)mouse movement cannot be disabled for the second cam
If you could tell me how to solve this, I would be more than happy to use the FPS cam
Greets Robin
-
Robin
-
Robin
well, I did follow your advice niko I found out that the reason for the black screen was the settarget function that was still hiding somwhere in my initialisation. (the setTarget didn't work in this version with the FPS did it?), now everything exept the mouse look, wich uses setTarget(), works(and I'm sure that will work too in the next version). So thanks, and keep up the awesome work
greets
greets
Help about events (mouse and keyboard)
Hi,
I've juste read your discuss before. I'm working on an school project wich use a virtual reality room. I need to have a stereoscopic vision (2 cameras positionning as 2 eyes and moving together). I'm doing that with a splitscreen like the tutorial. I'm setting 2 FPS cameras as you told before nad giving them the same event. This is my code for a custom EventReceiver:
There camera[2] and camera[3] are FPS cameras.
The problem is when I move mouse and moving with the keyboard I don't have the same reaction from the 2 cameras. I think it's because I have a splitting screen. But I'm not sure. I don't know how it's work in irrlicht
Can anybody giving some help?
Thank a lot
I've juste read your discuss before. I'm working on an school project wich use a virtual reality room. I need to have a stereoscopic vision (2 cameras positionning as 2 eyes and moving together). I'm doing that with a splitscreen like the tutorial. I'm setting 2 FPS cameras as you told before nad giving them the same event. This is my code for a custom EventReceiver:
Code: Select all
class MyEventReceiver : public IEventReceiver {
public:
virtual bool OnEvent(SEvent event) {
//Key S enables/disables SplitScreen
if (event.KeyInput.Key == KEY_KEY_S && event.KeyInput.PressedDown) {
SplitScreen = !SplitScreen;
return true;
}
//Send all other events to camera4
//if (camera[3])
camera[3]->OnEvent(event);
//if (camera[2])
camera[2]->OnEvent(event);
return false;
}
};
The problem is when I move mouse and moving with the keyboard I don't have the same reaction from the 2 cameras. I think it's because I have a splitting screen. But I'm not sure. I don't know how it's work in irrlicht
Can anybody giving some help?
Thank a lot
.: Franck :.
-
Guest
For what you want, maybe you should do the following:
while(device->run()) {
( move camera to left eye position )
driver->setViewport( leftviewport );
driver->BeginScene(...)
smgr->DrawAl();
driver->EndScene();
( move camera to right eye position )
driver->setViewport( leftviewport );
driver->BeginScene(...)
smgr->DrawAl();
driver->EndScene();
( move camera back to center )
}
(obviously you need to fill in the details yourself)
while(device->run()) {
( move camera to left eye position )
driver->setViewport( leftviewport );
driver->BeginScene(...)
smgr->DrawAl();
driver->EndScene();
( move camera to right eye position )
driver->setViewport( leftviewport );
driver->BeginScene(...)
smgr->DrawAl();
driver->EndScene();
( move camera back to center )
}
(obviously you need to fill in the details yourself)
-
Guest
It's workkkkkkk!!!!!
Thank a lot who ever you are, it's workkkk, thank Guest. Very helpfull
I will compute good figures to be set....
Just a question, I realise that the FPS is falling down a lot, I suppose it's normal. Is it an other way to to this??? keeping FPS a little bit higher...
Sorry for my bad english
I will compute good figures to be set....
Just a question, I realise that the FPS is falling down a lot, I suppose it's normal. Is it an other way to to this??? keeping FPS a little bit higher...
Sorry for my bad english
.: Franck :.
-
Guest