Normand Briere
2019-07-21 40f408aaee14abd85d391008b4d22977dc586b50
CameraPane.java
....@@ -37,7 +37,6 @@
3737 static boolean[] selectedstack = new boolean[65536];
3838 static int materialdepth = 0;
3939
40
- static boolean DEBUG = false;
4140 static boolean FRUSTUM = false; // still bogus true; // frustum culling
4241
4342 // camera change fix
....@@ -56,14 +55,12 @@
5655 static int CURRENTANTIALIAS = 0; // 1;
5756 /*static*/ boolean RENDERSHADOW = true;
5857 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
59
- static boolean ANIMATION = false;
60
- static String filename;
6158
6259 boolean DISPLAYTEXT = false;
6360 //boolean REDUCETEXTURE = true;
6461 boolean CACHETEXTURE = true;
6562 boolean CLEANCACHE = false; // true;
66
- boolean MIPMAP = false; // true;
63
+ boolean MIPMAP = true; // false; // true;
6764 boolean COMPRESSTEXTURE = false;
6865 boolean KOMPACTTEXTURE = false; // true;
6966 boolean RESIZETEXTURE = false;
....@@ -92,6 +89,8 @@
9289
9390 static int tickcount = 0; // slow pose issue
9491
92
+static boolean BUTTONLESSWHEEL = false;
93
+static boolean ZOOMBOXMODE = false;
9594 static boolean BOXMODE = false;
9695 static boolean IMAGEFLIP = false;
9796 static boolean SMOOTHFOCUS = false;
....@@ -106,7 +105,7 @@
106105 static boolean OEIL = true;
107106 static boolean OEILONCE = false; // do oeilon then oeiloff
108107 static boolean LOOKAT = true;
109
-static boolean RANDOM = true; // false;
108
+static boolean SWITCH = true; // false;
110109 static boolean HANDLES = false; // selection doesn't work!!
111110 static boolean PAINTMODE = false;
112111
....@@ -149,6 +148,8 @@
149148 defaultcaps.setAccumBlueBits(16);
150149 defaultcaps.setAccumAlphaBits(16);
151150 }
151
+
152
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
152153
153154 void SetAsGLRenderer(boolean b)
154155 {
....@@ -223,6 +224,11 @@
223224 public boolean IsBoxMode()
224225 {
225226 return BOXMODE;
227
+ }
228
+
229
+ public boolean IsZoomBoxMode()
230
+ {
231
+ return ZOOMBOXMODE;
226232 }
227233
228234 public void ClearDepth()
....@@ -320,7 +326,7 @@
320326 cStatic.objectstack[materialdepth++] = obj;
321327 //System.out.println("material " + material);
322328 //Applet3D.tracein(this, selected);
323
- display.vector2buffer = obj.projectedVertices;
329
+ //display.vector2buffer = obj.projectedVertices;
324330 if (obj instanceof Camera)
325331 {
326332 display.options1[0] = material.shift;
....@@ -329,14 +335,28 @@
329335 display.options1[2] = material.shadowbias;
330336 display.options1[3] = material.aniso;
331337 display.options1[4] = material.anisoV;
338
+// System.out.println("display.options1[0] " + display.options1[0]);
339
+// System.out.println("display.options1[1] " + display.options1[1]);
340
+// System.out.println("display.options1[2] " + display.options1[2]);
341
+// System.out.println("display.options1[3] " + display.options1[3]);
342
+// System.out.println("display.options1[4] " + display.options1[4]);
332343 display.options2[0] = material.opacity;
333344 display.options2[1] = material.diffuse;
334345 display.options2[2] = material.factor;
346
+// System.out.println("display.options2[0] " + display.options2[0]);
347
+// System.out.println("display.options2[1] " + display.options2[1]);
348
+// System.out.println("display.options2[2] " + display.options2[2]);
335349
336350 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
351
+// System.out.println("display.options3[0] " + display.options3[0]);
352
+// System.out.println("display.options3[1] " + display.options3[1]);
353
+// System.out.println("display.options3[2] " + display.options3[2]);
337354 display.options4[0] = material.cameralight/0.2f;
338355 display.options4[1] = material.subsurface;
339356 display.options4[2] = material.sheen;
357
+// System.out.println("display.options4[0] " + display.options4[0]);
358
+// System.out.println("display.options4[1] " + display.options4[1]);
359
+// System.out.println("display.options4[2] " + display.options4[2]);
340360
341361 // if (display.CURRENTANTIALIAS > 0)
342362 // display.options3[3] /= 4;
....@@ -352,7 +372,7 @@
352372 /**/
353373 } else
354374 {
355
- DrawMaterial(material, selected);
375
+ DrawMaterial(material, selected, obj.projectedVertices);
356376 }
357377 } else
358378 {
....@@ -376,8 +396,8 @@
376396 cStatic.objectstack[materialdepth++] = obj;
377397 //System.out.println("material " + material);
378398 //Applet3D.tracein("selected ", selected);
379
- display.vector2buffer = obj.projectedVertices;
380
- display.DrawMaterial(material, selected);
399
+ //display.vector2buffer = obj.projectedVertices;
400
+ display.DrawMaterial(material, selected, obj.projectedVertices);
381401 }
382402 }
383403
....@@ -394,8 +414,8 @@
394414 materialdepth -= 1;
395415 if (materialdepth > 0)
396416 {
397
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
398
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
417
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
418
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
399419 }
400420 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
401421 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -415,8 +435,8 @@
415435 materialdepth -= 1;
416436 if (materialdepth > 0)
417437 {
418
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
419
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
438
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
439
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
420440 }
421441 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
422442 //else
....@@ -457,10 +477,12 @@
457477 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
458478 {
459479 //gl.glBegin(gl.GL_TRIANGLES);
460
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
480
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
481
+ // TEST LIVE NORMALS && !obj.dontselect
482
+ ;
461483 if (!hasnorm)
462484 {
463
- // System.out.println("FUCK!!");
485
+ // System.out.println("Mesh normal");
464486 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
465487 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
466488 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1185,10 +1207,12 @@
11851207 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11861208 }
11871209 }
1210
+
11881211 if (flipV)
11891212 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11901213 else
11911214 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1215
+
11921216 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
11931217 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
11941218
....@@ -1208,10 +1232,12 @@
12081232 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12091233 }
12101234 }
1235
+
12111236 if (flipV)
12121237 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12131238 else
12141239 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1240
+
12151241 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12161242 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12171243
....@@ -1239,8 +1265,10 @@
12391265 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12401266 else
12411267 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1268
+
12421269 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12431270 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1271
+
12441272 count2 += 2;
12451273 count3 += 3;
12461274 }
....@@ -1596,7 +1624,7 @@
15961624 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
15971625 }
15981626
1599
- void DrawMaterial(cMaterial material, boolean selected)
1627
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16001628 {
16011629 CameraPane display = this;
16021630 //new Exception().printStackTrace();
....@@ -1612,18 +1640,18 @@
16121640 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
16131641 if (!material.multiply)
16141642 {
1615
- display.color = color;
1643
+ display.color = material.color;
16161644 display.saturation = material.modulation;
16171645 }
16181646 else
16191647 {
1620
- display.color *= color*2;
1648
+ display.color *= material.color*2;
16211649 display.saturation *= material.modulation*2;
16221650 }
16231651
16241652 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16251653
1626
- float[] colorV = GrafreeD.colorV;
1654
+ float[] colorV = Grafreed.colorV;
16271655
16281656 /**/
16291657 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1631,7 +1659,7 @@
16311659 colorV[0] = display.modelParams0[0] * material.diffuse;
16321660 colorV[1] = display.modelParams0[1] * material.diffuse;
16331661 colorV[2] = display.modelParams0[2] * material.diffuse;
1634
- colorV[3] = material.opacity;
1662
+ colorV[3] = 1; // material.opacity;
16351663
16361664 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16371665 //System.out.println("Opacity = " + opacity);
....@@ -1739,9 +1767,9 @@
17391767 display.modelParams7[2] = 0;
17401768 display.modelParams7[3] = 0;
17411769
1742
- display.modelParams6[0] = 100; // criss de bug de bump
1770
+ //display.modelParams6[0] = 100; // criss de bug de bump
17431771
1744
- Object3D.cVector2[] extparams = display.vector2buffer;
1772
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17451773 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17461774 {
17471775 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1883,7 +1911,7 @@
18831911 void PushMatrix(double[][] matrix)
18841912 {
18851913 // GrafreeD.tracein(matrix);
1886
- PushMatrix(matrix,1);
1914
+ PushMatrix(matrix, 1);
18871915 }
18881916
18891917 void PushMatrix()
....@@ -2037,7 +2065,7 @@
20372065 //System.err.println("Oeil on");
20382066 OEIL = true;
20392067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2040
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20412069 //pingthread.StepToTarget(true);
20422070 }
20432071
....@@ -2135,7 +2163,7 @@
21352163 System.err.println("LIVE = " + Globals.isLIVE());
21362164
21372165 if (!Globals.isLIVE()) // save sound
2138
- GrafreeD.savesound = true; // wav.save();
2166
+ Grafreed.savesound = true; // wav.save();
21392167 // else
21402168 repaint(); // start loop // may 2013
21412169 }
....@@ -2168,6 +2196,11 @@
21682196 public void ToggleBoxMode()
21692197 {
21702198 BOXMODE ^= true;
2199
+ }
2200
+
2201
+ public void ToggleZoomBoxMode()
2202
+ {
2203
+ ZOOMBOXMODE ^= true;
21712204 }
21722205
21732206 public void ToggleSmoothFocus()
....@@ -2247,7 +2280,7 @@
22472280
22482281 void ToggleDebug()
22492282 {
2250
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22512284 }
22522285
22532286 void ToggleLookAt()
....@@ -2255,9 +2288,9 @@
22552288 LOOKAT ^= true;
22562289 }
22572290
2258
- void ToggleRandom()
2291
+ void ToggleSwitch()
22592292 {
2260
- RANDOM ^= true;
2293
+ SWITCH ^= true;
22612294 }
22622295
22632296 void ToggleHandles()
....@@ -2265,10 +2298,17 @@
22652298 HANDLES ^= true;
22662299 }
22672300
2301
+ Object3D paintFolder;
2302
+
22682303 void TogglePaint()
22692304 {
22702305 PAINTMODE ^= true;
22712306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
22722312 }
22732313
22742314 void SwapCamera(int a, int b)
....@@ -2364,7 +2404,7 @@
23642404 {
23652405 return currentGL;
23662406 }
2367
-
2407
+
23682408 /**/
23692409 class CacheTexture
23702410 {
....@@ -2382,9 +2422,10 @@
23822422 /**/
23832423
23842424 // TEXTURE static Texture texture;
2385
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2386
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2387
- static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>();
2425
+ static public java.util.Hashtable<String, CacheTexture> textures = new java.util.Hashtable<String, CacheTexture>();
2426
+ static public java.util.Hashtable<BufferedImage, CacheTexture> bimtextures = new java.util.Hashtable<BufferedImage, CacheTexture>();
2427
+ static public java.util.HashSet<String> usedtextures = new java.util.HashSet<String>();
2428
+
23882429 int pigmentdepth = 0;
23892430 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
23902431 int bumpdepth = 0;
....@@ -2406,6 +2447,33 @@
24062447 true,
24072448 com.sun.opengl.util.texture.TextureIO.PNG);
24082449 } catch (java.io.IOException e)
2450
+ {
2451
+ throw new javax.media.opengl.GLException(e);
2452
+ }
2453
+
2454
+ if (bump)
2455
+ texturedata = ConvertBump(texturedata, false);
2456
+
2457
+ com.sun.opengl.util.texture.Texture texture =
2458
+ com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2459
+
2460
+ texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2461
+ texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2462
+
2463
+ return texture;
2464
+ }
2465
+
2466
+ com.sun.opengl.util.texture.Texture GetBimTexture(BufferedImage name, boolean bump)
2467
+ {
2468
+ TextureData texturedata = null;
2469
+
2470
+ try
2471
+ {
2472
+ texturedata =
2473
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2474
+ name,
2475
+ true);
2476
+ } catch (Exception e)
24092477 {
24102478 throw new javax.media.opengl.GLException(e);
24112479 }
....@@ -3492,6 +3560,8 @@
34923560
34933561 System.out.println("LOADING TEXTURE : " + name);
34943562
3563
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3564
+
34953565 //
34963566 if (false) // compressbit > 0)
34973567 {
....@@ -4196,6 +4266,7 @@
41964266
41974267 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
41984268 {
4269
+ new Exception().printStackTrace();
41994270 System.exit(0);
42004271 com.sun.opengl.util.texture.Texture texture = null;
42014272
....@@ -7889,7 +7960,7 @@
78897960 String pigment = Object3D.GetPigment(tex);
78907961 String bump = Object3D.GetBump(tex);
78917962
7892
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7963
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
78937964 {
78947965 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
78957966 // System.out.println("; bump = " + bump);
....@@ -7906,6 +7977,64 @@
79067977
79077978 ReleaseTexture(bump, true);
79087979 ReleaseTexture(pigment, false);
7980
+ }
7981
+
7982
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7983
+ {
7984
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7985
+ {
7986
+ return;
7987
+ }
7988
+
7989
+ if (tex == null)
7990
+ {
7991
+ ReleaseTexture(null, false);
7992
+ return;
7993
+ }
7994
+
7995
+ String pigment = Object3D.GetPigment(tex);
7996
+
7997
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7998
+ {
7999
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8000
+ // System.out.println("; bump = " + bump);
8001
+ }
8002
+
8003
+ if (pigment.equals(""))
8004
+ {
8005
+ pigment = null;
8006
+ }
8007
+
8008
+ ReleaseTexture(pigment, false);
8009
+ }
8010
+
8011
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8012
+ {
8013
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8014
+ {
8015
+ return;
8016
+ }
8017
+
8018
+ if (tex == null)
8019
+ {
8020
+ ReleaseTexture(null, true);
8021
+ return;
8022
+ }
8023
+
8024
+ String bump = Object3D.GetBump(tex);
8025
+
8026
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8027
+ {
8028
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8029
+ // System.out.println("; bump = " + bump);
8030
+ }
8031
+
8032
+ if (bump.equals(""))
8033
+ {
8034
+ bump = null;
8035
+ }
8036
+
8037
+ ReleaseTexture(bump, true);
79098038 }
79108039
79118040 void ReleaseTexture(String tex, boolean bump)
....@@ -8011,7 +8140,55 @@
80118140 }
80128141 }
80138142
8014
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8143
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
8144
+ {
8145
+// if (// DrawMode() != 0 || /*tex == null ||*/
8146
+// ambientOcclusion ) // || !textureon)
8147
+// {
8148
+// return; // false;
8149
+// }
8150
+//
8151
+// if (tex == null)
8152
+// {
8153
+// BindTexture(null,false,resolution);
8154
+// BindTexture(null,true,resolution);
8155
+// return;
8156
+// }
8157
+//
8158
+// String pigment = Object3D.GetPigment(tex);
8159
+// String bump = Object3D.GetBump(tex);
8160
+//
8161
+// usedtextures.add(pigment);
8162
+// usedtextures.add(bump);
8163
+//
8164
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8165
+// {
8166
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8167
+// // System.out.println("; bump = " + bump);
8168
+// }
8169
+//
8170
+// if (bump.equals(""))
8171
+// {
8172
+// bump = null;
8173
+// }
8174
+// if (pigment.equals(""))
8175
+// {
8176
+// pigment = null;
8177
+// }
8178
+//
8179
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8180
+// BindTexture(pigment, false, resolution);
8181
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8182
+// BindTexture(bump, true, resolution);
8183
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8184
+//
8185
+// return; // true;
8186
+
8187
+ BindPigmentTexture(tex, resolution);
8188
+ BindBumpTexture(tex, resolution);
8189
+ }
8190
+
8191
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
80158192 {
80168193 if (// DrawMode() != 0 || /*tex == null ||*/
80178194 ambientOcclusion ) // || !textureon)
....@@ -8021,18 +8198,48 @@
80218198
80228199 if (tex == null)
80238200 {
8024
- BindTexture(null,false,resolution);
8025
- BindTexture(null,true,resolution);
8201
+ BindTexture(null, null,false,resolution);
80268202 return;
80278203 }
80288204
80298205 String pigment = Object3D.GetPigment(tex);
8206
+
8207
+ usedtextures.add(pigment);
8208
+
8209
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8210
+ {
8211
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8212
+ // System.out.println("; bump = " + bump);
8213
+ }
8214
+
8215
+ if (pigment.equals(""))
8216
+ {
8217
+ pigment = null;
8218
+ }
8219
+
8220
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8221
+ BindTexture(tex.pigmenttexture, pigment, false, resolution);
8222
+ }
8223
+
8224
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8225
+ {
8226
+ if (// DrawMode() != 0 || /*tex == null ||*/
8227
+ ambientOcclusion ) // || !textureon)
8228
+ {
8229
+ return; // false;
8230
+ }
8231
+
8232
+ if (tex == null)
8233
+ {
8234
+ BindTexture(null, null,true,resolution);
8235
+ return;
8236
+ }
8237
+
80308238 String bump = Object3D.GetBump(tex);
80318239
8032
- usedtextures.put(pigment, pigment);
8033
- usedtextures.put(bump, bump);
8240
+ usedtextures.add(bump);
80348241
8035
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8242
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80368243 {
80378244 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80388245 // System.out.println("; bump = " + bump);
....@@ -8042,42 +8249,70 @@
80428249 {
80438250 bump = null;
80448251 }
8045
- if (pigment.equals(""))
8046
- {
8047
- pigment = null;
8048
- }
80498252
8050
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8051
- BindTexture(pigment, false, resolution);
80528253 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8053
- BindTexture(bump, true, resolution);
8254
+ BindTexture(tex.bumptexture, bump, true, resolution);
80548255 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8055
-
8056
- return; // true;
80578256 }
80588257
8059
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8258
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8259
+
8260
+ private boolean FileExists(String tex)
80608261 {
8061
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8262
+ if (missingTextures.contains(tex))
8263
+ {
8264
+ return false;
8265
+ }
8266
+
8267
+ boolean fileExists = new File(tex).exists();
8268
+
8269
+ if (!fileExists)
8270
+ {
8271
+ // If file exists, the "new File()" is not executed sgain
8272
+ missingTextures.add(tex);
8273
+ }
8274
+
8275
+ return fileExists;
8276
+ }
8277
+
8278
+ CacheTexture GetCacheTexture(java.awt.image.BufferedImage bim, String tex, boolean bump, int resolution) throws Exception
8279
+ {
8280
+ CacheTexture texturecache = null;
80628281
80638282 if (tex != null)
80648283 {
80658284 String texname = tex;
80668285
8067
- String[] split = tex.split("Textures");
8068
- if (split.length > 1)
8069
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8070
- else
8071
- if (!texname.startsWith("/"))
8072
- texname = "/Users/nbriere/Textures/" + texname;
8286
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8287
+
8288
+// String[] split = tex.split("Textures");
8289
+// if (split.length > 1)
8290
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8291
+// else
8292
+// if (!texname.startsWith("/"))
8293
+// texname = "/Users/nbriere/Textures/" + texname;
8294
+ if (!FileExists(tex))
8295
+ {
8296
+ texname = fallbackTextureName;
8297
+ }
80738298
80748299 if (CACHETEXTURE)
8075
- texture = textures.get(texname); // TEXTURE CACHE
8076
-
8077
- TextureData texturedata = null;
8078
-
8079
- if (texture == null || texture.resolution < resolution)
80808300 {
8301
+ if (bim == null)
8302
+ texturecache = textures.get(texname); // TEXTURE CACHE
8303
+ else
8304
+ texturecache = bimtextures.get(bim); // TEXTURE CACHE
8305
+ }
8306
+
8307
+ if (texturecache == null || texturecache.resolution < resolution)
8308
+ {
8309
+ TextureData texturedata = null;
8310
+
8311
+ if (bim == null)
8312
+ {
8313
+
8314
+ }
8315
+ else
80818316 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
80828317 {
80838318 assert(!bump);
....@@ -8089,19 +8324,19 @@
80898324 // }
80908325 // else
80918326 // {
8092
- texture = textures.get(tex);
8093
- if (texture == null)
8327
+ texturecache = textures.get(tex);
8328
+ if (texturecache == null)
80948329 {
8095
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8330
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
80968331 }
80978332 // }
80988333 } else
80998334 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81008335 {
81018336 assert(bump);
8102
- texture = textures.get(tex);
8103
- if (texture == null)
8104
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8337
+ texturecache = textures.get(tex);
8338
+ if (texturecache == null)
8339
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81058340 } else
81068341 {
81078342 //if (tex.equals("IMMORTAL"))
....@@ -8111,9 +8346,9 @@
81118346 //{
81128347 if (tex.equals("WHITE_NOISE"))
81138348 {
8114
- texture = textures.get(tex);
8115
- if (texture == null)
8116
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8349
+ texturecache = textures.get(tex);
8350
+ if (texturecache == null)
8351
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
81178352 } else
81188353 {
81198354 if (textureon)
....@@ -8138,7 +8373,7 @@
81388373 }
81398374
81408375 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8141
- if (!new File(cachename).exists())
8376
+ if (!FileExists(cachename))
81428377 cachename = texname;
81438378 else
81448379 processbump = false; // don't process bump map again
....@@ -8160,7 +8395,7 @@
81608395 }
81618396
81628397 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8163
- if (!new File(cachename).exists())
8398
+ if (!FileExists(cachename))
81648399 cachename = texname;
81658400 else
81668401 processbump = false; // don't process bump map again
....@@ -8169,20 +8404,22 @@
81698404 texturedata = GetFileTexture(cachename, processbump, resolution);
81708405
81718406
8172
- if (texturedata != null)
8173
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8407
+ if (texturedata == null)
8408
+ throw new Exception();
8409
+
8410
+ texturecache = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81748411 //texture = GetTexture(tex, bump);
81758412 }
81768413 }
81778414 //}
81788415 }
81798416
8180
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8417
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
81818418 {
81828419 //return false;
81838420
81848421 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8185
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8422
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
81868423 {
81878424 // String ext = "_highres";
81888425 // if (REDUCETEXTURE)
....@@ -8271,8 +8508,8 @@
82718508 textures.remove(texname);
82728509 }
82738510
8274
- texture.texturedata = texturedata;
8275
- textures.put(texname, texture);
8511
+ //texture.texturedata = texturedata;
8512
+ textures.put(texname, texturecache);
82768513
82778514 // newtex = true;
82788515 }
....@@ -8288,12 +8525,12 @@
82888525 }
82898526 }
82908527
8291
- return texture;
8528
+ return texturecache;
82928529 }
82938530
8294
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8531
+ com.sun.opengl.util.texture.Texture GetTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
82958532 {
8296
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8533
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
82978534
82988535 if (bump)
82998536 {
....@@ -8309,23 +8546,23 @@
83098546 return texture!=null?texture.texture:null;
83108547 }
83118548
8312
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8549
+ public com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83138550 {
8314
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8551
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83158552
83168553 return texture!=null?texture.texturedata:null;
83178554 }
83188555
8319
- boolean BindTexture(String tex, boolean bump, int resolution)
8556
+ boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83208557 {
83218558 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83228559 {
83238560 return false;
83248561 }
83258562
8326
- boolean newtex = false;
8563
+ //boolean newtex = false;
83278564
8328
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8565
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
83298566
83308567 if (texture == null)
83318568 return false;
....@@ -8355,7 +8592,7 @@
83558592 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83568593 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83578594
8358
- return newtex;
8595
+ return true; // Warning: not used.
83598596 }
83608597
83618598 ShadowBuffer shadowPBuf;
....@@ -9193,11 +9430,35 @@
91939430 jy8[3] = 0.5f;
91949431 }
91959432
9196
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9433
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
91979434 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
91989435 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
91999436 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92009437
9438
+ void ResetOptions()
9439
+ {
9440
+ options1[0] = 100;
9441
+ options1[1] = 0.025f;
9442
+ options1[2] = 0.01f;
9443
+ options1[3] = 0;
9444
+ options1[4] = 0;
9445
+
9446
+ options2[0] = 0;
9447
+ options2[1] = 0.75f;
9448
+ options2[2] = 0;
9449
+ options2[3] = 0;
9450
+
9451
+ options3[0] = 1;
9452
+ options3[1] = 1;
9453
+ options3[2] = 1;
9454
+ options3[3] = 0;
9455
+
9456
+ options4[0] = 1;
9457
+ options4[1] = 0;
9458
+ options4[2] = 1;
9459
+ options4[3] = 0;
9460
+ }
9461
+
92019462 static int imagecount = 0; // movie generation
92029463
92039464 static int jitter = 0;
....@@ -9293,8 +9554,8 @@
92939554 assert (parentcam != renderCamera);
92949555
92959556 if (renderCamera != lightCamera)
9296
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9297
- LA.matConcat(matrix, parentcam.toParent, matrix);
9557
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9558
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
92989559
92999560 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93009561
....@@ -9309,8 +9570,8 @@
93099570 LA.matCopy(renderCamera.fromScreen, matrix);
93109571
93119572 if (renderCamera != lightCamera)
9312
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9313
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9573
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9574
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93149575
93159576 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93169577
....@@ -9382,7 +9643,7 @@
93829643 //gl.glFlush();
93839644 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93849645
9385
- if (ANIMATION && ABORTED)
9646
+ if (Globals.ANIMATION && ABORTED)
93869647 {
93879648 System.err.println(" ABORTED FRAME");
93889649 break;
....@@ -9412,7 +9673,7 @@
94129673 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94139674
94149675 // save image
9415
- if (ANIMATION && !ABORTED)
9676
+ if (Globals.ANIMATION && !ABORTED)
94169677 {
94179678 VPwidth = viewport[2];
94189679 VPheight = viewport[3];
....@@ -9523,11 +9784,11 @@
95239784
95249785 // imagecount++;
95259786
9526
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9787
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
95279788
95289789 if (!BOXMODE)
95299790 {
9530
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9791
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95319792 }
95329793
95339794 if (!BOXMODE)
....@@ -9565,7 +9826,7 @@
95659826 ABORTED = false;
95669827 }
95679828 else
9568
- GrafreeD.wav.cursor += 735 * ACSIZE;
9829
+ Grafreed.wav.cursor += 735 * ACSIZE;
95699830
95709831 if (false)
95719832 {
....@@ -10228,11 +10489,11 @@
1022810489
1022910490 public void display(GLAutoDrawable drawable)
1023010491 {
10231
- if (GrafreeD.savesound && GrafreeD.hassound)
10492
+ if (Grafreed.savesound && Grafreed.hassound)
1023210493 {
10233
- GrafreeD.wav.save();
10234
- GrafreeD.savesound = false;
10235
- GrafreeD.hassound = false;
10494
+ Grafreed.wav.save();
10495
+ Grafreed.savesound = false;
10496
+ Grafreed.hassound = false;
1023610497 }
1023710498 // if (DEBUG_SELECTION)
1023810499 // {
....@@ -10308,6 +10569,7 @@
1030810569 ANTIALIAS = 0;
1030910570 //System.out.println("RESTART");
1031010571 AAtimer.restart();
10572
+ Globals.TIMERRUNNING = true;
1031110573 }
1031210574 }
1031310575 }
....@@ -10362,7 +10624,7 @@
1036210624 Object3D theobject = object;
1036310625 Object3D theparent = object.parent;
1036410626 object.parent = null;
10365
- object = (Object3D)GrafreeD.clone(object);
10627
+ object = (Object3D)Grafreed.clone(object);
1036610628 object.Stripify();
1036710629 if (theobject.selection == null || theobject.selection.Size() == 0)
1036810630 theobject.PreprocessOcclusion(this);
....@@ -10375,13 +10637,14 @@
1037510637 ambientOcclusion = false;
1037610638 }
1037710639
10378
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10640
+ if (//Globals.lighttouched &&
10641
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1037910642 {
1038010643 //if (RENDERSHADOW) // ?
1038110644 if (!IsFrozen())
1038210645 {
1038310646 // dec 2012
10384
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10647
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1038510648 {
1038610649 Globals.framecount++;
1038710650 shadowbuffer.display();
....@@ -10508,8 +10771,8 @@
1050810771
1050910772 // if (parentcam != renderCamera) // not a light
1051010773 if (cam != lightCamera)
10511
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10512
- LA.matConcat(matrix, parentcam.toParent, matrix);
10774
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10775
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1051310776
1051410777 for (int j = 0; j < 4; j++)
1051510778 {
....@@ -10523,8 +10786,8 @@
1052310786
1052410787 // if (parentcam != renderCamera) // not a light
1052510788 if (cam != lightCamera)
10526
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10527
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10789
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10790
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1052810791
1052910792 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1053010793
....@@ -10783,7 +11046,16 @@
1078311046 // Bump noise
1078411047 gl.glActiveTexture(GL.GL_TEXTURE6);
1078511048 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10786
- BindTexture(NOISE_TEXTURE, false, 2);
11049
+
11050
+ try
11051
+ {
11052
+ BindTexture(null, NOISE_TEXTURE, false, 2);
11053
+ }
11054
+ catch (Exception e)
11055
+ {
11056
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11057
+ }
11058
+
1078711059
1078811060 gl.glActiveTexture(GL.GL_TEXTURE0);
1078911061 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10806,9 +11078,9 @@
1080611078
1080711079 gl.glMatrixMode(GL.GL_MODELVIEW);
1080811080
10809
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10810
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10811
-//gl.glEnable(gl.GL_MULTISAMPLE);
11081
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11082
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11083
+gl.glEnable(gl.GL_MULTISAMPLE);
1081211084 } else
1081311085 {
1081411086 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10819,7 +11091,7 @@
1081911091 //System.out.println("BLENDING ON");
1082011092 gl.glEnable(GL.GL_BLEND);
1082111093 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10822
-
11094
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1082311095 gl.glMatrixMode(gl.GL_PROJECTION);
1082411096 gl.glLoadIdentity();
1082511097
....@@ -10908,8 +11180,8 @@
1090811180 System.err.println("parentcam != renderCamera");
1090911181
1091011182 // if (cam != lightCamera)
10911
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10912
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11183
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11184
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1091311185 }
1091411186
1091511187 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10930,8 +11202,8 @@
1093011202 if (true) // TODO
1093111203 {
1093211204 if (cam != lightCamera)
10933
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10934
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11205
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11206
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1093511207 }
1093611208
1093711209 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11247,8 +11519,14 @@
1124711519 {
1124811520 renderpass++;
1124911521 // System.out.println("Draw object... ");
11522
+ STEP = 1;
1125011523 if (FAST) // in case there is no script
11251
- STEP = 16;
11524
+ STEP = 8;
11525
+
11526
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11527
+ {
11528
+ STEP *= 4;
11529
+ }
1125211530
1125311531 //object.FullInvariants();
1125411532
....@@ -11262,23 +11540,44 @@
1126211540 e.printStackTrace();
1126311541 }
1126411542
11265
- if (GrafreeD.RENDERME > 0)
11266
- GrafreeD.RENDERME--; // mechante magouille
11543
+ if (Grafreed.RENDERME > 0)
11544
+ Grafreed.RENDERME--; // mechante magouille
1126711545
1126811546 Globals.ONESTEP = false;
1126911547 }
1127011548
1127111549 static boolean zoomonce = false;
1127211550
11551
+ static void CreateSelectedPoint()
11552
+ {
11553
+ if (selectedpoint == null)
11554
+ {
11555
+ debugpointG = new Sphere();
11556
+ debugpointP = new Sphere();
11557
+ debugpointC = new Sphere();
11558
+ debugpointR = new Sphere();
11559
+
11560
+ selectedpoint = new Superellipsoid();
11561
+
11562
+ for (int i=0; i<8; i++)
11563
+ {
11564
+ debugpoints[i] = new Sphere();
11565
+ }
11566
+ }
11567
+ }
11568
+
1127311569 void DrawObject(GL gl, boolean draw)
1127411570 {
11571
+ // To clear camera values
11572
+ ResetOptions();
11573
+
1127511574 //System.out.println("DRAW OBJECT " + mouseDown);
1127611575 // DrawMode() = SELECTION;
1127711576 //GL gl = getGL();
1127811577 if ((TRACK || SHADOWTRACK) || zoomonce)
1127911578 {
1128011579 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11281
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11580
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1128211581 pingthread.StepToTarget(true); // true);
1128311582 // zoomonce = false;
1128411583 }
....@@ -11333,7 +11632,14 @@
1133311632
1133411633 usedtextures.clear();
1133511634
11336
- BindTextures(DEFAULT_TEXTURES, 2);
11635
+ try
11636
+ {
11637
+ BindTextures(DEFAULT_TEXTURES, 2);
11638
+ }
11639
+ catch (Exception e)
11640
+ {
11641
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11642
+ }
1133711643 }
1133811644 //System.out.println("--> " + stackdepth);
1133911645 // GrafreeD.traceon();
....@@ -11343,8 +11649,9 @@
1134311649
1134411650 if (DrawMode() == DEFAULT)
1134511651 {
11346
- if (DEBUG)
11652
+ if (Globals.DEBUG)
1134711653 {
11654
+ CreateSelectedPoint();
1134811655 float radius = 0.05f;
1134911656 if (selectedpoint.radius != radius)
1135011657 {
....@@ -11407,7 +11714,7 @@
1140711714 if (tex.equals("WHITE_NOISE"))
1140811715 continue;
1140911716
11410
- if (!usedtextures.containsKey(tex))
11717
+ if (!usedtextures.contains(tex))
1141111718 {
1141211719 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1141311720 textures.get(tex).texture.dispose();
....@@ -11424,7 +11731,14 @@
1142411731 if (checker != null && DrawMode() == DEFAULT)
1142511732 {
1142611733 //BindTexture(IMMORTAL_TEXTURE);
11427
- BindTextures(checker.GetTextures(), checker.texres);
11734
+ try
11735
+ {
11736
+ BindTextures(checker.GetTextures(), checker.texres);
11737
+ }
11738
+ catch (Exception e)
11739
+ {
11740
+ System.err.println("FAILED: " + checker.GetTextures());
11741
+ }
1142811742 // NEAREST
1142911743 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1143011744 DrawChecker(gl);
....@@ -11506,7 +11820,7 @@
1150611820 return;
1150711821 }
1150811822
11509
- String string = obj.GetToolTip();
11823
+ String string = obj.toString(); //.GetToolTip();
1151011824
1151111825 GL gl = GetGL();
1151211826
....@@ -11823,8 +12137,8 @@
1182312137 //obj.TransformToWorld(light, light);
1182412138 for (int i = tp.size(); --i >= 0;)
1182512139 {
11826
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11827
- LA.xformPos(light, tp.get(i).toParent, light);
12140
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12141
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1182812142 }
1182912143
1183012144
....@@ -11841,8 +12155,8 @@
1184112155 parentcam = cameras[0];
1184212156 }
1184312157
11844
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11845
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12158
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12159
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1184612160
1184712161 LA.xformPos(light, renderCamera.toScreen, light);
1184812162
....@@ -12456,8 +12770,8 @@
1245612770
1245712771 // display shadow only (bump == 0)
1245812772 "SUB temp.x, half.x, shadow.x;" +
12459
- "MOV temp.y, -params6.x;" +
12460
- "SLT temp.z, temp.y, zero.x;" +
12773
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12774
+ "SLT temp.z, temp.y, -one2048th.x;" +
1246112775 "SUB temp.y, one.x, temp.z;" +
1246212776 "MUL temp.x, temp.x, temp.y;" +
1246312777 "KIL temp.x;" +
....@@ -12586,8 +12900,10 @@
1258612900 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1258712901
1258812902 "SUB temp.x, one.x, ndotl.x;" +
12589
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12590
- "ADD temp.y, one.y, options2.y;" + // sursurface
12903
+ // Tuning for default skin
12904
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12905
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12906
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1259112907 "MUL temp.x, temp.x, temp.y;" +
1259212908
1259312909 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12786,7 +13102,7 @@
1278613102 //once = true;
1278713103 }
1278813104
12789
- System.out.print("Program #" + mode + "; length = " + program.length());
13105
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1279013106 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1279113107 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1279213108
....@@ -12919,12 +13235,16 @@
1291913235
1292013236 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1292113237 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13238
+
13239
+ // Compare fragment depth in light space with shadowmap.
1292213240 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1292313241 "SGE temp.y, temp.x, zero.x;" +
12924
- "SUB " + shadow + ".y, one.x, temp.y;" +
13242
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13243
+
13244
+ // Reverse comparison
1292513245 "SUB temp.x, one.x, temp.x;" +
1292613246 "MUL " + shadow + ".x, temp.x, temp.y;" +
12927
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13247
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1292813248 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1292913249
1293013250 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12938,6 +13258,10 @@
1293813258 // No shadow for backface
1293913259 "DP3 temp.x, normal, lightd;" +
1294013260 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13261
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13262
+
13263
+ // No shadow when out of frustrum
13264
+ "SGE temp.x, " + depth + ".z, one.z;" +
1294113265 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1294213266 "";
1294313267 }
....@@ -13084,7 +13408,8 @@
1308413408 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1308513409 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1308613410 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13087
- Object3D.cVector2[] vector2buffer;
13411
+
13412
+ //Object3D.cVector2[] vector2buffer;
1308813413
1308913414 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1309013415 // OUT : diff, spec
....@@ -13100,9 +13425,10 @@
1310013425 "DP3 " + dest + ".z," + "normals," + "eye;" +
1310113426 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1310213427 //"MOV " + dest + ".w," + "normal.z;" +
13103
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13104
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13105
- //"MOV " + dest + ".z," + "params2.w;" +
13428
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13429
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13430
+
13431
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1310613432 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1310713433 "RCP " + dest + ".w," + dest + ".w;" +
1310813434 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13496,7 +13822,7 @@
1349613822 public void mousePressed(MouseEvent e)
1349713823 {
1349813824 //System.out.println("mousePressed: " + e);
13499
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13825
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1350013826 }
1350113827
1350213828 static long prevtime = 0;
....@@ -13523,6 +13849,7 @@
1352313849
1352413850 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1352513851
13852
+ if (BUTTONLESSWHEEL)
1352613853 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1352713854 {
1352813855 return;
....@@ -13531,7 +13858,7 @@
1353113858 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1353213859
1353313860 // TIMER
13534
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
13861
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1353513862 {
1353613863 keepboxmode = BOXMODE;
1353713864 keepsupport = SUPPORT;
....@@ -13571,8 +13898,8 @@
1357113898 // mode |= META;
1357213899 //}
1357313900
13574
- SetMouseMode(WHEEL | e.getModifiersEx());
13575
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13901
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13902
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1357613903 anchorX = ax;
1357713904 anchorY = ay;
1357813905 prevX = px;
....@@ -13606,6 +13933,7 @@
1360613933 else
1360713934 if (evt.getSource() == AAtimer)
1360813935 {
13936
+ Globals.TIMERRUNNING = false;
1360913937 if (mouseDown)
1361013938 {
1361113939 //new Exception().printStackTrace();
....@@ -13631,6 +13959,10 @@
1363113959 // LIVE = waslive;
1363213960 // wasliveok = true;
1363313961 // waslive = false;
13962
+
13963
+ // May 2019 Forget it:
13964
+ if (true)
13965
+ return;
1363413966
1363513967 // source == timer
1363613968 if (mouseDown)
....@@ -13661,7 +13993,7 @@
1366113993
1366213994 // fev 2014???
1366313995 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13664
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13996
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1366513997 pingthread.StepToTarget(true); // true);
1366613998 }
1366713999 // if (!LIVE)
....@@ -13670,12 +14002,13 @@
1367014002
1367114003 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1367214004
13673
- void clickStart(int x, int y, int modifiers)
14005
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1367414006 {
1367514007 if (!wasliveok)
1367614008 return;
1367714009
1367814010 AAtimer.restart(); //
14011
+ Globals.TIMERRUNNING = true;
1367914012
1368014013 // waslive = LIVE;
1368114014 // LIVE = false;
....@@ -13687,7 +14020,7 @@
1368714020 // touched = true; // main DL
1368814021 if (isRenderer)
1368914022 {
13690
- SetMouseMode(modifiers);
14023
+ SetMouseMode(modifiers, modifiersex);
1369114024 }
1369214025
1369314026 selectX = anchorX = x;
....@@ -13700,7 +14033,7 @@
1370014033 clicked = true;
1370114034 hold = false;
1370214035
13703
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14036
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1370414037 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1370514038 {
1370614039 // System.out.println("RESTART II " + modifiers);
....@@ -13731,7 +14064,7 @@
1373114064 info.camera = renderCamera;
1373214065 info.x = x;
1373314066 info.y = y;
13734
- info.modifiers = modifiers;
14067
+ info.modifiers = modifiersex;
1373514068 editObj = object.doEditClick(info, 0);
1373614069 if (!editObj)
1373714070 {
....@@ -13748,11 +14081,14 @@
1374814081
1374914082 public void mouseDragged(MouseEvent e)
1375014083 {
14084
+ Globals.MOUSEDRAGGED = true;
14085
+
14086
+ //System.out.println("mouseDragged: " + e);
1375114087 if (isRenderer)
1375214088 movingcamera = true;
14089
+
1375314090 //if (drawing)
1375414091 //return;
13755
- //System.out.println("mouseDragged: " + e);
1375614092 if ((e.getModifiersEx() & CTRL) != 0
1375714093 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1375814094 {
....@@ -13760,7 +14096,7 @@
1376014096 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1376114097 }
1376214098 else
13763
- drag(e.getX(), e.getY(), e.getModifiersEx());
14099
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1376414100
1376514101 //try { Thread.sleep(1); } catch (Exception ex) {}
1376614102 }
....@@ -13933,6 +14269,7 @@
1393314269
1393414270 public void run()
1393514271 {
14272
+ new Exception().printStackTrace();
1393614273 System.exit(0);
1393714274 for (;;)
1393814275 {
....@@ -13996,7 +14333,7 @@
1399614333 {
1399714334 Globals.lighttouched = true;
1399814335 }
13999
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14336
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1400014337 }
1400114338 //else
1400214339 }
....@@ -14010,12 +14347,12 @@
1401014347 void GoDown(int mod)
1401114348 {
1401214349 MODIFIERS |= COMMAND;
14013
- /*
14350
+ /**/
1401414351 if((mod&SHIFT) == SHIFT)
1401514352 manipCamera.RotatePosition(0, -speed);
1401614353 else
14017
- manipCamera.BackForth(0, -speed*delta, getWidth());
14018
- */
14354
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14355
+ /**/
1401914356 if ((mod & SHIFT) == SHIFT)
1402014357 {
1402114358 mouseMode = mouseMode; // VR??
....@@ -14031,12 +14368,12 @@
1403114368 void GoUp(int mod)
1403214369 {
1403314370 MODIFIERS |= COMMAND;
14034
- /*
14371
+ /**/
1403514372 if((mod&SHIFT) == SHIFT)
1403614373 manipCamera.RotatePosition(0, speed);
1403714374 else
14038
- manipCamera.BackForth(0, speed*delta, getWidth());
14039
- */
14375
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14376
+ /**/
1404014377 if ((mod & SHIFT) == SHIFT)
1404114378 {
1404214379 mouseMode = mouseMode;
....@@ -14052,12 +14389,12 @@
1405214389 void GoLeft(int mod)
1405314390 {
1405414391 MODIFIERS |= COMMAND;
14055
- /*
14392
+ /**/
1405614393 if((mod&SHIFT) == SHIFT)
14057
- manipCamera.RotatePosition(speed, 0);
14058
- else
1405914394 manipCamera.Translate(speed*delta, 0, getWidth());
14060
- */
14395
+ else
14396
+ manipCamera.RotatePosition(speed, 0);
14397
+ /**/
1406114398 if ((mod & SHIFT) == SHIFT)
1406214399 {
1406314400 mouseMode = mouseMode;
....@@ -14073,12 +14410,12 @@
1407314410 void GoRight(int mod)
1407414411 {
1407514412 MODIFIERS |= COMMAND;
14076
- /*
14413
+ /**/
1407714414 if((mod&SHIFT) == SHIFT)
14078
- manipCamera.RotatePosition(-speed, 0);
14079
- else
1408014415 manipCamera.Translate(-speed*delta, 0, getWidth());
14081
- */
14416
+ else
14417
+ manipCamera.RotatePosition(-speed, 0);
14418
+ /**/
1408214419 if ((mod & SHIFT) == SHIFT)
1408314420 {
1408414421 mouseMode = mouseMode;
....@@ -14096,7 +14433,7 @@
1409614433 int X, Y;
1409714434 boolean SX, SY;
1409814435
14099
- void drag(int x, int y, int modifiers)
14436
+ void drag(int x, int y, int modifiers, int modifiersex)
1410014437 {
1410114438 if (IsFrozen())
1410214439 {
....@@ -14105,17 +14442,17 @@
1410514442
1410614443 drag = true; // NEW
1410714444
14108
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14445
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1410914446
1411014447 X = x;
1411114448 Y = y;
1411214449 // floating state for animation
14113
- MODIFIERS = modifiers;
14114
- modifiers &= ~1024;
14450
+ MODIFIERS = modifiersex;
14451
+ modifiersex &= ~1024;
1411514452 if (false) // modifiers != 0)
1411614453 {
1411714454 //new Exception().printStackTrace();
14118
- System.out.println("mouseDragged: " + modifiers);
14455
+ System.out.println("mouseDragged: " + modifiersex);
1411914456 System.out.println("SHIFT = " + SHIFT);
1412014457 System.out.println("CONTROL = " + COMMAND);
1412114458 System.out.println("META = " + META);
....@@ -14135,7 +14472,8 @@
1413514472 info.camera = renderCamera;
1413614473 info.x = x;
1413714474 info.y = y;
14138
- object.editWindow.copy.doEditDrag(info);
14475
+ object.GetWindow().copy
14476
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1413914477 } else
1414014478 {
1414114479 if (x < startX)
....@@ -14287,7 +14625,6 @@
1428714625 public void mouseMoved(MouseEvent e)
1428814626 {
1428914627 //System.out.println("mouseMoved: " + e);
14290
-
1429114628 if (isRenderer)
1429214629 return;
1429314630
....@@ -14300,7 +14637,9 @@
1430014637 ci.camera = renderCamera;
1430114638 if (!isRenderer)
1430214639 {
14303
- if (object.editWindow.copy.doEditClick(ci, 0))
14640
+ //ObjEditor editWindow = object.editWindow;
14641
+ //Object3D copy = editWindow.copy;
14642
+ if (object.doEditClick(ci, 0))
1430414643 {
1430514644 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1430614645 } else
....@@ -14312,7 +14651,11 @@
1431214651
1431314652 public void mouseReleased(MouseEvent e)
1431414653 {
14654
+ Globals.MOUSEDRAGGED = false;
14655
+
1431514656 movingcamera = false;
14657
+ X = 0; // getBounds().width/2;
14658
+ Y = 0; // getBounds().height/2;
1431614659 //System.out.println("mouseReleased: " + e);
1431714660 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1431814661 }
....@@ -14335,9 +14678,9 @@
1433514678 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1433614679 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1433714680
14338
- if (control || command || IsFrozen())
14681
+// No delay if (control || command || IsFrozen())
1433914682 timeout = true;
14340
- else
14683
+// ?? May 2019 else
1434114684 // timer.setDelay((modifiers & 128) != 0?0:350);
1434214685 mouseDown = false;
1434314686 if (!control && !command) // june 2013
....@@ -14447,7 +14790,7 @@
1444714790 System.out.println("keyReleased: " + e);
1444814791 }
1444914792
14450
- void SetMouseMode(int modifiers)
14793
+ void SetMouseMode(int modifiers, int modifiersex)
1445114794 {
1445214795 //System.out.println("SetMouseMode = " + modifiers);
1445314796 //modifiers &= ~1024;
....@@ -14459,25 +14802,25 @@
1445914802 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1446014803 // return;
1446114804 //System.out.println("SetMode = " + modifiers);
14462
- if ((modifiers & WHEEL) == WHEEL)
14805
+ if ((modifiersex & WHEEL) == WHEEL)
1446314806 {
1446414807 mouseMode |= ZOOM;
1446514808 }
1446614809
1446714810 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14468
- if (capsLocked || (modifiers & META) == META)
14811
+ if (capsLocked) // || (modifiers & META) == META)
1446914812 {
1447014813 mouseMode |= VR; // BACKFORTH;
1447114814 }
14472
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14815
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1447314816 {
1447414817 mouseMode |= SELECT;
1447514818 }
14476
- if ((modifiers & COMMAND) == COMMAND)
14819
+ if ((modifiersex & COMMAND) == COMMAND)
1447714820 {
1447814821 mouseMode |= SELECT;
1447914822 }
14480
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14823
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1448114824 {
1448214825 mouseMode &= ~VR;
1448314826 mouseMode |= TRANSLATE;
....@@ -14506,7 +14849,7 @@
1450614849
1450714850 if (isRenderer) //
1450814851 {
14509
- SetMouseMode(modifiers);
14852
+ SetMouseMode(0, modifiers);
1451014853 }
1451114854
1451214855 Globals.theRenderer.keyPressed(key);
....@@ -14653,7 +14996,9 @@
1465314996 case 'E' : COMPACT ^= true;
1465414997 repaint();
1465514998 break;
14656
- case 'W' : DEBUGHSB ^= true;
14999
+ case 'W' : // Wide Window (fullscreen)
15000
+ //DEBUGHSB ^= true;
15001
+ ObjEditor.theFrame.ToggleFullScreen();
1465715002 repaint();
1465815003 break;
1465915004 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14678,8 +15023,8 @@
1467815023 RevertCamera();
1467915024 repaint();
1468015025 break;
14681
- case 'L':
1468215026 case 'l':
15027
+ //case 'L':
1468315028 if (lightMode)
1468415029 {
1468515030 lightMode = false;
....@@ -14822,9 +15167,9 @@
1482215167 case '_':
1482315168 kompactbit = 5;
1482415169 break;
14825
- case '+':
14826
- kompactbit = 6;
14827
- break;
15170
+// case '+':
15171
+// kompactbit = 6;
15172
+// break;
1482815173 case ' ':
1482915174 lightMode ^= true;
1483015175 Globals.lighttouched = true;
....@@ -14836,13 +15181,14 @@
1483615181 case ESC:
1483715182 RENDERPROGRAM += 1;
1483815183 RENDERPROGRAM %= 3;
15184
+
1483915185 repaint();
1484015186 break;
1484115187 case 'Z':
1484215188 //RESIZETEXTURE ^= true;
1484315189 //break;
1484415190 case 'z':
14845
- RENDERSHADOW ^= true;
15191
+ Globals.RENDERSHADOW ^= true;
1484615192 Globals.lighttouched = true;
1484715193 repaint();
1484815194 break;
....@@ -14875,8 +15221,9 @@
1487515221 case DELETE:
1487615222 ClearSelection();
1487715223 break;
14878
- /*
1487915224 case '+':
15225
+
15226
+ /*
1488015227 //fontsize += 1;
1488115228 bbzoom *= 2;
1488215229 repaint();
....@@ -14893,17 +15240,17 @@
1489315240 case '=':
1489415241 IncDepth();
1489515242 //fontsize += 1;
14896
- object.editWindow.refreshContents(true);
15243
+ object.GetWindow().refreshContents(true);
1489715244 maskbit = 6;
1489815245 break;
1489915246 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1490015247 DecDepth();
1490115248 maskbit = 5;
1490215249 //if(fontsize > 1) fontsize -= 1;
14903
- if (object.editWindow == null)
14904
- new Exception().printStackTrace();
14905
- else
14906
- object.editWindow.refreshContents(true);
15250
+// if (object.editWindow == null)
15251
+// new Exception().printStackTrace();
15252
+// else
15253
+ object.GetWindow().refreshContents(true);
1490715254 break;
1490815255 case '{':
1490915256 manipCamera.shaper_fovy /= 1.1;
....@@ -14966,7 +15313,7 @@
1496615313 //mode = ROTATE;
1496715314 if ((MODIFIERS & COMMAND) == 0) // VR??
1496815315 {
14969
- SetMouseMode(modifiers);
15316
+ SetMouseMode(0, modifiers);
1497015317 }
1497115318 }
1497215319
....@@ -15100,8 +15447,9 @@
1510015447
1510115448 protected void processMouseMotionEvent(MouseEvent e)
1510215449 {
15103
- //System.out.println("processMouseMotionEvent: " + mouseMode);
15104
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15450
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15451
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15452
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1510515453 {
1510615454 mouseMoved(e);
1510715455 } else
....@@ -15126,11 +15474,12 @@
1512615474 }
1512715475 */
1512815476
15129
- object.editWindow.EditSelection();
15477
+ object.GetWindow().EditSelection(false);
1513015478 }
1513115479
1513215480 void SelectParent()
1513315481 {
15482
+ new Exception().printStackTrace();
1513415483 System.exit(0);
1513515484 Composite group = (Composite) object;
1513615485 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -15142,10 +15491,10 @@
1514215491 {
1514315492 //selectees.remove(i);
1514415493 System.out.println("select parent of " + elem);
15145
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15494
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1514615495 } else
1514715496 {
15148
- group.editWindow.Select(elem.GetTreePath(), first, true);
15497
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1514915498 }
1515015499
1515115500 first = false;
....@@ -15154,6 +15503,7 @@
1515415503
1515515504 void SelectChildren()
1515615505 {
15506
+ new Exception().printStackTrace();
1515715507 System.exit(0);
1515815508 /*
1515915509 Composite group = (Composite) object;
....@@ -15186,12 +15536,12 @@
1518615536 for (int j = 0; j < group.children.size(); j++)
1518715537 {
1518815538 elem = (Object3D) group.children.elementAt(j);
15189
- object.editWindow.Select(elem.GetTreePath(), first, true);
15539
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1519015540 first = false;
1519115541 }
1519215542 } else
1519315543 {
15194
- object.editWindow.Select(elem.GetTreePath(), first, true);
15544
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1519515545 }
1519615546
1519715547 first = false;
....@@ -15202,21 +15552,21 @@
1520215552 {
1520315553 //Composite group = (Composite) object;
1520415554 Object3D group = object;
15205
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15555
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1520615556 }
1520715557
1520815558 void ResetTransform(int mask)
1520915559 {
1521015560 //Composite group = (Composite) object;
1521115561 Object3D group = object;
15212
- group.editWindow.ResetTransform(mask);
15562
+ group.GetWindow().ResetTransform(mask);
1521315563 }
1521415564
1521515565 void FlipTransform()
1521615566 {
1521715567 //Composite group = (Composite) object;
1521815568 Object3D group = object;
15219
- group.editWindow.FlipTransform();
15569
+ group.GetWindow().FlipTransform();
1522015570 // group.editWindow.ReduceMesh(true);
1522115571 }
1522215572
....@@ -15224,7 +15574,7 @@
1522415574 {
1522515575 //Composite group = (Composite) object;
1522615576 Object3D group = object;
15227
- group.editWindow.PrintMemory();
15577
+ group.GetWindow().PrintMemory();
1522815578 // group.editWindow.ReduceMesh(true);
1522915579 }
1523015580
....@@ -15232,7 +15582,7 @@
1523215582 {
1523315583 //Composite group = (Composite) object;
1523415584 Object3D group = object;
15235
- group.editWindow.ResetCentroid();
15585
+ group.GetWindow().ResetCentroid();
1523615586 }
1523715587
1523815588 void IncDepth()
....@@ -15318,7 +15668,9 @@
1531815668 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1531915669 //Image img = CreateImage(width, height);
1532015670 //System.out.println("width = " + width + "; height = " + height + "\n");
15671
+
1532115672 Graphics gr = g; // img.getGraphics();
15673
+
1532215674 if (!hasMarquee)
1532315675 {
1532415676 if (Xmin < Xmax) // !locked)
....@@ -15406,6 +15758,7 @@
1540615758 info.bounds.y += (height - desired) / 2;
1540715759 }
1540815760 }
15761
+
1540915762 info.g = gr;
1541015763 info.camera = renderCamera;
1541115764 /*
....@@ -15415,15 +15768,55 @@
1541515768 */
1541615769 if (!isRenderer)
1541715770 {
15418
- object.drawEditHandles(info, 0);
15771
+ Grafreed.Assert(object != null);
15772
+ Grafreed.Assert(object.selection != null);
15773
+ if (object.selection.Size() > 0)
15774
+ {
15775
+ int hitSomething = object.selection.get(0).hitSomething;
15776
+
15777
+ info.DX = 0;
15778
+ info.DY = 0;
15779
+ info.W = 1;
15780
+ if (hitSomething == Object3D.hitCenter)
15781
+ {
15782
+ info.DX = X;
15783
+ if (X != 0)
15784
+ info.DX -= info.bounds.width/2;
15785
+
15786
+ info.DY = Y;
15787
+ if (Y != 0)
15788
+ info.DY -= info.bounds.height/2;
15789
+ }
15790
+
15791
+ object.drawEditHandles(info, 0);
15792
+
15793
+ if (drag && (X != 0 || Y != 0))
15794
+ {
15795
+ switch (hitSomething)
15796
+ {
15797
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15798
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15799
+ break;
15800
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15801
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15802
+ break;
15803
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15804
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15805
+ break;
15806
+ }
15807
+
15808
+ }
15809
+ }
1541915810 }
1542015811 }
15812
+
1542115813 if (isRenderer)
1542215814 {
1542315815 //gr.setColor(Color.black);
1542415816 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1542515817 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1542615818 }
15819
+
1542715820 if (hasMarquee)
1542815821 {
1542915822 gr.setXORMode(Color.white);
....@@ -15536,6 +15929,7 @@
1553615929 public boolean mouseDown(Event evt, int x, int y)
1553715930 {
1553815931 System.out.println("mouseDown: " + evt);
15932
+ System.exit(0);
1553915933 /*
1554015934 locked = true;
1554115935 drag = false;
....@@ -15579,7 +15973,7 @@
1557915973 {
1558015974 keyPressed(0, modifiers);
1558115975 }
15582
- clickStart(x, y, modifiers);
15976
+ // clickStart(x, y, modifiers);
1558315977 return true;
1558415978 }
1558515979
....@@ -15697,7 +16091,7 @@
1569716091 {
1569816092 keyReleased(0, 0);
1569916093 }
15700
- drag(x, y, modifiers);
16094
+ drag(x, y, 0, modifiers);
1570116095 return true;
1570216096 }
1570316097
....@@ -15829,7 +16223,7 @@
1582916223 Object3D object;
1583016224 static Object3D trackedobject;
1583116225 Camera renderCamera; // Light or Eye (or Occlusion)
15832
- /*static*/ Camera manipCamera; // Light or Eye
16226
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1583316227 /*static*/ Camera eyeCamera;
1583416228 /*static*/ Camera lightCamera;
1583516229 int cameracount;
....@@ -16114,16 +16508,16 @@
1611416508 cStatic.objectstack[materialdepth++] = checker;
1611516509 //System.out.println("material " + material);
1611616510 //Applet3D.tracein(this, selected);
16117
- vector2buffer = checker.projectedVertices;
16511
+ //vector2buffer = checker.projectedVertices;
1611816512
1611916513 //checker.GetMaterial().Draw(this, false); // true);
16120
- DrawMaterial(checker.GetMaterial(), false); // true);
16514
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1612116515
1612216516 materialdepth -= 1;
1612316517 if (materialdepth > 0)
1612416518 {
16125
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16126
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16519
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16520
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1612716521 }
1612816522 //checker.GetMaterial().opacity = 1f;
1612916523 ////checker.GetMaterial().ambient = 1f;
....@@ -16209,6 +16603,14 @@
1620916603 }
1621016604 }
1621116605
16606
+ private Object3D GetFolder()
16607
+ {
16608
+ Object3D folder = object.GetWindow().copy;
16609
+ if (object.GetWindow().copy.selection.Size() > 0)
16610
+ folder = object.GetWindow().copy.selection.elementAt(0);
16611
+ return folder;
16612
+ }
16613
+
1621216614 class SelectBuffer implements GLEventListener
1621316615 {
1621416616
....@@ -16267,6 +16669,7 @@
1626716669 {
1626816670 if (!selection)
1626916671 {
16672
+ new Exception().printStackTrace();
1627016673 System.exit(0);
1627116674 return;
1627216675 }
....@@ -16287,6 +16690,17 @@
1628716690
1628816691 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1628916692
16693
+ if (PAINTMODE)
16694
+ {
16695
+ if (object.GetWindow().copy.selection.Size() > 0)
16696
+ {
16697
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16698
+
16699
+ // Make what you paint not selectable.
16700
+ paintobj.ResetSelectable();
16701
+ }
16702
+ }
16703
+
1629016704 //int tmp = selection_view;
1629116705 //selection_view = -1;
1629216706 int temp = DrawMode();
....@@ -16298,6 +16712,17 @@
1629816712 // temp = DEFAULT; // patch for selection debug
1629916713 Globals.drawMode = temp; // WARNING
1630016714
16715
+ if (PAINTMODE)
16716
+ {
16717
+ if (object.GetWindow().copy.selection.Size() > 0)
16718
+ {
16719
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16720
+
16721
+ // Revert.
16722
+ paintobj.RestoreSelectable();
16723
+ }
16724
+ }
16725
+
1630116726 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1630216727
1630316728 // trying different ways of getting the depth info over
....@@ -16345,6 +16770,8 @@
1634516770 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1634616771 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1634716772 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16773
+
16774
+ CreateSelectedPoint();
1634816775
1634916776 // Will fit the mesh !!!
1635016777 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16394,34 +16821,36 @@
1639416821 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]));
1639516822 }
1639616823
16397
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16824
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1639816825 }
1639916826 }
1640016827
1640116828 if (!movingcamera && !PAINTMODE)
16402
- object.editWindow.ScreenFitPoint(); // fev 2014
16829
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1640316830
16404
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16831
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1640516832 {
16406
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16833
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1640716834
16408
- Object3D group = new Object3D("inst" + paintcount++);
16835
+ if (object.GetWindow().copy.selection.Size() > 0)
16836
+ {
16837
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1640916838
16410
- group.CreateMaterial(); // use a void leaf to select instances
16411
-
16412
- group.add(paintobj); // link
16413
-
16414
- object.editWindow.SnapObject(group);
16415
-
16416
- Object3D folder = object.editWindow.copy;
16417
-
16418
- if (object.editWindow.copy.selection.Size() > 0)
16419
- folder = object.editWindow.copy.selection.elementAt(0);
16420
-
16421
- folder.add(group);
16422
-
16423
- object.editWindow.ResetModel();
16424
- object.editWindow.refreshContents();
16839
+ Object3D inst = new Object3D("inst" + paintcount++);
16840
+
16841
+ inst.CreateMaterial(); // use a void leaf to select instances
16842
+
16843
+ inst.add(paintobj); // link
16844
+
16845
+ object.GetWindow().SnapObject(inst);
16846
+
16847
+ Object3D folder = paintFolder; // GetFolder();
16848
+
16849
+ folder.add(inst);
16850
+
16851
+ object.GetWindow().ResetModel();
16852
+ object.GetWindow().refreshContents();
16853
+ }
1642516854 }
1642616855 else
1642716856 paintcount = 0;
....@@ -16460,6 +16889,11 @@
1646016889 //System.out.println("objects[color] = " + objects[color]);
1646116890 //objects[color].Select();
1646216891 indexcount = 0;
16892
+ ObjEditor window = object.GetWindow();
16893
+ if (window != null && deselect)
16894
+ {
16895
+ window.Select(null, deselect, true);
16896
+ }
1646316897 object.Select(color, deselect);
1646416898 }
1646516899
....@@ -16559,7 +16993,7 @@
1655916993 gl.glDisable(gl.GL_CULL_FACE);
1656016994 }
1656116995
16562
- if (!RENDERSHADOW)
16996
+ if (!Globals.RENDERSHADOW)
1656316997 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1656416998
1656516999 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16569,7 +17003,7 @@
1656917003 //gl.glColorMask(false, false, false, false);
1657017004
1657117005 //render_scene_from_light_view(gl, drawable, 0, 0);
16572
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17006
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1657317007 {
1657417008 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1657517009
....@@ -16985,23 +17419,15 @@
1698517419 int AAbuffersize = 0;
1698617420
1698717421 //double[] selectedpoint = new double[3];
16988
- static Superellipsoid selectedpoint = new Superellipsoid();
17422
+ static Superellipsoid selectedpoint;
1698917423 static Sphere previousselectedpoint = null;
16990
- static Sphere debugpointG = new Sphere();
16991
- static Sphere debugpointP = new Sphere();
16992
- static Sphere debugpointC = new Sphere();
16993
- static Sphere debugpointR = new Sphere();
17424
+ static Sphere debugpointG;
17425
+ static Sphere debugpointP;
17426
+ static Sphere debugpointC;
17427
+ static Sphere debugpointR;
1699417428
1699517429 static Sphere debugpoints[] = new Sphere[8];
1699617430
16997
- static
16998
- {
16999
- for (int i=0; i<8; i++)
17000
- {
17001
- debugpoints[i] = new Sphere();
17002
- }
17003
- }
17004
-
1700517431 static void InitPoints(float radius)
1700617432 {
1700717433 for (int i=0; i<8; i++)