Game Development Reference
In-Depth Information
1. For each instance, we should create a Geometry class with a Sphere
shape that will have the same radius as the size we will supply to the
StellarBody control.
2. The Geometry class should both be attached to rootNode and phys-
icsSpace of bulletAppState .
3. We add StellarBody as a control to the Geometry class and the
gravitationalBodies list.
7. Inside the update method, we have to take into account the gravity of the
StellarBody instances.
8. First, we define a new Vector3f instance called combinedGravity .
9. Then, we loop through our gravitationalBodies list and apply the follow-
ing line of code to apply the gravity to combinedGravity :
combinedGravity.addLocal(body.getGravity(ship.getSpatial().getWorldTranslation()));
10. Finally, we call the ship.setGravity(combinedGravity); statement.
Search WWH ::




Custom Search