Camera collisions

PadrinatoR

10-09-2007 16:04:52

Hi!!

I'm doing something like a mesh viewer and I need to implement camera collisions with the mesh.
I have created the ODE geometry from the mesh with an EntityInformer object, and attached a sphere body to the camera. In order to move the camera, I change the speed of the camera body.
In addition, I've disabled gravity, bouncyness and friction.

It works well but sometimes the camera gets blocked when it collides with the mesh. Is there any way to avoid this problem or any better way to implement camera collisions?

Thank you in advance!

Thunder0ne

11-09-2007 09:44:50

I do not know if this can help, but have you set the friction for the camera and the mesh?
Friction in ODE acts actually as a glue, therefore I am supposing this.

PadrinatoR

11-09-2007 14:16:57

Thanks for you reply!
I've set the friction to 0 for both of them.
I think the problem appears because of a deep collision which blocks the camera. I don't know how to solve it :(

Thunder0ne

11-09-2007 15:48:33

How are you simulating the camera?
I mean which solid (or body or shape or whatever it is called) are you using?
Or you are just caching the collision event and managing it in a custom way?
What about the hardness of those solids (if the parameter is called that way in ODE)?

PadrinatoR

11-09-2007 16:53:08

It's a sphere surrounding the camera, then I change the speed of that sphere in order to move the camera.

About hardness... I haven't seen that parameter but I think they're hard by default.
I'm letting ODE manage the collisions, I only set to 0 the friction and the bouncyness in the collisions, that's all :S

What's the best way to simulate the camera? Perhaps I should try with other physics engine like Newton... what do you recommend me?

Thanks again! Byee!!

Thunder0ne

11-09-2007 17:22:02

How do you set the speed, just changing the speed of the body?
Or do you use a velocity motor or something similar?
Otherwise you should handle the collision event and set to zero the component of the velocity of the camera that is normal to the collision surface.
That should work in most of the cases

PadrinatoR

11-09-2007 17:25:35

How do you set the speed, just changing the speed of the body?
Or do you use a velocity motor or something similar?

I do this:
sphere->SetLinearSpeed(Vector3(something));
And ODE moves it and calculates collisions.

Otherwise you should handle the collision event and set to zero the component of the velocity of the camera that is normal to the collision surface.
That should work in most of the cases

That's a very good idea!! I'll try it out! :D:D

Thank you very much :D:D:D

Thunder0ne

11-09-2007 20:54:35

I think I am understanding what is going wrong. If that does not work, consider using a ODE motor. I forgot actually which types of motors are available, but there should be a velocity motor or something similar.
If you set the velocity "manually" the ODE solver may have some troubles.
The velocity motor (provided ODE has one and that is its name :-P ) uses forces to set the velocity at the desired values: forces are "internal solver friendly" :)

PadrinatoR

12-09-2007 11:26:10

I think I am understanding what is going wrong. If that does not work, consider using a ODE motor. I forgot actually which types of motors are available, but there should be a velocity motor or something similar.
If you set the velocity "manually" the ODE solver may have some troubles.
The velocity motor (provided ODE has one and that is its name :-P ) uses forces to set the velocity at the desired values: forces are "internal solver friendly" :)


I don't know if I have understood your post (sorry, my English is very bad, I'm Spanish), but
sphere->SetLinearSpeed(Vector3(something));
is a method provided by OgreOde, so I assume that it will change the speed using the ODE's velocity motor.

I'll try to set to zero the component of the velocity of the camera that is normal to the collision surface as soon as I can.
Thank you again :D:D:D

PadrinatoR

12-09-2007 16:21:06

It didn't work but I used the normal vector and the depth of the collision to move the camera "out of" the collision.
I had to do a little workaround in order to get more accurate results, but it's working well.

Thank you for your help! See ya!

Thunder0ne

12-09-2007 16:36:00

Sorry I forgot to tell you that (to move the solid out of the collision using the collision depth), but you figured it yourself.
Actually setting the velocity as you are doing is not the same as using a velocity motor.
A motor is a force generator, setting the velocity is just setting the velocity which is different since when you use a motor the engine calculate the required force first and then run a simulation step.

I am happy you did it.

rewb0rn

13-09-2007 01:32:54

i think using a geometry and a body for the camera is not clever. the camera will always get stuck e.g. when it enters another tunnel then the player. better use raycasts and move the camera closer to the player when there was a hit. i have started a tutorial for ogreode in the ogre wiki. its not ready yet, but you can read the concept already, that might help.

http://www.ogre3d.org/wiki/index.php/OgreOde_Camera