Normand Briere
2019-08-22 6a145f6c81dfcbe0653eda27d042efb48daa7512
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;
....@@ -76,7 +110,11 @@
76110 //private Mat4f spotlightTransform = new Mat4f();
77111 //private Mat4f spotlightInverseTransform = new Mat4f();
78112 static GLContext glcontext = null;
79
- /*static*/ com.sun.opengl.util.texture.Texture cubemap;
113
+ /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb
114
+ /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom;
115
+ /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb;
116
+ boolean transformMode;
117
+
80118 boolean reverseUP = false;
81119 static boolean frozen = false;
82120 boolean enablebackspace = false; // patch for back buffer refresh
....@@ -92,6 +130,8 @@
92130
93131 static int tickcount = 0; // slow pose issue
94132
133
+static boolean BUTTONLESSWHEEL = false;
134
+static boolean ZOOMBOXMODE = false;
95135 static boolean BOXMODE = false;
96136 static boolean IMAGEFLIP = false;
97137 static boolean SMOOTHFOCUS = false;
....@@ -106,7 +146,7 @@
106146 static boolean OEIL = true;
107147 static boolean OEILONCE = false; // do oeilon then oeiloff
108148 static boolean LOOKAT = true;
109
-static boolean RANDOM = true; // false;
149
+static boolean SWITCH = true; // false;
110150 static boolean HANDLES = false; // selection doesn't work!!
111151 static boolean PAINTMODE = false;
112152
....@@ -128,7 +168,7 @@
128168
129169
130170 // OPTIONS
131
- boolean Skinshader = true;
171
+ boolean Skinshader = false; // true;
132172 boolean cameraLight = false;
133173 boolean UVdebug = false;
134174 boolean Udebug = false;
....@@ -137,7 +177,7 @@
137177 static boolean doublesided = false; // true; // reversed normals are awful for conformance
138178 boolean anisotropy = true;
139179 boolean softshadow = true; // slower but better false;
140
- boolean opacityhalo = false;
180
+ boolean opacityhalo = false; // reverse the halo effect (e.g. glass)
141181
142182 boolean macromode = false;
143183
....@@ -148,6 +188,21 @@
148188 defaultcaps.setAccumGreenBits(16);
149189 defaultcaps.setAccumBlueBits(16);
150190 defaultcaps.setAccumAlphaBits(16);
191
+ }
192
+
193
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
194
+
195
+ public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException
196
+ {
197
+ try
198
+ {
199
+ return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
200
+ } catch (IOException e)
201
+ {
202
+ System.out.println("NAME = " + name);
203
+ e.printStackTrace(); // throw new RuntimeException(e);
204
+ return null;
205
+ }
151206 }
152207
153208 void SetAsGLRenderer(boolean b)
....@@ -168,7 +223,8 @@
168223
169224 SetCamera(cam);
170225
171
- SetLight(new Camera(new cVector(10, 10, -20)));
226
+ // Warning: not used.
227
+ SetLight(new Camera(new cVector(15, 10, -20)));
172228
173229 object = o;
174230
....@@ -191,9 +247,43 @@
191247
192248 /// INTERFACE
193249
250
+ public javax.media.opengl.GL GetGL0()
251
+ {
252
+ return null;
253
+ }
254
+
255
+ public int GenList()
256
+ {
257
+ javax.media.opengl.GL gl = GetGL();
258
+ return gl.glGenLists(1);
259
+ }
260
+
261
+ public void NewList(int id)
262
+ {
263
+ javax.media.opengl.GL gl = GetGL();
264
+ gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE);
265
+ }
266
+
267
+ public void CallList(int id)
268
+ {
269
+ javax.media.opengl.GL gl = GetGL();
270
+ gl.glCallList(id);
271
+ }
272
+
273
+ public void EndList()
274
+ {
275
+ javax.media.opengl.GL gl = GetGL();
276
+ gl.glEndList();
277
+ }
278
+
194279 public boolean IsBoxMode()
195280 {
196281 return BOXMODE;
282
+ }
283
+
284
+ public boolean IsZoomBoxMode()
285
+ {
286
+ return ZOOMBOXMODE;
197287 }
198288
199289 public void ClearDepth()
....@@ -291,7 +381,7 @@
291381 cStatic.objectstack[materialdepth++] = obj;
292382 //System.out.println("material " + material);
293383 //Applet3D.tracein(this, selected);
294
- display.vector2buffer = obj.projectedVertices;
384
+ //display.vector2buffer = obj.projectedVertices;
295385 if (obj instanceof Camera)
296386 {
297387 display.options1[0] = material.shift;
....@@ -300,14 +390,28 @@
300390 display.options1[2] = material.shadowbias;
301391 display.options1[3] = material.aniso;
302392 display.options1[4] = material.anisoV;
393
+// System.out.println("display.options1[0] " + display.options1[0]);
394
+// System.out.println("display.options1[1] " + display.options1[1]);
395
+// System.out.println("display.options1[2] " + display.options1[2]);
396
+// System.out.println("display.options1[3] " + display.options1[3]);
397
+// System.out.println("display.options1[4] " + display.options1[4]);
303398 display.options2[0] = material.opacity;
304399 display.options2[1] = material.diffuse;
305400 display.options2[2] = material.factor;
401
+// System.out.println("display.options2[0] " + display.options2[0]);
402
+// System.out.println("display.options2[1] " + display.options2[1]);
403
+// System.out.println("display.options2[2] " + display.options2[2]);
306404
307405 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
406
+// System.out.println("display.options3[0] " + display.options3[0]);
407
+// System.out.println("display.options3[1] " + display.options3[1]);
408
+// System.out.println("display.options3[2] " + display.options3[2]);
308409 display.options4[0] = material.cameralight/0.2f;
309410 display.options4[1] = material.subsurface;
310411 display.options4[2] = material.sheen;
412
+// System.out.println("display.options4[0] " + display.options4[0]);
413
+// System.out.println("display.options4[1] " + display.options4[1]);
414
+// System.out.println("display.options4[2] " + display.options4[2]);
311415
312416 // if (display.CURRENTANTIALIAS > 0)
313417 // display.options3[3] /= 4;
....@@ -323,7 +427,7 @@
323427 /**/
324428 } else
325429 {
326
- DrawMaterial(material, selected);
430
+ DrawMaterial(material, selected, obj.projectedVertices);
327431 }
328432 } else
329433 {
....@@ -347,8 +451,8 @@
347451 cStatic.objectstack[materialdepth++] = obj;
348452 //System.out.println("material " + material);
349453 //Applet3D.tracein("selected ", selected);
350
- display.vector2buffer = obj.projectedVertices;
351
- display.DrawMaterial(material, selected);
454
+ //display.vector2buffer = obj.projectedVertices;
455
+ display.DrawMaterial(material, selected, obj.projectedVertices);
352456 }
353457 }
354458
....@@ -365,8 +469,8 @@
365469 materialdepth -= 1;
366470 if (materialdepth > 0)
367471 {
368
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
369
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
472
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
473
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
370474 }
371475 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
372476 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -386,8 +490,8 @@
386490 materialdepth -= 1;
387491 if (materialdepth > 0)
388492 {
389
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
390
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
493
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
494
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
391495 }
392496 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
393497 //else
....@@ -428,15 +532,18 @@
428532 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
429533 {
430534 //gl.glBegin(gl.GL_TRIANGLES);
431
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
535
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
536
+ // TEST LIVE NORMALS && !obj.dontselect
537
+ ;
432538 if (!hasnorm)
433539 {
434
- // System.out.println("FUCK!!");
540
+ // System.out.println("Mesh normal");
435541 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
436542 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
437543 LA.vecCross(obj.v0, obj.v1, obj.v2);
438544 LA.vecNormalize(obj.v2);
439
- gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
545
+
546
+ SetGLNormal(gl, (float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
440547 }
441548
442549 // P
....@@ -458,7 +565,7 @@
458565 y += ny * obj.NORMALPUSH;
459566 z += nz * obj.NORMALPUSH;
460567
461
- gl.glNormal3f(nx, ny, nz);
568
+ SetGLNormal(gl, nx, ny, nz);
462569 }
463570 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
464571 SetColor(obj, pv);
....@@ -490,7 +597,7 @@
490597 y += ny * obj.NORMALPUSH;
491598 z += nz * obj.NORMALPUSH;
492599
493
- gl.glNormal3f(nx, ny, nz);
600
+ SetGLNormal(gl, nx, ny, nz);
494601 }
495602 //System.out.println("vertexq = " + qv.s + ", " + qv.t);
496603 // boolean locked = false;
....@@ -538,7 +645,7 @@
538645 y += ny * obj.NORMALPUSH;
539646 z += nz * obj.NORMALPUSH;
540647
541
- gl.glNormal3f(nx, ny, nz);
648
+ SetGLNormal(gl, nx, ny, nz);
542649 }
543650
544651 // if ((dot&4) == 0)
....@@ -1059,8 +1166,345 @@
10591166 gl.glMatrixMode(gl.GL_MODELVIEW);
10601167 }
10611168
1169
+ public void DrawBox(cVector min, cVector max)
1170
+ {
1171
+ javax.media.opengl.GL gl = GetGL();
1172
+ gl.glBegin(gl.GL_LINES);
1173
+
1174
+ gl.glVertex3d(min.x, min.y, min.z);
1175
+ gl.glVertex3d(min.x, min.y, max.z);
1176
+ gl.glVertex3d(min.x, min.y, min.z);
1177
+ gl.glVertex3d(min.x, max.y, min.z);
1178
+ gl.glVertex3d(min.x, min.y, min.z);
1179
+ gl.glVertex3d(max.x, min.y, min.z);
1180
+
1181
+ gl.glVertex3d(max.x, max.y, max.z);
1182
+ gl.glVertex3d(min.x, max.y, max.z);
1183
+ gl.glVertex3d(max.x, max.y, max.z);
1184
+ gl.glVertex3d(max.x, min.y, max.z);
1185
+ gl.glVertex3d(max.x, max.y, max.z);
1186
+ gl.glVertex3d(max.x, max.y, min.z);
1187
+
1188
+ gl.glEnd();
1189
+ }
1190
+
1191
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1192
+ {
1193
+ int[] strips = bRep.getRawIndices();
1194
+
1195
+ javax.media.opengl.GL gl = GetGL();
1196
+
1197
+ // TRIANGLE STRIP ARRAY
1198
+ if (bRep.trimmed)
1199
+ {
1200
+ float[] v = bRep.getRawVertices();
1201
+ float[] n = bRep.getRawNormals();
1202
+ float[] c = bRep.getRawColors();
1203
+ float[] uv = bRep.getRawUVMap();
1204
+
1205
+ int count2 = 0;
1206
+ int count3 = 0;
1207
+
1208
+ if (n.length > 0)
1209
+ {
1210
+ for (int i = 0; i < strips.length; i++)
1211
+ {
1212
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1213
+
1214
+ /*
1215
+ boolean locked = false;
1216
+ float eps = 0.1f;
1217
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1218
+
1219
+ int dot = 0;
1220
+
1221
+ if ((dot&1) == 0)
1222
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1223
+
1224
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1225
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1226
+ else
1227
+ {
1228
+ locked = true;
1229
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1230
+ }
1231
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1232
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1233
+ if (hasnorm)
1234
+ {
1235
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1236
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1237
+ }
1238
+
1239
+ if ((dot&4) == 0)
1240
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1241
+
1242
+ if (wrap || !locked && (dot&8) != 0)
1243
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1244
+ else
1245
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1246
+
1247
+ f.dot = dot;
1248
+ */
1249
+
1250
+ if (!selectmode)
1251
+ {
1252
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1253
+ {
1254
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
1255
+ } else
1256
+ {
1257
+ SetGLNormal(gl, 0, 0, 1);
1258
+ }
1259
+
1260
+ if (c != null)
1261
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1262
+ {
1263
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1264
+ }
1265
+ }
1266
+
1267
+ if (flipV)
1268
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1269
+ else
1270
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1271
+
1272
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1273
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1274
+
1275
+ count2 += 2;
1276
+ count3 += 3;
1277
+ if (!selectmode)
1278
+ {
1279
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1280
+ {
1281
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
1282
+ } else
1283
+ {
1284
+ SetGLNormal(gl, 0, 0, 1);
1285
+ }
1286
+ if (c != null)
1287
+ {
1288
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1289
+ }
1290
+ }
1291
+
1292
+ if (flipV)
1293
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1294
+ else
1295
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1296
+
1297
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1298
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1299
+
1300
+ count2 += 2;
1301
+ count3 += 3;
1302
+ for (int j = 0; j < strips[i] - 2; j++)
1303
+ {
1304
+ //gl.glTexCoord2d(...);
1305
+ if (!selectmode)
1306
+ {
1307
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1308
+ {
1309
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
1310
+ } else
1311
+ {
1312
+ SetGLNormal(gl, 0, 0, 1);
1313
+ }
1314
+ if (c != null)
1315
+ {
1316
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1317
+ }
1318
+ }
1319
+
1320
+ if (flipV)
1321
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1322
+ else
1323
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1324
+
1325
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1326
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1327
+
1328
+ count2 += 2;
1329
+ count3 += 3;
1330
+ }
1331
+
1332
+ gl.glEnd();
1333
+ }
1334
+ }
1335
+
1336
+ assert count3 == v.length;
1337
+ }
1338
+ else // !trimmed
1339
+ {
1340
+ int count = 0;
1341
+ for (int i = 0; i < strips.length; i++)
1342
+ {
1343
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1344
+
1345
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1346
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1347
+
1348
+ drawVertex(gl, p, flipV, selectmode);
1349
+ drawVertex(gl, q, flipV, selectmode);
1350
+
1351
+ for (int j = 0; j < strips[i] - 2; j++)
1352
+ {
1353
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1354
+
1355
+ // if (j%2 == 0)
1356
+ // drawFace(p, q, r, display, null);
1357
+ // else
1358
+ // drawFace(p, r, q, display, null);
1359
+
1360
+ // p = q;
1361
+ // q = r;
1362
+ drawVertex(gl, r, flipV, selectmode);
1363
+ }
1364
+
1365
+ gl.glEnd();
1366
+ }
1367
+ }
1368
+ }
1369
+
1370
+ static cSpring.Point3D temp = new cSpring.Point3D();
1371
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1372
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1373
+
1374
+ public void DrawDynamicMesh(cMesh mesh)
1375
+ {
1376
+ GL gl = GetGL(); // getGL();
1377
+
1378
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1379
+
1380
+ gl.glDisable(gl.GL_LIGHTING);
1381
+
1382
+ gl.glLineWidth(1);
1383
+ gl.glColor3f(1,1,1);
1384
+ gl.glBegin(gl.GL_LINES);
1385
+ double scale = 0;
1386
+ int count = 0;
1387
+ for (int s=0; s<Phys.allSprings.size(); s++)
1388
+ {
1389
+ cSpring.Spring spring = Phys.allSprings.get(s);
1390
+ if(s == 0)
1391
+ {
1392
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1393
+ }
1394
+ if (mesh.showsprings)
1395
+ {
1396
+ temp.set(spring.a.position);
1397
+ temp.add(spring.b.position);
1398
+ temp.mul(0.5);
1399
+ temp2.set(spring.a.position);
1400
+ temp2.sub(spring.b.position);
1401
+ temp2.mul(spring.restLength/2);
1402
+ temp.sub(temp2);
1403
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1404
+ temp.add(temp2);
1405
+ temp.add(temp2);
1406
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1407
+ }
1408
+
1409
+ if (spring.isHandle)
1410
+ continue;
1411
+
1412
+ //if (scale < spring.restLength)
1413
+ scale += spring.restLength;
1414
+ count++;
1415
+ }
1416
+ gl.glEnd();
1417
+
1418
+ if (count == 0)
1419
+ scale = 0.01;
1420
+ else
1421
+ scale /= count * 3;
1422
+
1423
+ //scale = 0.25;
1424
+
1425
+ if (mesh.ShowInfo())
1426
+ {
1427
+ gl.glLineWidth(4);
1428
+ for (int s=0; s<Phys.allNodes.size(); s++)
1429
+ {
1430
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1431
+ if (node.mass == 0)
1432
+ continue;
1433
+
1434
+ int i = node.springs==null?-1:node.springs.size();
1435
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1436
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1437
+ //temp.normalize();
1438
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1439
+ gl.glBegin(gl.GL_LINES);
1440
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1441
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1442
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1443
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1444
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1445
+ gl.glEnd();
1446
+ }
1447
+
1448
+ gl.glLineWidth(8);
1449
+ for (int s=0; s<Phys.allNodes.size(); s++)
1450
+ {
1451
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1452
+
1453
+ if (node.springs != null)
1454
+ {
1455
+ for (int i=0; i<node.springs.size(); i+=1)
1456
+ {
1457
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1458
+
1459
+ int c = i+1;
1460
+ // c = node.springs.get(i).nbcopies;
1461
+
1462
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1463
+ gl.glBegin(gl.GL_LINES);
1464
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1465
+ 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);
1466
+ gl.glEnd();
1467
+ }
1468
+ }
1469
+ }
1470
+
1471
+ gl.glLineWidth(1);
1472
+ }
1473
+
1474
+ gl.glEnable(gl.GL_LIGHTING);
1475
+ }
1476
+
10621477 /// INTERFACE
10631478
1479
+ public void StartTriangles()
1480
+ {
1481
+ javax.media.opengl.GL gl = GetGL();
1482
+ gl.glBegin(gl.GL_TRIANGLES);
1483
+ }
1484
+
1485
+ public void EndTriangles()
1486
+ {
1487
+ GetGL().glEnd();
1488
+ }
1489
+
1490
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1491
+ {
1492
+ if (!selectmode)
1493
+ {
1494
+ SetGLNormal(gl, (float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1495
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1496
+
1497
+ if (flipV)
1498
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1499
+ else
1500
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1501
+ }
1502
+
1503
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1504
+ }
1505
+
1506
+ float[] colorV = new float[4];
1507
+
10641508 void SetColor(Object3D obj, Vertex p0)
10651509 {
10661510 CameraPane display = this;
....@@ -1128,8 +1572,6 @@
11281572 {
11291573 return;
11301574 }
1131
-
1132
- float[] colorV = new float[3];
11331575
11341576 if (false) // marked)
11351577 {
....@@ -1238,7 +1680,7 @@
12381680 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
12391681 }
12401682
1241
- void DrawMaterial(cMaterial material, boolean selected)
1683
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
12421684 {
12431685 CameraPane display = this;
12441686 //new Exception().printStackTrace();
....@@ -1254,18 +1696,18 @@
12541696 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
12551697 if (!material.multiply)
12561698 {
1257
- display.color = color;
1699
+ display.color = material.color;
12581700 display.saturation = material.modulation;
12591701 }
12601702 else
12611703 {
1262
- display.color *= color*2;
1704
+ display.color *= material.color*2;
12631705 display.saturation *= material.modulation*2;
12641706 }
12651707
12661708 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
12671709
1268
- float[] colorV = GrafreeD.colorV;
1710
+ float[] colorV = Grafreed.colorV;
12691711
12701712 /**/
12711713 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1273,7 +1715,7 @@
12731715 colorV[0] = display.modelParams0[0] * material.diffuse;
12741716 colorV[1] = display.modelParams0[1] * material.diffuse;
12751717 colorV[2] = display.modelParams0[2] * material.diffuse;
1276
- colorV[3] = material.opacity;
1718
+ colorV[3] = 1; // material.opacity;
12771719
12781720 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
12791721 //System.out.println("Opacity = " + opacity);
....@@ -1378,12 +1820,12 @@
13781820
13791821 display.modelParams7[0] = 0;
13801822 display.modelParams7[1] = 1000;
1381
- display.modelParams7[2] = 0;
1823
+ display.modelParams7[2] = material.parallax;
13821824 display.modelParams7[3] = 0;
13831825
1384
- display.modelParams6[0] = 100; // criss de bug de bump
1826
+ //display.modelParams6[0] = 100; // criss de bug de bump
13851827
1386
- Object3D.cVector2[] extparams = display.vector2buffer;
1828
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
13871829 if (extparams != null && extparams.length > 0 && extparams[0] != null)
13881830 {
13891831 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1525,7 +1967,7 @@
15251967 void PushMatrix(double[][] matrix)
15261968 {
15271969 // GrafreeD.tracein(matrix);
1528
- PushMatrix(matrix,1);
1970
+ PushMatrix(matrix, 1);
15291971 }
15301972
15311973 void PushMatrix()
....@@ -1611,9 +2053,9 @@
16112053 switch(viewcode)
16122054 {
16132055 case 0: return "main";
1614
- case 1: return "one";
1615
- case 2: return "two";
1616
- case 3: return "three";
2056
+ case 1: return "Red";
2057
+ case 2: return "Green";
2058
+ case 3: return "Blue";
16172059 case 4: return "light";
16182060 }
16192061
....@@ -1679,7 +2121,7 @@
16792121 //System.err.println("Oeil on");
16802122 OEIL = true;
16812123 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
1682
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2124
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
16832125 //pingthread.StepToTarget(true);
16842126 }
16852127
....@@ -1777,7 +2219,7 @@
17772219 System.err.println("LIVE = " + Globals.isLIVE());
17782220
17792221 if (!Globals.isLIVE()) // save sound
1780
- GrafreeD.savesound = true; // wav.save();
2222
+ Grafreed.savesound = true; // wav.save();
17812223 // else
17822224 repaint(); // start loop // may 2013
17832225 }
....@@ -1810,6 +2252,11 @@
18102252 public void ToggleBoxMode()
18112253 {
18122254 BOXMODE ^= true;
2255
+ }
2256
+
2257
+ public void ToggleZoomBoxMode()
2258
+ {
2259
+ ZOOMBOXMODE ^= true;
18132260 }
18142261
18152262 public void ToggleSmoothFocus()
....@@ -1889,7 +2336,7 @@
18892336
18902337 void ToggleDebug()
18912338 {
1892
- DEBUG ^= true;
2339
+ Globals.DEBUG ^= true;
18932340 }
18942341
18952342 void ToggleLookAt()
....@@ -1897,9 +2344,9 @@
18972344 LOOKAT ^= true;
18982345 }
18992346
1900
- void ToggleRandom()
2347
+ void ToggleSwitch()
19012348 {
1902
- RANDOM ^= true;
2349
+ SWITCH ^= true;
19032350 }
19042351
19052352 void ToggleHandles()
....@@ -1907,10 +2354,17 @@
19072354 HANDLES ^= true;
19082355 }
19092356
2357
+ Object3D paintFolder;
2358
+
19102359 void TogglePaint()
19112360 {
19122361 PAINTMODE ^= true;
19132362 paintcount = 0;
2363
+
2364
+ if (PAINTMODE)
2365
+ {
2366
+ paintFolder = GetFolder();
2367
+ }
19142368 }
19152369
19162370 void SwapCamera(int a, int b)
....@@ -2006,7 +2460,34 @@
20062460 {
20072461 return currentGL;
20082462 }
2009
-
2463
+
2464
+ static private BufferedImage CreateBim(TextureData texturedata)
2465
+ {
2466
+ Grafreed.Assert(texturedata != null);
2467
+
2468
+ int width = texturedata.getWidth();
2469
+ int height = texturedata.getHeight();
2470
+
2471
+ Buffer buffer = texturedata.getBuffer();
2472
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2473
+
2474
+ byte[] bytes = bytebuf.array();
2475
+
2476
+ return CreateBim(bytes, width, height);
2477
+ }
2478
+
2479
+ private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz)
2480
+ {
2481
+ gl.glNormal3f(nx, ny, nz);
2482
+
2483
+ if (ny > 0.9 || ny < -0.9)
2484
+ // Ground or ceiling
2485
+ gl.glVertexAttrib3f(4, 1, 0, 0);
2486
+ else
2487
+ // Walls
2488
+ gl.glVertexAttrib3f(4, 0, 1, 0);
2489
+ }
2490
+
20102491 /**/
20112492 class CacheTexture
20122493 {
....@@ -2015,28 +2496,31 @@
20152496
20162497 int resolution;
20172498
2018
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2499
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
20192500 {
2020
- texture = tex;
2501
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2502
+ texturedata = texdata;
20212503 resolution = res;
20222504 }
20232505 }
20242506 /**/
20252507
20262508 // 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>();
2509
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2510
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2511
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2512
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2513
+
20302514 int pigmentdepth = 0;
20312515 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
20322516 int bumpdepth = 0;
20332517 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
20342518 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
20352519 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2036
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2520
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
20372521 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
20382522
2039
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2523
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
20402524 {
20412525 TextureData texturedata = null;
20422526
....@@ -2046,7 +2530,7 @@
20462530 com.sun.opengl.util.texture.TextureIO.newTextureData(
20472531 getClass().getClassLoader().getResourceAsStream(name),
20482532 true,
2049
- com.sun.opengl.util.texture.TextureIO.PNG);
2533
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
20502534 } catch (java.io.IOException e)
20512535 {
20522536 throw new javax.media.opengl.GLException(e);
....@@ -2055,13 +2539,34 @@
20552539 if (bump)
20562540 texturedata = ConvertBump(texturedata, false);
20572541
2058
- com.sun.opengl.util.texture.Texture texture =
2059
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2542
+// com.sun.opengl.util.texture.Texture texture =
2543
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
20602544
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);
2545
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2546
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
20632547
2064
- return texture;
2548
+ return texturedata;
2549
+ }
2550
+
2551
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2552
+ {
2553
+ TextureData texturedata = null;
2554
+
2555
+ try
2556
+ {
2557
+ texturedata =
2558
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2559
+ bim,
2560
+ true);
2561
+ } catch (Exception e)
2562
+ {
2563
+ throw new javax.media.opengl.GLException(e);
2564
+ }
2565
+
2566
+ if (bump)
2567
+ texturedata = ConvertBump(texturedata, false);
2568
+
2569
+ return texturedata;
20652570 }
20662571
20672572 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3134,6 +3639,8 @@
31343639
31353640 System.out.println("LOADING TEXTURE : " + name);
31363641
3642
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3643
+
31373644 //
31383645 if (false) // compressbit > 0)
31393646 {
....@@ -3838,6 +4345,7 @@
38384345
38394346 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
38404347 {
4348
+ new Exception().printStackTrace();
38414349 System.exit(0);
38424350 com.sun.opengl.util.texture.Texture texture = null;
38434351
....@@ -7531,7 +8039,7 @@
75318039 String pigment = Object3D.GetPigment(tex);
75328040 String bump = Object3D.GetBump(tex);
75338041
7534
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8042
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
75358043 {
75368044 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
75378045 // System.out.println("; bump = " + bump);
....@@ -7546,11 +8054,69 @@
75468054 pigment = null;
75478055 }
75488056
7549
- ReleaseTexture(bump, true);
7550
- ReleaseTexture(pigment, false);
8057
+ ReleaseTexture(tex, true);
8058
+ ReleaseTexture(tex, false);
75518059 }
75528060
7553
- void ReleaseTexture(String tex, boolean bump)
8061
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
8062
+ {
8063
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8064
+ {
8065
+ return;
8066
+ }
8067
+
8068
+ if (tex == null)
8069
+ {
8070
+ ReleaseTexture(null, false);
8071
+ return;
8072
+ }
8073
+
8074
+ String pigment = Object3D.GetPigment(tex);
8075
+
8076
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8077
+ {
8078
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8079
+ // System.out.println("; bump = " + bump);
8080
+ }
8081
+
8082
+ if (pigment.equals(""))
8083
+ {
8084
+ pigment = null;
8085
+ }
8086
+
8087
+ ReleaseTexture(tex, false);
8088
+ }
8089
+
8090
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8091
+ {
8092
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8093
+ {
8094
+ return;
8095
+ }
8096
+
8097
+ if (tex == null)
8098
+ {
8099
+ ReleaseTexture(null, true);
8100
+ return;
8101
+ }
8102
+
8103
+ String bump = Object3D.GetBump(tex);
8104
+
8105
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8106
+ {
8107
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8108
+ // System.out.println("; bump = " + bump);
8109
+ }
8110
+
8111
+ if (bump.equals(""))
8112
+ {
8113
+ bump = null;
8114
+ }
8115
+
8116
+ ReleaseTexture(tex, true);
8117
+ }
8118
+
8119
+ void ReleaseTexture(cTexture tex, boolean bump)
75548120 {
75558121 if (// DrawMode() != 0 || /*tex == null ||*/
75568122 ambientOcclusion ) // || !textureon)
....@@ -7561,7 +8127,7 @@
75618127 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
75628128
75638129 if (tex != null)
7564
- texture = textures.get(tex);
8130
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
75658131
75668132 // //assert( texture != null );
75678133 // if (texture == null)
....@@ -7653,7 +8219,55 @@
76538219 }
76548220 }
76558221
7656
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8222
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
8223
+ {
8224
+// if (// DrawMode() != 0 || /*tex == null ||*/
8225
+// ambientOcclusion ) // || !textureon)
8226
+// {
8227
+// return; // false;
8228
+// }
8229
+//
8230
+// if (tex == null)
8231
+// {
8232
+// BindTexture(null,false,resolution);
8233
+// BindTexture(null,true,resolution);
8234
+// return;
8235
+// }
8236
+//
8237
+// String pigment = Object3D.GetPigment(tex);
8238
+// String bump = Object3D.GetBump(tex);
8239
+//
8240
+// usedtextures.add(pigment);
8241
+// usedtextures.add(bump);
8242
+//
8243
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8244
+// {
8245
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8246
+// // System.out.println("; bump = " + bump);
8247
+// }
8248
+//
8249
+// if (bump.equals(""))
8250
+// {
8251
+// bump = null;
8252
+// }
8253
+// if (pigment.equals(""))
8254
+// {
8255
+// pigment = null;
8256
+// }
8257
+//
8258
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8259
+// BindTexture(pigment, false, resolution);
8260
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8261
+// BindTexture(bump, true, resolution);
8262
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8263
+//
8264
+// return; // true;
8265
+
8266
+ BindPigmentTexture(tex, resolution);
8267
+ BindBumpTexture(tex, resolution);
8268
+ }
8269
+
8270
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
76578271 {
76588272 if (// DrawMode() != 0 || /*tex == null ||*/
76598273 ambientOcclusion ) // || !textureon)
....@@ -7664,17 +8278,47 @@
76648278 if (tex == null)
76658279 {
76668280 BindTexture(null,false,resolution);
7667
- BindTexture(null,true,resolution);
76688281 return;
76698282 }
76708283
76718284 String pigment = Object3D.GetPigment(tex);
8285
+
8286
+ usedtextures.add(tex);
8287
+
8288
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8289
+ {
8290
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8291
+ // System.out.println("; bump = " + bump);
8292
+ }
8293
+
8294
+ if (pigment.equals(""))
8295
+ {
8296
+ pigment = null;
8297
+ }
8298
+
8299
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8300
+ BindTexture(tex, false, resolution);
8301
+ }
8302
+
8303
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8304
+ {
8305
+ if (// DrawMode() != 0 || /*tex == null ||*/
8306
+ ambientOcclusion ) // || !textureon)
8307
+ {
8308
+ return; // false;
8309
+ }
8310
+
8311
+ if (tex == null)
8312
+ {
8313
+ BindTexture(null,true,resolution);
8314
+ return;
8315
+ }
8316
+
76728317 String bump = Object3D.GetBump(tex);
76738318
7674
- usedtextures.put(pigment, pigment);
7675
- usedtextures.put(bump, bump);
8319
+ usedtextures.add(tex);
76768320
7677
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8321
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
76788322 {
76798323 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
76808324 // System.out.println("; bump = " + bump);
....@@ -7684,43 +8328,94 @@
76848328 {
76858329 bump = null;
76868330 }
7687
- if (pigment.equals(""))
7688
- {
7689
- pigment = null;
7690
- }
76918331
7692
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
7693
- BindTexture(pigment, false, resolution);
76948332 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
7695
- BindTexture(bump, true, resolution);
8333
+ BindTexture(tex, true, resolution);
76968334 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
7697
-
7698
- return; // true;
76998335 }
77008336
7701
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8337
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8338
+
8339
+ private boolean FileExists(String tex)
77028340 {
7703
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8341
+ if (missingTextures.contains(tex))
8342
+ {
8343
+ return false;
8344
+ }
8345
+
8346
+ boolean fileExists = new File(tex).exists();
8347
+
8348
+ if (!fileExists)
8349
+ {
8350
+ // If file exists, the "new File()" is not executed sgain
8351
+ missingTextures.add(tex);
8352
+ }
8353
+
8354
+ return fileExists;
8355
+ }
8356
+
8357
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
8358
+ {
8359
+ CacheTexture texturecache = null;
77048360
77058361 if (tex != null)
77068362 {
7707
- String texname = tex;
8363
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8364
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
77088365
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;
8366
+ if (texname.equals("") && texdata == null)
8367
+ {
8368
+ return null;
8369
+ }
8370
+
8371
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8372
+
8373
+// String[] split = tex.split("Textures");
8374
+// if (split.length > 1)
8375
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8376
+// else
8377
+// if (!texname.startsWith("/"))
8378
+// texname = "/Users/nbriere/Textures/" + texname;
8379
+ if (!FileExists(texname) && !texname.startsWith("@"))
8380
+ {
8381
+ texname = fallbackTextureName;
8382
+ }
77158383
77168384 if (CACHETEXTURE)
7717
- texture = textures.get(texname); // TEXTURE CACHE
7718
-
7719
- TextureData texturedata = null;
7720
-
7721
- if (texture == null || texture.resolution < resolution)
77228385 {
7723
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8386
+ if (texdata == null)
8387
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8388
+ else
8389
+ texturecache = bimtextures.get(texdata);
8390
+ }
8391
+
8392
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8393
+ {
8394
+ TextureData texturedata = null;
8395
+
8396
+ if (texdata != null && textureon)
8397
+ {
8398
+ BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8399
+
8400
+ try
8401
+ {
8402
+ bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8403
+ }
8404
+ catch (Exception e)
8405
+ {
8406
+ bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8407
+ }
8408
+
8409
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8410
+ bimtextures.put(texdata, texturecache);
8411
+
8412
+ //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8413
+
8414
+ //Object bim2 = CreateBim(texturecache.texturedata);
8415
+ //bim2 = bim;
8416
+ }
8417
+ else
8418
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
77248419 {
77258420 assert(!bump);
77268421 // if (bump)
....@@ -7731,19 +8426,23 @@
77318426 // }
77328427 // else
77338428 // {
7734
- texture = textures.get(tex);
7735
- if (texture == null)
8429
+ // texturecache = textures.get(texname); // suspicious
8430
+ if (texturecache == null)
77368431 {
7737
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8432
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
77388433 }
8434
+ else
8435
+ new Exception().printStackTrace();
77398436 // }
77408437 } else
7741
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8438
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
77428439 {
77438440 assert(bump);
7744
- texture = textures.get(tex);
7745
- if (texture == null)
7746
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8441
+ // texturecache = textures.get(texname); // suspicious
8442
+ if (texturecache == null)
8443
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8444
+ else
8445
+ new Exception().printStackTrace();
77478446 } else
77488447 {
77498448 //if (tex.equals("IMMORTAL"))
....@@ -7751,11 +8450,22 @@
77518450 // texture = GetResourceTexture("default.png");
77528451 //} else
77538452 //{
7754
- if (tex.equals("WHITE_NOISE"))
8453
+ if (texname.endsWith("WHITE_NOISE"))
77558454 {
7756
- texture = textures.get(tex);
7757
- if (texture == null)
7758
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8455
+ // texturecache = textures.get(texname); // suspicious
8456
+ if (texturecache == null)
8457
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8458
+ else
8459
+ new Exception().printStackTrace();
8460
+ } else
8461
+ {
8462
+ if (texname.startsWith("@"))
8463
+ {
8464
+ // texturecache = textures.get(texname); // suspicious
8465
+ if (texturecache == null)
8466
+ texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution);
8467
+ else
8468
+ new Exception().printStackTrace();
77598469 } else
77608470 {
77618471 if (textureon)
....@@ -7780,7 +8490,7 @@
77808490 }
77818491
77828492 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
7783
- if (!new File(cachename).exists())
8493
+ if (!FileExists(cachename))
77848494 cachename = texname;
77858495 else
77868496 processbump = false; // don't process bump map again
....@@ -7802,7 +8512,7 @@
78028512 }
78038513
78048514 cachename = texname.substring(0, texname.length()-4)+ext+".png";
7805
- if (!new File(cachename).exists())
8515
+ if (!FileExists(cachename))
78068516 cachename = texname;
78078517 else
78088518 processbump = false; // don't process bump map again
....@@ -7811,20 +8521,23 @@
78118521 texturedata = GetFileTexture(cachename, processbump, resolution);
78128522
78138523
7814
- if (texturedata != null)
7815
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8524
+ if (texturedata == null)
8525
+ throw new Exception();
8526
+
8527
+ texturecache = new CacheTexture(texturedata,resolution);
78168528 //texture = GetTexture(tex, bump);
78178529 }
8530
+ }
78188531 }
78198532 //}
78208533 }
78218534
7822
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8535
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
78238536 {
78248537 //return false;
78258538
78268539 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
7827
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8540
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
78288541 {
78298542 // String ext = "_highres";
78308543 // if (REDUCETEXTURE)
....@@ -7841,52 +8554,17 @@
78418554 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
78428555 if (!cachefile.exists())
78438556 {
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))
8557
+ //if (texturedata.getWidth() == texturedata.getHeight())
78538558 {
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);
8559
+ BufferedImage rendImage = CreateBim(texturedata);
8560
+
78848561 ImageWriter writer = null;
78858562 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
78868563 if (iter.hasNext()) {
78878564 writer = (ImageWriter)iter.next();
78888565 }
7889
- float compressionQuality = 0.9f;
8566
+
8567
+ float compressionQuality = 0.85f;
78908568 try
78918569 {
78928570 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -7903,18 +8581,20 @@
79038581 }
79048582 }
79058583 }
7906
-
8584
+
8585
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8586
+
79078587 //System.out.println("Texture = " + tex);
7908
- if (textures.containsKey(texname))
8588
+ if (textures.containsKey(tex))
79098589 {
7910
- CacheTexture thetex = textures.get(texname);
8590
+ CacheTexture thetex = textures.get(tex);
79118591 thetex.texture.disable();
79128592 thetex.texture.dispose();
7913
- textures.remove(texname);
8593
+ textures.remove(tex);
79148594 }
79158595
7916
- texture.texturedata = texturedata;
7917
- textures.put(texname, texture);
8596
+ //texture.texturedata = texturedata;
8597
+ textures.put(tex, texturecache);
79188598
79198599 // newtex = true;
79208600 }
....@@ -7930,10 +8610,44 @@
79308610 }
79318611 }
79328612
7933
- return texture;
8613
+ return texturecache;
79348614 }
79358615
7936
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8616
+ static void EmbedTextures(cTexture tex)
8617
+ {
8618
+ if (tex.pigmentdata == null)
8619
+ {
8620
+ //String texname = Object3D.GetPigment(tex);
8621
+
8622
+ CacheTexture texturecache = texturepigment.get(tex);
8623
+
8624
+ if (texturecache != null)
8625
+ {
8626
+ tex.pw = texturecache.texturedata.getWidth();
8627
+ tex.ph = texturecache.texturedata.getHeight();
8628
+ tex.pigmentdata = //CompressJPEG(CreateBim
8629
+ ((ByteBuffer)texturecache.texturedata.getBuffer()).array()
8630
+ ;
8631
+ //, tex.pw, tex.ph), 0.5f);
8632
+ }
8633
+ }
8634
+
8635
+ if (tex.bumpdata == null)
8636
+ {
8637
+ //String texname = Object3D.GetBump(tex);
8638
+
8639
+ CacheTexture texturecache = texturebump.get(tex);
8640
+
8641
+ if (texturecache != null)
8642
+ {
8643
+ tex.bw = texturecache.texturedata.getWidth();
8644
+ tex.bh = texturecache.texturedata.getHeight();
8645
+ tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f);
8646
+ }
8647
+ }
8648
+ }
8649
+
8650
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
79378651 {
79388652 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
79398653
....@@ -7951,21 +8665,21 @@
79518665 return texture!=null?texture.texture:null;
79528666 }
79538667
7954
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8668
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
79558669 {
79568670 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
79578671
79588672 return texture!=null?texture.texturedata:null;
79598673 }
79608674
7961
- boolean BindTexture(String tex, boolean bump, int resolution)
8675
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
79628676 {
79638677 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
79648678 {
79658679 return false;
79668680 }
79678681
7968
- boolean newtex = false;
8682
+ //boolean newtex = false;
79698683
79708684 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
79718685
....@@ -7997,9 +8711,75 @@
79978711 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
79988712 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
79998713
8000
- return newtex;
8714
+ return true; // Warning: not used.
80018715 }
80028716
8717
+ public static byte[] CompressJPEG(BufferedImage image, float quality)
8718
+ {
8719
+ try
8720
+ {
8721
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
8722
+ Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg");
8723
+ ImageWriter writer = writers.next();
8724
+
8725
+ ImageWriteParam param = writer.getDefaultWriteParam();
8726
+ param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
8727
+ param.setCompressionQuality(quality);
8728
+
8729
+ ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
8730
+ writer.setOutput(ios);
8731
+ writer.write(null, new IIOImage(image, null, null), param);
8732
+
8733
+ byte[] data = baos.toByteArray();
8734
+ writer.dispose();
8735
+ return data;
8736
+ }
8737
+ catch (Exception e)
8738
+ {
8739
+ e.printStackTrace();
8740
+ return null;
8741
+ }
8742
+ }
8743
+
8744
+ public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException
8745
+ {
8746
+ ByteArrayInputStream baos = new ByteArrayInputStream(image);
8747
+ Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg");
8748
+ ImageReader reader = writers.next();
8749
+
8750
+ BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
8751
+
8752
+ ImageReadParam param = reader.getDefaultReadParam();
8753
+ param.setDestination(bim);
8754
+ //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB));
8755
+
8756
+ ImageInputStream ios = ImageIO.createImageInputStream(baos);
8757
+ reader.setInput(ios);
8758
+ BufferedImage bim2 = reader.read(0, param);
8759
+ reader.dispose();
8760
+
8761
+// WritableRaster raster = bim2.getRaster();
8762
+// DataBufferByte data = (DataBufferByte) raster.getDataBuffer();
8763
+// byte[] bytes = data.getData();
8764
+//
8765
+// int[] pixels = new int[bytes.length/3];
8766
+// for (int i=pixels.length; --i>=0;)
8767
+// {
8768
+// int i3 = i*3;
8769
+// pixels[i] = 0xFF;
8770
+// pixels[i] <<= 8;
8771
+// pixels[i] |= bytes[i3+2] & 0xFF;
8772
+// pixels[i] <<= 8;
8773
+// pixels[i] |= bytes[i3+1] & 0xFF;
8774
+// pixels[i] <<= 8;
8775
+// pixels[i] |= bytes[i3] & 0xFF;
8776
+// }
8777
+//
8778
+// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w);
8779
+
8780
+ return bim;
8781
+ }
8782
+
80038783 ShadowBuffer shadowPBuf;
80048784 AntialiasBuffer antialiasPBuf;
80058785 int MAXSTACK;
....@@ -8016,10 +8796,12 @@
80168796
80178797 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
80188798 MAXSTACK = temp[0];
8019
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8799
+ if (Globals.DEBUG)
8800
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
80208801 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
80218802 MAXSTACK = temp[0];
8022
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8803
+ if (Globals.DEBUG)
8804
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
80238805
80248806 // Use debug pipeline
80258807 //drawable.setGL(new DebugGL(gl)); //
....@@ -8027,7 +8809,8 @@
80278809 gl = drawable.getGL(); //
80288810
80298811 GL gl3 = getGL();
8030
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8812
+ if (Globals.DEBUG)
8813
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
80318814
80328815
80338816 //float pos[] = { 100, 100, 100, 0 };
....@@ -8192,7 +8975,7 @@
81928975
81938976 if (cubemap == null)
81948977 {
8195
- LoadEnvy(5);
8978
+ //LoadEnvy(1);
81968979 }
81978980
81988981 //cubemap.enable();
....@@ -8468,6 +9251,8 @@
84689251
84699252 void LoadEnvy(int which)
84709253 {
9254
+ assert(false);
9255
+
84719256 String name;
84729257 String ext;
84739258
....@@ -8479,37 +9264,58 @@
84799264 cubemap = null;
84809265 return;
84819266 case 1:
8482
- name = "cubemaps/box_";
8483
- ext = "png";
9267
+ name = "cubemaps/rgb/";
9268
+ ext = "jpg";
84849269 reverseUP = false;
84859270 break;
84869271 case 2:
8487
- name = "cubemaps/uffizi_";
8488
- ext = "png";
8489
- break; // reverseUP = true; break;
9272
+ name = "cubemaps/uffizi/";
9273
+ ext = "jpg";
9274
+ reverseUP = false;
9275
+ break;
84909276 case 3:
8491
- name = "cubemaps/CloudyHills_";
8492
- ext = "tga";
9277
+ name = "cubemaps/CloudyHills/";
9278
+ ext = "jpg";
84939279 reverseUP = false;
84949280 break;
84959281 case 4:
8496
- name = "cubemaps/cornell_";
9282
+ name = "cubemaps/cornell/";
84979283 ext = "png";
84989284 reverseUP = false;
84999285 break;
9286
+ case 5:
9287
+ name = "cubemaps/skycube/";
9288
+ ext = "jpg";
9289
+ reverseUP = false;
9290
+ break;
9291
+ case 6:
9292
+ name = "cubemaps/SaintLazarusChurch3/";
9293
+ ext = "jpg";
9294
+ reverseUP = false;
9295
+ break;
9296
+ case 7:
9297
+ name = "cubemaps/Sodermalmsallen/";
9298
+ ext = "jpg";
9299
+ reverseUP = false;
9300
+ break;
9301
+ case 8:
9302
+ name = "cubemaps/Sodermalmsallen2/";
9303
+ ext = "jpg";
9304
+ reverseUP = false;
9305
+ break;
9306
+ case 9:
9307
+ name = "cubemaps/UnionSquare/";
9308
+ ext = "jpg";
9309
+ reverseUP = false;
9310
+ break;
85009311 default:
8501
- name = "cubemaps/rgb_";
8502
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9312
+ name = "cubemaps/box/";
9313
+ ext = "png"; /*mipmap = true;*/
9314
+ reverseUP = false;
85039315 break;
85049316 }
8505
-
8506
- try
8507
- {
8508
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
8509
- } catch (IOException e)
8510
- {
8511
- throw new RuntimeException(e);
8512
- }
9317
+
9318
+ LoadSkybox(name, ext, mipmap);
85139319 }
85149320
85159321 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -8541,8 +9347,12 @@
85419347 static double[] model = new double[16];
85429348 double[] camera2light = new double[16];
85439349 double[] light2camera = new double[16];
8544
- int newenvy = -1;
8545
- boolean envyoff = true; // false;
9350
+
9351
+ //int newenvy = -1;
9352
+ //boolean envyoff = false;
9353
+
9354
+ String loadedskyboxname;
9355
+
85469356 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
85479357 //float[] light0 = { 0,0,0 };
85489358 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -8835,11 +9645,35 @@
88359645 jy8[3] = 0.5f;
88369646 }
88379647
8838
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9648
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
88399649 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
88409650 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
88419651 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
88429652
9653
+ void ResetOptions()
9654
+ {
9655
+ options1[0] = 100;
9656
+ options1[1] = 0.025f;
9657
+ options1[2] = 0.01f;
9658
+ options1[3] = 0;
9659
+ options1[4] = 0;
9660
+
9661
+ options2[0] = 0;
9662
+ options2[1] = 0.75f;
9663
+ options2[2] = 0;
9664
+ options2[3] = 0;
9665
+
9666
+ options3[0] = 1;
9667
+ options3[1] = 1;
9668
+ options3[2] = 1;
9669
+ options3[3] = 0;
9670
+
9671
+ options4[0] = 1;
9672
+ options4[1] = 0;
9673
+ options4[2] = 1;
9674
+ options4[3] = 0;
9675
+ }
9676
+
88439677 static int imagecount = 0; // movie generation
88449678
88459679 static int jitter = 0;
....@@ -8935,8 +9769,8 @@
89359769 assert (parentcam != renderCamera);
89369770
89379771 if (renderCamera != lightCamera)
8938
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8939
- LA.matConcat(matrix, parentcam.toParent, matrix);
9772
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9773
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
89409774
89419775 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
89429776
....@@ -8951,8 +9785,8 @@
89519785 LA.matCopy(renderCamera.fromScreen, matrix);
89529786
89539787 if (renderCamera != lightCamera)
8954
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8955
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9788
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9789
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
89569790
89579791 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
89589792
....@@ -8998,10 +9832,12 @@
89989832 rati = 1 / rati;
89999833 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
90009834 }
9001
- assert (newenvy == -1);
9835
+
9836
+ //assert (newenvy == -1);
9837
+
90029838 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
90039839 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
9004
- DrawSkyBox(gl);
9840
+ DrawSkyBox(gl, (float)rati);
90059841 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
90069842 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
90079843 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -9024,7 +9860,7 @@
90249860 //gl.glFlush();
90259861 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
90269862
9027
- if (ANIMATION && ABORTED)
9863
+ if (Globals.ANIMATION && ABORTED)
90289864 {
90299865 System.err.println(" ABORTED FRAME");
90309866 break;
....@@ -9054,7 +9890,7 @@
90549890 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
90559891
90569892 // save image
9057
- if (ANIMATION && !ABORTED)
9893
+ if (Globals.ANIMATION && !ABORTED)
90589894 {
90599895 VPwidth = viewport[2];
90609896 VPheight = viewport[3];
....@@ -9165,11 +10001,11 @@
916510001
916610002 // imagecount++;
916710003
9168
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
10004
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
916910005
917010006 if (!BOXMODE)
917110007 {
9172
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
10008
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
917310009 }
917410010
917510011 if (!BOXMODE)
....@@ -9207,7 +10043,7 @@
920710043 ABORTED = false;
920810044 }
920910045 else
9210
- GrafreeD.wav.cursor += 735 * ACSIZE;
10046
+ Grafreed.wav.cursor += 735 * ACSIZE;
921110047
921210048 if (false)
921310049 {
....@@ -9867,14 +10703,23 @@
986710703 static boolean init = false;
986810704
986910705 double[][] matrix = LA.newMatrix();
10706
+
10707
+ // This is to refresh the UI of the material panel.
10708
+ ObjEditor patchMaterial;
987010709
987110710 public void display(GLAutoDrawable drawable)
987210711 {
9873
- if (GrafreeD.savesound && GrafreeD.hassound)
10712
+ if (patchMaterial.patchMaterial)
987410713 {
9875
- GrafreeD.wav.save();
9876
- GrafreeD.savesound = false;
9877
- GrafreeD.hassound = false;
10714
+ patchMaterial.patchMaterial = false;
10715
+ patchMaterial.objectPanel.setSelectedIndex(1);
10716
+ }
10717
+
10718
+ if (Grafreed.savesound && Grafreed.hassound)
10719
+ {
10720
+ Grafreed.wav.save();
10721
+ Grafreed.savesound = false;
10722
+ Grafreed.hassound = false;
987810723 }
987910724 // if (DEBUG_SELECTION)
988010725 // {
....@@ -9950,6 +10795,7 @@
995010795 ANTIALIAS = 0;
995110796 //System.out.println("RESTART");
995210797 AAtimer.restart();
10798
+ Globals.TIMERRUNNING = true;
995310799 }
995410800 }
995510801 }
....@@ -10004,7 +10850,7 @@
1000410850 Object3D theobject = object;
1000510851 Object3D theparent = object.parent;
1000610852 object.parent = null;
10007
- object = (Object3D)GrafreeD.clone(object);
10853
+ object = (Object3D)Grafreed.clone(object);
1000810854 object.Stripify();
1000910855 if (theobject.selection == null || theobject.selection.Size() == 0)
1001010856 theobject.PreprocessOcclusion(this);
....@@ -10017,13 +10863,14 @@
1001710863 ambientOcclusion = false;
1001810864 }
1001910865
10020
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10866
+ if (//Globals.lighttouched &&
10867
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1002110868 {
1002210869 //if (RENDERSHADOW) // ?
1002310870 if (!IsFrozen())
1002410871 {
1002510872 // dec 2012
10026
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10873
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1002710874 {
1002810875 Globals.framecount++;
1002910876 shadowbuffer.display();
....@@ -10036,7 +10883,7 @@
1003610883
1003710884 if (wait)
1003810885 {
10039
- Sleep(500);
10886
+ Sleep(200); // blocks everything
1004010887
1004110888 wait = false;
1004210889 }
....@@ -10150,8 +10997,8 @@
1015010997
1015110998 // if (parentcam != renderCamera) // not a light
1015210999 if (cam != lightCamera)
10153
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10154
- LA.matConcat(matrix, parentcam.toParent, matrix);
11000
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11001
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
1015511002
1015611003 for (int j = 0; j < 4; j++)
1015711004 {
....@@ -10165,8 +11012,8 @@
1016511012
1016611013 // if (parentcam != renderCamera) // not a light
1016711014 if (cam != lightCamera)
10168
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10169
- LA.matConcat(parentcam.fromParent, matrix, matrix);
11015
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11016
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
1017011017
1017111018 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1017211019
....@@ -10252,13 +11099,43 @@
1025211099 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
1025311100 }
1025411101
10255
- if (newenvy > -1)
11102
+// if (newenvy > -1)
11103
+// {
11104
+// LoadEnvy(newenvy);
11105
+// }
11106
+//
11107
+// newenvy = -1;
11108
+
11109
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1025611110 {
10257
- LoadEnvy(newenvy);
11111
+ if (cubemaprgb == null)
11112
+ {
11113
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
11114
+ }
11115
+
11116
+ cubemap = cubemaprgb;
1025811117 }
10259
-
10260
- newenvy = -1;
10261
-
11118
+ else
11119
+ {
11120
+ if (object.skyboxname != null)
11121
+ {
11122
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11123
+ {
11124
+ if (cubemap != null && cubemap != cubemaprgb)
11125
+ cubemap.dispose();
11126
+ cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11127
+ loadedskyboxname = object.skyboxname;
11128
+ }
11129
+ }
11130
+ else
11131
+ {
11132
+ cubemapcustom = null;
11133
+ loadedskyboxname = null;
11134
+ }
11135
+
11136
+ cubemap = cubemapcustom;
11137
+ }
11138
+
1026211139 ratio = ((double) getWidth()) / getHeight();
1026311140 //System.out.println("ratio = " + ratio);
1026411141
....@@ -10274,7 +11151,7 @@
1027411151
1027511152 if (!IsFrozen() && !ambientOcclusion)
1027611153 {
10277
- DrawSkyBox(gl);
11154
+ DrawSkyBox(gl, (float)ratio);
1027811155 }
1027911156
1028011157 //if (selection_view == -1)
....@@ -10425,7 +11302,16 @@
1042511302 // Bump noise
1042611303 gl.glActiveTexture(GL.GL_TEXTURE6);
1042711304 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10428
- BindTexture(NOISE_TEXTURE, false, 2);
11305
+
11306
+ try
11307
+ {
11308
+ BindTexture(NOISE_TEXTURE, false, 2);
11309
+ }
11310
+ catch (Exception e)
11311
+ {
11312
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11313
+ }
11314
+
1042911315
1043011316 gl.glActiveTexture(GL.GL_TEXTURE0);
1043111317 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10448,9 +11334,9 @@
1044811334
1044911335 gl.glMatrixMode(GL.GL_MODELVIEW);
1045011336
10451
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10452
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10453
-//gl.glEnable(gl.GL_MULTISAMPLE);
11337
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11338
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11339
+gl.glEnable(gl.GL_MULTISAMPLE);
1045411340 } else
1045511341 {
1045611342 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10461,7 +11347,7 @@
1046111347 //System.out.println("BLENDING ON");
1046211348 gl.glEnable(GL.GL_BLEND);
1046311349 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10464
-
11350
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1046511351 gl.glMatrixMode(gl.GL_PROJECTION);
1046611352 gl.glLoadIdentity();
1046711353
....@@ -10550,8 +11436,8 @@
1055011436 System.err.println("parentcam != renderCamera");
1055111437
1055211438 // if (cam != lightCamera)
10553
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10554
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11439
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11440
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1055511441 }
1055611442
1055711443 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10572,8 +11458,8 @@
1057211458 if (true) // TODO
1057311459 {
1057411460 if (cam != lightCamera)
10575
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10576
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11461
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11462
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1057711463 }
1057811464
1057911465 LA.xformPos(light0, cam.toScreen, light0);
....@@ -10710,7 +11596,7 @@
1071011596 }
1071111597 }
1071211598
10713
- if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
11599
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
1071411600 {
1071511601 //gl.glDepthFunc(GL.GL_LEQUAL);
1071611602 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -10718,24 +11604,21 @@
1071811604
1071911605 boolean texon = textureon;
1072011606
10721
- if (RENDERPROGRAM > 0)
10722
- {
10723
- gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
10724
- textureon = false;
10725
- }
11607
+ gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11608
+ textureon = false;
11609
+
1072611610 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
1072711611 //System.out.println("ALLO");
1072811612 gl.glColorMask(false, false, false, false);
1072911613 DrawObject(gl);
10730
- if (RENDERPROGRAM > 0)
10731
- {
10732
- gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
10733
- textureon = texon;
10734
- }
11614
+
11615
+ gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11616
+ textureon = texon;
11617
+
1073511618 gl.glColorMask(true, true, true, true);
1073611619
1073711620 gl.glDepthFunc(GL.GL_EQUAL);
10738
- //gl.glDepthMask(false);
11621
+ gl.glDepthMask(false);
1073911622 }
1074011623
1074111624 if (false) // DrawMode() == SHADOW)
....@@ -10889,8 +11772,14 @@
1088911772 {
1089011773 renderpass++;
1089111774 // System.out.println("Draw object... ");
11775
+ STEP = 1;
1089211776 if (FAST) // in case there is no script
10893
- STEP = 16;
11777
+ STEP = 8;
11778
+
11779
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11780
+ {
11781
+ STEP *= 4;
11782
+ }
1089411783
1089511784 //object.FullInvariants();
1089611785
....@@ -10904,23 +11793,44 @@
1090411793 e.printStackTrace();
1090511794 }
1090611795
10907
- if (GrafreeD.RENDERME > 0)
10908
- GrafreeD.RENDERME--; // mechante magouille
11796
+ if (Grafreed.RENDERME > 0)
11797
+ Grafreed.RENDERME--; // mechante magouille
1090911798
1091011799 Globals.ONESTEP = false;
1091111800 }
1091211801
1091311802 static boolean zoomonce = false;
1091411803
11804
+ static void CreateSelectedPoint()
11805
+ {
11806
+ if (selectedpoint == null)
11807
+ {
11808
+ debugpointG = new Sphere();
11809
+ debugpointP = new Sphere();
11810
+ debugpointC = new Sphere();
11811
+ debugpointR = new Sphere();
11812
+
11813
+ selectedpoint = new Superellipsoid();
11814
+
11815
+ for (int i=0; i<8; i++)
11816
+ {
11817
+ debugpoints[i] = new Sphere();
11818
+ }
11819
+ }
11820
+ }
11821
+
1091511822 void DrawObject(GL gl, boolean draw)
1091611823 {
11824
+ // To clear camera values
11825
+ ResetOptions();
11826
+
1091711827 //System.out.println("DRAW OBJECT " + mouseDown);
1091811828 // DrawMode() = SELECTION;
1091911829 //GL gl = getGL();
1092011830 if ((TRACK || SHADOWTRACK) || zoomonce)
1092111831 {
1092211832 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
10923
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11833
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1092411834 pingthread.StepToTarget(true); // true);
1092511835 // zoomonce = false;
1092611836 }
....@@ -10975,7 +11885,14 @@
1097511885
1097611886 usedtextures.clear();
1097711887
10978
- BindTextures(DEFAULT_TEXTURES, 2);
11888
+ try
11889
+ {
11890
+ BindTextures(DEFAULT_TEXTURES, 2);
11891
+ }
11892
+ catch (Exception e)
11893
+ {
11894
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11895
+ }
1097911896 }
1098011897 //System.out.println("--> " + stackdepth);
1098111898 // GrafreeD.traceon();
....@@ -10985,8 +11902,9 @@
1098511902
1098611903 if (DrawMode() == DEFAULT)
1098711904 {
10988
- if (DEBUG)
11905
+ if (Globals.DEBUG)
1098911906 {
11907
+ CreateSelectedPoint();
1099011908 float radius = 0.05f;
1099111909 if (selectedpoint.radius != radius)
1099211910 {
....@@ -11040,20 +11958,32 @@
1104011958 ReleaseTextures(DEFAULT_TEXTURES);
1104111959
1104211960 if (CLEANCACHE)
11043
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11961
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1104411962 {
11045
- String tex = e.nextElement();
11963
+ cTexture tex = e.nextElement();
1104611964
1104711965 // System.out.println("Texture --------- " + tex);
1104811966
11049
- if (tex.equals("WHITE_NOISE"))
11967
+ if (tex.equals("WHITE_NOISE:"))
1105011968 continue;
1105111969
11052
- if (!usedtextures.containsKey(tex))
11970
+ if (!usedtextures.contains(tex))
1105311971 {
11972
+ CacheTexture gettex = texturepigment.get(tex);
1105411973 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11055
- textures.get(tex).texture.dispose();
11056
- textures.remove(tex);
11974
+ if (gettex != null)
11975
+ {
11976
+ gettex.texture.dispose();
11977
+ texturepigment.remove(tex);
11978
+ }
11979
+
11980
+ gettex = texturebump.get(tex);
11981
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11982
+ if (gettex != null)
11983
+ {
11984
+ gettex.texture.dispose();
11985
+ texturebump.remove(tex);
11986
+ }
1105711987 }
1105811988 }
1105911989 }
....@@ -11066,7 +11996,14 @@
1106611996 if (checker != null && DrawMode() == DEFAULT)
1106711997 {
1106811998 //BindTexture(IMMORTAL_TEXTURE);
11069
- BindTextures(checker.GetTextures(), checker.texres);
11999
+ try
12000
+ {
12001
+ BindTextures(checker.GetTextures(), checker.texres);
12002
+ }
12003
+ catch (Exception e)
12004
+ {
12005
+ System.err.println("FAILED: " + checker.GetTextures());
12006
+ }
1107012007 // NEAREST
1107112008 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1107212009 DrawChecker(gl);
....@@ -11148,7 +12085,7 @@
1114812085 return;
1114912086 }
1115012087
11151
- String string = obj.GetToolTip();
12088
+ String string = obj.toString(); //.GetToolTip();
1115212089
1115312090 GL gl = GetGL();
1115412091
....@@ -11465,8 +12402,8 @@
1146512402 //obj.TransformToWorld(light, light);
1146612403 for (int i = tp.size(); --i >= 0;)
1146712404 {
11468
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11469
- LA.xformPos(light, tp.get(i).toParent, light);
12405
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12406
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1147012407 }
1147112408
1147212409
....@@ -11483,8 +12420,8 @@
1148312420 parentcam = cameras[0];
1148412421 }
1148512422
11486
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11487
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12423
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12424
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1148812425
1148912426 LA.xformPos(light, renderCamera.toScreen, light);
1149012427
....@@ -11574,8 +12511,76 @@
1157412511
1157512512 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1157612513
11577
- String program =
12514
+ String programmin =
12515
+ // Min shader
1157812516 "!!ARBfp1.0\n" +
12517
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
12518
+ "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12519
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12520
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12521
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12522
+ "PARAM light2cam0 = program.env[10];" +
12523
+ "PARAM light2cam1 = program.env[11];" +
12524
+ "PARAM light2cam2 = program.env[12];" +
12525
+ "TEMP temp;" +
12526
+ "TEMP light;" +
12527
+ "TEMP ndotl;" +
12528
+ "TEMP normal;" +
12529
+ "TEMP depth;" +
12530
+ "TEMP eye;" +
12531
+ "TEMP pos;" +
12532
+
12533
+ "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12534
+ Normalize("normal") +
12535
+ "MOV light, state.light[0].position;" +
12536
+ "DP3 ndotl.x, light, normal;" +
12537
+
12538
+ // shadow
12539
+ "MOV pos, fragment.texcoord[1];" +
12540
+ "MOV temp, pos;" +
12541
+ ShadowTextureFetch("depth", "temp", "1") +
12542
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12543
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
12544
+
12545
+ // No shadow when out of frustum
12546
+ //"SGE temp.y, depth.z, zero123.y;" +
12547
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12548
+
12549
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
12550
+
12551
+ // Backlit
12552
+ "MOV pos.w, zero123.y;" +
12553
+ "DP4 eye.x, pos, light2cam0;" +
12554
+ "DP4 eye.y, pos, light2cam1;" +
12555
+ "DP4 eye.z, pos, light2cam2;" +
12556
+ Normalize("eye") +
12557
+
12558
+ "DP3 ndotl.y, -eye, normal;" +
12559
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12560
+ "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12561
+ "SUB ndotl.y, zero123.y, ndotl.y;" +
12562
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12563
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12564
+
12565
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12566
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
12567
+
12568
+ // Pigment
12569
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12570
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
12571
+ "MUL temp, temp, ndotl.x;" +
12572
+
12573
+ "MUL temp, temp, zero123.z;" +
12574
+
12575
+ //"MUL temp, temp, ndotl.y;" +
12576
+
12577
+ "MOV temp.w, zero123.y;" + // reset alpha
12578
+ "MOV result.color, temp;" +
12579
+ "END";
12580
+
12581
+ String programmax =
12582
+ "!!ARBfp1.0\n" +
12583
+
1157912584 //"OPTION ARB_fragment_program_shadow;" +
1158012585 "PARAM light2cam0 = program.env[10];" +
1158112586 "PARAM light2cam1 = program.env[11];" +
....@@ -11601,7 +12606,7 @@
1160112606 "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow
1160212607 "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias
1160312608 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
11604
- "PARAM params7 = program.env[7];" + // noise power, opacity power
12609
+ "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax
1160512610 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
1160612611 "PARAM options1 = program.env[62];" + // fog rgb color
1160712612 "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
....@@ -11690,8 +12695,7 @@
1169012695 "TEMP shininess;" +
1169112696 "\n" +
1169212697 "MOV texSamp, one;" +
11693
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
11694
-
12698
+
1169512699 "MOV mapgrid.x, one2048th.x;" +
1169612700 "MOV temp, fragment.texcoord[1];" +
1169712701 /*
....@@ -11712,20 +12716,20 @@
1171212716 "MUL temp, floor, mapgrid.x;" +
1171312717 //"TEX depth0, temp, texture[1], 2D;" +
1171412718 (((mode & FP_SOFTSHADOW) == 0) ? "" :
11715
- TextureFetch("depth0", "temp", "1") +
12719
+ ShadowTextureFetch("depth0", "temp", "1") +
1171612720 "") +
1171712721 "ADD temp.x, temp.x, mapgrid.x;" +
1171812722 //"TEX depth1, temp, texture[1], 2D;" +
1171912723 (((mode & FP_SOFTSHADOW) == 0) ? "" :
11720
- TextureFetch("depth1", "temp", "1") +
12724
+ ShadowTextureFetch("depth1", "temp", "1") +
1172112725 "") +
1172212726 "ADD temp.y, temp.y, mapgrid.x;" +
1172312727 //"TEX depth2, temp, texture[1], 2D;" +
11724
- TextureFetch("depth2", "temp", "1") +
12728
+ ShadowTextureFetch("depth2", "temp", "1") +
1172512729 "SUB temp.x, temp.x, mapgrid.x;" +
1172612730 //"TEX depth3, temp, texture[1], 2D;" +
1172712731 (((mode & FP_SOFTSHADOW) == 0) ? "" :
11728
- TextureFetch("depth3", "temp", "1") +
12732
+ ShadowTextureFetch("depth3", "temp", "1") +
1172912733 "") +
1173012734 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1173112735 //"MOV params, material;" +
....@@ -11847,7 +12851,7 @@
1184712851 "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut
1184812852 // mar 2013 ??? "KIL alpha.a;" +
1184912853 "MOV alpha, texSamp.aaaa;" + // y;" +
11850
- "KIL alpha.a;" +
12854
+ "KIL alpha.a;" + // not sure with parallax mapping
1185112855 /*
1185212856 "MUL temp.xy, temp, two;" +
1185312857 "TXB bump, temp, texture[0], 2D;" +
....@@ -11933,11 +12937,6 @@
1193312937 "SUB bump0, bump0, half;" +
1193412938 "ADD bump, bump, bump0;" +
1193512939
11936
- "MOV temp.x, texSamp.a;" +
11937
- "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
11938
- //"LRP texSamp0, params5.x, texSamp0, one;" +
11939
- "MOV texSamp.a, temp.x;" +
11940
-
1194112940 // double-sided
1194212941 /**/
1194312942 (doublesided?"DP3 temp.z, normal, eye;" +
....@@ -11954,19 +12953,62 @@
1195412953 "MOV normald, normal;" +
1195512954 "MOV normals, normal;" +
1195612955
12956
+ "MOV temp, fragment.texcoord[4];" +
12957
+
1195712958 // UV base
1195812959 //"DP3 UP.x,state.matrix.modelview.row[0],Y;" +
1195912960 //"DP3 UP.y,state.matrix.modelview.row[1],Y;" +
1196012961 //"DP3 UP.z,state.matrix.modelview.row[2],Y;" +
11961
- "DP3 UP.x,state.matrix.texture[7].row[0],Y;" +
11962
- "DP3 UP.y,state.matrix.texture[7].row[1],Y;" +
11963
- "DP3 UP.z,state.matrix.texture[7].row[2],Y;" +
12962
+ "DP3 UP.x,state.matrix.texture[7].row[0],temp;" +
12963
+ "DP3 UP.y,state.matrix.texture[7].row[1],temp;" +
12964
+ "DP3 UP.z,state.matrix.texture[7].row[2],temp;" +
12965
+ Normalize("UP") +
12966
+
1196412967 "XPD V, normal, UP;" +
1196512968 Normalize("V") +
1196612969 "XPD U, V, normal;" +
1196712970 Normalize("U") +
1196812971
1196912972 // parallax mapping
12973
+
12974
+ "DP3 temp2.x, V, eye;" +
12975
+ "DP3 temp2.y, U, eye;" +
12976
+ "DP3 temp2.z, normal, eye;" +
12977
+ "RCP temp2.z, temp2.z;" +
12978
+
12979
+ "DP3 temp2.w, texSamp, texSamp;" + // Height
12980
+ "RSQ temp2.w, temp2.w;" +
12981
+ "RCP temp2.w, temp2.w;" +
12982
+
12983
+ "SUB temp2.w, temp2.w, half;" +
12984
+// "SGE temp.x, temp2.w, eps.x;" +
12985
+// "MUL temp2.w, temp2.w, temp.x;" +
12986
+
12987
+ //"MOV texSamp, U;" +
12988
+
12989
+ "MUL temp2.z, temp2.z, temp2.w;" +
12990
+ "MUL temp2.z, temp2.z, params7.z;" + // parallax
12991
+
12992
+ "MUL temp2, temp2, temp2.z;" +
12993
+
12994
+ "MOV temp, fragment.texcoord[0];" +
12995
+
12996
+ "SUB temp, temp, temp2;" +
12997
+
12998
+ "TEX temp, temp, texture[0], 2D;" +
12999
+ "POW temp.a, temp.a, params6.w;" + // punch through
13000
+
13001
+ "ADD texSamp, temp, texSamp;" +
13002
+ "MUL texSamp.xyz, half, texSamp;" +
13003
+
13004
+ "MOV alpha, texSamp.aaaa;" +
13005
+
13006
+// parallax mapping
13007
+
13008
+ "MOV temp.x, texSamp.a;" +
13009
+ "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
13010
+ //"LRP texSamp0, params5.x, texSamp0, one;" +
13011
+ "MOV texSamp.a, temp.x;" +
1197013012
1197113013 //"MOV temp, fragment.texcoord[0];" +
1197213014 //
....@@ -12096,10 +13138,10 @@
1209613138 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1209713139 "") +
1209813140
12099
- // display shadow only (bump == 0)
13141
+ // display shadow only (fakedepth == 0)
1210013142 "SUB temp.x, half.x, shadow.x;" +
12101
- "MOV temp.y, -params6.x;" +
12102
- "SLT temp.z, temp.y, zero.x;" +
13143
+ "MOV temp.y, -params5.z;" + // params6.x;" +
13144
+ "SLT temp.z, temp.y, -c256i.x;" +
1210313145 "SUB temp.y, one.x, temp.z;" +
1210413146 "MUL temp.x, temp.x, temp.y;" +
1210513147 "KIL temp.x;" +
....@@ -12228,8 +13270,10 @@
1222813270 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1222913271
1223013272 "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
13273
+ // Tuning for default skin
13274
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
13275
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
13276
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1223313277 "MUL temp.x, temp.x, temp.y;" +
1223413278
1223513279 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12428,8 +13472,19 @@
1242813472 //once = true;
1242913473 }
1243013474
12431
- System.out.print("Program #" + mode + "; length = " + program.length());
12432
- System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13475
+ String program = programmax;
13476
+
13477
+ if (Globals.MINSHADER)
13478
+ {
13479
+ program = programmin;
13480
+ }
13481
+
13482
+ if (Globals.DEBUG)
13483
+ {
13484
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13485
+ System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13486
+ }
13487
+
1243313488 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1243413489
1243513490 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -12476,7 +13531,8 @@
1247613531 "\n" +
1247713532 "END\n";
1247813533
12479
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13534
+ if (Globals.DEBUG)
13535
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1248013536 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1248113537
1248213538 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -12521,25 +13577,26 @@
1252113577 return out;
1252213578 }
1252313579
12524
- String TextureFetch(String dest, String src, String unit)
13580
+ // Also does frustum culling
13581
+ String ShadowTextureFetch(String dest, String src, String unit)
1252513582 {
1252613583 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1252713584 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1252813585 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13586
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13587
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1252913588 "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;" +
13589
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13590
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1253413591 //"SWZ buffer, temp, w,w,w,w;";
12535
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13592
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1253613593 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1253713594 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1253813595 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
12539
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13596
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1254013597
12541
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
12542
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13598
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13599
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1254313600 }
1254413601
1254513602 String Shadow(String depth, String shadow)
....@@ -12561,12 +13618,16 @@
1256113618
1256213619 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1256313620 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13621
+
13622
+ // Compare fragment depth in light space with shadowmap.
1256413623 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1256513624 "SGE temp.y, temp.x, zero.x;" +
12566
- "SUB " + shadow + ".y, one.x, temp.y;" +
13625
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13626
+
13627
+ // Reverse comparison
1256713628 "SUB temp.x, one.x, temp.x;" +
1256813629 "MUL " + shadow + ".x, temp.x, temp.y;" +
12569
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13630
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1257013631 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1257113632
1257213633 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12580,6 +13641,10 @@
1258013641 // No shadow for backface
1258113642 "DP3 temp.x, normal, lightd;" +
1258213643 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13644
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13645
+
13646
+ // No shadow when out of frustum
13647
+ "SGE temp.x, " + depth + ".z, one.z;" +
1258313648 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1258413649 "";
1258513650 }
....@@ -12725,8 +13790,9 @@
1272513790 /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow
1272613791 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1272713792 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
12728
- /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
12729
- Object3D.cVector2[] vector2buffer;
13793
+ /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax
13794
+
13795
+ //Object3D.cVector2[] vector2buffer;
1273013796
1273113797 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1273213798 // OUT : diff, spec
....@@ -12742,9 +13808,10 @@
1274213808 "DP3 " + dest + ".z," + "normals," + "eye;" +
1274313809 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1274413810 //"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;" +
13811
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13812
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13813
+
13814
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1274813815 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1274913816 "RCP " + dest + ".w," + dest + ".w;" +
1275013817 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -12890,7 +13957,7 @@
1289013957 "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" +
1289113958 "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" +
1289213959 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
12893
- "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" +
13960
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1289413961 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1289513962 "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" +
1289613963 //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" +
....@@ -12951,7 +14018,7 @@
1295114018 "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" +
1295214019 "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" +
1295314020 "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" +
12954
- //"MOV result.texcoord, vertex.texcoord;" +
14021
+ //"MOV result.texcoord, vertex.fogcoord;" +
1295514022 "MOV result.texcoord, temp;" +
1295614023 // border fade
1295714024 "MOV result.texcoord[3], vertex.texcoord;" +
....@@ -12998,7 +14065,9 @@
1299814065
1299914066 //"ADD temp.z, temp.z, one;" +
1300014067
13001
- "MOV result.color, temp;"
14068
+ "MOV result.texcoord[4], vertex.attrib[4];" + // U dir
14069
+
14070
+ "MOV result.color, temp;" // Normal
1300214071 : "MOV result.color, vertex.color;") +
1300314072 ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;"
1300414073 : "") +
....@@ -13138,7 +14207,7 @@
1313814207 public void mousePressed(MouseEvent e)
1313914208 {
1314014209 //System.out.println("mousePressed: " + e);
13141
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
14210
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1314214211 }
1314314212
1314414213 static long prevtime = 0;
....@@ -13165,6 +14234,7 @@
1316514234
1316614235 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1316714236
14237
+ if (BUTTONLESSWHEEL)
1316814238 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1316914239 {
1317014240 return;
....@@ -13173,7 +14243,7 @@
1317314243 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1317414244
1317514245 // TIMER
13176
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
14246
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1317714247 {
1317814248 keepboxmode = BOXMODE;
1317914249 keepsupport = SUPPORT;
....@@ -13213,8 +14283,8 @@
1321314283 // mode |= META;
1321414284 //}
1321514285
13216
- SetMouseMode(WHEEL | e.getModifiersEx());
13217
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
14286
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
14287
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1321814288 anchorX = ax;
1321914289 anchorY = ay;
1322014290 prevX = px;
....@@ -13248,6 +14318,7 @@
1324814318 else
1324914319 if (evt.getSource() == AAtimer)
1325014320 {
14321
+ Globals.TIMERRUNNING = false;
1325114322 if (mouseDown)
1325214323 {
1325314324 //new Exception().printStackTrace();
....@@ -13273,6 +14344,10 @@
1327314344 // LIVE = waslive;
1327414345 // wasliveok = true;
1327514346 // waslive = false;
14347
+
14348
+ // May 2019 Forget it:
14349
+ if (true)
14350
+ return;
1327614351
1327714352 // source == timer
1327814353 if (mouseDown)
....@@ -13303,7 +14378,7 @@
1330314378
1330414379 // fev 2014???
1330514380 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13306
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14381
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1330714382 pingthread.StepToTarget(true); // true);
1330814383 }
1330914384 // if (!LIVE)
....@@ -13312,12 +14387,13 @@
1331214387
1331314388 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1331414389
13315
- void clickStart(int x, int y, int modifiers)
14390
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1331614391 {
1331714392 if (!wasliveok)
1331814393 return;
1331914394
1332014395 AAtimer.restart(); //
14396
+ Globals.TIMERRUNNING = true;
1332114397
1332214398 // waslive = LIVE;
1332314399 // LIVE = false;
....@@ -13329,7 +14405,7 @@
1332914405 // touched = true; // main DL
1333014406 if (isRenderer)
1333114407 {
13332
- SetMouseMode(modifiers);
14408
+ SetMouseMode(modifiers, modifiersex);
1333314409 }
1333414410
1333514411 selectX = anchorX = x;
....@@ -13342,7 +14418,7 @@
1334214418 clicked = true;
1334314419 hold = false;
1334414420
13345
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14421
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1334614422 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1334714423 {
1334814424 // System.out.println("RESTART II " + modifiers);
....@@ -13367,14 +14443,15 @@
1336714443 drag = false;
1336814444 //System.out.println("Mouse DOWN");
1336914445 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);
14446
+ //ClickInfo info = new ClickInfo();
14447
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14448
+ object.clickInfo.pane = this;
14449
+ object.clickInfo.camera = renderCamera;
14450
+ object.clickInfo.x = x;
14451
+ object.clickInfo.y = y;
14452
+ object.clickInfo.modifiers = modifiersex;
14453
+ editObj = object.doEditClick(//info,
14454
+ 0);
1337814455 if (!editObj)
1337914456 {
1338014457 hasMarquee = true;
....@@ -13390,11 +14467,14 @@
1339014467
1339114468 public void mouseDragged(MouseEvent e)
1339214469 {
14470
+ Globals.MOUSEDRAGGED = true;
14471
+
14472
+ //System.out.println("mouseDragged: " + e);
1339314473 if (isRenderer)
1339414474 movingcamera = true;
14475
+
1339514476 //if (drawing)
1339614477 //return;
13397
- //System.out.println("mouseDragged: " + e);
1339814478 if ((e.getModifiersEx() & CTRL) != 0
1339914479 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1340014480 {
....@@ -13402,7 +14482,7 @@
1340214482 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1340314483 }
1340414484 else
13405
- drag(e.getX(), e.getY(), e.getModifiersEx());
14485
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1340614486
1340714487 //try { Thread.sleep(1); } catch (Exception ex) {}
1340814488 }
....@@ -13575,6 +14655,7 @@
1357514655
1357614656 public void run()
1357714657 {
14658
+ new Exception().printStackTrace();
1357814659 System.exit(0);
1357914660 for (;;)
1358014661 {
....@@ -13638,7 +14719,7 @@
1363814719 {
1363914720 Globals.lighttouched = true;
1364014721 }
13641
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14722
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1364214723 }
1364314724 //else
1364414725 }
....@@ -13652,12 +14733,18 @@
1365214733 void GoDown(int mod)
1365314734 {
1365414735 MODIFIERS |= COMMAND;
13655
- /*
14736
+ boolean isVR = (mouseMode&VR)!=0;
14737
+ /**/
1365614738 if((mod&SHIFT) == SHIFT)
13657
- manipCamera.RotatePosition(0, -speed);
14739
+ {
14740
+ if (isVR)
14741
+ manipCamera.RotateInterest(0, -speed);
14742
+ else
14743
+ manipCamera.RotatePosition(0, -speed);
14744
+ }
1365814745 else
13659
- manipCamera.BackForth(0, -speed*delta, getWidth());
13660
- */
14746
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
14747
+ /**/
1366114748 if ((mod & SHIFT) == SHIFT)
1366214749 {
1366314750 mouseMode = mouseMode; // VR??
....@@ -13666,6 +14753,8 @@
1366614753 mouseMode |= BACKFORTH;
1366714754 }
1366814755
14756
+ targetLookAt.set(manipCamera.lookAt);
14757
+
1366914758 //prevX = X = anchorX;
1367014759 prevY = Y = anchorY - (int) (renderCamera.Distance());
1367114760 }
....@@ -13673,12 +14762,19 @@
1367314762 void GoUp(int mod)
1367414763 {
1367514764 MODIFIERS |= COMMAND;
13676
- /*
14765
+ /**/
14766
+ boolean isVR = (mouseMode&VR)!=0;
14767
+
1367714768 if((mod&SHIFT) == SHIFT)
13678
- manipCamera.RotatePosition(0, speed);
14769
+ {
14770
+ if (isVR)
14771
+ manipCamera.RotateInterest(0, speed);
14772
+ else
14773
+ manipCamera.RotatePosition(0, speed);
14774
+ }
1367914775 else
13680
- manipCamera.BackForth(0, speed*delta, getWidth());
13681
- */
14776
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
14777
+ /**/
1368214778 if ((mod & SHIFT) == SHIFT)
1368314779 {
1368414780 mouseMode = mouseMode;
....@@ -13687,6 +14783,8 @@
1368714783 mouseMode |= BACKFORTH;
1368814784 }
1368914785
14786
+ targetLookAt.set(manipCamera.lookAt);
14787
+
1369014788 //prevX = X = anchorX;
1369114789 prevY = Y = anchorY + (int) (renderCamera.Distance());
1369214790 }
....@@ -13694,12 +14792,17 @@
1369414792 void GoLeft(int mod)
1369514793 {
1369614794 MODIFIERS |= COMMAND;
13697
- /*
14795
+ /**/
1369814796 if((mod&SHIFT) == SHIFT)
13699
- manipCamera.RotatePosition(speed, 0);
14797
+ manipCamera.Translate(speed*delta, 0, getWidth());
1370014798 else
13701
- manipCamera.Translate(speed*delta, 0, getWidth());
13702
- */
14799
+ {
14800
+ if ((mouseMode&VR)!=0)
14801
+ manipCamera.RotateInterest(-speed, 0);
14802
+ else
14803
+ manipCamera.RotatePosition(speed, 0);
14804
+ }
14805
+ /**/
1370314806 if ((mod & SHIFT) == SHIFT)
1370414807 {
1370514808 mouseMode = mouseMode;
....@@ -13708,6 +14811,8 @@
1370814811 mouseMode |= ROTATE;
1370914812 } // TRANSLATE;
1371014813
14814
+ targetLookAt.set(manipCamera.lookAt);
14815
+
1371114816 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1371214817 prevY = Y = anchorY;
1371314818 }
....@@ -13715,12 +14820,18 @@
1371514820 void GoRight(int mod)
1371614821 {
1371714822 MODIFIERS |= COMMAND;
13718
- /*
14823
+ /**/
1371914824 if((mod&SHIFT) == SHIFT)
13720
- manipCamera.RotatePosition(-speed, 0);
14825
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1372114826 else
13722
- manipCamera.Translate(-speed*delta, 0, getWidth());
13723
- */
14827
+ {
14828
+ if ((mouseMode&VR)!=0)
14829
+ manipCamera.RotateInterest(speed, 0);
14830
+ else
14831
+ manipCamera.RotatePosition(-speed, 0);
14832
+ }
14833
+
14834
+ /**/
1372414835 if ((mod & SHIFT) == SHIFT)
1372514836 {
1372614837 mouseMode = mouseMode;
....@@ -13729,6 +14840,8 @@
1372914840 mouseMode |= ROTATE;
1373014841 } // TRANSLATE;
1373114842
14843
+ targetLookAt.set(manipCamera.lookAt);
14844
+
1373214845 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1373314846 prevY = Y = anchorY;
1373414847 }
....@@ -13738,7 +14851,7 @@
1373814851 int X, Y;
1373914852 boolean SX, SY;
1374014853
13741
- void drag(int x, int y, int modifiers)
14854
+ void drag(int x, int y, int modifiers, int modifiersex)
1374214855 {
1374314856 if (IsFrozen())
1374414857 {
....@@ -13747,17 +14860,17 @@
1374714860
1374814861 drag = true; // NEW
1374914862
13750
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14863
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1375114864
1375214865 X = x;
1375314866 Y = y;
1375414867 // floating state for animation
13755
- MODIFIERS = modifiers;
13756
- modifiers &= ~1024;
14868
+ MODIFIERS = modifiersex;
14869
+ modifiersex &= ~1024;
1375714870 if (false) // modifiers != 0)
1375814871 {
1375914872 //new Exception().printStackTrace();
13760
- System.out.println("mouseDragged: " + modifiers);
14873
+ System.out.println("mouseDragged: " + modifiersex);
1376114874 System.out.println("SHIFT = " + SHIFT);
1376214875 System.out.println("CONTROL = " + COMMAND);
1376314876 System.out.println("META = " + META);
....@@ -13770,14 +14883,16 @@
1377014883 if (editObj)
1377114884 {
1377214885 drag = true;
13773
- ClickInfo info = new ClickInfo();
13774
- info.bounds.setBounds(0, 0,
14886
+ //ClickInfo info = new ClickInfo();
14887
+ object.clickInfo.bounds.setBounds(0, 0,
1377514888 (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);
14889
+ object.clickInfo.pane = this;
14890
+ object.clickInfo.camera = renderCamera;
14891
+ object.clickInfo.x = x;
14892
+ object.clickInfo.y = y;
14893
+ object //.GetWindow().copy
14894
+ .doEditDrag(//info,
14895
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1378114896 } else
1378214897 {
1378314898 if (x < startX)
....@@ -13926,23 +15041,27 @@
1392615041 }
1392715042 }
1392815043
15044
+// ClickInfo clickInfo = new ClickInfo();
15045
+
1392915046 public void mouseMoved(MouseEvent e)
1393015047 {
1393115048 //System.out.println("mouseMoved: " + e);
13932
-
1393315049 if (isRenderer)
1393415050 return;
1393515051
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;
15052
+ // Mouse cursor feedback
15053
+ object.clickInfo.x = e.getX();
15054
+ object.clickInfo.y = e.getY();
15055
+ object.clickInfo.modifiers = e.getModifiersEx();
15056
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
15057
+ object.clickInfo.pane = this;
15058
+ object.clickInfo.camera = renderCamera;
1394315059 if (!isRenderer)
1394415060 {
13945
- if (object.editWindow.copy.doEditClick(ci, 0))
15061
+ //ObjEditor editWindow = object.editWindow;
15062
+ //Object3D copy = editWindow.copy;
15063
+ if (object.doEditClick(//clickInfo,
15064
+ 0))
1394615065 {
1394715066 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1394815067 } else
....@@ -13954,7 +15073,11 @@
1395415073
1395515074 public void mouseReleased(MouseEvent e)
1395615075 {
15076
+ Globals.MOUSEDRAGGED = false;
15077
+
1395715078 movingcamera = false;
15079
+ X = 0; // getBounds().width/2;
15080
+ Y = 0; // getBounds().height/2;
1395815081 //System.out.println("mouseReleased: " + e);
1395915082 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1396015083 }
....@@ -13977,9 +15100,9 @@
1397715100 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1397815101 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1397915102
13980
- if (control || command || IsFrozen())
15103
+// No delay if (control || command || IsFrozen())
1398115104 timeout = true;
13982
- else
15105
+// ?? May 2019 else
1398315106 // timer.setDelay((modifiers & 128) != 0?0:350);
1398415107 mouseDown = false;
1398515108 if (!control && !command) // june 2013
....@@ -14089,7 +15212,7 @@
1408915212 System.out.println("keyReleased: " + e);
1409015213 }
1409115214
14092
- void SetMouseMode(int modifiers)
15215
+ void SetMouseMode(int modifiers, int modifiersex)
1409315216 {
1409415217 //System.out.println("SetMouseMode = " + modifiers);
1409515218 //modifiers &= ~1024;
....@@ -14101,25 +15224,25 @@
1410115224 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1410215225 // return;
1410315226 //System.out.println("SetMode = " + modifiers);
14104
- if ((modifiers & WHEEL) == WHEEL)
15227
+ if ((modifiersex & WHEEL) == WHEEL)
1410515228 {
1410615229 mouseMode |= ZOOM;
1410715230 }
1410815231
1410915232 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14110
- if (capsLocked || (modifiers & META) == META)
15233
+ if (capsLocked) // || (modifiers & META) == META)
1411115234 {
1411215235 mouseMode |= VR; // BACKFORTH;
1411315236 }
14114
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
15237
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1411515238 {
1411615239 mouseMode |= SELECT;
1411715240 }
14118
- if ((modifiers & COMMAND) == COMMAND)
15241
+ if ((modifiersex & COMMAND) == COMMAND)
1411915242 {
1412015243 mouseMode |= SELECT;
1412115244 }
14122
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
15245
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1412315246 {
1412415247 mouseMode &= ~VR;
1412515248 mouseMode |= TRANSLATE;
....@@ -14148,7 +15271,7 @@
1414815271
1414915272 if (isRenderer) //
1415015273 {
14151
- SetMouseMode(modifiers);
15274
+ SetMouseMode(0, modifiers);
1415215275 }
1415315276
1415415277 Globals.theRenderer.keyPressed(key);
....@@ -14210,7 +15333,8 @@
1421015333 // break;
1421115334 case 'T':
1421215335 CACHETEXTURE ^= true;
14213
- textures.clear();
15336
+ texturepigment.clear();
15337
+ texturebump.clear();
1421415338 // repaint();
1421515339 break;
1421615340 case 'Y':
....@@ -14220,8 +15344,8 @@
1422015344 case 'K':
1422115345 KOMPACTTEXTURE ^= true;
1422215346 //textures.clear();
14223
- break;
14224
- case 'P': // Texture Projection macros
15347
+ // break;
15348
+ //case 'P': // Texture Projection macros
1422515349 // SAVETEXTURE ^= true;
1422615350 macromode = true;
1422715351 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -14295,7 +15419,9 @@
1429515419 case 'E' : COMPACT ^= true;
1429615420 repaint();
1429715421 break;
14298
- case 'W' : DEBUGHSB ^= true;
15422
+ case 'W' : // Wide Window (fullscreen)
15423
+ //DEBUGHSB ^= true;
15424
+ ObjEditor.theFrame.ToggleFullScreen();
1429915425 repaint();
1430015426 break;
1430115427 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14320,8 +15446,8 @@
1432015446 RevertCamera();
1432115447 repaint();
1432215448 break;
14323
- case 'L':
1432415449 case 'l':
15450
+ //case 'L':
1432515451 if (lightMode)
1432615452 {
1432715453 lightMode = false;
....@@ -14340,7 +15466,7 @@
1434015466 targetLookAt.set(manipCamera.lookAt);
1434115467 repaint();
1434215468 break;
14343
- case 'p':
15469
+ case 'P': // p':
1434415470 // c'est quoi ca au juste? spherical ^= true;
1434515471 Skinshader ^= true; programInitialized = false;
1434615472 repaint();
....@@ -14385,20 +15511,24 @@
1438515511 OCCLUSION_CULLING ^= true;
1438615512 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1438715513 break;
14388
- case '0': envyoff ^= true; repaint(); break;
15514
+ //case '0': envyoff ^= true; repaint(); break;
1438915515 case '1':
1439015516 case '2':
1439115517 case '3':
1439215518 case '4':
1439315519 case '5':
14394
- newenvy = Character.getNumericValue(key);
14395
- repaint();
14396
- break;
1439715520 case '6':
1439815521 case '7':
1439915522 case '8':
1440015523 case '9':
14401
- BGcolor = (key - '6')/3.f;
15524
+ if (true) // envyoff)
15525
+ {
15526
+ BGcolor = (key - '1')/8.f;
15527
+ }
15528
+ else
15529
+ {
15530
+ //newenvy = Character.getNumericValue(key);
15531
+ }
1440215532 repaint();
1440315533 break;
1440415534 case '!':
....@@ -14464,9 +15594,9 @@
1446415594 case '_':
1446515595 kompactbit = 5;
1446615596 break;
14467
- case '+':
14468
- kompactbit = 6;
14469
- break;
15597
+// case '+':
15598
+// kompactbit = 6;
15599
+// break;
1447015600 case ' ':
1447115601 lightMode ^= true;
1447215602 Globals.lighttouched = true;
....@@ -14478,13 +15608,14 @@
1447815608 case ESC:
1447915609 RENDERPROGRAM += 1;
1448015610 RENDERPROGRAM %= 3;
15611
+
1448115612 repaint();
1448215613 break;
1448315614 case 'Z':
1448415615 //RESIZETEXTURE ^= true;
1448515616 //break;
1448615617 case 'z':
14487
- RENDERSHADOW ^= true;
15618
+ Globals.RENDERSHADOW ^= true;
1448815619 Globals.lighttouched = true;
1448915620 repaint();
1449015621 break;
....@@ -14517,8 +15648,9 @@
1451715648 case DELETE:
1451815649 ClearSelection();
1451915650 break;
14520
- /*
1452115651 case '+':
15652
+
15653
+ /*
1452215654 //fontsize += 1;
1452315655 bbzoom *= 2;
1452415656 repaint();
....@@ -14535,17 +15667,17 @@
1453515667 case '=':
1453615668 IncDepth();
1453715669 //fontsize += 1;
14538
- object.editWindow.refreshContents(true);
15670
+ object.GetWindow().refreshContents(true);
1453915671 maskbit = 6;
1454015672 break;
1454115673 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1454215674 DecDepth();
1454315675 maskbit = 5;
1454415676 //if(fontsize > 1) fontsize -= 1;
14545
- if (object.editWindow == null)
14546
- new Exception().printStackTrace();
14547
- else
14548
- object.editWindow.refreshContents(true);
15677
+// if (object.editWindow == null)
15678
+// new Exception().printStackTrace();
15679
+// else
15680
+ object.GetWindow().refreshContents(true);
1454915681 break;
1455015682 case '{':
1455115683 manipCamera.shaper_fovy /= 1.1;
....@@ -14608,7 +15740,7 @@
1460815740 //mode = ROTATE;
1460915741 if ((MODIFIERS & COMMAND) == 0) // VR??
1461015742 {
14611
- SetMouseMode(modifiers);
15743
+ SetMouseMode(0, modifiers);
1461215744 }
1461315745 }
1461415746
....@@ -14742,8 +15874,9 @@
1474215874
1474315875 protected void processMouseMotionEvent(MouseEvent e)
1474415876 {
14745
- //System.out.println("processMouseMotionEvent: " + mouseMode);
14746
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15877
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15878
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15879
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1474715880 {
1474815881 mouseMoved(e);
1474915882 } else
....@@ -14768,11 +15901,12 @@
1476815901 }
1476915902 */
1477015903
14771
- object.editWindow.EditSelection();
15904
+ object.GetWindow().EditSelection(false);
1477215905 }
1477315906
1477415907 void SelectParent()
1477515908 {
15909
+ new Exception().printStackTrace();
1477615910 System.exit(0);
1477715911 Composite group = (Composite) object;
1477815912 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -14784,10 +15918,10 @@
1478415918 {
1478515919 //selectees.remove(i);
1478615920 System.out.println("select parent of " + elem);
14787
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15921
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1478815922 } else
1478915923 {
14790
- group.editWindow.Select(elem.GetTreePath(), first, true);
15924
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1479115925 }
1479215926
1479315927 first = false;
....@@ -14796,6 +15930,7 @@
1479615930
1479715931 void SelectChildren()
1479815932 {
15933
+ new Exception().printStackTrace();
1479915934 System.exit(0);
1480015935 /*
1480115936 Composite group = (Composite) object;
....@@ -14828,12 +15963,12 @@
1482815963 for (int j = 0; j < group.children.size(); j++)
1482915964 {
1483015965 elem = (Object3D) group.children.elementAt(j);
14831
- object.editWindow.Select(elem.GetTreePath(), first, true);
15966
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1483215967 first = false;
1483315968 }
1483415969 } else
1483515970 {
14836
- object.editWindow.Select(elem.GetTreePath(), first, true);
15971
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1483715972 }
1483815973
1483915974 first = false;
....@@ -14844,21 +15979,21 @@
1484415979 {
1484515980 //Composite group = (Composite) object;
1484615981 Object3D group = object;
14847
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15982
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1484815983 }
1484915984
1485015985 void ResetTransform(int mask)
1485115986 {
1485215987 //Composite group = (Composite) object;
1485315988 Object3D group = object;
14854
- group.editWindow.ResetTransform(mask);
15989
+ group.GetWindow().ResetTransform(mask);
1485515990 }
1485615991
1485715992 void FlipTransform()
1485815993 {
1485915994 //Composite group = (Composite) object;
1486015995 Object3D group = object;
14861
- group.editWindow.FlipTransform();
15996
+ group.GetWindow().FlipTransform();
1486215997 // group.editWindow.ReduceMesh(true);
1486315998 }
1486415999
....@@ -14866,7 +16001,7 @@
1486616001 {
1486716002 //Composite group = (Composite) object;
1486816003 Object3D group = object;
14869
- group.editWindow.PrintMemory();
16004
+ group.GetWindow().PrintMemory();
1487016005 // group.editWindow.ReduceMesh(true);
1487116006 }
1487216007
....@@ -14874,7 +16009,7 @@
1487416009 {
1487516010 //Composite group = (Composite) object;
1487616011 Object3D group = object;
14877
- group.editWindow.ResetCentroid();
16012
+ group.GetWindow().ResetCentroid();
1487816013 }
1487916014
1488016015 void IncDepth()
....@@ -14956,11 +16091,11 @@
1495616091
1495716092 int width = getBounds().width;
1495816093 int height = getBounds().height;
14959
- ClickInfo info = new ClickInfo();
14960
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1496116094 //Image img = CreateImage(width, height);
1496216095 //System.out.println("width = " + width + "; height = " + height + "\n");
16096
+
1496316097 Graphics gr = g; // img.getGraphics();
16098
+
1496416099 if (!hasMarquee)
1496516100 {
1496616101 if (Xmin < Xmax) // !locked)
....@@ -15032,44 +16167,92 @@
1503216167 }
1503316168 if (object != null && !hasMarquee)
1503416169 {
16170
+ if (object.clickInfo == null)
16171
+ object.clickInfo = new ClickInfo();
16172
+ ClickInfo info = object.clickInfo;
16173
+ //ClickInfo info = new ClickInfo();
16174
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
16175
+
1503516176 if (isRenderer)
1503616177 {
15037
- info.flags++;
16178
+ object.clickInfo.flags++;
1503816179 double frameAspect = (double) width / (double) height;
1503916180 if (frameAspect > renderCamera.aspect)
1504016181 {
1504116182 int desired = (int) ((double) height * renderCamera.aspect);
15042
- info.bounds.width -= width - desired;
15043
- info.bounds.x += (width - desired) / 2;
16183
+ object.clickInfo.bounds.width -= width - desired;
16184
+ object.clickInfo.bounds.x += (width - desired) / 2;
1504416185 } else
1504516186 {
1504616187 int desired = (int) ((double) width / renderCamera.aspect);
15047
- info.bounds.height -= height - desired;
15048
- info.bounds.y += (height - desired) / 2;
16188
+ object.clickInfo.bounds.height -= height - desired;
16189
+ object.clickInfo.bounds.y += (height - desired) / 2;
1504916190 }
1505016191 }
15051
- info.g = gr;
15052
- info.camera = renderCamera;
16192
+
16193
+ object.clickInfo.g = gr;
16194
+ object.clickInfo.camera = renderCamera;
1505316195 /*
1505416196 // Memory intensive (brep.verticescopy)
1505516197 if (!(object instanceof Composite))
1505616198 object.draw(info, 0, false); // SLOW :
1505716199 */
15058
- if (!isRenderer)
16200
+ if (!isRenderer) // && drag)
1505916201 {
15060
- object.drawEditHandles(info, 0);
16202
+ Grafreed.Assert(object != null);
16203
+ Grafreed.Assert(object.selection != null);
16204
+ if (object.selection.Size() > 0)
16205
+ {
16206
+ int hitSomething = object.selection.get(0).hitSomething;
16207
+
16208
+ object.clickInfo.DX = 0;
16209
+ object.clickInfo.DY = 0;
16210
+ object.clickInfo.W = 1;
16211
+ if (hitSomething == Object3D.hitCenter)
16212
+ {
16213
+ info.DX = X;
16214
+ if (X != 0)
16215
+ info.DX -= info.bounds.width/2;
16216
+
16217
+ info.DY = Y;
16218
+ if (Y != 0)
16219
+ info.DY -= info.bounds.height/2;
16220
+ }
16221
+
16222
+ object.drawEditHandles(//info,
16223
+ 0);
16224
+
16225
+ if (drag && (X != 0 || Y != 0))
16226
+ {
16227
+ switch (hitSomething)
16228
+ {
16229
+ case Object3D.hitCenter: gr.setColor(Color.white);
16230
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16231
+ break;
16232
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
16233
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16234
+ break;
16235
+ case Object3D.hitScale: gr.setColor(Color.cyan);
16236
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16237
+ break;
16238
+ }
16239
+
16240
+ }
16241
+ }
1506116242 }
1506216243 }
16244
+
1506316245 if (isRenderer)
1506416246 {
1506516247 //gr.setColor(Color.black);
1506616248 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1506716249 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1506816250 }
16251
+
1506916252 if (hasMarquee)
1507016253 {
1507116254 gr.setXORMode(Color.white);
15072
- gr.setColor(Color.red);
16255
+ gr.setColor(Color.white);
1507316256 if (!firstime)
1507416257 {
1507516258 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -15178,6 +16361,7 @@
1517816361 public boolean mouseDown(Event evt, int x, int y)
1517916362 {
1518016363 System.out.println("mouseDown: " + evt);
16364
+ System.exit(0);
1518116365 /*
1518216366 locked = true;
1518316367 drag = false;
....@@ -15221,7 +16405,7 @@
1522116405 {
1522216406 keyPressed(0, modifiers);
1522316407 }
15224
- clickStart(x, y, modifiers);
16408
+ // clickStart(x, y, modifiers);
1522516409 return true;
1522616410 }
1522716411
....@@ -15339,7 +16523,7 @@
1533916523 {
1534016524 keyReleased(0, 0);
1534116525 }
15342
- drag(x, y, modifiers);
16526
+ drag(x, y, 0, modifiers);
1534316527 return true;
1534416528 }
1534516529
....@@ -15471,7 +16655,7 @@
1547116655 Object3D object;
1547216656 static Object3D trackedobject;
1547316657 Camera renderCamera; // Light or Eye (or Occlusion)
15474
- /*static*/ Camera manipCamera; // Light or Eye
16658
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1547516659 /*static*/ Camera eyeCamera;
1547616660 /*static*/ Camera lightCamera;
1547716661 int cameracount;
....@@ -15535,6 +16719,8 @@
1553516719 private /*static*/ boolean firstime;
1553616720 private /*static*/ cVector newView = new cVector();
1553716721 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16722
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16723
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1553816724 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1553916725 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1554016726 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -15547,29 +16733,67 @@
1554716733 {
1554816734 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1554916735
16736
+ int usedsuf = 0;
16737
+
1555016738 for (int i = 0; i < suffixes.length; i++)
1555116739 {
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)
16740
+ String[] suffixe = suffixes;
16741
+ String[] fallback = suffixes2;
16742
+ String[] fallfallback = suffixes3;
16743
+
16744
+ for (int c=usedsuf; --c>=0;)
1555716745 {
15558
- throw new IOException("Unable to load texture " + resourceName);
16746
+// String[] temp = suffixe;
16747
+// suffixe = fallback;
16748
+// fallback = fallfallback;
16749
+// fallfallback = temp;
1555916750 }
16751
+
16752
+ String resourceName = basename + suffixe[i] + "." + suffix;
16753
+ TextureData data;
16754
+
16755
+ try
16756
+ {
16757
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16758
+ mipmapped,
16759
+ FileUtil.getFileSuffix(resourceName));
16760
+ }
16761
+ catch (Exception e)
16762
+ {
16763
+ try
16764
+ {
16765
+ resourceName = basename + fallback[i] + "." + suffix;
16766
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16767
+ mipmapped,
16768
+ FileUtil.getFileSuffix(resourceName));
16769
+ }
16770
+ catch (Exception e2)
16771
+ {
16772
+ resourceName = basename + fallfallback[i] + "." + suffix;
16773
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16774
+ mipmapped,
16775
+ FileUtil.getFileSuffix(resourceName));
16776
+ }
16777
+ }
16778
+
1556016779 //System.out.println("Target = " + targets[i]);
1556116780 cubemap.updateImage(data, targets[i]);
1556216781 }
1556316782
1556416783 return cubemap;
1556516784 }
16785
+
1556616786 int bigsphere = -1;
1556716787
1556816788 float BGcolor = 0.5f;
1556916789
15570
- private void DrawSkyBox(GL gl)
16790
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16791
+
16792
+ private void DrawSkyBox(GL gl, float ratio)
1557116793 {
15572
- if (envyoff || cubemap == null)
16794
+ if (//envyoff ||
16795
+ WIREFRAME ||
16796
+ cubemap == null)
1557316797 {
1557416798 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1557516799 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -15584,7 +16808,17 @@
1558416808 // Compensates for ExaminerViewer's modification of modelview matrix
1558516809 gl.glMatrixMode(GL.GL_MODELVIEW);
1558616810 gl.glLoadIdentity();
16811
+ gl.glScalef(1,ratio,1);
1558716812
16813
+// colorV[0] = 2;
16814
+// colorV[1] = 2;
16815
+// colorV[2] = 2;
16816
+// colorV[3] = 1;
16817
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16818
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16819
+//
16820
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16821
+
1558816822 //gl.glActiveTexture(GL.GL_TEXTURE1);
1558916823 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1559016824
....@@ -15616,6 +16850,7 @@
1561616850 {
1561716851 gl.glScalef(1.0f, -1.0f, 1.0f);
1561816852 }
16853
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1561916854 gl.glMultMatrixd(viewrot_1, 0);
1562016855 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1562116856 //viewer.updateInverseRotation(gl);
....@@ -15656,7 +16891,8 @@
1565616891 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1565716892
1565816893 cubemap.disable();
15659
- ////cubemap.unbind();
16894
+ //cubemap.dispose();
16895
+
1566016896 if (CULLFACE)
1566116897 {
1566216898 gl.glEnable(gl.GL_CULL_FACE);
....@@ -15712,7 +16948,7 @@
1571216948 gl.glScalef(1.0f, -1.0f, 1.0f);
1571316949 }
1571416950
15715
- gl.glNormal3f(0.0f, 0.0f, 1.0f);
16951
+ SetGLNormal(gl, 0.0f, 0.0f, 1.0f);
1571616952
1571716953 float step = 2; // 0.1666f; //0.25f;
1571816954 float stepv = 2; // step * 1652 / 998;
....@@ -15756,16 +16992,16 @@
1575616992 cStatic.objectstack[materialdepth++] = checker;
1575716993 //System.out.println("material " + material);
1575816994 //Applet3D.tracein(this, selected);
15759
- vector2buffer = checker.projectedVertices;
16995
+ //vector2buffer = checker.projectedVertices;
1576016996
1576116997 //checker.GetMaterial().Draw(this, false); // true);
15762
- DrawMaterial(checker.GetMaterial(), false); // true);
16998
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1576316999
1576417000 materialdepth -= 1;
1576517001 if (materialdepth > 0)
1576617002 {
15767
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
15768
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
17003
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
17004
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1576917005 }
1577017006 //checker.GetMaterial().opacity = 1f;
1577117007 ////checker.GetMaterial().ambient = 1f;
....@@ -15851,6 +17087,14 @@
1585117087 }
1585217088 }
1585317089
17090
+ private Object3D GetFolder()
17091
+ {
17092
+ Object3D folder = object.GetWindow().copy;
17093
+ if (object.GetWindow().copy.selection.Size() > 0)
17094
+ folder = object.GetWindow().copy.selection.elementAt(0);
17095
+ return folder;
17096
+ }
17097
+
1585417098 class SelectBuffer implements GLEventListener
1585517099 {
1585617100
....@@ -15866,7 +17110,7 @@
1586617110 //new Exception().printStackTrace();
1586717111 System.out.println("select buffer init");
1586817112 // Use debug pipeline
15869
- drawable.setGL(new DebugGL(drawable.getGL()));
17113
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1587017114
1587117115 GL gl = drawable.getGL();
1587217116
....@@ -15909,6 +17153,7 @@
1590917153 {
1591017154 if (!selection)
1591117155 {
17156
+ new Exception().printStackTrace();
1591217157 System.exit(0);
1591317158 return;
1591417159 }
....@@ -15929,6 +17174,17 @@
1592917174
1593017175 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1593117176
17177
+ if (PAINTMODE)
17178
+ {
17179
+ if (object.GetWindow().copy.selection.Size() > 0)
17180
+ {
17181
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
17182
+
17183
+ // Make what you paint not selectable.
17184
+ paintobj.ResetSelectable();
17185
+ }
17186
+ }
17187
+
1593217188 //int tmp = selection_view;
1593317189 //selection_view = -1;
1593417190 int temp = DrawMode();
....@@ -15940,6 +17196,17 @@
1594017196 // temp = DEFAULT; // patch for selection debug
1594117197 Globals.drawMode = temp; // WARNING
1594217198
17199
+ if (PAINTMODE)
17200
+ {
17201
+ if (object.GetWindow().copy.selection.Size() > 0)
17202
+ {
17203
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
17204
+
17205
+ // Revert.
17206
+ paintobj.RestoreSelectable();
17207
+ }
17208
+ }
17209
+
1594317210 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1594417211
1594517212 // trying different ways of getting the depth info over
....@@ -15987,6 +17254,8 @@
1598717254 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1598817255 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1598917256 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
17257
+
17258
+ CreateSelectedPoint();
1599017259
1599117260 // Will fit the mesh !!!
1599217261 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16036,34 +17305,36 @@
1603617305 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]));
1603717306 }
1603817307
16039
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
17308
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1604017309 }
1604117310 }
1604217311
1604317312 if (!movingcamera && !PAINTMODE)
16044
- object.editWindow.ScreenFitPoint(); // fev 2014
17313
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1604517314
16046
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
17315
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1604717316 {
16048
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
17317
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1604917318
16050
- Object3D group = new Object3D("inst" + paintcount++);
17319
+ if (object.GetWindow().copy.selection.Size() > 0)
17320
+ {
17321
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1605117322
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();
17323
+ Object3D inst = new Object3D("inst" + paintcount++);
17324
+
17325
+ inst.CreateMaterial(); // use a void leaf to select instances
17326
+
17327
+ inst.add(paintobj); // link
17328
+
17329
+ object.GetWindow().SnapObject(inst);
17330
+
17331
+ Object3D folder = paintFolder; // GetFolder();
17332
+
17333
+ folder.add(inst);
17334
+
17335
+ object.GetWindow().ResetModel();
17336
+ object.GetWindow().refreshContents();
17337
+ }
1606717338 }
1606817339 else
1606917340 paintcount = 0;
....@@ -16102,6 +17373,11 @@
1610217373 //System.out.println("objects[color] = " + objects[color]);
1610317374 //objects[color].Select();
1610417375 indexcount = 0;
17376
+ ObjEditor window = object.GetWindow();
17377
+ if (window != null && deselect)
17378
+ {
17379
+ window.Select(null, deselect, true);
17380
+ }
1610517381 object.Select(color, deselect);
1610617382 }
1610717383
....@@ -16152,6 +17428,7 @@
1615217428
1615317429 public void init(GLAutoDrawable drawable)
1615417430 {
17431
+ if (Globals.DEBUG)
1615517432 System.out.println("shadow buffer init");
1615617433
1615717434 GL gl = drawable.getGL();
....@@ -16201,7 +17478,7 @@
1620117478 gl.glDisable(gl.GL_CULL_FACE);
1620217479 }
1620317480
16204
- if (!RENDERSHADOW)
17481
+ if (!Globals.RENDERSHADOW)
1620517482 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1620617483
1620717484 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16211,7 +17488,7 @@
1621117488 //gl.glColorMask(false, false, false, false);
1621217489
1621317490 //render_scene_from_light_view(gl, drawable, 0, 0);
16214
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17491
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1621517492 {
1621617493 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1621717494
....@@ -16380,10 +17657,14 @@
1638017657 gl.glFlush();
1638117658
1638217659 /**/
16383
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
17660
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer);
1638417661
16385
- float[] pixels = occlusionsizebuffer.array();
17662
+ float[] depths = occlusiondepthbuffer.array();
1638617663
17664
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
17665
+
17666
+ int[] pixels = selectsizebuffer.array();
17667
+
1638717668 double r = 0, g = 0, b = 0;
1638817669
1638917670 double count = 0;
....@@ -16394,7 +17675,7 @@
1639417675
1639517676 double FACTOR = 1;
1639617677
16397
- for (int i = 0; i < pixels.length; i++)
17678
+ for (int i = 0; i < depths.length; i++)
1639817679 {
1639917680 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1640017681 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -16477,7 +17758,7 @@
1647717758
1647817759 double scale = ray.z; // 1; // cos
1647917760
16480
- float depth = pixels[newindex];
17761
+ float depth = depths[newindex];
1648117762
1648217763 /*
1648317764 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -16627,23 +17908,15 @@
1662717908 int AAbuffersize = 0;
1662817909
1662917910 //double[] selectedpoint = new double[3];
16630
- static Superellipsoid selectedpoint = new Superellipsoid();
17911
+ static Superellipsoid selectedpoint;
1663117912 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();
17913
+ static Sphere debugpointG;
17914
+ static Sphere debugpointP;
17915
+ static Sphere debugpointC;
17916
+ static Sphere debugpointR;
1663617917
1663717918 static Sphere debugpoints[] = new Sphere[8];
1663817919
16639
- static
16640
- {
16641
- for (int i=0; i<8; i++)
16642
- {
16643
- debugpoints[i] = new Sphere();
16644
- }
16645
- }
16646
-
1664717920 static void InitPoints(float radius)
1664817921 {
1664917922 for (int i=0; i<8; i++)
....@@ -16682,11 +17955,14 @@
1668217955 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1668317956 static IntBuffer bigAAbuffer;
1668417957 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
16685
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17958
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1668617959 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1668717960 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1668817961 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
16689
- static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17962
+ static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17963
+
17964
+ static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17965
+
1669017966 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1669117967 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1669217968 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();
....@@ -16695,10 +17971,11 @@
1669517971 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1669617972 // Depth buffer format
1669717973 //private int depth_format;
16698
- static public void NextIndex(Object3D o, GL gl)
17974
+
17975
+ public void NextIndex()
1669917976 {
1670017977 indexcount+=16;
16701
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17978
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1670217979 //objects[indexcount] = o;
1670317980 //System.out.println("indexcount = " + indexcount);
1670417981 }