_physics_controller_8h_source.html 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <title>gameplay: Main Page</title>
  7. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  8. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  9. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="search/search.js"></script>
  12. <script type="text/javascript">
  13. $(document).ready(function() { searchBox.OnSelectItem(0); });
  14. </script>
  15. </head>
  16. <body>
  17. <div id="top"><!-- do not remove this div! -->
  18. <!-- Generated by Doxygen 1.8.0 -->
  19. <script type="text/javascript">
  20. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  21. </script>
  22. <div id="navrow1" class="tabs">
  23. <ul class="tablist">
  24. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  25. <li><a href="annotated.html"><span>Classes</span></a></li>
  26. <li class="current"><a href="files.html"><span>Files</span></a></li>
  27. <li>
  28. <div id="MSearchBox" class="MSearchBoxInactive">
  29. <span class="left">
  30. <img id="MSearchSelect" src="search/mag_sel.png"
  31. onmouseover="return searchBox.OnSearchSelectShow()"
  32. onmouseout="return searchBox.OnSearchSelectHide()"
  33. alt=""/>
  34. <input type="text" id="MSearchField" value="Search" accesskey="S"
  35. onfocus="searchBox.OnSearchFieldFocus(true)"
  36. onblur="searchBox.OnSearchFieldFocus(false)"
  37. onkeyup="searchBox.OnSearchFieldChange(event)"/>
  38. </span><span class="right">
  39. <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
  40. </span>
  41. </div>
  42. </li>
  43. </ul>
  44. </div>
  45. <div id="navrow2" class="tabs2">
  46. <ul class="tablist">
  47. <li><a href="files.html"><span>File&#160;List</span></a></li>
  48. </ul>
  49. </div>
  50. </div>
  51. <!-- window showing the filter options -->
  52. <div id="MSearchSelectWindow"
  53. onmouseover="return searchBox.OnSearchSelectShow()"
  54. onmouseout="return searchBox.OnSearchSelectHide()"
  55. onkeydown="return searchBox.OnSearchSelectKey(event)">
  56. <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a></div>
  57. <!-- iframe showing the search results (closed by default) -->
  58. <div id="MSearchResultsWindow">
  59. <iframe src="javascript:void(0)" frameborder="0"
  60. name="MSearchResults" id="MSearchResults">
  61. </iframe>
  62. </div>
  63. <div class="header">
  64. <div class="headertitle">
  65. <div class="title">gameplay/src/PhysicsController.h</div> </div>
  66. </div><!--header-->
  67. <div class="contents">
  68. <div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef PHYSICSCONTROLLER_H_</span>
  69. <a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define PHYSICSCONTROLLER_H_</span>
  70. <a name="l00003"></a>00003 <span class="preprocessor"></span>
  71. <a name="l00004"></a>00004 <span class="preprocessor">#include &quot;PhysicsConstraint.h&quot;</span>
  72. <a name="l00005"></a>00005 <span class="preprocessor">#include &quot;PhysicsFixedConstraint.h&quot;</span>
  73. <a name="l00006"></a>00006 <span class="preprocessor">#include &quot;PhysicsGenericConstraint.h&quot;</span>
  74. <a name="l00007"></a>00007 <span class="preprocessor">#include &quot;PhysicsHingeConstraint.h&quot;</span>
  75. <a name="l00008"></a>00008 <span class="preprocessor">#include &quot;PhysicsSocketConstraint.h&quot;</span>
  76. <a name="l00009"></a>00009 <span class="preprocessor">#include &quot;PhysicsSpringConstraint.h&quot;</span>
  77. <a name="l00010"></a>00010 <span class="preprocessor">#include &quot;PhysicsCollisionObject.h&quot;</span>
  78. <a name="l00011"></a>00011 <span class="preprocessor">#include &quot;MeshBatch.h&quot;</span>
  79. <a name="l00012"></a>00012
  80. <a name="l00013"></a>00013 <span class="keyword">namespace </span>gameplay
  81. <a name="l00014"></a>00014 {
  82. <a name="l00015"></a>00015
  83. <a name="l00019"></a><a class="code" href="classgameplay_1_1_physics_controller.html">00019</a> <span class="keyword">class </span><a class="code" href="classgameplay_1_1_physics_controller.html">PhysicsController</a> : <span class="keyword">public</span> btCollisionWorld::ContactResultCallback
  84. <a name="l00020"></a>00020 {
  85. <a name="l00021"></a>00021 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classgameplay_1_1_game.html">Game</a>;
  86. <a name="l00022"></a>00022 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classgameplay_1_1_physics_constraint.html">PhysicsConstraint</a>;
  87. <a name="l00023"></a>00023 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>;
  88. <a name="l00024"></a>00024 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classgameplay_1_1_physics_character.html">PhysicsCharacter</a>;
  89. <a name="l00025"></a>00025 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classgameplay_1_1_physics_collision_object.html">PhysicsCollisionObject</a>;
  90. <a name="l00026"></a>00026 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classgameplay_1_1_physics_ghost_object.html">PhysicsGhostObject</a>;
  91. <a name="l00027"></a>00027
  92. <a name="l00028"></a>00028 <span class="keyword">public</span>:
  93. <a name="l00029"></a>00029
  94. <a name="l00033"></a><a class="code" href="classgameplay_1_1_physics_controller_1_1_listener.html">00033</a> <span class="keyword">class </span><a class="code" href="classgameplay_1_1_physics_controller_1_1_listener.html">Listener</a>
  95. <a name="l00034"></a>00034 {
  96. <a name="l00035"></a>00035 <span class="keyword">public</span>:
  97. <a name="l00036"></a>00036
  98. <a name="l00040"></a><a class="code" href="classgameplay_1_1_physics_controller_1_1_listener.html#a18b7daeec71d801c54838d967312a463">00040</a> <span class="keyword">enum</span> <a class="code" href="classgameplay_1_1_physics_controller_1_1_listener.html#a18b7daeec71d801c54838d967312a463">EventType</a>
  99. <a name="l00041"></a>00041 {
  100. <a name="l00045"></a><a class="code" href="classgameplay_1_1_physics_controller_1_1_listener.html#a18b7daeec71d801c54838d967312a463a317ed2f938ab1439d3a9cf75bdd00477">00045</a> <a class="code" href="classgameplay_1_1_physics_controller_1_1_listener.html#a18b7daeec71d801c54838d967312a463a317ed2f938ab1439d3a9cf75bdd00477">ACTIVATED</a>,
  101. <a name="l00046"></a>00046
  102. <a name="l00050"></a><a class="code" href="classgameplay_1_1_physics_controller_1_1_listener.html#a18b7daeec71d801c54838d967312a463afb412674f4b580a41c309eafc444a757">00050</a> <a class="code" href="classgameplay_1_1_physics_controller_1_1_listener.html#a18b7daeec71d801c54838d967312a463afb412674f4b580a41c309eafc444a757">DEACTIVATED</a>
  103. <a name="l00051"></a>00051 };
  104. <a name="l00052"></a>00052
  105. <a name="l00056"></a>00056 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classgameplay_1_1_physics_controller_1_1_listener.html#a5f10aadcd31d526306c0089fa0a7c48b">statusEvent</a>(<a class="code" href="classgameplay_1_1_physics_controller_1_1_listener.html#a18b7daeec71d801c54838d967312a463">EventType</a> type) = 0;
  106. <a name="l00057"></a>00057 };
  107. <a name="l00058"></a>00058
  108. <a name="l00062"></a><a class="code" href="structgameplay_1_1_physics_controller_1_1_hit_result.html">00062</a> <span class="keyword">struct </span><a class="code" href="structgameplay_1_1_physics_controller_1_1_hit_result.html">HitResult</a>
  109. <a name="l00063"></a>00063 {
  110. <a name="l00067"></a><a class="code" href="structgameplay_1_1_physics_controller_1_1_hit_result.html#aa7989e81df9ade10424ae7a0a2a6dd54">00067</a> <a class="code" href="classgameplay_1_1_physics_collision_object.html">PhysicsCollisionObject</a>* <a class="code" href="structgameplay_1_1_physics_controller_1_1_hit_result.html#aa7989e81df9ade10424ae7a0a2a6dd54">object</a>;
  111. <a name="l00068"></a>00068
  112. <a name="l00072"></a><a class="code" href="structgameplay_1_1_physics_controller_1_1_hit_result.html#a5c2d1e7fc5d361345b14164293dbaa7d">00072</a> <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a> <a class="code" href="structgameplay_1_1_physics_controller_1_1_hit_result.html#a5c2d1e7fc5d361345b14164293dbaa7d">point</a>;
  113. <a name="l00073"></a>00073
  114. <a name="l00077"></a><a class="code" href="structgameplay_1_1_physics_controller_1_1_hit_result.html#aeb60dd2b2787a74837dcb4f21bda2fa8">00077</a> <span class="keywordtype">float</span> <a class="code" href="structgameplay_1_1_physics_controller_1_1_hit_result.html#aeb60dd2b2787a74837dcb4f21bda2fa8">fraction</a>;
  115. <a name="l00078"></a>00078
  116. <a name="l00082"></a><a class="code" href="structgameplay_1_1_physics_controller_1_1_hit_result.html#aee488c3dc5ab66375f5fdc1c3e7f9478">00082</a> <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a> <a class="code" href="structgameplay_1_1_physics_controller_1_1_hit_result.html#aee488c3dc5ab66375f5fdc1c3e7f9478">normal</a>;
  117. <a name="l00083"></a>00083 };
  118. <a name="l00084"></a>00084
  119. <a name="l00090"></a>00090 <span class="keywordtype">void</span> <a class="code" href="classgameplay_1_1_physics_controller.html#a9c9c7800807569809a677be38873170a">addStatusListener</a>(<a class="code" href="classgameplay_1_1_physics_controller_1_1_listener.html">PhysicsController::Listener</a>* listener);
  120. <a name="l00091"></a>00091
  121. <a name="l00100"></a>00100 <a class="code" href="classgameplay_1_1_physics_fixed_constraint.html">PhysicsFixedConstraint</a>* <a class="code" href="classgameplay_1_1_physics_controller.html#a547b335f3814fb6c124e2470393812e2">createFixedConstraint</a>(<a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* a, <a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* b = NULL);
  122. <a name="l00101"></a>00101
  123. <a name="l00111"></a>00111 <a class="code" href="classgameplay_1_1_physics_generic_constraint.html">PhysicsGenericConstraint</a>* <a class="code" href="classgameplay_1_1_physics_controller.html#ad7ae74b385f8e9718cc37d57a3423583">createGenericConstraint</a>(<a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* a, <a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* b = NULL);
  124. <a name="l00112"></a>00112
  125. <a name="l00129"></a>00129 <a class="code" href="classgameplay_1_1_physics_generic_constraint.html">PhysicsGenericConstraint</a>* <a class="code" href="classgameplay_1_1_physics_controller.html#ad7ae74b385f8e9718cc37d57a3423583">createGenericConstraint</a>(<a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* a, <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_quaternion.html">Quaternion</a>&amp; rotationOffsetA, <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a>&amp; translationOffsetA,
  126. <a name="l00130"></a>00130 <a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* b = NULL, <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_quaternion.html">Quaternion</a>&amp; rotationOffsetB = <a class="code" href="classgameplay_1_1_quaternion.html">Quaternion</a>(), <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a>&amp; translationOffsetB = <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a>());
  127. <a name="l00131"></a>00131
  128. <a name="l00148"></a>00148 <a class="code" href="classgameplay_1_1_physics_hinge_constraint.html">PhysicsHingeConstraint</a>* <a class="code" href="classgameplay_1_1_physics_controller.html#aea8f1cc3f27d12c6c1cd954eb81c9cdc">createHingeConstraint</a>(<a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* a, <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_quaternion.html">Quaternion</a>&amp; rotationOffsetA, <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a>&amp; translationOffsetA,
  129. <a name="l00149"></a>00149 <a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* b = NULL, <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_quaternion.html">Quaternion</a>&amp; rotationOffsetB = <a class="code" href="classgameplay_1_1_quaternion.html">Quaternion</a>(), <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a>&amp; translationOffsetB = <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a>());
  130. <a name="l00150"></a>00150
  131. <a name="l00161"></a>00161 <a class="code" href="classgameplay_1_1_physics_socket_constraint.html">PhysicsSocketConstraint</a>* <a class="code" href="classgameplay_1_1_physics_controller.html#a8c1c19e84a2a21f9aa4f6e275cc22057">createSocketConstraint</a>(<a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* a, <a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* b = NULL);
  132. <a name="l00162"></a>00162
  133. <a name="l00175"></a>00175 <a class="code" href="classgameplay_1_1_physics_socket_constraint.html">PhysicsSocketConstraint</a>* <a class="code" href="classgameplay_1_1_physics_controller.html#a8c1c19e84a2a21f9aa4f6e275cc22057">createSocketConstraint</a>(<a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* a, <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a>&amp; translationOffsetA,
  134. <a name="l00176"></a>00176 <a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* b = NULL, <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a>&amp; translationOffsetB = <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a>());
  135. <a name="l00177"></a>00177
  136. <a name="l00188"></a>00188 <a class="code" href="classgameplay_1_1_physics_spring_constraint.html">PhysicsSpringConstraint</a>* <a class="code" href="classgameplay_1_1_physics_controller.html#a098c2ece05ee787648c15eb8098dde51">createSpringConstraint</a>(<a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* a, <a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* b);
  137. <a name="l00189"></a>00189
  138. <a name="l00206"></a>00206 <a class="code" href="classgameplay_1_1_physics_spring_constraint.html">PhysicsSpringConstraint</a>* <a class="code" href="classgameplay_1_1_physics_controller.html#a098c2ece05ee787648c15eb8098dde51">createSpringConstraint</a>(<a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* a, <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_quaternion.html">Quaternion</a>&amp; rotationOffsetA, <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a>&amp; translationOffsetA,
  139. <a name="l00207"></a>00207 <a class="code" href="classgameplay_1_1_physics_rigid_body.html">PhysicsRigidBody</a>* b, <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_quaternion.html">Quaternion</a>&amp; rotationOffsetB, <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a>&amp; translationOffsetB);
  140. <a name="l00208"></a>00208
  141. <a name="l00214"></a>00214 <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a>&amp; <a class="code" href="classgameplay_1_1_physics_controller.html#a9d38b041f052706cb0ac8b39e5283d2f">getGravity</a>() <span class="keyword">const</span>;
  142. <a name="l00215"></a>00215
  143. <a name="l00221"></a>00221 <span class="keywordtype">void</span> <a class="code" href="classgameplay_1_1_physics_controller.html#ab085ecda3423f445960150208e5ba1c9">setGravity</a>(<span class="keyword">const</span> <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a>&amp; gravity);
  144. <a name="l00222"></a>00222
  145. <a name="l00228"></a>00228 <span class="keywordtype">void</span> <a class="code" href="classgameplay_1_1_physics_controller.html#ae2089a6dababa097ef955d1105c4bd6d">drawDebug</a>(<span class="keyword">const</span> <a class="code" href="classgameplay_1_1_matrix.html">Matrix</a>&amp; viewProjection);
  146. <a name="l00229"></a>00229
  147. <a name="l00238"></a>00238 <span class="keywordtype">bool</span> <a class="code" href="classgameplay_1_1_physics_controller.html#aecbb567040146ce4003d3c3ab1ad6a0c">rayTest</a>(<span class="keyword">const</span> <a class="code" href="classgameplay_1_1_ray.html">Ray</a>&amp; ray, <span class="keywordtype">float</span> distance, <a class="code" href="structgameplay_1_1_physics_controller_1_1_hit_result.html">PhysicsController::HitResult</a>* result = NULL);
  148. <a name="l00239"></a>00239
  149. <a name="l00251"></a>00251 <span class="keywordtype">bool</span> <a class="code" href="classgameplay_1_1_physics_controller.html#ae0ef6e11ae93e4cbc871f7a9bd0eee10">sweepTest</a>(<a class="code" href="classgameplay_1_1_physics_collision_object.html">PhysicsCollisionObject</a>* <span class="keywordtype">object</span>, <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a>&amp; endPosition, <a class="code" href="structgameplay_1_1_physics_controller_1_1_hit_result.html">PhysicsController::HitResult</a>* result = NULL);
  150. <a name="l00252"></a>00252
  151. <a name="l00253"></a>00253 <span class="keyword">protected</span>:
  152. <a name="l00254"></a>00254
  153. <a name="l00258"></a>00258 btScalar <a class="code" href="classgameplay_1_1_physics_controller.html#a44243d5391f18bc002ed35a9dade2544">addSingleResult</a>(btManifoldPoint&amp; cp, <span class="keyword">const</span> btCollisionObject* a, <span class="keywordtype">int</span> partIdA, <span class="keywordtype">int</span> indexA, <span class="keyword">const</span> btCollisionObject* b, <span class="keywordtype">int</span> partIdB, <span class="keywordtype">int</span> indexB);
  154. <a name="l00259"></a>00259
  155. <a name="l00260"></a>00260 <span class="keyword">private</span>:
  156. <a name="l00261"></a>00261
  157. <a name="l00262"></a>00262 <span class="comment">// Internal constants for the collision status cache.</span>
  158. <a name="l00263"></a>00263 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> DIRTY;
  159. <a name="l00264"></a>00264 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> COLLISION;
  160. <a name="l00265"></a>00265 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> REGISTERED;
  161. <a name="l00266"></a>00266 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> REMOVE;
  162. <a name="l00267"></a>00267
  163. <a name="l00268"></a>00268 <span class="comment">// Represents the collision listeners and status for a given collision pair (used by the collision status cache).</span>
  164. <a name="l00269"></a>00269 <span class="keyword">struct </span>CollisionInfo
  165. <a name="l00270"></a>00270 {
  166. <a name="l00271"></a>00271 CollisionInfo() : _status(0) { }
  167. <a name="l00272"></a>00272
  168. <a name="l00273"></a>00273 std::vector&lt;PhysicsCollisionObject::CollisionListener*&gt; _listeners;
  169. <a name="l00274"></a>00274 <span class="keywordtype">int</span> _status;
  170. <a name="l00275"></a>00275 };
  171. <a name="l00276"></a>00276
  172. <a name="l00280"></a>00280 PhysicsController();
  173. <a name="l00281"></a>00281
  174. <a name="l00285"></a>00285 ~PhysicsController();
  175. <a name="l00286"></a>00286
  176. <a name="l00290"></a>00290 <span class="keywordtype">void</span> initialize();
  177. <a name="l00291"></a>00291
  178. <a name="l00295"></a>00295 <span class="keywordtype">void</span> finalize();
  179. <a name="l00296"></a>00296
  180. <a name="l00300"></a>00300 <span class="keywordtype">void</span> pause();
  181. <a name="l00301"></a>00301
  182. <a name="l00305"></a>00305 <span class="keywordtype">void</span> resume();
  183. <a name="l00306"></a>00306
  184. <a name="l00310"></a>00310 <span class="keywordtype">void</span> update(<span class="keywordtype">long</span> elapsedTime);
  185. <a name="l00311"></a>00311
  186. <a name="l00312"></a>00312 <span class="comment">// Adds the given collision listener for the two given collision objects.</span>
  187. <a name="l00313"></a>00313 <span class="keywordtype">void</span> addCollisionListener(PhysicsCollisionObject::CollisionListener* listener, PhysicsCollisionObject* objectA, PhysicsCollisionObject* objectB);
  188. <a name="l00314"></a>00314
  189. <a name="l00315"></a>00315 <span class="comment">// Removes the given collision listener.</span>
  190. <a name="l00316"></a>00316 <span class="keywordtype">void</span> removeCollisionListener(PhysicsCollisionObject::CollisionListener* listener, PhysicsCollisionObject* objectA, PhysicsCollisionObject* objectB);
  191. <a name="l00317"></a>00317
  192. <a name="l00318"></a>00318 <span class="comment">// Adds the given collision object to the world.</span>
  193. <a name="l00319"></a>00319 <span class="keywordtype">void</span> addCollisionObject(PhysicsCollisionObject* <span class="keywordtype">object</span>);
  194. <a name="l00320"></a>00320
  195. <a name="l00321"></a>00321 <span class="comment">// Removes the given collision object from the simulated physics world.</span>
  196. <a name="l00322"></a>00322 <span class="keywordtype">void</span> removeCollisionObject(PhysicsCollisionObject* <span class="keywordtype">object</span>);
  197. <a name="l00323"></a>00323
  198. <a name="l00324"></a>00324 <span class="comment">// Gets the corresponding GamePlay object for the given Bullet object.</span>
  199. <a name="l00325"></a>00325 PhysicsCollisionObject* getCollisionObject(<span class="keyword">const</span> btCollisionObject* collisionObject) <span class="keyword">const</span>;
  200. <a name="l00326"></a>00326
  201. <a name="l00327"></a>00327 <span class="comment">// Creates a collision shape for the given node and gameplay shape definition.</span>
  202. <a name="l00328"></a>00328 <span class="comment">// Populates &#39;centerOfMassOffset&#39; with the correct calculated center of mass offset.</span>
  203. <a name="l00329"></a>00329 PhysicsCollisionShape* createShape(Node* node, <span class="keyword">const</span> PhysicsCollisionShape::Definition&amp; shape, Vector3* centerOfMassOffset);
  204. <a name="l00330"></a>00330
  205. <a name="l00331"></a>00331 <span class="comment">// Creates a box collision shape.</span>
  206. <a name="l00332"></a>00332 PhysicsCollisionShape* createBox(<span class="keyword">const</span> Vector3&amp; extents, <span class="keyword">const</span> Vector3&amp; scale);
  207. <a name="l00333"></a>00333
  208. <a name="l00334"></a>00334 <span class="comment">// Creates a sphere collision shape.</span>
  209. <a name="l00335"></a>00335 PhysicsCollisionShape* createSphere(<span class="keywordtype">float</span> radius, <span class="keyword">const</span> Vector3&amp; scale);
  210. <a name="l00336"></a>00336
  211. <a name="l00337"></a>00337 <span class="comment">// Creates a capsule collision shape.</span>
  212. <a name="l00338"></a>00338 PhysicsCollisionShape* createCapsule(<span class="keywordtype">float</span> radius, <span class="keywordtype">float</span> height, <span class="keyword">const</span> Vector3&amp; scale);
  213. <a name="l00339"></a>00339
  214. <a name="l00340"></a>00340 <span class="comment">// Creates a heightfield collision shape.</span>
  215. <a name="l00341"></a>00341 PhysicsCollisionShape* createHeightfield(Node* node, Image* image, Vector3* centerOfMassOffset);
  216. <a name="l00342"></a>00342
  217. <a name="l00343"></a>00343 <span class="comment">// Creates a triangle mesh collision shape.</span>
  218. <a name="l00344"></a>00344 PhysicsCollisionShape* createMesh(Mesh* mesh, <span class="keyword">const</span> Vector3&amp; scale);
  219. <a name="l00345"></a>00345
  220. <a name="l00346"></a>00346 <span class="comment">// Destroys a collision shape created through PhysicsController</span>
  221. <a name="l00347"></a>00347 <span class="keywordtype">void</span> destroyShape(PhysicsCollisionShape* shape);
  222. <a name="l00348"></a>00348
  223. <a name="l00349"></a>00349 <span class="comment">// Helper function for calculating heights from heightmap (image) or heightfield data.</span>
  224. <a name="l00350"></a>00350 <span class="keyword">static</span> <span class="keywordtype">float</span> calculateHeight(<span class="keywordtype">float</span>* data, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> width, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> height, <span class="keywordtype">float</span> x, <span class="keywordtype">float</span> y);
  225. <a name="l00351"></a>00351
  226. <a name="l00352"></a>00352 <span class="comment">// Sets up the given constraint for the given two rigid bodies.</span>
  227. <a name="l00353"></a>00353 <span class="keywordtype">void</span> addConstraint(PhysicsRigidBody* a, PhysicsRigidBody* b, PhysicsConstraint* constraint);
  228. <a name="l00354"></a>00354
  229. <a name="l00355"></a>00355 <span class="comment">// Checks whether constraints are supported for the given rigid bodies and emits a warning if they are not.</span>
  230. <a name="l00356"></a>00356 <span class="keywordtype">bool</span> checkConstraintRigidBodies(PhysicsRigidBody* a, PhysicsRigidBody* b);
  231. <a name="l00357"></a>00357
  232. <a name="l00358"></a>00358 <span class="comment">// Removes the given constraint from the simulated physics world.</span>
  233. <a name="l00359"></a>00359 <span class="keywordtype">void</span> removeConstraint(PhysicsConstraint* constraint);
  234. <a name="l00360"></a>00360
  235. <a name="l00361"></a>00361 <span class="comment">// Draws Bullet debug information.</span>
  236. <a name="l00362"></a>00362 <span class="keyword">class </span>DebugDrawer : <span class="keyword">public</span> btIDebugDraw
  237. <a name="l00363"></a>00363 {
  238. <a name="l00364"></a>00364 <span class="keyword">public</span>:
  239. <a name="l00365"></a>00365
  240. <a name="l00369"></a><a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html">00369</a> <span class="keyword">struct </span><a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html">DebugVertex</a>
  241. <a name="l00370"></a>00370 {
  242. <a name="l00374"></a><a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html#a968be415f56ff18991749d7561d6bbc1">00374</a> <span class="keywordtype">float</span> <a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html#a968be415f56ff18991749d7561d6bbc1">x</a>;
  243. <a name="l00375"></a>00375
  244. <a name="l00379"></a><a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html#a0c48d8f78b370249169ff4e397c79ba7">00379</a> <span class="keywordtype">float</span> <a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html#a0c48d8f78b370249169ff4e397c79ba7">y</a>;
  245. <a name="l00380"></a>00380
  246. <a name="l00384"></a><a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html#a5a23e5aa2ffd66417b961995cba48f47">00384</a> <span class="keywordtype">float</span> <a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html#a5a23e5aa2ffd66417b961995cba48f47">z</a>;
  247. <a name="l00385"></a>00385
  248. <a name="l00389"></a><a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html#a47df31c095ed857c29bf9d6ea88c7765">00389</a> <span class="keywordtype">float</span> <a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html#a47df31c095ed857c29bf9d6ea88c7765">r</a>;
  249. <a name="l00390"></a>00390
  250. <a name="l00394"></a><a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html#acbc3a844f45670e7a9d1bfcfdc84e6e0">00394</a> <span class="keywordtype">float</span> <a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html#acbc3a844f45670e7a9d1bfcfdc84e6e0">g</a>;
  251. <a name="l00395"></a>00395
  252. <a name="l00399"></a><a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html#a2689be05ac4b5a5faddaa097510e75da">00399</a> <span class="keywordtype">float</span> <a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html#a2689be05ac4b5a5faddaa097510e75da">b</a>;
  253. <a name="l00400"></a>00400
  254. <a name="l00404"></a><a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html#a764182ac9b3e7db246dd1d0d8eeda046">00404</a> <span class="keywordtype">float</span> <a class="code" href="structgameplay_1_1_physics_controller_1_1_debug_drawer_1_1_debug_vertex.html#a764182ac9b3e7db246dd1d0d8eeda046">a</a>;
  255. <a name="l00405"></a>00405 };
  256. <a name="l00406"></a>00406
  257. <a name="l00410"></a>00410 DebugDrawer();
  258. <a name="l00411"></a>00411
  259. <a name="l00415"></a>00415 ~DebugDrawer();
  260. <a name="l00416"></a>00416
  261. <a name="l00417"></a>00417 <span class="keywordtype">void</span> begin(<span class="keyword">const</span> <a class="code" href="classgameplay_1_1_matrix.html">Matrix</a>&amp; viewProjection);
  262. <a name="l00418"></a>00418 <span class="keywordtype">void</span> end();
  263. <a name="l00419"></a>00419
  264. <a name="l00420"></a>00420 <span class="comment">// Overridden Bullet functions from btIDebugDraw.</span>
  265. <a name="l00421"></a>00421 <span class="keywordtype">void</span> drawLine(<span class="keyword">const</span> btVector3&amp; from, <span class="keyword">const</span> btVector3&amp; to, <span class="keyword">const</span> btVector3&amp; fromColor, <span class="keyword">const</span> btVector3&amp; toColor);
  266. <a name="l00422"></a>00422 <span class="keywordtype">void</span> drawLine(<span class="keyword">const</span> btVector3&amp; from, <span class="keyword">const</span> btVector3&amp; to, <span class="keyword">const</span> btVector3&amp; color);
  267. <a name="l00423"></a>00423 <span class="keywordtype">void</span> drawContactPoint(<span class="keyword">const</span> btVector3&amp; pointOnB, <span class="keyword">const</span> btVector3&amp; normalOnB, btScalar distance, <span class="keywordtype">int</span> lifeTime, <span class="keyword">const</span> btVector3&amp; color);
  268. <a name="l00424"></a>00424 <span class="keywordtype">void</span> reportErrorWarning(<span class="keyword">const</span> <span class="keywordtype">char</span>* warningString);
  269. <a name="l00425"></a>00425 <span class="keywordtype">void</span> draw3dText(<span class="keyword">const</span> btVector3&amp; location, <span class="keyword">const</span> <span class="keywordtype">char</span>* textString);
  270. <a name="l00426"></a>00426 <span class="keywordtype">void</span> setDebugMode(<span class="keywordtype">int</span> mode);
  271. <a name="l00427"></a>00427 <span class="keywordtype">int</span> getDebugMode() <span class="keyword">const</span>;
  272. <a name="l00428"></a>00428
  273. <a name="l00429"></a>00429 <span class="keyword">private</span>:
  274. <a name="l00430"></a>00430
  275. <a name="l00431"></a>00431 <span class="keywordtype">int</span> _mode;
  276. <a name="l00432"></a>00432 <span class="keyword">const</span> <a class="code" href="classgameplay_1_1_matrix.html">Matrix</a>* _viewProjection;
  277. <a name="l00433"></a>00433 <a class="code" href="classgameplay_1_1_mesh_batch.html">MeshBatch</a>* _meshBatch;
  278. <a name="l00434"></a>00434 };
  279. <a name="l00435"></a>00435
  280. <a name="l00436"></a>00436 btDefaultCollisionConfiguration* _collisionConfiguration;
  281. <a name="l00437"></a>00437 btCollisionDispatcher* _dispatcher;
  282. <a name="l00438"></a>00438 btBroadphaseInterface* _overlappingPairCache;
  283. <a name="l00439"></a>00439 btSequentialImpulseConstraintSolver* _solver;
  284. <a name="l00440"></a>00440 btDynamicsWorld* _world;
  285. <a name="l00441"></a>00441 btGhostPairCallback* _ghostPairCallback;
  286. <a name="l00442"></a>00442 std::vector&lt;PhysicsCollisionShape*&gt; _shapes;
  287. <a name="l00443"></a>00443 DebugDrawer* _debugDrawer;
  288. <a name="l00444"></a>00444 <a class="code" href="classgameplay_1_1_physics_controller_1_1_listener.html#a18b7daeec71d801c54838d967312a463">Listener::EventType</a> _status;
  289. <a name="l00445"></a>00445 std::vector&lt;Listener*&gt;* _listeners;
  290. <a name="l00446"></a>00446 <a class="code" href="classgameplay_1_1_vector3.html">Vector3</a> _gravity;
  291. <a name="l00447"></a>00447 std::map&lt;PhysicsCollisionObject::CollisionPair, CollisionInfo&gt; _collisionStatus;
  292. <a name="l00448"></a>00448
  293. <a name="l00449"></a>00449 };
  294. <a name="l00450"></a>00450
  295. <a name="l00451"></a>00451 }
  296. <a name="l00452"></a>00452
  297. <a name="l00453"></a>00453 <span class="preprocessor">#endif</span>
  298. </pre></div></div><!-- contents -->
  299. <hr class="footer"/><address class="footer"><small>
  300. Generated on Fri May 18 2012 12:10:37 for gameplay by &#160;<a href="http://www.doxygen.org/index.html">
  301. <img class="footer" src="doxygen.png" alt="doxygen"/>
  302. </a> 1.8.0
  303. </small></address>
  304. </body>
  305. </html>