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,6 +150,8 @@
150150 defaultcaps.setAccumAlphaBits(16);
151151 }
152152
153
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
154
+
153155 void SetAsGLRenderer(boolean b)
154156 {
155157 isRenderer = b;
....@@ -191,9 +193,43 @@
191193
192194 /// INTERFACE
193195
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
+
194225 public boolean IsBoxMode()
195226 {
196227 return BOXMODE;
228
+ }
229
+
230
+ public boolean IsZoomBoxMode()
231
+ {
232
+ return ZOOMBOXMODE;
197233 }
198234
199235 public void ClearDepth()
....@@ -428,10 +464,12 @@
428464 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
429465 {
430466 //gl.glBegin(gl.GL_TRIANGLES);
431
- 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
+ ;
432470 if (!hasnorm)
433471 {
434
- // System.out.println("FUCK!!");
472
+ // System.out.println("Mesh normal");
435473 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
436474 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
437475 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1059,7 +1097,342 @@
10591097 gl.glMatrixMode(gl.GL_MODELVIEW);
10601098 }
10611099
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
+
10621408 /// 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
+ }
10631436
10641437 void SetColor(Object3D obj, Vertex p0)
10651438 {
....@@ -1254,18 +1627,18 @@
12541627 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
12551628 if (!material.multiply)
12561629 {
1257
- display.color = color;
1630
+ display.color = material.color;
12581631 display.saturation = material.modulation;
12591632 }
12601633 else
12611634 {
1262
- display.color *= color*2;
1635
+ display.color *= material.color*2;
12631636 display.saturation *= material.modulation*2;
12641637 }
12651638
12661639 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
12671640
1268
- float[] colorV = GrafreeD.colorV;
1641
+ float[] colorV = Grafreed.colorV;
12691642
12701643 /**/
12711644 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1525,7 +1898,7 @@
15251898 void PushMatrix(double[][] matrix)
15261899 {
15271900 // GrafreeD.tracein(matrix);
1528
- PushMatrix(matrix,1);
1901
+ PushMatrix(matrix, 1);
15291902 }
15301903
15311904 void PushMatrix()
....@@ -1777,7 +2150,7 @@
17772150 System.err.println("LIVE = " + Globals.isLIVE());
17782151
17792152 if (!Globals.isLIVE()) // save sound
1780
- GrafreeD.savesound = true; // wav.save();
2153
+ Grafreed.savesound = true; // wav.save();
17812154 // else
17822155 repaint(); // start loop // may 2013
17832156 }
....@@ -1810,6 +2183,11 @@
18102183 public void ToggleBoxMode()
18112184 {
18122185 BOXMODE ^= true;
2186
+ }
2187
+
2188
+ public void ToggleZoomBoxMode()
2189
+ {
2190
+ ZOOMBOXMODE ^= true;
18132191 }
18142192
18152193 public void ToggleSmoothFocus()
....@@ -1897,9 +2275,9 @@
18972275 LOOKAT ^= true;
18982276 }
18992277
1900
- void ToggleRandom()
2278
+ void ToggleSwitch()
19012279 {
1902
- RANDOM ^= true;
2280
+ SWITCH ^= true;
19032281 }
19042282
19052283 void ToggleHandles()
....@@ -2006,7 +2384,7 @@
20062384 {
20072385 return currentGL;
20082386 }
2009
-
2387
+
20102388 /**/
20112389 class CacheTexture
20122390 {
....@@ -3838,6 +4216,7 @@
38384216
38394217 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
38404218 {
4219
+ new Exception().printStackTrace();
38414220 System.exit(0);
38424221 com.sun.opengl.util.texture.Texture texture = null;
38434222
....@@ -7550,6 +7929,64 @@
75507929 ReleaseTexture(pigment, false);
75517930 }
75527931
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
+
75537990 void ReleaseTexture(String tex, boolean bump)
75547991 {
75557992 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -7653,7 +8090,7 @@
76538090 }
76548091 }
76558092
7656
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8093
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
76578094 {
76588095 if (// DrawMode() != 0 || /*tex == null ||*/
76598096 ambientOcclusion ) // || !textureon)
....@@ -7698,7 +8135,94 @@
76988135 return; // true;
76998136 }
77008137
7701
- 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
77028226 {
77038227 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
77048228
....@@ -7706,12 +8230,18 @@
77068230 {
77078231 String texname = tex;
77088232
7709
- String[] split = tex.split("Textures");
7710
- if (split.length > 1)
7711
- texname = "/Users/nbriere/Textures" + split[split.length-1];
7712
- else
7713
- if (!texname.startsWith("/"))
7714
- 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
+ }
77158245
77168246 if (CACHETEXTURE)
77178247 texture = textures.get(texname); // TEXTURE CACHE
....@@ -7780,7 +8310,7 @@
77808310 }
77818311
77828312 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
7783
- if (!new File(cachename).exists())
8313
+ if (!FileExists(cachename))
77848314 cachename = texname;
77858315 else
77868316 processbump = false; // don't process bump map again
....@@ -7802,7 +8332,7 @@
78028332 }
78038333
78048334 cachename = texname.substring(0, texname.length()-4)+ext+".png";
7805
- if (!new File(cachename).exists())
8335
+ if (!FileExists(cachename))
78068336 cachename = texname;
78078337 else
78088338 processbump = false; // don't process bump map again
....@@ -7811,7 +8341,9 @@
78118341 texturedata = GetFileTexture(cachename, processbump, resolution);
78128342
78138343
7814
- if (texturedata != null)
8344
+ if (texturedata == null)
8345
+ throw new Exception();
8346
+
78158347 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
78168348 //texture = GetTexture(tex, bump);
78178349 }
....@@ -7933,7 +8465,7 @@
79338465 return texture;
79348466 }
79358467
7936
- 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
79378469 {
79388470 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
79398471
....@@ -7951,14 +8483,14 @@
79518483 return texture!=null?texture.texture:null;
79528484 }
79538485
7954
- public 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
79558487 {
79568488 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
79578489
79588490 return texture!=null?texture.texturedata:null;
79598491 }
79608492
7961
- boolean BindTexture(String tex, boolean bump, int resolution)
8493
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
79628494 {
79638495 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
79648496 {
....@@ -8935,8 +9467,8 @@
89359467 assert (parentcam != renderCamera);
89369468
89379469 if (renderCamera != lightCamera)
8938
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8939
- LA.matConcat(matrix, parentcam.toParent, matrix);
9470
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9471
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
89409472
89419473 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
89429474
....@@ -8951,8 +9483,8 @@
89519483 LA.matCopy(renderCamera.fromScreen, matrix);
89529484
89539485 if (renderCamera != lightCamera)
8954
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8955
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9486
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9487
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
89569488
89579489 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
89589490
....@@ -9024,7 +9556,7 @@
90249556 //gl.glFlush();
90259557 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
90269558
9027
- if (ANIMATION && ABORTED)
9559
+ if (Globals.ANIMATION && ABORTED)
90289560 {
90299561 System.err.println(" ABORTED FRAME");
90309562 break;
....@@ -9054,7 +9586,7 @@
90549586 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
90559587
90569588 // save image
9057
- if (ANIMATION && !ABORTED)
9589
+ if (Globals.ANIMATION && !ABORTED)
90589590 {
90599591 VPwidth = viewport[2];
90609592 VPheight = viewport[3];
....@@ -9165,11 +9697,11 @@
91659697
91669698 // imagecount++;
91679699
9168
- 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;
91699701
91709702 if (!BOXMODE)
91719703 {
9172
- 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) + ")");
91739705 }
91749706
91759707 if (!BOXMODE)
....@@ -9207,7 +9739,7 @@
92079739 ABORTED = false;
92089740 }
92099741 else
9210
- GrafreeD.wav.cursor += 735 * ACSIZE;
9742
+ Grafreed.wav.cursor += 735 * ACSIZE;
92119743
92129744 if (false)
92139745 {
....@@ -9870,11 +10402,11 @@
987010402
987110403 public void display(GLAutoDrawable drawable)
987210404 {
9873
- if (GrafreeD.savesound && GrafreeD.hassound)
10405
+ if (Grafreed.savesound && Grafreed.hassound)
987410406 {
9875
- GrafreeD.wav.save();
9876
- GrafreeD.savesound = false;
9877
- GrafreeD.hassound = false;
10407
+ Grafreed.wav.save();
10408
+ Grafreed.savesound = false;
10409
+ Grafreed.hassound = false;
987810410 }
987910411 // if (DEBUG_SELECTION)
988010412 // {
....@@ -10004,7 +10536,7 @@
1000410536 Object3D theobject = object;
1000510537 Object3D theparent = object.parent;
1000610538 object.parent = null;
10007
- object = (Object3D)GrafreeD.clone(object);
10539
+ object = (Object3D)Grafreed.clone(object);
1000810540 object.Stripify();
1000910541 if (theobject.selection == null || theobject.selection.Size() == 0)
1001010542 theobject.PreprocessOcclusion(this);
....@@ -10017,13 +10549,13 @@
1001710549 ambientOcclusion = false;
1001810550 }
1001910551
10020
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10552
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1002110553 {
1002210554 //if (RENDERSHADOW) // ?
1002310555 if (!IsFrozen())
1002410556 {
1002510557 // dec 2012
10026
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10558
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1002710559 {
1002810560 Globals.framecount++;
1002910561 shadowbuffer.display();
....@@ -10150,8 +10682,8 @@
1015010682
1015110683 // if (parentcam != renderCamera) // not a light
1015210684 if (cam != lightCamera)
10153
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10154
- LA.matConcat(matrix, parentcam.toParent, matrix);
10685
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10686
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1015510687
1015610688 for (int j = 0; j < 4; j++)
1015710689 {
....@@ -10165,8 +10697,8 @@
1016510697
1016610698 // if (parentcam != renderCamera) // not a light
1016710699 if (cam != lightCamera)
10168
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10169
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10700
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10701
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1017010702
1017110703 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1017210704
....@@ -10425,7 +10957,16 @@
1042510957 // Bump noise
1042610958 gl.glActiveTexture(GL.GL_TEXTURE6);
1042710959 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10428
- 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
+
1042910970
1043010971 gl.glActiveTexture(GL.GL_TEXTURE0);
1043110972 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10550,8 +11091,8 @@
1055011091 System.err.println("parentcam != renderCamera");
1055111092
1055211093 // if (cam != lightCamera)
10553
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10554
- 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
1055511096 }
1055611097
1055711098 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10572,8 +11113,8 @@
1057211113 if (true) // TODO
1057311114 {
1057411115 if (cam != lightCamera)
10575
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10576
- 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
1057711118 }
1057811119
1057911120 LA.xformPos(light0, cam.toScreen, light0);
....@@ -10889,8 +11430,14 @@
1088911430 {
1089011431 renderpass++;
1089111432 // System.out.println("Draw object... ");
11433
+ STEP = 1;
1089211434 if (FAST) // in case there is no script
10893
- STEP = 16;
11435
+ STEP = 8;
11436
+
11437
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11438
+ {
11439
+ STEP *= 4;
11440
+ }
1089411441
1089511442 //object.FullInvariants();
1089611443
....@@ -10904,8 +11451,8 @@
1090411451 e.printStackTrace();
1090511452 }
1090611453
10907
- if (GrafreeD.RENDERME > 0)
10908
- GrafreeD.RENDERME--; // mechante magouille
11454
+ if (Grafreed.RENDERME > 0)
11455
+ Grafreed.RENDERME--; // mechante magouille
1090911456
1091011457 Globals.ONESTEP = false;
1091111458 }
....@@ -10975,7 +11522,14 @@
1097511522
1097611523 usedtextures.clear();
1097711524
10978
- 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
+ }
1097911533 }
1098011534 //System.out.println("--> " + stackdepth);
1098111535 // GrafreeD.traceon();
....@@ -11066,7 +11620,14 @@
1106611620 if (checker != null && DrawMode() == DEFAULT)
1106711621 {
1106811622 //BindTexture(IMMORTAL_TEXTURE);
11069
- 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
+ }
1107011631 // NEAREST
1107111632 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1107211633 DrawChecker(gl);
....@@ -11148,7 +11709,7 @@
1114811709 return;
1114911710 }
1115011711
11151
- String string = obj.GetToolTip();
11712
+ String string = obj.toString(); //.GetToolTip();
1115211713
1115311714 GL gl = GetGL();
1115411715
....@@ -11465,8 +12026,8 @@
1146512026 //obj.TransformToWorld(light, light);
1146612027 for (int i = tp.size(); --i >= 0;)
1146712028 {
11468
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11469
- 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);
1147012031 }
1147112032
1147212033
....@@ -11483,8 +12044,8 @@
1148312044 parentcam = cameras[0];
1148412045 }
1148512046
11486
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11487
- 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
1148812049
1148912050 LA.xformPos(light, renderCamera.toScreen, light);
1149012051
....@@ -12098,8 +12659,8 @@
1209812659
1209912660 // display shadow only (bump == 0)
1210012661 "SUB temp.x, half.x, shadow.x;" +
12101
- "MOV temp.y, -params6.x;" +
12102
- "SLT temp.z, temp.y, zero.x;" +
12662
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12663
+ "SLT temp.z, temp.y, -one2048th.x;" +
1210312664 "SUB temp.y, one.x, temp.z;" +
1210412665 "MUL temp.x, temp.x, temp.y;" +
1210512666 "KIL temp.x;" +
....@@ -12228,8 +12789,10 @@
1222812789 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1222912790
1223012791 "SUB temp.x, one.x, ndotl.x;" +
12231
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12232
- "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
1223312796 "MUL temp.x, temp.x, temp.y;" +
1223412797
1223512798 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12428,7 +12991,7 @@
1242812991 //once = true;
1242912992 }
1243012993
12431
- System.out.print("Program #" + mode + "; length = " + program.length());
12994
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1243212995 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1243312996 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1243412997
....@@ -12561,12 +13124,16 @@
1256113124
1256213125 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1256313126 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13127
+
13128
+ // Compare fragment depth in light space with shadowmap.
1256413129 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1256513130 "SGE temp.y, temp.x, zero.x;" +
12566
- "SUB " + shadow + ".y, one.x, temp.y;" +
13131
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13132
+
13133
+ // Reverse comparison
1256713134 "SUB temp.x, one.x, temp.x;" +
1256813135 "MUL " + shadow + ".x, temp.x, temp.y;" +
12569
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13136
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1257013137 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1257113138
1257213139 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12580,6 +13147,10 @@
1258013147 // No shadow for backface
1258113148 "DP3 temp.x, normal, lightd;" +
1258213149 "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;" +
1258313154 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1258413155 "";
1258513156 }
....@@ -13138,7 +13709,7 @@
1313813709 public void mousePressed(MouseEvent e)
1313913710 {
1314013711 //System.out.println("mousePressed: " + e);
13141
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13712
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1314213713 }
1314313714
1314413715 static long prevtime = 0;
....@@ -13165,6 +13736,7 @@
1316513736
1316613737 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1316713738
13739
+ if (BUTTONLESSWHEEL)
1316813740 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1316913741 {
1317013742 return;
....@@ -13173,7 +13745,7 @@
1317313745 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1317413746
1317513747 // TIMER
13176
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
13748
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1317713749 {
1317813750 keepboxmode = BOXMODE;
1317913751 keepsupport = SUPPORT;
....@@ -13213,8 +13785,8 @@
1321313785 // mode |= META;
1321413786 //}
1321513787
13216
- SetMouseMode(WHEEL | e.getModifiersEx());
13217
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13788
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13789
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1321813790 anchorX = ax;
1321913791 anchorY = ay;
1322013792 prevX = px;
....@@ -13274,6 +13846,10 @@
1327413846 // wasliveok = true;
1327513847 // waslive = false;
1327613848
13849
+ // May 2019 Forget it:
13850
+ if (true)
13851
+ return;
13852
+
1327713853 // source == timer
1327813854 if (mouseDown)
1327913855 {
....@@ -13312,7 +13888,7 @@
1331213888
1331313889 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1331413890
13315
- void clickStart(int x, int y, int modifiers)
13891
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1331613892 {
1331713893 if (!wasliveok)
1331813894 return;
....@@ -13329,7 +13905,7 @@
1332913905 // touched = true; // main DL
1333013906 if (isRenderer)
1333113907 {
13332
- SetMouseMode(modifiers);
13908
+ SetMouseMode(modifiers, modifiersex);
1333313909 }
1333413910
1333513911 selectX = anchorX = x;
....@@ -13342,7 +13918,7 @@
1334213918 clicked = true;
1334313919 hold = false;
1334413920
13345
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13921
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1334613922 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1334713923 {
1334813924 // System.out.println("RESTART II " + modifiers);
....@@ -13373,7 +13949,7 @@
1337313949 info.camera = renderCamera;
1337413950 info.x = x;
1337513951 info.y = y;
13376
- info.modifiers = modifiers;
13952
+ info.modifiers = modifiersex;
1337713953 editObj = object.doEditClick(info, 0);
1337813954 if (!editObj)
1337913955 {
....@@ -13390,11 +13966,14 @@
1339013966
1339113967 public void mouseDragged(MouseEvent e)
1339213968 {
13969
+ Globals.MOUSEDRAGGED = true;
13970
+
13971
+ //System.out.println("mouseDragged: " + e);
1339313972 if (isRenderer)
1339413973 movingcamera = true;
13974
+
1339513975 //if (drawing)
1339613976 //return;
13397
- //System.out.println("mouseDragged: " + e);
1339813977 if ((e.getModifiersEx() & CTRL) != 0
1339913978 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1340013979 {
....@@ -13402,7 +13981,7 @@
1340213981 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1340313982 }
1340413983 else
13405
- drag(e.getX(), e.getY(), e.getModifiersEx());
13984
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1340613985
1340713986 //try { Thread.sleep(1); } catch (Exception ex) {}
1340813987 }
....@@ -13575,6 +14154,7 @@
1357514154
1357614155 public void run()
1357714156 {
14157
+ new Exception().printStackTrace();
1357814158 System.exit(0);
1357914159 for (;;)
1358014160 {
....@@ -13638,7 +14218,7 @@
1363814218 {
1363914219 Globals.lighttouched = true;
1364014220 }
13641
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14221
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1364214222 }
1364314223 //else
1364414224 }
....@@ -13738,7 +14318,7 @@
1373814318 int X, Y;
1373914319 boolean SX, SY;
1374014320
13741
- void drag(int x, int y, int modifiers)
14321
+ void drag(int x, int y, int modifiers, int modifiersex)
1374214322 {
1374314323 if (IsFrozen())
1374414324 {
....@@ -13747,17 +14327,17 @@
1374714327
1374814328 drag = true; // NEW
1374914329
13750
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14330
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1375114331
1375214332 X = x;
1375314333 Y = y;
1375414334 // floating state for animation
13755
- MODIFIERS = modifiers;
13756
- modifiers &= ~1024;
14335
+ MODIFIERS = modifiersex;
14336
+ modifiersex &= ~1024;
1375714337 if (false) // modifiers != 0)
1375814338 {
1375914339 //new Exception().printStackTrace();
13760
- System.out.println("mouseDragged: " + modifiers);
14340
+ System.out.println("mouseDragged: " + modifiersex);
1376114341 System.out.println("SHIFT = " + SHIFT);
1376214342 System.out.println("CONTROL = " + COMMAND);
1376314343 System.out.println("META = " + META);
....@@ -13777,7 +14357,7 @@
1377714357 info.camera = renderCamera;
1377814358 info.x = x;
1377914359 info.y = y;
13780
- object.editWindow.copy.doEditDrag(info);
14360
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1378114361 } else
1378214362 {
1378314363 if (x < startX)
....@@ -13929,7 +14509,6 @@
1392914509 public void mouseMoved(MouseEvent e)
1393014510 {
1393114511 //System.out.println("mouseMoved: " + e);
13932
-
1393314512 if (isRenderer)
1393414513 return;
1393514514
....@@ -13954,7 +14533,10 @@
1395414533
1395514534 public void mouseReleased(MouseEvent e)
1395614535 {
14536
+ Globals.MOUSEDRAGGED = false;
14537
+
1395714538 movingcamera = false;
14539
+ X = Y = 0;
1395814540 //System.out.println("mouseReleased: " + e);
1395914541 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1396014542 }
....@@ -13977,9 +14559,9 @@
1397714559 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1397814560 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1397914561
13980
- if (control || command || IsFrozen())
14562
+// No delay if (control || command || IsFrozen())
1398114563 timeout = true;
13982
- else
14564
+// ?? May 2019 else
1398314565 // timer.setDelay((modifiers & 128) != 0?0:350);
1398414566 mouseDown = false;
1398514567 if (!control && !command) // june 2013
....@@ -14089,7 +14671,7 @@
1408914671 System.out.println("keyReleased: " + e);
1409014672 }
1409114673
14092
- void SetMouseMode(int modifiers)
14674
+ void SetMouseMode(int modifiers, int modifiersex)
1409314675 {
1409414676 //System.out.println("SetMouseMode = " + modifiers);
1409514677 //modifiers &= ~1024;
....@@ -14101,25 +14683,25 @@
1410114683 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1410214684 // return;
1410314685 //System.out.println("SetMode = " + modifiers);
14104
- if ((modifiers & WHEEL) == WHEEL)
14686
+ if ((modifiersex & WHEEL) == WHEEL)
1410514687 {
1410614688 mouseMode |= ZOOM;
1410714689 }
1410814690
1410914691 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14110
- if (capsLocked || (modifiers & META) == META)
14692
+ if (capsLocked) // || (modifiers & META) == META)
1411114693 {
1411214694 mouseMode |= VR; // BACKFORTH;
1411314695 }
14114
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14696
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1411514697 {
1411614698 mouseMode |= SELECT;
1411714699 }
14118
- if ((modifiers & COMMAND) == COMMAND)
14700
+ if ((modifiersex & COMMAND) == COMMAND)
1411914701 {
1412014702 mouseMode |= SELECT;
1412114703 }
14122
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14704
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1412314705 {
1412414706 mouseMode &= ~VR;
1412514707 mouseMode |= TRANSLATE;
....@@ -14148,7 +14730,7 @@
1414814730
1414914731 if (isRenderer) //
1415014732 {
14151
- SetMouseMode(modifiers);
14733
+ SetMouseMode(0, modifiers);
1415214734 }
1415314735
1415414736 Globals.theRenderer.keyPressed(key);
....@@ -14484,7 +15066,7 @@
1448415066 //RESIZETEXTURE ^= true;
1448515067 //break;
1448615068 case 'z':
14487
- RENDERSHADOW ^= true;
15069
+ Globals.RENDERSHADOW ^= true;
1448815070 Globals.lighttouched = true;
1448915071 repaint();
1449015072 break;
....@@ -14608,7 +15190,7 @@
1460815190 //mode = ROTATE;
1460915191 if ((MODIFIERS & COMMAND) == 0) // VR??
1461015192 {
14611
- SetMouseMode(modifiers);
15193
+ SetMouseMode(0, modifiers);
1461215194 }
1461315195 }
1461415196
....@@ -14742,8 +15324,9 @@
1474215324
1474315325 protected void processMouseMotionEvent(MouseEvent e)
1474415326 {
14745
- //System.out.println("processMouseMotionEvent: " + mouseMode);
14746
- 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)
1474715330 {
1474815331 mouseMoved(e);
1474915332 } else
....@@ -14773,6 +15356,7 @@
1477315356
1477415357 void SelectParent()
1477515358 {
15359
+ new Exception().printStackTrace();
1477615360 System.exit(0);
1477715361 Composite group = (Composite) object;
1477815362 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -14796,6 +15380,7 @@
1479615380
1479715381 void SelectChildren()
1479815382 {
15383
+ new Exception().printStackTrace();
1479915384 System.exit(0);
1480015385 /*
1480115386 Composite group = (Composite) object;
....@@ -14960,7 +15545,9 @@
1496015545 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1496115546 //Image img = CreateImage(width, height);
1496215547 //System.out.println("width = " + width + "; height = " + height + "\n");
15548
+
1496315549 Graphics gr = g; // img.getGraphics();
15550
+
1496415551 if (!hasMarquee)
1496515552 {
1496615553 if (Xmin < Xmax) // !locked)
....@@ -15058,14 +15645,33 @@
1505815645 if (!isRenderer)
1505915646 {
1506015647 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
+ }
1506115665 }
1506215666 }
15667
+
1506315668 if (isRenderer)
1506415669 {
1506515670 //gr.setColor(Color.black);
1506615671 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1506715672 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1506815673 }
15674
+
1506915675 if (hasMarquee)
1507015676 {
1507115677 gr.setXORMode(Color.white);
....@@ -15178,6 +15784,7 @@
1517815784 public boolean mouseDown(Event evt, int x, int y)
1517915785 {
1518015786 System.out.println("mouseDown: " + evt);
15787
+ System.exit(0);
1518115788 /*
1518215789 locked = true;
1518315790 drag = false;
....@@ -15221,7 +15828,7 @@
1522115828 {
1522215829 keyPressed(0, modifiers);
1522315830 }
15224
- clickStart(x, y, modifiers);
15831
+ // clickStart(x, y, modifiers);
1522515832 return true;
1522615833 }
1522715834
....@@ -15339,7 +15946,7 @@
1533915946 {
1534015947 keyReleased(0, 0);
1534115948 }
15342
- drag(x, y, modifiers);
15949
+ drag(x, y, 0, modifiers);
1534315950 return true;
1534415951 }
1534515952
....@@ -15471,7 +16078,7 @@
1547116078 Object3D object;
1547216079 static Object3D trackedobject;
1547316080 Camera renderCamera; // Light or Eye (or Occlusion)
15474
- /*static*/ Camera manipCamera; // Light or Eye
16081
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1547516082 /*static*/ Camera eyeCamera;
1547616083 /*static*/ Camera lightCamera;
1547716084 int cameracount;
....@@ -15909,6 +16516,7 @@
1590916516 {
1591016517 if (!selection)
1591116518 {
16519
+ new Exception().printStackTrace();
1591216520 System.exit(0);
1591316521 return;
1591416522 }
....@@ -16036,16 +16644,16 @@
1603616644 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]));
1603716645 }
1603816646
16039
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16647
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1604016648 }
1604116649 }
1604216650
1604316651 if (!movingcamera && !PAINTMODE)
1604416652 object.editWindow.ScreenFitPoint(); // fev 2014
1604516653
16046
- 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)
1604716655 {
16048
- 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);
1604916657
1605016658 Object3D group = new Object3D("inst" + paintcount++);
1605116659
....@@ -16201,7 +16809,7 @@
1620116809 gl.glDisable(gl.GL_CULL_FACE);
1620216810 }
1620316811
16204
- if (!RENDERSHADOW)
16812
+ if (!Globals.RENDERSHADOW)
1620516813 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1620616814
1620716815 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16211,7 +16819,7 @@
1621116819 //gl.glColorMask(false, false, false, false);
1621216820
1621316821 //render_scene_from_light_view(gl, drawable, 0, 0);
16214
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16822
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1621516823 {
1621616824 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1621716825
....@@ -16695,10 +17303,11 @@
1669517303 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1669617304 // Depth buffer format
1669717305 //private int depth_format;
16698
- static public void NextIndex(Object3D o, GL gl)
17306
+
17307
+ public void NextIndex()
1669917308 {
1670017309 indexcount+=16;
16701
- 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);
1670217311 //objects[indexcount] = o;
1670317312 //System.out.println("indexcount = " + indexcount);
1670417313 }