|
@@ -22,11 +22,11 @@ If you are looking for info on how to respond to physics events, read about <a h
|
|
|
|
|
|
<p>
|
|
|
|
|
|
-Bullet physics runs internally at 60fps by default. This rate is not dependent on the actual framerate and it does not lock the framerate at 60fps. Instead, when the actual fps is higher than the physics framerate the system will display interpolated positions for the physics objects. When the framerate is lower than the physics framerate the physics space will be stepped multiple times per frame to make up for the missing calculations.
|
|
|
+Bullet physics runs internally at 60fps by default. This rate is not dependent on the actual framerate and it does not lock the framerate at 60fps. Instead, when the actual fps is higher than the physics framerate the system will display interpolated positions for the physics entities. When the framerate is lower than the physics framerate the physics space will be stepped multiple times per frame to make up for the missing calculations.
|
|
|
</p>
|
|
|
|
|
|
<p>
|
|
|
-A bullet physics space can be created with a BulletAppState. The updating and syncing of the actual physics objects happens in the following way:
|
|
|
+A bullet physics space can be created with a BulletAppState. The updating and syncing of the actual physics entities happens in the following way:
|
|
|
</p>
|
|
|
|
|
|
<p>
|
|
@@ -138,49 +138,51 @@ Before you can create a Physics Control, you must create a Collision Shape from
|
|
|
</p>
|
|
|
<div><table>
|
|
|
<tr>
|
|
|
- <th> Shape </th><th> Purpose </th>
|
|
|
+ <th> Shape </th><th> Usage </th><th> Examples </th>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> BoxCollisionShape </td><td> Box shaped objects such as bricks, crates, simple obstacles. Does not roll. </td>
|
|
|
+ <td> BoxCollisionShape </td><td> Box shaped entities Does not roll.</td><td> Bricks, crates, simple oblong entities. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> SphereCollisionShape </td><td> Spherical objects such as balls. Can roll. </td>
|
|
|
+ <td> SphereCollisionShape </td><td> Spherical entities. Can roll. </td><td> Balls, simple compact entities. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> CylinderCollisionShape </td><td> Tube-shaped pillars, disc-shaped wheels. Can roll on one side. </td>
|
|
|
+ <td> CylinderCollisionShape </td><td> Tube-shaped and disc-shaped entities. Can roll on one side. </td><td> Pillars, wheels. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> CapsuleCollisionShape </td><td> A compound of a cylinder plus two spheres at the top and bottom. Rotated upright, this shape is optimal for CharacterControls: A cylinder-shaped body does not get stuck at corners and vertical obstacles; the rounded top and bottom do not get stuck on stair steps and ground obstacles. Is locked to stay upright, does not roll. </td>
|
|
|
+ <td> CapsuleCollisionShape </td><td> A compound of a cylinder plus two spheres at the top and bottom. Is locked to stay upright, does not roll. </td><td> Optimized for CharacterControls: A cylinder-shaped body does not get stuck at corners and vertical obstacles; the rounded top and bottom do not get stuck on stair steps and ground obstacles. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> CompoundCollisionShape </td><td> A CompoundCollisionShape allows custom combinations of box/sphere/cylinder shapes to form another more complex shape. </td>
|
|
|
+ <td> CompoundCollisionShape </td><td> A CompoundCollisionShape allows custom combinations of box/sphere/cylinder shapes to form another more complex shape. </td><td> Complex shapes. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> MeshCollisionShape </td><td> A free-form mesh-accurate shape that wraps itself around a mesh. <br/>
|
|
|
-<strong>Limitations:</strong> Only non-mesh collision shapes (sphere, box, cylinder, compound) can collide with mesh-accurate collision shapes. The Mesh Collision Shape only works for static obstacles, e.g. for a game level model. </td>
|
|
|
+ <td> MeshCollisionShape </td><td> A free-form mesh-accurate shape that wraps itself around a static entity. <br/>
|
|
|
+<strong>Limitations:</strong> Only non-mesh collision shapes (sphere, box, cylinder, compound) can collide with mesh-accurate collision shapes. Only works for static obstacles. </td><td> A whole static game level model. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> GImpactCollisionShape </td><td> This free-form Mesh Collision Shape can be used for moving objects. Uses <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://gimpact.sourceforge.net/"><param name="text" value="<html><u>http://gimpact.sourceforge.net/</u></html>"><param name="textColor" value="blue"></object>. <strong>Limitations:</strong> CPU intensive, use sparingly! We recommend using HullCollisionShapes or CompoundShapes made of simple shapes if you need improved performance. </td>
|
|
|
+ <td> GImpactCollisionShape </td><td> This free-form Mesh Collision Shape that wraps itself around dynamically moving entities. Uses <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://gimpact.sourceforge.net/"><param name="text" value="<html><u>http://gimpact.sourceforge.net/</u></html>"><param name="textColor" value="blue"></object>. <br/>
|
|
|
+<strong>Limitations:</strong> CPU intensive, use sparingly! We recommend using HullCollisionShapes or CompoundShapes made of simple shapes if you need improved performance. </td><td> Physics simulation of a complex object. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> HeightFieldCollisionShape </td><td> Optimized Mesh Collision Shape for static terrains. This shape is much faster than a other Free-Form Mesh Shapes. Requires heightmap data.</td>
|
|
|
+ <td> HeightFieldCollisionShape </td><td> Optimized Mesh Collision Shape for static terrains. This shape is much faster than a other Free-Form Mesh Shapes. Requires heightmap data.</td><td>Optimized for terrains.</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> HullCollisionShape </td><td> A collision shape that is based on a mesh but is a simplified convex version. </td>
|
|
|
+ <td> HullCollisionShape </td><td> A collision shape that is based on a mesh but is a simplified convex version. </td><td> …</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> SimplexCollisionShape </td><td>A physical point, line, triangle, or quad Collision Shape, defined by one to four points.</td>
|
|
|
+ <td> SimplexCollisionShape </td><td>A physical point, line, triangle, or quad Collision Shape, defined by one to four points.</td><td>Guardrails</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> PlaneCollisionShape </td><td> A 2D plane that can be used as flat solid floor or wall. </td>
|
|
|
+ <td> PlaneCollisionShape </td><td> A 2D plane </td><td> Flat solid floor or wall. </td>
|
|
|
</tr>
|
|
|
</table></div>
|
|
|
-<!-- EDIT1 TABLE [3692-5610] -->
|
|
|
+<!-- EDIT1 TABLE [3694-5743] -->
|
|
|
<p>
|
|
|
|
|
|
-<strong>Tip:</strong> Pick the right shape for the mesh for what you want to do: If you give a box a sphere collision shape, it will roll; if you give a ball a box collision shape, it will sit on a slope. Make collision shapes visible by adding the following line after the bulletAppState initialization:
|
|
|
+<p><div>Pick the right shape for the mesh for what you want to do: If you give a box a sphere collision shape, it will roll; if you give a ball a box collision shape, it will sit on a slope. Make collision shapes visible by adding the following line after the bulletAppState initialization: <br/>
|
|
|
+<code>bulletAppState.getPhysicsSpace().enableDebug(assetManager);</code>
|
|
|
+</div></p>
|
|
|
</p>
|
|
|
-<pre>bulletAppState.getPhysicsSpace().enableDebug(assetManager);</pre>
|
|
|
|
|
|
<p>
|
|
|
Let's look at examples of how to use the CollisionShape constructor:
|
|
@@ -193,7 +195,7 @@ Let's look at examples of how to use the CollisionShape constructor:
|
|
|
|
|
|
<p>
|
|
|
|
|
|
-MeshCompoundShape and MeshCollisionShape are both mesh-accurate and are intended for immobile scene objects, such as terrains, buildings, or whole shooter levels. Limitation: Only collisions of non-mesh-accurate shapes (sphere, box, etc) shapes can be detected against mesh-accurate shapes.
|
|
|
+MeshCompoundShape and MeshCollisionShape are both mesh-accurate and are intended for immobile scene entities, such as terrains, buildings, or whole shooter levels. Limitation: Only collisions of non-mesh-accurate shapes (sphere, box, etc) shapes can be detected against mesh-accurate shapes.
|
|
|
|
|
|
</p>
|
|
|
<pre>CompoundCollisionShape myComplexShape =
|
|
@@ -218,7 +220,7 @@ SphereCollisionShape, BoxCollisionShape, CapsuleCollisionShape are also not mesh
|
|
|
|
|
|
<p>
|
|
|
|
|
|
-BulletPhysics are available in jME3 through Bullet Physics Controls from the com.jme3.bullet.control package. PhysicsControls are the recommended way to use physics in a jME3 application. PhysicsControls are flexible and can be added to any Spatial to make it act according to physical properties. These Control classes directly extend Bullet Physics Objects.
|
|
|
+BulletPhysics are available in jME3 through Bullet Physics Controls from the com.jme3.bullet.control package. PhysicsControls are the recommended way to use physics in a jME3 application. PhysicsControls are flexible and can be added to any Spatial to make it act according to physical properties. jME's PhysicsControl classes directly extend Bullet Physics objects.
|
|
|
|
|
|
</p>
|
|
|
<div><table>
|
|
@@ -226,23 +228,23 @@ BulletPhysics are available in jME3 through Bullet Physics Controls from the com
|
|
|
<th>Physics Control</th><th>Purpose</th>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td>RigidBodyControl</td><td>Use for physical objects in the scene, e.g. projectiles and obstacles – things that are freely affected by physical forces, be it by collision or falling.</td>
|
|
|
+ <td>RigidBodyControl</td><td>Use for dynamic physical entities in the scene – things that are freely affected by physical forces such as collisions, forces, or changing gravity. For example: Impacting projectiles, moving obstacles like crates, rolling and bouncing balls, space ships…</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td>CharacterControl</td><td>Use for characters (persons, animals) that stand upright, orthogonally to the X/Z plane. When directional forces are applied to a CharacterControl'ed Spatial, it does not tip over (as a RigidBodyControl'ed Spatial would), but it moves upright (as a walking character would).</td>
|
|
|
+ <td>CharacterControl</td><td>Use for upright characters (persons, animals) that moves and stands orthogonally to the X/Z plane. It is not affected by directional forces or gravity and it does not fall over (as a RigidBodyControl'ed spatial would), a CharacterControl's spatial is permanently locked locked upright (as a walking character would). </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td>GhostControl</td><td>A GhostControl is a PhysicsControl that detects overlaps with other physical objects. A GhostControl is <em>non-solid</em> and moves with the Spatial it is attached to. Use this for game elements that do not have a visible solid Geometry: Aggro radius, motion detectors, photoelectric sensors, radioactive areas, life-draining ghosts, etc. </td>
|
|
|
+ <td>GhostControl</td><td>Use for collision and intersection detection between physical entities. A GhostControl is <em>non-solid</em> and invisible, and it moves with the Spatial it is attached to. Use this for interactive game elements that do not have a visible solid Geometry: A monster's "aggro radius", motion detectors, photoelectric alarm sensors, poisonous or radioactive perimeters, life-draining ghosts, etc. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<td>VehicleControl <br/>
|
|
|
-PhysicsVehicleWheel</td><td> Implements <a href="/com/jme3/gde/core/docs/jme3/advanced/vehicles.html">terrestric vehicle</a> behaviour.</td>
|
|
|
+PhysicsVehicleWheel</td><td> Use for <a href="/com/jme3/gde/core/docs/jme3/advanced/vehicles.html">vehicles</a> such as cars, tanks, hover crafts, ships, motorcycles.</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td>RagDollControl</td><td> Implements <a href="/com/jme3/gde/core/docs/jme3/advanced/ragdoll.html">Ragdoll</a> behaviour.</td>
|
|
|
+ <td>RagDollControl</td><td> Use for collapsing, flailing, or loosely falling characters or with a <a href="/com/jme3/gde/core/docs/jme3/advanced/ragdoll.html">Ragdoll</a> (or puppet-on-strings) behaviour.</td>
|
|
|
</tr>
|
|
|
</table></div>
|
|
|
-<!-- EDIT2 TABLE [7377-8399] -->
|
|
|
+<!-- EDIT2 TABLE [7519-8845] -->
|
|
|
</div>
|
|
|
|
|
|
<h3><a>PhysicsControls Code Samples</a></h3>
|
|
@@ -273,7 +275,12 @@ model.addControl(character_phys);
|
|
|
bulletAppState.getPhysicsSpace().add(character_phys);</pre>
|
|
|
|
|
|
<p>
|
|
|
-<strong>Tip:</strong> Spheres and Boxes can fall back to the correct default Collision Shape if you do not specify a Collision Shape in the RigidBodyControl constructor. For example, the following creates a box with the correct Box Collision Shape:
|
|
|
+<p><div>Spheres and Boxes can fall back to the correct default CollisionShape if you do not specify a CollisionShape in the RigidBodyControl constructor.
|
|
|
+</div></p>
|
|
|
+</p>
|
|
|
+
|
|
|
+<p>
|
|
|
+For example, the following creates a box with the correct Box Collision Shape:
|
|
|
</p>
|
|
|
<pre>Box(1,1,1);
|
|
|
myBox.addControl(new RigidBodyControl( 1.0f )); // implicit BoxCollisionShape
|
|
@@ -286,7 +293,7 @@ bulletAppState.getPhysicsSpace().add(myBox);</pre>
|
|
|
|
|
|
<p>
|
|
|
|
|
|
-The Physics Space is an object in BulletAppState that is like a rootNode for Physics Controls.
|
|
|
+The Physics Space is an object in BulletAppState that is like a rootNode for Physics Controls. It manages global settings.
|
|
|
</p>
|
|
|
<ol>
|
|
|
<li><div> You can specify parameters such as gravity and accuracy.<pre>bulletAppState.getPhysicsSpace().setGravity(new Vector3f(0f,-1f,0f));
|
|
@@ -306,7 +313,7 @@ bulletAppState.getPhysicsSpace().setAccuracy(0.005f);</pre>
|
|
|
|
|
|
<p>
|
|
|
|
|
|
-You remove physical objects from the scene like this:
|
|
|
+You remove physical entities from the scene by removing their PhysicsControl from the PhysicsSpace and also their Spatial from the rootNode:
|
|
|
|
|
|
</p>
|
|
|
<pre>bulletAppState.getPhysicsSpace().remove(myPhysicsControl);
|
|
@@ -314,7 +321,7 @@ myModel.removeFromParent();</pre>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
-<h2><a>Properties of Physical Objects</a></h2>
|
|
|
+<h2><a>Properties of Physical Entities</a></h2>
|
|
|
<div>
|
|
|
|
|
|
<p>
|
|
@@ -326,50 +333,56 @@ On a PhysicsControl, you can set the following physical properties.
|
|
|
<th> RigidBodyControl Method </th><th> Property </th>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setFriction(1f) </td><td> Friction. </td>
|
|
|
+ <td> setGravity(new Vector3f(0f,-10f,0f)) </td><td> You can change the gravity of individual physics entities after they were added to the physics space. Gravity is a vector pointing towards the center of gravity. The longer the vector, the stronger is gravity. If gravity is the same absolute direction for all entities, set this vector globally on the physics space. If the center of gravity is relative (e.g. towards a planet's core or towards a black hole) then you have to use this method to adjust the vectors of all entities at each tick of the update loop.</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setMass(1f) </td><td> Sets the mass. Dynamic objects have masses > 0.0f. <br/>
|
|
|
-Static immobile obstacles (including buildings and terrains) have mass 0.0f. </td>
|
|
|
+ <td> setFriction(1f) </td><td> Friction. Ice and slides have low friction, the are slippery. Soil, concrete and rock have high friction. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setPhysicsLocation()</td><td>Positions the object. Do not use setLocalTranslation().</td>
|
|
|
+ <td> setMass(1f) </td><td> Sets the mass. Dynamic entities have masses > 0.0f. Heavy dynamic entities need more force to be moved and light ones move with small amounts of force. <br/>
|
|
|
+Static immobile entities (obstacles, including buildings and terrains) must have mass = 0.0f. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setPhysicsRotation()</td><td>Rotates the object. Do not use setLocalRotate().</td>
|
|
|
+ <td> setPhysicsLocation()</td><td>Positions the entity. Do not use setLocalTranslation() for physical entities.. Important: Make certain not to make CollisionShapes overlap when positioning them (Use the debug mode to check the shapes). </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setRestitution(0.0f) </td><td> How bouncy the object is. For a rubber object set this > 0.0f. This setting has an impact on performance. </td>
|
|
|
+ <td> setPhysicsRotation()</td><td>Rotates the entity. Do not use setLocalRotate() for physical entities.</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setKinematic(true) </td><td> A kinematic Spatial is not affected by gravity, but it is solid and affects other physics objects. It has a mass its position is updated from the spatials translation. You can attach joints to it. </td>
|
|
|
+ <td> setRestitution(0.0f) </td><td> How bouncy an entity is, normally 0.0f. <br/>
|
|
|
+For a bouncy, such as rubber balls, set this > 0.0f. This setting has an impact on performance, so use it sparingly. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setGravity(new Vector3f(0f,-1f,0f)) </td><td> You can change the gravity of a physics object after it was added to the physics space. </td>
|
|
|
+ <td> setKinematic(true) </td><td> A kinematic RigidBodyControl'ed entity is not affected by gravity or other forces! You write translation and rotation code in the update loop to describe the motion of physical entities. A kinematic has a mass and is solid (e.g. characters can stand on it), this means a kinematic affects other physics entities that bump into it (e.g. pushes them away). You also can attach <a href="/com/jme3/gde/core/docs/jme3/advanced/joints_and_hinges.html">joints and hinges</a> to it ("air hook"). The position of a kinematic RigidBodyControl is updated depending on its spatial's translation. <br/>
|
|
|
+By default, PhysicsControls are not kinematic.</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setCcdMotionThreshold(0.1f) </td><td> The amount of motion in 1 physics tick to trigger the continuous motion detection. </td>
|
|
|
+ <td> setCcdMotionThreshold(0.1f) </td><td> The amount of motion in 1 physics tick to trigger the continuous motion detection. Rarely used, but necessary if you need to fiddle with details. </td>
|
|
|
</tr>
|
|
|
+</table></div>
|
|
|
+<!-- EDIT3 TABLE [11266-13531] --><div><table>
|
|
|
<tr>
|
|
|
<th> CharacterControl Method </th><th> Property </th>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setFallSpeed(1f) </td><td> Fall speed (down) </td>
|
|
|
+ <td> setUpAxis(1)</td><td> CharacterControls have a fixed upward axis! This means they cannot fall over. <br/>
|
|
|
+Values: 0 = X axis , 1 = Y axis , 2 = Z axis. <br/>
|
|
|
+Default: 1, because for characters and vehicle, up is typically along the Y axis.</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setJumpSpeed(1f) </td><td> Jump speed (up) </td>
|
|
|
+ <td> setJumpSpeed(1f) </td><td> Jump speed (movement along up axis) </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setMaxSlope(1.5f) </td><td> How steep the slopes are that the character can still climb. </td>
|
|
|
+ <td> setFallSpeed(1f) </td><td> Fall speed (movement along negative up axis) </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setUpAxis(1)</td><td> 0 = X axis , 1 = Y axis , 2 = Z axis. E.g. for characters and vehicle, up is usually along the the Y axis.</td>
|
|
|
+ <td> setMaxSlope(1.5f) </td><td> How steep the slopes and steps are that the character can climb without considering them an obstacle. Higher obstacles need to be jumped. In world units. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setGravity(1f) </td><td> You can change the Gravity of a physics object after it was added to the physics space</td>
|
|
|
+ <td> setGravity(1f) </td><td> The intensity of gravity for this CharacterControl'ed entity. To change the direction of gravity for a character, modify the up axis.</td>
|
|
|
</tr>
|
|
|
</table></div>
|
|
|
-<!-- EDIT3 TABLE [10696-12109] -->
|
|
|
+<!-- EDIT4 TABLE [13533-14261] -->
|
|
|
</div>
|
|
|
|
|
|
<h3><a>Kinematic vs Dynamic vs Static</a></h3>
|
|
@@ -377,75 +390,83 @@ Static immobile obstacles (including buildings and terrains) have mass 0.0f. </t
|
|
|
|
|
|
<p>
|
|
|
|
|
|
-All physical objects…
|
|
|
+All physical entities…
|
|
|
</p>
|
|
|
<ul>
|
|
|
<li><div> must not overlap.</div>
|
|
|
</li>
|
|
|
<li><div> can detect collisions and report several values about the impact.</div>
|
|
|
</li>
|
|
|
-<li><div> can respond dynamically or statically or kinematically to collisions.</div>
|
|
|
+<li><div> can respond dynamically, or statically, or kinematically to collisions.</div>
|
|
|
</li>
|
|
|
</ul>
|
|
|
<div><table>
|
|
|
<tr>
|
|
|
- <td> Property </td><th> Static </th><th> Dynamic </th><th> Kinematic </th>
|
|
|
+ <td> Property </td><th> Static </th><th> Kinematic </th><th> Dynamic </th>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <th> Does it have a mass?</th><td>no, 0f</td><td>yes, >0f</td><td>yes, >0f (Inertia is calculated for kinematic objects you need mass to do that)</td>
|
|
|
+ <th> Examples</th><td>Immobile obstacles: Floors, walls, buildings, …</td><td>Remote-controlled entities: Airships, meteorites, doors; networked or remote-controlled NPCs; invisible "airhooks" for hinges and joints.</td><td>Interactive entities: Rolling balls, movable crates, falling pillar, space ship…</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <th> How does it move?</th><td>never</td><td>setWalkDirection(), setLinearVelocity(), applyForce(), etc</td><td>setLocalTranslation(), move()</td>
|
|
|
+ <th> Does it have a mass?</th><td>no, 0.0f</td><td>yes<sup><a href="#fn__1">1)</a></sup>, >0.0f </td><td>yes, >0.0f</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <th> Can it move and push others?</th><td>no</td><td>yes</td><td>yes</td>
|
|
|
+ <th> How does it move?</th><td>never</td><td>setLocalTranslation();</td><td>setLinearVelocity(); applyForce(); <br/>
|
|
|
+setWalkDirection(); for CharacterControl</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <th> Is is affected by forces? <br/>
|
|
|
-(Falls when it mid-air? Can be pushed by others?)</th><td>no</td><td>yes</td><td>no</td>
|
|
|
+ <th> How to place in scene?</th><td>setPhysicsLocation(); <br/>
|
|
|
+setPhysicsRotation()</td><td>setLocalTranslation(); <br/>
|
|
|
+setLocalRotation();</td><td>setPhysicsLocation(); <br/>
|
|
|
+ setPhysicsRotation()</td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <th> Can it move and push others?</th><td>no</td><td>yes</td><td>yes</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <th> Examples</th><td>Immobile obstacles: Floor, wall, buildings, …</td><td>Interactive objects: Soccer ball, movable crate, falling pillar, …</td><td>Remote-controlled objects: Airship, meteorites, networked NPCs, invisible "airhooks" for hinges and joints.</td>
|
|
|
+ <th> Is is affected by forces? <br/>
|
|
|
+(Falls when it mid-air? Can be pushed by others?)</th><td>no</td><td>no</td><td>yes</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <th> How to activate? </th><td>setMass(0f), (By default, objects are not kinematics)</td><td>setMass(1f), setKinematic(false)</td><td>setMass(1f), setKinematic(true)</td>
|
|
|
+ <th> How to activate? </th><td>setMass(0f); <br/>
|
|
|
+setKinematic(false); </td><td>setMass(1f); <br/>
|
|
|
+setKinematic(false);</td><td>setMass(1f); <br/>
|
|
|
+setKinematic(true);</td>
|
|
|
</tr>
|
|
|
</table></div>
|
|
|
-<!-- EDIT4 TABLE [12344-13135] -->
|
|
|
+<!-- EDIT5 TABLE [14499-15521] -->
|
|
|
<p>
|
|
|
-
|
|
|
-<strong>Tip:</strong> Typically, Spatials with a kinematic RigidBodyControl are moved programmatically, e.g. using setLocalTranslation() or move() in the update() loop, or by an Animation Path. You can also "hang them up in mid-air" and attach other PhysicsControls to them using <a href="/com/jme3/gde/core/docs/jme3/advanced/hinges_and_joints.html">hinges and joints</a>.
|
|
|
-
|
|
|
+<p><div>You move Spatials with a kinematic RigidBodyControl programmatically, that is by using setLocalTranslation() or move() in the update() loop, or using a <a href="/com/jme3/gde/core/docs/jme3/advanced/motionpath.html">MotionPath</a>. You can also "hang them up in mid-air" and attach other PhysicsControls to them using <a href="/com/jme3/gde/core/docs/jme3/advanced/hinges_and_joints.html">hinges and joints</a>.
|
|
|
+</div></p>
|
|
|
</p>
|
|
|
-<pre>airhook.setKinematic(true);</pre>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
-<h2><a>Forces: Moving Physical Objects</a></h2>
|
|
|
+<h2><a>Forces: Moving Physical Entities</a></h2>
|
|
|
<div>
|
|
|
|
|
|
<p>
|
|
|
|
|
|
-Use the following methods to move physics objects.
|
|
|
+Use the following methods to move physics entities.
|
|
|
</p>
|
|
|
<div><table>
|
|
|
<tr>
|
|
|
<th> PhysicsControl Method </th><th> Motion </th>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setLinearVelocity(new Vector3f(0f,0f,1f)) </td><td> Set the linear speed of this object. </td>
|
|
|
+ <td> setLinearVelocity(new Vector3f(0f,0f,1f)) </td><td> Set the linear speed of this entity. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setAngularVelocity(new Vector3f(0f,0f,1f)) </td><td> Set the rotational speed of the object; the x, y and z component are the speed of rotation around that axis. </td>
|
|
|
+ <td> setAngularVelocity(new Vector3f(0f,0f,1f)) </td><td> Set the rotational speed of the entity; the x, y and z component are the speed of rotation around that axis. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> applyCentralForce(…) </td><td> Move (push) the object once with a certain moment, expressed as a Vector3f. </td>
|
|
|
+ <td> applyCentralForce(…) </td><td> Move (push) the entity once with a certain moment, expressed as a Vector3f. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> applyForce(…) </td><td> Move (push) the object once with a certain moment, expressed as a Vector3f. Optionally, you can specify where on the object the pushing force hits. </td>
|
|
|
+ <td> applyForce(…) </td><td> Move (push) the entity once with a certain moment, expressed as a Vector3f. Optionally, you can specify where on the entity the pushing force hits. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> applyTorque(…) </td><td> Rotate (twist) the object once around its axes, expressed as a Vector3f. </td>
|
|
|
+ <td> applyTorque(…) </td><td> Rotate (twist) the entity once around its axes, expressed as a Vector3f. </td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<td> applyImpulse(…) </td><td> An idealised change of momentum. This is the kind of push that you would use on a pool billiard ball. </td>
|
|
@@ -460,10 +481,11 @@ Use the following methods to move physics objects.
|
|
|
<td>clearForces()</td><td>Cancels out all forces (force, torque) etc and stops the motion.</td>
|
|
|
</tr>
|
|
|
</table></div>
|
|
|
-<!-- EDIT5 TABLE [13584-14809] -->
|
|
|
+<!-- EDIT6 TABLE [15937-17161] -->
|
|
|
<p>
|
|
|
|
|
|
-<strong>Note:</strong> It is technically possible to position PhysicsControls using setLocalTranslation(), e.g. to place them in their start position in the scene. However you must be very careful not to cause an "impossible state" where one physical object overlaps with another! Within the game, you typically use the setters shown here exclusively.
|
|
|
+<p><div>It is technically possible to position PhysicsControls using setLocalTranslation(), e.g. to place them in their start position in the scene. However you must be very careful not to cause an "impossible state" where one physical entity overlaps with another! Within the game, you typically use the setters shown here exclusively.
|
|
|
+</div></p>
|
|
|
</p>
|
|
|
|
|
|
<p>
|
|
@@ -480,7 +502,7 @@ PhysicsControls also supports the following features:
|
|
|
<td> setCollideWithGroups() <br/>
|
|
|
setCollisionGroup() <br/>
|
|
|
addCollideWithGroup(COLLISION_GROUP_01) <br/>
|
|
|
-removeCollideWithGroup(COLLISION_GROUP_01)</td><td>Collision Groups are integer bit masks – enums are available in CollisionObject. All physics objects are by default in COLLISION_GROUP_01. Two objects collide when the collideWithGroups set of one contains, the Collision Group of the other.</td>
|
|
|
+removeCollideWithGroup(COLLISION_GROUP_01)</td><td>Collision Groups are integer bit masks – enums are available in CollisionObject. All physics entities are by default in COLLISION_GROUP_01. Two entities collide when the collideWithGroups set of one contains, the Collision Group of the other.</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<td> setDamping(float, float)</td><td>The first value is the linear threshold and the second the angular.</td>
|
|
@@ -492,10 +514,10 @@ removeCollideWithGroup(COLLISION_GROUP_01)</td><td>Collision Groups are integer
|
|
|
<td> setCcdSweptSphereRadius()</td><td>?</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td> setSleepingThreshold(float,float)</td><td>Sets the sleeping thresholds wich define when the object gets deactivated to save ressources. Low values keep the object active when it barely moves. The first value is the linear threshold and the second the angular.</td>
|
|
|
+ <td> setSleepingThreshold(float,float)</td><td>Sets the sleeping thresholds which define when the entity gets deactivated to save resources. Low values keep the entity active when it barely moves. The first value is the linear threshold and the second the angular.</td>
|
|
|
</tr>
|
|
|
</table></div>
|
|
|
-<!-- EDIT6 TABLE [15205-16200] -->
|
|
|
+<!-- EDIT7 TABLE [17570-18567] -->
|
|
|
</div>
|
|
|
|
|
|
<h2><a>Best Practices</a></h2>
|
|
@@ -517,7 +539,7 @@ removeCollideWithGroup(COLLISION_GROUP_01)</td><td>Collision Groups are integer
|
|
|
</li>
|
|
|
</ul>
|
|
|
<ul>
|
|
|
-<li><div> For large static meshes like shooter levels or terrain it is best to divide the scene model into multiple physics objects, with each its own CollisionShape. A huge city level should not be one huge mesh (model) of pavement and streets and buildings. Instead, you make individual models for buildings, for pieces of pavement, for pieces of streets, etc. Position them next to one another to form the whole city, and give each piece its own optimal CollisionShape. E.g. streets can use a fast PlaneCollisionShape if you keep them separate for buildings. Breaking the level into manageable pieces helps the engine improve performance: The less CPU-intensive <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://en.wikipedia.org/wiki/Sweep_and_prune"><param name="text" value="<html><u>broadphase</u></html>"><param name="textColor" value="blue"></object> can now filter out parts of the scene that are behind you or out of reach, and it only calculates the details of collisions for parts that are actually close to the action.</div>
|
|
|
+<li><div> For large static meshes like shooter levels or terrain it is best to divide the scene model into multiple physics entities, with each its own CollisionShape. A huge city level should not be one huge mesh (model) of pavement and streets and buildings. Instead, you make individual models for buildings, for pieces of pavement, for pieces of streets, etc. Position them next to one another to form the whole city, and give each piece its own optimal CollisionShape. E.g. streets can use a fast PlaneCollisionShape if you keep them separate for buildings. Breaking the level into manageable pieces helps the engine improve performance: The less CPU-intensive <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://en.wikipedia.org/wiki/Sweep_and_prune"><param name="text" value="<html><u>broadphase</u></html>"><param name="textColor" value="blue"></object> can now filter out parts of the scene that are behind you or out of reach, and it only calculates the details of collisions for parts that are actually close to the action.</div>
|
|
|
</li>
|
|
|
</ul>
|
|
|
<div><span>
|
|
@@ -526,5 +548,9 @@ removeCollideWithGroup(COLLISION_GROUP_01)</td><td>Collision Groups are integer
|
|
|
<a href="/wiki/doku.php/tag:control?do=showtag&tag=tag%3Acontrol">control</a>
|
|
|
</span></div>
|
|
|
|
|
|
+</div>
|
|
|
+<div>
|
|
|
+<div><sup><a href="#fnt__1">1)</a></sup>
|
|
|
+Inertia is calculated for kinematic entities, and you need mass to do that.</div>
|
|
|
</div>
|
|
|
<p><em><a href="http://jmonkeyengine.org/wiki/doku.php/jme3:advanced:physics?do=export_xhtmlbody">view online version</a></em></p>
|