Normand Briere
2019-06-24 c67da2e5d8655704601d6d06e8bc60aabe212253
Compute shadow when live option.
7 files modified
87 ■■■■ changed files
CameraPane.java 42 ●●●● patch | view | raw | blame | history
Globals.java 1 ●●●● patch | view | raw | blame | history
Grafreed.java 2 ●●● patch | view | raw | blame | history
GroupEditor.java 30 ●●●●● patch | view | raw | blame | history
Mocap.java 2 ●●● patch | view | raw | blame | history
Object3D.java 7 ●●●●● patch | view | raw | blame | history
cRadio.java 3 ●●●●● patch | view | raw | blame | history
CameraPane.java
....@@ -326,7 +326,7 @@
326326 cStatic.objectstack[materialdepth++] = obj;
327327 //System.out.println("material " + material);
328328 //Applet3D.tracein(this, selected);
329
- display.vector2buffer = obj.projectedVertices;
329
+ //display.vector2buffer = obj.projectedVertices;
330330 if (obj instanceof Camera)
331331 {
332332 display.options1[0] = material.shift;
....@@ -358,7 +358,7 @@
358358 /**/
359359 } else
360360 {
361
- DrawMaterial(material, selected);
361
+ DrawMaterial(material, selected, obj.projectedVertices);
362362 }
363363 } else
364364 {
....@@ -382,8 +382,8 @@
382382 cStatic.objectstack[materialdepth++] = obj;
383383 //System.out.println("material " + material);
384384 //Applet3D.tracein("selected ", selected);
385
- display.vector2buffer = obj.projectedVertices;
386
- display.DrawMaterial(material, selected);
385
+ //display.vector2buffer = obj.projectedVertices;
386
+ display.DrawMaterial(material, selected, obj.projectedVertices);
387387 }
388388 }
389389
....@@ -400,8 +400,8 @@
400400 materialdepth -= 1;
401401 if (materialdepth > 0)
402402 {
403
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
404
- 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);
405405 }
406406 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
407407 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -421,8 +421,8 @@
421421 materialdepth -= 1;
422422 if (materialdepth > 0)
423423 {
424
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
425
- 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);
426426 }
427427 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
428428 //else
....@@ -1610,7 +1610,7 @@
16101610 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16111611 }
16121612
1613
- void DrawMaterial(cMaterial material, boolean selected)
1613
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16141614 {
16151615 CameraPane display = this;
16161616 //new Exception().printStackTrace();
....@@ -1645,7 +1645,7 @@
16451645 colorV[0] = display.modelParams0[0] * material.diffuse;
16461646 colorV[1] = display.modelParams0[1] * material.diffuse;
16471647 colorV[2] = display.modelParams0[2] * material.diffuse;
1648
- colorV[3] = material.opacity;
1648
+ colorV[3] = 1; // material.opacity;
16491649
16501650 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16511651 //System.out.println("Opacity = " + opacity);
....@@ -1753,9 +1753,9 @@
17531753 display.modelParams7[2] = 0;
17541754 display.modelParams7[3] = 0;
17551755
1756
- display.modelParams6[0] = 100; // criss de bug de bump
1756
+ //display.modelParams6[0] = 100; // criss de bug de bump
17571757
1758
- Object3D.cVector2[] extparams = display.vector2buffer;
1758
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17591759 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17601760 {
17611761 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -10548,7 +10548,8 @@
1054810548 ambientOcclusion = false;
1054910549 }
1055010550
10551
- if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
10551
+ if (//Globals.lighttouched &&
10552
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1055210553 {
1055310554 //if (RENDERSHADOW) // ?
1055410555 if (!IsFrozen())
....@@ -13315,7 +13316,8 @@
1331513316 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1331613317 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1331713318 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13318
- Object3D.cVector2[] vector2buffer;
13319
+
13320
+ //Object3D.cVector2[] vector2buffer;
1331913321
1332013322 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1332113323 // OUT : diff, spec
....@@ -14539,7 +14541,9 @@
1453914541 ci.camera = renderCamera;
1454014542 if (!isRenderer)
1454114543 {
14542
- if (object.editWindow.copy.doEditClick(ci, 0))
14544
+ ObjEditor editWindow = object.editWindow;
14545
+ Object3D copy = editWindow.copy;
14546
+ if (copy.doEditClick(ci, 0))
1454314547 {
1454414548 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1454514549 } else
....@@ -16385,16 +16389,16 @@
1638516389 cStatic.objectstack[materialdepth++] = checker;
1638616390 //System.out.println("material " + material);
1638716391 //Applet3D.tracein(this, selected);
16388
- vector2buffer = checker.projectedVertices;
16392
+ //vector2buffer = checker.projectedVertices;
1638916393
1639016394 //checker.GetMaterial().Draw(this, false); // true);
16391
- DrawMaterial(checker.GetMaterial(), false); // true);
16395
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1639216396
1639316397 materialdepth -= 1;
1639416398 if (materialdepth > 0)
1639516399 {
16396
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16397
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16400
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16401
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1639816402 }
1639916403 //checker.GetMaterial().opacity = 1f;
1640016404 ////checker.GetMaterial().ambient = 1f;
Globals.java
....@@ -7,6 +7,7 @@
77 static iCameraPane theRenderer;
88
99 private static boolean LIVE = false;
10
+ public static boolean COMPUTESHADOWWHENLIVE = true;
1011 public static boolean RENDERSHADOW = true;
1112
1213 public static boolean MOUSEDRAGGED = false;
Grafreed.java
....@@ -876,7 +876,7 @@
876876 static int depth = 0;
877877 static java.util.Stack stack = new java.util.Stack();
878878 static boolean traceoff = false; // true;
879
- static float[] colorV = new float[5];
879
+ static float[] colorV = new float[4]; // 5];
880880
881881 static void traceon()
882882 {
GroupEditor.java
....@@ -808,11 +808,19 @@
808808 // debugCB.addItemListener(this);
809809
810810 panel.add(oeilCB = new cCheckBox("Eye", CameraPane.OEIL)); //, constraints);
811
+ oeilCB.setToolTipText("Move camera when tracking target");
811812 oeilCB.addItemListener(this);
812813
814
+ panel.add(shadowCB = new cCheckBox("Shadow", Globals.COMPUTESHADOWWHENLIVE)); //, constraints);
815
+ shadowCB.setToolTipText("Compute shadows when live");
816
+ shadowCB.addItemListener(this);
817
+
818
+ if (Globals.ADVANCED)
819
+ {
813820 panel.add(lookAtCB = new cCheckBox("Target", CameraPane.LOOKAT)); //, constraints);
814821 lookAtCB.setToolTipText("Look-at target");
815822 lookAtCB.addItemListener(this);
823
+ }
816824
817825 }
818826
....@@ -827,6 +835,14 @@
827835 void EditObject(Object3D obj)
828836 {
829837 cRadio radioButton = new cRadio(obj.name);
838
+
839
+ // Patch to avoid bug with transparency.
840
+ radioButton.hadMaterial = obj.material != null;
841
+ if (!radioButton.hadMaterial)
842
+ {
843
+ obj.material = new cMaterial();
844
+ }
845
+
830846 radioButton.SetObject(obj);
831847 radioButton.layout = sevenButton;
832848 radioButton.SetCamera(cameraView.renderCamera, false);
....@@ -863,7 +879,9 @@
863879 JCheckBox speakerCameraCB;
864880 JCheckBox speakerFocusCB;
865881 JCheckBox debugCB;
882
+
866883 JCheckBox oeilCB;
884
+ JCheckBox shadowCB;
867885 JCheckBox lookAtCB;
868886
869887 // static int COLOR = 1;
....@@ -966,6 +984,10 @@
966984 else if(e.getSource() == oeilCB)
967985 {
968986 cameraView.ToggleOeil();
987
+ }
988
+ else if(e.getSource() == shadowCB)
989
+ {
990
+ Globals.COMPUTESHADOWWHENLIVE ^= true;
969991 }
970992 else if(e.getSource() == lookAtCB)
971993 {
....@@ -3126,8 +3148,14 @@
31263148 for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
31273149 {
31283150 ab = (cRadio)e.nextElement();
3129
- if(ab.getModel().isSelected() && ab.GetObject() != client)
3151
+ if (ab.getModel().isSelected() && ab.GetObject() != client)
31303152 {
3153
+ // Patch to avoid bug with transparency.
3154
+ if (!ab.hadMaterial)
3155
+ {
3156
+ ab.object.material = null;
3157
+ }
3158
+
31313159 buttonGroup.remove(ab);
31323160 radioPanel.remove(ab);
31333161
Mocap.java
....@@ -3915,7 +3915,7 @@
39153915 // return;
39163916
39173917 if (//!restarted && /*display.restartframe &&*/
3918
- Globals.isLIVE() && live && (display.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW))
3918
+ Globals.isLIVE() && live && (display.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE))
39193919 {
39203920 //display.restartframe = false;
39213921 restarted = true;
Object3D.java
....@@ -881,7 +881,7 @@
881881
882882 if (marked && Globals.isLIVE() && live &&
883883 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
884
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
885885 currentframe != Globals.framecount)
886886 {
887887 currentframe = Globals.framecount;
....@@ -966,6 +966,7 @@
966966 if (material == null || material.multiply)
967967 return true;
968968
969
+ // Transparent objects are dynamic because we have to sort the triangles.
969970 return material.opacity > 0.99;
970971 }
971972
....@@ -5750,7 +5751,7 @@
57505751 support = support;
57515752
57525753 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5753
- boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5754
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
57545755
57555756 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57565757 {
....@@ -5771,7 +5772,7 @@
57715772
57725773 if (!selectmode && //display.DrawMode() != display.SELECTION &&
57735774 //(touched || (bRep != null && bRep.displaylist <= 0)))
5774
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
5775
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && (bRep != null && bRep.displaylist <= 0)))
57755776 {
57765777 Globals.lighttouched = true;
57775778 } // all panes...
cRadio.java
....@@ -38,6 +38,9 @@
3838 byte[] graphs[] = new byte[10000][];
3939 int undoindex = 0;
4040
41
+ // Patch to avoid bug with transparency.
42
+ boolean hadMaterial;
43
+
4144 Object3D object;
4245 Camera camera;
4346 cButton layout;