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
....@@ -61,7 +60,7 @@
6160 //boolean REDUCETEXTURE = true;
6261 boolean CACHETEXTURE = true;
6362 boolean CLEANCACHE = false; // true;
64
- boolean MIPMAP = false; // true;
63
+ boolean MIPMAP = true; // false; // true;
6564 boolean COMPRESSTEXTURE = false;
6665 boolean KOMPACTTEXTURE = false; // true;
6766 boolean RESIZETEXTURE = 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 {
....@@ -325,7 +326,7 @@
325326 cStatic.objectstack[materialdepth++] = obj;
326327 //System.out.println("material " + material);
327328 //Applet3D.tracein(this, selected);
328
- display.vector2buffer = obj.projectedVertices;
329
+ //display.vector2buffer = obj.projectedVertices;
329330 if (obj instanceof Camera)
330331 {
331332 display.options1[0] = material.shift;
....@@ -334,14 +335,28 @@
334335 display.options1[2] = material.shadowbias;
335336 display.options1[3] = material.aniso;
336337 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]);
337343 display.options2[0] = material.opacity;
338344 display.options2[1] = material.diffuse;
339345 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]);
340349
341350 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]);
342354 display.options4[0] = material.cameralight/0.2f;
343355 display.options4[1] = material.subsurface;
344356 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]);
345360
346361 // if (display.CURRENTANTIALIAS > 0)
347362 // display.options3[3] /= 4;
....@@ -357,7 +372,7 @@
357372 /**/
358373 } else
359374 {
360
- DrawMaterial(material, selected);
375
+ DrawMaterial(material, selected, obj.projectedVertices);
361376 }
362377 } else
363378 {
....@@ -381,8 +396,8 @@
381396 cStatic.objectstack[materialdepth++] = obj;
382397 //System.out.println("material " + material);
383398 //Applet3D.tracein("selected ", selected);
384
- display.vector2buffer = obj.projectedVertices;
385
- display.DrawMaterial(material, selected);
399
+ //display.vector2buffer = obj.projectedVertices;
400
+ display.DrawMaterial(material, selected, obj.projectedVertices);
386401 }
387402 }
388403
....@@ -399,8 +414,8 @@
399414 materialdepth -= 1;
400415 if (materialdepth > 0)
401416 {
402
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
403
- 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);
404419 }
405420 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
406421 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -420,8 +435,8 @@
420435 materialdepth -= 1;
421436 if (materialdepth > 0)
422437 {
423
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
424
- 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);
425440 }
426441 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
427442 //else
....@@ -462,10 +477,12 @@
462477 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
463478 {
464479 //gl.glBegin(gl.GL_TRIANGLES);
465
- 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
+ ;
466483 if (!hasnorm)
467484 {
468
- // System.out.println("FUCK!!");
485
+ // System.out.println("Mesh normal");
469486 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
470487 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
471488 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1190,10 +1207,12 @@
11901207 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11911208 }
11921209 }
1210
+
11931211 if (flipV)
11941212 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11951213 else
11961214 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1215
+
11971216 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
11981217 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
11991218
....@@ -1213,10 +1232,12 @@
12131232 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12141233 }
12151234 }
1235
+
12161236 if (flipV)
12171237 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12181238 else
12191239 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1240
+
12201241 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12211242 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12221243
....@@ -1244,8 +1265,10 @@
12441265 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12451266 else
12461267 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1268
+
12471269 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12481270 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1271
+
12491272 count2 += 2;
12501273 count3 += 3;
12511274 }
....@@ -1601,7 +1624,7 @@
16011624 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16021625 }
16031626
1604
- void DrawMaterial(cMaterial material, boolean selected)
1627
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16051628 {
16061629 CameraPane display = this;
16071630 //new Exception().printStackTrace();
....@@ -1628,7 +1651,7 @@
16281651
16291652 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16301653
1631
- float[] colorV = GrafreeD.colorV;
1654
+ float[] colorV = Grafreed.colorV;
16321655
16331656 /**/
16341657 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1636,7 +1659,7 @@
16361659 colorV[0] = display.modelParams0[0] * material.diffuse;
16371660 colorV[1] = display.modelParams0[1] * material.diffuse;
16381661 colorV[2] = display.modelParams0[2] * material.diffuse;
1639
- colorV[3] = material.opacity;
1662
+ colorV[3] = 1; // material.opacity;
16401663
16411664 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16421665 //System.out.println("Opacity = " + opacity);
....@@ -1744,9 +1767,9 @@
17441767 display.modelParams7[2] = 0;
17451768 display.modelParams7[3] = 0;
17461769
1747
- display.modelParams6[0] = 100; // criss de bug de bump
1770
+ //display.modelParams6[0] = 100; // criss de bug de bump
17481771
1749
- Object3D.cVector2[] extparams = display.vector2buffer;
1772
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17501773 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17511774 {
17521775 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1888,7 +1911,7 @@
18881911 void PushMatrix(double[][] matrix)
18891912 {
18901913 // GrafreeD.tracein(matrix);
1891
- PushMatrix(matrix,1);
1914
+ PushMatrix(matrix, 1);
18921915 }
18931916
18941917 void PushMatrix()
....@@ -2042,7 +2065,7 @@
20422065 //System.err.println("Oeil on");
20432066 OEIL = true;
20442067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2045
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20462069 //pingthread.StepToTarget(true);
20472070 }
20482071
....@@ -2140,7 +2163,7 @@
21402163 System.err.println("LIVE = " + Globals.isLIVE());
21412164
21422165 if (!Globals.isLIVE()) // save sound
2143
- GrafreeD.savesound = true; // wav.save();
2166
+ Grafreed.savesound = true; // wav.save();
21442167 // else
21452168 repaint(); // start loop // may 2013
21462169 }
....@@ -2257,7 +2280,7 @@
22572280
22582281 void ToggleDebug()
22592282 {
2260
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22612284 }
22622285
22632286 void ToggleLookAt()
....@@ -2265,9 +2288,9 @@
22652288 LOOKAT ^= true;
22662289 }
22672290
2268
- void ToggleRandom()
2291
+ void ToggleSwitch()
22692292 {
2270
- RANDOM ^= true;
2293
+ SWITCH ^= true;
22712294 }
22722295
22732296 void ToggleHandles()
....@@ -2275,10 +2298,17 @@
22752298 HANDLES ^= true;
22762299 }
22772300
2301
+ Object3D paintFolder;
2302
+
22782303 void TogglePaint()
22792304 {
22802305 PAINTMODE ^= true;
22812306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
22822312 }
22832313
22842314 void SwapCamera(int a, int b)
....@@ -2374,7 +2404,7 @@
23742404 {
23752405 return currentGL;
23762406 }
2377
-
2407
+
23782408 /**/
23792409 class CacheTexture
23802410 {
....@@ -2392,9 +2422,10 @@
23922422 /**/
23932423
23942424 // TEXTURE static Texture texture;
2395
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2396
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2397
- 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
+
23982429 int pigmentdepth = 0;
23992430 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24002431 int bumpdepth = 0;
....@@ -2416,6 +2447,33 @@
24162447 true,
24172448 com.sun.opengl.util.texture.TextureIO.PNG);
24182449 } 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)
24192477 {
24202478 throw new javax.media.opengl.GLException(e);
24212479 }
....@@ -3502,6 +3560,8 @@
35023560
35033561 System.out.println("LOADING TEXTURE : " + name);
35043562
3563
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3564
+
35053565 //
35063566 if (false) // compressbit > 0)
35073567 {
....@@ -7900,7 +7960,7 @@
79007960 String pigment = Object3D.GetPigment(tex);
79017961 String bump = Object3D.GetBump(tex);
79027962
7903
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7963
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79047964 {
79057965 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79067966 // System.out.println("; bump = " + bump);
....@@ -7917,6 +7977,64 @@
79177977
79187978 ReleaseTexture(bump, true);
79197979 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);
79208038 }
79218039
79228040 void ReleaseTexture(String tex, boolean bump)
....@@ -8022,7 +8140,55 @@
80228140 }
80238141 }
80248142
8025
- /*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
80268192 {
80278193 if (// DrawMode() != 0 || /*tex == null ||*/
80288194 ambientOcclusion ) // || !textureon)
....@@ -8032,18 +8198,48 @@
80328198
80338199 if (tex == null)
80348200 {
8035
- BindTexture(null,false,resolution);
8036
- BindTexture(null,true,resolution);
8201
+ BindTexture(null, null,false,resolution);
80378202 return;
80388203 }
80398204
80408205 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
+
80418238 String bump = Object3D.GetBump(tex);
80428239
8043
- usedtextures.put(pigment, pigment);
8044
- usedtextures.put(bump, bump);
8240
+ usedtextures.add(bump);
80458241
8046
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8242
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80478243 {
80488244 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80498245 // System.out.println("; bump = " + bump);
....@@ -8053,42 +8249,70 @@
80538249 {
80548250 bump = null;
80558251 }
8056
- if (pigment.equals(""))
8057
- {
8058
- pigment = null;
8059
- }
80608252
8061
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8062
- BindTexture(pigment, false, resolution);
80638253 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8064
- BindTexture(bump, true, resolution);
8254
+ BindTexture(tex.bumptexture, bump, true, resolution);
80658255 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8066
-
8067
- return; // true;
80688256 }
80698257
8070
- 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)
80718261 {
8072
- 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;
80738281
80748282 if (tex != null)
80758283 {
80768284 String texname = tex;
80778285
8078
- String[] split = tex.split("Textures");
8079
- if (split.length > 1)
8080
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8081
- else
8082
- if (!texname.startsWith("/"))
8083
- 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
+ }
80848298
80858299 if (CACHETEXTURE)
8086
- texture = textures.get(texname); // TEXTURE CACHE
8087
-
8088
- TextureData texturedata = null;
8089
-
8090
- if (texture == null || texture.resolution < resolution)
80918300 {
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
80928316 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
80938317 {
80948318 assert(!bump);
....@@ -8100,19 +8324,19 @@
81008324 // }
81018325 // else
81028326 // {
8103
- texture = textures.get(tex);
8104
- if (texture == null)
8327
+ texturecache = textures.get(tex);
8328
+ if (texturecache == null)
81058329 {
8106
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8330
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81078331 }
81088332 // }
81098333 } else
81108334 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81118335 {
81128336 assert(bump);
8113
- texture = textures.get(tex);
8114
- if (texture == null)
8115
- 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);
81168340 } else
81178341 {
81188342 //if (tex.equals("IMMORTAL"))
....@@ -8122,9 +8346,9 @@
81228346 //{
81238347 if (tex.equals("WHITE_NOISE"))
81248348 {
8125
- texture = textures.get(tex);
8126
- if (texture == null)
8127
- 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);
81288352 } else
81298353 {
81308354 if (textureon)
....@@ -8149,7 +8373,7 @@
81498373 }
81508374
81518375 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8152
- if (!new File(cachename).exists())
8376
+ if (!FileExists(cachename))
81538377 cachename = texname;
81548378 else
81558379 processbump = false; // don't process bump map again
....@@ -8171,7 +8395,7 @@
81718395 }
81728396
81738397 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8174
- if (!new File(cachename).exists())
8398
+ if (!FileExists(cachename))
81758399 cachename = texname;
81768400 else
81778401 processbump = false; // don't process bump map again
....@@ -8180,20 +8404,22 @@
81808404 texturedata = GetFileTexture(cachename, processbump, resolution);
81818405
81828406
8183
- if (texturedata != null)
8184
- 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);
81858411 //texture = GetTexture(tex, bump);
81868412 }
81878413 }
81888414 //}
81898415 }
81908416
8191
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8417
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
81928418 {
81938419 //return false;
81948420
81958421 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8196
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8422
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
81978423 {
81988424 // String ext = "_highres";
81998425 // if (REDUCETEXTURE)
....@@ -8282,8 +8508,8 @@
82828508 textures.remove(texname);
82838509 }
82848510
8285
- texture.texturedata = texturedata;
8286
- textures.put(texname, texture);
8511
+ //texture.texturedata = texturedata;
8512
+ textures.put(texname, texturecache);
82878513
82888514 // newtex = true;
82898515 }
....@@ -8299,12 +8525,12 @@
82998525 }
83008526 }
83018527
8302
- return texture;
8528
+ return texturecache;
83038529 }
83048530
8305
- 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
83068532 {
8307
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8533
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83088534
83098535 if (bump)
83108536 {
....@@ -8320,23 +8546,23 @@
83208546 return texture!=null?texture.texture:null;
83218547 }
83228548
8323
- 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
83248550 {
8325
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8551
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83268552
83278553 return texture!=null?texture.texturedata:null;
83288554 }
83298555
8330
- boolean BindTexture(String tex, boolean bump, int resolution)
8556
+ boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83318557 {
83328558 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83338559 {
83348560 return false;
83358561 }
83368562
8337
- boolean newtex = false;
8563
+ //boolean newtex = false;
83388564
8339
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8565
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
83408566
83418567 if (texture == null)
83428568 return false;
....@@ -8366,7 +8592,7 @@
83668592 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83678593 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83688594
8369
- return newtex;
8595
+ return true; // Warning: not used.
83708596 }
83718597
83728598 ShadowBuffer shadowPBuf;
....@@ -9204,11 +9430,35 @@
92049430 jy8[3] = 0.5f;
92059431 }
92069432
9207
- 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
92089434 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92099435 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92109436 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92119437
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
+
92129462 static int imagecount = 0; // movie generation
92139463
92149464 static int jitter = 0;
....@@ -9304,8 +9554,8 @@
93049554 assert (parentcam != renderCamera);
93059555
93069556 if (renderCamera != lightCamera)
9307
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9308
- LA.matConcat(matrix, parentcam.toParent, matrix);
9557
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9558
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93099559
93109560 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93119561
....@@ -9320,8 +9570,8 @@
93209570 LA.matCopy(renderCamera.fromScreen, matrix);
93219571
93229572 if (renderCamera != lightCamera)
9323
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9324
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9573
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9574
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93259575
93269576 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93279577
....@@ -9538,7 +9788,7 @@
95389788
95399789 if (!BOXMODE)
95409790 {
9541
- 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) + ")");
95429792 }
95439793
95449794 if (!BOXMODE)
....@@ -9576,7 +9826,7 @@
95769826 ABORTED = false;
95779827 }
95789828 else
9579
- GrafreeD.wav.cursor += 735 * ACSIZE;
9829
+ Grafreed.wav.cursor += 735 * ACSIZE;
95809830
95819831 if (false)
95829832 {
....@@ -10239,11 +10489,11 @@
1023910489
1024010490 public void display(GLAutoDrawable drawable)
1024110491 {
10242
- if (GrafreeD.savesound && GrafreeD.hassound)
10492
+ if (Grafreed.savesound && Grafreed.hassound)
1024310493 {
10244
- GrafreeD.wav.save();
10245
- GrafreeD.savesound = false;
10246
- GrafreeD.hassound = false;
10494
+ Grafreed.wav.save();
10495
+ Grafreed.savesound = false;
10496
+ Grafreed.hassound = false;
1024710497 }
1024810498 // if (DEBUG_SELECTION)
1024910499 // {
....@@ -10319,6 +10569,7 @@
1031910569 ANTIALIAS = 0;
1032010570 //System.out.println("RESTART");
1032110571 AAtimer.restart();
10572
+ Globals.TIMERRUNNING = true;
1032210573 }
1032310574 }
1032410575 }
....@@ -10373,7 +10624,7 @@
1037310624 Object3D theobject = object;
1037410625 Object3D theparent = object.parent;
1037510626 object.parent = null;
10376
- object = (Object3D)GrafreeD.clone(object);
10627
+ object = (Object3D)Grafreed.clone(object);
1037710628 object.Stripify();
1037810629 if (theobject.selection == null || theobject.selection.Size() == 0)
1037910630 theobject.PreprocessOcclusion(this);
....@@ -10386,13 +10637,14 @@
1038610637 ambientOcclusion = false;
1038710638 }
1038810639
10389
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10640
+ if (//Globals.lighttouched &&
10641
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039010642 {
1039110643 //if (RENDERSHADOW) // ?
1039210644 if (!IsFrozen())
1039310645 {
1039410646 // dec 2012
10395
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10647
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039610648 {
1039710649 Globals.framecount++;
1039810650 shadowbuffer.display();
....@@ -10519,8 +10771,8 @@
1051910771
1052010772 // if (parentcam != renderCamera) // not a light
1052110773 if (cam != lightCamera)
10522
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10523
- LA.matConcat(matrix, parentcam.toParent, matrix);
10774
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10775
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052410776
1052510777 for (int j = 0; j < 4; j++)
1052610778 {
....@@ -10534,8 +10786,8 @@
1053410786
1053510787 // if (parentcam != renderCamera) // not a light
1053610788 if (cam != lightCamera)
10537
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10538
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10789
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10790
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1053910791
1054010792 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054110793
....@@ -10794,7 +11046,16 @@
1079411046 // Bump noise
1079511047 gl.glActiveTexture(GL.GL_TEXTURE6);
1079611048 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10797
- 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
+
1079811059
1079911060 gl.glActiveTexture(GL.GL_TEXTURE0);
1080011061 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10817,9 +11078,9 @@
1081711078
1081811079 gl.glMatrixMode(GL.GL_MODELVIEW);
1081911080
10820
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10821
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10822
-//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);
1082311084 } else
1082411085 {
1082511086 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10830,7 +11091,7 @@
1083011091 //System.out.println("BLENDING ON");
1083111092 gl.glEnable(GL.GL_BLEND);
1083211093 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10833
-
11094
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1083411095 gl.glMatrixMode(gl.GL_PROJECTION);
1083511096 gl.glLoadIdentity();
1083611097
....@@ -10919,8 +11180,8 @@
1091911180 System.err.println("parentcam != renderCamera");
1092011181
1092111182 // if (cam != lightCamera)
10922
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10923
- 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
1092411185 }
1092511186
1092611187 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10941,8 +11202,8 @@
1094111202 if (true) // TODO
1094211203 {
1094311204 if (cam != lightCamera)
10944
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10945
- 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
1094611207 }
1094711208
1094811209 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11279,23 +11540,44 @@
1127911540 e.printStackTrace();
1128011541 }
1128111542
11282
- if (GrafreeD.RENDERME > 0)
11283
- GrafreeD.RENDERME--; // mechante magouille
11543
+ if (Grafreed.RENDERME > 0)
11544
+ Grafreed.RENDERME--; // mechante magouille
1128411545
1128511546 Globals.ONESTEP = false;
1128611547 }
1128711548
1128811549 static boolean zoomonce = false;
1128911550
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
+
1129011569 void DrawObject(GL gl, boolean draw)
1129111570 {
11571
+ // To clear camera values
11572
+ ResetOptions();
11573
+
1129211574 //System.out.println("DRAW OBJECT " + mouseDown);
1129311575 // DrawMode() = SELECTION;
1129411576 //GL gl = getGL();
1129511577 if ((TRACK || SHADOWTRACK) || zoomonce)
1129611578 {
1129711579 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11298
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11580
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1129911581 pingthread.StepToTarget(true); // true);
1130011582 // zoomonce = false;
1130111583 }
....@@ -11350,7 +11632,14 @@
1135011632
1135111633 usedtextures.clear();
1135211634
11353
- 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
+ }
1135411643 }
1135511644 //System.out.println("--> " + stackdepth);
1135611645 // GrafreeD.traceon();
....@@ -11360,8 +11649,9 @@
1136011649
1136111650 if (DrawMode() == DEFAULT)
1136211651 {
11363
- if (DEBUG)
11652
+ if (Globals.DEBUG)
1136411653 {
11654
+ CreateSelectedPoint();
1136511655 float radius = 0.05f;
1136611656 if (selectedpoint.radius != radius)
1136711657 {
....@@ -11424,7 +11714,7 @@
1142411714 if (tex.equals("WHITE_NOISE"))
1142511715 continue;
1142611716
11427
- if (!usedtextures.containsKey(tex))
11717
+ if (!usedtextures.contains(tex))
1142811718 {
1142911719 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1143011720 textures.get(tex).texture.dispose();
....@@ -11441,7 +11731,14 @@
1144111731 if (checker != null && DrawMode() == DEFAULT)
1144211732 {
1144311733 //BindTexture(IMMORTAL_TEXTURE);
11444
- 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
+ }
1144511742 // NEAREST
1144611743 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144711744 DrawChecker(gl);
....@@ -11523,7 +11820,7 @@
1152311820 return;
1152411821 }
1152511822
11526
- String string = obj.GetToolTip();
11823
+ String string = obj.toString(); //.GetToolTip();
1152711824
1152811825 GL gl = GetGL();
1152911826
....@@ -11840,8 +12137,8 @@
1184012137 //obj.TransformToWorld(light, light);
1184112138 for (int i = tp.size(); --i >= 0;)
1184212139 {
11843
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11844
- 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);
1184512142 }
1184612143
1184712144
....@@ -11858,8 +12155,8 @@
1185812155 parentcam = cameras[0];
1185912156 }
1186012157
11861
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11862
- 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
1186312160
1186412161 LA.xformPos(light, renderCamera.toScreen, light);
1186512162
....@@ -12473,8 +12770,8 @@
1247312770
1247412771 // display shadow only (bump == 0)
1247512772 "SUB temp.x, half.x, shadow.x;" +
12476
- "MOV temp.y, -params6.x;" +
12477
- "SLT temp.z, temp.y, zero.x;" +
12773
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12774
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247812775 "SUB temp.y, one.x, temp.z;" +
1247912776 "MUL temp.x, temp.x, temp.y;" +
1248012777 "KIL temp.x;" +
....@@ -12754,7 +13051,7 @@
1275413051 "MUL final.y, fragment.texcoord[0].x, c256;" +
1275513052 "FLR final.x, final.y;" +
1275613053 "SUB final.y, final.y, final.x;" +
12757
- //"MUL final.x, final.x, c256i;" +
13054
+ "MUL final.x, final.x, c256i;" +
1275813055 "MOV final.z, zero.x;" +
1275913056 "MOV final.a, one.w;":""
1276013057 ) +
....@@ -12762,7 +13059,7 @@
1276213059 "MUL final.y, fragment.texcoord[0].y, c256;" +
1276313060 "FLR final.x, final.y;" +
1276413061 "SUB final.y, final.y, final.x;" +
12765
- //"MUL final.x, final.x, c256i;" +
13062
+ "MUL final.x, final.x, c256i;" +
1276613063 "MOV final.z, zero.x;" +
1276713064 "MOV final.a, one.w;":""
1276813065 ) +
....@@ -12805,7 +13102,7 @@
1280513102 //once = true;
1280613103 }
1280713104
12808
- System.out.print("Program #" + mode + "; length = " + program.length());
13105
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280913106 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1281013107 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1281113108
....@@ -12938,12 +13235,16 @@
1293813235
1293913236 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1294013237 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13238
+
13239
+ // Compare fragment depth in light space with shadowmap.
1294113240 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1294213241 "SGE temp.y, temp.x, zero.x;" +
12943
- "SUB " + shadow + ".y, one.x, temp.y;" +
13242
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13243
+
13244
+ // Reverse comparison
1294413245 "SUB temp.x, one.x, temp.x;" +
1294513246 "MUL " + shadow + ".x, temp.x, temp.y;" +
12946
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13247
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294713248 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294813249
1294913250 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12957,6 +13258,10 @@
1295713258 // No shadow for backface
1295813259 "DP3 temp.x, normal, lightd;" +
1295913260 "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;" +
1296013265 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1296113266 "";
1296213267 }
....@@ -13103,7 +13408,8 @@
1310313408 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1310413409 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1310513410 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13106
- Object3D.cVector2[] vector2buffer;
13411
+
13412
+ //Object3D.cVector2[] vector2buffer;
1310713413
1310813414 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1310913415 // OUT : diff, spec
....@@ -13119,9 +13425,10 @@
1311913425 "DP3 " + dest + ".z," + "normals," + "eye;" +
1312013426 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1312113427 //"MOV " + dest + ".w," + "normal.z;" +
13122
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13123
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13124
- //"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
1312513432 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1312613433 "RCP " + dest + ".w," + dest + ".w;" +
1312713434 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13515,7 +13822,7 @@
1351513822 public void mousePressed(MouseEvent e)
1351613823 {
1351713824 //System.out.println("mousePressed: " + e);
13518
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13825
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351913826 }
1352013827
1352113828 static long prevtime = 0;
....@@ -13591,8 +13898,8 @@
1359113898 // mode |= META;
1359213899 //}
1359313900
13594
- SetMouseMode(WHEEL | e.getModifiersEx());
13595
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13901
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13902
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359613903 anchorX = ax;
1359713904 anchorY = ay;
1359813905 prevX = px;
....@@ -13626,6 +13933,7 @@
1362613933 else
1362713934 if (evt.getSource() == AAtimer)
1362813935 {
13936
+ Globals.TIMERRUNNING = false;
1362913937 if (mouseDown)
1363013938 {
1363113939 //new Exception().printStackTrace();
....@@ -13651,6 +13959,10 @@
1365113959 // LIVE = waslive;
1365213960 // wasliveok = true;
1365313961 // waslive = false;
13962
+
13963
+ // May 2019 Forget it:
13964
+ if (true)
13965
+ return;
1365413966
1365513967 // source == timer
1365613968 if (mouseDown)
....@@ -13681,7 +13993,7 @@
1368113993
1368213994 // fev 2014???
1368313995 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13684
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13996
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1368513997 pingthread.StepToTarget(true); // true);
1368613998 }
1368713999 // if (!LIVE)
....@@ -13690,12 +14002,13 @@
1369014002
1369114003 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1369214004
13693
- void clickStart(int x, int y, int modifiers)
14005
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1369414006 {
1369514007 if (!wasliveok)
1369614008 return;
1369714009
1369814010 AAtimer.restart(); //
14011
+ Globals.TIMERRUNNING = true;
1369914012
1370014013 // waslive = LIVE;
1370114014 // LIVE = false;
....@@ -13707,7 +14020,7 @@
1370714020 // touched = true; // main DL
1370814021 if (isRenderer)
1370914022 {
13710
- SetMouseMode(modifiers);
14023
+ SetMouseMode(modifiers, modifiersex);
1371114024 }
1371214025
1371314026 selectX = anchorX = x;
....@@ -13720,7 +14033,7 @@
1372014033 clicked = true;
1372114034 hold = false;
1372214035
13723
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14036
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1372414037 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1372514038 {
1372614039 // System.out.println("RESTART II " + modifiers);
....@@ -13751,7 +14064,7 @@
1375114064 info.camera = renderCamera;
1375214065 info.x = x;
1375314066 info.y = y;
13754
- info.modifiers = modifiers;
14067
+ info.modifiers = modifiersex;
1375514068 editObj = object.doEditClick(info, 0);
1375614069 if (!editObj)
1375714070 {
....@@ -13768,9 +14081,12 @@
1376814081
1376914082 public void mouseDragged(MouseEvent e)
1377014083 {
14084
+ Globals.MOUSEDRAGGED = true;
14085
+
1377114086 //System.out.println("mouseDragged: " + e);
1377214087 if (isRenderer)
1377314088 movingcamera = true;
14089
+
1377414090 //if (drawing)
1377514091 //return;
1377614092 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13780,7 +14096,7 @@
1378014096 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1378114097 }
1378214098 else
13783
- drag(e.getX(), e.getY(), e.getModifiersEx());
14099
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1378414100
1378514101 //try { Thread.sleep(1); } catch (Exception ex) {}
1378614102 }
....@@ -14017,7 +14333,7 @@
1401714333 {
1401814334 Globals.lighttouched = true;
1401914335 }
14020
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14336
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1402114337 }
1402214338 //else
1402314339 }
....@@ -14031,12 +14347,12 @@
1403114347 void GoDown(int mod)
1403214348 {
1403314349 MODIFIERS |= COMMAND;
14034
- /*
14350
+ /**/
1403514351 if((mod&SHIFT) == SHIFT)
1403614352 manipCamera.RotatePosition(0, -speed);
1403714353 else
14038
- manipCamera.BackForth(0, -speed*delta, getWidth());
14039
- */
14354
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14355
+ /**/
1404014356 if ((mod & SHIFT) == SHIFT)
1404114357 {
1404214358 mouseMode = mouseMode; // VR??
....@@ -14052,12 +14368,12 @@
1405214368 void GoUp(int mod)
1405314369 {
1405414370 MODIFIERS |= COMMAND;
14055
- /*
14371
+ /**/
1405614372 if((mod&SHIFT) == SHIFT)
1405714373 manipCamera.RotatePosition(0, speed);
1405814374 else
14059
- manipCamera.BackForth(0, speed*delta, getWidth());
14060
- */
14375
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14376
+ /**/
1406114377 if ((mod & SHIFT) == SHIFT)
1406214378 {
1406314379 mouseMode = mouseMode;
....@@ -14073,12 +14389,12 @@
1407314389 void GoLeft(int mod)
1407414390 {
1407514391 MODIFIERS |= COMMAND;
14076
- /*
14392
+ /**/
1407714393 if((mod&SHIFT) == SHIFT)
14078
- manipCamera.RotatePosition(speed, 0);
14079
- else
1408014394 manipCamera.Translate(speed*delta, 0, getWidth());
14081
- */
14395
+ else
14396
+ manipCamera.RotatePosition(speed, 0);
14397
+ /**/
1408214398 if ((mod & SHIFT) == SHIFT)
1408314399 {
1408414400 mouseMode = mouseMode;
....@@ -14094,12 +14410,12 @@
1409414410 void GoRight(int mod)
1409514411 {
1409614412 MODIFIERS |= COMMAND;
14097
- /*
14413
+ /**/
1409814414 if((mod&SHIFT) == SHIFT)
14099
- manipCamera.RotatePosition(-speed, 0);
14100
- else
1410114415 manipCamera.Translate(-speed*delta, 0, getWidth());
14102
- */
14416
+ else
14417
+ manipCamera.RotatePosition(-speed, 0);
14418
+ /**/
1410314419 if ((mod & SHIFT) == SHIFT)
1410414420 {
1410514421 mouseMode = mouseMode;
....@@ -14117,7 +14433,7 @@
1411714433 int X, Y;
1411814434 boolean SX, SY;
1411914435
14120
- void drag(int x, int y, int modifiers)
14436
+ void drag(int x, int y, int modifiers, int modifiersex)
1412114437 {
1412214438 if (IsFrozen())
1412314439 {
....@@ -14126,17 +14442,17 @@
1412614442
1412714443 drag = true; // NEW
1412814444
14129
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14445
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1413014446
1413114447 X = x;
1413214448 Y = y;
1413314449 // floating state for animation
14134
- MODIFIERS = modifiers;
14135
- modifiers &= ~1024;
14450
+ MODIFIERS = modifiersex;
14451
+ modifiersex &= ~1024;
1413614452 if (false) // modifiers != 0)
1413714453 {
1413814454 //new Exception().printStackTrace();
14139
- System.out.println("mouseDragged: " + modifiers);
14455
+ System.out.println("mouseDragged: " + modifiersex);
1414014456 System.out.println("SHIFT = " + SHIFT);
1414114457 System.out.println("CONTROL = " + COMMAND);
1414214458 System.out.println("META = " + META);
....@@ -14156,7 +14472,8 @@
1415614472 info.camera = renderCamera;
1415714473 info.x = x;
1415814474 info.y = y;
14159
- object.editWindow.copy.doEditDrag(info);
14475
+ object.GetWindow().copy
14476
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1416014477 } else
1416114478 {
1416214479 if (x < startX)
....@@ -14320,7 +14637,9 @@
1432014637 ci.camera = renderCamera;
1432114638 if (!isRenderer)
1432214639 {
14323
- if (object.editWindow.copy.doEditClick(ci, 0))
14640
+ //ObjEditor editWindow = object.editWindow;
14641
+ //Object3D copy = editWindow.copy;
14642
+ if (object.doEditClick(ci, 0))
1432414643 {
1432514644 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1432614645 } else
....@@ -14332,7 +14651,11 @@
1433214651
1433314652 public void mouseReleased(MouseEvent e)
1433414653 {
14654
+ Globals.MOUSEDRAGGED = false;
14655
+
1433514656 movingcamera = false;
14657
+ X = 0; // getBounds().width/2;
14658
+ Y = 0; // getBounds().height/2;
1433614659 //System.out.println("mouseReleased: " + e);
1433714660 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433814661 }
....@@ -14355,9 +14678,9 @@
1435514678 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435614679 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435714680
14358
- if (control || command || IsFrozen())
14681
+// No delay if (control || command || IsFrozen())
1435914682 timeout = true;
14360
- else
14683
+// ?? May 2019 else
1436114684 // timer.setDelay((modifiers & 128) != 0?0:350);
1436214685 mouseDown = false;
1436314686 if (!control && !command) // june 2013
....@@ -14467,7 +14790,7 @@
1446714790 System.out.println("keyReleased: " + e);
1446814791 }
1446914792
14470
- void SetMouseMode(int modifiers)
14793
+ void SetMouseMode(int modifiers, int modifiersex)
1447114794 {
1447214795 //System.out.println("SetMouseMode = " + modifiers);
1447314796 //modifiers &= ~1024;
....@@ -14479,25 +14802,25 @@
1447914802 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1448014803 // return;
1448114804 //System.out.println("SetMode = " + modifiers);
14482
- if ((modifiers & WHEEL) == WHEEL)
14805
+ if ((modifiersex & WHEEL) == WHEEL)
1448314806 {
1448414807 mouseMode |= ZOOM;
1448514808 }
1448614809
1448714810 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14488
- if (capsLocked || (modifiers & META) == META)
14811
+ if (capsLocked) // || (modifiers & META) == META)
1448914812 {
1449014813 mouseMode |= VR; // BACKFORTH;
1449114814 }
14492
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14815
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1449314816 {
1449414817 mouseMode |= SELECT;
1449514818 }
14496
- if ((modifiers & COMMAND) == COMMAND)
14819
+ if ((modifiersex & COMMAND) == COMMAND)
1449714820 {
1449814821 mouseMode |= SELECT;
1449914822 }
14500
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14823
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1450114824 {
1450214825 mouseMode &= ~VR;
1450314826 mouseMode |= TRANSLATE;
....@@ -14526,7 +14849,7 @@
1452614849
1452714850 if (isRenderer) //
1452814851 {
14529
- SetMouseMode(modifiers);
14852
+ SetMouseMode(0, modifiers);
1453014853 }
1453114854
1453214855 Globals.theRenderer.keyPressed(key);
....@@ -14673,7 +14996,9 @@
1467314996 case 'E' : COMPACT ^= true;
1467414997 repaint();
1467514998 break;
14676
- case 'W' : DEBUGHSB ^= true;
14999
+ case 'W' : // Wide Window (fullscreen)
15000
+ //DEBUGHSB ^= true;
15001
+ ObjEditor.theFrame.ToggleFullScreen();
1467715002 repaint();
1467815003 break;
1467915004 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14698,8 +15023,8 @@
1469815023 RevertCamera();
1469915024 repaint();
1470015025 break;
14701
- case 'L':
1470215026 case 'l':
15027
+ //case 'L':
1470315028 if (lightMode)
1470415029 {
1470515030 lightMode = false;
....@@ -14842,9 +15167,9 @@
1484215167 case '_':
1484315168 kompactbit = 5;
1484415169 break;
14845
- case '+':
14846
- kompactbit = 6;
14847
- break;
15170
+// case '+':
15171
+// kompactbit = 6;
15172
+// break;
1484815173 case ' ':
1484915174 lightMode ^= true;
1485015175 Globals.lighttouched = true;
....@@ -14856,13 +15181,14 @@
1485615181 case ESC:
1485715182 RENDERPROGRAM += 1;
1485815183 RENDERPROGRAM %= 3;
15184
+
1485915185 repaint();
1486015186 break;
1486115187 case 'Z':
1486215188 //RESIZETEXTURE ^= true;
1486315189 //break;
1486415190 case 'z':
14865
- RENDERSHADOW ^= true;
15191
+ Globals.RENDERSHADOW ^= true;
1486615192 Globals.lighttouched = true;
1486715193 repaint();
1486815194 break;
....@@ -14895,8 +15221,9 @@
1489515221 case DELETE:
1489615222 ClearSelection();
1489715223 break;
14898
- /*
1489915224 case '+':
15225
+
15226
+ /*
1490015227 //fontsize += 1;
1490115228 bbzoom *= 2;
1490215229 repaint();
....@@ -14913,17 +15240,17 @@
1491315240 case '=':
1491415241 IncDepth();
1491515242 //fontsize += 1;
14916
- object.editWindow.refreshContents(true);
15243
+ object.GetWindow().refreshContents(true);
1491715244 maskbit = 6;
1491815245 break;
1491915246 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1492015247 DecDepth();
1492115248 maskbit = 5;
1492215249 //if(fontsize > 1) fontsize -= 1;
14923
- if (object.editWindow == null)
14924
- new Exception().printStackTrace();
14925
- else
14926
- object.editWindow.refreshContents(true);
15250
+// if (object.editWindow == null)
15251
+// new Exception().printStackTrace();
15252
+// else
15253
+ object.GetWindow().refreshContents(true);
1492715254 break;
1492815255 case '{':
1492915256 manipCamera.shaper_fovy /= 1.1;
....@@ -14986,7 +15313,7 @@
1498615313 //mode = ROTATE;
1498715314 if ((MODIFIERS & COMMAND) == 0) // VR??
1498815315 {
14989
- SetMouseMode(modifiers);
15316
+ SetMouseMode(0, modifiers);
1499015317 }
1499115318 }
1499215319
....@@ -15122,7 +15449,7 @@
1512215449 {
1512315450 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1512415451 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15125
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15452
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1512615453 {
1512715454 mouseMoved(e);
1512815455 } else
....@@ -15147,7 +15474,7 @@
1514715474 }
1514815475 */
1514915476
15150
- object.editWindow.EditSelection();
15477
+ object.GetWindow().EditSelection(false);
1515115478 }
1515215479
1515315480 void SelectParent()
....@@ -15164,10 +15491,10 @@
1516415491 {
1516515492 //selectees.remove(i);
1516615493 System.out.println("select parent of " + elem);
15167
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15494
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1516815495 } else
1516915496 {
15170
- group.editWindow.Select(elem.GetTreePath(), first, true);
15497
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1517115498 }
1517215499
1517315500 first = false;
....@@ -15209,12 +15536,12 @@
1520915536 for (int j = 0; j < group.children.size(); j++)
1521015537 {
1521115538 elem = (Object3D) group.children.elementAt(j);
15212
- object.editWindow.Select(elem.GetTreePath(), first, true);
15539
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1521315540 first = false;
1521415541 }
1521515542 } else
1521615543 {
15217
- object.editWindow.Select(elem.GetTreePath(), first, true);
15544
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1521815545 }
1521915546
1522015547 first = false;
....@@ -15225,21 +15552,21 @@
1522515552 {
1522615553 //Composite group = (Composite) object;
1522715554 Object3D group = object;
15228
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15555
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1522915556 }
1523015557
1523115558 void ResetTransform(int mask)
1523215559 {
1523315560 //Composite group = (Composite) object;
1523415561 Object3D group = object;
15235
- group.editWindow.ResetTransform(mask);
15562
+ group.GetWindow().ResetTransform(mask);
1523615563 }
1523715564
1523815565 void FlipTransform()
1523915566 {
1524015567 //Composite group = (Composite) object;
1524115568 Object3D group = object;
15242
- group.editWindow.FlipTransform();
15569
+ group.GetWindow().FlipTransform();
1524315570 // group.editWindow.ReduceMesh(true);
1524415571 }
1524515572
....@@ -15247,7 +15574,7 @@
1524715574 {
1524815575 //Composite group = (Composite) object;
1524915576 Object3D group = object;
15250
- group.editWindow.PrintMemory();
15577
+ group.GetWindow().PrintMemory();
1525115578 // group.editWindow.ReduceMesh(true);
1525215579 }
1525315580
....@@ -15255,7 +15582,7 @@
1525515582 {
1525615583 //Composite group = (Composite) object;
1525715584 Object3D group = object;
15258
- group.editWindow.ResetCentroid();
15585
+ group.GetWindow().ResetCentroid();
1525915586 }
1526015587
1526115588 void IncDepth()
....@@ -15341,7 +15668,9 @@
1534115668 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1534215669 //Image img = CreateImage(width, height);
1534315670 //System.out.println("width = " + width + "; height = " + height + "\n");
15671
+
1534415672 Graphics gr = g; // img.getGraphics();
15673
+
1534515674 if (!hasMarquee)
1534615675 {
1534715676 if (Xmin < Xmax) // !locked)
....@@ -15429,6 +15758,7 @@
1542915758 info.bounds.y += (height - desired) / 2;
1543015759 }
1543115760 }
15761
+
1543215762 info.g = gr;
1543315763 info.camera = renderCamera;
1543415764 /*
....@@ -15438,15 +15768,55 @@
1543815768 */
1543915769 if (!isRenderer)
1544015770 {
15441
- 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
+ }
1544215810 }
1544315811 }
15812
+
1544415813 if (isRenderer)
1544515814 {
1544615815 //gr.setColor(Color.black);
1544715816 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544815817 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544915818 }
15819
+
1545015820 if (hasMarquee)
1545115821 {
1545215822 gr.setXORMode(Color.white);
....@@ -15559,6 +15929,7 @@
1555915929 public boolean mouseDown(Event evt, int x, int y)
1556015930 {
1556115931 System.out.println("mouseDown: " + evt);
15932
+ System.exit(0);
1556215933 /*
1556315934 locked = true;
1556415935 drag = false;
....@@ -15602,7 +15973,7 @@
1560215973 {
1560315974 keyPressed(0, modifiers);
1560415975 }
15605
- clickStart(x, y, modifiers);
15976
+ // clickStart(x, y, modifiers);
1560615977 return true;
1560715978 }
1560815979
....@@ -15720,7 +16091,7 @@
1572016091 {
1572116092 keyReleased(0, 0);
1572216093 }
15723
- drag(x, y, modifiers);
16094
+ drag(x, y, 0, modifiers);
1572416095 return true;
1572516096 }
1572616097
....@@ -15852,7 +16223,7 @@
1585216223 Object3D object;
1585316224 static Object3D trackedobject;
1585416225 Camera renderCamera; // Light or Eye (or Occlusion)
15855
- /*static*/ Camera manipCamera; // Light or Eye
16226
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585616227 /*static*/ Camera eyeCamera;
1585716228 /*static*/ Camera lightCamera;
1585816229 int cameracount;
....@@ -16137,16 +16508,16 @@
1613716508 cStatic.objectstack[materialdepth++] = checker;
1613816509 //System.out.println("material " + material);
1613916510 //Applet3D.tracein(this, selected);
16140
- vector2buffer = checker.projectedVertices;
16511
+ //vector2buffer = checker.projectedVertices;
1614116512
1614216513 //checker.GetMaterial().Draw(this, false); // true);
16143
- DrawMaterial(checker.GetMaterial(), false); // true);
16514
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1614416515
1614516516 materialdepth -= 1;
1614616517 if (materialdepth > 0)
1614716518 {
16148
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16149
- 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);
1615016521 }
1615116522 //checker.GetMaterial().opacity = 1f;
1615216523 ////checker.GetMaterial().ambient = 1f;
....@@ -16232,6 +16603,14 @@
1623216603 }
1623316604 }
1623416605
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
+
1623516614 class SelectBuffer implements GLEventListener
1623616615 {
1623716616
....@@ -16311,6 +16690,17 @@
1631116690
1631216691 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1631316692
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
+
1631416704 //int tmp = selection_view;
1631516705 //selection_view = -1;
1631616706 int temp = DrawMode();
....@@ -16322,6 +16712,17 @@
1632216712 // temp = DEFAULT; // patch for selection debug
1632316713 Globals.drawMode = temp; // WARNING
1632416714
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
+
1632516726 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1632616727
1632716728 // trying different ways of getting the depth info over
....@@ -16369,6 +16770,8 @@
1636916770 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1637016771 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1637116772 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16773
+
16774
+ CreateSelectedPoint();
1637216775
1637316776 // Will fit the mesh !!!
1637416777 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16418,34 +16821,36 @@
1641816821 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]));
1641916822 }
1642016823
16421
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16824
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1642216825 }
1642316826 }
1642416827
1642516828 if (!movingcamera && !PAINTMODE)
16426
- object.editWindow.ScreenFitPoint(); // fev 2014
16829
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1642716830
16428
- 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)
1642916832 {
16430
- 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);
1643116834
16432
- Object3D group = new Object3D("inst" + paintcount++);
16835
+ if (object.GetWindow().copy.selection.Size() > 0)
16836
+ {
16837
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1643316838
16434
- group.CreateMaterial(); // use a void leaf to select instances
16435
-
16436
- group.add(paintobj); // link
16437
-
16438
- object.editWindow.SnapObject(group);
16439
-
16440
- Object3D folder = object.editWindow.copy;
16441
-
16442
- if (object.editWindow.copy.selection.Size() > 0)
16443
- folder = object.editWindow.copy.selection.elementAt(0);
16444
-
16445
- folder.add(group);
16446
-
16447
- object.editWindow.ResetModel();
16448
- 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
+ }
1644916854 }
1645016855 else
1645116856 paintcount = 0;
....@@ -16484,6 +16889,11 @@
1648416889 //System.out.println("objects[color] = " + objects[color]);
1648516890 //objects[color].Select();
1648616891 indexcount = 0;
16892
+ ObjEditor window = object.GetWindow();
16893
+ if (window != null && deselect)
16894
+ {
16895
+ window.Select(null, deselect, true);
16896
+ }
1648716897 object.Select(color, deselect);
1648816898 }
1648916899
....@@ -16583,7 +16993,7 @@
1658316993 gl.glDisable(gl.GL_CULL_FACE);
1658416994 }
1658516995
16586
- if (!RENDERSHADOW)
16996
+ if (!Globals.RENDERSHADOW)
1658716997 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658816998
1658916999 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16593,7 +17003,7 @@
1659317003 //gl.glColorMask(false, false, false, false);
1659417004
1659517005 //render_scene_from_light_view(gl, drawable, 0, 0);
16596
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17006
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659717007 {
1659817008 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659917009
....@@ -17009,23 +17419,15 @@
1700917419 int AAbuffersize = 0;
1701017420
1701117421 //double[] selectedpoint = new double[3];
17012
- static Superellipsoid selectedpoint = new Superellipsoid();
17422
+ static Superellipsoid selectedpoint;
1701317423 static Sphere previousselectedpoint = null;
17014
- static Sphere debugpointG = new Sphere();
17015
- static Sphere debugpointP = new Sphere();
17016
- static Sphere debugpointC = new Sphere();
17017
- static Sphere debugpointR = new Sphere();
17424
+ static Sphere debugpointG;
17425
+ static Sphere debugpointP;
17426
+ static Sphere debugpointC;
17427
+ static Sphere debugpointR;
1701817428
1701917429 static Sphere debugpoints[] = new Sphere[8];
1702017430
17021
- static
17022
- {
17023
- for (int i=0; i<8; i++)
17024
- {
17025
- debugpoints[i] = new Sphere();
17026
- }
17027
- }
17028
-
1702917431 static void InitPoints(float radius)
1703017432 {
1703117433 for (int i=0; i<8; i++)