Normand Briere
2019-06-29 a69bb4474a3264a9a7a7f8b8d8154ea771f167c8
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
....@@ -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
....@@ -2267,7 +2280,7 @@
22672280
22682281 void ToggleDebug()
22692282 {
2270
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22712284 }
22722285
22732286 void ToggleLookAt()
....@@ -9367,11 +9380,35 @@
93679380 jy8[3] = 0.5f;
93689381 }
93699382
9370
- 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
93719384 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
93729385 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
93739386 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
93749387
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
+
93759412 static int imagecount = 0; // movie generation
93769413
93779414 static int jitter = 0;
....@@ -10482,6 +10519,7 @@
1048210519 ANTIALIAS = 0;
1048310520 //System.out.println("RESTART");
1048410521 AAtimer.restart();
10522
+ Globals.TIMERRUNNING = true;
1048510523 }
1048610524 }
1048710525 }
....@@ -10549,7 +10587,8 @@
1054910587 ambientOcclusion = false;
1055010588 }
1055110589
10552
- if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
10590
+ if (//Globals.lighttouched &&
10591
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1055310592 {
1055410593 //if (RENDERSHADOW) // ?
1055510594 if (!IsFrozen())
....@@ -11459,8 +11498,29 @@
1145911498
1146011499 static boolean zoomonce = false;
1146111500
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
+
1146211519 void DrawObject(GL gl, boolean draw)
1146311520 {
11521
+ // To clear camera values
11522
+ ResetOptions();
11523
+
1146411524 //System.out.println("DRAW OBJECT " + mouseDown);
1146511525 // DrawMode() = SELECTION;
1146611526 //GL gl = getGL();
....@@ -11539,8 +11599,9 @@
1153911599
1154011600 if (DrawMode() == DEFAULT)
1154111601 {
11542
- if (DEBUG)
11602
+ if (Globals.DEBUG)
1154311603 {
11604
+ CreateSelectedPoint();
1154411605 float radius = 0.05f;
1154511606 if (selectedpoint.radius != radius)
1154611607 {
....@@ -12027,7 +12088,7 @@
1202712088 for (int i = tp.size(); --i >= 0;)
1202812089 {
1202912090 //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12030
- LA.xformPos(light, tp.get(i).GlobalTransform(), light);
12091
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1203112092 }
1203212093
1203312094
....@@ -13297,7 +13358,8 @@
1329713358 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1329813359 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1329913360 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13300
- Object3D.cVector2[] vector2buffer;
13361
+
13362
+ //Object3D.cVector2[] vector2buffer;
1330113363
1330213364 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1330313365 // OUT : diff, spec
....@@ -13313,9 +13375,10 @@
1331313375 "DP3 " + dest + ".z," + "normals," + "eye;" +
1331413376 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1331513377 //"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;" +
13378
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13379
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13380
+
13381
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1331913382 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1332013383 "RCP " + dest + ".w," + dest + ".w;" +
1332113384 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13820,6 +13883,7 @@
1382013883 else
1382113884 if (evt.getSource() == AAtimer)
1382213885 {
13886
+ Globals.TIMERRUNNING = false;
1382313887 if (mouseDown)
1382413888 {
1382513889 //new Exception().printStackTrace();
....@@ -13894,6 +13958,7 @@
1389413958 return;
1389513959
1389613960 AAtimer.restart(); //
13961
+ Globals.TIMERRUNNING = true;
1389713962
1389813963 // waslive = LIVE;
1389913964 // LIVE = false;
....@@ -14357,7 +14422,8 @@
1435714422 info.camera = renderCamera;
1435814423 info.x = x;
1435914424 info.y = y;
14360
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14425
+ object.GetWindow().copy
14426
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1436114427 } else
1436214428 {
1436314429 if (x < startX)
....@@ -14521,7 +14587,9 @@
1452114587 ci.camera = renderCamera;
1452214588 if (!isRenderer)
1452314589 {
14524
- if (object.editWindow.copy.doEditClick(ci, 0))
14590
+ //ObjEditor editWindow = object.editWindow;
14591
+ //Object3D copy = editWindow.copy;
14592
+ if (object.doEditClick(ci, 0))
1452514593 {
1452614594 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1452714595 } else
....@@ -14902,8 +14970,14 @@
1490214970 RevertCamera();
1490314971 repaint();
1490414972 break;
14905
- case 'L':
1490614973 case 'l':
14974
+ lightMode ^= true;
14975
+ Globals.lighttouched = true;
14976
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14977
+ targetLookAt.set(manipCamera.lookAt);
14978
+ repaint();
14979
+ break;
14980
+ case 'L':
1490714981 if (lightMode)
1490814982 {
1490914983 lightMode = false;
....@@ -15046,20 +15120,18 @@
1504615120 case '_':
1504715121 kompactbit = 5;
1504815122 break;
15049
- case '+':
15050
- kompactbit = 6;
15051
- break;
15123
+// case '+':
15124
+// kompactbit = 6;
15125
+// break;
1505215126 case ' ':
15053
- lightMode ^= true;
15054
- Globals.lighttouched = true;
15055
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
15056
- targetLookAt.set(manipCamera.lookAt);
15127
+ ObjEditor.theFrame.ToggleFullScreen();
1505715128 repaint();
1505815129 break;
1505915130 //case '`' :
1506015131 case ESC:
1506115132 RENDERPROGRAM += 1;
1506215133 RENDERPROGRAM %= 3;
15134
+
1506315135 repaint();
1506415136 break;
1506515137 case 'Z':
....@@ -15099,8 +15171,8 @@
1509915171 case DELETE:
1510015172 ClearSelection();
1510115173 break;
15102
- /*
1510315174 case '+':
15175
+ /*
1510415176 //fontsize += 1;
1510515177 bbzoom *= 2;
1510615178 repaint();
....@@ -15351,7 +15423,7 @@
1535115423 }
1535215424 */
1535315425
15354
- object.editWindow.EditSelection();
15426
+ object.editWindow.EditSelection(false);
1535515427 }
1535615428
1535715429 void SelectParent()
....@@ -16363,16 +16435,16 @@
1636316435 cStatic.objectstack[materialdepth++] = checker;
1636416436 //System.out.println("material " + material);
1636516437 //Applet3D.tracein(this, selected);
16366
- vector2buffer = checker.projectedVertices;
16438
+ //vector2buffer = checker.projectedVertices;
1636716439
1636816440 //checker.GetMaterial().Draw(this, false); // true);
16369
- DrawMaterial(checker.GetMaterial(), false); // true);
16441
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1637016442
1637116443 materialdepth -= 1;
1637216444 if (materialdepth > 0)
1637316445 {
16374
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16375
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16446
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16447
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1637616448 }
1637716449 //checker.GetMaterial().opacity = 1f;
1637816450 ////checker.GetMaterial().ambient = 1f;
....@@ -16596,6 +16668,8 @@
1659616668 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1659716669 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1659816670
16671
+ CreateSelectedPoint();
16672
+
1659916673 // Will fit the mesh !!!
1660016674 selectedpoint.toParent[0][0] = 0.0001;
1660116675 selectedpoint.toParent[1][1] = 0.0001;
....@@ -16710,6 +16784,11 @@
1671016784 //System.out.println("objects[color] = " + objects[color]);
1671116785 //objects[color].Select();
1671216786 indexcount = 0;
16787
+ ObjEditor window = object.GetWindow();
16788
+ if (window != null && deselect)
16789
+ {
16790
+ window.Select(null, deselect, true);
16791
+ }
1671316792 object.Select(color, deselect);
1671416793 }
1671516794
....@@ -17235,23 +17314,15 @@
1723517314 int AAbuffersize = 0;
1723617315
1723717316 //double[] selectedpoint = new double[3];
17238
- static Superellipsoid selectedpoint = new Superellipsoid();
17317
+ static Superellipsoid selectedpoint;
1723917318 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();
17319
+ static Sphere debugpointG;
17320
+ static Sphere debugpointP;
17321
+ static Sphere debugpointC;
17322
+ static Sphere debugpointR;
1724417323
1724517324 static Sphere debugpoints[] = new Sphere[8];
1724617325
17247
- static
17248
- {
17249
- for (int i=0; i<8; i++)
17250
- {
17251
- debugpoints[i] = new Sphere();
17252
- }
17253
- }
17254
-
1725517326 static void InitPoints(float radius)
1725617327 {
1725717328 for (int i=0; i<8; i++)