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
....@@ -1890,7 +1911,7 @@
18901911 void PushMatrix(double[][] matrix)
18911912 {
18921913 // GrafreeD.tracein(matrix);
1893
- PushMatrix(matrix,1);
1914
+ PushMatrix(matrix, 1);
18941915 }
18951916
18961917 void PushMatrix()
....@@ -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;
....@@ -9335,7 +9555,7 @@
93359555
93369556 if (renderCamera != lightCamera)
93379557 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9338
- LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
9558
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93399559
93409560 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93419561
....@@ -9351,7 +9571,7 @@
93519571
93529572 if (renderCamera != lightCamera)
93539573 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9354
- LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
9574
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93559575
93569576 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93579577
....@@ -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())
....@@ -10550,7 +10772,7 @@
1055010772 // if (parentcam != renderCamera) // not a light
1055110773 if (cam != lightCamera)
1055210774 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10553
- LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
10775
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1055410776
1055510777 for (int j = 0; j < 4; j++)
1055610778 {
....@@ -10565,7 +10787,7 @@
1056510787 // if (parentcam != renderCamera) // not a light
1056610788 if (cam != lightCamera)
1056710789 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10568
- LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
10790
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1056910791
1057010792 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1057110793
....@@ -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
....@@ -10959,7 +11181,7 @@
1095911181
1096011182 // if (cam != lightCamera)
1096111183 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10962
- LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
11184
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1096311185 }
1096411186
1096511187 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10981,7 +11203,7 @@
1098111203 {
1098211204 if (cam != lightCamera)
1098311205 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10984
- LA.xformDir(light0, parentcam.GlobalTransformInv(), light0); // may 2013
11206
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1098511207 }
1098611208
1098711209 LA.xformPos(light0, cam.toScreen, light0);
....@@ -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();
....@@ -11912,7 +12156,7 @@
1191212156 }
1191312157
1191412158 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11915
- LA.xformPos(light, parentcam.GlobalTransformInv(), light); // may 2013
12159
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1191612160
1191712161 LA.xformPos(light, renderCamera.toScreen, light);
1191812162
....@@ -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;
....@@ -13833,6 +14081,8 @@
1383314081
1383414082 public void mouseDragged(MouseEvent e)
1383514083 {
14084
+ Globals.MOUSEDRAGGED = true;
14085
+
1383614086 //System.out.println("mouseDragged: " + e);
1383714087 if (isRenderer)
1383814088 movingcamera = true;
....@@ -14097,12 +14347,12 @@
1409714347 void GoDown(int mod)
1409814348 {
1409914349 MODIFIERS |= COMMAND;
14100
- /*
14350
+ /**/
1410114351 if((mod&SHIFT) == SHIFT)
1410214352 manipCamera.RotatePosition(0, -speed);
1410314353 else
14104
- manipCamera.BackForth(0, -speed*delta, getWidth());
14105
- */
14354
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14355
+ /**/
1410614356 if ((mod & SHIFT) == SHIFT)
1410714357 {
1410814358 mouseMode = mouseMode; // VR??
....@@ -14118,12 +14368,12 @@
1411814368 void GoUp(int mod)
1411914369 {
1412014370 MODIFIERS |= COMMAND;
14121
- /*
14371
+ /**/
1412214372 if((mod&SHIFT) == SHIFT)
1412314373 manipCamera.RotatePosition(0, speed);
1412414374 else
14125
- manipCamera.BackForth(0, speed*delta, getWidth());
14126
- */
14375
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14376
+ /**/
1412714377 if ((mod & SHIFT) == SHIFT)
1412814378 {
1412914379 mouseMode = mouseMode;
....@@ -14139,12 +14389,12 @@
1413914389 void GoLeft(int mod)
1414014390 {
1414114391 MODIFIERS |= COMMAND;
14142
- /*
14392
+ /**/
1414314393 if((mod&SHIFT) == SHIFT)
14144
- manipCamera.RotatePosition(speed, 0);
14145
- else
1414614394 manipCamera.Translate(speed*delta, 0, getWidth());
14147
- */
14395
+ else
14396
+ manipCamera.RotatePosition(speed, 0);
14397
+ /**/
1414814398 if ((mod & SHIFT) == SHIFT)
1414914399 {
1415014400 mouseMode = mouseMode;
....@@ -14160,12 +14410,12 @@
1416014410 void GoRight(int mod)
1416114411 {
1416214412 MODIFIERS |= COMMAND;
14163
- /*
14413
+ /**/
1416414414 if((mod&SHIFT) == SHIFT)
14165
- manipCamera.RotatePosition(-speed, 0);
14166
- else
1416714415 manipCamera.Translate(-speed*delta, 0, getWidth());
14168
- */
14416
+ else
14417
+ manipCamera.RotatePosition(-speed, 0);
14418
+ /**/
1416914419 if ((mod & SHIFT) == SHIFT)
1417014420 {
1417114421 mouseMode = mouseMode;
....@@ -14222,7 +14472,8 @@
1422214472 info.camera = renderCamera;
1422314473 info.x = x;
1422414474 info.y = y;
14225
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14475
+ object.GetWindow().copy
14476
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1422614477 } else
1422714478 {
1422814479 if (x < startX)
....@@ -14386,7 +14637,9 @@
1438614637 ci.camera = renderCamera;
1438714638 if (!isRenderer)
1438814639 {
14389
- if (object.editWindow.copy.doEditClick(ci, 0))
14640
+ //ObjEditor editWindow = object.editWindow;
14641
+ //Object3D copy = editWindow.copy;
14642
+ if (object.doEditClick(ci, 0))
1439014643 {
1439114644 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1439214645 } else
....@@ -14398,8 +14651,11 @@
1439814651
1439914652 public void mouseReleased(MouseEvent e)
1440014653 {
14654
+ Globals.MOUSEDRAGGED = false;
14655
+
1440114656 movingcamera = false;
14402
- X = Y = 0;
14657
+ X = 0; // getBounds().width/2;
14658
+ Y = 0; // getBounds().height/2;
1440314659 //System.out.println("mouseReleased: " + e);
1440414660 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1440514661 }
....@@ -14740,7 +14996,9 @@
1474014996 case 'E' : COMPACT ^= true;
1474114997 repaint();
1474214998 break;
14743
- case 'W' : DEBUGHSB ^= true;
14999
+ case 'W' : // Wide Window (fullscreen)
15000
+ //DEBUGHSB ^= true;
15001
+ ObjEditor.theFrame.ToggleFullScreen();
1474415002 repaint();
1474515003 break;
1474615004 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14765,8 +15023,8 @@
1476515023 RevertCamera();
1476615024 repaint();
1476715025 break;
14768
- case 'L':
1476915026 case 'l':
15027
+ //case 'L':
1477015028 if (lightMode)
1477115029 {
1477215030 lightMode = false;
....@@ -14909,9 +15167,9 @@
1490915167 case '_':
1491015168 kompactbit = 5;
1491115169 break;
14912
- case '+':
14913
- kompactbit = 6;
14914
- break;
15170
+// case '+':
15171
+// kompactbit = 6;
15172
+// break;
1491515173 case ' ':
1491615174 lightMode ^= true;
1491715175 Globals.lighttouched = true;
....@@ -14923,6 +15181,7 @@
1492315181 case ESC:
1492415182 RENDERPROGRAM += 1;
1492515183 RENDERPROGRAM %= 3;
15184
+
1492615185 repaint();
1492715186 break;
1492815187 case 'Z':
....@@ -14962,8 +15221,9 @@
1496215221 case DELETE:
1496315222 ClearSelection();
1496415223 break;
14965
- /*
1496615224 case '+':
15225
+
15226
+ /*
1496715227 //fontsize += 1;
1496815228 bbzoom *= 2;
1496915229 repaint();
....@@ -14980,17 +15240,17 @@
1498015240 case '=':
1498115241 IncDepth();
1498215242 //fontsize += 1;
14983
- object.editWindow.refreshContents(true);
15243
+ object.GetWindow().refreshContents(true);
1498415244 maskbit = 6;
1498515245 break;
1498615246 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1498715247 DecDepth();
1498815248 maskbit = 5;
1498915249 //if(fontsize > 1) fontsize -= 1;
14990
- if (object.editWindow == null)
14991
- new Exception().printStackTrace();
14992
- else
14993
- object.editWindow.refreshContents(true);
15250
+// if (object.editWindow == null)
15251
+// new Exception().printStackTrace();
15252
+// else
15253
+ object.GetWindow().refreshContents(true);
1499415254 break;
1499515255 case '{':
1499615256 manipCamera.shaper_fovy /= 1.1;
....@@ -15214,7 +15474,7 @@
1521415474 }
1521515475 */
1521615476
15217
- object.editWindow.EditSelection();
15477
+ object.GetWindow().EditSelection(false);
1521815478 }
1521915479
1522015480 void SelectParent()
....@@ -15231,10 +15491,10 @@
1523115491 {
1523215492 //selectees.remove(i);
1523315493 System.out.println("select parent of " + elem);
15234
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15494
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1523515495 } else
1523615496 {
15237
- group.editWindow.Select(elem.GetTreePath(), first, true);
15497
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1523815498 }
1523915499
1524015500 first = false;
....@@ -15276,12 +15536,12 @@
1527615536 for (int j = 0; j < group.children.size(); j++)
1527715537 {
1527815538 elem = (Object3D) group.children.elementAt(j);
15279
- object.editWindow.Select(elem.GetTreePath(), first, true);
15539
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1528015540 first = false;
1528115541 }
1528215542 } else
1528315543 {
15284
- object.editWindow.Select(elem.GetTreePath(), first, true);
15544
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1528515545 }
1528615546
1528715547 first = false;
....@@ -15292,21 +15552,21 @@
1529215552 {
1529315553 //Composite group = (Composite) object;
1529415554 Object3D group = object;
15295
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15555
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1529615556 }
1529715557
1529815558 void ResetTransform(int mask)
1529915559 {
1530015560 //Composite group = (Composite) object;
1530115561 Object3D group = object;
15302
- group.editWindow.ResetTransform(mask);
15562
+ group.GetWindow().ResetTransform(mask);
1530315563 }
1530415564
1530515565 void FlipTransform()
1530615566 {
1530715567 //Composite group = (Composite) object;
1530815568 Object3D group = object;
15309
- group.editWindow.FlipTransform();
15569
+ group.GetWindow().FlipTransform();
1531015570 // group.editWindow.ReduceMesh(true);
1531115571 }
1531215572
....@@ -15314,7 +15574,7 @@
1531415574 {
1531515575 //Composite group = (Composite) object;
1531615576 Object3D group = object;
15317
- group.editWindow.PrintMemory();
15577
+ group.GetWindow().PrintMemory();
1531815578 // group.editWindow.ReduceMesh(true);
1531915579 }
1532015580
....@@ -15322,7 +15582,7 @@
1532215582 {
1532315583 //Composite group = (Composite) object;
1532415584 Object3D group = object;
15325
- group.editWindow.ResetCentroid();
15585
+ group.GetWindow().ResetCentroid();
1532615586 }
1532715587
1532815588 void IncDepth()
....@@ -15498,6 +15758,7 @@
1549815758 info.bounds.y += (height - desired) / 2;
1549915759 }
1550015760 }
15761
+
1550115762 info.g = gr;
1550215763 info.camera = renderCamera;
1550315764 /*
....@@ -15507,18 +15768,44 @@
1550715768 */
1550815769 if (!isRenderer)
1550915770 {
15510
- object.drawEditHandles(info, 0);
15511
-
15512
- 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)
1551315774 {
15514
- 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)
1551515781 {
15516
- case Object3D.hitCenter: gr.setColor(Color.pink); break;
15517
- case Object3D.hitRotate: gr.setColor(Color.green); break;
15518
- case Object3D.hitScale: gr.setColor(Color.cyan); 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;
1551915789 }
15520
-
15521
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
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
+ }
1552215809 }
1552315810 }
1552415811 }
....@@ -16221,16 +16508,16 @@
1622116508 cStatic.objectstack[materialdepth++] = checker;
1622216509 //System.out.println("material " + material);
1622316510 //Applet3D.tracein(this, selected);
16224
- vector2buffer = checker.projectedVertices;
16511
+ //vector2buffer = checker.projectedVertices;
1622516512
1622616513 //checker.GetMaterial().Draw(this, false); // true);
16227
- DrawMaterial(checker.GetMaterial(), false); // true);
16514
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1622816515
1622916516 materialdepth -= 1;
1623016517 if (materialdepth > 0)
1623116518 {
16232
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16233
- 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);
1623416521 }
1623516522 //checker.GetMaterial().opacity = 1f;
1623616523 ////checker.GetMaterial().ambient = 1f;
....@@ -16316,6 +16603,14 @@
1631616603 }
1631716604 }
1631816605
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
+
1631916614 class SelectBuffer implements GLEventListener
1632016615 {
1632116616
....@@ -16395,6 +16690,17 @@
1639516690
1639616691 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1639716692
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
+
1639816704 //int tmp = selection_view;
1639916705 //selection_view = -1;
1640016706 int temp = DrawMode();
....@@ -16406,6 +16712,17 @@
1640616712 // temp = DEFAULT; // patch for selection debug
1640716713 Globals.drawMode = temp; // WARNING
1640816714
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
+
1640916726 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1641016727
1641116728 // trying different ways of getting the depth info over
....@@ -16453,6 +16770,8 @@
1645316770 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1645416771 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1645516772 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16773
+
16774
+ CreateSelectedPoint();
1645616775
1645716776 // Will fit the mesh !!!
1645816777 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16507,29 +16826,31 @@
1650716826 }
1650816827
1650916828 if (!movingcamera && !PAINTMODE)
16510
- object.editWindow.ScreenFitPoint(); // fev 2014
16829
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1651116830
16512
- 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)
1651316832 {
16514
- 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);
1651516834
16516
- Object3D group = new Object3D("inst" + paintcount++);
16835
+ if (object.GetWindow().copy.selection.Size() > 0)
16836
+ {
16837
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1651716838
16518
- group.CreateMaterial(); // use a void leaf to select instances
16519
-
16520
- group.add(paintobj); // link
16521
-
16522
- object.editWindow.SnapObject(group);
16523
-
16524
- Object3D folder = object.editWindow.copy;
16525
-
16526
- if (object.editWindow.copy.selection.Size() > 0)
16527
- folder = object.editWindow.copy.selection.elementAt(0);
16528
-
16529
- folder.add(group);
16530
-
16531
- object.editWindow.ResetModel();
16532
- 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
+ }
1653316854 }
1653416855 else
1653516856 paintcount = 0;
....@@ -16568,6 +16889,11 @@
1656816889 //System.out.println("objects[color] = " + objects[color]);
1656916890 //objects[color].Select();
1657016891 indexcount = 0;
16892
+ ObjEditor window = object.GetWindow();
16893
+ if (window != null && deselect)
16894
+ {
16895
+ window.Select(null, deselect, true);
16896
+ }
1657116897 object.Select(color, deselect);
1657216898 }
1657316899
....@@ -17093,23 +17419,15 @@
1709317419 int AAbuffersize = 0;
1709417420
1709517421 //double[] selectedpoint = new double[3];
17096
- static Superellipsoid selectedpoint = new Superellipsoid();
17422
+ static Superellipsoid selectedpoint;
1709717423 static Sphere previousselectedpoint = null;
17098
- static Sphere debugpointG = new Sphere();
17099
- static Sphere debugpointP = new Sphere();
17100
- static Sphere debugpointC = new Sphere();
17101
- static Sphere debugpointR = new Sphere();
17424
+ static Sphere debugpointG;
17425
+ static Sphere debugpointP;
17426
+ static Sphere debugpointC;
17427
+ static Sphere debugpointR;
1710217428
1710317429 static Sphere debugpoints[] = new Sphere[8];
1710417430
17105
- static
17106
- {
17107
- for (int i=0; i<8; i++)
17108
- {
17109
- debugpoints[i] = new Sphere();
17110
- }
17111
- }
17112
-
1711317431 static void InitPoints(float radius)
1711417432 {
1711517433 for (int i=0; i<8; i++)