356 lines
16 KiB
HTML
356 lines
16 KiB
HTML
|
|
|
|
<!DOCTYPE html>
|
|
<!--[if IE 8]><html class="no-js lt-ie9" lang="" > <![endif]-->
|
|
<!--[if gt IE 8]><!--> <html class="no-js" lang="" > <!--<![endif]-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
|
<title>Rigid Body Overview — NVIDIA PhysX SDK 4.1 Documentation</title>
|
|
|
|
|
|
|
|
<link rel="shortcut icon" href="_static/images/favicon.ico"/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
<link rel="stylesheet" href="../_static/breathe.css" type="text/css" />
|
|
<link rel="next" title="Rigid Body Collision" href="RigidBodyCollision.html" />
|
|
<link rel="prev" title="Geometry" href="Geometry.html" />
|
|
<link href="../_static/css/nvidia_theme.css" rel="stylesheet" type="text/css">
|
|
|
|
|
|
<style>
|
|
.wy-nav-content::before {
|
|
content: "PhysX 4.1 SDK Guide";
|
|
}
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<script src="../_static/js/modernizr.min.js"></script>
|
|
|
|
</head>
|
|
|
|
<body class="wy-body-for-nav">
|
|
|
|
|
|
<div class="wy-grid-for-nav">
|
|
|
|
|
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
|
<div class="wy-side-scroll">
|
|
<div class="wy-side-nav-search">
|
|
|
|
|
|
|
|
<a href="../Index.html" class="icon icon-home"> Python
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
<div role="search">
|
|
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
|
<input type="text" name="q" placeholder="Search docs" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ul class="current">
|
|
<li class="toctree-l1 current"><a class="reference internal" href="Index.html">User's Guide</a><ul class="current">
|
|
<li class="toctree-l2"><a class="reference internal" href="License.html">PhysX License</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="Introduction.html">Welcome to PhysX</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="HelloWorld.html">Snippets</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="BuildingWithPhysX.html">Building with PhysX</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="API.html">The PhysX API</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="Startup.html">Startup and Shutdown</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="Threading.html">Threading</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="Geometry.html">Geometry</a></li>
|
|
<li class="toctree-l2 current"><a class="current reference internal" href="">Rigid Body Overview</a><ul>
|
|
<li class="toctree-l3"><a class="reference internal" href="#introduction">Introduction</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#rigid-body-object-model">Rigid Body Object Model</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#the-simulation-loop">The Simulation Loop</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l2"><a class="reference internal" href="RigidBodyCollision.html">Rigid Body Collision</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="RigidBodyDynamics.html">Rigid Body Dynamics</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="Simulation.html">Simulation</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="AdvancedCollisionDetection.html">Advanced Collision Detection</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="Joints.html">Joints</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="Articulations.html">Articulations</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="Articulations.html#maximal-coordinate-and-reduced-articulations">Maximal Coordinate and Reduced Articulations</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="Articulations.html#maximal-coordinate-articulations">Maximal Coordinate Articulations</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="Articulations.html#reduced-coordinate-articulations">Reduced Coordinate Articulations</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="OriginShift.html">Scene Origin</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="GPURigidBodies.html">GPU Rigid Bodies</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="GeometryQueries.html">Geometry Queries</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="SceneQueries.html">Scene Queries</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="Vehicles.html">Vehicles</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="CharacterControllers.html">Character Controllers</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="DebugVisualization.html">Debug Visualization</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="VisualDebugger.html">PhysX Visual Debugger (PVD)</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="Statistics.html">Simulation Statistics</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="Serialization.html">Serialization</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="ExtendingSerialization.html">Extending Serialization</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="BestPractices.html">Best Practices Guide</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="MigrationFrom28.html">Migrating From PhysX SDK 2.x to 3.x</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="MigrationTo33.html">Migrating From PhysX SDK 3.2 to 3.3</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="MigrationTo34.html">Migrating From PhysX SDK 3.3 to 3.4</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="MigrationTo40.html">Migrating From PhysX SDK 3.4 to 4.0</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
|
|
|
|
|
<nav class="wy-nav-top" aria-label="top navigation">
|
|
|
|
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
|
<a href="../Index.html">Python</a>
|
|
|
|
</nav>
|
|
|
|
|
|
<div class="wy-nav-content">
|
|
|
|
<div class="rst-content">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div role="navigation" aria-label="breadcrumbs navigation">
|
|
|
|
<ul class="wy-breadcrumbs">
|
|
|
|
<li><a href="../Index.html">Docs</a> »</li>
|
|
|
|
<li><a href="Index.html">User's Guide</a> »</li>
|
|
|
|
<li>Rigid Body Overview</li>
|
|
|
|
|
|
<li class="wy-breadcrumbs-aside">
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
<hr/>
|
|
</div>
|
|
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
|
<div itemprop="articleBody">
|
|
|
|
<div class="section" id="rigid-body-overview">
|
|
<span id="rigidbodyoverview"></span><h1>Rigid Body Overview<a class="headerlink" href="#rigid-body-overview" title="Permalink to this headline">¶</a></h1>
|
|
<div class="section" id="introduction">
|
|
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
|
|
<p>This chapter will introduce the fundamentals of simulating rigid body dynamics using the NVIDIA PhysX engine.</p>
|
|
</div>
|
|
<div class="section" id="rigid-body-object-model">
|
|
<h2>Rigid Body Object Model<a class="headerlink" href="#rigid-body-object-model" title="Permalink to this headline">¶</a></h2>
|
|
<p>PhysX uses a hierarchical rigid body object/actor model, which looks like this:</p>
|
|
<img alt="../_images/ObjectModel.png" src="../_images/ObjectModel.png" />
|
|
<table border="1" class="docutils">
|
|
<colgroup>
|
|
<col width="12%" />
|
|
<col width="16%" />
|
|
<col width="72%" />
|
|
</colgroup>
|
|
<thead valign="bottom">
|
|
<tr class="row-odd"><th class="head">Class</th>
|
|
<th class="head">Extends</th>
|
|
<th class="head">Functionality</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody valign="top">
|
|
<tr class="row-even"><td><em>PxBase</em></td>
|
|
<td>N/A</td>
|
|
<td>Reflection/querying object types.</td>
|
|
</tr>
|
|
<tr class="row-odd"><td><em>PxActor</em></td>
|
|
<td>PxBase</td>
|
|
<td>Actor name, actor flags, dominance, clients, aggregates, query world bounds.</td>
|
|
</tr>
|
|
<tr class="row-even"><td><em>PxRigidActor</em></td>
|
|
<td>PxActor</td>
|
|
<td>Shapes and transforms.</td>
|
|
</tr>
|
|
<tr class="row-odd"><td><em>PxRigidBody</em></td>
|
|
<td>PxRigidActor</td>
|
|
<td>Mass, inertia, velocities, body flags.</td>
|
|
</tr>
|
|
<tr class="row-even"><td><em>PxRigidStatic</em></td>
|
|
<td>PxRigidActor</td>
|
|
<td>Interface for static body in the scene. This kind of body has implicit infinite mass/inertia.</td>
|
|
</tr>
|
|
<tr class="row-odd"><td><em>PxRigidDynamic</em></td>
|
|
<td>PxRigidBody</td>
|
|
<td>Interface for dynamic rigid body in the scene. Introduces support for kinematic targets and object sleeping.</td>
|
|
</tr>
|
|
<tr class="row-even"><td><em>PxArticulationLink</em></td>
|
|
<td>PxRigidBody</td>
|
|
<td>Interface for a dynamic rigid body link in a PxArticulation. Introduces support for querying the articulation and adjacent links.</td>
|
|
</tr>
|
|
<tr class="row-odd"><td><em>PxArticulation</em></td>
|
|
<td>PxBase</td>
|
|
<td>Defines interface for a PxArticulation. Effectively a contained referencing multiple PxArticualtionLink rigid bodies.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>The following diagram shows the relationship between the main types involved in the rigid body pipeline:</p>
|
|
<img alt="../_images/RigidBodyOverview.PNG" src="../_images/RigidBodyOverview.PNG" />
|
|
</div>
|
|
<div class="section" id="the-simulation-loop">
|
|
<h2>The Simulation Loop<a class="headerlink" href="#the-simulation-loop" title="Permalink to this headline">¶</a></h2>
|
|
<p>Now use the method PxScene::simulate() to advance the world forward in time. Here is simplified code from the samples' fixed stepper class:</p>
|
|
<div class="highlight-c++"><div class="highlight"><pre><span class="n">mAccumulator</span> <span class="o">=</span> <span class="mf">0.0f</span><span class="p">;</span>
|
|
<span class="n">mStepSize</span> <span class="o">=</span> <span class="mf">1.0f</span> <span class="o">/</span> <span class="mf">60.0f</span><span class="p">;</span>
|
|
|
|
<span class="k">virtual</span> <span class="kt">bool</span> <span class="nf">advance</span><span class="p">(</span><span class="n">PxReal</span> <span class="n">dt</span><span class="p">)</span>
|
|
<span class="p">{</span>
|
|
<span class="n">mAccumulator</span> <span class="o">+=</span> <span class="n">dt</span><span class="p">;</span>
|
|
<span class="k">if</span><span class="p">(</span><span class="n">mAccumulator</span> <span class="o"><</span> <span class="n">mStepSize</span><span class="p">)</span>
|
|
<span class="k">return</span> <span class="nb">false</span><span class="p">;</span>
|
|
|
|
<span class="n">mAccumulator</span> <span class="o">-=</span> <span class="n">mStepSize</span><span class="p">;</span>
|
|
|
|
<span class="n">mScene</span><span class="o">-></span><span class="n">simulate</span><span class="p">(</span><span class="n">mStepSize</span><span class="p">);</span>
|
|
<span class="k">return</span> <span class="nb">true</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>This is called from the sample framework whenever the app is done with processing events and is starting to idle. It accumulates elapsed real time until it is greater than a sixtieth of a second, and then calls simulate(), which moves all objects in the scene forward by that interval. This is probably the simplest of very many different ways to deal with time when stepping the simulation forward.</p>
|
|
<p>To allow the simulation to finish and return the results, simply call:</p>
|
|
<div class="highlight-c++"><div class="highlight"><pre><span class="n">mScene</span><span class="o">-></span><span class="n">fetchResults</span><span class="p">(</span><span class="nb">true</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>True indicates that the simulation should block until it is finished, so that on return the results are guaranteed to be available. When fetchResults completes, any simulation event callback functions that you defined will also be called. See the chapter <a class="reference internal" href="Simulation.html#callbacks"><em>Callback Sequence</em></a>.</p>
|
|
<p>It is possible to read and write from the scene during simulation. The samples take advantage of this to perform rendering work in parallel with physics. Until fetchResults() returns, the results of the current simulation step are not available. So running rendering in parallel with simulation renders the actors as they were when simulate() was called. After fetchResults() returns, all these functions will return the new, post-simulate state. See the chapter <a class="reference internal" href="Threading.html#threading"><em>Threading</em></a> for more details about reading and writing while the simulation is running.</p>
|
|
<p>For the human eye to perceive animated motion as smooth, use at least twenty discrete frames per second, with each frame corresponding to a physics time step. To have smooth, realistic simulation of more complex physical scenes, use at least fifty frames per second.</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">If you are making a real-time interactive simulation, you may be tempted to take different sized time steps which correspond to the amount of real time that has elapsed since the last simulation frame. Be very careful if you do this, rather than taking constant-sized time steps: The simulation code is sensitive to both very small and large time steps, and also to too much variation between time steps. In these cases it will likely produce jittery simulation.</p>
|
|
</div>
|
|
<p>See <a class="reference internal" href="Simulation.html#simulation-memory"><em>Simulation memory</em></a> for details of how memory is used in simulation.</p>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<footer>
|
|
|
|
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
|
|
|
<a href="RigidBodyCollision.html" class="btn btn-neutral float-right" title="Rigid Body Collision" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
|
|
|
|
|
|
<a href="Geometry.html" class="btn btn-neutral" title="Geometry" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
|
|
|
</div>
|
|
|
|
|
|
<hr/>
|
|
|
|
<div role="contentinfo">
|
|
<p>
|
|
© Copyright 2008-2021 NVIDIA Corporation, 2788 San Tomas Expressway, Santa Clara, CA 95051 U.S.A. All rights reserved
|
|
|
|
</p>
|
|
</div>
|
|
|
|
</footer>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT:'../',
|
|
VERSION:'4.1',
|
|
LANGUAGE:'',
|
|
COLLAPSE_INDEX:false,
|
|
FILE_SUFFIX:'.html',
|
|
HAS_SOURCE: true,
|
|
SOURCELINK_SUFFIX: ''
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript" src="../_static/js/theme.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
jQuery(function () {
|
|
SphinxRtdTheme.Navigation.enable(false);
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html> |