how can i recognize objects by coordinates?

hi all
I have a house and some dynamic objects in i want to stop camera going through wall and get into house.i want to write a function calculate that is there any wall or not in that coordinates, if there is stop the camera .is there any function?a function that if there is not something return null.


that what you want to do is not a really good idea, because what will be the result if you
check for the x coordinate 16.000001 and the ‘wall’ is on the x coordinate 16.0?

Those ‘walls’, triangles, quads, triangle-strips, … in OpenGL are infinite thin! I would really
just use a phyiscs library like bullet physics which provides these features in a fast and reliable
way. You’ll just feed all your vertices to the physics library and it will check for you if a
collision happened or not and how the objects should behave after that collision.

Another, but more costly way to deal with it, would be bounding volumes. You will check
if the bounding volume from the camera intersects with the bounding volume from the
wall. Physics libraries support those features too, because they are based on it, but
if you want to implement it on your own, bounding volumes would be the right choice.

  • Daniel

Sounds like you want some sort of collision dedection.

If you only want your camera to collide with world objects, you can do that by casting rays into you scene
representation and check for collisions with bounding volumes of your objects.

If you want your dynamic objects to move and collide with things, the whole thing might get a little more
involved and you would need something more sophisticated.

A typicall approach is to build a tree structure (something like bounding sphere tree) to do a rough estimation
of objects that might collide and then do a finer grained collission dedection on the resulting objects.

If at some point you were to decide that dynamics simulation is a cool thing to have, the easiest approach
would be to go ahead and use an existing “physics engine”.

There are countless free software physics engines out there that implement collision dedection as well as
rigid body dynamics simulation.

To name a few:
[li]Newton [/li][li]Bullet [/li][li]IBDS [/li][li]ODE [/li][li]… [/li][/ul]