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)
....@@ -192,9 +193,43 @@
192193
193194 /// INTERFACE
194195
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
+
195225 public boolean IsBoxMode()
196226 {
197227 return BOXMODE;
228
+ }
229
+
230
+ public boolean IsZoomBoxMode()
231
+ {
232
+ return ZOOMBOXMODE;
198233 }
199234
200235 public void ClearDepth()
....@@ -236,9 +271,14 @@
236271 return this.ambientOcclusion;
237272 }
238273
274
+ public boolean IsDebugSelection()
275
+ {
276
+ return DEBUG_SELECTION;
277
+ }
278
+
239279 public boolean IsFrozen()
240280 {
241
- boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
281
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
242282
243283 return !selectmode && cameracount == 0; // != 0;
244284 }
....@@ -259,9 +299,19 @@
259299 return lightCamera;
260300 }
261301
302
+ public Camera ManipCamera()
303
+ {
304
+ return manipCamera;
305
+ }
306
+
262307 public Camera RenderCamera()
263308 {
264309 return renderCamera;
310
+ }
311
+
312
+ public Camera[] Cameras()
313
+ {
314
+ return cameras;
265315 }
266316
267317 public void PushMaterial(Object3D obj, boolean selected)
....@@ -408,16 +458,18 @@
408458
409459 javax.media.opengl.GL gl = display.GetGL();
410460
411
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
461
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
412462
413463 //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
414464 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
415465 {
416466 //gl.glBegin(gl.GL_TRIANGLES);
417
- 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
+ ;
418470 if (!hasnorm)
419471 {
420
- // System.out.println("FUCK!!");
472
+ // System.out.println("Mesh normal");
421473 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
422474 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
423475 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -760,7 +812,627 @@
760812 //// tris.postdraw(this);
761813 }
762814
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
+
7631408 /// 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
+ }
7641436
7651437 void SetColor(Object3D obj, Vertex p0)
7661438 {
....@@ -955,18 +1627,18 @@
9551627 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
9561628 if (!material.multiply)
9571629 {
958
- display.color = color;
1630
+ display.color = material.color;
9591631 display.saturation = material.modulation;
9601632 }
9611633 else
9621634 {
963
- display.color *= color*2;
1635
+ display.color *= material.color*2;
9641636 display.saturation *= material.modulation*2;
9651637 }
9661638
9671639 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
9681640
969
- float[] colorV = GrafreeD.colorV;
1641
+ float[] colorV = Grafreed.colorV;
9701642
9711643 /**/
9721644 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1226,7 +1898,7 @@
12261898 void PushMatrix(double[][] matrix)
12271899 {
12281900 // GrafreeD.tracein(matrix);
1229
- PushMatrix(matrix,1);
1901
+ PushMatrix(matrix, 1);
12301902 }
12311903
12321904 void PushMatrix()
....@@ -1323,7 +1995,7 @@
13231995
13241996 static int camerachangeframe;
13251997
1326
- boolean SetCamera(Camera cam)
1998
+ public boolean SetCamera(Camera cam)
13271999 {
13282000 // may 2014 if (cam == cameras[0] || cam == cameras[1])
13292001 // return false;
....@@ -1451,33 +2123,6 @@
14512123 mainDL ^= true;
14522124 }
14532125
1454
- void ToggleTexture()
1455
- {
1456
- textureon ^= true;
1457
- }
1458
-
1459
- void ToggleLive()
1460
- {
1461
- Globals.setLIVE(Globals.isLIVE() ^ true);
1462
-
1463
- System.err.println("LIVE = " + Globals.isLIVE());
1464
-
1465
- if (!Globals.isLIVE()) // save sound
1466
- GrafreeD.savesound = true; // wav.save();
1467
- // else
1468
- repaint(); // start loop // may 2013
1469
- }
1470
-
1471
- void ToggleSupport()
1472
- {
1473
- SUPPORT ^= true;
1474
- }
1475
-
1476
- void ToggleAbort()
1477
- {
1478
- ABORTMODE ^= true;
1479
- }
1480
-
14812126 void ToggleFullScreen()
14822127 {
14832128 FULLSCREEN ^= true;
....@@ -1488,72 +2133,94 @@
14882133 Globals.CROWD ^= true;
14892134 }
14902135
1491
- void ToggleInertia()
1492
- {
1493
- INERTIA ^= true;
1494
- }
1495
-
14962136 void ToggleLocal()
14972137 {
14982138 LOCALTRANSFORM ^= true;
14992139 }
15002140
1501
- 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()
15022174 {
15032175 FAST ^= true;
15042176 }
15052177
1506
- void ToggleSlowPose()
2178
+ public void ToggleSlowPose()
15072179 {
15082180 SLOWPOSE ^= true;
15092181 }
15102182
1511
- void ToggleFootContact()
1512
- {
1513
- FOOTCONTACT ^= true;
1514
- }
1515
-
1516
- void ToggleBoxMode()
2183
+ public void ToggleBoxMode()
15172184 {
15182185 BOXMODE ^= true;
15192186 }
15202187
1521
- void ToggleSmoothFocus()
2188
+ public void ToggleZoomBoxMode()
2189
+ {
2190
+ ZOOMBOXMODE ^= true;
2191
+ }
2192
+
2193
+ public void ToggleSmoothFocus()
15222194 {
15232195 SMOOTHFOCUS ^= true;
15242196 }
15252197
1526
- void ToggleImageFlip()
2198
+ public void ToggleImageFlip()
15272199 {
15282200 IMAGEFLIP ^= true;
15292201 }
15302202
1531
- void ToggleSpeakerMocap()
2203
+ public void ToggleSpeakerMocap()
15322204 {
15332205 SPEAKERMOCAP ^= true;
15342206 }
15352207
1536
- void ToggleSpeakerCamera()
2208
+ public void ToggleSpeakerCamera()
15372209 {
15382210 SPEAKERCAMERA ^= true;
15392211 }
15402212
1541
- void ToggleSpeakerFocus()
2213
+ public void ToggleSpeakerFocus()
15422214 {
15432215 SPEAKERFOCUS ^= true;
15442216 }
15452217
1546
- void ToggleDebug()
1547
- {
1548
- DEBUG ^= true;
1549
- }
1550
-
1551
- void ToggleFrustum()
2218
+ public void ToggleFrustum()
15522219 {
15532220 FRUSTUM ^= true;
15542221 }
15552222
1556
- void ToggleTrack()
2223
+ public void ToggleTrack()
15572224 {
15582225 TRACK ^= true;
15592226 if (TRACK)
....@@ -1572,25 +2239,35 @@
15722239 repaint();
15732240 }
15742241
1575
- void ToggleTrackOnce()
2242
+ public void ToggleTrackOnce()
15762243 {
15772244 TRACKONCE ^= true;
15782245 }
15792246
1580
- void ToggleShadowTrack()
2247
+ public void ToggleShadowTrack()
15812248 {
15822249 SHADOWTRACK ^= true;
15832250 repaint();
15842251 }
15852252
1586
- void ToggleOeil()
2253
+ public void ToggleOeil()
15872254 {
15882255 OEIL ^= true;
15892256 }
15902257
1591
- void ToggleOeilOnce()
2258
+ public void ToggleOeilOnce()
15922259 {
15932260 OEILONCE ^= true;
2261
+ }
2262
+
2263
+ void ToggleFootContact()
2264
+ {
2265
+ FOOTCONTACT ^= true;
2266
+ }
2267
+
2268
+ void ToggleDebug()
2269
+ {
2270
+ DEBUG ^= true;
15942271 }
15952272
15962273 void ToggleLookAt()
....@@ -1598,9 +2275,9 @@
15982275 LOOKAT ^= true;
15992276 }
16002277
1601
- void ToggleRandom()
2278
+ void ToggleSwitch()
16022279 {
1603
- RANDOM ^= true;
2280
+ SWITCH ^= true;
16042281 }
16052282
16062283 void ToggleHandles()
....@@ -1707,7 +2384,7 @@
17072384 {
17082385 return currentGL;
17092386 }
1710
-
2387
+
17112388 /**/
17122389 class CacheTexture
17132390 {
....@@ -3539,6 +4216,7 @@
35394216
35404217 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
35414218 {
4219
+ new Exception().printStackTrace();
35424220 System.exit(0);
35434221 com.sun.opengl.util.texture.Texture texture = null;
35444222
....@@ -7251,6 +7929,64 @@
72517929 ReleaseTexture(pigment, false);
72527930 }
72537931
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
+
72547990 void ReleaseTexture(String tex, boolean bump)
72557991 {
72567992 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -7354,7 +8090,7 @@
73548090 }
73558091 }
73568092
7357
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8093
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
73588094 {
73598095 if (// DrawMode() != 0 || /*tex == null ||*/
73608096 ambientOcclusion ) // || !textureon)
....@@ -7399,7 +8135,94 @@
73998135 return; // true;
74008136 }
74018137
7402
- 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
74038226 {
74048227 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
74058228
....@@ -7407,12 +8230,18 @@
74078230 {
74088231 String texname = tex;
74098232
7410
- String[] split = tex.split("Textures");
7411
- if (split.length > 1)
7412
- texname = "/Users/nbriere/Textures" + split[split.length-1];
7413
- else
7414
- if (!texname.startsWith("/"))
7415
- 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
+ }
74168245
74178246 if (CACHETEXTURE)
74188247 texture = textures.get(texname); // TEXTURE CACHE
....@@ -7481,7 +8310,7 @@
74818310 }
74828311
74838312 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
7484
- if (!new File(cachename).exists())
8313
+ if (!FileExists(cachename))
74858314 cachename = texname;
74868315 else
74878316 processbump = false; // don't process bump map again
....@@ -7503,7 +8332,7 @@
75038332 }
75048333
75058334 cachename = texname.substring(0, texname.length()-4)+ext+".png";
7506
- if (!new File(cachename).exists())
8335
+ if (!FileExists(cachename))
75078336 cachename = texname;
75088337 else
75098338 processbump = false; // don't process bump map again
....@@ -7512,7 +8341,9 @@
75128341 texturedata = GetFileTexture(cachename, processbump, resolution);
75138342
75148343
7515
- if (texturedata != null)
8344
+ if (texturedata == null)
8345
+ throw new Exception();
8346
+
75168347 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
75178348 //texture = GetTexture(tex, bump);
75188349 }
....@@ -7634,7 +8465,7 @@
76348465 return texture;
76358466 }
76368467
7637
- 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
76388469 {
76398470 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
76408471
....@@ -7652,14 +8483,14 @@
76528483 return texture!=null?texture.texture:null;
76538484 }
76548485
7655
- 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
76568487 {
76578488 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
76588489
76598490 return texture!=null?texture.texturedata:null;
76608491 }
76618492
7662
- boolean BindTexture(String tex, boolean bump, int resolution)
8493
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
76638494 {
76648495 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
76658496 {
....@@ -8636,8 +9467,8 @@
86369467 assert (parentcam != renderCamera);
86379468
86389469 if (renderCamera != lightCamera)
8639
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8640
- LA.matConcat(matrix, parentcam.toParent, matrix);
9470
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9471
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
86419472
86429473 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
86439474
....@@ -8652,8 +9483,8 @@
86529483 LA.matCopy(renderCamera.fromScreen, matrix);
86539484
86549485 if (renderCamera != lightCamera)
8655
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8656
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9486
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9487
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
86579488
86589489 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
86599490
....@@ -8725,7 +9556,7 @@
87259556 //gl.glFlush();
87269557 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
87279558
8728
- if (ANIMATION && ABORTED)
9559
+ if (Globals.ANIMATION && ABORTED)
87299560 {
87309561 System.err.println(" ABORTED FRAME");
87319562 break;
....@@ -8755,7 +9586,7 @@
87559586 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
87569587
87579588 // save image
8758
- if (ANIMATION && !ABORTED)
9589
+ if (Globals.ANIMATION && !ABORTED)
87599590 {
87609591 VPwidth = viewport[2];
87619592 VPheight = viewport[3];
....@@ -8866,11 +9697,11 @@
88669697
88679698 // imagecount++;
88689699
8869
- 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;
88709701
88719702 if (!BOXMODE)
88729703 {
8873
- 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) + ")");
88749705 }
88759706
88769707 if (!BOXMODE)
....@@ -8908,7 +9739,7 @@
89089739 ABORTED = false;
89099740 }
89109741 else
8911
- GrafreeD.wav.cursor += 735 * ACSIZE;
9742
+ Grafreed.wav.cursor += 735 * ACSIZE;
89129743
89139744 if (false)
89149745 {
....@@ -9571,11 +10402,11 @@
957110402
957210403 public void display(GLAutoDrawable drawable)
957310404 {
9574
- if (GrafreeD.savesound && GrafreeD.hassound)
10405
+ if (Grafreed.savesound && Grafreed.hassound)
957510406 {
9576
- GrafreeD.wav.save();
9577
- GrafreeD.savesound = false;
9578
- GrafreeD.hassound = false;
10407
+ Grafreed.wav.save();
10408
+ Grafreed.savesound = false;
10409
+ Grafreed.hassound = false;
957910410 }
958010411 // if (DEBUG_SELECTION)
958110412 // {
....@@ -9705,7 +10536,7 @@
970510536 Object3D theobject = object;
970610537 Object3D theparent = object.parent;
970710538 object.parent = null;
9708
- object = (Object3D)GrafreeD.clone(object);
10539
+ object = (Object3D)Grafreed.clone(object);
970910540 object.Stripify();
971010541 if (theobject.selection == null || theobject.selection.Size() == 0)
971110542 theobject.PreprocessOcclusion(this);
....@@ -9718,13 +10549,13 @@
971810549 ambientOcclusion = false;
971910550 }
972010551
9721
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10552
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
972210553 {
972310554 //if (RENDERSHADOW) // ?
972410555 if (!IsFrozen())
972510556 {
972610557 // dec 2012
9727
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10558
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
972810559 {
972910560 Globals.framecount++;
973010561 shadowbuffer.display();
....@@ -9851,8 +10682,8 @@
985110682
985210683 // if (parentcam != renderCamera) // not a light
985310684 if (cam != lightCamera)
9854
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9855
- LA.matConcat(matrix, parentcam.toParent, matrix);
10685
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10686
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
985610687
985710688 for (int j = 0; j < 4; j++)
985810689 {
....@@ -9866,8 +10697,8 @@
986610697
986710698 // if (parentcam != renderCamera) // not a light
986810699 if (cam != lightCamera)
9869
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9870
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10700
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10701
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
987110702
987210703 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
987310704
....@@ -10126,7 +10957,16 @@
1012610957 // Bump noise
1012710958 gl.glActiveTexture(GL.GL_TEXTURE6);
1012810959 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10129
- 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
+
1013010970
1013110971 gl.glActiveTexture(GL.GL_TEXTURE0);
1013210972 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10251,8 +11091,8 @@
1025111091 System.err.println("parentcam != renderCamera");
1025211092
1025311093 // if (cam != lightCamera)
10254
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10255
- 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
1025611096 }
1025711097
1025811098 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10273,8 +11113,8 @@
1027311113 if (true) // TODO
1027411114 {
1027511115 if (cam != lightCamera)
10276
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10277
- 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
1027811118 }
1027911119
1028011120 LA.xformPos(light0, cam.toScreen, light0);
....@@ -10340,7 +11180,7 @@
1034011180 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
1034111181 //System.out.println("fragmentMode = " + fragmentMode);
1034211182
10343
- if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION)
11183
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
1034411184 {
1034511185 /*
1034611186 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -10590,8 +11430,14 @@
1059011430 {
1059111431 renderpass++;
1059211432 // System.out.println("Draw object... ");
11433
+ STEP = 1;
1059311434 if (FAST) // in case there is no script
10594
- STEP = 16;
11435
+ STEP = 8;
11436
+
11437
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11438
+ {
11439
+ STEP *= 4;
11440
+ }
1059511441
1059611442 //object.FullInvariants();
1059711443
....@@ -10605,8 +11451,8 @@
1060511451 e.printStackTrace();
1060611452 }
1060711453
10608
- if (GrafreeD.RENDERME > 0)
10609
- GrafreeD.RENDERME--; // mechante magouille
11454
+ if (Grafreed.RENDERME > 0)
11455
+ Grafreed.RENDERME--; // mechante magouille
1061011456
1061111457 Globals.ONESTEP = false;
1061211458 }
....@@ -10641,7 +11487,7 @@
1064111487 callist = gl.glGenLists(1);
1064211488 }
1064311489
10644
- boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
11490
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
1064511491
1064611492 boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
1064711493
....@@ -10676,7 +11522,14 @@
1067611522
1067711523 usedtextures.clear();
1067811524
10679
- 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
+ }
1068011533 }
1068111534 //System.out.println("--> " + stackdepth);
1068211535 // GrafreeD.traceon();
....@@ -10767,7 +11620,14 @@
1076711620 if (checker != null && DrawMode() == DEFAULT)
1076811621 {
1076911622 //BindTexture(IMMORTAL_TEXTURE);
10770
- 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
+ }
1077111631 // NEAREST
1077211632 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1077311633 DrawChecker(gl);
....@@ -10849,7 +11709,7 @@
1084911709 return;
1085011710 }
1085111711
10852
- String string = obj.GetToolTip();
11712
+ String string = obj.toString(); //.GetToolTip();
1085311713
1085411714 GL gl = GetGL();
1085511715
....@@ -11166,8 +12026,8 @@
1116612026 //obj.TransformToWorld(light, light);
1116712027 for (int i = tp.size(); --i >= 0;)
1116812028 {
11169
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11170
- 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);
1117112031 }
1117212032
1117312033
....@@ -11184,8 +12044,8 @@
1118412044 parentcam = cameras[0];
1118512045 }
1118612046
11187
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11188
- 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
1118912049
1119012050 LA.xformPos(light, renderCamera.toScreen, light);
1119112051
....@@ -11799,8 +12659,8 @@
1179912659
1180012660 // display shadow only (bump == 0)
1180112661 "SUB temp.x, half.x, shadow.x;" +
11802
- "MOV temp.y, -params6.x;" +
11803
- "SLT temp.z, temp.y, zero.x;" +
12662
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12663
+ "SLT temp.z, temp.y, -one2048th.x;" +
1180412664 "SUB temp.y, one.x, temp.z;" +
1180512665 "MUL temp.x, temp.x, temp.y;" +
1180612666 "KIL temp.x;" +
....@@ -11929,8 +12789,10 @@
1192912789 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1193012790
1193112791 "SUB temp.x, one.x, ndotl.x;" +
11932
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
11933
- "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
1193412796 "MUL temp.x, temp.x, temp.y;" +
1193512797
1193612798 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12129,7 +12991,7 @@
1212912991 //once = true;
1213012992 }
1213112993
12132
- System.out.print("Program #" + mode + "; length = " + program.length());
12994
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1213312995 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1213412996 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1213512997
....@@ -12262,12 +13124,16 @@
1226213124
1226313125 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1226413126 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13127
+
13128
+ // Compare fragment depth in light space with shadowmap.
1226513129 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1226613130 "SGE temp.y, temp.x, zero.x;" +
12267
- "SUB " + shadow + ".y, one.x, temp.y;" +
13131
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13132
+
13133
+ // Reverse comparison
1226813134 "SUB temp.x, one.x, temp.x;" +
1226913135 "MUL " + shadow + ".x, temp.x, temp.y;" +
12270
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13136
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1227113137 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1227213138
1227313139 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12281,6 +13147,10 @@
1228113147 // No shadow for backface
1228213148 "DP3 temp.x, normal, lightd;" +
1228313149 "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;" +
1228413154 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1228513155 "";
1228613156 }
....@@ -12839,7 +13709,7 @@
1283913709 public void mousePressed(MouseEvent e)
1284013710 {
1284113711 //System.out.println("mousePressed: " + e);
12842
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13712
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1284313713 }
1284413714
1284513715 static long prevtime = 0;
....@@ -12866,6 +13736,7 @@
1286613736
1286713737 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1286813738
13739
+ if (BUTTONLESSWHEEL)
1286913740 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1287013741 {
1287113742 return;
....@@ -12874,7 +13745,7 @@
1287413745 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1287513746
1287613747 // TIMER
12877
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
13748
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1287813749 {
1287913750 keepboxmode = BOXMODE;
1288013751 keepsupport = SUPPORT;
....@@ -12914,8 +13785,8 @@
1291413785 // mode |= META;
1291513786 //}
1291613787
12917
- SetMouseMode(WHEEL | e.getModifiersEx());
12918
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13788
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13789
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1291913790 anchorX = ax;
1292013791 anchorY = ay;
1292113792 prevX = px;
....@@ -12975,6 +13846,10 @@
1297513846 // wasliveok = true;
1297613847 // waslive = false;
1297713848
13849
+ // May 2019 Forget it:
13850
+ if (true)
13851
+ return;
13852
+
1297813853 // source == timer
1297913854 if (mouseDown)
1298013855 {
....@@ -13013,7 +13888,7 @@
1301313888
1301413889 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1301513890
13016
- void clickStart(int x, int y, int modifiers)
13891
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1301713892 {
1301813893 if (!wasliveok)
1301913894 return;
....@@ -13030,7 +13905,7 @@
1303013905 // touched = true; // main DL
1303113906 if (isRenderer)
1303213907 {
13033
- SetMouseMode(modifiers);
13908
+ SetMouseMode(modifiers, modifiersex);
1303413909 }
1303513910
1303613911 selectX = anchorX = x;
....@@ -13043,7 +13918,7 @@
1304313918 clicked = true;
1304413919 hold = false;
1304513920
13046
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13921
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1304713922 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1304813923 {
1304913924 // System.out.println("RESTART II " + modifiers);
....@@ -13074,7 +13949,7 @@
1307413949 info.camera = renderCamera;
1307513950 info.x = x;
1307613951 info.y = y;
13077
- info.modifiers = modifiers;
13952
+ info.modifiers = modifiersex;
1307813953 editObj = object.doEditClick(info, 0);
1307913954 if (!editObj)
1308013955 {
....@@ -13091,11 +13966,14 @@
1309113966
1309213967 public void mouseDragged(MouseEvent e)
1309313968 {
13969
+ Globals.MOUSEDRAGGED = true;
13970
+
13971
+ //System.out.println("mouseDragged: " + e);
1309413972 if (isRenderer)
1309513973 movingcamera = true;
13974
+
1309613975 //if (drawing)
1309713976 //return;
13098
- //System.out.println("mouseDragged: " + e);
1309913977 if ((e.getModifiersEx() & CTRL) != 0
1310013978 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1310113979 {
....@@ -13103,7 +13981,7 @@
1310313981 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1310413982 }
1310513983 else
13106
- drag(e.getX(), e.getY(), e.getModifiersEx());
13984
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1310713985
1310813986 //try { Thread.sleep(1); } catch (Exception ex) {}
1310913987 }
....@@ -13115,6 +13993,11 @@
1311513993 cVector tmp = new cVector();
1311613994 cVector tmp2 = new cVector();
1311713995 boolean isMoving;
13996
+
13997
+ public cVector TargetLookAt()
13998
+ {
13999
+ return targetLookAt;
14000
+ }
1311814001
1311914002 class PingThread extends Thread
1312014003 {
....@@ -13271,6 +14154,7 @@
1327114154
1327214155 public void run()
1327314156 {
14157
+ new Exception().printStackTrace();
1327414158 System.exit(0);
1327514159 for (;;)
1327614160 {
....@@ -13334,7 +14218,7 @@
1333414218 {
1333514219 Globals.lighttouched = true;
1333614220 }
13337
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14221
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1333814222 }
1333914223 //else
1334014224 }
....@@ -13434,7 +14318,7 @@
1343414318 int X, Y;
1343514319 boolean SX, SY;
1343614320
13437
- void drag(int x, int y, int modifiers)
14321
+ void drag(int x, int y, int modifiers, int modifiersex)
1343814322 {
1343914323 if (IsFrozen())
1344014324 {
....@@ -13443,17 +14327,17 @@
1344314327
1344414328 drag = true; // NEW
1344514329
13446
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14330
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1344714331
1344814332 X = x;
1344914333 Y = y;
1345014334 // floating state for animation
13451
- MODIFIERS = modifiers;
13452
- modifiers &= ~1024;
14335
+ MODIFIERS = modifiersex;
14336
+ modifiersex &= ~1024;
1345314337 if (false) // modifiers != 0)
1345414338 {
1345514339 //new Exception().printStackTrace();
13456
- System.out.println("mouseDragged: " + modifiers);
14340
+ System.out.println("mouseDragged: " + modifiersex);
1345714341 System.out.println("SHIFT = " + SHIFT);
1345814342 System.out.println("CONTROL = " + COMMAND);
1345914343 System.out.println("META = " + META);
....@@ -13473,7 +14357,7 @@
1347314357 info.camera = renderCamera;
1347414358 info.x = x;
1347514359 info.y = y;
13476
- object.editWindow.copy.doEditDrag(info);
14360
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1347714361 } else
1347814362 {
1347914363 if (x < startX)
....@@ -13625,7 +14509,6 @@
1362514509 public void mouseMoved(MouseEvent e)
1362614510 {
1362714511 //System.out.println("mouseMoved: " + e);
13628
-
1362914512 if (isRenderer)
1363014513 return;
1363114514
....@@ -13650,7 +14533,10 @@
1365014533
1365114534 public void mouseReleased(MouseEvent e)
1365214535 {
14536
+ Globals.MOUSEDRAGGED = false;
14537
+
1365314538 movingcamera = false;
14539
+ X = Y = 0;
1365414540 //System.out.println("mouseReleased: " + e);
1365514541 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1365614542 }
....@@ -13673,9 +14559,9 @@
1367314559 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1367414560 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1367514561
13676
- if (control || command || IsFrozen())
14562
+// No delay if (control || command || IsFrozen())
1367714563 timeout = true;
13678
- else
14564
+// ?? May 2019 else
1367914565 // timer.setDelay((modifiers & 128) != 0?0:350);
1368014566 mouseDown = false;
1368114567 if (!control && !command) // june 2013
....@@ -13785,7 +14671,7 @@
1378514671 System.out.println("keyReleased: " + e);
1378614672 }
1378714673
13788
- void SetMouseMode(int modifiers)
14674
+ void SetMouseMode(int modifiers, int modifiersex)
1378914675 {
1379014676 //System.out.println("SetMouseMode = " + modifiers);
1379114677 //modifiers &= ~1024;
....@@ -13797,25 +14683,25 @@
1379714683 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1379814684 // return;
1379914685 //System.out.println("SetMode = " + modifiers);
13800
- if ((modifiers & WHEEL) == WHEEL)
14686
+ if ((modifiersex & WHEEL) == WHEEL)
1380114687 {
1380214688 mouseMode |= ZOOM;
1380314689 }
1380414690
1380514691 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
13806
- if (capsLocked || (modifiers & META) == META)
14692
+ if (capsLocked) // || (modifiers & META) == META)
1380714693 {
1380814694 mouseMode |= VR; // BACKFORTH;
1380914695 }
13810
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14696
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1381114697 {
1381214698 mouseMode |= SELECT;
1381314699 }
13814
- if ((modifiers & COMMAND) == COMMAND)
14700
+ if ((modifiersex & COMMAND) == COMMAND)
1381514701 {
1381614702 mouseMode |= SELECT;
1381714703 }
13818
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14704
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1381914705 {
1382014706 mouseMode &= ~VR;
1382114707 mouseMode |= TRANSLATE;
....@@ -13844,10 +14730,10 @@
1384414730
1384514731 if (isRenderer) //
1384614732 {
13847
- SetMouseMode(modifiers);
14733
+ SetMouseMode(0, modifiers);
1384814734 }
1384914735
13850
- theRenderer.keyPressed(key);
14736
+ Globals.theRenderer.keyPressed(key);
1385114737 }
1385214738
1385314739 int kompactbit = 4; // power bit
....@@ -13859,7 +14745,7 @@
1385914745 float SATPOW = 1; // 2; // 0.5f;
1386014746 float BRIPOW = 1; // 0.5f; // 0.5f;
1386114747
13862
- void keyPressed(int key)
14748
+ public void keyPressed(int key)
1386314749 {
1386414750 if (key >= '0' && key <= '5')
1386514751 clampbit = (key-'0');
....@@ -14180,7 +15066,7 @@
1418015066 //RESIZETEXTURE ^= true;
1418115067 //break;
1418215068 case 'z':
14183
- RENDERSHADOW ^= true;
15069
+ Globals.RENDERSHADOW ^= true;
1418415070 Globals.lighttouched = true;
1418515071 repaint();
1418615072 break;
....@@ -14296,6 +15182,7 @@
1429615182 }
1429715183 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1429815184 }
15185
+
1429915186 static double OCCLUSIONBOOST = 1; // 0.5;
1430015187
1430115188 void keyReleased(int key, int modifiers)
....@@ -14303,11 +15190,11 @@
1430315190 //mode = ROTATE;
1430415191 if ((MODIFIERS & COMMAND) == 0) // VR??
1430515192 {
14306
- SetMouseMode(modifiers);
15193
+ SetMouseMode(0, modifiers);
1430715194 }
1430815195 }
1430915196
14310
- protected void processKeyEvent(KeyEvent e)
15197
+ public void processKeyEvent(KeyEvent e)
1431115198 {
1431215199 switch (e.getID())
1431315200 {
....@@ -14437,8 +15324,9 @@
1443715324
1443815325 protected void processMouseMotionEvent(MouseEvent e)
1443915326 {
14440
- //System.out.println("processMouseMotionEvent: " + mouseMode);
14441
- 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)
1444215330 {
1444315331 mouseMoved(e);
1444415332 } else
....@@ -14468,6 +15356,7 @@
1446815356
1446915357 void SelectParent()
1447015358 {
15359
+ new Exception().printStackTrace();
1447115360 System.exit(0);
1447215361 Composite group = (Composite) object;
1447315362 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -14491,6 +15380,7 @@
1449115380
1449215381 void SelectChildren()
1449315382 {
15383
+ new Exception().printStackTrace();
1449415384 System.exit(0);
1449515385 /*
1449615386 Composite group = (Composite) object;
....@@ -14655,7 +15545,9 @@
1465515545 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1465615546 //Image img = CreateImage(width, height);
1465715547 //System.out.println("width = " + width + "; height = " + height + "\n");
15548
+
1465815549 Graphics gr = g; // img.getGraphics();
15550
+
1465915551 if (!hasMarquee)
1466015552 {
1466115553 if (Xmin < Xmax) // !locked)
....@@ -14753,14 +15645,33 @@
1475315645 if (!isRenderer)
1475415646 {
1475515647 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
+ }
1475615665 }
1475715666 }
15667
+
1475815668 if (isRenderer)
1475915669 {
1476015670 //gr.setColor(Color.black);
1476115671 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1476215672 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1476315673 }
15674
+
1476415675 if (hasMarquee)
1476515676 {
1476615677 gr.setXORMode(Color.white);
....@@ -14873,6 +15784,7 @@
1487315784 public boolean mouseDown(Event evt, int x, int y)
1487415785 {
1487515786 System.out.println("mouseDown: " + evt);
15787
+ System.exit(0);
1487615788 /*
1487715789 locked = true;
1487815790 drag = false;
....@@ -14916,7 +15828,7 @@
1491615828 {
1491715829 keyPressed(0, modifiers);
1491815830 }
14919
- clickStart(x, y, modifiers);
15831
+ // clickStart(x, y, modifiers);
1492015832 return true;
1492115833 }
1492215834
....@@ -15034,7 +15946,7 @@
1503415946 {
1503515947 keyReleased(0, 0);
1503615948 }
15037
- drag(x, y, modifiers);
15949
+ drag(x, y, 0, modifiers);
1503815950 return true;
1503915951 }
1504015952
....@@ -15166,7 +16078,7 @@
1516616078 Object3D object;
1516716079 static Object3D trackedobject;
1516816080 Camera renderCamera; // Light or Eye (or Occlusion)
15169
- /*static*/ Camera manipCamera; // Light or Eye
16081
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1517016082 /*static*/ Camera eyeCamera;
1517116083 /*static*/ Camera lightCamera;
1517216084 int cameracount;
....@@ -15604,6 +16516,7 @@
1560416516 {
1560516517 if (!selection)
1560616518 {
16519
+ new Exception().printStackTrace();
1560716520 System.exit(0);
1560816521 return;
1560916522 }
....@@ -15731,16 +16644,16 @@
1573116644 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]));
1573216645 }
1573316646
15734
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16647
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1573516648 }
1573616649 }
1573716650
1573816651 if (!movingcamera && !PAINTMODE)
1573916652 object.editWindow.ScreenFitPoint(); // fev 2014
1574016653
15741
- 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)
1574216655 {
15743
- 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);
1574416657
1574516658 Object3D group = new Object3D("inst" + paintcount++);
1574616659
....@@ -15896,7 +16809,7 @@
1589616809 gl.glDisable(gl.GL_CULL_FACE);
1589716810 }
1589816811
15899
- if (!RENDERSHADOW)
16812
+ if (!Globals.RENDERSHADOW)
1590016813 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1590116814
1590216815 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -15906,7 +16819,7 @@
1590616819 //gl.glColorMask(false, false, false, false);
1590716820
1590816821 //render_scene_from_light_view(gl, drawable, 0, 0);
15909
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16822
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1591016823 {
1591116824 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1591216825
....@@ -15966,7 +16879,6 @@
1596616879
1596716880 class AntialiasBuffer implements GLEventListener
1596816881 {
15969
-
1597016882 CameraPane parent = null;
1597116883
1597216884 AntialiasBuffer(CameraPane p)
....@@ -16359,7 +17271,7 @@
1635917271 }
1636017272 }
1636117273
16362
- static void DrawPoints(CameraPane cpane)
17274
+ static void DrawPoints(iCameraPane cpane)
1636317275 {
1636417276 for (int i=0; i<8; i++) // first and last are red
1636517277 {
....@@ -16391,10 +17303,11 @@
1639117303 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1639217304 // Depth buffer format
1639317305 //private int depth_format;
16394
- static public void NextIndex(Object3D o, GL gl)
17306
+
17307
+ public void NextIndex()
1639517308 {
1639617309 indexcount+=16;
16397
- 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);
1639817311 //objects[indexcount] = o;
1639917312 //System.out.println("indexcount = " + indexcount);
1640017313 }