Normand Briere
2019-06-26 89b25e7cc97f6fe221dfd41c4d463500f8a31bc1
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
....@@ -2259,7 +2280,7 @@
22592280
22602281 void ToggleDebug()
22612282 {
2262
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22632284 }
22642285
22652286 void ToggleLookAt()
....@@ -9359,11 +9380,35 @@
93599380 jy8[3] = 0.5f;
93609381 }
93619382
9362
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9383
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
93639384 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
93649385 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
93659386 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
93669387
9388
+ void ResetOptions()
9389
+ {
9390
+ options1[0] = 100;
9391
+ options1[1] = 0.025f;
9392
+ options1[2] = 0.01f;
9393
+ options1[3] = 0;
9394
+ options1[4] = 0;
9395
+
9396
+ options2[0] = 0;
9397
+ options2[1] = 0.75f;
9398
+ options2[2] = 0;
9399
+ options2[3] = 0;
9400
+
9401
+ options3[0] = 1;
9402
+ options3[1] = 1;
9403
+ options3[2] = 1;
9404
+ options3[3] = 0;
9405
+
9406
+ options4[0] = 1;
9407
+ options4[1] = 0;
9408
+ options4[2] = 1;
9409
+ options4[3] = 0;
9410
+ }
9411
+
93679412 static int imagecount = 0; // movie generation
93689413
93699414 static int jitter = 0;
....@@ -10474,6 +10519,7 @@
1047410519 ANTIALIAS = 0;
1047510520 //System.out.println("RESTART");
1047610521 AAtimer.restart();
10522
+ Globals.TIMERRUNNING = true;
1047710523 }
1047810524 }
1047910525 }
....@@ -10541,7 +10587,8 @@
1054110587 ambientOcclusion = false;
1054210588 }
1054310589
10544
- if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
10590
+ if (//Globals.lighttouched &&
10591
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1054510592 {
1054610593 //if (RENDERSHADOW) // ?
1054710594 if (!IsFrozen())
....@@ -11451,8 +11498,29 @@
1145111498
1145211499 static boolean zoomonce = false;
1145311500
11501
+ static void CreateSelectedPoint()
11502
+ {
11503
+ if (selectedpoint == null)
11504
+ {
11505
+ debugpointG = new Sphere();
11506
+ debugpointP = new Sphere();
11507
+ debugpointC = new Sphere();
11508
+ debugpointR = new Sphere();
11509
+
11510
+ selectedpoint = new Superellipsoid();
11511
+
11512
+ for (int i=0; i<8; i++)
11513
+ {
11514
+ debugpoints[i] = new Sphere();
11515
+ }
11516
+ }
11517
+ }
11518
+
1145411519 void DrawObject(GL gl, boolean draw)
1145511520 {
11521
+ // To clear camera values
11522
+ ResetOptions();
11523
+
1145611524 //System.out.println("DRAW OBJECT " + mouseDown);
1145711525 // DrawMode() = SELECTION;
1145811526 //GL gl = getGL();
....@@ -11531,8 +11599,9 @@
1153111599
1153211600 if (DrawMode() == DEFAULT)
1153311601 {
11534
- if (DEBUG)
11602
+ if (Globals.DEBUG)
1153511603 {
11604
+ CreateSelectedPoint();
1153611605 float radius = 0.05f;
1153711606 if (selectedpoint.radius != radius)
1153811607 {
....@@ -12019,7 +12088,7 @@
1201912088 for (int i = tp.size(); --i >= 0;)
1202012089 {
1202112090 //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12022
- LA.xformPos(light, tp.get(i).GlobalTransform(), light);
12091
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1202312092 }
1202412093
1202512094
....@@ -13289,7 +13358,8 @@
1328913358 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1329013359 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1329113360 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13292
- Object3D.cVector2[] vector2buffer;
13361
+
13362
+ //Object3D.cVector2[] vector2buffer;
1329313363
1329413364 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1329513365 // OUT : diff, spec
....@@ -13812,6 +13882,7 @@
1381213882 else
1381313883 if (evt.getSource() == AAtimer)
1381413884 {
13885
+ Globals.TIMERRUNNING = false;
1381513886 if (mouseDown)
1381613887 {
1381713888 //new Exception().printStackTrace();
....@@ -13886,6 +13957,7 @@
1388613957 return;
1388713958
1388813959 AAtimer.restart(); //
13960
+ Globals.TIMERRUNNING = true;
1388913961
1389013962 // waslive = LIVE;
1389113963 // LIVE = false;
....@@ -14349,7 +14421,8 @@
1434914421 info.camera = renderCamera;
1435014422 info.x = x;
1435114423 info.y = y;
14352
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14424
+ object.GetWindow().copy
14425
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1435314426 } else
1435414427 {
1435514428 if (x < startX)
....@@ -14513,7 +14586,9 @@
1451314586 ci.camera = renderCamera;
1451414587 if (!isRenderer)
1451514588 {
14516
- if (object.editWindow.copy.doEditClick(ci, 0))
14589
+ //ObjEditor editWindow = object.editWindow;
14590
+ //Object3D copy = editWindow.copy;
14591
+ if (object.doEditClick(ci, 0))
1451714592 {
1451814593 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1451914594 } else
....@@ -14894,8 +14969,14 @@
1489414969 RevertCamera();
1489514970 repaint();
1489614971 break;
14897
- case 'L':
1489814972 case 'l':
14973
+ lightMode ^= true;
14974
+ Globals.lighttouched = true;
14975
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14976
+ targetLookAt.set(manipCamera.lookAt);
14977
+ repaint();
14978
+ break;
14979
+ case 'L':
1489914980 if (lightMode)
1490014981 {
1490114982 lightMode = false;
....@@ -15042,16 +15123,14 @@
1504215123 kompactbit = 6;
1504315124 break;
1504415125 case ' ':
15045
- lightMode ^= true;
15046
- Globals.lighttouched = true;
15047
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
15048
- targetLookAt.set(manipCamera.lookAt);
15126
+ ObjEditor.theFrame.ToggleFullScreen();
1504915127 repaint();
1505015128 break;
1505115129 //case '`' :
1505215130 case ESC:
1505315131 RENDERPROGRAM += 1;
1505415132 RENDERPROGRAM %= 3;
15133
+
1505515134 repaint();
1505615135 break;
1505715136 case 'Z':
....@@ -15343,7 +15422,7 @@
1534315422 }
1534415423 */
1534515424
15346
- object.editWindow.EditSelection();
15425
+ object.editWindow.EditSelection(false);
1534715426 }
1534815427
1534915428 void SelectParent()
....@@ -16355,16 +16434,16 @@
1635516434 cStatic.objectstack[materialdepth++] = checker;
1635616435 //System.out.println("material " + material);
1635716436 //Applet3D.tracein(this, selected);
16358
- vector2buffer = checker.projectedVertices;
16437
+ //vector2buffer = checker.projectedVertices;
1635916438
1636016439 //checker.GetMaterial().Draw(this, false); // true);
16361
- DrawMaterial(checker.GetMaterial(), false); // true);
16440
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1636216441
1636316442 materialdepth -= 1;
1636416443 if (materialdepth > 0)
1636516444 {
16366
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16367
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16445
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16446
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1636816447 }
1636916448 //checker.GetMaterial().opacity = 1f;
1637016449 ////checker.GetMaterial().ambient = 1f;
....@@ -16587,6 +16666,8 @@
1658716666 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1658816667 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1658916668 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16669
+
16670
+ CreateSelectedPoint();
1659016671
1659116672 // Will fit the mesh !!!
1659216673 selectedpoint.toParent[0][0] = 0.0001;
....@@ -17227,23 +17308,15 @@
1722717308 int AAbuffersize = 0;
1722817309
1722917310 //double[] selectedpoint = new double[3];
17230
- static Superellipsoid selectedpoint = new Superellipsoid();
17311
+ static Superellipsoid selectedpoint;
1723117312 static Sphere previousselectedpoint = null;
17232
- static Sphere debugpointG = new Sphere();
17233
- static Sphere debugpointP = new Sphere();
17234
- static Sphere debugpointC = new Sphere();
17235
- static Sphere debugpointR = new Sphere();
17313
+ static Sphere debugpointG;
17314
+ static Sphere debugpointP;
17315
+ static Sphere debugpointC;
17316
+ static Sphere debugpointR;
1723617317
1723717318 static Sphere debugpoints[] = new Sphere[8];
1723817319
17239
- static
17240
- {
17241
- for (int i=0; i<8; i++)
17242
- {
17243
- debugpoints[i] = new Sphere();
17244
- }
17245
- }
17246
-
1724717320 static void InitPoints(float radius)
1724817321 {
1724917322 for (int i=0; i<8; i++)