Normand Briere
2019-04-24 92e4487d01f910c705211ffb5762a5c96bdd6d8c
CameraPane.java
....@@ -149,12 +149,11 @@
149149 defaultcaps.setAccumBlueBits(16);
150150 defaultcaps.setAccumAlphaBits(16);
151151 }
152
- static CameraPane theRenderer;
153
-
152
+
154153 void SetAsGLRenderer(boolean b)
155154 {
156155 isRenderer = b;
157
- theRenderer = this;
156
+ Globals.theRenderer = this;
158157 }
159158
160159 CameraPane(Object3D o, Camera cam, boolean withcontext)
....@@ -191,6 +190,40 @@
191190 }
192191
193192 /// INTERFACE
193
+
194
+ public javax.media.opengl.GL GetGL0()
195
+ {
196
+ return null;
197
+ }
198
+
199
+ public int GenList()
200
+ {
201
+ javax.media.opengl.GL gl = GetGL();
202
+ return gl.glGenLists(1);
203
+ }
204
+
205
+ public void NewList(int id)
206
+ {
207
+ javax.media.opengl.GL gl = GetGL();
208
+ gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE);
209
+ }
210
+
211
+ public void CallList(int id)
212
+ {
213
+ javax.media.opengl.GL gl = GetGL();
214
+ gl.glCallList(id);
215
+ }
216
+
217
+ public void EndList()
218
+ {
219
+ javax.media.opengl.GL gl = GetGL();
220
+ gl.glEndList();
221
+ }
222
+
223
+ public boolean IsBoxMode()
224
+ {
225
+ return BOXMODE;
226
+ }
194227
195228 public void ClearDepth()
196229 {
....@@ -231,9 +264,14 @@
231264 return this.ambientOcclusion;
232265 }
233266
267
+ public boolean IsDebugSelection()
268
+ {
269
+ return DEBUG_SELECTION;
270
+ }
271
+
234272 public boolean IsFrozen()
235273 {
236
- boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
274
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
237275
238276 return !selectmode && cameracount == 0; // != 0;
239277 }
....@@ -254,9 +292,19 @@
254292 return lightCamera;
255293 }
256294
295
+ public Camera ManipCamera()
296
+ {
297
+ return manipCamera;
298
+ }
299
+
257300 public Camera RenderCamera()
258301 {
259302 return renderCamera;
303
+ }
304
+
305
+ public Camera[] Cameras()
306
+ {
307
+ return cameras;
260308 }
261309
262310 public void PushMaterial(Object3D obj, boolean selected)
....@@ -403,7 +451,7 @@
403451
404452 javax.media.opengl.GL gl = display.GetGL();
405453
406
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
454
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
407455
408456 //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
409457 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
....@@ -566,7 +614,810 @@
566614 }
567615 }
568616
617
+ /**
618
+ * <code>draw</code> renders a <code>TriMesh</code> object including
619
+ * it's normals, colors, textures and vertices.
620
+ *
621
+ * @see Renderer#draw(TriMesh)
622
+ * @param tris
623
+ * the mesh to render.
624
+ */
625
+ public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris)
626
+ {
627
+ CameraPane display = this;
628
+
629
+ float r = display.modelParams0[0];
630
+ float g = display.modelParams0[1];
631
+ float b = display.modelParams0[2];
632
+ float opacity = display.modelParams5[1];
633
+
634
+ //final GL gl = GLU.getCurrentGL();
635
+ GL gl = display.GetGL(); // getGL();
636
+
637
+ FloatBuffer vertBuf = geo.vertBuf;
638
+
639
+ int v = vertBuf.capacity();
640
+
641
+ int count = 0;
642
+
643
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
644
+ gl.glEnable(gl.GL_CULL_FACE);
645
+ // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024);
646
+ for (int i=0; i<v/3; i++)
647
+ {
648
+ int index3 = i*3;
649
+
650
+ if (geo.sizeBuf.get(index3+1) == 0)
651
+ continue;
652
+
653
+ count++;
654
+
655
+ int index4 = i*4;
656
+
657
+ float tx = vertBuf.get(index3);
658
+ float ty = vertBuf.get(index3+1);
659
+ float tz = vertBuf.get(index3+2);
660
+
661
+ // if (tx == 0 && ty == 0 && tz == 0)
662
+ // continue;
663
+
664
+ gl.glMatrixMode(gl.GL_TEXTURE);
665
+ gl.glPushMatrix();
666
+
667
+ float[] texmat = geo.texmat;
668
+ texmat[12] = texmat[13] = texmat[14] = i;
669
+
670
+ gl.glMultMatrixf(texmat, 0);
671
+
672
+ gl.glMatrixMode(gl.GL_MODELVIEW);
673
+ gl.glPushMatrix();
674
+
675
+ gl.glTranslatef(tx,ty,tz);
676
+
677
+ if (rotate)
678
+ gl.glRotatef(i, 0, 1, 0);
679
+
680
+ float size = geo.sizeBuf.get(index3) / 100;
681
+ gl.glScalef(size,size,size);
682
+
683
+ float cr = geo.colorBuf.get(index4);
684
+ float cg = geo.colorBuf.get(index4+1);
685
+ float cb = geo.colorBuf.get(index4+2);
686
+ float ca = geo.colorBuf.get(index4+3);
687
+
688
+ display.modelParams0[0] = r * cr;
689
+ display.modelParams0[1] = g * cg;
690
+ display.modelParams0[2] = b * cb;
691
+
692
+ display.modelParams5[1] = opacity * ca;
693
+
694
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
695
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
696
+
697
+ RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i;
698
+ RandomNode.globalseed2 = RandomNode.globalseed;
699
+
700
+// gl.glColor4f(cr,cg,cb,ca);
701
+ // gl.glScalef(1024/16,1024/16,1024/16);
702
+ shape.Draw/*Node*/(display,null,selected,false); // blocked
703
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
704
+ //gl.glTranslatef(-tx,-ty,-tz);
705
+ gl.glPopMatrix();
706
+
707
+ gl.glMatrixMode(gl.GL_TEXTURE);
708
+ gl.glPopMatrix();
709
+ }
710
+ // gl.glScalef(1024,1024,1024);
711
+ if (!cf)
712
+ gl.glDisable(gl.GL_CULL_FACE);
713
+
714
+ display.modelParams0[0] = r;
715
+ display.modelParams0[1] = g;
716
+ display.modelParams0[2] = b;
717
+
718
+ display.modelParams5[1] = opacity;
719
+
720
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
721
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
722
+
723
+ gl.glMatrixMode(gl.GL_MODELVIEW);
724
+
725
+// System.err.println("total = " + v/3 + "; displayed = " + count);
726
+ if (true)
727
+ return;
728
+
729
+//// if (!tris.predraw(this))
730
+//// {
731
+//// return;
732
+//// }
733
+//// if (Debug.stats)
734
+//// {
735
+//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount());
736
+//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount());
737
+//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1);
738
+//// }
739
+////
740
+//// if (tris.getDisplayListID() != -1)
741
+//// {
742
+//// renderDisplayList(tris);
743
+//// return;
744
+//// }
745
+////
746
+//// if (!generatingDisplayList)
747
+//// {
748
+//// applyStates(tris.states, tris);
749
+//// }
750
+//// if (Debug.stats)
751
+//// {
752
+//// StatCollector.startStat(StatType.STAT_RENDER_TIMER);
753
+//// }
754
+//// boolean transformed = doTransforms(tris);
755
+//
756
+// int glMode = GL.GL_TRIANGLES;
757
+// switch (getMode())
758
+// {
759
+// case Triangles:
760
+// glMode = GL.GL_TRIANGLES;
761
+// break;
762
+// case Strip:
763
+// glMode = GL.GL_TRIANGLE_STRIP;
764
+// break;
765
+// case Fan:
766
+// glMode = GL.GL_TRIANGLE_FAN;
767
+// break;
768
+// }
769
+//
770
+// if (!predrawGeometry(gl))
771
+// {
772
+// // make sure only the necessary indices are sent through on old
773
+// // cards.
774
+// IntBuffer indices = this.getIndexBuffer();
775
+// if (indices == null)
776
+// {
777
+// logger.severe("missing indices on geometry object: " + this.toString());
778
+// } else
779
+// {
780
+// indices.rewind();
781
+// indices.limit(this.getMaxIndex());
782
+//
783
+// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT
784
+//
785
+// indices.clear();
786
+// }
787
+// } else
788
+// {
789
+// gl.glDrawElements(glMode, this.getIndexBuffer().limit(),
790
+// GL.GL_UNSIGNED_INT, 0);
791
+// }
792
+//
793
+//// postdrawGeometry(tris);
794
+//// if (transformed)
795
+//// {
796
+//// undoTransforms(tris);
797
+//// }
798
+////
799
+//// if (Debug.stats)
800
+//// {
801
+//// StatCollector.endStat(StatType.STAT_RENDER_TIMER);
802
+//// }
803
+//// tris.postdraw(this);
804
+ }
805
+
806
+ static Camera localcamera = new Camera();
807
+ static cVector from = new cVector();
808
+ static cVector to = new cVector();
809
+
810
+ public void PrepOcclusion(BoundaryRep br, double[][] transform)
811
+ {
812
+ CameraPane cp = this;
813
+
814
+ Camera keep = cp.RenderCamera();
815
+ cp.renderCamera = localcamera;
816
+
817
+ if (br.trimmed)
818
+ {
819
+ float[] colors = new float[br.positions.length / 3];
820
+
821
+ int i3 = 0;
822
+ for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
823
+ {
824
+ if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
825
+ continue;
826
+
827
+ from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
828
+ to.set(br.positions[i3] + br.normals[i3],
829
+ br.positions[i3 + 1] + br.normals[i3 + 1],
830
+ br.positions[i3 + 2] + br.normals[i3 + 2]);
831
+ LA.xformPos(from, transform, from);
832
+ LA.xformPos(to, transform, to); // RIGID ONLY
833
+ localcamera.setAim(from, to);
834
+
835
+ CameraPane.occlusionbuffer.display();
836
+
837
+ if (CameraPane.DEBUG_OCCLUSION)
838
+ cp.display(); // debug
839
+
840
+ colors[i] = cp.vertexOcclusion.r;
841
+ //colors[i3 + 1] = cp.vertexOcclusion.g;
842
+ //colors[i3 + 2] = cp.vertexOcclusion.b;
843
+
844
+ if ((i % 100) == 0 && i != 0)
845
+ {
846
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
847
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
848
+ System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
849
+ }
850
+ }
851
+
852
+ br.colors = colors;
853
+ }
854
+ else
855
+ {
856
+ for (int i = 0; i < br.VertexCount(); i++)
857
+ {
858
+ Vertex v = br.GetVertex(i);
859
+
860
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
861
+ continue;
862
+
863
+ from.set(v.x, v.y, v.z);
864
+ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
865
+ LA.xformPos(from, transform, from);
866
+ LA.xformPos(to, transform, to); // RIGID ONLY
867
+ localcamera.setAim(from, to);
868
+
869
+ CameraPane.occlusionbuffer.display();
870
+
871
+ if (CameraPane.DEBUG_OCCLUSION)
872
+ cp.display(); // debug
873
+
874
+ v.AO = cp.vertexOcclusion.r;
875
+
876
+ if ((i % 100) == 0 && i != 0)
877
+ {
878
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
879
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
880
+ System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
881
+ }
882
+ }
883
+ }
884
+
885
+ //System.out.println("done.");
886
+
887
+ cp.renderCamera = keep;
888
+ }
889
+
890
+ void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
891
+ {
892
+ CameraPane display = this;
893
+ pointFlow.CreateHT();
894
+
895
+ float r = display.modelParams0[0];
896
+ float g = display.modelParams0[1];
897
+ float b = display.modelParams0[2];
898
+ float opacity = display.modelParams5[1];
899
+
900
+ //final GL gl = GLU.getCurrentGL();
901
+ GL gl = display.GetGL(); // getGL();
902
+
903
+ int s = pointFlow.points.size();
904
+
905
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
906
+ gl.glEnable(gl.GL_CULL_FACE);
907
+
908
+ for (int i=s; --i>=0;)
909
+ //for (int i=0; i<s; i++)
910
+ {
911
+ cVector v = pointFlow.points.get(i);
912
+
913
+ double mindist = Double.MAX_VALUE;
914
+
915
+ double size = pointFlow.minimumSize;
916
+
917
+ double distancenext = 0;
918
+
919
+ if (i > 0)
920
+ {
921
+ cVector w = pointFlow.points.get(i-1);
922
+
923
+ double dist = w.distance(v);
924
+
925
+ distancenext = dist;
926
+
927
+ if (mindist > dist)
928
+ {
929
+ mindist = dist;
930
+ size = mindist*pointFlow.resizefactor;
931
+ }
932
+ }
933
+
934
+ if (i < s-1)
935
+ {
936
+ cVector w = pointFlow.points.get(i+1);
937
+
938
+ double dist = w.distance(v);
939
+
940
+ if (mindist > dist)
941
+ {
942
+ mindist = dist;
943
+ size = mindist*pointFlow.resizefactor;
944
+ }
945
+ }
946
+
947
+ if (size < pointFlow.minimumSize)
948
+ size = pointFlow.minimumSize;
949
+ if (size > pointFlow.maximumSize)
950
+ size = pointFlow.maximumSize;
951
+
952
+ double tx = v.x;
953
+ double ty = v.y;
954
+ double tz = v.z;
955
+
956
+ // if (tx == 0 && ty == 0 && tz == 0)
957
+ // continue;
958
+
959
+ gl.glMatrixMode(gl.GL_TEXTURE);
960
+ gl.glPushMatrix();
961
+ pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
962
+
963
+ gl.glMultMatrixf(pointFlow.texmat, 0);
964
+
965
+ gl.glMatrixMode(gl.GL_MODELVIEW);
966
+ gl.glPushMatrix();
967
+
968
+ gl.glTranslated(tx,ty,tz);
969
+
970
+ gl.glScaled(size,size,size);
971
+
972
+// float cr = colorBuf.get(index4);
973
+// float cg = colorBuf.get(index4+1);
974
+// float cb = colorBuf.get(index4+2);
975
+// float ca = colorBuf.get(index4+3);
976
+//
977
+// display.modelParams0[0] = r * cr;
978
+// display.modelParams0[1] = g * cg;
979
+// display.modelParams0[2] = b * cb;
980
+//
981
+// display.modelParams5[1] = opacity * ca;
982
+//
983
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
984
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
985
+//
986
+// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
987
+// RandomNode.globalseed2 = RandomNode.globalseed;
988
+//
989
+//// gl.glColor4f(cr,cg,cb,ca);
990
+// // gl.glScalef(1024/16,1024/16,1024/16);
991
+ pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
992
+
993
+ gl.glPopMatrix();
994
+
995
+ double step = size/4; //
996
+
997
+ if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
998
+ continue;
999
+
1000
+ int nbsteps = (int)(distancenext/step);
1001
+
1002
+ step = distancenext/nbsteps;
1003
+
1004
+ cVector next = pointFlow.points.get(i-1);
1005
+
1006
+ tmp.set(next);
1007
+ tmp.sub(v);
1008
+ tmp.normalize();
1009
+ tmp.mul(step);
1010
+
1011
+ // calculate next size
1012
+ mindist = Double.MAX_VALUE;
1013
+
1014
+ double nextsize = pointFlow.minimumSize;
1015
+
1016
+ if (i > 1)
1017
+ {
1018
+ cVector w = pointFlow.points.get(i-2);
1019
+
1020
+ double dist = w.distance(next);
1021
+
1022
+ if (mindist > dist)
1023
+ {
1024
+ mindist = dist;
1025
+ nextsize = mindist*pointFlow.resizefactor;
1026
+ }
1027
+ }
1028
+
1029
+ double dist = v.distance(next);
1030
+
1031
+ if (mindist > dist)
1032
+ {
1033
+ mindist = dist;
1034
+ nextsize = mindist*pointFlow.resizefactor;
1035
+ }
1036
+
1037
+ if (nextsize < pointFlow.minimumSize)
1038
+ nextsize = pointFlow.minimumSize;
1039
+ if (nextsize > pointFlow.maximumSize)
1040
+ nextsize = pointFlow.maximumSize;
1041
+ //
1042
+
1043
+ double count = 0;
1044
+
1045
+ while (distancenext > 0.000000001) // step
1046
+ {
1047
+ gl.glPushMatrix();
1048
+
1049
+ gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
1050
+
1051
+ double K = count/nbsteps;
1052
+
1053
+ double intersize = K*nextsize + (1-K)*size;
1054
+
1055
+ gl.glScaled(intersize,intersize,intersize);
1056
+
1057
+ pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
1058
+
1059
+ count++;
1060
+
1061
+ distancenext -= step;
1062
+
1063
+ gl.glPopMatrix();
1064
+ }
1065
+
1066
+ if (count != nbsteps)
1067
+ assert(count == nbsteps);
1068
+
1069
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
1070
+ //gl.glTranslatef(-tx,-ty,-tz);
1071
+
1072
+ gl.glMatrixMode(gl.GL_TEXTURE);
1073
+ gl.glPopMatrix();
1074
+ }
1075
+
1076
+ if (!cf)
1077
+ gl.glDisable(gl.GL_CULL_FACE);
1078
+
1079
+// display.modelParams0[0] = r;
1080
+// display.modelParams0[1] = g;
1081
+// display.modelParams0[2] = b;
1082
+//
1083
+// display.modelParams5[1] = opacity;
1084
+//
1085
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1086
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1087
+
1088
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1089
+ }
1090
+
1091
+ public void DrawBox(cVector min, cVector max)
1092
+ {
1093
+ javax.media.opengl.GL gl = GetGL();
1094
+ gl.glBegin(gl.GL_LINES);
1095
+
1096
+ gl.glVertex3d(min.x, min.y, min.z);
1097
+ gl.glVertex3d(min.x, min.y, max.z);
1098
+ gl.glVertex3d(min.x, min.y, min.z);
1099
+ gl.glVertex3d(min.x, max.y, min.z);
1100
+ gl.glVertex3d(min.x, min.y, min.z);
1101
+ gl.glVertex3d(max.x, min.y, min.z);
1102
+
1103
+ gl.glVertex3d(max.x, max.y, max.z);
1104
+ gl.glVertex3d(min.x, max.y, max.z);
1105
+ gl.glVertex3d(max.x, max.y, max.z);
1106
+ gl.glVertex3d(max.x, min.y, max.z);
1107
+ gl.glVertex3d(max.x, max.y, max.z);
1108
+ gl.glVertex3d(max.x, max.y, min.z);
1109
+
1110
+ gl.glEnd();
1111
+ }
1112
+
1113
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1114
+ {
1115
+ int[] strips = bRep.getRawIndices();
1116
+
1117
+ javax.media.opengl.GL gl = GetGL();
1118
+
1119
+ // TRIANGLE STRIP ARRAY
1120
+ if (bRep.trimmed)
1121
+ {
1122
+ float[] v = bRep.getRawVertices();
1123
+ float[] n = bRep.getRawNormals();
1124
+ float[] c = bRep.getRawColors();
1125
+ float[] uv = bRep.getRawUVMap();
1126
+
1127
+ int count2 = 0;
1128
+ int count3 = 0;
1129
+
1130
+ if (n.length > 0)
1131
+ {
1132
+ for (int i = 0; i < strips.length; i++)
1133
+ {
1134
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1135
+
1136
+ /*
1137
+ boolean locked = false;
1138
+ float eps = 0.1f;
1139
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1140
+
1141
+ int dot = 0;
1142
+
1143
+ if ((dot&1) == 0)
1144
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1145
+
1146
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1147
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1148
+ else
1149
+ {
1150
+ locked = true;
1151
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1152
+ }
1153
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1154
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1155
+ if (hasnorm)
1156
+ {
1157
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1158
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1159
+ }
1160
+
1161
+ if ((dot&4) == 0)
1162
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1163
+
1164
+ if (wrap || !locked && (dot&8) != 0)
1165
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1166
+ else
1167
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1168
+
1169
+ f.dot = dot;
1170
+ */
1171
+
1172
+ if (!selectmode)
1173
+ {
1174
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1175
+ {
1176
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1177
+ } else
1178
+ {
1179
+ gl.glNormal3f(0, 0, 1);
1180
+ }
1181
+
1182
+ if (c != null)
1183
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1184
+ {
1185
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1186
+ }
1187
+ }
1188
+ if (flipV)
1189
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1190
+ else
1191
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1192
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1193
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1194
+
1195
+ count2 += 2;
1196
+ count3 += 3;
1197
+ if (!selectmode)
1198
+ {
1199
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1200
+ {
1201
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1202
+ } else
1203
+ {
1204
+ gl.glNormal3f(0, 0, 1);
1205
+ }
1206
+ if (c != null)
1207
+ {
1208
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1209
+ }
1210
+ }
1211
+ if (flipV)
1212
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1213
+ else
1214
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1215
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1216
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1217
+
1218
+ count2 += 2;
1219
+ count3 += 3;
1220
+ for (int j = 0; j < strips[i] - 2; j++)
1221
+ {
1222
+ //gl.glTexCoord2d(...);
1223
+ if (!selectmode)
1224
+ {
1225
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1226
+ {
1227
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1228
+ } else
1229
+ {
1230
+ gl.glNormal3f(0, 0, 1);
1231
+ }
1232
+ if (c != null)
1233
+ {
1234
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1235
+ }
1236
+ }
1237
+
1238
+ if (flipV)
1239
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1240
+ else
1241
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1242
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1243
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1244
+ count2 += 2;
1245
+ count3 += 3;
1246
+ }
1247
+
1248
+ gl.glEnd();
1249
+ }
1250
+ }
1251
+
1252
+ assert count3 == v.length;
1253
+ }
1254
+ else // !trimmed
1255
+ {
1256
+ int count = 0;
1257
+ for (int i = 0; i < strips.length; i++)
1258
+ {
1259
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1260
+
1261
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1262
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1263
+
1264
+ drawVertex(gl, p, flipV, selectmode);
1265
+ drawVertex(gl, q, flipV, selectmode);
1266
+
1267
+ for (int j = 0; j < strips[i] - 2; j++)
1268
+ {
1269
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1270
+
1271
+ // if (j%2 == 0)
1272
+ // drawFace(p, q, r, display, null);
1273
+ // else
1274
+ // drawFace(p, r, q, display, null);
1275
+
1276
+ // p = q;
1277
+ // q = r;
1278
+ drawVertex(gl, r, flipV, selectmode);
1279
+ }
1280
+
1281
+ gl.glEnd();
1282
+ }
1283
+ }
1284
+ }
1285
+
1286
+ static cSpring.Point3D temp = new cSpring.Point3D();
1287
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1288
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1289
+
1290
+ public void DrawDynamicMesh(cMesh mesh)
1291
+ {
1292
+ GL gl = GetGL(); // getGL();
1293
+
1294
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1295
+
1296
+ gl.glDisable(gl.GL_LIGHTING);
1297
+
1298
+ gl.glLineWidth(1);
1299
+ gl.glColor3f(1,1,1);
1300
+ gl.glBegin(gl.GL_LINES);
1301
+ double scale = 0;
1302
+ int count = 0;
1303
+ for (int s=0; s<Phys.allSprings.size(); s++)
1304
+ {
1305
+ cSpring.Spring spring = Phys.allSprings.get(s);
1306
+ if(s == 0)
1307
+ {
1308
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1309
+ }
1310
+ if (mesh.showsprings)
1311
+ {
1312
+ temp.set(spring.a.position);
1313
+ temp.add(spring.b.position);
1314
+ temp.mul(0.5);
1315
+ temp2.set(spring.a.position);
1316
+ temp2.sub(spring.b.position);
1317
+ temp2.mul(spring.restLength/2);
1318
+ temp.sub(temp2);
1319
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1320
+ temp.add(temp2);
1321
+ temp.add(temp2);
1322
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1323
+ }
1324
+
1325
+ if (spring.isHandle)
1326
+ continue;
1327
+
1328
+ //if (scale < spring.restLength)
1329
+ scale += spring.restLength;
1330
+ count++;
1331
+ }
1332
+ gl.glEnd();
1333
+
1334
+ if (count == 0)
1335
+ scale = 0.01;
1336
+ else
1337
+ scale /= count * 3;
1338
+
1339
+ //scale = 0.25;
1340
+
1341
+ if (mesh.ShowInfo())
1342
+ {
1343
+ gl.glLineWidth(4);
1344
+ for (int s=0; s<Phys.allNodes.size(); s++)
1345
+ {
1346
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1347
+ if (node.mass == 0)
1348
+ continue;
1349
+
1350
+ int i = node.springs==null?-1:node.springs.size();
1351
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1352
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1353
+ //temp.normalize();
1354
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1355
+ gl.glBegin(gl.GL_LINES);
1356
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1357
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1358
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1359
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1360
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1361
+ gl.glEnd();
1362
+ }
1363
+
1364
+ gl.glLineWidth(8);
1365
+ for (int s=0; s<Phys.allNodes.size(); s++)
1366
+ {
1367
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1368
+
1369
+ if (node.springs != null)
1370
+ {
1371
+ for (int i=0; i<node.springs.size(); i+=1)
1372
+ {
1373
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1374
+
1375
+ int c = i+1;
1376
+ // c = node.springs.get(i).nbcopies;
1377
+
1378
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1379
+ gl.glBegin(gl.GL_LINES);
1380
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1381
+ 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);
1382
+ gl.glEnd();
1383
+ }
1384
+ }
1385
+ }
1386
+
1387
+ gl.glLineWidth(1);
1388
+ }
1389
+
1390
+ gl.glEnable(gl.GL_LIGHTING);
1391
+ }
1392
+
5691393 /// INTERFACE
1394
+
1395
+ public void StartTriangles()
1396
+ {
1397
+ javax.media.opengl.GL gl = GetGL();
1398
+ gl.glBegin(gl.GL_TRIANGLES);
1399
+ }
1400
+
1401
+ public void EndTriangles()
1402
+ {
1403
+ GetGL().glEnd();
1404
+ }
1405
+
1406
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1407
+ {
1408
+ if (!selectmode)
1409
+ {
1410
+ gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1411
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1412
+
1413
+ if (flipV)
1414
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1415
+ else
1416
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1417
+ }
1418
+
1419
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1420
+ }
5701421
5711422 void SetColor(Object3D obj, Vertex p0)
5721423 {
....@@ -1129,7 +1980,7 @@
11291980
11301981 static int camerachangeframe;
11311982
1132
- boolean SetCamera(Camera cam)
1983
+ public boolean SetCamera(Camera cam)
11331984 {
11341985 // may 2014 if (cam == cameras[0] || cam == cameras[1])
11351986 // return false;
....@@ -1257,12 +2108,27 @@
12572108 mainDL ^= true;
12582109 }
12592110
1260
- void ToggleTexture()
2111
+ void ToggleFullScreen()
2112
+ {
2113
+ FULLSCREEN ^= true;
2114
+ }
2115
+
2116
+ void ToggleCrowd()
2117
+ {
2118
+ Globals.CROWD ^= true;
2119
+ }
2120
+
2121
+ void ToggleLocal()
2122
+ {
2123
+ LOCALTRANSFORM ^= true;
2124
+ }
2125
+
2126
+ public void ToggleTexture()
12612127 {
12622128 textureon ^= true;
12632129 }
12642130
1265
- void ToggleLive()
2131
+ public void ToggleLive()
12662132 {
12672133 Globals.setLIVE(Globals.isLIVE() ^ true);
12682134
....@@ -1274,92 +2140,67 @@
12742140 repaint(); // start loop // may 2013
12752141 }
12762142
1277
- void ToggleSupport()
2143
+ public void ToggleSupport()
12782144 {
12792145 SUPPORT ^= true;
12802146 }
12812147
1282
- void ToggleAbort()
2148
+ public void ToggleAbort()
12832149 {
12842150 ABORTMODE ^= true;
12852151 }
12862152
1287
- void ToggleFullScreen()
1288
- {
1289
- FULLSCREEN ^= true;
1290
- }
1291
-
1292
- void ToggleCrowd()
1293
- {
1294
- Globals.CROWD ^= true;
1295
- }
1296
-
1297
- void ToggleInertia()
2153
+ public void ToggleInertia()
12982154 {
12992155 INERTIA ^= true;
13002156 }
13012157
1302
- void ToggleLocal()
1303
- {
1304
- LOCALTRANSFORM ^= true;
1305
- }
1306
-
1307
- void ToggleFast()
2158
+ public void ToggleFast()
13082159 {
13092160 FAST ^= true;
13102161 }
13112162
1312
- void ToggleSlowPose()
2163
+ public void ToggleSlowPose()
13132164 {
13142165 SLOWPOSE ^= true;
13152166 }
13162167
1317
- void ToggleFootContact()
1318
- {
1319
- FOOTCONTACT ^= true;
1320
- }
1321
-
1322
- void ToggleBoxMode()
2168
+ public void ToggleBoxMode()
13232169 {
13242170 BOXMODE ^= true;
13252171 }
13262172
1327
- void ToggleSmoothFocus()
2173
+ public void ToggleSmoothFocus()
13282174 {
13292175 SMOOTHFOCUS ^= true;
13302176 }
13312177
1332
- void ToggleImageFlip()
2178
+ public void ToggleImageFlip()
13332179 {
13342180 IMAGEFLIP ^= true;
13352181 }
13362182
1337
- void ToggleSpeakerMocap()
2183
+ public void ToggleSpeakerMocap()
13382184 {
13392185 SPEAKERMOCAP ^= true;
13402186 }
13412187
1342
- void ToggleSpeakerCamera()
2188
+ public void ToggleSpeakerCamera()
13432189 {
13442190 SPEAKERCAMERA ^= true;
13452191 }
13462192
1347
- void ToggleSpeakerFocus()
2193
+ public void ToggleSpeakerFocus()
13482194 {
13492195 SPEAKERFOCUS ^= true;
13502196 }
13512197
1352
- void ToggleDebug()
1353
- {
1354
- DEBUG ^= true;
1355
- }
1356
-
1357
- void ToggleFrustum()
2198
+ public void ToggleFrustum()
13582199 {
13592200 FRUSTUM ^= true;
13602201 }
13612202
1362
- void ToggleTrack()
2203
+ public void ToggleTrack()
13632204 {
13642205 TRACK ^= true;
13652206 if (TRACK)
....@@ -1378,25 +2219,35 @@
13782219 repaint();
13792220 }
13802221
1381
- void ToggleTrackOnce()
2222
+ public void ToggleTrackOnce()
13822223 {
13832224 TRACKONCE ^= true;
13842225 }
13852226
1386
- void ToggleShadowTrack()
2227
+ public void ToggleShadowTrack()
13872228 {
13882229 SHADOWTRACK ^= true;
13892230 repaint();
13902231 }
13912232
1392
- void ToggleOeil()
2233
+ public void ToggleOeil()
13932234 {
13942235 OEIL ^= true;
13952236 }
13962237
1397
- void ToggleOeilOnce()
2238
+ public void ToggleOeilOnce()
13982239 {
13992240 OEILONCE ^= true;
2241
+ }
2242
+
2243
+ void ToggleFootContact()
2244
+ {
2245
+ FOOTCONTACT ^= true;
2246
+ }
2247
+
2248
+ void ToggleDebug()
2249
+ {
2250
+ DEBUG ^= true;
14002251 }
14012252
14022253 void ToggleLookAt()
....@@ -7458,7 +8309,7 @@
74588309 return texture!=null?texture.texture:null;
74598310 }
74608311
7461
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8312
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
74628313 {
74638314 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
74648315
....@@ -10146,7 +10997,7 @@
1014610997 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
1014710998 //System.out.println("fragmentMode = " + fragmentMode);
1014810999
10149
- if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION)
11000
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
1015011001 {
1015111002 /*
1015211003 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -10447,7 +11298,7 @@
1044711298 callist = gl.glGenLists(1);
1044811299 }
1044911300
10450
- boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
11301
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
1045111302
1045211303 boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
1045311304
....@@ -12922,6 +13773,11 @@
1292213773 cVector tmp2 = new cVector();
1292313774 boolean isMoving;
1292413775
13776
+ public cVector TargetLookAt()
13777
+ {
13778
+ return targetLookAt;
13779
+ }
13780
+
1292513781 class PingThread extends Thread
1292613782 {
1292713783 boolean jump;
....@@ -13653,7 +14509,7 @@
1365314509 SetMouseMode(modifiers);
1365414510 }
1365514511
13656
- theRenderer.keyPressed(key);
14512
+ Globals.theRenderer.keyPressed(key);
1365714513 }
1365814514
1365914515 int kompactbit = 4; // power bit
....@@ -13665,7 +14521,7 @@
1366514521 float SATPOW = 1; // 2; // 0.5f;
1366614522 float BRIPOW = 1; // 0.5f; // 0.5f;
1366714523
13668
- void keyPressed(int key)
14524
+ public void keyPressed(int key)
1366914525 {
1367014526 if (key >= '0' && key <= '5')
1367114527 clampbit = (key-'0');
....@@ -14102,6 +14958,7 @@
1410214958 }
1410314959 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1410414960 }
14961
+
1410514962 static double OCCLUSIONBOOST = 1; // 0.5;
1410614963
1410714964 void keyReleased(int key, int modifiers)
....@@ -14113,7 +14970,7 @@
1411314970 }
1411414971 }
1411514972
14116
- protected void processKeyEvent(KeyEvent e)
14973
+ public void processKeyEvent(KeyEvent e)
1411714974 {
1411814975 switch (e.getID())
1411914976 {
....@@ -15772,7 +16629,6 @@
1577216629
1577316630 class AntialiasBuffer implements GLEventListener
1577416631 {
15775
-
1577616632 CameraPane parent = null;
1577716633
1577816634 AntialiasBuffer(CameraPane p)
....@@ -16165,7 +17021,7 @@
1616517021 }
1616617022 }
1616717023
16168
- static void DrawPoints(CameraPane cpane)
17024
+ static void DrawPoints(iCameraPane cpane)
1616917025 {
1617017026 for (int i=0; i<8; i++) // first and last are red
1617117027 {
....@@ -16197,10 +17053,11 @@
1619717053 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1619817054 // Depth buffer format
1619917055 //private int depth_format;
16200
- static public void NextIndex(Object3D o, GL gl)
17056
+
17057
+ public void NextIndex()
1620117058 {
1620217059 indexcount+=16;
16203
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17060
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1620417061 //objects[indexcount] = o;
1620517062 //System.out.println("indexcount = " + indexcount);
1620617063 }