Normand Briere
2019-05-01 b1585b5b2b60c4165be400636c787fae24428c6a
CameraPane.java
....@@ -86,12 +86,14 @@
8686 static boolean FULLSCREEN = false;
8787 static boolean SUPPORT = true;
8888 static boolean INERTIA = true;
89
-static boolean FAST = false;
89
+static boolean FAST = true; // false;
9090 static boolean SLOWPOSE = false;
9191 static boolean FOOTCONTACT = true;
9292
9393 static int tickcount = 0; // slow pose issue
9494
95
+static boolean BUTTONLESSWHEEL = false;
96
+static boolean ZOOMBOXMODE = false;
9597 static boolean BOXMODE = false;
9698 static boolean IMAGEFLIP = false;
9799 static boolean SMOOTHFOCUS = false;
....@@ -149,12 +151,11 @@
149151 defaultcaps.setAccumBlueBits(16);
150152 defaultcaps.setAccumAlphaBits(16);
151153 }
152
- static CameraPane theRenderer;
153
-
154
+
154155 void SetAsGLRenderer(boolean b)
155156 {
156157 isRenderer = b;
157
- theRenderer = this;
158
+ Globals.theRenderer = this;
158159 }
159160
160161 CameraPane(Object3D o, Camera cam, boolean withcontext)
....@@ -192,9 +193,43 @@
192193
193194 /// INTERFACE
194195
196
+ public javax.media.opengl.GL GetGL0()
197
+ {
198
+ return null;
199
+ }
200
+
201
+ public int GenList()
202
+ {
203
+ javax.media.opengl.GL gl = GetGL();
204
+ return gl.glGenLists(1);
205
+ }
206
+
207
+ public void NewList(int id)
208
+ {
209
+ javax.media.opengl.GL gl = GetGL();
210
+ gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE);
211
+ }
212
+
213
+ public void CallList(int id)
214
+ {
215
+ javax.media.opengl.GL gl = GetGL();
216
+ gl.glCallList(id);
217
+ }
218
+
219
+ public void EndList()
220
+ {
221
+ javax.media.opengl.GL gl = GetGL();
222
+ gl.glEndList();
223
+ }
224
+
195225 public boolean IsBoxMode()
196226 {
197227 return BOXMODE;
228
+ }
229
+
230
+ public boolean IsZoomBoxMode()
231
+ {
232
+ return ZOOMBOXMODE;
198233 }
199234
200235 public void ClearDepth()
....@@ -236,9 +271,14 @@
236271 return this.ambientOcclusion;
237272 }
238273
274
+ public boolean IsDebugSelection()
275
+ {
276
+ return DEBUG_SELECTION;
277
+ }
278
+
239279 public boolean IsFrozen()
240280 {
241
- boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
281
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
242282
243283 return !selectmode && cameracount == 0; // != 0;
244284 }
....@@ -259,9 +299,19 @@
259299 return lightCamera;
260300 }
261301
302
+ public Camera ManipCamera()
303
+ {
304
+ return manipCamera;
305
+ }
306
+
262307 public Camera RenderCamera()
263308 {
264309 return renderCamera;
310
+ }
311
+
312
+ public Camera[] Cameras()
313
+ {
314
+ return cameras;
265315 }
266316
267317 public void PushMaterial(Object3D obj, boolean selected)
....@@ -408,7 +458,7 @@
408458
409459 javax.media.opengl.GL gl = display.GetGL();
410460
411
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
461
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
412462
413463 //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
414464 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
....@@ -760,7 +810,621 @@
760810 //// tris.postdraw(this);
761811 }
762812
813
+ static Camera localcamera = new Camera();
814
+ static cVector from = new cVector();
815
+ static cVector to = new cVector();
816
+
817
+ public void PrepOcclusion(BoundaryRep br, double[][] transform)
818
+ {
819
+ CameraPane cp = this;
820
+
821
+ Camera keep = cp.RenderCamera();
822
+ cp.renderCamera = localcamera;
823
+
824
+ if (br.trimmed)
825
+ {
826
+ float[] colors = new float[br.positions.length / 3];
827
+
828
+ int i3 = 0;
829
+ for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
830
+ {
831
+ if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
832
+ continue;
833
+
834
+ from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
835
+ to.set(br.positions[i3] + br.normals[i3],
836
+ br.positions[i3 + 1] + br.normals[i3 + 1],
837
+ br.positions[i3 + 2] + br.normals[i3 + 2]);
838
+ LA.xformPos(from, transform, from);
839
+ LA.xformPos(to, transform, to); // RIGID ONLY
840
+ localcamera.setAim(from, to);
841
+
842
+ CameraPane.occlusionbuffer.display();
843
+
844
+ if (CameraPane.DEBUG_OCCLUSION)
845
+ cp.display(); // debug
846
+
847
+ colors[i] = cp.vertexOcclusion.r;
848
+ //colors[i3 + 1] = cp.vertexOcclusion.g;
849
+ //colors[i3 + 2] = cp.vertexOcclusion.b;
850
+
851
+ if ((i % 100) == 0 && i != 0)
852
+ {
853
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
854
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
855
+ System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
856
+ }
857
+ }
858
+
859
+ br.colors = colors;
860
+ }
861
+ else
862
+ {
863
+ for (int i = 0; i < br.VertexCount(); i++)
864
+ {
865
+ Vertex v = br.GetVertex(i);
866
+
867
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
868
+ continue;
869
+
870
+ from.set(v.x, v.y, v.z);
871
+ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
872
+ LA.xformPos(from, transform, from);
873
+ LA.xformPos(to, transform, to); // RIGID ONLY
874
+ localcamera.setAim(from, to);
875
+
876
+ CameraPane.occlusionbuffer.display();
877
+
878
+ if (CameraPane.DEBUG_OCCLUSION)
879
+ cp.display(); // debug
880
+
881
+ v.AO = cp.vertexOcclusion.r;
882
+
883
+ if ((i % 100) == 0 && i != 0)
884
+ {
885
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
886
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
887
+ System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
888
+ }
889
+ }
890
+ }
891
+
892
+ //System.out.println("done.");
893
+
894
+ cp.renderCamera = keep;
895
+ }
896
+
897
+ void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
898
+ {
899
+ CameraPane display = this;
900
+ pointFlow.CreateHT();
901
+
902
+ float r = display.modelParams0[0];
903
+ float g = display.modelParams0[1];
904
+ float b = display.modelParams0[2];
905
+ float opacity = display.modelParams5[1];
906
+
907
+ //final GL gl = GLU.getCurrentGL();
908
+ GL gl = display.GetGL(); // getGL();
909
+
910
+ int s = pointFlow.points.size();
911
+
912
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
913
+ gl.glEnable(gl.GL_CULL_FACE);
914
+
915
+ for (int i=s; --i>=0;)
916
+ //for (int i=0; i<s; i++)
917
+ {
918
+ cVector v = pointFlow.points.get(i);
919
+
920
+ double mindist = Double.MAX_VALUE;
921
+
922
+ double size = pointFlow.minimumSize;
923
+
924
+ double distancenext = 0;
925
+
926
+ if (i > 0)
927
+ {
928
+ cVector w = pointFlow.points.get(i-1);
929
+
930
+ double dist = w.distance(v);
931
+
932
+ distancenext = dist;
933
+
934
+ if (mindist > dist)
935
+ {
936
+ mindist = dist;
937
+ size = mindist*pointFlow.resizefactor;
938
+ }
939
+ }
940
+
941
+ if (i < s-1)
942
+ {
943
+ cVector w = pointFlow.points.get(i+1);
944
+
945
+ double dist = w.distance(v);
946
+
947
+ if (mindist > dist)
948
+ {
949
+ mindist = dist;
950
+ size = mindist*pointFlow.resizefactor;
951
+ }
952
+ }
953
+
954
+ if (size < pointFlow.minimumSize)
955
+ size = pointFlow.minimumSize;
956
+ if (size > pointFlow.maximumSize)
957
+ size = pointFlow.maximumSize;
958
+
959
+ double tx = v.x;
960
+ double ty = v.y;
961
+ double tz = v.z;
962
+
963
+ // if (tx == 0 && ty == 0 && tz == 0)
964
+ // continue;
965
+
966
+ gl.glMatrixMode(gl.GL_TEXTURE);
967
+ gl.glPushMatrix();
968
+ pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
969
+
970
+ gl.glMultMatrixf(pointFlow.texmat, 0);
971
+
972
+ gl.glMatrixMode(gl.GL_MODELVIEW);
973
+ gl.glPushMatrix();
974
+
975
+ gl.glTranslated(tx,ty,tz);
976
+
977
+ gl.glScaled(size,size,size);
978
+
979
+// float cr = colorBuf.get(index4);
980
+// float cg = colorBuf.get(index4+1);
981
+// float cb = colorBuf.get(index4+2);
982
+// float ca = colorBuf.get(index4+3);
983
+//
984
+// display.modelParams0[0] = r * cr;
985
+// display.modelParams0[1] = g * cg;
986
+// display.modelParams0[2] = b * cb;
987
+//
988
+// display.modelParams5[1] = opacity * ca;
989
+//
990
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
991
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
992
+//
993
+// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
994
+// RandomNode.globalseed2 = RandomNode.globalseed;
995
+//
996
+//// gl.glColor4f(cr,cg,cb,ca);
997
+// // gl.glScalef(1024/16,1024/16,1024/16);
998
+ pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
999
+
1000
+ gl.glPopMatrix();
1001
+
1002
+ double step = size/4; //
1003
+
1004
+ if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
1005
+ continue;
1006
+
1007
+ int nbsteps = (int)(distancenext/step);
1008
+
1009
+ step = distancenext/nbsteps;
1010
+
1011
+ cVector next = pointFlow.points.get(i-1);
1012
+
1013
+ tmp.set(next);
1014
+ tmp.sub(v);
1015
+ tmp.normalize();
1016
+ tmp.mul(step);
1017
+
1018
+ // calculate next size
1019
+ mindist = Double.MAX_VALUE;
1020
+
1021
+ double nextsize = pointFlow.minimumSize;
1022
+
1023
+ if (i > 1)
1024
+ {
1025
+ cVector w = pointFlow.points.get(i-2);
1026
+
1027
+ double dist = w.distance(next);
1028
+
1029
+ if (mindist > dist)
1030
+ {
1031
+ mindist = dist;
1032
+ nextsize = mindist*pointFlow.resizefactor;
1033
+ }
1034
+ }
1035
+
1036
+ double dist = v.distance(next);
1037
+
1038
+ if (mindist > dist)
1039
+ {
1040
+ mindist = dist;
1041
+ nextsize = mindist*pointFlow.resizefactor;
1042
+ }
1043
+
1044
+ if (nextsize < pointFlow.minimumSize)
1045
+ nextsize = pointFlow.minimumSize;
1046
+ if (nextsize > pointFlow.maximumSize)
1047
+ nextsize = pointFlow.maximumSize;
1048
+ //
1049
+
1050
+ double count = 0;
1051
+
1052
+ while (distancenext > 0.000000001) // step
1053
+ {
1054
+ gl.glPushMatrix();
1055
+
1056
+ gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
1057
+
1058
+ double K = count/nbsteps;
1059
+
1060
+ double intersize = K*nextsize + (1-K)*size;
1061
+
1062
+ gl.glScaled(intersize,intersize,intersize);
1063
+
1064
+ pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
1065
+
1066
+ count++;
1067
+
1068
+ distancenext -= step;
1069
+
1070
+ gl.glPopMatrix();
1071
+ }
1072
+
1073
+ if (count != nbsteps)
1074
+ assert(count == nbsteps);
1075
+
1076
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
1077
+ //gl.glTranslatef(-tx,-ty,-tz);
1078
+
1079
+ gl.glMatrixMode(gl.GL_TEXTURE);
1080
+ gl.glPopMatrix();
1081
+ }
1082
+
1083
+ if (!cf)
1084
+ gl.glDisable(gl.GL_CULL_FACE);
1085
+
1086
+// display.modelParams0[0] = r;
1087
+// display.modelParams0[1] = g;
1088
+// display.modelParams0[2] = b;
1089
+//
1090
+// display.modelParams5[1] = opacity;
1091
+//
1092
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1093
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1094
+
1095
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1096
+ }
1097
+
1098
+ public void DrawBox(cVector min, cVector max)
1099
+ {
1100
+ javax.media.opengl.GL gl = GetGL();
1101
+ gl.glBegin(gl.GL_LINES);
1102
+
1103
+ gl.glVertex3d(min.x, min.y, min.z);
1104
+ gl.glVertex3d(min.x, min.y, max.z);
1105
+ gl.glVertex3d(min.x, min.y, min.z);
1106
+ gl.glVertex3d(min.x, max.y, min.z);
1107
+ gl.glVertex3d(min.x, min.y, min.z);
1108
+ gl.glVertex3d(max.x, min.y, min.z);
1109
+
1110
+ gl.glVertex3d(max.x, max.y, max.z);
1111
+ gl.glVertex3d(min.x, max.y, max.z);
1112
+ gl.glVertex3d(max.x, max.y, max.z);
1113
+ gl.glVertex3d(max.x, min.y, max.z);
1114
+ gl.glVertex3d(max.x, max.y, max.z);
1115
+ gl.glVertex3d(max.x, max.y, min.z);
1116
+
1117
+ gl.glEnd();
1118
+ }
1119
+
1120
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1121
+ {
1122
+ int[] strips = bRep.getRawIndices();
1123
+
1124
+ javax.media.opengl.GL gl = GetGL();
1125
+
1126
+ // TRIANGLE STRIP ARRAY
1127
+ if (bRep.trimmed)
1128
+ {
1129
+ float[] v = bRep.getRawVertices();
1130
+ float[] n = bRep.getRawNormals();
1131
+ float[] c = bRep.getRawColors();
1132
+ float[] uv = bRep.getRawUVMap();
1133
+
1134
+ int count2 = 0;
1135
+ int count3 = 0;
1136
+
1137
+ if (n.length > 0)
1138
+ {
1139
+ for (int i = 0; i < strips.length; i++)
1140
+ {
1141
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1142
+
1143
+ /*
1144
+ boolean locked = false;
1145
+ float eps = 0.1f;
1146
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1147
+
1148
+ int dot = 0;
1149
+
1150
+ if ((dot&1) == 0)
1151
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1152
+
1153
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1154
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1155
+ else
1156
+ {
1157
+ locked = true;
1158
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1159
+ }
1160
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1161
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1162
+ if (hasnorm)
1163
+ {
1164
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1165
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1166
+ }
1167
+
1168
+ if ((dot&4) == 0)
1169
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1170
+
1171
+ if (wrap || !locked && (dot&8) != 0)
1172
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1173
+ else
1174
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1175
+
1176
+ f.dot = dot;
1177
+ */
1178
+
1179
+ if (!selectmode)
1180
+ {
1181
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1182
+ {
1183
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1184
+ } else
1185
+ {
1186
+ gl.glNormal3f(0, 0, 1);
1187
+ }
1188
+
1189
+ if (c != null)
1190
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1191
+ {
1192
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1193
+ }
1194
+ }
1195
+ if (flipV)
1196
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1197
+ else
1198
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1199
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1200
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1201
+
1202
+ count2 += 2;
1203
+ count3 += 3;
1204
+ if (!selectmode)
1205
+ {
1206
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1207
+ {
1208
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1209
+ } else
1210
+ {
1211
+ gl.glNormal3f(0, 0, 1);
1212
+ }
1213
+ if (c != null)
1214
+ {
1215
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1216
+ }
1217
+ }
1218
+ if (flipV)
1219
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1220
+ else
1221
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1222
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1223
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1224
+
1225
+ count2 += 2;
1226
+ count3 += 3;
1227
+ for (int j = 0; j < strips[i] - 2; j++)
1228
+ {
1229
+ //gl.glTexCoord2d(...);
1230
+ if (!selectmode)
1231
+ {
1232
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1233
+ {
1234
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1235
+ } else
1236
+ {
1237
+ gl.glNormal3f(0, 0, 1);
1238
+ }
1239
+ if (c != null)
1240
+ {
1241
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1242
+ }
1243
+ }
1244
+
1245
+ if (flipV)
1246
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1247
+ else
1248
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1249
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1250
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1251
+ count2 += 2;
1252
+ count3 += 3;
1253
+ }
1254
+
1255
+ gl.glEnd();
1256
+ }
1257
+ }
1258
+
1259
+ assert count3 == v.length;
1260
+ }
1261
+ else // !trimmed
1262
+ {
1263
+ int count = 0;
1264
+ for (int i = 0; i < strips.length; i++)
1265
+ {
1266
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1267
+
1268
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1269
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1270
+
1271
+ drawVertex(gl, p, flipV, selectmode);
1272
+ drawVertex(gl, q, flipV, selectmode);
1273
+
1274
+ for (int j = 0; j < strips[i] - 2; j++)
1275
+ {
1276
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1277
+
1278
+ // if (j%2 == 0)
1279
+ // drawFace(p, q, r, display, null);
1280
+ // else
1281
+ // drawFace(p, r, q, display, null);
1282
+
1283
+ // p = q;
1284
+ // q = r;
1285
+ drawVertex(gl, r, flipV, selectmode);
1286
+ }
1287
+
1288
+ gl.glEnd();
1289
+ }
1290
+ }
1291
+ }
1292
+
1293
+ static cSpring.Point3D temp = new cSpring.Point3D();
1294
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1295
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1296
+
1297
+ public void DrawDynamicMesh(cMesh mesh)
1298
+ {
1299
+ GL gl = GetGL(); // getGL();
1300
+
1301
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1302
+
1303
+ gl.glDisable(gl.GL_LIGHTING);
1304
+
1305
+ gl.glLineWidth(1);
1306
+ gl.glColor3f(1,1,1);
1307
+ gl.glBegin(gl.GL_LINES);
1308
+ double scale = 0;
1309
+ int count = 0;
1310
+ for (int s=0; s<Phys.allSprings.size(); s++)
1311
+ {
1312
+ cSpring.Spring spring = Phys.allSprings.get(s);
1313
+ if(s == 0)
1314
+ {
1315
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1316
+ }
1317
+ if (mesh.showsprings)
1318
+ {
1319
+ temp.set(spring.a.position);
1320
+ temp.add(spring.b.position);
1321
+ temp.mul(0.5);
1322
+ temp2.set(spring.a.position);
1323
+ temp2.sub(spring.b.position);
1324
+ temp2.mul(spring.restLength/2);
1325
+ temp.sub(temp2);
1326
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1327
+ temp.add(temp2);
1328
+ temp.add(temp2);
1329
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1330
+ }
1331
+
1332
+ if (spring.isHandle)
1333
+ continue;
1334
+
1335
+ //if (scale < spring.restLength)
1336
+ scale += spring.restLength;
1337
+ count++;
1338
+ }
1339
+ gl.glEnd();
1340
+
1341
+ if (count == 0)
1342
+ scale = 0.01;
1343
+ else
1344
+ scale /= count * 3;
1345
+
1346
+ //scale = 0.25;
1347
+
1348
+ if (mesh.ShowInfo())
1349
+ {
1350
+ gl.glLineWidth(4);
1351
+ for (int s=0; s<Phys.allNodes.size(); s++)
1352
+ {
1353
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1354
+ if (node.mass == 0)
1355
+ continue;
1356
+
1357
+ int i = node.springs==null?-1:node.springs.size();
1358
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1359
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1360
+ //temp.normalize();
1361
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1362
+ gl.glBegin(gl.GL_LINES);
1363
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1364
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1365
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1366
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1367
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1368
+ gl.glEnd();
1369
+ }
1370
+
1371
+ gl.glLineWidth(8);
1372
+ for (int s=0; s<Phys.allNodes.size(); s++)
1373
+ {
1374
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1375
+
1376
+ if (node.springs != null)
1377
+ {
1378
+ for (int i=0; i<node.springs.size(); i+=1)
1379
+ {
1380
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1381
+
1382
+ int c = i+1;
1383
+ // c = node.springs.get(i).nbcopies;
1384
+
1385
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1386
+ gl.glBegin(gl.GL_LINES);
1387
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1388
+ gl.glVertex3d(f.position.x/3+node.position.x*2/3, f.position.y/3+node.position.y*2/3, f.position.z/3+node.position.z*2/3);
1389
+ gl.glEnd();
1390
+ }
1391
+ }
1392
+ }
1393
+
1394
+ gl.glLineWidth(1);
1395
+ }
1396
+
1397
+ gl.glEnable(gl.GL_LIGHTING);
1398
+ }
1399
+
7631400 /// INTERFACE
1401
+
1402
+ public void StartTriangles()
1403
+ {
1404
+ javax.media.opengl.GL gl = GetGL();
1405
+ gl.glBegin(gl.GL_TRIANGLES);
1406
+ }
1407
+
1408
+ public void EndTriangles()
1409
+ {
1410
+ GetGL().glEnd();
1411
+ }
1412
+
1413
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1414
+ {
1415
+ if (!selectmode)
1416
+ {
1417
+ gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1418
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1419
+
1420
+ if (flipV)
1421
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1422
+ else
1423
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1424
+ }
1425
+
1426
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1427
+ }
7641428
7651429 void SetColor(Object3D obj, Vertex p0)
7661430 {
....@@ -955,12 +1619,12 @@
9551619 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
9561620 if (!material.multiply)
9571621 {
958
- display.color = color;
1622
+ display.color = material.color;
9591623 display.saturation = material.modulation;
9601624 }
9611625 else
9621626 {
963
- display.color *= color*2;
1627
+ display.color *= material.color*2;
9641628 display.saturation *= material.modulation*2;
9651629 }
9661630
....@@ -1323,7 +1987,7 @@
13231987
13241988 static int camerachangeframe;
13251989
1326
- boolean SetCamera(Camera cam)
1990
+ public boolean SetCamera(Camera cam)
13271991 {
13281992 // may 2014 if (cam == cameras[0] || cam == cameras[1])
13291993 // return false;
....@@ -1451,12 +2115,27 @@
14512115 mainDL ^= true;
14522116 }
14532117
1454
- void ToggleTexture()
2118
+ void ToggleFullScreen()
2119
+ {
2120
+ FULLSCREEN ^= true;
2121
+ }
2122
+
2123
+ void ToggleCrowd()
2124
+ {
2125
+ Globals.CROWD ^= true;
2126
+ }
2127
+
2128
+ void ToggleLocal()
2129
+ {
2130
+ LOCALTRANSFORM ^= true;
2131
+ }
2132
+
2133
+ public void ToggleTexture()
14552134 {
14562135 textureon ^= true;
14572136 }
14582137
1459
- void ToggleLive()
2138
+ public void ToggleLive()
14602139 {
14612140 Globals.setLIVE(Globals.isLIVE() ^ true);
14622141
....@@ -1468,92 +2147,72 @@
14682147 repaint(); // start loop // may 2013
14692148 }
14702149
1471
- void ToggleSupport()
2150
+ public void ToggleSupport()
14722151 {
14732152 SUPPORT ^= true;
14742153 }
14752154
1476
- void ToggleAbort()
2155
+ public void ToggleAbort()
14772156 {
14782157 ABORTMODE ^= true;
14792158 }
14802159
1481
- void ToggleFullScreen()
1482
- {
1483
- FULLSCREEN ^= true;
1484
- }
1485
-
1486
- void ToggleCrowd()
1487
- {
1488
- Globals.CROWD ^= true;
1489
- }
1490
-
1491
- void ToggleInertia()
2160
+ public void ToggleInertia()
14922161 {
14932162 INERTIA ^= true;
14942163 }
14952164
1496
- void ToggleLocal()
1497
- {
1498
- LOCALTRANSFORM ^= true;
1499
- }
1500
-
1501
- void ToggleFast()
2165
+ public void ToggleFast()
15022166 {
15032167 FAST ^= true;
15042168 }
15052169
1506
- void ToggleSlowPose()
2170
+ public void ToggleSlowPose()
15072171 {
15082172 SLOWPOSE ^= true;
15092173 }
15102174
1511
- void ToggleFootContact()
1512
- {
1513
- FOOTCONTACT ^= true;
1514
- }
1515
-
1516
- void ToggleBoxMode()
2175
+ public void ToggleBoxMode()
15172176 {
15182177 BOXMODE ^= true;
15192178 }
15202179
1521
- void ToggleSmoothFocus()
2180
+ public void ToggleZoomBoxMode()
2181
+ {
2182
+ ZOOMBOXMODE ^= true;
2183
+ }
2184
+
2185
+ public void ToggleSmoothFocus()
15222186 {
15232187 SMOOTHFOCUS ^= true;
15242188 }
15252189
1526
- void ToggleImageFlip()
2190
+ public void ToggleImageFlip()
15272191 {
15282192 IMAGEFLIP ^= true;
15292193 }
15302194
1531
- void ToggleSpeakerMocap()
2195
+ public void ToggleSpeakerMocap()
15322196 {
15332197 SPEAKERMOCAP ^= true;
15342198 }
15352199
1536
- void ToggleSpeakerCamera()
2200
+ public void ToggleSpeakerCamera()
15372201 {
15382202 SPEAKERCAMERA ^= true;
15392203 }
15402204
1541
- void ToggleSpeakerFocus()
2205
+ public void ToggleSpeakerFocus()
15422206 {
15432207 SPEAKERFOCUS ^= true;
15442208 }
15452209
1546
- void ToggleDebug()
1547
- {
1548
- DEBUG ^= true;
1549
- }
1550
-
1551
- void ToggleFrustum()
2210
+ public void ToggleFrustum()
15522211 {
15532212 FRUSTUM ^= true;
15542213 }
15552214
1556
- void ToggleTrack()
2215
+ public void ToggleTrack()
15572216 {
15582217 TRACK ^= true;
15592218 if (TRACK)
....@@ -1572,25 +2231,35 @@
15722231 repaint();
15732232 }
15742233
1575
- void ToggleTrackOnce()
2234
+ public void ToggleTrackOnce()
15762235 {
15772236 TRACKONCE ^= true;
15782237 }
15792238
1580
- void ToggleShadowTrack()
2239
+ public void ToggleShadowTrack()
15812240 {
15822241 SHADOWTRACK ^= true;
15832242 repaint();
15842243 }
15852244
1586
- void ToggleOeil()
2245
+ public void ToggleOeil()
15872246 {
15882247 OEIL ^= true;
15892248 }
15902249
1591
- void ToggleOeilOnce()
2250
+ public void ToggleOeilOnce()
15922251 {
15932252 OEILONCE ^= true;
2253
+ }
2254
+
2255
+ void ToggleFootContact()
2256
+ {
2257
+ FOOTCONTACT ^= true;
2258
+ }
2259
+
2260
+ void ToggleDebug()
2261
+ {
2262
+ DEBUG ^= true;
15942263 }
15952264
15962265 void ToggleLookAt()
....@@ -3539,6 +4208,7 @@
35394208
35404209 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
35414210 {
4211
+ new Exception().printStackTrace();
35424212 System.exit(0);
35434213 com.sun.opengl.util.texture.Texture texture = null;
35444214
....@@ -7652,7 +8322,7 @@
76528322 return texture!=null?texture.texture:null;
76538323 }
76548324
7655
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8325
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
76568326 {
76578327 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
76588328
....@@ -10340,7 +11010,7 @@
1034011010 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
1034111011 //System.out.println("fragmentMode = " + fragmentMode);
1034211012
10343
- if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION)
11013
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
1034411014 {
1034511015 /*
1034611016 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -10641,7 +11311,7 @@
1064111311 callist = gl.glGenLists(1);
1064211312 }
1064311313
10644
- boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
11314
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
1064511315
1064611316 boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
1064711317
....@@ -12078,7 +12748,7 @@
1207812748 "MUL final.y, fragment.texcoord[0].x, c256;" +
1207912749 "FLR final.x, final.y;" +
1208012750 "SUB final.y, final.y, final.x;" +
12081
- "MUL final.x, final.x, c256i;" +
12751
+ //"MUL final.x, final.x, c256i;" +
1208212752 "MOV final.z, zero.x;" +
1208312753 "MOV final.a, one.w;":""
1208412754 ) +
....@@ -12086,7 +12756,7 @@
1208612756 "MUL final.y, fragment.texcoord[0].y, c256;" +
1208712757 "FLR final.x, final.y;" +
1208812758 "SUB final.y, final.y, final.x;" +
12089
- "MUL final.x, final.x, c256i;" +
12759
+ //"MUL final.x, final.x, c256i;" +
1209012760 "MOV final.z, zero.x;" +
1209112761 "MOV final.a, one.w;":""
1209212762 ) +
....@@ -12866,6 +13536,7 @@
1286613536
1286713537 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1286813538
13539
+ if (BUTTONLESSWHEEL)
1286913540 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1287013541 {
1287113542 return;
....@@ -12874,7 +13545,7 @@
1287413545 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1287513546
1287613547 // TIMER
12877
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
13548
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1287813549 {
1287913550 keepboxmode = BOXMODE;
1288013551 keepsupport = SUPPORT;
....@@ -13091,11 +13762,11 @@
1309113762
1309213763 public void mouseDragged(MouseEvent e)
1309313764 {
13765
+ //System.out.println("mouseDragged: " + e);
1309413766 if (isRenderer)
1309513767 movingcamera = true;
1309613768 //if (drawing)
1309713769 //return;
13098
- //System.out.println("mouseDragged: " + e);
1309913770 if ((e.getModifiersEx() & CTRL) != 0
1310013771 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1310113772 {
....@@ -13115,6 +13786,11 @@
1311513786 cVector tmp = new cVector();
1311613787 cVector tmp2 = new cVector();
1311713788 boolean isMoving;
13789
+
13790
+ public cVector TargetLookAt()
13791
+ {
13792
+ return targetLookAt;
13793
+ }
1311813794
1311913795 class PingThread extends Thread
1312013796 {
....@@ -13271,6 +13947,7 @@
1327113947
1327213948 public void run()
1327313949 {
13950
+ new Exception().printStackTrace();
1327413951 System.exit(0);
1327513952 for (;;)
1327613953 {
....@@ -13625,7 +14302,6 @@
1362514302 public void mouseMoved(MouseEvent e)
1362614303 {
1362714304 //System.out.println("mouseMoved: " + e);
13628
-
1362914305 if (isRenderer)
1363014306 return;
1363114307
....@@ -13847,7 +14523,7 @@
1384714523 SetMouseMode(modifiers);
1384814524 }
1384914525
13850
- theRenderer.keyPressed(key);
14526
+ Globals.theRenderer.keyPressed(key);
1385114527 }
1385214528
1385314529 int kompactbit = 4; // power bit
....@@ -13859,7 +14535,7 @@
1385914535 float SATPOW = 1; // 2; // 0.5f;
1386014536 float BRIPOW = 1; // 0.5f; // 0.5f;
1386114537
13862
- void keyPressed(int key)
14538
+ public void keyPressed(int key)
1386314539 {
1386414540 if (key >= '0' && key <= '5')
1386514541 clampbit = (key-'0');
....@@ -14296,6 +14972,7 @@
1429614972 }
1429714973 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1429814974 }
14975
+
1429914976 static double OCCLUSIONBOOST = 1; // 0.5;
1430014977
1430114978 void keyReleased(int key, int modifiers)
....@@ -14307,7 +14984,7 @@
1430714984 }
1430814985 }
1430914986
14310
- protected void processKeyEvent(KeyEvent e)
14987
+ public void processKeyEvent(KeyEvent e)
1431114988 {
1431214989 switch (e.getID())
1431314990 {
....@@ -14437,8 +15114,9 @@
1443715114
1443815115 protected void processMouseMotionEvent(MouseEvent e)
1443915116 {
14440
- //System.out.println("processMouseMotionEvent: " + mouseMode);
14441
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15117
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15118
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15119
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
1444215120 {
1444315121 mouseMoved(e);
1444415122 } else
....@@ -14468,6 +15146,7 @@
1446815146
1446915147 void SelectParent()
1447015148 {
15149
+ new Exception().printStackTrace();
1447115150 System.exit(0);
1447215151 Composite group = (Composite) object;
1447315152 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -14491,6 +15170,7 @@
1449115170
1449215171 void SelectChildren()
1449315172 {
15173
+ new Exception().printStackTrace();
1449415174 System.exit(0);
1449515175 /*
1449615176 Composite group = (Composite) object;
....@@ -15604,6 +16284,7 @@
1560416284 {
1560516285 if (!selection)
1560616286 {
16287
+ new Exception().printStackTrace();
1560716288 System.exit(0);
1560816289 return;
1560916290 }
....@@ -15966,7 +16647,6 @@
1596616647
1596716648 class AntialiasBuffer implements GLEventListener
1596816649 {
15969
-
1597016650 CameraPane parent = null;
1597116651
1597216652 AntialiasBuffer(CameraPane p)
....@@ -16359,7 +17039,7 @@
1635917039 }
1636017040 }
1636117041
16362
- static void DrawPoints(CameraPane cpane)
17042
+ static void DrawPoints(iCameraPane cpane)
1636317043 {
1636417044 for (int i=0; i<8; i++) // first and last are red
1636517045 {
....@@ -16391,10 +17071,11 @@
1639117071 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1639217072 // Depth buffer format
1639317073 //private int depth_format;
16394
- static public void NextIndex(Object3D o, GL gl)
17074
+
17075
+ public void NextIndex()
1639517076 {
1639617077 indexcount+=16;
16397
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17078
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1639817079 //objects[indexcount] = o;
1639917080 //System.out.println("indexcount = " + indexcount);
1640017081 }