Normand Briere
2019-04-22 3c4c16e0a4ca3949a7a37a24607df7f89abfe7ea
Refactoring phase 3
13 files modified
830 ■■■■ changed files
BoundaryRep.java 88 ●●●●● patch | view | raw | blame | history
CSG.java 4 ●●●● patch | view | raw | blame | history
CameraPane.java 319 ●●●●● patch | view | raw | blame | history
CameraScroller.java 6 ●●●● patch | view | raw | blame | history
Composite.java 6 ●●●● patch | view | raw | blame | history
Globals.java 18 ●●●● patch | view | raw | blame | history
Merge.java 4 ●●●● patch | view | raw | blame | history
Mocap.java 2 ●●● patch | view | raw | blame | history
ObjEditor.java 10 ●●●● patch | view | raw | blame | history
Object3D.java 159 ●●●● patch | view | raw | blame | history
PointFlow.java 201 ●●●●● patch | view | raw | blame | history
cLinker.java 2 ●●● patch | view | raw | blame | history
iCameraPane.java 11 ●●●● patch | view | raw | blame | history
BoundaryRep.java
....@@ -15,7 +15,7 @@
1515 {
1616 this(0, 0);
1717 }
18
-
18
+
1919 void SaveSupports()
2020 {
2121 transientsupport = support;
....@@ -4893,7 +4893,7 @@
48934893 return verticesCopy;
48944894 }
48954895
4896
- void PreprocessOcclusion(CameraPane cp, double[][] transform)
4896
+ void PreprocessOcclusion(iCameraPane cp, double[][] transform)
48974897 {
48984898 if (//!trimmed ||
48994899 AOdone)
....@@ -4902,80 +4902,7 @@
49024902 return;
49034903 }
49044904
4905
- Camera keep = cp.renderCamera;
4906
- cp.renderCamera = localcamera;
4907
-
4908
- if (trimmed)
4909
- {
4910
- float[] colors = new float[positions.length / 3];
4911
-
4912
- int i3 = 0;
4913
- for (int i = 0; i < positions.length / 3; i++, i3 += 3)
4914
- {
4915
- if (normals[i3] == 0 && normals[i3+1] == 0 && normals[i3+2] == 0)
4916
- continue;
4917
-
4918
- from.set(positions[i3], positions[i3 + 1], positions[i3 + 2]);
4919
- to.set(positions[i3] + normals[i3],
4920
- positions[i3 + 1] + normals[i3 + 1],
4921
- positions[i3 + 2] + normals[i3 + 2]);
4922
- LA.xformPos(from, transform, from);
4923
- LA.xformPos(to, transform, to); // RIGID ONLY
4924
- localcamera.setAim(from, to);
4925
-
4926
- CameraPane.occlusionbuffer.display();
4927
-
4928
- if (CameraPane.DEBUG_OCCLUSION)
4929
- cp.display(); // debug
4930
-
4931
- colors[i] = cp.vertexOcclusion.r;
4932
- //colors[i3 + 1] = cp.vertexOcclusion.g;
4933
- //colors[i3 + 2] = cp.vertexOcclusion.b;
4934
-
4935
- if ((i % 100) == 0 && i != 0)
4936
- {
4937
- CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
4938
- //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
4939
- System.out.println((int) (100.0 * i / (positions.length / 3)) + "% (" + i + " of " + (positions.length / 3) + ")");
4940
- }
4941
- }
4942
-
4943
- this.colors = colors;
4944
- }
4945
- else
4946
- {
4947
- for (int i = 0; i < VertexCount(); i++)
4948
- {
4949
- Vertex v = GetVertex(i);
4950
-
4951
- if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
4952
- continue;
4953
-
4954
- from.set(v.x, v.y, v.z);
4955
- to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
4956
- LA.xformPos(from, transform, from);
4957
- LA.xformPos(to, transform, to); // RIGID ONLY
4958
- localcamera.setAim(from, to);
4959
-
4960
- CameraPane.occlusionbuffer.display();
4961
-
4962
- if (CameraPane.DEBUG_OCCLUSION)
4963
- cp.display(); // debug
4964
-
4965
- v.AO = cp.vertexOcclusion.r;
4966
-
4967
- if ((i % 100) == 0 && i != 0)
4968
- {
4969
- CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
4970
- //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
4971
- System.out.println((int) (100.0 * i / VertexCount()) + "% (" + i + " of " + VertexCount() + ")");
4972
- }
4973
- }
4974
- }
4975
-
4976
- //System.out.println("done.");
4977
-
4978
- cp.renderCamera = keep;
4905
+ cp.PrepOcclusion(this, transform);
49794906
49804907 AOdone = true;
49814908 }
....@@ -8354,9 +8281,6 @@
83548281 return "trim = " + trimmed + "; stripped = " + stripified + "; colors = " + colors + "; faces = " + (faces!=null?faces.size():null) + "; triangles = " + (triangles!=null?triangles.length:null) + "; indices = " + indices;
83558282 }
83568283
8357
- static Camera localcamera = new Camera();
8358
- static cVector from = new cVector();
8359
- static cVector to = new cVector();
83608284 boolean trimmed = false;
83618285 boolean stripified = false;
83628286 transient boolean AOdone = false;
....@@ -8364,8 +8288,10 @@
83648288 /*transient*/ int maxIndexV = 0;
83658289 /*transient*/ int bufV, bufF;
83668290 // Raw version
8367
- private float[] positions;
8368
- private float[] normals;
8291
+ //private
8292
+ float[] positions;
8293
+ //private
8294
+ float[] normals;
83698295 float[] colors;
83708296 private float[] uvmap;
83718297 private int[] triangles;
CSG.java
....@@ -132,7 +132,7 @@
132132 }
133133
134134 /**/
135
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
135
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
136136 {
137137 if (csgType == UNION || !link2master) // || csgType == MERGE)
138138 {
....@@ -154,7 +154,7 @@
154154 }
155155 /**/
156156
157
- void PreprocessOcclusion(CameraPane cp)
157
+ void PreprocessOcclusion(iCameraPane cp)
158158 {
159159 if (csgType == UNION) // || csgType == MERGE)
160160 {
CameraPane.java
....@@ -149,8 +149,9 @@
149149 defaultcaps.setAccumBlueBits(16);
150150 defaultcaps.setAccumAlphaBits(16);
151151 }
152
+
152153 static CameraPane theRenderer;
153
-
154
+
154155 void SetAsGLRenderer(boolean b)
155156 {
156157 isRenderer = b;
....@@ -236,9 +237,14 @@
236237 return this.ambientOcclusion;
237238 }
238239
240
+ public boolean IsDebugSelection()
241
+ {
242
+ return DEBUG_SELECTION;
243
+ }
244
+
239245 public boolean IsFrozen()
240246 {
241
- boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
247
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
242248
243249 return !selectmode && cameracount == 0; // != 0;
244250 }
....@@ -259,9 +265,19 @@
259265 return lightCamera;
260266 }
261267
268
+ public Camera ManipCamera()
269
+ {
270
+ return manipCamera;
271
+ }
272
+
262273 public Camera RenderCamera()
263274 {
264275 return renderCamera;
276
+ }
277
+
278
+ public Camera[] Cameras()
279
+ {
280
+ return cameras;
265281 }
266282
267283 public void PushMaterial(Object3D obj, boolean selected)
....@@ -408,7 +424,7 @@
408424
409425 javax.media.opengl.GL gl = display.GetGL();
410426
411
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
427
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
412428
413429 //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
414430 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
....@@ -760,6 +776,291 @@
760776 //// tris.postdraw(this);
761777 }
762778
779
+ static Camera localcamera = new Camera();
780
+ static cVector from = new cVector();
781
+ static cVector to = new cVector();
782
+
783
+ public void PrepOcclusion(BoundaryRep br, double[][] transform)
784
+ {
785
+ CameraPane cp = this;
786
+
787
+ Camera keep = cp.RenderCamera();
788
+ cp.renderCamera = localcamera;
789
+
790
+ if (br.trimmed)
791
+ {
792
+ float[] colors = new float[br.positions.length / 3];
793
+
794
+ int i3 = 0;
795
+ for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
796
+ {
797
+ if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
798
+ continue;
799
+
800
+ from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
801
+ to.set(br.positions[i3] + br.normals[i3],
802
+ br.positions[i3 + 1] + br.normals[i3 + 1],
803
+ br.positions[i3 + 2] + br.normals[i3 + 2]);
804
+ LA.xformPos(from, transform, from);
805
+ LA.xformPos(to, transform, to); // RIGID ONLY
806
+ localcamera.setAim(from, to);
807
+
808
+ CameraPane.occlusionbuffer.display();
809
+
810
+ if (CameraPane.DEBUG_OCCLUSION)
811
+ cp.display(); // debug
812
+
813
+ colors[i] = cp.vertexOcclusion.r;
814
+ //colors[i3 + 1] = cp.vertexOcclusion.g;
815
+ //colors[i3 + 2] = cp.vertexOcclusion.b;
816
+
817
+ if ((i % 100) == 0 && i != 0)
818
+ {
819
+ CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
820
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
821
+ System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
822
+ }
823
+ }
824
+
825
+ br.colors = colors;
826
+ }
827
+ else
828
+ {
829
+ for (int i = 0; i < br.VertexCount(); i++)
830
+ {
831
+ Vertex v = br.GetVertex(i);
832
+
833
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
834
+ continue;
835
+
836
+ from.set(v.x, v.y, v.z);
837
+ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
838
+ LA.xformPos(from, transform, from);
839
+ LA.xformPos(to, transform, to); // RIGID ONLY
840
+ localcamera.setAim(from, to);
841
+
842
+ CameraPane.occlusionbuffer.display();
843
+
844
+ if (CameraPane.DEBUG_OCCLUSION)
845
+ cp.display(); // debug
846
+
847
+ v.AO = cp.vertexOcclusion.r;
848
+
849
+ if ((i % 100) == 0 && i != 0)
850
+ {
851
+ CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
852
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
853
+ System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
854
+ }
855
+ }
856
+ }
857
+
858
+ //System.out.println("done.");
859
+
860
+ cp.renderCamera = keep;
861
+ }
862
+
863
+ void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
864
+ {
865
+ CameraPane display = this;
866
+ pointFlow.CreateHT();
867
+
868
+ float r = display.modelParams0[0];
869
+ float g = display.modelParams0[1];
870
+ float b = display.modelParams0[2];
871
+ float opacity = display.modelParams5[1];
872
+
873
+ //final GL gl = GLU.getCurrentGL();
874
+ GL gl = display.GetGL(); // getGL();
875
+
876
+ int s = pointFlow.points.size();
877
+
878
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
879
+ gl.glEnable(gl.GL_CULL_FACE);
880
+
881
+ for (int i=s; --i>=0;)
882
+ //for (int i=0; i<s; i++)
883
+ {
884
+ cVector v = pointFlow.points.get(i);
885
+
886
+ double mindist = Double.MAX_VALUE;
887
+
888
+ double size = pointFlow.minimumSize;
889
+
890
+ double distancenext = 0;
891
+
892
+ if (i > 0)
893
+ {
894
+ cVector w = pointFlow.points.get(i-1);
895
+
896
+ double dist = w.distance(v);
897
+
898
+ distancenext = dist;
899
+
900
+ if (mindist > dist)
901
+ {
902
+ mindist = dist;
903
+ size = mindist*pointFlow.resizefactor;
904
+ }
905
+ }
906
+
907
+ if (i < s-1)
908
+ {
909
+ cVector w = pointFlow.points.get(i+1);
910
+
911
+ double dist = w.distance(v);
912
+
913
+ if (mindist > dist)
914
+ {
915
+ mindist = dist;
916
+ size = mindist*pointFlow.resizefactor;
917
+ }
918
+ }
919
+
920
+ if (size < pointFlow.minimumSize)
921
+ size = pointFlow.minimumSize;
922
+ if (size > pointFlow.maximumSize)
923
+ size = pointFlow.maximumSize;
924
+
925
+ double tx = v.x;
926
+ double ty = v.y;
927
+ double tz = v.z;
928
+
929
+ // if (tx == 0 && ty == 0 && tz == 0)
930
+ // continue;
931
+
932
+ gl.glMatrixMode(gl.GL_TEXTURE);
933
+ gl.glPushMatrix();
934
+ pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
935
+
936
+ gl.glMultMatrixf(pointFlow.texmat, 0);
937
+
938
+ gl.glMatrixMode(gl.GL_MODELVIEW);
939
+ gl.glPushMatrix();
940
+
941
+ gl.glTranslated(tx,ty,tz);
942
+
943
+ gl.glScaled(size,size,size);
944
+
945
+// float cr = colorBuf.get(index4);
946
+// float cg = colorBuf.get(index4+1);
947
+// float cb = colorBuf.get(index4+2);
948
+// float ca = colorBuf.get(index4+3);
949
+//
950
+// display.modelParams0[0] = r * cr;
951
+// display.modelParams0[1] = g * cg;
952
+// display.modelParams0[2] = b * cb;
953
+//
954
+// display.modelParams5[1] = opacity * ca;
955
+//
956
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
957
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
958
+//
959
+// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
960
+// RandomNode.globalseed2 = RandomNode.globalseed;
961
+//
962
+//// gl.glColor4f(cr,cg,cb,ca);
963
+// // gl.glScalef(1024/16,1024/16,1024/16);
964
+ pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
965
+
966
+ gl.glPopMatrix();
967
+
968
+ double step = size/4; //
969
+
970
+ if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
971
+ continue;
972
+
973
+ int nbsteps = (int)(distancenext/step);
974
+
975
+ step = distancenext/nbsteps;
976
+
977
+ cVector next = pointFlow.points.get(i-1);
978
+
979
+ tmp.set(next);
980
+ tmp.sub(v);
981
+ tmp.normalize();
982
+ tmp.mul(step);
983
+
984
+ // calculate next size
985
+ mindist = Double.MAX_VALUE;
986
+
987
+ double nextsize = pointFlow.minimumSize;
988
+
989
+ if (i > 1)
990
+ {
991
+ cVector w = pointFlow.points.get(i-2);
992
+
993
+ double dist = w.distance(next);
994
+
995
+ if (mindist > dist)
996
+ {
997
+ mindist = dist;
998
+ nextsize = mindist*pointFlow.resizefactor;
999
+ }
1000
+ }
1001
+
1002
+ double dist = v.distance(next);
1003
+
1004
+ if (mindist > dist)
1005
+ {
1006
+ mindist = dist;
1007
+ nextsize = mindist*pointFlow.resizefactor;
1008
+ }
1009
+
1010
+ if (nextsize < pointFlow.minimumSize)
1011
+ nextsize = pointFlow.minimumSize;
1012
+ if (nextsize > pointFlow.maximumSize)
1013
+ nextsize = pointFlow.maximumSize;
1014
+ //
1015
+
1016
+ double count = 0;
1017
+
1018
+ while (distancenext > 0.000000001) // step
1019
+ {
1020
+ gl.glPushMatrix();
1021
+
1022
+ gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
1023
+
1024
+ double K = count/nbsteps;
1025
+
1026
+ double intersize = K*nextsize + (1-K)*size;
1027
+
1028
+ gl.glScaled(intersize,intersize,intersize);
1029
+
1030
+ pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
1031
+
1032
+ count++;
1033
+
1034
+ distancenext -= step;
1035
+
1036
+ gl.glPopMatrix();
1037
+ }
1038
+
1039
+ if (count != nbsteps)
1040
+ assert(count == nbsteps);
1041
+
1042
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
1043
+ //gl.glTranslatef(-tx,-ty,-tz);
1044
+
1045
+ gl.glMatrixMode(gl.GL_TEXTURE);
1046
+ gl.glPopMatrix();
1047
+ }
1048
+
1049
+ if (!cf)
1050
+ gl.glDisable(gl.GL_CULL_FACE);
1051
+
1052
+// display.modelParams0[0] = r;
1053
+// display.modelParams0[1] = g;
1054
+// display.modelParams0[2] = b;
1055
+//
1056
+// display.modelParams5[1] = opacity;
1057
+//
1058
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1059
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1060
+
1061
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1062
+ }
1063
+
7631064 /// INTERFACE
7641065
7651066 void SetColor(Object3D obj, Vertex p0)
....@@ -10340,7 +10641,7 @@
1034010641 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
1034110642 //System.out.println("fragmentMode = " + fragmentMode);
1034210643
10343
- if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION)
10644
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
1034410645 {
1034510646 /*
1034610647 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -10641,7 +10942,7 @@
1064110942 callist = gl.glGenLists(1);
1064210943 }
1064310944
10644
- boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
10945
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
1064510946
1064610947 boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
1064710948
....@@ -13115,6 +13416,11 @@
1311513416 cVector tmp = new cVector();
1311613417 cVector tmp2 = new cVector();
1311713418 boolean isMoving;
13419
+
13420
+ public cVector TargetLookAt()
13421
+ {
13422
+ return targetLookAt;
13423
+ }
1311813424
1311913425 class PingThread extends Thread
1312013426 {
....@@ -15966,7 +16272,6 @@
1596616272
1596716273 class AntialiasBuffer implements GLEventListener
1596816274 {
15969
-
1597016275 CameraPane parent = null;
1597116276
1597216277 AntialiasBuffer(CameraPane p)
....@@ -16359,7 +16664,7 @@
1635916664 }
1636016665 }
1636116666
16362
- static void DrawPoints(CameraPane cpane)
16667
+ static void DrawPoints(iCameraPane cpane)
1636316668 {
1636416669 for (int i=0; i<8; i++) // first and last are red
1636516670 {
CameraScroller.java
....@@ -15,10 +15,10 @@
1515 //horizCenter = imageWidth / 2;
1616 //vertCenter = imageHeight / 2;
1717 setLayout(new BorderLayout());
18
- cameraPane = new CameraPane(null, null, false);
18
+// TODO cameraPane = new CameraPane(null, null, false);
1919 //JScrollPane pain = new JScrollPane(cameraPane);
2020 /*add("North", (*/ caption = new Label("", 0); //);
21
- add("Center", cameraPane);
21
+// TODO add("Center", cameraPane);
2222 //add("East", vScroll = new Scrollbar(1));
2323 //add("South", hScroll = new Scrollbar(0));
2424 //add("Center", cameraPane = new CameraPane());
....@@ -124,7 +124,7 @@
124124 }
125125 */
126126
127
- CameraPane cameraPane;
127
+// TODO CameraPane cameraPane;
128128 //Scrollbar vScroll;
129129 //Scrollbar hScroll;
130130 Label caption;
Composite.java
....@@ -837,7 +837,7 @@
837837 }
838838
839839 if ((//display.drawMode == CameraPane.SHADOW ||
840
- display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) &&
840
+ display.DrawMode() == CameraPane.SELECTION || display.IsDebugSelection()) &&
841841 //HasTransparency())
842842 // SERIAL PATCH
843843 // if (viewCode == -1)
....@@ -855,7 +855,7 @@
855855
856856 cTexture tex = null;
857857
858
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
858
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
859859
860860 if (//display.drawMode != display.SHADOW &&
861861 !selectmode // display.drawMode != display.SELECTION
....@@ -994,7 +994,7 @@
994994 // }
995995 // }
996996
997
- void drawSelfOld(CameraPane display, Object3D /*Composite*/ root, boolean selected)
997
+ void drawSelfOld(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
998998 {
999999 // if (count <= 0) // || display.IsFreezed())
10001000 // {
Globals.java
....@@ -1,12 +1,20 @@
11
22 public class Globals
33 {
4
-static boolean CROWD = false;
5
- static public int drawMode = iCameraPane.DEFAULT; // WARNING
6
- static public boolean lighttouched = false; // WARNING
7
-
8
- static int framecount = 0; // general-purpose global count
94 private static boolean LIVE = false;
5
+
6
+ static boolean CROWD = false;
7
+ static public int drawMode = iCameraPane.DEFAULT; // WARNING
8
+
9
+ static public boolean lighttouched = false;
10
+ static public boolean ANIMATION = false;
11
+ static public int imagecount = 0;
12
+ static public String filename;
13
+
14
+ static public boolean fromscript = false;
15
+ static public boolean fullreset = false;
16
+
17
+ static int framecount = 0; // general-purpose global count
1018 static boolean ONESTEP = false; // do LIVE once
1119
1220 public static boolean isLIVE()
Merge.java
....@@ -396,9 +396,9 @@
396396
397397 }
398398
399
- public void drawCube(CameraPane display, float extent)
399
+ public void drawCube(iCameraPane display, float extent)
400400 {
401
- GL gl = display.getGL();
401
+ GL gl = display.GetGL();
402402
403403 extent = extent * 0.5f;
404404
Mocap.java
....@@ -1519,7 +1519,7 @@
15191519 // mywave = currentwave++;
15201520 // }
15211521 // sound
1522
- cVector eye = CameraPane.theRenderer.eyeCamera.location;
1522
+ cVector eye = CameraPane.theRenderer.EyeCamera().location;
15231523
15241524 // if (sourcenode.parent.parent != null)
15251525 // sourcenode.parent.parent.TransformToWorld(floor, tmp);
ObjEditor.java
....@@ -3297,25 +3297,25 @@
32973297
32983298 void ToggleAnimation()
32993299 {
3300
- if (!CameraPane.ANIMATION)
3300
+ if (!Globals.ANIMATION)
33013301 {
33023302 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
33033303 browser.show();
33043304 String filename = browser.getFile();
33053305 if (filename != null && filename.length() > 0)
33063306 {
3307
- CameraPane.filename = browser.getDirectory() + filename;
3307
+ Globals.filename = browser.getDirectory() + filename;
33083308 //CameraPane.framecount = 0;
3309
- CameraPane.imagecount = 0;
3309
+ Globals.imagecount = 0;
33103310
3311
- CameraPane.ANIMATION ^= true;
3311
+ Globals.ANIMATION ^= true;
33123312
33133313 GrafreeD.wav.cursor = 0;
33143314 GrafreeD.wav.loop = 0;
33153315 }
33163316 } else
33173317 {
3318
- CameraPane.ANIMATION ^= true;
3318
+ Globals.ANIMATION ^= true;
33193319 }
33203320 }
33213321
Object3D.java
....@@ -430,16 +430,16 @@
430430 {
431431 Object3D copy = this;
432432
433
- Camera parentcam = CameraPane.theRenderer.manipCamera;
433
+ Camera parentcam = CameraPane.theRenderer.ManipCamera();
434434
435
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
435
+ if (CameraPane.theRenderer.ManipCamera() == CameraPane.theRenderer.Cameras()[0])
436436 {
437
- parentcam = CameraPane.theRenderer.cameras[1];
437
+ parentcam = CameraPane.theRenderer.Cameras()[1];
438438 }
439439
440
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
440
+ if (CameraPane.theRenderer.ManipCamera() == CameraPane.theRenderer.Cameras()[1])
441441 {
442
- parentcam = CameraPane.theRenderer.cameras[0];
442
+ parentcam = CameraPane.theRenderer.Cameras()[0];
443443 }
444444
445445 if (this == parentcam)
....@@ -447,7 +447,7 @@
447447 //assert(this instanceof Camera);
448448
449449 for (int count = parentcam.GetTransformCount(); --count>=0;)
450
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
450
+ LA.xformPos(CameraPane.theRenderer.TargetLookAt(), parentcam.toParent, CameraPane.theRenderer.TargetLookAt());
451451 }
452452
453453 copy.marked ^= true;
....@@ -467,7 +467,7 @@
467467 //assert(this instanceof Camera);
468468
469469 for (int count = parentcam.GetTransformCount(); --count>=0;)
470
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
470
+ LA.xformPos(CameraPane.theRenderer.TargetLookAt(), parentcam.fromParent, CameraPane.theRenderer.TargetLookAt());
471471 }
472472
473473 copy.Touch(); // display list issue
....@@ -602,7 +602,7 @@
602602 return;
603603 }
604604
605
- if (CameraPane.fromscript)
605
+ if (Globals.fromscript)
606606 {
607607 transformcount = 0;
608608 return;
....@@ -4854,7 +4854,7 @@
48544854 return globalTransform;
48554855 }
48564856
4857
- void PreprocessOcclusion(CameraPane cp)
4857
+ void PreprocessOcclusion(iCameraPane cp)
48584858 {
48594859 /*
48604860 if (AOdone)
....@@ -5327,6 +5327,7 @@
53275327 && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
53285328 }
53295329
5330
+ static boolean DEBUG_SELECTION = false;
53305331
53315332 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53325333 {
....@@ -5365,7 +5366,7 @@
53655366 }
53665367
53675368 if ((//display.DrawMode() == CameraPane.SHADOW ||
5368
- display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5369
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53695370 {
53705371 return;
53715372 }
....@@ -5406,7 +5407,7 @@
54065407
54075408 boolean compiled = false;
54085409
5409
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
5410
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54105411
54115412 if (!selectmode && //display.DrawMode() != display.SELECTION &&
54125413 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5484,9 +5485,9 @@
54845485
54855486 // frustum culling
54865487 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5487
- && display.DrawMode() != CameraPane.SELECTION)
5488
+ && display.DrawMode() != iCameraPane.SELECTION)
54885489 {
5489
- if (display.DrawMode() == CameraPane.SHADOW)
5490
+ if (display.DrawMode() == iCameraPane.SHADOW)
54905491 {
54915492 if (!link2master // tricky to cull in shadow mode.
54925493 && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
....@@ -5533,7 +5534,7 @@
55335534
55345535
55355536 if (!culled)
5536
- if (display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION)
5537
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55375538 {
55385539 if (GetBRep() != null)
55395540 {
....@@ -5973,7 +5974,7 @@
59735974 {
59745975 //throw new Error();
59755976
5976
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
5977
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59775978
59785979 int[] strips = bRep.getRawIndices();
59795980
....@@ -6993,83 +6994,83 @@
69936994 int spotw = spot.x + spot.width;
69946995 int spoth = spot.y + spot.height;
69956996 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
6996
- if (CameraPane.Xmin > spot.x)
6997
- {
6998
- CameraPane.Xmin = spot.x;
6999
- }
7000
- if (CameraPane.Xmax < spotw)
7001
- {
7002
- CameraPane.Xmax = spotw;
7003
- }
7004
- if (CameraPane.Ymin > spot.y)
7005
- {
7006
- CameraPane.Ymin = spot.y;
7007
- }
7008
- if (CameraPane.Ymax < spoth)
7009
- {
7010
- CameraPane.Ymax = spoth;
7011
- }
6997
+// if (CameraPane.Xmin > spot.x)
6998
+// {
6999
+// CameraPane.Xmin = spot.x;
7000
+// }
7001
+// if (CameraPane.Xmax < spotw)
7002
+// {
7003
+// CameraPane.Xmax = spotw;
7004
+// }
7005
+// if (CameraPane.Ymin > spot.y)
7006
+// {
7007
+// CameraPane.Ymin = spot.y;
7008
+// }
7009
+// if (CameraPane.Ymax < spoth)
7010
+// {
7011
+// CameraPane.Ymax = spoth;
7012
+// }
70127013 spot.translate(32, 32);
70137014 spotw = spot.x + spot.width;
70147015 spoth = spot.y + spot.height;
70157016 info.g.setColor(Color.blue);
70167017 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7017
- if (CameraPane.Xmin > spot.x)
7018
- {
7019
- CameraPane.Xmin = spot.x;
7020
- }
7021
- if (CameraPane.Xmax < spotw)
7022
- {
7023
- CameraPane.Xmax = spotw;
7024
- }
7025
- if (CameraPane.Ymin > spot.y)
7026
- {
7027
- CameraPane.Ymin = spot.y;
7028
- }
7029
- if (CameraPane.Ymax < spoth)
7030
- {
7031
- CameraPane.Ymax = spoth;
7032
- }
7018
+// if (CameraPane.Xmin > spot.x)
7019
+// {
7020
+// CameraPane.Xmin = spot.x;
7021
+// }
7022
+// if (CameraPane.Xmax < spotw)
7023
+// {
7024
+// CameraPane.Xmax = spotw;
7025
+// }
7026
+// if (CameraPane.Ymin > spot.y)
7027
+// {
7028
+// CameraPane.Ymin = spot.y;
7029
+// }
7030
+// if (CameraPane.Ymax < spoth)
7031
+// {
7032
+// CameraPane.Ymax = spoth;
7033
+// }
70337034 info.g.drawLine(spotw, spoth, spotw, spoth - 15);
70347035 info.g.drawLine(spotw, spoth, spotw - 15, spoth);
70357036 spot.translate(0, -32);
70367037 info.g.setColor(Color.green);
70377038 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7038
- if (CameraPane.Xmin > spot.x)
7039
- {
7040
- CameraPane.Xmin = spot.x;
7041
- }
7042
- if (CameraPane.Xmax < spotw)
7043
- {
7044
- CameraPane.Xmax = spotw;
7045
- }
7046
- if (CameraPane.Ymin > spot.y)
7047
- {
7048
- CameraPane.Ymin = spot.y;
7049
- }
7050
- if (CameraPane.Ymax < spoth)
7051
- {
7052
- CameraPane.Ymax = spoth;
7053
- }
7039
+// if (CameraPane.Xmin > spot.x)
7040
+// {
7041
+// CameraPane.Xmin = spot.x;
7042
+// }
7043
+// if (CameraPane.Xmax < spotw)
7044
+// {
7045
+// CameraPane.Xmax = spotw;
7046
+// }
7047
+// if (CameraPane.Ymin > spot.y)
7048
+// {
7049
+// CameraPane.Ymin = spot.y;
7050
+// }
7051
+// if (CameraPane.Ymax < spoth)
7052
+// {
7053
+// CameraPane.Ymax = spoth;
7054
+// }
70547055 info.g.drawArc(boundary.x, boundary.y,
70557056 boundary.width, boundary.height, 0, 360);
70567057 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7057
- if (CameraPane.Xmin > boundary.x)
7058
- {
7059
- CameraPane.Xmin = boundary.x;
7060
- }
7061
- if (CameraPane.Xmax < boundary.x + boundary.width)
7062
- {
7063
- CameraPane.Xmax = boundary.x + boundary.width;
7064
- }
7065
- if (CameraPane.Ymin > boundary.y)
7066
- {
7067
- CameraPane.Ymin = boundary.y;
7068
- }
7069
- if (CameraPane.Ymax < boundary.y + boundary.height)
7070
- {
7071
- CameraPane.Ymax = boundary.y + boundary.height;
7072
- }
7058
+// if (CameraPane.Xmin > boundary.x)
7059
+// {
7060
+// CameraPane.Xmin = boundary.x;
7061
+// }
7062
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7063
+// {
7064
+// CameraPane.Xmax = boundary.x + boundary.width;
7065
+// }
7066
+// if (CameraPane.Ymin > boundary.y)
7067
+// {
7068
+// CameraPane.Ymin = boundary.y;
7069
+// }
7070
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7071
+// {
7072
+// CameraPane.Ymax = boundary.y + boundary.height;
7073
+// }
70737074 return;
70747075 }
70757076 }
PointFlow.java
....@@ -102,208 +102,7 @@
102102 double resizefactor = 1;
103103
104104 static cVector tmp = new cVector();
105
-
106
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
107
- {
108
- CreateHT();
109105
110
- float r = display.modelParams0[0];
111
- float g = display.modelParams0[1];
112
- float b = display.modelParams0[2];
113
- float opacity = display.modelParams5[1];
114
-
115
- //final GL gl = GLU.getCurrentGL();
116
- GL gl = display.GetGL(); // getGL();
117
-
118
- int s = points.size();
119
-
120
- boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
121
- gl.glEnable(gl.GL_CULL_FACE);
122
-
123
- for (int i=s; --i>=0;)
124
- //for (int i=0; i<s; i++)
125
- {
126
- cVector v = points.get(i);
127
-
128
- double mindist = Double.MAX_VALUE;
129
-
130
- double size = minimumSize;
131
-
132
- double distancenext = 0;
133
-
134
- if (i > 0)
135
- {
136
- cVector w = points.get(i-1);
137
-
138
- double dist = w.distance(v);
139
-
140
- distancenext = dist;
141
-
142
- if (mindist > dist)
143
- {
144
- mindist = dist;
145
- size = mindist*resizefactor;
146
- }
147
- }
148
-
149
- if (i < s-1)
150
- {
151
- cVector w = points.get(i+1);
152
-
153
- double dist = w.distance(v);
154
-
155
- if (mindist > dist)
156
- {
157
- mindist = dist;
158
- size = mindist*resizefactor;
159
- }
160
- }
161
-
162
- if (size < minimumSize)
163
- size = minimumSize;
164
- if (size > maximumSize)
165
- size = maximumSize;
166
-
167
- double tx = v.x;
168
- double ty = v.y;
169
- double tz = v.z;
170
-
171
- // if (tx == 0 && ty == 0 && tz == 0)
172
- // continue;
173
-
174
- gl.glMatrixMode(gl.GL_TEXTURE);
175
- gl.glPushMatrix();
176
- texmat[12] = texmat[13] = texmat[14] = i;
177
-
178
- gl.glMultMatrixf(texmat, 0);
179
-
180
- gl.glMatrixMode(gl.GL_MODELVIEW);
181
- gl.glPushMatrix();
182
-
183
- gl.glTranslated(tx,ty,tz);
184
-
185
- gl.glScaled(size,size,size);
186
-
187
-// float cr = colorBuf.get(index4);
188
-// float cg = colorBuf.get(index4+1);
189
-// float cb = colorBuf.get(index4+2);
190
-// float ca = colorBuf.get(index4+3);
191
-//
192
-// display.modelParams0[0] = r * cr;
193
-// display.modelParams0[1] = g * cg;
194
-// display.modelParams0[2] = b * cb;
195
-//
196
-// display.modelParams5[1] = opacity * ca;
197
-//
198
-// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
199
-// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
200
-//
201
-// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
202
-// RandomNode.globalseed2 = RandomNode.globalseed;
203
-//
204
-//// gl.glColor4f(cr,cg,cb,ca);
205
-// // gl.glScalef(1024/16,1024/16,1024/16);
206
- geo.Draw/*Node*/(display,null,selected, blocked);
207
-
208
- gl.glPopMatrix();
209
-
210
- double step = size/4; //
211
-
212
- if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
213
- continue;
214
-
215
- int nbsteps = (int)(distancenext/step);
216
-
217
- step = distancenext/nbsteps;
218
-
219
- cVector next = points.get(i-1);
220
-
221
- tmp.set(next);
222
- tmp.sub(v);
223
- tmp.normalize();
224
- tmp.mul(step);
225
-
226
- // calculate next size
227
- mindist = Double.MAX_VALUE;
228
-
229
- double nextsize = minimumSize;
230
-
231
- if (i > 1)
232
- {
233
- cVector w = points.get(i-2);
234
-
235
- double dist = w.distance(next);
236
-
237
- if (mindist > dist)
238
- {
239
- mindist = dist;
240
- nextsize = mindist*resizefactor;
241
- }
242
- }
243
-
244
- double dist = v.distance(next);
245
-
246
- if (mindist > dist)
247
- {
248
- mindist = dist;
249
- nextsize = mindist*resizefactor;
250
- }
251
-
252
- if (nextsize < minimumSize)
253
- nextsize = minimumSize;
254
- if (nextsize > maximumSize)
255
- nextsize = maximumSize;
256
- //
257
-
258
- double count = 0;
259
-
260
- while (distancenext > 0.000000001) // step
261
- {
262
- gl.glPushMatrix();
263
-
264
- gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
265
-
266
- double K = count/nbsteps;
267
-
268
- double intersize = K*nextsize + (1-K)*size;
269
-
270
- gl.glScaled(intersize,intersize,intersize);
271
-
272
- geo.Draw/*Node*/(display,null,selected,blocked);
273
-
274
- count++;
275
-
276
- distancenext -= step;
277
-
278
- gl.glPopMatrix();
279
- }
280
-
281
- if (count != nbsteps)
282
- assert(count == nbsteps);
283
-
284
- // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
285
- //gl.glTranslatef(-tx,-ty,-tz);
286
-
287
- gl.glMatrixMode(gl.GL_TEXTURE);
288
- gl.glPopMatrix();
289
- }
290
-
291
- if (!cf)
292
- gl.glDisable(gl.GL_CULL_FACE);
293
-
294
-// display.modelParams0[0] = r;
295
-// display.modelParams0[1] = g;
296
-// display.modelParams0[2] = b;
297
-//
298
-// display.modelParams5[1] = opacity;
299
-//
300
-// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
301
-// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
302
-
303
- gl.glMatrixMode(gl.GL_MODELVIEW);
304
- }
305
-
306
-
307106 void createEditWindow(GroupEditor callee, boolean newWindow)
308107 {
309108 //editWindow = (new SphereEditor(this, deepCopy(), callee)).GetEditor();
cLinker.java
....@@ -34,7 +34,7 @@
3434 //if(count <= 0)
3535 // return;
3636
37
- if(display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION)
37
+ if(display.DrawMode() == display.SELECTION || display.IsDebugSelection())
3838 {
3939 super.draw(display, root, selected, blocked);
4040 return;
iCameraPane.java
....@@ -6,6 +6,8 @@
66 static final public int SHADOW = 2;
77 static final public int OCCLUSION = 3;
88
9
+ boolean IsDebugSelection();
10
+
911 boolean IsBoxMode();
1012
1113 void ClearDepth();
....@@ -33,12 +35,15 @@
3335 void PushTextureMatrix(double[][] matrix, int count);
3436 void PopTextureMatrix(double[][] matrix);
3537
38
+ Camera[] Cameras();
39
+
3640 Camera EyeCamera();
37
-
3841 Camera LightCamera();
39
-
42
+ Camera ManipCamera();
4043 Camera RenderCamera();
4144
45
+ cVector TargetLookAt();
46
+
4247 // Should be cMaterial
4348 void PushMaterial(Object3D obj, boolean selected);
4449 void PushMaterial2(Object3D obj, boolean selected);
....@@ -54,4 +59,6 @@
5459 void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face);
5560
5661 void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate);
62
+
63
+ void PrepOcclusion(BoundaryRep br, double[][] transform);
5764 }