2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
16 #include "btBulletDynamicsCommon.h"
17 #include "ConcaveDemo.h"
20 #include "LinearMath/btDefaultMotionState.h"
21 #include "LinearMath/btIDebugDraw.h"
22 #include "LinearMath/btQuickprof.h"
23 #include "LinearMath/btDefaultMotionState.h"
24 #include "BulletCollision/Gimpact/btGImpactShape.h"
25 #include "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h"
26 #include "GLDebugFont.h"
30 #include "GLDebugDrawer.h"
32 #include "GL_ShapeDrawer.h"
33 #include "GlutStuff.h"
36 GLDebugDrawer debugDrawer1;
38 //***************************THE FAMOUS BUNNY TRIMESH********************************************//
41 const int NUM_TRIANGLES =902;
42 const int NUM_VERTICES = 453;
43 const int NUM_INDICES = NUM_TRIANGLES * 3;
46 REAL gVertices[NUM_VERTICES * 3] = {
47 REAL(-0.334392), REAL(0.133007), REAL(0.062259),
48 REAL(-0.350189), REAL(0.150354), REAL(-0.147769),
49 REAL(-0.234201), REAL(0.343811), REAL(-0.174307),
50 REAL(-0.200259), REAL(0.285207), REAL(0.093749),
51 REAL(0.003520), REAL(0.475208), REAL(-0.159365),
52 REAL(0.001856), REAL(0.419203), REAL(0.098582),
53 REAL(-0.252802), REAL(0.093666), REAL(0.237538),
54 REAL(-0.162901), REAL(0.237984), REAL(0.206905),
55 REAL(0.000865), REAL(0.318141), REAL(0.235370),
56 REAL(-0.414624), REAL(0.164083), REAL(-0.278254),
57 REAL(-0.262213), REAL(0.357334), REAL(-0.293246),
58 REAL(0.004628), REAL(0.482694), REAL(-0.338626),
59 REAL(-0.402162), REAL(0.133528), REAL(-0.443247),
60 REAL(-0.243781), REAL(0.324275), REAL(-0.436763),
61 REAL(0.005293), REAL(0.437592), REAL(-0.458332),
62 REAL(-0.339884), REAL(-0.041150), REAL(-0.668211),
63 REAL(-0.248382), REAL(0.255825), REAL(-0.627493),
64 REAL(0.006261), REAL(0.376103), REAL(-0.631506),
65 REAL(-0.216201), REAL(-0.126776), REAL(-0.886936),
66 REAL(-0.171075), REAL(0.011544), REAL(-0.881386),
67 REAL(-0.181074), REAL(0.098223), REAL(-0.814779),
68 REAL(-0.119891), REAL(0.218786), REAL(-0.760153),
69 REAL(-0.078895), REAL(0.276780), REAL(-0.739281),
70 REAL(0.006801), REAL(0.310959), REAL(-0.735661),
71 REAL(-0.168842), REAL(0.102387), REAL(-0.920381),
72 REAL(-0.104072), REAL(0.177278), REAL(-0.952530),
73 REAL(-0.129704), REAL(0.211848), REAL(-0.836678),
74 REAL(-0.099875), REAL(0.310931), REAL(-0.799381),
75 REAL(0.007237), REAL(0.361687), REAL(-0.794439),
76 REAL(-0.077913), REAL(0.258753), REAL(-0.921640),
77 REAL(0.007957), REAL(0.282241), REAL(-0.931680),
78 REAL(-0.252222), REAL(-0.550401), REAL(-0.557810),
79 REAL(-0.267633), REAL(-0.603419), REAL(-0.655209),
80 REAL(-0.446838), REAL(-0.118517), REAL(-0.466159),
81 REAL(-0.459488), REAL(-0.093017), REAL(-0.311341),
82 REAL(-0.370645), REAL(-0.100108), REAL(-0.159454),
83 REAL(-0.371984), REAL(-0.091991), REAL(-0.011044),
84 REAL(-0.328945), REAL(-0.098269), REAL(0.088659),
85 REAL(-0.282452), REAL(-0.018862), REAL(0.311501),
86 REAL(-0.352403), REAL(-0.131341), REAL(0.144902),
87 REAL(-0.364126), REAL(-0.200299), REAL(0.202388),
88 REAL(-0.283965), REAL(-0.231869), REAL(0.023668),
89 REAL(-0.298943), REAL(-0.155218), REAL(0.369716),
90 REAL(-0.293787), REAL(-0.121856), REAL(0.419097),
91 REAL(-0.290163), REAL(-0.290797), REAL(0.107824),
92 REAL(-0.264165), REAL(-0.272849), REAL(0.036347),
93 REAL(-0.228567), REAL(-0.372573), REAL(0.290309),
94 REAL(-0.190431), REAL(-0.286997), REAL(0.421917),
95 REAL(-0.191039), REAL(-0.240973), REAL(0.507118),
96 REAL(-0.287272), REAL(-0.276431), REAL(-0.065444),
97 REAL(-0.295675), REAL(-0.280818), REAL(-0.174200),
98 REAL(-0.399537), REAL(-0.313131), REAL(-0.376167),
99 REAL(-0.392666), REAL(-0.488581), REAL(-0.427494),
100 REAL(-0.331669), REAL(-0.570185), REAL(-0.466054),
101 REAL(-0.282290), REAL(-0.618140), REAL(-0.589220),
102 REAL(-0.374238), REAL(-0.594882), REAL(-0.323298),
103 REAL(-0.381071), REAL(-0.629723), REAL(-0.350777),
104 REAL(-0.382112), REAL(-0.624060), REAL(-0.221577),
105 REAL(-0.272701), REAL(-0.566522), REAL(0.259157),
106 REAL(-0.256702), REAL(-0.663406), REAL(0.286079),
107 REAL(-0.280948), REAL(-0.428359), REAL(0.055790),
108 REAL(-0.184974), REAL(-0.508894), REAL(0.326265),
109 REAL(-0.279971), REAL(-0.526918), REAL(0.395319),
110 REAL(-0.282599), REAL(-0.663393), REAL(0.412411),
111 REAL(-0.188329), REAL(-0.475093), REAL(0.417954),
112 REAL(-0.263384), REAL(-0.663396), REAL(0.466604),
113 REAL(-0.209063), REAL(-0.663393), REAL(0.509344),
114 REAL(-0.002044), REAL(-0.319624), REAL(0.553078),
115 REAL(-0.001266), REAL(-0.371260), REAL(0.413296),
116 REAL(-0.219753), REAL(-0.339762), REAL(-0.040921),
117 REAL(-0.256986), REAL(-0.282511), REAL(-0.006349),
118 REAL(-0.271706), REAL(-0.260881), REAL(0.001764),
119 REAL(-0.091191), REAL(-0.419184), REAL(-0.045912),
120 REAL(-0.114944), REAL(-0.429752), REAL(-0.124739),
121 REAL(-0.113970), REAL(-0.382987), REAL(-0.188540),
122 REAL(-0.243012), REAL(-0.464942), REAL(-0.242850),
123 REAL(-0.314815), REAL(-0.505402), REAL(-0.324768),
124 REAL(0.002774), REAL(-0.437526), REAL(-0.262766),
125 REAL(-0.072625), REAL(-0.417748), REAL(-0.221440),
126 REAL(-0.160112), REAL(-0.476932), REAL(-0.293450),
127 REAL(0.003859), REAL(-0.453425), REAL(-0.443916),
128 REAL(-0.120363), REAL(-0.581567), REAL(-0.438689),
129 REAL(-0.091499), REAL(-0.584191), REAL(-0.294511),
130 REAL(-0.116469), REAL(-0.599861), REAL(-0.188308),
131 REAL(-0.208032), REAL(-0.513640), REAL(-0.134649),
132 REAL(-0.235749), REAL(-0.610017), REAL(-0.040939),
133 REAL(-0.344916), REAL(-0.622487), REAL(-0.085380),
134 REAL(-0.336401), REAL(-0.531864), REAL(-0.212298),
135 REAL(0.001961), REAL(-0.459550), REAL(-0.135547),
136 REAL(-0.058296), REAL(-0.430536), REAL(-0.043440),
137 REAL(0.001378), REAL(-0.449511), REAL(-0.037762),
138 REAL(-0.130135), REAL(-0.510222), REAL(0.079144),
139 REAL(0.000142), REAL(-0.477549), REAL(0.157064),
140 REAL(-0.114284), REAL(-0.453206), REAL(0.304397),
141 REAL(-0.000592), REAL(-0.443558), REAL(0.285401),
142 REAL(-0.056215), REAL(-0.663402), REAL(0.326073),
143 REAL(-0.026248), REAL(-0.568010), REAL(0.273318),
144 REAL(-0.049261), REAL(-0.531064), REAL(0.389854),
145 REAL(-0.127096), REAL(-0.663398), REAL(0.479316),
146 REAL(-0.058384), REAL(-0.663401), REAL(0.372891),
147 REAL(-0.303961), REAL(0.054199), REAL(0.625921),
148 REAL(-0.268594), REAL(0.193403), REAL(0.502766),
149 REAL(-0.277159), REAL(0.126123), REAL(0.443289),
150 REAL(-0.287605), REAL(-0.005722), REAL(0.531844),
151 REAL(-0.231396), REAL(-0.121289), REAL(0.587387),
152 REAL(-0.253475), REAL(-0.081797), REAL(0.756541),
153 REAL(-0.195164), REAL(-0.137969), REAL(0.728011),
154 REAL(-0.167673), REAL(-0.156573), REAL(0.609388),
155 REAL(-0.145917), REAL(-0.169029), REAL(0.697600),
156 REAL(-0.077776), REAL(-0.214247), REAL(0.622586),
157 REAL(-0.076873), REAL(-0.214971), REAL(0.696301),
158 REAL(-0.002341), REAL(-0.233135), REAL(0.622859),
159 REAL(-0.002730), REAL(-0.213526), REAL(0.691267),
160 REAL(-0.003136), REAL(-0.192628), REAL(0.762731),
161 REAL(-0.056136), REAL(-0.201222), REAL(0.763806),
162 REAL(-0.114589), REAL(-0.166192), REAL(0.770723),
163 REAL(-0.155145), REAL(-0.129632), REAL(0.791738),
164 REAL(-0.183611), REAL(-0.058705), REAL(0.847012),
165 REAL(-0.165562), REAL(0.001980), REAL(0.833386),
166 REAL(-0.220084), REAL(0.019914), REAL(0.768935),
167 REAL(-0.255730), REAL(0.090306), REAL(0.670782),
168 REAL(-0.255594), REAL(0.113833), REAL(0.663389),
169 REAL(-0.226380), REAL(0.212655), REAL(0.617740),
170 REAL(-0.003367), REAL(-0.195342), REAL(0.799680),
171 REAL(-0.029743), REAL(-0.210508), REAL(0.827180),
172 REAL(-0.003818), REAL(-0.194783), REAL(0.873636),
173 REAL(-0.004116), REAL(-0.157907), REAL(0.931268),
174 REAL(-0.031280), REAL(-0.184555), REAL(0.889476),
175 REAL(-0.059885), REAL(-0.184448), REAL(0.841330),
176 REAL(-0.135333), REAL(-0.164332), REAL(0.878200),
177 REAL(-0.085574), REAL(-0.170948), REAL(0.925547),
178 REAL(-0.163833), REAL(-0.094170), REAL(0.897114),
179 REAL(-0.138444), REAL(-0.104250), REAL(0.945975),
180 REAL(-0.083497), REAL(-0.084934), REAL(0.979607),
181 REAL(-0.004433), REAL(-0.146642), REAL(0.985872),
182 REAL(-0.150715), REAL(0.032650), REAL(0.884111),
183 REAL(-0.135892), REAL(-0.035520), REAL(0.945455),
184 REAL(-0.070612), REAL(0.036849), REAL(0.975733),
185 REAL(-0.004458), REAL(-0.042526), REAL(1.015670),
186 REAL(-0.004249), REAL(0.046042), REAL(1.003240),
187 REAL(-0.086969), REAL(0.133224), REAL(0.947633),
188 REAL(-0.003873), REAL(0.161605), REAL(0.970499),
189 REAL(-0.125544), REAL(0.140012), REAL(0.917678),
190 REAL(-0.125651), REAL(0.250246), REAL(0.857602),
191 REAL(-0.003127), REAL(0.284070), REAL(0.878870),
192 REAL(-0.159174), REAL(0.125726), REAL(0.888878),
193 REAL(-0.183807), REAL(0.196970), REAL(0.844480),
194 REAL(-0.159890), REAL(0.291736), REAL(0.732480),
195 REAL(-0.199495), REAL(0.207230), REAL(0.779864),
196 REAL(-0.206182), REAL(0.164608), REAL(0.693257),
197 REAL(-0.186315), REAL(0.160689), REAL(0.817193),
198 REAL(-0.192827), REAL(0.166706), REAL(0.782271),
199 REAL(-0.175112), REAL(0.110008), REAL(0.860621),
200 REAL(-0.161022), REAL(0.057420), REAL(0.855111),
201 REAL(-0.172319), REAL(0.036155), REAL(0.816189),
202 REAL(-0.190318), REAL(0.064083), REAL(0.760605),
203 REAL(-0.195072), REAL(0.129179), REAL(0.731104),
204 REAL(-0.203126), REAL(0.410287), REAL(0.680536),
205 REAL(-0.216677), REAL(0.309274), REAL(0.642272),
206 REAL(-0.241515), REAL(0.311485), REAL(0.587832),
207 REAL(-0.002209), REAL(0.366663), REAL(0.749413),
208 REAL(-0.088230), REAL(0.396265), REAL(0.678635),
209 REAL(-0.170147), REAL(0.109517), REAL(0.840784),
210 REAL(-0.160521), REAL(0.067766), REAL(0.830650),
211 REAL(-0.181546), REAL(0.139805), REAL(0.812146),
212 REAL(-0.180495), REAL(0.148568), REAL(0.776087),
213 REAL(-0.180255), REAL(0.129125), REAL(0.744192),
214 REAL(-0.186298), REAL(0.078308), REAL(0.769352),
215 REAL(-0.167622), REAL(0.060539), REAL(0.806675),
216 REAL(-0.189876), REAL(0.102760), REAL(0.802582),
217 REAL(-0.108340), REAL(0.455446), REAL(0.657174),
218 REAL(-0.241585), REAL(0.527592), REAL(0.669296),
219 REAL(-0.265676), REAL(0.513366), REAL(0.634594),
220 REAL(-0.203073), REAL(0.478550), REAL(0.581526),
221 REAL(-0.266772), REAL(0.642330), REAL(0.602061),
222 REAL(-0.216961), REAL(0.564846), REAL(0.535435),
223 REAL(-0.202210), REAL(0.525495), REAL(0.475944),
224 REAL(-0.193888), REAL(0.467925), REAL(0.520606),
225 REAL(-0.265837), REAL(0.757267), REAL(0.500933),
226 REAL(-0.240306), REAL(0.653440), REAL(0.463215),
227 REAL(-0.309239), REAL(0.776868), REAL(0.304726),
228 REAL(-0.271009), REAL(0.683094), REAL(0.382018),
229 REAL(-0.312111), REAL(0.671099), REAL(0.286687),
230 REAL(-0.268791), REAL(0.624342), REAL(0.377231),
231 REAL(-0.302457), REAL(0.533996), REAL(0.360289),
232 REAL(-0.263656), REAL(0.529310), REAL(0.412564),
233 REAL(-0.282311), REAL(0.415167), REAL(0.447666),
234 REAL(-0.239201), REAL(0.442096), REAL(0.495604),
235 REAL(-0.220043), REAL(0.569026), REAL(0.445877),
236 REAL(-0.001263), REAL(0.395631), REAL(0.602029),
237 REAL(-0.057345), REAL(0.442535), REAL(0.572224),
238 REAL(-0.088927), REAL(0.506333), REAL(0.529106),
239 REAL(-0.125738), REAL(0.535076), REAL(0.612913),
240 REAL(-0.126251), REAL(0.577170), REAL(0.483159),
241 REAL(-0.149594), REAL(0.611520), REAL(0.557731),
242 REAL(-0.163188), REAL(0.660791), REAL(0.491080),
243 REAL(-0.172482), REAL(0.663387), REAL(0.415416),
244 REAL(-0.160464), REAL(0.591710), REAL(0.370659),
245 REAL(-0.156445), REAL(0.536396), REAL(0.378302),
246 REAL(-0.136496), REAL(0.444358), REAL(0.425226),
247 REAL(-0.095564), REAL(0.373768), REAL(0.473659),
248 REAL(-0.104146), REAL(0.315912), REAL(0.498104),
249 REAL(-0.000496), REAL(0.384194), REAL(0.473817),
250 REAL(-0.000183), REAL(0.297770), REAL(0.401486),
251 REAL(-0.129042), REAL(0.270145), REAL(0.434495),
252 REAL(0.000100), REAL(0.272963), REAL(0.349138),
253 REAL(-0.113060), REAL(0.236984), REAL(0.385554),
254 REAL(0.007260), REAL(0.016311), REAL(-0.883396),
255 REAL(0.007865), REAL(0.122104), REAL(-0.956137),
256 REAL(-0.032842), REAL(0.115282), REAL(-0.953252),
257 REAL(-0.089115), REAL(0.108449), REAL(-0.950317),
258 REAL(-0.047440), REAL(0.014729), REAL(-0.882756),
259 REAL(-0.104458), REAL(0.013137), REAL(-0.882070),
260 REAL(-0.086439), REAL(-0.584866), REAL(-0.608343),
261 REAL(-0.115026), REAL(-0.662605), REAL(-0.436732),
262 REAL(-0.071683), REAL(-0.665372), REAL(-0.606385),
263 REAL(-0.257884), REAL(-0.665381), REAL(-0.658052),
264 REAL(-0.272542), REAL(-0.665381), REAL(-0.592063),
265 REAL(-0.371322), REAL(-0.665382), REAL(-0.353620),
266 REAL(-0.372362), REAL(-0.665381), REAL(-0.224420),
267 REAL(-0.335166), REAL(-0.665380), REAL(-0.078623),
268 REAL(-0.225999), REAL(-0.665375), REAL(-0.038981),
269 REAL(-0.106719), REAL(-0.665374), REAL(-0.186351),
270 REAL(-0.081749), REAL(-0.665372), REAL(-0.292554),
271 REAL(0.006943), REAL(-0.091505), REAL(-0.858354),
272 REAL(0.006117), REAL(-0.280985), REAL(-0.769967),
273 REAL(0.004495), REAL(-0.502360), REAL(-0.559799),
274 REAL(-0.198638), REAL(-0.302135), REAL(-0.845816),
275 REAL(-0.237395), REAL(-0.542544), REAL(-0.587188),
276 REAL(-0.270001), REAL(-0.279489), REAL(-0.669861),
277 REAL(-0.134547), REAL(-0.119852), REAL(-0.959004),
278 REAL(-0.052088), REAL(-0.122463), REAL(-0.944549),
279 REAL(-0.124463), REAL(-0.293508), REAL(-0.899566),
280 REAL(-0.047616), REAL(-0.289643), REAL(-0.879292),
281 REAL(-0.168595), REAL(-0.529132), REAL(-0.654931),
282 REAL(-0.099793), REAL(-0.515719), REAL(-0.645873),
283 REAL(-0.186168), REAL(-0.605282), REAL(-0.724690),
284 REAL(-0.112970), REAL(-0.583097), REAL(-0.707469),
285 REAL(-0.108152), REAL(-0.665375), REAL(-0.700408),
286 REAL(-0.183019), REAL(-0.665378), REAL(-0.717630),
287 REAL(-0.349529), REAL(-0.334459), REAL(-0.511985),
288 REAL(-0.141182), REAL(-0.437705), REAL(-0.798194),
289 REAL(-0.212670), REAL(-0.448725), REAL(-0.737447),
290 REAL(-0.261111), REAL(-0.414945), REAL(-0.613835),
291 REAL(-0.077364), REAL(-0.431480), REAL(-0.778113),
292 REAL(0.005174), REAL(-0.425277), REAL(-0.651592),
293 REAL(0.089236), REAL(-0.431732), REAL(-0.777093),
294 REAL(0.271006), REAL(-0.415749), REAL(-0.610577),
295 REAL(0.223981), REAL(-0.449384), REAL(-0.734774),
296 REAL(0.153275), REAL(-0.438150), REAL(-0.796391),
297 REAL(0.358414), REAL(-0.335529), REAL(-0.507649),
298 REAL(0.193434), REAL(-0.665946), REAL(-0.715325),
299 REAL(0.118363), REAL(-0.665717), REAL(-0.699021),
300 REAL(0.123515), REAL(-0.583454), REAL(-0.706020),
301 REAL(0.196851), REAL(-0.605860), REAL(-0.722345),
302 REAL(0.109788), REAL(-0.516035), REAL(-0.644590),
303 REAL(0.178656), REAL(-0.529656), REAL(-0.652804),
304 REAL(0.061157), REAL(-0.289807), REAL(-0.878626),
305 REAL(0.138234), REAL(-0.293905), REAL(-0.897958),
306 REAL(0.066933), REAL(-0.122643), REAL(-0.943820),
307 REAL(0.149571), REAL(-0.120281), REAL(-0.957264),
308 REAL(0.280989), REAL(-0.280321), REAL(-0.666487),
309 REAL(0.246581), REAL(-0.543275), REAL(-0.584224),
310 REAL(0.211720), REAL(-0.302754), REAL(-0.843303),
311 REAL(0.086966), REAL(-0.665627), REAL(-0.291520),
312 REAL(0.110634), REAL(-0.665702), REAL(-0.185021),
313 REAL(0.228099), REAL(-0.666061), REAL(-0.036201),
314 REAL(0.337743), REAL(-0.666396), REAL(-0.074503),
315 REAL(0.376722), REAL(-0.666513), REAL(-0.219833),
316 REAL(0.377265), REAL(-0.666513), REAL(-0.349036),
317 REAL(0.281411), REAL(-0.666217), REAL(-0.588670),
318 REAL(0.267564), REAL(-0.666174), REAL(-0.654834),
319 REAL(0.080745), REAL(-0.665602), REAL(-0.605452),
320 REAL(0.122016), REAL(-0.662963), REAL(-0.435280),
321 REAL(0.095767), REAL(-0.585141), REAL(-0.607228),
322 REAL(0.118944), REAL(0.012799), REAL(-0.880702),
323 REAL(0.061944), REAL(0.014564), REAL(-0.882086),
324 REAL(0.104725), REAL(0.108156), REAL(-0.949130),
325 REAL(0.048513), REAL(0.115159), REAL(-0.952753),
326 REAL(0.112696), REAL(0.236643), REAL(0.386937),
327 REAL(0.128177), REAL(0.269757), REAL(0.436071),
328 REAL(0.102643), REAL(0.315600), REAL(0.499370),
329 REAL(0.094535), REAL(0.373481), REAL(0.474824),
330 REAL(0.136270), REAL(0.443946), REAL(0.426895),
331 REAL(0.157071), REAL(0.535923), REAL(0.380222),
332 REAL(0.161350), REAL(0.591224), REAL(0.372630),
333 REAL(0.173035), REAL(0.662865), REAL(0.417531),
334 REAL(0.162808), REAL(0.660299), REAL(0.493077),
335 REAL(0.148250), REAL(0.611070), REAL(0.559555),
336 REAL(0.125719), REAL(0.576790), REAL(0.484702),
337 REAL(0.123489), REAL(0.534699), REAL(0.614440),
338 REAL(0.087621), REAL(0.506066), REAL(0.530188),
339 REAL(0.055321), REAL(0.442365), REAL(0.572915),
340 REAL(0.219936), REAL(0.568361), REAL(0.448571),
341 REAL(0.238099), REAL(0.441375), REAL(0.498528),
342 REAL(0.281711), REAL(0.414315), REAL(0.451121),
343 REAL(0.263833), REAL(0.528513), REAL(0.415794),
344 REAL(0.303284), REAL(0.533081), REAL(0.363998),
345 REAL(0.269687), REAL(0.623528), REAL(0.380528),
346 REAL(0.314255), REAL(0.670153), REAL(0.290524),
347 REAL(0.272023), REAL(0.682273), REAL(0.385343),
348 REAL(0.311480), REAL(0.775931), REAL(0.308527),
349 REAL(0.240239), REAL(0.652714), REAL(0.466159),
350 REAL(0.265619), REAL(0.756464), REAL(0.504187),
351 REAL(0.192562), REAL(0.467341), REAL(0.522972),
352 REAL(0.201605), REAL(0.524885), REAL(0.478417),
353 REAL(0.215743), REAL(0.564193), REAL(0.538084),
354 REAL(0.264969), REAL(0.641527), REAL(0.605317),
355 REAL(0.201031), REAL(0.477940), REAL(0.584002),
356 REAL(0.263086), REAL(0.512567), REAL(0.637832),
357 REAL(0.238615), REAL(0.526867), REAL(0.672237),
358 REAL(0.105309), REAL(0.455123), REAL(0.658482),
359 REAL(0.183993), REAL(0.102195), REAL(0.804872),
360 REAL(0.161563), REAL(0.060042), REAL(0.808692),
361 REAL(0.180748), REAL(0.077754), REAL(0.771600),
362 REAL(0.175168), REAL(0.128588), REAL(0.746368),
363 REAL(0.175075), REAL(0.148030), REAL(0.778264),
364 REAL(0.175658), REAL(0.139265), REAL(0.814333),
365 REAL(0.154191), REAL(0.067291), REAL(0.832578),
366 REAL(0.163818), REAL(0.109013), REAL(0.842830),
367 REAL(0.084760), REAL(0.396004), REAL(0.679695),
368 REAL(0.238888), REAL(0.310760), REAL(0.590775),
369 REAL(0.213380), REAL(0.308625), REAL(0.644905),
370 REAL(0.199666), REAL(0.409678), REAL(0.683003),
371 REAL(0.190143), REAL(0.128597), REAL(0.733463),
372 REAL(0.184833), REAL(0.063516), REAL(0.762902),
373 REAL(0.166070), REAL(0.035644), REAL(0.818261),
374 REAL(0.154361), REAL(0.056943), REAL(0.857042),
375 REAL(0.168542), REAL(0.109489), REAL(0.862725),
376 REAL(0.187387), REAL(0.166131), REAL(0.784599),
377 REAL(0.180428), REAL(0.160135), REAL(0.819438),
378 REAL(0.201823), REAL(0.163991), REAL(0.695756),
379 REAL(0.194206), REAL(0.206635), REAL(0.782275),
380 REAL(0.155438), REAL(0.291260), REAL(0.734412),
381 REAL(0.177696), REAL(0.196424), REAL(0.846693),
382 REAL(0.152305), REAL(0.125256), REAL(0.890786),
383 REAL(0.119546), REAL(0.249876), REAL(0.859104),
384 REAL(0.118369), REAL(0.139643), REAL(0.919173),
385 REAL(0.079410), REAL(0.132973), REAL(0.948652),
386 REAL(0.062419), REAL(0.036648), REAL(0.976547),
387 REAL(0.127847), REAL(-0.035919), REAL(0.947070),
388 REAL(0.143624), REAL(0.032206), REAL(0.885913),
389 REAL(0.074888), REAL(-0.085173), REAL(0.980577),
390 REAL(0.130184), REAL(-0.104656), REAL(0.947620),
391 REAL(0.156201), REAL(-0.094653), REAL(0.899074),
392 REAL(0.077366), REAL(-0.171194), REAL(0.926545),
393 REAL(0.127722), REAL(-0.164729), REAL(0.879810),
394 REAL(0.052670), REAL(-0.184618), REAL(0.842019),
395 REAL(0.023477), REAL(-0.184638), REAL(0.889811),
396 REAL(0.022626), REAL(-0.210587), REAL(0.827500),
397 REAL(0.223089), REAL(0.211976), REAL(0.620493),
398 REAL(0.251444), REAL(0.113067), REAL(0.666494),
399 REAL(0.251419), REAL(0.089540), REAL(0.673887),
400 REAL(0.214360), REAL(0.019258), REAL(0.771595),
401 REAL(0.158999), REAL(0.001490), REAL(0.835374),
402 REAL(0.176696), REAL(-0.059249), REAL(0.849218),
403 REAL(0.148696), REAL(-0.130091), REAL(0.793599),
404 REAL(0.108290), REAL(-0.166528), REAL(0.772088),
405 REAL(0.049820), REAL(-0.201382), REAL(0.764454),
406 REAL(0.071341), REAL(-0.215195), REAL(0.697209),
407 REAL(0.073148), REAL(-0.214475), REAL(0.623510),
408 REAL(0.140502), REAL(-0.169461), REAL(0.699354),
409 REAL(0.163374), REAL(-0.157073), REAL(0.611416),
410 REAL(0.189466), REAL(-0.138550), REAL(0.730366),
411 REAL(0.247593), REAL(-0.082554), REAL(0.759610),
412 REAL(0.227468), REAL(-0.121982), REAL(0.590197),
413 REAL(0.284702), REAL(-0.006586), REAL(0.535347),
414 REAL(0.275741), REAL(0.125287), REAL(0.446676),
415 REAL(0.266650), REAL(0.192594), REAL(0.506044),
416 REAL(0.300086), REAL(0.053287), REAL(0.629620),
417 REAL(0.055450), REAL(-0.663935), REAL(0.375065),
418 REAL(0.122854), REAL(-0.664138), REAL(0.482323),
419 REAL(0.046520), REAL(-0.531571), REAL(0.391918),
420 REAL(0.024824), REAL(-0.568450), REAL(0.275106),
421 REAL(0.053855), REAL(-0.663931), REAL(0.328224),
422 REAL(0.112829), REAL(-0.453549), REAL(0.305788),
423 REAL(0.131265), REAL(-0.510617), REAL(0.080746),
424 REAL(0.061174), REAL(-0.430716), REAL(-0.042710),
425 REAL(0.341019), REAL(-0.532887), REAL(-0.208150),
426 REAL(0.347705), REAL(-0.623533), REAL(-0.081139),
427 REAL(0.238040), REAL(-0.610732), REAL(-0.038037),
428 REAL(0.211764), REAL(-0.514274), REAL(-0.132078),
429 REAL(0.120605), REAL(-0.600219), REAL(-0.186856),
430 REAL(0.096985), REAL(-0.584476), REAL(-0.293357),
431 REAL(0.127621), REAL(-0.581941), REAL(-0.437170),
432 REAL(0.165902), REAL(-0.477425), REAL(-0.291453),
433 REAL(0.077720), REAL(-0.417975), REAL(-0.220519),
434 REAL(0.320892), REAL(-0.506363), REAL(-0.320874),
435 REAL(0.248214), REAL(-0.465684), REAL(-0.239842),
436 REAL(0.118764), REAL(-0.383338), REAL(-0.187114),
437 REAL(0.118816), REAL(-0.430106), REAL(-0.123307),
438 REAL(0.094131), REAL(-0.419464), REAL(-0.044777),
439 REAL(0.274526), REAL(-0.261706), REAL(0.005110),
440 REAL(0.259842), REAL(-0.283292), REAL(-0.003185),
441 REAL(0.222861), REAL(-0.340431), REAL(-0.038210),
442 REAL(0.204445), REAL(-0.664380), REAL(0.513353),
443 REAL(0.259286), REAL(-0.664547), REAL(0.471281),
444 REAL(0.185402), REAL(-0.476020), REAL(0.421718),
445 REAL(0.279163), REAL(-0.664604), REAL(0.417328),
446 REAL(0.277157), REAL(-0.528122), REAL(0.400208),
447 REAL(0.183069), REAL(-0.509812), REAL(0.329995),
448 REAL(0.282599), REAL(-0.429210), REAL(0.059242),
449 REAL(0.254816), REAL(-0.664541), REAL(0.290687),
450 REAL(0.271436), REAL(-0.567707), REAL(0.263966),
451 REAL(0.386561), REAL(-0.625221), REAL(-0.216870),
452 REAL(0.387086), REAL(-0.630883), REAL(-0.346073),
453 REAL(0.380021), REAL(-0.596021), REAL(-0.318679),
454 REAL(0.291269), REAL(-0.619007), REAL(-0.585707),
455 REAL(0.339280), REAL(-0.571198), REAL(-0.461946),
456 REAL(0.400045), REAL(-0.489778), REAL(-0.422640),
457 REAL(0.406817), REAL(-0.314349), REAL(-0.371230),
458 REAL(0.300588), REAL(-0.281718), REAL(-0.170549),
459 REAL(0.290866), REAL(-0.277304), REAL(-0.061905),
460 REAL(0.187735), REAL(-0.241545), REAL(0.509437),
461 REAL(0.188032), REAL(-0.287569), REAL(0.424234),
462 REAL(0.227520), REAL(-0.373262), REAL(0.293102),
463 REAL(0.266526), REAL(-0.273650), REAL(0.039597),
464 REAL(0.291592), REAL(-0.291676), REAL(0.111386),
465 REAL(0.291914), REAL(-0.122741), REAL(0.422683),
466 REAL(0.297574), REAL(-0.156119), REAL(0.373368),
467 REAL(0.286603), REAL(-0.232731), REAL(0.027162),
468 REAL(0.364663), REAL(-0.201399), REAL(0.206850),
469 REAL(0.353855), REAL(-0.132408), REAL(0.149228),
470 REAL(0.282208), REAL(-0.019715), REAL(0.314960),
471 REAL(0.331187), REAL(-0.099266), REAL(0.092701),
472 REAL(0.375463), REAL(-0.093120), REAL(-0.006467),
473 REAL(0.375917), REAL(-0.101236), REAL(-0.154882),
474 REAL(0.466635), REAL(-0.094416), REAL(-0.305669),
475 REAL(0.455805), REAL(-0.119881), REAL(-0.460632),
476 REAL(0.277465), REAL(-0.604242), REAL(-0.651871),
477 REAL(0.261022), REAL(-0.551176), REAL(-0.554667),
478 REAL(0.093627), REAL(0.258494), REAL(-0.920589),
479 REAL(0.114248), REAL(0.310608), REAL(-0.798070),
480 REAL(0.144232), REAL(0.211434), REAL(-0.835001),
481 REAL(0.119916), REAL(0.176940), REAL(-0.951159),
482 REAL(0.184061), REAL(0.101854), REAL(-0.918220),
483 REAL(0.092431), REAL(0.276521), REAL(-0.738231),
484 REAL(0.133504), REAL(0.218403), REAL(-0.758602),
485 REAL(0.194987), REAL(0.097655), REAL(-0.812476),
486 REAL(0.185542), REAL(0.011005), REAL(-0.879202),
487 REAL(0.230315), REAL(-0.127450), REAL(-0.884202),
488 REAL(0.260471), REAL(0.255056), REAL(-0.624378),
489 REAL(0.351567), REAL(-0.042194), REAL(-0.663976),
490 REAL(0.253742), REAL(0.323524), REAL(-0.433716),
491 REAL(0.411612), REAL(0.132299), REAL(-0.438264),
492 REAL(0.270513), REAL(0.356530), REAL(-0.289984),
493 REAL(0.422146), REAL(0.162819), REAL(-0.273130),
494 REAL(0.164724), REAL(0.237490), REAL(0.208912),
495 REAL(0.253806), REAL(0.092900), REAL(0.240640),
496 REAL(0.203608), REAL(0.284597), REAL(0.096223),
497 REAL(0.241006), REAL(0.343093), REAL(-0.171396),
498 REAL(0.356076), REAL(0.149288), REAL(-0.143443),
499 REAL(0.337656), REAL(0.131992), REAL(0.066374)
502 int gIndices[NUM_TRIANGLES][3] = {
1408 //***************************THE END OF FAMOUS BUNNY TRIMESH********************************************//
1414 ///User can override this material combiner by implementing gContactAddedCallback and setting body0->m_collisionFlags |= btCollisionObject::customMaterialCallback;
1415 inline btScalar calculateCombinedFriction(float friction0,float friction1)
1417 btScalar friction = friction0 * friction1;
1419 const btScalar MAX_FRICTION = 10.f;
1420 if (friction < -MAX_FRICTION)
1421 friction = -MAX_FRICTION;
1422 if (friction > MAX_FRICTION)
1423 friction = MAX_FRICTION;
1428 inline btScalar calculateCombinedRestitution(float restitution0,float restitution1)
1430 return restitution0 * restitution1;
1435 bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1)
1438 float friction0 = colObj0Wrap->getCollisionObject()->getFriction();
1439 float friction1 = colObj1Wrap->getCollisionObject()->getFriction();
1440 float restitution0 = colObj0Wrap->getCollisionObject()->getRestitution();
1441 float restitution1 = colObj1Wrap->getCollisionObject()->getRestitution();
1443 if (colObj0Wrap->getCollisionObject()->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
1445 friction0 = 1.0;//partId0,index0
1448 if (colObj1Wrap->getCollisionObject()->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
1452 friction1 = 1.0f;//partId1,index1
1460 cp.m_combinedFriction = calculateCombinedFriction(friction0,friction1);
1461 cp.m_combinedRestitution = calculateCombinedRestitution(restitution0,restitution1);
1463 //this return value is currently ignored, but to be on the safe side: return false if you don't calculate friction
1467 extern ContactAddedCallback gContactAddedCallback;
1471 int main(int argc,char** argv)
1473 gContactAddedCallback = CustomMaterialCombinerCallback;
1475 ConcaveDemo* concaveDemo = new ConcaveDemo();
1476 concaveDemo->initPhysics();
1477 concaveDemo->setCameraDistance(30.f);
1478 //cannot run stepFront yet, the OpenGL context is not opened (stepFront updates camera...)
1479 // concaveDemo->stepFront();
1480 // concaveDemo->stepFront();
1481 // concaveDemo->stepFront();
1482 // concaveDemo->stepFront();
1484 return glutmain(argc, argv,640,480,"Moving Concave Mesh Demo",concaveDemo);
1487 void ConcaveDemo::renderme()
1493 if (m_dynamicsWorld)
1495 btVector3 worldBoundsMin,worldBoundsMax;
1496 getDynamicsWorld()->getBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax);
1499 int numObjects = m_dynamicsWorld->getNumCollisionObjects();
1500 btVector3 wireColor(1,0,0);
1501 for (int i=0;i<numObjects;i++)
1503 btCollisionObject* colObj = m_dynamicsWorld->getCollisionObjectArray()[i];
1504 btRigidBody* body = btRigidBody::upcast(colObj);
1506 if (body && body->getMotionState())
1508 btDefaultMotionState* myMotionState = (btDefaultMotionState*)body->getMotionState();
1509 myMotionState->m_graphicsWorldTrans.getOpenGLMatrix(m);
1512 colObj->getWorldTransform().getOpenGLMatrix(m);
1515 btVector3 wireColor(1.f,1.0f,0.5f); //wants deactivation
1518 wireColor = btVector3(0.f,0.0f,1.f);
1520 ///color differently for active, sleeping, wantsdeactivation states
1521 if (colObj->getActivationState() == 1) //active
1525 wireColor += btVector3 (1.f,0.f,0.f);
1528 wireColor += btVector3 (.5f,0.f,0.f);
1531 if (colObj->getActivationState() == 2) //ISLAND_SLEEPING
1535 wireColor += btVector3 (0.f,1.f, 0.f);
1538 wireColor += btVector3 (0.f,0.5f,0.f);
1542 m_shapeDrawer->drawOpenGL(m,colObj->getCollisionShape(),wireColor,getDebugMode(),worldBoundsMin,worldBoundsMax);
1546 float xOffset = 10.f;
1547 float yStart = 20.f;
1553 setOrthographicProjection();
1555 sprintf(buf,"mouse to interact");
1556 GLDebugDrawString(xOffset,xOffset,buf);
1559 /* glRasterPos3f(xOffset,xOffset,0);
1560 sprintf(buf,"space to reset");
1561 GLDebugDrawString(xOffset,xOffset,buf);
1565 sprintf(buf,"cursor keys and z,x to navigate");
1566 GLDebugDrawString(xOffset,xOffset,buf);
1570 sprintf(buf,"i to toggle simulation, s single step");
1571 GLDebugDrawString(xOffset,xOffset,buf);
1575 sprintf(buf,"q to quit");
1576 GLDebugDrawString(xOffset,xOffset,buf);
1580 sprintf(buf,". to shoot TRIMESH (dot)");
1581 GLDebugDrawString(xOffset,xOffset,buf);
1584 // not yet hooked up again after refactoring...
1586 /* glRasterPos3f(xOffset,xOffset,0);
1587 sprintf(buf,"d to toggle deactivation");
1588 GLDebugDrawString(xOffset,xOffset,buf);
1593 glRasterPos3f(xOffset,xOffset,0);
1594 sprintf(buf,"a to draw temporal AABBs");
1595 GLDebugDrawString(xOffset,xOffset,buf);
1600 sprintf(buf,"h to toggle help text");
1601 GLDebugDrawString(xOffset,xOffset,buf);
1604 //bool useBulletLCP = !(getDebugMode() & btIDebugDraw::DBG_DisableBulletLCP);
1606 bool useCCD = ((getDebugMode() & btIDebugDraw::DBG_EnableCCD) != 0);
1609 sprintf(buf,"1 CCD mode (adhoc) = %i",useCCD);
1610 GLDebugDrawString(xOffset,xOffset,buf);
1614 sprintf(buf,"+- shooting speed = %10.2f",m_ShootBoxInitialSpeed);
1615 GLDebugDrawString(xOffset,xOffset,buf);
1618 resetPerspectiveProjection();
1627 void ConcaveDemo::initGImpactCollision()
1630 btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray(NUM_TRIANGLES,
1633 NUM_VERTICES,(REAL*) &gVertices[0],sizeof(REAL)*3);
1635 btGImpactMeshShape * trimesh = new btGImpactMeshShape(indexVertexArrays);
1636 trimesh->setLocalScaling(btVector3(4.f,4.f,4.f));
1637 trimesh->updateBound();
1638 m_trimeshShape = trimesh;
1640 //register algorithm
1642 btCollisionDispatcher * dispatcher = static_cast<btCollisionDispatcher *>(m_dynamicsWorld ->getDispatcher());
1643 btGImpactCollisionAlgorithm::registerAlgorithm(dispatcher);
1647 void ConcaveDemo::initPhysics()
1650 btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
1652 //btConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
1653 btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
1654 //btOverlappingPairCache* broadphase = new btSimpleBroadphase();
1655 btBroadphaseInterface* broadphase = new btSimpleBroadphase();
1657 btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
1658 m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,constraintSolver,collisionConfiguration);
1661 //create trimesh model and shape
1662 initGImpactCollision();
1667 btTransform startTransform;
1668 startTransform.setIdentity();
1670 btCollisionShape* staticboxShape1 = new btBoxShape(btVector3(200,1,200));//floor
1671 btCollisionShape* staticboxShape2 = new btBoxShape(btVector3(1,50,200));//left wall
1672 btCollisionShape* staticboxShape3 = new btBoxShape(btVector3(1,50,200));//right wall
1673 btCollisionShape* staticboxShape4 = new btBoxShape(btVector3(200,50,1));//front wall
1674 btCollisionShape* staticboxShape5 = new btBoxShape(btVector3(200,50,1));//back wall
1676 btCompoundShape* staticScenario = new btCompoundShape();//static scenario
1678 startTransform.setOrigin(btVector3(0,0,0));
1679 staticScenario->addChildShape(startTransform,staticboxShape1);
1680 startTransform.setOrigin(btVector3(-200,25,0));
1681 staticScenario->addChildShape(startTransform,staticboxShape2);
1682 startTransform.setOrigin(btVector3(200,25,0));
1683 staticScenario->addChildShape(startTransform,staticboxShape3);
1684 startTransform.setOrigin(btVector3(0,25,200));
1685 staticScenario->addChildShape(startTransform,staticboxShape4);
1686 startTransform.setOrigin(btVector3(0,25,-200));
1687 staticScenario->addChildShape(startTransform,staticboxShape5);
1689 startTransform.setOrigin(btVector3(0,0,0));
1691 btRigidBody* staticBody = localCreateRigidBody(mass, startTransform,staticScenario);
1693 staticBody->setCollisionFlags(staticBody->getCollisionFlags()|btCollisionObject::CF_STATIC_OBJECT);
1695 //enable custom material callback
1696 staticBody->setCollisionFlags(staticBody->getCollisionFlags()|btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
1700 btVector3 normal(0.4,1.5,-0.4);
1702 btCollisionShape* staticplaneShape6 = new btStaticPlaneShape(normal,0.0);// A plane
1704 startTransform.setOrigin(btVector3(0,0,0));
1706 btRigidBody* staticBody2 = localCreateRigidBody(mass, startTransform,staticplaneShape6 );
1708 staticBody2->setCollisionFlags(staticBody2->getCollisionFlags()|btCollisionObject::CF_STATIC_OBJECT);
1711 for (int i=0;i<9;i++)
1713 btCollisionShape* boxShape = new btBoxShape(btVector3(1,1,1));
1714 startTransform.setOrigin(btVector3(2*i-5,2,-3));
1715 localCreateRigidBody(1, startTransform,boxShape);
1719 shootTrimesh(btVector3(0,10,0),btVector3(0,0,0));
1721 shootTrimesh(btVector3(0,20,0),btVector3(0,10,0));
1723 //m_debugMode |= btIDebugDraw::DBG_DrawWireframe;
1727 void ConcaveDemo::keyboardCallback(unsigned char key, int x, int y)
1733 case 'q' : exit(0); break;
1735 case 'l' : stepLeft(); break;
1736 case 'r' : stepRight(); break;
1737 case 'f' : stepFront(); break;
1738 case 'b' : stepBack(); break;
1739 case 'z' : zoomIn(); break;
1740 case 'x' : zoomOut(); break;
1741 case 'i' : toggleIdle(); break;
1743 if (m_debugMode & btIDebugDraw::DBG_NoHelpText)
1744 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_NoHelpText);
1746 m_debugMode |= btIDebugDraw::DBG_NoHelpText;
1750 if (m_debugMode & btIDebugDraw::DBG_DrawWireframe)
1751 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawWireframe);
1753 m_debugMode |= btIDebugDraw::DBG_DrawWireframe;
1757 if (m_debugMode & btIDebugDraw::DBG_ProfileTimings)
1758 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_ProfileTimings);
1760 m_debugMode |= btIDebugDraw::DBG_ProfileTimings;
1764 if (m_debugMode & btIDebugDraw::DBG_EnableSatComparison)
1765 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_EnableSatComparison);
1767 m_debugMode |= btIDebugDraw::DBG_EnableSatComparison;
1771 if (m_debugMode & btIDebugDraw::DBG_DisableBulletLCP)
1772 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DisableBulletLCP);
1774 m_debugMode |= btIDebugDraw::DBG_DisableBulletLCP;
1778 if (m_debugMode & btIDebugDraw::DBG_DrawText)
1779 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawText);
1781 m_debugMode |= btIDebugDraw::DBG_DrawText;
1784 if (m_debugMode & btIDebugDraw::DBG_DrawFeaturesText)
1785 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawFeaturesText);
1787 m_debugMode |= btIDebugDraw::DBG_DrawFeaturesText;
1790 if (m_debugMode & btIDebugDraw::DBG_DrawAabb)
1791 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawAabb);
1793 m_debugMode |= btIDebugDraw::DBG_DrawAabb;
1796 if (m_debugMode & btIDebugDraw::DBG_DrawContactPoints)
1797 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawContactPoints);
1799 m_debugMode |= btIDebugDraw::DBG_DrawContactPoints;
1803 if (m_debugMode & btIDebugDraw::DBG_NoDeactivation)
1804 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_NoDeactivation);
1806 m_debugMode |= btIDebugDraw::DBG_NoDeactivation;
1807 if (m_debugMode | btIDebugDraw::DBG_NoDeactivation)
1809 gDisableDeactivation = true;
1812 gDisableDeactivation = false;
1821 m_stepping = !m_stepping;
1824 case 's' : clientMoveAndDisplay(); break;
1825 // case ' ' : newRandom(); break;
1831 if (m_debugMode & btIDebugDraw::DBG_EnableCCD)
1832 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_EnableCCD);
1834 m_debugMode |= btIDebugDraw::DBG_EnableCCD;
1840 shootTrimesh(getCameraPosition(),getCameraTargetPosition());
1846 m_ShootBoxInitialSpeed += 10.f;
1851 m_ShootBoxInitialSpeed -= 10.f;
1856 // std::cout << "unused key : " << key << std::endl;
1860 if (getDynamicsWorld() && getDynamicsWorld()->getDebugDrawer())
1861 getDynamicsWorld()->getDebugDrawer()->setDebugMode(m_debugMode);
1863 glutPostRedisplay();
1868 void ConcaveDemo::shootTrimesh(const btVector3& startPosition,const btVector3& destination)
1871 if (m_dynamicsWorld)
1874 btTransform startTransform;
1875 startTransform.setIdentity();
1876 startTransform.setOrigin(startPosition);
1878 btRigidBody* body = this->localCreateRigidBody(mass, startTransform,m_trimeshShape);
1880 btVector3 linVel(destination[0]-startPosition[0],destination[1]-startPosition[1],destination[2]-startPosition[2]);
1882 linVel*=m_ShootBoxInitialSpeed*0.25;
1884 body->getWorldTransform().setOrigin(startPosition);
1885 body->getWorldTransform().setRotation(btQuaternion(0,0,0,1));
1886 body->setLinearVelocity(linVel);
1887 body->setAngularVelocity(btVector3(0,0,0));
1891 void ConcaveDemo::clientMoveAndDisplay()
1893 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1895 float dt = float(getDeltaTimeMicroseconds()) * 0.000001f;
1897 m_dynamicsWorld->stepSimulation(dt);
1899 //optional but useful: debug drawing
1900 m_dynamicsWorld->debugDrawWorld();
1912 void ConcaveDemo::displayCallback(void) {
1914 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1918 //optional but useful: debug drawing
1919 if (m_dynamicsWorld)
1920 m_dynamicsWorld->debugDrawWorld();