Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm building a game using WebGL and Three.js, and so far I have a terrain with a guy walking on it. I simply cast a ray downwards to know the terrain height.

How can I do this for other 3D objects, like the inside of a house? Is this possible by casting many rays in every direction of the player?

If not, I would like to know how I can achieve the simplest collision detection possible for other meshes. Do you have to cast a ray to every triangle in every mesh nearby?

share|improve this question
add comment

2 Answers

Pick an open source 3D physics engine, and see how they do this. Better yet, use it and improve it if you need too, this would help the HTML5 community a lot.

share|improve this answer
add comment

You can use simpler, invisible objects like spheres and cubes to simulate the collisions. The person might have many many polygons, and he might be supposed to bounce off of a rock wall with many many polygons, but the person could be represented by a sphere and the rock wall as a simple plane, and have collisions detection work with those objects. There are many examples of code for colliding two spheres, two cubes (even easier if they're lined up with the axis) and many others.

If you need precise collision checking, you can start with the simple primitives and only if there's the chance of a collision between two objects do you try something more complicated.

http://en.wikipedia.org/wiki/Bounding_volume#Common_types_of_bounding_volume

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.