Normand Briere
2019-07-21 76522bc3ee92bd50dbd946d7f865666be4ad7bac
CameraPane.java
....@@ -37,7 +37,6 @@
3737 static boolean[] selectedstack = new boolean[65536];
3838 static int materialdepth = 0;
3939
40
- static boolean DEBUG = false;
4140 static boolean FRUSTUM = false; // still bogus true; // frustum culling
4241
4342 // camera change fix
....@@ -56,8 +55,6 @@
5655 static int CURRENTANTIALIAS = 0; // 1;
5756 /*static*/ boolean RENDERSHADOW = true;
5857 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
59
- static boolean ANIMATION = false;
60
- static String filename;
6158
6259 boolean DISPLAYTEXT = false;
6360 //boolean REDUCETEXTURE = true;
....@@ -92,6 +89,8 @@
9289
9390 static int tickcount = 0; // slow pose issue
9491
92
+static boolean BUTTONLESSWHEEL = false;
93
+static boolean ZOOMBOXMODE = false;
9594 static boolean BOXMODE = false;
9695 static boolean IMAGEFLIP = false;
9796 static boolean SMOOTHFOCUS = false;
....@@ -106,7 +105,7 @@
106105 static boolean OEIL = true;
107106 static boolean OEILONCE = false; // do oeilon then oeiloff
108107 static boolean LOOKAT = true;
109
-static boolean RANDOM = true; // false;
108
+static boolean SWITCH = true; // false;
110109 static boolean HANDLES = false; // selection doesn't work!!
111110 static boolean PAINTMODE = false;
112111
....@@ -150,12 +149,12 @@
150149 defaultcaps.setAccumAlphaBits(16);
151150 }
152151
153
- static CameraPane theRenderer;
152
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
154153
155154 void SetAsGLRenderer(boolean b)
156155 {
157156 isRenderer = b;
158
- theRenderer = this;
157
+ Globals.theRenderer = this;
159158 }
160159
161160 CameraPane(Object3D o, Camera cam, boolean withcontext)
....@@ -193,9 +192,43 @@
193192
194193 /// INTERFACE
195194
195
+ public javax.media.opengl.GL GetGL0()
196
+ {
197
+ return null;
198
+ }
199
+
200
+ public int GenList()
201
+ {
202
+ javax.media.opengl.GL gl = GetGL();
203
+ return gl.glGenLists(1);
204
+ }
205
+
206
+ public void NewList(int id)
207
+ {
208
+ javax.media.opengl.GL gl = GetGL();
209
+ gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE);
210
+ }
211
+
212
+ public void CallList(int id)
213
+ {
214
+ javax.media.opengl.GL gl = GetGL();
215
+ gl.glCallList(id);
216
+ }
217
+
218
+ public void EndList()
219
+ {
220
+ javax.media.opengl.GL gl = GetGL();
221
+ gl.glEndList();
222
+ }
223
+
196224 public boolean IsBoxMode()
197225 {
198226 return BOXMODE;
227
+ }
228
+
229
+ public boolean IsZoomBoxMode()
230
+ {
231
+ return ZOOMBOXMODE;
199232 }
200233
201234 public void ClearDepth()
....@@ -293,7 +326,7 @@
293326 cStatic.objectstack[materialdepth++] = obj;
294327 //System.out.println("material " + material);
295328 //Applet3D.tracein(this, selected);
296
- display.vector2buffer = obj.projectedVertices;
329
+ //display.vector2buffer = obj.projectedVertices;
297330 if (obj instanceof Camera)
298331 {
299332 display.options1[0] = material.shift;
....@@ -302,14 +335,28 @@
302335 display.options1[2] = material.shadowbias;
303336 display.options1[3] = material.aniso;
304337 display.options1[4] = material.anisoV;
338
+// System.out.println("display.options1[0] " + display.options1[0]);
339
+// System.out.println("display.options1[1] " + display.options1[1]);
340
+// System.out.println("display.options1[2] " + display.options1[2]);
341
+// System.out.println("display.options1[3] " + display.options1[3]);
342
+// System.out.println("display.options1[4] " + display.options1[4]);
305343 display.options2[0] = material.opacity;
306344 display.options2[1] = material.diffuse;
307345 display.options2[2] = material.factor;
346
+// System.out.println("display.options2[0] " + display.options2[0]);
347
+// System.out.println("display.options2[1] " + display.options2[1]);
348
+// System.out.println("display.options2[2] " + display.options2[2]);
308349
309350 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
351
+// System.out.println("display.options3[0] " + display.options3[0]);
352
+// System.out.println("display.options3[1] " + display.options3[1]);
353
+// System.out.println("display.options3[2] " + display.options3[2]);
310354 display.options4[0] = material.cameralight/0.2f;
311355 display.options4[1] = material.subsurface;
312356 display.options4[2] = material.sheen;
357
+// System.out.println("display.options4[0] " + display.options4[0]);
358
+// System.out.println("display.options4[1] " + display.options4[1]);
359
+// System.out.println("display.options4[2] " + display.options4[2]);
313360
314361 // if (display.CURRENTANTIALIAS > 0)
315362 // display.options3[3] /= 4;
....@@ -325,7 +372,7 @@
325372 /**/
326373 } else
327374 {
328
- DrawMaterial(material, selected);
375
+ DrawMaterial(material, selected, obj.projectedVertices);
329376 }
330377 } else
331378 {
....@@ -349,8 +396,8 @@
349396 cStatic.objectstack[materialdepth++] = obj;
350397 //System.out.println("material " + material);
351398 //Applet3D.tracein("selected ", selected);
352
- display.vector2buffer = obj.projectedVertices;
353
- display.DrawMaterial(material, selected);
399
+ //display.vector2buffer = obj.projectedVertices;
400
+ display.DrawMaterial(material, selected, obj.projectedVertices);
354401 }
355402 }
356403
....@@ -367,8 +414,8 @@
367414 materialdepth -= 1;
368415 if (materialdepth > 0)
369416 {
370
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
371
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
417
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
418
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
372419 }
373420 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
374421 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -388,8 +435,8 @@
388435 materialdepth -= 1;
389436 if (materialdepth > 0)
390437 {
391
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
392
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
438
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
439
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
393440 }
394441 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
395442 //else
....@@ -430,10 +477,12 @@
430477 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
431478 {
432479 //gl.glBegin(gl.GL_TRIANGLES);
433
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
480
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
481
+ // TEST LIVE NORMALS && !obj.dontselect
482
+ ;
434483 if (!hasnorm)
435484 {
436
- // System.out.println("FUCK!!");
485
+ // System.out.println("Mesh normal");
437486 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
438487 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
439488 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -816,7 +865,7 @@
816865
817866 if ((i % 100) == 0 && i != 0)
818867 {
819
- CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
868
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
820869 //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
821870 System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
822871 }
....@@ -848,7 +897,7 @@
848897
849898 if ((i % 100) == 0 && i != 0)
850899 {
851
- CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
900
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
852901 //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
853902 System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
854903 }
....@@ -1061,7 +1110,342 @@
10611110 gl.glMatrixMode(gl.GL_MODELVIEW);
10621111 }
10631112
1113
+ public void DrawBox(cVector min, cVector max)
1114
+ {
1115
+ javax.media.opengl.GL gl = GetGL();
1116
+ gl.glBegin(gl.GL_LINES);
1117
+
1118
+ gl.glVertex3d(min.x, min.y, min.z);
1119
+ gl.glVertex3d(min.x, min.y, max.z);
1120
+ gl.glVertex3d(min.x, min.y, min.z);
1121
+ gl.glVertex3d(min.x, max.y, min.z);
1122
+ gl.glVertex3d(min.x, min.y, min.z);
1123
+ gl.glVertex3d(max.x, min.y, min.z);
1124
+
1125
+ gl.glVertex3d(max.x, max.y, max.z);
1126
+ gl.glVertex3d(min.x, max.y, max.z);
1127
+ gl.glVertex3d(max.x, max.y, max.z);
1128
+ gl.glVertex3d(max.x, min.y, max.z);
1129
+ gl.glVertex3d(max.x, max.y, max.z);
1130
+ gl.glVertex3d(max.x, max.y, min.z);
1131
+
1132
+ gl.glEnd();
1133
+ }
1134
+
1135
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1136
+ {
1137
+ int[] strips = bRep.getRawIndices();
1138
+
1139
+ javax.media.opengl.GL gl = GetGL();
1140
+
1141
+ // TRIANGLE STRIP ARRAY
1142
+ if (bRep.trimmed)
1143
+ {
1144
+ float[] v = bRep.getRawVertices();
1145
+ float[] n = bRep.getRawNormals();
1146
+ float[] c = bRep.getRawColors();
1147
+ float[] uv = bRep.getRawUVMap();
1148
+
1149
+ int count2 = 0;
1150
+ int count3 = 0;
1151
+
1152
+ if (n.length > 0)
1153
+ {
1154
+ for (int i = 0; i < strips.length; i++)
1155
+ {
1156
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1157
+
1158
+ /*
1159
+ boolean locked = false;
1160
+ float eps = 0.1f;
1161
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1162
+
1163
+ int dot = 0;
1164
+
1165
+ if ((dot&1) == 0)
1166
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1167
+
1168
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1169
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1170
+ else
1171
+ {
1172
+ locked = true;
1173
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1174
+ }
1175
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1176
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1177
+ if (hasnorm)
1178
+ {
1179
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1180
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1181
+ }
1182
+
1183
+ if ((dot&4) == 0)
1184
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1185
+
1186
+ if (wrap || !locked && (dot&8) != 0)
1187
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1188
+ else
1189
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1190
+
1191
+ f.dot = dot;
1192
+ */
1193
+
1194
+ if (!selectmode)
1195
+ {
1196
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1197
+ {
1198
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1199
+ } else
1200
+ {
1201
+ gl.glNormal3f(0, 0, 1);
1202
+ }
1203
+
1204
+ if (c != null)
1205
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1206
+ {
1207
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1208
+ }
1209
+ }
1210
+
1211
+ if (flipV)
1212
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1213
+ else
1214
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1215
+
1216
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1217
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1218
+
1219
+ count2 += 2;
1220
+ count3 += 3;
1221
+ if (!selectmode)
1222
+ {
1223
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1224
+ {
1225
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1226
+ } else
1227
+ {
1228
+ gl.glNormal3f(0, 0, 1);
1229
+ }
1230
+ if (c != null)
1231
+ {
1232
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1233
+ }
1234
+ }
1235
+
1236
+ if (flipV)
1237
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1238
+ else
1239
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1240
+
1241
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1242
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1243
+
1244
+ count2 += 2;
1245
+ count3 += 3;
1246
+ for (int j = 0; j < strips[i] - 2; j++)
1247
+ {
1248
+ //gl.glTexCoord2d(...);
1249
+ if (!selectmode)
1250
+ {
1251
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1252
+ {
1253
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1254
+ } else
1255
+ {
1256
+ gl.glNormal3f(0, 0, 1);
1257
+ }
1258
+ if (c != null)
1259
+ {
1260
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1261
+ }
1262
+ }
1263
+
1264
+ if (flipV)
1265
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1266
+ else
1267
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1268
+
1269
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1270
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1271
+
1272
+ count2 += 2;
1273
+ count3 += 3;
1274
+ }
1275
+
1276
+ gl.glEnd();
1277
+ }
1278
+ }
1279
+
1280
+ assert count3 == v.length;
1281
+ }
1282
+ else // !trimmed
1283
+ {
1284
+ int count = 0;
1285
+ for (int i = 0; i < strips.length; i++)
1286
+ {
1287
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1288
+
1289
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1290
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1291
+
1292
+ drawVertex(gl, p, flipV, selectmode);
1293
+ drawVertex(gl, q, flipV, selectmode);
1294
+
1295
+ for (int j = 0; j < strips[i] - 2; j++)
1296
+ {
1297
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1298
+
1299
+ // if (j%2 == 0)
1300
+ // drawFace(p, q, r, display, null);
1301
+ // else
1302
+ // drawFace(p, r, q, display, null);
1303
+
1304
+ // p = q;
1305
+ // q = r;
1306
+ drawVertex(gl, r, flipV, selectmode);
1307
+ }
1308
+
1309
+ gl.glEnd();
1310
+ }
1311
+ }
1312
+ }
1313
+
1314
+ static cSpring.Point3D temp = new cSpring.Point3D();
1315
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1316
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1317
+
1318
+ public void DrawDynamicMesh(cMesh mesh)
1319
+ {
1320
+ GL gl = GetGL(); // getGL();
1321
+
1322
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1323
+
1324
+ gl.glDisable(gl.GL_LIGHTING);
1325
+
1326
+ gl.glLineWidth(1);
1327
+ gl.glColor3f(1,1,1);
1328
+ gl.glBegin(gl.GL_LINES);
1329
+ double scale = 0;
1330
+ int count = 0;
1331
+ for (int s=0; s<Phys.allSprings.size(); s++)
1332
+ {
1333
+ cSpring.Spring spring = Phys.allSprings.get(s);
1334
+ if(s == 0)
1335
+ {
1336
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1337
+ }
1338
+ if (mesh.showsprings)
1339
+ {
1340
+ temp.set(spring.a.position);
1341
+ temp.add(spring.b.position);
1342
+ temp.mul(0.5);
1343
+ temp2.set(spring.a.position);
1344
+ temp2.sub(spring.b.position);
1345
+ temp2.mul(spring.restLength/2);
1346
+ temp.sub(temp2);
1347
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1348
+ temp.add(temp2);
1349
+ temp.add(temp2);
1350
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1351
+ }
1352
+
1353
+ if (spring.isHandle)
1354
+ continue;
1355
+
1356
+ //if (scale < spring.restLength)
1357
+ scale += spring.restLength;
1358
+ count++;
1359
+ }
1360
+ gl.glEnd();
1361
+
1362
+ if (count == 0)
1363
+ scale = 0.01;
1364
+ else
1365
+ scale /= count * 3;
1366
+
1367
+ //scale = 0.25;
1368
+
1369
+ if (mesh.ShowInfo())
1370
+ {
1371
+ gl.glLineWidth(4);
1372
+ for (int s=0; s<Phys.allNodes.size(); s++)
1373
+ {
1374
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1375
+ if (node.mass == 0)
1376
+ continue;
1377
+
1378
+ int i = node.springs==null?-1:node.springs.size();
1379
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1380
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1381
+ //temp.normalize();
1382
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1383
+ gl.glBegin(gl.GL_LINES);
1384
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1385
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1386
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1387
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1388
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1389
+ gl.glEnd();
1390
+ }
1391
+
1392
+ gl.glLineWidth(8);
1393
+ for (int s=0; s<Phys.allNodes.size(); s++)
1394
+ {
1395
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1396
+
1397
+ if (node.springs != null)
1398
+ {
1399
+ for (int i=0; i<node.springs.size(); i+=1)
1400
+ {
1401
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1402
+
1403
+ int c = i+1;
1404
+ // c = node.springs.get(i).nbcopies;
1405
+
1406
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1407
+ gl.glBegin(gl.GL_LINES);
1408
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1409
+ 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);
1410
+ gl.glEnd();
1411
+ }
1412
+ }
1413
+ }
1414
+
1415
+ gl.glLineWidth(1);
1416
+ }
1417
+
1418
+ gl.glEnable(gl.GL_LIGHTING);
1419
+ }
1420
+
10641421 /// INTERFACE
1422
+
1423
+ public void StartTriangles()
1424
+ {
1425
+ javax.media.opengl.GL gl = GetGL();
1426
+ gl.glBegin(gl.GL_TRIANGLES);
1427
+ }
1428
+
1429
+ public void EndTriangles()
1430
+ {
1431
+ GetGL().glEnd();
1432
+ }
1433
+
1434
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1435
+ {
1436
+ if (!selectmode)
1437
+ {
1438
+ gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1439
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1440
+
1441
+ if (flipV)
1442
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1443
+ else
1444
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1445
+ }
1446
+
1447
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1448
+ }
10651449
10661450 void SetColor(Object3D obj, Vertex p0)
10671451 {
....@@ -1240,7 +1624,7 @@
12401624 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
12411625 }
12421626
1243
- void DrawMaterial(cMaterial material, boolean selected)
1627
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
12441628 {
12451629 CameraPane display = this;
12461630 //new Exception().printStackTrace();
....@@ -1256,18 +1640,18 @@
12561640 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
12571641 if (!material.multiply)
12581642 {
1259
- display.color = color;
1643
+ display.color = material.color;
12601644 display.saturation = material.modulation;
12611645 }
12621646 else
12631647 {
1264
- display.color *= color*2;
1648
+ display.color *= material.color*2;
12651649 display.saturation *= material.modulation*2;
12661650 }
12671651
12681652 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
12691653
1270
- float[] colorV = GrafreeD.colorV;
1654
+ float[] colorV = Grafreed.colorV;
12711655
12721656 /**/
12731657 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1275,7 +1659,7 @@
12751659 colorV[0] = display.modelParams0[0] * material.diffuse;
12761660 colorV[1] = display.modelParams0[1] * material.diffuse;
12771661 colorV[2] = display.modelParams0[2] * material.diffuse;
1278
- colorV[3] = material.opacity;
1662
+ colorV[3] = 1; // material.opacity;
12791663
12801664 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
12811665 //System.out.println("Opacity = " + opacity);
....@@ -1383,9 +1767,9 @@
13831767 display.modelParams7[2] = 0;
13841768 display.modelParams7[3] = 0;
13851769
1386
- display.modelParams6[0] = 100; // criss de bug de bump
1770
+ //display.modelParams6[0] = 100; // criss de bug de bump
13871771
1388
- Object3D.cVector2[] extparams = display.vector2buffer;
1772
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
13891773 if (extparams != null && extparams.length > 0 && extparams[0] != null)
13901774 {
13911775 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1527,7 +1911,7 @@
15271911 void PushMatrix(double[][] matrix)
15281912 {
15291913 // GrafreeD.tracein(matrix);
1530
- PushMatrix(matrix,1);
1914
+ PushMatrix(matrix, 1);
15311915 }
15321916
15331917 void PushMatrix()
....@@ -1624,7 +2008,7 @@
16242008
16252009 static int camerachangeframe;
16262010
1627
- boolean SetCamera(Camera cam)
2011
+ public boolean SetCamera(Camera cam)
16282012 {
16292013 // may 2014 if (cam == cameras[0] || cam == cameras[1])
16302014 // return false;
....@@ -1681,7 +2065,7 @@
16812065 //System.err.println("Oeil on");
16822066 OEIL = true;
16832067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
1684
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
16852069 //pingthread.StepToTarget(true);
16862070 }
16872071
....@@ -1752,33 +2136,6 @@
17522136 mainDL ^= true;
17532137 }
17542138
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
-
17822139 void ToggleFullScreen()
17832140 {
17842141 FULLSCREEN ^= true;
....@@ -1789,72 +2146,94 @@
17892146 Globals.CROWD ^= true;
17902147 }
17912148
1792
- void ToggleInertia()
1793
- {
1794
- INERTIA ^= true;
1795
- }
1796
-
17972149 void ToggleLocal()
17982150 {
17992151 LOCALTRANSFORM ^= true;
18002152 }
18012153
1802
- void ToggleFast()
2154
+ public void ToggleTexture()
2155
+ {
2156
+ textureon ^= true;
2157
+ }
2158
+
2159
+ public void ToggleLive()
2160
+ {
2161
+ Globals.setLIVE(Globals.isLIVE() ^ true);
2162
+
2163
+ System.err.println("LIVE = " + Globals.isLIVE());
2164
+
2165
+ if (!Globals.isLIVE()) // save sound
2166
+ Grafreed.savesound = true; // wav.save();
2167
+ // else
2168
+ repaint(); // start loop // may 2013
2169
+ }
2170
+
2171
+ public void ToggleSupport()
2172
+ {
2173
+ SUPPORT ^= true;
2174
+ }
2175
+
2176
+ public void ToggleAbort()
2177
+ {
2178
+ ABORTMODE ^= true;
2179
+ }
2180
+
2181
+ public void ToggleInertia()
2182
+ {
2183
+ INERTIA ^= true;
2184
+ }
2185
+
2186
+ public void ToggleFast()
18032187 {
18042188 FAST ^= true;
18052189 }
18062190
1807
- void ToggleSlowPose()
2191
+ public void ToggleSlowPose()
18082192 {
18092193 SLOWPOSE ^= true;
18102194 }
18112195
1812
- void ToggleFootContact()
1813
- {
1814
- FOOTCONTACT ^= true;
1815
- }
1816
-
1817
- void ToggleBoxMode()
2196
+ public void ToggleBoxMode()
18182197 {
18192198 BOXMODE ^= true;
18202199 }
18212200
1822
- void ToggleSmoothFocus()
2201
+ public void ToggleZoomBoxMode()
2202
+ {
2203
+ ZOOMBOXMODE ^= true;
2204
+ }
2205
+
2206
+ public void ToggleSmoothFocus()
18232207 {
18242208 SMOOTHFOCUS ^= true;
18252209 }
18262210
1827
- void ToggleImageFlip()
2211
+ public void ToggleImageFlip()
18282212 {
18292213 IMAGEFLIP ^= true;
18302214 }
18312215
1832
- void ToggleSpeakerMocap()
2216
+ public void ToggleSpeakerMocap()
18332217 {
18342218 SPEAKERMOCAP ^= true;
18352219 }
18362220
1837
- void ToggleSpeakerCamera()
2221
+ public void ToggleSpeakerCamera()
18382222 {
18392223 SPEAKERCAMERA ^= true;
18402224 }
18412225
1842
- void ToggleSpeakerFocus()
2226
+ public void ToggleSpeakerFocus()
18432227 {
18442228 SPEAKERFOCUS ^= true;
18452229 }
18462230
1847
- void ToggleDebug()
1848
- {
1849
- DEBUG ^= true;
1850
- }
1851
-
1852
- void ToggleFrustum()
2231
+ public void ToggleFrustum()
18532232 {
18542233 FRUSTUM ^= true;
18552234 }
18562235
1857
- void ToggleTrack()
2236
+ public void ToggleTrack()
18582237 {
18592238 TRACK ^= true;
18602239 if (TRACK)
....@@ -1873,25 +2252,35 @@
18732252 repaint();
18742253 }
18752254
1876
- void ToggleTrackOnce()
2255
+ public void ToggleTrackOnce()
18772256 {
18782257 TRACKONCE ^= true;
18792258 }
18802259
1881
- void ToggleShadowTrack()
2260
+ public void ToggleShadowTrack()
18822261 {
18832262 SHADOWTRACK ^= true;
18842263 repaint();
18852264 }
18862265
1887
- void ToggleOeil()
2266
+ public void ToggleOeil()
18882267 {
18892268 OEIL ^= true;
18902269 }
18912270
1892
- void ToggleOeilOnce()
2271
+ public void ToggleOeilOnce()
18932272 {
18942273 OEILONCE ^= true;
2274
+ }
2275
+
2276
+ void ToggleFootContact()
2277
+ {
2278
+ FOOTCONTACT ^= true;
2279
+ }
2280
+
2281
+ void ToggleDebug()
2282
+ {
2283
+ Globals.DEBUG ^= true;
18952284 }
18962285
18972286 void ToggleLookAt()
....@@ -1899,9 +2288,9 @@
18992288 LOOKAT ^= true;
19002289 }
19012290
1902
- void ToggleRandom()
2291
+ void ToggleSwitch()
19032292 {
1904
- RANDOM ^= true;
2293
+ SWITCH ^= true;
19052294 }
19062295
19072296 void ToggleHandles()
....@@ -1909,10 +2298,17 @@
19092298 HANDLES ^= true;
19102299 }
19112300
2301
+ Object3D paintFolder;
2302
+
19122303 void TogglePaint()
19132304 {
19142305 PAINTMODE ^= true;
19152306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
19162312 }
19172313
19182314 void SwapCamera(int a, int b)
....@@ -2008,7 +2404,7 @@
20082404 {
20092405 return currentGL;
20102406 }
2011
-
2407
+
20122408 /**/
20132409 class CacheTexture
20142410 {
....@@ -3840,6 +4236,7 @@
38404236
38414237 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
38424238 {
4239
+ new Exception().printStackTrace();
38434240 System.exit(0);
38444241 com.sun.opengl.util.texture.Texture texture = null;
38454242
....@@ -7533,7 +7930,7 @@
75337930 String pigment = Object3D.GetPigment(tex);
75347931 String bump = Object3D.GetBump(tex);
75357932
7536
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7933
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
75377934 {
75387935 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
75397936 // System.out.println("; bump = " + bump);
....@@ -7550,6 +7947,64 @@
75507947
75517948 ReleaseTexture(bump, true);
75527949 ReleaseTexture(pigment, false);
7950
+ }
7951
+
7952
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7953
+ {
7954
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7955
+ {
7956
+ return;
7957
+ }
7958
+
7959
+ if (tex == null)
7960
+ {
7961
+ ReleaseTexture(null, false);
7962
+ return;
7963
+ }
7964
+
7965
+ String pigment = Object3D.GetPigment(tex);
7966
+
7967
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7968
+ {
7969
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7970
+ // System.out.println("; bump = " + bump);
7971
+ }
7972
+
7973
+ if (pigment.equals(""))
7974
+ {
7975
+ pigment = null;
7976
+ }
7977
+
7978
+ ReleaseTexture(pigment, false);
7979
+ }
7980
+
7981
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
7982
+ {
7983
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7984
+ {
7985
+ return;
7986
+ }
7987
+
7988
+ if (tex == null)
7989
+ {
7990
+ ReleaseTexture(null, true);
7991
+ return;
7992
+ }
7993
+
7994
+ String bump = Object3D.GetBump(tex);
7995
+
7996
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7997
+ {
7998
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7999
+ // System.out.println("; bump = " + bump);
8000
+ }
8001
+
8002
+ if (bump.equals(""))
8003
+ {
8004
+ bump = null;
8005
+ }
8006
+
8007
+ ReleaseTexture(bump, true);
75538008 }
75548009
75558010 void ReleaseTexture(String tex, boolean bump)
....@@ -7655,7 +8110,7 @@
76558110 }
76568111 }
76578112
7658
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8113
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
76598114 {
76608115 if (// DrawMode() != 0 || /*tex == null ||*/
76618116 ambientOcclusion ) // || !textureon)
....@@ -7676,7 +8131,7 @@
76768131 usedtextures.put(pigment, pigment);
76778132 usedtextures.put(bump, bump);
76788133
7679
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8134
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
76808135 {
76818136 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
76828137 // System.out.println("; bump = " + bump);
....@@ -7700,7 +8155,94 @@
77008155 return; // true;
77018156 }
77028157
7703
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8158
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8159
+ {
8160
+ if (// DrawMode() != 0 || /*tex == null ||*/
8161
+ ambientOcclusion ) // || !textureon)
8162
+ {
8163
+ return; // false;
8164
+ }
8165
+
8166
+ if (tex == null)
8167
+ {
8168
+ BindTexture(null,false,resolution);
8169
+ return;
8170
+ }
8171
+
8172
+ String pigment = Object3D.GetPigment(tex);
8173
+
8174
+ usedtextures.put(pigment, pigment);
8175
+
8176
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8177
+ {
8178
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8179
+ // System.out.println("; bump = " + bump);
8180
+ }
8181
+
8182
+ if (pigment.equals(""))
8183
+ {
8184
+ pigment = null;
8185
+ }
8186
+
8187
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8188
+ BindTexture(pigment, false, resolution);
8189
+ }
8190
+
8191
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8192
+ {
8193
+ if (// DrawMode() != 0 || /*tex == null ||*/
8194
+ ambientOcclusion ) // || !textureon)
8195
+ {
8196
+ return; // false;
8197
+ }
8198
+
8199
+ if (tex == null)
8200
+ {
8201
+ BindTexture(null,true,resolution);
8202
+ return;
8203
+ }
8204
+
8205
+ String bump = Object3D.GetBump(tex);
8206
+
8207
+ usedtextures.put(bump, bump);
8208
+
8209
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8210
+ {
8211
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8212
+ // System.out.println("; bump = " + bump);
8213
+ }
8214
+
8215
+ if (bump.equals(""))
8216
+ {
8217
+ bump = null;
8218
+ }
8219
+
8220
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8221
+ BindTexture(bump, true, resolution);
8222
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8223
+ }
8224
+
8225
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8226
+
8227
+ private boolean FileExists(String tex)
8228
+ {
8229
+ if (missingTextures.contains(tex))
8230
+ {
8231
+ return false;
8232
+ }
8233
+
8234
+ boolean fileExists = new File(tex).exists();
8235
+
8236
+ if (!fileExists)
8237
+ {
8238
+ // If file exists, the "new File()" is not executed sgain
8239
+ missingTextures.add(tex);
8240
+ }
8241
+
8242
+ return fileExists;
8243
+ }
8244
+
8245
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
77048246 {
77058247 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
77068248
....@@ -7708,12 +8250,18 @@
77088250 {
77098251 String texname = tex;
77108252
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;
8253
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8254
+
8255
+// String[] split = tex.split("Textures");
8256
+// if (split.length > 1)
8257
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8258
+// else
8259
+// if (!texname.startsWith("/"))
8260
+// texname = "/Users/nbriere/Textures/" + texname;
8261
+ if (!FileExists(tex))
8262
+ {
8263
+ texname = fallbackTextureName;
8264
+ }
77178265
77188266 if (CACHETEXTURE)
77198267 texture = textures.get(texname); // TEXTURE CACHE
....@@ -7782,7 +8330,7 @@
77828330 }
77838331
77848332 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
7785
- if (!new File(cachename).exists())
8333
+ if (!FileExists(cachename))
77868334 cachename = texname;
77878335 else
77888336 processbump = false; // don't process bump map again
....@@ -7804,7 +8352,7 @@
78048352 }
78058353
78068354 cachename = texname.substring(0, texname.length()-4)+ext+".png";
7807
- if (!new File(cachename).exists())
8355
+ if (!FileExists(cachename))
78088356 cachename = texname;
78098357 else
78108358 processbump = false; // don't process bump map again
....@@ -7813,7 +8361,9 @@
78138361 texturedata = GetFileTexture(cachename, processbump, resolution);
78148362
78158363
7816
- if (texturedata != null)
8364
+ if (texturedata == null)
8365
+ throw new Exception();
8366
+
78178367 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
78188368 //texture = GetTexture(tex, bump);
78198369 }
....@@ -7935,7 +8485,7 @@
79358485 return texture;
79368486 }
79378487
7938
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8488
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
79398489 {
79408490 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
79418491
....@@ -7953,21 +8503,21 @@
79538503 return texture!=null?texture.texture:null;
79548504 }
79558505
7956
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8506
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
79578507 {
79588508 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
79598509
79608510 return texture!=null?texture.texturedata:null;
79618511 }
79628512
7963
- boolean BindTexture(String tex, boolean bump, int resolution)
8513
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
79648514 {
79658515 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
79668516 {
79678517 return false;
79688518 }
79698519
7970
- boolean newtex = false;
8520
+ //boolean newtex = false;
79718521
79728522 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
79738523
....@@ -7999,7 +8549,7 @@
79998549 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
80008550 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
80018551
8002
- return newtex;
8552
+ return true; // Warning: not used.
80038553 }
80048554
80058555 ShadowBuffer shadowPBuf;
....@@ -8837,11 +9387,35 @@
88379387 jy8[3] = 0.5f;
88389388 }
88399389
8840
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9390
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
88419391 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
88429392 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
88439393 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
88449394
9395
+ void ResetOptions()
9396
+ {
9397
+ options1[0] = 100;
9398
+ options1[1] = 0.025f;
9399
+ options1[2] = 0.01f;
9400
+ options1[3] = 0;
9401
+ options1[4] = 0;
9402
+
9403
+ options2[0] = 0;
9404
+ options2[1] = 0.75f;
9405
+ options2[2] = 0;
9406
+ options2[3] = 0;
9407
+
9408
+ options3[0] = 1;
9409
+ options3[1] = 1;
9410
+ options3[2] = 1;
9411
+ options3[3] = 0;
9412
+
9413
+ options4[0] = 1;
9414
+ options4[1] = 0;
9415
+ options4[2] = 1;
9416
+ options4[3] = 0;
9417
+ }
9418
+
88459419 static int imagecount = 0; // movie generation
88469420
88479421 static int jitter = 0;
....@@ -8937,8 +9511,8 @@
89379511 assert (parentcam != renderCamera);
89389512
89399513 if (renderCamera != lightCamera)
8940
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8941
- LA.matConcat(matrix, parentcam.toParent, matrix);
9514
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9515
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
89429516
89439517 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
89449518
....@@ -8953,8 +9527,8 @@
89539527 LA.matCopy(renderCamera.fromScreen, matrix);
89549528
89559529 if (renderCamera != lightCamera)
8956
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8957
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9530
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9531
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
89589532
89599533 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
89609534
....@@ -9026,7 +9600,7 @@
90269600 //gl.glFlush();
90279601 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
90289602
9029
- if (ANIMATION && ABORTED)
9603
+ if (Globals.ANIMATION && ABORTED)
90309604 {
90319605 System.err.println(" ABORTED FRAME");
90329606 break;
....@@ -9056,7 +9630,7 @@
90569630 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
90579631
90589632 // save image
9059
- if (ANIMATION && !ABORTED)
9633
+ if (Globals.ANIMATION && !ABORTED)
90609634 {
90619635 VPwidth = viewport[2];
90629636 VPheight = viewport[3];
....@@ -9167,11 +9741,11 @@
91679741
91689742 // imagecount++;
91699743
9170
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9744
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
91719745
91729746 if (!BOXMODE)
91739747 {
9174
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9748
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
91759749 }
91769750
91779751 if (!BOXMODE)
....@@ -9209,7 +9783,7 @@
92099783 ABORTED = false;
92109784 }
92119785 else
9212
- GrafreeD.wav.cursor += 735 * ACSIZE;
9786
+ Grafreed.wav.cursor += 735 * ACSIZE;
92139787
92149788 if (false)
92159789 {
....@@ -9872,11 +10446,11 @@
987210446
987310447 public void display(GLAutoDrawable drawable)
987410448 {
9875
- if (GrafreeD.savesound && GrafreeD.hassound)
10449
+ if (Grafreed.savesound && Grafreed.hassound)
987610450 {
9877
- GrafreeD.wav.save();
9878
- GrafreeD.savesound = false;
9879
- GrafreeD.hassound = false;
10451
+ Grafreed.wav.save();
10452
+ Grafreed.savesound = false;
10453
+ Grafreed.hassound = false;
988010454 }
988110455 // if (DEBUG_SELECTION)
988210456 // {
....@@ -9952,6 +10526,7 @@
995210526 ANTIALIAS = 0;
995310527 //System.out.println("RESTART");
995410528 AAtimer.restart();
10529
+ Globals.TIMERRUNNING = true;
995510530 }
995610531 }
995710532 }
....@@ -10006,7 +10581,7 @@
1000610581 Object3D theobject = object;
1000710582 Object3D theparent = object.parent;
1000810583 object.parent = null;
10009
- object = (Object3D)GrafreeD.clone(object);
10584
+ object = (Object3D)Grafreed.clone(object);
1001010585 object.Stripify();
1001110586 if (theobject.selection == null || theobject.selection.Size() == 0)
1001210587 theobject.PreprocessOcclusion(this);
....@@ -10019,13 +10594,14 @@
1001910594 ambientOcclusion = false;
1002010595 }
1002110596
10022
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10597
+ if (//Globals.lighttouched &&
10598
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1002310599 {
1002410600 //if (RENDERSHADOW) // ?
1002510601 if (!IsFrozen())
1002610602 {
1002710603 // dec 2012
10028
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10604
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1002910605 {
1003010606 Globals.framecount++;
1003110607 shadowbuffer.display();
....@@ -10152,8 +10728,8 @@
1015210728
1015310729 // if (parentcam != renderCamera) // not a light
1015410730 if (cam != lightCamera)
10155
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10156
- LA.matConcat(matrix, parentcam.toParent, matrix);
10731
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10732
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1015710733
1015810734 for (int j = 0; j < 4; j++)
1015910735 {
....@@ -10167,8 +10743,8 @@
1016710743
1016810744 // if (parentcam != renderCamera) // not a light
1016910745 if (cam != lightCamera)
10170
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10171
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10746
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10747
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1017210748
1017310749 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1017410750
....@@ -10427,7 +11003,16 @@
1042711003 // Bump noise
1042811004 gl.glActiveTexture(GL.GL_TEXTURE6);
1042911005 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10430
- BindTexture(NOISE_TEXTURE, false, 2);
11006
+
11007
+ try
11008
+ {
11009
+ BindTexture(NOISE_TEXTURE, false, 2);
11010
+ }
11011
+ catch (Exception e)
11012
+ {
11013
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11014
+ }
11015
+
1043111016
1043211017 gl.glActiveTexture(GL.GL_TEXTURE0);
1043311018 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10450,9 +11035,9 @@
1045011035
1045111036 gl.glMatrixMode(GL.GL_MODELVIEW);
1045211037
10453
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10454
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10455
-//gl.glEnable(gl.GL_MULTISAMPLE);
11038
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11039
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11040
+gl.glEnable(gl.GL_MULTISAMPLE);
1045611041 } else
1045711042 {
1045811043 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10463,7 +11048,7 @@
1046311048 //System.out.println("BLENDING ON");
1046411049 gl.glEnable(GL.GL_BLEND);
1046511050 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10466
-
11051
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1046711052 gl.glMatrixMode(gl.GL_PROJECTION);
1046811053 gl.glLoadIdentity();
1046911054
....@@ -10552,8 +11137,8 @@
1055211137 System.err.println("parentcam != renderCamera");
1055311138
1055411139 // if (cam != lightCamera)
10555
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10556
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11140
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11141
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1055711142 }
1055811143
1055911144 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10574,8 +11159,8 @@
1057411159 if (true) // TODO
1057511160 {
1057611161 if (cam != lightCamera)
10577
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10578
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11162
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11163
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1057911164 }
1058011165
1058111166 LA.xformPos(light0, cam.toScreen, light0);
....@@ -10891,8 +11476,14 @@
1089111476 {
1089211477 renderpass++;
1089311478 // System.out.println("Draw object... ");
11479
+ STEP = 1;
1089411480 if (FAST) // in case there is no script
10895
- STEP = 16;
11481
+ STEP = 8;
11482
+
11483
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11484
+ {
11485
+ STEP *= 4;
11486
+ }
1089611487
1089711488 //object.FullInvariants();
1089811489
....@@ -10906,23 +11497,44 @@
1090611497 e.printStackTrace();
1090711498 }
1090811499
10909
- if (GrafreeD.RENDERME > 0)
10910
- GrafreeD.RENDERME--; // mechante magouille
11500
+ if (Grafreed.RENDERME > 0)
11501
+ Grafreed.RENDERME--; // mechante magouille
1091111502
1091211503 Globals.ONESTEP = false;
1091311504 }
1091411505
1091511506 static boolean zoomonce = false;
1091611507
11508
+ static void CreateSelectedPoint()
11509
+ {
11510
+ if (selectedpoint == null)
11511
+ {
11512
+ debugpointG = new Sphere();
11513
+ debugpointP = new Sphere();
11514
+ debugpointC = new Sphere();
11515
+ debugpointR = new Sphere();
11516
+
11517
+ selectedpoint = new Superellipsoid();
11518
+
11519
+ for (int i=0; i<8; i++)
11520
+ {
11521
+ debugpoints[i] = new Sphere();
11522
+ }
11523
+ }
11524
+ }
11525
+
1091711526 void DrawObject(GL gl, boolean draw)
1091811527 {
11528
+ // To clear camera values
11529
+ ResetOptions();
11530
+
1091911531 //System.out.println("DRAW OBJECT " + mouseDown);
1092011532 // DrawMode() = SELECTION;
1092111533 //GL gl = getGL();
1092211534 if ((TRACK || SHADOWTRACK) || zoomonce)
1092311535 {
1092411536 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
10925
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11537
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1092611538 pingthread.StepToTarget(true); // true);
1092711539 // zoomonce = false;
1092811540 }
....@@ -10977,7 +11589,14 @@
1097711589
1097811590 usedtextures.clear();
1097911591
10980
- BindTextures(DEFAULT_TEXTURES, 2);
11592
+ try
11593
+ {
11594
+ BindTextures(DEFAULT_TEXTURES, 2);
11595
+ }
11596
+ catch (Exception e)
11597
+ {
11598
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11599
+ }
1098111600 }
1098211601 //System.out.println("--> " + stackdepth);
1098311602 // GrafreeD.traceon();
....@@ -10987,8 +11606,9 @@
1098711606
1098811607 if (DrawMode() == DEFAULT)
1098911608 {
10990
- if (DEBUG)
11609
+ if (Globals.DEBUG)
1099111610 {
11611
+ CreateSelectedPoint();
1099211612 float radius = 0.05f;
1099311613 if (selectedpoint.radius != radius)
1099411614 {
....@@ -11068,7 +11688,14 @@
1106811688 if (checker != null && DrawMode() == DEFAULT)
1106911689 {
1107011690 //BindTexture(IMMORTAL_TEXTURE);
11071
- BindTextures(checker.GetTextures(), checker.texres);
11691
+ try
11692
+ {
11693
+ BindTextures(checker.GetTextures(), checker.texres);
11694
+ }
11695
+ catch (Exception e)
11696
+ {
11697
+ System.err.println("FAILED: " + checker.GetTextures());
11698
+ }
1107211699 // NEAREST
1107311700 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1107411701 DrawChecker(gl);
....@@ -11150,7 +11777,7 @@
1115011777 return;
1115111778 }
1115211779
11153
- String string = obj.GetToolTip();
11780
+ String string = obj.toString(); //.GetToolTip();
1115411781
1115511782 GL gl = GetGL();
1115611783
....@@ -11467,8 +12094,8 @@
1146712094 //obj.TransformToWorld(light, light);
1146812095 for (int i = tp.size(); --i >= 0;)
1146912096 {
11470
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11471
- LA.xformPos(light, tp.get(i).toParent, light);
12097
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12098
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1147212099 }
1147312100
1147412101
....@@ -11485,8 +12112,8 @@
1148512112 parentcam = cameras[0];
1148612113 }
1148712114
11488
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11489
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12115
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12116
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1149012117
1149112118 LA.xformPos(light, renderCamera.toScreen, light);
1149212119
....@@ -12100,8 +12727,8 @@
1210012727
1210112728 // display shadow only (bump == 0)
1210212729 "SUB temp.x, half.x, shadow.x;" +
12103
- "MOV temp.y, -params6.x;" +
12104
- "SLT temp.z, temp.y, zero.x;" +
12730
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12731
+ "SLT temp.z, temp.y, -one2048th.x;" +
1210512732 "SUB temp.y, one.x, temp.z;" +
1210612733 "MUL temp.x, temp.x, temp.y;" +
1210712734 "KIL temp.x;" +
....@@ -12230,8 +12857,10 @@
1223012857 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1223112858
1223212859 "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
12860
+ // Tuning for default skin
12861
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12862
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12863
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1223512864 "MUL temp.x, temp.x, temp.y;" +
1223612865
1223712866 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12430,7 +13059,7 @@
1243013059 //once = true;
1243113060 }
1243213061
12433
- System.out.print("Program #" + mode + "; length = " + program.length());
13062
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1243413063 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1243513064 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1243613065
....@@ -12563,12 +13192,16 @@
1256313192
1256413193 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1256513194 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13195
+
13196
+ // Compare fragment depth in light space with shadowmap.
1256613197 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1256713198 "SGE temp.y, temp.x, zero.x;" +
12568
- "SUB " + shadow + ".y, one.x, temp.y;" +
13199
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13200
+
13201
+ // Reverse comparison
1256913202 "SUB temp.x, one.x, temp.x;" +
1257013203 "MUL " + shadow + ".x, temp.x, temp.y;" +
12571
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13204
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1257213205 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1257313206
1257413207 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12582,6 +13215,10 @@
1258213215 // No shadow for backface
1258313216 "DP3 temp.x, normal, lightd;" +
1258413217 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13218
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13219
+
13220
+ // No shadow when out of frustrum
13221
+ "SGE temp.x, " + depth + ".z, one.z;" +
1258513222 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1258613223 "";
1258713224 }
....@@ -12728,7 +13365,8 @@
1272813365 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1272913366 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1273013367 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
12731
- Object3D.cVector2[] vector2buffer;
13368
+
13369
+ //Object3D.cVector2[] vector2buffer;
1273213370
1273313371 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1273413372 // OUT : diff, spec
....@@ -12744,9 +13382,10 @@
1274413382 "DP3 " + dest + ".z," + "normals," + "eye;" +
1274513383 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1274613384 //"MOV " + dest + ".w," + "normal.z;" +
12747
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
12748
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
12749
- //"MOV " + dest + ".z," + "params2.w;" +
13385
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13386
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13387
+
13388
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1275013389 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1275113390 "RCP " + dest + ".w," + dest + ".w;" +
1275213391 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13140,7 +13779,7 @@
1314013779 public void mousePressed(MouseEvent e)
1314113780 {
1314213781 //System.out.println("mousePressed: " + e);
13143
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13782
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1314413783 }
1314513784
1314613785 static long prevtime = 0;
....@@ -13167,6 +13806,7 @@
1316713806
1316813807 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1316913808
13809
+ if (BUTTONLESSWHEEL)
1317013810 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1317113811 {
1317213812 return;
....@@ -13175,7 +13815,7 @@
1317513815 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1317613816
1317713817 // TIMER
13178
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
13818
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1317913819 {
1318013820 keepboxmode = BOXMODE;
1318113821 keepsupport = SUPPORT;
....@@ -13215,8 +13855,8 @@
1321513855 // mode |= META;
1321613856 //}
1321713857
13218
- SetMouseMode(WHEEL | e.getModifiersEx());
13219
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13858
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13859
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1322013860 anchorX = ax;
1322113861 anchorY = ay;
1322213862 prevX = px;
....@@ -13250,6 +13890,7 @@
1325013890 else
1325113891 if (evt.getSource() == AAtimer)
1325213892 {
13893
+ Globals.TIMERRUNNING = false;
1325313894 if (mouseDown)
1325413895 {
1325513896 //new Exception().printStackTrace();
....@@ -13275,6 +13916,10 @@
1327513916 // LIVE = waslive;
1327613917 // wasliveok = true;
1327713918 // waslive = false;
13919
+
13920
+ // May 2019 Forget it:
13921
+ if (true)
13922
+ return;
1327813923
1327913924 // source == timer
1328013925 if (mouseDown)
....@@ -13305,7 +13950,7 @@
1330513950
1330613951 // fev 2014???
1330713952 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13308
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13953
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1330913954 pingthread.StepToTarget(true); // true);
1331013955 }
1331113956 // if (!LIVE)
....@@ -13314,12 +13959,13 @@
1331413959
1331513960 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1331613961
13317
- void clickStart(int x, int y, int modifiers)
13962
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1331813963 {
1331913964 if (!wasliveok)
1332013965 return;
1332113966
1332213967 AAtimer.restart(); //
13968
+ Globals.TIMERRUNNING = true;
1332313969
1332413970 // waslive = LIVE;
1332513971 // LIVE = false;
....@@ -13331,7 +13977,7 @@
1333113977 // touched = true; // main DL
1333213978 if (isRenderer)
1333313979 {
13334
- SetMouseMode(modifiers);
13980
+ SetMouseMode(modifiers, modifiersex);
1333513981 }
1333613982
1333713983 selectX = anchorX = x;
....@@ -13344,7 +13990,7 @@
1334413990 clicked = true;
1334513991 hold = false;
1334613992
13347
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13993
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1334813994 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1334913995 {
1335013996 // System.out.println("RESTART II " + modifiers);
....@@ -13375,7 +14021,7 @@
1337514021 info.camera = renderCamera;
1337614022 info.x = x;
1337714023 info.y = y;
13378
- info.modifiers = modifiers;
14024
+ info.modifiers = modifiersex;
1337914025 editObj = object.doEditClick(info, 0);
1338014026 if (!editObj)
1338114027 {
....@@ -13392,11 +14038,14 @@
1339214038
1339314039 public void mouseDragged(MouseEvent e)
1339414040 {
14041
+ Globals.MOUSEDRAGGED = true;
14042
+
14043
+ //System.out.println("mouseDragged: " + e);
1339514044 if (isRenderer)
1339614045 movingcamera = true;
14046
+
1339714047 //if (drawing)
1339814048 //return;
13399
- //System.out.println("mouseDragged: " + e);
1340014049 if ((e.getModifiersEx() & CTRL) != 0
1340114050 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1340214051 {
....@@ -13404,7 +14053,7 @@
1340414053 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1340514054 }
1340614055 else
13407
- drag(e.getX(), e.getY(), e.getModifiersEx());
14056
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1340814057
1340914058 //try { Thread.sleep(1); } catch (Exception ex) {}
1341014059 }
....@@ -13577,6 +14226,7 @@
1357714226
1357814227 public void run()
1357914228 {
14229
+ new Exception().printStackTrace();
1358014230 System.exit(0);
1358114231 for (;;)
1358214232 {
....@@ -13640,7 +14290,7 @@
1364014290 {
1364114291 Globals.lighttouched = true;
1364214292 }
13643
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14293
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1364414294 }
1364514295 //else
1364614296 }
....@@ -13654,12 +14304,12 @@
1365414304 void GoDown(int mod)
1365514305 {
1365614306 MODIFIERS |= COMMAND;
13657
- /*
14307
+ /**/
1365814308 if((mod&SHIFT) == SHIFT)
1365914309 manipCamera.RotatePosition(0, -speed);
1366014310 else
13661
- manipCamera.BackForth(0, -speed*delta, getWidth());
13662
- */
14311
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14312
+ /**/
1366314313 if ((mod & SHIFT) == SHIFT)
1366414314 {
1366514315 mouseMode = mouseMode; // VR??
....@@ -13675,12 +14325,12 @@
1367514325 void GoUp(int mod)
1367614326 {
1367714327 MODIFIERS |= COMMAND;
13678
- /*
14328
+ /**/
1367914329 if((mod&SHIFT) == SHIFT)
1368014330 manipCamera.RotatePosition(0, speed);
1368114331 else
13682
- manipCamera.BackForth(0, speed*delta, getWidth());
13683
- */
14332
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14333
+ /**/
1368414334 if ((mod & SHIFT) == SHIFT)
1368514335 {
1368614336 mouseMode = mouseMode;
....@@ -13696,12 +14346,12 @@
1369614346 void GoLeft(int mod)
1369714347 {
1369814348 MODIFIERS |= COMMAND;
13699
- /*
14349
+ /**/
1370014350 if((mod&SHIFT) == SHIFT)
13701
- manipCamera.RotatePosition(speed, 0);
13702
- else
1370314351 manipCamera.Translate(speed*delta, 0, getWidth());
13704
- */
14352
+ else
14353
+ manipCamera.RotatePosition(speed, 0);
14354
+ /**/
1370514355 if ((mod & SHIFT) == SHIFT)
1370614356 {
1370714357 mouseMode = mouseMode;
....@@ -13717,12 +14367,12 @@
1371714367 void GoRight(int mod)
1371814368 {
1371914369 MODIFIERS |= COMMAND;
13720
- /*
14370
+ /**/
1372114371 if((mod&SHIFT) == SHIFT)
13722
- manipCamera.RotatePosition(-speed, 0);
13723
- else
1372414372 manipCamera.Translate(-speed*delta, 0, getWidth());
13725
- */
14373
+ else
14374
+ manipCamera.RotatePosition(-speed, 0);
14375
+ /**/
1372614376 if ((mod & SHIFT) == SHIFT)
1372714377 {
1372814378 mouseMode = mouseMode;
....@@ -13740,7 +14390,7 @@
1374014390 int X, Y;
1374114391 boolean SX, SY;
1374214392
13743
- void drag(int x, int y, int modifiers)
14393
+ void drag(int x, int y, int modifiers, int modifiersex)
1374414394 {
1374514395 if (IsFrozen())
1374614396 {
....@@ -13749,17 +14399,17 @@
1374914399
1375014400 drag = true; // NEW
1375114401
13752
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14402
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1375314403
1375414404 X = x;
1375514405 Y = y;
1375614406 // floating state for animation
13757
- MODIFIERS = modifiers;
13758
- modifiers &= ~1024;
14407
+ MODIFIERS = modifiersex;
14408
+ modifiersex &= ~1024;
1375914409 if (false) // modifiers != 0)
1376014410 {
1376114411 //new Exception().printStackTrace();
13762
- System.out.println("mouseDragged: " + modifiers);
14412
+ System.out.println("mouseDragged: " + modifiersex);
1376314413 System.out.println("SHIFT = " + SHIFT);
1376414414 System.out.println("CONTROL = " + COMMAND);
1376514415 System.out.println("META = " + META);
....@@ -13779,7 +14429,8 @@
1377914429 info.camera = renderCamera;
1378014430 info.x = x;
1378114431 info.y = y;
13782
- object.editWindow.copy.doEditDrag(info);
14432
+ object.GetWindow().copy
14433
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1378314434 } else
1378414435 {
1378514436 if (x < startX)
....@@ -13931,7 +14582,6 @@
1393114582 public void mouseMoved(MouseEvent e)
1393214583 {
1393314584 //System.out.println("mouseMoved: " + e);
13934
-
1393514585 if (isRenderer)
1393614586 return;
1393714587
....@@ -13944,7 +14594,9 @@
1394414594 ci.camera = renderCamera;
1394514595 if (!isRenderer)
1394614596 {
13947
- if (object.editWindow.copy.doEditClick(ci, 0))
14597
+ //ObjEditor editWindow = object.editWindow;
14598
+ //Object3D copy = editWindow.copy;
14599
+ if (object.doEditClick(ci, 0))
1394814600 {
1394914601 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1395014602 } else
....@@ -13956,7 +14608,11 @@
1395614608
1395714609 public void mouseReleased(MouseEvent e)
1395814610 {
14611
+ Globals.MOUSEDRAGGED = false;
14612
+
1395914613 movingcamera = false;
14614
+ X = 0; // getBounds().width/2;
14615
+ Y = 0; // getBounds().height/2;
1396014616 //System.out.println("mouseReleased: " + e);
1396114617 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1396214618 }
....@@ -13979,9 +14635,9 @@
1397914635 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1398014636 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1398114637
13982
- if (control || command || IsFrozen())
14638
+// No delay if (control || command || IsFrozen())
1398314639 timeout = true;
13984
- else
14640
+// ?? May 2019 else
1398514641 // timer.setDelay((modifiers & 128) != 0?0:350);
1398614642 mouseDown = false;
1398714643 if (!control && !command) // june 2013
....@@ -14091,7 +14747,7 @@
1409114747 System.out.println("keyReleased: " + e);
1409214748 }
1409314749
14094
- void SetMouseMode(int modifiers)
14750
+ void SetMouseMode(int modifiers, int modifiersex)
1409514751 {
1409614752 //System.out.println("SetMouseMode = " + modifiers);
1409714753 //modifiers &= ~1024;
....@@ -14103,25 +14759,25 @@
1410314759 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1410414760 // return;
1410514761 //System.out.println("SetMode = " + modifiers);
14106
- if ((modifiers & WHEEL) == WHEEL)
14762
+ if ((modifiersex & WHEEL) == WHEEL)
1410714763 {
1410814764 mouseMode |= ZOOM;
1410914765 }
1411014766
1411114767 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14112
- if (capsLocked || (modifiers & META) == META)
14768
+ if (capsLocked) // || (modifiers & META) == META)
1411314769 {
1411414770 mouseMode |= VR; // BACKFORTH;
1411514771 }
14116
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14772
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1411714773 {
1411814774 mouseMode |= SELECT;
1411914775 }
14120
- if ((modifiers & COMMAND) == COMMAND)
14776
+ if ((modifiersex & COMMAND) == COMMAND)
1412114777 {
1412214778 mouseMode |= SELECT;
1412314779 }
14124
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14780
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1412514781 {
1412614782 mouseMode &= ~VR;
1412714783 mouseMode |= TRANSLATE;
....@@ -14150,10 +14806,10 @@
1415014806
1415114807 if (isRenderer) //
1415214808 {
14153
- SetMouseMode(modifiers);
14809
+ SetMouseMode(0, modifiers);
1415414810 }
1415514811
14156
- theRenderer.keyPressed(key);
14812
+ Globals.theRenderer.keyPressed(key);
1415714813 }
1415814814
1415914815 int kompactbit = 4; // power bit
....@@ -14165,7 +14821,7 @@
1416514821 float SATPOW = 1; // 2; // 0.5f;
1416614822 float BRIPOW = 1; // 0.5f; // 0.5f;
1416714823
14168
- void keyPressed(int key)
14824
+ public void keyPressed(int key)
1416914825 {
1417014826 if (key >= '0' && key <= '5')
1417114827 clampbit = (key-'0');
....@@ -14297,7 +14953,9 @@
1429714953 case 'E' : COMPACT ^= true;
1429814954 repaint();
1429914955 break;
14300
- case 'W' : DEBUGHSB ^= true;
14956
+ case 'W' : // Wide Window (fullscreen)
14957
+ //DEBUGHSB ^= true;
14958
+ ObjEditor.theFrame.ToggleFullScreen();
1430114959 repaint();
1430214960 break;
1430314961 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14322,8 +14980,8 @@
1432214980 RevertCamera();
1432314981 repaint();
1432414982 break;
14325
- case 'L':
1432614983 case 'l':
14984
+ //case 'L':
1432714985 if (lightMode)
1432814986 {
1432914987 lightMode = false;
....@@ -14466,9 +15124,9 @@
1446615124 case '_':
1446715125 kompactbit = 5;
1446815126 break;
14469
- case '+':
14470
- kompactbit = 6;
14471
- break;
15127
+// case '+':
15128
+// kompactbit = 6;
15129
+// break;
1447215130 case ' ':
1447315131 lightMode ^= true;
1447415132 Globals.lighttouched = true;
....@@ -14480,13 +15138,14 @@
1448015138 case ESC:
1448115139 RENDERPROGRAM += 1;
1448215140 RENDERPROGRAM %= 3;
15141
+
1448315142 repaint();
1448415143 break;
1448515144 case 'Z':
1448615145 //RESIZETEXTURE ^= true;
1448715146 //break;
1448815147 case 'z':
14489
- RENDERSHADOW ^= true;
15148
+ Globals.RENDERSHADOW ^= true;
1449015149 Globals.lighttouched = true;
1449115150 repaint();
1449215151 break;
....@@ -14519,8 +15178,9 @@
1451915178 case DELETE:
1452015179 ClearSelection();
1452115180 break;
14522
- /*
1452315181 case '+':
15182
+
15183
+ /*
1452415184 //fontsize += 1;
1452515185 bbzoom *= 2;
1452615186 repaint();
....@@ -14537,17 +15197,17 @@
1453715197 case '=':
1453815198 IncDepth();
1453915199 //fontsize += 1;
14540
- object.editWindow.refreshContents(true);
15200
+ object.GetWindow().refreshContents(true);
1454115201 maskbit = 6;
1454215202 break;
1454315203 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1454415204 DecDepth();
1454515205 maskbit = 5;
1454615206 //if(fontsize > 1) fontsize -= 1;
14547
- if (object.editWindow == null)
14548
- new Exception().printStackTrace();
14549
- else
14550
- object.editWindow.refreshContents(true);
15207
+// if (object.editWindow == null)
15208
+// new Exception().printStackTrace();
15209
+// else
15210
+ object.GetWindow().refreshContents(true);
1455115211 break;
1455215212 case '{':
1455315213 manipCamera.shaper_fovy /= 1.1;
....@@ -14602,6 +15262,7 @@
1460215262 }
1460315263 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1460415264 }
15265
+
1460515266 static double OCCLUSIONBOOST = 1; // 0.5;
1460615267
1460715268 void keyReleased(int key, int modifiers)
....@@ -14609,11 +15270,11 @@
1460915270 //mode = ROTATE;
1461015271 if ((MODIFIERS & COMMAND) == 0) // VR??
1461115272 {
14612
- SetMouseMode(modifiers);
15273
+ SetMouseMode(0, modifiers);
1461315274 }
1461415275 }
1461515276
14616
- protected void processKeyEvent(KeyEvent e)
15277
+ public void processKeyEvent(KeyEvent e)
1461715278 {
1461815279 switch (e.getID())
1461915280 {
....@@ -14743,8 +15404,9 @@
1474315404
1474415405 protected void processMouseMotionEvent(MouseEvent e)
1474515406 {
14746
- //System.out.println("processMouseMotionEvent: " + mouseMode);
14747
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15407
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15408
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15409
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1474815410 {
1474915411 mouseMoved(e);
1475015412 } else
....@@ -14769,11 +15431,12 @@
1476915431 }
1477015432 */
1477115433
14772
- object.editWindow.EditSelection();
15434
+ object.GetWindow().EditSelection(false);
1477315435 }
1477415436
1477515437 void SelectParent()
1477615438 {
15439
+ new Exception().printStackTrace();
1477715440 System.exit(0);
1477815441 Composite group = (Composite) object;
1477915442 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -14785,10 +15448,10 @@
1478515448 {
1478615449 //selectees.remove(i);
1478715450 System.out.println("select parent of " + elem);
14788
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15451
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1478915452 } else
1479015453 {
14791
- group.editWindow.Select(elem.GetTreePath(), first, true);
15454
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1479215455 }
1479315456
1479415457 first = false;
....@@ -14797,6 +15460,7 @@
1479715460
1479815461 void SelectChildren()
1479915462 {
15463
+ new Exception().printStackTrace();
1480015464 System.exit(0);
1480115465 /*
1480215466 Composite group = (Composite) object;
....@@ -14829,12 +15493,12 @@
1482915493 for (int j = 0; j < group.children.size(); j++)
1483015494 {
1483115495 elem = (Object3D) group.children.elementAt(j);
14832
- object.editWindow.Select(elem.GetTreePath(), first, true);
15496
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1483315497 first = false;
1483415498 }
1483515499 } else
1483615500 {
14837
- object.editWindow.Select(elem.GetTreePath(), first, true);
15501
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1483815502 }
1483915503
1484015504 first = false;
....@@ -14845,21 +15509,21 @@
1484515509 {
1484615510 //Composite group = (Composite) object;
1484715511 Object3D group = object;
14848
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15512
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1484915513 }
1485015514
1485115515 void ResetTransform(int mask)
1485215516 {
1485315517 //Composite group = (Composite) object;
1485415518 Object3D group = object;
14855
- group.editWindow.ResetTransform(mask);
15519
+ group.GetWindow().ResetTransform(mask);
1485615520 }
1485715521
1485815522 void FlipTransform()
1485915523 {
1486015524 //Composite group = (Composite) object;
1486115525 Object3D group = object;
14862
- group.editWindow.FlipTransform();
15526
+ group.GetWindow().FlipTransform();
1486315527 // group.editWindow.ReduceMesh(true);
1486415528 }
1486515529
....@@ -14867,7 +15531,7 @@
1486715531 {
1486815532 //Composite group = (Composite) object;
1486915533 Object3D group = object;
14870
- group.editWindow.PrintMemory();
15534
+ group.GetWindow().PrintMemory();
1487115535 // group.editWindow.ReduceMesh(true);
1487215536 }
1487315537
....@@ -14875,7 +15539,7 @@
1487515539 {
1487615540 //Composite group = (Composite) object;
1487715541 Object3D group = object;
14878
- group.editWindow.ResetCentroid();
15542
+ group.GetWindow().ResetCentroid();
1487915543 }
1488015544
1488115545 void IncDepth()
....@@ -14961,7 +15625,9 @@
1496115625 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1496215626 //Image img = CreateImage(width, height);
1496315627 //System.out.println("width = " + width + "; height = " + height + "\n");
15628
+
1496415629 Graphics gr = g; // img.getGraphics();
15630
+
1496515631 if (!hasMarquee)
1496615632 {
1496715633 if (Xmin < Xmax) // !locked)
....@@ -15049,6 +15715,7 @@
1504915715 info.bounds.y += (height - desired) / 2;
1505015716 }
1505115717 }
15718
+
1505215719 info.g = gr;
1505315720 info.camera = renderCamera;
1505415721 /*
....@@ -15058,15 +15725,55 @@
1505815725 */
1505915726 if (!isRenderer)
1506015727 {
15061
- object.drawEditHandles(info, 0);
15728
+ Grafreed.Assert(object != null);
15729
+ Grafreed.Assert(object.selection != null);
15730
+ if (object.selection.Size() > 0)
15731
+ {
15732
+ int hitSomething = object.selection.get(0).hitSomething;
15733
+
15734
+ info.DX = 0;
15735
+ info.DY = 0;
15736
+ info.W = 1;
15737
+ if (hitSomething == Object3D.hitCenter)
15738
+ {
15739
+ info.DX = X;
15740
+ if (X != 0)
15741
+ info.DX -= info.bounds.width/2;
15742
+
15743
+ info.DY = Y;
15744
+ if (Y != 0)
15745
+ info.DY -= info.bounds.height/2;
15746
+ }
15747
+
15748
+ object.drawEditHandles(info, 0);
15749
+
15750
+ if (drag && (X != 0 || Y != 0))
15751
+ {
15752
+ switch (hitSomething)
15753
+ {
15754
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15755
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15756
+ break;
15757
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15758
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15759
+ break;
15760
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15761
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15762
+ break;
15763
+ }
15764
+
15765
+ }
15766
+ }
1506215767 }
1506315768 }
15769
+
1506415770 if (isRenderer)
1506515771 {
1506615772 //gr.setColor(Color.black);
1506715773 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1506815774 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1506915775 }
15776
+
1507015777 if (hasMarquee)
1507115778 {
1507215779 gr.setXORMode(Color.white);
....@@ -15179,6 +15886,7 @@
1517915886 public boolean mouseDown(Event evt, int x, int y)
1518015887 {
1518115888 System.out.println("mouseDown: " + evt);
15889
+ System.exit(0);
1518215890 /*
1518315891 locked = true;
1518415892 drag = false;
....@@ -15222,7 +15930,7 @@
1522215930 {
1522315931 keyPressed(0, modifiers);
1522415932 }
15225
- clickStart(x, y, modifiers);
15933
+ // clickStart(x, y, modifiers);
1522615934 return true;
1522715935 }
1522815936
....@@ -15340,7 +16048,7 @@
1534016048 {
1534116049 keyReleased(0, 0);
1534216050 }
15343
- drag(x, y, modifiers);
16051
+ drag(x, y, 0, modifiers);
1534416052 return true;
1534516053 }
1534616054
....@@ -15472,7 +16180,7 @@
1547216180 Object3D object;
1547316181 static Object3D trackedobject;
1547416182 Camera renderCamera; // Light or Eye (or Occlusion)
15475
- /*static*/ Camera manipCamera; // Light or Eye
16183
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1547616184 /*static*/ Camera eyeCamera;
1547716185 /*static*/ Camera lightCamera;
1547816186 int cameracount;
....@@ -15757,16 +16465,16 @@
1575716465 cStatic.objectstack[materialdepth++] = checker;
1575816466 //System.out.println("material " + material);
1575916467 //Applet3D.tracein(this, selected);
15760
- vector2buffer = checker.projectedVertices;
16468
+ //vector2buffer = checker.projectedVertices;
1576116469
1576216470 //checker.GetMaterial().Draw(this, false); // true);
15763
- DrawMaterial(checker.GetMaterial(), false); // true);
16471
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1576416472
1576516473 materialdepth -= 1;
1576616474 if (materialdepth > 0)
1576716475 {
15768
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
15769
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16476
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16477
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1577016478 }
1577116479 //checker.GetMaterial().opacity = 1f;
1577216480 ////checker.GetMaterial().ambient = 1f;
....@@ -15852,6 +16560,14 @@
1585216560 }
1585316561 }
1585416562
16563
+ private Object3D GetFolder()
16564
+ {
16565
+ Object3D folder = object.GetWindow().copy;
16566
+ if (object.GetWindow().copy.selection.Size() > 0)
16567
+ folder = object.GetWindow().copy.selection.elementAt(0);
16568
+ return folder;
16569
+ }
16570
+
1585516571 class SelectBuffer implements GLEventListener
1585616572 {
1585716573
....@@ -15910,6 +16626,7 @@
1591016626 {
1591116627 if (!selection)
1591216628 {
16629
+ new Exception().printStackTrace();
1591316630 System.exit(0);
1591416631 return;
1591516632 }
....@@ -15930,6 +16647,17 @@
1593016647
1593116648 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1593216649
16650
+ if (PAINTMODE)
16651
+ {
16652
+ if (object.GetWindow().copy.selection.Size() > 0)
16653
+ {
16654
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16655
+
16656
+ // Make what you paint not selectable.
16657
+ paintobj.ResetSelectable();
16658
+ }
16659
+ }
16660
+
1593316661 //int tmp = selection_view;
1593416662 //selection_view = -1;
1593516663 int temp = DrawMode();
....@@ -15941,6 +16669,17 @@
1594116669 // temp = DEFAULT; // patch for selection debug
1594216670 Globals.drawMode = temp; // WARNING
1594316671
16672
+ if (PAINTMODE)
16673
+ {
16674
+ if (object.GetWindow().copy.selection.Size() > 0)
16675
+ {
16676
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16677
+
16678
+ // Revert.
16679
+ paintobj.RestoreSelectable();
16680
+ }
16681
+ }
16682
+
1594416683 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1594516684
1594616685 // trying different ways of getting the depth info over
....@@ -15988,6 +16727,8 @@
1598816727 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1598916728 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1599016729 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16730
+
16731
+ CreateSelectedPoint();
1599116732
1599216733 // Will fit the mesh !!!
1599316734 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16037,34 +16778,36 @@
1603716778 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]));
1603816779 }
1603916780
16040
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16781
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1604116782 }
1604216783 }
1604316784
1604416785 if (!movingcamera && !PAINTMODE)
16045
- object.editWindow.ScreenFitPoint(); // fev 2014
16786
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1604616787
16047
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16788
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1604816789 {
16049
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16790
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1605016791
16051
- Object3D group = new Object3D("inst" + paintcount++);
16792
+ if (object.GetWindow().copy.selection.Size() > 0)
16793
+ {
16794
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1605216795
16053
- group.CreateMaterial(); // use a void leaf to select instances
16054
-
16055
- group.add(paintobj); // link
16056
-
16057
- object.editWindow.SnapObject(group);
16058
-
16059
- Object3D folder = object.editWindow.copy;
16060
-
16061
- if (object.editWindow.copy.selection.Size() > 0)
16062
- folder = object.editWindow.copy.selection.elementAt(0);
16063
-
16064
- folder.add(group);
16065
-
16066
- object.editWindow.ResetModel();
16067
- object.editWindow.refreshContents();
16796
+ Object3D inst = new Object3D("inst" + paintcount++);
16797
+
16798
+ inst.CreateMaterial(); // use a void leaf to select instances
16799
+
16800
+ inst.add(paintobj); // link
16801
+
16802
+ object.GetWindow().SnapObject(inst);
16803
+
16804
+ Object3D folder = paintFolder; // GetFolder();
16805
+
16806
+ folder.add(inst);
16807
+
16808
+ object.GetWindow().ResetModel();
16809
+ object.GetWindow().refreshContents();
16810
+ }
1606816811 }
1606916812 else
1607016813 paintcount = 0;
....@@ -16103,6 +16846,11 @@
1610316846 //System.out.println("objects[color] = " + objects[color]);
1610416847 //objects[color].Select();
1610516848 indexcount = 0;
16849
+ ObjEditor window = object.GetWindow();
16850
+ if (window != null && deselect)
16851
+ {
16852
+ window.Select(null, deselect, true);
16853
+ }
1610616854 object.Select(color, deselect);
1610716855 }
1610816856
....@@ -16202,7 +16950,7 @@
1620216950 gl.glDisable(gl.GL_CULL_FACE);
1620316951 }
1620416952
16205
- if (!RENDERSHADOW)
16953
+ if (!Globals.RENDERSHADOW)
1620616954 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1620716955
1620816956 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16212,7 +16960,7 @@
1621216960 //gl.glColorMask(false, false, false, false);
1621316961
1621416962 //render_scene_from_light_view(gl, drawable, 0, 0);
16215
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16963
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1621616964 {
1621716965 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1621816966
....@@ -16628,23 +17376,15 @@
1662817376 int AAbuffersize = 0;
1662917377
1663017378 //double[] selectedpoint = new double[3];
16631
- static Superellipsoid selectedpoint = new Superellipsoid();
17379
+ static Superellipsoid selectedpoint;
1663217380 static Sphere previousselectedpoint = null;
16633
- static Sphere debugpointG = new Sphere();
16634
- static Sphere debugpointP = new Sphere();
16635
- static Sphere debugpointC = new Sphere();
16636
- static Sphere debugpointR = new Sphere();
17381
+ static Sphere debugpointG;
17382
+ static Sphere debugpointP;
17383
+ static Sphere debugpointC;
17384
+ static Sphere debugpointR;
1663717385
1663817386 static Sphere debugpoints[] = new Sphere[8];
1663917387
16640
- static
16641
- {
16642
- for (int i=0; i<8; i++)
16643
- {
16644
- debugpoints[i] = new Sphere();
16645
- }
16646
- }
16647
-
1664817388 static void InitPoints(float radius)
1664917389 {
1665017390 for (int i=0; i<8; i++)
....@@ -16696,10 +17436,11 @@
1669617436 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1669717437 // Depth buffer format
1669817438 //private int depth_format;
16699
- static public void NextIndex(Object3D o, GL gl)
17439
+
17440
+ public void NextIndex()
1670017441 {
1670117442 indexcount+=16;
16702
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17443
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1670317444 //objects[indexcount] = o;
1670417445 //System.out.println("indexcount = " + indexcount);
1670517446 }