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
....@@ -1611,7 +1624,7 @@
16111624 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16121625 }
16131626
1614
- void DrawMaterial(cMaterial material, boolean selected)
1627
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16151628 {
16161629 CameraPane display = this;
16171630 //new Exception().printStackTrace();
....@@ -1646,7 +1659,7 @@
16461659 colorV[0] = display.modelParams0[0] * material.diffuse;
16471660 colorV[1] = display.modelParams0[1] * material.diffuse;
16481661 colorV[2] = display.modelParams0[2] * material.diffuse;
1649
- colorV[3] = material.opacity;
1662
+ colorV[3] = 1; // material.opacity;
16501663
16511664 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16521665 //System.out.println("Opacity = " + opacity);
....@@ -1754,9 +1767,9 @@
17541767 display.modelParams7[2] = 0;
17551768 display.modelParams7[3] = 0;
17561769
1757
- display.modelParams6[0] = 100; // criss de bug de bump
1770
+ //display.modelParams6[0] = 100; // criss de bug de bump
17581771
1759
- Object3D.cVector2[] extparams = display.vector2buffer;
1772
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17601773 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17611774 {
17621775 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -2052,7 +2065,7 @@
20522065 //System.err.println("Oeil on");
20532066 OEIL = true;
20542067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2055
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20562069 //pingthread.StepToTarget(true);
20572070 }
20582071
....@@ -2267,7 +2280,7 @@
22672280
22682281 void ToggleDebug()
22692282 {
2270
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22712284 }
22722285
22732286 void ToggleLookAt()
....@@ -2285,10 +2298,17 @@
22852298 HANDLES ^= true;
22862299 }
22872300
2301
+ Object3D paintFolder;
2302
+
22882303 void TogglePaint()
22892304 {
22902305 PAINTMODE ^= true;
22912306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
22922312 }
22932313
22942314 void SwapCamera(int a, int b)
....@@ -2385,6 +2405,45 @@
23852405 return currentGL;
23862406 }
23872407
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
+
23882447 /**/
23892448 class CacheTexture
23902449 {
....@@ -2402,9 +2461,10 @@
24022461 /**/
24032462
24042463 // TEXTURE static Texture texture;
2405
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2406
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2407
- 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
+
24082468 int pigmentdepth = 0;
24092469 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24102470 int bumpdepth = 0;
....@@ -2426,6 +2486,33 @@
24262486 true,
24272487 com.sun.opengl.util.texture.TextureIO.PNG);
24282488 } 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)
24292516 {
24302517 throw new javax.media.opengl.GLException(e);
24312518 }
....@@ -3512,6 +3599,8 @@
35123599
35133600 System.out.println("LOADING TEXTURE : " + name);
35143601
3602
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3603
+
35153604 //
35163605 if (false) // compressbit > 0)
35173606 {
....@@ -7910,7 +7999,7 @@
79107999 String pigment = Object3D.GetPigment(tex);
79118000 String bump = Object3D.GetBump(tex);
79128001
7913
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8002
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79148003 {
79158004 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79168005 // System.out.println("; bump = " + bump);
....@@ -7944,7 +8033,7 @@
79448033
79458034 String pigment = Object3D.GetPigment(tex);
79468035
7947
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8036
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79488037 {
79498038 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79508039 // System.out.println("; bump = " + bump);
....@@ -7973,7 +8062,7 @@
79738062
79748063 String bump = Object3D.GetBump(tex);
79758064
7976
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8065
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79778066 {
79788067 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79798068 // System.out.println("; bump = " + bump);
....@@ -8092,47 +8181,50 @@
80928181
80938182 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80948183 {
8095
- if (// DrawMode() != 0 || /*tex == null ||*/
8096
- ambientOcclusion ) // || !textureon)
8097
- {
8098
- return; // false;
8099
- }
8100
-
8101
- if (tex == null)
8102
- {
8103
- BindTexture(null,false,resolution);
8104
- BindTexture(null,true,resolution);
8105
- return;
8106
- }
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;
81078225
8108
- String pigment = Object3D.GetPigment(tex);
8109
- String bump = Object3D.GetBump(tex);
8110
-
8111
- usedtextures.put(pigment, pigment);
8112
- usedtextures.put(bump, bump);
8113
-
8114
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8115
- {
8116
- // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8117
- // System.out.println("; bump = " + bump);
8118
- }
8119
-
8120
- if (bump.equals(""))
8121
- {
8122
- bump = null;
8123
- }
8124
- if (pigment.equals(""))
8125
- {
8126
- pigment = null;
8127
- }
8128
-
8129
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8130
- BindTexture(pigment, false, resolution);
8131
- GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8132
- BindTexture(bump, true, resolution);
8133
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8134
-
8135
- return; // true;
8226
+ BindPigmentTexture(tex, resolution);
8227
+ BindBumpTexture(tex, resolution);
81368228 }
81378229
81388230 /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8145,15 +8237,15 @@
81458237
81468238 if (tex == null)
81478239 {
8148
- BindTexture(null,false,resolution);
8240
+ BindTexture(null, null,false,resolution);
81498241 return;
81508242 }
81518243
81528244 String pigment = Object3D.GetPigment(tex);
81538245
8154
- usedtextures.put(pigment, pigment);
8246
+ usedtextures.add(pigment);
81558247
8156
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8248
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81578249 {
81588250 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81598251 // System.out.println("; bump = " + bump);
....@@ -8165,7 +8257,7 @@
81658257 }
81668258
81678259 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8168
- BindTexture(pigment, false, resolution);
8260
+ BindTexture(tex.pigmenttexture, pigment, false, resolution);
81698261 }
81708262
81718263 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8178,15 +8270,15 @@
81788270
81798271 if (tex == null)
81808272 {
8181
- BindTexture(null,true,resolution);
8273
+ BindTexture(null, null,true,resolution);
81828274 return;
81838275 }
81848276
81858277 String bump = Object3D.GetBump(tex);
81868278
8187
- usedtextures.put(bump, bump);
8279
+ usedtextures.add(bump);
81888280
8189
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8281
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81908282 {
81918283 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81928284 // System.out.println("; bump = " + bump);
....@@ -8198,7 +8290,7 @@
81988290 }
81998291
82008292 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8201
- BindTexture(bump, true, resolution);
8293
+ BindTexture(tex.bumptexture, bump, true, resolution);
82028294 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
82038295 }
82048296
....@@ -8222,9 +8314,9 @@
82228314 return fileExists;
82238315 }
82248316
8225
- 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
82268318 {
8227
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8319
+ CacheTexture texturecache = null;
82288320
82298321 if (tex != null)
82308322 {
....@@ -8244,12 +8336,22 @@
82448336 }
82458337
82468338 if (CACHETEXTURE)
8247
- texture = textures.get(texname); // TEXTURE CACHE
8248
-
8249
- TextureData texturedata = null;
8250
-
8251
- if (texture == null || texture.resolution < resolution)
82528339 {
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
82538355 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
82548356 {
82558357 assert(!bump);
....@@ -8261,19 +8363,23 @@
82618363 // }
82628364 // else
82638365 // {
8264
- texture = textures.get(tex);
8265
- if (texture == null)
8366
+ texturecache = textures.get(tex);
8367
+ if (texturecache == null)
82668368 {
8267
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8369
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
82688370 }
8371
+ else
8372
+ new Exception().printStackTrace();
82698373 // }
82708374 } else
82718375 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
82728376 {
82738377 assert(bump);
8274
- texture = textures.get(tex);
8275
- if (texture == null)
8276
- 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();
82778383 } else
82788384 {
82798385 //if (tex.equals("IMMORTAL"))
....@@ -8283,9 +8389,11 @@
82838389 //{
82848390 if (tex.equals("WHITE_NOISE"))
82858391 {
8286
- texture = textures.get(tex);
8287
- if (texture == null)
8288
- 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();
82898397 } else
82908398 {
82918399 if (textureon)
....@@ -8344,19 +8452,20 @@
83448452 if (texturedata == null)
83458453 throw new Exception();
83468454
8347
- 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);
83488456 //texture = GetTexture(tex, bump);
83498457 }
83508458 }
83518459 //}
83528460 }
83538461
8354
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8462
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
83558463 {
83568464 //return false;
8465
+ assert(bim == null);
83578466
83588467 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8359
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8468
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
83608469 {
83618470 // String ext = "_highres";
83628471 // if (REDUCETEXTURE)
....@@ -8373,52 +8482,17 @@
83738482 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
83748483 if (!cachefile.exists())
83758484 {
8376
- // cache to disk
8377
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8378
- //buffers[0].
8379
-
8380
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8381
- int[] pixels = new int[bytebuf.capacity()/3];
8382
-
8383
- // squared size heuristic...
8384
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8485
+ //if (texturedata.getWidth() == texturedata.getHeight())
83858486 {
8386
- for (int i=pixels.length; --i>=0;)
8387
- {
8388
- int i3 = i*3;
8389
- pixels[i] = 0xFF;
8390
- pixels[i] <<= 8;
8391
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8392
- pixels[i] <<= 8;
8393
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8394
- pixels[i] <<= 8;
8395
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8396
- }
8397
-
8398
- /*
8399
- int r=0,g=0,b=0,a=0;
8400
- for (int i=0; i<width; i++)
8401
- for (int j=0; j<height; j++)
8402
- {
8403
- int index = j*width+i;
8404
- int p = pixels[index];
8405
- a = ((p>>24) & 0xFF);
8406
- r = ((p>>16) & 0xFF);
8407
- g = ((p>>8) & 0xFF);
8408
- b = (p & 0xFF);
8409
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8410
- }
8411
- /**/
8412
- int width = (int)Math.sqrt(pixels.length); // squared
8413
- int height = width;
8414
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8415
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8487
+ BufferedImage rendImage = CreateBim(texturedata);
8488
+
84168489 ImageWriter writer = null;
84178490 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
84188491 if (iter.hasNext()) {
84198492 writer = (ImageWriter)iter.next();
84208493 }
8421
- float compressionQuality = 0.9f;
8494
+
8495
+ float compressionQuality = 0.85f;
84228496 try
84238497 {
84248498 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8445,8 +8519,8 @@
84458519 textures.remove(texname);
84468520 }
84478521
8448
- texture.texturedata = texturedata;
8449
- textures.put(texname, texture);
8522
+ //texture.texturedata = texturedata;
8523
+ textures.put(texname, texturecache);
84508524
84518525 // newtex = true;
84528526 }
....@@ -8462,12 +8536,17 @@
84628536 }
84638537 }
84648538
8465
- return texture;
8539
+ return texturecache;
84668540 }
84678541
8468
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
8542
+ static void EmbedTextures(cTexture tex)
84698543 {
8470
- 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);
84718550
84728551 if (bump)
84738552 {
....@@ -8483,23 +8562,23 @@
84838562 return texture!=null?texture.texture:null;
84848563 }
84858564
8486
- 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
84878566 {
8488
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8567
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
84898568
84908569 return texture!=null?texture.texturedata:null;
84918570 }
84928571
8493
- 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
84948573 {
84958574 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
84968575 {
84978576 return false;
84988577 }
84998578
8500
- boolean newtex = false;
8579
+ //boolean newtex = false;
85018580
8502
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8581
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
85038582
85048583 if (texture == null)
85058584 return false;
....@@ -8529,7 +8608,7 @@
85298608 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
85308609 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
85318610
8532
- return newtex;
8611
+ return true; // Warning: not used.
85338612 }
85348613
85358614 ShadowBuffer shadowPBuf;
....@@ -9367,11 +9446,35 @@
93679446 jy8[3] = 0.5f;
93689447 }
93699448
9370
- 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
93719450 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
93729451 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
93739452 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
93749453
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
+
93759478 static int imagecount = 0; // movie generation
93769479
93779480 static int jitter = 0;
....@@ -10482,6 +10585,7 @@
1048210585 ANTIALIAS = 0;
1048310586 //System.out.println("RESTART");
1048410587 AAtimer.restart();
10588
+ Globals.TIMERRUNNING = true;
1048510589 }
1048610590 }
1048710591 }
....@@ -10549,7 +10653,8 @@
1054910653 ambientOcclusion = false;
1055010654 }
1055110655
10552
- if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
10656
+ if (//Globals.lighttouched &&
10657
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1055310658 {
1055410659 //if (RENDERSHADOW) // ?
1055510660 if (!IsFrozen())
....@@ -10960,7 +11065,7 @@
1096011065
1096111066 try
1096211067 {
10963
- BindTexture(NOISE_TEXTURE, false, 2);
11068
+ BindTexture(null, NOISE_TEXTURE, false, 2);
1096411069 }
1096511070 catch (Exception e)
1096611071 {
....@@ -10989,9 +11094,9 @@
1098911094
1099011095 gl.glMatrixMode(GL.GL_MODELVIEW);
1099111096
10992
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10993
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10994
-//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);
1099511100 } else
1099611101 {
1099711102 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -11002,7 +11107,7 @@
1100211107 //System.out.println("BLENDING ON");
1100311108 gl.glEnable(GL.GL_BLEND);
1100411109 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
11005
-
11110
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1100611111 gl.glMatrixMode(gl.GL_PROJECTION);
1100711112 gl.glLoadIdentity();
1100811113
....@@ -11459,15 +11564,36 @@
1145911564
1146011565 static boolean zoomonce = false;
1146111566
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
+
1146211585 void DrawObject(GL gl, boolean draw)
1146311586 {
11587
+ // To clear camera values
11588
+ ResetOptions();
11589
+
1146411590 //System.out.println("DRAW OBJECT " + mouseDown);
1146511591 // DrawMode() = SELECTION;
1146611592 //GL gl = getGL();
1146711593 if ((TRACK || SHADOWTRACK) || zoomonce)
1146811594 {
1146911595 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11470
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11596
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1147111597 pingthread.StepToTarget(true); // true);
1147211598 // zoomonce = false;
1147311599 }
....@@ -11539,8 +11665,9 @@
1153911665
1154011666 if (DrawMode() == DEFAULT)
1154111667 {
11542
- if (DEBUG)
11668
+ if (Globals.DEBUG)
1154311669 {
11670
+ CreateSelectedPoint();
1154411671 float radius = 0.05f;
1154511672 if (selectedpoint.radius != radius)
1154611673 {
....@@ -11603,7 +11730,7 @@
1160311730 if (tex.equals("WHITE_NOISE"))
1160411731 continue;
1160511732
11606
- if (!usedtextures.containsKey(tex))
11733
+ if (!usedtextures.contains(tex))
1160711734 {
1160811735 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1160911736 textures.get(tex).texture.dispose();
....@@ -12027,7 +12154,7 @@
1202712154 for (int i = tp.size(); --i >= 0;)
1202812155 {
1202912156 //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12030
- LA.xformPos(light, tp.get(i).GlobalTransform(), light);
12157
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1203112158 }
1203212159
1203312160
....@@ -13297,7 +13424,8 @@
1329713424 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1329813425 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1329913426 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13300
- Object3D.cVector2[] vector2buffer;
13427
+
13428
+ //Object3D.cVector2[] vector2buffer;
1330113429
1330213430 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1330313431 // OUT : diff, spec
....@@ -13313,9 +13441,10 @@
1331313441 "DP3 " + dest + ".z," + "normals," + "eye;" +
1331413442 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1331513443 //"MOV " + dest + ".w," + "normal.z;" +
13316
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13317
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13318
- //"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
1331913448 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1332013449 "RCP " + dest + ".w," + dest + ".w;" +
1332113450 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13820,6 +13949,7 @@
1382013949 else
1382113950 if (evt.getSource() == AAtimer)
1382213951 {
13952
+ Globals.TIMERRUNNING = false;
1382313953 if (mouseDown)
1382413954 {
1382513955 //new Exception().printStackTrace();
....@@ -13879,7 +14009,7 @@
1387914009
1388014010 // fev 2014???
1388114011 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13882
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14012
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1388314013 pingthread.StepToTarget(true); // true);
1388414014 }
1388514015 // if (!LIVE)
....@@ -13894,6 +14024,7 @@
1389414024 return;
1389514025
1389614026 AAtimer.restart(); //
14027
+ Globals.TIMERRUNNING = true;
1389714028
1389814029 // waslive = LIVE;
1389914030 // LIVE = false;
....@@ -14232,12 +14363,12 @@
1423214363 void GoDown(int mod)
1423314364 {
1423414365 MODIFIERS |= COMMAND;
14235
- /*
14366
+ /**/
1423614367 if((mod&SHIFT) == SHIFT)
1423714368 manipCamera.RotatePosition(0, -speed);
1423814369 else
14239
- manipCamera.BackForth(0, -speed*delta, getWidth());
14240
- */
14370
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14371
+ /**/
1424114372 if ((mod & SHIFT) == SHIFT)
1424214373 {
1424314374 mouseMode = mouseMode; // VR??
....@@ -14253,12 +14384,12 @@
1425314384 void GoUp(int mod)
1425414385 {
1425514386 MODIFIERS |= COMMAND;
14256
- /*
14387
+ /**/
1425714388 if((mod&SHIFT) == SHIFT)
1425814389 manipCamera.RotatePosition(0, speed);
1425914390 else
14260
- manipCamera.BackForth(0, speed*delta, getWidth());
14261
- */
14391
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14392
+ /**/
1426214393 if ((mod & SHIFT) == SHIFT)
1426314394 {
1426414395 mouseMode = mouseMode;
....@@ -14274,12 +14405,12 @@
1427414405 void GoLeft(int mod)
1427514406 {
1427614407 MODIFIERS |= COMMAND;
14277
- /*
14408
+ /**/
1427814409 if((mod&SHIFT) == SHIFT)
14279
- manipCamera.RotatePosition(speed, 0);
14280
- else
1428114410 manipCamera.Translate(speed*delta, 0, getWidth());
14282
- */
14411
+ else
14412
+ manipCamera.RotatePosition(speed, 0);
14413
+ /**/
1428314414 if ((mod & SHIFT) == SHIFT)
1428414415 {
1428514416 mouseMode = mouseMode;
....@@ -14295,12 +14426,12 @@
1429514426 void GoRight(int mod)
1429614427 {
1429714428 MODIFIERS |= COMMAND;
14298
- /*
14429
+ /**/
1429914430 if((mod&SHIFT) == SHIFT)
14300
- manipCamera.RotatePosition(-speed, 0);
14301
- else
1430214431 manipCamera.Translate(-speed*delta, 0, getWidth());
14303
- */
14432
+ else
14433
+ manipCamera.RotatePosition(-speed, 0);
14434
+ /**/
1430414435 if ((mod & SHIFT) == SHIFT)
1430514436 {
1430614437 mouseMode = mouseMode;
....@@ -14357,7 +14488,8 @@
1435714488 info.camera = renderCamera;
1435814489 info.x = x;
1435914490 info.y = y;
14360
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14491
+ object.GetWindow().copy
14492
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1436114493 } else
1436214494 {
1436314495 if (x < startX)
....@@ -14521,7 +14653,9 @@
1452114653 ci.camera = renderCamera;
1452214654 if (!isRenderer)
1452314655 {
14524
- if (object.editWindow.copy.doEditClick(ci, 0))
14656
+ //ObjEditor editWindow = object.editWindow;
14657
+ //Object3D copy = editWindow.copy;
14658
+ if (object.doEditClick(ci, 0))
1452514659 {
1452614660 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1452714661 } else
....@@ -14536,7 +14670,8 @@
1453614670 Globals.MOUSEDRAGGED = false;
1453714671
1453814672 movingcamera = false;
14539
- X = Y = 0;
14673
+ X = 0; // getBounds().width/2;
14674
+ Y = 0; // getBounds().height/2;
1454014675 //System.out.println("mouseReleased: " + e);
1454114676 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1454214677 }
....@@ -14877,7 +15012,9 @@
1487715012 case 'E' : COMPACT ^= true;
1487815013 repaint();
1487915014 break;
14880
- case 'W' : DEBUGHSB ^= true;
15015
+ case 'W' : // Wide Window (fullscreen)
15016
+ //DEBUGHSB ^= true;
15017
+ ObjEditor.theFrame.ToggleFullScreen();
1488115018 repaint();
1488215019 break;
1488315020 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14902,8 +15039,8 @@
1490215039 RevertCamera();
1490315040 repaint();
1490415041 break;
14905
- case 'L':
1490615042 case 'l':
15043
+ //case 'L':
1490715044 if (lightMode)
1490815045 {
1490915046 lightMode = false;
....@@ -15046,9 +15183,9 @@
1504615183 case '_':
1504715184 kompactbit = 5;
1504815185 break;
15049
- case '+':
15050
- kompactbit = 6;
15051
- break;
15186
+// case '+':
15187
+// kompactbit = 6;
15188
+// break;
1505215189 case ' ':
1505315190 lightMode ^= true;
1505415191 Globals.lighttouched = true;
....@@ -15060,6 +15197,7 @@
1506015197 case ESC:
1506115198 RENDERPROGRAM += 1;
1506215199 RENDERPROGRAM %= 3;
15200
+
1506315201 repaint();
1506415202 break;
1506515203 case 'Z':
....@@ -15099,8 +15237,9 @@
1509915237 case DELETE:
1510015238 ClearSelection();
1510115239 break;
15102
- /*
1510315240 case '+':
15241
+
15242
+ /*
1510415243 //fontsize += 1;
1510515244 bbzoom *= 2;
1510615245 repaint();
....@@ -15117,17 +15256,17 @@
1511715256 case '=':
1511815257 IncDepth();
1511915258 //fontsize += 1;
15120
- object.editWindow.refreshContents(true);
15259
+ object.GetWindow().refreshContents(true);
1512115260 maskbit = 6;
1512215261 break;
1512315262 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1512415263 DecDepth();
1512515264 maskbit = 5;
1512615265 //if(fontsize > 1) fontsize -= 1;
15127
- if (object.editWindow == null)
15128
- new Exception().printStackTrace();
15129
- else
15130
- object.editWindow.refreshContents(true);
15266
+// if (object.editWindow == null)
15267
+// new Exception().printStackTrace();
15268
+// else
15269
+ object.GetWindow().refreshContents(true);
1513115270 break;
1513215271 case '{':
1513315272 manipCamera.shaper_fovy /= 1.1;
....@@ -15351,7 +15490,7 @@
1535115490 }
1535215491 */
1535315492
15354
- object.editWindow.EditSelection();
15493
+ object.GetWindow().EditSelection(false);
1535515494 }
1535615495
1535715496 void SelectParent()
....@@ -15368,10 +15507,10 @@
1536815507 {
1536915508 //selectees.remove(i);
1537015509 System.out.println("select parent of " + elem);
15371
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15510
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1537215511 } else
1537315512 {
15374
- group.editWindow.Select(elem.GetTreePath(), first, true);
15513
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1537515514 }
1537615515
1537715516 first = false;
....@@ -15413,12 +15552,12 @@
1541315552 for (int j = 0; j < group.children.size(); j++)
1541415553 {
1541515554 elem = (Object3D) group.children.elementAt(j);
15416
- object.editWindow.Select(elem.GetTreePath(), first, true);
15555
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1541715556 first = false;
1541815557 }
1541915558 } else
1542015559 {
15421
- object.editWindow.Select(elem.GetTreePath(), first, true);
15560
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1542215561 }
1542315562
1542415563 first = false;
....@@ -15429,21 +15568,21 @@
1542915568 {
1543015569 //Composite group = (Composite) object;
1543115570 Object3D group = object;
15432
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15571
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1543315572 }
1543415573
1543515574 void ResetTransform(int mask)
1543615575 {
1543715576 //Composite group = (Composite) object;
1543815577 Object3D group = object;
15439
- group.editWindow.ResetTransform(mask);
15578
+ group.GetWindow().ResetTransform(mask);
1544015579 }
1544115580
1544215581 void FlipTransform()
1544315582 {
1544415583 //Composite group = (Composite) object;
1544515584 Object3D group = object;
15446
- group.editWindow.FlipTransform();
15585
+ group.GetWindow().FlipTransform();
1544715586 // group.editWindow.ReduceMesh(true);
1544815587 }
1544915588
....@@ -15451,7 +15590,7 @@
1545115590 {
1545215591 //Composite group = (Composite) object;
1545315592 Object3D group = object;
15454
- group.editWindow.PrintMemory();
15593
+ group.GetWindow().PrintMemory();
1545515594 // group.editWindow.ReduceMesh(true);
1545615595 }
1545715596
....@@ -15459,7 +15598,7 @@
1545915598 {
1546015599 //Composite group = (Composite) object;
1546115600 Object3D group = object;
15462
- group.editWindow.ResetCentroid();
15601
+ group.GetWindow().ResetCentroid();
1546315602 }
1546415603
1546515604 void IncDepth()
....@@ -15635,6 +15774,7 @@
1563515774 info.bounds.y += (height - desired) / 2;
1563615775 }
1563715776 }
15777
+
1563815778 info.g = gr;
1563915779 info.camera = renderCamera;
1564015780 /*
....@@ -15644,23 +15784,44 @@
1564415784 */
1564515785 if (!isRenderer)
1564615786 {
15647
- object.drawEditHandles(info, 0);
15648
-
15649
- 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)
1565015790 {
15651
- 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)
1565215797 {
15653
- case Object3D.hitCenter: gr.setColor(Color.pink);
15654
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15655
- break;
15656
- case Object3D.hitRotate: gr.setColor(Color.yellow);
15657
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15658
- break;
15659
- case Object3D.hitScale: gr.setColor(Color.cyan);
15660
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15661
- 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;
1566215805 }
15663
-
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
+ }
1566415825 }
1566515826 }
1566615827 }
....@@ -16363,16 +16524,16 @@
1636316524 cStatic.objectstack[materialdepth++] = checker;
1636416525 //System.out.println("material " + material);
1636516526 //Applet3D.tracein(this, selected);
16366
- vector2buffer = checker.projectedVertices;
16527
+ //vector2buffer = checker.projectedVertices;
1636716528
1636816529 //checker.GetMaterial().Draw(this, false); // true);
16369
- DrawMaterial(checker.GetMaterial(), false); // true);
16530
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1637016531
1637116532 materialdepth -= 1;
1637216533 if (materialdepth > 0)
1637316534 {
16374
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16375
- 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);
1637616537 }
1637716538 //checker.GetMaterial().opacity = 1f;
1637816539 ////checker.GetMaterial().ambient = 1f;
....@@ -16458,6 +16619,14 @@
1645816619 }
1645916620 }
1646016621
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
+
1646116630 class SelectBuffer implements GLEventListener
1646216631 {
1646316632
....@@ -16537,6 +16706,17 @@
1653716706
1653816707 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1653916708
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
+
1654016720 //int tmp = selection_view;
1654116721 //selection_view = -1;
1654216722 int temp = DrawMode();
....@@ -16548,6 +16728,17 @@
1654816728 // temp = DEFAULT; // patch for selection debug
1654916729 Globals.drawMode = temp; // WARNING
1655016730
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
+
1655116742 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1655216743
1655316744 // trying different ways of getting the depth info over
....@@ -16595,6 +16786,8 @@
1659516786 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1659616787 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1659716788 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16789
+
16790
+ CreateSelectedPoint();
1659816791
1659916792 // Will fit the mesh !!!
1660016793 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16649,29 +16842,31 @@
1664916842 }
1665016843
1665116844 if (!movingcamera && !PAINTMODE)
16652
- object.editWindow.ScreenFitPoint(); // fev 2014
16845
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1665316846
16654
- 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)
1665516848 {
16656
- 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);
1665716850
16658
- Object3D group = new Object3D("inst" + paintcount++);
16851
+ if (object.GetWindow().copy.selection.Size() > 0)
16852
+ {
16853
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1665916854
16660
- group.CreateMaterial(); // use a void leaf to select instances
16661
-
16662
- group.add(paintobj); // link
16663
-
16664
- object.editWindow.SnapObject(group);
16665
-
16666
- Object3D folder = object.editWindow.copy;
16667
-
16668
- if (object.editWindow.copy.selection.Size() > 0)
16669
- folder = object.editWindow.copy.selection.elementAt(0);
16670
-
16671
- folder.add(group);
16672
-
16673
- object.editWindow.ResetModel();
16674
- 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
+ }
1667516870 }
1667616871 else
1667716872 paintcount = 0;
....@@ -16710,6 +16905,11 @@
1671016905 //System.out.println("objects[color] = " + objects[color]);
1671116906 //objects[color].Select();
1671216907 indexcount = 0;
16908
+ ObjEditor window = object.GetWindow();
16909
+ if (window != null && deselect)
16910
+ {
16911
+ window.Select(null, deselect, true);
16912
+ }
1671316913 object.Select(color, deselect);
1671416914 }
1671516915
....@@ -17235,23 +17435,15 @@
1723517435 int AAbuffersize = 0;
1723617436
1723717437 //double[] selectedpoint = new double[3];
17238
- static Superellipsoid selectedpoint = new Superellipsoid();
17438
+ static Superellipsoid selectedpoint;
1723917439 static Sphere previousselectedpoint = null;
17240
- static Sphere debugpointG = new Sphere();
17241
- static Sphere debugpointP = new Sphere();
17242
- static Sphere debugpointC = new Sphere();
17243
- static Sphere debugpointR = new Sphere();
17440
+ static Sphere debugpointG;
17441
+ static Sphere debugpointP;
17442
+ static Sphere debugpointC;
17443
+ static Sphere debugpointR;
1724417444
1724517445 static Sphere debugpoints[] = new Sphere[8];
1724617446
17247
- static
17248
- {
17249
- for (int i=0; i<8; i++)
17250
- {
17251
- debugpoints[i] = new Sphere();
17252
- }
17253
- }
17254
-
1725517447 static void InitPoints(float radius)
1725617448 {
1725717449 for (int i=0; i<8; i++)