Normand Briere
2019-07-21 5a546232b84ce65d8779d29e9171e7e2df013614
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
....@@ -1890,7 +1911,7 @@
18901911 void PushMatrix(double[][] matrix)
18911912 {
18921913 // GrafreeD.tracein(matrix);
1893
- PushMatrix(matrix,1);
1914
+ PushMatrix(matrix, 1);
18941915 }
18951916
18961917 void PushMatrix()
....@@ -2044,7 +2065,7 @@
20442065 //System.err.println("Oeil on");
20452066 OEIL = true;
20462067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2047
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20482069 //pingthread.StepToTarget(true);
20492070 }
20502071
....@@ -2259,7 +2280,7 @@
22592280
22602281 void ToggleDebug()
22612282 {
2262
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22632284 }
22642285
22652286 void ToggleLookAt()
....@@ -2277,10 +2298,17 @@
22772298 HANDLES ^= true;
22782299 }
22792300
2301
+ Object3D paintFolder;
2302
+
22802303 void TogglePaint()
22812304 {
22822305 PAINTMODE ^= true;
22832306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
22842312 }
22852313
22862314 void SwapCamera(int a, int b)
....@@ -7902,7 +7930,7 @@
79027930 String pigment = Object3D.GetPigment(tex);
79037931 String bump = Object3D.GetBump(tex);
79047932
7905
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7933
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79067934 {
79077935 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79087936 // System.out.println("; bump = " + bump);
....@@ -7919,6 +7947,64 @@
79197947
79207948 ReleaseTexture(bump, true);
79217949 ReleaseTexture(pigment, false);
7950
+ }
7951
+
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);
79228008 }
79238009
79248010 void ReleaseTexture(String tex, boolean bump)
....@@ -8045,7 +8131,7 @@
80458131 usedtextures.put(pigment, pigment);
80468132 usedtextures.put(bump, bump);
80478133
8048
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8134
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80498135 {
80508136 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80518137 // System.out.println("; bump = " + bump);
....@@ -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>();
....@@ -8364,7 +8517,7 @@
83648517 return false;
83658518 }
83668519
8367
- boolean newtex = false;
8520
+ //boolean newtex = false;
83688521
83698522 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
83708523
....@@ -8396,7 +8549,7 @@
83968549 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83978550 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83988551
8399
- return newtex;
8552
+ return true; // Warning: not used.
84008553 }
84018554
84028555 ShadowBuffer shadowPBuf;
....@@ -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;
....@@ -9335,7 +9512,7 @@
93359512
93369513 if (renderCamera != lightCamera)
93379514 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9338
- LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
9515
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93399516
93409517 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93419518
....@@ -9351,7 +9528,7 @@
93519528
93529529 if (renderCamera != lightCamera)
93539530 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9354
- LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
9531
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93559532
93569533 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93579534
....@@ -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())
....@@ -10550,7 +10729,7 @@
1055010729 // if (parentcam != renderCamera) // not a light
1055110730 if (cam != lightCamera)
1055210731 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10553
- LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
10732
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1055410733
1055510734 for (int j = 0; j < 4; j++)
1055610735 {
....@@ -10565,7 +10744,7 @@
1056510744 // if (parentcam != renderCamera) // not a light
1056610745 if (cam != lightCamera)
1056710746 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10568
- LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
10747
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1056910748
1057010749 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1057110750
....@@ -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
....@@ -10959,7 +11138,7 @@
1095911138
1096011139 // if (cam != lightCamera)
1096111140 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10962
- LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
11141
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1096311142 }
1096411143
1096511144 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10981,7 +11160,7 @@
1098111160 {
1098211161 if (cam != lightCamera)
1098311162 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10984
- LA.xformDir(light0, parentcam.GlobalTransformInv(), light0); // may 2013
11163
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1098511164 }
1098611165
1098711166 LA.xformPos(light0, cam.toScreen, light0);
....@@ -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 {
....@@ -11912,7 +12113,7 @@
1191212113 }
1191312114
1191412115 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11915
- LA.xformPos(light, parentcam.GlobalTransformInv(), light); // may 2013
12116
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1191612117
1191712118 LA.xformPos(light, renderCamera.toScreen, light);
1191812119
....@@ -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;
....@@ -13833,6 +14038,8 @@
1383314038
1383414039 public void mouseDragged(MouseEvent e)
1383514040 {
14041
+ Globals.MOUSEDRAGGED = true;
14042
+
1383614043 //System.out.println("mouseDragged: " + e);
1383714044 if (isRenderer)
1383814045 movingcamera = true;
....@@ -14097,12 +14304,12 @@
1409714304 void GoDown(int mod)
1409814305 {
1409914306 MODIFIERS |= COMMAND;
14100
- /*
14307
+ /**/
1410114308 if((mod&SHIFT) == SHIFT)
1410214309 manipCamera.RotatePosition(0, -speed);
1410314310 else
14104
- manipCamera.BackForth(0, -speed*delta, getWidth());
14105
- */
14311
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14312
+ /**/
1410614313 if ((mod & SHIFT) == SHIFT)
1410714314 {
1410814315 mouseMode = mouseMode; // VR??
....@@ -14118,12 +14325,12 @@
1411814325 void GoUp(int mod)
1411914326 {
1412014327 MODIFIERS |= COMMAND;
14121
- /*
14328
+ /**/
1412214329 if((mod&SHIFT) == SHIFT)
1412314330 manipCamera.RotatePosition(0, speed);
1412414331 else
14125
- manipCamera.BackForth(0, speed*delta, getWidth());
14126
- */
14332
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14333
+ /**/
1412714334 if ((mod & SHIFT) == SHIFT)
1412814335 {
1412914336 mouseMode = mouseMode;
....@@ -14139,12 +14346,12 @@
1413914346 void GoLeft(int mod)
1414014347 {
1414114348 MODIFIERS |= COMMAND;
14142
- /*
14349
+ /**/
1414314350 if((mod&SHIFT) == SHIFT)
14144
- manipCamera.RotatePosition(speed, 0);
14145
- else
1414614351 manipCamera.Translate(speed*delta, 0, getWidth());
14147
- */
14352
+ else
14353
+ manipCamera.RotatePosition(speed, 0);
14354
+ /**/
1414814355 if ((mod & SHIFT) == SHIFT)
1414914356 {
1415014357 mouseMode = mouseMode;
....@@ -14160,12 +14367,12 @@
1416014367 void GoRight(int mod)
1416114368 {
1416214369 MODIFIERS |= COMMAND;
14163
- /*
14370
+ /**/
1416414371 if((mod&SHIFT) == SHIFT)
14165
- manipCamera.RotatePosition(-speed, 0);
14166
- else
1416714372 manipCamera.Translate(-speed*delta, 0, getWidth());
14168
- */
14373
+ else
14374
+ manipCamera.RotatePosition(-speed, 0);
14375
+ /**/
1416914376 if ((mod & SHIFT) == SHIFT)
1417014377 {
1417114378 mouseMode = mouseMode;
....@@ -14222,7 +14429,8 @@
1422214429 info.camera = renderCamera;
1422314430 info.x = x;
1422414431 info.y = y;
14225
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14432
+ object.GetWindow().copy
14433
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1422614434 } else
1422714435 {
1422814436 if (x < startX)
....@@ -14386,7 +14594,9 @@
1438614594 ci.camera = renderCamera;
1438714595 if (!isRenderer)
1438814596 {
14389
- if (object.editWindow.copy.doEditClick(ci, 0))
14597
+ //ObjEditor editWindow = object.editWindow;
14598
+ //Object3D copy = editWindow.copy;
14599
+ if (object.doEditClick(ci, 0))
1439014600 {
1439114601 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1439214602 } else
....@@ -14398,8 +14608,11 @@
1439814608
1439914609 public void mouseReleased(MouseEvent e)
1440014610 {
14611
+ Globals.MOUSEDRAGGED = false;
14612
+
1440114613 movingcamera = false;
14402
- X = Y = 0;
14614
+ X = 0; // getBounds().width/2;
14615
+ Y = 0; // getBounds().height/2;
1440314616 //System.out.println("mouseReleased: " + e);
1440414617 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1440514618 }
....@@ -14740,7 +14953,9 @@
1474014953 case 'E' : COMPACT ^= true;
1474114954 repaint();
1474214955 break;
14743
- case 'W' : DEBUGHSB ^= true;
14956
+ case 'W' : // Wide Window (fullscreen)
14957
+ //DEBUGHSB ^= true;
14958
+ ObjEditor.theFrame.ToggleFullScreen();
1474414959 repaint();
1474514960 break;
1474614961 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14765,8 +14980,8 @@
1476514980 RevertCamera();
1476614981 repaint();
1476714982 break;
14768
- case 'L':
1476914983 case 'l':
14984
+ //case 'L':
1477014985 if (lightMode)
1477114986 {
1477214987 lightMode = false;
....@@ -14909,9 +15124,9 @@
1490915124 case '_':
1491015125 kompactbit = 5;
1491115126 break;
14912
- case '+':
14913
- kompactbit = 6;
14914
- break;
15127
+// case '+':
15128
+// kompactbit = 6;
15129
+// break;
1491515130 case ' ':
1491615131 lightMode ^= true;
1491715132 Globals.lighttouched = true;
....@@ -14923,6 +15138,7 @@
1492315138 case ESC:
1492415139 RENDERPROGRAM += 1;
1492515140 RENDERPROGRAM %= 3;
15141
+
1492615142 repaint();
1492715143 break;
1492815144 case 'Z':
....@@ -14962,8 +15178,9 @@
1496215178 case DELETE:
1496315179 ClearSelection();
1496415180 break;
14965
- /*
1496615181 case '+':
15182
+
15183
+ /*
1496715184 //fontsize += 1;
1496815185 bbzoom *= 2;
1496915186 repaint();
....@@ -14980,17 +15197,17 @@
1498015197 case '=':
1498115198 IncDepth();
1498215199 //fontsize += 1;
14983
- object.editWindow.refreshContents(true);
15200
+ object.GetWindow().refreshContents(true);
1498415201 maskbit = 6;
1498515202 break;
1498615203 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1498715204 DecDepth();
1498815205 maskbit = 5;
1498915206 //if(fontsize > 1) fontsize -= 1;
14990
- if (object.editWindow == null)
14991
- new Exception().printStackTrace();
14992
- else
14993
- object.editWindow.refreshContents(true);
15207
+// if (object.editWindow == null)
15208
+// new Exception().printStackTrace();
15209
+// else
15210
+ object.GetWindow().refreshContents(true);
1499415211 break;
1499515212 case '{':
1499615213 manipCamera.shaper_fovy /= 1.1;
....@@ -15214,7 +15431,7 @@
1521415431 }
1521515432 */
1521615433
15217
- object.editWindow.EditSelection();
15434
+ object.GetWindow().EditSelection(false);
1521815435 }
1521915436
1522015437 void SelectParent()
....@@ -15231,10 +15448,10 @@
1523115448 {
1523215449 //selectees.remove(i);
1523315450 System.out.println("select parent of " + elem);
15234
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15451
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1523515452 } else
1523615453 {
15237
- group.editWindow.Select(elem.GetTreePath(), first, true);
15454
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1523815455 }
1523915456
1524015457 first = false;
....@@ -15276,12 +15493,12 @@
1527615493 for (int j = 0; j < group.children.size(); j++)
1527715494 {
1527815495 elem = (Object3D) group.children.elementAt(j);
15279
- object.editWindow.Select(elem.GetTreePath(), first, true);
15496
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1528015497 first = false;
1528115498 }
1528215499 } else
1528315500 {
15284
- object.editWindow.Select(elem.GetTreePath(), first, true);
15501
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1528515502 }
1528615503
1528715504 first = false;
....@@ -15292,21 +15509,21 @@
1529215509 {
1529315510 //Composite group = (Composite) object;
1529415511 Object3D group = object;
15295
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15512
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1529615513 }
1529715514
1529815515 void ResetTransform(int mask)
1529915516 {
1530015517 //Composite group = (Composite) object;
1530115518 Object3D group = object;
15302
- group.editWindow.ResetTransform(mask);
15519
+ group.GetWindow().ResetTransform(mask);
1530315520 }
1530415521
1530515522 void FlipTransform()
1530615523 {
1530715524 //Composite group = (Composite) object;
1530815525 Object3D group = object;
15309
- group.editWindow.FlipTransform();
15526
+ group.GetWindow().FlipTransform();
1531015527 // group.editWindow.ReduceMesh(true);
1531115528 }
1531215529
....@@ -15314,7 +15531,7 @@
1531415531 {
1531515532 //Composite group = (Composite) object;
1531615533 Object3D group = object;
15317
- group.editWindow.PrintMemory();
15534
+ group.GetWindow().PrintMemory();
1531815535 // group.editWindow.ReduceMesh(true);
1531915536 }
1532015537
....@@ -15322,7 +15539,7 @@
1532215539 {
1532315540 //Composite group = (Composite) object;
1532415541 Object3D group = object;
15325
- group.editWindow.ResetCentroid();
15542
+ group.GetWindow().ResetCentroid();
1532615543 }
1532715544
1532815545 void IncDepth()
....@@ -15498,6 +15715,7 @@
1549815715 info.bounds.y += (height - desired) / 2;
1549915716 }
1550015717 }
15718
+
1550115719 info.g = gr;
1550215720 info.camera = renderCamera;
1550315721 /*
....@@ -15507,18 +15725,44 @@
1550715725 */
1550815726 if (!isRenderer)
1550915727 {
15510
- object.drawEditHandles(info, 0);
15511
-
15512
- 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)
1551315731 {
15514
- 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)
1551515738 {
15516
- case Object3D.hitCenter: gr.setColor(Color.pink); break;
15517
- case Object3D.hitRotate: gr.setColor(Color.green); break;
15518
- case Object3D.hitScale: gr.setColor(Color.cyan); break;
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;
1551915746 }
15520
-
15521
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
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
+ }
1552215766 }
1552315767 }
1552415768 }
....@@ -16221,16 +16465,16 @@
1622116465 cStatic.objectstack[materialdepth++] = checker;
1622216466 //System.out.println("material " + material);
1622316467 //Applet3D.tracein(this, selected);
16224
- vector2buffer = checker.projectedVertices;
16468
+ //vector2buffer = checker.projectedVertices;
1622516469
1622616470 //checker.GetMaterial().Draw(this, false); // true);
16227
- DrawMaterial(checker.GetMaterial(), false); // true);
16471
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1622816472
1622916473 materialdepth -= 1;
1623016474 if (materialdepth > 0)
1623116475 {
16232
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16233
- 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);
1623416478 }
1623516479 //checker.GetMaterial().opacity = 1f;
1623616480 ////checker.GetMaterial().ambient = 1f;
....@@ -16316,6 +16560,14 @@
1631616560 }
1631716561 }
1631816562
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
+
1631916571 class SelectBuffer implements GLEventListener
1632016572 {
1632116573
....@@ -16395,6 +16647,17 @@
1639516647
1639616648 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1639716649
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
+
1639816661 //int tmp = selection_view;
1639916662 //selection_view = -1;
1640016663 int temp = DrawMode();
....@@ -16406,6 +16669,17 @@
1640616669 // temp = DEFAULT; // patch for selection debug
1640716670 Globals.drawMode = temp; // WARNING
1640816671
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
+
1640916683 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1641016684
1641116685 // trying different ways of getting the depth info over
....@@ -16453,6 +16727,8 @@
1645316727 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1645416728 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1645516729 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16730
+
16731
+ CreateSelectedPoint();
1645616732
1645716733 // Will fit the mesh !!!
1645816734 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16507,29 +16783,31 @@
1650716783 }
1650816784
1650916785 if (!movingcamera && !PAINTMODE)
16510
- object.editWindow.ScreenFitPoint(); // fev 2014
16786
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1651116787
16512
- 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)
1651316789 {
16514
- 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);
1651516791
16516
- Object3D group = new Object3D("inst" + paintcount++);
16792
+ if (object.GetWindow().copy.selection.Size() > 0)
16793
+ {
16794
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1651716795
16518
- group.CreateMaterial(); // use a void leaf to select instances
16519
-
16520
- group.add(paintobj); // link
16521
-
16522
- object.editWindow.SnapObject(group);
16523
-
16524
- Object3D folder = object.editWindow.copy;
16525
-
16526
- if (object.editWindow.copy.selection.Size() > 0)
16527
- folder = object.editWindow.copy.selection.elementAt(0);
16528
-
16529
- folder.add(group);
16530
-
16531
- object.editWindow.ResetModel();
16532
- object.editWindow.refreshContents();
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
+ }
1653316811 }
1653416812 else
1653516813 paintcount = 0;
....@@ -16568,6 +16846,11 @@
1656816846 //System.out.println("objects[color] = " + objects[color]);
1656916847 //objects[color].Select();
1657016848 indexcount = 0;
16849
+ ObjEditor window = object.GetWindow();
16850
+ if (window != null && deselect)
16851
+ {
16852
+ window.Select(null, deselect, true);
16853
+ }
1657116854 object.Select(color, deselect);
1657216855 }
1657316856
....@@ -17093,23 +17376,15 @@
1709317376 int AAbuffersize = 0;
1709417377
1709517378 //double[] selectedpoint = new double[3];
17096
- static Superellipsoid selectedpoint = new Superellipsoid();
17379
+ static Superellipsoid selectedpoint;
1709717380 static Sphere previousselectedpoint = null;
17098
- static Sphere debugpointG = new Sphere();
17099
- static Sphere debugpointP = new Sphere();
17100
- static Sphere debugpointC = new Sphere();
17101
- static Sphere debugpointR = new Sphere();
17381
+ static Sphere debugpointG;
17382
+ static Sphere debugpointP;
17383
+ static Sphere debugpointC;
17384
+ static Sphere debugpointR;
1710217385
1710317386 static Sphere debugpoints[] = new Sphere[8];
1710417387
17105
- static
17106
- {
17107
- for (int i=0; i<8; i++)
17108
- {
17109
- debugpoints[i] = new Sphere();
17110
- }
17111
- }
17112
-
1711317388 static void InitPoints(float radius)
1711417389 {
1711517390 for (int i=0; i<8; i++)