Normand Briere
2019-08-12 8f1afe25ea8fc8801aab66331c32a50859a758c2
CameraPane.java
....@@ -18,7 +18,10 @@
1818 import javax.imageio.ImageIO;
1919 import javax.imageio.ImageWriteParam;
2020 import javax.imageio.ImageWriter;
21
+import javax.imageio.ImageReadParam;
22
+import javax.imageio.ImageReader;
2123 import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
24
+import javax.imageio.stream.ImageInputStream;
2225 import javax.imageio.stream.ImageOutputStream;
2326 import javax.imageio.ImageWriteParam;
2427
....@@ -30,6 +33,7 @@
3033 import java.nio.*;
3134
3235 import gleem.linalg.Mat4f;
36
+import javax.imageio.ImageTypeSpecifier;
3337
3438 class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
3539 {
....@@ -37,7 +41,6 @@
3741 static boolean[] selectedstack = new boolean[65536];
3842 static int materialdepth = 0;
3943
40
- static boolean DEBUG = false;
4144 static boolean FRUSTUM = false; // still bogus true; // frustum culling
4245
4346 // camera change fix
....@@ -45,6 +48,39 @@
4548 static boolean ABORTED = false;
4649
4750 static int STEP = 1;
51
+
52
+ private static BufferedImage CreateBim(byte[] bytes, int width, int height)
53
+ {
54
+ int[] pixels = new int[bytes.length/3];
55
+ for (int i=pixels.length; --i>=0;)
56
+ {
57
+ int i3 = i*3;
58
+ pixels[i] = 0xFF;
59
+ pixels[i] <<= 8;
60
+ pixels[i] |= bytes[i3+2] & 0xFF;
61
+ pixels[i] <<= 8;
62
+ pixels[i] |= bytes[i3+1] & 0xFF;
63
+ pixels[i] <<= 8;
64
+ pixels[i] |= bytes[i3] & 0xFF;
65
+ }
66
+ /*
67
+ int r=0,g=0,b=0,a=0;
68
+ for (int i=0; i<width; i++)
69
+ for (int j=0; j<height; j++)
70
+ {
71
+ int index = j*width+i;
72
+ int p = pixels[index];
73
+ a = ((p>>24) & 0xFF);
74
+ r = ((p>>16) & 0xFF);
75
+ g = ((p>>8) & 0xFF);
76
+ b = (p & 0xFF);
77
+ pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
78
+ }
79
+ /**/
80
+ BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
81
+ rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
82
+ return rendImage;
83
+ }
4884
4985 /*static*/ private boolean CULLFACE = false; // true;
5086 /*static*/ boolean NEAREST = false; // true;
....@@ -56,14 +92,12 @@
5692 static int CURRENTANTIALIAS = 0; // 1;
5793 /*static*/ boolean RENDERSHADOW = true;
5894 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
59
- static boolean ANIMATION = false;
60
- static String filename;
6195
6296 boolean DISPLAYTEXT = false;
6397 //boolean REDUCETEXTURE = true;
6498 boolean CACHETEXTURE = true;
6599 boolean CLEANCACHE = false; // true;
66
- boolean MIPMAP = false; // true;
100
+ boolean MIPMAP = false; // true; // never works...
67101 boolean COMPRESSTEXTURE = false;
68102 boolean KOMPACTTEXTURE = false; // true;
69103 boolean RESIZETEXTURE = false;
....@@ -92,6 +126,8 @@
92126
93127 static int tickcount = 0; // slow pose issue
94128
129
+static boolean BUTTONLESSWHEEL = false;
130
+static boolean ZOOMBOXMODE = false;
95131 static boolean BOXMODE = false;
96132 static boolean IMAGEFLIP = false;
97133 static boolean SMOOTHFOCUS = false;
....@@ -106,7 +142,7 @@
106142 static boolean OEIL = true;
107143 static boolean OEILONCE = false; // do oeilon then oeiloff
108144 static boolean LOOKAT = true;
109
-static boolean RANDOM = true; // false;
145
+static boolean SWITCH = true; // false;
110146 static boolean HANDLES = false; // selection doesn't work!!
111147 static boolean PAINTMODE = false;
112148
....@@ -150,6 +186,20 @@
150186 defaultcaps.setAccumAlphaBits(16);
151187 }
152188
189
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
190
+
191
+ public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException
192
+ {
193
+ try
194
+ {
195
+ cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
196
+ } catch (IOException e)
197
+ {
198
+ System.out.println("NAME = " + name);
199
+ e.printStackTrace(); // throw new RuntimeException(e);
200
+ }
201
+ }
202
+
153203 void SetAsGLRenderer(boolean b)
154204 {
155205 isRenderer = b;
....@@ -168,7 +218,8 @@
168218
169219 SetCamera(cam);
170220
171
- SetLight(new Camera(new cVector(10, 10, -20)));
221
+ // Warning: not used.
222
+ SetLight(new Camera(new cVector(15, 10, -20)));
172223
173224 object = o;
174225
....@@ -191,9 +242,43 @@
191242
192243 /// INTERFACE
193244
245
+ public javax.media.opengl.GL GetGL0()
246
+ {
247
+ return null;
248
+ }
249
+
250
+ public int GenList()
251
+ {
252
+ javax.media.opengl.GL gl = GetGL();
253
+ return gl.glGenLists(1);
254
+ }
255
+
256
+ public void NewList(int id)
257
+ {
258
+ javax.media.opengl.GL gl = GetGL();
259
+ gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE);
260
+ }
261
+
262
+ public void CallList(int id)
263
+ {
264
+ javax.media.opengl.GL gl = GetGL();
265
+ gl.glCallList(id);
266
+ }
267
+
268
+ public void EndList()
269
+ {
270
+ javax.media.opengl.GL gl = GetGL();
271
+ gl.glEndList();
272
+ }
273
+
194274 public boolean IsBoxMode()
195275 {
196276 return BOXMODE;
277
+ }
278
+
279
+ public boolean IsZoomBoxMode()
280
+ {
281
+ return ZOOMBOXMODE;
197282 }
198283
199284 public void ClearDepth()
....@@ -291,7 +376,7 @@
291376 cStatic.objectstack[materialdepth++] = obj;
292377 //System.out.println("material " + material);
293378 //Applet3D.tracein(this, selected);
294
- display.vector2buffer = obj.projectedVertices;
379
+ //display.vector2buffer = obj.projectedVertices;
295380 if (obj instanceof Camera)
296381 {
297382 display.options1[0] = material.shift;
....@@ -300,14 +385,28 @@
300385 display.options1[2] = material.shadowbias;
301386 display.options1[3] = material.aniso;
302387 display.options1[4] = material.anisoV;
388
+// System.out.println("display.options1[0] " + display.options1[0]);
389
+// System.out.println("display.options1[1] " + display.options1[1]);
390
+// System.out.println("display.options1[2] " + display.options1[2]);
391
+// System.out.println("display.options1[3] " + display.options1[3]);
392
+// System.out.println("display.options1[4] " + display.options1[4]);
303393 display.options2[0] = material.opacity;
304394 display.options2[1] = material.diffuse;
305395 display.options2[2] = material.factor;
396
+// System.out.println("display.options2[0] " + display.options2[0]);
397
+// System.out.println("display.options2[1] " + display.options2[1]);
398
+// System.out.println("display.options2[2] " + display.options2[2]);
306399
307400 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
401
+// System.out.println("display.options3[0] " + display.options3[0]);
402
+// System.out.println("display.options3[1] " + display.options3[1]);
403
+// System.out.println("display.options3[2] " + display.options3[2]);
308404 display.options4[0] = material.cameralight/0.2f;
309405 display.options4[1] = material.subsurface;
310406 display.options4[2] = material.sheen;
407
+// System.out.println("display.options4[0] " + display.options4[0]);
408
+// System.out.println("display.options4[1] " + display.options4[1]);
409
+// System.out.println("display.options4[2] " + display.options4[2]);
311410
312411 // if (display.CURRENTANTIALIAS > 0)
313412 // display.options3[3] /= 4;
....@@ -323,7 +422,7 @@
323422 /**/
324423 } else
325424 {
326
- DrawMaterial(material, selected);
425
+ DrawMaterial(material, selected, obj.projectedVertices);
327426 }
328427 } else
329428 {
....@@ -347,8 +446,8 @@
347446 cStatic.objectstack[materialdepth++] = obj;
348447 //System.out.println("material " + material);
349448 //Applet3D.tracein("selected ", selected);
350
- display.vector2buffer = obj.projectedVertices;
351
- display.DrawMaterial(material, selected);
449
+ //display.vector2buffer = obj.projectedVertices;
450
+ display.DrawMaterial(material, selected, obj.projectedVertices);
352451 }
353452 }
354453
....@@ -365,8 +464,8 @@
365464 materialdepth -= 1;
366465 if (materialdepth > 0)
367466 {
368
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
369
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
467
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
468
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
370469 }
371470 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
372471 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -386,8 +485,8 @@
386485 materialdepth -= 1;
387486 if (materialdepth > 0)
388487 {
389
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
390
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
488
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
489
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
391490 }
392491 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
393492 //else
....@@ -428,10 +527,12 @@
428527 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
429528 {
430529 //gl.glBegin(gl.GL_TRIANGLES);
431
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
530
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
531
+ // TEST LIVE NORMALS && !obj.dontselect
532
+ ;
432533 if (!hasnorm)
433534 {
434
- // System.out.println("FUCK!!");
535
+ // System.out.println("Mesh normal");
435536 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
436537 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
437538 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1059,8 +1160,345 @@
10591160 gl.glMatrixMode(gl.GL_MODELVIEW);
10601161 }
10611162
1163
+ public void DrawBox(cVector min, cVector max)
1164
+ {
1165
+ javax.media.opengl.GL gl = GetGL();
1166
+ gl.glBegin(gl.GL_LINES);
1167
+
1168
+ gl.glVertex3d(min.x, min.y, min.z);
1169
+ gl.glVertex3d(min.x, min.y, max.z);
1170
+ gl.glVertex3d(min.x, min.y, min.z);
1171
+ gl.glVertex3d(min.x, max.y, min.z);
1172
+ gl.glVertex3d(min.x, min.y, min.z);
1173
+ gl.glVertex3d(max.x, min.y, min.z);
1174
+
1175
+ gl.glVertex3d(max.x, max.y, max.z);
1176
+ gl.glVertex3d(min.x, max.y, max.z);
1177
+ gl.glVertex3d(max.x, max.y, max.z);
1178
+ gl.glVertex3d(max.x, min.y, max.z);
1179
+ gl.glVertex3d(max.x, max.y, max.z);
1180
+ gl.glVertex3d(max.x, max.y, min.z);
1181
+
1182
+ gl.glEnd();
1183
+ }
1184
+
1185
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1186
+ {
1187
+ int[] strips = bRep.getRawIndices();
1188
+
1189
+ javax.media.opengl.GL gl = GetGL();
1190
+
1191
+ // TRIANGLE STRIP ARRAY
1192
+ if (bRep.trimmed)
1193
+ {
1194
+ float[] v = bRep.getRawVertices();
1195
+ float[] n = bRep.getRawNormals();
1196
+ float[] c = bRep.getRawColors();
1197
+ float[] uv = bRep.getRawUVMap();
1198
+
1199
+ int count2 = 0;
1200
+ int count3 = 0;
1201
+
1202
+ if (n.length > 0)
1203
+ {
1204
+ for (int i = 0; i < strips.length; i++)
1205
+ {
1206
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1207
+
1208
+ /*
1209
+ boolean locked = false;
1210
+ float eps = 0.1f;
1211
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1212
+
1213
+ int dot = 0;
1214
+
1215
+ if ((dot&1) == 0)
1216
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1217
+
1218
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1219
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1220
+ else
1221
+ {
1222
+ locked = true;
1223
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1224
+ }
1225
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1226
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1227
+ if (hasnorm)
1228
+ {
1229
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1230
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1231
+ }
1232
+
1233
+ if ((dot&4) == 0)
1234
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1235
+
1236
+ if (wrap || !locked && (dot&8) != 0)
1237
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1238
+ else
1239
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1240
+
1241
+ f.dot = dot;
1242
+ */
1243
+
1244
+ if (!selectmode)
1245
+ {
1246
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1247
+ {
1248
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1249
+ } else
1250
+ {
1251
+ gl.glNormal3f(0, 0, 1);
1252
+ }
1253
+
1254
+ if (c != null)
1255
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1256
+ {
1257
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1258
+ }
1259
+ }
1260
+
1261
+ if (flipV)
1262
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1263
+ else
1264
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1265
+
1266
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1267
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1268
+
1269
+ count2 += 2;
1270
+ count3 += 3;
1271
+ if (!selectmode)
1272
+ {
1273
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1274
+ {
1275
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1276
+ } else
1277
+ {
1278
+ gl.glNormal3f(0, 0, 1);
1279
+ }
1280
+ if (c != null)
1281
+ {
1282
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1283
+ }
1284
+ }
1285
+
1286
+ if (flipV)
1287
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1288
+ else
1289
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1290
+
1291
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1292
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1293
+
1294
+ count2 += 2;
1295
+ count3 += 3;
1296
+ for (int j = 0; j < strips[i] - 2; j++)
1297
+ {
1298
+ //gl.glTexCoord2d(...);
1299
+ if (!selectmode)
1300
+ {
1301
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1302
+ {
1303
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1304
+ } else
1305
+ {
1306
+ gl.glNormal3f(0, 0, 1);
1307
+ }
1308
+ if (c != null)
1309
+ {
1310
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1311
+ }
1312
+ }
1313
+
1314
+ if (flipV)
1315
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1316
+ else
1317
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1318
+
1319
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1320
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1321
+
1322
+ count2 += 2;
1323
+ count3 += 3;
1324
+ }
1325
+
1326
+ gl.glEnd();
1327
+ }
1328
+ }
1329
+
1330
+ assert count3 == v.length;
1331
+ }
1332
+ else // !trimmed
1333
+ {
1334
+ int count = 0;
1335
+ for (int i = 0; i < strips.length; i++)
1336
+ {
1337
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1338
+
1339
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1340
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1341
+
1342
+ drawVertex(gl, p, flipV, selectmode);
1343
+ drawVertex(gl, q, flipV, selectmode);
1344
+
1345
+ for (int j = 0; j < strips[i] - 2; j++)
1346
+ {
1347
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1348
+
1349
+ // if (j%2 == 0)
1350
+ // drawFace(p, q, r, display, null);
1351
+ // else
1352
+ // drawFace(p, r, q, display, null);
1353
+
1354
+ // p = q;
1355
+ // q = r;
1356
+ drawVertex(gl, r, flipV, selectmode);
1357
+ }
1358
+
1359
+ gl.glEnd();
1360
+ }
1361
+ }
1362
+ }
1363
+
1364
+ static cSpring.Point3D temp = new cSpring.Point3D();
1365
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1366
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1367
+
1368
+ public void DrawDynamicMesh(cMesh mesh)
1369
+ {
1370
+ GL gl = GetGL(); // getGL();
1371
+
1372
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1373
+
1374
+ gl.glDisable(gl.GL_LIGHTING);
1375
+
1376
+ gl.glLineWidth(1);
1377
+ gl.glColor3f(1,1,1);
1378
+ gl.glBegin(gl.GL_LINES);
1379
+ double scale = 0;
1380
+ int count = 0;
1381
+ for (int s=0; s<Phys.allSprings.size(); s++)
1382
+ {
1383
+ cSpring.Spring spring = Phys.allSprings.get(s);
1384
+ if(s == 0)
1385
+ {
1386
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1387
+ }
1388
+ if (mesh.showsprings)
1389
+ {
1390
+ temp.set(spring.a.position);
1391
+ temp.add(spring.b.position);
1392
+ temp.mul(0.5);
1393
+ temp2.set(spring.a.position);
1394
+ temp2.sub(spring.b.position);
1395
+ temp2.mul(spring.restLength/2);
1396
+ temp.sub(temp2);
1397
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1398
+ temp.add(temp2);
1399
+ temp.add(temp2);
1400
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1401
+ }
1402
+
1403
+ if (spring.isHandle)
1404
+ continue;
1405
+
1406
+ //if (scale < spring.restLength)
1407
+ scale += spring.restLength;
1408
+ count++;
1409
+ }
1410
+ gl.glEnd();
1411
+
1412
+ if (count == 0)
1413
+ scale = 0.01;
1414
+ else
1415
+ scale /= count * 3;
1416
+
1417
+ //scale = 0.25;
1418
+
1419
+ if (mesh.ShowInfo())
1420
+ {
1421
+ gl.glLineWidth(4);
1422
+ for (int s=0; s<Phys.allNodes.size(); s++)
1423
+ {
1424
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1425
+ if (node.mass == 0)
1426
+ continue;
1427
+
1428
+ int i = node.springs==null?-1:node.springs.size();
1429
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1430
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1431
+ //temp.normalize();
1432
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1433
+ gl.glBegin(gl.GL_LINES);
1434
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1435
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1436
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1437
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1438
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1439
+ gl.glEnd();
1440
+ }
1441
+
1442
+ gl.glLineWidth(8);
1443
+ for (int s=0; s<Phys.allNodes.size(); s++)
1444
+ {
1445
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1446
+
1447
+ if (node.springs != null)
1448
+ {
1449
+ for (int i=0; i<node.springs.size(); i+=1)
1450
+ {
1451
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1452
+
1453
+ int c = i+1;
1454
+ // c = node.springs.get(i).nbcopies;
1455
+
1456
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1457
+ gl.glBegin(gl.GL_LINES);
1458
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1459
+ 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);
1460
+ gl.glEnd();
1461
+ }
1462
+ }
1463
+ }
1464
+
1465
+ gl.glLineWidth(1);
1466
+ }
1467
+
1468
+ gl.glEnable(gl.GL_LIGHTING);
1469
+ }
1470
+
10621471 /// INTERFACE
10631472
1473
+ public void StartTriangles()
1474
+ {
1475
+ javax.media.opengl.GL gl = GetGL();
1476
+ gl.glBegin(gl.GL_TRIANGLES);
1477
+ }
1478
+
1479
+ public void EndTriangles()
1480
+ {
1481
+ GetGL().glEnd();
1482
+ }
1483
+
1484
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1485
+ {
1486
+ if (!selectmode)
1487
+ {
1488
+ gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1489
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1490
+
1491
+ if (flipV)
1492
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1493
+ else
1494
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1495
+ }
1496
+
1497
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1498
+ }
1499
+
1500
+ float[] colorV = new float[4];
1501
+
10641502 void SetColor(Object3D obj, Vertex p0)
10651503 {
10661504 CameraPane display = this;
....@@ -1128,8 +1566,6 @@
11281566 {
11291567 return;
11301568 }
1131
-
1132
- float[] colorV = new float[3];
11331569
11341570 if (false) // marked)
11351571 {
....@@ -1238,7 +1674,7 @@
12381674 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
12391675 }
12401676
1241
- void DrawMaterial(cMaterial material, boolean selected)
1677
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
12421678 {
12431679 CameraPane display = this;
12441680 //new Exception().printStackTrace();
....@@ -1254,18 +1690,18 @@
12541690 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
12551691 if (!material.multiply)
12561692 {
1257
- display.color = color;
1693
+ display.color = material.color;
12581694 display.saturation = material.modulation;
12591695 }
12601696 else
12611697 {
1262
- display.color *= color*2;
1698
+ display.color *= material.color*2;
12631699 display.saturation *= material.modulation*2;
12641700 }
12651701
12661702 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
12671703
1268
- float[] colorV = GrafreeD.colorV;
1704
+ float[] colorV = Grafreed.colorV;
12691705
12701706 /**/
12711707 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1273,7 +1709,7 @@
12731709 colorV[0] = display.modelParams0[0] * material.diffuse;
12741710 colorV[1] = display.modelParams0[1] * material.diffuse;
12751711 colorV[2] = display.modelParams0[2] * material.diffuse;
1276
- colorV[3] = material.opacity;
1712
+ colorV[3] = 1; // material.opacity;
12771713
12781714 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
12791715 //System.out.println("Opacity = " + opacity);
....@@ -1381,9 +1817,9 @@
13811817 display.modelParams7[2] = 0;
13821818 display.modelParams7[3] = 0;
13831819
1384
- display.modelParams6[0] = 100; // criss de bug de bump
1820
+ //display.modelParams6[0] = 100; // criss de bug de bump
13851821
1386
- Object3D.cVector2[] extparams = display.vector2buffer;
1822
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
13871823 if (extparams != null && extparams.length > 0 && extparams[0] != null)
13881824 {
13891825 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1525,7 +1961,7 @@
15251961 void PushMatrix(double[][] matrix)
15261962 {
15271963 // GrafreeD.tracein(matrix);
1528
- PushMatrix(matrix,1);
1964
+ PushMatrix(matrix, 1);
15291965 }
15301966
15311967 void PushMatrix()
....@@ -1679,7 +2115,7 @@
16792115 //System.err.println("Oeil on");
16802116 OEIL = true;
16812117 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
1682
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2118
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
16832119 //pingthread.StepToTarget(true);
16842120 }
16852121
....@@ -1777,7 +2213,7 @@
17772213 System.err.println("LIVE = " + Globals.isLIVE());
17782214
17792215 if (!Globals.isLIVE()) // save sound
1780
- GrafreeD.savesound = true; // wav.save();
2216
+ Grafreed.savesound = true; // wav.save();
17812217 // else
17822218 repaint(); // start loop // may 2013
17832219 }
....@@ -1810,6 +2246,11 @@
18102246 public void ToggleBoxMode()
18112247 {
18122248 BOXMODE ^= true;
2249
+ }
2250
+
2251
+ public void ToggleZoomBoxMode()
2252
+ {
2253
+ ZOOMBOXMODE ^= true;
18132254 }
18142255
18152256 public void ToggleSmoothFocus()
....@@ -1889,7 +2330,7 @@
18892330
18902331 void ToggleDebug()
18912332 {
1892
- DEBUG ^= true;
2333
+ Globals.DEBUG ^= true;
18932334 }
18942335
18952336 void ToggleLookAt()
....@@ -1897,9 +2338,9 @@
18972338 LOOKAT ^= true;
18982339 }
18992340
1900
- void ToggleRandom()
2341
+ void ToggleSwitch()
19012342 {
1902
- RANDOM ^= true;
2343
+ SWITCH ^= true;
19032344 }
19042345
19052346 void ToggleHandles()
....@@ -1907,10 +2348,17 @@
19072348 HANDLES ^= true;
19082349 }
19092350
2351
+ Object3D paintFolder;
2352
+
19102353 void TogglePaint()
19112354 {
19122355 PAINTMODE ^= true;
19132356 paintcount = 0;
2357
+
2358
+ if (PAINTMODE)
2359
+ {
2360
+ paintFolder = GetFolder();
2361
+ }
19142362 }
19152363
19162364 void SwapCamera(int a, int b)
....@@ -2006,7 +2454,22 @@
20062454 {
20072455 return currentGL;
20082456 }
2009
-
2457
+
2458
+ static private BufferedImage CreateBim(TextureData texturedata)
2459
+ {
2460
+ Grafreed.Assert(texturedata != null);
2461
+
2462
+ int width = texturedata.getWidth();
2463
+ int height = texturedata.getHeight();
2464
+
2465
+ Buffer buffer = texturedata.getBuffer();
2466
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2467
+
2468
+ byte[] bytes = bytebuf.array();
2469
+
2470
+ return CreateBim(bytes, width, height);
2471
+ }
2472
+
20102473 /**/
20112474 class CacheTexture
20122475 {
....@@ -2015,28 +2478,31 @@
20152478
20162479 int resolution;
20172480
2018
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2481
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
20192482 {
2020
- texture = tex;
2483
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2484
+ texturedata = texdata;
20212485 resolution = res;
20222486 }
20232487 }
20242488 /**/
20252489
20262490 // TEXTURE static Texture texture;
2027
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2028
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2029
- static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>();
2491
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2492
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2493
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2494
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2495
+
20302496 int pigmentdepth = 0;
20312497 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
20322498 int bumpdepth = 0;
20332499 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
20342500 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
20352501 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2036
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2502
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
20372503 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
20382504
2039
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2505
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
20402506 {
20412507 TextureData texturedata = null;
20422508
....@@ -2055,13 +2521,34 @@
20552521 if (bump)
20562522 texturedata = ConvertBump(texturedata, false);
20572523
2058
- com.sun.opengl.util.texture.Texture texture =
2059
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2524
+// com.sun.opengl.util.texture.Texture texture =
2525
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
20602526
2061
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2062
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2527
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2528
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
20632529
2064
- return texture;
2530
+ return texturedata;
2531
+ }
2532
+
2533
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2534
+ {
2535
+ TextureData texturedata = null;
2536
+
2537
+ try
2538
+ {
2539
+ texturedata =
2540
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2541
+ bim,
2542
+ true);
2543
+ } catch (Exception e)
2544
+ {
2545
+ throw new javax.media.opengl.GLException(e);
2546
+ }
2547
+
2548
+ if (bump)
2549
+ texturedata = ConvertBump(texturedata, false);
2550
+
2551
+ return texturedata;
20652552 }
20662553
20672554 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3134,6 +3621,8 @@
31343621
31353622 System.out.println("LOADING TEXTURE : " + name);
31363623
3624
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3625
+
31373626 //
31383627 if (false) // compressbit > 0)
31393628 {
....@@ -3838,6 +4327,7 @@
38384327
38394328 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
38404329 {
4330
+ new Exception().printStackTrace();
38414331 System.exit(0);
38424332 com.sun.opengl.util.texture.Texture texture = null;
38434333
....@@ -7531,7 +8021,7 @@
75318021 String pigment = Object3D.GetPigment(tex);
75328022 String bump = Object3D.GetBump(tex);
75338023
7534
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8024
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
75358025 {
75368026 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
75378027 // System.out.println("; bump = " + bump);
....@@ -7546,11 +8036,69 @@
75468036 pigment = null;
75478037 }
75488038
7549
- ReleaseTexture(bump, true);
7550
- ReleaseTexture(pigment, false);
8039
+ ReleaseTexture(tex, true);
8040
+ ReleaseTexture(tex, false);
75518041 }
75528042
7553
- void ReleaseTexture(String tex, boolean bump)
8043
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
8044
+ {
8045
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8046
+ {
8047
+ return;
8048
+ }
8049
+
8050
+ if (tex == null)
8051
+ {
8052
+ ReleaseTexture(null, false);
8053
+ return;
8054
+ }
8055
+
8056
+ String pigment = Object3D.GetPigment(tex);
8057
+
8058
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8059
+ {
8060
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8061
+ // System.out.println("; bump = " + bump);
8062
+ }
8063
+
8064
+ if (pigment.equals(""))
8065
+ {
8066
+ pigment = null;
8067
+ }
8068
+
8069
+ ReleaseTexture(tex, false);
8070
+ }
8071
+
8072
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8073
+ {
8074
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8075
+ {
8076
+ return;
8077
+ }
8078
+
8079
+ if (tex == null)
8080
+ {
8081
+ ReleaseTexture(null, true);
8082
+ return;
8083
+ }
8084
+
8085
+ String bump = Object3D.GetBump(tex);
8086
+
8087
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8088
+ {
8089
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8090
+ // System.out.println("; bump = " + bump);
8091
+ }
8092
+
8093
+ if (bump.equals(""))
8094
+ {
8095
+ bump = null;
8096
+ }
8097
+
8098
+ ReleaseTexture(tex, true);
8099
+ }
8100
+
8101
+ void ReleaseTexture(cTexture tex, boolean bump)
75548102 {
75558103 if (// DrawMode() != 0 || /*tex == null ||*/
75568104 ambientOcclusion ) // || !textureon)
....@@ -7561,7 +8109,7 @@
75618109 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
75628110
75638111 if (tex != null)
7564
- texture = textures.get(tex);
8112
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
75658113
75668114 // //assert( texture != null );
75678115 // if (texture == null)
....@@ -7653,7 +8201,55 @@
76538201 }
76548202 }
76558203
7656
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8204
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
8205
+ {
8206
+// if (// DrawMode() != 0 || /*tex == null ||*/
8207
+// ambientOcclusion ) // || !textureon)
8208
+// {
8209
+// return; // false;
8210
+// }
8211
+//
8212
+// if (tex == null)
8213
+// {
8214
+// BindTexture(null,false,resolution);
8215
+// BindTexture(null,true,resolution);
8216
+// return;
8217
+// }
8218
+//
8219
+// String pigment = Object3D.GetPigment(tex);
8220
+// String bump = Object3D.GetBump(tex);
8221
+//
8222
+// usedtextures.add(pigment);
8223
+// usedtextures.add(bump);
8224
+//
8225
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8226
+// {
8227
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8228
+// // System.out.println("; bump = " + bump);
8229
+// }
8230
+//
8231
+// if (bump.equals(""))
8232
+// {
8233
+// bump = null;
8234
+// }
8235
+// if (pigment.equals(""))
8236
+// {
8237
+// pigment = null;
8238
+// }
8239
+//
8240
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8241
+// BindTexture(pigment, false, resolution);
8242
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8243
+// BindTexture(bump, true, resolution);
8244
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8245
+//
8246
+// return; // true;
8247
+
8248
+ BindPigmentTexture(tex, resolution);
8249
+ BindBumpTexture(tex, resolution);
8250
+ }
8251
+
8252
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
76578253 {
76588254 if (// DrawMode() != 0 || /*tex == null ||*/
76598255 ambientOcclusion ) // || !textureon)
....@@ -7664,17 +8260,47 @@
76648260 if (tex == null)
76658261 {
76668262 BindTexture(null,false,resolution);
7667
- BindTexture(null,true,resolution);
76688263 return;
76698264 }
76708265
76718266 String pigment = Object3D.GetPigment(tex);
8267
+
8268
+ usedtextures.add(tex);
8269
+
8270
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8271
+ {
8272
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8273
+ // System.out.println("; bump = " + bump);
8274
+ }
8275
+
8276
+ if (pigment.equals(""))
8277
+ {
8278
+ pigment = null;
8279
+ }
8280
+
8281
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8282
+ BindTexture(tex, false, resolution);
8283
+ }
8284
+
8285
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8286
+ {
8287
+ if (// DrawMode() != 0 || /*tex == null ||*/
8288
+ ambientOcclusion ) // || !textureon)
8289
+ {
8290
+ return; // false;
8291
+ }
8292
+
8293
+ if (tex == null)
8294
+ {
8295
+ BindTexture(null,true,resolution);
8296
+ return;
8297
+ }
8298
+
76728299 String bump = Object3D.GetBump(tex);
76738300
7674
- usedtextures.put(pigment, pigment);
7675
- usedtextures.put(bump, bump);
8301
+ usedtextures.add(tex);
76768302
7677
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8303
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
76788304 {
76798305 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
76808306 // System.out.println("; bump = " + bump);
....@@ -7684,43 +8310,94 @@
76848310 {
76858311 bump = null;
76868312 }
7687
- if (pigment.equals(""))
7688
- {
7689
- pigment = null;
7690
- }
76918313
7692
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
7693
- BindTexture(pigment, false, resolution);
76948314 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
7695
- BindTexture(bump, true, resolution);
8315
+ BindTexture(tex, true, resolution);
76968316 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
7697
-
7698
- return; // true;
76998317 }
77008318
7701
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8319
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8320
+
8321
+ private boolean FileExists(String tex)
77028322 {
7703
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8323
+ if (missingTextures.contains(tex))
8324
+ {
8325
+ return false;
8326
+ }
8327
+
8328
+ boolean fileExists = new File(tex).exists();
8329
+
8330
+ if (!fileExists)
8331
+ {
8332
+ // If file exists, the "new File()" is not executed sgain
8333
+ missingTextures.add(tex);
8334
+ }
8335
+
8336
+ return fileExists;
8337
+ }
8338
+
8339
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
8340
+ {
8341
+ CacheTexture texturecache = null;
77048342
77058343 if (tex != null)
77068344 {
7707
- String texname = tex;
8345
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8346
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
77088347
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;
8348
+ if (texname.equals("") && texdata == null)
8349
+ {
8350
+ return null;
8351
+ }
8352
+
8353
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8354
+
8355
+// String[] split = tex.split("Textures");
8356
+// if (split.length > 1)
8357
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8358
+// else
8359
+// if (!texname.startsWith("/"))
8360
+// texname = "/Users/nbriere/Textures/" + texname;
8361
+ if (!FileExists(texname) && !texname.startsWith("@"))
8362
+ {
8363
+ texname = fallbackTextureName;
8364
+ }
77158365
77168366 if (CACHETEXTURE)
7717
- texture = textures.get(texname); // TEXTURE CACHE
7718
-
7719
- TextureData texturedata = null;
7720
-
7721
- if (texture == null || texture.resolution < resolution)
77228367 {
7723
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8368
+ if (texdata == null)
8369
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8370
+ else
8371
+ texturecache = bimtextures.get(texdata);
8372
+ }
8373
+
8374
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8375
+ {
8376
+ TextureData texturedata = null;
8377
+
8378
+ if (texdata != null && textureon)
8379
+ {
8380
+ BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8381
+
8382
+ try
8383
+ {
8384
+ bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8385
+ }
8386
+ catch (Exception e)
8387
+ {
8388
+ bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8389
+ }
8390
+
8391
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8392
+ bimtextures.put(texdata, texturecache);
8393
+
8394
+ //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8395
+
8396
+ //Object bim2 = CreateBim(texturecache.texturedata);
8397
+ //bim2 = bim;
8398
+ }
8399
+ else
8400
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
77248401 {
77258402 assert(!bump);
77268403 // if (bump)
....@@ -7731,19 +8408,23 @@
77318408 // }
77328409 // else
77338410 // {
7734
- texture = textures.get(tex);
7735
- if (texture == null)
8411
+ // texturecache = textures.get(texname); // suspicious
8412
+ if (texturecache == null)
77368413 {
7737
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8414
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
77388415 }
8416
+ else
8417
+ new Exception().printStackTrace();
77398418 // }
77408419 } else
7741
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8420
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
77428421 {
77438422 assert(bump);
7744
- texture = textures.get(tex);
7745
- if (texture == null)
7746
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8423
+ // texturecache = textures.get(texname); // suspicious
8424
+ if (texturecache == null)
8425
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8426
+ else
8427
+ new Exception().printStackTrace();
77478428 } else
77488429 {
77498430 //if (tex.equals("IMMORTAL"))
....@@ -7751,11 +8432,22 @@
77518432 // texture = GetResourceTexture("default.png");
77528433 //} else
77538434 //{
7754
- if (tex.equals("WHITE_NOISE"))
8435
+ if (texname.endsWith("WHITE_NOISE"))
77558436 {
7756
- texture = textures.get(tex);
7757
- if (texture == null)
7758
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8437
+ // texturecache = textures.get(texname); // suspicious
8438
+ if (texturecache == null)
8439
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8440
+ else
8441
+ new Exception().printStackTrace();
8442
+ } else
8443
+ {
8444
+ if (texname.startsWith("@"))
8445
+ {
8446
+ // texturecache = textures.get(texname); // suspicious
8447
+ if (texturecache == null)
8448
+ texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution);
8449
+ else
8450
+ new Exception().printStackTrace();
77598451 } else
77608452 {
77618453 if (textureon)
....@@ -7780,7 +8472,7 @@
77808472 }
77818473
77828474 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
7783
- if (!new File(cachename).exists())
8475
+ if (!FileExists(cachename))
77848476 cachename = texname;
77858477 else
77868478 processbump = false; // don't process bump map again
....@@ -7802,7 +8494,7 @@
78028494 }
78038495
78048496 cachename = texname.substring(0, texname.length()-4)+ext+".png";
7805
- if (!new File(cachename).exists())
8497
+ if (!FileExists(cachename))
78068498 cachename = texname;
78078499 else
78088500 processbump = false; // don't process bump map again
....@@ -7811,20 +8503,23 @@
78118503 texturedata = GetFileTexture(cachename, processbump, resolution);
78128504
78138505
7814
- if (texturedata != null)
7815
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8506
+ if (texturedata == null)
8507
+ throw new Exception();
8508
+
8509
+ texturecache = new CacheTexture(texturedata,resolution);
78168510 //texture = GetTexture(tex, bump);
78178511 }
8512
+ }
78188513 }
78198514 //}
78208515 }
78218516
7822
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8517
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
78238518 {
78248519 //return false;
78258520
78268521 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
7827
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8522
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
78288523 {
78298524 // String ext = "_highres";
78308525 // if (REDUCETEXTURE)
....@@ -7841,52 +8536,17 @@
78418536 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
78428537 if (!cachefile.exists())
78438538 {
7844
- // cache to disk
7845
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
7846
- //buffers[0].
7847
-
7848
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
7849
- int[] pixels = new int[bytebuf.capacity()/3];
7850
-
7851
- // squared size heuristic...
7852
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8539
+ //if (texturedata.getWidth() == texturedata.getHeight())
78538540 {
7854
- for (int i=pixels.length; --i>=0;)
7855
- {
7856
- int i3 = i*3;
7857
- pixels[i] = 0xFF;
7858
- pixels[i] <<= 8;
7859
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
7860
- pixels[i] <<= 8;
7861
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
7862
- pixels[i] <<= 8;
7863
- pixels[i] |= bytebuf.get(i3) & 0xFF;
7864
- }
7865
-
7866
- /*
7867
- int r=0,g=0,b=0,a=0;
7868
- for (int i=0; i<width; i++)
7869
- for (int j=0; j<height; j++)
7870
- {
7871
- int index = j*width+i;
7872
- int p = pixels[index];
7873
- a = ((p>>24) & 0xFF);
7874
- r = ((p>>16) & 0xFF);
7875
- g = ((p>>8) & 0xFF);
7876
- b = (p & 0xFF);
7877
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
7878
- }
7879
- /**/
7880
- int width = (int)Math.sqrt(pixels.length); // squared
7881
- int height = width;
7882
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
7883
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8541
+ BufferedImage rendImage = CreateBim(texturedata);
8542
+
78848543 ImageWriter writer = null;
78858544 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
78868545 if (iter.hasNext()) {
78878546 writer = (ImageWriter)iter.next();
78888547 }
7889
- float compressionQuality = 0.9f;
8548
+
8549
+ float compressionQuality = 0.85f;
78908550 try
78918551 {
78928552 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -7903,18 +8563,20 @@
79038563 }
79048564 }
79058565 }
7906
-
8566
+
8567
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8568
+
79078569 //System.out.println("Texture = " + tex);
7908
- if (textures.containsKey(texname))
8570
+ if (textures.containsKey(tex))
79098571 {
7910
- CacheTexture thetex = textures.get(texname);
8572
+ CacheTexture thetex = textures.get(tex);
79118573 thetex.texture.disable();
79128574 thetex.texture.dispose();
7913
- textures.remove(texname);
8575
+ textures.remove(tex);
79148576 }
79158577
7916
- texture.texturedata = texturedata;
7917
- textures.put(texname, texture);
8578
+ //texture.texturedata = texturedata;
8579
+ textures.put(tex, texturecache);
79188580
79198581 // newtex = true;
79208582 }
....@@ -7930,10 +8592,44 @@
79308592 }
79318593 }
79328594
7933
- return texture;
8595
+ return texturecache;
79348596 }
79358597
7936
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8598
+ static void EmbedTextures(cTexture tex)
8599
+ {
8600
+ if (tex.pigmentdata == null)
8601
+ {
8602
+ //String texname = Object3D.GetPigment(tex);
8603
+
8604
+ CacheTexture texturecache = texturepigment.get(tex);
8605
+
8606
+ if (texturecache != null)
8607
+ {
8608
+ tex.pw = texturecache.texturedata.getWidth();
8609
+ tex.ph = texturecache.texturedata.getHeight();
8610
+ tex.pigmentdata = //CompressJPEG(CreateBim
8611
+ ((ByteBuffer)texturecache.texturedata.getBuffer()).array()
8612
+ ;
8613
+ //, tex.pw, tex.ph), 0.5f);
8614
+ }
8615
+ }
8616
+
8617
+ if (tex.bumpdata == null)
8618
+ {
8619
+ //String texname = Object3D.GetBump(tex);
8620
+
8621
+ CacheTexture texturecache = texturebump.get(tex);
8622
+
8623
+ if (texturecache != null)
8624
+ {
8625
+ tex.bw = texturecache.texturedata.getWidth();
8626
+ tex.bh = texturecache.texturedata.getHeight();
8627
+ tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f);
8628
+ }
8629
+ }
8630
+ }
8631
+
8632
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
79378633 {
79388634 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
79398635
....@@ -7951,21 +8647,21 @@
79518647 return texture!=null?texture.texture:null;
79528648 }
79538649
7954
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8650
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
79558651 {
79568652 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
79578653
79588654 return texture!=null?texture.texturedata:null;
79598655 }
79608656
7961
- boolean BindTexture(String tex, boolean bump, int resolution)
8657
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
79628658 {
79638659 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
79648660 {
79658661 return false;
79668662 }
79678663
7968
- boolean newtex = false;
8664
+ //boolean newtex = false;
79698665
79708666 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
79718667
....@@ -7997,9 +8693,75 @@
79978693 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
79988694 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
79998695
8000
- return newtex;
8696
+ return true; // Warning: not used.
80018697 }
80028698
8699
+ public static byte[] CompressJPEG(BufferedImage image, float quality)
8700
+ {
8701
+ try
8702
+ {
8703
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
8704
+ Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg");
8705
+ ImageWriter writer = writers.next();
8706
+
8707
+ ImageWriteParam param = writer.getDefaultWriteParam();
8708
+ param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
8709
+ param.setCompressionQuality(quality);
8710
+
8711
+ ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
8712
+ writer.setOutput(ios);
8713
+ writer.write(null, new IIOImage(image, null, null), param);
8714
+
8715
+ byte[] data = baos.toByteArray();
8716
+ writer.dispose();
8717
+ return data;
8718
+ }
8719
+ catch (Exception e)
8720
+ {
8721
+ e.printStackTrace();
8722
+ return null;
8723
+ }
8724
+ }
8725
+
8726
+ public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException
8727
+ {
8728
+ ByteArrayInputStream baos = new ByteArrayInputStream(image);
8729
+ Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg");
8730
+ ImageReader reader = writers.next();
8731
+
8732
+ BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
8733
+
8734
+ ImageReadParam param = reader.getDefaultReadParam();
8735
+ param.setDestination(bim);
8736
+ //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB));
8737
+
8738
+ ImageInputStream ios = ImageIO.createImageInputStream(baos);
8739
+ reader.setInput(ios);
8740
+ BufferedImage bim2 = reader.read(0, param);
8741
+ reader.dispose();
8742
+
8743
+// WritableRaster raster = bim2.getRaster();
8744
+// DataBufferByte data = (DataBufferByte) raster.getDataBuffer();
8745
+// byte[] bytes = data.getData();
8746
+//
8747
+// int[] pixels = new int[bytes.length/3];
8748
+// for (int i=pixels.length; --i>=0;)
8749
+// {
8750
+// int i3 = i*3;
8751
+// pixels[i] = 0xFF;
8752
+// pixels[i] <<= 8;
8753
+// pixels[i] |= bytes[i3+2] & 0xFF;
8754
+// pixels[i] <<= 8;
8755
+// pixels[i] |= bytes[i3+1] & 0xFF;
8756
+// pixels[i] <<= 8;
8757
+// pixels[i] |= bytes[i3] & 0xFF;
8758
+// }
8759
+//
8760
+// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w);
8761
+
8762
+ return bim;
8763
+ }
8764
+
80038765 ShadowBuffer shadowPBuf;
80048766 AntialiasBuffer antialiasPBuf;
80058767 int MAXSTACK;
....@@ -8016,10 +8778,12 @@
80168778
80178779 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
80188780 MAXSTACK = temp[0];
8019
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8781
+ if (Globals.DEBUG)
8782
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
80208783 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
80218784 MAXSTACK = temp[0];
8022
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8785
+ if (Globals.DEBUG)
8786
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
80238787
80248788 // Use debug pipeline
80258789 //drawable.setGL(new DebugGL(gl)); //
....@@ -8027,7 +8791,8 @@
80278791 gl = drawable.getGL(); //
80288792
80298793 GL gl3 = getGL();
8030
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8794
+ if (Globals.DEBUG)
8795
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
80318796
80328797
80338798 //float pos[] = { 100, 100, 100, 0 };
....@@ -8192,7 +8957,7 @@
81928957
81938958 if (cubemap == null)
81948959 {
8195
- LoadEnvy(5);
8960
+ //LoadEnvy(1);
81968961 }
81978962
81988963 //cubemap.enable();
....@@ -8479,37 +9244,58 @@
84799244 cubemap = null;
84809245 return;
84819246 case 1:
8482
- name = "cubemaps/box_";
8483
- ext = "png";
9247
+ name = "cubemaps/rgb/";
9248
+ ext = "jpg";
84849249 reverseUP = false;
84859250 break;
84869251 case 2:
8487
- name = "cubemaps/uffizi_";
8488
- ext = "png";
8489
- break; // reverseUP = true; break;
9252
+ name = "cubemaps/uffizi/";
9253
+ ext = "jpg";
9254
+ reverseUP = false;
9255
+ break;
84909256 case 3:
8491
- name = "cubemaps/CloudyHills_";
8492
- ext = "tga";
9257
+ name = "cubemaps/CloudyHills/";
9258
+ ext = "jpg";
84939259 reverseUP = false;
84949260 break;
84959261 case 4:
8496
- name = "cubemaps/cornell_";
9262
+ name = "cubemaps/cornell/";
84979263 ext = "png";
84989264 reverseUP = false;
84999265 break;
9266
+ case 5:
9267
+ name = "cubemaps/skycube/";
9268
+ ext = "jpg";
9269
+ reverseUP = false;
9270
+ break;
9271
+ case 6:
9272
+ name = "cubemaps/SaintLazarusChurch3/";
9273
+ ext = "jpg";
9274
+ reverseUP = false;
9275
+ break;
9276
+ case 7:
9277
+ name = "cubemaps/Sodermalmsallen/";
9278
+ ext = "jpg";
9279
+ reverseUP = false;
9280
+ break;
9281
+ case 8:
9282
+ name = "cubemaps/Sodermalmsallen2/";
9283
+ ext = "jpg";
9284
+ reverseUP = false;
9285
+ break;
9286
+ case 9:
9287
+ name = "cubemaps/UnionSquare/";
9288
+ ext = "jpg";
9289
+ reverseUP = false;
9290
+ break;
85009291 default:
8501
- name = "cubemaps/rgb_";
8502
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9292
+ name = "cubemaps/box/";
9293
+ ext = "png"; /*mipmap = true;*/
9294
+ reverseUP = false;
85039295 break;
85049296 }
8505
-
8506
- try
8507
- {
8508
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
8509
- } catch (IOException e)
8510
- {
8511
- throw new RuntimeException(e);
8512
- }
9297
+
9298
+ LoadSkybox(name, ext, mipmap);
85139299 }
85149300
85159301 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -8541,8 +9327,12 @@
85419327 static double[] model = new double[16];
85429328 double[] camera2light = new double[16];
85439329 double[] light2camera = new double[16];
8544
- int newenvy = -1;
8545
- boolean envyoff = true; // false;
9330
+
9331
+ //int newenvy = -1;
9332
+ //boolean envyoff = false;
9333
+
9334
+ String loadedskyboxname;
9335
+
85469336 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
85479337 //float[] light0 = { 0,0,0 };
85489338 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -8835,11 +9625,35 @@
88359625 jy8[3] = 0.5f;
88369626 }
88379627
8838
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9628
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
88399629 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
88409630 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
88419631 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
88429632
9633
+ void ResetOptions()
9634
+ {
9635
+ options1[0] = 100;
9636
+ options1[1] = 0.025f;
9637
+ options1[2] = 0.01f;
9638
+ options1[3] = 0;
9639
+ options1[4] = 0;
9640
+
9641
+ options2[0] = 0;
9642
+ options2[1] = 0.75f;
9643
+ options2[2] = 0;
9644
+ options2[3] = 0;
9645
+
9646
+ options3[0] = 1;
9647
+ options3[1] = 1;
9648
+ options3[2] = 1;
9649
+ options3[3] = 0;
9650
+
9651
+ options4[0] = 1;
9652
+ options4[1] = 0;
9653
+ options4[2] = 1;
9654
+ options4[3] = 0;
9655
+ }
9656
+
88439657 static int imagecount = 0; // movie generation
88449658
88459659 static int jitter = 0;
....@@ -8935,8 +9749,8 @@
89359749 assert (parentcam != renderCamera);
89369750
89379751 if (renderCamera != lightCamera)
8938
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8939
- LA.matConcat(matrix, parentcam.toParent, matrix);
9752
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9753
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
89409754
89419755 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
89429756
....@@ -8951,8 +9765,8 @@
89519765 LA.matCopy(renderCamera.fromScreen, matrix);
89529766
89539767 if (renderCamera != lightCamera)
8954
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8955
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9768
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9769
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
89569770
89579771 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
89589772
....@@ -8998,10 +9812,12 @@
89989812 rati = 1 / rati;
89999813 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
90009814 }
9001
- assert (newenvy == -1);
9815
+
9816
+ //assert (newenvy == -1);
9817
+
90029818 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
90039819 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
9004
- DrawSkyBox(gl);
9820
+ DrawSkyBox(gl, (float)rati);
90059821 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
90069822 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
90079823 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -9024,7 +9840,7 @@
90249840 //gl.glFlush();
90259841 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
90269842
9027
- if (ANIMATION && ABORTED)
9843
+ if (Globals.ANIMATION && ABORTED)
90289844 {
90299845 System.err.println(" ABORTED FRAME");
90309846 break;
....@@ -9054,7 +9870,7 @@
90549870 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
90559871
90569872 // save image
9057
- if (ANIMATION && !ABORTED)
9873
+ if (Globals.ANIMATION && !ABORTED)
90589874 {
90599875 VPwidth = viewport[2];
90609876 VPheight = viewport[3];
....@@ -9165,11 +9981,11 @@
91659981
91669982 // imagecount++;
91679983
9168
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9984
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
91699985
91709986 if (!BOXMODE)
91719987 {
9172
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9988
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
91739989 }
91749990
91759991 if (!BOXMODE)
....@@ -9207,7 +10023,7 @@
920710023 ABORTED = false;
920810024 }
920910025 else
9210
- GrafreeD.wav.cursor += 735 * ACSIZE;
10026
+ Grafreed.wav.cursor += 735 * ACSIZE;
921110027
921210028 if (false)
921310029 {
....@@ -9870,11 +10686,11 @@
987010686
987110687 public void display(GLAutoDrawable drawable)
987210688 {
9873
- if (GrafreeD.savesound && GrafreeD.hassound)
10689
+ if (Grafreed.savesound && Grafreed.hassound)
987410690 {
9875
- GrafreeD.wav.save();
9876
- GrafreeD.savesound = false;
9877
- GrafreeD.hassound = false;
10691
+ Grafreed.wav.save();
10692
+ Grafreed.savesound = false;
10693
+ Grafreed.hassound = false;
987810694 }
987910695 // if (DEBUG_SELECTION)
988010696 // {
....@@ -9950,6 +10766,7 @@
995010766 ANTIALIAS = 0;
995110767 //System.out.println("RESTART");
995210768 AAtimer.restart();
10769
+ Globals.TIMERRUNNING = true;
995310770 }
995410771 }
995510772 }
....@@ -10004,7 +10821,7 @@
1000410821 Object3D theobject = object;
1000510822 Object3D theparent = object.parent;
1000610823 object.parent = null;
10007
- object = (Object3D)GrafreeD.clone(object);
10824
+ object = (Object3D)Grafreed.clone(object);
1000810825 object.Stripify();
1000910826 if (theobject.selection == null || theobject.selection.Size() == 0)
1001010827 theobject.PreprocessOcclusion(this);
....@@ -10017,13 +10834,14 @@
1001710834 ambientOcclusion = false;
1001810835 }
1001910836
10020
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10837
+ if (//Globals.lighttouched &&
10838
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1002110839 {
1002210840 //if (RENDERSHADOW) // ?
1002310841 if (!IsFrozen())
1002410842 {
1002510843 // dec 2012
10026
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10844
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1002710845 {
1002810846 Globals.framecount++;
1002910847 shadowbuffer.display();
....@@ -10036,7 +10854,7 @@
1003610854
1003710855 if (wait)
1003810856 {
10039
- Sleep(500);
10857
+ Sleep(200); // blocks everything
1004010858
1004110859 wait = false;
1004210860 }
....@@ -10150,8 +10968,8 @@
1015010968
1015110969 // if (parentcam != renderCamera) // not a light
1015210970 if (cam != lightCamera)
10153
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10154
- LA.matConcat(matrix, parentcam.toParent, matrix);
10971
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10972
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
1015510973
1015610974 for (int j = 0; j < 4; j++)
1015710975 {
....@@ -10165,8 +10983,8 @@
1016510983
1016610984 // if (parentcam != renderCamera) // not a light
1016710985 if (cam != lightCamera)
10168
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10169
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10986
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10987
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
1017010988
1017110989 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1017210990
....@@ -10252,13 +11070,27 @@
1025211070 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
1025311071 }
1025411072
10255
- if (newenvy > -1)
11073
+// if (newenvy > -1)
11074
+// {
11075
+// LoadEnvy(newenvy);
11076
+// }
11077
+//
11078
+// newenvy = -1;
11079
+
11080
+ if (object.skyboxname != null)
1025611081 {
10257
- LoadEnvy(newenvy);
11082
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11083
+ {
11084
+ LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11085
+ loadedskyboxname = object.skyboxname;
11086
+ }
1025811087 }
10259
-
10260
- newenvy = -1;
10261
-
11088
+ else
11089
+ {
11090
+ cubemap = null;
11091
+ loadedskyboxname = null;
11092
+ }
11093
+
1026211094 ratio = ((double) getWidth()) / getHeight();
1026311095 //System.out.println("ratio = " + ratio);
1026411096
....@@ -10274,7 +11106,7 @@
1027411106
1027511107 if (!IsFrozen() && !ambientOcclusion)
1027611108 {
10277
- DrawSkyBox(gl);
11109
+ DrawSkyBox(gl, (float)ratio);
1027811110 }
1027911111
1028011112 //if (selection_view == -1)
....@@ -10425,7 +11257,16 @@
1042511257 // Bump noise
1042611258 gl.glActiveTexture(GL.GL_TEXTURE6);
1042711259 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10428
- BindTexture(NOISE_TEXTURE, false, 2);
11260
+
11261
+ try
11262
+ {
11263
+ BindTexture(NOISE_TEXTURE, false, 2);
11264
+ }
11265
+ catch (Exception e)
11266
+ {
11267
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11268
+ }
11269
+
1042911270
1043011271 gl.glActiveTexture(GL.GL_TEXTURE0);
1043111272 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10448,9 +11289,9 @@
1044811289
1044911290 gl.glMatrixMode(GL.GL_MODELVIEW);
1045011291
10451
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10452
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10453
-//gl.glEnable(gl.GL_MULTISAMPLE);
11292
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11293
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11294
+gl.glEnable(gl.GL_MULTISAMPLE);
1045411295 } else
1045511296 {
1045611297 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10461,7 +11302,7 @@
1046111302 //System.out.println("BLENDING ON");
1046211303 gl.glEnable(GL.GL_BLEND);
1046311304 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10464
-
11305
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1046511306 gl.glMatrixMode(gl.GL_PROJECTION);
1046611307 gl.glLoadIdentity();
1046711308
....@@ -10550,8 +11391,8 @@
1055011391 System.err.println("parentcam != renderCamera");
1055111392
1055211393 // if (cam != lightCamera)
10553
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10554
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11394
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11395
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1055511396 }
1055611397
1055711398 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10572,8 +11413,8 @@
1057211413 if (true) // TODO
1057311414 {
1057411415 if (cam != lightCamera)
10575
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10576
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11416
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11417
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1057711418 }
1057811419
1057911420 LA.xformPos(light0, cam.toScreen, light0);
....@@ -10710,7 +11551,7 @@
1071011551 }
1071111552 }
1071211553
10713
- if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
11554
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
1071411555 {
1071511556 //gl.glDepthFunc(GL.GL_LEQUAL);
1071611557 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -10718,24 +11559,21 @@
1071811559
1071911560 boolean texon = textureon;
1072011561
10721
- if (RENDERPROGRAM > 0)
10722
- {
10723
- gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
10724
- textureon = false;
10725
- }
11562
+ gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11563
+ textureon = false;
11564
+
1072611565 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
1072711566 //System.out.println("ALLO");
1072811567 gl.glColorMask(false, false, false, false);
1072911568 DrawObject(gl);
10730
- if (RENDERPROGRAM > 0)
10731
- {
10732
- gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
10733
- textureon = texon;
10734
- }
11569
+
11570
+ gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11571
+ textureon = texon;
11572
+
1073511573 gl.glColorMask(true, true, true, true);
1073611574
1073711575 gl.glDepthFunc(GL.GL_EQUAL);
10738
- //gl.glDepthMask(false);
11576
+ gl.glDepthMask(false);
1073911577 }
1074011578
1074111579 if (false) // DrawMode() == SHADOW)
....@@ -10889,8 +11727,14 @@
1088911727 {
1089011728 renderpass++;
1089111729 // System.out.println("Draw object... ");
11730
+ STEP = 1;
1089211731 if (FAST) // in case there is no script
10893
- STEP = 16;
11732
+ STEP = 8;
11733
+
11734
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11735
+ {
11736
+ STEP *= 4;
11737
+ }
1089411738
1089511739 //object.FullInvariants();
1089611740
....@@ -10904,23 +11748,44 @@
1090411748 e.printStackTrace();
1090511749 }
1090611750
10907
- if (GrafreeD.RENDERME > 0)
10908
- GrafreeD.RENDERME--; // mechante magouille
11751
+ if (Grafreed.RENDERME > 0)
11752
+ Grafreed.RENDERME--; // mechante magouille
1090911753
1091011754 Globals.ONESTEP = false;
1091111755 }
1091211756
1091311757 static boolean zoomonce = false;
1091411758
11759
+ static void CreateSelectedPoint()
11760
+ {
11761
+ if (selectedpoint == null)
11762
+ {
11763
+ debugpointG = new Sphere();
11764
+ debugpointP = new Sphere();
11765
+ debugpointC = new Sphere();
11766
+ debugpointR = new Sphere();
11767
+
11768
+ selectedpoint = new Superellipsoid();
11769
+
11770
+ for (int i=0; i<8; i++)
11771
+ {
11772
+ debugpoints[i] = new Sphere();
11773
+ }
11774
+ }
11775
+ }
11776
+
1091511777 void DrawObject(GL gl, boolean draw)
1091611778 {
11779
+ // To clear camera values
11780
+ ResetOptions();
11781
+
1091711782 //System.out.println("DRAW OBJECT " + mouseDown);
1091811783 // DrawMode() = SELECTION;
1091911784 //GL gl = getGL();
1092011785 if ((TRACK || SHADOWTRACK) || zoomonce)
1092111786 {
1092211787 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
10923
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11788
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1092411789 pingthread.StepToTarget(true); // true);
1092511790 // zoomonce = false;
1092611791 }
....@@ -10975,7 +11840,14 @@
1097511840
1097611841 usedtextures.clear();
1097711842
10978
- BindTextures(DEFAULT_TEXTURES, 2);
11843
+ try
11844
+ {
11845
+ BindTextures(DEFAULT_TEXTURES, 2);
11846
+ }
11847
+ catch (Exception e)
11848
+ {
11849
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11850
+ }
1097911851 }
1098011852 //System.out.println("--> " + stackdepth);
1098111853 // GrafreeD.traceon();
....@@ -10985,8 +11857,9 @@
1098511857
1098611858 if (DrawMode() == DEFAULT)
1098711859 {
10988
- if (DEBUG)
11860
+ if (Globals.DEBUG)
1098911861 {
11862
+ CreateSelectedPoint();
1099011863 float radius = 0.05f;
1099111864 if (selectedpoint.radius != radius)
1099211865 {
....@@ -11040,20 +11913,32 @@
1104011913 ReleaseTextures(DEFAULT_TEXTURES);
1104111914
1104211915 if (CLEANCACHE)
11043
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11916
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1104411917 {
11045
- String tex = e.nextElement();
11918
+ cTexture tex = e.nextElement();
1104611919
1104711920 // System.out.println("Texture --------- " + tex);
1104811921
11049
- if (tex.equals("WHITE_NOISE"))
11922
+ if (tex.equals("WHITE_NOISE:"))
1105011923 continue;
1105111924
11052
- if (!usedtextures.containsKey(tex))
11925
+ if (!usedtextures.contains(tex))
1105311926 {
11927
+ CacheTexture gettex = texturepigment.get(tex);
1105411928 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11055
- textures.get(tex).texture.dispose();
11056
- textures.remove(tex);
11929
+ if (gettex != null)
11930
+ {
11931
+ gettex.texture.dispose();
11932
+ texturepigment.remove(tex);
11933
+ }
11934
+
11935
+ gettex = texturebump.get(tex);
11936
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11937
+ if (gettex != null)
11938
+ {
11939
+ gettex.texture.dispose();
11940
+ texturebump.remove(tex);
11941
+ }
1105711942 }
1105811943 }
1105911944 }
....@@ -11066,7 +11951,14 @@
1106611951 if (checker != null && DrawMode() == DEFAULT)
1106711952 {
1106811953 //BindTexture(IMMORTAL_TEXTURE);
11069
- BindTextures(checker.GetTextures(), checker.texres);
11954
+ try
11955
+ {
11956
+ BindTextures(checker.GetTextures(), checker.texres);
11957
+ }
11958
+ catch (Exception e)
11959
+ {
11960
+ System.err.println("FAILED: " + checker.GetTextures());
11961
+ }
1107011962 // NEAREST
1107111963 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1107211964 DrawChecker(gl);
....@@ -11148,7 +12040,7 @@
1114812040 return;
1114912041 }
1115012042
11151
- String string = obj.GetToolTip();
12043
+ String string = obj.toString(); //.GetToolTip();
1115212044
1115312045 GL gl = GetGL();
1115412046
....@@ -11465,8 +12357,8 @@
1146512357 //obj.TransformToWorld(light, light);
1146612358 for (int i = tp.size(); --i >= 0;)
1146712359 {
11468
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11469
- LA.xformPos(light, tp.get(i).toParent, light);
12360
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12361
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1147012362 }
1147112363
1147212364
....@@ -11483,8 +12375,8 @@
1148312375 parentcam = cameras[0];
1148412376 }
1148512377
11486
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11487
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12378
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12379
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1148812380
1148912381 LA.xformPos(light, renderCamera.toScreen, light);
1149012382
....@@ -11574,8 +12466,76 @@
1157412466
1157512467 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1157612468
11577
- String program =
12469
+ String programmin =
12470
+ // Min shader
1157812471 "!!ARBfp1.0\n" +
12472
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
12473
+ "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12474
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12475
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12476
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12477
+ "PARAM light2cam0 = program.env[10];" +
12478
+ "PARAM light2cam1 = program.env[11];" +
12479
+ "PARAM light2cam2 = program.env[12];" +
12480
+ "TEMP temp;" +
12481
+ "TEMP light;" +
12482
+ "TEMP ndotl;" +
12483
+ "TEMP normal;" +
12484
+ "TEMP depth;" +
12485
+ "TEMP eye;" +
12486
+ "TEMP pos;" +
12487
+
12488
+ "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12489
+ Normalize("normal") +
12490
+ "MOV light, state.light[0].position;" +
12491
+ "DP3 ndotl.x, light, normal;" +
12492
+
12493
+ // shadow
12494
+ "MOV pos, fragment.texcoord[1];" +
12495
+ "MOV temp, pos;" +
12496
+ ShadowTextureFetch("depth", "temp", "1") +
12497
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12498
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
12499
+
12500
+ // No shadow when out of frustum
12501
+ //"SGE temp.y, depth.z, zero123.y;" +
12502
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12503
+
12504
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
12505
+
12506
+ // Backlit
12507
+ "MOV pos.w, zero123.y;" +
12508
+ "DP4 eye.x, pos, light2cam0;" +
12509
+ "DP4 eye.y, pos, light2cam1;" +
12510
+ "DP4 eye.z, pos, light2cam2;" +
12511
+ Normalize("eye") +
12512
+
12513
+ "DP3 ndotl.y, -eye, normal;" +
12514
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12515
+ "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12516
+ "SUB ndotl.y, zero123.y, ndotl.y;" +
12517
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12518
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12519
+
12520
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12521
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
12522
+
12523
+ // Pigment
12524
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12525
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
12526
+ "MUL temp, temp, ndotl.x;" +
12527
+
12528
+ "MUL temp, temp, zero123.z;" +
12529
+
12530
+ //"MUL temp, temp, ndotl.y;" +
12531
+
12532
+ "MOV temp.w, zero123.y;" + // reset alpha
12533
+ "MOV result.color, temp;" +
12534
+ "END";
12535
+
12536
+ String programmax =
12537
+ "!!ARBfp1.0\n" +
12538
+
1157912539 //"OPTION ARB_fragment_program_shadow;" +
1158012540 "PARAM light2cam0 = program.env[10];" +
1158112541 "PARAM light2cam1 = program.env[11];" +
....@@ -11690,8 +12650,7 @@
1169012650 "TEMP shininess;" +
1169112651 "\n" +
1169212652 "MOV texSamp, one;" +
11693
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
11694
-
12653
+
1169512654 "MOV mapgrid.x, one2048th.x;" +
1169612655 "MOV temp, fragment.texcoord[1];" +
1169712656 /*
....@@ -11712,20 +12671,20 @@
1171212671 "MUL temp, floor, mapgrid.x;" +
1171312672 //"TEX depth0, temp, texture[1], 2D;" +
1171412673 (((mode & FP_SOFTSHADOW) == 0) ? "" :
11715
- TextureFetch("depth0", "temp", "1") +
12674
+ ShadowTextureFetch("depth0", "temp", "1") +
1171612675 "") +
1171712676 "ADD temp.x, temp.x, mapgrid.x;" +
1171812677 //"TEX depth1, temp, texture[1], 2D;" +
1171912678 (((mode & FP_SOFTSHADOW) == 0) ? "" :
11720
- TextureFetch("depth1", "temp", "1") +
12679
+ ShadowTextureFetch("depth1", "temp", "1") +
1172112680 "") +
1172212681 "ADD temp.y, temp.y, mapgrid.x;" +
1172312682 //"TEX depth2, temp, texture[1], 2D;" +
11724
- TextureFetch("depth2", "temp", "1") +
12683
+ ShadowTextureFetch("depth2", "temp", "1") +
1172512684 "SUB temp.x, temp.x, mapgrid.x;" +
1172612685 //"TEX depth3, temp, texture[1], 2D;" +
1172712686 (((mode & FP_SOFTSHADOW) == 0) ? "" :
11728
- TextureFetch("depth3", "temp", "1") +
12687
+ ShadowTextureFetch("depth3", "temp", "1") +
1172912688 "") +
1173012689 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1173112690 //"MOV params, material;" +
....@@ -12096,10 +13055,10 @@
1209613055 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1209713056 "") +
1209813057
12099
- // display shadow only (bump == 0)
13058
+ // display shadow only (fakedepth == 0)
1210013059 "SUB temp.x, half.x, shadow.x;" +
12101
- "MOV temp.y, -params6.x;" +
12102
- "SLT temp.z, temp.y, zero.x;" +
13060
+ "MOV temp.y, -params5.z;" + // params6.x;" +
13061
+ "SLT temp.z, temp.y, -c256i.x;" +
1210313062 "SUB temp.y, one.x, temp.z;" +
1210413063 "MUL temp.x, temp.x, temp.y;" +
1210513064 "KIL temp.x;" +
....@@ -12228,8 +13187,10 @@
1222813187 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1222913188
1223013189 "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
13190
+ // Tuning for default skin
13191
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
13192
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
13193
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1223313194 "MUL temp.x, temp.x, temp.y;" +
1223413195
1223513196 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12428,7 +13389,14 @@
1242813389 //once = true;
1242913390 }
1243013391
12431
- System.out.print("Program #" + mode + "; length = " + program.length());
13392
+ String program = programmax;
13393
+
13394
+ if (Globals.MINSHADER)
13395
+ {
13396
+ program = programmin;
13397
+ }
13398
+
13399
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1243213400 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1243313401 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1243413402
....@@ -12521,25 +13489,26 @@
1252113489 return out;
1252213490 }
1252313491
12524
- String TextureFetch(String dest, String src, String unit)
13492
+ // Also does frustum culling
13493
+ String ShadowTextureFetch(String dest, String src, String unit)
1252513494 {
1252613495 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1252713496 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1252813497 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13498
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13499
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1252913500 "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
12530
- "SLT " + src + ".z, " + src + ".x, one.x;" +
12531
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
12532
- "SLT " + src + ".z, " + src + ".y, one.x;" +
12533
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13501
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13502
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1253413503 //"SWZ buffer, temp, w,w,w,w;";
12535
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13504
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1253613505 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1253713506 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1253813507 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
12539
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13508
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1254013509
12541
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
12542
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13510
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13511
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1254313512 }
1254413513
1254513514 String Shadow(String depth, String shadow)
....@@ -12561,12 +13530,16 @@
1256113530
1256213531 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1256313532 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13533
+
13534
+ // Compare fragment depth in light space with shadowmap.
1256413535 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1256513536 "SGE temp.y, temp.x, zero.x;" +
12566
- "SUB " + shadow + ".y, one.x, temp.y;" +
13537
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13538
+
13539
+ // Reverse comparison
1256713540 "SUB temp.x, one.x, temp.x;" +
1256813541 "MUL " + shadow + ".x, temp.x, temp.y;" +
12569
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13542
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1257013543 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1257113544
1257213545 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12580,6 +13553,10 @@
1258013553 // No shadow for backface
1258113554 "DP3 temp.x, normal, lightd;" +
1258213555 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13556
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13557
+
13558
+ // No shadow when out of frustum
13559
+ "SGE temp.x, " + depth + ".z, one.z;" +
1258313560 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1258413561 "";
1258513562 }
....@@ -12726,7 +13703,8 @@
1272613703 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1272713704 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1272813705 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
12729
- Object3D.cVector2[] vector2buffer;
13706
+
13707
+ //Object3D.cVector2[] vector2buffer;
1273013708
1273113709 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1273213710 // OUT : diff, spec
....@@ -12742,9 +13720,10 @@
1274213720 "DP3 " + dest + ".z," + "normals," + "eye;" +
1274313721 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1274413722 //"MOV " + dest + ".w," + "normal.z;" +
12745
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
12746
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
12747
- //"MOV " + dest + ".z," + "params2.w;" +
13723
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13724
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13725
+
13726
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1274813727 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1274913728 "RCP " + dest + ".w," + dest + ".w;" +
1275013729 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13138,7 +14117,7 @@
1313814117 public void mousePressed(MouseEvent e)
1313914118 {
1314014119 //System.out.println("mousePressed: " + e);
13141
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
14120
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1314214121 }
1314314122
1314414123 static long prevtime = 0;
....@@ -13165,6 +14144,7 @@
1316514144
1316614145 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1316714146
14147
+ if (BUTTONLESSWHEEL)
1316814148 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1316914149 {
1317014150 return;
....@@ -13173,7 +14153,7 @@
1317314153 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1317414154
1317514155 // TIMER
13176
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
14156
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1317714157 {
1317814158 keepboxmode = BOXMODE;
1317914159 keepsupport = SUPPORT;
....@@ -13213,8 +14193,8 @@
1321314193 // mode |= META;
1321414194 //}
1321514195
13216
- SetMouseMode(WHEEL | e.getModifiersEx());
13217
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
14196
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
14197
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1321814198 anchorX = ax;
1321914199 anchorY = ay;
1322014200 prevX = px;
....@@ -13248,6 +14228,7 @@
1324814228 else
1324914229 if (evt.getSource() == AAtimer)
1325014230 {
14231
+ Globals.TIMERRUNNING = false;
1325114232 if (mouseDown)
1325214233 {
1325314234 //new Exception().printStackTrace();
....@@ -13273,6 +14254,10 @@
1327314254 // LIVE = waslive;
1327414255 // wasliveok = true;
1327514256 // waslive = false;
14257
+
14258
+ // May 2019 Forget it:
14259
+ if (true)
14260
+ return;
1327614261
1327714262 // source == timer
1327814263 if (mouseDown)
....@@ -13303,7 +14288,7 @@
1330314288
1330414289 // fev 2014???
1330514290 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13306
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14291
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1330714292 pingthread.StepToTarget(true); // true);
1330814293 }
1330914294 // if (!LIVE)
....@@ -13312,12 +14297,13 @@
1331214297
1331314298 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1331414299
13315
- void clickStart(int x, int y, int modifiers)
14300
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1331614301 {
1331714302 if (!wasliveok)
1331814303 return;
1331914304
1332014305 AAtimer.restart(); //
14306
+ Globals.TIMERRUNNING = true;
1332114307
1332214308 // waslive = LIVE;
1332314309 // LIVE = false;
....@@ -13329,7 +14315,7 @@
1332914315 // touched = true; // main DL
1333014316 if (isRenderer)
1333114317 {
13332
- SetMouseMode(modifiers);
14318
+ SetMouseMode(modifiers, modifiersex);
1333314319 }
1333414320
1333514321 selectX = anchorX = x;
....@@ -13342,7 +14328,7 @@
1334214328 clicked = true;
1334314329 hold = false;
1334414330
13345
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14331
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1334614332 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1334714333 {
1334814334 // System.out.println("RESTART II " + modifiers);
....@@ -13367,14 +14353,15 @@
1336714353 drag = false;
1336814354 //System.out.println("Mouse DOWN");
1336914355 editObj = false;
13370
- ClickInfo info = new ClickInfo();
13371
- info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
13372
- info.pane = this;
13373
- info.camera = renderCamera;
13374
- info.x = x;
13375
- info.y = y;
13376
- info.modifiers = modifiers;
13377
- editObj = object.doEditClick(info, 0);
14356
+ //ClickInfo info = new ClickInfo();
14357
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14358
+ object.clickInfo.pane = this;
14359
+ object.clickInfo.camera = renderCamera;
14360
+ object.clickInfo.x = x;
14361
+ object.clickInfo.y = y;
14362
+ object.clickInfo.modifiers = modifiersex;
14363
+ editObj = object.doEditClick(//info,
14364
+ 0);
1337814365 if (!editObj)
1337914366 {
1338014367 hasMarquee = true;
....@@ -13390,11 +14377,14 @@
1339014377
1339114378 public void mouseDragged(MouseEvent e)
1339214379 {
14380
+ Globals.MOUSEDRAGGED = true;
14381
+
14382
+ //System.out.println("mouseDragged: " + e);
1339314383 if (isRenderer)
1339414384 movingcamera = true;
14385
+
1339514386 //if (drawing)
1339614387 //return;
13397
- //System.out.println("mouseDragged: " + e);
1339814388 if ((e.getModifiersEx() & CTRL) != 0
1339914389 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1340014390 {
....@@ -13402,7 +14392,7 @@
1340214392 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1340314393 }
1340414394 else
13405
- drag(e.getX(), e.getY(), e.getModifiersEx());
14395
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1340614396
1340714397 //try { Thread.sleep(1); } catch (Exception ex) {}
1340814398 }
....@@ -13575,6 +14565,7 @@
1357514565
1357614566 public void run()
1357714567 {
14568
+ new Exception().printStackTrace();
1357814569 System.exit(0);
1357914570 for (;;)
1358014571 {
....@@ -13638,7 +14629,7 @@
1363814629 {
1363914630 Globals.lighttouched = true;
1364014631 }
13641
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14632
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1364214633 }
1364314634 //else
1364414635 }
....@@ -13652,12 +14643,12 @@
1365214643 void GoDown(int mod)
1365314644 {
1365414645 MODIFIERS |= COMMAND;
13655
- /*
14646
+ /**/
1365614647 if((mod&SHIFT) == SHIFT)
13657
- manipCamera.RotatePosition(0, -speed);
14648
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
1365814649 else
13659
- manipCamera.BackForth(0, -speed*delta, getWidth());
13660
- */
14650
+ manipCamera.RotatePosition(0, -speed);
14651
+ /**/
1366114652 if ((mod & SHIFT) == SHIFT)
1366214653 {
1366314654 mouseMode = mouseMode; // VR??
....@@ -13673,12 +14664,12 @@
1367314664 void GoUp(int mod)
1367414665 {
1367514666 MODIFIERS |= COMMAND;
13676
- /*
14667
+ /**/
1367714668 if((mod&SHIFT) == SHIFT)
13678
- manipCamera.RotatePosition(0, speed);
14669
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
1367914670 else
13680
- manipCamera.BackForth(0, speed*delta, getWidth());
13681
- */
14671
+ manipCamera.RotatePosition(0, speed);
14672
+ /**/
1368214673 if ((mod & SHIFT) == SHIFT)
1368314674 {
1368414675 mouseMode = mouseMode;
....@@ -13694,12 +14685,12 @@
1369414685 void GoLeft(int mod)
1369514686 {
1369614687 MODIFIERS |= COMMAND;
13697
- /*
14688
+ /**/
1369814689 if((mod&SHIFT) == SHIFT)
13699
- manipCamera.RotatePosition(speed, 0);
13700
- else
1370114690 manipCamera.Translate(speed*delta, 0, getWidth());
13702
- */
14691
+ else
14692
+ manipCamera.RotatePosition(speed, 0);
14693
+ /**/
1370314694 if ((mod & SHIFT) == SHIFT)
1370414695 {
1370514696 mouseMode = mouseMode;
....@@ -13715,12 +14706,12 @@
1371514706 void GoRight(int mod)
1371614707 {
1371714708 MODIFIERS |= COMMAND;
13718
- /*
14709
+ /**/
1371914710 if((mod&SHIFT) == SHIFT)
13720
- manipCamera.RotatePosition(-speed, 0);
13721
- else
1372214711 manipCamera.Translate(-speed*delta, 0, getWidth());
13723
- */
14712
+ else
14713
+ manipCamera.RotatePosition(-speed, 0);
14714
+ /**/
1372414715 if ((mod & SHIFT) == SHIFT)
1372514716 {
1372614717 mouseMode = mouseMode;
....@@ -13738,7 +14729,7 @@
1373814729 int X, Y;
1373914730 boolean SX, SY;
1374014731
13741
- void drag(int x, int y, int modifiers)
14732
+ void drag(int x, int y, int modifiers, int modifiersex)
1374214733 {
1374314734 if (IsFrozen())
1374414735 {
....@@ -13747,17 +14738,17 @@
1374714738
1374814739 drag = true; // NEW
1374914740
13750
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14741
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1375114742
1375214743 X = x;
1375314744 Y = y;
1375414745 // floating state for animation
13755
- MODIFIERS = modifiers;
13756
- modifiers &= ~1024;
14746
+ MODIFIERS = modifiersex;
14747
+ modifiersex &= ~1024;
1375714748 if (false) // modifiers != 0)
1375814749 {
1375914750 //new Exception().printStackTrace();
13760
- System.out.println("mouseDragged: " + modifiers);
14751
+ System.out.println("mouseDragged: " + modifiersex);
1376114752 System.out.println("SHIFT = " + SHIFT);
1376214753 System.out.println("CONTROL = " + COMMAND);
1376314754 System.out.println("META = " + META);
....@@ -13770,14 +14761,16 @@
1377014761 if (editObj)
1377114762 {
1377214763 drag = true;
13773
- ClickInfo info = new ClickInfo();
13774
- info.bounds.setBounds(0, 0,
14764
+ //ClickInfo info = new ClickInfo();
14765
+ object.clickInfo.bounds.setBounds(0, 0,
1377514766 (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
13776
- info.pane = this;
13777
- info.camera = renderCamera;
13778
- info.x = x;
13779
- info.y = y;
13780
- object.editWindow.copy.doEditDrag(info);
14767
+ object.clickInfo.pane = this;
14768
+ object.clickInfo.camera = renderCamera;
14769
+ object.clickInfo.x = x;
14770
+ object.clickInfo.y = y;
14771
+ object //.GetWindow().copy
14772
+ .doEditDrag(//info,
14773
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1378114774 } else
1378214775 {
1378314776 if (x < startX)
....@@ -13926,23 +14919,27 @@
1392614919 }
1392714920 }
1392814921
14922
+// ClickInfo clickInfo = new ClickInfo();
14923
+
1392914924 public void mouseMoved(MouseEvent e)
1393014925 {
1393114926 //System.out.println("mouseMoved: " + e);
13932
-
1393314927 if (isRenderer)
1393414928 return;
1393514929
13936
- ClickInfo ci = new ClickInfo();
13937
- ci.x = e.getX();
13938
- ci.y = e.getY();
13939
- ci.modifiers = e.getModifiersEx();
13940
- ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
13941
- ci.pane = this;
13942
- ci.camera = renderCamera;
14930
+ // Mouse cursor feedback
14931
+ object.clickInfo.x = e.getX();
14932
+ object.clickInfo.y = e.getY();
14933
+ object.clickInfo.modifiers = e.getModifiersEx();
14934
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14935
+ object.clickInfo.pane = this;
14936
+ object.clickInfo.camera = renderCamera;
1394314937 if (!isRenderer)
1394414938 {
13945
- if (object.editWindow.copy.doEditClick(ci, 0))
14939
+ //ObjEditor editWindow = object.editWindow;
14940
+ //Object3D copy = editWindow.copy;
14941
+ if (object.doEditClick(//clickInfo,
14942
+ 0))
1394614943 {
1394714944 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1394814945 } else
....@@ -13954,7 +14951,11 @@
1395414951
1395514952 public void mouseReleased(MouseEvent e)
1395614953 {
14954
+ Globals.MOUSEDRAGGED = false;
14955
+
1395714956 movingcamera = false;
14957
+ X = 0; // getBounds().width/2;
14958
+ Y = 0; // getBounds().height/2;
1395814959 //System.out.println("mouseReleased: " + e);
1395914960 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1396014961 }
....@@ -13977,9 +14978,9 @@
1397714978 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1397814979 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1397914980
13980
- if (control || command || IsFrozen())
14981
+// No delay if (control || command || IsFrozen())
1398114982 timeout = true;
13982
- else
14983
+// ?? May 2019 else
1398314984 // timer.setDelay((modifiers & 128) != 0?0:350);
1398414985 mouseDown = false;
1398514986 if (!control && !command) // june 2013
....@@ -14089,7 +15090,7 @@
1408915090 System.out.println("keyReleased: " + e);
1409015091 }
1409115092
14092
- void SetMouseMode(int modifiers)
15093
+ void SetMouseMode(int modifiers, int modifiersex)
1409315094 {
1409415095 //System.out.println("SetMouseMode = " + modifiers);
1409515096 //modifiers &= ~1024;
....@@ -14101,25 +15102,25 @@
1410115102 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1410215103 // return;
1410315104 //System.out.println("SetMode = " + modifiers);
14104
- if ((modifiers & WHEEL) == WHEEL)
15105
+ if ((modifiersex & WHEEL) == WHEEL)
1410515106 {
1410615107 mouseMode |= ZOOM;
1410715108 }
1410815109
1410915110 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14110
- if (capsLocked || (modifiers & META) == META)
15111
+ if (capsLocked) // || (modifiers & META) == META)
1411115112 {
1411215113 mouseMode |= VR; // BACKFORTH;
1411315114 }
14114
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
15115
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1411515116 {
1411615117 mouseMode |= SELECT;
1411715118 }
14118
- if ((modifiers & COMMAND) == COMMAND)
15119
+ if ((modifiersex & COMMAND) == COMMAND)
1411915120 {
1412015121 mouseMode |= SELECT;
1412115122 }
14122
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
15123
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1412315124 {
1412415125 mouseMode &= ~VR;
1412515126 mouseMode |= TRANSLATE;
....@@ -14148,7 +15149,7 @@
1414815149
1414915150 if (isRenderer) //
1415015151 {
14151
- SetMouseMode(modifiers);
15152
+ SetMouseMode(0, modifiers);
1415215153 }
1415315154
1415415155 Globals.theRenderer.keyPressed(key);
....@@ -14210,7 +15211,8 @@
1421015211 // break;
1421115212 case 'T':
1421215213 CACHETEXTURE ^= true;
14213
- textures.clear();
15214
+ texturepigment.clear();
15215
+ texturebump.clear();
1421415216 // repaint();
1421515217 break;
1421615218 case 'Y':
....@@ -14295,7 +15297,9 @@
1429515297 case 'E' : COMPACT ^= true;
1429615298 repaint();
1429715299 break;
14298
- case 'W' : DEBUGHSB ^= true;
15300
+ case 'W' : // Wide Window (fullscreen)
15301
+ //DEBUGHSB ^= true;
15302
+ ObjEditor.theFrame.ToggleFullScreen();
1429915303 repaint();
1430015304 break;
1430115305 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14320,8 +15324,8 @@
1432015324 RevertCamera();
1432115325 repaint();
1432215326 break;
14323
- case 'L':
1432415327 case 'l':
15328
+ //case 'L':
1432515329 if (lightMode)
1432615330 {
1432715331 lightMode = false;
....@@ -14385,20 +15389,24 @@
1438515389 OCCLUSION_CULLING ^= true;
1438615390 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1438715391 break;
14388
- case '0': envyoff ^= true; repaint(); break;
15392
+ //case '0': envyoff ^= true; repaint(); break;
1438915393 case '1':
1439015394 case '2':
1439115395 case '3':
1439215396 case '4':
1439315397 case '5':
14394
- newenvy = Character.getNumericValue(key);
14395
- repaint();
14396
- break;
1439715398 case '6':
1439815399 case '7':
1439915400 case '8':
1440015401 case '9':
14401
- BGcolor = (key - '6')/3.f;
15402
+ if (true) // envyoff)
15403
+ {
15404
+ BGcolor = (key - '1')/8.f;
15405
+ }
15406
+ else
15407
+ {
15408
+ //newenvy = Character.getNumericValue(key);
15409
+ }
1440215410 repaint();
1440315411 break;
1440415412 case '!':
....@@ -14464,9 +15472,9 @@
1446415472 case '_':
1446515473 kompactbit = 5;
1446615474 break;
14467
- case '+':
14468
- kompactbit = 6;
14469
- break;
15475
+// case '+':
15476
+// kompactbit = 6;
15477
+// break;
1447015478 case ' ':
1447115479 lightMode ^= true;
1447215480 Globals.lighttouched = true;
....@@ -14478,13 +15486,14 @@
1447815486 case ESC:
1447915487 RENDERPROGRAM += 1;
1448015488 RENDERPROGRAM %= 3;
15489
+
1448115490 repaint();
1448215491 break;
1448315492 case 'Z':
1448415493 //RESIZETEXTURE ^= true;
1448515494 //break;
1448615495 case 'z':
14487
- RENDERSHADOW ^= true;
15496
+ Globals.RENDERSHADOW ^= true;
1448815497 Globals.lighttouched = true;
1448915498 repaint();
1449015499 break;
....@@ -14517,8 +15526,9 @@
1451715526 case DELETE:
1451815527 ClearSelection();
1451915528 break;
14520
- /*
1452115529 case '+':
15530
+
15531
+ /*
1452215532 //fontsize += 1;
1452315533 bbzoom *= 2;
1452415534 repaint();
....@@ -14535,17 +15545,17 @@
1453515545 case '=':
1453615546 IncDepth();
1453715547 //fontsize += 1;
14538
- object.editWindow.refreshContents(true);
15548
+ object.GetWindow().refreshContents(true);
1453915549 maskbit = 6;
1454015550 break;
1454115551 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1454215552 DecDepth();
1454315553 maskbit = 5;
1454415554 //if(fontsize > 1) fontsize -= 1;
14545
- if (object.editWindow == null)
14546
- new Exception().printStackTrace();
14547
- else
14548
- object.editWindow.refreshContents(true);
15555
+// if (object.editWindow == null)
15556
+// new Exception().printStackTrace();
15557
+// else
15558
+ object.GetWindow().refreshContents(true);
1454915559 break;
1455015560 case '{':
1455115561 manipCamera.shaper_fovy /= 1.1;
....@@ -14608,7 +15618,7 @@
1460815618 //mode = ROTATE;
1460915619 if ((MODIFIERS & COMMAND) == 0) // VR??
1461015620 {
14611
- SetMouseMode(modifiers);
15621
+ SetMouseMode(0, modifiers);
1461215622 }
1461315623 }
1461415624
....@@ -14742,8 +15752,9 @@
1474215752
1474315753 protected void processMouseMotionEvent(MouseEvent e)
1474415754 {
14745
- //System.out.println("processMouseMotionEvent: " + mouseMode);
14746
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15755
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15756
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15757
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1474715758 {
1474815759 mouseMoved(e);
1474915760 } else
....@@ -14768,11 +15779,12 @@
1476815779 }
1476915780 */
1477015781
14771
- object.editWindow.EditSelection();
15782
+ object.GetWindow().EditSelection(false);
1477215783 }
1477315784
1477415785 void SelectParent()
1477515786 {
15787
+ new Exception().printStackTrace();
1477615788 System.exit(0);
1477715789 Composite group = (Composite) object;
1477815790 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -14784,10 +15796,10 @@
1478415796 {
1478515797 //selectees.remove(i);
1478615798 System.out.println("select parent of " + elem);
14787
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15799
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1478815800 } else
1478915801 {
14790
- group.editWindow.Select(elem.GetTreePath(), first, true);
15802
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1479115803 }
1479215804
1479315805 first = false;
....@@ -14796,6 +15808,7 @@
1479615808
1479715809 void SelectChildren()
1479815810 {
15811
+ new Exception().printStackTrace();
1479915812 System.exit(0);
1480015813 /*
1480115814 Composite group = (Composite) object;
....@@ -14828,12 +15841,12 @@
1482815841 for (int j = 0; j < group.children.size(); j++)
1482915842 {
1483015843 elem = (Object3D) group.children.elementAt(j);
14831
- object.editWindow.Select(elem.GetTreePath(), first, true);
15844
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1483215845 first = false;
1483315846 }
1483415847 } else
1483515848 {
14836
- object.editWindow.Select(elem.GetTreePath(), first, true);
15849
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1483715850 }
1483815851
1483915852 first = false;
....@@ -14844,21 +15857,21 @@
1484415857 {
1484515858 //Composite group = (Composite) object;
1484615859 Object3D group = object;
14847
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15860
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1484815861 }
1484915862
1485015863 void ResetTransform(int mask)
1485115864 {
1485215865 //Composite group = (Composite) object;
1485315866 Object3D group = object;
14854
- group.editWindow.ResetTransform(mask);
15867
+ group.GetWindow().ResetTransform(mask);
1485515868 }
1485615869
1485715870 void FlipTransform()
1485815871 {
1485915872 //Composite group = (Composite) object;
1486015873 Object3D group = object;
14861
- group.editWindow.FlipTransform();
15874
+ group.GetWindow().FlipTransform();
1486215875 // group.editWindow.ReduceMesh(true);
1486315876 }
1486415877
....@@ -14866,7 +15879,7 @@
1486615879 {
1486715880 //Composite group = (Composite) object;
1486815881 Object3D group = object;
14869
- group.editWindow.PrintMemory();
15882
+ group.GetWindow().PrintMemory();
1487015883 // group.editWindow.ReduceMesh(true);
1487115884 }
1487215885
....@@ -14874,7 +15887,7 @@
1487415887 {
1487515888 //Composite group = (Composite) object;
1487615889 Object3D group = object;
14877
- group.editWindow.ResetCentroid();
15890
+ group.GetWindow().ResetCentroid();
1487815891 }
1487915892
1488015893 void IncDepth()
....@@ -14956,11 +15969,11 @@
1495615969
1495715970 int width = getBounds().width;
1495815971 int height = getBounds().height;
14959
- ClickInfo info = new ClickInfo();
14960
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1496115972 //Image img = CreateImage(width, height);
1496215973 //System.out.println("width = " + width + "; height = " + height + "\n");
15974
+
1496315975 Graphics gr = g; // img.getGraphics();
15976
+
1496415977 if (!hasMarquee)
1496515978 {
1496615979 if (Xmin < Xmax) // !locked)
....@@ -15032,40 +16045,88 @@
1503216045 }
1503316046 if (object != null && !hasMarquee)
1503416047 {
16048
+ if (object.clickInfo == null)
16049
+ object.clickInfo = new ClickInfo();
16050
+ ClickInfo info = object.clickInfo;
16051
+ //ClickInfo info = new ClickInfo();
16052
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
16053
+
1503516054 if (isRenderer)
1503616055 {
15037
- info.flags++;
16056
+ object.clickInfo.flags++;
1503816057 double frameAspect = (double) width / (double) height;
1503916058 if (frameAspect > renderCamera.aspect)
1504016059 {
1504116060 int desired = (int) ((double) height * renderCamera.aspect);
15042
- info.bounds.width -= width - desired;
15043
- info.bounds.x += (width - desired) / 2;
16061
+ object.clickInfo.bounds.width -= width - desired;
16062
+ object.clickInfo.bounds.x += (width - desired) / 2;
1504416063 } else
1504516064 {
1504616065 int desired = (int) ((double) width / renderCamera.aspect);
15047
- info.bounds.height -= height - desired;
15048
- info.bounds.y += (height - desired) / 2;
16066
+ object.clickInfo.bounds.height -= height - desired;
16067
+ object.clickInfo.bounds.y += (height - desired) / 2;
1504916068 }
1505016069 }
15051
- info.g = gr;
15052
- info.camera = renderCamera;
16070
+
16071
+ object.clickInfo.g = gr;
16072
+ object.clickInfo.camera = renderCamera;
1505316073 /*
1505416074 // Memory intensive (brep.verticescopy)
1505516075 if (!(object instanceof Composite))
1505616076 object.draw(info, 0, false); // SLOW :
1505716077 */
15058
- if (!isRenderer)
16078
+ if (!isRenderer) // && drag)
1505916079 {
15060
- object.drawEditHandles(info, 0);
16080
+ Grafreed.Assert(object != null);
16081
+ Grafreed.Assert(object.selection != null);
16082
+ if (object.selection.Size() > 0)
16083
+ {
16084
+ int hitSomething = object.selection.get(0).hitSomething;
16085
+
16086
+ object.clickInfo.DX = 0;
16087
+ object.clickInfo.DY = 0;
16088
+ object.clickInfo.W = 1;
16089
+ if (hitSomething == Object3D.hitCenter)
16090
+ {
16091
+ info.DX = X;
16092
+ if (X != 0)
16093
+ info.DX -= info.bounds.width/2;
16094
+
16095
+ info.DY = Y;
16096
+ if (Y != 0)
16097
+ info.DY -= info.bounds.height/2;
16098
+ }
16099
+
16100
+ object.drawEditHandles(//info,
16101
+ 0);
16102
+
16103
+ if (drag && (X != 0 || Y != 0))
16104
+ {
16105
+ switch (hitSomething)
16106
+ {
16107
+ case Object3D.hitCenter: gr.setColor(Color.pink);
16108
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16109
+ break;
16110
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
16111
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16112
+ break;
16113
+ case Object3D.hitScale: gr.setColor(Color.cyan);
16114
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16115
+ break;
16116
+ }
16117
+
16118
+ }
16119
+ }
1506116120 }
1506216121 }
16122
+
1506316123 if (isRenderer)
1506416124 {
1506516125 //gr.setColor(Color.black);
1506616126 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1506716127 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1506816128 }
16129
+
1506916130 if (hasMarquee)
1507016131 {
1507116132 gr.setXORMode(Color.white);
....@@ -15178,6 +16239,7 @@
1517816239 public boolean mouseDown(Event evt, int x, int y)
1517916240 {
1518016241 System.out.println("mouseDown: " + evt);
16242
+ System.exit(0);
1518116243 /*
1518216244 locked = true;
1518316245 drag = false;
....@@ -15221,7 +16283,7 @@
1522116283 {
1522216284 keyPressed(0, modifiers);
1522316285 }
15224
- clickStart(x, y, modifiers);
16286
+ // clickStart(x, y, modifiers);
1522516287 return true;
1522616288 }
1522716289
....@@ -15339,7 +16401,7 @@
1533916401 {
1534016402 keyReleased(0, 0);
1534116403 }
15342
- drag(x, y, modifiers);
16404
+ drag(x, y, 0, modifiers);
1534316405 return true;
1534416406 }
1534516407
....@@ -15471,7 +16533,7 @@
1547116533 Object3D object;
1547216534 static Object3D trackedobject;
1547316535 Camera renderCamera; // Light or Eye (or Occlusion)
15474
- /*static*/ Camera manipCamera; // Light or Eye
16536
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1547516537 /*static*/ Camera eyeCamera;
1547616538 /*static*/ Camera lightCamera;
1547716539 int cameracount;
....@@ -15535,6 +16597,8 @@
1553516597 private /*static*/ boolean firstime;
1553616598 private /*static*/ cVector newView = new cVector();
1553716599 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16600
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16601
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1553816602 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1553916603 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1554016604 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -15547,29 +16611,67 @@
1554716611 {
1554816612 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1554916613
16614
+ int usedsuf = 0;
16615
+
1555016616 for (int i = 0; i < suffixes.length; i++)
1555116617 {
15552
- String resourceName = basename + suffixes[i] + "." + suffix;
15553
- TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
15554
- mipmapped,
15555
- FileUtil.getFileSuffix(resourceName));
15556
- if (data == null)
16618
+ String[] suffixe = suffixes;
16619
+ String[] fallback = suffixes2;
16620
+ String[] fallfallback = suffixes3;
16621
+
16622
+ for (int c=usedsuf; --c>=0;)
1555716623 {
15558
- throw new IOException("Unable to load texture " + resourceName);
16624
+// String[] temp = suffixe;
16625
+// suffixe = fallback;
16626
+// fallback = fallfallback;
16627
+// fallfallback = temp;
1555916628 }
16629
+
16630
+ String resourceName = basename + suffixe[i] + "." + suffix;
16631
+ TextureData data;
16632
+
16633
+ try
16634
+ {
16635
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16636
+ mipmapped,
16637
+ FileUtil.getFileSuffix(resourceName));
16638
+ }
16639
+ catch (Exception e)
16640
+ {
16641
+ try
16642
+ {
16643
+ resourceName = basename + fallback[i] + "." + suffix;
16644
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16645
+ mipmapped,
16646
+ FileUtil.getFileSuffix(resourceName));
16647
+ }
16648
+ catch (Exception e2)
16649
+ {
16650
+ resourceName = basename + fallfallback[i] + "." + suffix;
16651
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16652
+ mipmapped,
16653
+ FileUtil.getFileSuffix(resourceName));
16654
+ }
16655
+ }
16656
+
1556016657 //System.out.println("Target = " + targets[i]);
1556116658 cubemap.updateImage(data, targets[i]);
1556216659 }
1556316660
1556416661 return cubemap;
1556516662 }
16663
+
1556616664 int bigsphere = -1;
1556716665
1556816666 float BGcolor = 0.5f;
1556916667
15570
- private void DrawSkyBox(GL gl)
16668
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16669
+
16670
+ private void DrawSkyBox(GL gl, float ratio)
1557116671 {
15572
- if (envyoff || cubemap == null)
16672
+ if (//envyoff ||
16673
+ WIREFRAME ||
16674
+ cubemap == null)
1557316675 {
1557416676 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1557516677 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -15584,7 +16686,17 @@
1558416686 // Compensates for ExaminerViewer's modification of modelview matrix
1558516687 gl.glMatrixMode(GL.GL_MODELVIEW);
1558616688 gl.glLoadIdentity();
16689
+ gl.glScalef(1,ratio,1);
1558716690
16691
+// colorV[0] = 2;
16692
+// colorV[1] = 2;
16693
+// colorV[2] = 2;
16694
+// colorV[3] = 1;
16695
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16696
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16697
+//
16698
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16699
+
1558816700 //gl.glActiveTexture(GL.GL_TEXTURE1);
1558916701 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1559016702
....@@ -15616,6 +16728,7 @@
1561616728 {
1561716729 gl.glScalef(1.0f, -1.0f, 1.0f);
1561816730 }
16731
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1561916732 gl.glMultMatrixd(viewrot_1, 0);
1562016733 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1562116734 //viewer.updateInverseRotation(gl);
....@@ -15756,16 +16869,16 @@
1575616869 cStatic.objectstack[materialdepth++] = checker;
1575716870 //System.out.println("material " + material);
1575816871 //Applet3D.tracein(this, selected);
15759
- vector2buffer = checker.projectedVertices;
16872
+ //vector2buffer = checker.projectedVertices;
1576016873
1576116874 //checker.GetMaterial().Draw(this, false); // true);
15762
- DrawMaterial(checker.GetMaterial(), false); // true);
16875
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1576316876
1576416877 materialdepth -= 1;
1576516878 if (materialdepth > 0)
1576616879 {
15767
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
15768
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16880
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16881
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1576916882 }
1577016883 //checker.GetMaterial().opacity = 1f;
1577116884 ////checker.GetMaterial().ambient = 1f;
....@@ -15851,6 +16964,14 @@
1585116964 }
1585216965 }
1585316966
16967
+ private Object3D GetFolder()
16968
+ {
16969
+ Object3D folder = object.GetWindow().copy;
16970
+ if (object.GetWindow().copy.selection.Size() > 0)
16971
+ folder = object.GetWindow().copy.selection.elementAt(0);
16972
+ return folder;
16973
+ }
16974
+
1585416975 class SelectBuffer implements GLEventListener
1585516976 {
1585616977
....@@ -15866,7 +16987,7 @@
1586616987 //new Exception().printStackTrace();
1586716988 System.out.println("select buffer init");
1586816989 // Use debug pipeline
15869
- drawable.setGL(new DebugGL(drawable.getGL()));
16990
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1587016991
1587116992 GL gl = drawable.getGL();
1587216993
....@@ -15909,6 +17030,7 @@
1590917030 {
1591017031 if (!selection)
1591117032 {
17033
+ new Exception().printStackTrace();
1591217034 System.exit(0);
1591317035 return;
1591417036 }
....@@ -15929,6 +17051,17 @@
1592917051
1593017052 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1593117053
17054
+ if (PAINTMODE)
17055
+ {
17056
+ if (object.GetWindow().copy.selection.Size() > 0)
17057
+ {
17058
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
17059
+
17060
+ // Make what you paint not selectable.
17061
+ paintobj.ResetSelectable();
17062
+ }
17063
+ }
17064
+
1593217065 //int tmp = selection_view;
1593317066 //selection_view = -1;
1593417067 int temp = DrawMode();
....@@ -15940,6 +17073,17 @@
1594017073 // temp = DEFAULT; // patch for selection debug
1594117074 Globals.drawMode = temp; // WARNING
1594217075
17076
+ if (PAINTMODE)
17077
+ {
17078
+ if (object.GetWindow().copy.selection.Size() > 0)
17079
+ {
17080
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
17081
+
17082
+ // Revert.
17083
+ paintobj.RestoreSelectable();
17084
+ }
17085
+ }
17086
+
1594317087 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1594417088
1594517089 // trying different ways of getting the depth info over
....@@ -15987,6 +17131,8 @@
1598717131 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1598817132 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1598917133 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
17134
+
17135
+ CreateSelectedPoint();
1599017136
1599117137 // Will fit the mesh !!!
1599217138 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16036,34 +17182,36 @@
1603617182 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]));
1603717183 }
1603817184
16039
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
17185
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1604017186 }
1604117187 }
1604217188
1604317189 if (!movingcamera && !PAINTMODE)
16044
- object.editWindow.ScreenFitPoint(); // fev 2014
17190
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1604517191
16046
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
17192
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1604717193 {
16048
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
17194
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1604917195
16050
- Object3D group = new Object3D("inst" + paintcount++);
17196
+ if (object.GetWindow().copy.selection.Size() > 0)
17197
+ {
17198
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1605117199
16052
- group.CreateMaterial(); // use a void leaf to select instances
16053
-
16054
- group.add(paintobj); // link
16055
-
16056
- object.editWindow.SnapObject(group);
16057
-
16058
- Object3D folder = object.editWindow.copy;
16059
-
16060
- if (object.editWindow.copy.selection.Size() > 0)
16061
- folder = object.editWindow.copy.selection.elementAt(0);
16062
-
16063
- folder.add(group);
16064
-
16065
- object.editWindow.ResetModel();
16066
- object.editWindow.refreshContents();
17200
+ Object3D inst = new Object3D("inst" + paintcount++);
17201
+
17202
+ inst.CreateMaterial(); // use a void leaf to select instances
17203
+
17204
+ inst.add(paintobj); // link
17205
+
17206
+ object.GetWindow().SnapObject(inst);
17207
+
17208
+ Object3D folder = paintFolder; // GetFolder();
17209
+
17210
+ folder.add(inst);
17211
+
17212
+ object.GetWindow().ResetModel();
17213
+ object.GetWindow().refreshContents();
17214
+ }
1606717215 }
1606817216 else
1606917217 paintcount = 0;
....@@ -16102,6 +17250,11 @@
1610217250 //System.out.println("objects[color] = " + objects[color]);
1610317251 //objects[color].Select();
1610417252 indexcount = 0;
17253
+ ObjEditor window = object.GetWindow();
17254
+ if (window != null && deselect)
17255
+ {
17256
+ window.Select(null, deselect, true);
17257
+ }
1610517258 object.Select(color, deselect);
1610617259 }
1610717260
....@@ -16201,7 +17354,7 @@
1620117354 gl.glDisable(gl.GL_CULL_FACE);
1620217355 }
1620317356
16204
- if (!RENDERSHADOW)
17357
+ if (!Globals.RENDERSHADOW)
1620517358 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1620617359
1620717360 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16211,7 +17364,7 @@
1621117364 //gl.glColorMask(false, false, false, false);
1621217365
1621317366 //render_scene_from_light_view(gl, drawable, 0, 0);
16214
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17367
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1621517368 {
1621617369 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1621717370
....@@ -16627,23 +17780,15 @@
1662717780 int AAbuffersize = 0;
1662817781
1662917782 //double[] selectedpoint = new double[3];
16630
- static Superellipsoid selectedpoint = new Superellipsoid();
17783
+ static Superellipsoid selectedpoint;
1663117784 static Sphere previousselectedpoint = null;
16632
- static Sphere debugpointG = new Sphere();
16633
- static Sphere debugpointP = new Sphere();
16634
- static Sphere debugpointC = new Sphere();
16635
- static Sphere debugpointR = new Sphere();
17785
+ static Sphere debugpointG;
17786
+ static Sphere debugpointP;
17787
+ static Sphere debugpointC;
17788
+ static Sphere debugpointR;
1663617789
1663717790 static Sphere debugpoints[] = new Sphere[8];
1663817791
16639
- static
16640
- {
16641
- for (int i=0; i<8; i++)
16642
- {
16643
- debugpoints[i] = new Sphere();
16644
- }
16645
- }
16646
-
1664717792 static void InitPoints(float radius)
1664817793 {
1664917794 for (int i=0; i<8; i++)
....@@ -16695,10 +17840,11 @@
1669517840 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1669617841 // Depth buffer format
1669717842 //private int depth_format;
16698
- static public void NextIndex(Object3D o, GL gl)
17843
+
17844
+ public void NextIndex()
1669917845 {
1670017846 indexcount+=16;
16701
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17847
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1670217848 //objects[indexcount] = o;
1670317849 //System.out.println("indexcount = " + indexcount);
1670417850 }