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
....@@ -1890,7 +1911,7 @@
18901911 void PushMatrix(double[][] matrix)
18911912 {
18921913 // GrafreeD.tracein(matrix);
1893
- PushMatrix(matrix,1);
1914
+ PushMatrix(matrix, 1);
18941915 }
18951916
18961917 void PushMatrix()
....@@ -2044,7 +2065,7 @@
20442065 //System.err.println("Oeil on");
20452066 OEIL = true;
20462067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2047
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20482069 //pingthread.StepToTarget(true);
20492070 }
20502071
....@@ -2259,7 +2280,7 @@
22592280
22602281 void ToggleDebug()
22612282 {
2262
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22632284 }
22642285
22652286 void ToggleLookAt()
....@@ -2277,10 +2298,17 @@
22772298 HANDLES ^= true;
22782299 }
22792300
2301
+ Object3D paintFolder;
2302
+
22802303 void TogglePaint()
22812304 {
22822305 PAINTMODE ^= true;
22832306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
22842312 }
22852313
22862314 void SwapCamera(int a, int b)
....@@ -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);
....@@ -7919,6 +8016,64 @@
79198016
79208017 ReleaseTexture(bump, true);
79218018 ReleaseTexture(pigment, false);
8019
+ }
8020
+
8021
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
8022
+ {
8023
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8024
+ {
8025
+ return;
8026
+ }
8027
+
8028
+ if (tex == null)
8029
+ {
8030
+ ReleaseTexture(null, false);
8031
+ return;
8032
+ }
8033
+
8034
+ String pigment = Object3D.GetPigment(tex);
8035
+
8036
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8037
+ {
8038
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8039
+ // System.out.println("; bump = " + bump);
8040
+ }
8041
+
8042
+ if (pigment.equals(""))
8043
+ {
8044
+ pigment = null;
8045
+ }
8046
+
8047
+ ReleaseTexture(pigment, false);
8048
+ }
8049
+
8050
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8051
+ {
8052
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8053
+ {
8054
+ return;
8055
+ }
8056
+
8057
+ if (tex == null)
8058
+ {
8059
+ ReleaseTexture(null, true);
8060
+ return;
8061
+ }
8062
+
8063
+ String bump = Object3D.GetBump(tex);
8064
+
8065
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8066
+ {
8067
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8068
+ // System.out.println("; bump = " + bump);
8069
+ }
8070
+
8071
+ if (bump.equals(""))
8072
+ {
8073
+ bump = null;
8074
+ }
8075
+
8076
+ ReleaseTexture(bump, true);
79228077 }
79238078
79248079 void ReleaseTexture(String tex, boolean bump)
....@@ -8026,6 +8181,54 @@
80268181
80278182 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80288183 {
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;
8225
+
8226
+ BindPigmentTexture(tex, resolution);
8227
+ BindBumpTexture(tex, resolution);
8228
+ }
8229
+
8230
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8231
+ {
80298232 if (// DrawMode() != 0 || /*tex == null ||*/
80308233 ambientOcclusion ) // || !textureon)
80318234 {
....@@ -8034,18 +8237,48 @@
80348237
80358238 if (tex == null)
80368239 {
8037
- BindTexture(null,false,resolution);
8038
- BindTexture(null,true,resolution);
8240
+ BindTexture(null, null,false,resolution);
80398241 return;
80408242 }
80418243
80428244 String pigment = Object3D.GetPigment(tex);
8245
+
8246
+ usedtextures.add(pigment);
8247
+
8248
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8249
+ {
8250
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8251
+ // System.out.println("; bump = " + bump);
8252
+ }
8253
+
8254
+ if (pigment.equals(""))
8255
+ {
8256
+ pigment = null;
8257
+ }
8258
+
8259
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8260
+ BindTexture(tex.pigmenttexture, pigment, false, resolution);
8261
+ }
8262
+
8263
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8264
+ {
8265
+ if (// DrawMode() != 0 || /*tex == null ||*/
8266
+ ambientOcclusion ) // || !textureon)
8267
+ {
8268
+ return; // false;
8269
+ }
8270
+
8271
+ if (tex == null)
8272
+ {
8273
+ BindTexture(null, null,true,resolution);
8274
+ return;
8275
+ }
8276
+
80438277 String bump = Object3D.GetBump(tex);
80448278
8045
- usedtextures.put(pigment, pigment);
8046
- usedtextures.put(bump, bump);
8279
+ usedtextures.add(bump);
80478280
8048
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8281
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80498282 {
80508283 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80518284 // System.out.println("; bump = " + bump);
....@@ -8055,18 +8288,10 @@
80558288 {
80568289 bump = null;
80578290 }
8058
- if (pigment.equals(""))
8059
- {
8060
- pigment = null;
8061
- }
80628291
8063
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8064
- BindTexture(pigment, false, resolution);
80658292 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8066
- BindTexture(bump, true, resolution);
8293
+ BindTexture(tex.bumptexture, bump, true, resolution);
80678294 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8068
-
8069
- return; // true;
80708295 }
80718296
80728297 java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
....@@ -8089,9 +8314,9 @@
80898314 return fileExists;
80908315 }
80918316
8092
- 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
80938318 {
8094
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8319
+ CacheTexture texturecache = null;
80958320
80968321 if (tex != null)
80978322 {
....@@ -8111,12 +8336,22 @@
81118336 }
81128337
81138338 if (CACHETEXTURE)
8114
- texture = textures.get(texname); // TEXTURE CACHE
8115
-
8116
- TextureData texturedata = null;
8117
-
8118
- if (texture == null || texture.resolution < resolution)
81198339 {
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
81208355 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
81218356 {
81228357 assert(!bump);
....@@ -8128,19 +8363,23 @@
81288363 // }
81298364 // else
81308365 // {
8131
- texture = textures.get(tex);
8132
- if (texture == null)
8366
+ texturecache = textures.get(tex);
8367
+ if (texturecache == null)
81338368 {
8134
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8369
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81358370 }
8371
+ else
8372
+ new Exception().printStackTrace();
81368373 // }
81378374 } else
81388375 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81398376 {
81408377 assert(bump);
8141
- texture = textures.get(tex);
8142
- if (texture == null)
8143
- 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();
81448383 } else
81458384 {
81468385 //if (tex.equals("IMMORTAL"))
....@@ -8150,9 +8389,11 @@
81508389 //{
81518390 if (tex.equals("WHITE_NOISE"))
81528391 {
8153
- texture = textures.get(tex);
8154
- if (texture == null)
8155
- 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();
81568397 } else
81578398 {
81588399 if (textureon)
....@@ -8211,19 +8452,20 @@
82118452 if (texturedata == null)
82128453 throw new Exception();
82138454
8214
- 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);
82158456 //texture = GetTexture(tex, bump);
82168457 }
82178458 }
82188459 //}
82198460 }
82208461
8221
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8462
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
82228463 {
82238464 //return false;
8465
+ assert(bim == null);
82248466
82258467 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8226
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8468
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
82278469 {
82288470 // String ext = "_highres";
82298471 // if (REDUCETEXTURE)
....@@ -8240,52 +8482,17 @@
82408482 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
82418483 if (!cachefile.exists())
82428484 {
8243
- // cache to disk
8244
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8245
- //buffers[0].
8246
-
8247
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8248
- int[] pixels = new int[bytebuf.capacity()/3];
8249
-
8250
- // squared size heuristic...
8251
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8485
+ //if (texturedata.getWidth() == texturedata.getHeight())
82528486 {
8253
- for (int i=pixels.length; --i>=0;)
8254
- {
8255
- int i3 = i*3;
8256
- pixels[i] = 0xFF;
8257
- pixels[i] <<= 8;
8258
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8259
- pixels[i] <<= 8;
8260
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8261
- pixels[i] <<= 8;
8262
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8263
- }
8264
-
8265
- /*
8266
- int r=0,g=0,b=0,a=0;
8267
- for (int i=0; i<width; i++)
8268
- for (int j=0; j<height; j++)
8269
- {
8270
- int index = j*width+i;
8271
- int p = pixels[index];
8272
- a = ((p>>24) & 0xFF);
8273
- r = ((p>>16) & 0xFF);
8274
- g = ((p>>8) & 0xFF);
8275
- b = (p & 0xFF);
8276
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8277
- }
8278
- /**/
8279
- int width = (int)Math.sqrt(pixels.length); // squared
8280
- int height = width;
8281
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8282
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8487
+ BufferedImage rendImage = CreateBim(texturedata);
8488
+
82838489 ImageWriter writer = null;
82848490 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
82858491 if (iter.hasNext()) {
82868492 writer = (ImageWriter)iter.next();
82878493 }
8288
- float compressionQuality = 0.9f;
8494
+
8495
+ float compressionQuality = 0.85f;
82898496 try
82908497 {
82918498 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8312,8 +8519,8 @@
83128519 textures.remove(texname);
83138520 }
83148521
8315
- texture.texturedata = texturedata;
8316
- textures.put(texname, texture);
8522
+ //texture.texturedata = texturedata;
8523
+ textures.put(texname, texturecache);
83178524
83188525 // newtex = true;
83198526 }
....@@ -8329,12 +8536,17 @@
83298536 }
83308537 }
83318538
8332
- return texture;
8539
+ return texturecache;
83338540 }
83348541
8335
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
8542
+ static void EmbedTextures(cTexture tex)
83368543 {
8337
- 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);
83388550
83398551 if (bump)
83408552 {
....@@ -8350,23 +8562,23 @@
83508562 return texture!=null?texture.texture:null;
83518563 }
83528564
8353
- 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
83548566 {
8355
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8567
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83568568
83578569 return texture!=null?texture.texturedata:null;
83588570 }
83598571
8360
- 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
83618573 {
83628574 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83638575 {
83648576 return false;
83658577 }
83668578
8367
- boolean newtex = false;
8579
+ //boolean newtex = false;
83688580
8369
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8581
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
83708582
83718583 if (texture == null)
83728584 return false;
....@@ -8396,7 +8608,7 @@
83968608 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83978609 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83988610
8399
- return newtex;
8611
+ return true; // Warning: not used.
84008612 }
84018613
84028614 ShadowBuffer shadowPBuf;
....@@ -9234,11 +9446,35 @@
92349446 jy8[3] = 0.5f;
92359447 }
92369448
9237
- 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
92389450 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92399451 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92409452 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92419453
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
+
92429478 static int imagecount = 0; // movie generation
92439479
92449480 static int jitter = 0;
....@@ -9335,7 +9571,7 @@
93359571
93369572 if (renderCamera != lightCamera)
93379573 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9338
- LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
9574
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93399575
93409576 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93419577
....@@ -9351,7 +9587,7 @@
93519587
93529588 if (renderCamera != lightCamera)
93539589 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9354
- LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
9590
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93559591
93569592 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93579593
....@@ -10349,6 +10585,7 @@
1034910585 ANTIALIAS = 0;
1035010586 //System.out.println("RESTART");
1035110587 AAtimer.restart();
10588
+ Globals.TIMERRUNNING = true;
1035210589 }
1035310590 }
1035410591 }
....@@ -10416,7 +10653,8 @@
1041610653 ambientOcclusion = false;
1041710654 }
1041810655
10419
- if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
10656
+ if (//Globals.lighttouched &&
10657
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1042010658 {
1042110659 //if (RENDERSHADOW) // ?
1042210660 if (!IsFrozen())
....@@ -10550,7 +10788,7 @@
1055010788 // if (parentcam != renderCamera) // not a light
1055110789 if (cam != lightCamera)
1055210790 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10553
- LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
10791
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1055410792
1055510793 for (int j = 0; j < 4; j++)
1055610794 {
....@@ -10565,7 +10803,7 @@
1056510803 // if (parentcam != renderCamera) // not a light
1056610804 if (cam != lightCamera)
1056710805 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10568
- LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
10806
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1056910807
1057010808 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1057110809
....@@ -10827,7 +11065,7 @@
1082711065
1082811066 try
1082911067 {
10830
- BindTexture(NOISE_TEXTURE, false, 2);
11068
+ BindTexture(null, NOISE_TEXTURE, false, 2);
1083111069 }
1083211070 catch (Exception e)
1083311071 {
....@@ -10856,9 +11094,9 @@
1085611094
1085711095 gl.glMatrixMode(GL.GL_MODELVIEW);
1085811096
10859
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10860
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10861
-//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);
1086211100 } else
1086311101 {
1086411102 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10869,7 +11107,7 @@
1086911107 //System.out.println("BLENDING ON");
1087011108 gl.glEnable(GL.GL_BLEND);
1087111109 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10872
-
11110
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1087311111 gl.glMatrixMode(gl.GL_PROJECTION);
1087411112 gl.glLoadIdentity();
1087511113
....@@ -10959,7 +11197,7 @@
1095911197
1096011198 // if (cam != lightCamera)
1096111199 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10962
- LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
11200
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1096311201 }
1096411202
1096511203 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10981,7 +11219,7 @@
1098111219 {
1098211220 if (cam != lightCamera)
1098311221 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10984
- LA.xformDir(light0, parentcam.GlobalTransformInv(), light0); // may 2013
11222
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1098511223 }
1098611224
1098711225 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11326,15 +11564,36 @@
1132611564
1132711565 static boolean zoomonce = false;
1132811566
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
+
1132911585 void DrawObject(GL gl, boolean draw)
1133011586 {
11587
+ // To clear camera values
11588
+ ResetOptions();
11589
+
1133111590 //System.out.println("DRAW OBJECT " + mouseDown);
1133211591 // DrawMode() = SELECTION;
1133311592 //GL gl = getGL();
1133411593 if ((TRACK || SHADOWTRACK) || zoomonce)
1133511594 {
1133611595 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11337
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11596
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1133811597 pingthread.StepToTarget(true); // true);
1133911598 // zoomonce = false;
1134011599 }
....@@ -11406,8 +11665,9 @@
1140611665
1140711666 if (DrawMode() == DEFAULT)
1140811667 {
11409
- if (DEBUG)
11668
+ if (Globals.DEBUG)
1141011669 {
11670
+ CreateSelectedPoint();
1141111671 float radius = 0.05f;
1141211672 if (selectedpoint.radius != radius)
1141311673 {
....@@ -11470,7 +11730,7 @@
1147011730 if (tex.equals("WHITE_NOISE"))
1147111731 continue;
1147211732
11473
- if (!usedtextures.containsKey(tex))
11733
+ if (!usedtextures.contains(tex))
1147411734 {
1147511735 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1147611736 textures.get(tex).texture.dispose();
....@@ -11912,7 +12172,7 @@
1191212172 }
1191312173
1191412174 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11915
- LA.xformPos(light, parentcam.GlobalTransformInv(), light); // may 2013
12175
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1191612176
1191712177 LA.xformPos(light, renderCamera.toScreen, light);
1191812178
....@@ -13164,7 +13424,8 @@
1316413424 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1316513425 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1316613426 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13167
- Object3D.cVector2[] vector2buffer;
13427
+
13428
+ //Object3D.cVector2[] vector2buffer;
1316813429
1316913430 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1317013431 // OUT : diff, spec
....@@ -13180,9 +13441,10 @@
1318013441 "DP3 " + dest + ".z," + "normals," + "eye;" +
1318113442 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1318213443 //"MOV " + dest + ".w," + "normal.z;" +
13183
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13184
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13185
- //"MOV " + dest + ".z," + "params2.w;" +
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
1318613448 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1318713449 "RCP " + dest + ".w," + dest + ".w;" +
1318813450 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13687,6 +13949,7 @@
1368713949 else
1368813950 if (evt.getSource() == AAtimer)
1368913951 {
13952
+ Globals.TIMERRUNNING = false;
1369013953 if (mouseDown)
1369113954 {
1369213955 //new Exception().printStackTrace();
....@@ -13746,7 +14009,7 @@
1374614009
1374714010 // fev 2014???
1374814011 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13749
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14012
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1375014013 pingthread.StepToTarget(true); // true);
1375114014 }
1375214015 // if (!LIVE)
....@@ -13761,6 +14024,7 @@
1376114024 return;
1376214025
1376314026 AAtimer.restart(); //
14027
+ Globals.TIMERRUNNING = true;
1376414028
1376514029 // waslive = LIVE;
1376614030 // LIVE = false;
....@@ -13833,6 +14097,8 @@
1383314097
1383414098 public void mouseDragged(MouseEvent e)
1383514099 {
14100
+ Globals.MOUSEDRAGGED = true;
14101
+
1383614102 //System.out.println("mouseDragged: " + e);
1383714103 if (isRenderer)
1383814104 movingcamera = true;
....@@ -14097,12 +14363,12 @@
1409714363 void GoDown(int mod)
1409814364 {
1409914365 MODIFIERS |= COMMAND;
14100
- /*
14366
+ /**/
1410114367 if((mod&SHIFT) == SHIFT)
1410214368 manipCamera.RotatePosition(0, -speed);
1410314369 else
14104
- manipCamera.BackForth(0, -speed*delta, getWidth());
14105
- */
14370
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14371
+ /**/
1410614372 if ((mod & SHIFT) == SHIFT)
1410714373 {
1410814374 mouseMode = mouseMode; // VR??
....@@ -14118,12 +14384,12 @@
1411814384 void GoUp(int mod)
1411914385 {
1412014386 MODIFIERS |= COMMAND;
14121
- /*
14387
+ /**/
1412214388 if((mod&SHIFT) == SHIFT)
1412314389 manipCamera.RotatePosition(0, speed);
1412414390 else
14125
- manipCamera.BackForth(0, speed*delta, getWidth());
14126
- */
14391
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14392
+ /**/
1412714393 if ((mod & SHIFT) == SHIFT)
1412814394 {
1412914395 mouseMode = mouseMode;
....@@ -14139,12 +14405,12 @@
1413914405 void GoLeft(int mod)
1414014406 {
1414114407 MODIFIERS |= COMMAND;
14142
- /*
14408
+ /**/
1414314409 if((mod&SHIFT) == SHIFT)
14144
- manipCamera.RotatePosition(speed, 0);
14145
- else
1414614410 manipCamera.Translate(speed*delta, 0, getWidth());
14147
- */
14411
+ else
14412
+ manipCamera.RotatePosition(speed, 0);
14413
+ /**/
1414814414 if ((mod & SHIFT) == SHIFT)
1414914415 {
1415014416 mouseMode = mouseMode;
....@@ -14160,12 +14426,12 @@
1416014426 void GoRight(int mod)
1416114427 {
1416214428 MODIFIERS |= COMMAND;
14163
- /*
14429
+ /**/
1416414430 if((mod&SHIFT) == SHIFT)
14165
- manipCamera.RotatePosition(-speed, 0);
14166
- else
1416714431 manipCamera.Translate(-speed*delta, 0, getWidth());
14168
- */
14432
+ else
14433
+ manipCamera.RotatePosition(-speed, 0);
14434
+ /**/
1416914435 if ((mod & SHIFT) == SHIFT)
1417014436 {
1417114437 mouseMode = mouseMode;
....@@ -14222,7 +14488,8 @@
1422214488 info.camera = renderCamera;
1422314489 info.x = x;
1422414490 info.y = y;
14225
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14491
+ object.GetWindow().copy
14492
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1422614493 } else
1422714494 {
1422814495 if (x < startX)
....@@ -14386,7 +14653,9 @@
1438614653 ci.camera = renderCamera;
1438714654 if (!isRenderer)
1438814655 {
14389
- if (object.editWindow.copy.doEditClick(ci, 0))
14656
+ //ObjEditor editWindow = object.editWindow;
14657
+ //Object3D copy = editWindow.copy;
14658
+ if (object.doEditClick(ci, 0))
1439014659 {
1439114660 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1439214661 } else
....@@ -14398,8 +14667,11 @@
1439814667
1439914668 public void mouseReleased(MouseEvent e)
1440014669 {
14670
+ Globals.MOUSEDRAGGED = false;
14671
+
1440114672 movingcamera = false;
14402
- X = Y = 0;
14673
+ X = 0; // getBounds().width/2;
14674
+ Y = 0; // getBounds().height/2;
1440314675 //System.out.println("mouseReleased: " + e);
1440414676 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1440514677 }
....@@ -14740,7 +15012,9 @@
1474015012 case 'E' : COMPACT ^= true;
1474115013 repaint();
1474215014 break;
14743
- case 'W' : DEBUGHSB ^= true;
15015
+ case 'W' : // Wide Window (fullscreen)
15016
+ //DEBUGHSB ^= true;
15017
+ ObjEditor.theFrame.ToggleFullScreen();
1474415018 repaint();
1474515019 break;
1474615020 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14765,8 +15039,8 @@
1476515039 RevertCamera();
1476615040 repaint();
1476715041 break;
14768
- case 'L':
1476915042 case 'l':
15043
+ //case 'L':
1477015044 if (lightMode)
1477115045 {
1477215046 lightMode = false;
....@@ -14909,9 +15183,9 @@
1490915183 case '_':
1491015184 kompactbit = 5;
1491115185 break;
14912
- case '+':
14913
- kompactbit = 6;
14914
- break;
15186
+// case '+':
15187
+// kompactbit = 6;
15188
+// break;
1491515189 case ' ':
1491615190 lightMode ^= true;
1491715191 Globals.lighttouched = true;
....@@ -14923,6 +15197,7 @@
1492315197 case ESC:
1492415198 RENDERPROGRAM += 1;
1492515199 RENDERPROGRAM %= 3;
15200
+
1492615201 repaint();
1492715202 break;
1492815203 case 'Z':
....@@ -14962,8 +15237,9 @@
1496215237 case DELETE:
1496315238 ClearSelection();
1496415239 break;
14965
- /*
1496615240 case '+':
15241
+
15242
+ /*
1496715243 //fontsize += 1;
1496815244 bbzoom *= 2;
1496915245 repaint();
....@@ -14980,17 +15256,17 @@
1498015256 case '=':
1498115257 IncDepth();
1498215258 //fontsize += 1;
14983
- object.editWindow.refreshContents(true);
15259
+ object.GetWindow().refreshContents(true);
1498415260 maskbit = 6;
1498515261 break;
1498615262 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1498715263 DecDepth();
1498815264 maskbit = 5;
1498915265 //if(fontsize > 1) fontsize -= 1;
14990
- if (object.editWindow == null)
14991
- new Exception().printStackTrace();
14992
- else
14993
- object.editWindow.refreshContents(true);
15266
+// if (object.editWindow == null)
15267
+// new Exception().printStackTrace();
15268
+// else
15269
+ object.GetWindow().refreshContents(true);
1499415270 break;
1499515271 case '{':
1499615272 manipCamera.shaper_fovy /= 1.1;
....@@ -15214,7 +15490,7 @@
1521415490 }
1521515491 */
1521615492
15217
- object.editWindow.EditSelection();
15493
+ object.GetWindow().EditSelection(false);
1521815494 }
1521915495
1522015496 void SelectParent()
....@@ -15231,10 +15507,10 @@
1523115507 {
1523215508 //selectees.remove(i);
1523315509 System.out.println("select parent of " + elem);
15234
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15510
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1523515511 } else
1523615512 {
15237
- group.editWindow.Select(elem.GetTreePath(), first, true);
15513
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1523815514 }
1523915515
1524015516 first = false;
....@@ -15276,12 +15552,12 @@
1527615552 for (int j = 0; j < group.children.size(); j++)
1527715553 {
1527815554 elem = (Object3D) group.children.elementAt(j);
15279
- object.editWindow.Select(elem.GetTreePath(), first, true);
15555
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1528015556 first = false;
1528115557 }
1528215558 } else
1528315559 {
15284
- object.editWindow.Select(elem.GetTreePath(), first, true);
15560
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1528515561 }
1528615562
1528715563 first = false;
....@@ -15292,21 +15568,21 @@
1529215568 {
1529315569 //Composite group = (Composite) object;
1529415570 Object3D group = object;
15295
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15571
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1529615572 }
1529715573
1529815574 void ResetTransform(int mask)
1529915575 {
1530015576 //Composite group = (Composite) object;
1530115577 Object3D group = object;
15302
- group.editWindow.ResetTransform(mask);
15578
+ group.GetWindow().ResetTransform(mask);
1530315579 }
1530415580
1530515581 void FlipTransform()
1530615582 {
1530715583 //Composite group = (Composite) object;
1530815584 Object3D group = object;
15309
- group.editWindow.FlipTransform();
15585
+ group.GetWindow().FlipTransform();
1531015586 // group.editWindow.ReduceMesh(true);
1531115587 }
1531215588
....@@ -15314,7 +15590,7 @@
1531415590 {
1531515591 //Composite group = (Composite) object;
1531615592 Object3D group = object;
15317
- group.editWindow.PrintMemory();
15593
+ group.GetWindow().PrintMemory();
1531815594 // group.editWindow.ReduceMesh(true);
1531915595 }
1532015596
....@@ -15322,7 +15598,7 @@
1532215598 {
1532315599 //Composite group = (Composite) object;
1532415600 Object3D group = object;
15325
- group.editWindow.ResetCentroid();
15601
+ group.GetWindow().ResetCentroid();
1532615602 }
1532715603
1532815604 void IncDepth()
....@@ -15498,6 +15774,7 @@
1549815774 info.bounds.y += (height - desired) / 2;
1549915775 }
1550015776 }
15777
+
1550115778 info.g = gr;
1550215779 info.camera = renderCamera;
1550315780 /*
....@@ -15507,18 +15784,44 @@
1550715784 */
1550815785 if (!isRenderer)
1550915786 {
15510
- object.drawEditHandles(info, 0);
15511
-
15512
- 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)
1551315790 {
15514
- 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)
1551515797 {
15516
- case Object3D.hitCenter: gr.setColor(Color.pink); break;
15517
- case Object3D.hitRotate: gr.setColor(Color.green); break;
15518
- case Object3D.hitScale: gr.setColor(Color.cyan); break;
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;
1551915805 }
15520
-
15521
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
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
+ }
1552215825 }
1552315826 }
1552415827 }
....@@ -16221,16 +16524,16 @@
1622116524 cStatic.objectstack[materialdepth++] = checker;
1622216525 //System.out.println("material " + material);
1622316526 //Applet3D.tracein(this, selected);
16224
- vector2buffer = checker.projectedVertices;
16527
+ //vector2buffer = checker.projectedVertices;
1622516528
1622616529 //checker.GetMaterial().Draw(this, false); // true);
16227
- DrawMaterial(checker.GetMaterial(), false); // true);
16530
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1622816531
1622916532 materialdepth -= 1;
1623016533 if (materialdepth > 0)
1623116534 {
16232
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16233
- 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);
1623416537 }
1623516538 //checker.GetMaterial().opacity = 1f;
1623616539 ////checker.GetMaterial().ambient = 1f;
....@@ -16316,6 +16619,14 @@
1631616619 }
1631716620 }
1631816621
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
+
1631916630 class SelectBuffer implements GLEventListener
1632016631 {
1632116632
....@@ -16395,6 +16706,17 @@
1639516706
1639616707 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1639716708
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
+
1639816720 //int tmp = selection_view;
1639916721 //selection_view = -1;
1640016722 int temp = DrawMode();
....@@ -16406,6 +16728,17 @@
1640616728 // temp = DEFAULT; // patch for selection debug
1640716729 Globals.drawMode = temp; // WARNING
1640816730
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
+
1640916742 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1641016743
1641116744 // trying different ways of getting the depth info over
....@@ -16453,6 +16786,8 @@
1645316786 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1645416787 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1645516788 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16789
+
16790
+ CreateSelectedPoint();
1645616791
1645716792 // Will fit the mesh !!!
1645816793 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16507,29 +16842,31 @@
1650716842 }
1650816843
1650916844 if (!movingcamera && !PAINTMODE)
16510
- object.editWindow.ScreenFitPoint(); // fev 2014
16845
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1651116846
16512
- 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)
1651316848 {
16514
- 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);
1651516850
16516
- Object3D group = new Object3D("inst" + paintcount++);
16851
+ if (object.GetWindow().copy.selection.Size() > 0)
16852
+ {
16853
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1651716854
16518
- group.CreateMaterial(); // use a void leaf to select instances
16519
-
16520
- group.add(paintobj); // link
16521
-
16522
- object.editWindow.SnapObject(group);
16523
-
16524
- Object3D folder = object.editWindow.copy;
16525
-
16526
- if (object.editWindow.copy.selection.Size() > 0)
16527
- folder = object.editWindow.copy.selection.elementAt(0);
16528
-
16529
- folder.add(group);
16530
-
16531
- object.editWindow.ResetModel();
16532
- object.editWindow.refreshContents();
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
+ }
1653316870 }
1653416871 else
1653516872 paintcount = 0;
....@@ -16568,6 +16905,11 @@
1656816905 //System.out.println("objects[color] = " + objects[color]);
1656916906 //objects[color].Select();
1657016907 indexcount = 0;
16908
+ ObjEditor window = object.GetWindow();
16909
+ if (window != null && deselect)
16910
+ {
16911
+ window.Select(null, deselect, true);
16912
+ }
1657116913 object.Select(color, deselect);
1657216914 }
1657316915
....@@ -17093,23 +17435,15 @@
1709317435 int AAbuffersize = 0;
1709417436
1709517437 //double[] selectedpoint = new double[3];
17096
- static Superellipsoid selectedpoint = new Superellipsoid();
17438
+ static Superellipsoid selectedpoint;
1709717439 static Sphere previousselectedpoint = null;
17098
- static Sphere debugpointG = new Sphere();
17099
- static Sphere debugpointP = new Sphere();
17100
- static Sphere debugpointC = new Sphere();
17101
- static Sphere debugpointR = new Sphere();
17440
+ static Sphere debugpointG;
17441
+ static Sphere debugpointP;
17442
+ static Sphere debugpointC;
17443
+ static Sphere debugpointR;
1710217444
1710317445 static Sphere debugpoints[] = new Sphere[8];
1710417446
17105
- static
17106
- {
17107
- for (int i=0; i<8; i++)
17108
- {
17109
- debugpoints[i] = new Sphere();
17110
- }
17111
- }
17112
-
1711317447 static void InitPoints(float radius)
1711417448 {
1711517449 for (int i=0; i<8; i++)