Best solution for camera to world collisions

Started by
2 comments, last by jamesl22 12 years, 10 months ago
Hi,

I'm making a very simple jumping game in C++ and OpenGL. It is in first person view and my whole world is made only of cubes of uniform size. I have all the graphics sorted but I now need to work on physics between you and the rest of the environment. My question is: what is the best solution for detecting and acting upon collisions between you and the world. I don't need a full blown physics engine as im not going to be using joints and such. Plus the only thing that will be moving is the camera. I really only need to handle gravity.

Thanks,

James
Advertisement
give the player force on 3 dimensions.

his velocity is force/mass.

Then to do collision you would propably get the grid point the camera is in using simple math, and also get the grid point below him, and get all the objects that touch either of those grid points.

If the player is in (or would be moved in) an object, make his force to that direction 0, or add something to not let him move in that direction (like changing the velocity instead of force) so you wont lose all momentum from touching a block.

Not the best way to do it and i propably explained it bad but it should work for a platformer :P

o3o

Thanks for the reply. I was thinking of using a premade physics engine in my game. I was thinking of using tokamak (http://www.tokamakphysics.com/). I was going to make the camera a rigidbody and all of the cubes in my world animatedbodies. Would this work? How would I handle input from the user and give it to the physics engine?
Is there a collision detection library that i can give a list of vertices, give it your position and have it return the plane normal? It needs to be in c or c++ and cross-platform.

This topic is closed to new replies.

Advertisement