Normand Briere
2019-07-20 0a52bd4800459cd9935f360d7ca9555b6bea2146
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
....@@ -327,7 +326,7 @@
327326 cStatic.objectstack[materialdepth++] = obj;
328327 //System.out.println("material " + material);
329328 //Applet3D.tracein(this, selected);
330
- display.vector2buffer = obj.projectedVertices;
329
+ //display.vector2buffer = obj.projectedVertices;
331330 if (obj instanceof Camera)
332331 {
333332 display.options1[0] = material.shift;
....@@ -336,14 +335,28 @@
336335 display.options1[2] = material.shadowbias;
337336 display.options1[3] = material.aniso;
338337 display.options1[4] = material.anisoV;
338
+// System.out.println("display.options1[0] " + display.options1[0]);
339
+// System.out.println("display.options1[1] " + display.options1[1]);
340
+// System.out.println("display.options1[2] " + display.options1[2]);
341
+// System.out.println("display.options1[3] " + display.options1[3]);
342
+// System.out.println("display.options1[4] " + display.options1[4]);
339343 display.options2[0] = material.opacity;
340344 display.options2[1] = material.diffuse;
341345 display.options2[2] = material.factor;
346
+// System.out.println("display.options2[0] " + display.options2[0]);
347
+// System.out.println("display.options2[1] " + display.options2[1]);
348
+// System.out.println("display.options2[2] " + display.options2[2]);
342349
343350 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
351
+// System.out.println("display.options3[0] " + display.options3[0]);
352
+// System.out.println("display.options3[1] " + display.options3[1]);
353
+// System.out.println("display.options3[2] " + display.options3[2]);
344354 display.options4[0] = material.cameralight/0.2f;
345355 display.options4[1] = material.subsurface;
346356 display.options4[2] = material.sheen;
357
+// System.out.println("display.options4[0] " + display.options4[0]);
358
+// System.out.println("display.options4[1] " + display.options4[1]);
359
+// System.out.println("display.options4[2] " + display.options4[2]);
347360
348361 // if (display.CURRENTANTIALIAS > 0)
349362 // display.options3[3] /= 4;
....@@ -359,7 +372,7 @@
359372 /**/
360373 } else
361374 {
362
- DrawMaterial(material, selected);
375
+ DrawMaterial(material, selected, obj.projectedVertices);
363376 }
364377 } else
365378 {
....@@ -383,8 +396,8 @@
383396 cStatic.objectstack[materialdepth++] = obj;
384397 //System.out.println("material " + material);
385398 //Applet3D.tracein("selected ", selected);
386
- display.vector2buffer = obj.projectedVertices;
387
- display.DrawMaterial(material, selected);
399
+ //display.vector2buffer = obj.projectedVertices;
400
+ display.DrawMaterial(material, selected, obj.projectedVertices);
388401 }
389402 }
390403
....@@ -401,8 +414,8 @@
401414 materialdepth -= 1;
402415 if (materialdepth > 0)
403416 {
404
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
405
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
417
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
418
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
406419 }
407420 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
408421 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -422,8 +435,8 @@
422435 materialdepth -= 1;
423436 if (materialdepth > 0)
424437 {
425
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
426
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
438
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
439
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
427440 }
428441 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
429442 //else
....@@ -464,10 +477,12 @@
464477 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
465478 {
466479 //gl.glBegin(gl.GL_TRIANGLES);
467
- boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
480
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
481
+ // TEST LIVE NORMALS && !obj.dontselect
482
+ ;
468483 if (!hasnorm)
469484 {
470
- // System.out.println("FUCK!!");
485
+ // System.out.println("Mesh normal");
471486 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
472487 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
473488 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1192,10 +1207,12 @@
11921207 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11931208 }
11941209 }
1210
+
11951211 if (flipV)
11961212 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11971213 else
11981214 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1215
+
11991216 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12001217 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12011218
....@@ -1215,10 +1232,12 @@
12151232 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12161233 }
12171234 }
1235
+
12181236 if (flipV)
12191237 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12201238 else
12211239 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1240
+
12221241 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12231242 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12241243
....@@ -1246,8 +1265,10 @@
12461265 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12471266 else
12481267 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1268
+
12491269 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12501270 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1271
+
12511272 count2 += 2;
12521273 count3 += 3;
12531274 }
....@@ -1603,7 +1624,7 @@
16031624 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16041625 }
16051626
1606
- void DrawMaterial(cMaterial material, boolean selected)
1627
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16071628 {
16081629 CameraPane display = this;
16091630 //new Exception().printStackTrace();
....@@ -1638,7 +1659,7 @@
16381659 colorV[0] = display.modelParams0[0] * material.diffuse;
16391660 colorV[1] = display.modelParams0[1] * material.diffuse;
16401661 colorV[2] = display.modelParams0[2] * material.diffuse;
1641
- colorV[3] = material.opacity;
1662
+ colorV[3] = 1; // material.opacity;
16421663
16431664 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16441665 //System.out.println("Opacity = " + opacity);
....@@ -1746,9 +1767,9 @@
17461767 display.modelParams7[2] = 0;
17471768 display.modelParams7[3] = 0;
17481769
1749
- display.modelParams6[0] = 100; // criss de bug de bump
1770
+ //display.modelParams6[0] = 100; // criss de bug de bump
17501771
1751
- Object3D.cVector2[] extparams = display.vector2buffer;
1772
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17521773 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17531774 {
17541775 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -2044,7 +2065,7 @@
20442065 //System.err.println("Oeil on");
20452066 OEIL = true;
20462067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2047
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20482069 //pingthread.StepToTarget(true);
20492070 }
20502071
....@@ -2259,7 +2280,7 @@
22592280
22602281 void ToggleDebug()
22612282 {
2262
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22632284 }
22642285
22652286 void ToggleLookAt()
....@@ -2277,10 +2298,17 @@
22772298 HANDLES ^= true;
22782299 }
22792300
2301
+ Object3D paintFolder;
2302
+
22802303 void TogglePaint()
22812304 {
22822305 PAINTMODE ^= true;
22832306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
22842312 }
22852313
22862314 void SwapCamera(int a, int b)
....@@ -7921,6 +7949,64 @@
79217949 ReleaseTexture(pigment, false);
79227950 }
79237951
7952
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7953
+ {
7954
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7955
+ {
7956
+ return;
7957
+ }
7958
+
7959
+ if (tex == null)
7960
+ {
7961
+ ReleaseTexture(null, false);
7962
+ return;
7963
+ }
7964
+
7965
+ String pigment = Object3D.GetPigment(tex);
7966
+
7967
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7968
+ {
7969
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7970
+ // System.out.println("; bump = " + bump);
7971
+ }
7972
+
7973
+ if (pigment.equals(""))
7974
+ {
7975
+ pigment = null;
7976
+ }
7977
+
7978
+ ReleaseTexture(pigment, false);
7979
+ }
7980
+
7981
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
7982
+ {
7983
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7984
+ {
7985
+ return;
7986
+ }
7987
+
7988
+ if (tex == null)
7989
+ {
7990
+ ReleaseTexture(null, true);
7991
+ return;
7992
+ }
7993
+
7994
+ String bump = Object3D.GetBump(tex);
7995
+
7996
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7997
+ {
7998
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7999
+ // System.out.println("; bump = " + bump);
8000
+ }
8001
+
8002
+ if (bump.equals(""))
8003
+ {
8004
+ bump = null;
8005
+ }
8006
+
8007
+ ReleaseTexture(bump, true);
8008
+ }
8009
+
79248010 void ReleaseTexture(String tex, boolean bump)
79258011 {
79268012 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8067,6 +8153,73 @@
80678153 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
80688154
80698155 return; // true;
8156
+ }
8157
+
8158
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8159
+ {
8160
+ if (// DrawMode() != 0 || /*tex == null ||*/
8161
+ ambientOcclusion ) // || !textureon)
8162
+ {
8163
+ return; // false;
8164
+ }
8165
+
8166
+ if (tex == null)
8167
+ {
8168
+ BindTexture(null,false,resolution);
8169
+ return;
8170
+ }
8171
+
8172
+ String pigment = Object3D.GetPigment(tex);
8173
+
8174
+ usedtextures.put(pigment, pigment);
8175
+
8176
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8177
+ {
8178
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8179
+ // System.out.println("; bump = " + bump);
8180
+ }
8181
+
8182
+ if (pigment.equals(""))
8183
+ {
8184
+ pigment = null;
8185
+ }
8186
+
8187
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8188
+ BindTexture(pigment, false, resolution);
8189
+ }
8190
+
8191
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8192
+ {
8193
+ if (// DrawMode() != 0 || /*tex == null ||*/
8194
+ ambientOcclusion ) // || !textureon)
8195
+ {
8196
+ return; // false;
8197
+ }
8198
+
8199
+ if (tex == null)
8200
+ {
8201
+ BindTexture(null,true,resolution);
8202
+ return;
8203
+ }
8204
+
8205
+ String bump = Object3D.GetBump(tex);
8206
+
8207
+ usedtextures.put(bump, bump);
8208
+
8209
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8210
+ {
8211
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8212
+ // System.out.println("; bump = " + bump);
8213
+ }
8214
+
8215
+ if (bump.equals(""))
8216
+ {
8217
+ bump = null;
8218
+ }
8219
+
8220
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8221
+ BindTexture(bump, true, resolution);
8222
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
80708223 }
80718224
80728225 java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
....@@ -8357,7 +8510,7 @@
83578510 return texture!=null?texture.texturedata:null;
83588511 }
83598512
8360
- boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
8513
+ com.sun.opengl.util.texture.Texture BindTexture(String tex, boolean bump, int resolution) throws Exception
83618514 {
83628515 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83638516 {
....@@ -8369,7 +8522,7 @@
83698522 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
83708523
83718524 if (texture == null)
8372
- return false;
8525
+ return texture;
83738526 /**/
83748527
83758528 if (textureon || tex.equals("DEFAULT_TEXTURE") || tex.equals("DEFAULT_TEXTURE_BUMP") || tex.equals("WHITE_NOISE")) // || tex.equals("IMMORTAL"))
....@@ -9234,11 +9387,35 @@
92349387 jy8[3] = 0.5f;
92359388 }
92369389
9237
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9390
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
92389391 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92399392 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92409393 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92419394
9395
+ void ResetOptions()
9396
+ {
9397
+ options1[0] = 100;
9398
+ options1[1] = 0.025f;
9399
+ options1[2] = 0.01f;
9400
+ options1[3] = 0;
9401
+ options1[4] = 0;
9402
+
9403
+ options2[0] = 0;
9404
+ options2[1] = 0.75f;
9405
+ options2[2] = 0;
9406
+ options2[3] = 0;
9407
+
9408
+ options3[0] = 1;
9409
+ options3[1] = 1;
9410
+ options3[2] = 1;
9411
+ options3[3] = 0;
9412
+
9413
+ options4[0] = 1;
9414
+ options4[1] = 0;
9415
+ options4[2] = 1;
9416
+ options4[3] = 0;
9417
+ }
9418
+
92429419 static int imagecount = 0; // movie generation
92439420
92449421 static int jitter = 0;
....@@ -10349,6 +10526,7 @@
1034910526 ANTIALIAS = 0;
1035010527 //System.out.println("RESTART");
1035110528 AAtimer.restart();
10529
+ Globals.TIMERRUNNING = true;
1035210530 }
1035310531 }
1035410532 }
....@@ -10416,7 +10594,8 @@
1041610594 ambientOcclusion = false;
1041710595 }
1041810596
10419
- if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
10597
+ if (//Globals.lighttouched &&
10598
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1042010599 {
1042110600 //if (RENDERSHADOW) // ?
1042210601 if (!IsFrozen())
....@@ -10856,9 +11035,9 @@
1085611035
1085711036 gl.glMatrixMode(GL.GL_MODELVIEW);
1085811037
10859
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10860
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10861
-//gl.glEnable(gl.GL_MULTISAMPLE);
11038
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11039
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11040
+gl.glEnable(gl.GL_MULTISAMPLE);
1086211041 } else
1086311042 {
1086411043 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10869,7 +11048,7 @@
1086911048 //System.out.println("BLENDING ON");
1087011049 gl.glEnable(GL.GL_BLEND);
1087111050 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10872
-
11051
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1087311052 gl.glMatrixMode(gl.GL_PROJECTION);
1087411053 gl.glLoadIdentity();
1087511054
....@@ -11326,15 +11505,36 @@
1132611505
1132711506 static boolean zoomonce = false;
1132811507
11508
+ static void CreateSelectedPoint()
11509
+ {
11510
+ if (selectedpoint == null)
11511
+ {
11512
+ debugpointG = new Sphere();
11513
+ debugpointP = new Sphere();
11514
+ debugpointC = new Sphere();
11515
+ debugpointR = new Sphere();
11516
+
11517
+ selectedpoint = new Superellipsoid();
11518
+
11519
+ for (int i=0; i<8; i++)
11520
+ {
11521
+ debugpoints[i] = new Sphere();
11522
+ }
11523
+ }
11524
+ }
11525
+
1132911526 void DrawObject(GL gl, boolean draw)
1133011527 {
11528
+ // To clear camera values
11529
+ ResetOptions();
11530
+
1133111531 //System.out.println("DRAW OBJECT " + mouseDown);
1133211532 // DrawMode() = SELECTION;
1133311533 //GL gl = getGL();
1133411534 if ((TRACK || SHADOWTRACK) || zoomonce)
1133511535 {
1133611536 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11337
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11537
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1133811538 pingthread.StepToTarget(true); // true);
1133911539 // zoomonce = false;
1134011540 }
....@@ -11406,8 +11606,9 @@
1140611606
1140711607 if (DrawMode() == DEFAULT)
1140811608 {
11409
- if (DEBUG)
11609
+ if (Globals.DEBUG)
1141011610 {
11611
+ CreateSelectedPoint();
1141111612 float radius = 0.05f;
1141211613 if (selectedpoint.radius != radius)
1141311614 {
....@@ -11894,7 +12095,7 @@
1189412095 for (int i = tp.size(); --i >= 0;)
1189512096 {
1189612097 //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11897
- LA.xformPos(light, tp.get(i).GlobalTransform(), light);
12098
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1189812099 }
1189912100
1190012101
....@@ -13164,7 +13365,8 @@
1316413365 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1316513366 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1316613367 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13167
- Object3D.cVector2[] vector2buffer;
13368
+
13369
+ //Object3D.cVector2[] vector2buffer;
1316813370
1316913371 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1317013372 // OUT : diff, spec
....@@ -13180,9 +13382,10 @@
1318013382 "DP3 " + dest + ".z," + "normals," + "eye;" +
1318113383 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1318213384 //"MOV " + dest + ".w," + "normal.z;" +
13183
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13184
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13185
- //"MOV " + dest + ".z," + "params2.w;" +
13385
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13386
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13387
+
13388
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1318613389 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1318713390 "RCP " + dest + ".w," + dest + ".w;" +
1318813391 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13687,6 +13890,7 @@
1368713890 else
1368813891 if (evt.getSource() == AAtimer)
1368913892 {
13893
+ Globals.TIMERRUNNING = false;
1369013894 if (mouseDown)
1369113895 {
1369213896 //new Exception().printStackTrace();
....@@ -13746,7 +13950,7 @@
1374613950
1374713951 // fev 2014???
1374813952 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13749
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13953
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1375013954 pingthread.StepToTarget(true); // true);
1375113955 }
1375213956 // if (!LIVE)
....@@ -13761,6 +13965,7 @@
1376113965 return;
1376213966
1376313967 AAtimer.restart(); //
13968
+ Globals.TIMERRUNNING = true;
1376413969
1376513970 // waslive = LIVE;
1376613971 // LIVE = false;
....@@ -14099,12 +14304,12 @@
1409914304 void GoDown(int mod)
1410014305 {
1410114306 MODIFIERS |= COMMAND;
14102
- /*
14307
+ /**/
1410314308 if((mod&SHIFT) == SHIFT)
1410414309 manipCamera.RotatePosition(0, -speed);
1410514310 else
14106
- manipCamera.BackForth(0, -speed*delta, getWidth());
14107
- */
14311
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14312
+ /**/
1410814313 if ((mod & SHIFT) == SHIFT)
1410914314 {
1411014315 mouseMode = mouseMode; // VR??
....@@ -14120,12 +14325,12 @@
1412014325 void GoUp(int mod)
1412114326 {
1412214327 MODIFIERS |= COMMAND;
14123
- /*
14328
+ /**/
1412414329 if((mod&SHIFT) == SHIFT)
1412514330 manipCamera.RotatePosition(0, speed);
1412614331 else
14127
- manipCamera.BackForth(0, speed*delta, getWidth());
14128
- */
14332
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14333
+ /**/
1412914334 if ((mod & SHIFT) == SHIFT)
1413014335 {
1413114336 mouseMode = mouseMode;
....@@ -14141,12 +14346,12 @@
1414114346 void GoLeft(int mod)
1414214347 {
1414314348 MODIFIERS |= COMMAND;
14144
- /*
14349
+ /**/
1414514350 if((mod&SHIFT) == SHIFT)
14146
- manipCamera.RotatePosition(speed, 0);
14147
- else
1414814351 manipCamera.Translate(speed*delta, 0, getWidth());
14149
- */
14352
+ else
14353
+ manipCamera.RotatePosition(speed, 0);
14354
+ /**/
1415014355 if ((mod & SHIFT) == SHIFT)
1415114356 {
1415214357 mouseMode = mouseMode;
....@@ -14162,12 +14367,12 @@
1416214367 void GoRight(int mod)
1416314368 {
1416414369 MODIFIERS |= COMMAND;
14165
- /*
14370
+ /**/
1416614371 if((mod&SHIFT) == SHIFT)
14167
- manipCamera.RotatePosition(-speed, 0);
14168
- else
1416914372 manipCamera.Translate(-speed*delta, 0, getWidth());
14170
- */
14373
+ else
14374
+ manipCamera.RotatePosition(-speed, 0);
14375
+ /**/
1417114376 if ((mod & SHIFT) == SHIFT)
1417214377 {
1417314378 mouseMode = mouseMode;
....@@ -14224,7 +14429,8 @@
1422414429 info.camera = renderCamera;
1422514430 info.x = x;
1422614431 info.y = y;
14227
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14432
+ object.GetWindow().copy
14433
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1422814434 } else
1422914435 {
1423014436 if (x < startX)
....@@ -14388,7 +14594,9 @@
1438814594 ci.camera = renderCamera;
1438914595 if (!isRenderer)
1439014596 {
14391
- if (object.editWindow.copy.doEditClick(ci, 0))
14597
+ //ObjEditor editWindow = object.editWindow;
14598
+ //Object3D copy = editWindow.copy;
14599
+ if (object.doEditClick(ci, 0))
1439214600 {
1439314601 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1439414602 } else
....@@ -14403,7 +14611,8 @@
1440314611 Globals.MOUSEDRAGGED = false;
1440414612
1440514613 movingcamera = false;
14406
- X = Y = 0;
14614
+ X = 0; // getBounds().width/2;
14615
+ Y = 0; // getBounds().height/2;
1440714616 //System.out.println("mouseReleased: " + e);
1440814617 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1440914618 }
....@@ -14744,7 +14953,9 @@
1474414953 case 'E' : COMPACT ^= true;
1474514954 repaint();
1474614955 break;
14747
- case 'W' : DEBUGHSB ^= true;
14956
+ case 'W' : // Wide Window (fullscreen)
14957
+ //DEBUGHSB ^= true;
14958
+ ObjEditor.theFrame.ToggleFullScreen();
1474814959 repaint();
1474914960 break;
1475014961 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14769,8 +14980,8 @@
1476914980 RevertCamera();
1477014981 repaint();
1477114982 break;
14772
- case 'L':
1477314983 case 'l':
14984
+ //case 'L':
1477414985 if (lightMode)
1477514986 {
1477614987 lightMode = false;
....@@ -14913,9 +15124,9 @@
1491315124 case '_':
1491415125 kompactbit = 5;
1491515126 break;
14916
- case '+':
14917
- kompactbit = 6;
14918
- break;
15127
+// case '+':
15128
+// kompactbit = 6;
15129
+// break;
1491915130 case ' ':
1492015131 lightMode ^= true;
1492115132 Globals.lighttouched = true;
....@@ -14927,6 +15138,7 @@
1492715138 case ESC:
1492815139 RENDERPROGRAM += 1;
1492915140 RENDERPROGRAM %= 3;
15141
+
1493015142 repaint();
1493115143 break;
1493215144 case 'Z':
....@@ -14966,8 +15178,9 @@
1496615178 case DELETE:
1496715179 ClearSelection();
1496815180 break;
14969
- /*
1497015181 case '+':
15182
+
15183
+ /*
1497115184 //fontsize += 1;
1497215185 bbzoom *= 2;
1497315186 repaint();
....@@ -14984,17 +15197,17 @@
1498415197 case '=':
1498515198 IncDepth();
1498615199 //fontsize += 1;
14987
- object.editWindow.refreshContents(true);
15200
+ object.GetWindow().refreshContents(true);
1498815201 maskbit = 6;
1498915202 break;
1499015203 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1499115204 DecDepth();
1499215205 maskbit = 5;
1499315206 //if(fontsize > 1) fontsize -= 1;
14994
- if (object.editWindow == null)
14995
- new Exception().printStackTrace();
14996
- else
14997
- object.editWindow.refreshContents(true);
15207
+// if (object.editWindow == null)
15208
+// new Exception().printStackTrace();
15209
+// else
15210
+ object.GetWindow().refreshContents(true);
1499815211 break;
1499915212 case '{':
1500015213 manipCamera.shaper_fovy /= 1.1;
....@@ -15218,7 +15431,7 @@
1521815431 }
1521915432 */
1522015433
15221
- object.editWindow.EditSelection();
15434
+ object.GetWindow().EditSelection(false);
1522215435 }
1522315436
1522415437 void SelectParent()
....@@ -15235,10 +15448,10 @@
1523515448 {
1523615449 //selectees.remove(i);
1523715450 System.out.println("select parent of " + elem);
15238
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15451
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1523915452 } else
1524015453 {
15241
- group.editWindow.Select(elem.GetTreePath(), first, true);
15454
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1524215455 }
1524315456
1524415457 first = false;
....@@ -15280,12 +15493,12 @@
1528015493 for (int j = 0; j < group.children.size(); j++)
1528115494 {
1528215495 elem = (Object3D) group.children.elementAt(j);
15283
- object.editWindow.Select(elem.GetTreePath(), first, true);
15496
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1528415497 first = false;
1528515498 }
1528615499 } else
1528715500 {
15288
- object.editWindow.Select(elem.GetTreePath(), first, true);
15501
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1528915502 }
1529015503
1529115504 first = false;
....@@ -15296,21 +15509,21 @@
1529615509 {
1529715510 //Composite group = (Composite) object;
1529815511 Object3D group = object;
15299
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15512
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1530015513 }
1530115514
1530215515 void ResetTransform(int mask)
1530315516 {
1530415517 //Composite group = (Composite) object;
1530515518 Object3D group = object;
15306
- group.editWindow.ResetTransform(mask);
15519
+ group.GetWindow().ResetTransform(mask);
1530715520 }
1530815521
1530915522 void FlipTransform()
1531015523 {
1531115524 //Composite group = (Composite) object;
1531215525 Object3D group = object;
15313
- group.editWindow.FlipTransform();
15526
+ group.GetWindow().FlipTransform();
1531415527 // group.editWindow.ReduceMesh(true);
1531515528 }
1531615529
....@@ -15318,7 +15531,7 @@
1531815531 {
1531915532 //Composite group = (Composite) object;
1532015533 Object3D group = object;
15321
- group.editWindow.PrintMemory();
15534
+ group.GetWindow().PrintMemory();
1532215535 // group.editWindow.ReduceMesh(true);
1532315536 }
1532415537
....@@ -15326,7 +15539,7 @@
1532615539 {
1532715540 //Composite group = (Composite) object;
1532815541 Object3D group = object;
15329
- group.editWindow.ResetCentroid();
15542
+ group.GetWindow().ResetCentroid();
1533015543 }
1533115544
1533215545 void IncDepth()
....@@ -15502,6 +15715,7 @@
1550215715 info.bounds.y += (height - desired) / 2;
1550315716 }
1550415717 }
15718
+
1550515719 info.g = gr;
1550615720 info.camera = renderCamera;
1550715721 /*
....@@ -15511,23 +15725,44 @@
1551115725 */
1551215726 if (!isRenderer)
1551315727 {
15514
- object.drawEditHandles(info, 0);
15515
-
15516
- if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15728
+ Grafreed.Assert(object != null);
15729
+ Grafreed.Assert(object.selection != null);
15730
+ if (object.selection.Size() > 0)
1551715731 {
15518
- switch (object.selection.get(0).hitSomething)
15732
+ int hitSomething = object.selection.get(0).hitSomething;
15733
+
15734
+ info.DX = 0;
15735
+ info.DY = 0;
15736
+ info.W = 1;
15737
+ if (hitSomething == Object3D.hitCenter)
1551915738 {
15520
- case Object3D.hitCenter: gr.setColor(Color.pink);
15521
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15522
- break;
15523
- case Object3D.hitRotate: gr.setColor(Color.yellow);
15524
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15525
- break;
15526
- case Object3D.hitScale: gr.setColor(Color.cyan);
15527
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15528
- break;
15739
+ info.DX = X;
15740
+ if (X != 0)
15741
+ info.DX -= info.bounds.width/2;
15742
+
15743
+ info.DY = Y;
15744
+ if (Y != 0)
15745
+ info.DY -= info.bounds.height/2;
1552915746 }
15530
-
15747
+
15748
+ object.drawEditHandles(info, 0);
15749
+
15750
+ if (drag && (X != 0 || Y != 0))
15751
+ {
15752
+ switch (hitSomething)
15753
+ {
15754
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15755
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15756
+ break;
15757
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15758
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15759
+ break;
15760
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15761
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15762
+ break;
15763
+ }
15764
+
15765
+ }
1553115766 }
1553215767 }
1553315768 }
....@@ -16230,16 +16465,16 @@
1623016465 cStatic.objectstack[materialdepth++] = checker;
1623116466 //System.out.println("material " + material);
1623216467 //Applet3D.tracein(this, selected);
16233
- vector2buffer = checker.projectedVertices;
16468
+ //vector2buffer = checker.projectedVertices;
1623416469
1623516470 //checker.GetMaterial().Draw(this, false); // true);
16236
- DrawMaterial(checker.GetMaterial(), false); // true);
16471
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1623716472
1623816473 materialdepth -= 1;
1623916474 if (materialdepth > 0)
1624016475 {
16241
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16242
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16476
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16477
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1624316478 }
1624416479 //checker.GetMaterial().opacity = 1f;
1624516480 ////checker.GetMaterial().ambient = 1f;
....@@ -16325,6 +16560,14 @@
1632516560 }
1632616561 }
1632716562
16563
+ private Object3D GetFolder()
16564
+ {
16565
+ Object3D folder = object.GetWindow().copy;
16566
+ if (object.GetWindow().copy.selection.Size() > 0)
16567
+ folder = object.GetWindow().copy.selection.elementAt(0);
16568
+ return folder;
16569
+ }
16570
+
1632816571 class SelectBuffer implements GLEventListener
1632916572 {
1633016573
....@@ -16404,6 +16647,17 @@
1640416647
1640516648 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1640616649
16650
+ if (PAINTMODE)
16651
+ {
16652
+ if (object.GetWindow().copy.selection.Size() > 0)
16653
+ {
16654
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16655
+
16656
+ // Make what you paint not selectable.
16657
+ paintobj.ResetSelectable();
16658
+ }
16659
+ }
16660
+
1640716661 //int tmp = selection_view;
1640816662 //selection_view = -1;
1640916663 int temp = DrawMode();
....@@ -16415,6 +16669,17 @@
1641516669 // temp = DEFAULT; // patch for selection debug
1641616670 Globals.drawMode = temp; // WARNING
1641716671
16672
+ if (PAINTMODE)
16673
+ {
16674
+ if (object.GetWindow().copy.selection.Size() > 0)
16675
+ {
16676
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16677
+
16678
+ // Revert.
16679
+ paintobj.RestoreSelectable();
16680
+ }
16681
+ }
16682
+
1641816683 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1641916684
1642016685 // trying different ways of getting the depth info over
....@@ -16462,6 +16727,8 @@
1646216727 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1646316728 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1646416729 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16730
+
16731
+ CreateSelectedPoint();
1646516732
1646616733 // Will fit the mesh !!!
1646716734 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16516,29 +16783,31 @@
1651616783 }
1651716784
1651816785 if (!movingcamera && !PAINTMODE)
16519
- object.editWindow.ScreenFitPoint(); // fev 2014
16786
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1652016787
16521
- if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16788
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1652216789 {
16523
- Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16790
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1652416791
16525
- Object3D group = new Object3D("inst" + paintcount++);
16792
+ if (object.GetWindow().copy.selection.Size() > 0)
16793
+ {
16794
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1652616795
16527
- group.CreateMaterial(); // use a void leaf to select instances
16528
-
16529
- group.add(paintobj); // link
16530
-
16531
- object.editWindow.SnapObject(group);
16532
-
16533
- Object3D folder = object.editWindow.copy;
16534
-
16535
- if (object.editWindow.copy.selection.Size() > 0)
16536
- folder = object.editWindow.copy.selection.elementAt(0);
16537
-
16538
- folder.add(group);
16539
-
16540
- object.editWindow.ResetModel();
16541
- object.editWindow.refreshContents();
16796
+ Object3D inst = new Object3D("inst" + paintcount++);
16797
+
16798
+ inst.CreateMaterial(); // use a void leaf to select instances
16799
+
16800
+ inst.add(paintobj); // link
16801
+
16802
+ object.GetWindow().SnapObject(inst);
16803
+
16804
+ Object3D folder = paintFolder; // GetFolder();
16805
+
16806
+ folder.add(inst);
16807
+
16808
+ object.GetWindow().ResetModel();
16809
+ object.GetWindow().refreshContents();
16810
+ }
1654216811 }
1654316812 else
1654416813 paintcount = 0;
....@@ -16577,6 +16846,11 @@
1657716846 //System.out.println("objects[color] = " + objects[color]);
1657816847 //objects[color].Select();
1657916848 indexcount = 0;
16849
+ ObjEditor window = object.GetWindow();
16850
+ if (window != null && deselect)
16851
+ {
16852
+ window.Select(null, deselect, true);
16853
+ }
1658016854 object.Select(color, deselect);
1658116855 }
1658216856
....@@ -17102,23 +17376,15 @@
1710217376 int AAbuffersize = 0;
1710317377
1710417378 //double[] selectedpoint = new double[3];
17105
- static Superellipsoid selectedpoint = new Superellipsoid();
17379
+ static Superellipsoid selectedpoint;
1710617380 static Sphere previousselectedpoint = null;
17107
- static Sphere debugpointG = new Sphere();
17108
- static Sphere debugpointP = new Sphere();
17109
- static Sphere debugpointC = new Sphere();
17110
- static Sphere debugpointR = new Sphere();
17381
+ static Sphere debugpointG;
17382
+ static Sphere debugpointP;
17383
+ static Sphere debugpointC;
17384
+ static Sphere debugpointR;
1711117385
1711217386 static Sphere debugpoints[] = new Sphere[8];
1711317387
17114
- static
17115
- {
17116
- for (int i=0; i<8; i++)
17117
- {
17118
- debugpoints[i] = new Sphere();
17119
- }
17120
- }
17121
-
1712217388 static void InitPoints(float radius)
1712317389 {
1712417390 for (int i=0; i<8; i++)