Normand Briere
2019-09-24 767be784dc7fe293bf5c5ee6507df242526be3ed
Rag doll is back.
11 files modified
313 ■■■■■ changed files
BBox.java 65 ●●●● patch | view | raw | blame | history
CameraPane.java 9 ●●●●● patch | view | raw | blame | history
GenericJoint.java 5 ●●●●● patch | view | raw | blame | history
GroupEditor.java 14 ●●●● patch | view | raw | blame | history
ObjEditor.java 2 ●●● patch | view | raw | blame | history
Object3D.java 60 ●●●● patch | view | raw | blame | history
PhysicsEditor.java 5 ●●●●● patch | view | raw | blame | history
PhysicsNode.java 38 ●●●●● patch | view | raw | blame | history
RagDoll.java 86 ●●●●● patch | view | raw | blame | history
com/bulletphysics/collision/shapes/ShapeHull.java 7 ●●●●● patch | view | raw | blame | history
com/bulletphysics/dynamics/RigidBody.java 22 ●●●●● patch | view | raw | blame | history
BBox.java
....@@ -104,12 +104,6 @@
104104 double t1 = (min.x - ray.eyePoint.x) / ray.viewDirection.x;
105105 double t2 = (max.x - ray.eyePoint.x) / ray.viewDirection.x;
106106
107
- double mint = t1;
108
- if (mint > t2) mint = t2;
109
-
110
- double maxt = t1;
111
- if (maxt < t2) maxt = t2;
112
-
113107 if (ray.viewDirection.x == 0)
114108 {
115109 if (ray.eyePoint.x <= min.x || ray.eyePoint.x >= max.x)
....@@ -117,18 +111,16 @@
117111 }
118112 else
119113 {
120
- if (tmin > mint) tmin = mint;
121
- if (tmax < maxt) tmax = maxt;
122
- }
123
-
124
- t1 = (min.y - ray.eyePoint.y) / ray.viewDirection.y;
125
- t2 = (max.y - ray.eyePoint.y) / ray.viewDirection.y;
114
+ if (t1 > t2)
115
+ {
116
+ double t = t1;
117
+ t1 = t2;
118
+ t2 = t;
119
+ }
126120
127
- mint = t1;
128
- if (mint > t2) mint = t2;
129
-
130
- maxt = t1;
131
- if (maxt < t2) maxt = t2;
121
+ if (tmin > t1) tmin = t1;
122
+ if (tmax < t2) tmax = t2;
123
+ }
132124
133125 if (ray.viewDirection.y == 0)
134126 {
....@@ -137,18 +129,19 @@
137129 }
138130 else
139131 {
140
- if (tmin > mint) tmin = mint;
141
- if (tmax < maxt) tmax = maxt;
142
- }
143
-
144
- t1 = (min.z - ray.eyePoint.z) / ray.viewDirection.z;
145
- t2 = (max.z - ray.eyePoint.z) / ray.viewDirection.z;
132
+ t1 = (min.y - ray.eyePoint.y) / ray.viewDirection.y;
133
+ t2 = (max.y - ray.eyePoint.y) / ray.viewDirection.y;
146134
147
- mint = t1;
148
- if (mint > t2) mint = t2;
149
-
150
- maxt = t1;
151
- if (maxt < t2) maxt = t2;
135
+ if (t1 > t2)
136
+ {
137
+ double t = t1;
138
+ t1 = t2;
139
+ t2 = t;
140
+ }
141
+
142
+ if (tmin > t1) tmin = t1;
143
+ if (tmax < t2) tmax = t2;
144
+ }
152145
153146 if (ray.viewDirection.z == 0)
154147 {
....@@ -157,10 +150,20 @@
157150 }
158151 else
159152 {
160
- if (tmin > mint) tmin = mint;
161
- if (tmax < maxt) tmax = maxt;
153
+ t1 = (min.z - ray.eyePoint.z) / ray.viewDirection.z;
154
+ t2 = (max.z - ray.eyePoint.z) / ray.viewDirection.z;
155
+
156
+ if (t1 > t2)
157
+ {
158
+ double t = t1;
159
+ t1 = t2;
160
+ t2 = t;
161
+ }
162
+
163
+ if (tmin > t1) tmin = t1;
164
+ if (tmax < t2) tmax = t2;
162165 }
163166
164
- return tmax > tmin && tmax > 0.0;
167
+ return tmax >= tmin && tmax > 0.0;
165168 }
166169 }
CameraPane.java
....@@ -1,4 +1,5 @@
11
2
+import com.bulletphysics.dynamics.RigidBody;
23 import java.awt.*;
34 import java.awt.event.*;
45 import java.awt.image.*;
....@@ -14667,6 +14668,14 @@
1466714668 // only one thread!? synchronized
1466814669 void StepToTarget(boolean jump)
1466914670 {
14671
+ RigidBody.pos.x = (float)manipCamera.lookAt.x;
14672
+ RigidBody.pos.y = (float)manipCamera.lookAt.y;
14673
+ RigidBody.pos.z = (float)manipCamera.lookAt.z;
14674
+// RigidBody.wind.x = (float)manipCamera.right.x;
14675
+// RigidBody.wind.y = (float)manipCamera.right.y;
14676
+// RigidBody.wind.z = (float)manipCamera.right.z;
14677
+ //RigidBody.wind.normalize();
14678
+
1467014679 if (mute)
1467114680 return;
1467214681
GenericJoint.java
....@@ -177,7 +177,8 @@
177177
178178 public void spawnRagdoll(boolean walk) // random)
179179 {
180
- RagDoll ragDoll = new RagDoll(null, new Vector3f(0f, 0f, 0f), 0.45f, walk); // Math.random() > 0.5/*true*/); // true);
180
+ // KIDS4
181
+ RagDoll ragDoll = new RagDoll(null, new Vector3f(0f, 0f, 0f), 0.45f/2, walk); // Math.random() > 0.5/*true*/); // true);
181182 ragdolls.add(ragDoll);
182183
183184 bRep = null;
....@@ -309,7 +310,7 @@
309310 walkdefined = true;
310311 }
311312
312
- ragdolls.get(0).init(/*staticdynamicsWorld,*/ new Vector3f(0f, 0f, 0f), 0.45f, walk);
313
+ ragdolls.get(0).init(/*staticdynamicsWorld,*/ new Vector3f(0f, 0f, 0f), ragdolls.get(0).scale, walk);
313314
314315 bRep = null;
315316 }
GroupEditor.java
....@@ -2515,13 +2515,13 @@
25152515 ragdoll.toParent = LA.newMatrix();
25162516 ragdoll.fromParent = LA.newMatrix();
25172517
2518
- ragdoll.fromParent[1][1] = 1/1.03;
2519
- ragdoll.toParent[1][1] = 1.03;
2520
-
2521
- ragdoll.fromParent[3][1] = 0.02;
2522
- ragdoll.toParent[3][1] = -0.02;
2523
- ragdoll.fromParent[3][2] = 0.01;
2524
- ragdoll.toParent[3][2] = -0.01;
2518
+// ragdoll.fromParent[1][1] = 1/1.03;
2519
+// ragdoll.toParent[1][1] = 1.03;
2520
+//
2521
+// ragdoll.fromParent[3][1] = 0.02;
2522
+// ragdoll.toParent[3][1] = -0.02;
2523
+// ragdoll.fromParent[3][2] = 0.01;
2524
+// ragdoll.toParent[3][2] = -0.01;
25252525
25262526 makeSomething(ragdoll);
25272527 //makeSomething(new VehicleDemo());
ObjEditor.java
....@@ -4617,7 +4617,7 @@
46174617
46184618 ResetModel();
46194619
4620
- DuplicateVersion();
4620
+ //DuplicateVersion();
46214621
46224622 this.SetVersionStates();
46234623 objEditor.refreshContents();
Object3D.java
....@@ -1023,7 +1023,7 @@
10231023
10241024 void Step()
10251025 {
1026
- // marde pour serialization de Texture
1026
+ // patch pour serialization de Texture
10271027 resetmaxcount();
10281028 resettransformcount();
10291029 resetstep();
....@@ -4101,11 +4101,6 @@
41014101 Step();
41024102 Touch();
41034103
4104
- StepRecur();
4105
- }
4106
-
4107
- void StepRecur()
4108
- {
41094104 for (int i = 0; i < size(); i++)
41104105 {
41114106 Object3D child = (Object3D) get(i); // reserve(i);
....@@ -6182,6 +6177,10 @@
61826177 return live && bRep != null;
61836178 }
61846179
6180
+ static cVector minima = new cVector();
6181
+ static cVector maxima = new cVector();
6182
+ static javax.vecmath.Point3d center = new javax.vecmath.Point3d();
6183
+
61856184 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
61866185 {
61876186 Invariants(); // june 2013
....@@ -6189,6 +6188,29 @@
61896188 if (support != null)
61906189 {
61916190 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
6191
+ }
6192
+
6193
+ if (live && link2master && support == null && !this.marked) // project on ground
6194
+ {
6195
+ getBounds(minima, maxima, true);
6196
+ center.x = (minima.x + maxima.x) / 2;
6197
+ center.y = 10000; // (minima.y + maxima.y) / 2;
6198
+ center.z = (minima.z + maxima.z) / 2;
6199
+
6200
+ Ray ray = new Ray(center, new Vector3d(0,-1,0));
6201
+
6202
+ IntersectResult res = new IntersectResult();
6203
+ res.t = Double.POSITIVE_INFINITY;
6204
+
6205
+ if (Grafreed.grafreed.universe.intersect(ray, res))
6206
+ {
6207
+ double resx = ray.eyePoint.x + ray.viewDirection.x * res.t;
6208
+ double resy = ray.eyePoint.y + ray.viewDirection.y * res.t;
6209
+ double resz = ray.eyePoint.z + ray.viewDirection.z * res.t;
6210
+
6211
+ LA.matTranslate(toParent, 0, resy - minima.y, 0);
6212
+ LA.matInvert(toParent, fromParent);
6213
+ }
61926214 }
61936215
61946216 if (display.DrawMode() == iCameraPane.SELECTION &&
....@@ -6985,7 +7007,7 @@
69857007 facescompare[k] = new FaceCompare(k);
69867008 }
69877009
6988
- center = new cVector();
7010
+ centertriangle = new cVector();
69897011 }
69907012 else
69917013 {
....@@ -7108,7 +7130,7 @@
71087130 */
71097131 }
71107132
7111
- transient cVector center;
7133
+ transient cVector centertriangle;
71127134
71137135 class FaceCompare implements Comparable
71147136 {
....@@ -7137,14 +7159,14 @@
71377159 Vertex q = bRep.GetVertex(face.q);
71387160 Vertex r = bRep.GetVertex(face.r);
71397161
7140
- center.set(p);
7141
- center.add(q);
7142
- center.add(r);
7143
- center.mul(1.0/3);
7162
+ centertriangle.set(p);
7163
+ centertriangle.add(q);
7164
+ centertriangle.add(r);
7165
+ centertriangle.mul(1.0/3);
71447166
7145
- center.sub(Globals.theRenderer.EyeCamera().location);
7167
+ centertriangle.sub(Globals.theRenderer.EyeCamera().location);
71467168
7147
- distance = center.dot(center);
7169
+ distance = centertriangle.dot(centertriangle);
71487170 }
71497171
71507172 return distance;
....@@ -8903,7 +8925,7 @@
89038925 cVector min = new cVector();
89048926 cVector max = new cVector();
89058927
8906
- this.getBounds(min, max, false);
8928
+ this.getBounds(min, max, true);
89078929
89088930 bbox.min.x = min.x;
89098931 bbox.min.y = min.y;
....@@ -8914,7 +8936,7 @@
89148936 bbox.max.z = max.z;
89158937 }
89168938
8917
- if (bbox.intersect(ray, result))
8939
+ if (true) // NOT WORKING bbox.intersect(ray, result))
89188940 {
89198941 success |= intersectMesh(ray, result);
89208942 }
....@@ -8958,6 +8980,12 @@
89588980
89598981 private boolean intersectTriangle(Ray ray, IntersectResult result, Vertex v1, Vertex v2, Vertex v3)
89608982 {
8983
+ if (false)
8984
+ {
8985
+ result.t = 0;
8986
+ return true;
8987
+ }
8988
+
89618989 /*
89628990 Fast, Minimum Storage Ray/Triangle Intersection, Moller et al.
89638991
PhysicsEditor.java
....@@ -70,7 +70,7 @@
7070 */
7171 super.SetupUI2(oe);
7272
73
- gravityPanel = AddSlider(oe.ctrlPanel, "Gravity:", 0, 20.0, physicsnode.gravity, 1);
73
+ gravityPanel = AddSlider(oe.ctrlPanel, "Gravity:", 0, 100.0, physicsnode.gravity, 1);
7474 gravityField = (cNumberSlider)gravityPanel.getComponent(1);
7575
7676 // oe.ctrlPanel.add(gravityLabel = new JLabel("Gravity: ")); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
....@@ -79,7 +79,7 @@
7979
8080 oe.ctrlPanel.Return();
8181
82
- windPanel = AddSlider(oe.ctrlPanel, "Wind:", 0, 20.0, physicsnode.wind, 1);
82
+ windPanel = AddSlider(oe.ctrlPanel, "Wind:", 0, 100.0, physicsnode.wind, 1);
8383 windField = (cNumberSlider)windPanel.getComponent(1);
8484
8585 // oe.ctrlPanel.add(windLabel = new JLabel("Wind: ")); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
....@@ -203,6 +203,7 @@
203203 physicsnode.floor = (float)floorField.getFloat(); // biparam.minUDivs, 99);
204204 //biparam.name = nameField.getText();
205205
206
+ physicsnode.transientDynamicsWorld.setGravity(new javax.vecmath.Vector3f(0, -physicsnode.gravity, physicsnode.wind));
206207 // june 2013 super.applySelf();
207208 }
208209 /**/
PhysicsNode.java
....@@ -78,6 +78,8 @@
7878 super("Physics");
7979
8080 live = true;
81
+
82
+ gravity = 1;
8183 }
8284
8385 void Reset()
....@@ -193,39 +195,41 @@
193195 //staticdynamicsWorld = dynamicsWorld;
194196 // dynamicsWorld.setDebugDrawer(new GLDebugDrawer(gl));
195197
198
+ float boxsize = 100;
199
+
196200 // Setup a big ground box
197201 // {
198
- CollisionShape groundShape = new BoxShape(new Vector3f(200f, 10f, 200f));
202
+ CollisionShape groundShape = new BoxShape(new Vector3f(boxsize, 10f, boxsize));
199203 Transform groundTransform = new Transform();
200204 groundTransform.setIdentity();
201205 groundTransform.origin.set(0f, -floor - 10, 0f);
202206 localCreateRigidBody(0f, groundTransform, groundShape);
203207
204
- groundShape = new BoxShape(new Vector3f(200f, 200f, 200f));
208
+ groundShape = new BoxShape(new Vector3f(boxsize, boxsize, boxsize));
205209 groundTransform = new Transform();
206210 groundTransform.setIdentity();
207
- groundTransform.origin.set(0f, 100, -201f);
208
- //localCreateRigidBody(0f, groundTransform, groundShape);
211
+ groundTransform.origin.set(0f, boxsize/2, -boxsize-1);
212
+ localCreateRigidBody(0f, groundTransform, groundShape);
209213
210
- groundShape = new BoxShape(new Vector3f(200f, 200f, 200f));
214
+ groundShape = new BoxShape(new Vector3f(boxsize, boxsize, boxsize));
211215 groundTransform = new Transform();
212216 groundTransform.setIdentity();
213
- groundTransform.origin.set(-201f, 100, 0f);
214
- //localCreateRigidBody(0f, groundTransform, groundShape);
217
+ groundTransform.origin.set(-boxsize-1, boxsize/2, 0f);
218
+ localCreateRigidBody(0f, groundTransform, groundShape);
215219
216
- groundShape = new BoxShape(new Vector3f(200f, 200f, 200f));
220
+ groundShape = new BoxShape(new Vector3f(boxsize, boxsize, boxsize));
217221 groundTransform = new Transform();
218222 groundTransform.setIdentity();
219
- groundTransform.origin.set(201f, 100, 0f);
220
- //localCreateRigidBody(0f, groundTransform, groundShape);
223
+ groundTransform.origin.set(boxsize+1, boxsize/2, 0f);
224
+ localCreateRigidBody(0f, groundTransform, groundShape);
221225
222
- groundShape = new BoxShape(new Vector3f(200f, 200f, 200f));
226
+ groundShape = new BoxShape(new Vector3f(boxsize, boxsize, boxsize));
223227 groundTransform = new Transform();
224228 groundTransform.setIdentity();
225
- groundTransform.origin.set(0f, 100, 201f);
226
- //localCreateRigidBody(0f, groundTransform, groundShape);
229
+ groundTransform.origin.set(0f, boxsize/2, boxsize+1);
230
+ localCreateRigidBody(0f, groundTransform, groundShape);
227231
228
- transientDynamicsWorld.setGravity(new Vector3f(0, -gravity, wind));
232
+ transientDynamicsWorld.setGravity(new Vector3f(0.075f, -gravity, wind));
229233
230234 SetDynamics(transientDynamicsWorld);
231235 }
....@@ -251,7 +255,7 @@
251255 // myoffset = dynamicsWorld.getNumCollisionObjects() - 1;
252256 //
253257 // if (myoffset == 0)
254
- clientResetScene();
258
+// clientResetScene();
255259 }
256260
257261 public RigidBody localCreateRigidBody(float mass, Transform startTransform, CollisionShape shape)
....@@ -271,7 +275,7 @@
271275 //#ifdef USE_MOTIONSTATE
272276 DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
273277
274
- float friction = 1;
278
+ float friction = 1f;
275279
276280 RigidBodyConstructionInfo cInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia, friction);
277281
....@@ -288,7 +292,7 @@
288292
289293 public void clientResetScene()
290294 {
291
-// System.exit(0);
295
+ System.exit(0);
292296 //#ifdef SHOW_NUM_DEEP_PENETRATIONS
293297 BulletStats.gNumDeepPenetrationChecks = 0;
294298 BulletStats.gNumGjkChecks = 0;
RagDoll.java
....@@ -123,6 +123,8 @@
123123 JOINT_COUNT
124124 }
125125
126
+ float scale;
127
+
126128 //DynamicsWorld ownerWorld;
127129 CollisionShape[] shapes = new CollisionShape[BodyPart.BODYPART_COUNT.ordinal()];
128130 RigidBody/*Serial*/[] bodies = new RigidBody/*Serial*/[BodyPart.BODYPART_COUNT.ordinal()];
....@@ -140,6 +142,8 @@
140142
141143 public void init(/*DynamicsWorld ownerWorld,*/ Vector3f positionOffset, float scale_ragdoll, boolean walk)
142144 {
145
+ scale = scale_ragdoll;
146
+
143147 this.walkmotion = walk;
144148
145149 boolean hasbodies = (bodies[BodyPart.BODYPART_SPINE.ordinal()] != null);
....@@ -149,32 +153,40 @@
149153 Transform tmpTrans = new Transform();
150154 Vector3f tmp = new Vector3f();
151155
152
- boolean node = true;
156
+ boolean node = false; // true;
157
+
158
+ // KIDS4
159
+ float upperarmlength = 0.3f; // 0.25
160
+ float lowerarmlength = 0.25f; // 0.2
161
+ float handlength = 0.1f; // 0.1
162
+ float upperarmdist = 0.15f;
153163
154164 // Setup the geometry
155165 //shapes[BodyPart.BODYPART_GROUND.ordinal()] = new CapsuleShape(scale_ragdoll * 0.125f, scale_ragdoll * 0.20f);
156166 //scale_ragdoll /= 1.25;
157167 if (!hasbodies)
158168 {
159
- shapes[BodyPart.BODYPART_PELVIS.ordinal()] = new CapsuleShape(scale_ragdoll * 0.15f, scale_ragdoll * 0.35f,false);
160
- shapes[BodyPart.BODYPART_SPINE.ordinal()] = new CapsuleShape(scale_ragdoll * 0.2f, scale_ragdoll * 0.5f,false);
161
- shapes[BodyPart.BODYPART_HEAD.ordinal()] = new CapsuleShape(scale_ragdoll * 0.15f, scale_ragdoll * 0.15f,false);
169
+ float thin = 0.1f;
170
+
171
+ shapes[BodyPart.BODYPART_PELVIS.ordinal()] = new CapsuleShape(scale_ragdoll * 0.15f, scale_ragdoll * 0.35f, false);
172
+ shapes[BodyPart.BODYPART_SPINE.ordinal()] = new CapsuleShape(scale_ragdoll * 0.2f, scale_ragdoll * 0.5f, false);
173
+ shapes[BodyPart.BODYPART_HEAD.ordinal()] = new CapsuleShape(scale_ragdoll * 0.15f, scale_ragdoll * 0.15f, false);
162174
163
- shapes[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.1f, scale_ragdoll * 0.4f,false);
164
- shapes[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.06f, scale_ragdoll * 0.37f,node);
165
- shapes[BodyPart.BODYPART_LEFT_FOOT.ordinal()] = new CapsuleShape(scale_ragdoll * 0.04f, scale_ragdoll * 0.1f,node);
175
+ shapes[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.4f * thin, scale_ragdoll * 0.4f, node);
176
+ shapes[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.37f * thin, scale_ragdoll * 0.37f, node);
177
+ shapes[BodyPart.BODYPART_LEFT_FOOT.ordinal()] = new CapsuleShape(scale_ragdoll * 0.1f * thin, scale_ragdoll * 0.1f, node);
166178
167
- shapes[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.1f, scale_ragdoll * 0.4f,false);
168
- shapes[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.06f, scale_ragdoll * 0.37f,node);
169
- shapes[BodyPart.BODYPART_RIGHT_FOOT.ordinal()] = new CapsuleShape(scale_ragdoll * 0.04f, scale_ragdoll * 0.1f,node);
179
+ shapes[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.4f * thin, scale_ragdoll * 0.4f, node);
180
+ shapes[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.37f * thin, scale_ragdoll * 0.37f, node);
181
+ shapes[BodyPart.BODYPART_RIGHT_FOOT.ordinal()] = new CapsuleShape(scale_ragdoll * 0.1f * thin, scale_ragdoll * 0.1f, node);
170182
171
- shapes[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * 0.08f, scale_ragdoll * 0.25f,node);
172
- shapes[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * 0.06f, scale_ragdoll * 0.2f,node);
173
- shapes[BodyPart.BODYPART_LEFT_HAND.ordinal()] = new CapsuleShape(scale_ragdoll * 0.04f, scale_ragdoll * 0.1f,node);
183
+ shapes[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * upperarmlength * thin, scale_ragdoll * upperarmlength, node);
184
+ shapes[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * lowerarmlength * thin, scale_ragdoll * lowerarmlength, node);
185
+ shapes[BodyPart.BODYPART_LEFT_HAND.ordinal()] = new CapsuleShape(scale_ragdoll * handlength * thin, scale_ragdoll * handlength, node);
174186
175
- shapes[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * 0.08f, scale_ragdoll * 0.25f,node);
176
- shapes[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * 0.06f, scale_ragdoll * 0.2f,node);
177
- shapes[BodyPart.BODYPART_RIGHT_HAND.ordinal()] = new CapsuleShape(scale_ragdoll * 0.04f, scale_ragdoll * 0.1f,node);
187
+ shapes[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * upperarmlength * thin, scale_ragdoll * upperarmlength, node);
188
+ shapes[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()] = new CapsuleShape(scale_ragdoll * lowerarmlength * thin, scale_ragdoll * lowerarmlength, node);
189
+ shapes[BodyPart.BODYPART_RIGHT_HAND.ordinal()] = new CapsuleShape(scale_ragdoll * handlength * thin, scale_ragdoll * handlength, node);
178190 }
179191 //scale_ragdoll *= 1.25;
180192
....@@ -185,7 +197,7 @@
185197
186198 Transform transform = new Transform();
187199
188
- float depth = -0.02f; // .02f;
200
+ float depth = -0.01f; // .02f;
189201
190202 // transform.setIdentity();
191203 // transform.origin.set(0f, scale_ragdoll * 1f, 0f);
....@@ -242,7 +254,7 @@
242254 transform.setIdentity();
243255 if ((body = bodies[BodyPart.BODYPART_LEFT_FOOT.ordinal()]) == null)
244256 body = bodies[BodyPart.BODYPART_LEFT_FOOT.ordinal()] = localCreateRigidBody(massfeet, poisefeet, transform, shapes[BodyPart.BODYPART_LEFT_FOOT.ordinal()]);
245
- transform.origin.set(-0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.025f);
257
+ transform.origin.set(-0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.0125f);
246258 MatrixUtil.setEulerZYX(transform.basis, BulletGlobals.SIMD_PI/2, 0,BulletGlobals.SIMD_PI); // BulletGlobals.SIMD_PI, 0);
247259 tmpTrans.mul(offset, transform);
248260 body.worldTransform.set(tmpTrans);
....@@ -252,7 +264,7 @@
252264 transform.setIdentity();
253265 if ((body = bodies[BodyPart.BODYPART_RIGHT_FOOT.ordinal()]) == null)
254266 body = bodies[BodyPart.BODYPART_RIGHT_FOOT.ordinal()] = localCreateRigidBody(massfeet, poisefeet, transform, shapes[BodyPart.BODYPART_RIGHT_FOOT.ordinal()]);
255
- transform.origin.set(0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.025f);
267
+ transform.origin.set(0.09f * scale_ragdoll, 0.075f * scale_ragdoll, 0.0125f);
256268 MatrixUtil.setEulerZYX(transform.basis, BulletGlobals.SIMD_PI/2, 0,BulletGlobals.SIMD_PI); // BulletGlobals.SIMD_PI, 0);
257269 tmpTrans.mul(offset, transform);
258270 body.worldTransform.set(tmpTrans);
....@@ -300,7 +312,7 @@
300312 transform.setIdentity();
301313 if ((body = bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()]) == null)
302314 body = bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()]);
303
- transform.origin.set(-0.275f * scale_ragdoll, 1.325f * scale_ragdoll, depth);
315
+ transform.origin.set(-(upperarmlength/2 + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth);
304316 MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_HALF_PI);
305317 tmpTrans.mul(offset, transform);
306318 body.worldTransform.set(tmpTrans);
....@@ -310,7 +322,7 @@
310322 transform.setIdentity();
311323 if ((body = bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()]) == null)
312324 body = bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()]);
313
- transform.origin.set(-0.5f * scale_ragdoll, 1.325f * scale_ragdoll, depth);
325
+ transform.origin.set(-(lowerarmlength/2 + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth);
314326 MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_HALF_PI);
315327 tmpTrans.mul(offset, transform);
316328 body.worldTransform.set(tmpTrans);
....@@ -320,7 +332,7 @@
320332 transform.setIdentity();
321333 if ((body = bodies[BodyPart.BODYPART_LEFT_HAND.ordinal()]) == null)
322334 body = bodies[BodyPart.BODYPART_LEFT_HAND.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_LEFT_HAND.ordinal()]);
323
- transform.origin.set(-0.65f * scale_ragdoll, 1.325f * scale_ragdoll, depth);
335
+ transform.origin.set(-(handlength/2 + lowerarmlength + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth);
324336 MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_HALF_PI);
325337 tmpTrans.mul(offset, transform);
326338 body.worldTransform.set(tmpTrans);
....@@ -330,7 +342,7 @@
330342 transform.setIdentity();
331343 if ((body = bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()]) == null)
332344 body = bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()]);
333
- transform.origin.set(0.275f * scale_ragdoll, 1.325f * scale_ragdoll, depth);
345
+ transform.origin.set((upperarmlength/2 + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth);
334346 MatrixUtil.setEulerZYX(transform.basis, 0, 0, -BulletGlobals.SIMD_HALF_PI);
335347 tmpTrans.mul(offset, transform);
336348 body.worldTransform.set(tmpTrans);
....@@ -340,7 +352,7 @@
340352 transform.setIdentity();
341353 if ((body = bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()]) == null)
342354 body = bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()]);
343
- transform.origin.set(0.50f * scale_ragdoll, 1.325f * scale_ragdoll, depth);
355
+ transform.origin.set((lowerarmlength/2 + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth);
344356 MatrixUtil.setEulerZYX(transform.basis, 0, 0, -BulletGlobals.SIMD_HALF_PI);
345357 tmpTrans.mul(offset, transform);
346358 body.worldTransform.set(tmpTrans);
....@@ -350,7 +362,7 @@
350362 transform.setIdentity();
351363 if ((body = bodies[BodyPart.BODYPART_RIGHT_HAND.ordinal()]) == null)
352364 body = bodies[BodyPart.BODYPART_RIGHT_HAND.ordinal()] = localCreateRigidBody(1f, 0, transform, shapes[BodyPart.BODYPART_RIGHT_HAND.ordinal()]);
353
- transform.origin.set(0.65f * scale_ragdoll, 1.325f * scale_ragdoll, depth);
365
+ transform.origin.set((handlength/2 + lowerarmlength + upperarmlength + upperarmdist) * scale_ragdoll, 1.325f * scale_ragdoll, depth);
354366 MatrixUtil.setEulerZYX(transform.basis, 0, 0, -BulletGlobals.SIMD_HALF_PI);
355367 tmpTrans.mul(offset, transform);
356368 body.worldTransform.set(tmpTrans);
....@@ -418,10 +430,10 @@
418430 localA.setIdentity();
419431 localB.setIdentity();
420432
421
- localA.origin.set(-0.15f * scale_ragdoll, 0.125f * scale_ragdoll, depth);
433
+ localA.origin.set(-upperarmdist * scale_ragdoll, 0.125f * scale_ragdoll, depth);
422434
423435 MatrixUtil.setEulerZYX(localB.basis, 0/*BulletGlobals.SIMD_HALF_PI*/, 0, -BulletGlobals.SIMD_HALF_PI);
424
- localB.origin.set(0f, -0.125f * scale_ragdoll, 0);
436
+ localB.origin.set(0f, -upperarmlength/2 * scale_ragdoll, 0);
425437
426438 joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_SPINE.ordinal()], bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()], localA, localB, useLinearReferenceFrameA);
427439
....@@ -447,9 +459,9 @@
447459 localA.setIdentity();
448460 localB.setIdentity();
449461
450
- localA.origin.set(0.15f * scale_ragdoll, 0.125f * scale_ragdoll, depth);
462
+ localA.origin.set(upperarmdist * scale_ragdoll, 0.125f * scale_ragdoll, depth);
451463 MatrixUtil.setEulerZYX(localB.basis, 0, 0, BulletGlobals.SIMD_HALF_PI);
452
- localB.origin.set(0f, -0.125f * scale_ragdoll, 0);
464
+ localB.origin.set(0f, -upperarmlength/2 * scale_ragdoll, 0);
453465 joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_SPINE.ordinal()], bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()], localA, localB, useLinearReferenceFrameA);
454466
455467 //#ifdef RIGID
....@@ -474,8 +486,8 @@
474486 localA.setIdentity();
475487 localB.setIdentity();
476488
477
- localA.origin.set(0f, 0.125f * scale_ragdoll, 0f);
478
- localB.origin.set(0f, -0.1f * scale_ragdoll, 0f);
489
+ localA.origin.set(0f, upperarmlength/2 * scale_ragdoll, 0f);
490
+ localB.origin.set(0f, -lowerarmlength/2 * scale_ragdoll, 0f);
479491 joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()], bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()], localA, localB, useLinearReferenceFrameA);
480492
481493 //#ifdef RIGID
....@@ -500,8 +512,8 @@
500512 localA.setIdentity();
501513 localB.setIdentity();
502514
503
- localA.origin.set(0f, 0.125f * scale_ragdoll, 0f);
504
- localB.origin.set(0f, -0.1f * scale_ragdoll, 0f);
515
+ localA.origin.set(0f, upperarmlength/2 * scale_ragdoll, 0f);
516
+ localB.origin.set(0f, -lowerarmlength/2 * scale_ragdoll, 0f);
505517 joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()], bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()], localA, localB, useLinearReferenceFrameA);
506518
507519 //#ifdef RIGID
....@@ -526,8 +538,8 @@
526538 localA.setIdentity();
527539 localB.setIdentity();
528540
529
- localA.origin.set(0f, 0.1f * scale_ragdoll, 0f);
530
- localB.origin.set(0f, -0.05f * scale_ragdoll, 0f);
541
+ localA.origin.set(0f, lowerarmlength/2 * scale_ragdoll, 0f);
542
+ localB.origin.set(0f, -handlength/2 * scale_ragdoll, 0f);
531543 joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()], bodies[BodyPart.BODYPART_LEFT_HAND.ordinal()], localA, localB, useLinearReferenceFrameA);
532544
533545 //#ifdef RIGID
....@@ -552,8 +564,8 @@
552564 localA.setIdentity();
553565 localB.setIdentity();
554566
555
- localA.origin.set(0f, 0.1f * scale_ragdoll, 0f);
556
- localB.origin.set(0f, -0.05f * scale_ragdoll, 0f);
567
+ localA.origin.set(0f, lowerarmlength/2 * scale_ragdoll, 0f);
568
+ localB.origin.set(0f, -handlength/2 * scale_ragdoll, 0f);
557569 joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()], bodies[BodyPart.BODYPART_RIGHT_HAND.ordinal()], localA, localB, useLinearReferenceFrameA);
558570
559571 //#ifdef RIGID
com/bulletphysics/collision/shapes/ShapeHull.java
....@@ -118,6 +118,12 @@
118118 if (loop == 1)
119119 {
120120 //vec2.scale(0.5f);
121
+
122
+ // Nodes are bigger
123
+ vec2.x *= 5;
124
+ vec2.y *= 5;
125
+ vec2.z *= 5;
126
+
121127 switch (capsule.getUpAxis())
122128 {
123129 case 0: vec2.x /= capsule.getHalfHeight(); vec2.x *= capsule.getRadius()/2; vec2.x -= capsule.getHalfHeight(); break;
....@@ -125,6 +131,7 @@
125131 case 2: vec2.z /= capsule.getHalfHeight(); vec2.z *= capsule.getRadius()/2; vec2.z -= capsule.getHalfHeight(); break;
126132 }
127133 }
134
+
128135 vertices.getQuick(loop*NUM_UNITSPHERE_POINTS + i*rows + j).set(vec2);
129136 normals.getQuick(loop*NUM_UNITSPHERE_POINTS + i*rows + j).set(normout);
130137 }
com/bulletphysics/dynamics/RigidBody.java
....@@ -214,11 +214,31 @@
214214 }
215215 }
216216
217
+ static Vector3f g = new Vector3f();
218
+ static Vector3f w = new Vector3f();
219
+ static public Vector3f wind = new Vector3f();
220
+ static public Vector3f pos = new Vector3f();
221
+
217222 public void applyGravity() {
218223 if (isStaticOrKinematicObject())
219224 return;
220225
221
- applyCentralForce(gravity);
226
+ g.y = gravity.y;
227
+ applyCentralForce(g);
228
+
229
+ wind.set(pos);
230
+ wind.x -= worldTransform.origin.x;
231
+ wind.y -= worldTransform.origin.y;
232
+ wind.z -= worldTransform.origin.z;
233
+
234
+ float dot = pos.x * wind.x + pos.y * wind.y + pos.z * wind.z;
235
+
236
+ dot = 10;
237
+
238
+ w.x = wind.x * gravity.z * dot;
239
+ w.y = wind.y * gravity.z * dot;
240
+ w.z = wind.z * gravity.z * dot;
241
+ applyCentralForce(w);
222242 }
223243
224244 public void setGravity(Vector3f acceleration) {