Normand Briere
2019-07-21 d32f24f147068e6cbecb31c7f98047f68bc8b58a
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)
....@@ -2377,6 +2405,45 @@
23772405 return currentGL;
23782406 }
23792407
2408
+ private BufferedImage CreateBim(TextureData texturedata)
2409
+ {
2410
+ // cache to disk
2411
+ Buffer buffer = texturedata.getBuffer(); // getMipmapData();
2412
+ //buffers[0].
2413
+ ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
2414
+ int[] pixels = new int[bytebuf.capacity()/3];
2415
+ int width = texturedata.getWidth(); //(int)Math.sqrt(pixels.length); // squared
2416
+ int height = width;
2417
+ for (int i=pixels.length; --i>=0;)
2418
+ {
2419
+ int i3 = i*3;
2420
+ pixels[i] = 0xFF;
2421
+ pixels[i] <<= 8;
2422
+ pixels[i] |= bytebuf.get(i3+2) & 0xFF;
2423
+ pixels[i] <<= 8;
2424
+ pixels[i] |= bytebuf.get(i3+1) & 0xFF;
2425
+ pixels[i] <<= 8;
2426
+ pixels[i] |= bytebuf.get(i3) & 0xFF;
2427
+ }
2428
+ /*
2429
+ int r=0,g=0,b=0,a=0;
2430
+ for (int i=0; i<width; i++)
2431
+ for (int j=0; j<height; j++)
2432
+ {
2433
+ int index = j*width+i;
2434
+ int p = pixels[index];
2435
+ a = ((p>>24) & 0xFF);
2436
+ r = ((p>>16) & 0xFF);
2437
+ g = ((p>>8) & 0xFF);
2438
+ b = (p & 0xFF);
2439
+ pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
2440
+ }
2441
+ /**/
2442
+ BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
2443
+ rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
2444
+ return rendImage;
2445
+ }
2446
+
23802447 /**/
23812448 class CacheTexture
23822449 {
....@@ -2394,9 +2461,10 @@
23942461 /**/
23952462
23962463 // 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>();
2464
+ static public java.util.Hashtable<String, CacheTexture> textures = new java.util.Hashtable<String, CacheTexture>();
2465
+ static public java.util.Hashtable<BufferedImage, CacheTexture> bimtextures = new java.util.Hashtable<BufferedImage, CacheTexture>();
2466
+ static public java.util.HashSet<String> usedtextures = new java.util.HashSet<String>();
2467
+
24002468 int pigmentdepth = 0;
24012469 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24022470 int bumpdepth = 0;
....@@ -2418,6 +2486,33 @@
24182486 true,
24192487 com.sun.opengl.util.texture.TextureIO.PNG);
24202488 } catch (java.io.IOException e)
2489
+ {
2490
+ throw new javax.media.opengl.GLException(e);
2491
+ }
2492
+
2493
+ if (bump)
2494
+ texturedata = ConvertBump(texturedata, false);
2495
+
2496
+ com.sun.opengl.util.texture.Texture texture =
2497
+ com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2498
+
2499
+ texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2500
+ texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2501
+
2502
+ return texture;
2503
+ }
2504
+
2505
+ com.sun.opengl.util.texture.Texture GetBimTexture(BufferedImage name, boolean bump)
2506
+ {
2507
+ TextureData texturedata = null;
2508
+
2509
+ try
2510
+ {
2511
+ texturedata =
2512
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2513
+ name,
2514
+ true);
2515
+ } catch (Exception e)
24212516 {
24222517 throw new javax.media.opengl.GLException(e);
24232518 }
....@@ -3504,6 +3599,8 @@
35043599
35053600 System.out.println("LOADING TEXTURE : " + name);
35063601
3602
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3603
+
35073604 //
35083605 if (false) // compressbit > 0)
35093606 {
....@@ -7902,7 +7999,7 @@
79027999 String pigment = Object3D.GetPigment(tex);
79038000 String bump = Object3D.GetBump(tex);
79048001
7905
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8002
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79068003 {
79078004 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79088005 // System.out.println("; bump = " + bump);
....@@ -7936,7 +8033,7 @@
79368033
79378034 String pigment = Object3D.GetPigment(tex);
79388035
7939
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8036
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79408037 {
79418038 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79428039 // System.out.println("; bump = " + bump);
....@@ -7965,7 +8062,7 @@
79658062
79668063 String bump = Object3D.GetBump(tex);
79678064
7968
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8065
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79698066 {
79708067 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79718068 // System.out.println("; bump = " + bump);
....@@ -8084,47 +8181,50 @@
80848181
80858182 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80868183 {
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
- }
8184
+// if (// DrawMode() != 0 || /*tex == null ||*/
8185
+// ambientOcclusion ) // || !textureon)
8186
+// {
8187
+// return; // false;
8188
+// }
8189
+//
8190
+// if (tex == null)
8191
+// {
8192
+// BindTexture(null,false,resolution);
8193
+// BindTexture(null,true,resolution);
8194
+// return;
8195
+// }
8196
+//
8197
+// String pigment = Object3D.GetPigment(tex);
8198
+// String bump = Object3D.GetBump(tex);
8199
+//
8200
+// usedtextures.add(pigment);
8201
+// usedtextures.add(bump);
8202
+//
8203
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8204
+// {
8205
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8206
+// // System.out.println("; bump = " + bump);
8207
+// }
8208
+//
8209
+// if (bump.equals(""))
8210
+// {
8211
+// bump = null;
8212
+// }
8213
+// if (pigment.equals(""))
8214
+// {
8215
+// pigment = null;
8216
+// }
8217
+//
8218
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8219
+// BindTexture(pigment, false, resolution);
8220
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8221
+// BindTexture(bump, true, resolution);
8222
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8223
+//
8224
+// return; // true;
80998225
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;
8226
+ BindPigmentTexture(tex, resolution);
8227
+ BindBumpTexture(tex, resolution);
81288228 }
81298229
81308230 /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8137,15 +8237,15 @@
81378237
81388238 if (tex == null)
81398239 {
8140
- BindTexture(null,false,resolution);
8240
+ BindTexture(null, null,false,resolution);
81418241 return;
81428242 }
81438243
81448244 String pigment = Object3D.GetPigment(tex);
81458245
8146
- usedtextures.put(pigment, pigment);
8246
+ usedtextures.add(pigment);
81478247
8148
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8248
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81498249 {
81508250 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81518251 // System.out.println("; bump = " + bump);
....@@ -8157,7 +8257,7 @@
81578257 }
81588258
81598259 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8160
- BindTexture(pigment, false, resolution);
8260
+ BindTexture(tex.pigmenttexture, pigment, false, resolution);
81618261 }
81628262
81638263 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8170,15 +8270,15 @@
81708270
81718271 if (tex == null)
81728272 {
8173
- BindTexture(null,true,resolution);
8273
+ BindTexture(null, null,true,resolution);
81748274 return;
81758275 }
81768276
81778277 String bump = Object3D.GetBump(tex);
81788278
8179
- usedtextures.put(bump, bump);
8279
+ usedtextures.add(bump);
81808280
8181
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8281
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81828282 {
81838283 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81848284 // System.out.println("; bump = " + bump);
....@@ -8190,7 +8290,7 @@
81908290 }
81918291
81928292 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8193
- BindTexture(bump, true, resolution);
8293
+ BindTexture(tex.bumptexture, bump, true, resolution);
81948294 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
81958295 }
81968296
....@@ -8214,9 +8314,9 @@
82148314 return fileExists;
82158315 }
82168316
8217
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
8317
+ CacheTexture GetCacheTexture(java.awt.image.BufferedImage bim, String tex, boolean bump, int resolution) throws Exception
82188318 {
8219
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8319
+ CacheTexture texturecache = null;
82208320
82218321 if (tex != null)
82228322 {
....@@ -8236,12 +8336,22 @@
82368336 }
82378337
82388338 if (CACHETEXTURE)
8239
- texture = textures.get(texname); // TEXTURE CACHE
8240
-
8241
- TextureData texturedata = null;
8242
-
8243
- if (texture == null || texture.resolution < resolution)
82448339 {
8340
+ if (bim == null)
8341
+ texturecache = textures.get(texname); // TEXTURE CACHE
8342
+ else
8343
+ texturecache = bimtextures.get(bim); // TEXTURE CACHE
8344
+ }
8345
+
8346
+ if (texturecache == null || texturecache.resolution < resolution)
8347
+ {
8348
+ TextureData texturedata = null;
8349
+
8350
+ if (bim != null)
8351
+ {
8352
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8353
+ }
8354
+ else
82458355 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
82468356 {
82478357 assert(!bump);
....@@ -8253,19 +8363,23 @@
82538363 // }
82548364 // else
82558365 // {
8256
- texture = textures.get(tex);
8257
- if (texture == null)
8366
+ texturecache = textures.get(tex);
8367
+ if (texturecache == null)
82588368 {
8259
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8369
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
82608370 }
8371
+ else
8372
+ new Exception().printStackTrace();
82618373 // }
82628374 } else
82638375 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
82648376 {
82658377 assert(bump);
8266
- texture = textures.get(tex);
8267
- if (texture == null)
8268
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8378
+ texturecache = textures.get(tex);
8379
+ if (texturecache == null)
8380
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8381
+ else
8382
+ new Exception().printStackTrace();
82698383 } else
82708384 {
82718385 //if (tex.equals("IMMORTAL"))
....@@ -8275,9 +8389,11 @@
82758389 //{
82768390 if (tex.equals("WHITE_NOISE"))
82778391 {
8278
- texture = textures.get(tex);
8279
- if (texture == null)
8280
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8392
+ texturecache = textures.get(tex);
8393
+ if (texturecache == null)
8394
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8395
+ else
8396
+ new Exception().printStackTrace();
82818397 } else
82828398 {
82838399 if (textureon)
....@@ -8336,19 +8452,20 @@
83368452 if (texturedata == null)
83378453 throw new Exception();
83388454
8339
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8455
+ texturecache = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
83408456 //texture = GetTexture(tex, bump);
83418457 }
83428458 }
83438459 //}
83448460 }
83458461
8346
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8462
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
83478463 {
83488464 //return false;
8465
+ assert(bim == null);
83498466
83508467 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8351
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8468
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
83528469 {
83538470 // String ext = "_highres";
83548471 // if (REDUCETEXTURE)
....@@ -8365,52 +8482,17 @@
83658482 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
83668483 if (!cachefile.exists())
83678484 {
8368
- // cache to disk
8369
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8370
- //buffers[0].
8371
-
8372
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8373
- int[] pixels = new int[bytebuf.capacity()/3];
8374
-
8375
- // squared size heuristic...
8376
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8485
+ //if (texturedata.getWidth() == texturedata.getHeight())
83778486 {
8378
- for (int i=pixels.length; --i>=0;)
8379
- {
8380
- int i3 = i*3;
8381
- pixels[i] = 0xFF;
8382
- pixels[i] <<= 8;
8383
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8384
- pixels[i] <<= 8;
8385
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8386
- pixels[i] <<= 8;
8387
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8388
- }
8389
-
8390
- /*
8391
- int r=0,g=0,b=0,a=0;
8392
- for (int i=0; i<width; i++)
8393
- for (int j=0; j<height; j++)
8394
- {
8395
- int index = j*width+i;
8396
- int p = pixels[index];
8397
- a = ((p>>24) & 0xFF);
8398
- r = ((p>>16) & 0xFF);
8399
- g = ((p>>8) & 0xFF);
8400
- b = (p & 0xFF);
8401
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8402
- }
8403
- /**/
8404
- int width = (int)Math.sqrt(pixels.length); // squared
8405
- int height = width;
8406
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8407
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8487
+ BufferedImage rendImage = CreateBim(texturedata);
8488
+
84088489 ImageWriter writer = null;
84098490 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
84108491 if (iter.hasNext()) {
84118492 writer = (ImageWriter)iter.next();
84128493 }
8413
- float compressionQuality = 0.9f;
8494
+
8495
+ float compressionQuality = 0.85f;
84148496 try
84158497 {
84168498 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8437,8 +8519,8 @@
84378519 textures.remove(texname);
84388520 }
84398521
8440
- texture.texturedata = texturedata;
8441
- textures.put(texname, texture);
8522
+ //texture.texturedata = texturedata;
8523
+ textures.put(texname, texturecache);
84428524
84438525 // newtex = true;
84448526 }
....@@ -8454,12 +8536,17 @@
84548536 }
84558537 }
84568538
8457
- return texture;
8539
+ return texturecache;
84588540 }
84598541
8460
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
8542
+ static void EmbedTextures(cTexture tex)
84618543 {
8462
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8544
+
8545
+ }
8546
+
8547
+ com.sun.opengl.util.texture.Texture GetTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
8548
+ {
8549
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
84638550
84648551 if (bump)
84658552 {
....@@ -8475,23 +8562,23 @@
84758562 return texture!=null?texture.texture:null;
84768563 }
84778564
8478
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
8565
+ public com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
84798566 {
8480
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8567
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
84818568
84828569 return texture!=null?texture.texturedata:null;
84838570 }
84848571
8485
- boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
8572
+ boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
84868573 {
84878574 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
84888575 {
84898576 return false;
84908577 }
84918578
8492
- boolean newtex = false;
8579
+ //boolean newtex = false;
84938580
8494
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8581
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
84958582
84968583 if (texture == null)
84978584 return false;
....@@ -8521,7 +8608,7 @@
85218608 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
85228609 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
85238610
8524
- return newtex;
8611
+ return true; // Warning: not used.
85258612 }
85268613
85278614 ShadowBuffer shadowPBuf;
....@@ -9359,11 +9446,35 @@
93599446 jy8[3] = 0.5f;
93609447 }
93619448
9362
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9449
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
93639450 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
93649451 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
93659452 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
93669453
9454
+ void ResetOptions()
9455
+ {
9456
+ options1[0] = 100;
9457
+ options1[1] = 0.025f;
9458
+ options1[2] = 0.01f;
9459
+ options1[3] = 0;
9460
+ options1[4] = 0;
9461
+
9462
+ options2[0] = 0;
9463
+ options2[1] = 0.75f;
9464
+ options2[2] = 0;
9465
+ options2[3] = 0;
9466
+
9467
+ options3[0] = 1;
9468
+ options3[1] = 1;
9469
+ options3[2] = 1;
9470
+ options3[3] = 0;
9471
+
9472
+ options4[0] = 1;
9473
+ options4[1] = 0;
9474
+ options4[2] = 1;
9475
+ options4[3] = 0;
9476
+ }
9477
+
93679478 static int imagecount = 0; // movie generation
93689479
93699480 static int jitter = 0;
....@@ -10474,6 +10585,7 @@
1047410585 ANTIALIAS = 0;
1047510586 //System.out.println("RESTART");
1047610587 AAtimer.restart();
10588
+ Globals.TIMERRUNNING = true;
1047710589 }
1047810590 }
1047910591 }
....@@ -10541,7 +10653,8 @@
1054110653 ambientOcclusion = false;
1054210654 }
1054310655
10544
- if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
10656
+ if (//Globals.lighttouched &&
10657
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1054510658 {
1054610659 //if (RENDERSHADOW) // ?
1054710660 if (!IsFrozen())
....@@ -10952,7 +11065,7 @@
1095211065
1095311066 try
1095411067 {
10955
- BindTexture(NOISE_TEXTURE, false, 2);
11068
+ BindTexture(null, NOISE_TEXTURE, false, 2);
1095611069 }
1095711070 catch (Exception e)
1095811071 {
....@@ -10981,9 +11094,9 @@
1098111094
1098211095 gl.glMatrixMode(GL.GL_MODELVIEW);
1098311096
10984
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10985
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10986
-//gl.glEnable(gl.GL_MULTISAMPLE);
11097
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11098
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11099
+gl.glEnable(gl.GL_MULTISAMPLE);
1098711100 } else
1098811101 {
1098911102 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10994,7 +11107,7 @@
1099411107 //System.out.println("BLENDING ON");
1099511108 gl.glEnable(GL.GL_BLEND);
1099611109 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10997
-
11110
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1099811111 gl.glMatrixMode(gl.GL_PROJECTION);
1099911112 gl.glLoadIdentity();
1100011113
....@@ -11451,15 +11564,36 @@
1145111564
1145211565 static boolean zoomonce = false;
1145311566
11567
+ static void CreateSelectedPoint()
11568
+ {
11569
+ if (selectedpoint == null)
11570
+ {
11571
+ debugpointG = new Sphere();
11572
+ debugpointP = new Sphere();
11573
+ debugpointC = new Sphere();
11574
+ debugpointR = new Sphere();
11575
+
11576
+ selectedpoint = new Superellipsoid();
11577
+
11578
+ for (int i=0; i<8; i++)
11579
+ {
11580
+ debugpoints[i] = new Sphere();
11581
+ }
11582
+ }
11583
+ }
11584
+
1145411585 void DrawObject(GL gl, boolean draw)
1145511586 {
11587
+ // To clear camera values
11588
+ ResetOptions();
11589
+
1145611590 //System.out.println("DRAW OBJECT " + mouseDown);
1145711591 // DrawMode() = SELECTION;
1145811592 //GL gl = getGL();
1145911593 if ((TRACK || SHADOWTRACK) || zoomonce)
1146011594 {
1146111595 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11462
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11596
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1146311597 pingthread.StepToTarget(true); // true);
1146411598 // zoomonce = false;
1146511599 }
....@@ -11531,8 +11665,9 @@
1153111665
1153211666 if (DrawMode() == DEFAULT)
1153311667 {
11534
- if (DEBUG)
11668
+ if (Globals.DEBUG)
1153511669 {
11670
+ CreateSelectedPoint();
1153611671 float radius = 0.05f;
1153711672 if (selectedpoint.radius != radius)
1153811673 {
....@@ -11595,7 +11730,7 @@
1159511730 if (tex.equals("WHITE_NOISE"))
1159611731 continue;
1159711732
11598
- if (!usedtextures.containsKey(tex))
11733
+ if (!usedtextures.contains(tex))
1159911734 {
1160011735 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1160111736 textures.get(tex).texture.dispose();
....@@ -12019,7 +12154,7 @@
1201912154 for (int i = tp.size(); --i >= 0;)
1202012155 {
1202112156 //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12022
- LA.xformPos(light, tp.get(i).GlobalTransform(), light);
12157
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1202312158 }
1202412159
1202512160
....@@ -13289,7 +13424,8 @@
1328913424 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1329013425 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1329113426 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13292
- Object3D.cVector2[] vector2buffer;
13427
+
13428
+ //Object3D.cVector2[] vector2buffer;
1329313429
1329413430 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1329513431 // OUT : diff, spec
....@@ -13305,9 +13441,10 @@
1330513441 "DP3 " + dest + ".z," + "normals," + "eye;" +
1330613442 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1330713443 //"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;" +
13444
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13445
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13446
+
13447
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1331113448 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1331213449 "RCP " + dest + ".w," + dest + ".w;" +
1331313450 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13812,6 +13949,7 @@
1381213949 else
1381313950 if (evt.getSource() == AAtimer)
1381413951 {
13952
+ Globals.TIMERRUNNING = false;
1381513953 if (mouseDown)
1381613954 {
1381713955 //new Exception().printStackTrace();
....@@ -13871,7 +14009,7 @@
1387114009
1387214010 // fev 2014???
1387314011 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13874
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14012
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1387514013 pingthread.StepToTarget(true); // true);
1387614014 }
1387714015 // if (!LIVE)
....@@ -13886,6 +14024,7 @@
1388614024 return;
1388714025
1388814026 AAtimer.restart(); //
14027
+ Globals.TIMERRUNNING = true;
1388914028
1389014029 // waslive = LIVE;
1389114030 // LIVE = false;
....@@ -14224,12 +14363,12 @@
1422414363 void GoDown(int mod)
1422514364 {
1422614365 MODIFIERS |= COMMAND;
14227
- /*
14366
+ /**/
1422814367 if((mod&SHIFT) == SHIFT)
1422914368 manipCamera.RotatePosition(0, -speed);
1423014369 else
14231
- manipCamera.BackForth(0, -speed*delta, getWidth());
14232
- */
14370
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14371
+ /**/
1423314372 if ((mod & SHIFT) == SHIFT)
1423414373 {
1423514374 mouseMode = mouseMode; // VR??
....@@ -14245,12 +14384,12 @@
1424514384 void GoUp(int mod)
1424614385 {
1424714386 MODIFIERS |= COMMAND;
14248
- /*
14387
+ /**/
1424914388 if((mod&SHIFT) == SHIFT)
1425014389 manipCamera.RotatePosition(0, speed);
1425114390 else
14252
- manipCamera.BackForth(0, speed*delta, getWidth());
14253
- */
14391
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14392
+ /**/
1425414393 if ((mod & SHIFT) == SHIFT)
1425514394 {
1425614395 mouseMode = mouseMode;
....@@ -14266,12 +14405,12 @@
1426614405 void GoLeft(int mod)
1426714406 {
1426814407 MODIFIERS |= COMMAND;
14269
- /*
14408
+ /**/
1427014409 if((mod&SHIFT) == SHIFT)
14271
- manipCamera.RotatePosition(speed, 0);
14272
- else
1427314410 manipCamera.Translate(speed*delta, 0, getWidth());
14274
- */
14411
+ else
14412
+ manipCamera.RotatePosition(speed, 0);
14413
+ /**/
1427514414 if ((mod & SHIFT) == SHIFT)
1427614415 {
1427714416 mouseMode = mouseMode;
....@@ -14287,12 +14426,12 @@
1428714426 void GoRight(int mod)
1428814427 {
1428914428 MODIFIERS |= COMMAND;
14290
- /*
14429
+ /**/
1429114430 if((mod&SHIFT) == SHIFT)
14292
- manipCamera.RotatePosition(-speed, 0);
14293
- else
1429414431 manipCamera.Translate(-speed*delta, 0, getWidth());
14295
- */
14432
+ else
14433
+ manipCamera.RotatePosition(-speed, 0);
14434
+ /**/
1429614435 if ((mod & SHIFT) == SHIFT)
1429714436 {
1429814437 mouseMode = mouseMode;
....@@ -14349,7 +14488,8 @@
1434914488 info.camera = renderCamera;
1435014489 info.x = x;
1435114490 info.y = y;
14352
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14491
+ object.GetWindow().copy
14492
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1435314493 } else
1435414494 {
1435514495 if (x < startX)
....@@ -14513,7 +14653,9 @@
1451314653 ci.camera = renderCamera;
1451414654 if (!isRenderer)
1451514655 {
14516
- if (object.editWindow.copy.doEditClick(ci, 0))
14656
+ //ObjEditor editWindow = object.editWindow;
14657
+ //Object3D copy = editWindow.copy;
14658
+ if (object.doEditClick(ci, 0))
1451714659 {
1451814660 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1451914661 } else
....@@ -14528,7 +14670,8 @@
1452814670 Globals.MOUSEDRAGGED = false;
1452914671
1453014672 movingcamera = false;
14531
- X = Y = 0;
14673
+ X = 0; // getBounds().width/2;
14674
+ Y = 0; // getBounds().height/2;
1453214675 //System.out.println("mouseReleased: " + e);
1453314676 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1453414677 }
....@@ -14869,7 +15012,9 @@
1486915012 case 'E' : COMPACT ^= true;
1487015013 repaint();
1487115014 break;
14872
- case 'W' : DEBUGHSB ^= true;
15015
+ case 'W' : // Wide Window (fullscreen)
15016
+ //DEBUGHSB ^= true;
15017
+ ObjEditor.theFrame.ToggleFullScreen();
1487315018 repaint();
1487415019 break;
1487515020 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14894,8 +15039,8 @@
1489415039 RevertCamera();
1489515040 repaint();
1489615041 break;
14897
- case 'L':
1489815042 case 'l':
15043
+ //case 'L':
1489915044 if (lightMode)
1490015045 {
1490115046 lightMode = false;
....@@ -15038,9 +15183,9 @@
1503815183 case '_':
1503915184 kompactbit = 5;
1504015185 break;
15041
- case '+':
15042
- kompactbit = 6;
15043
- break;
15186
+// case '+':
15187
+// kompactbit = 6;
15188
+// break;
1504415189 case ' ':
1504515190 lightMode ^= true;
1504615191 Globals.lighttouched = true;
....@@ -15052,6 +15197,7 @@
1505215197 case ESC:
1505315198 RENDERPROGRAM += 1;
1505415199 RENDERPROGRAM %= 3;
15200
+
1505515201 repaint();
1505615202 break;
1505715203 case 'Z':
....@@ -15091,8 +15237,9 @@
1509115237 case DELETE:
1509215238 ClearSelection();
1509315239 break;
15094
- /*
1509515240 case '+':
15241
+
15242
+ /*
1509615243 //fontsize += 1;
1509715244 bbzoom *= 2;
1509815245 repaint();
....@@ -15109,17 +15256,17 @@
1510915256 case '=':
1511015257 IncDepth();
1511115258 //fontsize += 1;
15112
- object.editWindow.refreshContents(true);
15259
+ object.GetWindow().refreshContents(true);
1511315260 maskbit = 6;
1511415261 break;
1511515262 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1511615263 DecDepth();
1511715264 maskbit = 5;
1511815265 //if(fontsize > 1) fontsize -= 1;
15119
- if (object.editWindow == null)
15120
- new Exception().printStackTrace();
15121
- else
15122
- object.editWindow.refreshContents(true);
15266
+// if (object.editWindow == null)
15267
+// new Exception().printStackTrace();
15268
+// else
15269
+ object.GetWindow().refreshContents(true);
1512315270 break;
1512415271 case '{':
1512515272 manipCamera.shaper_fovy /= 1.1;
....@@ -15343,7 +15490,7 @@
1534315490 }
1534415491 */
1534515492
15346
- object.editWindow.EditSelection();
15493
+ object.GetWindow().EditSelection(false);
1534715494 }
1534815495
1534915496 void SelectParent()
....@@ -15360,10 +15507,10 @@
1536015507 {
1536115508 //selectees.remove(i);
1536215509 System.out.println("select parent of " + elem);
15363
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15510
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1536415511 } else
1536515512 {
15366
- group.editWindow.Select(elem.GetTreePath(), first, true);
15513
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1536715514 }
1536815515
1536915516 first = false;
....@@ -15405,12 +15552,12 @@
1540515552 for (int j = 0; j < group.children.size(); j++)
1540615553 {
1540715554 elem = (Object3D) group.children.elementAt(j);
15408
- object.editWindow.Select(elem.GetTreePath(), first, true);
15555
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1540915556 first = false;
1541015557 }
1541115558 } else
1541215559 {
15413
- object.editWindow.Select(elem.GetTreePath(), first, true);
15560
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1541415561 }
1541515562
1541615563 first = false;
....@@ -15421,21 +15568,21 @@
1542115568 {
1542215569 //Composite group = (Composite) object;
1542315570 Object3D group = object;
15424
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15571
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1542515572 }
1542615573
1542715574 void ResetTransform(int mask)
1542815575 {
1542915576 //Composite group = (Composite) object;
1543015577 Object3D group = object;
15431
- group.editWindow.ResetTransform(mask);
15578
+ group.GetWindow().ResetTransform(mask);
1543215579 }
1543315580
1543415581 void FlipTransform()
1543515582 {
1543615583 //Composite group = (Composite) object;
1543715584 Object3D group = object;
15438
- group.editWindow.FlipTransform();
15585
+ group.GetWindow().FlipTransform();
1543915586 // group.editWindow.ReduceMesh(true);
1544015587 }
1544115588
....@@ -15443,7 +15590,7 @@
1544315590 {
1544415591 //Composite group = (Composite) object;
1544515592 Object3D group = object;
15446
- group.editWindow.PrintMemory();
15593
+ group.GetWindow().PrintMemory();
1544715594 // group.editWindow.ReduceMesh(true);
1544815595 }
1544915596
....@@ -15451,7 +15598,7 @@
1545115598 {
1545215599 //Composite group = (Composite) object;
1545315600 Object3D group = object;
15454
- group.editWindow.ResetCentroid();
15601
+ group.GetWindow().ResetCentroid();
1545515602 }
1545615603
1545715604 void IncDepth()
....@@ -15627,6 +15774,7 @@
1562715774 info.bounds.y += (height - desired) / 2;
1562815775 }
1562915776 }
15777
+
1563015778 info.g = gr;
1563115779 info.camera = renderCamera;
1563215780 /*
....@@ -15636,23 +15784,44 @@
1563615784 */
1563715785 if (!isRenderer)
1563815786 {
15639
- object.drawEditHandles(info, 0);
15640
-
15641
- if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15787
+ Grafreed.Assert(object != null);
15788
+ Grafreed.Assert(object.selection != null);
15789
+ if (object.selection.Size() > 0)
1564215790 {
15643
- switch (object.selection.get(0).hitSomething)
15791
+ int hitSomething = object.selection.get(0).hitSomething;
15792
+
15793
+ info.DX = 0;
15794
+ info.DY = 0;
15795
+ info.W = 1;
15796
+ if (hitSomething == Object3D.hitCenter)
1564415797 {
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;
15798
+ info.DX = X;
15799
+ if (X != 0)
15800
+ info.DX -= info.bounds.width/2;
15801
+
15802
+ info.DY = Y;
15803
+ if (Y != 0)
15804
+ info.DY -= info.bounds.height/2;
1565415805 }
15655
-
15806
+
15807
+ object.drawEditHandles(info, 0);
15808
+
15809
+ if (drag && (X != 0 || Y != 0))
15810
+ {
15811
+ switch (hitSomething)
15812
+ {
15813
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15814
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15815
+ break;
15816
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15817
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15818
+ break;
15819
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15820
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15821
+ break;
15822
+ }
15823
+
15824
+ }
1565615825 }
1565715826 }
1565815827 }
....@@ -16355,16 +16524,16 @@
1635516524 cStatic.objectstack[materialdepth++] = checker;
1635616525 //System.out.println("material " + material);
1635716526 //Applet3D.tracein(this, selected);
16358
- vector2buffer = checker.projectedVertices;
16527
+ //vector2buffer = checker.projectedVertices;
1635916528
1636016529 //checker.GetMaterial().Draw(this, false); // true);
16361
- DrawMaterial(checker.GetMaterial(), false); // true);
16530
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1636216531
1636316532 materialdepth -= 1;
1636416533 if (materialdepth > 0)
1636516534 {
16366
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16367
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16535
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16536
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1636816537 }
1636916538 //checker.GetMaterial().opacity = 1f;
1637016539 ////checker.GetMaterial().ambient = 1f;
....@@ -16450,6 +16619,14 @@
1645016619 }
1645116620 }
1645216621
16622
+ private Object3D GetFolder()
16623
+ {
16624
+ Object3D folder = object.GetWindow().copy;
16625
+ if (object.GetWindow().copy.selection.Size() > 0)
16626
+ folder = object.GetWindow().copy.selection.elementAt(0);
16627
+ return folder;
16628
+ }
16629
+
1645316630 class SelectBuffer implements GLEventListener
1645416631 {
1645516632
....@@ -16529,6 +16706,17 @@
1652916706
1653016707 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1653116708
16709
+ if (PAINTMODE)
16710
+ {
16711
+ if (object.GetWindow().copy.selection.Size() > 0)
16712
+ {
16713
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16714
+
16715
+ // Make what you paint not selectable.
16716
+ paintobj.ResetSelectable();
16717
+ }
16718
+ }
16719
+
1653216720 //int tmp = selection_view;
1653316721 //selection_view = -1;
1653416722 int temp = DrawMode();
....@@ -16540,6 +16728,17 @@
1654016728 // temp = DEFAULT; // patch for selection debug
1654116729 Globals.drawMode = temp; // WARNING
1654216730
16731
+ if (PAINTMODE)
16732
+ {
16733
+ if (object.GetWindow().copy.selection.Size() > 0)
16734
+ {
16735
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16736
+
16737
+ // Revert.
16738
+ paintobj.RestoreSelectable();
16739
+ }
16740
+ }
16741
+
1654316742 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1654416743
1654516744 // trying different ways of getting the depth info over
....@@ -16587,6 +16786,8 @@
1658716786 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1658816787 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1658916788 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16789
+
16790
+ CreateSelectedPoint();
1659016791
1659116792 // Will fit the mesh !!!
1659216793 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16641,29 +16842,31 @@
1664116842 }
1664216843
1664316844 if (!movingcamera && !PAINTMODE)
16644
- object.editWindow.ScreenFitPoint(); // fev 2014
16845
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1664516846
16646
- if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16847
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1664716848 {
16648
- Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16849
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1664916850
16650
- Object3D group = new Object3D("inst" + paintcount++);
16851
+ if (object.GetWindow().copy.selection.Size() > 0)
16852
+ {
16853
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1665116854
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();
16855
+ Object3D inst = new Object3D("inst" + paintcount++);
16856
+
16857
+ inst.CreateMaterial(); // use a void leaf to select instances
16858
+
16859
+ inst.add(paintobj); // link
16860
+
16861
+ object.GetWindow().SnapObject(inst);
16862
+
16863
+ Object3D folder = paintFolder; // GetFolder();
16864
+
16865
+ folder.add(inst);
16866
+
16867
+ object.GetWindow().ResetModel();
16868
+ object.GetWindow().refreshContents();
16869
+ }
1666716870 }
1666816871 else
1666916872 paintcount = 0;
....@@ -16702,6 +16905,11 @@
1670216905 //System.out.println("objects[color] = " + objects[color]);
1670316906 //objects[color].Select();
1670416907 indexcount = 0;
16908
+ ObjEditor window = object.GetWindow();
16909
+ if (window != null && deselect)
16910
+ {
16911
+ window.Select(null, deselect, true);
16912
+ }
1670516913 object.Select(color, deselect);
1670616914 }
1670716915
....@@ -17227,23 +17435,15 @@
1722717435 int AAbuffersize = 0;
1722817436
1722917437 //double[] selectedpoint = new double[3];
17230
- static Superellipsoid selectedpoint = new Superellipsoid();
17438
+ static Superellipsoid selectedpoint;
1723117439 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();
17440
+ static Sphere debugpointG;
17441
+ static Sphere debugpointP;
17442
+ static Sphere debugpointC;
17443
+ static Sphere debugpointR;
1723617444
1723717445 static Sphere debugpoints[] = new Sphere[8];
1723817446
17239
- static
17240
- {
17241
- for (int i=0; i<8; i++)
17242
- {
17243
- debugpoints[i] = new Sphere();
17244
- }
17245
- }
17246
-
1724717447 static void InitPoints(float radius)
1724817448 {
1724917449 for (int i=0; i<8; i++)