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;
....@@ -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();
....@@ -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
....@@ -2257,7 +2280,7 @@
22572280
22582281 void ToggleDebug()
22592282 {
2260
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22612284 }
22622285
22632286 void ToggleLookAt()
....@@ -2265,7 +2288,7 @@
22652288 LOOKAT ^= true;
22662289 }
22672290
2268
- void ToggleRandom()
2291
+ void ToggleSwitch()
22692292 {
22702293 SWITCH ^= true;
22712294 }
....@@ -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)
....@@ -8024,6 +8142,54 @@
80248142
80258143 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80268144 {
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
8192
+ {
80278193 if (// DrawMode() != 0 || /*tex == null ||*/
80288194 ambientOcclusion ) // || !textureon)
80298195 {
....@@ -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,46 +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) throws Exception
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
8286
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8287
+
80788288 // String[] split = tex.split("Textures");
80798289 // if (split.length > 1)
80808290 // texname = "/Users/nbriere/Textures" + split[split.length-1];
80818291 // else
80828292 // if (!texname.startsWith("/"))
80838293 // texname = "/Users/nbriere/Textures/" + texname;
8084
- if (!new File(tex).exists())
8294
+ if (!FileExists(tex))
80858295 {
8086
- texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname;
8296
+ texname = fallbackTextureName;
80878297 }
80888298
80898299 if (CACHETEXTURE)
8090
- texture = textures.get(texname); // TEXTURE CACHE
8091
-
8092
- TextureData texturedata = null;
8093
-
8094
- if (texture == null || texture.resolution < resolution)
80958300 {
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
80968316 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
80978317 {
80988318 assert(!bump);
....@@ -8104,19 +8324,19 @@
81048324 // }
81058325 // else
81068326 // {
8107
- texture = textures.get(tex);
8108
- if (texture == null)
8327
+ texturecache = textures.get(tex);
8328
+ if (texturecache == null)
81098329 {
8110
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8330
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81118331 }
81128332 // }
81138333 } else
81148334 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81158335 {
81168336 assert(bump);
8117
- texture = textures.get(tex);
8118
- if (texture == null)
8119
- 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);
81208340 } else
81218341 {
81228342 //if (tex.equals("IMMORTAL"))
....@@ -8126,9 +8346,9 @@
81268346 //{
81278347 if (tex.equals("WHITE_NOISE"))
81288348 {
8129
- texture = textures.get(tex);
8130
- if (texture == null)
8131
- 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);
81328352 } else
81338353 {
81348354 if (textureon)
....@@ -8153,7 +8373,7 @@
81538373 }
81548374
81558375 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8156
- if (!new File(cachename).exists())
8376
+ if (!FileExists(cachename))
81578377 cachename = texname;
81588378 else
81598379 processbump = false; // don't process bump map again
....@@ -8175,7 +8395,7 @@
81758395 }
81768396
81778397 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8178
- if (!new File(cachename).exists())
8398
+ if (!FileExists(cachename))
81798399 cachename = texname;
81808400 else
81818401 processbump = false; // don't process bump map again
....@@ -8187,19 +8407,19 @@
81878407 if (texturedata == null)
81888408 throw new Exception();
81898409
8190
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8410
+ texturecache = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81918411 //texture = GetTexture(tex, bump);
81928412 }
81938413 }
81948414 //}
81958415 }
81968416
8197
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8417
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
81988418 {
81998419 //return false;
82008420
82018421 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8202
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8422
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
82038423 {
82048424 // String ext = "_highres";
82058425 // if (REDUCETEXTURE)
....@@ -8288,8 +8508,8 @@
82888508 textures.remove(texname);
82898509 }
82908510
8291
- texture.texturedata = texturedata;
8292
- textures.put(texname, texture);
8511
+ //texture.texturedata = texturedata;
8512
+ textures.put(texname, texturecache);
82938513
82948514 // newtex = true;
82958515 }
....@@ -8305,12 +8525,12 @@
83058525 }
83068526 }
83078527
8308
- return texture;
8528
+ return texturecache;
83098529 }
83108530
8311
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
8531
+ com.sun.opengl.util.texture.Texture GetTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83128532 {
8313
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8533
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83148534
83158535 if (bump)
83168536 {
....@@ -8326,23 +8546,23 @@
83268546 return texture!=null?texture.texture:null;
83278547 }
83288548
8329
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
8549
+ public com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83308550 {
8331
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8551
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83328552
83338553 return texture!=null?texture.texturedata:null;
83348554 }
83358555
8336
- boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
8556
+ boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83378557 {
83388558 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83398559 {
83408560 return false;
83418561 }
83428562
8343
- boolean newtex = false;
8563
+ //boolean newtex = false;
83448564
8345
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8565
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
83468566
83478567 if (texture == null)
83488568 return false;
....@@ -8372,7 +8592,7 @@
83728592 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83738593 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83748594
8375
- return newtex;
8595
+ return true; // Warning: not used.
83768596 }
83778597
83788598 ShadowBuffer shadowPBuf;
....@@ -9210,11 +9430,35 @@
92109430 jy8[3] = 0.5f;
92119431 }
92129432
9213
- 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
92149434 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92159435 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92169436 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92179437
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
+
92189462 static int imagecount = 0; // movie generation
92199463
92209464 static int jitter = 0;
....@@ -9310,8 +9554,8 @@
93109554 assert (parentcam != renderCamera);
93119555
93129556 if (renderCamera != lightCamera)
9313
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9314
- LA.matConcat(matrix, parentcam.toParent, matrix);
9557
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9558
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93159559
93169560 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93179561
....@@ -9326,8 +9570,8 @@
93269570 LA.matCopy(renderCamera.fromScreen, matrix);
93279571
93289572 if (renderCamera != lightCamera)
9329
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9330
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9573
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9574
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93319575
93329576 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93339577
....@@ -10325,6 +10569,7 @@
1032510569 ANTIALIAS = 0;
1032610570 //System.out.println("RESTART");
1032710571 AAtimer.restart();
10572
+ Globals.TIMERRUNNING = true;
1032810573 }
1032910574 }
1033010575 }
....@@ -10392,13 +10637,14 @@
1039210637 ambientOcclusion = false;
1039310638 }
1039410639
10395
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10640
+ if (//Globals.lighttouched &&
10641
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039610642 {
1039710643 //if (RENDERSHADOW) // ?
1039810644 if (!IsFrozen())
1039910645 {
1040010646 // dec 2012
10401
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10647
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1040210648 {
1040310649 Globals.framecount++;
1040410650 shadowbuffer.display();
....@@ -10525,8 +10771,8 @@
1052510771
1052610772 // if (parentcam != renderCamera) // not a light
1052710773 if (cam != lightCamera)
10528
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10529
- LA.matConcat(matrix, parentcam.toParent, matrix);
10774
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10775
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1053010776
1053110777 for (int j = 0; j < 4; j++)
1053210778 {
....@@ -10540,8 +10786,8 @@
1054010786
1054110787 // if (parentcam != renderCamera) // not a light
1054210788 if (cam != lightCamera)
10543
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10544
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10789
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10790
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054510791
1054610792 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054710793
....@@ -10803,7 +11049,7 @@
1080311049
1080411050 try
1080511051 {
10806
- BindTexture(NOISE_TEXTURE, false, 2);
11052
+ BindTexture(null, NOISE_TEXTURE, false, 2);
1080711053 }
1080811054 catch (Exception e)
1080911055 {
....@@ -10832,9 +11078,9 @@
1083211078
1083311079 gl.glMatrixMode(GL.GL_MODELVIEW);
1083411080
10835
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10836
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10837
-//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);
1083811084 } else
1083911085 {
1084011086 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10845,7 +11091,7 @@
1084511091 //System.out.println("BLENDING ON");
1084611092 gl.glEnable(GL.GL_BLEND);
1084711093 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10848
-
11094
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1084911095 gl.glMatrixMode(gl.GL_PROJECTION);
1085011096 gl.glLoadIdentity();
1085111097
....@@ -10934,8 +11180,8 @@
1093411180 System.err.println("parentcam != renderCamera");
1093511181
1093611182 // if (cam != lightCamera)
10937
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10938
- 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
1093911185 }
1094011186
1094111187 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10956,8 +11202,8 @@
1095611202 if (true) // TODO
1095711203 {
1095811204 if (cam != lightCamera)
10959
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10960
- 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
1096111207 }
1096211208
1096311209 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11302,15 +11548,36 @@
1130211548
1130311549 static boolean zoomonce = false;
1130411550
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
+
1130511569 void DrawObject(GL gl, boolean draw)
1130611570 {
11571
+ // To clear camera values
11572
+ ResetOptions();
11573
+
1130711574 //System.out.println("DRAW OBJECT " + mouseDown);
1130811575 // DrawMode() = SELECTION;
1130911576 //GL gl = getGL();
1131011577 if ((TRACK || SHADOWTRACK) || zoomonce)
1131111578 {
1131211579 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11313
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11580
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1131411581 pingthread.StepToTarget(true); // true);
1131511582 // zoomonce = false;
1131611583 }
....@@ -11382,8 +11649,9 @@
1138211649
1138311650 if (DrawMode() == DEFAULT)
1138411651 {
11385
- if (DEBUG)
11652
+ if (Globals.DEBUG)
1138611653 {
11654
+ CreateSelectedPoint();
1138711655 float radius = 0.05f;
1138811656 if (selectedpoint.radius != radius)
1138911657 {
....@@ -11446,7 +11714,7 @@
1144611714 if (tex.equals("WHITE_NOISE"))
1144711715 continue;
1144811716
11449
- if (!usedtextures.containsKey(tex))
11717
+ if (!usedtextures.contains(tex))
1145011718 {
1145111719 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1145211720 textures.get(tex).texture.dispose();
....@@ -11552,7 +11820,7 @@
1155211820 return;
1155311821 }
1155411822
11555
- String string = obj.GetToolTip();
11823
+ String string = obj.toString(); //.GetToolTip();
1155611824
1155711825 GL gl = GetGL();
1155811826
....@@ -11869,8 +12137,8 @@
1186912137 //obj.TransformToWorld(light, light);
1187012138 for (int i = tp.size(); --i >= 0;)
1187112139 {
11872
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11873
- 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);
1187412142 }
1187512143
1187612144
....@@ -11887,8 +12155,8 @@
1188712155 parentcam = cameras[0];
1188812156 }
1188912157
11890
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11891
- 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
1189212160
1189312161 LA.xformPos(light, renderCamera.toScreen, light);
1189412162
....@@ -13140,7 +13408,8 @@
1314013408 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1314113409 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1314213410 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13143
- Object3D.cVector2[] vector2buffer;
13411
+
13412
+ //Object3D.cVector2[] vector2buffer;
1314413413
1314513414 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1314613415 // OUT : diff, spec
....@@ -13156,9 +13425,10 @@
1315613425 "DP3 " + dest + ".z," + "normals," + "eye;" +
1315713426 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1315813427 //"MOV " + dest + ".w," + "normal.z;" +
13159
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13160
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13161
- //"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
1316213432 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1316313433 "RCP " + dest + ".w," + dest + ".w;" +
1316413434 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13663,6 +13933,7 @@
1366313933 else
1366413934 if (evt.getSource() == AAtimer)
1366513935 {
13936
+ Globals.TIMERRUNNING = false;
1366613937 if (mouseDown)
1366713938 {
1366813939 //new Exception().printStackTrace();
....@@ -13722,7 +13993,7 @@
1372213993
1372313994 // fev 2014???
1372413995 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13725
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13996
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1372613997 pingthread.StepToTarget(true); // true);
1372713998 }
1372813999 // if (!LIVE)
....@@ -13737,6 +14008,7 @@
1373714008 return;
1373814009
1373914010 AAtimer.restart(); //
14011
+ Globals.TIMERRUNNING = true;
1374014012
1374114013 // waslive = LIVE;
1374214014 // LIVE = false;
....@@ -13809,9 +14081,12 @@
1380914081
1381014082 public void mouseDragged(MouseEvent e)
1381114083 {
14084
+ Globals.MOUSEDRAGGED = true;
14085
+
1381214086 //System.out.println("mouseDragged: " + e);
1381314087 if (isRenderer)
1381414088 movingcamera = true;
14089
+
1381514090 //if (drawing)
1381614091 //return;
1381714092 if ((e.getModifiersEx() & CTRL) != 0
....@@ -14072,12 +14347,12 @@
1407214347 void GoDown(int mod)
1407314348 {
1407414349 MODIFIERS |= COMMAND;
14075
- /*
14350
+ /**/
1407614351 if((mod&SHIFT) == SHIFT)
1407714352 manipCamera.RotatePosition(0, -speed);
1407814353 else
14079
- manipCamera.BackForth(0, -speed*delta, getWidth());
14080
- */
14354
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14355
+ /**/
1408114356 if ((mod & SHIFT) == SHIFT)
1408214357 {
1408314358 mouseMode = mouseMode; // VR??
....@@ -14093,12 +14368,12 @@
1409314368 void GoUp(int mod)
1409414369 {
1409514370 MODIFIERS |= COMMAND;
14096
- /*
14371
+ /**/
1409714372 if((mod&SHIFT) == SHIFT)
1409814373 manipCamera.RotatePosition(0, speed);
1409914374 else
14100
- manipCamera.BackForth(0, speed*delta, getWidth());
14101
- */
14375
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14376
+ /**/
1410214377 if ((mod & SHIFT) == SHIFT)
1410314378 {
1410414379 mouseMode = mouseMode;
....@@ -14114,12 +14389,12 @@
1411414389 void GoLeft(int mod)
1411514390 {
1411614391 MODIFIERS |= COMMAND;
14117
- /*
14392
+ /**/
1411814393 if((mod&SHIFT) == SHIFT)
14119
- manipCamera.RotatePosition(speed, 0);
14120
- else
1412114394 manipCamera.Translate(speed*delta, 0, getWidth());
14122
- */
14395
+ else
14396
+ manipCamera.RotatePosition(speed, 0);
14397
+ /**/
1412314398 if ((mod & SHIFT) == SHIFT)
1412414399 {
1412514400 mouseMode = mouseMode;
....@@ -14135,12 +14410,12 @@
1413514410 void GoRight(int mod)
1413614411 {
1413714412 MODIFIERS |= COMMAND;
14138
- /*
14413
+ /**/
1413914414 if((mod&SHIFT) == SHIFT)
14140
- manipCamera.RotatePosition(-speed, 0);
14141
- else
1414214415 manipCamera.Translate(-speed*delta, 0, getWidth());
14143
- */
14416
+ else
14417
+ manipCamera.RotatePosition(-speed, 0);
14418
+ /**/
1414414419 if ((mod & SHIFT) == SHIFT)
1414514420 {
1414614421 mouseMode = mouseMode;
....@@ -14197,7 +14472,8 @@
1419714472 info.camera = renderCamera;
1419814473 info.x = x;
1419914474 info.y = y;
14200
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14475
+ object.GetWindow().copy
14476
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1420114477 } else
1420214478 {
1420314479 if (x < startX)
....@@ -14361,7 +14637,9 @@
1436114637 ci.camera = renderCamera;
1436214638 if (!isRenderer)
1436314639 {
14364
- if (object.editWindow.copy.doEditClick(ci, 0))
14640
+ //ObjEditor editWindow = object.editWindow;
14641
+ //Object3D copy = editWindow.copy;
14642
+ if (object.doEditClick(ci, 0))
1436514643 {
1436614644 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1436714645 } else
....@@ -14373,7 +14651,11 @@
1437314651
1437414652 public void mouseReleased(MouseEvent e)
1437514653 {
14654
+ Globals.MOUSEDRAGGED = false;
14655
+
1437614656 movingcamera = false;
14657
+ X = 0; // getBounds().width/2;
14658
+ Y = 0; // getBounds().height/2;
1437714659 //System.out.println("mouseReleased: " + e);
1437814660 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1437914661 }
....@@ -14714,7 +14996,9 @@
1471414996 case 'E' : COMPACT ^= true;
1471514997 repaint();
1471614998 break;
14717
- case 'W' : DEBUGHSB ^= true;
14999
+ case 'W' : // Wide Window (fullscreen)
15000
+ //DEBUGHSB ^= true;
15001
+ ObjEditor.theFrame.ToggleFullScreen();
1471815002 repaint();
1471915003 break;
1472015004 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14739,8 +15023,8 @@
1473915023 RevertCamera();
1474015024 repaint();
1474115025 break;
14742
- case 'L':
1474315026 case 'l':
15027
+ //case 'L':
1474415028 if (lightMode)
1474515029 {
1474615030 lightMode = false;
....@@ -14883,9 +15167,9 @@
1488315167 case '_':
1488415168 kompactbit = 5;
1488515169 break;
14886
- case '+':
14887
- kompactbit = 6;
14888
- break;
15170
+// case '+':
15171
+// kompactbit = 6;
15172
+// break;
1488915173 case ' ':
1489015174 lightMode ^= true;
1489115175 Globals.lighttouched = true;
....@@ -14897,6 +15181,7 @@
1489715181 case ESC:
1489815182 RENDERPROGRAM += 1;
1489915183 RENDERPROGRAM %= 3;
15184
+
1490015185 repaint();
1490115186 break;
1490215187 case 'Z':
....@@ -14936,8 +15221,9 @@
1493615221 case DELETE:
1493715222 ClearSelection();
1493815223 break;
14939
- /*
1494015224 case '+':
15225
+
15226
+ /*
1494115227 //fontsize += 1;
1494215228 bbzoom *= 2;
1494315229 repaint();
....@@ -14954,17 +15240,17 @@
1495415240 case '=':
1495515241 IncDepth();
1495615242 //fontsize += 1;
14957
- object.editWindow.refreshContents(true);
15243
+ object.GetWindow().refreshContents(true);
1495815244 maskbit = 6;
1495915245 break;
1496015246 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1496115247 DecDepth();
1496215248 maskbit = 5;
1496315249 //if(fontsize > 1) fontsize -= 1;
14964
- if (object.editWindow == null)
14965
- new Exception().printStackTrace();
14966
- else
14967
- object.editWindow.refreshContents(true);
15250
+// if (object.editWindow == null)
15251
+// new Exception().printStackTrace();
15252
+// else
15253
+ object.GetWindow().refreshContents(true);
1496815254 break;
1496915255 case '{':
1497015256 manipCamera.shaper_fovy /= 1.1;
....@@ -15188,7 +15474,7 @@
1518815474 }
1518915475 */
1519015476
15191
- object.editWindow.EditSelection();
15477
+ object.GetWindow().EditSelection(false);
1519215478 }
1519315479
1519415480 void SelectParent()
....@@ -15205,10 +15491,10 @@
1520515491 {
1520615492 //selectees.remove(i);
1520715493 System.out.println("select parent of " + elem);
15208
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15494
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1520915495 } else
1521015496 {
15211
- group.editWindow.Select(elem.GetTreePath(), first, true);
15497
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1521215498 }
1521315499
1521415500 first = false;
....@@ -15250,12 +15536,12 @@
1525015536 for (int j = 0; j < group.children.size(); j++)
1525115537 {
1525215538 elem = (Object3D) group.children.elementAt(j);
15253
- object.editWindow.Select(elem.GetTreePath(), first, true);
15539
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1525415540 first = false;
1525515541 }
1525615542 } else
1525715543 {
15258
- object.editWindow.Select(elem.GetTreePath(), first, true);
15544
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1525915545 }
1526015546
1526115547 first = false;
....@@ -15266,21 +15552,21 @@
1526615552 {
1526715553 //Composite group = (Composite) object;
1526815554 Object3D group = object;
15269
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15555
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1527015556 }
1527115557
1527215558 void ResetTransform(int mask)
1527315559 {
1527415560 //Composite group = (Composite) object;
1527515561 Object3D group = object;
15276
- group.editWindow.ResetTransform(mask);
15562
+ group.GetWindow().ResetTransform(mask);
1527715563 }
1527815564
1527915565 void FlipTransform()
1528015566 {
1528115567 //Composite group = (Composite) object;
1528215568 Object3D group = object;
15283
- group.editWindow.FlipTransform();
15569
+ group.GetWindow().FlipTransform();
1528415570 // group.editWindow.ReduceMesh(true);
1528515571 }
1528615572
....@@ -15288,7 +15574,7 @@
1528815574 {
1528915575 //Composite group = (Composite) object;
1529015576 Object3D group = object;
15291
- group.editWindow.PrintMemory();
15577
+ group.GetWindow().PrintMemory();
1529215578 // group.editWindow.ReduceMesh(true);
1529315579 }
1529415580
....@@ -15296,7 +15582,7 @@
1529615582 {
1529715583 //Composite group = (Composite) object;
1529815584 Object3D group = object;
15299
- group.editWindow.ResetCentroid();
15585
+ group.GetWindow().ResetCentroid();
1530015586 }
1530115587
1530215588 void IncDepth()
....@@ -15382,7 +15668,9 @@
1538215668 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1538315669 //Image img = CreateImage(width, height);
1538415670 //System.out.println("width = " + width + "; height = " + height + "\n");
15671
+
1538515672 Graphics gr = g; // img.getGraphics();
15673
+
1538615674 if (!hasMarquee)
1538715675 {
1538815676 if (Xmin < Xmax) // !locked)
....@@ -15470,6 +15758,7 @@
1547015758 info.bounds.y += (height - desired) / 2;
1547115759 }
1547215760 }
15761
+
1547315762 info.g = gr;
1547415763 info.camera = renderCamera;
1547515764 /*
....@@ -15479,15 +15768,55 @@
1547915768 */
1548015769 if (!isRenderer)
1548115770 {
15482
- 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
+ }
1548315810 }
1548415811 }
15812
+
1548515813 if (isRenderer)
1548615814 {
1548715815 //gr.setColor(Color.black);
1548815816 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1548915817 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1549015818 }
15819
+
1549115820 if (hasMarquee)
1549215821 {
1549315822 gr.setXORMode(Color.white);
....@@ -15894,7 +16223,7 @@
1589416223 Object3D object;
1589516224 static Object3D trackedobject;
1589616225 Camera renderCamera; // Light or Eye (or Occlusion)
15897
- /*static*/ Camera manipCamera; // Light or Eye
16226
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1589816227 /*static*/ Camera eyeCamera;
1589916228 /*static*/ Camera lightCamera;
1590016229 int cameracount;
....@@ -16179,16 +16508,16 @@
1617916508 cStatic.objectstack[materialdepth++] = checker;
1618016509 //System.out.println("material " + material);
1618116510 //Applet3D.tracein(this, selected);
16182
- vector2buffer = checker.projectedVertices;
16511
+ //vector2buffer = checker.projectedVertices;
1618316512
1618416513 //checker.GetMaterial().Draw(this, false); // true);
16185
- DrawMaterial(checker.GetMaterial(), false); // true);
16514
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1618616515
1618716516 materialdepth -= 1;
1618816517 if (materialdepth > 0)
1618916518 {
16190
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16191
- 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);
1619216521 }
1619316522 //checker.GetMaterial().opacity = 1f;
1619416523 ////checker.GetMaterial().ambient = 1f;
....@@ -16274,6 +16603,14 @@
1627416603 }
1627516604 }
1627616605
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
+
1627716614 class SelectBuffer implements GLEventListener
1627816615 {
1627916616
....@@ -16353,6 +16690,17 @@
1635316690
1635416691 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1635516692
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
+
1635616704 //int tmp = selection_view;
1635716705 //selection_view = -1;
1635816706 int temp = DrawMode();
....@@ -16364,6 +16712,17 @@
1636416712 // temp = DEFAULT; // patch for selection debug
1636516713 Globals.drawMode = temp; // WARNING
1636616714
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
+
1636716726 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1636816727
1636916728 // trying different ways of getting the depth info over
....@@ -16411,6 +16770,8 @@
1641116770 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1641216771 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1641316772 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16773
+
16774
+ CreateSelectedPoint();
1641416775
1641516776 // Will fit the mesh !!!
1641616777 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16465,29 +16826,31 @@
1646516826 }
1646616827
1646716828 if (!movingcamera && !PAINTMODE)
16468
- object.editWindow.ScreenFitPoint(); // fev 2014
16829
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1646916830
16470
- 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)
1647116832 {
16472
- 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);
1647316834
16474
- Object3D group = new Object3D("inst" + paintcount++);
16835
+ if (object.GetWindow().copy.selection.Size() > 0)
16836
+ {
16837
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1647516838
16476
- group.CreateMaterial(); // use a void leaf to select instances
16477
-
16478
- group.add(paintobj); // link
16479
-
16480
- object.editWindow.SnapObject(group);
16481
-
16482
- Object3D folder = object.editWindow.copy;
16483
-
16484
- if (object.editWindow.copy.selection.Size() > 0)
16485
- folder = object.editWindow.copy.selection.elementAt(0);
16486
-
16487
- folder.add(group);
16488
-
16489
- object.editWindow.ResetModel();
16490
- 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
+ }
1649116854 }
1649216855 else
1649316856 paintcount = 0;
....@@ -16526,6 +16889,11 @@
1652616889 //System.out.println("objects[color] = " + objects[color]);
1652716890 //objects[color].Select();
1652816891 indexcount = 0;
16892
+ ObjEditor window = object.GetWindow();
16893
+ if (window != null && deselect)
16894
+ {
16895
+ window.Select(null, deselect, true);
16896
+ }
1652916897 object.Select(color, deselect);
1653016898 }
1653116899
....@@ -17051,23 +17419,15 @@
1705117419 int AAbuffersize = 0;
1705217420
1705317421 //double[] selectedpoint = new double[3];
17054
- static Superellipsoid selectedpoint = new Superellipsoid();
17422
+ static Superellipsoid selectedpoint;
1705517423 static Sphere previousselectedpoint = null;
17056
- static Sphere debugpointG = new Sphere();
17057
- static Sphere debugpointP = new Sphere();
17058
- static Sphere debugpointC = new Sphere();
17059
- static Sphere debugpointR = new Sphere();
17424
+ static Sphere debugpointG;
17425
+ static Sphere debugpointP;
17426
+ static Sphere debugpointC;
17427
+ static Sphere debugpointR;
1706017428
1706117429 static Sphere debugpoints[] = new Sphere[8];
1706217430
17063
- static
17064
- {
17065
- for (int i=0; i<8; i++)
17066
- {
17067
- debugpoints[i] = new Sphere();
17068
- }
17069
- }
17070
-
1707117431 static void InitPoints(float radius)
1707217432 {
1707317433 for (int i=0; i<8; i++)