Normand Briere
2019-07-21 d32f24f147068e6cbecb31c7f98047f68bc8b58a
CameraPane.java
....@@ -60,7 +60,7 @@
6060 //boolean REDUCETEXTURE = true;
6161 boolean CACHETEXTURE = true;
6262 boolean CLEANCACHE = false; // true;
63
- boolean MIPMAP = false; // true;
63
+ boolean MIPMAP = true; // false; // true;
6464 boolean COMPRESSTEXTURE = false;
6565 boolean KOMPACTTEXTURE = false; // true;
6666 boolean RESIZETEXTURE = false;
....@@ -326,7 +326,7 @@
326326 cStatic.objectstack[materialdepth++] = obj;
327327 //System.out.println("material " + material);
328328 //Applet3D.tracein(this, selected);
329
- display.vector2buffer = obj.projectedVertices;
329
+ //display.vector2buffer = obj.projectedVertices;
330330 if (obj instanceof Camera)
331331 {
332332 display.options1[0] = material.shift;
....@@ -335,14 +335,28 @@
335335 display.options1[2] = material.shadowbias;
336336 display.options1[3] = material.aniso;
337337 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]);
338343 display.options2[0] = material.opacity;
339344 display.options2[1] = material.diffuse;
340345 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]);
341349
342350 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]);
343354 display.options4[0] = material.cameralight/0.2f;
344355 display.options4[1] = material.subsurface;
345356 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]);
346360
347361 // if (display.CURRENTANTIALIAS > 0)
348362 // display.options3[3] /= 4;
....@@ -358,7 +372,7 @@
358372 /**/
359373 } else
360374 {
361
- DrawMaterial(material, selected);
375
+ DrawMaterial(material, selected, obj.projectedVertices);
362376 }
363377 } else
364378 {
....@@ -382,8 +396,8 @@
382396 cStatic.objectstack[materialdepth++] = obj;
383397 //System.out.println("material " + material);
384398 //Applet3D.tracein("selected ", selected);
385
- display.vector2buffer = obj.projectedVertices;
386
- display.DrawMaterial(material, selected);
399
+ //display.vector2buffer = obj.projectedVertices;
400
+ display.DrawMaterial(material, selected, obj.projectedVertices);
387401 }
388402 }
389403
....@@ -400,8 +414,8 @@
400414 materialdepth -= 1;
401415 if (materialdepth > 0)
402416 {
403
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
404
- 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);
405419 }
406420 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
407421 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -421,8 +435,8 @@
421435 materialdepth -= 1;
422436 if (materialdepth > 0)
423437 {
424
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
425
- 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);
426440 }
427441 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
428442 //else
....@@ -1610,7 +1624,7 @@
16101624 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16111625 }
16121626
1613
- void DrawMaterial(cMaterial material, boolean selected)
1627
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16141628 {
16151629 CameraPane display = this;
16161630 //new Exception().printStackTrace();
....@@ -1645,7 +1659,7 @@
16451659 colorV[0] = display.modelParams0[0] * material.diffuse;
16461660 colorV[1] = display.modelParams0[1] * material.diffuse;
16471661 colorV[2] = display.modelParams0[2] * material.diffuse;
1648
- colorV[3] = material.opacity;
1662
+ colorV[3] = 1; // material.opacity;
16491663
16501664 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16511665 //System.out.println("Opacity = " + opacity);
....@@ -1753,9 +1767,9 @@
17531767 display.modelParams7[2] = 0;
17541768 display.modelParams7[3] = 0;
17551769
1756
- display.modelParams6[0] = 100; // criss de bug de bump
1770
+ //display.modelParams6[0] = 100; // criss de bug de bump
17571771
1758
- Object3D.cVector2[] extparams = display.vector2buffer;
1772
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17591773 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17601774 {
17611775 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -2051,7 +2065,7 @@
20512065 //System.err.println("Oeil on");
20522066 OEIL = true;
20532067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2054
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20552069 //pingthread.StepToTarget(true);
20562070 }
20572071
....@@ -2284,10 +2298,17 @@
22842298 HANDLES ^= true;
22852299 }
22862300
2301
+ Object3D paintFolder;
2302
+
22872303 void TogglePaint()
22882304 {
22892305 PAINTMODE ^= true;
22902306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
22912312 }
22922313
22932314 void SwapCamera(int a, int b)
....@@ -2384,6 +2405,45 @@
23842405 return currentGL;
23852406 }
23862407
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
+
23872447 /**/
23882448 class CacheTexture
23892449 {
....@@ -2401,9 +2461,10 @@
24012461 /**/
24022462
24032463 // TEXTURE static Texture texture;
2404
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2405
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2406
- 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
+
24072468 int pigmentdepth = 0;
24082469 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24092470 int bumpdepth = 0;
....@@ -2425,6 +2486,33 @@
24252486 true,
24262487 com.sun.opengl.util.texture.TextureIO.PNG);
24272488 } 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)
24282516 {
24292517 throw new javax.media.opengl.GLException(e);
24302518 }
....@@ -3511,6 +3599,8 @@
35113599
35123600 System.out.println("LOADING TEXTURE : " + name);
35133601
3602
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3603
+
35143604 //
35153605 if (false) // compressbit > 0)
35163606 {
....@@ -7909,7 +7999,7 @@
79097999 String pigment = Object3D.GetPigment(tex);
79108000 String bump = Object3D.GetBump(tex);
79118001
7912
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8002
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79138003 {
79148004 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79158005 // System.out.println("; bump = " + bump);
....@@ -7943,7 +8033,7 @@
79438033
79448034 String pigment = Object3D.GetPigment(tex);
79458035
7946
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8036
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79478037 {
79488038 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79498039 // System.out.println("; bump = " + bump);
....@@ -7972,7 +8062,7 @@
79728062
79738063 String bump = Object3D.GetBump(tex);
79748064
7975
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8065
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79768066 {
79778067 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79788068 // System.out.println("; bump = " + bump);
....@@ -8091,47 +8181,50 @@
80918181
80928182 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80938183 {
8094
- if (// DrawMode() != 0 || /*tex == null ||*/
8095
- ambientOcclusion ) // || !textureon)
8096
- {
8097
- return; // false;
8098
- }
8099
-
8100
- if (tex == null)
8101
- {
8102
- BindTexture(null,false,resolution);
8103
- BindTexture(null,true,resolution);
8104
- return;
8105
- }
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;
81068225
8107
- String pigment = Object3D.GetPigment(tex);
8108
- String bump = Object3D.GetBump(tex);
8109
-
8110
- usedtextures.put(pigment, pigment);
8111
- usedtextures.put(bump, bump);
8112
-
8113
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8114
- {
8115
- // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8116
- // System.out.println("; bump = " + bump);
8117
- }
8118
-
8119
- if (bump.equals(""))
8120
- {
8121
- bump = null;
8122
- }
8123
- if (pigment.equals(""))
8124
- {
8125
- pigment = null;
8126
- }
8127
-
8128
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8129
- BindTexture(pigment, false, resolution);
8130
- GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8131
- BindTexture(bump, true, resolution);
8132
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8133
-
8134
- return; // true;
8226
+ BindPigmentTexture(tex, resolution);
8227
+ BindBumpTexture(tex, resolution);
81358228 }
81368229
81378230 /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8144,15 +8237,15 @@
81448237
81458238 if (tex == null)
81468239 {
8147
- BindTexture(null,false,resolution);
8240
+ BindTexture(null, null,false,resolution);
81488241 return;
81498242 }
81508243
81518244 String pigment = Object3D.GetPigment(tex);
81528245
8153
- usedtextures.put(pigment, pigment);
8246
+ usedtextures.add(pigment);
81548247
8155
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8248
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81568249 {
81578250 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81588251 // System.out.println("; bump = " + bump);
....@@ -8164,7 +8257,7 @@
81648257 }
81658258
81668259 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8167
- BindTexture(pigment, false, resolution);
8260
+ BindTexture(tex.pigmenttexture, pigment, false, resolution);
81688261 }
81698262
81708263 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8177,15 +8270,15 @@
81778270
81788271 if (tex == null)
81798272 {
8180
- BindTexture(null,true,resolution);
8273
+ BindTexture(null, null,true,resolution);
81818274 return;
81828275 }
81838276
81848277 String bump = Object3D.GetBump(tex);
81858278
8186
- usedtextures.put(bump, bump);
8279
+ usedtextures.add(bump);
81878280
8188
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8281
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81898282 {
81908283 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81918284 // System.out.println("; bump = " + bump);
....@@ -8197,7 +8290,7 @@
81978290 }
81988291
81998292 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8200
- BindTexture(bump, true, resolution);
8293
+ BindTexture(tex.bumptexture, bump, true, resolution);
82018294 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
82028295 }
82038296
....@@ -8221,9 +8314,9 @@
82218314 return fileExists;
82228315 }
82238316
8224
- 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
82258318 {
8226
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8319
+ CacheTexture texturecache = null;
82278320
82288321 if (tex != null)
82298322 {
....@@ -8243,12 +8336,22 @@
82438336 }
82448337
82458338 if (CACHETEXTURE)
8246
- texture = textures.get(texname); // TEXTURE CACHE
8247
-
8248
- TextureData texturedata = null;
8249
-
8250
- if (texture == null || texture.resolution < resolution)
82518339 {
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
82528355 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
82538356 {
82548357 assert(!bump);
....@@ -8260,19 +8363,23 @@
82608363 // }
82618364 // else
82628365 // {
8263
- texture = textures.get(tex);
8264
- if (texture == null)
8366
+ texturecache = textures.get(tex);
8367
+ if (texturecache == null)
82658368 {
8266
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8369
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
82678370 }
8371
+ else
8372
+ new Exception().printStackTrace();
82688373 // }
82698374 } else
82708375 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
82718376 {
82728377 assert(bump);
8273
- texture = textures.get(tex);
8274
- if (texture == null)
8275
- 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();
82768383 } else
82778384 {
82788385 //if (tex.equals("IMMORTAL"))
....@@ -8282,9 +8389,11 @@
82828389 //{
82838390 if (tex.equals("WHITE_NOISE"))
82848391 {
8285
- texture = textures.get(tex);
8286
- if (texture == null)
8287
- 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();
82888397 } else
82898398 {
82908399 if (textureon)
....@@ -8343,19 +8452,20 @@
83438452 if (texturedata == null)
83448453 throw new Exception();
83458454
8346
- 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);
83478456 //texture = GetTexture(tex, bump);
83488457 }
83498458 }
83508459 //}
83518460 }
83528461
8353
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8462
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
83548463 {
83558464 //return false;
8465
+ assert(bim == null);
83568466
83578467 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8358
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8468
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
83598469 {
83608470 // String ext = "_highres";
83618471 // if (REDUCETEXTURE)
....@@ -8372,52 +8482,17 @@
83728482 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
83738483 if (!cachefile.exists())
83748484 {
8375
- // cache to disk
8376
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8377
- //buffers[0].
8378
-
8379
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8380
- int[] pixels = new int[bytebuf.capacity()/3];
8381
-
8382
- // squared size heuristic...
8383
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8485
+ //if (texturedata.getWidth() == texturedata.getHeight())
83848486 {
8385
- for (int i=pixels.length; --i>=0;)
8386
- {
8387
- int i3 = i*3;
8388
- pixels[i] = 0xFF;
8389
- pixels[i] <<= 8;
8390
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8391
- pixels[i] <<= 8;
8392
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8393
- pixels[i] <<= 8;
8394
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8395
- }
8396
-
8397
- /*
8398
- int r=0,g=0,b=0,a=0;
8399
- for (int i=0; i<width; i++)
8400
- for (int j=0; j<height; j++)
8401
- {
8402
- int index = j*width+i;
8403
- int p = pixels[index];
8404
- a = ((p>>24) & 0xFF);
8405
- r = ((p>>16) & 0xFF);
8406
- g = ((p>>8) & 0xFF);
8407
- b = (p & 0xFF);
8408
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8409
- }
8410
- /**/
8411
- int width = (int)Math.sqrt(pixels.length); // squared
8412
- int height = width;
8413
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8414
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8487
+ BufferedImage rendImage = CreateBim(texturedata);
8488
+
84158489 ImageWriter writer = null;
84168490 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
84178491 if (iter.hasNext()) {
84188492 writer = (ImageWriter)iter.next();
84198493 }
8420
- float compressionQuality = 0.9f;
8494
+
8495
+ float compressionQuality = 0.85f;
84218496 try
84228497 {
84238498 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8444,8 +8519,8 @@
84448519 textures.remove(texname);
84458520 }
84468521
8447
- texture.texturedata = texturedata;
8448
- textures.put(texname, texture);
8522
+ //texture.texturedata = texturedata;
8523
+ textures.put(texname, texturecache);
84498524
84508525 // newtex = true;
84518526 }
....@@ -8461,12 +8536,17 @@
84618536 }
84628537 }
84638538
8464
- return texture;
8539
+ return texturecache;
84658540 }
84668541
8467
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
8542
+ static void EmbedTextures(cTexture tex)
84688543 {
8469
- 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);
84708550
84718551 if (bump)
84728552 {
....@@ -8482,23 +8562,23 @@
84828562 return texture!=null?texture.texture:null;
84838563 }
84848564
8485
- 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
84868566 {
8487
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8567
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
84888568
84898569 return texture!=null?texture.texturedata:null;
84908570 }
84918571
8492
- 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
84938573 {
84948574 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
84958575 {
84968576 return false;
84978577 }
84988578
8499
- boolean newtex = false;
8579
+ //boolean newtex = false;
85008580
8501
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8581
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
85028582
85038583 if (texture == null)
85048584 return false;
....@@ -8528,7 +8608,7 @@
85288608 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
85298609 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
85308610
8531
- return newtex;
8611
+ return true; // Warning: not used.
85328612 }
85338613
85348614 ShadowBuffer shadowPBuf;
....@@ -9366,11 +9446,35 @@
93669446 jy8[3] = 0.5f;
93679447 }
93689448
9369
- 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
93709450 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
93719451 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
93729452 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
93739453
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
+
93749478 static int imagecount = 0; // movie generation
93759479
93769480 static int jitter = 0;
....@@ -10481,6 +10585,7 @@
1048110585 ANTIALIAS = 0;
1048210586 //System.out.println("RESTART");
1048310587 AAtimer.restart();
10588
+ Globals.TIMERRUNNING = true;
1048410589 }
1048510590 }
1048610591 }
....@@ -10548,7 +10653,8 @@
1054810653 ambientOcclusion = false;
1054910654 }
1055010655
10551
- if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
10656
+ if (//Globals.lighttouched &&
10657
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1055210658 {
1055310659 //if (RENDERSHADOW) // ?
1055410660 if (!IsFrozen())
....@@ -10959,7 +11065,7 @@
1095911065
1096011066 try
1096111067 {
10962
- BindTexture(NOISE_TEXTURE, false, 2);
11068
+ BindTexture(null, NOISE_TEXTURE, false, 2);
1096311069 }
1096411070 catch (Exception e)
1096511071 {
....@@ -10988,9 +11094,9 @@
1098811094
1098911095 gl.glMatrixMode(GL.GL_MODELVIEW);
1099011096
10991
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10992
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10993
-//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);
1099411100 } else
1099511101 {
1099611102 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -11001,7 +11107,7 @@
1100111107 //System.out.println("BLENDING ON");
1100211108 gl.glEnable(GL.GL_BLEND);
1100311109 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
11004
-
11110
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1100511111 gl.glMatrixMode(gl.GL_PROJECTION);
1100611112 gl.glLoadIdentity();
1100711113
....@@ -11458,7 +11564,7 @@
1145811564
1145911565 static boolean zoomonce = false;
1146011566
11461
- void CreateSelectedPoint()
11567
+ static void CreateSelectedPoint()
1146211568 {
1146311569 if (selectedpoint == null)
1146411570 {
....@@ -11478,13 +11584,16 @@
1147811584
1147911585 void DrawObject(GL gl, boolean draw)
1148011586 {
11587
+ // To clear camera values
11588
+ ResetOptions();
11589
+
1148111590 //System.out.println("DRAW OBJECT " + mouseDown);
1148211591 // DrawMode() = SELECTION;
1148311592 //GL gl = getGL();
1148411593 if ((TRACK || SHADOWTRACK) || zoomonce)
1148511594 {
1148611595 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11487
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11596
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1148811597 pingthread.StepToTarget(true); // true);
1148911598 // zoomonce = false;
1149011599 }
....@@ -11621,7 +11730,7 @@
1162111730 if (tex.equals("WHITE_NOISE"))
1162211731 continue;
1162311732
11624
- if (!usedtextures.containsKey(tex))
11733
+ if (!usedtextures.contains(tex))
1162511734 {
1162611735 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1162711736 textures.get(tex).texture.dispose();
....@@ -12045,7 +12154,7 @@
1204512154 for (int i = tp.size(); --i >= 0;)
1204612155 {
1204712156 //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12048
- LA.xformPos(light, tp.get(i).GlobalTransform(), light);
12157
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1204912158 }
1205012159
1205112160
....@@ -13315,7 +13424,8 @@
1331513424 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1331613425 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1331713426 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13318
- Object3D.cVector2[] vector2buffer;
13427
+
13428
+ //Object3D.cVector2[] vector2buffer;
1331913429
1332013430 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1332113431 // OUT : diff, spec
....@@ -13331,9 +13441,10 @@
1333113441 "DP3 " + dest + ".z," + "normals," + "eye;" +
1333213442 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1333313443 //"MOV " + dest + ".w," + "normal.z;" +
13334
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13335
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13336
- //"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
1333713448 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1333813449 "RCP " + dest + ".w," + dest + ".w;" +
1333913450 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13838,6 +13949,7 @@
1383813949 else
1383913950 if (evt.getSource() == AAtimer)
1384013951 {
13952
+ Globals.TIMERRUNNING = false;
1384113953 if (mouseDown)
1384213954 {
1384313955 //new Exception().printStackTrace();
....@@ -13897,7 +14009,7 @@
1389714009
1389814010 // fev 2014???
1389914011 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13900
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14012
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1390114013 pingthread.StepToTarget(true); // true);
1390214014 }
1390314015 // if (!LIVE)
....@@ -13912,6 +14024,7 @@
1391214024 return;
1391314025
1391414026 AAtimer.restart(); //
14027
+ Globals.TIMERRUNNING = true;
1391514028
1391614029 // waslive = LIVE;
1391714030 // LIVE = false;
....@@ -14250,12 +14363,12 @@
1425014363 void GoDown(int mod)
1425114364 {
1425214365 MODIFIERS |= COMMAND;
14253
- /*
14366
+ /**/
1425414367 if((mod&SHIFT) == SHIFT)
1425514368 manipCamera.RotatePosition(0, -speed);
1425614369 else
14257
- manipCamera.BackForth(0, -speed*delta, getWidth());
14258
- */
14370
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14371
+ /**/
1425914372 if ((mod & SHIFT) == SHIFT)
1426014373 {
1426114374 mouseMode = mouseMode; // VR??
....@@ -14271,12 +14384,12 @@
1427114384 void GoUp(int mod)
1427214385 {
1427314386 MODIFIERS |= COMMAND;
14274
- /*
14387
+ /**/
1427514388 if((mod&SHIFT) == SHIFT)
1427614389 manipCamera.RotatePosition(0, speed);
1427714390 else
14278
- manipCamera.BackForth(0, speed*delta, getWidth());
14279
- */
14391
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14392
+ /**/
1428014393 if ((mod & SHIFT) == SHIFT)
1428114394 {
1428214395 mouseMode = mouseMode;
....@@ -14292,12 +14405,12 @@
1429214405 void GoLeft(int mod)
1429314406 {
1429414407 MODIFIERS |= COMMAND;
14295
- /*
14408
+ /**/
1429614409 if((mod&SHIFT) == SHIFT)
14297
- manipCamera.RotatePosition(speed, 0);
14298
- else
1429914410 manipCamera.Translate(speed*delta, 0, getWidth());
14300
- */
14411
+ else
14412
+ manipCamera.RotatePosition(speed, 0);
14413
+ /**/
1430114414 if ((mod & SHIFT) == SHIFT)
1430214415 {
1430314416 mouseMode = mouseMode;
....@@ -14313,12 +14426,12 @@
1431314426 void GoRight(int mod)
1431414427 {
1431514428 MODIFIERS |= COMMAND;
14316
- /*
14429
+ /**/
1431714430 if((mod&SHIFT) == SHIFT)
14318
- manipCamera.RotatePosition(-speed, 0);
14319
- else
1432014431 manipCamera.Translate(-speed*delta, 0, getWidth());
14321
- */
14432
+ else
14433
+ manipCamera.RotatePosition(-speed, 0);
14434
+ /**/
1432214435 if ((mod & SHIFT) == SHIFT)
1432314436 {
1432414437 mouseMode = mouseMode;
....@@ -14375,7 +14488,8 @@
1437514488 info.camera = renderCamera;
1437614489 info.x = x;
1437714490 info.y = y;
14378
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14491
+ object.GetWindow().copy
14492
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1437914493 } else
1438014494 {
1438114495 if (x < startX)
....@@ -14539,7 +14653,9 @@
1453914653 ci.camera = renderCamera;
1454014654 if (!isRenderer)
1454114655 {
14542
- if (object.editWindow.copy.doEditClick(ci, 0))
14656
+ //ObjEditor editWindow = object.editWindow;
14657
+ //Object3D copy = editWindow.copy;
14658
+ if (object.doEditClick(ci, 0))
1454314659 {
1454414660 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1454514661 } else
....@@ -14554,7 +14670,8 @@
1455414670 Globals.MOUSEDRAGGED = false;
1455514671
1455614672 movingcamera = false;
14557
- X = Y = 0;
14673
+ X = 0; // getBounds().width/2;
14674
+ Y = 0; // getBounds().height/2;
1455814675 //System.out.println("mouseReleased: " + e);
1455914676 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1456014677 }
....@@ -14895,7 +15012,9 @@
1489515012 case 'E' : COMPACT ^= true;
1489615013 repaint();
1489715014 break;
14898
- case 'W' : DEBUGHSB ^= true;
15015
+ case 'W' : // Wide Window (fullscreen)
15016
+ //DEBUGHSB ^= true;
15017
+ ObjEditor.theFrame.ToggleFullScreen();
1489915018 repaint();
1490015019 break;
1490115020 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14921,13 +15040,7 @@
1492115040 repaint();
1492215041 break;
1492315042 case 'l':
14924
- lightMode ^= true;
14925
- Globals.lighttouched = true;
14926
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14927
- targetLookAt.set(manipCamera.lookAt);
14928
- repaint();
14929
- break;
14930
- case 'L':
15043
+ //case 'L':
1493115044 if (lightMode)
1493215045 {
1493315046 lightMode = false;
....@@ -15070,11 +15183,14 @@
1507015183 case '_':
1507115184 kompactbit = 5;
1507215185 break;
15073
- case '+':
15074
- kompactbit = 6;
15075
- break;
15186
+// case '+':
15187
+// kompactbit = 6;
15188
+// break;
1507615189 case ' ':
15077
- ObjEditor.theFrame.ToggleFullScreen();
15190
+ lightMode ^= true;
15191
+ Globals.lighttouched = true;
15192
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
15193
+ targetLookAt.set(manipCamera.lookAt);
1507815194 repaint();
1507915195 break;
1508015196 //case '`' :
....@@ -15121,8 +15237,9 @@
1512115237 case DELETE:
1512215238 ClearSelection();
1512315239 break;
15124
- /*
1512515240 case '+':
15241
+
15242
+ /*
1512615243 //fontsize += 1;
1512715244 bbzoom *= 2;
1512815245 repaint();
....@@ -15139,17 +15256,17 @@
1513915256 case '=':
1514015257 IncDepth();
1514115258 //fontsize += 1;
15142
- object.editWindow.refreshContents(true);
15259
+ object.GetWindow().refreshContents(true);
1514315260 maskbit = 6;
1514415261 break;
1514515262 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1514615263 DecDepth();
1514715264 maskbit = 5;
1514815265 //if(fontsize > 1) fontsize -= 1;
15149
- if (object.editWindow == null)
15150
- new Exception().printStackTrace();
15151
- else
15152
- object.editWindow.refreshContents(true);
15266
+// if (object.editWindow == null)
15267
+// new Exception().printStackTrace();
15268
+// else
15269
+ object.GetWindow().refreshContents(true);
1515315270 break;
1515415271 case '{':
1515515272 manipCamera.shaper_fovy /= 1.1;
....@@ -15373,7 +15490,7 @@
1537315490 }
1537415491 */
1537515492
15376
- object.editWindow.EditSelection();
15493
+ object.GetWindow().EditSelection(false);
1537715494 }
1537815495
1537915496 void SelectParent()
....@@ -15390,10 +15507,10 @@
1539015507 {
1539115508 //selectees.remove(i);
1539215509 System.out.println("select parent of " + elem);
15393
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15510
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1539415511 } else
1539515512 {
15396
- group.editWindow.Select(elem.GetTreePath(), first, true);
15513
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1539715514 }
1539815515
1539915516 first = false;
....@@ -15435,12 +15552,12 @@
1543515552 for (int j = 0; j < group.children.size(); j++)
1543615553 {
1543715554 elem = (Object3D) group.children.elementAt(j);
15438
- object.editWindow.Select(elem.GetTreePath(), first, true);
15555
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1543915556 first = false;
1544015557 }
1544115558 } else
1544215559 {
15443
- object.editWindow.Select(elem.GetTreePath(), first, true);
15560
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1544415561 }
1544515562
1544615563 first = false;
....@@ -15451,21 +15568,21 @@
1545115568 {
1545215569 //Composite group = (Composite) object;
1545315570 Object3D group = object;
15454
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15571
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1545515572 }
1545615573
1545715574 void ResetTransform(int mask)
1545815575 {
1545915576 //Composite group = (Composite) object;
1546015577 Object3D group = object;
15461
- group.editWindow.ResetTransform(mask);
15578
+ group.GetWindow().ResetTransform(mask);
1546215579 }
1546315580
1546415581 void FlipTransform()
1546515582 {
1546615583 //Composite group = (Composite) object;
1546715584 Object3D group = object;
15468
- group.editWindow.FlipTransform();
15585
+ group.GetWindow().FlipTransform();
1546915586 // group.editWindow.ReduceMesh(true);
1547015587 }
1547115588
....@@ -15473,7 +15590,7 @@
1547315590 {
1547415591 //Composite group = (Composite) object;
1547515592 Object3D group = object;
15476
- group.editWindow.PrintMemory();
15593
+ group.GetWindow().PrintMemory();
1547715594 // group.editWindow.ReduceMesh(true);
1547815595 }
1547915596
....@@ -15481,7 +15598,7 @@
1548115598 {
1548215599 //Composite group = (Composite) object;
1548315600 Object3D group = object;
15484
- group.editWindow.ResetCentroid();
15601
+ group.GetWindow().ResetCentroid();
1548515602 }
1548615603
1548715604 void IncDepth()
....@@ -15657,6 +15774,7 @@
1565715774 info.bounds.y += (height - desired) / 2;
1565815775 }
1565915776 }
15777
+
1566015778 info.g = gr;
1566115779 info.camera = renderCamera;
1566215780 /*
....@@ -15666,23 +15784,44 @@
1566615784 */
1566715785 if (!isRenderer)
1566815786 {
15669
- object.drawEditHandles(info, 0);
15670
-
15671
- 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)
1567215790 {
15673
- 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)
1567415797 {
15675
- case Object3D.hitCenter: gr.setColor(Color.pink);
15676
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15677
- break;
15678
- case Object3D.hitRotate: gr.setColor(Color.yellow);
15679
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15680
- break;
15681
- case Object3D.hitScale: gr.setColor(Color.cyan);
15682
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15683
- 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;
1568415805 }
15685
-
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
+ }
1568615825 }
1568715826 }
1568815827 }
....@@ -16385,16 +16524,16 @@
1638516524 cStatic.objectstack[materialdepth++] = checker;
1638616525 //System.out.println("material " + material);
1638716526 //Applet3D.tracein(this, selected);
16388
- vector2buffer = checker.projectedVertices;
16527
+ //vector2buffer = checker.projectedVertices;
1638916528
1639016529 //checker.GetMaterial().Draw(this, false); // true);
16391
- DrawMaterial(checker.GetMaterial(), false); // true);
16530
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1639216531
1639316532 materialdepth -= 1;
1639416533 if (materialdepth > 0)
1639516534 {
16396
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16397
- 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);
1639816537 }
1639916538 //checker.GetMaterial().opacity = 1f;
1640016539 ////checker.GetMaterial().ambient = 1f;
....@@ -16480,6 +16619,14 @@
1648016619 }
1648116620 }
1648216621
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
+
1648316630 class SelectBuffer implements GLEventListener
1648416631 {
1648516632
....@@ -16559,6 +16706,17 @@
1655916706
1656016707 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1656116708
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
+
1656216720 //int tmp = selection_view;
1656316721 //selection_view = -1;
1656416722 int temp = DrawMode();
....@@ -16570,6 +16728,17 @@
1657016728 // temp = DEFAULT; // patch for selection debug
1657116729 Globals.drawMode = temp; // WARNING
1657216730
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
+
1657316742 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1657416743
1657516744 // trying different ways of getting the depth info over
....@@ -16617,6 +16786,8 @@
1661716786 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1661816787 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1661916788 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16789
+
16790
+ CreateSelectedPoint();
1662016791
1662116792 // Will fit the mesh !!!
1662216793 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16671,29 +16842,31 @@
1667116842 }
1667216843
1667316844 if (!movingcamera && !PAINTMODE)
16674
- object.editWindow.ScreenFitPoint(); // fev 2014
16845
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1667516846
16676
- 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)
1667716848 {
16678
- 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);
1667916850
16680
- Object3D group = new Object3D("inst" + paintcount++);
16851
+ if (object.GetWindow().copy.selection.Size() > 0)
16852
+ {
16853
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1668116854
16682
- group.CreateMaterial(); // use a void leaf to select instances
16683
-
16684
- group.add(paintobj); // link
16685
-
16686
- object.editWindow.SnapObject(group);
16687
-
16688
- Object3D folder = object.editWindow.copy;
16689
-
16690
- if (object.editWindow.copy.selection.Size() > 0)
16691
- folder = object.editWindow.copy.selection.elementAt(0);
16692
-
16693
- folder.add(group);
16694
-
16695
- object.editWindow.ResetModel();
16696
- 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
+ }
1669716870 }
1669816871 else
1669916872 paintcount = 0;
....@@ -16732,6 +16905,11 @@
1673216905 //System.out.println("objects[color] = " + objects[color]);
1673316906 //objects[color].Select();
1673416907 indexcount = 0;
16908
+ ObjEditor window = object.GetWindow();
16909
+ if (window != null && deselect)
16910
+ {
16911
+ window.Select(null, deselect, true);
16912
+ }
1673516913 object.Select(color, deselect);
1673616914 }
1673716915