This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
es:orx:tutorials:physics [2012/03/03 07:43 (13 years ago)] – [Sumario] zera | es:orx:tutorials:physics [2020/08/19 21:14 (5 years ago)] (current) – Old content sausage | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Tutorial de Física ====== | ||
- | |||
- | |||
- | |||
- | ===== Sumario ===== | ||
- | |||
- | Ver los anteriores [[main# | ||
- | |||
- | Este tutorial muestra como añadirle propiedades físicas a los objetos y manejar colisiones. | ||
- | |||
- | Como puedes ver, las propiedades físicas son completamente manipuladas por datos. Así, creando un objeto con propiedades físicas (ej. con un cuerpo) o sin ellas, resulta en exactamente la misma linea de código. | ||
- | |||
- | Los objetos pueden ser enlazados a un cuerpo, que puede ser estático o dinámico.\\ | ||
- | Cada cuerpo puede estar hecho de hasta 8 partes. | ||
- | |||
- | Un cuerpo es definido por: | ||
- | * su forma (actualmente caja, esfera y malla(ej. poligono convexo) son los únicos disponibles) | ||
- | * información acerca del tamaño de la forma (esquinas para la caja, centro y radio para la esdera, ) | ||
- | |||
- | A body part is defined by: | ||
- | * its shape (currently box, sphere and mesh (ie. convex polygon) are the only available) | ||
- | * information about the shape size (corners for the box, center and radius for the sphere, vertices for the mesh) | ||
- | * if no size data is specified, the shape will try to fill the complete body (using the object size and scale) | ||
- | * collision " | ||
- | * collision " | ||
- | * a flag ('' | ||
- | * various attributes such as restitution, | ||
- | |||
- | In this tutorial we create static solid walls around our screen. We then spawn boxes in the middle.\\ | ||
- | The number of boxes created is tweakable through the config file and is 100 by default. | ||
- | |||
- | The only interaction possible is using left and right mouse buttons (or left and right keys) to rotate the camera.\\ | ||
- | As we rotate it, we also update the gravity vector of our simulation.\\ | ||
- | Doing so, it gives the impression that the boxes will be always falling toward the bottom of our screen no matter how the camera is rotated. | ||
- | |||
- | We also register to the physics events to add a visual FXs on two colliding objects.\\ | ||
- | By default the FX is a fast color flash and is, as usual, tweakable in realtime | ||
- | (ie. reloading the config history will apply the new settings immediately as the FX isn't kept in cache by default). | ||
- | |||
- | Updating an object scale (including changing its scale with FXs) will update its physical properties (ie. its body).\\ | ||
- | Keep in mind that scaling an object with a physical body is more expensive as we have to delete the current shapes and recreate them at the correct size.\\ | ||
- | This is done this way as our current single physics plugin is based on Box2D which doesn' | ||
- | |||
- | This tutorial does only show basic physics and collision control, but, for example, you can also be notified with events for object separating or keeping contact. | ||
- | |||
- | ===== Detalles ===== | ||
- | |||
- | |||
- | |||
- | ===== Recursos ===== | ||
- | |||