Initialize libbullet git in 2.0_beta.
[platform/upstream/libbullet.git] / Demos / MovingConcaveDemo / ConcavePhysicsDemo.cpp
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
4
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:
10
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.
14 */
15
16 #include "btBulletDynamicsCommon.h"
17 #include "ConcaveDemo.h"
18
19 #include "LinearMath/btDefaultMotionState.h"
20 #include "LinearMath/btIDebugDraw.h"
21 #include "LinearMath/btQuickprof.h"
22 #include "LinearMath/btDefaultMotionState.h"
23 #include "BulletCollision/Gimpact/btGImpactShape.h"
24 #include "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h"
25 #include "GLDebugFont.h"
26
27
28
29 #include "GLDebugDrawer.h"
30
31 #include "GL_ShapeDrawer.h"
32 #include "GlutStuff.h"
33
34
35 GLDebugDrawer   debugDrawer;
36
37 //***************************THE FAMOUS BUNNY TRIMESH********************************************//
38
39 #define REAL btScalar
40 const int NUM_TRIANGLES =902;
41 const int NUM_VERTICES = 453;
42 const int NUM_INDICES  = NUM_TRIANGLES * 3;
43
44
45 REAL gVertices[NUM_VERTICES * 3] = {
46         REAL(-0.334392), REAL(0.133007), REAL(0.062259),
47         REAL(-0.350189), REAL(0.150354), REAL(-0.147769),
48         REAL(-0.234201), REAL(0.343811), REAL(-0.174307),
49         REAL(-0.200259), REAL(0.285207), REAL(0.093749),
50         REAL(0.003520), REAL(0.475208), REAL(-0.159365),
51         REAL(0.001856), REAL(0.419203), REAL(0.098582),
52         REAL(-0.252802), REAL(0.093666), REAL(0.237538),
53         REAL(-0.162901), REAL(0.237984), REAL(0.206905),
54         REAL(0.000865), REAL(0.318141), REAL(0.235370),
55         REAL(-0.414624), REAL(0.164083), REAL(-0.278254),
56         REAL(-0.262213), REAL(0.357334), REAL(-0.293246),
57         REAL(0.004628), REAL(0.482694), REAL(-0.338626),
58         REAL(-0.402162), REAL(0.133528), REAL(-0.443247),
59         REAL(-0.243781), REAL(0.324275), REAL(-0.436763),
60         REAL(0.005293), REAL(0.437592), REAL(-0.458332),
61         REAL(-0.339884), REAL(-0.041150), REAL(-0.668211),
62         REAL(-0.248382), REAL(0.255825), REAL(-0.627493),
63         REAL(0.006261), REAL(0.376103), REAL(-0.631506),
64         REAL(-0.216201), REAL(-0.126776), REAL(-0.886936),
65         REAL(-0.171075), REAL(0.011544), REAL(-0.881386),
66         REAL(-0.181074), REAL(0.098223), REAL(-0.814779),
67         REAL(-0.119891), REAL(0.218786), REAL(-0.760153),
68         REAL(-0.078895), REAL(0.276780), REAL(-0.739281),
69         REAL(0.006801), REAL(0.310959), REAL(-0.735661),
70         REAL(-0.168842), REAL(0.102387), REAL(-0.920381),
71         REAL(-0.104072), REAL(0.177278), REAL(-0.952530),
72         REAL(-0.129704), REAL(0.211848), REAL(-0.836678),
73         REAL(-0.099875), REAL(0.310931), REAL(-0.799381),
74         REAL(0.007237), REAL(0.361687), REAL(-0.794439),
75         REAL(-0.077913), REAL(0.258753), REAL(-0.921640),
76         REAL(0.007957), REAL(0.282241), REAL(-0.931680),
77         REAL(-0.252222), REAL(-0.550401), REAL(-0.557810),
78         REAL(-0.267633), REAL(-0.603419), REAL(-0.655209),
79         REAL(-0.446838), REAL(-0.118517), REAL(-0.466159),
80         REAL(-0.459488), REAL(-0.093017), REAL(-0.311341),
81         REAL(-0.370645), REAL(-0.100108), REAL(-0.159454),
82         REAL(-0.371984), REAL(-0.091991), REAL(-0.011044),
83         REAL(-0.328945), REAL(-0.098269), REAL(0.088659),
84         REAL(-0.282452), REAL(-0.018862), REAL(0.311501),
85         REAL(-0.352403), REAL(-0.131341), REAL(0.144902),
86         REAL(-0.364126), REAL(-0.200299), REAL(0.202388),
87         REAL(-0.283965), REAL(-0.231869), REAL(0.023668),
88         REAL(-0.298943), REAL(-0.155218), REAL(0.369716),
89         REAL(-0.293787), REAL(-0.121856), REAL(0.419097),
90         REAL(-0.290163), REAL(-0.290797), REAL(0.107824),
91         REAL(-0.264165), REAL(-0.272849), REAL(0.036347),
92         REAL(-0.228567), REAL(-0.372573), REAL(0.290309),
93         REAL(-0.190431), REAL(-0.286997), REAL(0.421917),
94         REAL(-0.191039), REAL(-0.240973), REAL(0.507118),
95         REAL(-0.287272), REAL(-0.276431), REAL(-0.065444),
96         REAL(-0.295675), REAL(-0.280818), REAL(-0.174200),
97         REAL(-0.399537), REAL(-0.313131), REAL(-0.376167),
98         REAL(-0.392666), REAL(-0.488581), REAL(-0.427494),
99         REAL(-0.331669), REAL(-0.570185), REAL(-0.466054),
100         REAL(-0.282290), REAL(-0.618140), REAL(-0.589220),
101         REAL(-0.374238), REAL(-0.594882), REAL(-0.323298),
102         REAL(-0.381071), REAL(-0.629723), REAL(-0.350777),
103         REAL(-0.382112), REAL(-0.624060), REAL(-0.221577),
104         REAL(-0.272701), REAL(-0.566522), REAL(0.259157),
105         REAL(-0.256702), REAL(-0.663406), REAL(0.286079),
106         REAL(-0.280948), REAL(-0.428359), REAL(0.055790),
107         REAL(-0.184974), REAL(-0.508894), REAL(0.326265),
108         REAL(-0.279971), REAL(-0.526918), REAL(0.395319),
109         REAL(-0.282599), REAL(-0.663393), REAL(0.412411),
110         REAL(-0.188329), REAL(-0.475093), REAL(0.417954),
111         REAL(-0.263384), REAL(-0.663396), REAL(0.466604),
112         REAL(-0.209063), REAL(-0.663393), REAL(0.509344),
113         REAL(-0.002044), REAL(-0.319624), REAL(0.553078),
114         REAL(-0.001266), REAL(-0.371260), REAL(0.413296),
115         REAL(-0.219753), REAL(-0.339762), REAL(-0.040921),
116         REAL(-0.256986), REAL(-0.282511), REAL(-0.006349),
117         REAL(-0.271706), REAL(-0.260881), REAL(0.001764),
118         REAL(-0.091191), REAL(-0.419184), REAL(-0.045912),
119         REAL(-0.114944), REAL(-0.429752), REAL(-0.124739),
120         REAL(-0.113970), REAL(-0.382987), REAL(-0.188540),
121         REAL(-0.243012), REAL(-0.464942), REAL(-0.242850),
122         REAL(-0.314815), REAL(-0.505402), REAL(-0.324768),
123         REAL(0.002774), REAL(-0.437526), REAL(-0.262766),
124         REAL(-0.072625), REAL(-0.417748), REAL(-0.221440),
125         REAL(-0.160112), REAL(-0.476932), REAL(-0.293450),
126         REAL(0.003859), REAL(-0.453425), REAL(-0.443916),
127         REAL(-0.120363), REAL(-0.581567), REAL(-0.438689),
128         REAL(-0.091499), REAL(-0.584191), REAL(-0.294511),
129         REAL(-0.116469), REAL(-0.599861), REAL(-0.188308),
130         REAL(-0.208032), REAL(-0.513640), REAL(-0.134649),
131         REAL(-0.235749), REAL(-0.610017), REAL(-0.040939),
132         REAL(-0.344916), REAL(-0.622487), REAL(-0.085380),
133         REAL(-0.336401), REAL(-0.531864), REAL(-0.212298),
134         REAL(0.001961), REAL(-0.459550), REAL(-0.135547),
135         REAL(-0.058296), REAL(-0.430536), REAL(-0.043440),
136         REAL(0.001378), REAL(-0.449511), REAL(-0.037762),
137         REAL(-0.130135), REAL(-0.510222), REAL(0.079144),
138         REAL(0.000142), REAL(-0.477549), REAL(0.157064),
139         REAL(-0.114284), REAL(-0.453206), REAL(0.304397),
140         REAL(-0.000592), REAL(-0.443558), REAL(0.285401),
141         REAL(-0.056215), REAL(-0.663402), REAL(0.326073),
142         REAL(-0.026248), REAL(-0.568010), REAL(0.273318),
143         REAL(-0.049261), REAL(-0.531064), REAL(0.389854),
144         REAL(-0.127096), REAL(-0.663398), REAL(0.479316),
145         REAL(-0.058384), REAL(-0.663401), REAL(0.372891),
146         REAL(-0.303961), REAL(0.054199), REAL(0.625921),
147         REAL(-0.268594), REAL(0.193403), REAL(0.502766),
148         REAL(-0.277159), REAL(0.126123), REAL(0.443289),
149         REAL(-0.287605), REAL(-0.005722), REAL(0.531844),
150         REAL(-0.231396), REAL(-0.121289), REAL(0.587387),
151         REAL(-0.253475), REAL(-0.081797), REAL(0.756541),
152         REAL(-0.195164), REAL(-0.137969), REAL(0.728011),
153         REAL(-0.167673), REAL(-0.156573), REAL(0.609388),
154         REAL(-0.145917), REAL(-0.169029), REAL(0.697600),
155         REAL(-0.077776), REAL(-0.214247), REAL(0.622586),
156         REAL(-0.076873), REAL(-0.214971), REAL(0.696301),
157         REAL(-0.002341), REAL(-0.233135), REAL(0.622859),
158         REAL(-0.002730), REAL(-0.213526), REAL(0.691267),
159         REAL(-0.003136), REAL(-0.192628), REAL(0.762731),
160         REAL(-0.056136), REAL(-0.201222), REAL(0.763806),
161         REAL(-0.114589), REAL(-0.166192), REAL(0.770723),
162         REAL(-0.155145), REAL(-0.129632), REAL(0.791738),
163         REAL(-0.183611), REAL(-0.058705), REAL(0.847012),
164         REAL(-0.165562), REAL(0.001980), REAL(0.833386),
165         REAL(-0.220084), REAL(0.019914), REAL(0.768935),
166         REAL(-0.255730), REAL(0.090306), REAL(0.670782),
167         REAL(-0.255594), REAL(0.113833), REAL(0.663389),
168         REAL(-0.226380), REAL(0.212655), REAL(0.617740),
169         REAL(-0.003367), REAL(-0.195342), REAL(0.799680),
170         REAL(-0.029743), REAL(-0.210508), REAL(0.827180),
171         REAL(-0.003818), REAL(-0.194783), REAL(0.873636),
172         REAL(-0.004116), REAL(-0.157907), REAL(0.931268),
173         REAL(-0.031280), REAL(-0.184555), REAL(0.889476),
174         REAL(-0.059885), REAL(-0.184448), REAL(0.841330),
175         REAL(-0.135333), REAL(-0.164332), REAL(0.878200),
176         REAL(-0.085574), REAL(-0.170948), REAL(0.925547),
177         REAL(-0.163833), REAL(-0.094170), REAL(0.897114),
178         REAL(-0.138444), REAL(-0.104250), REAL(0.945975),
179         REAL(-0.083497), REAL(-0.084934), REAL(0.979607),
180         REAL(-0.004433), REAL(-0.146642), REAL(0.985872),
181         REAL(-0.150715), REAL(0.032650), REAL(0.884111),
182         REAL(-0.135892), REAL(-0.035520), REAL(0.945455),
183         REAL(-0.070612), REAL(0.036849), REAL(0.975733),
184         REAL(-0.004458), REAL(-0.042526), REAL(1.015670),
185         REAL(-0.004249), REAL(0.046042), REAL(1.003240),
186         REAL(-0.086969), REAL(0.133224), REAL(0.947633),
187         REAL(-0.003873), REAL(0.161605), REAL(0.970499),
188         REAL(-0.125544), REAL(0.140012), REAL(0.917678),
189         REAL(-0.125651), REAL(0.250246), REAL(0.857602),
190         REAL(-0.003127), REAL(0.284070), REAL(0.878870),
191         REAL(-0.159174), REAL(0.125726), REAL(0.888878),
192         REAL(-0.183807), REAL(0.196970), REAL(0.844480),
193         REAL(-0.159890), REAL(0.291736), REAL(0.732480),
194         REAL(-0.199495), REAL(0.207230), REAL(0.779864),
195         REAL(-0.206182), REAL(0.164608), REAL(0.693257),
196         REAL(-0.186315), REAL(0.160689), REAL(0.817193),
197         REAL(-0.192827), REAL(0.166706), REAL(0.782271),
198         REAL(-0.175112), REAL(0.110008), REAL(0.860621),
199         REAL(-0.161022), REAL(0.057420), REAL(0.855111),
200         REAL(-0.172319), REAL(0.036155), REAL(0.816189),
201         REAL(-0.190318), REAL(0.064083), REAL(0.760605),
202         REAL(-0.195072), REAL(0.129179), REAL(0.731104),
203         REAL(-0.203126), REAL(0.410287), REAL(0.680536),
204         REAL(-0.216677), REAL(0.309274), REAL(0.642272),
205         REAL(-0.241515), REAL(0.311485), REAL(0.587832),
206         REAL(-0.002209), REAL(0.366663), REAL(0.749413),
207         REAL(-0.088230), REAL(0.396265), REAL(0.678635),
208         REAL(-0.170147), REAL(0.109517), REAL(0.840784),
209         REAL(-0.160521), REAL(0.067766), REAL(0.830650),
210         REAL(-0.181546), REAL(0.139805), REAL(0.812146),
211         REAL(-0.180495), REAL(0.148568), REAL(0.776087),
212         REAL(-0.180255), REAL(0.129125), REAL(0.744192),
213         REAL(-0.186298), REAL(0.078308), REAL(0.769352),
214         REAL(-0.167622), REAL(0.060539), REAL(0.806675),
215         REAL(-0.189876), REAL(0.102760), REAL(0.802582),
216         REAL(-0.108340), REAL(0.455446), REAL(0.657174),
217         REAL(-0.241585), REAL(0.527592), REAL(0.669296),
218         REAL(-0.265676), REAL(0.513366), REAL(0.634594),
219         REAL(-0.203073), REAL(0.478550), REAL(0.581526),
220         REAL(-0.266772), REAL(0.642330), REAL(0.602061),
221         REAL(-0.216961), REAL(0.564846), REAL(0.535435),
222         REAL(-0.202210), REAL(0.525495), REAL(0.475944),
223         REAL(-0.193888), REAL(0.467925), REAL(0.520606),
224         REAL(-0.265837), REAL(0.757267), REAL(0.500933),
225         REAL(-0.240306), REAL(0.653440), REAL(0.463215),
226         REAL(-0.309239), REAL(0.776868), REAL(0.304726),
227         REAL(-0.271009), REAL(0.683094), REAL(0.382018),
228         REAL(-0.312111), REAL(0.671099), REAL(0.286687),
229         REAL(-0.268791), REAL(0.624342), REAL(0.377231),
230         REAL(-0.302457), REAL(0.533996), REAL(0.360289),
231         REAL(-0.263656), REAL(0.529310), REAL(0.412564),
232         REAL(-0.282311), REAL(0.415167), REAL(0.447666),
233         REAL(-0.239201), REAL(0.442096), REAL(0.495604),
234         REAL(-0.220043), REAL(0.569026), REAL(0.445877),
235         REAL(-0.001263), REAL(0.395631), REAL(0.602029),
236         REAL(-0.057345), REAL(0.442535), REAL(0.572224),
237         REAL(-0.088927), REAL(0.506333), REAL(0.529106),
238         REAL(-0.125738), REAL(0.535076), REAL(0.612913),
239         REAL(-0.126251), REAL(0.577170), REAL(0.483159),
240         REAL(-0.149594), REAL(0.611520), REAL(0.557731),
241         REAL(-0.163188), REAL(0.660791), REAL(0.491080),
242         REAL(-0.172482), REAL(0.663387), REAL(0.415416),
243         REAL(-0.160464), REAL(0.591710), REAL(0.370659),
244         REAL(-0.156445), REAL(0.536396), REAL(0.378302),
245         REAL(-0.136496), REAL(0.444358), REAL(0.425226),
246         REAL(-0.095564), REAL(0.373768), REAL(0.473659),
247         REAL(-0.104146), REAL(0.315912), REAL(0.498104),
248         REAL(-0.000496), REAL(0.384194), REAL(0.473817),
249         REAL(-0.000183), REAL(0.297770), REAL(0.401486),
250         REAL(-0.129042), REAL(0.270145), REAL(0.434495),
251         REAL(0.000100), REAL(0.272963), REAL(0.349138),
252         REAL(-0.113060), REAL(0.236984), REAL(0.385554),
253         REAL(0.007260), REAL(0.016311), REAL(-0.883396),
254         REAL(0.007865), REAL(0.122104), REAL(-0.956137),
255         REAL(-0.032842), REAL(0.115282), REAL(-0.953252),
256         REAL(-0.089115), REAL(0.108449), REAL(-0.950317),
257         REAL(-0.047440), REAL(0.014729), REAL(-0.882756),
258         REAL(-0.104458), REAL(0.013137), REAL(-0.882070),
259         REAL(-0.086439), REAL(-0.584866), REAL(-0.608343),
260         REAL(-0.115026), REAL(-0.662605), REAL(-0.436732),
261         REAL(-0.071683), REAL(-0.665372), REAL(-0.606385),
262         REAL(-0.257884), REAL(-0.665381), REAL(-0.658052),
263         REAL(-0.272542), REAL(-0.665381), REAL(-0.592063),
264         REAL(-0.371322), REAL(-0.665382), REAL(-0.353620),
265         REAL(-0.372362), REAL(-0.665381), REAL(-0.224420),
266         REAL(-0.335166), REAL(-0.665380), REAL(-0.078623),
267         REAL(-0.225999), REAL(-0.665375), REAL(-0.038981),
268         REAL(-0.106719), REAL(-0.665374), REAL(-0.186351),
269         REAL(-0.081749), REAL(-0.665372), REAL(-0.292554),
270         REAL(0.006943), REAL(-0.091505), REAL(-0.858354),
271         REAL(0.006117), REAL(-0.280985), REAL(-0.769967),
272         REAL(0.004495), REAL(-0.502360), REAL(-0.559799),
273         REAL(-0.198638), REAL(-0.302135), REAL(-0.845816),
274         REAL(-0.237395), REAL(-0.542544), REAL(-0.587188),
275         REAL(-0.270001), REAL(-0.279489), REAL(-0.669861),
276         REAL(-0.134547), REAL(-0.119852), REAL(-0.959004),
277         REAL(-0.052088), REAL(-0.122463), REAL(-0.944549),
278         REAL(-0.124463), REAL(-0.293508), REAL(-0.899566),
279         REAL(-0.047616), REAL(-0.289643), REAL(-0.879292),
280         REAL(-0.168595), REAL(-0.529132), REAL(-0.654931),
281         REAL(-0.099793), REAL(-0.515719), REAL(-0.645873),
282         REAL(-0.186168), REAL(-0.605282), REAL(-0.724690),
283         REAL(-0.112970), REAL(-0.583097), REAL(-0.707469),
284         REAL(-0.108152), REAL(-0.665375), REAL(-0.700408),
285         REAL(-0.183019), REAL(-0.665378), REAL(-0.717630),
286         REAL(-0.349529), REAL(-0.334459), REAL(-0.511985),
287         REAL(-0.141182), REAL(-0.437705), REAL(-0.798194),
288         REAL(-0.212670), REAL(-0.448725), REAL(-0.737447),
289         REAL(-0.261111), REAL(-0.414945), REAL(-0.613835),
290         REAL(-0.077364), REAL(-0.431480), REAL(-0.778113),
291         REAL(0.005174), REAL(-0.425277), REAL(-0.651592),
292         REAL(0.089236), REAL(-0.431732), REAL(-0.777093),
293         REAL(0.271006), REAL(-0.415749), REAL(-0.610577),
294         REAL(0.223981), REAL(-0.449384), REAL(-0.734774),
295         REAL(0.153275), REAL(-0.438150), REAL(-0.796391),
296         REAL(0.358414), REAL(-0.335529), REAL(-0.507649),
297         REAL(0.193434), REAL(-0.665946), REAL(-0.715325),
298         REAL(0.118363), REAL(-0.665717), REAL(-0.699021),
299         REAL(0.123515), REAL(-0.583454), REAL(-0.706020),
300         REAL(0.196851), REAL(-0.605860), REAL(-0.722345),
301         REAL(0.109788), REAL(-0.516035), REAL(-0.644590),
302         REAL(0.178656), REAL(-0.529656), REAL(-0.652804),
303         REAL(0.061157), REAL(-0.289807), REAL(-0.878626),
304         REAL(0.138234), REAL(-0.293905), REAL(-0.897958),
305         REAL(0.066933), REAL(-0.122643), REAL(-0.943820),
306         REAL(0.149571), REAL(-0.120281), REAL(-0.957264),
307         REAL(0.280989), REAL(-0.280321), REAL(-0.666487),
308         REAL(0.246581), REAL(-0.543275), REAL(-0.584224),
309         REAL(0.211720), REAL(-0.302754), REAL(-0.843303),
310         REAL(0.086966), REAL(-0.665627), REAL(-0.291520),
311         REAL(0.110634), REAL(-0.665702), REAL(-0.185021),
312         REAL(0.228099), REAL(-0.666061), REAL(-0.036201),
313         REAL(0.337743), REAL(-0.666396), REAL(-0.074503),
314         REAL(0.376722), REAL(-0.666513), REAL(-0.219833),
315         REAL(0.377265), REAL(-0.666513), REAL(-0.349036),
316         REAL(0.281411), REAL(-0.666217), REAL(-0.588670),
317         REAL(0.267564), REAL(-0.666174), REAL(-0.654834),
318         REAL(0.080745), REAL(-0.665602), REAL(-0.605452),
319         REAL(0.122016), REAL(-0.662963), REAL(-0.435280),
320         REAL(0.095767), REAL(-0.585141), REAL(-0.607228),
321         REAL(0.118944), REAL(0.012799), REAL(-0.880702),
322         REAL(0.061944), REAL(0.014564), REAL(-0.882086),
323         REAL(0.104725), REAL(0.108156), REAL(-0.949130),
324         REAL(0.048513), REAL(0.115159), REAL(-0.952753),
325         REAL(0.112696), REAL(0.236643), REAL(0.386937),
326         REAL(0.128177), REAL(0.269757), REAL(0.436071),
327         REAL(0.102643), REAL(0.315600), REAL(0.499370),
328         REAL(0.094535), REAL(0.373481), REAL(0.474824),
329         REAL(0.136270), REAL(0.443946), REAL(0.426895),
330         REAL(0.157071), REAL(0.535923), REAL(0.380222),
331         REAL(0.161350), REAL(0.591224), REAL(0.372630),
332         REAL(0.173035), REAL(0.662865), REAL(0.417531),
333         REAL(0.162808), REAL(0.660299), REAL(0.493077),
334         REAL(0.148250), REAL(0.611070), REAL(0.559555),
335         REAL(0.125719), REAL(0.576790), REAL(0.484702),
336         REAL(0.123489), REAL(0.534699), REAL(0.614440),
337         REAL(0.087621), REAL(0.506066), REAL(0.530188),
338         REAL(0.055321), REAL(0.442365), REAL(0.572915),
339         REAL(0.219936), REAL(0.568361), REAL(0.448571),
340         REAL(0.238099), REAL(0.441375), REAL(0.498528),
341         REAL(0.281711), REAL(0.414315), REAL(0.451121),
342         REAL(0.263833), REAL(0.528513), REAL(0.415794),
343         REAL(0.303284), REAL(0.533081), REAL(0.363998),
344         REAL(0.269687), REAL(0.623528), REAL(0.380528),
345         REAL(0.314255), REAL(0.670153), REAL(0.290524),
346         REAL(0.272023), REAL(0.682273), REAL(0.385343),
347         REAL(0.311480), REAL(0.775931), REAL(0.308527),
348         REAL(0.240239), REAL(0.652714), REAL(0.466159),
349         REAL(0.265619), REAL(0.756464), REAL(0.504187),
350         REAL(0.192562), REAL(0.467341), REAL(0.522972),
351         REAL(0.201605), REAL(0.524885), REAL(0.478417),
352         REAL(0.215743), REAL(0.564193), REAL(0.538084),
353         REAL(0.264969), REAL(0.641527), REAL(0.605317),
354         REAL(0.201031), REAL(0.477940), REAL(0.584002),
355         REAL(0.263086), REAL(0.512567), REAL(0.637832),
356         REAL(0.238615), REAL(0.526867), REAL(0.672237),
357         REAL(0.105309), REAL(0.455123), REAL(0.658482),
358         REAL(0.183993), REAL(0.102195), REAL(0.804872),
359         REAL(0.161563), REAL(0.060042), REAL(0.808692),
360         REAL(0.180748), REAL(0.077754), REAL(0.771600),
361         REAL(0.175168), REAL(0.128588), REAL(0.746368),
362         REAL(0.175075), REAL(0.148030), REAL(0.778264),
363         REAL(0.175658), REAL(0.139265), REAL(0.814333),
364         REAL(0.154191), REAL(0.067291), REAL(0.832578),
365         REAL(0.163818), REAL(0.109013), REAL(0.842830),
366         REAL(0.084760), REAL(0.396004), REAL(0.679695),
367         REAL(0.238888), REAL(0.310760), REAL(0.590775),
368         REAL(0.213380), REAL(0.308625), REAL(0.644905),
369         REAL(0.199666), REAL(0.409678), REAL(0.683003),
370         REAL(0.190143), REAL(0.128597), REAL(0.733463),
371         REAL(0.184833), REAL(0.063516), REAL(0.762902),
372         REAL(0.166070), REAL(0.035644), REAL(0.818261),
373         REAL(0.154361), REAL(0.056943), REAL(0.857042),
374         REAL(0.168542), REAL(0.109489), REAL(0.862725),
375         REAL(0.187387), REAL(0.166131), REAL(0.784599),
376         REAL(0.180428), REAL(0.160135), REAL(0.819438),
377         REAL(0.201823), REAL(0.163991), REAL(0.695756),
378         REAL(0.194206), REAL(0.206635), REAL(0.782275),
379         REAL(0.155438), REAL(0.291260), REAL(0.734412),
380         REAL(0.177696), REAL(0.196424), REAL(0.846693),
381         REAL(0.152305), REAL(0.125256), REAL(0.890786),
382         REAL(0.119546), REAL(0.249876), REAL(0.859104),
383         REAL(0.118369), REAL(0.139643), REAL(0.919173),
384         REAL(0.079410), REAL(0.132973), REAL(0.948652),
385         REAL(0.062419), REAL(0.036648), REAL(0.976547),
386         REAL(0.127847), REAL(-0.035919), REAL(0.947070),
387         REAL(0.143624), REAL(0.032206), REAL(0.885913),
388         REAL(0.074888), REAL(-0.085173), REAL(0.980577),
389         REAL(0.130184), REAL(-0.104656), REAL(0.947620),
390         REAL(0.156201), REAL(-0.094653), REAL(0.899074),
391         REAL(0.077366), REAL(-0.171194), REAL(0.926545),
392         REAL(0.127722), REAL(-0.164729), REAL(0.879810),
393         REAL(0.052670), REAL(-0.184618), REAL(0.842019),
394         REAL(0.023477), REAL(-0.184638), REAL(0.889811),
395         REAL(0.022626), REAL(-0.210587), REAL(0.827500),
396         REAL(0.223089), REAL(0.211976), REAL(0.620493),
397         REAL(0.251444), REAL(0.113067), REAL(0.666494),
398         REAL(0.251419), REAL(0.089540), REAL(0.673887),
399         REAL(0.214360), REAL(0.019258), REAL(0.771595),
400         REAL(0.158999), REAL(0.001490), REAL(0.835374),
401         REAL(0.176696), REAL(-0.059249), REAL(0.849218),
402         REAL(0.148696), REAL(-0.130091), REAL(0.793599),
403         REAL(0.108290), REAL(-0.166528), REAL(0.772088),
404         REAL(0.049820), REAL(-0.201382), REAL(0.764454),
405         REAL(0.071341), REAL(-0.215195), REAL(0.697209),
406         REAL(0.073148), REAL(-0.214475), REAL(0.623510),
407         REAL(0.140502), REAL(-0.169461), REAL(0.699354),
408         REAL(0.163374), REAL(-0.157073), REAL(0.611416),
409         REAL(0.189466), REAL(-0.138550), REAL(0.730366),
410         REAL(0.247593), REAL(-0.082554), REAL(0.759610),
411         REAL(0.227468), REAL(-0.121982), REAL(0.590197),
412         REAL(0.284702), REAL(-0.006586), REAL(0.535347),
413         REAL(0.275741), REAL(0.125287), REAL(0.446676),
414         REAL(0.266650), REAL(0.192594), REAL(0.506044),
415         REAL(0.300086), REAL(0.053287), REAL(0.629620),
416         REAL(0.055450), REAL(-0.663935), REAL(0.375065),
417         REAL(0.122854), REAL(-0.664138), REAL(0.482323),
418         REAL(0.046520), REAL(-0.531571), REAL(0.391918),
419         REAL(0.024824), REAL(-0.568450), REAL(0.275106),
420         REAL(0.053855), REAL(-0.663931), REAL(0.328224),
421         REAL(0.112829), REAL(-0.453549), REAL(0.305788),
422         REAL(0.131265), REAL(-0.510617), REAL(0.080746),
423         REAL(0.061174), REAL(-0.430716), REAL(-0.042710),
424         REAL(0.341019), REAL(-0.532887), REAL(-0.208150),
425         REAL(0.347705), REAL(-0.623533), REAL(-0.081139),
426         REAL(0.238040), REAL(-0.610732), REAL(-0.038037),
427         REAL(0.211764), REAL(-0.514274), REAL(-0.132078),
428         REAL(0.120605), REAL(-0.600219), REAL(-0.186856),
429         REAL(0.096985), REAL(-0.584476), REAL(-0.293357),
430         REAL(0.127621), REAL(-0.581941), REAL(-0.437170),
431         REAL(0.165902), REAL(-0.477425), REAL(-0.291453),
432         REAL(0.077720), REAL(-0.417975), REAL(-0.220519),
433         REAL(0.320892), REAL(-0.506363), REAL(-0.320874),
434         REAL(0.248214), REAL(-0.465684), REAL(-0.239842),
435         REAL(0.118764), REAL(-0.383338), REAL(-0.187114),
436         REAL(0.118816), REAL(-0.430106), REAL(-0.123307),
437         REAL(0.094131), REAL(-0.419464), REAL(-0.044777),
438         REAL(0.274526), REAL(-0.261706), REAL(0.005110),
439         REAL(0.259842), REAL(-0.283292), REAL(-0.003185),
440         REAL(0.222861), REAL(-0.340431), REAL(-0.038210),
441         REAL(0.204445), REAL(-0.664380), REAL(0.513353),
442         REAL(0.259286), REAL(-0.664547), REAL(0.471281),
443         REAL(0.185402), REAL(-0.476020), REAL(0.421718),
444         REAL(0.279163), REAL(-0.664604), REAL(0.417328),
445         REAL(0.277157), REAL(-0.528122), REAL(0.400208),
446         REAL(0.183069), REAL(-0.509812), REAL(0.329995),
447         REAL(0.282599), REAL(-0.429210), REAL(0.059242),
448         REAL(0.254816), REAL(-0.664541), REAL(0.290687),
449         REAL(0.271436), REAL(-0.567707), REAL(0.263966),
450         REAL(0.386561), REAL(-0.625221), REAL(-0.216870),
451         REAL(0.387086), REAL(-0.630883), REAL(-0.346073),
452         REAL(0.380021), REAL(-0.596021), REAL(-0.318679),
453         REAL(0.291269), REAL(-0.619007), REAL(-0.585707),
454         REAL(0.339280), REAL(-0.571198), REAL(-0.461946),
455         REAL(0.400045), REAL(-0.489778), REAL(-0.422640),
456         REAL(0.406817), REAL(-0.314349), REAL(-0.371230),
457         REAL(0.300588), REAL(-0.281718), REAL(-0.170549),
458         REAL(0.290866), REAL(-0.277304), REAL(-0.061905),
459         REAL(0.187735), REAL(-0.241545), REAL(0.509437),
460         REAL(0.188032), REAL(-0.287569), REAL(0.424234),
461         REAL(0.227520), REAL(-0.373262), REAL(0.293102),
462         REAL(0.266526), REAL(-0.273650), REAL(0.039597),
463         REAL(0.291592), REAL(-0.291676), REAL(0.111386),
464         REAL(0.291914), REAL(-0.122741), REAL(0.422683),
465         REAL(0.297574), REAL(-0.156119), REAL(0.373368),
466         REAL(0.286603), REAL(-0.232731), REAL(0.027162),
467         REAL(0.364663), REAL(-0.201399), REAL(0.206850),
468         REAL(0.353855), REAL(-0.132408), REAL(0.149228),
469         REAL(0.282208), REAL(-0.019715), REAL(0.314960),
470         REAL(0.331187), REAL(-0.099266), REAL(0.092701),
471         REAL(0.375463), REAL(-0.093120), REAL(-0.006467),
472         REAL(0.375917), REAL(-0.101236), REAL(-0.154882),
473         REAL(0.466635), REAL(-0.094416), REAL(-0.305669),
474         REAL(0.455805), REAL(-0.119881), REAL(-0.460632),
475         REAL(0.277465), REAL(-0.604242), REAL(-0.651871),
476         REAL(0.261022), REAL(-0.551176), REAL(-0.554667),
477         REAL(0.093627), REAL(0.258494), REAL(-0.920589),
478         REAL(0.114248), REAL(0.310608), REAL(-0.798070),
479         REAL(0.144232), REAL(0.211434), REAL(-0.835001),
480         REAL(0.119916), REAL(0.176940), REAL(-0.951159),
481         REAL(0.184061), REAL(0.101854), REAL(-0.918220),
482         REAL(0.092431), REAL(0.276521), REAL(-0.738231),
483         REAL(0.133504), REAL(0.218403), REAL(-0.758602),
484         REAL(0.194987), REAL(0.097655), REAL(-0.812476),
485         REAL(0.185542), REAL(0.011005), REAL(-0.879202),
486         REAL(0.230315), REAL(-0.127450), REAL(-0.884202),
487         REAL(0.260471), REAL(0.255056), REAL(-0.624378),
488         REAL(0.351567), REAL(-0.042194), REAL(-0.663976),
489         REAL(0.253742), REAL(0.323524), REAL(-0.433716),
490         REAL(0.411612), REAL(0.132299), REAL(-0.438264),
491         REAL(0.270513), REAL(0.356530), REAL(-0.289984),
492         REAL(0.422146), REAL(0.162819), REAL(-0.273130),
493         REAL(0.164724), REAL(0.237490), REAL(0.208912),
494         REAL(0.253806), REAL(0.092900), REAL(0.240640),
495         REAL(0.203608), REAL(0.284597), REAL(0.096223),
496         REAL(0.241006), REAL(0.343093), REAL(-0.171396),
497         REAL(0.356076), REAL(0.149288), REAL(-0.143443),
498         REAL(0.337656), REAL(0.131992), REAL(0.066374)
499 };
500
501 int gIndices[NUM_TRIANGLES][3] = {
502         {126,134,133},
503         {342,138,134},
504         {133,134,138},
505         {126,342,134},
506         {312,316,317},
507         {169,163,162},
508         {312,317,319},
509         {312,319,318},
510         {169,162,164},
511         {169,168,163},
512         {312,314,315},
513         {169,164,165},
514         {169,167,168},
515         {312,315,316},
516         {312,313,314},
517         {169,165,166},
518         {169,166,167},
519         {312,318,313},
520         {308,304,305},
521         {308,305,306},
522         {179,181,188},
523         {177,173,175},
524         {177,175,176},
525         {302,293,300},
526         {322,294,304},
527         {188,176,175},
528         {188,175,179},
529         {158,177,187},
530         {305,293,302},
531         {305,302,306},
532         {322,304,308},
533         {188,181,183},
534         {158,173,177},
535         {293,298,300},
536         {304,294,296},
537         {304,296,305},
538         {185,176,188},
539         {185,188,183},
540         {187,177,176},
541         {187,176,185},
542         {305,296,298},
543         {305,298,293},
544         {436,432, 28},
545         {436, 28, 23},
546         {434,278,431},
547         { 30,208,209},
548         { 30,209, 29},
549         { 19, 20, 24},
550         {208,207,211},
551         {208,211,209},
552         { 19,210,212},
553         {433,434,431},
554         {433,431,432},
555         {433,432,436},
556         {436,437,433},
557         {277,275,276},
558         {277,276,278},
559         {209,210, 25},
560         { 21, 26, 24},
561         { 21, 24, 20},
562         { 25, 26, 27},
563         { 25, 27, 29},
564         {435,439,277},
565         {439,275,277},
566         {432,431, 30},
567         {432, 30, 28},
568         {433,437,438},
569         {433,438,435},
570         {434,277,278},
571         { 24, 25,210},
572         { 24, 26, 25},
573         { 29, 27, 28},
574         { 29, 28, 30},
575         { 19, 24,210},
576         {208, 30,431},
577         {208,431,278},
578         {435,434,433},
579         {435,277,434},
580         { 25, 29,209},
581         { 27, 22, 23},
582         { 27, 23, 28},
583         { 26, 22, 27},
584         { 26, 21, 22},
585         {212,210,209},
586         {212,209,211},
587         {207,208,278},
588         {207,278,276},
589         {439,435,438},
590         { 12,  9, 10},
591         { 12, 10, 13},
592         {  2,  3,  5},
593         {  2,  5,  4},
594         { 16, 13, 14},
595         { 16, 14, 17},
596         { 22, 21, 16},
597         { 13, 10, 11},
598         { 13, 11, 14},
599         {  1,  0,  3},
600         {  1,  3,  2},
601         { 15, 12, 16},
602         { 19, 18, 15},
603         { 19, 15, 16},
604         { 19, 16, 20},
605         {  9,  1,  2},
606         {  9,  2, 10},
607         {  3,  7,  8},
608         {  3,  8,  5},
609         { 16, 17, 23},
610         { 16, 23, 22},
611         { 21, 20, 16},
612         { 10,  2,  4},
613         { 10,  4, 11},
614         {  0,  6,  7},
615         {  0,  7,  3},
616         { 12, 13, 16},
617         {451,446,445},
618         {451,445,450},
619         {442,440,439},
620         {442,439,438},
621         {442,438,441},
622         {421,420,422},
623         {412,411,426},
624         {412,426,425},
625         {408,405,407},
626         {413, 67, 68},
627         {413, 68,414},
628         {391,390,412},
629         { 80,384,386},
630         {404,406,378},
631         {390,391,377},
632         {390,377, 88},
633         {400,415,375},
634         {398,396,395},
635         {398,395,371},
636         {398,371,370},
637         {112,359,358},
638         {112,358,113},
639         {351,352,369},
640         {125,349,348},
641         {345,343,342},
642         {342,340,339},
643         {341,335,337},
644         {328,341,327},
645         {331,323,333},
646         {331,322,323},
647         {327,318,319},
648         {327,319,328},
649         {315,314,324},
650         {302,300,301},
651         {302,301,303},
652         {320,311,292},
653         {285,284,289},
654         {310,307,288},
655         {310,288,290},
656         {321,350,281},
657         {321,281,282},
658         {423,448,367},
659         {272,273,384},
660         {272,384,274},
661         {264,265,382},
662         {264,382,383},
663         {440,442,261},
664         {440,261,263},
665         {252,253,254},
666         {252,254,251},
667         {262,256,249},
668         {262,249,248},
669         {228,243,242},
670         {228, 31,243},
671         {213,215,238},
672         {213,238,237},
673         { 19,212,230},
674         {224,225,233},
675         {224,233,231},
676         {217,218, 56},
677         {217, 56, 54},
678         {217,216,239},
679         {217,239,238},
680         {217,238,215},
681         {218,217,215},
682         {218,215,214},
683         {  6,102,206},
684         {186,199,200},
685         {197,182,180},
686         {170,171,157},
687         {201,200,189},
688         {170,190,191},
689         {170,191,192},
690         {175,174,178},
691         {175,178,179},
692         {168,167,155},
693         {122,149,158},
694         {122,158,159},
695         {135,153,154},
696         {135,154,118},
697         {143,140,141},
698         {143,141,144},
699         {132,133,136},
700         {130,126,133},
701         {124,125,127},
702         {122,101,100},
703         {122,100,121},
704         {110,108,107},
705         {110,107,109},
706         { 98, 99, 97},
707         { 98, 97, 64},
708         { 98, 64, 66},
709         { 87, 55, 57},
710         { 83, 82, 79},
711         { 83, 79, 84},
712         { 78, 74, 50},
713         { 49, 71, 41},
714         { 49, 41, 37},
715         { 49, 37, 36},
716         { 58, 44, 60},
717         { 60, 59, 58},
718         { 51, 34, 33},
719         { 39, 40, 42},
720         { 39, 42, 38},
721         {243,240, 33},
722         {243, 33,229},
723         { 39, 38,  6},
724         { 44, 46, 40},
725         { 55, 56, 57},
726         { 64, 62, 65},
727         { 64, 65, 66},
728         { 41, 71, 45},
729         { 75, 50, 51},
730         { 81, 79, 82},
731         { 77, 88, 73},
732         { 93, 92, 94},
733         { 68, 47, 46},
734         { 96, 97, 99},
735         { 96, 99, 95},
736         {110,109,111},
737         {111,112,110},
738         {114,113,123},
739         {114,123,124},
740         {132,131,129},
741         {133,137,136},
742         {135,142,145},
743         {145,152,135},
744         {149,147,157},
745         {157,158,149},
746         {164,150,151},
747         {153,163,168},
748         {153,168,154},
749         {185,183,182},
750         {185,182,184},
751         {161,189,190},
752         {200,199,191},
753         {200,191,190},
754         {180,178,195},
755         {180,195,196},
756         {102,101,204},
757         {102,204,206},
758         { 43, 48,104},
759         { 43,104,103},
760         {216,217, 54},
761         {216, 54, 32},
762         {207,224,231},
763         {230,212,211},
764         {230,211,231},
765         {227,232,241},
766         {227,241,242},
767         {235,234,241},
768         {235,241,244},
769         {430,248,247},
770         {272,274,253},
771         {272,253,252},
772         {439,260,275},
773         {225,224,259},
774         {225,259,257},
775         {269,270,407},
776         {269,407,405},
777         {270,269,273},
778         {270,273,272},
779         {273,269,268},
780         {273,268,267},
781         {273,267,266},
782         {273,266,265},
783         {273,265,264},
784         {448,279,367},
785         {281,350,368},
786         {285,286,301},
787         {290,323,310},
788         {290,311,323},
789         {282,281,189},
790         {292,311,290},
791         {292,290,291},
792         {307,306,302},
793         {307,302,303},
794         {316,315,324},
795         {316,324,329},
796         {331,351,350},
797         {330,334,335},
798         {330,335,328},
799         {341,337,338},
800         {344,355,354},
801         {346,345,348},
802         {346,348,347},
803         {364,369,352},
804         {364,352,353},
805         {365,363,361},
806         {365,361,362},
807         {376,401,402},
808         {373,372,397},
809         {373,397,400},
810         {376, 92,377},
811         {381,378,387},
812         {381,387,385},
813         {386, 77, 80},
814         {390,389,412},
815         {416,417,401},
816         {403,417,415},
817         {408,429,430},
818         {419,423,418},
819         {427,428,444},
820         {427,444,446},
821         {437,436,441},
822         {450,445, 11},
823         {450, 11,  4},
824         {447,449,  5},
825         {447,  5,  8},
826         {441,438,437},
827         {425,426,451},
828         {425,451,452},
829         {417,421,415},
830         {408,407,429},
831         {399,403,400},
832         {399,400,397},
833         {394,393,416},
834         {389,411,412},
835         {386,383,385},
836         {408,387,378},
837         {408,378,406},
838         {377,391,376},
839         { 94,375,415},
840         {372,373,374},
841         {372,374,370},
842         {359,111,360},
843         {359,112,111},
844         {113,358,349},
845         {113,349,123},
846         {346,343,345},
847         {343,340,342},
848         {338,336,144},
849         {338,144,141},
850         {327,341,354},
851         {327,354,326},
852         {331,350,321},
853         {331,321,322},
854         {314,313,326},
855         {314,326,325},
856         {300,298,299},
857         {300,299,301},
858         {288,287,289},
859         {189,292,282},
860         {287,288,303},
861         {284,285,297},
862         {368,280,281},
863         {448,447,279},
864         {274,226,255},
865         {267,268,404},
866         {267,404,379},
867         {429,262,430},
868         {439,440,260},
869         {257,258,249},
870         {257,249,246},
871         {430,262,248},
872         {234,228,242},
873         {234,242,241},
874         {237,238,239},
875         {237,239,236},
876         { 15, 18,227},
877         { 15,227,229},
878         {222,223, 82},
879         {222, 82, 83},
880         {214,215,213},
881         {214,213, 81},
882         { 38,102,  6},
883         {122,159,200},
884         {122,200,201},
885         {174,171,192},
886         {174,192,194},
887         {197,193,198},
888         {190,170,161},
889         {181,179,178},
890         {181,178,180},
891         {166,156,155},
892         {163,153,152},
893         {163,152,162},
894         {120,156,149},
895         {120,149,121},
896         {152,153,135},
897         {140,143,142},
898         {135,131,132},
899         {135,132,136},
900         {130,129,128},
901         {130,128,127},
902         {100,105,119},
903         {100,119,120},
904         {106,104,107},
905         {106,107,108},
906         { 91, 95, 59},
907         { 93, 94, 68},
908         { 91, 89, 92},
909         { 76, 53, 55},
910         { 76, 55, 87},
911         { 81, 78, 79},
912         { 74, 73, 49},
913         { 69, 60, 45},
914         { 58, 62, 64},
915         { 58, 64, 61},
916         { 53, 31, 32},
917         { 32, 54, 53},
918         { 42, 43, 38},
919         { 35, 36,  0},
920         { 35,  0,  1},
921         { 34, 35,  1},
922         { 34,  1,  9},
923         { 44, 40, 41},
924         { 44, 41, 45},
925         { 33,240, 51},
926         { 63, 62, 58},
927         { 63, 58, 59},
928         { 45, 71, 70},
929         { 76, 75, 51},
930         { 76, 51, 52},
931         { 86, 85, 84},
932         { 86, 84, 87},
933         { 89, 72, 73},
934         { 89, 73, 88},
935         { 91, 92, 96},
936         { 91, 96, 95},
937         { 72, 91, 60},
938         { 72, 60, 69},
939         {104,106,105},
940         {119,105,117},
941         {119,117,118},
942         {124,127,128},
943         {117,116,129},
944         {117,129,131},
945         {118,117,131},
946         {135,140,142},
947         {146,150,152},
948         {146,152,145},
949         {149,122,121},
950         {166,165,151},
951         {166,151,156},
952         {158,172,173},
953         {161,160,189},
954         {199,198,193},
955         {199,193,191},
956         {204,201,202},
957         {178,174,194},
958         {200,159,186},
959         {109, 48, 67},
960         { 48,107,104},
961         {216, 32,236},
962         {216,236,239},
963         {223,214, 81},
964         {223, 81, 82},
965         { 33, 12, 15},
966         { 32,228,234},
967         { 32,234,236},
968         {240, 31, 52},
969         {256,255,246},
970         {256,246,249},
971         {258,263,248},
972         {258,248,249},
973         {275,260,259},
974         {275,259,276},
975         {207,276,259},
976         {270,271,429},
977         {270,429,407},
978         {413,418,366},
979         {413,366,365},
980         {368,367,279},
981         {368,279,280},
982         {303,301,286},
983         {303,286,287},
984         {283,282,292},
985         {283,292,291},
986         {320,292,189},
987         {298,296,297},
988         {298,297,299},
989         {318,327,326},
990         {318,326,313},
991         {329,330,317},
992         {336,333,320},
993         {326,354,353},
994         {334,332,333},
995         {334,333,336},
996         {342,339,139},
997         {342,139,138},
998         {345,342,126},
999         {347,357,356},
1000         {369,368,351},
1001         {363,356,357},
1002         {363,357,361},
1003         {366,367,368},
1004         {366,368,369},
1005         {375,373,400},
1006         { 92, 90,377},
1007         {409,387,408},
1008         {386,385,387},
1009         {386,387,388},
1010         {412,394,391},
1011         {396,398,399},
1012         {408,406,405},
1013         {415,421,419},
1014         {415,419,414},
1015         {425,452,448},
1016         {425,448,424},
1017         {444,441,443},
1018         {448,452,449},
1019         {448,449,447},
1020         {446,444,443},
1021         {446,443,445},
1022         {250,247,261},
1023         {250,261,428},
1024         {421,422,423},
1025         {421,423,419},
1026         {427,410,250},
1027         {417,403,401},
1028         {403,402,401},
1029         {420,392,412},
1030         {420,412,425},
1031         {420,425,424},
1032         {386,411,389},
1033         {383,382,381},
1034         {383,381,385},
1035         {378,379,404},
1036         {372,371,395},
1037         {372,395,397},
1038         {371,372,370},
1039         {361,359,360},
1040         {361,360,362},
1041         {368,350,351},
1042         {349,347,348},
1043         {356,355,344},
1044         {356,344,346},
1045         {344,341,340},
1046         {344,340,343},
1047         {338,337,336},
1048         {328,335,341},
1049         {324,352,351},
1050         {324,351,331},
1051         {320,144,336},
1052         {314,325,324},
1053         {322,308,309},
1054         {310,309,307},
1055         {287,286,289},
1056         {203,280,279},
1057         {203,279,205},
1058         {297,295,283},
1059         {297,283,284},
1060         {447,205,279},
1061         {274,384, 80},
1062         {274, 80,226},
1063         {266,267,379},
1064         {266,379,380},
1065         {225,257,246},
1066         {225,246,245},
1067         {256,254,253},
1068         {256,253,255},
1069         {430,247,250},
1070         {226,235,244},
1071         {226,244,245},
1072         {232,233,244},
1073         {232,244,241},
1074         {230, 18, 19},
1075         { 32, 31,228},
1076         {219,220, 86},
1077         {219, 86, 57},
1078         {226,213,235},
1079         {206,  7,  6},
1080         {122,201,101},
1081         {201,204,101},
1082         {180,196,197},
1083         {170,192,171},
1084         {200,190,189},
1085         {194,193,195},
1086         {183,181,180},
1087         {183,180,182},
1088         {155,154,168},
1089         {149,156,151},
1090         {149,151,148},
1091         {155,156,120},
1092         {145,142,143},
1093         {145,143,146},
1094         {136,137,140},
1095         {133,132,130},
1096         {128,129,116},
1097         {100,120,121},
1098         {110,112,113},
1099         {110,113,114},
1100         { 66, 65, 63},
1101         { 66, 63, 99},
1102         { 66, 99, 98},
1103         { 96, 46, 61},
1104         { 89, 88, 90},
1105         { 86, 87, 57},
1106         { 80, 78, 81},
1107         { 72, 69, 49},
1108         { 67, 48, 47},
1109         { 67, 47, 68},
1110         { 56, 55, 53},
1111         { 50, 49, 36},
1112         { 50, 36, 35},
1113         { 40, 39, 41},
1114         {242,243,229},
1115         {242,229,227},
1116         {  6, 37, 39},
1117         { 42, 47, 48},
1118         { 42, 48, 43},
1119         { 61, 46, 44},
1120         { 45, 70, 69},
1121         { 69, 70, 71},
1122         { 69, 71, 49},
1123         { 74, 78, 77},
1124         { 83, 84, 85},
1125         { 73, 74, 77},
1126         { 93, 96, 92},
1127         { 68, 46, 93},
1128         { 95, 99, 63},
1129         { 95, 63, 59},
1130         {115,108,110},
1131         {115,110,114},
1132         {125,126,127},
1133         {129,130,132},
1134         {137,133,138},
1135         {137,138,139},
1136         {148,146,143},
1137         {148,143,147},
1138         {119,118,154},
1139         {161,147,143},
1140         {165,164,151},
1141         {158,157,171},
1142         {158,171,172},
1143         {159,158,187},
1144         {159,187,186},
1145         {194,192,191},
1146         {194,191,193},
1147         {189,202,201},
1148         {182,197,184},
1149         {205,  8,  7},
1150         { 48,109,107},
1151         {218,219, 57},
1152         {218, 57, 56},
1153         {207,231,211},
1154         {232,230,231},
1155         {232,231,233},
1156         { 53, 52, 31},
1157         {388,411,386},
1158         {409,430,250},
1159         {262,429,254},
1160         {262,254,256},
1161         {442,444,428},
1162         {273,264,383},
1163         {273,383,384},
1164         {429,271,251},
1165         {429,251,254},
1166         {413,365,362},
1167         { 67,413,360},
1168         {282,283,295},
1169         {285,301,299},
1170         {202,281,280},
1171         {284,283,291},
1172         {284,291,289},
1173         {320,189,160},
1174         {308,306,307},
1175         {307,309,308},
1176         {319,317,330},
1177         {319,330,328},
1178         {353,352,324},
1179         {332,331,333},
1180         {340,341,338},
1181         {354,341,344},
1182         {349,358,357},
1183         {349,357,347},
1184         {364,355,356},
1185         {364,356,363},
1186         {364,365,366},
1187         {364,366,369},
1188         {374,376,402},
1189         {375, 92,373},
1190         { 77,389,390},
1191         {382,380,381},
1192         {389, 77,386},
1193         {393,394,412},
1194         {393,412,392},
1195         {401,394,416},
1196         {415,400,403},
1197         {411,410,427},
1198         {411,427,426},
1199         {422,420,424},
1200         {247,248,263},
1201         {247,263,261},
1202         {445,443, 14},
1203         {445, 14, 11},
1204         {449,450,  4},
1205         {449,  4,  5},
1206         {443,441, 17},
1207         {443, 17, 14},
1208         {436, 23, 17},
1209         {436, 17,441},
1210         {424,448,422},
1211         {448,423,422},
1212         {414,419,418},
1213         {414,418,413},
1214         {406,404,405},
1215         {399,397,395},
1216         {399,395,396},
1217         {420,416,392},
1218         {388,410,411},
1219         {386,384,383},
1220         {390, 88, 77},
1221         {375, 94, 92},
1222         {415,414, 68},
1223         {415, 68, 94},
1224         {370,374,402},
1225         {370,402,398},
1226         {361,357,358},
1227         {361,358,359},
1228         {125,348,126},
1229         {346,344,343},
1230         {340,338,339},
1231         {337,335,334},
1232         {337,334,336},
1233         {325,353,324},
1234         {324,331,332},
1235         {324,332,329},
1236         {323,322,309},
1237         {323,309,310},
1238         {294,295,297},
1239         {294,297,296},
1240         {289,286,285},
1241         {202,280,203},
1242         {288,307,303},
1243         {282,295,321},
1244         { 67,360,111},
1245         {418,423,367},
1246         {418,367,366},
1247         {272,252,251},
1248         {272,251,271},
1249         {272,271,270},
1250         {255,253,274},
1251         {265,266,380},
1252         {265,380,382},
1253         {442,428,261},
1254         {440,263,258},
1255         {440,258,260},
1256         {409,250,410},
1257         {255,226,245},
1258         {255,245,246},
1259         { 31,240,243},
1260         {236,234,235},
1261         {236,235,237},
1262         {233,225,245},
1263         {233,245,244},
1264         {220,221, 85},
1265         {220, 85, 86},
1266         { 81,213,226},
1267         { 81,226, 80},
1268         {  7,206,205},
1269         {186,184,198},
1270         {186,198,199},
1271         {204,203,205},
1272         {204,205,206},
1273         {195,193,196},
1274         {171,174,172},
1275         {173,174,175},
1276         {173,172,174},
1277         {155,167,166},
1278         {160,161,143},
1279         {160,143,144},
1280         {119,154,155},
1281         {148,151,150},
1282         {148,150,146},
1283         {140,137,139},
1284         {140,139,141},
1285         {127,126,130},
1286         {114,124,128},
1287         {114,128,115},
1288         {117,105,106},
1289         {117,106,116},
1290         {104,105,100},
1291         {104,100,103},
1292         { 59, 60, 91},
1293         { 97, 96, 61},
1294         { 97, 61, 64},
1295         { 91, 72, 89},
1296         { 87, 84, 79},
1297         { 87, 79, 76},
1298         { 78, 80, 77},
1299         { 49, 50, 74},
1300         { 60, 44, 45},
1301         { 61, 44, 58},
1302         { 51, 50, 35},
1303         { 51, 35, 34},
1304         { 39, 37, 41},
1305         { 33, 34,  9},
1306         { 33,  9, 12},
1307         {  0, 36, 37},
1308         {  0, 37,  6},
1309         { 40, 46, 47},
1310         { 40, 47, 42},
1311         { 53, 54, 56},
1312         { 65, 62, 63},
1313         { 72, 49, 73},
1314         { 79, 78, 75},
1315         { 79, 75, 76},
1316         { 52, 53, 76},
1317         { 92, 89, 90},
1318         { 96, 93, 46},
1319         {102,103,100},
1320         {102,100,101},
1321         {116,106,108},
1322         {116,108,115},
1323         {123,125,124},
1324         {116,115,128},
1325         {118,131,135},
1326         {140,135,136},
1327         {148,147,149},
1328         {120,119,155},
1329         {164,162,152},
1330         {164,152,150},
1331         {157,147,161},
1332         {157,161,170},
1333         {186,187,185},
1334         {186,185,184},
1335         {193,197,196},
1336         {202,203,204},
1337         {194,195,178},
1338         {198,184,197},
1339         { 67,111,109},
1340         { 38, 43,103},
1341         { 38,103,102},
1342         {214,223,222},
1343         {214,222,221},
1344         {214,221,220},
1345         {214,220,219},
1346         {214,219,218},
1347         {213,237,235},
1348         {221,222, 83},
1349         {221, 83, 85},
1350         { 15,229, 33},
1351         {227, 18,230},
1352         {227,230,232},
1353         { 52, 51,240},
1354         { 75, 78, 50},
1355         {408,430,409},
1356         {260,258,257},
1357         {260,257,259},
1358         {224,207,259},
1359         {268,269,405},
1360         {268,405,404},
1361         {413,362,360},
1362         {447,  8,205},
1363         {299,297,285},
1364         {189,281,202},
1365         {290,288,289},
1366         {290,289,291},
1367         {322,321,295},
1368         {322,295,294},
1369         {333,323,311},
1370         {333,311,320},
1371         {317,316,329},
1372         {320,160,144},
1373         {353,325,326},
1374         {329,332,334},
1375         {329,334,330},
1376         {339,338,141},
1377         {339,141,139},
1378         {348,345,126},
1379         {347,356,346},
1380         {123,349,125},
1381         {364,353,354},
1382         {364,354,355},
1383         {365,364,363},
1384         {376,391,394},
1385         {376,394,401},
1386         { 92,376,374},
1387         { 92,374,373},
1388         {377, 90, 88},
1389         {380,379,378},
1390         {380,378,381},
1391         {388,387,409},
1392         {388,409,410},
1393         {416,393,392},
1394         {399,398,402},
1395         {399,402,403},
1396         {250,428,427},
1397         {421,417,416},
1398         {421,416,420},
1399         {426,427,446},
1400         {426,446,451},
1401         {444,442,441},
1402         {452,451,450},
1403         {452,450,449}
1404 };
1405
1406
1407 //***************************THE END OF FAMOUS BUNNY TRIMESH********************************************//
1408
1409 //****GLOBALS
1410
1411 //****GLOBALS
1412
1413 ///User can override this material combiner by implementing gContactAddedCallback and setting body0->m_collisionFlags |= btCollisionObject::customMaterialCallback;
1414 inline btScalar calculateCombinedFriction(float friction0,float friction1)
1415 {
1416         btScalar friction = friction0 * friction1;
1417
1418         const btScalar MAX_FRICTION  = 10.f;
1419         if (friction < -MAX_FRICTION)
1420                 friction = -MAX_FRICTION;
1421         if (friction > MAX_FRICTION)
1422                 friction = MAX_FRICTION;
1423         return friction;
1424
1425 }
1426
1427 inline btScalar calculateCombinedRestitution(float restitution0,float restitution1)
1428 {
1429         return restitution0 * restitution1;
1430 }
1431
1432
1433
1434 bool CustomMaterialCombinerCallback(btManifoldPoint& cp,        const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
1435 {
1436
1437         float friction0 = colObj0->getFriction();
1438         float friction1 = colObj1->getFriction();
1439         float restitution0 = colObj0->getRestitution();
1440         float restitution1 = colObj1->getRestitution();
1441
1442         if (colObj0->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
1443         {
1444                 friction0 = 1.0;//partId0,index0
1445                 restitution0 = 0.f;
1446         }
1447         if (colObj1->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
1448         {
1449                 if (index1&1)
1450                 {
1451                         friction1 = 1.0f;//partId1,index1
1452                 } else
1453                 {
1454                         friction1 = 0.f;
1455                 }
1456                 restitution1 = 0.f;
1457         }
1458
1459         cp.m_combinedFriction = calculateCombinedFriction(friction0,friction1);
1460         cp.m_combinedRestitution = calculateCombinedRestitution(restitution0,restitution1);
1461
1462         //this return value is currently ignored, but to be on the safe side: return false if you don't calculate friction
1463         return true;
1464 }
1465
1466 extern ContactAddedCallback             gContactAddedCallback;
1467
1468
1469
1470 int main(int argc,char** argv)
1471 {
1472         gContactAddedCallback = CustomMaterialCombinerCallback;
1473
1474         ConcaveDemo* concaveDemo = new ConcaveDemo();
1475         concaveDemo->initPhysics();
1476         concaveDemo->setCameraDistance(30.f);
1477 //cannot run stepFront yet, the OpenGL context is not opened (stepFront updates camera...)
1478 //      concaveDemo->stepFront();
1479 //      concaveDemo->stepFront();
1480 //      concaveDemo->stepFront();
1481 //      concaveDemo->stepFront();
1482
1483         return glutmain(argc, argv,640,480,"Moving Concave Mesh Demo",concaveDemo);
1484 }
1485
1486 void ConcaveDemo::renderme()
1487 {
1488         updateCamera();
1489
1490         btScalar m[16];
1491
1492         if (m_dynamicsWorld)
1493         {
1494                 btVector3       worldBoundsMin,worldBoundsMax;
1495                 getDynamicsWorld()->getBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax);
1496
1497
1498                 int numObjects = m_dynamicsWorld->getNumCollisionObjects();
1499                 btVector3 wireColor(1,0,0);
1500                 for (int i=0;i<numObjects;i++)
1501                 {
1502                         btCollisionObject* colObj = m_dynamicsWorld->getCollisionObjectArray()[i];
1503                         btRigidBody* body = btRigidBody::upcast(colObj);
1504
1505                         if (body && body->getMotionState())
1506                         {
1507                                 btDefaultMotionState* myMotionState = (btDefaultMotionState*)body->getMotionState();
1508                                 myMotionState->m_graphicsWorldTrans.getOpenGLMatrix(m);
1509                         } else
1510                         {
1511                                 colObj->getWorldTransform().getOpenGLMatrix(m);
1512                         }
1513
1514                         btVector3 wireColor(1.f,1.0f,0.5f); //wants deactivation
1515                         if (i & 1)
1516                         {
1517                                 wireColor = btVector3(0.f,0.0f,1.f);
1518                         }
1519                         ///color differently for active, sleeping, wantsdeactivation states
1520                         if (colObj->getActivationState() == 1) //active
1521                         {
1522                                 if (i & 1)
1523                                 {
1524                                         wireColor += btVector3 (1.f,0.f,0.f);
1525                                 } else
1526                                 {
1527                                         wireColor += btVector3 (.5f,0.f,0.f);
1528                                 }
1529                         }
1530                         if (colObj->getActivationState() == 2) //ISLAND_SLEEPING
1531                         {
1532                                 if (i & 1)
1533                                 {
1534                                         wireColor += btVector3 (0.f,1.f, 0.f);
1535                                 } else
1536                                 {
1537                                         wireColor += btVector3 (0.f,0.5f,0.f);
1538                                 }
1539                         }
1540
1541                         m_shapeDrawer->drawOpenGL(m,colObj->getCollisionShape(),wireColor,getDebugMode(),worldBoundsMin,worldBoundsMax);
1542                 }
1543
1544
1545                         float xOffset = 10.f;
1546                         float yStart = 20.f;
1547                         float yIncr = 20.f;
1548                         char buf[124];
1549
1550                         glColor3f(0, 0, 0);
1551
1552                         setOrthographicProjection();
1553
1554                         sprintf(buf,"mouse to interact");
1555                         GLDebugDrawString(xOffset,xOffset,buf);
1556                         xOffset += yIncr;
1557
1558                 /*      glRasterPos3f(xOffset,xOffset,0);
1559                         sprintf(buf,"space to reset");
1560                         GLDebugDrawString(xOffset,xOffset,buf);
1561                         xOffset += yIncr;
1562                 */
1563
1564                         sprintf(buf,"cursor keys and z,x to navigate");
1565                         GLDebugDrawString(xOffset,xOffset,buf);
1566                         xOffset += yIncr;
1567
1568
1569                         sprintf(buf,"i to toggle simulation, s single step");
1570                         GLDebugDrawString(xOffset,xOffset,buf);
1571                         xOffset += yIncr;
1572
1573
1574                         sprintf(buf,"q to quit");
1575                         GLDebugDrawString(xOffset,xOffset,buf);
1576                         xOffset += yIncr;
1577
1578
1579                         sprintf(buf,". to shoot TRIMESH (dot)");
1580                         GLDebugDrawString(xOffset,xOffset,buf);
1581                         xOffset += yIncr;
1582
1583                         // not yet hooked up again after refactoring...
1584
1585 /*                      glRasterPos3f(xOffset,xOffset,0);
1586                         sprintf(buf,"d to toggle deactivation");
1587                         GLDebugDrawString(xOffset,xOffset,buf);
1588                         xOffset += yIncr;
1589 */
1590
1591                 /*
1592                         glRasterPos3f(xOffset,xOffset,0);
1593                         sprintf(buf,"a to draw temporal AABBs");
1594                         GLDebugDrawString(xOffset,xOffset,buf);
1595                         xOffset += yIncr;
1596                 */
1597
1598
1599                         sprintf(buf,"h to toggle help text");
1600                         GLDebugDrawString(xOffset,xOffset,buf);
1601                         xOffset += yIncr;
1602
1603                         //bool useBulletLCP = !(getDebugMode() & btIDebugDraw::DBG_DisableBulletLCP);
1604
1605                         bool useCCD = ((getDebugMode() & btIDebugDraw::DBG_EnableCCD) != 0);
1606
1607
1608                         sprintf(buf,"1 CCD mode (adhoc) = %i",useCCD);
1609                         GLDebugDrawString(xOffset,xOffset,buf);
1610                         xOffset += yIncr;
1611
1612
1613                         sprintf(buf,"+- shooting speed = %10.2f",m_ShootBoxInitialSpeed);
1614                         GLDebugDrawString(xOffset,xOffset,buf);
1615                         xOffset += yIncr;
1616
1617                         resetPerspectiveProjection();
1618
1619
1620         }
1621
1622 }
1623
1624
1625
1626 void    ConcaveDemo::initGImpactCollision()
1627 {
1628         // create trimesh
1629         btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray(NUM_TRIANGLES,
1630                 &gIndices[0][0],
1631                 3*sizeof(int),
1632                 NUM_VERTICES,(REAL*) &gVertices[0],sizeof(REAL)*3);
1633
1634         btGImpactMeshShape * trimesh = new btGImpactMeshShape(indexVertexArrays);
1635         trimesh->setLocalScaling(btVector3(4.f,4.f,4.f));
1636         trimesh->updateBound();
1637         m_trimeshShape = trimesh;
1638
1639         //register algorithm
1640
1641         btCollisionDispatcher * dispatcher = static_cast<btCollisionDispatcher *>(m_dynamicsWorld ->getDispatcher());
1642         btGImpactCollisionAlgorithm::registerAlgorithm(dispatcher);
1643
1644 }
1645
1646 void    ConcaveDemo::initPhysics()
1647 {
1648
1649         btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
1650
1651         //btConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
1652         btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
1653         //btOverlappingPairCache* broadphase = new btSimpleBroadphase();
1654         btBroadphaseInterface* broadphase = new btSimpleBroadphase();
1655
1656         btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
1657         m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,constraintSolver,collisionConfiguration);
1658
1659
1660         //create trimesh model and shape
1661         initGImpactCollision();
1662
1663
1664
1665         float mass = 0.f;
1666         btTransform     startTransform;
1667         startTransform.setIdentity();
1668
1669         btCollisionShape* staticboxShape1 = new btBoxShape(btVector3(200,1,200));//floor
1670         btCollisionShape* staticboxShape2 = new btBoxShape(btVector3(1,50,200));//left wall
1671         btCollisionShape* staticboxShape3 = new btBoxShape(btVector3(1,50,200));//right wall
1672         btCollisionShape* staticboxShape4 = new btBoxShape(btVector3(200,50,1));//front wall
1673         btCollisionShape* staticboxShape5 = new btBoxShape(btVector3(200,50,1));//back wall
1674
1675         btCompoundShape* staticScenario = new btCompoundShape();//static scenario
1676
1677         startTransform.setOrigin(btVector3(0,0,0));
1678         staticScenario->addChildShape(startTransform,staticboxShape1);
1679         startTransform.setOrigin(btVector3(-200,25,0));
1680         staticScenario->addChildShape(startTransform,staticboxShape2);
1681         startTransform.setOrigin(btVector3(200,25,0));
1682         staticScenario->addChildShape(startTransform,staticboxShape3);
1683         startTransform.setOrigin(btVector3(0,25,200));
1684         staticScenario->addChildShape(startTransform,staticboxShape4);
1685         startTransform.setOrigin(btVector3(0,25,-200));
1686         staticScenario->addChildShape(startTransform,staticboxShape5);
1687
1688         startTransform.setOrigin(btVector3(0,0,0));
1689
1690         btRigidBody* staticBody = localCreateRigidBody(mass, startTransform,staticScenario);
1691
1692         staticBody->setCollisionFlags(staticBody->getCollisionFlags()|btCollisionObject::CF_STATIC_OBJECT);
1693
1694         //enable custom material callback
1695         staticBody->setCollisionFlags(staticBody->getCollisionFlags()|btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
1696
1697
1698         //static plane
1699         btVector3 normal(0.4,1.5,-0.4);
1700         normal.normalize();
1701         btCollisionShape* staticplaneShape6 = new btStaticPlaneShape(normal,0.0);// A plane
1702
1703         startTransform.setOrigin(btVector3(0,0,0));
1704
1705         btRigidBody* staticBody2 = localCreateRigidBody(mass, startTransform,staticplaneShape6 );
1706
1707         staticBody2->setCollisionFlags(staticBody2->getCollisionFlags()|btCollisionObject::CF_STATIC_OBJECT);
1708
1709         {
1710                 for (int i=0;i<9;i++)
1711                 {
1712                         btCollisionShape* boxShape = new btBoxShape(btVector3(1,1,1));
1713                         startTransform.setOrigin(btVector3(2*i-5,2,-3));
1714                         localCreateRigidBody(1, startTransform,boxShape);
1715                 }
1716         }
1717
1718         shootTrimesh(btVector3(0,10,0),btVector3(0,0,0));
1719
1720         shootTrimesh(btVector3(0,20,0),btVector3(0,10,0));
1721
1722         //m_debugMode |= btIDebugDraw::DBG_DrawWireframe;
1723
1724 }
1725
1726 void ConcaveDemo::keyboardCallback(unsigned char key, int x, int y)
1727 {
1728                 m_lastKey = 0;
1729
1730     switch (key)
1731     {
1732     case 'q' : exit(0); break;
1733
1734     case 'l' : stepLeft(); break;
1735     case 'r' : stepRight(); break;
1736     case 'f' : stepFront(); break;
1737     case 'b' : stepBack(); break;
1738     case 'z' : zoomIn(); break;
1739     case 'x' : zoomOut(); break;
1740     case 'i' : toggleIdle(); break;
1741         case 'h':
1742                         if (m_debugMode & btIDebugDraw::DBG_NoHelpText)
1743                                 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_NoHelpText);
1744                         else
1745                                 m_debugMode |= btIDebugDraw::DBG_NoHelpText;
1746                         break;
1747
1748         case 'w':
1749                         if (m_debugMode & btIDebugDraw::DBG_DrawWireframe)
1750                                 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawWireframe);
1751                         else
1752                                 m_debugMode |= btIDebugDraw::DBG_DrawWireframe;
1753                    break;
1754
1755    case 'p':
1756            if (m_debugMode & btIDebugDraw::DBG_ProfileTimings)
1757                 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_ProfileTimings);
1758         else
1759                 m_debugMode |= btIDebugDraw::DBG_ProfileTimings;
1760    break;
1761
1762    case 'm':
1763            if (m_debugMode & btIDebugDraw::DBG_EnableSatComparison)
1764                 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_EnableSatComparison);
1765         else
1766                 m_debugMode |= btIDebugDraw::DBG_EnableSatComparison;
1767    break;
1768
1769    case 'n':
1770            if (m_debugMode & btIDebugDraw::DBG_DisableBulletLCP)
1771                 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DisableBulletLCP);
1772         else
1773                 m_debugMode |= btIDebugDraw::DBG_DisableBulletLCP;
1774    break;
1775
1776         case 't' :
1777                         if (m_debugMode & btIDebugDraw::DBG_DrawText)
1778                                 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawText);
1779                         else
1780                                 m_debugMode |= btIDebugDraw::DBG_DrawText;
1781                    break;
1782         case 'y':
1783                         if (m_debugMode & btIDebugDraw::DBG_DrawFeaturesText)
1784                                 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawFeaturesText);
1785                         else
1786                                 m_debugMode |= btIDebugDraw::DBG_DrawFeaturesText;
1787                 break;
1788         case 'a':
1789                 if (m_debugMode & btIDebugDraw::DBG_DrawAabb)
1790                                 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawAabb);
1791                         else
1792                                 m_debugMode |= btIDebugDraw::DBG_DrawAabb;
1793                         break;
1794                 case 'c' :
1795                         if (m_debugMode & btIDebugDraw::DBG_DrawContactPoints)
1796                                 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawContactPoints);
1797                         else
1798                                 m_debugMode |= btIDebugDraw::DBG_DrawContactPoints;
1799                         break;
1800
1801                 case 'd' :
1802                         if (m_debugMode & btIDebugDraw::DBG_NoDeactivation)
1803                                 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_NoDeactivation);
1804                         else
1805                                 m_debugMode |= btIDebugDraw::DBG_NoDeactivation;
1806                         if (m_debugMode | btIDebugDraw::DBG_NoDeactivation)
1807                         {
1808                                 gDisableDeactivation = true;
1809                         } else
1810                         {
1811                                 gDisableDeactivation = false;
1812                         }
1813                         break;
1814
1815
1816
1817
1818         case 'o' :
1819                 {
1820                         m_stepping = !m_stepping;
1821                         break;
1822                 }
1823         case 's' : clientMoveAndDisplay(); break;
1824 //    case ' ' : newRandom(); break;
1825         case ' ':
1826                 clientResetScene();
1827                         break;
1828         case '1':
1829                 {
1830                         if (m_debugMode & btIDebugDraw::DBG_EnableCCD)
1831                                 m_debugMode = m_debugMode & (~btIDebugDraw::DBG_EnableCCD);
1832                         else
1833                                 m_debugMode |= btIDebugDraw::DBG_EnableCCD;
1834                         break;
1835                 }
1836
1837                 case '.':
1838                 {
1839                         shootTrimesh(getCameraPosition(),getCameraTargetPosition());
1840                         break;
1841                 }
1842
1843                 case '+':
1844                 {
1845                         m_ShootBoxInitialSpeed += 10.f;
1846                         break;
1847                 }
1848                 case '-':
1849                 {
1850                         m_ShootBoxInitialSpeed -= 10.f;
1851                         break;
1852                 }
1853
1854     default:
1855 //        std::cout << "unused key : " << key << std::endl;
1856         break;
1857     }
1858
1859         if (getDynamicsWorld() && getDynamicsWorld()->getDebugDrawer())
1860                 getDynamicsWorld()->getDebugDrawer()->setDebugMode(m_debugMode);
1861
1862         glutPostRedisplay();
1863
1864 }
1865
1866
1867 void ConcaveDemo::shootTrimesh(const btVector3& startPosition,const btVector3& destination)
1868 {
1869
1870         if (m_dynamicsWorld)
1871         {
1872                 float mass = 4.f;
1873                 btTransform startTransform;
1874                 startTransform.setIdentity();
1875                 startTransform.setOrigin(startPosition);
1876
1877                 btRigidBody* body = this->localCreateRigidBody(mass, startTransform,m_trimeshShape);
1878
1879                 btVector3 linVel(destination[0]-startPosition[0],destination[1]-startPosition[1],destination[2]-startPosition[2]);
1880                 linVel.normalize();
1881                 linVel*=m_ShootBoxInitialSpeed*0.25;
1882
1883                 body->getWorldTransform().setOrigin(startPosition);
1884                 body->getWorldTransform().setRotation(btQuaternion(0,0,0,1));
1885                 body->setLinearVelocity(linVel);
1886                 body->setAngularVelocity(btVector3(0,0,0));
1887         }
1888 }
1889
1890 void ConcaveDemo::clientMoveAndDisplay()
1891 {
1892          glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1893
1894         float dt = float(getDeltaTimeMicroseconds()) * 0.000001f;
1895
1896         m_dynamicsWorld->stepSimulation(dt);
1897
1898         //optional but useful: debug drawing
1899         m_dynamicsWorld->debugDrawWorld();
1900
1901         renderme();
1902
1903     glFlush();
1904     glutSwapBuffers();
1905
1906 }
1907
1908
1909
1910
1911 void ConcaveDemo::displayCallback(void) {
1912
1913     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1914
1915         renderme();
1916
1917         //optional but useful: debug drawing
1918         if (m_dynamicsWorld)
1919                 m_dynamicsWorld->debugDrawWorld();
1920
1921     glFlush();
1922     glutSwapBuffers();
1923 }
1924
1925