Normand Briere
2019-06-21 15123b19e7bc8da2869429b07f0fbaa0598e945e
CameraPane.java
....@@ -56,8 +56,6 @@
5656 static int CURRENTANTIALIAS = 0; // 1;
5757 /*static*/ boolean RENDERSHADOW = true;
5858 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
59
- static boolean ANIMATION = false;
60
- static String filename;
6159
6260 boolean DISPLAYTEXT = false;
6361 //boolean REDUCETEXTURE = true;
....@@ -92,6 +90,8 @@
9290
9391 static int tickcount = 0; // slow pose issue
9492
93
+static boolean BUTTONLESSWHEEL = false;
94
+static boolean ZOOMBOXMODE = false;
9595 static boolean BOXMODE = false;
9696 static boolean IMAGEFLIP = false;
9797 static boolean SMOOTHFOCUS = false;
....@@ -106,7 +106,7 @@
106106 static boolean OEIL = true;
107107 static boolean OEILONCE = false; // do oeilon then oeiloff
108108 static boolean LOOKAT = true;
109
-static boolean RANDOM = true; // false;
109
+static boolean SWITCH = true; // false;
110110 static boolean HANDLES = false; // selection doesn't work!!
111111 static boolean PAINTMODE = false;
112112
....@@ -149,12 +149,13 @@
149149 defaultcaps.setAccumBlueBits(16);
150150 defaultcaps.setAccumAlphaBits(16);
151151 }
152
- static CameraPane theRenderer;
153
-
152
+
153
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
154
+
154155 void SetAsGLRenderer(boolean b)
155156 {
156157 isRenderer = b;
157
- theRenderer = this;
158
+ Globals.theRenderer = this;
158159 }
159160
160161 CameraPane(Object3D o, Camera cam, boolean withcontext)
....@@ -191,6 +192,45 @@
191192 }
192193
193194 /// INTERFACE
195
+
196
+ public javax.media.opengl.GL GetGL0()
197
+ {
198
+ return null;
199
+ }
200
+
201
+ public int GenList()
202
+ {
203
+ javax.media.opengl.GL gl = GetGL();
204
+ return gl.glGenLists(1);
205
+ }
206
+
207
+ public void NewList(int id)
208
+ {
209
+ javax.media.opengl.GL gl = GetGL();
210
+ gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE);
211
+ }
212
+
213
+ public void CallList(int id)
214
+ {
215
+ javax.media.opengl.GL gl = GetGL();
216
+ gl.glCallList(id);
217
+ }
218
+
219
+ public void EndList()
220
+ {
221
+ javax.media.opengl.GL gl = GetGL();
222
+ gl.glEndList();
223
+ }
224
+
225
+ public boolean IsBoxMode()
226
+ {
227
+ return BOXMODE;
228
+ }
229
+
230
+ public boolean IsZoomBoxMode()
231
+ {
232
+ return ZOOMBOXMODE;
233
+ }
194234
195235 public void ClearDepth()
196236 {
....@@ -231,9 +271,14 @@
231271 return this.ambientOcclusion;
232272 }
233273
274
+ public boolean IsDebugSelection()
275
+ {
276
+ return DEBUG_SELECTION;
277
+ }
278
+
234279 public boolean IsFrozen()
235280 {
236
- boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
281
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
237282
238283 return !selectmode && cameracount == 0; // != 0;
239284 }
....@@ -254,9 +299,19 @@
254299 return lightCamera;
255300 }
256301
302
+ public Camera ManipCamera()
303
+ {
304
+ return manipCamera;
305
+ }
306
+
257307 public Camera RenderCamera()
258308 {
259309 return renderCamera;
310
+ }
311
+
312
+ public Camera[] Cameras()
313
+ {
314
+ return cameras;
260315 }
261316
262317 public void PushMaterial(Object3D obj, boolean selected)
....@@ -403,16 +458,18 @@
403458
404459 javax.media.opengl.GL gl = display.GetGL();
405460
406
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
461
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
407462
408463 //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
409464 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
410465 {
411466 //gl.glBegin(gl.GL_TRIANGLES);
412
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
467
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
468
+ // TEST LIVE NORMALS && !obj.dontselect
469
+ ;
413470 if (!hasnorm)
414471 {
415
- // System.out.println("FUCK!!");
472
+ // System.out.println("Mesh normal");
416473 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
417474 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
418475 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -566,7 +623,816 @@
566623 }
567624 }
568625
626
+ /**
627
+ * <code>draw</code> renders a <code>TriMesh</code> object including
628
+ * it's normals, colors, textures and vertices.
629
+ *
630
+ * @see Renderer#draw(TriMesh)
631
+ * @param tris
632
+ * the mesh to render.
633
+ */
634
+ public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris)
635
+ {
636
+ CameraPane display = this;
637
+
638
+ float r = display.modelParams0[0];
639
+ float g = display.modelParams0[1];
640
+ float b = display.modelParams0[2];
641
+ float opacity = display.modelParams5[1];
642
+
643
+ //final GL gl = GLU.getCurrentGL();
644
+ GL gl = display.GetGL(); // getGL();
645
+
646
+ FloatBuffer vertBuf = geo.vertBuf;
647
+
648
+ int v = vertBuf.capacity();
649
+
650
+ int count = 0;
651
+
652
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
653
+ gl.glEnable(gl.GL_CULL_FACE);
654
+ // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024);
655
+ for (int i=0; i<v/3; i++)
656
+ {
657
+ int index3 = i*3;
658
+
659
+ if (geo.sizeBuf.get(index3+1) == 0)
660
+ continue;
661
+
662
+ count++;
663
+
664
+ int index4 = i*4;
665
+
666
+ float tx = vertBuf.get(index3);
667
+ float ty = vertBuf.get(index3+1);
668
+ float tz = vertBuf.get(index3+2);
669
+
670
+ // if (tx == 0 && ty == 0 && tz == 0)
671
+ // continue;
672
+
673
+ gl.glMatrixMode(gl.GL_TEXTURE);
674
+ gl.glPushMatrix();
675
+
676
+ float[] texmat = geo.texmat;
677
+ texmat[12] = texmat[13] = texmat[14] = i;
678
+
679
+ gl.glMultMatrixf(texmat, 0);
680
+
681
+ gl.glMatrixMode(gl.GL_MODELVIEW);
682
+ gl.glPushMatrix();
683
+
684
+ gl.glTranslatef(tx,ty,tz);
685
+
686
+ if (rotate)
687
+ gl.glRotatef(i, 0, 1, 0);
688
+
689
+ float size = geo.sizeBuf.get(index3) / 100;
690
+ gl.glScalef(size,size,size);
691
+
692
+ float cr = geo.colorBuf.get(index4);
693
+ float cg = geo.colorBuf.get(index4+1);
694
+ float cb = geo.colorBuf.get(index4+2);
695
+ float ca = geo.colorBuf.get(index4+3);
696
+
697
+ display.modelParams0[0] = r * cr;
698
+ display.modelParams0[1] = g * cg;
699
+ display.modelParams0[2] = b * cb;
700
+
701
+ display.modelParams5[1] = opacity * ca;
702
+
703
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
704
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
705
+
706
+ RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i;
707
+ RandomNode.globalseed2 = RandomNode.globalseed;
708
+
709
+// gl.glColor4f(cr,cg,cb,ca);
710
+ // gl.glScalef(1024/16,1024/16,1024/16);
711
+ shape.Draw/*Node*/(display,null,selected,false); // blocked
712
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
713
+ //gl.glTranslatef(-tx,-ty,-tz);
714
+ gl.glPopMatrix();
715
+
716
+ gl.glMatrixMode(gl.GL_TEXTURE);
717
+ gl.glPopMatrix();
718
+ }
719
+ // gl.glScalef(1024,1024,1024);
720
+ if (!cf)
721
+ gl.glDisable(gl.GL_CULL_FACE);
722
+
723
+ display.modelParams0[0] = r;
724
+ display.modelParams0[1] = g;
725
+ display.modelParams0[2] = b;
726
+
727
+ display.modelParams5[1] = opacity;
728
+
729
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
730
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
731
+
732
+ gl.glMatrixMode(gl.GL_MODELVIEW);
733
+
734
+// System.err.println("total = " + v/3 + "; displayed = " + count);
735
+ if (true)
736
+ return;
737
+
738
+//// if (!tris.predraw(this))
739
+//// {
740
+//// return;
741
+//// }
742
+//// if (Debug.stats)
743
+//// {
744
+//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount());
745
+//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount());
746
+//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1);
747
+//// }
748
+////
749
+//// if (tris.getDisplayListID() != -1)
750
+//// {
751
+//// renderDisplayList(tris);
752
+//// return;
753
+//// }
754
+////
755
+//// if (!generatingDisplayList)
756
+//// {
757
+//// applyStates(tris.states, tris);
758
+//// }
759
+//// if (Debug.stats)
760
+//// {
761
+//// StatCollector.startStat(StatType.STAT_RENDER_TIMER);
762
+//// }
763
+//// boolean transformed = doTransforms(tris);
764
+//
765
+// int glMode = GL.GL_TRIANGLES;
766
+// switch (getMode())
767
+// {
768
+// case Triangles:
769
+// glMode = GL.GL_TRIANGLES;
770
+// break;
771
+// case Strip:
772
+// glMode = GL.GL_TRIANGLE_STRIP;
773
+// break;
774
+// case Fan:
775
+// glMode = GL.GL_TRIANGLE_FAN;
776
+// break;
777
+// }
778
+//
779
+// if (!predrawGeometry(gl))
780
+// {
781
+// // make sure only the necessary indices are sent through on old
782
+// // cards.
783
+// IntBuffer indices = this.getIndexBuffer();
784
+// if (indices == null)
785
+// {
786
+// logger.severe("missing indices on geometry object: " + this.toString());
787
+// } else
788
+// {
789
+// indices.rewind();
790
+// indices.limit(this.getMaxIndex());
791
+//
792
+// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT
793
+//
794
+// indices.clear();
795
+// }
796
+// } else
797
+// {
798
+// gl.glDrawElements(glMode, this.getIndexBuffer().limit(),
799
+// GL.GL_UNSIGNED_INT, 0);
800
+// }
801
+//
802
+//// postdrawGeometry(tris);
803
+//// if (transformed)
804
+//// {
805
+//// undoTransforms(tris);
806
+//// }
807
+////
808
+//// if (Debug.stats)
809
+//// {
810
+//// StatCollector.endStat(StatType.STAT_RENDER_TIMER);
811
+//// }
812
+//// tris.postdraw(this);
813
+ }
814
+
815
+ static Camera localcamera = new Camera();
816
+ static cVector from = new cVector();
817
+ static cVector to = new cVector();
818
+
819
+ public void PrepOcclusion(BoundaryRep br, double[][] transform)
820
+ {
821
+ CameraPane cp = this;
822
+
823
+ Camera keep = cp.RenderCamera();
824
+ cp.renderCamera = localcamera;
825
+
826
+ if (br.trimmed)
827
+ {
828
+ float[] colors = new float[br.positions.length / 3];
829
+
830
+ int i3 = 0;
831
+ for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
832
+ {
833
+ if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
834
+ continue;
835
+
836
+ from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
837
+ to.set(br.positions[i3] + br.normals[i3],
838
+ br.positions[i3 + 1] + br.normals[i3 + 1],
839
+ br.positions[i3 + 2] + br.normals[i3 + 2]);
840
+ LA.xformPos(from, transform, from);
841
+ LA.xformPos(to, transform, to); // RIGID ONLY
842
+ localcamera.setAim(from, to);
843
+
844
+ CameraPane.occlusionbuffer.display();
845
+
846
+ if (CameraPane.DEBUG_OCCLUSION)
847
+ cp.display(); // debug
848
+
849
+ colors[i] = cp.vertexOcclusion.r;
850
+ //colors[i3 + 1] = cp.vertexOcclusion.g;
851
+ //colors[i3 + 2] = cp.vertexOcclusion.b;
852
+
853
+ if ((i % 100) == 0 && i != 0)
854
+ {
855
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
856
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
857
+ System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
858
+ }
859
+ }
860
+
861
+ br.colors = colors;
862
+ }
863
+ else
864
+ {
865
+ for (int i = 0; i < br.VertexCount(); i++)
866
+ {
867
+ Vertex v = br.GetVertex(i);
868
+
869
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
870
+ continue;
871
+
872
+ from.set(v.x, v.y, v.z);
873
+ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
874
+ LA.xformPos(from, transform, from);
875
+ LA.xformPos(to, transform, to); // RIGID ONLY
876
+ localcamera.setAim(from, to);
877
+
878
+ CameraPane.occlusionbuffer.display();
879
+
880
+ if (CameraPane.DEBUG_OCCLUSION)
881
+ cp.display(); // debug
882
+
883
+ v.AO = cp.vertexOcclusion.r;
884
+
885
+ if ((i % 100) == 0 && i != 0)
886
+ {
887
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
888
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
889
+ System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
890
+ }
891
+ }
892
+ }
893
+
894
+ //System.out.println("done.");
895
+
896
+ cp.renderCamera = keep;
897
+ }
898
+
899
+ void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
900
+ {
901
+ CameraPane display = this;
902
+ pointFlow.CreateHT();
903
+
904
+ float r = display.modelParams0[0];
905
+ float g = display.modelParams0[1];
906
+ float b = display.modelParams0[2];
907
+ float opacity = display.modelParams5[1];
908
+
909
+ //final GL gl = GLU.getCurrentGL();
910
+ GL gl = display.GetGL(); // getGL();
911
+
912
+ int s = pointFlow.points.size();
913
+
914
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
915
+ gl.glEnable(gl.GL_CULL_FACE);
916
+
917
+ for (int i=s; --i>=0;)
918
+ //for (int i=0; i<s; i++)
919
+ {
920
+ cVector v = pointFlow.points.get(i);
921
+
922
+ double mindist = Double.MAX_VALUE;
923
+
924
+ double size = pointFlow.minimumSize;
925
+
926
+ double distancenext = 0;
927
+
928
+ if (i > 0)
929
+ {
930
+ cVector w = pointFlow.points.get(i-1);
931
+
932
+ double dist = w.distance(v);
933
+
934
+ distancenext = dist;
935
+
936
+ if (mindist > dist)
937
+ {
938
+ mindist = dist;
939
+ size = mindist*pointFlow.resizefactor;
940
+ }
941
+ }
942
+
943
+ if (i < s-1)
944
+ {
945
+ cVector w = pointFlow.points.get(i+1);
946
+
947
+ double dist = w.distance(v);
948
+
949
+ if (mindist > dist)
950
+ {
951
+ mindist = dist;
952
+ size = mindist*pointFlow.resizefactor;
953
+ }
954
+ }
955
+
956
+ if (size < pointFlow.minimumSize)
957
+ size = pointFlow.minimumSize;
958
+ if (size > pointFlow.maximumSize)
959
+ size = pointFlow.maximumSize;
960
+
961
+ double tx = v.x;
962
+ double ty = v.y;
963
+ double tz = v.z;
964
+
965
+ // if (tx == 0 && ty == 0 && tz == 0)
966
+ // continue;
967
+
968
+ gl.glMatrixMode(gl.GL_TEXTURE);
969
+ gl.glPushMatrix();
970
+ pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
971
+
972
+ gl.glMultMatrixf(pointFlow.texmat, 0);
973
+
974
+ gl.glMatrixMode(gl.GL_MODELVIEW);
975
+ gl.glPushMatrix();
976
+
977
+ gl.glTranslated(tx,ty,tz);
978
+
979
+ gl.glScaled(size,size,size);
980
+
981
+// float cr = colorBuf.get(index4);
982
+// float cg = colorBuf.get(index4+1);
983
+// float cb = colorBuf.get(index4+2);
984
+// float ca = colorBuf.get(index4+3);
985
+//
986
+// display.modelParams0[0] = r * cr;
987
+// display.modelParams0[1] = g * cg;
988
+// display.modelParams0[2] = b * cb;
989
+//
990
+// display.modelParams5[1] = opacity * ca;
991
+//
992
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
993
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
994
+//
995
+// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
996
+// RandomNode.globalseed2 = RandomNode.globalseed;
997
+//
998
+//// gl.glColor4f(cr,cg,cb,ca);
999
+// // gl.glScalef(1024/16,1024/16,1024/16);
1000
+ pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
1001
+
1002
+ gl.glPopMatrix();
1003
+
1004
+ double step = size/4; //
1005
+
1006
+ if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
1007
+ continue;
1008
+
1009
+ int nbsteps = (int)(distancenext/step);
1010
+
1011
+ step = distancenext/nbsteps;
1012
+
1013
+ cVector next = pointFlow.points.get(i-1);
1014
+
1015
+ tmp.set(next);
1016
+ tmp.sub(v);
1017
+ tmp.normalize();
1018
+ tmp.mul(step);
1019
+
1020
+ // calculate next size
1021
+ mindist = Double.MAX_VALUE;
1022
+
1023
+ double nextsize = pointFlow.minimumSize;
1024
+
1025
+ if (i > 1)
1026
+ {
1027
+ cVector w = pointFlow.points.get(i-2);
1028
+
1029
+ double dist = w.distance(next);
1030
+
1031
+ if (mindist > dist)
1032
+ {
1033
+ mindist = dist;
1034
+ nextsize = mindist*pointFlow.resizefactor;
1035
+ }
1036
+ }
1037
+
1038
+ double dist = v.distance(next);
1039
+
1040
+ if (mindist > dist)
1041
+ {
1042
+ mindist = dist;
1043
+ nextsize = mindist*pointFlow.resizefactor;
1044
+ }
1045
+
1046
+ if (nextsize < pointFlow.minimumSize)
1047
+ nextsize = pointFlow.minimumSize;
1048
+ if (nextsize > pointFlow.maximumSize)
1049
+ nextsize = pointFlow.maximumSize;
1050
+ //
1051
+
1052
+ double count = 0;
1053
+
1054
+ while (distancenext > 0.000000001) // step
1055
+ {
1056
+ gl.glPushMatrix();
1057
+
1058
+ gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
1059
+
1060
+ double K = count/nbsteps;
1061
+
1062
+ double intersize = K*nextsize + (1-K)*size;
1063
+
1064
+ gl.glScaled(intersize,intersize,intersize);
1065
+
1066
+ pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
1067
+
1068
+ count++;
1069
+
1070
+ distancenext -= step;
1071
+
1072
+ gl.glPopMatrix();
1073
+ }
1074
+
1075
+ if (count != nbsteps)
1076
+ assert(count == nbsteps);
1077
+
1078
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
1079
+ //gl.glTranslatef(-tx,-ty,-tz);
1080
+
1081
+ gl.glMatrixMode(gl.GL_TEXTURE);
1082
+ gl.glPopMatrix();
1083
+ }
1084
+
1085
+ if (!cf)
1086
+ gl.glDisable(gl.GL_CULL_FACE);
1087
+
1088
+// display.modelParams0[0] = r;
1089
+// display.modelParams0[1] = g;
1090
+// display.modelParams0[2] = b;
1091
+//
1092
+// display.modelParams5[1] = opacity;
1093
+//
1094
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1095
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1096
+
1097
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1098
+ }
1099
+
1100
+ public void DrawBox(cVector min, cVector max)
1101
+ {
1102
+ javax.media.opengl.GL gl = GetGL();
1103
+ gl.glBegin(gl.GL_LINES);
1104
+
1105
+ gl.glVertex3d(min.x, min.y, min.z);
1106
+ gl.glVertex3d(min.x, min.y, max.z);
1107
+ gl.glVertex3d(min.x, min.y, min.z);
1108
+ gl.glVertex3d(min.x, max.y, min.z);
1109
+ gl.glVertex3d(min.x, min.y, min.z);
1110
+ gl.glVertex3d(max.x, min.y, min.z);
1111
+
1112
+ gl.glVertex3d(max.x, max.y, max.z);
1113
+ gl.glVertex3d(min.x, max.y, max.z);
1114
+ gl.glVertex3d(max.x, max.y, max.z);
1115
+ gl.glVertex3d(max.x, min.y, max.z);
1116
+ gl.glVertex3d(max.x, max.y, max.z);
1117
+ gl.glVertex3d(max.x, max.y, min.z);
1118
+
1119
+ gl.glEnd();
1120
+ }
1121
+
1122
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1123
+ {
1124
+ int[] strips = bRep.getRawIndices();
1125
+
1126
+ javax.media.opengl.GL gl = GetGL();
1127
+
1128
+ // TRIANGLE STRIP ARRAY
1129
+ if (bRep.trimmed)
1130
+ {
1131
+ float[] v = bRep.getRawVertices();
1132
+ float[] n = bRep.getRawNormals();
1133
+ float[] c = bRep.getRawColors();
1134
+ float[] uv = bRep.getRawUVMap();
1135
+
1136
+ int count2 = 0;
1137
+ int count3 = 0;
1138
+
1139
+ if (n.length > 0)
1140
+ {
1141
+ for (int i = 0; i < strips.length; i++)
1142
+ {
1143
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1144
+
1145
+ /*
1146
+ boolean locked = false;
1147
+ float eps = 0.1f;
1148
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1149
+
1150
+ int dot = 0;
1151
+
1152
+ if ((dot&1) == 0)
1153
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1154
+
1155
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1156
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1157
+ else
1158
+ {
1159
+ locked = true;
1160
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1161
+ }
1162
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1163
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1164
+ if (hasnorm)
1165
+ {
1166
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1167
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1168
+ }
1169
+
1170
+ if ((dot&4) == 0)
1171
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1172
+
1173
+ if (wrap || !locked && (dot&8) != 0)
1174
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1175
+ else
1176
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1177
+
1178
+ f.dot = dot;
1179
+ */
1180
+
1181
+ if (!selectmode)
1182
+ {
1183
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1184
+ {
1185
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1186
+ } else
1187
+ {
1188
+ gl.glNormal3f(0, 0, 1);
1189
+ }
1190
+
1191
+ if (c != null)
1192
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1193
+ {
1194
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1195
+ }
1196
+ }
1197
+
1198
+ if (flipV)
1199
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1200
+ else
1201
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1202
+
1203
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1204
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1205
+
1206
+ count2 += 2;
1207
+ count3 += 3;
1208
+ if (!selectmode)
1209
+ {
1210
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1211
+ {
1212
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1213
+ } else
1214
+ {
1215
+ gl.glNormal3f(0, 0, 1);
1216
+ }
1217
+ if (c != null)
1218
+ {
1219
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1220
+ }
1221
+ }
1222
+
1223
+ if (flipV)
1224
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1225
+ else
1226
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1227
+
1228
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1229
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1230
+
1231
+ count2 += 2;
1232
+ count3 += 3;
1233
+ for (int j = 0; j < strips[i] - 2; j++)
1234
+ {
1235
+ //gl.glTexCoord2d(...);
1236
+ if (!selectmode)
1237
+ {
1238
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1239
+ {
1240
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1241
+ } else
1242
+ {
1243
+ gl.glNormal3f(0, 0, 1);
1244
+ }
1245
+ if (c != null)
1246
+ {
1247
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1248
+ }
1249
+ }
1250
+
1251
+ if (flipV)
1252
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1253
+ else
1254
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1255
+
1256
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1257
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1258
+
1259
+ count2 += 2;
1260
+ count3 += 3;
1261
+ }
1262
+
1263
+ gl.glEnd();
1264
+ }
1265
+ }
1266
+
1267
+ assert count3 == v.length;
1268
+ }
1269
+ else // !trimmed
1270
+ {
1271
+ int count = 0;
1272
+ for (int i = 0; i < strips.length; i++)
1273
+ {
1274
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1275
+
1276
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1277
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1278
+
1279
+ drawVertex(gl, p, flipV, selectmode);
1280
+ drawVertex(gl, q, flipV, selectmode);
1281
+
1282
+ for (int j = 0; j < strips[i] - 2; j++)
1283
+ {
1284
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1285
+
1286
+ // if (j%2 == 0)
1287
+ // drawFace(p, q, r, display, null);
1288
+ // else
1289
+ // drawFace(p, r, q, display, null);
1290
+
1291
+ // p = q;
1292
+ // q = r;
1293
+ drawVertex(gl, r, flipV, selectmode);
1294
+ }
1295
+
1296
+ gl.glEnd();
1297
+ }
1298
+ }
1299
+ }
1300
+
1301
+ static cSpring.Point3D temp = new cSpring.Point3D();
1302
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1303
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1304
+
1305
+ public void DrawDynamicMesh(cMesh mesh)
1306
+ {
1307
+ GL gl = GetGL(); // getGL();
1308
+
1309
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1310
+
1311
+ gl.glDisable(gl.GL_LIGHTING);
1312
+
1313
+ gl.glLineWidth(1);
1314
+ gl.glColor3f(1,1,1);
1315
+ gl.glBegin(gl.GL_LINES);
1316
+ double scale = 0;
1317
+ int count = 0;
1318
+ for (int s=0; s<Phys.allSprings.size(); s++)
1319
+ {
1320
+ cSpring.Spring spring = Phys.allSprings.get(s);
1321
+ if(s == 0)
1322
+ {
1323
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1324
+ }
1325
+ if (mesh.showsprings)
1326
+ {
1327
+ temp.set(spring.a.position);
1328
+ temp.add(spring.b.position);
1329
+ temp.mul(0.5);
1330
+ temp2.set(spring.a.position);
1331
+ temp2.sub(spring.b.position);
1332
+ temp2.mul(spring.restLength/2);
1333
+ temp.sub(temp2);
1334
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1335
+ temp.add(temp2);
1336
+ temp.add(temp2);
1337
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1338
+ }
1339
+
1340
+ if (spring.isHandle)
1341
+ continue;
1342
+
1343
+ //if (scale < spring.restLength)
1344
+ scale += spring.restLength;
1345
+ count++;
1346
+ }
1347
+ gl.glEnd();
1348
+
1349
+ if (count == 0)
1350
+ scale = 0.01;
1351
+ else
1352
+ scale /= count * 3;
1353
+
1354
+ //scale = 0.25;
1355
+
1356
+ if (mesh.ShowInfo())
1357
+ {
1358
+ gl.glLineWidth(4);
1359
+ for (int s=0; s<Phys.allNodes.size(); s++)
1360
+ {
1361
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1362
+ if (node.mass == 0)
1363
+ continue;
1364
+
1365
+ int i = node.springs==null?-1:node.springs.size();
1366
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1367
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1368
+ //temp.normalize();
1369
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1370
+ gl.glBegin(gl.GL_LINES);
1371
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1372
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1373
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1374
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1375
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1376
+ gl.glEnd();
1377
+ }
1378
+
1379
+ gl.glLineWidth(8);
1380
+ for (int s=0; s<Phys.allNodes.size(); s++)
1381
+ {
1382
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1383
+
1384
+ if (node.springs != null)
1385
+ {
1386
+ for (int i=0; i<node.springs.size(); i+=1)
1387
+ {
1388
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1389
+
1390
+ int c = i+1;
1391
+ // c = node.springs.get(i).nbcopies;
1392
+
1393
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1394
+ gl.glBegin(gl.GL_LINES);
1395
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1396
+ gl.glVertex3d(f.position.x/3+node.position.x*2/3, f.position.y/3+node.position.y*2/3, f.position.z/3+node.position.z*2/3);
1397
+ gl.glEnd();
1398
+ }
1399
+ }
1400
+ }
1401
+
1402
+ gl.glLineWidth(1);
1403
+ }
1404
+
1405
+ gl.glEnable(gl.GL_LIGHTING);
1406
+ }
1407
+
5691408 /// INTERFACE
1409
+
1410
+ public void StartTriangles()
1411
+ {
1412
+ javax.media.opengl.GL gl = GetGL();
1413
+ gl.glBegin(gl.GL_TRIANGLES);
1414
+ }
1415
+
1416
+ public void EndTriangles()
1417
+ {
1418
+ GetGL().glEnd();
1419
+ }
1420
+
1421
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1422
+ {
1423
+ if (!selectmode)
1424
+ {
1425
+ gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1426
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1427
+
1428
+ if (flipV)
1429
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1430
+ else
1431
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1432
+ }
1433
+
1434
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1435
+ }
5701436
5711437 void SetColor(Object3D obj, Vertex p0)
5721438 {
....@@ -761,18 +1627,18 @@
7611627 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
7621628 if (!material.multiply)
7631629 {
764
- display.color = color;
1630
+ display.color = material.color;
7651631 display.saturation = material.modulation;
7661632 }
7671633 else
7681634 {
769
- display.color *= color*2;
1635
+ display.color *= material.color*2;
7701636 display.saturation *= material.modulation*2;
7711637 }
7721638
7731639 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
7741640
775
- float[] colorV = GrafreeD.colorV;
1641
+ float[] colorV = Grafreed.colorV;
7761642
7771643 /**/
7781644 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1032,7 +1898,7 @@
10321898 void PushMatrix(double[][] matrix)
10331899 {
10341900 // GrafreeD.tracein(matrix);
1035
- PushMatrix(matrix,1);
1901
+ PushMatrix(matrix, 1);
10361902 }
10371903
10381904 void PushMatrix()
....@@ -1129,7 +1995,7 @@
11291995
11301996 static int camerachangeframe;
11311997
1132
- boolean SetCamera(Camera cam)
1998
+ public boolean SetCamera(Camera cam)
11331999 {
11342000 // may 2014 if (cam == cameras[0] || cam == cameras[1])
11352001 // return false;
....@@ -1257,33 +2123,6 @@
12572123 mainDL ^= true;
12582124 }
12592125
1260
- void ToggleTexture()
1261
- {
1262
- textureon ^= true;
1263
- }
1264
-
1265
- void ToggleLive()
1266
- {
1267
- Globals.setLIVE(Globals.isLIVE() ^ true);
1268
-
1269
- System.err.println("LIVE = " + Globals.isLIVE());
1270
-
1271
- if (!Globals.isLIVE()) // save sound
1272
- GrafreeD.savesound = true; // wav.save();
1273
- // else
1274
- repaint(); // start loop // may 2013
1275
- }
1276
-
1277
- void ToggleSupport()
1278
- {
1279
- SUPPORT ^= true;
1280
- }
1281
-
1282
- void ToggleAbort()
1283
- {
1284
- ABORTMODE ^= true;
1285
- }
1286
-
12872126 void ToggleFullScreen()
12882127 {
12892128 FULLSCREEN ^= true;
....@@ -1294,72 +2133,94 @@
12942133 Globals.CROWD ^= true;
12952134 }
12962135
1297
- void ToggleInertia()
1298
- {
1299
- INERTIA ^= true;
1300
- }
1301
-
13022136 void ToggleLocal()
13032137 {
13042138 LOCALTRANSFORM ^= true;
13052139 }
13062140
1307
- void ToggleFast()
2141
+ public void ToggleTexture()
2142
+ {
2143
+ textureon ^= true;
2144
+ }
2145
+
2146
+ public void ToggleLive()
2147
+ {
2148
+ Globals.setLIVE(Globals.isLIVE() ^ true);
2149
+
2150
+ System.err.println("LIVE = " + Globals.isLIVE());
2151
+
2152
+ if (!Globals.isLIVE()) // save sound
2153
+ Grafreed.savesound = true; // wav.save();
2154
+ // else
2155
+ repaint(); // start loop // may 2013
2156
+ }
2157
+
2158
+ public void ToggleSupport()
2159
+ {
2160
+ SUPPORT ^= true;
2161
+ }
2162
+
2163
+ public void ToggleAbort()
2164
+ {
2165
+ ABORTMODE ^= true;
2166
+ }
2167
+
2168
+ public void ToggleInertia()
2169
+ {
2170
+ INERTIA ^= true;
2171
+ }
2172
+
2173
+ public void ToggleFast()
13082174 {
13092175 FAST ^= true;
13102176 }
13112177
1312
- void ToggleSlowPose()
2178
+ public void ToggleSlowPose()
13132179 {
13142180 SLOWPOSE ^= true;
13152181 }
13162182
1317
- void ToggleFootContact()
1318
- {
1319
- FOOTCONTACT ^= true;
1320
- }
1321
-
1322
- void ToggleBoxMode()
2183
+ public void ToggleBoxMode()
13232184 {
13242185 BOXMODE ^= true;
13252186 }
13262187
1327
- void ToggleSmoothFocus()
2188
+ public void ToggleZoomBoxMode()
2189
+ {
2190
+ ZOOMBOXMODE ^= true;
2191
+ }
2192
+
2193
+ public void ToggleSmoothFocus()
13282194 {
13292195 SMOOTHFOCUS ^= true;
13302196 }
13312197
1332
- void ToggleImageFlip()
2198
+ public void ToggleImageFlip()
13332199 {
13342200 IMAGEFLIP ^= true;
13352201 }
13362202
1337
- void ToggleSpeakerMocap()
2203
+ public void ToggleSpeakerMocap()
13382204 {
13392205 SPEAKERMOCAP ^= true;
13402206 }
13412207
1342
- void ToggleSpeakerCamera()
2208
+ public void ToggleSpeakerCamera()
13432209 {
13442210 SPEAKERCAMERA ^= true;
13452211 }
13462212
1347
- void ToggleSpeakerFocus()
2213
+ public void ToggleSpeakerFocus()
13482214 {
13492215 SPEAKERFOCUS ^= true;
13502216 }
13512217
1352
- void ToggleDebug()
1353
- {
1354
- DEBUG ^= true;
1355
- }
1356
-
1357
- void ToggleFrustum()
2218
+ public void ToggleFrustum()
13582219 {
13592220 FRUSTUM ^= true;
13602221 }
13612222
1362
- void ToggleTrack()
2223
+ public void ToggleTrack()
13632224 {
13642225 TRACK ^= true;
13652226 if (TRACK)
....@@ -1378,25 +2239,35 @@
13782239 repaint();
13792240 }
13802241
1381
- void ToggleTrackOnce()
2242
+ public void ToggleTrackOnce()
13822243 {
13832244 TRACKONCE ^= true;
13842245 }
13852246
1386
- void ToggleShadowTrack()
2247
+ public void ToggleShadowTrack()
13872248 {
13882249 SHADOWTRACK ^= true;
13892250 repaint();
13902251 }
13912252
1392
- void ToggleOeil()
2253
+ public void ToggleOeil()
13932254 {
13942255 OEIL ^= true;
13952256 }
13962257
1397
- void ToggleOeilOnce()
2258
+ public void ToggleOeilOnce()
13982259 {
13992260 OEILONCE ^= true;
2261
+ }
2262
+
2263
+ void ToggleFootContact()
2264
+ {
2265
+ FOOTCONTACT ^= true;
2266
+ }
2267
+
2268
+ void ToggleDebug()
2269
+ {
2270
+ DEBUG ^= true;
14002271 }
14012272
14022273 void ToggleLookAt()
....@@ -1404,9 +2275,9 @@
14042275 LOOKAT ^= true;
14052276 }
14062277
1407
- void ToggleRandom()
2278
+ void ToggleSwitch()
14082279 {
1409
- RANDOM ^= true;
2280
+ SWITCH ^= true;
14102281 }
14112282
14122283 void ToggleHandles()
....@@ -1513,7 +2384,7 @@
15132384 {
15142385 return currentGL;
15152386 }
1516
-
2387
+
15172388 /**/
15182389 class CacheTexture
15192390 {
....@@ -3345,6 +4216,7 @@
33454216
33464217 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
33474218 {
4219
+ new Exception().printStackTrace();
33484220 System.exit(0);
33494221 com.sun.opengl.util.texture.Texture texture = null;
33504222
....@@ -7057,6 +7929,64 @@
70577929 ReleaseTexture(pigment, false);
70587930 }
70597931
7932
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7933
+ {
7934
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7935
+ {
7936
+ return;
7937
+ }
7938
+
7939
+ if (tex == null)
7940
+ {
7941
+ ReleaseTexture(null, false);
7942
+ return;
7943
+ }
7944
+
7945
+ String pigment = Object3D.GetPigment(tex);
7946
+
7947
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7948
+ {
7949
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7950
+ // System.out.println("; bump = " + bump);
7951
+ }
7952
+
7953
+ if (pigment.equals(""))
7954
+ {
7955
+ pigment = null;
7956
+ }
7957
+
7958
+ ReleaseTexture(pigment, false);
7959
+ }
7960
+
7961
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
7962
+ {
7963
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7964
+ {
7965
+ return;
7966
+ }
7967
+
7968
+ if (tex == null)
7969
+ {
7970
+ ReleaseTexture(null, true);
7971
+ return;
7972
+ }
7973
+
7974
+ String bump = Object3D.GetBump(tex);
7975
+
7976
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7977
+ {
7978
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7979
+ // System.out.println("; bump = " + bump);
7980
+ }
7981
+
7982
+ if (bump.equals(""))
7983
+ {
7984
+ bump = null;
7985
+ }
7986
+
7987
+ ReleaseTexture(bump, true);
7988
+ }
7989
+
70607990 void ReleaseTexture(String tex, boolean bump)
70617991 {
70627992 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -7160,7 +8090,7 @@
71608090 }
71618091 }
71628092
7163
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8093
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
71648094 {
71658095 if (// DrawMode() != 0 || /*tex == null ||*/
71668096 ambientOcclusion ) // || !textureon)
....@@ -7205,7 +8135,94 @@
72058135 return; // true;
72068136 }
72078137
7208
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8138
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8139
+ {
8140
+ if (// DrawMode() != 0 || /*tex == null ||*/
8141
+ ambientOcclusion ) // || !textureon)
8142
+ {
8143
+ return; // false;
8144
+ }
8145
+
8146
+ if (tex == null)
8147
+ {
8148
+ BindTexture(null,false,resolution);
8149
+ return;
8150
+ }
8151
+
8152
+ String pigment = Object3D.GetPigment(tex);
8153
+
8154
+ usedtextures.put(pigment, pigment);
8155
+
8156
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8157
+ {
8158
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8159
+ // System.out.println("; bump = " + bump);
8160
+ }
8161
+
8162
+ if (pigment.equals(""))
8163
+ {
8164
+ pigment = null;
8165
+ }
8166
+
8167
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8168
+ BindTexture(pigment, false, resolution);
8169
+ }
8170
+
8171
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8172
+ {
8173
+ if (// DrawMode() != 0 || /*tex == null ||*/
8174
+ ambientOcclusion ) // || !textureon)
8175
+ {
8176
+ return; // false;
8177
+ }
8178
+
8179
+ if (tex == null)
8180
+ {
8181
+ BindTexture(null,true,resolution);
8182
+ return;
8183
+ }
8184
+
8185
+ String bump = Object3D.GetBump(tex);
8186
+
8187
+ usedtextures.put(bump, bump);
8188
+
8189
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8190
+ {
8191
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8192
+ // System.out.println("; bump = " + bump);
8193
+ }
8194
+
8195
+ if (bump.equals(""))
8196
+ {
8197
+ bump = null;
8198
+ }
8199
+
8200
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8201
+ BindTexture(bump, true, resolution);
8202
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8203
+ }
8204
+
8205
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8206
+
8207
+ private boolean FileExists(String tex)
8208
+ {
8209
+ if (missingTextures.contains(tex))
8210
+ {
8211
+ return false;
8212
+ }
8213
+
8214
+ boolean fileExists = new File(tex).exists();
8215
+
8216
+ if (!fileExists)
8217
+ {
8218
+ // If file exists, the "new File()" is not executed sgain
8219
+ missingTextures.add(tex);
8220
+ }
8221
+
8222
+ return fileExists;
8223
+ }
8224
+
8225
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
72098226 {
72108227 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
72118228
....@@ -7213,12 +8230,18 @@
72138230 {
72148231 String texname = tex;
72158232
7216
- String[] split = tex.split("Textures");
7217
- if (split.length > 1)
7218
- texname = "/Users/nbriere/Textures" + split[split.length-1];
7219
- else
7220
- if (!texname.startsWith("/"))
7221
- texname = "/Users/nbriere/Textures/" + texname;
8233
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8234
+
8235
+// String[] split = tex.split("Textures");
8236
+// if (split.length > 1)
8237
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8238
+// else
8239
+// if (!texname.startsWith("/"))
8240
+// texname = "/Users/nbriere/Textures/" + texname;
8241
+ if (!FileExists(tex))
8242
+ {
8243
+ texname = fallbackTextureName;
8244
+ }
72228245
72238246 if (CACHETEXTURE)
72248247 texture = textures.get(texname); // TEXTURE CACHE
....@@ -7287,7 +8310,7 @@
72878310 }
72888311
72898312 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
7290
- if (!new File(cachename).exists())
8313
+ if (!FileExists(cachename))
72918314 cachename = texname;
72928315 else
72938316 processbump = false; // don't process bump map again
....@@ -7309,7 +8332,7 @@
73098332 }
73108333
73118334 cachename = texname.substring(0, texname.length()-4)+ext+".png";
7312
- if (!new File(cachename).exists())
8335
+ if (!FileExists(cachename))
73138336 cachename = texname;
73148337 else
73158338 processbump = false; // don't process bump map again
....@@ -7318,7 +8341,9 @@
73188341 texturedata = GetFileTexture(cachename, processbump, resolution);
73198342
73208343
7321
- if (texturedata != null)
8344
+ if (texturedata == null)
8345
+ throw new Exception();
8346
+
73228347 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
73238348 //texture = GetTexture(tex, bump);
73248349 }
....@@ -7440,7 +8465,7 @@
74408465 return texture;
74418466 }
74428467
7443
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8468
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
74448469 {
74458470 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
74468471
....@@ -7458,14 +8483,14 @@
74588483 return texture!=null?texture.texture:null;
74598484 }
74608485
7461
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8486
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
74628487 {
74638488 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
74648489
74658490 return texture!=null?texture.texturedata:null;
74668491 }
74678492
7468
- boolean BindTexture(String tex, boolean bump, int resolution)
8493
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
74698494 {
74708495 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
74718496 {
....@@ -8442,8 +9467,8 @@
84429467 assert (parentcam != renderCamera);
84439468
84449469 if (renderCamera != lightCamera)
8445
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8446
- LA.matConcat(matrix, parentcam.toParent, matrix);
9470
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9471
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
84479472
84489473 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
84499474
....@@ -8458,8 +9483,8 @@
84589483 LA.matCopy(renderCamera.fromScreen, matrix);
84599484
84609485 if (renderCamera != lightCamera)
8461
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8462
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9486
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9487
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
84639488
84649489 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
84659490
....@@ -8531,7 +9556,7 @@
85319556 //gl.glFlush();
85329557 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
85339558
8534
- if (ANIMATION && ABORTED)
9559
+ if (Globals.ANIMATION && ABORTED)
85359560 {
85369561 System.err.println(" ABORTED FRAME");
85379562 break;
....@@ -8561,7 +9586,7 @@
85619586 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
85629587
85639588 // save image
8564
- if (ANIMATION && !ABORTED)
9589
+ if (Globals.ANIMATION && !ABORTED)
85659590 {
85669591 VPwidth = viewport[2];
85679592 VPheight = viewport[3];
....@@ -8672,11 +9697,11 @@
86729697
86739698 // imagecount++;
86749699
8675
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9700
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
86769701
86779702 if (!BOXMODE)
86789703 {
8679
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9704
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
86809705 }
86819706
86829707 if (!BOXMODE)
....@@ -8714,7 +9739,7 @@
87149739 ABORTED = false;
87159740 }
87169741 else
8717
- GrafreeD.wav.cursor += 735 * ACSIZE;
9742
+ Grafreed.wav.cursor += 735 * ACSIZE;
87189743
87199744 if (false)
87209745 {
....@@ -9377,11 +10402,11 @@
937710402
937810403 public void display(GLAutoDrawable drawable)
937910404 {
9380
- if (GrafreeD.savesound && GrafreeD.hassound)
10405
+ if (Grafreed.savesound && Grafreed.hassound)
938110406 {
9382
- GrafreeD.wav.save();
9383
- GrafreeD.savesound = false;
9384
- GrafreeD.hassound = false;
10407
+ Grafreed.wav.save();
10408
+ Grafreed.savesound = false;
10409
+ Grafreed.hassound = false;
938510410 }
938610411 // if (DEBUG_SELECTION)
938710412 // {
....@@ -9511,7 +10536,7 @@
951110536 Object3D theobject = object;
951210537 Object3D theparent = object.parent;
951310538 object.parent = null;
9514
- object = (Object3D)GrafreeD.clone(object);
10539
+ object = (Object3D)Grafreed.clone(object);
951510540 object.Stripify();
951610541 if (theobject.selection == null || theobject.selection.Size() == 0)
951710542 theobject.PreprocessOcclusion(this);
....@@ -9524,13 +10549,13 @@
952410549 ambientOcclusion = false;
952510550 }
952610551
9527
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10552
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
952810553 {
952910554 //if (RENDERSHADOW) // ?
953010555 if (!IsFrozen())
953110556 {
953210557 // dec 2012
9533
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10558
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
953410559 {
953510560 Globals.framecount++;
953610561 shadowbuffer.display();
....@@ -9657,8 +10682,8 @@
965710682
965810683 // if (parentcam != renderCamera) // not a light
965910684 if (cam != lightCamera)
9660
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9661
- LA.matConcat(matrix, parentcam.toParent, matrix);
10685
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10686
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
966210687
966310688 for (int j = 0; j < 4; j++)
966410689 {
....@@ -9672,8 +10697,8 @@
967210697
967310698 // if (parentcam != renderCamera) // not a light
967410699 if (cam != lightCamera)
9675
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9676
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10700
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10701
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
967710702
967810703 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
967910704
....@@ -9932,7 +10957,16 @@
993210957 // Bump noise
993310958 gl.glActiveTexture(GL.GL_TEXTURE6);
993410959 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
9935
- BindTexture(NOISE_TEXTURE, false, 2);
10960
+
10961
+ try
10962
+ {
10963
+ BindTexture(NOISE_TEXTURE, false, 2);
10964
+ }
10965
+ catch (Exception e)
10966
+ {
10967
+ System.err.println("FAILED: " + NOISE_TEXTURE);
10968
+ }
10969
+
993610970
993710971 gl.glActiveTexture(GL.GL_TEXTURE0);
993810972 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10057,8 +11091,8 @@
1005711091 System.err.println("parentcam != renderCamera");
1005811092
1005911093 // if (cam != lightCamera)
10060
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10061
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11094
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11095
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1006211096 }
1006311097
1006411098 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10079,8 +11113,8 @@
1007911113 if (true) // TODO
1008011114 {
1008111115 if (cam != lightCamera)
10082
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10083
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11116
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11117
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1008411118 }
1008511119
1008611120 LA.xformPos(light0, cam.toScreen, light0);
....@@ -10146,7 +11180,7 @@
1014611180 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
1014711181 //System.out.println("fragmentMode = " + fragmentMode);
1014811182
10149
- if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION)
11183
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
1015011184 {
1015111185 /*
1015211186 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -10396,8 +11430,14 @@
1039611430 {
1039711431 renderpass++;
1039811432 // System.out.println("Draw object... ");
11433
+ STEP = 1;
1039911434 if (FAST) // in case there is no script
10400
- STEP = 16;
11435
+ STEP = 8;
11436
+
11437
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11438
+ {
11439
+ STEP *= 4;
11440
+ }
1040111441
1040211442 //object.FullInvariants();
1040311443
....@@ -10411,8 +11451,8 @@
1041111451 e.printStackTrace();
1041211452 }
1041311453
10414
- if (GrafreeD.RENDERME > 0)
10415
- GrafreeD.RENDERME--; // mechante magouille
11454
+ if (Grafreed.RENDERME > 0)
11455
+ Grafreed.RENDERME--; // mechante magouille
1041611456
1041711457 Globals.ONESTEP = false;
1041811458 }
....@@ -10447,7 +11487,7 @@
1044711487 callist = gl.glGenLists(1);
1044811488 }
1044911489
10450
- boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
11490
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
1045111491
1045211492 boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
1045311493
....@@ -10482,7 +11522,14 @@
1048211522
1048311523 usedtextures.clear();
1048411524
10485
- BindTextures(DEFAULT_TEXTURES, 2);
11525
+ try
11526
+ {
11527
+ BindTextures(DEFAULT_TEXTURES, 2);
11528
+ }
11529
+ catch (Exception e)
11530
+ {
11531
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11532
+ }
1048611533 }
1048711534 //System.out.println("--> " + stackdepth);
1048811535 // GrafreeD.traceon();
....@@ -10573,7 +11620,14 @@
1057311620 if (checker != null && DrawMode() == DEFAULT)
1057411621 {
1057511622 //BindTexture(IMMORTAL_TEXTURE);
10576
- BindTextures(checker.GetTextures(), checker.texres);
11623
+ try
11624
+ {
11625
+ BindTextures(checker.GetTextures(), checker.texres);
11626
+ }
11627
+ catch (Exception e)
11628
+ {
11629
+ System.err.println("FAILED: " + checker.GetTextures());
11630
+ }
1057711631 // NEAREST
1057811632 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1057911633 DrawChecker(gl);
....@@ -10655,7 +11709,7 @@
1065511709 return;
1065611710 }
1065711711
10658
- String string = obj.GetToolTip();
11712
+ String string = obj.toString(); //.GetToolTip();
1065911713
1066011714 GL gl = GetGL();
1066111715
....@@ -10972,8 +12026,8 @@
1097212026 //obj.TransformToWorld(light, light);
1097312027 for (int i = tp.size(); --i >= 0;)
1097412028 {
10975
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
10976
- LA.xformPos(light, tp.get(i).toParent, light);
12029
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12030
+ LA.xformPos(light, tp.get(i).GlobalTransform(), light);
1097712031 }
1097812032
1097912033
....@@ -10990,8 +12044,8 @@
1099012044 parentcam = cameras[0];
1099112045 }
1099212046
10993
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10994
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12047
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12048
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1099512049
1099612050 LA.xformPos(light, renderCamera.toScreen, light);
1099712051
....@@ -11605,8 +12659,8 @@
1160512659
1160612660 // display shadow only (bump == 0)
1160712661 "SUB temp.x, half.x, shadow.x;" +
11608
- "MOV temp.y, -params6.x;" +
11609
- "SLT temp.z, temp.y, zero.x;" +
12662
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12663
+ "SLT temp.z, temp.y, -one2048th.x;" +
1161012664 "SUB temp.y, one.x, temp.z;" +
1161112665 "MUL temp.x, temp.x, temp.y;" +
1161212666 "KIL temp.x;" +
....@@ -11735,8 +12789,10 @@
1173512789 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1173612790
1173712791 "SUB temp.x, one.x, ndotl.x;" +
11738
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
11739
- "ADD temp.y, one.y, options2.y;" + // sursurface
12792
+ // Tuning for default skin
12793
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12794
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12795
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1174012796 "MUL temp.x, temp.x, temp.y;" +
1174112797
1174212798 "MUL saturation, saturation, temp.xxxx;" +
....@@ -11935,7 +12991,7 @@
1193512991 //once = true;
1193612992 }
1193712993
11938
- System.out.print("Program #" + mode + "; length = " + program.length());
12994
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1193912995 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1194012996 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1194112997
....@@ -12068,12 +13124,16 @@
1206813124
1206913125 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1207013126 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13127
+
13128
+ // Compare fragment depth in light space with shadowmap.
1207113129 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1207213130 "SGE temp.y, temp.x, zero.x;" +
12073
- "SUB " + shadow + ".y, one.x, temp.y;" +
13131
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13132
+
13133
+ // Reverse comparison
1207413134 "SUB temp.x, one.x, temp.x;" +
1207513135 "MUL " + shadow + ".x, temp.x, temp.y;" +
12076
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13136
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1207713137 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1207813138
1207913139 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12087,6 +13147,10 @@
1208713147 // No shadow for backface
1208813148 "DP3 temp.x, normal, lightd;" +
1208913149 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13150
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13151
+
13152
+ // No shadow when out of frustrum
13153
+ "SGE temp.x, " + depth + ".z, one.z;" +
1209013154 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1209113155 "";
1209213156 }
....@@ -12645,7 +13709,7 @@
1264513709 public void mousePressed(MouseEvent e)
1264613710 {
1264713711 //System.out.println("mousePressed: " + e);
12648
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13712
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1264913713 }
1265013714
1265113715 static long prevtime = 0;
....@@ -12672,6 +13736,7 @@
1267213736
1267313737 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1267413738
13739
+ if (BUTTONLESSWHEEL)
1267513740 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1267613741 {
1267713742 return;
....@@ -12680,7 +13745,7 @@
1268013745 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1268113746
1268213747 // TIMER
12683
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
13748
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1268413749 {
1268513750 keepboxmode = BOXMODE;
1268613751 keepsupport = SUPPORT;
....@@ -12720,8 +13785,8 @@
1272013785 // mode |= META;
1272113786 //}
1272213787
12723
- SetMouseMode(WHEEL | e.getModifiersEx());
12724
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13788
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13789
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1272513790 anchorX = ax;
1272613791 anchorY = ay;
1272713792 prevX = px;
....@@ -12781,6 +13846,10 @@
1278113846 // wasliveok = true;
1278213847 // waslive = false;
1278313848
13849
+ // May 2019 Forget it:
13850
+ if (true)
13851
+ return;
13852
+
1278413853 // source == timer
1278513854 if (mouseDown)
1278613855 {
....@@ -12819,7 +13888,7 @@
1281913888
1282013889 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1282113890
12822
- void clickStart(int x, int y, int modifiers)
13891
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1282313892 {
1282413893 if (!wasliveok)
1282513894 return;
....@@ -12836,7 +13905,7 @@
1283613905 // touched = true; // main DL
1283713906 if (isRenderer)
1283813907 {
12839
- SetMouseMode(modifiers);
13908
+ SetMouseMode(modifiers, modifiersex);
1284013909 }
1284113910
1284213911 selectX = anchorX = x;
....@@ -12849,7 +13918,7 @@
1284913918 clicked = true;
1285013919 hold = false;
1285113920
12852
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13921
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1285313922 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1285413923 {
1285513924 // System.out.println("RESTART II " + modifiers);
....@@ -12880,7 +13949,7 @@
1288013949 info.camera = renderCamera;
1288113950 info.x = x;
1288213951 info.y = y;
12883
- info.modifiers = modifiers;
13952
+ info.modifiers = modifiersex;
1288413953 editObj = object.doEditClick(info, 0);
1288513954 if (!editObj)
1288613955 {
....@@ -12897,11 +13966,14 @@
1289713966
1289813967 public void mouseDragged(MouseEvent e)
1289913968 {
13969
+ Globals.MOUSEDRAGGED = true;
13970
+
13971
+ //System.out.println("mouseDragged: " + e);
1290013972 if (isRenderer)
1290113973 movingcamera = true;
13974
+
1290213975 //if (drawing)
1290313976 //return;
12904
- //System.out.println("mouseDragged: " + e);
1290513977 if ((e.getModifiersEx() & CTRL) != 0
1290613978 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1290713979 {
....@@ -12909,7 +13981,7 @@
1290913981 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1291013982 }
1291113983 else
12912
- drag(e.getX(), e.getY(), e.getModifiersEx());
13984
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1291313985
1291413986 //try { Thread.sleep(1); } catch (Exception ex) {}
1291513987 }
....@@ -12921,6 +13993,11 @@
1292113993 cVector tmp = new cVector();
1292213994 cVector tmp2 = new cVector();
1292313995 boolean isMoving;
13996
+
13997
+ public cVector TargetLookAt()
13998
+ {
13999
+ return targetLookAt;
14000
+ }
1292414001
1292514002 class PingThread extends Thread
1292614003 {
....@@ -13077,6 +14154,7 @@
1307714154
1307814155 public void run()
1307914156 {
14157
+ new Exception().printStackTrace();
1308014158 System.exit(0);
1308114159 for (;;)
1308214160 {
....@@ -13140,7 +14218,7 @@
1314014218 {
1314114219 Globals.lighttouched = true;
1314214220 }
13143
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14221
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1314414222 }
1314514223 //else
1314614224 }
....@@ -13240,7 +14318,7 @@
1324014318 int X, Y;
1324114319 boolean SX, SY;
1324214320
13243
- void drag(int x, int y, int modifiers)
14321
+ void drag(int x, int y, int modifiers, int modifiersex)
1324414322 {
1324514323 if (IsFrozen())
1324614324 {
....@@ -13249,17 +14327,17 @@
1324914327
1325014328 drag = true; // NEW
1325114329
13252
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14330
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1325314331
1325414332 X = x;
1325514333 Y = y;
1325614334 // floating state for animation
13257
- MODIFIERS = modifiers;
13258
- modifiers &= ~1024;
14335
+ MODIFIERS = modifiersex;
14336
+ modifiersex &= ~1024;
1325914337 if (false) // modifiers != 0)
1326014338 {
1326114339 //new Exception().printStackTrace();
13262
- System.out.println("mouseDragged: " + modifiers);
14340
+ System.out.println("mouseDragged: " + modifiersex);
1326314341 System.out.println("SHIFT = " + SHIFT);
1326414342 System.out.println("CONTROL = " + COMMAND);
1326514343 System.out.println("META = " + META);
....@@ -13279,7 +14357,7 @@
1327914357 info.camera = renderCamera;
1328014358 info.x = x;
1328114359 info.y = y;
13282
- object.editWindow.copy.doEditDrag(info);
14360
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1328314361 } else
1328414362 {
1328514363 if (x < startX)
....@@ -13431,7 +14509,6 @@
1343114509 public void mouseMoved(MouseEvent e)
1343214510 {
1343314511 //System.out.println("mouseMoved: " + e);
13434
-
1343514512 if (isRenderer)
1343614513 return;
1343714514
....@@ -13456,7 +14533,10 @@
1345614533
1345714534 public void mouseReleased(MouseEvent e)
1345814535 {
14536
+ Globals.MOUSEDRAGGED = false;
14537
+
1345914538 movingcamera = false;
14539
+ X = Y = 0;
1346014540 //System.out.println("mouseReleased: " + e);
1346114541 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1346214542 }
....@@ -13479,9 +14559,9 @@
1347914559 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1348014560 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1348114561
13482
- if (control || command || IsFrozen())
14562
+// No delay if (control || command || IsFrozen())
1348314563 timeout = true;
13484
- else
14564
+// ?? May 2019 else
1348514565 // timer.setDelay((modifiers & 128) != 0?0:350);
1348614566 mouseDown = false;
1348714567 if (!control && !command) // june 2013
....@@ -13591,7 +14671,7 @@
1359114671 System.out.println("keyReleased: " + e);
1359214672 }
1359314673
13594
- void SetMouseMode(int modifiers)
14674
+ void SetMouseMode(int modifiers, int modifiersex)
1359514675 {
1359614676 //System.out.println("SetMouseMode = " + modifiers);
1359714677 //modifiers &= ~1024;
....@@ -13603,25 +14683,25 @@
1360314683 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1360414684 // return;
1360514685 //System.out.println("SetMode = " + modifiers);
13606
- if ((modifiers & WHEEL) == WHEEL)
14686
+ if ((modifiersex & WHEEL) == WHEEL)
1360714687 {
1360814688 mouseMode |= ZOOM;
1360914689 }
1361014690
1361114691 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
13612
- if (capsLocked || (modifiers & META) == META)
14692
+ if (capsLocked) // || (modifiers & META) == META)
1361314693 {
1361414694 mouseMode |= VR; // BACKFORTH;
1361514695 }
13616
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14696
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1361714697 {
1361814698 mouseMode |= SELECT;
1361914699 }
13620
- if ((modifiers & COMMAND) == COMMAND)
14700
+ if ((modifiersex & COMMAND) == COMMAND)
1362114701 {
1362214702 mouseMode |= SELECT;
1362314703 }
13624
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14704
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1362514705 {
1362614706 mouseMode &= ~VR;
1362714707 mouseMode |= TRANSLATE;
....@@ -13650,10 +14730,10 @@
1365014730
1365114731 if (isRenderer) //
1365214732 {
13653
- SetMouseMode(modifiers);
14733
+ SetMouseMode(0, modifiers);
1365414734 }
1365514735
13656
- theRenderer.keyPressed(key);
14736
+ Globals.theRenderer.keyPressed(key);
1365714737 }
1365814738
1365914739 int kompactbit = 4; // power bit
....@@ -13665,7 +14745,7 @@
1366514745 float SATPOW = 1; // 2; // 0.5f;
1366614746 float BRIPOW = 1; // 0.5f; // 0.5f;
1366714747
13668
- void keyPressed(int key)
14748
+ public void keyPressed(int key)
1366914749 {
1367014750 if (key >= '0' && key <= '5')
1367114751 clampbit = (key-'0');
....@@ -13986,7 +15066,7 @@
1398615066 //RESIZETEXTURE ^= true;
1398715067 //break;
1398815068 case 'z':
13989
- RENDERSHADOW ^= true;
15069
+ Globals.RENDERSHADOW ^= true;
1399015070 Globals.lighttouched = true;
1399115071 repaint();
1399215072 break;
....@@ -14102,6 +15182,7 @@
1410215182 }
1410315183 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1410415184 }
15185
+
1410515186 static double OCCLUSIONBOOST = 1; // 0.5;
1410615187
1410715188 void keyReleased(int key, int modifiers)
....@@ -14109,11 +15190,11 @@
1410915190 //mode = ROTATE;
1411015191 if ((MODIFIERS & COMMAND) == 0) // VR??
1411115192 {
14112
- SetMouseMode(modifiers);
15193
+ SetMouseMode(0, modifiers);
1411315194 }
1411415195 }
1411515196
14116
- protected void processKeyEvent(KeyEvent e)
15197
+ public void processKeyEvent(KeyEvent e)
1411715198 {
1411815199 switch (e.getID())
1411915200 {
....@@ -14243,8 +15324,9 @@
1424315324
1424415325 protected void processMouseMotionEvent(MouseEvent e)
1424515326 {
14246
- //System.out.println("processMouseMotionEvent: " + mouseMode);
14247
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15327
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15328
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15329
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1424815330 {
1424915331 mouseMoved(e);
1425015332 } else
....@@ -14274,6 +15356,7 @@
1427415356
1427515357 void SelectParent()
1427615358 {
15359
+ new Exception().printStackTrace();
1427715360 System.exit(0);
1427815361 Composite group = (Composite) object;
1427915362 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -14297,6 +15380,7 @@
1429715380
1429815381 void SelectChildren()
1429915382 {
15383
+ new Exception().printStackTrace();
1430015384 System.exit(0);
1430115385 /*
1430215386 Composite group = (Composite) object;
....@@ -14461,7 +15545,9 @@
1446115545 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1446215546 //Image img = CreateImage(width, height);
1446315547 //System.out.println("width = " + width + "; height = " + height + "\n");
15548
+
1446415549 Graphics gr = g; // img.getGraphics();
15550
+
1446515551 if (!hasMarquee)
1446615552 {
1446715553 if (Xmin < Xmax) // !locked)
....@@ -14559,14 +15645,33 @@
1455915645 if (!isRenderer)
1456015646 {
1456115647 object.drawEditHandles(info, 0);
15648
+
15649
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15650
+ {
15651
+ switch (object.selection.get(0).hitSomething)
15652
+ {
15653
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15654
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15655
+ break;
15656
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15657
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15658
+ break;
15659
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15660
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15661
+ break;
15662
+ }
15663
+
15664
+ }
1456215665 }
1456315666 }
15667
+
1456415668 if (isRenderer)
1456515669 {
1456615670 //gr.setColor(Color.black);
1456715671 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1456815672 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1456915673 }
15674
+
1457015675 if (hasMarquee)
1457115676 {
1457215677 gr.setXORMode(Color.white);
....@@ -14679,6 +15784,7 @@
1467915784 public boolean mouseDown(Event evt, int x, int y)
1468015785 {
1468115786 System.out.println("mouseDown: " + evt);
15787
+ System.exit(0);
1468215788 /*
1468315789 locked = true;
1468415790 drag = false;
....@@ -14722,7 +15828,7 @@
1472215828 {
1472315829 keyPressed(0, modifiers);
1472415830 }
14725
- clickStart(x, y, modifiers);
15831
+ // clickStart(x, y, modifiers);
1472615832 return true;
1472715833 }
1472815834
....@@ -14840,7 +15946,7 @@
1484015946 {
1484115947 keyReleased(0, 0);
1484215948 }
14843
- drag(x, y, modifiers);
15949
+ drag(x, y, 0, modifiers);
1484415950 return true;
1484515951 }
1484615952
....@@ -14972,7 +16078,7 @@
1497216078 Object3D object;
1497316079 static Object3D trackedobject;
1497416080 Camera renderCamera; // Light or Eye (or Occlusion)
14975
- /*static*/ Camera manipCamera; // Light or Eye
16081
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1497616082 /*static*/ Camera eyeCamera;
1497716083 /*static*/ Camera lightCamera;
1497816084 int cameracount;
....@@ -15410,6 +16516,7 @@
1541016516 {
1541116517 if (!selection)
1541216518 {
16519
+ new Exception().printStackTrace();
1541316520 System.exit(0);
1541416521 return;
1541516522 }
....@@ -15537,16 +16644,16 @@
1553716644 System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2]));
1553816645 }
1553916646
15540
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16647
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1554116648 }
1554216649 }
1554316650
1554416651 if (!movingcamera && !PAINTMODE)
1554516652 object.editWindow.ScreenFitPoint(); // fev 2014
1554616653
15547
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16654
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1554816655 {
15549
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16656
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1555016657
1555116658 Object3D group = new Object3D("inst" + paintcount++);
1555216659
....@@ -15702,7 +16809,7 @@
1570216809 gl.glDisable(gl.GL_CULL_FACE);
1570316810 }
1570416811
15705
- if (!RENDERSHADOW)
16812
+ if (!Globals.RENDERSHADOW)
1570616813 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1570716814
1570816815 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -15712,7 +16819,7 @@
1571216819 //gl.glColorMask(false, false, false, false);
1571316820
1571416821 //render_scene_from_light_view(gl, drawable, 0, 0);
15715
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16822
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1571616823 {
1571716824 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1571816825
....@@ -15772,7 +16879,6 @@
1577216879
1577316880 class AntialiasBuffer implements GLEventListener
1577416881 {
15775
-
1577616882 CameraPane parent = null;
1577716883
1577816884 AntialiasBuffer(CameraPane p)
....@@ -16165,7 +17271,7 @@
1616517271 }
1616617272 }
1616717273
16168
- static void DrawPoints(CameraPane cpane)
17274
+ static void DrawPoints(iCameraPane cpane)
1616917275 {
1617017276 for (int i=0; i<8; i++) // first and last are red
1617117277 {
....@@ -16197,10 +17303,11 @@
1619717303 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1619817304 // Depth buffer format
1619917305 //private int depth_format;
16200
- static public void NextIndex(Object3D o, GL gl)
17306
+
17307
+ public void NextIndex()
1620117308 {
1620217309 indexcount+=16;
16203
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17310
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1620417311 //objects[indexcount] = o;
1620517312 //System.out.println("indexcount = " + indexcount);
1620617313 }