Click and drag to rotate view. The last collided triangle will show in red when rotating. (doesn't redraw normally) TODO: implement conversion to and from ellipsoid space to allow collision for ellipsoids of any size (right now forced to 1x1x1) 21st December: Changed to move sphere to just before point of collision to avoid rounding errors sticking the sphere in the geometry. Changed starting position and velocity to better show collision working in the bowl.
What could this be used for? ---------------------------------------- In it's current state, it could easily be used for a game like Super Monkey Ball or a Racing Game. With a bit more adaptation, it could be used in a First Person Shooter or 3rd Person Platformer. The current model has 28 faces and it struggles a bit with one sphere with collision (0.015s for collision step in normal situations), so to reasonably make a game that uses 3d collision you would need to partition the model into a three dimensional octree to minimize the number of triangles the collision check is performed on. What are... Half the things that you're doing? ------------------------------------------------------------------ Because Scratch doesn't feature any object oriented aspects, I can't make any specialized classes for Vectors or Planes, so I have to code all of the calculations inline. Because of this, I have way too many variables in the local space, so I reuse variables in places you wouldn't expect the name to make sense to avoid making the variables list like 20 pages long. This happens in the collision section and the model's utility functions. I'll find a way to make this smarter in time. I would also comment the code, however the comments system is very glitchy so I wasn't able to place any. If I did, upon saving and reloading they would be moved around and assigned to the wrong piece of code... which would be even more confusing. The collision and response stepqs closely follow that described in the paper, so if you read that you should be able to understand what I'm doing in the code. It's also great reading material! References: ------------------- Kasper Fauerby, Improved Collision detection and Response http://www.peroxide.dk/papers/collision/collision.pdf