Normand Briere
2019-06-25 21104baa536c6b3d3d0f9ecb7231222ed706f0e8
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;
....@@ -359,7 +358,7 @@
359358 /**/
360359 } else
361360 {
362
- DrawMaterial(material, selected);
361
+ DrawMaterial(material, selected, obj.projectedVertices);
363362 }
364363 } else
365364 {
....@@ -383,8 +382,8 @@
383382 cStatic.objectstack[materialdepth++] = obj;
384383 //System.out.println("material " + material);
385384 //Applet3D.tracein("selected ", selected);
386
- display.vector2buffer = obj.projectedVertices;
387
- display.DrawMaterial(material, selected);
385
+ //display.vector2buffer = obj.projectedVertices;
386
+ display.DrawMaterial(material, selected, obj.projectedVertices);
388387 }
389388 }
390389
....@@ -401,8 +400,8 @@
401400 materialdepth -= 1;
402401 if (materialdepth > 0)
403402 {
404
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
405
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
403
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
404
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
406405 }
407406 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
408407 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -422,8 +421,8 @@
422421 materialdepth -= 1;
423422 if (materialdepth > 0)
424423 {
425
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
426
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
424
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
425
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
427426 }
428427 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
429428 //else
....@@ -464,10 +463,12 @@
464463 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
465464 {
466465 //gl.glBegin(gl.GL_TRIANGLES);
467
- boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
466
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
467
+ // TEST LIVE NORMALS && !obj.dontselect
468
+ ;
468469 if (!hasnorm)
469470 {
470
- // System.out.println("FUCK!!");
471
+ // System.out.println("Mesh normal");
471472 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
472473 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
473474 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1192,10 +1193,12 @@
11921193 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11931194 }
11941195 }
1196
+
11951197 if (flipV)
11961198 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11971199 else
11981200 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1201
+
11991202 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12001203 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12011204
....@@ -1215,10 +1218,12 @@
12151218 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12161219 }
12171220 }
1221
+
12181222 if (flipV)
12191223 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12201224 else
12211225 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1226
+
12221227 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12231228 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12241229
....@@ -1246,8 +1251,10 @@
12461251 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12471252 else
12481253 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1254
+
12491255 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12501256 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1257
+
12511258 count2 += 2;
12521259 count3 += 3;
12531260 }
....@@ -1603,7 +1610,7 @@
16031610 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16041611 }
16051612
1606
- void DrawMaterial(cMaterial material, boolean selected)
1613
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16071614 {
16081615 CameraPane display = this;
16091616 //new Exception().printStackTrace();
....@@ -1638,7 +1645,7 @@
16381645 colorV[0] = display.modelParams0[0] * material.diffuse;
16391646 colorV[1] = display.modelParams0[1] * material.diffuse;
16401647 colorV[2] = display.modelParams0[2] * material.diffuse;
1641
- colorV[3] = material.opacity;
1648
+ colorV[3] = 1; // material.opacity;
16421649
16431650 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16441651 //System.out.println("Opacity = " + opacity);
....@@ -1746,9 +1753,9 @@
17461753 display.modelParams7[2] = 0;
17471754 display.modelParams7[3] = 0;
17481755
1749
- display.modelParams6[0] = 100; // criss de bug de bump
1756
+ //display.modelParams6[0] = 100; // criss de bug de bump
17501757
1751
- Object3D.cVector2[] extparams = display.vector2buffer;
1758
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17521759 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17531760 {
17541761 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -2259,7 +2266,7 @@
22592266
22602267 void ToggleDebug()
22612268 {
2262
- DEBUG ^= true;
2269
+ Globals.DEBUG ^= true;
22632270 }
22642271
22652272 void ToggleLookAt()
....@@ -9359,11 +9366,35 @@
93599366 jy8[3] = 0.5f;
93609367 }
93619368
9362
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9369
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
93639370 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
93649371 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
93659372 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
93669373
9374
+ void ResetOptions()
9375
+ {
9376
+ options1[0] = 100;
9377
+ options1[1] = 0.00001f;
9378
+ options1[2] = 20;
9379
+ options1[3] = 0;
9380
+ options1[4] = 0;
9381
+
9382
+ options2[0] = 0;
9383
+ options2[1] = 1;
9384
+ options2[2] = 0;
9385
+ options2[3] = 0;
9386
+
9387
+ options3[0] = 1;
9388
+ options3[1] = 1;
9389
+ options3[2] = 1;
9390
+ options3[3] = 0;
9391
+
9392
+ options4[0] = 1;
9393
+ options4[1] = 0;
9394
+ options4[2] = 1;
9395
+ options4[3] = 0;
9396
+ }
9397
+
93679398 static int imagecount = 0; // movie generation
93689399
93699400 static int jitter = 0;
....@@ -10474,6 +10505,7 @@
1047410505 ANTIALIAS = 0;
1047510506 //System.out.println("RESTART");
1047610507 AAtimer.restart();
10508
+ Globals.TIMERRUNNING = true;
1047710509 }
1047810510 }
1047910511 }
....@@ -10541,7 +10573,8 @@
1054110573 ambientOcclusion = false;
1054210574 }
1054310575
10544
- if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
10576
+ if (//Globals.lighttouched &&
10577
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1054510578 {
1054610579 //if (RENDERSHADOW) // ?
1054710580 if (!IsFrozen())
....@@ -11451,8 +11484,29 @@
1145111484
1145211485 static boolean zoomonce = false;
1145311486
11487
+ static void CreateSelectedPoint()
11488
+ {
11489
+ if (selectedpoint == null)
11490
+ {
11491
+ debugpointG = new Sphere();
11492
+ debugpointP = new Sphere();
11493
+ debugpointC = new Sphere();
11494
+ debugpointR = new Sphere();
11495
+
11496
+ selectedpoint = new Superellipsoid();
11497
+
11498
+ for (int i=0; i<8; i++)
11499
+ {
11500
+ debugpoints[i] = new Sphere();
11501
+ }
11502
+ }
11503
+ }
11504
+
1145411505 void DrawObject(GL gl, boolean draw)
1145511506 {
11507
+ // To clear camera values
11508
+ ResetOptions();
11509
+
1145611510 //System.out.println("DRAW OBJECT " + mouseDown);
1145711511 // DrawMode() = SELECTION;
1145811512 //GL gl = getGL();
....@@ -11531,8 +11585,9 @@
1153111585
1153211586 if (DrawMode() == DEFAULT)
1153311587 {
11534
- if (DEBUG)
11588
+ if (Globals.DEBUG)
1153511589 {
11590
+ CreateSelectedPoint();
1153611591 float radius = 0.05f;
1153711592 if (selectedpoint.radius != radius)
1153811593 {
....@@ -12019,7 +12074,7 @@
1201912074 for (int i = tp.size(); --i >= 0;)
1202012075 {
1202112076 //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12022
- LA.xformPos(light, tp.get(i).GlobalTransform(), light);
12077
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1202312078 }
1202412079
1202512080
....@@ -13289,7 +13344,8 @@
1328913344 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1329013345 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1329113346 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13292
- Object3D.cVector2[] vector2buffer;
13347
+
13348
+ //Object3D.cVector2[] vector2buffer;
1329313349
1329413350 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1329513351 // OUT : diff, spec
....@@ -13812,6 +13868,7 @@
1381213868 else
1381313869 if (evt.getSource() == AAtimer)
1381413870 {
13871
+ Globals.TIMERRUNNING = false;
1381513872 if (mouseDown)
1381613873 {
1381713874 //new Exception().printStackTrace();
....@@ -13886,6 +13943,7 @@
1388613943 return;
1388713944
1388813945 AAtimer.restart(); //
13946
+ Globals.TIMERRUNNING = true;
1388913947
1389013948 // waslive = LIVE;
1389113949 // LIVE = false;
....@@ -14349,7 +14407,8 @@
1434914407 info.camera = renderCamera;
1435014408 info.x = x;
1435114409 info.y = y;
14352
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14410
+ object.GetWindow().copy
14411
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1435314412 } else
1435414413 {
1435514414 if (x < startX)
....@@ -14513,7 +14572,9 @@
1451314572 ci.camera = renderCamera;
1451414573 if (!isRenderer)
1451514574 {
14516
- if (object.editWindow.copy.doEditClick(ci, 0))
14575
+ //ObjEditor editWindow = object.editWindow;
14576
+ //Object3D copy = editWindow.copy;
14577
+ if (object.doEditClick(ci, 0))
1451714578 {
1451814579 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1451914580 } else
....@@ -14894,8 +14955,14 @@
1489414955 RevertCamera();
1489514956 repaint();
1489614957 break;
14897
- case 'L':
1489814958 case 'l':
14959
+ lightMode ^= true;
14960
+ Globals.lighttouched = true;
14961
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14962
+ targetLookAt.set(manipCamera.lookAt);
14963
+ repaint();
14964
+ break;
14965
+ case 'L':
1489914966 if (lightMode)
1490014967 {
1490114968 lightMode = false;
....@@ -15042,16 +15109,14 @@
1504215109 kompactbit = 6;
1504315110 break;
1504415111 case ' ':
15045
- lightMode ^= true;
15046
- Globals.lighttouched = true;
15047
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
15048
- targetLookAt.set(manipCamera.lookAt);
15112
+ ObjEditor.theFrame.ToggleFullScreen();
1504915113 repaint();
1505015114 break;
1505115115 //case '`' :
1505215116 case ESC:
1505315117 RENDERPROGRAM += 1;
1505415118 RENDERPROGRAM %= 3;
15119
+
1505515120 repaint();
1505615121 break;
1505715122 case 'Z':
....@@ -15343,7 +15408,7 @@
1534315408 }
1534415409 */
1534515410
15346
- object.editWindow.EditSelection();
15411
+ object.editWindow.EditSelection(false);
1534715412 }
1534815413
1534915414 void SelectParent()
....@@ -16355,16 +16420,16 @@
1635516420 cStatic.objectstack[materialdepth++] = checker;
1635616421 //System.out.println("material " + material);
1635716422 //Applet3D.tracein(this, selected);
16358
- vector2buffer = checker.projectedVertices;
16423
+ //vector2buffer = checker.projectedVertices;
1635916424
1636016425 //checker.GetMaterial().Draw(this, false); // true);
16361
- DrawMaterial(checker.GetMaterial(), false); // true);
16426
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1636216427
1636316428 materialdepth -= 1;
1636416429 if (materialdepth > 0)
1636516430 {
16366
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16367
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16431
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16432
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1636816433 }
1636916434 //checker.GetMaterial().opacity = 1f;
1637016435 ////checker.GetMaterial().ambient = 1f;
....@@ -16587,6 +16652,8 @@
1658716652 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1658816653 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1658916654 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16655
+
16656
+ CreateSelectedPoint();
1659016657
1659116658 // Will fit the mesh !!!
1659216659 selectedpoint.toParent[0][0] = 0.0001;
....@@ -17227,23 +17294,15 @@
1722717294 int AAbuffersize = 0;
1722817295
1722917296 //double[] selectedpoint = new double[3];
17230
- static Superellipsoid selectedpoint = new Superellipsoid();
17297
+ static Superellipsoid selectedpoint;
1723117298 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();
17299
+ static Sphere debugpointG;
17300
+ static Sphere debugpointP;
17301
+ static Sphere debugpointC;
17302
+ static Sphere debugpointR;
1723617303
1723717304 static Sphere debugpoints[] = new Sphere[8];
1723817305
17239
- static
17240
- {
17241
- for (int i=0; i<8; i++)
17242
- {
17243
- debugpoints[i] = new Sphere();
17244
- }
17245
- }
17246
-
1724717306 static void InitPoints(float radius)
1724817307 {
1724917308 for (int i=0; i<8; i++)