Normand Briere
2019-06-17 26b49d8e26625491f4a407a05e9bc9d72037f938
CameraPane.java
....@@ -56,8 +56,6 @@
5656 static int CURRENTANTIALIAS = 0; // 1;
5757 /*static*/ boolean RENDERSHADOW = true;
5858 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
59
- static boolean ANIMATION = false;
60
- static String filename;
6159
6260 boolean DISPLAYTEXT = false;
6361 //boolean REDUCETEXTURE = true;
....@@ -92,6 +90,8 @@
9290
9391 static int tickcount = 0; // slow pose issue
9492
93
+static boolean BUTTONLESSWHEEL = false;
94
+static boolean ZOOMBOXMODE = false;
9595 static boolean BOXMODE = false;
9696 static boolean IMAGEFLIP = false;
9797 static boolean SMOOTHFOCUS = false;
....@@ -106,7 +106,7 @@
106106 static boolean OEIL = true;
107107 static boolean OEILONCE = false; // do oeilon then oeiloff
108108 static boolean LOOKAT = true;
109
-static boolean RANDOM = true; // false;
109
+static boolean SWITCH = true; // false;
110110 static boolean HANDLES = false; // selection doesn't work!!
111111 static boolean PAINTMODE = false;
112112
....@@ -150,12 +150,12 @@
150150 defaultcaps.setAccumAlphaBits(16);
151151 }
152152
153
- static CameraPane theRenderer;
153
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
154154
155155 void SetAsGLRenderer(boolean b)
156156 {
157157 isRenderer = b;
158
- theRenderer = this;
158
+ Globals.theRenderer = this;
159159 }
160160
161161 CameraPane(Object3D o, Camera cam, boolean withcontext)
....@@ -193,9 +193,43 @@
193193
194194 /// INTERFACE
195195
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
+
196225 public boolean IsBoxMode()
197226 {
198227 return BOXMODE;
228
+ }
229
+
230
+ public boolean IsZoomBoxMode()
231
+ {
232
+ return ZOOMBOXMODE;
199233 }
200234
201235 public void ClearDepth()
....@@ -430,7 +464,7 @@
430464 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
431465 {
432466 //gl.glBegin(gl.GL_TRIANGLES);
433
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
467
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
434468 if (!hasnorm)
435469 {
436470 // System.out.println("FUCK!!");
....@@ -816,7 +850,7 @@
816850
817851 if ((i % 100) == 0 && i != 0)
818852 {
819
- CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
853
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
820854 //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
821855 System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
822856 }
....@@ -848,7 +882,7 @@
848882
849883 if ((i % 100) == 0 && i != 0)
850884 {
851
- CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
885
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
852886 //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
853887 System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
854888 }
....@@ -1061,7 +1095,336 @@
10611095 gl.glMatrixMode(gl.GL_MODELVIEW);
10621096 }
10631097
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
+
10641400 /// 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
+ }
10651428
10661429 void SetColor(Object3D obj, Vertex p0)
10671430 {
....@@ -1256,18 +1619,18 @@
12561619 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
12571620 if (!material.multiply)
12581621 {
1259
- display.color = color;
1622
+ display.color = material.color;
12601623 display.saturation = material.modulation;
12611624 }
12621625 else
12631626 {
1264
- display.color *= color*2;
1627
+ display.color *= material.color*2;
12651628 display.saturation *= material.modulation*2;
12661629 }
12671630
12681631 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
12691632
1270
- float[] colorV = GrafreeD.colorV;
1633
+ float[] colorV = Grafreed.colorV;
12711634
12721635 /**/
12731636 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1527,7 +1890,7 @@
15271890 void PushMatrix(double[][] matrix)
15281891 {
15291892 // GrafreeD.tracein(matrix);
1530
- PushMatrix(matrix,1);
1893
+ PushMatrix(matrix, 1);
15311894 }
15321895
15331896 void PushMatrix()
....@@ -1624,7 +1987,7 @@
16241987
16251988 static int camerachangeframe;
16261989
1627
- boolean SetCamera(Camera cam)
1990
+ public boolean SetCamera(Camera cam)
16281991 {
16291992 // may 2014 if (cam == cameras[0] || cam == cameras[1])
16301993 // return false;
....@@ -1752,33 +2115,6 @@
17522115 mainDL ^= true;
17532116 }
17542117
1755
- void ToggleTexture()
1756
- {
1757
- textureon ^= true;
1758
- }
1759
-
1760
- void ToggleLive()
1761
- {
1762
- Globals.setLIVE(Globals.isLIVE() ^ true);
1763
-
1764
- System.err.println("LIVE = " + Globals.isLIVE());
1765
-
1766
- if (!Globals.isLIVE()) // save sound
1767
- GrafreeD.savesound = true; // wav.save();
1768
- // else
1769
- repaint(); // start loop // may 2013
1770
- }
1771
-
1772
- void ToggleSupport()
1773
- {
1774
- SUPPORT ^= true;
1775
- }
1776
-
1777
- void ToggleAbort()
1778
- {
1779
- ABORTMODE ^= true;
1780
- }
1781
-
17822118 void ToggleFullScreen()
17832119 {
17842120 FULLSCREEN ^= true;
....@@ -1789,72 +2125,94 @@
17892125 Globals.CROWD ^= true;
17902126 }
17912127
1792
- void ToggleInertia()
1793
- {
1794
- INERTIA ^= true;
1795
- }
1796
-
17972128 void ToggleLocal()
17982129 {
17992130 LOCALTRANSFORM ^= true;
18002131 }
18012132
1802
- void ToggleFast()
2133
+ public void ToggleTexture()
2134
+ {
2135
+ textureon ^= true;
2136
+ }
2137
+
2138
+ public void ToggleLive()
2139
+ {
2140
+ Globals.setLIVE(Globals.isLIVE() ^ true);
2141
+
2142
+ System.err.println("LIVE = " + Globals.isLIVE());
2143
+
2144
+ if (!Globals.isLIVE()) // save sound
2145
+ Grafreed.savesound = true; // wav.save();
2146
+ // else
2147
+ repaint(); // start loop // may 2013
2148
+ }
2149
+
2150
+ public void ToggleSupport()
2151
+ {
2152
+ SUPPORT ^= true;
2153
+ }
2154
+
2155
+ public void ToggleAbort()
2156
+ {
2157
+ ABORTMODE ^= true;
2158
+ }
2159
+
2160
+ public void ToggleInertia()
2161
+ {
2162
+ INERTIA ^= true;
2163
+ }
2164
+
2165
+ public void ToggleFast()
18032166 {
18042167 FAST ^= true;
18052168 }
18062169
1807
- void ToggleSlowPose()
2170
+ public void ToggleSlowPose()
18082171 {
18092172 SLOWPOSE ^= true;
18102173 }
18112174
1812
- void ToggleFootContact()
1813
- {
1814
- FOOTCONTACT ^= true;
1815
- }
1816
-
1817
- void ToggleBoxMode()
2175
+ public void ToggleBoxMode()
18182176 {
18192177 BOXMODE ^= true;
18202178 }
18212179
1822
- void ToggleSmoothFocus()
2180
+ public void ToggleZoomBoxMode()
2181
+ {
2182
+ ZOOMBOXMODE ^= true;
2183
+ }
2184
+
2185
+ public void ToggleSmoothFocus()
18232186 {
18242187 SMOOTHFOCUS ^= true;
18252188 }
18262189
1827
- void ToggleImageFlip()
2190
+ public void ToggleImageFlip()
18282191 {
18292192 IMAGEFLIP ^= true;
18302193 }
18312194
1832
- void ToggleSpeakerMocap()
2195
+ public void ToggleSpeakerMocap()
18332196 {
18342197 SPEAKERMOCAP ^= true;
18352198 }
18362199
1837
- void ToggleSpeakerCamera()
2200
+ public void ToggleSpeakerCamera()
18382201 {
18392202 SPEAKERCAMERA ^= true;
18402203 }
18412204
1842
- void ToggleSpeakerFocus()
2205
+ public void ToggleSpeakerFocus()
18432206 {
18442207 SPEAKERFOCUS ^= true;
18452208 }
18462209
1847
- void ToggleDebug()
1848
- {
1849
- DEBUG ^= true;
1850
- }
1851
-
1852
- void ToggleFrustum()
2210
+ public void ToggleFrustum()
18532211 {
18542212 FRUSTUM ^= true;
18552213 }
18562214
1857
- void ToggleTrack()
2215
+ public void ToggleTrack()
18582216 {
18592217 TRACK ^= true;
18602218 if (TRACK)
....@@ -1873,25 +2231,35 @@
18732231 repaint();
18742232 }
18752233
1876
- void ToggleTrackOnce()
2234
+ public void ToggleTrackOnce()
18772235 {
18782236 TRACKONCE ^= true;
18792237 }
18802238
1881
- void ToggleShadowTrack()
2239
+ public void ToggleShadowTrack()
18822240 {
18832241 SHADOWTRACK ^= true;
18842242 repaint();
18852243 }
18862244
1887
- void ToggleOeil()
2245
+ public void ToggleOeil()
18882246 {
18892247 OEIL ^= true;
18902248 }
18912249
1892
- void ToggleOeilOnce()
2250
+ public void ToggleOeilOnce()
18932251 {
18942252 OEILONCE ^= true;
2253
+ }
2254
+
2255
+ void ToggleFootContact()
2256
+ {
2257
+ FOOTCONTACT ^= true;
2258
+ }
2259
+
2260
+ void ToggleDebug()
2261
+ {
2262
+ DEBUG ^= true;
18952263 }
18962264
18972265 void ToggleLookAt()
....@@ -1899,9 +2267,9 @@
18992267 LOOKAT ^= true;
19002268 }
19012269
1902
- void ToggleRandom()
2270
+ void ToggleSwitch()
19032271 {
1904
- RANDOM ^= true;
2272
+ SWITCH ^= true;
19052273 }
19062274
19072275 void ToggleHandles()
....@@ -2008,7 +2376,7 @@
20082376 {
20092377 return currentGL;
20102378 }
2011
-
2379
+
20122380 /**/
20132381 class CacheTexture
20142382 {
....@@ -3840,6 +4208,7 @@
38404208
38414209 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
38424210 {
4211
+ new Exception().printStackTrace();
38434212 System.exit(0);
38444213 com.sun.opengl.util.texture.Texture texture = null;
38454214
....@@ -7655,7 +8024,7 @@
76558024 }
76568025 }
76578026
7658
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8027
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
76598028 {
76608029 if (// DrawMode() != 0 || /*tex == null ||*/
76618030 ambientOcclusion ) // || !textureon)
....@@ -7700,7 +8069,27 @@
77008069 return; // true;
77018070 }
77028071
7703
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8072
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8073
+
8074
+ private boolean FileExists(String tex)
8075
+ {
8076
+ if (missingTextures.contains(tex))
8077
+ {
8078
+ return false;
8079
+ }
8080
+
8081
+ boolean fileExists = new File(tex).exists();
8082
+
8083
+ if (!fileExists)
8084
+ {
8085
+ // If file exists, the "new File()" is not executed sgain
8086
+ missingTextures.add(tex);
8087
+ }
8088
+
8089
+ return fileExists;
8090
+ }
8091
+
8092
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
77048093 {
77058094 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
77068095
....@@ -7708,12 +8097,18 @@
77088097 {
77098098 String texname = tex;
77108099
7711
- String[] split = tex.split("Textures");
7712
- if (split.length > 1)
7713
- texname = "/Users/nbriere/Textures" + split[split.length-1];
7714
- else
7715
- if (!texname.startsWith("/"))
7716
- texname = "/Users/nbriere/Textures/" + texname;
8100
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8101
+
8102
+// String[] split = tex.split("Textures");
8103
+// if (split.length > 1)
8104
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8105
+// else
8106
+// if (!texname.startsWith("/"))
8107
+// texname = "/Users/nbriere/Textures/" + texname;
8108
+ if (!FileExists(tex))
8109
+ {
8110
+ texname = fallbackTextureName;
8111
+ }
77178112
77188113 if (CACHETEXTURE)
77198114 texture = textures.get(texname); // TEXTURE CACHE
....@@ -7782,7 +8177,7 @@
77828177 }
77838178
77848179 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
7785
- if (!new File(cachename).exists())
8180
+ if (!FileExists(cachename))
77868181 cachename = texname;
77878182 else
77888183 processbump = false; // don't process bump map again
....@@ -7804,7 +8199,7 @@
78048199 }
78058200
78068201 cachename = texname.substring(0, texname.length()-4)+ext+".png";
7807
- if (!new File(cachename).exists())
8202
+ if (!FileExists(cachename))
78088203 cachename = texname;
78098204 else
78108205 processbump = false; // don't process bump map again
....@@ -7813,7 +8208,9 @@
78138208 texturedata = GetFileTexture(cachename, processbump, resolution);
78148209
78158210
7816
- if (texturedata != null)
8211
+ if (texturedata == null)
8212
+ throw new Exception();
8213
+
78178214 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
78188215 //texture = GetTexture(tex, bump);
78198216 }
....@@ -7935,7 +8332,7 @@
79358332 return texture;
79368333 }
79378334
7938
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8335
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
79398336 {
79408337 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
79418338
....@@ -7953,14 +8350,14 @@
79538350 return texture!=null?texture.texture:null;
79548351 }
79558352
7956
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8353
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
79578354 {
79588355 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
79598356
79608357 return texture!=null?texture.texturedata:null;
79618358 }
79628359
7963
- boolean BindTexture(String tex, boolean bump, int resolution)
8360
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
79648361 {
79658362 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
79668363 {
....@@ -8937,8 +9334,8 @@
89379334 assert (parentcam != renderCamera);
89389335
89399336 if (renderCamera != lightCamera)
8940
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8941
- LA.matConcat(matrix, parentcam.toParent, matrix);
9337
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9338
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
89429339
89439340 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
89449341
....@@ -8953,8 +9350,8 @@
89539350 LA.matCopy(renderCamera.fromScreen, matrix);
89549351
89559352 if (renderCamera != lightCamera)
8956
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8957
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9353
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9354
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
89589355
89599356 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
89609357
....@@ -9026,7 +9423,7 @@
90269423 //gl.glFlush();
90279424 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
90289425
9029
- if (ANIMATION && ABORTED)
9426
+ if (Globals.ANIMATION && ABORTED)
90309427 {
90319428 System.err.println(" ABORTED FRAME");
90329429 break;
....@@ -9056,7 +9453,7 @@
90569453 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
90579454
90589455 // save image
9059
- if (ANIMATION && !ABORTED)
9456
+ if (Globals.ANIMATION && !ABORTED)
90609457 {
90619458 VPwidth = viewport[2];
90629459 VPheight = viewport[3];
....@@ -9167,11 +9564,11 @@
91679564
91689565 // imagecount++;
91699566
9170
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9567
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
91719568
91729569 if (!BOXMODE)
91739570 {
9174
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9571
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
91759572 }
91769573
91779574 if (!BOXMODE)
....@@ -9209,7 +9606,7 @@
92099606 ABORTED = false;
92109607 }
92119608 else
9212
- GrafreeD.wav.cursor += 735 * ACSIZE;
9609
+ Grafreed.wav.cursor += 735 * ACSIZE;
92139610
92149611 if (false)
92159612 {
....@@ -9872,11 +10269,11 @@
987210269
987310270 public void display(GLAutoDrawable drawable)
987410271 {
9875
- if (GrafreeD.savesound && GrafreeD.hassound)
10272
+ if (Grafreed.savesound && Grafreed.hassound)
987610273 {
9877
- GrafreeD.wav.save();
9878
- GrafreeD.savesound = false;
9879
- GrafreeD.hassound = false;
10274
+ Grafreed.wav.save();
10275
+ Grafreed.savesound = false;
10276
+ Grafreed.hassound = false;
988010277 }
988110278 // if (DEBUG_SELECTION)
988210279 // {
....@@ -10006,7 +10403,7 @@
1000610403 Object3D theobject = object;
1000710404 Object3D theparent = object.parent;
1000810405 object.parent = null;
10009
- object = (Object3D)GrafreeD.clone(object);
10406
+ object = (Object3D)Grafreed.clone(object);
1001010407 object.Stripify();
1001110408 if (theobject.selection == null || theobject.selection.Size() == 0)
1001210409 theobject.PreprocessOcclusion(this);
....@@ -10019,13 +10416,13 @@
1001910416 ambientOcclusion = false;
1002010417 }
1002110418
10022
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10419
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1002310420 {
1002410421 //if (RENDERSHADOW) // ?
1002510422 if (!IsFrozen())
1002610423 {
1002710424 // dec 2012
10028
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10425
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1002910426 {
1003010427 Globals.framecount++;
1003110428 shadowbuffer.display();
....@@ -10152,8 +10549,8 @@
1015210549
1015310550 // if (parentcam != renderCamera) // not a light
1015410551 if (cam != lightCamera)
10155
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10156
- LA.matConcat(matrix, parentcam.toParent, matrix);
10552
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10553
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1015710554
1015810555 for (int j = 0; j < 4; j++)
1015910556 {
....@@ -10167,8 +10564,8 @@
1016710564
1016810565 // if (parentcam != renderCamera) // not a light
1016910566 if (cam != lightCamera)
10170
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10171
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10567
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10568
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1017210569
1017310570 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1017410571
....@@ -10427,7 +10824,16 @@
1042710824 // Bump noise
1042810825 gl.glActiveTexture(GL.GL_TEXTURE6);
1042910826 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10430
- BindTexture(NOISE_TEXTURE, false, 2);
10827
+
10828
+ try
10829
+ {
10830
+ BindTexture(NOISE_TEXTURE, false, 2);
10831
+ }
10832
+ catch (Exception e)
10833
+ {
10834
+ System.err.println("FAILED: " + NOISE_TEXTURE);
10835
+ }
10836
+
1043110837
1043210838 gl.glActiveTexture(GL.GL_TEXTURE0);
1043310839 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10552,8 +10958,8 @@
1055210958 System.err.println("parentcam != renderCamera");
1055310959
1055410960 // if (cam != lightCamera)
10555
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10556
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
10961
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10962
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1055710963 }
1055810964
1055910965 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10574,8 +10980,8 @@
1057410980 if (true) // TODO
1057510981 {
1057610982 if (cam != lightCamera)
10577
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10578
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
10983
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10984
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1057910985 }
1058010986
1058110987 LA.xformPos(light0, cam.toScreen, light0);
....@@ -10891,8 +11297,14 @@
1089111297 {
1089211298 renderpass++;
1089311299 // System.out.println("Draw object... ");
11300
+ STEP = 1;
1089411301 if (FAST) // in case there is no script
10895
- STEP = 16;
11302
+ STEP = 8;
11303
+
11304
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11305
+ {
11306
+ STEP *= 4;
11307
+ }
1089611308
1089711309 //object.FullInvariants();
1089811310
....@@ -10906,8 +11318,8 @@
1090611318 e.printStackTrace();
1090711319 }
1090811320
10909
- if (GrafreeD.RENDERME > 0)
10910
- GrafreeD.RENDERME--; // mechante magouille
11321
+ if (Grafreed.RENDERME > 0)
11322
+ Grafreed.RENDERME--; // mechante magouille
1091111323
1091211324 Globals.ONESTEP = false;
1091311325 }
....@@ -10977,7 +11389,14 @@
1097711389
1097811390 usedtextures.clear();
1097911391
10980
- BindTextures(DEFAULT_TEXTURES, 2);
11392
+ try
11393
+ {
11394
+ BindTextures(DEFAULT_TEXTURES, 2);
11395
+ }
11396
+ catch (Exception e)
11397
+ {
11398
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11399
+ }
1098111400 }
1098211401 //System.out.println("--> " + stackdepth);
1098311402 // GrafreeD.traceon();
....@@ -11068,7 +11487,14 @@
1106811487 if (checker != null && DrawMode() == DEFAULT)
1106911488 {
1107011489 //BindTexture(IMMORTAL_TEXTURE);
11071
- BindTextures(checker.GetTextures(), checker.texres);
11490
+ try
11491
+ {
11492
+ BindTextures(checker.GetTextures(), checker.texres);
11493
+ }
11494
+ catch (Exception e)
11495
+ {
11496
+ System.err.println("FAILED: " + checker.GetTextures());
11497
+ }
1107211498 // NEAREST
1107311499 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1107411500 DrawChecker(gl);
....@@ -11150,7 +11576,7 @@
1115011576 return;
1115111577 }
1115211578
11153
- String string = obj.GetToolTip();
11579
+ String string = obj.toString(); //.GetToolTip();
1115411580
1115511581 GL gl = GetGL();
1115611582
....@@ -11467,8 +11893,8 @@
1146711893 //obj.TransformToWorld(light, light);
1146811894 for (int i = tp.size(); --i >= 0;)
1146911895 {
11470
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11471
- LA.xformPos(light, tp.get(i).toParent, light);
11896
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11897
+ LA.xformPos(light, tp.get(i).GlobalTransform(), light);
1147211898 }
1147311899
1147411900
....@@ -11485,8 +11911,8 @@
1148511911 parentcam = cameras[0];
1148611912 }
1148711913
11488
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11489
- LA.xformPos(light, parentcam.toParent, light); // may 2013
11914
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11915
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1149011916
1149111917 LA.xformPos(light, renderCamera.toScreen, light);
1149211918
....@@ -12100,8 +12526,8 @@
1210012526
1210112527 // display shadow only (bump == 0)
1210212528 "SUB temp.x, half.x, shadow.x;" +
12103
- "MOV temp.y, -params6.x;" +
12104
- "SLT temp.z, temp.y, zero.x;" +
12529
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12530
+ "SLT temp.z, temp.y, -one2048th.x;" +
1210512531 "SUB temp.y, one.x, temp.z;" +
1210612532 "MUL temp.x, temp.x, temp.y;" +
1210712533 "KIL temp.x;" +
....@@ -12230,8 +12656,10 @@
1223012656 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1223112657
1223212658 "SUB temp.x, one.x, ndotl.x;" +
12233
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12234
- "ADD temp.y, one.y, options2.y;" + // sursurface
12659
+ // Tuning for default skin
12660
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12661
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12662
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1223512663 "MUL temp.x, temp.x, temp.y;" +
1223612664
1223712665 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12430,7 +12858,7 @@
1243012858 //once = true;
1243112859 }
1243212860
12433
- System.out.print("Program #" + mode + "; length = " + program.length());
12861
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1243412862 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1243512863 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1243612864
....@@ -12563,12 +12991,16 @@
1256312991
1256412992 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1256512993 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
12994
+
12995
+ // Compare fragment depth in light space with shadowmap.
1256612996 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1256712997 "SGE temp.y, temp.x, zero.x;" +
12568
- "SUB " + shadow + ".y, one.x, temp.y;" +
12998
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
12999
+
13000
+ // Reverse comparison
1256913001 "SUB temp.x, one.x, temp.x;" +
1257013002 "MUL " + shadow + ".x, temp.x, temp.y;" +
12571
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13003
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1257213004 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1257313005
1257413006 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12582,6 +13014,10 @@
1258213014 // No shadow for backface
1258313015 "DP3 temp.x, normal, lightd;" +
1258413016 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13017
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13018
+
13019
+ // No shadow when out of frustrum
13020
+ "SGE temp.x, " + depth + ".z, one.z;" +
1258513021 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1258613022 "";
1258713023 }
....@@ -13140,7 +13576,7 @@
1314013576 public void mousePressed(MouseEvent e)
1314113577 {
1314213578 //System.out.println("mousePressed: " + e);
13143
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13579
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1314413580 }
1314513581
1314613582 static long prevtime = 0;
....@@ -13167,6 +13603,7 @@
1316713603
1316813604 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1316913605
13606
+ if (BUTTONLESSWHEEL)
1317013607 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1317113608 {
1317213609 return;
....@@ -13175,7 +13612,7 @@
1317513612 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1317613613
1317713614 // TIMER
13178
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
13615
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1317913616 {
1318013617 keepboxmode = BOXMODE;
1318113618 keepsupport = SUPPORT;
....@@ -13215,8 +13652,8 @@
1321513652 // mode |= META;
1321613653 //}
1321713654
13218
- SetMouseMode(WHEEL | e.getModifiersEx());
13219
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13655
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13656
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1322013657 anchorX = ax;
1322113658 anchorY = ay;
1322213659 prevX = px;
....@@ -13276,6 +13713,10 @@
1327613713 // wasliveok = true;
1327713714 // waslive = false;
1327813715
13716
+ // May 2019 Forget it:
13717
+ if (true)
13718
+ return;
13719
+
1327913720 // source == timer
1328013721 if (mouseDown)
1328113722 {
....@@ -13314,7 +13755,7 @@
1331413755
1331513756 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1331613757
13317
- void clickStart(int x, int y, int modifiers)
13758
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1331813759 {
1331913760 if (!wasliveok)
1332013761 return;
....@@ -13331,7 +13772,7 @@
1333113772 // touched = true; // main DL
1333213773 if (isRenderer)
1333313774 {
13334
- SetMouseMode(modifiers);
13775
+ SetMouseMode(modifiers, modifiersex);
1333513776 }
1333613777
1333713778 selectX = anchorX = x;
....@@ -13344,7 +13785,7 @@
1334413785 clicked = true;
1334513786 hold = false;
1334613787
13347
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13788
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1334813789 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1334913790 {
1335013791 // System.out.println("RESTART II " + modifiers);
....@@ -13375,7 +13816,7 @@
1337513816 info.camera = renderCamera;
1337613817 info.x = x;
1337713818 info.y = y;
13378
- info.modifiers = modifiers;
13819
+ info.modifiers = modifiersex;
1337913820 editObj = object.doEditClick(info, 0);
1338013821 if (!editObj)
1338113822 {
....@@ -13392,11 +13833,14 @@
1339213833
1339313834 public void mouseDragged(MouseEvent e)
1339413835 {
13836
+ Globals.MOUSEDRAGGED = true;
13837
+
13838
+ //System.out.println("mouseDragged: " + e);
1339513839 if (isRenderer)
1339613840 movingcamera = true;
13841
+
1339713842 //if (drawing)
1339813843 //return;
13399
- //System.out.println("mouseDragged: " + e);
1340013844 if ((e.getModifiersEx() & CTRL) != 0
1340113845 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1340213846 {
....@@ -13404,7 +13848,7 @@
1340413848 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1340513849 }
1340613850 else
13407
- drag(e.getX(), e.getY(), e.getModifiersEx());
13851
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1340813852
1340913853 //try { Thread.sleep(1); } catch (Exception ex) {}
1341013854 }
....@@ -13577,6 +14021,7 @@
1357714021
1357814022 public void run()
1357914023 {
14024
+ new Exception().printStackTrace();
1358014025 System.exit(0);
1358114026 for (;;)
1358214027 {
....@@ -13640,7 +14085,7 @@
1364014085 {
1364114086 Globals.lighttouched = true;
1364214087 }
13643
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14088
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1364414089 }
1364514090 //else
1364614091 }
....@@ -13740,7 +14185,7 @@
1374014185 int X, Y;
1374114186 boolean SX, SY;
1374214187
13743
- void drag(int x, int y, int modifiers)
14188
+ void drag(int x, int y, int modifiers, int modifiersex)
1374414189 {
1374514190 if (IsFrozen())
1374614191 {
....@@ -13749,17 +14194,17 @@
1374914194
1375014195 drag = true; // NEW
1375114196
13752
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14197
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1375314198
1375414199 X = x;
1375514200 Y = y;
1375614201 // floating state for animation
13757
- MODIFIERS = modifiers;
13758
- modifiers &= ~1024;
14202
+ MODIFIERS = modifiersex;
14203
+ modifiersex &= ~1024;
1375914204 if (false) // modifiers != 0)
1376014205 {
1376114206 //new Exception().printStackTrace();
13762
- System.out.println("mouseDragged: " + modifiers);
14207
+ System.out.println("mouseDragged: " + modifiersex);
1376314208 System.out.println("SHIFT = " + SHIFT);
1376414209 System.out.println("CONTROL = " + COMMAND);
1376514210 System.out.println("META = " + META);
....@@ -13779,7 +14224,7 @@
1377914224 info.camera = renderCamera;
1378014225 info.x = x;
1378114226 info.y = y;
13782
- object.editWindow.copy.doEditDrag(info);
14227
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1378314228 } else
1378414229 {
1378514230 if (x < startX)
....@@ -13931,7 +14376,6 @@
1393114376 public void mouseMoved(MouseEvent e)
1393214377 {
1393314378 //System.out.println("mouseMoved: " + e);
13934
-
1393514379 if (isRenderer)
1393614380 return;
1393714381
....@@ -13956,7 +14400,10 @@
1395614400
1395714401 public void mouseReleased(MouseEvent e)
1395814402 {
14403
+ Globals.MOUSEDRAGGED = false;
14404
+
1395914405 movingcamera = false;
14406
+ X = Y = 0;
1396014407 //System.out.println("mouseReleased: " + e);
1396114408 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1396214409 }
....@@ -13979,9 +14426,9 @@
1397914426 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1398014427 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1398114428
13982
- if (control || command || IsFrozen())
14429
+// No delay if (control || command || IsFrozen())
1398314430 timeout = true;
13984
- else
14431
+// ?? May 2019 else
1398514432 // timer.setDelay((modifiers & 128) != 0?0:350);
1398614433 mouseDown = false;
1398714434 if (!control && !command) // june 2013
....@@ -14091,7 +14538,7 @@
1409114538 System.out.println("keyReleased: " + e);
1409214539 }
1409314540
14094
- void SetMouseMode(int modifiers)
14541
+ void SetMouseMode(int modifiers, int modifiersex)
1409514542 {
1409614543 //System.out.println("SetMouseMode = " + modifiers);
1409714544 //modifiers &= ~1024;
....@@ -14103,25 +14550,25 @@
1410314550 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1410414551 // return;
1410514552 //System.out.println("SetMode = " + modifiers);
14106
- if ((modifiers & WHEEL) == WHEEL)
14553
+ if ((modifiersex & WHEEL) == WHEEL)
1410714554 {
1410814555 mouseMode |= ZOOM;
1410914556 }
1411014557
1411114558 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14112
- if (capsLocked || (modifiers & META) == META)
14559
+ if (capsLocked) // || (modifiers & META) == META)
1411314560 {
1411414561 mouseMode |= VR; // BACKFORTH;
1411514562 }
14116
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14563
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1411714564 {
1411814565 mouseMode |= SELECT;
1411914566 }
14120
- if ((modifiers & COMMAND) == COMMAND)
14567
+ if ((modifiersex & COMMAND) == COMMAND)
1412114568 {
1412214569 mouseMode |= SELECT;
1412314570 }
14124
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14571
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1412514572 {
1412614573 mouseMode &= ~VR;
1412714574 mouseMode |= TRANSLATE;
....@@ -14150,10 +14597,10 @@
1415014597
1415114598 if (isRenderer) //
1415214599 {
14153
- SetMouseMode(modifiers);
14600
+ SetMouseMode(0, modifiers);
1415414601 }
1415514602
14156
- theRenderer.keyPressed(key);
14603
+ Globals.theRenderer.keyPressed(key);
1415714604 }
1415814605
1415914606 int kompactbit = 4; // power bit
....@@ -14165,7 +14612,7 @@
1416514612 float SATPOW = 1; // 2; // 0.5f;
1416614613 float BRIPOW = 1; // 0.5f; // 0.5f;
1416714614
14168
- void keyPressed(int key)
14615
+ public void keyPressed(int key)
1416914616 {
1417014617 if (key >= '0' && key <= '5')
1417114618 clampbit = (key-'0');
....@@ -14486,7 +14933,7 @@
1448614933 //RESIZETEXTURE ^= true;
1448714934 //break;
1448814935 case 'z':
14489
- RENDERSHADOW ^= true;
14936
+ Globals.RENDERSHADOW ^= true;
1449014937 Globals.lighttouched = true;
1449114938 repaint();
1449214939 break;
....@@ -14602,6 +15049,7 @@
1460215049 }
1460315050 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1460415051 }
15052
+
1460515053 static double OCCLUSIONBOOST = 1; // 0.5;
1460615054
1460715055 void keyReleased(int key, int modifiers)
....@@ -14609,11 +15057,11 @@
1460915057 //mode = ROTATE;
1461015058 if ((MODIFIERS & COMMAND) == 0) // VR??
1461115059 {
14612
- SetMouseMode(modifiers);
15060
+ SetMouseMode(0, modifiers);
1461315061 }
1461415062 }
1461515063
14616
- protected void processKeyEvent(KeyEvent e)
15064
+ public void processKeyEvent(KeyEvent e)
1461715065 {
1461815066 switch (e.getID())
1461915067 {
....@@ -14743,8 +15191,9 @@
1474315191
1474415192 protected void processMouseMotionEvent(MouseEvent e)
1474515193 {
14746
- //System.out.println("processMouseMotionEvent: " + mouseMode);
14747
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15194
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15195
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15196
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1474815197 {
1474915198 mouseMoved(e);
1475015199 } else
....@@ -14774,6 +15223,7 @@
1477415223
1477515224 void SelectParent()
1477615225 {
15226
+ new Exception().printStackTrace();
1477715227 System.exit(0);
1477815228 Composite group = (Composite) object;
1477915229 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -14797,6 +15247,7 @@
1479715247
1479815248 void SelectChildren()
1479915249 {
15250
+ new Exception().printStackTrace();
1480015251 System.exit(0);
1480115252 /*
1480215253 Composite group = (Composite) object;
....@@ -14961,7 +15412,9 @@
1496115412 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1496215413 //Image img = CreateImage(width, height);
1496315414 //System.out.println("width = " + width + "; height = " + height + "\n");
15415
+
1496415416 Graphics gr = g; // img.getGraphics();
15417
+
1496515418 if (!hasMarquee)
1496615419 {
1496715420 if (Xmin < Xmax) // !locked)
....@@ -15059,14 +15512,33 @@
1505915512 if (!isRenderer)
1506015513 {
1506115514 object.drawEditHandles(info, 0);
15515
+
15516
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15517
+ {
15518
+ switch (object.selection.get(0).hitSomething)
15519
+ {
15520
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15521
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15522
+ break;
15523
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15524
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15525
+ break;
15526
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15527
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15528
+ break;
15529
+ }
15530
+
15531
+ }
1506215532 }
1506315533 }
15534
+
1506415535 if (isRenderer)
1506515536 {
1506615537 //gr.setColor(Color.black);
1506715538 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1506815539 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1506915540 }
15541
+
1507015542 if (hasMarquee)
1507115543 {
1507215544 gr.setXORMode(Color.white);
....@@ -15179,6 +15651,7 @@
1517915651 public boolean mouseDown(Event evt, int x, int y)
1518015652 {
1518115653 System.out.println("mouseDown: " + evt);
15654
+ System.exit(0);
1518215655 /*
1518315656 locked = true;
1518415657 drag = false;
....@@ -15222,7 +15695,7 @@
1522215695 {
1522315696 keyPressed(0, modifiers);
1522415697 }
15225
- clickStart(x, y, modifiers);
15698
+ // clickStart(x, y, modifiers);
1522615699 return true;
1522715700 }
1522815701
....@@ -15340,7 +15813,7 @@
1534015813 {
1534115814 keyReleased(0, 0);
1534215815 }
15343
- drag(x, y, modifiers);
15816
+ drag(x, y, 0, modifiers);
1534415817 return true;
1534515818 }
1534615819
....@@ -15472,7 +15945,7 @@
1547215945 Object3D object;
1547315946 static Object3D trackedobject;
1547415947 Camera renderCamera; // Light or Eye (or Occlusion)
15475
- /*static*/ Camera manipCamera; // Light or Eye
15948
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1547615949 /*static*/ Camera eyeCamera;
1547715950 /*static*/ Camera lightCamera;
1547815951 int cameracount;
....@@ -15910,6 +16383,7 @@
1591016383 {
1591116384 if (!selection)
1591216385 {
16386
+ new Exception().printStackTrace();
1591316387 System.exit(0);
1591416388 return;
1591516389 }
....@@ -16037,16 +16511,16 @@
1603716511 System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2]));
1603816512 }
1603916513
16040
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16514
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1604116515 }
1604216516 }
1604316517
1604416518 if (!movingcamera && !PAINTMODE)
1604516519 object.editWindow.ScreenFitPoint(); // fev 2014
1604616520
16047
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16521
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1604816522 {
16049
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16523
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1605016524
1605116525 Object3D group = new Object3D("inst" + paintcount++);
1605216526
....@@ -16202,7 +16676,7 @@
1620216676 gl.glDisable(gl.GL_CULL_FACE);
1620316677 }
1620416678
16205
- if (!RENDERSHADOW)
16679
+ if (!Globals.RENDERSHADOW)
1620616680 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1620716681
1620816682 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16212,7 +16686,7 @@
1621216686 //gl.glColorMask(false, false, false, false);
1621316687
1621416688 //render_scene_from_light_view(gl, drawable, 0, 0);
16215
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16689
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1621616690 {
1621716691 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1621816692
....@@ -16696,10 +17170,11 @@
1669617170 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1669717171 // Depth buffer format
1669817172 //private int depth_format;
16699
- static public void NextIndex(Object3D o, GL gl)
17173
+
17174
+ public void NextIndex()
1670017175 {
1670117176 indexcount+=16;
16702
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17177
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1670317178 //objects[indexcount] = o;
1670417179 //System.out.println("indexcount = " + indexcount);
1670517180 }