Normand Briere
2019-06-21 15123b19e7bc8da2869429b07f0fbaa0598e945e
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,10 +464,12 @@
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)
468
+ // TEST LIVE NORMALS && !obj.dontselect
469
+ ;
434470 if (!hasnorm)
435471 {
436
- // System.out.println("FUCK!!");
472
+ // System.out.println("Mesh normal");
437473 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
438474 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
439475 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -816,7 +852,7 @@
816852
817853 if ((i % 100) == 0 && i != 0)
818854 {
819
- CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
855
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
820856 //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
821857 System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
822858 }
....@@ -848,7 +884,7 @@
848884
849885 if ((i % 100) == 0 && i != 0)
850886 {
851
- CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
887
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
852888 //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
853889 System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
854890 }
....@@ -1061,7 +1097,342 @@
10611097 gl.glMatrixMode(gl.GL_MODELVIEW);
10621098 }
10631099
1100
+ public void DrawBox(cVector min, cVector max)
1101
+ {
1102
+ javax.media.opengl.GL gl = GetGL();
1103
+ gl.glBegin(gl.GL_LINES);
1104
+
1105
+ gl.glVertex3d(min.x, min.y, min.z);
1106
+ gl.glVertex3d(min.x, min.y, max.z);
1107
+ gl.glVertex3d(min.x, min.y, min.z);
1108
+ gl.glVertex3d(min.x, max.y, min.z);
1109
+ gl.glVertex3d(min.x, min.y, min.z);
1110
+ gl.glVertex3d(max.x, min.y, min.z);
1111
+
1112
+ gl.glVertex3d(max.x, max.y, max.z);
1113
+ gl.glVertex3d(min.x, max.y, max.z);
1114
+ gl.glVertex3d(max.x, max.y, max.z);
1115
+ gl.glVertex3d(max.x, min.y, max.z);
1116
+ gl.glVertex3d(max.x, max.y, max.z);
1117
+ gl.glVertex3d(max.x, max.y, min.z);
1118
+
1119
+ gl.glEnd();
1120
+ }
1121
+
1122
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1123
+ {
1124
+ int[] strips = bRep.getRawIndices();
1125
+
1126
+ javax.media.opengl.GL gl = GetGL();
1127
+
1128
+ // TRIANGLE STRIP ARRAY
1129
+ if (bRep.trimmed)
1130
+ {
1131
+ float[] v = bRep.getRawVertices();
1132
+ float[] n = bRep.getRawNormals();
1133
+ float[] c = bRep.getRawColors();
1134
+ float[] uv = bRep.getRawUVMap();
1135
+
1136
+ int count2 = 0;
1137
+ int count3 = 0;
1138
+
1139
+ if (n.length > 0)
1140
+ {
1141
+ for (int i = 0; i < strips.length; i++)
1142
+ {
1143
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1144
+
1145
+ /*
1146
+ boolean locked = false;
1147
+ float eps = 0.1f;
1148
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1149
+
1150
+ int dot = 0;
1151
+
1152
+ if ((dot&1) == 0)
1153
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1154
+
1155
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1156
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1157
+ else
1158
+ {
1159
+ locked = true;
1160
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1161
+ }
1162
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1163
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1164
+ if (hasnorm)
1165
+ {
1166
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1167
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1168
+ }
1169
+
1170
+ if ((dot&4) == 0)
1171
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1172
+
1173
+ if (wrap || !locked && (dot&8) != 0)
1174
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1175
+ else
1176
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1177
+
1178
+ f.dot = dot;
1179
+ */
1180
+
1181
+ if (!selectmode)
1182
+ {
1183
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1184
+ {
1185
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1186
+ } else
1187
+ {
1188
+ gl.glNormal3f(0, 0, 1);
1189
+ }
1190
+
1191
+ if (c != null)
1192
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1193
+ {
1194
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1195
+ }
1196
+ }
1197
+
1198
+ if (flipV)
1199
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1200
+ else
1201
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1202
+
1203
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1204
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1205
+
1206
+ count2 += 2;
1207
+ count3 += 3;
1208
+ if (!selectmode)
1209
+ {
1210
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1211
+ {
1212
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1213
+ } else
1214
+ {
1215
+ gl.glNormal3f(0, 0, 1);
1216
+ }
1217
+ if (c != null)
1218
+ {
1219
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1220
+ }
1221
+ }
1222
+
1223
+ if (flipV)
1224
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1225
+ else
1226
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1227
+
1228
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1229
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1230
+
1231
+ count2 += 2;
1232
+ count3 += 3;
1233
+ for (int j = 0; j < strips[i] - 2; j++)
1234
+ {
1235
+ //gl.glTexCoord2d(...);
1236
+ if (!selectmode)
1237
+ {
1238
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1239
+ {
1240
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1241
+ } else
1242
+ {
1243
+ gl.glNormal3f(0, 0, 1);
1244
+ }
1245
+ if (c != null)
1246
+ {
1247
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1248
+ }
1249
+ }
1250
+
1251
+ if (flipV)
1252
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1253
+ else
1254
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1255
+
1256
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1257
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1258
+
1259
+ count2 += 2;
1260
+ count3 += 3;
1261
+ }
1262
+
1263
+ gl.glEnd();
1264
+ }
1265
+ }
1266
+
1267
+ assert count3 == v.length;
1268
+ }
1269
+ else // !trimmed
1270
+ {
1271
+ int count = 0;
1272
+ for (int i = 0; i < strips.length; i++)
1273
+ {
1274
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1275
+
1276
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1277
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1278
+
1279
+ drawVertex(gl, p, flipV, selectmode);
1280
+ drawVertex(gl, q, flipV, selectmode);
1281
+
1282
+ for (int j = 0; j < strips[i] - 2; j++)
1283
+ {
1284
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1285
+
1286
+ // if (j%2 == 0)
1287
+ // drawFace(p, q, r, display, null);
1288
+ // else
1289
+ // drawFace(p, r, q, display, null);
1290
+
1291
+ // p = q;
1292
+ // q = r;
1293
+ drawVertex(gl, r, flipV, selectmode);
1294
+ }
1295
+
1296
+ gl.glEnd();
1297
+ }
1298
+ }
1299
+ }
1300
+
1301
+ static cSpring.Point3D temp = new cSpring.Point3D();
1302
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1303
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1304
+
1305
+ public void DrawDynamicMesh(cMesh mesh)
1306
+ {
1307
+ GL gl = GetGL(); // getGL();
1308
+
1309
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1310
+
1311
+ gl.glDisable(gl.GL_LIGHTING);
1312
+
1313
+ gl.glLineWidth(1);
1314
+ gl.glColor3f(1,1,1);
1315
+ gl.glBegin(gl.GL_LINES);
1316
+ double scale = 0;
1317
+ int count = 0;
1318
+ for (int s=0; s<Phys.allSprings.size(); s++)
1319
+ {
1320
+ cSpring.Spring spring = Phys.allSprings.get(s);
1321
+ if(s == 0)
1322
+ {
1323
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1324
+ }
1325
+ if (mesh.showsprings)
1326
+ {
1327
+ temp.set(spring.a.position);
1328
+ temp.add(spring.b.position);
1329
+ temp.mul(0.5);
1330
+ temp2.set(spring.a.position);
1331
+ temp2.sub(spring.b.position);
1332
+ temp2.mul(spring.restLength/2);
1333
+ temp.sub(temp2);
1334
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1335
+ temp.add(temp2);
1336
+ temp.add(temp2);
1337
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1338
+ }
1339
+
1340
+ if (spring.isHandle)
1341
+ continue;
1342
+
1343
+ //if (scale < spring.restLength)
1344
+ scale += spring.restLength;
1345
+ count++;
1346
+ }
1347
+ gl.glEnd();
1348
+
1349
+ if (count == 0)
1350
+ scale = 0.01;
1351
+ else
1352
+ scale /= count * 3;
1353
+
1354
+ //scale = 0.25;
1355
+
1356
+ if (mesh.ShowInfo())
1357
+ {
1358
+ gl.glLineWidth(4);
1359
+ for (int s=0; s<Phys.allNodes.size(); s++)
1360
+ {
1361
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1362
+ if (node.mass == 0)
1363
+ continue;
1364
+
1365
+ int i = node.springs==null?-1:node.springs.size();
1366
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1367
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1368
+ //temp.normalize();
1369
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1370
+ gl.glBegin(gl.GL_LINES);
1371
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1372
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1373
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1374
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1375
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1376
+ gl.glEnd();
1377
+ }
1378
+
1379
+ gl.glLineWidth(8);
1380
+ for (int s=0; s<Phys.allNodes.size(); s++)
1381
+ {
1382
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1383
+
1384
+ if (node.springs != null)
1385
+ {
1386
+ for (int i=0; i<node.springs.size(); i+=1)
1387
+ {
1388
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1389
+
1390
+ int c = i+1;
1391
+ // c = node.springs.get(i).nbcopies;
1392
+
1393
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1394
+ gl.glBegin(gl.GL_LINES);
1395
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1396
+ 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);
1397
+ gl.glEnd();
1398
+ }
1399
+ }
1400
+ }
1401
+
1402
+ gl.glLineWidth(1);
1403
+ }
1404
+
1405
+ gl.glEnable(gl.GL_LIGHTING);
1406
+ }
1407
+
10641408 /// INTERFACE
1409
+
1410
+ public void StartTriangles()
1411
+ {
1412
+ javax.media.opengl.GL gl = GetGL();
1413
+ gl.glBegin(gl.GL_TRIANGLES);
1414
+ }
1415
+
1416
+ public void EndTriangles()
1417
+ {
1418
+ GetGL().glEnd();
1419
+ }
1420
+
1421
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1422
+ {
1423
+ if (!selectmode)
1424
+ {
1425
+ gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1426
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1427
+
1428
+ if (flipV)
1429
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1430
+ else
1431
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1432
+ }
1433
+
1434
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1435
+ }
10651436
10661437 void SetColor(Object3D obj, Vertex p0)
10671438 {
....@@ -1256,18 +1627,18 @@
12561627 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
12571628 if (!material.multiply)
12581629 {
1259
- display.color = color;
1630
+ display.color = material.color;
12601631 display.saturation = material.modulation;
12611632 }
12621633 else
12631634 {
1264
- display.color *= color*2;
1635
+ display.color *= material.color*2;
12651636 display.saturation *= material.modulation*2;
12661637 }
12671638
12681639 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
12691640
1270
- float[] colorV = GrafreeD.colorV;
1641
+ float[] colorV = Grafreed.colorV;
12711642
12721643 /**/
12731644 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1527,7 +1898,7 @@
15271898 void PushMatrix(double[][] matrix)
15281899 {
15291900 // GrafreeD.tracein(matrix);
1530
- PushMatrix(matrix,1);
1901
+ PushMatrix(matrix, 1);
15311902 }
15321903
15331904 void PushMatrix()
....@@ -1624,7 +1995,7 @@
16241995
16251996 static int camerachangeframe;
16261997
1627
- boolean SetCamera(Camera cam)
1998
+ public boolean SetCamera(Camera cam)
16281999 {
16292000 // may 2014 if (cam == cameras[0] || cam == cameras[1])
16302001 // return false;
....@@ -1752,33 +2123,6 @@
17522123 mainDL ^= true;
17532124 }
17542125
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
-
17822126 void ToggleFullScreen()
17832127 {
17842128 FULLSCREEN ^= true;
....@@ -1789,72 +2133,94 @@
17892133 Globals.CROWD ^= true;
17902134 }
17912135
1792
- void ToggleInertia()
1793
- {
1794
- INERTIA ^= true;
1795
- }
1796
-
17972136 void ToggleLocal()
17982137 {
17992138 LOCALTRANSFORM ^= true;
18002139 }
18012140
1802
- void ToggleFast()
2141
+ public void ToggleTexture()
2142
+ {
2143
+ textureon ^= true;
2144
+ }
2145
+
2146
+ public void ToggleLive()
2147
+ {
2148
+ Globals.setLIVE(Globals.isLIVE() ^ true);
2149
+
2150
+ System.err.println("LIVE = " + Globals.isLIVE());
2151
+
2152
+ if (!Globals.isLIVE()) // save sound
2153
+ Grafreed.savesound = true; // wav.save();
2154
+ // else
2155
+ repaint(); // start loop // may 2013
2156
+ }
2157
+
2158
+ public void ToggleSupport()
2159
+ {
2160
+ SUPPORT ^= true;
2161
+ }
2162
+
2163
+ public void ToggleAbort()
2164
+ {
2165
+ ABORTMODE ^= true;
2166
+ }
2167
+
2168
+ public void ToggleInertia()
2169
+ {
2170
+ INERTIA ^= true;
2171
+ }
2172
+
2173
+ public void ToggleFast()
18032174 {
18042175 FAST ^= true;
18052176 }
18062177
1807
- void ToggleSlowPose()
2178
+ public void ToggleSlowPose()
18082179 {
18092180 SLOWPOSE ^= true;
18102181 }
18112182
1812
- void ToggleFootContact()
1813
- {
1814
- FOOTCONTACT ^= true;
1815
- }
1816
-
1817
- void ToggleBoxMode()
2183
+ public void ToggleBoxMode()
18182184 {
18192185 BOXMODE ^= true;
18202186 }
18212187
1822
- void ToggleSmoothFocus()
2188
+ public void ToggleZoomBoxMode()
2189
+ {
2190
+ ZOOMBOXMODE ^= true;
2191
+ }
2192
+
2193
+ public void ToggleSmoothFocus()
18232194 {
18242195 SMOOTHFOCUS ^= true;
18252196 }
18262197
1827
- void ToggleImageFlip()
2198
+ public void ToggleImageFlip()
18282199 {
18292200 IMAGEFLIP ^= true;
18302201 }
18312202
1832
- void ToggleSpeakerMocap()
2203
+ public void ToggleSpeakerMocap()
18332204 {
18342205 SPEAKERMOCAP ^= true;
18352206 }
18362207
1837
- void ToggleSpeakerCamera()
2208
+ public void ToggleSpeakerCamera()
18382209 {
18392210 SPEAKERCAMERA ^= true;
18402211 }
18412212
1842
- void ToggleSpeakerFocus()
2213
+ public void ToggleSpeakerFocus()
18432214 {
18442215 SPEAKERFOCUS ^= true;
18452216 }
18462217
1847
- void ToggleDebug()
1848
- {
1849
- DEBUG ^= true;
1850
- }
1851
-
1852
- void ToggleFrustum()
2218
+ public void ToggleFrustum()
18532219 {
18542220 FRUSTUM ^= true;
18552221 }
18562222
1857
- void ToggleTrack()
2223
+ public void ToggleTrack()
18582224 {
18592225 TRACK ^= true;
18602226 if (TRACK)
....@@ -1873,25 +2239,35 @@
18732239 repaint();
18742240 }
18752241
1876
- void ToggleTrackOnce()
2242
+ public void ToggleTrackOnce()
18772243 {
18782244 TRACKONCE ^= true;
18792245 }
18802246
1881
- void ToggleShadowTrack()
2247
+ public void ToggleShadowTrack()
18822248 {
18832249 SHADOWTRACK ^= true;
18842250 repaint();
18852251 }
18862252
1887
- void ToggleOeil()
2253
+ public void ToggleOeil()
18882254 {
18892255 OEIL ^= true;
18902256 }
18912257
1892
- void ToggleOeilOnce()
2258
+ public void ToggleOeilOnce()
18932259 {
18942260 OEILONCE ^= true;
2261
+ }
2262
+
2263
+ void ToggleFootContact()
2264
+ {
2265
+ FOOTCONTACT ^= true;
2266
+ }
2267
+
2268
+ void ToggleDebug()
2269
+ {
2270
+ DEBUG ^= true;
18952271 }
18962272
18972273 void ToggleLookAt()
....@@ -1899,9 +2275,9 @@
18992275 LOOKAT ^= true;
19002276 }
19012277
1902
- void ToggleRandom()
2278
+ void ToggleSwitch()
19032279 {
1904
- RANDOM ^= true;
2280
+ SWITCH ^= true;
19052281 }
19062282
19072283 void ToggleHandles()
....@@ -2008,7 +2384,7 @@
20082384 {
20092385 return currentGL;
20102386 }
2011
-
2387
+
20122388 /**/
20132389 class CacheTexture
20142390 {
....@@ -3840,6 +4216,7 @@
38404216
38414217 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
38424218 {
4219
+ new Exception().printStackTrace();
38434220 System.exit(0);
38444221 com.sun.opengl.util.texture.Texture texture = null;
38454222
....@@ -7552,6 +7929,64 @@
75527929 ReleaseTexture(pigment, false);
75537930 }
75547931
7932
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7933
+ {
7934
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7935
+ {
7936
+ return;
7937
+ }
7938
+
7939
+ if (tex == null)
7940
+ {
7941
+ ReleaseTexture(null, false);
7942
+ return;
7943
+ }
7944
+
7945
+ String pigment = Object3D.GetPigment(tex);
7946
+
7947
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7948
+ {
7949
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7950
+ // System.out.println("; bump = " + bump);
7951
+ }
7952
+
7953
+ if (pigment.equals(""))
7954
+ {
7955
+ pigment = null;
7956
+ }
7957
+
7958
+ ReleaseTexture(pigment, false);
7959
+ }
7960
+
7961
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
7962
+ {
7963
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7964
+ {
7965
+ return;
7966
+ }
7967
+
7968
+ if (tex == null)
7969
+ {
7970
+ ReleaseTexture(null, true);
7971
+ return;
7972
+ }
7973
+
7974
+ String bump = Object3D.GetBump(tex);
7975
+
7976
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7977
+ {
7978
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7979
+ // System.out.println("; bump = " + bump);
7980
+ }
7981
+
7982
+ if (bump.equals(""))
7983
+ {
7984
+ bump = null;
7985
+ }
7986
+
7987
+ ReleaseTexture(bump, true);
7988
+ }
7989
+
75557990 void ReleaseTexture(String tex, boolean bump)
75567991 {
75577992 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -7655,7 +8090,7 @@
76558090 }
76568091 }
76578092
7658
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8093
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
76598094 {
76608095 if (// DrawMode() != 0 || /*tex == null ||*/
76618096 ambientOcclusion ) // || !textureon)
....@@ -7700,7 +8135,94 @@
77008135 return; // true;
77018136 }
77028137
7703
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8138
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8139
+ {
8140
+ if (// DrawMode() != 0 || /*tex == null ||*/
8141
+ ambientOcclusion ) // || !textureon)
8142
+ {
8143
+ return; // false;
8144
+ }
8145
+
8146
+ if (tex == null)
8147
+ {
8148
+ BindTexture(null,false,resolution);
8149
+ return;
8150
+ }
8151
+
8152
+ String pigment = Object3D.GetPigment(tex);
8153
+
8154
+ usedtextures.put(pigment, pigment);
8155
+
8156
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8157
+ {
8158
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8159
+ // System.out.println("; bump = " + bump);
8160
+ }
8161
+
8162
+ if (pigment.equals(""))
8163
+ {
8164
+ pigment = null;
8165
+ }
8166
+
8167
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8168
+ BindTexture(pigment, false, resolution);
8169
+ }
8170
+
8171
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8172
+ {
8173
+ if (// DrawMode() != 0 || /*tex == null ||*/
8174
+ ambientOcclusion ) // || !textureon)
8175
+ {
8176
+ return; // false;
8177
+ }
8178
+
8179
+ if (tex == null)
8180
+ {
8181
+ BindTexture(null,true,resolution);
8182
+ return;
8183
+ }
8184
+
8185
+ String bump = Object3D.GetBump(tex);
8186
+
8187
+ usedtextures.put(bump, bump);
8188
+
8189
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8190
+ {
8191
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8192
+ // System.out.println("; bump = " + bump);
8193
+ }
8194
+
8195
+ if (bump.equals(""))
8196
+ {
8197
+ bump = null;
8198
+ }
8199
+
8200
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8201
+ BindTexture(bump, true, resolution);
8202
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8203
+ }
8204
+
8205
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8206
+
8207
+ private boolean FileExists(String tex)
8208
+ {
8209
+ if (missingTextures.contains(tex))
8210
+ {
8211
+ return false;
8212
+ }
8213
+
8214
+ boolean fileExists = new File(tex).exists();
8215
+
8216
+ if (!fileExists)
8217
+ {
8218
+ // If file exists, the "new File()" is not executed sgain
8219
+ missingTextures.add(tex);
8220
+ }
8221
+
8222
+ return fileExists;
8223
+ }
8224
+
8225
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
77048226 {
77058227 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
77068228
....@@ -7708,12 +8230,18 @@
77088230 {
77098231 String texname = tex;
77108232
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;
8233
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8234
+
8235
+// String[] split = tex.split("Textures");
8236
+// if (split.length > 1)
8237
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8238
+// else
8239
+// if (!texname.startsWith("/"))
8240
+// texname = "/Users/nbriere/Textures/" + texname;
8241
+ if (!FileExists(tex))
8242
+ {
8243
+ texname = fallbackTextureName;
8244
+ }
77178245
77188246 if (CACHETEXTURE)
77198247 texture = textures.get(texname); // TEXTURE CACHE
....@@ -7782,7 +8310,7 @@
77828310 }
77838311
77848312 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
7785
- if (!new File(cachename).exists())
8313
+ if (!FileExists(cachename))
77868314 cachename = texname;
77878315 else
77888316 processbump = false; // don't process bump map again
....@@ -7804,7 +8332,7 @@
78048332 }
78058333
78068334 cachename = texname.substring(0, texname.length()-4)+ext+".png";
7807
- if (!new File(cachename).exists())
8335
+ if (!FileExists(cachename))
78088336 cachename = texname;
78098337 else
78108338 processbump = false; // don't process bump map again
....@@ -7813,7 +8341,9 @@
78138341 texturedata = GetFileTexture(cachename, processbump, resolution);
78148342
78158343
7816
- if (texturedata != null)
8344
+ if (texturedata == null)
8345
+ throw new Exception();
8346
+
78178347 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
78188348 //texture = GetTexture(tex, bump);
78198349 }
....@@ -7935,7 +8465,7 @@
79358465 return texture;
79368466 }
79378467
7938
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8468
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
79398469 {
79408470 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
79418471
....@@ -7953,14 +8483,14 @@
79538483 return texture!=null?texture.texture:null;
79548484 }
79558485
7956
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8486
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
79578487 {
79588488 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
79598489
79608490 return texture!=null?texture.texturedata:null;
79618491 }
79628492
7963
- boolean BindTexture(String tex, boolean bump, int resolution)
8493
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
79648494 {
79658495 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
79668496 {
....@@ -8937,8 +9467,8 @@
89379467 assert (parentcam != renderCamera);
89389468
89399469 if (renderCamera != lightCamera)
8940
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8941
- LA.matConcat(matrix, parentcam.toParent, matrix);
9470
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9471
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
89429472
89439473 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
89449474
....@@ -8953,8 +9483,8 @@
89539483 LA.matCopy(renderCamera.fromScreen, matrix);
89549484
89559485 if (renderCamera != lightCamera)
8956
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8957
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9486
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9487
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
89589488
89599489 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
89609490
....@@ -9026,7 +9556,7 @@
90269556 //gl.glFlush();
90279557 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
90289558
9029
- if (ANIMATION && ABORTED)
9559
+ if (Globals.ANIMATION && ABORTED)
90309560 {
90319561 System.err.println(" ABORTED FRAME");
90329562 break;
....@@ -9056,7 +9586,7 @@
90569586 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
90579587
90589588 // save image
9059
- if (ANIMATION && !ABORTED)
9589
+ if (Globals.ANIMATION && !ABORTED)
90609590 {
90619591 VPwidth = viewport[2];
90629592 VPheight = viewport[3];
....@@ -9167,11 +9697,11 @@
91679697
91689698 // imagecount++;
91699699
9170
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9700
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
91719701
91729702 if (!BOXMODE)
91739703 {
9174
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9704
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
91759705 }
91769706
91779707 if (!BOXMODE)
....@@ -9209,7 +9739,7 @@
92099739 ABORTED = false;
92109740 }
92119741 else
9212
- GrafreeD.wav.cursor += 735 * ACSIZE;
9742
+ Grafreed.wav.cursor += 735 * ACSIZE;
92139743
92149744 if (false)
92159745 {
....@@ -9872,11 +10402,11 @@
987210402
987310403 public void display(GLAutoDrawable drawable)
987410404 {
9875
- if (GrafreeD.savesound && GrafreeD.hassound)
10405
+ if (Grafreed.savesound && Grafreed.hassound)
987610406 {
9877
- GrafreeD.wav.save();
9878
- GrafreeD.savesound = false;
9879
- GrafreeD.hassound = false;
10407
+ Grafreed.wav.save();
10408
+ Grafreed.savesound = false;
10409
+ Grafreed.hassound = false;
988010410 }
988110411 // if (DEBUG_SELECTION)
988210412 // {
....@@ -10006,7 +10536,7 @@
1000610536 Object3D theobject = object;
1000710537 Object3D theparent = object.parent;
1000810538 object.parent = null;
10009
- object = (Object3D)GrafreeD.clone(object);
10539
+ object = (Object3D)Grafreed.clone(object);
1001010540 object.Stripify();
1001110541 if (theobject.selection == null || theobject.selection.Size() == 0)
1001210542 theobject.PreprocessOcclusion(this);
....@@ -10019,13 +10549,13 @@
1001910549 ambientOcclusion = false;
1002010550 }
1002110551
10022
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10552
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1002310553 {
1002410554 //if (RENDERSHADOW) // ?
1002510555 if (!IsFrozen())
1002610556 {
1002710557 // dec 2012
10028
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10558
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1002910559 {
1003010560 Globals.framecount++;
1003110561 shadowbuffer.display();
....@@ -10152,8 +10682,8 @@
1015210682
1015310683 // if (parentcam != renderCamera) // not a light
1015410684 if (cam != lightCamera)
10155
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10156
- LA.matConcat(matrix, parentcam.toParent, matrix);
10685
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10686
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1015710687
1015810688 for (int j = 0; j < 4; j++)
1015910689 {
....@@ -10167,8 +10697,8 @@
1016710697
1016810698 // if (parentcam != renderCamera) // not a light
1016910699 if (cam != lightCamera)
10170
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10171
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10700
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10701
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1017210702
1017310703 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1017410704
....@@ -10427,7 +10957,16 @@
1042710957 // Bump noise
1042810958 gl.glActiveTexture(GL.GL_TEXTURE6);
1042910959 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10430
- BindTexture(NOISE_TEXTURE, false, 2);
10960
+
10961
+ try
10962
+ {
10963
+ BindTexture(NOISE_TEXTURE, false, 2);
10964
+ }
10965
+ catch (Exception e)
10966
+ {
10967
+ System.err.println("FAILED: " + NOISE_TEXTURE);
10968
+ }
10969
+
1043110970
1043210971 gl.glActiveTexture(GL.GL_TEXTURE0);
1043310972 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10552,8 +11091,8 @@
1055211091 System.err.println("parentcam != renderCamera");
1055311092
1055411093 // if (cam != lightCamera)
10555
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10556
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11094
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11095
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1055711096 }
1055811097
1055911098 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10574,8 +11113,8 @@
1057411113 if (true) // TODO
1057511114 {
1057611115 if (cam != lightCamera)
10577
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10578
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11116
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11117
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1057911118 }
1058011119
1058111120 LA.xformPos(light0, cam.toScreen, light0);
....@@ -10891,8 +11430,14 @@
1089111430 {
1089211431 renderpass++;
1089311432 // System.out.println("Draw object... ");
11433
+ STEP = 1;
1089411434 if (FAST) // in case there is no script
10895
- STEP = 16;
11435
+ STEP = 8;
11436
+
11437
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11438
+ {
11439
+ STEP *= 4;
11440
+ }
1089611441
1089711442 //object.FullInvariants();
1089811443
....@@ -10906,8 +11451,8 @@
1090611451 e.printStackTrace();
1090711452 }
1090811453
10909
- if (GrafreeD.RENDERME > 0)
10910
- GrafreeD.RENDERME--; // mechante magouille
11454
+ if (Grafreed.RENDERME > 0)
11455
+ Grafreed.RENDERME--; // mechante magouille
1091111456
1091211457 Globals.ONESTEP = false;
1091311458 }
....@@ -10977,7 +11522,14 @@
1097711522
1097811523 usedtextures.clear();
1097911524
10980
- BindTextures(DEFAULT_TEXTURES, 2);
11525
+ try
11526
+ {
11527
+ BindTextures(DEFAULT_TEXTURES, 2);
11528
+ }
11529
+ catch (Exception e)
11530
+ {
11531
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11532
+ }
1098111533 }
1098211534 //System.out.println("--> " + stackdepth);
1098311535 // GrafreeD.traceon();
....@@ -11068,7 +11620,14 @@
1106811620 if (checker != null && DrawMode() == DEFAULT)
1106911621 {
1107011622 //BindTexture(IMMORTAL_TEXTURE);
11071
- BindTextures(checker.GetTextures(), checker.texres);
11623
+ try
11624
+ {
11625
+ BindTextures(checker.GetTextures(), checker.texres);
11626
+ }
11627
+ catch (Exception e)
11628
+ {
11629
+ System.err.println("FAILED: " + checker.GetTextures());
11630
+ }
1107211631 // NEAREST
1107311632 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1107411633 DrawChecker(gl);
....@@ -11150,7 +11709,7 @@
1115011709 return;
1115111710 }
1115211711
11153
- String string = obj.GetToolTip();
11712
+ String string = obj.toString(); //.GetToolTip();
1115411713
1115511714 GL gl = GetGL();
1115611715
....@@ -11467,8 +12026,8 @@
1146712026 //obj.TransformToWorld(light, light);
1146812027 for (int i = tp.size(); --i >= 0;)
1146912028 {
11470
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11471
- LA.xformPos(light, tp.get(i).toParent, light);
12029
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12030
+ LA.xformPos(light, tp.get(i).GlobalTransform(), light);
1147212031 }
1147312032
1147412033
....@@ -11485,8 +12044,8 @@
1148512044 parentcam = cameras[0];
1148612045 }
1148712046
11488
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11489
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12047
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12048
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1149012049
1149112050 LA.xformPos(light, renderCamera.toScreen, light);
1149212051
....@@ -12100,8 +12659,8 @@
1210012659
1210112660 // display shadow only (bump == 0)
1210212661 "SUB temp.x, half.x, shadow.x;" +
12103
- "MOV temp.y, -params6.x;" +
12104
- "SLT temp.z, temp.y, zero.x;" +
12662
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12663
+ "SLT temp.z, temp.y, -one2048th.x;" +
1210512664 "SUB temp.y, one.x, temp.z;" +
1210612665 "MUL temp.x, temp.x, temp.y;" +
1210712666 "KIL temp.x;" +
....@@ -12230,8 +12789,10 @@
1223012789 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1223112790
1223212791 "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
12792
+ // Tuning for default skin
12793
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12794
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12795
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1223512796 "MUL temp.x, temp.x, temp.y;" +
1223612797
1223712798 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12430,7 +12991,7 @@
1243012991 //once = true;
1243112992 }
1243212993
12433
- System.out.print("Program #" + mode + "; length = " + program.length());
12994
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1243412995 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1243512996 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1243612997
....@@ -12563,12 +13124,16 @@
1256313124
1256413125 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1256513126 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13127
+
13128
+ // Compare fragment depth in light space with shadowmap.
1256613129 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1256713130 "SGE temp.y, temp.x, zero.x;" +
12568
- "SUB " + shadow + ".y, one.x, temp.y;" +
13131
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13132
+
13133
+ // Reverse comparison
1256913134 "SUB temp.x, one.x, temp.x;" +
1257013135 "MUL " + shadow + ".x, temp.x, temp.y;" +
12571
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13136
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1257213137 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1257313138
1257413139 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12582,6 +13147,10 @@
1258213147 // No shadow for backface
1258313148 "DP3 temp.x, normal, lightd;" +
1258413149 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13150
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13151
+
13152
+ // No shadow when out of frustrum
13153
+ "SGE temp.x, " + depth + ".z, one.z;" +
1258513154 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1258613155 "";
1258713156 }
....@@ -13140,7 +13709,7 @@
1314013709 public void mousePressed(MouseEvent e)
1314113710 {
1314213711 //System.out.println("mousePressed: " + e);
13143
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13712
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1314413713 }
1314513714
1314613715 static long prevtime = 0;
....@@ -13167,6 +13736,7 @@
1316713736
1316813737 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1316913738
13739
+ if (BUTTONLESSWHEEL)
1317013740 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1317113741 {
1317213742 return;
....@@ -13175,7 +13745,7 @@
1317513745 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1317613746
1317713747 // TIMER
13178
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
13748
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1317913749 {
1318013750 keepboxmode = BOXMODE;
1318113751 keepsupport = SUPPORT;
....@@ -13215,8 +13785,8 @@
1321513785 // mode |= META;
1321613786 //}
1321713787
13218
- SetMouseMode(WHEEL | e.getModifiersEx());
13219
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13788
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13789
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1322013790 anchorX = ax;
1322113791 anchorY = ay;
1322213792 prevX = px;
....@@ -13276,6 +13846,10 @@
1327613846 // wasliveok = true;
1327713847 // waslive = false;
1327813848
13849
+ // May 2019 Forget it:
13850
+ if (true)
13851
+ return;
13852
+
1327913853 // source == timer
1328013854 if (mouseDown)
1328113855 {
....@@ -13314,7 +13888,7 @@
1331413888
1331513889 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1331613890
13317
- void clickStart(int x, int y, int modifiers)
13891
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1331813892 {
1331913893 if (!wasliveok)
1332013894 return;
....@@ -13331,7 +13905,7 @@
1333113905 // touched = true; // main DL
1333213906 if (isRenderer)
1333313907 {
13334
- SetMouseMode(modifiers);
13908
+ SetMouseMode(modifiers, modifiersex);
1333513909 }
1333613910
1333713911 selectX = anchorX = x;
....@@ -13344,7 +13918,7 @@
1334413918 clicked = true;
1334513919 hold = false;
1334613920
13347
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13921
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1334813922 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1334913923 {
1335013924 // System.out.println("RESTART II " + modifiers);
....@@ -13375,7 +13949,7 @@
1337513949 info.camera = renderCamera;
1337613950 info.x = x;
1337713951 info.y = y;
13378
- info.modifiers = modifiers;
13952
+ info.modifiers = modifiersex;
1337913953 editObj = object.doEditClick(info, 0);
1338013954 if (!editObj)
1338113955 {
....@@ -13392,11 +13966,14 @@
1339213966
1339313967 public void mouseDragged(MouseEvent e)
1339413968 {
13969
+ Globals.MOUSEDRAGGED = true;
13970
+
13971
+ //System.out.println("mouseDragged: " + e);
1339513972 if (isRenderer)
1339613973 movingcamera = true;
13974
+
1339713975 //if (drawing)
1339813976 //return;
13399
- //System.out.println("mouseDragged: " + e);
1340013977 if ((e.getModifiersEx() & CTRL) != 0
1340113978 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1340213979 {
....@@ -13404,7 +13981,7 @@
1340413981 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1340513982 }
1340613983 else
13407
- drag(e.getX(), e.getY(), e.getModifiersEx());
13984
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1340813985
1340913986 //try { Thread.sleep(1); } catch (Exception ex) {}
1341013987 }
....@@ -13577,6 +14154,7 @@
1357714154
1357814155 public void run()
1357914156 {
14157
+ new Exception().printStackTrace();
1358014158 System.exit(0);
1358114159 for (;;)
1358214160 {
....@@ -13640,7 +14218,7 @@
1364014218 {
1364114219 Globals.lighttouched = true;
1364214220 }
13643
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14221
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1364414222 }
1364514223 //else
1364614224 }
....@@ -13740,7 +14318,7 @@
1374014318 int X, Y;
1374114319 boolean SX, SY;
1374214320
13743
- void drag(int x, int y, int modifiers)
14321
+ void drag(int x, int y, int modifiers, int modifiersex)
1374414322 {
1374514323 if (IsFrozen())
1374614324 {
....@@ -13749,17 +14327,17 @@
1374914327
1375014328 drag = true; // NEW
1375114329
13752
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14330
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1375314331
1375414332 X = x;
1375514333 Y = y;
1375614334 // floating state for animation
13757
- MODIFIERS = modifiers;
13758
- modifiers &= ~1024;
14335
+ MODIFIERS = modifiersex;
14336
+ modifiersex &= ~1024;
1375914337 if (false) // modifiers != 0)
1376014338 {
1376114339 //new Exception().printStackTrace();
13762
- System.out.println("mouseDragged: " + modifiers);
14340
+ System.out.println("mouseDragged: " + modifiersex);
1376314341 System.out.println("SHIFT = " + SHIFT);
1376414342 System.out.println("CONTROL = " + COMMAND);
1376514343 System.out.println("META = " + META);
....@@ -13779,7 +14357,7 @@
1377914357 info.camera = renderCamera;
1378014358 info.x = x;
1378114359 info.y = y;
13782
- object.editWindow.copy.doEditDrag(info);
14360
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1378314361 } else
1378414362 {
1378514363 if (x < startX)
....@@ -13931,7 +14509,6 @@
1393114509 public void mouseMoved(MouseEvent e)
1393214510 {
1393314511 //System.out.println("mouseMoved: " + e);
13934
-
1393514512 if (isRenderer)
1393614513 return;
1393714514
....@@ -13956,7 +14533,10 @@
1395614533
1395714534 public void mouseReleased(MouseEvent e)
1395814535 {
14536
+ Globals.MOUSEDRAGGED = false;
14537
+
1395914538 movingcamera = false;
14539
+ X = Y = 0;
1396014540 //System.out.println("mouseReleased: " + e);
1396114541 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1396214542 }
....@@ -13979,9 +14559,9 @@
1397914559 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1398014560 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1398114561
13982
- if (control || command || IsFrozen())
14562
+// No delay if (control || command || IsFrozen())
1398314563 timeout = true;
13984
- else
14564
+// ?? May 2019 else
1398514565 // timer.setDelay((modifiers & 128) != 0?0:350);
1398614566 mouseDown = false;
1398714567 if (!control && !command) // june 2013
....@@ -14091,7 +14671,7 @@
1409114671 System.out.println("keyReleased: " + e);
1409214672 }
1409314673
14094
- void SetMouseMode(int modifiers)
14674
+ void SetMouseMode(int modifiers, int modifiersex)
1409514675 {
1409614676 //System.out.println("SetMouseMode = " + modifiers);
1409714677 //modifiers &= ~1024;
....@@ -14103,25 +14683,25 @@
1410314683 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1410414684 // return;
1410514685 //System.out.println("SetMode = " + modifiers);
14106
- if ((modifiers & WHEEL) == WHEEL)
14686
+ if ((modifiersex & WHEEL) == WHEEL)
1410714687 {
1410814688 mouseMode |= ZOOM;
1410914689 }
1411014690
1411114691 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14112
- if (capsLocked || (modifiers & META) == META)
14692
+ if (capsLocked) // || (modifiers & META) == META)
1411314693 {
1411414694 mouseMode |= VR; // BACKFORTH;
1411514695 }
14116
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14696
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1411714697 {
1411814698 mouseMode |= SELECT;
1411914699 }
14120
- if ((modifiers & COMMAND) == COMMAND)
14700
+ if ((modifiersex & COMMAND) == COMMAND)
1412114701 {
1412214702 mouseMode |= SELECT;
1412314703 }
14124
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14704
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1412514705 {
1412614706 mouseMode &= ~VR;
1412714707 mouseMode |= TRANSLATE;
....@@ -14150,10 +14730,10 @@
1415014730
1415114731 if (isRenderer) //
1415214732 {
14153
- SetMouseMode(modifiers);
14733
+ SetMouseMode(0, modifiers);
1415414734 }
1415514735
14156
- theRenderer.keyPressed(key);
14736
+ Globals.theRenderer.keyPressed(key);
1415714737 }
1415814738
1415914739 int kompactbit = 4; // power bit
....@@ -14165,7 +14745,7 @@
1416514745 float SATPOW = 1; // 2; // 0.5f;
1416614746 float BRIPOW = 1; // 0.5f; // 0.5f;
1416714747
14168
- void keyPressed(int key)
14748
+ public void keyPressed(int key)
1416914749 {
1417014750 if (key >= '0' && key <= '5')
1417114751 clampbit = (key-'0');
....@@ -14486,7 +15066,7 @@
1448615066 //RESIZETEXTURE ^= true;
1448715067 //break;
1448815068 case 'z':
14489
- RENDERSHADOW ^= true;
15069
+ Globals.RENDERSHADOW ^= true;
1449015070 Globals.lighttouched = true;
1449115071 repaint();
1449215072 break;
....@@ -14602,6 +15182,7 @@
1460215182 }
1460315183 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1460415184 }
15185
+
1460515186 static double OCCLUSIONBOOST = 1; // 0.5;
1460615187
1460715188 void keyReleased(int key, int modifiers)
....@@ -14609,11 +15190,11 @@
1460915190 //mode = ROTATE;
1461015191 if ((MODIFIERS & COMMAND) == 0) // VR??
1461115192 {
14612
- SetMouseMode(modifiers);
15193
+ SetMouseMode(0, modifiers);
1461315194 }
1461415195 }
1461515196
14616
- protected void processKeyEvent(KeyEvent e)
15197
+ public void processKeyEvent(KeyEvent e)
1461715198 {
1461815199 switch (e.getID())
1461915200 {
....@@ -14743,8 +15324,9 @@
1474315324
1474415325 protected void processMouseMotionEvent(MouseEvent e)
1474515326 {
14746
- //System.out.println("processMouseMotionEvent: " + mouseMode);
14747
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15327
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15328
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15329
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1474815330 {
1474915331 mouseMoved(e);
1475015332 } else
....@@ -14774,6 +15356,7 @@
1477415356
1477515357 void SelectParent()
1477615358 {
15359
+ new Exception().printStackTrace();
1477715360 System.exit(0);
1477815361 Composite group = (Composite) object;
1477915362 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -14797,6 +15380,7 @@
1479715380
1479815381 void SelectChildren()
1479915382 {
15383
+ new Exception().printStackTrace();
1480015384 System.exit(0);
1480115385 /*
1480215386 Composite group = (Composite) object;
....@@ -14961,7 +15545,9 @@
1496115545 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1496215546 //Image img = CreateImage(width, height);
1496315547 //System.out.println("width = " + width + "; height = " + height + "\n");
15548
+
1496415549 Graphics gr = g; // img.getGraphics();
15550
+
1496515551 if (!hasMarquee)
1496615552 {
1496715553 if (Xmin < Xmax) // !locked)
....@@ -15059,14 +15645,33 @@
1505915645 if (!isRenderer)
1506015646 {
1506115647 object.drawEditHandles(info, 0);
15648
+
15649
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15650
+ {
15651
+ switch (object.selection.get(0).hitSomething)
15652
+ {
15653
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15654
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15655
+ break;
15656
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15657
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15658
+ break;
15659
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15660
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15661
+ break;
15662
+ }
15663
+
15664
+ }
1506215665 }
1506315666 }
15667
+
1506415668 if (isRenderer)
1506515669 {
1506615670 //gr.setColor(Color.black);
1506715671 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1506815672 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1506915673 }
15674
+
1507015675 if (hasMarquee)
1507115676 {
1507215677 gr.setXORMode(Color.white);
....@@ -15179,6 +15784,7 @@
1517915784 public boolean mouseDown(Event evt, int x, int y)
1518015785 {
1518115786 System.out.println("mouseDown: " + evt);
15787
+ System.exit(0);
1518215788 /*
1518315789 locked = true;
1518415790 drag = false;
....@@ -15222,7 +15828,7 @@
1522215828 {
1522315829 keyPressed(0, modifiers);
1522415830 }
15225
- clickStart(x, y, modifiers);
15831
+ // clickStart(x, y, modifiers);
1522615832 return true;
1522715833 }
1522815834
....@@ -15340,7 +15946,7 @@
1534015946 {
1534115947 keyReleased(0, 0);
1534215948 }
15343
- drag(x, y, modifiers);
15949
+ drag(x, y, 0, modifiers);
1534415950 return true;
1534515951 }
1534615952
....@@ -15472,7 +16078,7 @@
1547216078 Object3D object;
1547316079 static Object3D trackedobject;
1547416080 Camera renderCamera; // Light or Eye (or Occlusion)
15475
- /*static*/ Camera manipCamera; // Light or Eye
16081
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1547616082 /*static*/ Camera eyeCamera;
1547716083 /*static*/ Camera lightCamera;
1547816084 int cameracount;
....@@ -15910,6 +16516,7 @@
1591016516 {
1591116517 if (!selection)
1591216518 {
16519
+ new Exception().printStackTrace();
1591316520 System.exit(0);
1591416521 return;
1591516522 }
....@@ -16037,16 +16644,16 @@
1603716644 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]));
1603816645 }
1603916646
16040
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16647
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1604116648 }
1604216649 }
1604316650
1604416651 if (!movingcamera && !PAINTMODE)
1604516652 object.editWindow.ScreenFitPoint(); // fev 2014
1604616653
16047
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16654
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1604816655 {
16049
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16656
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1605016657
1605116658 Object3D group = new Object3D("inst" + paintcount++);
1605216659
....@@ -16202,7 +16809,7 @@
1620216809 gl.glDisable(gl.GL_CULL_FACE);
1620316810 }
1620416811
16205
- if (!RENDERSHADOW)
16812
+ if (!Globals.RENDERSHADOW)
1620616813 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1620716814
1620816815 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16212,7 +16819,7 @@
1621216819 //gl.glColorMask(false, false, false, false);
1621316820
1621416821 //render_scene_from_light_view(gl, drawable, 0, 0);
16215
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16822
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1621616823 {
1621716824 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1621816825
....@@ -16696,10 +17303,11 @@
1669617303 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1669717304 // Depth buffer format
1669817305 //private int depth_format;
16699
- static public void NextIndex(Object3D o, GL gl)
17306
+
17307
+ public void NextIndex()
1670017308 {
1670117309 indexcount+=16;
16702
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17310
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1670317311 //objects[indexcount] = o;
1670417312 //System.out.println("indexcount = " + indexcount);
1670517313 }