Today I started working on physics.
This seems to be a very hard thing to implement efficiently, and I don't know if I will ever attempt to implement complex physics and collisions with irregular objects, so for now I'll start to implement the easier things, and gradually add new features.
Today I defined two classes, a WeightForce and a DragForce class.
These holds the important data to calculate the correspondent force (for example in WeightForce is stored a 3d acceleration and the mass of the object).
With these two classes I managed to implement a simple gravity system that uses a gravity weight force and an air drag force.
I also added a very useful debug tool: every 5 frames a red low-poly sphere is instanced in the position of the object.
This allows to follow the path of the object in a nice visual way (as you can see in the image).
Finally I added a few commands to the shell to make physics debugging easier: a pause method that leave the camera active, the automatic pause when shell is active, the command "\r" to restart the simulation, and so on.

Nessun commento:
Posta un commento