Debian Codegraph @

demo/Joints.c

raw symbols SCIP
1 /* Copyright (c) 2007 Scott Lembcke
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 * SOFTWARE.
20 */
21
22 #include "chipmunk/chipmunk.h"cxx . . $ `<file>/include/chipmunk/chipmunk.h`/
23 #include "ChipmunkDemo.h"cxx . . $ `<file>/demo/ChipmunkDemo.h`/
24
25 static cpBodycxx . . $ cpBody# *
26 addBallcxx . . $ addBall(7741c491a97a793d).(cpSpacecxx . . $ cpSpace# *space, cpVectcxx . . $ cpVect# pos, cpVectcxx . . $ cpVect# boxOffset)
27 {
28 cpFloatcxx . . $ cpFloat# radius = 15.0f;
29 cpFloatcxx . . $ cpFloat# mass = 1.0f;
30 cpBodycxx . . $ cpBody# *body = cpSpaceAddBodycxx . . $ cpSpaceAddBody(1a8396fd971b33e7).(space, cpBodyNewcxx . . $ cpBodyNew(51915e6cc8310751).(mass, cpMomentForCirclecxx . . $ cpMomentForCircle(a539e2d95614f770).(mass, 0.0f, radius, cpvzerocxx . . $ cpvzero.)));
31 cpBodySetPositioncxx . . $ cpBodySetPosition(864e17bcbe059b08).(body, cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(pos, boxOffset));
32
33 cpShapecxx . . $ cpShape# *shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpCircleShapeNewcxx . . $ cpCircleShapeNew(e5e4e3a52c89533b).(body, radius, cpvzerocxx . . $ cpvzero.));
34 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 0.0f);
35 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 0.7f);
36
37 return body;
38 }
39
40 static cpBodycxx . . $ cpBody# *
41 addLevercxx . . $ addLever(7741c491a97a793d).(cpSpacecxx . . $ cpSpace# *space, cpVectcxx . . $ cpVect# pos, cpVectcxx . . $ cpVect# boxOffset)
42 {
43 cpFloatcxx . . $ cpFloat# mass = 1.0f;
44 cpVectcxx . . $ cpVect# a = cpvcxx . . $ cpv(3142d57d978b2176).(0, 15);
45 cpVectcxx . . $ cpVect# b = cpvcxx . . $ cpv(3142d57d978b2176).(0, -15);
46
47 cpBodycxx . . $ cpBody# *body = cpSpaceAddBodycxx . . $ cpSpaceAddBody(1a8396fd971b33e7).(space, cpBodyNewcxx . . $ cpBodyNew(51915e6cc8310751).(mass, cpMomentForSegmentcxx . . $ cpMomentForSegment(13ad460f360d98d3).(mass, a, b, 0.0f)));
48 cpBodySetPositioncxx . . $ cpBodySetPosition(864e17bcbe059b08).(body, cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(pos, cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(boxOffset, cpvcxx . . $ cpv(3142d57d978b2176).(0, -15))));
49
50 cpShapecxx . . $ cpShape# *shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(body, a, b, 5.0f));
51 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 0.0f);
52 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 0.7f);
53
54 return body;
55 }
56
57 static cpBodycxx . . $ cpBody# *
58 addBarcxx . . $ addBar(7741c491a97a793d).(cpSpacecxx . . $ cpSpace# *space, cpVectcxx . . $ cpVect# pos, cpVectcxx . . $ cpVect# boxOffset)
59 {
60 cpFloatcxx . . $ cpFloat# mass = 2.0f;
61 cpVectcxx . . $ cpVect# a = cpvcxx . . $ cpv(3142d57d978b2176).(0, 30);
62 cpVectcxx . . $ cpVect# b = cpvcxx . . $ cpv(3142d57d978b2176).(0, -30);
63
64 cpBodycxx . . $ cpBody# *body = cpSpaceAddBodycxx . . $ cpSpaceAddBody(1a8396fd971b33e7).(space, cpBodyNewcxx . . $ cpBodyNew(51915e6cc8310751).(mass, cpMomentForSegmentcxx . . $ cpMomentForSegment(13ad460f360d98d3).(mass, a, b, 0.0f)));
65 cpBodySetPositioncxx . . $ cpBodySetPosition(864e17bcbe059b08).(body, cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(pos, boxOffset));
66
67 cpShapecxx . . $ cpShape# *shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(body, a, b, 5.0f));
68 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 0.0f);
69 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 0.7f);
70 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, cpShapeFilterNewcxx . . $ cpShapeFilterNew(d4cd326b51c6d7a3).(1, CP_ALL_CATEGORIEScxx . . $ `include/chipmunk/chipmunk_types.h:233:10`!, CP_ALL_CATEGORIEScxx . . $ `include/chipmunk/chipmunk_types.h:233:10`!));
71
72 return body;
73 }
74
75 static cpBodycxx . . $ cpBody# *
76 addWheelcxx . . $ addWheel(7741c491a97a793d).(cpSpacecxx . . $ cpSpace# *space, cpVectcxx . . $ cpVect# pos, cpVectcxx . . $ cpVect# boxOffset)
77 {
78 cpFloatcxx . . $ cpFloat# radius = 15.0f;
79 cpFloatcxx . . $ cpFloat# mass = 1.0f;
80 cpBodycxx . . $ cpBody# *body = cpSpaceAddBodycxx . . $ cpSpaceAddBody(1a8396fd971b33e7).(space, cpBodyNewcxx . . $ cpBodyNew(51915e6cc8310751).(mass, cpMomentForCirclecxx . . $ cpMomentForCircle(a539e2d95614f770).(mass, 0.0f, radius, cpvzerocxx . . $ cpvzero.)));
81 cpBodySetPositioncxx . . $ cpBodySetPosition(864e17bcbe059b08).(body, cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(pos, boxOffset));
82
83 cpShapecxx . . $ cpShape# *shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpCircleShapeNewcxx . . $ cpCircleShapeNew(e5e4e3a52c89533b).(body, radius, cpvzerocxx . . $ cpvzero.));
84 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 0.0f);
85 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 0.7f);
86 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, cpShapeFilterNewcxx . . $ cpShapeFilterNew(d4cd326b51c6d7a3).(1, CP_ALL_CATEGORIEScxx . . $ `include/chipmunk/chipmunk_types.h:233:10`!, CP_ALL_CATEGORIEScxx . . $ `include/chipmunk/chipmunk_types.h:233:10`!));
87
88 return body;
89 }
90
91 static cpBodycxx . . $ cpBody# *
92 addChassiscxx . . $ addChassis(7741c491a97a793d).(cpSpacecxx . . $ cpSpace# *space, cpVectcxx . . $ cpVect# pos, cpVectcxx . . $ cpVect# boxOffset)
93 {
94 cpFloatcxx . . $ cpFloat# mass = 5.0f;
95 cpFloatcxx . . $ cpFloat# width = 80;
96 cpFloatcxx . . $ cpFloat# height = 30;
97
98 cpBodycxx . . $ cpBody# *body = cpSpaceAddBodycxx . . $ cpSpaceAddBody(1a8396fd971b33e7).(space, cpBodyNewcxx . . $ cpBodyNew(51915e6cc8310751).(mass, cpMomentForBoxcxx . . $ cpMomentForBox(7678bba071383ab).(mass, width, height)));
99 cpBodySetPositioncxx . . $ cpBodySetPosition(864e17bcbe059b08).(body, cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(pos, boxOffset));
100
101 cpShapecxx . . $ cpShape# *shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpBoxShapeNewcxx . . $ cpBoxShapeNew(94c4f8982441e75a).(body, width, height, 0.0));
102 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 0.0f);
103 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 0.7f);
104 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, cpShapeFilterNewcxx . . $ cpShapeFilterNew(d4cd326b51c6d7a3).(1, CP_ALL_CATEGORIEScxx . . $ `include/chipmunk/chipmunk_types.h:233:10`!, CP_ALL_CATEGORIEScxx . . $ `include/chipmunk/chipmunk_types.h:233:10`!));
105
106 return body;
107 }
108
109 static cpSpacecxx . . $ cpSpace# *
110 initcxx . . $ init(1f0082e822a7ce76).(void)
111 {
112 cpSpacecxx . . $ cpSpace# *space = cpSpaceNewcxx . . $ cpSpaceNew(1f0082e822a7ce76).();
113 cpSpaceSetIterationscxx . . $ cpSpaceSetIterations(3274f250b6e81e27).(space, 10);
114 cpSpaceSetGravitycxx . . $ cpSpaceSetGravity(7561685522e3e327).(space, cpvcxx . . $ cpv(3142d57d978b2176).(0, -100));
115 cpSpaceSetSleepTimeThresholdcxx . . $ cpSpaceSetSleepTimeThreshold(fa66a0a48611083e).(space, 0.5f);
116
117 cpBodycxx . . $ cpBody# *staticBody = cpSpaceGetStaticBodycxx . . $ cpSpaceGetStaticBody(d6ad68aaf406e51f).(space);
118 cpShapecxx . . $ cpShape# *shape;
119
120 shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(staticBody, cpvcxx . . $ cpv(3142d57d978b2176).(-320,240), cpvcxx . . $ cpv(3142d57d978b2176).(320,240), 0.0f));
121 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 1.0f);
122 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 1.0f);
123 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, NOT_GRABBABLE_FILTERcxx . . $ NOT_GRABBABLE_FILTER.);
124
125 shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(staticBody, cpvcxx . . $ cpv(3142d57d978b2176).(-320,120), cpvcxx . . $ cpv(3142d57d978b2176).(320,120), 0.0f));
126 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 1.0f);
127 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 1.0f);
128 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, NOT_GRABBABLE_FILTERcxx . . $ NOT_GRABBABLE_FILTER.);
129
130 shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(staticBody, cpvcxx . . $ cpv(3142d57d978b2176).(-320,0), cpvcxx . . $ cpv(3142d57d978b2176).(320,0), 0.0f));
131 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 1.0f);
132 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 1.0f);
133 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, NOT_GRABBABLE_FILTERcxx . . $ NOT_GRABBABLE_FILTER.);
134
135 shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(staticBody, cpvcxx . . $ cpv(3142d57d978b2176).(-320,-120), cpvcxx . . $ cpv(3142d57d978b2176).(320,-120), 0.0f));
136 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 1.0f);
137 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 1.0f);
138 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, NOT_GRABBABLE_FILTERcxx . . $ NOT_GRABBABLE_FILTER.);
139
140 shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(staticBody, cpvcxx . . $ cpv(3142d57d978b2176).(-320,-240), cpvcxx . . $ cpv(3142d57d978b2176).(320,-240), 0.0f));
141 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 1.0f);
142 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 1.0f);
143 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, NOT_GRABBABLE_FILTERcxx . . $ NOT_GRABBABLE_FILTER.);
144
145
146 shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(staticBody, cpvcxx . . $ cpv(3142d57d978b2176).(-320,-240), cpvcxx . . $ cpv(3142d57d978b2176).(-320,240), 0.0f));
147 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 1.0f);
148 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 1.0f);
149 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, NOT_GRABBABLE_FILTERcxx . . $ NOT_GRABBABLE_FILTER.);
150
151 shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(staticBody, cpvcxx . . $ cpv(3142d57d978b2176).(-160,-240), cpvcxx . . $ cpv(3142d57d978b2176).(-160,240), 0.0f));
152 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 1.0f);
153 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 1.0f);
154 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, NOT_GRABBABLE_FILTERcxx . . $ NOT_GRABBABLE_FILTER.);
155
156 shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(staticBody, cpvcxx . . $ cpv(3142d57d978b2176).(0,-240), cpvcxx . . $ cpv(3142d57d978b2176).(0,240), 0.0f));
157 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 1.0f);
158 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 1.0f);
159 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, NOT_GRABBABLE_FILTERcxx . . $ NOT_GRABBABLE_FILTER.);
160
161 shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(staticBody, cpvcxx . . $ cpv(3142d57d978b2176).(160,-240), cpvcxx . . $ cpv(3142d57d978b2176).(160,240), 0.0f));
162 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 1.0f);
163 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 1.0f);
164 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, NOT_GRABBABLE_FILTERcxx . . $ NOT_GRABBABLE_FILTER.);
165
166 shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(staticBody, cpvcxx . . $ cpv(3142d57d978b2176).(320,-240), cpvcxx . . $ cpv(3142d57d978b2176).(320,240), 0.0f));
167 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 1.0f);
168 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 1.0f);
169 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, NOT_GRABBABLE_FILTERcxx . . $ NOT_GRABBABLE_FILTER.);
170
171 cpVectcxx . . $ cpVect# boxOffset;
172 cpBodycxx . . $ cpBody# *body1, *body2;
173
174 cpVectcxx . . $ cpVect# posA = cpvcxx . . $ cpv(3142d57d978b2176).( 50, 60);
175 cpVectcxx . . $ cpVect# posB = cpvcxx . . $ cpv(3142d57d978b2176).(110, 60);
176
177 #define POS_Acxx . . $ `demo/Joints.c:177:10`! cpvadd(boxOffset, posA)
178 #define POS_Bcxx . . $ `demo/Joints.c:178:10`! cpvadd(boxOffset, posB)
179
180 // Pin Joints - Link shapes with a solid bar or pin.
181 // Keeps the anchor points the same distance apart from when the joint was created.
182 boxOffset = cpvcxx . . $ cpv(3142d57d978b2176).(-320, -240);
183 body1 = addBallcxx . . $ addBall(7741c491a97a793d).(space, posA, boxOffset);
184 body2 = addBallcxx . . $ addBall(7741c491a97a793d).(space, posB, boxOffset);
185 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpPinJointNewcxx . . $ cpPinJointNew(74f6d8fa0e302020).(body1, body2, cpvcxx . . $ cpv(3142d57d978b2176).(15,0), cpvcxx . . $ cpv(3142d57d978b2176).(-15,0)));
186
187 // Slide Joints - Like pin joints but with a min/max distance.
188 // Can be used for a cheap approximation of a rope.
189 boxOffset = cpvcxx . . $ cpv(3142d57d978b2176).(-160, -240);
190 body1 = addBallcxx . . $ addBall(7741c491a97a793d).(space, posA, boxOffset);
191 body2 = addBallcxx . . $ addBall(7741c491a97a793d).(space, posB, boxOffset);
192 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpSlideJointNewcxx . . $ cpSlideJointNew(5b97552dd9e8a693).(body1, body2, cpvcxx . . $ cpv(3142d57d978b2176).(15,0), cpvcxx . . $ cpv(3142d57d978b2176).(-15,0), 20.0f, 40.0f));
193
194 // Pivot Joints - Holds the two anchor points together. Like a swivel.
195 boxOffset = cpvcxx . . $ cpv(3142d57d978b2176).(0, -240);
196 body1 = addBallcxx . . $ addBall(7741c491a97a793d).(space, posA, boxOffset);
197 body2 = addBallcxx . . $ addBall(7741c491a97a793d).(space, posB, boxOffset);
198 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpPivotJointNewcxx . . $ cpPivotJointNew(8cdc1c6d6b6f0abb).(body1, body2, cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(boxOffset, cpvcxx . . $ cpv(3142d57d978b2176).(80,60))));
199 // cpPivotJointNew() takes it's anchor parameter in world coordinates. The anchors are calculated from that
200 // cpPivotJointNew2() lets you specify the two anchor points explicitly
201
202 // Groove Joints - Like a pivot joint, but one of the anchors is a line segment that the pivot can slide in
203 boxOffset = cpvcxx . . $ cpv(3142d57d978b2176).(160, -240);
204 body1 = addBallcxx . . $ addBall(7741c491a97a793d).(space, posA, boxOffset);
205 body2 = addBallcxx . . $ addBall(7741c491a97a793d).(space, posB, boxOffset);
206 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpGrooveJointNewcxx . . $ cpGrooveJointNew(f2f94869a8417a6b).(body1, body2, cpvcxx . . $ cpv(3142d57d978b2176).(30,30), cpvcxx . . $ cpv(3142d57d978b2176).(30,-30), cpvcxx . . $ cpv(3142d57d978b2176).(-30,0)));
207
208 // Damped Springs
209 boxOffset = cpvcxx . . $ cpv(3142d57d978b2176).(-320, -120);
210 body1 = addBallcxx . . $ addBall(7741c491a97a793d).(space, posA, boxOffset);
211 body2 = addBallcxx . . $ addBall(7741c491a97a793d).(space, posB, boxOffset);
212 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpDampedSpringNewcxx . . $ cpDampedSpringNew(4558d7d073b8c5fd).(body1, body2, cpvcxx . . $ cpv(3142d57d978b2176).(15,0), cpvcxx . . $ cpv(3142d57d978b2176).(-15,0), 20.0f, 5.0f, 0.3f));
213
214 // Damped Rotary Springs
215 boxOffset = cpvcxx . . $ cpv(3142d57d978b2176).(-160, -120);
216 body1 = addBarcxx . . $ addBar(7741c491a97a793d).(space, posA, boxOffset);
217 body2 = addBarcxx . . $ addBar(7741c491a97a793d).(space, posB, boxOffset);
218 // Add some pin joints to hold the circles in place.
219 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpPivotJointNewcxx . . $ cpPivotJointNew(8cdc1c6d6b6f0abb).(body1, staticBody, POS_Acxx . . $ `demo/Joints.c:177:10`!));
220 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpPivotJointNewcxx . . $ cpPivotJointNew(8cdc1c6d6b6f0abb).(body2, staticBody, POS_Bcxx . . $ `demo/Joints.c:178:10`!));
221 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpDampedRotarySpringNewcxx . . $ cpDampedRotarySpringNew(6e76adfc32a0e240).(body1, body2, 0.0f, 3000.0f, 60.0f));
222
223 // Rotary Limit Joint
224 boxOffset = cpvcxx . . $ cpv(3142d57d978b2176).(0, -120);
225 body1 = addLevercxx . . $ addLever(7741c491a97a793d).(space, posA, boxOffset);
226 body2 = addLevercxx . . $ addLever(7741c491a97a793d).(space, posB, boxOffset);
227 // Add some pin joints to hold the circles in place.
228 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpPivotJointNewcxx . . $ cpPivotJointNew(8cdc1c6d6b6f0abb).(body1, staticBody, POS_Acxx . . $ `demo/Joints.c:177:10`!));
229 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpPivotJointNewcxx . . $ cpPivotJointNew(8cdc1c6d6b6f0abb).(body2, staticBody, POS_Bcxx . . $ `demo/Joints.c:178:10`!));
230 // Hold their rotation within 90 degrees of each other.
231 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpRotaryLimitJointNewcxx . . $ cpRotaryLimitJointNew(d029de5d93e4cb4a).(body1, body2, -CP_PIcxx . . $ `include/chipmunk/chipmunk_types.h:115:9`!/2.0f, CP_PIcxx . . $ `include/chipmunk/chipmunk_types.h:115:9`!/2.0f));
232
233 // Ratchet Joint - A rotary ratchet, like a socket wrench
234 boxOffset = cpvcxx . . $ cpv(3142d57d978b2176).(160, -120);
235 body1 = addLevercxx . . $ addLever(7741c491a97a793d).(space, posA, boxOffset);
236 body2 = addLevercxx . . $ addLever(7741c491a97a793d).(space, posB, boxOffset);
237 // Add some pin joints to hold the circles in place.
238 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpPivotJointNewcxx . . $ cpPivotJointNew(8cdc1c6d6b6f0abb).(body1, staticBody, POS_Acxx . . $ `demo/Joints.c:177:10`!));
239 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpPivotJointNewcxx . . $ cpPivotJointNew(8cdc1c6d6b6f0abb).(body2, staticBody, POS_Bcxx . . $ `demo/Joints.c:178:10`!));
240 // Ratchet every 90 degrees
241 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpRatchetJointNewcxx . . $ cpRatchetJointNew(d029de5d93e4cb4a).(body1, body2, 0.0f, CP_PIcxx . . $ `include/chipmunk/chipmunk_types.h:115:9`!/2.0f));
242
243 // Gear Joint - Maintain a specific angular velocity ratio
244 boxOffset = cpvcxx . . $ cpv(3142d57d978b2176).(-320, 0);
245 body1 = addBarcxx . . $ addBar(7741c491a97a793d).(space, posA, boxOffset);
246 body2 = addBarcxx . . $ addBar(7741c491a97a793d).(space, posB, boxOffset);
247 // Add some pin joints to hold the circles in place.
248 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpPivotJointNewcxx . . $ cpPivotJointNew(8cdc1c6d6b6f0abb).(body1, staticBody, POS_Acxx . . $ `demo/Joints.c:177:10`!));
249 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpPivotJointNewcxx . . $ cpPivotJointNew(8cdc1c6d6b6f0abb).(body2, staticBody, POS_Bcxx . . $ `demo/Joints.c:178:10`!));
250 // Force one to sping 2x as fast as the other
251 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpGearJointNewcxx . . $ cpGearJointNew(d029de5d93e4cb4a).(body1, body2, 0.0f, 2.0f));
252
253 // Simple Motor - Maintain a specific angular relative velocity
254 boxOffset = cpvcxx . . $ cpv(3142d57d978b2176).(-160, 0);
255 body1 = addBarcxx . . $ addBar(7741c491a97a793d).(space, posA, boxOffset);
256 body2 = addBarcxx . . $ addBar(7741c491a97a793d).(space, posB, boxOffset);
257 // Add some pin joints to hold the circles in place.
258 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpPivotJointNewcxx . . $ cpPivotJointNew(8cdc1c6d6b6f0abb).(body1, staticBody, POS_Acxx . . $ `demo/Joints.c:177:10`!));
259 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpPivotJointNewcxx . . $ cpPivotJointNew(8cdc1c6d6b6f0abb).(body2, staticBody, POS_Bcxx . . $ `demo/Joints.c:178:10`!));
260 // Make them spin at 1/2 revolution per second in relation to each other.
261 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpSimpleMotorNewcxx . . $ cpSimpleMotorNew(fc786efe5abab4f7).(body1, body2, CP_PIcxx . . $ `include/chipmunk/chipmunk_types.h:115:9`!));
262
263 // Make a car with some nice soft suspension
264 boxOffset = cpvcxx . . $ cpv(3142d57d978b2176).(0, 0);
265 cpBodycxx . . $ cpBody# *wheel1 = addWheelcxx . . $ addWheel(7741c491a97a793d).(space, posA, boxOffset);
266 cpBodycxx . . $ cpBody# *wheel2 = addWheelcxx . . $ addWheel(7741c491a97a793d).(space, posB, boxOffset);
267 cpBodycxx . . $ cpBody# *chassis = addChassiscxx . . $ addChassis(7741c491a97a793d).(space, cpvcxx . . $ cpv(3142d57d978b2176).(80, 100), boxOffset);
268
269 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpGrooveJointNewcxx . . $ cpGrooveJointNew(f2f94869a8417a6b).(chassis, wheel1, cpvcxx . . $ cpv(3142d57d978b2176).(-30, -10), cpvcxx . . $ cpv(3142d57d978b2176).(-30, -40), cpvzerocxx . . $ cpvzero.));
270 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpGrooveJointNewcxx . . $ cpGrooveJointNew(f2f94869a8417a6b).(chassis, wheel2, cpvcxx . . $ cpv(3142d57d978b2176).( 30, -10), cpvcxx . . $ cpv(3142d57d978b2176).( 30, -40), cpvzerocxx . . $ cpvzero.));
271
272 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpDampedSpringNewcxx . . $ cpDampedSpringNew(4558d7d073b8c5fd).(chassis, wheel1, cpvcxx . . $ cpv(3142d57d978b2176).(-30, 0), cpvzerocxx . . $ cpvzero., 50.0f, 20.0f, 10.0f));
273 cpSpaceAddConstraintcxx . . $ cpSpaceAddConstraint(9bcc8bada2b14254).(space, cpDampedSpringNewcxx . . $ cpDampedSpringNew(4558d7d073b8c5fd).(chassis, wheel2, cpvcxx . . $ cpv(3142d57d978b2176).( 30, 0), cpvzerocxx . . $ cpvzero., 50.0f, 20.0f, 10.0f));
274
275 return space;
276 }
277
278 static void
279 updatecxx . . $ update(fa66a0a48611083e).(cpSpacecxx . . $ cpSpace# *space, double dt)
280 {
281 cpSpaceStepcxx . . $ cpSpaceStep(fa66a0a48611083e).(space, dt);
282 }
283
284 static void
285 destroycxx . . $ destroy(728b9c9a69722ef8).(cpSpacecxx . . $ cpSpace# *space)
286 {
287 ChipmunkDemoFreeSpaceChildrencxx . . $ ChipmunkDemoFreeSpaceChildren(728b9c9a69722ef8).(space);
288 cpSpaceFreecxx . . $ cpSpaceFree(728b9c9a69722ef8).(space);
289 }
290
291 ChipmunkDemocxx . . $ ChipmunkDemo# Jointscxx . . $ Joints. = {
292 "Joints and Constraints",
293 1.0/60.0,
294 initcxx . . $ init(1f0082e822a7ce76).,
295 updatecxx . . $ update(fa66a0a48611083e).,
296 ChipmunkDemoDefaultDrawImplcxx . . $ ChipmunkDemoDefaultDrawImpl(728b9c9a69722ef8).,
297 destroycxx . . $ destroy(728b9c9a69722ef8).,
298 };