#54916 - duencil - Fri Sep 23, 2005 4:47 pm
I don't know of any 3d collision libraries out there that are suitable to the fixed point restrictions of the DS. Anyway, most of the work in collision testing is working out how to do as few tests as possible each frame, and then optimizing to the maximum the tests you do make. For the first its useful first to organise your 3d world and the objects within it into a hierarchical structure, like a quadtree, octree, bsp, portal system, or whatever. Actually my preferance is for another structure, the kd-tree. Then for the second, well it sounds like you have a base to start with. I want to work on putting together some 3d primitive( probably sphere or box) vs triangle/quad routines in the near future.
#54958 - TheChuckster - Fri Sep 23, 2005 10:12 pm
Without an FPU, ODE for DS is not going to happen. You could always opt for integer or fixed point addition physics.
Have three vectors and set acceleration's y-value to -1:
Do:
Velocity += Acceleration
Position += Velocity
Yay. Gravity. Adjust the acceleration to add lateral forces and jumping. This will simulate the gravity parabola and acceleration very nicely.
RESEARCH THE FOLLOWING ON YOUR OWN FOR MORE INFO:
When a sprite hits a wall or the floor, you need to generate an impulse for collision response. Assuming you have collision detection, come up with a quantity called j based on the relative velocity, the collision normal, and the elacsticity of the collision. Apply that directly to the colliding objects' velocities.
As for rotation, derive three new quantities (angular vel, accel, orientation) and integrate the same way. (Forgive my psuedo-Calculus terminology. I am still in Trig.) Now if one adds a force at a point other than the center of mass, the object will rotate accordingly. Now with collisions, you want your objects to spin, too. Find a new impulse equation that takes in account torque and apply the resulting torques to your bodies.
As for contact, I have yet to fully understand it myself. Real 3D physics engines use LCPs or quadratic programming. Above my high school mathematics education even more so than the Calculus concepts. You can get around this shortcoming by adding a value to the acceleration vector (and velocity vector?) so that the force of gravity is cancelled out and the rigid body does not pass through the ground. Good luck with handling contact points though.
That pretty much sums up game physics, at least in the 2D world. If anyone learns more about contact or contraints/joints, please fill me in as I have been unsuccessfully trying to learn about/understand those topics myself.
#54959 - sajiimori - Fri Sep 23, 2005 10:39 pm
Most real games don't do things like angular velocity. If you want to talk about "real" 3D engines, try reading the Quake 3 source. You might be surprised at how simple the simulation is.