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;
....@@ -327,7 +326,7 @@
327326 cStatic.objectstack[materialdepth++] = obj;
328327 //System.out.println("material " + material);
329328 //Applet3D.tracein(this, selected);
330
- display.vector2buffer = obj.projectedVertices;
329
+ //display.vector2buffer = obj.projectedVertices;
331330 if (obj instanceof Camera)
332331 {
333332 display.options1[0] = material.shift;
....@@ -336,14 +335,28 @@
336335 display.options1[2] = material.shadowbias;
337336 display.options1[3] = material.aniso;
338337 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]);
339343 display.options2[0] = material.opacity;
340344 display.options2[1] = material.diffuse;
341345 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]);
342349
343350 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]);
344354 display.options4[0] = material.cameralight/0.2f;
345355 display.options4[1] = material.subsurface;
346356 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]);
347360
348361 // if (display.CURRENTANTIALIAS > 0)
349362 // display.options3[3] /= 4;
....@@ -359,7 +372,7 @@
359372 /**/
360373 } else
361374 {
362
- DrawMaterial(material, selected);
375
+ DrawMaterial(material, selected, obj.projectedVertices);
363376 }
364377 } else
365378 {
....@@ -383,8 +396,8 @@
383396 cStatic.objectstack[materialdepth++] = obj;
384397 //System.out.println("material " + material);
385398 //Applet3D.tracein("selected ", selected);
386
- display.vector2buffer = obj.projectedVertices;
387
- display.DrawMaterial(material, selected);
399
+ //display.vector2buffer = obj.projectedVertices;
400
+ display.DrawMaterial(material, selected, obj.projectedVertices);
388401 }
389402 }
390403
....@@ -401,8 +414,8 @@
401414 materialdepth -= 1;
402415 if (materialdepth > 0)
403416 {
404
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
405
- 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);
406419 }
407420 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
408421 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -422,8 +435,8 @@
422435 materialdepth -= 1;
423436 if (materialdepth > 0)
424437 {
425
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
426
- 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);
427440 }
428441 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
429442 //else
....@@ -464,10 +477,12 @@
464477 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
465478 {
466479 //gl.glBegin(gl.GL_TRIANGLES);
467
- 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
+ ;
468483 if (!hasnorm)
469484 {
470
- // System.out.println("FUCK!!");
485
+ // System.out.println("Mesh normal");
471486 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
472487 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
473488 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1192,10 +1207,12 @@
11921207 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11931208 }
11941209 }
1210
+
11951211 if (flipV)
11961212 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11971213 else
11981214 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1215
+
11991216 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12001217 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12011218
....@@ -1215,10 +1232,12 @@
12151232 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12161233 }
12171234 }
1235
+
12181236 if (flipV)
12191237 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12201238 else
12211239 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1240
+
12221241 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12231242 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12241243
....@@ -1246,8 +1265,10 @@
12461265 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12471266 else
12481267 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1268
+
12491269 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12501270 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1271
+
12511272 count2 += 2;
12521273 count3 += 3;
12531274 }
....@@ -1603,7 +1624,7 @@
16031624 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16041625 }
16051626
1606
- void DrawMaterial(cMaterial material, boolean selected)
1627
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16071628 {
16081629 CameraPane display = this;
16091630 //new Exception().printStackTrace();
....@@ -1638,7 +1659,7 @@
16381659 colorV[0] = display.modelParams0[0] * material.diffuse;
16391660 colorV[1] = display.modelParams0[1] * material.diffuse;
16401661 colorV[2] = display.modelParams0[2] * material.diffuse;
1641
- colorV[3] = material.opacity;
1662
+ colorV[3] = 1; // material.opacity;
16421663
16431664 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16441665 //System.out.println("Opacity = " + opacity);
....@@ -1746,9 +1767,9 @@
17461767 display.modelParams7[2] = 0;
17471768 display.modelParams7[3] = 0;
17481769
1749
- display.modelParams6[0] = 100; // criss de bug de bump
1770
+ //display.modelParams6[0] = 100; // criss de bug de bump
17501771
1751
- Object3D.cVector2[] extparams = display.vector2buffer;
1772
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17521773 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17531774 {
17541775 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -2044,7 +2065,7 @@
20442065 //System.err.println("Oeil on");
20452066 OEIL = true;
20462067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2047
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20482069 //pingthread.StepToTarget(true);
20492070 }
20502071
....@@ -2259,7 +2280,7 @@
22592280
22602281 void ToggleDebug()
22612282 {
2262
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22632284 }
22642285
22652286 void ToggleLookAt()
....@@ -2277,10 +2298,17 @@
22772298 HANDLES ^= true;
22782299 }
22792300
2301
+ Object3D paintFolder;
2302
+
22802303 void TogglePaint()
22812304 {
22822305 PAINTMODE ^= true;
22832306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
22842312 }
22852313
22862314 void SwapCamera(int a, int b)
....@@ -2394,9 +2422,10 @@
23942422 /**/
23952423
23962424 // TEXTURE static Texture texture;
2397
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2398
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2399
- 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
+
24002429 int pigmentdepth = 0;
24012430 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24022431 int bumpdepth = 0;
....@@ -2418,6 +2447,33 @@
24182447 true,
24192448 com.sun.opengl.util.texture.TextureIO.PNG);
24202449 } 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)
24212477 {
24222478 throw new javax.media.opengl.GLException(e);
24232479 }
....@@ -3504,6 +3560,8 @@
35043560
35053561 System.out.println("LOADING TEXTURE : " + name);
35063562
3563
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3564
+
35073565 //
35083566 if (false) // compressbit > 0)
35093567 {
....@@ -7902,7 +7960,7 @@
79027960 String pigment = Object3D.GetPigment(tex);
79037961 String bump = Object3D.GetBump(tex);
79047962
7905
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7963
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79067964 {
79077965 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79087966 // System.out.println("; bump = " + bump);
....@@ -7919,6 +7977,64 @@
79197977
79207978 ReleaseTexture(bump, true);
79217979 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);
79228038 }
79238039
79248040 void ReleaseTexture(String tex, boolean bump)
....@@ -8026,6 +8142,54 @@
80268142
80278143 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80288144 {
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
+ {
80298193 if (// DrawMode() != 0 || /*tex == null ||*/
80308194 ambientOcclusion ) // || !textureon)
80318195 {
....@@ -8034,18 +8198,48 @@
80348198
80358199 if (tex == null)
80368200 {
8037
- BindTexture(null,false,resolution);
8038
- BindTexture(null,true,resolution);
8201
+ BindTexture(null, null,false,resolution);
80398202 return;
80408203 }
80418204
80428205 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
+
80438238 String bump = Object3D.GetBump(tex);
80448239
8045
- usedtextures.put(pigment, pigment);
8046
- usedtextures.put(bump, bump);
8240
+ usedtextures.add(bump);
80478241
8048
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8242
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80498243 {
80508244 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80518245 // System.out.println("; bump = " + bump);
....@@ -8055,18 +8249,10 @@
80558249 {
80568250 bump = null;
80578251 }
8058
- if (pigment.equals(""))
8059
- {
8060
- pigment = null;
8061
- }
80628252
8063
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8064
- BindTexture(pigment, false, resolution);
80658253 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8066
- BindTexture(bump, true, resolution);
8254
+ BindTexture(tex.bumptexture, bump, true, resolution);
80678255 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8068
-
8069
- return; // true;
80708256 }
80718257
80728258 java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
....@@ -8089,9 +8275,9 @@
80898275 return fileExists;
80908276 }
80918277
8092
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
8278
+ CacheTexture GetCacheTexture(java.awt.image.BufferedImage bim, String tex, boolean bump, int resolution) throws Exception
80938279 {
8094
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8280
+ CacheTexture texturecache = null;
80958281
80968282 if (tex != null)
80978283 {
....@@ -8111,12 +8297,22 @@
81118297 }
81128298
81138299 if (CACHETEXTURE)
8114
- texture = textures.get(texname); // TEXTURE CACHE
8115
-
8116
- TextureData texturedata = null;
8117
-
8118
- if (texture == null || texture.resolution < resolution)
81198300 {
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
81208316 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
81218317 {
81228318 assert(!bump);
....@@ -8128,19 +8324,19 @@
81288324 // }
81298325 // else
81308326 // {
8131
- texture = textures.get(tex);
8132
- if (texture == null)
8327
+ texturecache = textures.get(tex);
8328
+ if (texturecache == null)
81338329 {
8134
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8330
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81358331 }
81368332 // }
81378333 } else
81388334 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81398335 {
81408336 assert(bump);
8141
- texture = textures.get(tex);
8142
- if (texture == null)
8143
- 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);
81448340 } else
81458341 {
81468342 //if (tex.equals("IMMORTAL"))
....@@ -8150,9 +8346,9 @@
81508346 //{
81518347 if (tex.equals("WHITE_NOISE"))
81528348 {
8153
- texture = textures.get(tex);
8154
- if (texture == null)
8155
- 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);
81568352 } else
81578353 {
81588354 if (textureon)
....@@ -8211,19 +8407,19 @@
82118407 if (texturedata == null)
82128408 throw new Exception();
82138409
8214
- 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);
82158411 //texture = GetTexture(tex, bump);
82168412 }
82178413 }
82188414 //}
82198415 }
82208416
8221
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8417
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
82228418 {
82238419 //return false;
82248420
82258421 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8226
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8422
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
82278423 {
82288424 // String ext = "_highres";
82298425 // if (REDUCETEXTURE)
....@@ -8312,8 +8508,8 @@
83128508 textures.remove(texname);
83138509 }
83148510
8315
- texture.texturedata = texturedata;
8316
- textures.put(texname, texture);
8511
+ //texture.texturedata = texturedata;
8512
+ textures.put(texname, texturecache);
83178513
83188514 // newtex = true;
83198515 }
....@@ -8329,12 +8525,12 @@
83298525 }
83308526 }
83318527
8332
- return texture;
8528
+ return texturecache;
83338529 }
83348530
8335
- 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
83368532 {
8337
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8533
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83388534
83398535 if (bump)
83408536 {
....@@ -8350,23 +8546,23 @@
83508546 return texture!=null?texture.texture:null;
83518547 }
83528548
8353
- 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
83548550 {
8355
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8551
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83568552
83578553 return texture!=null?texture.texturedata:null;
83588554 }
83598555
8360
- 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
83618557 {
83628558 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83638559 {
83648560 return false;
83658561 }
83668562
8367
- boolean newtex = false;
8563
+ //boolean newtex = false;
83688564
8369
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8565
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
83708566
83718567 if (texture == null)
83728568 return false;
....@@ -8396,7 +8592,7 @@
83968592 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83978593 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83988594
8399
- return newtex;
8595
+ return true; // Warning: not used.
84008596 }
84018597
84028598 ShadowBuffer shadowPBuf;
....@@ -9234,11 +9430,35 @@
92349430 jy8[3] = 0.5f;
92359431 }
92369432
9237
- 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
92389434 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92399435 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92409436 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92419437
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
+
92429462 static int imagecount = 0; // movie generation
92439463
92449464 static int jitter = 0;
....@@ -10349,6 +10569,7 @@
1034910569 ANTIALIAS = 0;
1035010570 //System.out.println("RESTART");
1035110571 AAtimer.restart();
10572
+ Globals.TIMERRUNNING = true;
1035210573 }
1035310574 }
1035410575 }
....@@ -10416,7 +10637,8 @@
1041610637 ambientOcclusion = false;
1041710638 }
1041810639
10419
- if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
10640
+ if (//Globals.lighttouched &&
10641
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1042010642 {
1042110643 //if (RENDERSHADOW) // ?
1042210644 if (!IsFrozen())
....@@ -10827,7 +11049,7 @@
1082711049
1082811050 try
1082911051 {
10830
- BindTexture(NOISE_TEXTURE, false, 2);
11052
+ BindTexture(null, NOISE_TEXTURE, false, 2);
1083111053 }
1083211054 catch (Exception e)
1083311055 {
....@@ -10856,9 +11078,9 @@
1085611078
1085711079 gl.glMatrixMode(GL.GL_MODELVIEW);
1085811080
10859
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10860
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10861
-//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);
1086211084 } else
1086311085 {
1086411086 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10869,7 +11091,7 @@
1086911091 //System.out.println("BLENDING ON");
1087011092 gl.glEnable(GL.GL_BLEND);
1087111093 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10872
-
11094
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1087311095 gl.glMatrixMode(gl.GL_PROJECTION);
1087411096 gl.glLoadIdentity();
1087511097
....@@ -11326,15 +11548,36 @@
1132611548
1132711549 static boolean zoomonce = false;
1132811550
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
+
1132911569 void DrawObject(GL gl, boolean draw)
1133011570 {
11571
+ // To clear camera values
11572
+ ResetOptions();
11573
+
1133111574 //System.out.println("DRAW OBJECT " + mouseDown);
1133211575 // DrawMode() = SELECTION;
1133311576 //GL gl = getGL();
1133411577 if ((TRACK || SHADOWTRACK) || zoomonce)
1133511578 {
1133611579 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11337
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11580
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1133811581 pingthread.StepToTarget(true); // true);
1133911582 // zoomonce = false;
1134011583 }
....@@ -11406,8 +11649,9 @@
1140611649
1140711650 if (DrawMode() == DEFAULT)
1140811651 {
11409
- if (DEBUG)
11652
+ if (Globals.DEBUG)
1141011653 {
11654
+ CreateSelectedPoint();
1141111655 float radius = 0.05f;
1141211656 if (selectedpoint.radius != radius)
1141311657 {
....@@ -11470,7 +11714,7 @@
1147011714 if (tex.equals("WHITE_NOISE"))
1147111715 continue;
1147211716
11473
- if (!usedtextures.containsKey(tex))
11717
+ if (!usedtextures.contains(tex))
1147411718 {
1147511719 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1147611720 textures.get(tex).texture.dispose();
....@@ -11894,7 +12138,7 @@
1189412138 for (int i = tp.size(); --i >= 0;)
1189512139 {
1189612140 //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11897
- LA.xformPos(light, tp.get(i).GlobalTransform(), light);
12141
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1189812142 }
1189912143
1190012144
....@@ -13164,7 +13408,8 @@
1316413408 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1316513409 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1316613410 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13167
- Object3D.cVector2[] vector2buffer;
13411
+
13412
+ //Object3D.cVector2[] vector2buffer;
1316813413
1316913414 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1317013415 // OUT : diff, spec
....@@ -13180,9 +13425,10 @@
1318013425 "DP3 " + dest + ".z," + "normals," + "eye;" +
1318113426 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1318213427 //"MOV " + dest + ".w," + "normal.z;" +
13183
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13184
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13185
- //"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
1318613432 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1318713433 "RCP " + dest + ".w," + dest + ".w;" +
1318813434 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13687,6 +13933,7 @@
1368713933 else
1368813934 if (evt.getSource() == AAtimer)
1368913935 {
13936
+ Globals.TIMERRUNNING = false;
1369013937 if (mouseDown)
1369113938 {
1369213939 //new Exception().printStackTrace();
....@@ -13746,7 +13993,7 @@
1374613993
1374713994 // fev 2014???
1374813995 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13749
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13996
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1375013997 pingthread.StepToTarget(true); // true);
1375113998 }
1375213999 // if (!LIVE)
....@@ -13761,6 +14008,7 @@
1376114008 return;
1376214009
1376314010 AAtimer.restart(); //
14011
+ Globals.TIMERRUNNING = true;
1376414012
1376514013 // waslive = LIVE;
1376614014 // LIVE = false;
....@@ -14099,12 +14347,12 @@
1409914347 void GoDown(int mod)
1410014348 {
1410114349 MODIFIERS |= COMMAND;
14102
- /*
14350
+ /**/
1410314351 if((mod&SHIFT) == SHIFT)
1410414352 manipCamera.RotatePosition(0, -speed);
1410514353 else
14106
- manipCamera.BackForth(0, -speed*delta, getWidth());
14107
- */
14354
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14355
+ /**/
1410814356 if ((mod & SHIFT) == SHIFT)
1410914357 {
1411014358 mouseMode = mouseMode; // VR??
....@@ -14120,12 +14368,12 @@
1412014368 void GoUp(int mod)
1412114369 {
1412214370 MODIFIERS |= COMMAND;
14123
- /*
14371
+ /**/
1412414372 if((mod&SHIFT) == SHIFT)
1412514373 manipCamera.RotatePosition(0, speed);
1412614374 else
14127
- manipCamera.BackForth(0, speed*delta, getWidth());
14128
- */
14375
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14376
+ /**/
1412914377 if ((mod & SHIFT) == SHIFT)
1413014378 {
1413114379 mouseMode = mouseMode;
....@@ -14141,12 +14389,12 @@
1414114389 void GoLeft(int mod)
1414214390 {
1414314391 MODIFIERS |= COMMAND;
14144
- /*
14392
+ /**/
1414514393 if((mod&SHIFT) == SHIFT)
14146
- manipCamera.RotatePosition(speed, 0);
14147
- else
1414814394 manipCamera.Translate(speed*delta, 0, getWidth());
14149
- */
14395
+ else
14396
+ manipCamera.RotatePosition(speed, 0);
14397
+ /**/
1415014398 if ((mod & SHIFT) == SHIFT)
1415114399 {
1415214400 mouseMode = mouseMode;
....@@ -14162,12 +14410,12 @@
1416214410 void GoRight(int mod)
1416314411 {
1416414412 MODIFIERS |= COMMAND;
14165
- /*
14413
+ /**/
1416614414 if((mod&SHIFT) == SHIFT)
14167
- manipCamera.RotatePosition(-speed, 0);
14168
- else
1416914415 manipCamera.Translate(-speed*delta, 0, getWidth());
14170
- */
14416
+ else
14417
+ manipCamera.RotatePosition(-speed, 0);
14418
+ /**/
1417114419 if ((mod & SHIFT) == SHIFT)
1417214420 {
1417314421 mouseMode = mouseMode;
....@@ -14224,7 +14472,8 @@
1422414472 info.camera = renderCamera;
1422514473 info.x = x;
1422614474 info.y = y;
14227
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14475
+ object.GetWindow().copy
14476
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1422814477 } else
1422914478 {
1423014479 if (x < startX)
....@@ -14388,7 +14637,9 @@
1438814637 ci.camera = renderCamera;
1438914638 if (!isRenderer)
1439014639 {
14391
- if (object.editWindow.copy.doEditClick(ci, 0))
14640
+ //ObjEditor editWindow = object.editWindow;
14641
+ //Object3D copy = editWindow.copy;
14642
+ if (object.doEditClick(ci, 0))
1439214643 {
1439314644 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1439414645 } else
....@@ -14403,7 +14654,8 @@
1440314654 Globals.MOUSEDRAGGED = false;
1440414655
1440514656 movingcamera = false;
14406
- X = Y = 0;
14657
+ X = 0; // getBounds().width/2;
14658
+ Y = 0; // getBounds().height/2;
1440714659 //System.out.println("mouseReleased: " + e);
1440814660 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1440914661 }
....@@ -14744,7 +14996,9 @@
1474414996 case 'E' : COMPACT ^= true;
1474514997 repaint();
1474614998 break;
14747
- case 'W' : DEBUGHSB ^= true;
14999
+ case 'W' : // Wide Window (fullscreen)
15000
+ //DEBUGHSB ^= true;
15001
+ ObjEditor.theFrame.ToggleFullScreen();
1474815002 repaint();
1474915003 break;
1475015004 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14769,8 +15023,8 @@
1476915023 RevertCamera();
1477015024 repaint();
1477115025 break;
14772
- case 'L':
1477315026 case 'l':
15027
+ //case 'L':
1477415028 if (lightMode)
1477515029 {
1477615030 lightMode = false;
....@@ -14913,9 +15167,9 @@
1491315167 case '_':
1491415168 kompactbit = 5;
1491515169 break;
14916
- case '+':
14917
- kompactbit = 6;
14918
- break;
15170
+// case '+':
15171
+// kompactbit = 6;
15172
+// break;
1491915173 case ' ':
1492015174 lightMode ^= true;
1492115175 Globals.lighttouched = true;
....@@ -14927,6 +15181,7 @@
1492715181 case ESC:
1492815182 RENDERPROGRAM += 1;
1492915183 RENDERPROGRAM %= 3;
15184
+
1493015185 repaint();
1493115186 break;
1493215187 case 'Z':
....@@ -14966,8 +15221,9 @@
1496615221 case DELETE:
1496715222 ClearSelection();
1496815223 break;
14969
- /*
1497015224 case '+':
15225
+
15226
+ /*
1497115227 //fontsize += 1;
1497215228 bbzoom *= 2;
1497315229 repaint();
....@@ -14984,17 +15240,17 @@
1498415240 case '=':
1498515241 IncDepth();
1498615242 //fontsize += 1;
14987
- object.editWindow.refreshContents(true);
15243
+ object.GetWindow().refreshContents(true);
1498815244 maskbit = 6;
1498915245 break;
1499015246 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1499115247 DecDepth();
1499215248 maskbit = 5;
1499315249 //if(fontsize > 1) fontsize -= 1;
14994
- if (object.editWindow == null)
14995
- new Exception().printStackTrace();
14996
- else
14997
- object.editWindow.refreshContents(true);
15250
+// if (object.editWindow == null)
15251
+// new Exception().printStackTrace();
15252
+// else
15253
+ object.GetWindow().refreshContents(true);
1499815254 break;
1499915255 case '{':
1500015256 manipCamera.shaper_fovy /= 1.1;
....@@ -15218,7 +15474,7 @@
1521815474 }
1521915475 */
1522015476
15221
- object.editWindow.EditSelection();
15477
+ object.GetWindow().EditSelection(false);
1522215478 }
1522315479
1522415480 void SelectParent()
....@@ -15235,10 +15491,10 @@
1523515491 {
1523615492 //selectees.remove(i);
1523715493 System.out.println("select parent of " + elem);
15238
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15494
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1523915495 } else
1524015496 {
15241
- group.editWindow.Select(elem.GetTreePath(), first, true);
15497
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1524215498 }
1524315499
1524415500 first = false;
....@@ -15280,12 +15536,12 @@
1528015536 for (int j = 0; j < group.children.size(); j++)
1528115537 {
1528215538 elem = (Object3D) group.children.elementAt(j);
15283
- object.editWindow.Select(elem.GetTreePath(), first, true);
15539
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1528415540 first = false;
1528515541 }
1528615542 } else
1528715543 {
15288
- object.editWindow.Select(elem.GetTreePath(), first, true);
15544
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1528915545 }
1529015546
1529115547 first = false;
....@@ -15296,21 +15552,21 @@
1529615552 {
1529715553 //Composite group = (Composite) object;
1529815554 Object3D group = object;
15299
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15555
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1530015556 }
1530115557
1530215558 void ResetTransform(int mask)
1530315559 {
1530415560 //Composite group = (Composite) object;
1530515561 Object3D group = object;
15306
- group.editWindow.ResetTransform(mask);
15562
+ group.GetWindow().ResetTransform(mask);
1530715563 }
1530815564
1530915565 void FlipTransform()
1531015566 {
1531115567 //Composite group = (Composite) object;
1531215568 Object3D group = object;
15313
- group.editWindow.FlipTransform();
15569
+ group.GetWindow().FlipTransform();
1531415570 // group.editWindow.ReduceMesh(true);
1531515571 }
1531615572
....@@ -15318,7 +15574,7 @@
1531815574 {
1531915575 //Composite group = (Composite) object;
1532015576 Object3D group = object;
15321
- group.editWindow.PrintMemory();
15577
+ group.GetWindow().PrintMemory();
1532215578 // group.editWindow.ReduceMesh(true);
1532315579 }
1532415580
....@@ -15326,7 +15582,7 @@
1532615582 {
1532715583 //Composite group = (Composite) object;
1532815584 Object3D group = object;
15329
- group.editWindow.ResetCentroid();
15585
+ group.GetWindow().ResetCentroid();
1533015586 }
1533115587
1533215588 void IncDepth()
....@@ -15502,6 +15758,7 @@
1550215758 info.bounds.y += (height - desired) / 2;
1550315759 }
1550415760 }
15761
+
1550515762 info.g = gr;
1550615763 info.camera = renderCamera;
1550715764 /*
....@@ -15511,23 +15768,44 @@
1551115768 */
1551215769 if (!isRenderer)
1551315770 {
15514
- object.drawEditHandles(info, 0);
15515
-
15516
- if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15771
+ Grafreed.Assert(object != null);
15772
+ Grafreed.Assert(object.selection != null);
15773
+ if (object.selection.Size() > 0)
1551715774 {
15518
- switch (object.selection.get(0).hitSomething)
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)
1551915781 {
15520
- case Object3D.hitCenter: gr.setColor(Color.pink);
15521
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15522
- break;
15523
- case Object3D.hitRotate: gr.setColor(Color.yellow);
15524
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15525
- break;
15526
- case Object3D.hitScale: gr.setColor(Color.cyan);
15527
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15528
- break;
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;
1552915789 }
15530
-
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
+ }
1553115809 }
1553215810 }
1553315811 }
....@@ -16230,16 +16508,16 @@
1623016508 cStatic.objectstack[materialdepth++] = checker;
1623116509 //System.out.println("material " + material);
1623216510 //Applet3D.tracein(this, selected);
16233
- vector2buffer = checker.projectedVertices;
16511
+ //vector2buffer = checker.projectedVertices;
1623416512
1623516513 //checker.GetMaterial().Draw(this, false); // true);
16236
- DrawMaterial(checker.GetMaterial(), false); // true);
16514
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1623716515
1623816516 materialdepth -= 1;
1623916517 if (materialdepth > 0)
1624016518 {
16241
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16242
- 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);
1624316521 }
1624416522 //checker.GetMaterial().opacity = 1f;
1624516523 ////checker.GetMaterial().ambient = 1f;
....@@ -16325,6 +16603,14 @@
1632516603 }
1632616604 }
1632716605
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
+
1632816614 class SelectBuffer implements GLEventListener
1632916615 {
1633016616
....@@ -16404,6 +16690,17 @@
1640416690
1640516691 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1640616692
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
+
1640716704 //int tmp = selection_view;
1640816705 //selection_view = -1;
1640916706 int temp = DrawMode();
....@@ -16415,6 +16712,17 @@
1641516712 // temp = DEFAULT; // patch for selection debug
1641616713 Globals.drawMode = temp; // WARNING
1641716714
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
+
1641816726 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1641916727
1642016728 // trying different ways of getting the depth info over
....@@ -16462,6 +16770,8 @@
1646216770 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1646316771 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1646416772 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16773
+
16774
+ CreateSelectedPoint();
1646516775
1646616776 // Will fit the mesh !!!
1646716777 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16516,29 +16826,31 @@
1651616826 }
1651716827
1651816828 if (!movingcamera && !PAINTMODE)
16519
- object.editWindow.ScreenFitPoint(); // fev 2014
16829
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1652016830
16521
- 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)
1652216832 {
16523
- 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);
1652416834
16525
- Object3D group = new Object3D("inst" + paintcount++);
16835
+ if (object.GetWindow().copy.selection.Size() > 0)
16836
+ {
16837
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1652616838
16527
- group.CreateMaterial(); // use a void leaf to select instances
16528
-
16529
- group.add(paintobj); // link
16530
-
16531
- object.editWindow.SnapObject(group);
16532
-
16533
- Object3D folder = object.editWindow.copy;
16534
-
16535
- if (object.editWindow.copy.selection.Size() > 0)
16536
- folder = object.editWindow.copy.selection.elementAt(0);
16537
-
16538
- folder.add(group);
16539
-
16540
- object.editWindow.ResetModel();
16541
- 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
+ }
1654216854 }
1654316855 else
1654416856 paintcount = 0;
....@@ -16577,6 +16889,11 @@
1657716889 //System.out.println("objects[color] = " + objects[color]);
1657816890 //objects[color].Select();
1657916891 indexcount = 0;
16892
+ ObjEditor window = object.GetWindow();
16893
+ if (window != null && deselect)
16894
+ {
16895
+ window.Select(null, deselect, true);
16896
+ }
1658016897 object.Select(color, deselect);
1658116898 }
1658216899
....@@ -17102,23 +17419,15 @@
1710217419 int AAbuffersize = 0;
1710317420
1710417421 //double[] selectedpoint = new double[3];
17105
- static Superellipsoid selectedpoint = new Superellipsoid();
17422
+ static Superellipsoid selectedpoint;
1710617423 static Sphere previousselectedpoint = null;
17107
- static Sphere debugpointG = new Sphere();
17108
- static Sphere debugpointP = new Sphere();
17109
- static Sphere debugpointC = new Sphere();
17110
- static Sphere debugpointR = new Sphere();
17424
+ static Sphere debugpointG;
17425
+ static Sphere debugpointP;
17426
+ static Sphere debugpointC;
17427
+ static Sphere debugpointR;
1711117428
1711217429 static Sphere debugpoints[] = new Sphere[8];
1711317430
17114
- static
17115
- {
17116
- for (int i=0; i<8; i++)
17117
- {
17118
- debugpoints[i] = new Sphere();
17119
- }
17120
- }
17121
-
1712217431 static void InitPoints(float radius)
1712317432 {
1712417433 for (int i=0; i<8; i++)