its very east to see if a point is inside a cube. i.e.
x > cube_min_x && x < cube_max_x etc... So you could do that for each of the points on the bounding box of your car. might want to do a distance check to save some calculations. i.e. (x*x+y*y+z*z) to have true distance you need to square that, but I wouldn't square root is a pretty costly function. There are some various bit shifting you can do from memory to speed it all along but really that works it just makes you distances rather large. On Oct 22, 1:11 am, "Joshua Granick" <[email protected]> wrote: > You can look into using Box2D. I use that in several of my projects. > Especially in games like racing games, there's ways to construct the world > so it only requires 2D physics. > > On Wed, 20 Oct 2010 07:06:03 -0700, jonny <[email protected]> > wrote: > > > > > > > > > > > Hi, > > > There have been a number of posts on collision detection in Away3D but > > I still havent found a satisfactory answer to my issue. > > > I am creating a simple driving game where I am moving a Camera around > > a track. Simple movement is done with the keyboard e.g > > * Up Key calls camera.moveForward(x) > > * Right Key calls camera.pan(x) etc > > > I will have about 100 objects placed around the world (setup as simple > > cubes) and I am trying to implement some simple collision detection > > with the camera and these objects. > > > From what I have seen there are a number of options: > > Physics engine such as Jiglib - This is not feasable as I need to port > > this game to another platform afterwards so I want to avoid reliance > > on a physics engine. > > CollisionMap - not feasable for same reason as above. No Collision > > Maps available on other platform. > > > I have also played around with the Ray class but not had much luck. > > > At any point I know the camera position, what I need to work out is > > what the new position of the camera will be when I call the next > > camera.moveforward(x) command? How do I work this out? Bearing in mind > > that the camera.pan(x) calls, when turning right or left, will have > > affected the rotations, transformations etc of the camera. > > > Once I know what the camera position is now and what the camera > > position will be the next time I move forward, I then just need to > > work out if the camera will cross one of the faces of the cube > > objects. > > > I know the theory of what I want to do but not sure of the math/ > > function calls I can use to achieve it. > > > I would really appreciate any help you guys can give me. > > > Many Thanks! > > -- > Using Opera's revolutionary email client:http://www.opera.com/mail/
