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);
....@@ -7936,7 +7994,7 @@
79367994
79377995 String pigment = Object3D.GetPigment(tex);
79387996
7939
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7997
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79407998 {
79417999 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79428000 // System.out.println("; bump = " + bump);
....@@ -7965,7 +8023,7 @@
79658023
79668024 String bump = Object3D.GetBump(tex);
79678025
7968
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8026
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79698027 {
79708028 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79718029 // System.out.println("; bump = " + bump);
....@@ -8084,47 +8142,50 @@
80848142
80858143 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80868144 {
8087
- if (// DrawMode() != 0 || /*tex == null ||*/
8088
- ambientOcclusion ) // || !textureon)
8089
- {
8090
- return; // false;
8091
- }
8092
-
8093
- if (tex == null)
8094
- {
8095
- BindTexture(null,false,resolution);
8096
- BindTexture(null,true,resolution);
8097
- return;
8098
- }
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;
80998186
8100
- String pigment = Object3D.GetPigment(tex);
8101
- String bump = Object3D.GetBump(tex);
8102
-
8103
- usedtextures.put(pigment, pigment);
8104
- usedtextures.put(bump, bump);
8105
-
8106
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8107
- {
8108
- // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8109
- // System.out.println("; bump = " + bump);
8110
- }
8111
-
8112
- if (bump.equals(""))
8113
- {
8114
- bump = null;
8115
- }
8116
- if (pigment.equals(""))
8117
- {
8118
- pigment = null;
8119
- }
8120
-
8121
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8122
- BindTexture(pigment, false, resolution);
8123
- GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8124
- BindTexture(bump, true, resolution);
8125
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8126
-
8127
- return; // true;
8187
+ BindPigmentTexture(tex, resolution);
8188
+ BindBumpTexture(tex, resolution);
81288189 }
81298190
81308191 /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8137,15 +8198,15 @@
81378198
81388199 if (tex == null)
81398200 {
8140
- BindTexture(null,false,resolution);
8201
+ BindTexture(null, null,false,resolution);
81418202 return;
81428203 }
81438204
81448205 String pigment = Object3D.GetPigment(tex);
81458206
8146
- usedtextures.put(pigment, pigment);
8207
+ usedtextures.add(pigment);
81478208
8148
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8209
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81498210 {
81508211 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81518212 // System.out.println("; bump = " + bump);
....@@ -8157,7 +8218,7 @@
81578218 }
81588219
81598220 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8160
- BindTexture(pigment, false, resolution);
8221
+ BindTexture(tex.pigmenttexture, pigment, false, resolution);
81618222 }
81628223
81638224 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8170,15 +8231,15 @@
81708231
81718232 if (tex == null)
81728233 {
8173
- BindTexture(null,true,resolution);
8234
+ BindTexture(null, null,true,resolution);
81748235 return;
81758236 }
81768237
81778238 String bump = Object3D.GetBump(tex);
81788239
8179
- usedtextures.put(bump, bump);
8240
+ usedtextures.add(bump);
81808241
8181
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8242
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81828243 {
81838244 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81848245 // System.out.println("; bump = " + bump);
....@@ -8190,7 +8251,7 @@
81908251 }
81918252
81928253 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8193
- BindTexture(bump, true, resolution);
8254
+ BindTexture(tex.bumptexture, bump, true, resolution);
81948255 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
81958256 }
81968257
....@@ -8214,9 +8275,9 @@
82148275 return fileExists;
82158276 }
82168277
8217
- 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
82188279 {
8219
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8280
+ CacheTexture texturecache = null;
82208281
82218282 if (tex != null)
82228283 {
....@@ -8236,12 +8297,22 @@
82368297 }
82378298
82388299 if (CACHETEXTURE)
8239
- texture = textures.get(texname); // TEXTURE CACHE
8240
-
8241
- TextureData texturedata = null;
8242
-
8243
- if (texture == null || texture.resolution < resolution)
82448300 {
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
82458316 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
82468317 {
82478318 assert(!bump);
....@@ -8253,19 +8324,19 @@
82538324 // }
82548325 // else
82558326 // {
8256
- texture = textures.get(tex);
8257
- if (texture == null)
8327
+ texturecache = textures.get(tex);
8328
+ if (texturecache == null)
82588329 {
8259
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8330
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
82608331 }
82618332 // }
82628333 } else
82638334 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
82648335 {
82658336 assert(bump);
8266
- texture = textures.get(tex);
8267
- if (texture == null)
8268
- 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);
82698340 } else
82708341 {
82718342 //if (tex.equals("IMMORTAL"))
....@@ -8275,9 +8346,9 @@
82758346 //{
82768347 if (tex.equals("WHITE_NOISE"))
82778348 {
8278
- texture = textures.get(tex);
8279
- if (texture == null)
8280
- 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);
82818352 } else
82828353 {
82838354 if (textureon)
....@@ -8336,19 +8407,19 @@
83368407 if (texturedata == null)
83378408 throw new Exception();
83388409
8339
- 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);
83408411 //texture = GetTexture(tex, bump);
83418412 }
83428413 }
83438414 //}
83448415 }
83458416
8346
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8417
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
83478418 {
83488419 //return false;
83498420
83508421 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8351
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8422
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
83528423 {
83538424 // String ext = "_highres";
83548425 // if (REDUCETEXTURE)
....@@ -8437,8 +8508,8 @@
84378508 textures.remove(texname);
84388509 }
84398510
8440
- texture.texturedata = texturedata;
8441
- textures.put(texname, texture);
8511
+ //texture.texturedata = texturedata;
8512
+ textures.put(texname, texturecache);
84428513
84438514 // newtex = true;
84448515 }
....@@ -8454,12 +8525,12 @@
84548525 }
84558526 }
84568527
8457
- return texture;
8528
+ return texturecache;
84588529 }
84598530
8460
- 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
84618532 {
8462
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8533
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
84638534
84648535 if (bump)
84658536 {
....@@ -8475,23 +8546,23 @@
84758546 return texture!=null?texture.texture:null;
84768547 }
84778548
8478
- 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
84798550 {
8480
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8551
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
84818552
84828553 return texture!=null?texture.texturedata:null;
84838554 }
84848555
8485
- 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
84868557 {
84878558 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
84888559 {
84898560 return false;
84908561 }
84918562
8492
- boolean newtex = false;
8563
+ //boolean newtex = false;
84938564
8494
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8565
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
84958566
84968567 if (texture == null)
84978568 return false;
....@@ -8521,7 +8592,7 @@
85218592 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
85228593 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
85238594
8524
- return newtex;
8595
+ return true; // Warning: not used.
85258596 }
85268597
85278598 ShadowBuffer shadowPBuf;
....@@ -9359,11 +9430,35 @@
93599430 jy8[3] = 0.5f;
93609431 }
93619432
9362
- 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
93639434 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
93649435 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
93659436 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
93669437
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
+
93679462 static int imagecount = 0; // movie generation
93689463
93699464 static int jitter = 0;
....@@ -10474,6 +10569,7 @@
1047410569 ANTIALIAS = 0;
1047510570 //System.out.println("RESTART");
1047610571 AAtimer.restart();
10572
+ Globals.TIMERRUNNING = true;
1047710573 }
1047810574 }
1047910575 }
....@@ -10541,7 +10637,8 @@
1054110637 ambientOcclusion = false;
1054210638 }
1054310639
10544
- if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
10640
+ if (//Globals.lighttouched &&
10641
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1054510642 {
1054610643 //if (RENDERSHADOW) // ?
1054710644 if (!IsFrozen())
....@@ -10952,7 +11049,7 @@
1095211049
1095311050 try
1095411051 {
10955
- BindTexture(NOISE_TEXTURE, false, 2);
11052
+ BindTexture(null, NOISE_TEXTURE, false, 2);
1095611053 }
1095711054 catch (Exception e)
1095811055 {
....@@ -10981,9 +11078,9 @@
1098111078
1098211079 gl.glMatrixMode(GL.GL_MODELVIEW);
1098311080
10984
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10985
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10986
-//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);
1098711084 } else
1098811085 {
1098911086 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10994,7 +11091,7 @@
1099411091 //System.out.println("BLENDING ON");
1099511092 gl.glEnable(GL.GL_BLEND);
1099611093 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10997
-
11094
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1099811095 gl.glMatrixMode(gl.GL_PROJECTION);
1099911096 gl.glLoadIdentity();
1100011097
....@@ -11451,15 +11548,36 @@
1145111548
1145211549 static boolean zoomonce = false;
1145311550
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
+
1145411569 void DrawObject(GL gl, boolean draw)
1145511570 {
11571
+ // To clear camera values
11572
+ ResetOptions();
11573
+
1145611574 //System.out.println("DRAW OBJECT " + mouseDown);
1145711575 // DrawMode() = SELECTION;
1145811576 //GL gl = getGL();
1145911577 if ((TRACK || SHADOWTRACK) || zoomonce)
1146011578 {
1146111579 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11462
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11580
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1146311581 pingthread.StepToTarget(true); // true);
1146411582 // zoomonce = false;
1146511583 }
....@@ -11531,8 +11649,9 @@
1153111649
1153211650 if (DrawMode() == DEFAULT)
1153311651 {
11534
- if (DEBUG)
11652
+ if (Globals.DEBUG)
1153511653 {
11654
+ CreateSelectedPoint();
1153611655 float radius = 0.05f;
1153711656 if (selectedpoint.radius != radius)
1153811657 {
....@@ -11595,7 +11714,7 @@
1159511714 if (tex.equals("WHITE_NOISE"))
1159611715 continue;
1159711716
11598
- if (!usedtextures.containsKey(tex))
11717
+ if (!usedtextures.contains(tex))
1159911718 {
1160011719 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1160111720 textures.get(tex).texture.dispose();
....@@ -12019,7 +12138,7 @@
1201912138 for (int i = tp.size(); --i >= 0;)
1202012139 {
1202112140 //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12022
- LA.xformPos(light, tp.get(i).GlobalTransform(), light);
12141
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1202312142 }
1202412143
1202512144
....@@ -13289,7 +13408,8 @@
1328913408 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1329013409 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1329113410 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13292
- Object3D.cVector2[] vector2buffer;
13411
+
13412
+ //Object3D.cVector2[] vector2buffer;
1329313413
1329413414 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1329513415 // OUT : diff, spec
....@@ -13305,9 +13425,10 @@
1330513425 "DP3 " + dest + ".z," + "normals," + "eye;" +
1330613426 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1330713427 //"MOV " + dest + ".w," + "normal.z;" +
13308
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13309
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13310
- //"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
1331113432 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1331213433 "RCP " + dest + ".w," + dest + ".w;" +
1331313434 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13812,6 +13933,7 @@
1381213933 else
1381313934 if (evt.getSource() == AAtimer)
1381413935 {
13936
+ Globals.TIMERRUNNING = false;
1381513937 if (mouseDown)
1381613938 {
1381713939 //new Exception().printStackTrace();
....@@ -13871,7 +13993,7 @@
1387113993
1387213994 // fev 2014???
1387313995 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13874
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13996
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1387513997 pingthread.StepToTarget(true); // true);
1387613998 }
1387713999 // if (!LIVE)
....@@ -13886,6 +14008,7 @@
1388614008 return;
1388714009
1388814010 AAtimer.restart(); //
14011
+ Globals.TIMERRUNNING = true;
1388914012
1389014013 // waslive = LIVE;
1389114014 // LIVE = false;
....@@ -14224,12 +14347,12 @@
1422414347 void GoDown(int mod)
1422514348 {
1422614349 MODIFIERS |= COMMAND;
14227
- /*
14350
+ /**/
1422814351 if((mod&SHIFT) == SHIFT)
1422914352 manipCamera.RotatePosition(0, -speed);
1423014353 else
14231
- manipCamera.BackForth(0, -speed*delta, getWidth());
14232
- */
14354
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14355
+ /**/
1423314356 if ((mod & SHIFT) == SHIFT)
1423414357 {
1423514358 mouseMode = mouseMode; // VR??
....@@ -14245,12 +14368,12 @@
1424514368 void GoUp(int mod)
1424614369 {
1424714370 MODIFIERS |= COMMAND;
14248
- /*
14371
+ /**/
1424914372 if((mod&SHIFT) == SHIFT)
1425014373 manipCamera.RotatePosition(0, speed);
1425114374 else
14252
- manipCamera.BackForth(0, speed*delta, getWidth());
14253
- */
14375
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14376
+ /**/
1425414377 if ((mod & SHIFT) == SHIFT)
1425514378 {
1425614379 mouseMode = mouseMode;
....@@ -14266,12 +14389,12 @@
1426614389 void GoLeft(int mod)
1426714390 {
1426814391 MODIFIERS |= COMMAND;
14269
- /*
14392
+ /**/
1427014393 if((mod&SHIFT) == SHIFT)
14271
- manipCamera.RotatePosition(speed, 0);
14272
- else
1427314394 manipCamera.Translate(speed*delta, 0, getWidth());
14274
- */
14395
+ else
14396
+ manipCamera.RotatePosition(speed, 0);
14397
+ /**/
1427514398 if ((mod & SHIFT) == SHIFT)
1427614399 {
1427714400 mouseMode = mouseMode;
....@@ -14287,12 +14410,12 @@
1428714410 void GoRight(int mod)
1428814411 {
1428914412 MODIFIERS |= COMMAND;
14290
- /*
14413
+ /**/
1429114414 if((mod&SHIFT) == SHIFT)
14292
- manipCamera.RotatePosition(-speed, 0);
14293
- else
1429414415 manipCamera.Translate(-speed*delta, 0, getWidth());
14295
- */
14416
+ else
14417
+ manipCamera.RotatePosition(-speed, 0);
14418
+ /**/
1429614419 if ((mod & SHIFT) == SHIFT)
1429714420 {
1429814421 mouseMode = mouseMode;
....@@ -14349,7 +14472,8 @@
1434914472 info.camera = renderCamera;
1435014473 info.x = x;
1435114474 info.y = y;
14352
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14475
+ object.GetWindow().copy
14476
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1435314477 } else
1435414478 {
1435514479 if (x < startX)
....@@ -14513,7 +14637,9 @@
1451314637 ci.camera = renderCamera;
1451414638 if (!isRenderer)
1451514639 {
14516
- if (object.editWindow.copy.doEditClick(ci, 0))
14640
+ //ObjEditor editWindow = object.editWindow;
14641
+ //Object3D copy = editWindow.copy;
14642
+ if (object.doEditClick(ci, 0))
1451714643 {
1451814644 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1451914645 } else
....@@ -14528,7 +14654,8 @@
1452814654 Globals.MOUSEDRAGGED = false;
1452914655
1453014656 movingcamera = false;
14531
- X = Y = 0;
14657
+ X = 0; // getBounds().width/2;
14658
+ Y = 0; // getBounds().height/2;
1453214659 //System.out.println("mouseReleased: " + e);
1453314660 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1453414661 }
....@@ -14869,7 +14996,9 @@
1486914996 case 'E' : COMPACT ^= true;
1487014997 repaint();
1487114998 break;
14872
- case 'W' : DEBUGHSB ^= true;
14999
+ case 'W' : // Wide Window (fullscreen)
15000
+ //DEBUGHSB ^= true;
15001
+ ObjEditor.theFrame.ToggleFullScreen();
1487315002 repaint();
1487415003 break;
1487515004 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14894,8 +15023,8 @@
1489415023 RevertCamera();
1489515024 repaint();
1489615025 break;
14897
- case 'L':
1489815026 case 'l':
15027
+ //case 'L':
1489915028 if (lightMode)
1490015029 {
1490115030 lightMode = false;
....@@ -15038,9 +15167,9 @@
1503815167 case '_':
1503915168 kompactbit = 5;
1504015169 break;
15041
- case '+':
15042
- kompactbit = 6;
15043
- break;
15170
+// case '+':
15171
+// kompactbit = 6;
15172
+// break;
1504415173 case ' ':
1504515174 lightMode ^= true;
1504615175 Globals.lighttouched = true;
....@@ -15052,6 +15181,7 @@
1505215181 case ESC:
1505315182 RENDERPROGRAM += 1;
1505415183 RENDERPROGRAM %= 3;
15184
+
1505515185 repaint();
1505615186 break;
1505715187 case 'Z':
....@@ -15091,8 +15221,9 @@
1509115221 case DELETE:
1509215222 ClearSelection();
1509315223 break;
15094
- /*
1509515224 case '+':
15225
+
15226
+ /*
1509615227 //fontsize += 1;
1509715228 bbzoom *= 2;
1509815229 repaint();
....@@ -15109,17 +15240,17 @@
1510915240 case '=':
1511015241 IncDepth();
1511115242 //fontsize += 1;
15112
- object.editWindow.refreshContents(true);
15243
+ object.GetWindow().refreshContents(true);
1511315244 maskbit = 6;
1511415245 break;
1511515246 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1511615247 DecDepth();
1511715248 maskbit = 5;
1511815249 //if(fontsize > 1) fontsize -= 1;
15119
- if (object.editWindow == null)
15120
- new Exception().printStackTrace();
15121
- else
15122
- object.editWindow.refreshContents(true);
15250
+// if (object.editWindow == null)
15251
+// new Exception().printStackTrace();
15252
+// else
15253
+ object.GetWindow().refreshContents(true);
1512315254 break;
1512415255 case '{':
1512515256 manipCamera.shaper_fovy /= 1.1;
....@@ -15343,7 +15474,7 @@
1534315474 }
1534415475 */
1534515476
15346
- object.editWindow.EditSelection();
15477
+ object.GetWindow().EditSelection(false);
1534715478 }
1534815479
1534915480 void SelectParent()
....@@ -15360,10 +15491,10 @@
1536015491 {
1536115492 //selectees.remove(i);
1536215493 System.out.println("select parent of " + elem);
15363
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15494
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1536415495 } else
1536515496 {
15366
- group.editWindow.Select(elem.GetTreePath(), first, true);
15497
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1536715498 }
1536815499
1536915500 first = false;
....@@ -15405,12 +15536,12 @@
1540515536 for (int j = 0; j < group.children.size(); j++)
1540615537 {
1540715538 elem = (Object3D) group.children.elementAt(j);
15408
- object.editWindow.Select(elem.GetTreePath(), first, true);
15539
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1540915540 first = false;
1541015541 }
1541115542 } else
1541215543 {
15413
- object.editWindow.Select(elem.GetTreePath(), first, true);
15544
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1541415545 }
1541515546
1541615547 first = false;
....@@ -15421,21 +15552,21 @@
1542115552 {
1542215553 //Composite group = (Composite) object;
1542315554 Object3D group = object;
15424
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15555
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1542515556 }
1542615557
1542715558 void ResetTransform(int mask)
1542815559 {
1542915560 //Composite group = (Composite) object;
1543015561 Object3D group = object;
15431
- group.editWindow.ResetTransform(mask);
15562
+ group.GetWindow().ResetTransform(mask);
1543215563 }
1543315564
1543415565 void FlipTransform()
1543515566 {
1543615567 //Composite group = (Composite) object;
1543715568 Object3D group = object;
15438
- group.editWindow.FlipTransform();
15569
+ group.GetWindow().FlipTransform();
1543915570 // group.editWindow.ReduceMesh(true);
1544015571 }
1544115572
....@@ -15443,7 +15574,7 @@
1544315574 {
1544415575 //Composite group = (Composite) object;
1544515576 Object3D group = object;
15446
- group.editWindow.PrintMemory();
15577
+ group.GetWindow().PrintMemory();
1544715578 // group.editWindow.ReduceMesh(true);
1544815579 }
1544915580
....@@ -15451,7 +15582,7 @@
1545115582 {
1545215583 //Composite group = (Composite) object;
1545315584 Object3D group = object;
15454
- group.editWindow.ResetCentroid();
15585
+ group.GetWindow().ResetCentroid();
1545515586 }
1545615587
1545715588 void IncDepth()
....@@ -15627,6 +15758,7 @@
1562715758 info.bounds.y += (height - desired) / 2;
1562815759 }
1562915760 }
15761
+
1563015762 info.g = gr;
1563115763 info.camera = renderCamera;
1563215764 /*
....@@ -15636,23 +15768,44 @@
1563615768 */
1563715769 if (!isRenderer)
1563815770 {
15639
- object.drawEditHandles(info, 0);
15640
-
15641
- 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)
1564215774 {
15643
- 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)
1564415781 {
15645
- case Object3D.hitCenter: gr.setColor(Color.pink);
15646
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15647
- break;
15648
- case Object3D.hitRotate: gr.setColor(Color.yellow);
15649
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15650
- break;
15651
- case Object3D.hitScale: gr.setColor(Color.cyan);
15652
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15653
- 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;
1565415789 }
15655
-
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
+ }
1565615809 }
1565715810 }
1565815811 }
....@@ -16355,16 +16508,16 @@
1635516508 cStatic.objectstack[materialdepth++] = checker;
1635616509 //System.out.println("material " + material);
1635716510 //Applet3D.tracein(this, selected);
16358
- vector2buffer = checker.projectedVertices;
16511
+ //vector2buffer = checker.projectedVertices;
1635916512
1636016513 //checker.GetMaterial().Draw(this, false); // true);
16361
- DrawMaterial(checker.GetMaterial(), false); // true);
16514
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1636216515
1636316516 materialdepth -= 1;
1636416517 if (materialdepth > 0)
1636516518 {
16366
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16367
- 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);
1636816521 }
1636916522 //checker.GetMaterial().opacity = 1f;
1637016523 ////checker.GetMaterial().ambient = 1f;
....@@ -16450,6 +16603,14 @@
1645016603 }
1645116604 }
1645216605
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
+
1645316614 class SelectBuffer implements GLEventListener
1645416615 {
1645516616
....@@ -16529,6 +16690,17 @@
1652916690
1653016691 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1653116692
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
+
1653216704 //int tmp = selection_view;
1653316705 //selection_view = -1;
1653416706 int temp = DrawMode();
....@@ -16540,6 +16712,17 @@
1654016712 // temp = DEFAULT; // patch for selection debug
1654116713 Globals.drawMode = temp; // WARNING
1654216714
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
+
1654316726 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1654416727
1654516728 // trying different ways of getting the depth info over
....@@ -16587,6 +16770,8 @@
1658716770 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1658816771 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1658916772 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16773
+
16774
+ CreateSelectedPoint();
1659016775
1659116776 // Will fit the mesh !!!
1659216777 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16641,29 +16826,31 @@
1664116826 }
1664216827
1664316828 if (!movingcamera && !PAINTMODE)
16644
- object.editWindow.ScreenFitPoint(); // fev 2014
16829
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1664516830
16646
- 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)
1664716832 {
16648
- 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);
1664916834
16650
- Object3D group = new Object3D("inst" + paintcount++);
16835
+ if (object.GetWindow().copy.selection.Size() > 0)
16836
+ {
16837
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1665116838
16652
- group.CreateMaterial(); // use a void leaf to select instances
16653
-
16654
- group.add(paintobj); // link
16655
-
16656
- object.editWindow.SnapObject(group);
16657
-
16658
- Object3D folder = object.editWindow.copy;
16659
-
16660
- if (object.editWindow.copy.selection.Size() > 0)
16661
- folder = object.editWindow.copy.selection.elementAt(0);
16662
-
16663
- folder.add(group);
16664
-
16665
- object.editWindow.ResetModel();
16666
- 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
+ }
1666716854 }
1666816855 else
1666916856 paintcount = 0;
....@@ -16702,6 +16889,11 @@
1670216889 //System.out.println("objects[color] = " + objects[color]);
1670316890 //objects[color].Select();
1670416891 indexcount = 0;
16892
+ ObjEditor window = object.GetWindow();
16893
+ if (window != null && deselect)
16894
+ {
16895
+ window.Select(null, deselect, true);
16896
+ }
1670516897 object.Select(color, deselect);
1670616898 }
1670716899
....@@ -17227,23 +17419,15 @@
1722717419 int AAbuffersize = 0;
1722817420
1722917421 //double[] selectedpoint = new double[3];
17230
- static Superellipsoid selectedpoint = new Superellipsoid();
17422
+ static Superellipsoid selectedpoint;
1723117423 static Sphere previousselectedpoint = null;
17232
- static Sphere debugpointG = new Sphere();
17233
- static Sphere debugpointP = new Sphere();
17234
- static Sphere debugpointC = new Sphere();
17235
- static Sphere debugpointR = new Sphere();
17424
+ static Sphere debugpointG;
17425
+ static Sphere debugpointP;
17426
+ static Sphere debugpointC;
17427
+ static Sphere debugpointR;
1723617428
1723717429 static Sphere debugpoints[] = new Sphere[8];
1723817430
17239
- static
17240
- {
17241
- for (int i=0; i<8; i++)
17242
- {
17243
- debugpoints[i] = new Sphere();
17244
- }
17245
- }
17246
-
1724717431 static void InitPoints(float radius)
1724817432 {
1724917433 for (int i=0; i<8; i++)