Normand Briere
2019-07-25 f2b6a33fdf84a06b958f9cb9d667a2eff3063d8b
CameraPane.java
....@@ -18,7 +18,10 @@
1818 import javax.imageio.ImageIO;
1919 import javax.imageio.ImageWriteParam;
2020 import javax.imageio.ImageWriter;
21
+import javax.imageio.ImageReadParam;
22
+import javax.imageio.ImageReader;
2123 import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
24
+import javax.imageio.stream.ImageInputStream;
2225 import javax.imageio.stream.ImageOutputStream;
2326 import javax.imageio.ImageWriteParam;
2427
....@@ -30,6 +33,7 @@
3033 import java.nio.*;
3134
3235 import gleem.linalg.Mat4f;
36
+import javax.imageio.ImageTypeSpecifier;
3337
3438 class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
3539 {
....@@ -37,7 +41,6 @@
3741 static boolean[] selectedstack = new boolean[65536];
3842 static int materialdepth = 0;
3943
40
- static boolean DEBUG = false;
4144 static boolean FRUSTUM = false; // still bogus true; // frustum culling
4245
4346 // camera change fix
....@@ -45,6 +48,39 @@
4548 static boolean ABORTED = false;
4649
4750 static int STEP = 1;
51
+
52
+ private static BufferedImage CreateBim(byte[] bytes, int width, int height)
53
+ {
54
+ int[] pixels = new int[bytes.length/3];
55
+ for (int i=pixels.length; --i>=0;)
56
+ {
57
+ int i3 = i*3;
58
+ pixels[i] = 0xFF;
59
+ pixels[i] <<= 8;
60
+ pixels[i] |= bytes[i3+2] & 0xFF;
61
+ pixels[i] <<= 8;
62
+ pixels[i] |= bytes[i3+1] & 0xFF;
63
+ pixels[i] <<= 8;
64
+ pixels[i] |= bytes[i3] & 0xFF;
65
+ }
66
+ /*
67
+ int r=0,g=0,b=0,a=0;
68
+ for (int i=0; i<width; i++)
69
+ for (int j=0; j<height; j++)
70
+ {
71
+ int index = j*width+i;
72
+ int p = pixels[index];
73
+ a = ((p>>24) & 0xFF);
74
+ r = ((p>>16) & 0xFF);
75
+ g = ((p>>8) & 0xFF);
76
+ b = (p & 0xFF);
77
+ pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
78
+ }
79
+ /**/
80
+ BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
81
+ rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
82
+ return rendImage;
83
+ }
4884
4985 /*static*/ private boolean CULLFACE = false; // true;
5086 /*static*/ boolean NEAREST = false; // true;
....@@ -56,14 +92,12 @@
5692 static int CURRENTANTIALIAS = 0; // 1;
5793 /*static*/ boolean RENDERSHADOW = true;
5894 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
59
- static boolean ANIMATION = false;
60
- static String filename;
6195
6296 boolean DISPLAYTEXT = false;
6397 //boolean REDUCETEXTURE = true;
6498 boolean CACHETEXTURE = true;
6599 boolean CLEANCACHE = false; // true;
66
- boolean MIPMAP = false; // true;
100
+ boolean MIPMAP = false; // true; // never works...
67101 boolean COMPRESSTEXTURE = false;
68102 boolean KOMPACTTEXTURE = false; // true;
69103 boolean RESIZETEXTURE = false;
....@@ -92,6 +126,8 @@
92126
93127 static int tickcount = 0; // slow pose issue
94128
129
+static boolean BUTTONLESSWHEEL = false;
130
+static boolean ZOOMBOXMODE = false;
95131 static boolean BOXMODE = false;
96132 static boolean IMAGEFLIP = false;
97133 static boolean SMOOTHFOCUS = false;
....@@ -106,7 +142,7 @@
106142 static boolean OEIL = true;
107143 static boolean OEILONCE = false; // do oeilon then oeiloff
108144 static boolean LOOKAT = true;
109
-static boolean RANDOM = true; // false;
145
+static boolean SWITCH = true; // false;
110146 static boolean HANDLES = false; // selection doesn't work!!
111147 static boolean PAINTMODE = false;
112148
....@@ -149,12 +185,13 @@
149185 defaultcaps.setAccumBlueBits(16);
150186 defaultcaps.setAccumAlphaBits(16);
151187 }
152
- static CameraPane theRenderer;
153
-
188
+
189
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
190
+
154191 void SetAsGLRenderer(boolean b)
155192 {
156193 isRenderer = b;
157
- theRenderer = this;
194
+ Globals.theRenderer = this;
158195 }
159196
160197 CameraPane(Object3D o, Camera cam, boolean withcontext)
....@@ -192,9 +229,43 @@
192229
193230 /// INTERFACE
194231
232
+ public javax.media.opengl.GL GetGL0()
233
+ {
234
+ return null;
235
+ }
236
+
237
+ public int GenList()
238
+ {
239
+ javax.media.opengl.GL gl = GetGL();
240
+ return gl.glGenLists(1);
241
+ }
242
+
243
+ public void NewList(int id)
244
+ {
245
+ javax.media.opengl.GL gl = GetGL();
246
+ gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE);
247
+ }
248
+
249
+ public void CallList(int id)
250
+ {
251
+ javax.media.opengl.GL gl = GetGL();
252
+ gl.glCallList(id);
253
+ }
254
+
255
+ public void EndList()
256
+ {
257
+ javax.media.opengl.GL gl = GetGL();
258
+ gl.glEndList();
259
+ }
260
+
195261 public boolean IsBoxMode()
196262 {
197263 return BOXMODE;
264
+ }
265
+
266
+ public boolean IsZoomBoxMode()
267
+ {
268
+ return ZOOMBOXMODE;
198269 }
199270
200271 public void ClearDepth()
....@@ -236,9 +307,14 @@
236307 return this.ambientOcclusion;
237308 }
238309
310
+ public boolean IsDebugSelection()
311
+ {
312
+ return DEBUG_SELECTION;
313
+ }
314
+
239315 public boolean IsFrozen()
240316 {
241
- boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
317
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
242318
243319 return !selectmode && cameracount == 0; // != 0;
244320 }
....@@ -259,9 +335,19 @@
259335 return lightCamera;
260336 }
261337
338
+ public Camera ManipCamera()
339
+ {
340
+ return manipCamera;
341
+ }
342
+
262343 public Camera RenderCamera()
263344 {
264345 return renderCamera;
346
+ }
347
+
348
+ public Camera[] Cameras()
349
+ {
350
+ return cameras;
265351 }
266352
267353 public void PushMaterial(Object3D obj, boolean selected)
....@@ -277,7 +363,7 @@
277363 cStatic.objectstack[materialdepth++] = obj;
278364 //System.out.println("material " + material);
279365 //Applet3D.tracein(this, selected);
280
- display.vector2buffer = obj.projectedVertices;
366
+ //display.vector2buffer = obj.projectedVertices;
281367 if (obj instanceof Camera)
282368 {
283369 display.options1[0] = material.shift;
....@@ -286,14 +372,28 @@
286372 display.options1[2] = material.shadowbias;
287373 display.options1[3] = material.aniso;
288374 display.options1[4] = material.anisoV;
375
+// System.out.println("display.options1[0] " + display.options1[0]);
376
+// System.out.println("display.options1[1] " + display.options1[1]);
377
+// System.out.println("display.options1[2] " + display.options1[2]);
378
+// System.out.println("display.options1[3] " + display.options1[3]);
379
+// System.out.println("display.options1[4] " + display.options1[4]);
289380 display.options2[0] = material.opacity;
290381 display.options2[1] = material.diffuse;
291382 display.options2[2] = material.factor;
383
+// System.out.println("display.options2[0] " + display.options2[0]);
384
+// System.out.println("display.options2[1] " + display.options2[1]);
385
+// System.out.println("display.options2[2] " + display.options2[2]);
292386
293387 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
388
+// System.out.println("display.options3[0] " + display.options3[0]);
389
+// System.out.println("display.options3[1] " + display.options3[1]);
390
+// System.out.println("display.options3[2] " + display.options3[2]);
294391 display.options4[0] = material.cameralight/0.2f;
295392 display.options4[1] = material.subsurface;
296393 display.options4[2] = material.sheen;
394
+// System.out.println("display.options4[0] " + display.options4[0]);
395
+// System.out.println("display.options4[1] " + display.options4[1]);
396
+// System.out.println("display.options4[2] " + display.options4[2]);
297397
298398 // if (display.CURRENTANTIALIAS > 0)
299399 // display.options3[3] /= 4;
....@@ -309,7 +409,7 @@
309409 /**/
310410 } else
311411 {
312
- DrawMaterial(material, selected);
412
+ DrawMaterial(material, selected, obj.projectedVertices);
313413 }
314414 } else
315415 {
....@@ -333,8 +433,8 @@
333433 cStatic.objectstack[materialdepth++] = obj;
334434 //System.out.println("material " + material);
335435 //Applet3D.tracein("selected ", selected);
336
- display.vector2buffer = obj.projectedVertices;
337
- display.DrawMaterial(material, selected);
436
+ //display.vector2buffer = obj.projectedVertices;
437
+ display.DrawMaterial(material, selected, obj.projectedVertices);
338438 }
339439 }
340440
....@@ -351,8 +451,8 @@
351451 materialdepth -= 1;
352452 if (materialdepth > 0)
353453 {
354
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
355
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
454
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
455
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
356456 }
357457 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
358458 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -372,8 +472,8 @@
372472 materialdepth -= 1;
373473 if (materialdepth > 0)
374474 {
375
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
376
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
475
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
476
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
377477 }
378478 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
379479 //else
....@@ -408,16 +508,18 @@
408508
409509 javax.media.opengl.GL gl = display.GetGL();
410510
411
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
511
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
412512
413513 //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
414514 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
415515 {
416516 //gl.glBegin(gl.GL_TRIANGLES);
417
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
517
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
518
+ // TEST LIVE NORMALS && !obj.dontselect
519
+ ;
418520 if (!hasnorm)
419521 {
420
- // System.out.println("FUCK!!");
522
+ // System.out.println("Mesh normal");
421523 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
422524 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
423525 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -760,7 +862,627 @@
760862 //// tris.postdraw(this);
761863 }
762864
865
+ static Camera localcamera = new Camera();
866
+ static cVector from = new cVector();
867
+ static cVector to = new cVector();
868
+
869
+ public void PrepOcclusion(BoundaryRep br, double[][] transform)
870
+ {
871
+ CameraPane cp = this;
872
+
873
+ Camera keep = cp.RenderCamera();
874
+ cp.renderCamera = localcamera;
875
+
876
+ if (br.trimmed)
877
+ {
878
+ float[] colors = new float[br.positions.length / 3];
879
+
880
+ int i3 = 0;
881
+ for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
882
+ {
883
+ if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
884
+ continue;
885
+
886
+ from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
887
+ to.set(br.positions[i3] + br.normals[i3],
888
+ br.positions[i3 + 1] + br.normals[i3 + 1],
889
+ br.positions[i3 + 2] + br.normals[i3 + 2]);
890
+ LA.xformPos(from, transform, from);
891
+ LA.xformPos(to, transform, to); // RIGID ONLY
892
+ localcamera.setAim(from, to);
893
+
894
+ CameraPane.occlusionbuffer.display();
895
+
896
+ if (CameraPane.DEBUG_OCCLUSION)
897
+ cp.display(); // debug
898
+
899
+ colors[i] = cp.vertexOcclusion.r;
900
+ //colors[i3 + 1] = cp.vertexOcclusion.g;
901
+ //colors[i3 + 2] = cp.vertexOcclusion.b;
902
+
903
+ if ((i % 100) == 0 && i != 0)
904
+ {
905
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
906
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
907
+ System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
908
+ }
909
+ }
910
+
911
+ br.colors = colors;
912
+ }
913
+ else
914
+ {
915
+ for (int i = 0; i < br.VertexCount(); i++)
916
+ {
917
+ Vertex v = br.GetVertex(i);
918
+
919
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
920
+ continue;
921
+
922
+ from.set(v.x, v.y, v.z);
923
+ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
924
+ LA.xformPos(from, transform, from);
925
+ LA.xformPos(to, transform, to); // RIGID ONLY
926
+ localcamera.setAim(from, to);
927
+
928
+ CameraPane.occlusionbuffer.display();
929
+
930
+ if (CameraPane.DEBUG_OCCLUSION)
931
+ cp.display(); // debug
932
+
933
+ v.AO = cp.vertexOcclusion.r;
934
+
935
+ if ((i % 100) == 0 && i != 0)
936
+ {
937
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
938
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
939
+ System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
940
+ }
941
+ }
942
+ }
943
+
944
+ //System.out.println("done.");
945
+
946
+ cp.renderCamera = keep;
947
+ }
948
+
949
+ void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
950
+ {
951
+ CameraPane display = this;
952
+ pointFlow.CreateHT();
953
+
954
+ float r = display.modelParams0[0];
955
+ float g = display.modelParams0[1];
956
+ float b = display.modelParams0[2];
957
+ float opacity = display.modelParams5[1];
958
+
959
+ //final GL gl = GLU.getCurrentGL();
960
+ GL gl = display.GetGL(); // getGL();
961
+
962
+ int s = pointFlow.points.size();
963
+
964
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
965
+ gl.glEnable(gl.GL_CULL_FACE);
966
+
967
+ for (int i=s; --i>=0;)
968
+ //for (int i=0; i<s; i++)
969
+ {
970
+ cVector v = pointFlow.points.get(i);
971
+
972
+ double mindist = Double.MAX_VALUE;
973
+
974
+ double size = pointFlow.minimumSize;
975
+
976
+ double distancenext = 0;
977
+
978
+ if (i > 0)
979
+ {
980
+ cVector w = pointFlow.points.get(i-1);
981
+
982
+ double dist = w.distance(v);
983
+
984
+ distancenext = dist;
985
+
986
+ if (mindist > dist)
987
+ {
988
+ mindist = dist;
989
+ size = mindist*pointFlow.resizefactor;
990
+ }
991
+ }
992
+
993
+ if (i < s-1)
994
+ {
995
+ cVector w = pointFlow.points.get(i+1);
996
+
997
+ double dist = w.distance(v);
998
+
999
+ if (mindist > dist)
1000
+ {
1001
+ mindist = dist;
1002
+ size = mindist*pointFlow.resizefactor;
1003
+ }
1004
+ }
1005
+
1006
+ if (size < pointFlow.minimumSize)
1007
+ size = pointFlow.minimumSize;
1008
+ if (size > pointFlow.maximumSize)
1009
+ size = pointFlow.maximumSize;
1010
+
1011
+ double tx = v.x;
1012
+ double ty = v.y;
1013
+ double tz = v.z;
1014
+
1015
+ // if (tx == 0 && ty == 0 && tz == 0)
1016
+ // continue;
1017
+
1018
+ gl.glMatrixMode(gl.GL_TEXTURE);
1019
+ gl.glPushMatrix();
1020
+ pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
1021
+
1022
+ gl.glMultMatrixf(pointFlow.texmat, 0);
1023
+
1024
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1025
+ gl.glPushMatrix();
1026
+
1027
+ gl.glTranslated(tx,ty,tz);
1028
+
1029
+ gl.glScaled(size,size,size);
1030
+
1031
+// float cr = colorBuf.get(index4);
1032
+// float cg = colorBuf.get(index4+1);
1033
+// float cb = colorBuf.get(index4+2);
1034
+// float ca = colorBuf.get(index4+3);
1035
+//
1036
+// display.modelParams0[0] = r * cr;
1037
+// display.modelParams0[1] = g * cg;
1038
+// display.modelParams0[2] = b * cb;
1039
+//
1040
+// display.modelParams5[1] = opacity * ca;
1041
+//
1042
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1043
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1044
+//
1045
+// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
1046
+// RandomNode.globalseed2 = RandomNode.globalseed;
1047
+//
1048
+//// gl.glColor4f(cr,cg,cb,ca);
1049
+// // gl.glScalef(1024/16,1024/16,1024/16);
1050
+ pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
1051
+
1052
+ gl.glPopMatrix();
1053
+
1054
+ double step = size/4; //
1055
+
1056
+ if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
1057
+ continue;
1058
+
1059
+ int nbsteps = (int)(distancenext/step);
1060
+
1061
+ step = distancenext/nbsteps;
1062
+
1063
+ cVector next = pointFlow.points.get(i-1);
1064
+
1065
+ tmp.set(next);
1066
+ tmp.sub(v);
1067
+ tmp.normalize();
1068
+ tmp.mul(step);
1069
+
1070
+ // calculate next size
1071
+ mindist = Double.MAX_VALUE;
1072
+
1073
+ double nextsize = pointFlow.minimumSize;
1074
+
1075
+ if (i > 1)
1076
+ {
1077
+ cVector w = pointFlow.points.get(i-2);
1078
+
1079
+ double dist = w.distance(next);
1080
+
1081
+ if (mindist > dist)
1082
+ {
1083
+ mindist = dist;
1084
+ nextsize = mindist*pointFlow.resizefactor;
1085
+ }
1086
+ }
1087
+
1088
+ double dist = v.distance(next);
1089
+
1090
+ if (mindist > dist)
1091
+ {
1092
+ mindist = dist;
1093
+ nextsize = mindist*pointFlow.resizefactor;
1094
+ }
1095
+
1096
+ if (nextsize < pointFlow.minimumSize)
1097
+ nextsize = pointFlow.minimumSize;
1098
+ if (nextsize > pointFlow.maximumSize)
1099
+ nextsize = pointFlow.maximumSize;
1100
+ //
1101
+
1102
+ double count = 0;
1103
+
1104
+ while (distancenext > 0.000000001) // step
1105
+ {
1106
+ gl.glPushMatrix();
1107
+
1108
+ gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
1109
+
1110
+ double K = count/nbsteps;
1111
+
1112
+ double intersize = K*nextsize + (1-K)*size;
1113
+
1114
+ gl.glScaled(intersize,intersize,intersize);
1115
+
1116
+ pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
1117
+
1118
+ count++;
1119
+
1120
+ distancenext -= step;
1121
+
1122
+ gl.glPopMatrix();
1123
+ }
1124
+
1125
+ if (count != nbsteps)
1126
+ assert(count == nbsteps);
1127
+
1128
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
1129
+ //gl.glTranslatef(-tx,-ty,-tz);
1130
+
1131
+ gl.glMatrixMode(gl.GL_TEXTURE);
1132
+ gl.glPopMatrix();
1133
+ }
1134
+
1135
+ if (!cf)
1136
+ gl.glDisable(gl.GL_CULL_FACE);
1137
+
1138
+// display.modelParams0[0] = r;
1139
+// display.modelParams0[1] = g;
1140
+// display.modelParams0[2] = b;
1141
+//
1142
+// display.modelParams5[1] = opacity;
1143
+//
1144
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1145
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1146
+
1147
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1148
+ }
1149
+
1150
+ public void DrawBox(cVector min, cVector max)
1151
+ {
1152
+ javax.media.opengl.GL gl = GetGL();
1153
+ gl.glBegin(gl.GL_LINES);
1154
+
1155
+ gl.glVertex3d(min.x, min.y, min.z);
1156
+ gl.glVertex3d(min.x, min.y, max.z);
1157
+ gl.glVertex3d(min.x, min.y, min.z);
1158
+ gl.glVertex3d(min.x, max.y, min.z);
1159
+ gl.glVertex3d(min.x, min.y, min.z);
1160
+ gl.glVertex3d(max.x, min.y, min.z);
1161
+
1162
+ gl.glVertex3d(max.x, max.y, max.z);
1163
+ gl.glVertex3d(min.x, max.y, max.z);
1164
+ gl.glVertex3d(max.x, max.y, max.z);
1165
+ gl.glVertex3d(max.x, min.y, max.z);
1166
+ gl.glVertex3d(max.x, max.y, max.z);
1167
+ gl.glVertex3d(max.x, max.y, min.z);
1168
+
1169
+ gl.glEnd();
1170
+ }
1171
+
1172
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1173
+ {
1174
+ int[] strips = bRep.getRawIndices();
1175
+
1176
+ javax.media.opengl.GL gl = GetGL();
1177
+
1178
+ // TRIANGLE STRIP ARRAY
1179
+ if (bRep.trimmed)
1180
+ {
1181
+ float[] v = bRep.getRawVertices();
1182
+ float[] n = bRep.getRawNormals();
1183
+ float[] c = bRep.getRawColors();
1184
+ float[] uv = bRep.getRawUVMap();
1185
+
1186
+ int count2 = 0;
1187
+ int count3 = 0;
1188
+
1189
+ if (n.length > 0)
1190
+ {
1191
+ for (int i = 0; i < strips.length; i++)
1192
+ {
1193
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1194
+
1195
+ /*
1196
+ boolean locked = false;
1197
+ float eps = 0.1f;
1198
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1199
+
1200
+ int dot = 0;
1201
+
1202
+ if ((dot&1) == 0)
1203
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1204
+
1205
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1206
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1207
+ else
1208
+ {
1209
+ locked = true;
1210
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1211
+ }
1212
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1213
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1214
+ if (hasnorm)
1215
+ {
1216
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1217
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1218
+ }
1219
+
1220
+ if ((dot&4) == 0)
1221
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1222
+
1223
+ if (wrap || !locked && (dot&8) != 0)
1224
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1225
+ else
1226
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1227
+
1228
+ f.dot = dot;
1229
+ */
1230
+
1231
+ if (!selectmode)
1232
+ {
1233
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1234
+ {
1235
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1236
+ } else
1237
+ {
1238
+ gl.glNormal3f(0, 0, 1);
1239
+ }
1240
+
1241
+ if (c != null)
1242
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1243
+ {
1244
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1245
+ }
1246
+ }
1247
+
1248
+ if (flipV)
1249
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1250
+ else
1251
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1252
+
1253
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1254
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1255
+
1256
+ count2 += 2;
1257
+ count3 += 3;
1258
+ if (!selectmode)
1259
+ {
1260
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1261
+ {
1262
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1263
+ } else
1264
+ {
1265
+ gl.glNormal3f(0, 0, 1);
1266
+ }
1267
+ if (c != null)
1268
+ {
1269
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1270
+ }
1271
+ }
1272
+
1273
+ if (flipV)
1274
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1275
+ else
1276
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1277
+
1278
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1279
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1280
+
1281
+ count2 += 2;
1282
+ count3 += 3;
1283
+ for (int j = 0; j < strips[i] - 2; j++)
1284
+ {
1285
+ //gl.glTexCoord2d(...);
1286
+ if (!selectmode)
1287
+ {
1288
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1289
+ {
1290
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1291
+ } else
1292
+ {
1293
+ gl.glNormal3f(0, 0, 1);
1294
+ }
1295
+ if (c != null)
1296
+ {
1297
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1298
+ }
1299
+ }
1300
+
1301
+ if (flipV)
1302
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1303
+ else
1304
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1305
+
1306
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1307
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1308
+
1309
+ count2 += 2;
1310
+ count3 += 3;
1311
+ }
1312
+
1313
+ gl.glEnd();
1314
+ }
1315
+ }
1316
+
1317
+ assert count3 == v.length;
1318
+ }
1319
+ else // !trimmed
1320
+ {
1321
+ int count = 0;
1322
+ for (int i = 0; i < strips.length; i++)
1323
+ {
1324
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1325
+
1326
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1327
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1328
+
1329
+ drawVertex(gl, p, flipV, selectmode);
1330
+ drawVertex(gl, q, flipV, selectmode);
1331
+
1332
+ for (int j = 0; j < strips[i] - 2; j++)
1333
+ {
1334
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1335
+
1336
+ // if (j%2 == 0)
1337
+ // drawFace(p, q, r, display, null);
1338
+ // else
1339
+ // drawFace(p, r, q, display, null);
1340
+
1341
+ // p = q;
1342
+ // q = r;
1343
+ drawVertex(gl, r, flipV, selectmode);
1344
+ }
1345
+
1346
+ gl.glEnd();
1347
+ }
1348
+ }
1349
+ }
1350
+
1351
+ static cSpring.Point3D temp = new cSpring.Point3D();
1352
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1353
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1354
+
1355
+ public void DrawDynamicMesh(cMesh mesh)
1356
+ {
1357
+ GL gl = GetGL(); // getGL();
1358
+
1359
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1360
+
1361
+ gl.glDisable(gl.GL_LIGHTING);
1362
+
1363
+ gl.glLineWidth(1);
1364
+ gl.glColor3f(1,1,1);
1365
+ gl.glBegin(gl.GL_LINES);
1366
+ double scale = 0;
1367
+ int count = 0;
1368
+ for (int s=0; s<Phys.allSprings.size(); s++)
1369
+ {
1370
+ cSpring.Spring spring = Phys.allSprings.get(s);
1371
+ if(s == 0)
1372
+ {
1373
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1374
+ }
1375
+ if (mesh.showsprings)
1376
+ {
1377
+ temp.set(spring.a.position);
1378
+ temp.add(spring.b.position);
1379
+ temp.mul(0.5);
1380
+ temp2.set(spring.a.position);
1381
+ temp2.sub(spring.b.position);
1382
+ temp2.mul(spring.restLength/2);
1383
+ temp.sub(temp2);
1384
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1385
+ temp.add(temp2);
1386
+ temp.add(temp2);
1387
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1388
+ }
1389
+
1390
+ if (spring.isHandle)
1391
+ continue;
1392
+
1393
+ //if (scale < spring.restLength)
1394
+ scale += spring.restLength;
1395
+ count++;
1396
+ }
1397
+ gl.glEnd();
1398
+
1399
+ if (count == 0)
1400
+ scale = 0.01;
1401
+ else
1402
+ scale /= count * 3;
1403
+
1404
+ //scale = 0.25;
1405
+
1406
+ if (mesh.ShowInfo())
1407
+ {
1408
+ gl.glLineWidth(4);
1409
+ for (int s=0; s<Phys.allNodes.size(); s++)
1410
+ {
1411
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1412
+ if (node.mass == 0)
1413
+ continue;
1414
+
1415
+ int i = node.springs==null?-1:node.springs.size();
1416
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1417
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1418
+ //temp.normalize();
1419
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1420
+ gl.glBegin(gl.GL_LINES);
1421
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1422
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1423
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1424
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1425
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1426
+ gl.glEnd();
1427
+ }
1428
+
1429
+ gl.glLineWidth(8);
1430
+ for (int s=0; s<Phys.allNodes.size(); s++)
1431
+ {
1432
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1433
+
1434
+ if (node.springs != null)
1435
+ {
1436
+ for (int i=0; i<node.springs.size(); i+=1)
1437
+ {
1438
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1439
+
1440
+ int c = i+1;
1441
+ // c = node.springs.get(i).nbcopies;
1442
+
1443
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1444
+ gl.glBegin(gl.GL_LINES);
1445
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1446
+ 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);
1447
+ gl.glEnd();
1448
+ }
1449
+ }
1450
+ }
1451
+
1452
+ gl.glLineWidth(1);
1453
+ }
1454
+
1455
+ gl.glEnable(gl.GL_LIGHTING);
1456
+ }
1457
+
7631458 /// INTERFACE
1459
+
1460
+ public void StartTriangles()
1461
+ {
1462
+ javax.media.opengl.GL gl = GetGL();
1463
+ gl.glBegin(gl.GL_TRIANGLES);
1464
+ }
1465
+
1466
+ public void EndTriangles()
1467
+ {
1468
+ GetGL().glEnd();
1469
+ }
1470
+
1471
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1472
+ {
1473
+ if (!selectmode)
1474
+ {
1475
+ gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1476
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1477
+
1478
+ if (flipV)
1479
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1480
+ else
1481
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1482
+ }
1483
+
1484
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1485
+ }
7641486
7651487 void SetColor(Object3D obj, Vertex p0)
7661488 {
....@@ -939,7 +1661,7 @@
9391661 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
9401662 }
9411663
942
- void DrawMaterial(cMaterial material, boolean selected)
1664
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
9431665 {
9441666 CameraPane display = this;
9451667 //new Exception().printStackTrace();
....@@ -955,18 +1677,18 @@
9551677 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
9561678 if (!material.multiply)
9571679 {
958
- display.color = color;
1680
+ display.color = material.color;
9591681 display.saturation = material.modulation;
9601682 }
9611683 else
9621684 {
963
- display.color *= color*2;
1685
+ display.color *= material.color*2;
9641686 display.saturation *= material.modulation*2;
9651687 }
9661688
9671689 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
9681690
969
- float[] colorV = GrafreeD.colorV;
1691
+ float[] colorV = Grafreed.colorV;
9701692
9711693 /**/
9721694 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -974,7 +1696,7 @@
9741696 colorV[0] = display.modelParams0[0] * material.diffuse;
9751697 colorV[1] = display.modelParams0[1] * material.diffuse;
9761698 colorV[2] = display.modelParams0[2] * material.diffuse;
977
- colorV[3] = material.opacity;
1699
+ colorV[3] = 1; // material.opacity;
9781700
9791701 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
9801702 //System.out.println("Opacity = " + opacity);
....@@ -1082,9 +1804,9 @@
10821804 display.modelParams7[2] = 0;
10831805 display.modelParams7[3] = 0;
10841806
1085
- display.modelParams6[0] = 100; // criss de bug de bump
1807
+ //display.modelParams6[0] = 100; // criss de bug de bump
10861808
1087
- Object3D.cVector2[] extparams = display.vector2buffer;
1809
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
10881810 if (extparams != null && extparams.length > 0 && extparams[0] != null)
10891811 {
10901812 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1226,7 +1948,7 @@
12261948 void PushMatrix(double[][] matrix)
12271949 {
12281950 // GrafreeD.tracein(matrix);
1229
- PushMatrix(matrix,1);
1951
+ PushMatrix(matrix, 1);
12301952 }
12311953
12321954 void PushMatrix()
....@@ -1323,7 +2045,7 @@
13232045
13242046 static int camerachangeframe;
13252047
1326
- boolean SetCamera(Camera cam)
2048
+ public boolean SetCamera(Camera cam)
13272049 {
13282050 // may 2014 if (cam == cameras[0] || cam == cameras[1])
13292051 // return false;
....@@ -1380,7 +2102,7 @@
13802102 //System.err.println("Oeil on");
13812103 OEIL = true;
13822104 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
1383
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2105
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13842106 //pingthread.StepToTarget(true);
13852107 }
13862108
....@@ -1451,33 +2173,6 @@
14512173 mainDL ^= true;
14522174 }
14532175
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
-
14812176 void ToggleFullScreen()
14822177 {
14832178 FULLSCREEN ^= true;
....@@ -1488,72 +2183,94 @@
14882183 Globals.CROWD ^= true;
14892184 }
14902185
1491
- void ToggleInertia()
1492
- {
1493
- INERTIA ^= true;
1494
- }
1495
-
14962186 void ToggleLocal()
14972187 {
14982188 LOCALTRANSFORM ^= true;
14992189 }
15002190
1501
- void ToggleFast()
2191
+ public void ToggleTexture()
2192
+ {
2193
+ textureon ^= true;
2194
+ }
2195
+
2196
+ public void ToggleLive()
2197
+ {
2198
+ Globals.setLIVE(Globals.isLIVE() ^ true);
2199
+
2200
+ System.err.println("LIVE = " + Globals.isLIVE());
2201
+
2202
+ if (!Globals.isLIVE()) // save sound
2203
+ Grafreed.savesound = true; // wav.save();
2204
+ // else
2205
+ repaint(); // start loop // may 2013
2206
+ }
2207
+
2208
+ public void ToggleSupport()
2209
+ {
2210
+ SUPPORT ^= true;
2211
+ }
2212
+
2213
+ public void ToggleAbort()
2214
+ {
2215
+ ABORTMODE ^= true;
2216
+ }
2217
+
2218
+ public void ToggleInertia()
2219
+ {
2220
+ INERTIA ^= true;
2221
+ }
2222
+
2223
+ public void ToggleFast()
15022224 {
15032225 FAST ^= true;
15042226 }
15052227
1506
- void ToggleSlowPose()
2228
+ public void ToggleSlowPose()
15072229 {
15082230 SLOWPOSE ^= true;
15092231 }
15102232
1511
- void ToggleFootContact()
1512
- {
1513
- FOOTCONTACT ^= true;
1514
- }
1515
-
1516
- void ToggleBoxMode()
2233
+ public void ToggleBoxMode()
15172234 {
15182235 BOXMODE ^= true;
15192236 }
15202237
1521
- void ToggleSmoothFocus()
2238
+ public void ToggleZoomBoxMode()
2239
+ {
2240
+ ZOOMBOXMODE ^= true;
2241
+ }
2242
+
2243
+ public void ToggleSmoothFocus()
15222244 {
15232245 SMOOTHFOCUS ^= true;
15242246 }
15252247
1526
- void ToggleImageFlip()
2248
+ public void ToggleImageFlip()
15272249 {
15282250 IMAGEFLIP ^= true;
15292251 }
15302252
1531
- void ToggleSpeakerMocap()
2253
+ public void ToggleSpeakerMocap()
15322254 {
15332255 SPEAKERMOCAP ^= true;
15342256 }
15352257
1536
- void ToggleSpeakerCamera()
2258
+ public void ToggleSpeakerCamera()
15372259 {
15382260 SPEAKERCAMERA ^= true;
15392261 }
15402262
1541
- void ToggleSpeakerFocus()
2263
+ public void ToggleSpeakerFocus()
15422264 {
15432265 SPEAKERFOCUS ^= true;
15442266 }
15452267
1546
- void ToggleDebug()
1547
- {
1548
- DEBUG ^= true;
1549
- }
1550
-
1551
- void ToggleFrustum()
2268
+ public void ToggleFrustum()
15522269 {
15532270 FRUSTUM ^= true;
15542271 }
15552272
1556
- void ToggleTrack()
2273
+ public void ToggleTrack()
15572274 {
15582275 TRACK ^= true;
15592276 if (TRACK)
....@@ -1572,25 +2289,35 @@
15722289 repaint();
15732290 }
15742291
1575
- void ToggleTrackOnce()
2292
+ public void ToggleTrackOnce()
15762293 {
15772294 TRACKONCE ^= true;
15782295 }
15792296
1580
- void ToggleShadowTrack()
2297
+ public void ToggleShadowTrack()
15812298 {
15822299 SHADOWTRACK ^= true;
15832300 repaint();
15842301 }
15852302
1586
- void ToggleOeil()
2303
+ public void ToggleOeil()
15872304 {
15882305 OEIL ^= true;
15892306 }
15902307
1591
- void ToggleOeilOnce()
2308
+ public void ToggleOeilOnce()
15922309 {
15932310 OEILONCE ^= true;
2311
+ }
2312
+
2313
+ void ToggleFootContact()
2314
+ {
2315
+ FOOTCONTACT ^= true;
2316
+ }
2317
+
2318
+ void ToggleDebug()
2319
+ {
2320
+ Globals.DEBUG ^= true;
15942321 }
15952322
15962323 void ToggleLookAt()
....@@ -1598,9 +2325,9 @@
15982325 LOOKAT ^= true;
15992326 }
16002327
1601
- void ToggleRandom()
2328
+ void ToggleSwitch()
16022329 {
1603
- RANDOM ^= true;
2330
+ SWITCH ^= true;
16042331 }
16052332
16062333 void ToggleHandles()
....@@ -1608,10 +2335,17 @@
16082335 HANDLES ^= true;
16092336 }
16102337
2338
+ Object3D paintFolder;
2339
+
16112340 void TogglePaint()
16122341 {
16132342 PAINTMODE ^= true;
16142343 paintcount = 0;
2344
+
2345
+ if (PAINTMODE)
2346
+ {
2347
+ paintFolder = GetFolder();
2348
+ }
16152349 }
16162350
16172351 void SwapCamera(int a, int b)
....@@ -1707,7 +2441,22 @@
17072441 {
17082442 return currentGL;
17092443 }
1710
-
2444
+
2445
+ static private BufferedImage CreateBim(TextureData texturedata)
2446
+ {
2447
+ Grafreed.Assert(texturedata != null);
2448
+
2449
+ int width = texturedata.getWidth();
2450
+ int height = texturedata.getHeight();
2451
+
2452
+ Buffer buffer = texturedata.getBuffer();
2453
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2454
+
2455
+ byte[] bytes = bytebuf.array();
2456
+
2457
+ return CreateBim(bytes, width, height);
2458
+ }
2459
+
17112460 /**/
17122461 class CacheTexture
17132462 {
....@@ -1716,28 +2465,31 @@
17162465
17172466 int resolution;
17182467
1719
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2468
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
17202469 {
1721
- texture = tex;
2470
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2471
+ texturedata = texdata;
17222472 resolution = res;
17232473 }
17242474 }
17252475 /**/
17262476
17272477 // TEXTURE static Texture texture;
1728
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
1729
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
1730
- static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>();
2478
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2479
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2480
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2481
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2482
+
17312483 int pigmentdepth = 0;
17322484 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
17332485 int bumpdepth = 0;
17342486 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
17352487 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
17362488 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
1737
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2489
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
17382490 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
17392491
1740
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2492
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
17412493 {
17422494 TextureData texturedata = null;
17432495
....@@ -1756,13 +2508,34 @@
17562508 if (bump)
17572509 texturedata = ConvertBump(texturedata, false);
17582510
1759
- com.sun.opengl.util.texture.Texture texture =
1760
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2511
+// com.sun.opengl.util.texture.Texture texture =
2512
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
17612513
1762
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
1763
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2514
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2515
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
17642516
1765
- return texture;
2517
+ return texturedata;
2518
+ }
2519
+
2520
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2521
+ {
2522
+ TextureData texturedata = null;
2523
+
2524
+ try
2525
+ {
2526
+ texturedata =
2527
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2528
+ bim,
2529
+ true);
2530
+ } catch (Exception e)
2531
+ {
2532
+ throw new javax.media.opengl.GLException(e);
2533
+ }
2534
+
2535
+ if (bump)
2536
+ texturedata = ConvertBump(texturedata, false);
2537
+
2538
+ return texturedata;
17662539 }
17672540
17682541 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -2835,6 +3608,8 @@
28353608
28363609 System.out.println("LOADING TEXTURE : " + name);
28373610
3611
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3612
+
28383613 //
28393614 if (false) // compressbit > 0)
28403615 {
....@@ -3539,6 +4314,7 @@
35394314
35404315 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
35414316 {
4317
+ new Exception().printStackTrace();
35424318 System.exit(0);
35434319 com.sun.opengl.util.texture.Texture texture = null;
35444320
....@@ -7232,7 +8008,7 @@
72328008 String pigment = Object3D.GetPigment(tex);
72338009 String bump = Object3D.GetBump(tex);
72348010
7235
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8011
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
72368012 {
72378013 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
72388014 // System.out.println("; bump = " + bump);
....@@ -7247,11 +8023,69 @@
72478023 pigment = null;
72488024 }
72498025
7250
- ReleaseTexture(bump, true);
7251
- ReleaseTexture(pigment, false);
8026
+ ReleaseTexture(tex, true);
8027
+ ReleaseTexture(tex, false);
72528028 }
72538029
7254
- void ReleaseTexture(String tex, boolean bump)
8030
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
8031
+ {
8032
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8033
+ {
8034
+ return;
8035
+ }
8036
+
8037
+ if (tex == null)
8038
+ {
8039
+ ReleaseTexture(null, false);
8040
+ return;
8041
+ }
8042
+
8043
+ String pigment = Object3D.GetPigment(tex);
8044
+
8045
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8046
+ {
8047
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8048
+ // System.out.println("; bump = " + bump);
8049
+ }
8050
+
8051
+ if (pigment.equals(""))
8052
+ {
8053
+ pigment = null;
8054
+ }
8055
+
8056
+ ReleaseTexture(tex, false);
8057
+ }
8058
+
8059
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8060
+ {
8061
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8062
+ {
8063
+ return;
8064
+ }
8065
+
8066
+ if (tex == null)
8067
+ {
8068
+ ReleaseTexture(null, true);
8069
+ return;
8070
+ }
8071
+
8072
+ String bump = Object3D.GetBump(tex);
8073
+
8074
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8075
+ {
8076
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8077
+ // System.out.println("; bump = " + bump);
8078
+ }
8079
+
8080
+ if (bump.equals(""))
8081
+ {
8082
+ bump = null;
8083
+ }
8084
+
8085
+ ReleaseTexture(tex, true);
8086
+ }
8087
+
8088
+ void ReleaseTexture(cTexture tex, boolean bump)
72558089 {
72568090 if (// DrawMode() != 0 || /*tex == null ||*/
72578091 ambientOcclusion ) // || !textureon)
....@@ -7262,7 +8096,7 @@
72628096 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
72638097
72648098 if (tex != null)
7265
- texture = textures.get(tex);
8099
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
72668100
72678101 // //assert( texture != null );
72688102 // if (texture == null)
....@@ -7354,7 +8188,55 @@
73548188 }
73558189 }
73568190
7357
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8191
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
8192
+ {
8193
+// if (// DrawMode() != 0 || /*tex == null ||*/
8194
+// ambientOcclusion ) // || !textureon)
8195
+// {
8196
+// return; // false;
8197
+// }
8198
+//
8199
+// if (tex == null)
8200
+// {
8201
+// BindTexture(null,false,resolution);
8202
+// BindTexture(null,true,resolution);
8203
+// return;
8204
+// }
8205
+//
8206
+// String pigment = Object3D.GetPigment(tex);
8207
+// String bump = Object3D.GetBump(tex);
8208
+//
8209
+// usedtextures.add(pigment);
8210
+// usedtextures.add(bump);
8211
+//
8212
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8213
+// {
8214
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8215
+// // System.out.println("; bump = " + bump);
8216
+// }
8217
+//
8218
+// if (bump.equals(""))
8219
+// {
8220
+// bump = null;
8221
+// }
8222
+// if (pigment.equals(""))
8223
+// {
8224
+// pigment = null;
8225
+// }
8226
+//
8227
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8228
+// BindTexture(pigment, false, resolution);
8229
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8230
+// BindTexture(bump, true, resolution);
8231
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8232
+//
8233
+// return; // true;
8234
+
8235
+ BindPigmentTexture(tex, resolution);
8236
+ BindBumpTexture(tex, resolution);
8237
+ }
8238
+
8239
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
73588240 {
73598241 if (// DrawMode() != 0 || /*tex == null ||*/
73608242 ambientOcclusion ) // || !textureon)
....@@ -7365,17 +8247,47 @@
73658247 if (tex == null)
73668248 {
73678249 BindTexture(null,false,resolution);
7368
- BindTexture(null,true,resolution);
73698250 return;
73708251 }
73718252
73728253 String pigment = Object3D.GetPigment(tex);
8254
+
8255
+ usedtextures.add(tex);
8256
+
8257
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8258
+ {
8259
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8260
+ // System.out.println("; bump = " + bump);
8261
+ }
8262
+
8263
+ if (pigment.equals(""))
8264
+ {
8265
+ pigment = null;
8266
+ }
8267
+
8268
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8269
+ BindTexture(tex, false, resolution);
8270
+ }
8271
+
8272
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8273
+ {
8274
+ if (// DrawMode() != 0 || /*tex == null ||*/
8275
+ ambientOcclusion ) // || !textureon)
8276
+ {
8277
+ return; // false;
8278
+ }
8279
+
8280
+ if (tex == null)
8281
+ {
8282
+ BindTexture(null,true,resolution);
8283
+ return;
8284
+ }
8285
+
73738286 String bump = Object3D.GetBump(tex);
73748287
7375
- usedtextures.put(pigment, pigment);
7376
- usedtextures.put(bump, bump);
8288
+ usedtextures.add(tex);
73778289
7378
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8290
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
73798291 {
73808292 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
73818293 // System.out.println("; bump = " + bump);
....@@ -7385,43 +8297,94 @@
73858297 {
73868298 bump = null;
73878299 }
7388
- if (pigment.equals(""))
7389
- {
7390
- pigment = null;
7391
- }
73928300
7393
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
7394
- BindTexture(pigment, false, resolution);
73958301 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
7396
- BindTexture(bump, true, resolution);
8302
+ BindTexture(tex, true, resolution);
73978303 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
7398
-
7399
- return; // true;
74008304 }
74018305
7402
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8306
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8307
+
8308
+ private boolean FileExists(String tex)
74038309 {
7404
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8310
+ if (missingTextures.contains(tex))
8311
+ {
8312
+ return false;
8313
+ }
8314
+
8315
+ boolean fileExists = new File(tex).exists();
8316
+
8317
+ if (!fileExists)
8318
+ {
8319
+ // If file exists, the "new File()" is not executed sgain
8320
+ missingTextures.add(tex);
8321
+ }
8322
+
8323
+ return fileExists;
8324
+ }
8325
+
8326
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
8327
+ {
8328
+ CacheTexture texturecache = null;
74058329
74068330 if (tex != null)
74078331 {
7408
- String texname = tex;
8332
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8333
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
74098334
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;
8335
+ if (texname.equals("") && texdata == null)
8336
+ {
8337
+ return null;
8338
+ }
8339
+
8340
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8341
+
8342
+// String[] split = tex.split("Textures");
8343
+// if (split.length > 1)
8344
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8345
+// else
8346
+// if (!texname.startsWith("/"))
8347
+// texname = "/Users/nbriere/Textures/" + texname;
8348
+ if (!FileExists(texname))
8349
+ {
8350
+ texname = fallbackTextureName;
8351
+ }
74168352
74178353 if (CACHETEXTURE)
7418
- texture = textures.get(texname); // TEXTURE CACHE
7419
-
7420
- TextureData texturedata = null;
7421
-
7422
- if (texture == null || texture.resolution < resolution)
74238354 {
7424
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8355
+ if (texdata == null)
8356
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8357
+ else
8358
+ texturecache = bimtextures.get(texdata);
8359
+ }
8360
+
8361
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8362
+ {
8363
+ TextureData texturedata = null;
8364
+
8365
+ if (texdata != null && textureon)
8366
+ {
8367
+ BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8368
+
8369
+ try
8370
+ {
8371
+ bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8372
+ }
8373
+ catch (Exception e)
8374
+ {
8375
+ bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8376
+ }
8377
+
8378
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8379
+ bimtextures.put(texdata, texturecache);
8380
+
8381
+ //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8382
+
8383
+ //Object bim2 = CreateBim(texturecache.texturedata);
8384
+ //bim2 = bim;
8385
+ }
8386
+ else
8387
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
74258388 {
74268389 assert(!bump);
74278390 // if (bump)
....@@ -7432,19 +8395,23 @@
74328395 // }
74338396 // else
74348397 // {
7435
- texture = textures.get(tex);
7436
- if (texture == null)
8398
+ // texturecache = textures.get(texname); // suspicious
8399
+ if (texturecache == null)
74378400 {
7438
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8401
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
74398402 }
8403
+ else
8404
+ new Exception().printStackTrace();
74408405 // }
74418406 } else
7442
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8407
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
74438408 {
74448409 assert(bump);
7445
- texture = textures.get(tex);
7446
- if (texture == null)
7447
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8410
+ // texturecache = textures.get(texname); // suspicious
8411
+ if (texturecache == null)
8412
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8413
+ else
8414
+ new Exception().printStackTrace();
74488415 } else
74498416 {
74508417 //if (tex.equals("IMMORTAL"))
....@@ -7452,11 +8419,13 @@
74528419 // texture = GetResourceTexture("default.png");
74538420 //} else
74548421 //{
7455
- if (tex.equals("WHITE_NOISE"))
8422
+ if (texname.endsWith("WHITE_NOISE"))
74568423 {
7457
- texture = textures.get(tex);
7458
- if (texture == null)
7459
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8424
+ // texturecache = textures.get(texname); // suspicious
8425
+ if (texturecache == null)
8426
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8427
+ else
8428
+ new Exception().printStackTrace();
74608429 } else
74618430 {
74628431 if (textureon)
....@@ -7481,7 +8450,7 @@
74818450 }
74828451
74838452 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
7484
- if (!new File(cachename).exists())
8453
+ if (!FileExists(cachename))
74858454 cachename = texname;
74868455 else
74878456 processbump = false; // don't process bump map again
....@@ -7503,7 +8472,7 @@
75038472 }
75048473
75058474 cachename = texname.substring(0, texname.length()-4)+ext+".png";
7506
- if (!new File(cachename).exists())
8475
+ if (!FileExists(cachename))
75078476 cachename = texname;
75088477 else
75098478 processbump = false; // don't process bump map again
....@@ -7512,20 +8481,22 @@
75128481 texturedata = GetFileTexture(cachename, processbump, resolution);
75138482
75148483
7515
- if (texturedata != null)
7516
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8484
+ if (texturedata == null)
8485
+ throw new Exception();
8486
+
8487
+ texturecache = new CacheTexture(texturedata,resolution);
75178488 //texture = GetTexture(tex, bump);
75188489 }
75198490 }
75208491 //}
75218492 }
75228493
7523
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8494
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
75248495 {
75258496 //return false;
75268497
75278498 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
7528
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8499
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
75298500 {
75308501 // String ext = "_highres";
75318502 // if (REDUCETEXTURE)
....@@ -7542,52 +8513,17 @@
75428513 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
75438514 if (!cachefile.exists())
75448515 {
7545
- // cache to disk
7546
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
7547
- //buffers[0].
7548
-
7549
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
7550
- int[] pixels = new int[bytebuf.capacity()/3];
7551
-
7552
- // squared size heuristic...
7553
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8516
+ //if (texturedata.getWidth() == texturedata.getHeight())
75548517 {
7555
- for (int i=pixels.length; --i>=0;)
7556
- {
7557
- int i3 = i*3;
7558
- pixels[i] = 0xFF;
7559
- pixels[i] <<= 8;
7560
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
7561
- pixels[i] <<= 8;
7562
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
7563
- pixels[i] <<= 8;
7564
- pixels[i] |= bytebuf.get(i3) & 0xFF;
7565
- }
7566
-
7567
- /*
7568
- int r=0,g=0,b=0,a=0;
7569
- for (int i=0; i<width; i++)
7570
- for (int j=0; j<height; j++)
7571
- {
7572
- int index = j*width+i;
7573
- int p = pixels[index];
7574
- a = ((p>>24) & 0xFF);
7575
- r = ((p>>16) & 0xFF);
7576
- g = ((p>>8) & 0xFF);
7577
- b = (p & 0xFF);
7578
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
7579
- }
7580
- /**/
7581
- int width = (int)Math.sqrt(pixels.length); // squared
7582
- int height = width;
7583
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
7584
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8518
+ BufferedImage rendImage = CreateBim(texturedata);
8519
+
75858520 ImageWriter writer = null;
75868521 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
75878522 if (iter.hasNext()) {
75888523 writer = (ImageWriter)iter.next();
75898524 }
7590
- float compressionQuality = 0.9f;
8525
+
8526
+ float compressionQuality = 0.85f;
75918527 try
75928528 {
75938529 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -7604,18 +8540,20 @@
76048540 }
76058541 }
76068542 }
7607
-
8543
+
8544
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8545
+
76088546 //System.out.println("Texture = " + tex);
7609
- if (textures.containsKey(texname))
8547
+ if (textures.containsKey(tex))
76108548 {
7611
- CacheTexture thetex = textures.get(texname);
8549
+ CacheTexture thetex = textures.get(tex);
76128550 thetex.texture.disable();
76138551 thetex.texture.dispose();
7614
- textures.remove(texname);
8552
+ textures.remove(tex);
76158553 }
76168554
7617
- texture.texturedata = texturedata;
7618
- textures.put(texname, texture);
8555
+ //texture.texturedata = texturedata;
8556
+ textures.put(tex, texturecache);
76198557
76208558 // newtex = true;
76218559 }
....@@ -7631,10 +8569,44 @@
76318569 }
76328570 }
76338571
7634
- return texture;
8572
+ return texturecache;
76358573 }
76368574
7637
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8575
+ static void EmbedTextures(cTexture tex)
8576
+ {
8577
+ if (tex.pigmentdata == null)
8578
+ {
8579
+ //String texname = Object3D.GetPigment(tex);
8580
+
8581
+ CacheTexture texturecache = texturepigment.get(tex);
8582
+
8583
+ if (texturecache != null)
8584
+ {
8585
+ tex.pw = texturecache.texturedata.getWidth();
8586
+ tex.ph = texturecache.texturedata.getHeight();
8587
+ tex.pigmentdata = //CompressJPEG(CreateBim
8588
+ ((ByteBuffer)texturecache.texturedata.getBuffer()).array()
8589
+ ;
8590
+ //, tex.pw, tex.ph), 0.5f);
8591
+ }
8592
+ }
8593
+
8594
+ if (tex.bumpdata == null)
8595
+ {
8596
+ //String texname = Object3D.GetBump(tex);
8597
+
8598
+ CacheTexture texturecache = texturebump.get(tex);
8599
+
8600
+ if (texturecache != null)
8601
+ {
8602
+ tex.bw = texturecache.texturedata.getWidth();
8603
+ tex.bh = texturecache.texturedata.getHeight();
8604
+ tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f);
8605
+ }
8606
+ }
8607
+ }
8608
+
8609
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
76388610 {
76398611 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
76408612
....@@ -7652,21 +8624,21 @@
76528624 return texture!=null?texture.texture:null;
76538625 }
76548626
7655
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8627
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
76568628 {
76578629 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
76588630
76598631 return texture!=null?texture.texturedata:null;
76608632 }
76618633
7662
- boolean BindTexture(String tex, boolean bump, int resolution)
8634
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
76638635 {
76648636 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
76658637 {
76668638 return false;
76678639 }
76688640
7669
- boolean newtex = false;
8641
+ //boolean newtex = false;
76708642
76718643 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
76728644
....@@ -7698,9 +8670,75 @@
76988670 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
76998671 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
77008672
7701
- return newtex;
8673
+ return true; // Warning: not used.
77028674 }
77038675
8676
+ public static byte[] CompressJPEG(BufferedImage image, float quality)
8677
+ {
8678
+ try
8679
+ {
8680
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
8681
+ Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg");
8682
+ ImageWriter writer = writers.next();
8683
+
8684
+ ImageWriteParam param = writer.getDefaultWriteParam();
8685
+ param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
8686
+ param.setCompressionQuality(quality);
8687
+
8688
+ ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
8689
+ writer.setOutput(ios);
8690
+ writer.write(null, new IIOImage(image, null, null), param);
8691
+
8692
+ byte[] data = baos.toByteArray();
8693
+ writer.dispose();
8694
+ return data;
8695
+ }
8696
+ catch (Exception e)
8697
+ {
8698
+ e.printStackTrace();
8699
+ return null;
8700
+ }
8701
+ }
8702
+
8703
+ public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException
8704
+ {
8705
+ ByteArrayInputStream baos = new ByteArrayInputStream(image);
8706
+ Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg");
8707
+ ImageReader reader = writers.next();
8708
+
8709
+ BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
8710
+
8711
+ ImageReadParam param = reader.getDefaultReadParam();
8712
+ param.setDestination(bim);
8713
+ //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB));
8714
+
8715
+ ImageInputStream ios = ImageIO.createImageInputStream(baos);
8716
+ reader.setInput(ios);
8717
+ BufferedImage bim2 = reader.read(0, param);
8718
+ reader.dispose();
8719
+
8720
+// WritableRaster raster = bim2.getRaster();
8721
+// DataBufferByte data = (DataBufferByte) raster.getDataBuffer();
8722
+// byte[] bytes = data.getData();
8723
+//
8724
+// int[] pixels = new int[bytes.length/3];
8725
+// for (int i=pixels.length; --i>=0;)
8726
+// {
8727
+// int i3 = i*3;
8728
+// pixels[i] = 0xFF;
8729
+// pixels[i] <<= 8;
8730
+// pixels[i] |= bytes[i3+2] & 0xFF;
8731
+// pixels[i] <<= 8;
8732
+// pixels[i] |= bytes[i3+1] & 0xFF;
8733
+// pixels[i] <<= 8;
8734
+// pixels[i] |= bytes[i3] & 0xFF;
8735
+// }
8736
+//
8737
+// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w);
8738
+
8739
+ return bim;
8740
+ }
8741
+
77048742 ShadowBuffer shadowPBuf;
77058743 AntialiasBuffer antialiasPBuf;
77068744 int MAXSTACK;
....@@ -8536,11 +9574,35 @@
85369574 jy8[3] = 0.5f;
85379575 }
85389576
8539
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9577
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
85409578 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
85419579 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
85429580 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
85439581
9582
+ void ResetOptions()
9583
+ {
9584
+ options1[0] = 100;
9585
+ options1[1] = 0.025f;
9586
+ options1[2] = 0.01f;
9587
+ options1[3] = 0;
9588
+ options1[4] = 0;
9589
+
9590
+ options2[0] = 0;
9591
+ options2[1] = 0.75f;
9592
+ options2[2] = 0;
9593
+ options2[3] = 0;
9594
+
9595
+ options3[0] = 1;
9596
+ options3[1] = 1;
9597
+ options3[2] = 1;
9598
+ options3[3] = 0;
9599
+
9600
+ options4[0] = 1;
9601
+ options4[1] = 0;
9602
+ options4[2] = 1;
9603
+ options4[3] = 0;
9604
+ }
9605
+
85449606 static int imagecount = 0; // movie generation
85459607
85469608 static int jitter = 0;
....@@ -8636,8 +9698,8 @@
86369698 assert (parentcam != renderCamera);
86379699
86389700 if (renderCamera != lightCamera)
8639
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8640
- LA.matConcat(matrix, parentcam.toParent, matrix);
9701
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9702
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
86419703
86429704 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
86439705
....@@ -8652,8 +9714,8 @@
86529714 LA.matCopy(renderCamera.fromScreen, matrix);
86539715
86549716 if (renderCamera != lightCamera)
8655
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8656
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9717
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9718
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
86579719
86589720 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
86599721
....@@ -8725,7 +9787,7 @@
87259787 //gl.glFlush();
87269788 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
87279789
8728
- if (ANIMATION && ABORTED)
9790
+ if (Globals.ANIMATION && ABORTED)
87299791 {
87309792 System.err.println(" ABORTED FRAME");
87319793 break;
....@@ -8755,7 +9817,7 @@
87559817 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
87569818
87579819 // save image
8758
- if (ANIMATION && !ABORTED)
9820
+ if (Globals.ANIMATION && !ABORTED)
87599821 {
87609822 VPwidth = viewport[2];
87619823 VPheight = viewport[3];
....@@ -8866,11 +9928,11 @@
88669928
88679929 // imagecount++;
88689930
8869
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9931
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
88709932
88719933 if (!BOXMODE)
88729934 {
8873
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9935
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
88749936 }
88759937
88769938 if (!BOXMODE)
....@@ -8908,7 +9970,7 @@
89089970 ABORTED = false;
89099971 }
89109972 else
8911
- GrafreeD.wav.cursor += 735 * ACSIZE;
9973
+ Grafreed.wav.cursor += 735 * ACSIZE;
89129974
89139975 if (false)
89149976 {
....@@ -9571,11 +10633,11 @@
957110633
957210634 public void display(GLAutoDrawable drawable)
957310635 {
9574
- if (GrafreeD.savesound && GrafreeD.hassound)
10636
+ if (Grafreed.savesound && Grafreed.hassound)
957510637 {
9576
- GrafreeD.wav.save();
9577
- GrafreeD.savesound = false;
9578
- GrafreeD.hassound = false;
10638
+ Grafreed.wav.save();
10639
+ Grafreed.savesound = false;
10640
+ Grafreed.hassound = false;
957910641 }
958010642 // if (DEBUG_SELECTION)
958110643 // {
....@@ -9651,6 +10713,7 @@
965110713 ANTIALIAS = 0;
965210714 //System.out.println("RESTART");
965310715 AAtimer.restart();
10716
+ Globals.TIMERRUNNING = true;
965410717 }
965510718 }
965610719 }
....@@ -9705,7 +10768,7 @@
970510768 Object3D theobject = object;
970610769 Object3D theparent = object.parent;
970710770 object.parent = null;
9708
- object = (Object3D)GrafreeD.clone(object);
10771
+ object = (Object3D)Grafreed.clone(object);
970910772 object.Stripify();
971010773 if (theobject.selection == null || theobject.selection.Size() == 0)
971110774 theobject.PreprocessOcclusion(this);
....@@ -9718,13 +10781,14 @@
971810781 ambientOcclusion = false;
971910782 }
972010783
9721
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10784
+ if (//Globals.lighttouched &&
10785
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
972210786 {
972310787 //if (RENDERSHADOW) // ?
972410788 if (!IsFrozen())
972510789 {
972610790 // dec 2012
9727
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10791
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
972810792 {
972910793 Globals.framecount++;
973010794 shadowbuffer.display();
....@@ -9851,8 +10915,8 @@
985110915
985210916 // if (parentcam != renderCamera) // not a light
985310917 if (cam != lightCamera)
9854
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9855
- LA.matConcat(matrix, parentcam.toParent, matrix);
10918
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10919
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
985610920
985710921 for (int j = 0; j < 4; j++)
985810922 {
....@@ -9866,8 +10930,8 @@
986610930
986710931 // if (parentcam != renderCamera) // not a light
986810932 if (cam != lightCamera)
9869
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9870
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10933
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10934
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
987110935
987210936 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
987310937
....@@ -10126,7 +11190,16 @@
1012611190 // Bump noise
1012711191 gl.glActiveTexture(GL.GL_TEXTURE6);
1012811192 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10129
- BindTexture(NOISE_TEXTURE, false, 2);
11193
+
11194
+ try
11195
+ {
11196
+ BindTexture(NOISE_TEXTURE, false, 2);
11197
+ }
11198
+ catch (Exception e)
11199
+ {
11200
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11201
+ }
11202
+
1013011203
1013111204 gl.glActiveTexture(GL.GL_TEXTURE0);
1013211205 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10149,9 +11222,9 @@
1014911222
1015011223 gl.glMatrixMode(GL.GL_MODELVIEW);
1015111224
10152
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10153
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10154
-//gl.glEnable(gl.GL_MULTISAMPLE);
11225
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11226
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11227
+gl.glEnable(gl.GL_MULTISAMPLE);
1015511228 } else
1015611229 {
1015711230 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10162,7 +11235,7 @@
1016211235 //System.out.println("BLENDING ON");
1016311236 gl.glEnable(GL.GL_BLEND);
1016411237 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10165
-
11238
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1016611239 gl.glMatrixMode(gl.GL_PROJECTION);
1016711240 gl.glLoadIdentity();
1016811241
....@@ -10251,8 +11324,8 @@
1025111324 System.err.println("parentcam != renderCamera");
1025211325
1025311326 // if (cam != lightCamera)
10254
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10255
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11327
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11328
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1025611329 }
1025711330
1025811331 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10273,8 +11346,8 @@
1027311346 if (true) // TODO
1027411347 {
1027511348 if (cam != lightCamera)
10276
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10277
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11349
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11350
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1027811351 }
1027911352
1028011353 LA.xformPos(light0, cam.toScreen, light0);
....@@ -10340,7 +11413,7 @@
1034011413 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
1034111414 //System.out.println("fragmentMode = " + fragmentMode);
1034211415
10343
- if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION)
11416
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
1034411417 {
1034511418 /*
1034611419 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -10411,7 +11484,7 @@
1041111484 }
1041211485 }
1041311486
10414
- if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
11487
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
1041511488 {
1041611489 //gl.glDepthFunc(GL.GL_LEQUAL);
1041711490 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -10419,24 +11492,21 @@
1041911492
1042011493 boolean texon = textureon;
1042111494
10422
- if (RENDERPROGRAM > 0)
10423
- {
10424
- gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
10425
- textureon = false;
10426
- }
11495
+ gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11496
+ textureon = false;
11497
+
1042711498 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
1042811499 //System.out.println("ALLO");
1042911500 gl.glColorMask(false, false, false, false);
1043011501 DrawObject(gl);
10431
- if (RENDERPROGRAM > 0)
10432
- {
10433
- gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
10434
- textureon = texon;
10435
- }
11502
+
11503
+ gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11504
+ textureon = texon;
11505
+
1043611506 gl.glColorMask(true, true, true, true);
1043711507
1043811508 gl.glDepthFunc(GL.GL_EQUAL);
10439
- //gl.glDepthMask(false);
11509
+ gl.glDepthMask(false);
1044011510 }
1044111511
1044211512 if (false) // DrawMode() == SHADOW)
....@@ -10590,8 +11660,14 @@
1059011660 {
1059111661 renderpass++;
1059211662 // System.out.println("Draw object... ");
11663
+ STEP = 1;
1059311664 if (FAST) // in case there is no script
10594
- STEP = 16;
11665
+ STEP = 8;
11666
+
11667
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11668
+ {
11669
+ STEP *= 4;
11670
+ }
1059511671
1059611672 //object.FullInvariants();
1059711673
....@@ -10605,23 +11681,44 @@
1060511681 e.printStackTrace();
1060611682 }
1060711683
10608
- if (GrafreeD.RENDERME > 0)
10609
- GrafreeD.RENDERME--; // mechante magouille
11684
+ if (Grafreed.RENDERME > 0)
11685
+ Grafreed.RENDERME--; // mechante magouille
1061011686
1061111687 Globals.ONESTEP = false;
1061211688 }
1061311689
1061411690 static boolean zoomonce = false;
1061511691
11692
+ static void CreateSelectedPoint()
11693
+ {
11694
+ if (selectedpoint == null)
11695
+ {
11696
+ debugpointG = new Sphere();
11697
+ debugpointP = new Sphere();
11698
+ debugpointC = new Sphere();
11699
+ debugpointR = new Sphere();
11700
+
11701
+ selectedpoint = new Superellipsoid();
11702
+
11703
+ for (int i=0; i<8; i++)
11704
+ {
11705
+ debugpoints[i] = new Sphere();
11706
+ }
11707
+ }
11708
+ }
11709
+
1061611710 void DrawObject(GL gl, boolean draw)
1061711711 {
11712
+ // To clear camera values
11713
+ ResetOptions();
11714
+
1061811715 //System.out.println("DRAW OBJECT " + mouseDown);
1061911716 // DrawMode() = SELECTION;
1062011717 //GL gl = getGL();
1062111718 if ((TRACK || SHADOWTRACK) || zoomonce)
1062211719 {
1062311720 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
10624
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11721
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1062511722 pingthread.StepToTarget(true); // true);
1062611723 // zoomonce = false;
1062711724 }
....@@ -10641,7 +11738,7 @@
1064111738 callist = gl.glGenLists(1);
1064211739 }
1064311740
10644
- boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
11741
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
1064511742
1064611743 boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
1064711744
....@@ -10676,7 +11773,14 @@
1067611773
1067711774 usedtextures.clear();
1067811775
10679
- BindTextures(DEFAULT_TEXTURES, 2);
11776
+ try
11777
+ {
11778
+ BindTextures(DEFAULT_TEXTURES, 2);
11779
+ }
11780
+ catch (Exception e)
11781
+ {
11782
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11783
+ }
1068011784 }
1068111785 //System.out.println("--> " + stackdepth);
1068211786 // GrafreeD.traceon();
....@@ -10686,8 +11790,9 @@
1068611790
1068711791 if (DrawMode() == DEFAULT)
1068811792 {
10689
- if (DEBUG)
11793
+ if (Globals.DEBUG)
1069011794 {
11795
+ CreateSelectedPoint();
1069111796 float radius = 0.05f;
1069211797 if (selectedpoint.radius != radius)
1069311798 {
....@@ -10741,20 +11846,32 @@
1074111846 ReleaseTextures(DEFAULT_TEXTURES);
1074211847
1074311848 if (CLEANCACHE)
10744
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11849
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1074511850 {
10746
- String tex = e.nextElement();
11851
+ cTexture tex = e.nextElement();
1074711852
1074811853 // System.out.println("Texture --------- " + tex);
1074911854
10750
- if (tex.equals("WHITE_NOISE"))
11855
+ if (tex.equals("WHITE_NOISE:"))
1075111856 continue;
1075211857
10753
- if (!usedtextures.containsKey(tex))
11858
+ if (!usedtextures.contains(tex))
1075411859 {
11860
+ CacheTexture gettex = texturepigment.get(tex);
1075511861 // System.out.println("DISPOSE +++++++++++++++ " + tex);
10756
- textures.get(tex).texture.dispose();
10757
- textures.remove(tex);
11862
+ if (gettex != null)
11863
+ {
11864
+ gettex.texture.dispose();
11865
+ texturepigment.remove(tex);
11866
+ }
11867
+
11868
+ gettex = texturebump.get(tex);
11869
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11870
+ if (gettex != null)
11871
+ {
11872
+ gettex.texture.dispose();
11873
+ texturebump.remove(tex);
11874
+ }
1075811875 }
1075911876 }
1076011877 }
....@@ -10767,7 +11884,14 @@
1076711884 if (checker != null && DrawMode() == DEFAULT)
1076811885 {
1076911886 //BindTexture(IMMORTAL_TEXTURE);
10770
- BindTextures(checker.GetTextures(), checker.texres);
11887
+ try
11888
+ {
11889
+ BindTextures(checker.GetTextures(), checker.texres);
11890
+ }
11891
+ catch (Exception e)
11892
+ {
11893
+ System.err.println("FAILED: " + checker.GetTextures());
11894
+ }
1077111895 // NEAREST
1077211896 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1077311897 DrawChecker(gl);
....@@ -10849,7 +11973,7 @@
1084911973 return;
1085011974 }
1085111975
10852
- String string = obj.GetToolTip();
11976
+ String string = obj.toString(); //.GetToolTip();
1085311977
1085411978 GL gl = GetGL();
1085511979
....@@ -11166,8 +12290,8 @@
1116612290 //obj.TransformToWorld(light, light);
1116712291 for (int i = tp.size(); --i >= 0;)
1116812292 {
11169
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11170
- LA.xformPos(light, tp.get(i).toParent, light);
12293
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12294
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1117112295 }
1117212296
1117312297
....@@ -11184,8 +12308,8 @@
1118412308 parentcam = cameras[0];
1118512309 }
1118612310
11187
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11188
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12311
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12312
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1118912313
1119012314 LA.xformPos(light, renderCamera.toScreen, light);
1119112315
....@@ -11276,7 +12400,52 @@
1127612400 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1127712401
1127812402 String program =
12403
+ // Min shader
1127912404 "!!ARBfp1.0\n" +
12405
+ "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" +
12406
+ "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12407
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12408
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12409
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12410
+ "TEMP temp;" +
12411
+ "TEMP light;" +
12412
+ "TEMP ndotl;" +
12413
+ "TEMP normal;" +
12414
+ "TEMP depth;" +
12415
+
12416
+ "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12417
+
12418
+ "MOV light, state.light[0].position;" +
12419
+ "DP3 ndotl.x, light, normal;" +
12420
+
12421
+ // shadow
12422
+ "MOV temp, fragment.texcoord[1];" +
12423
+ TextureFetch("depth", "temp", "1") +
12424
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12425
+ "SLT temp.x, fragment.texcoord[1].z, depth.z;" +
12426
+
12427
+
12428
+ // No shadow when out of frustum
12429
+ //"SGE temp.y, depth.z, zero123.y;" +
12430
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12431
+
12432
+ "MUL ndotl.x, ndotl.x, temp.x;" +
12433
+ "MAX ndotl.x, ndotl.x, pow2.y;" +
12434
+
12435
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12436
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
12437
+ "MUL temp, temp, ndotl.x;" +
12438
+
12439
+ "MUL temp, temp, zero123.z;" +
12440
+
12441
+ "MOV temp.w, zero123.y;" + // reset alpha
12442
+
12443
+ "MOV result.color, temp;" +
12444
+ "END";
12445
+
12446
+ String program2 =
12447
+ "!!ARBfp1.0\n" +
12448
+
1128012449 //"OPTION ARB_fragment_program_shadow;" +
1128112450 "PARAM light2cam0 = program.env[10];" +
1128212451 "PARAM light2cam1 = program.env[11];" +
....@@ -11391,8 +12560,7 @@
1139112560 "TEMP shininess;" +
1139212561 "\n" +
1139312562 "MOV texSamp, one;" +
11394
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
11395
-
12563
+
1139612564 "MOV mapgrid.x, one2048th.x;" +
1139712565 "MOV temp, fragment.texcoord[1];" +
1139812566 /*
....@@ -11797,10 +12965,10 @@
1179712965 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1179812966 "") +
1179912967
11800
- // display shadow only (bump == 0)
12968
+ // display shadow only (fakedepth == 0)
1180112969 "SUB temp.x, half.x, shadow.x;" +
11802
- "MOV temp.y, -params6.x;" +
11803
- "SLT temp.z, temp.y, zero.x;" +
12970
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12971
+ "SLT temp.z, temp.y, -one2048th.x;" +
1180412972 "SUB temp.y, one.x, temp.z;" +
1180512973 "MUL temp.x, temp.x, temp.y;" +
1180612974 "KIL temp.x;" +
....@@ -11929,8 +13097,10 @@
1192913097 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1193013098
1193113099 "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
13100
+ // Tuning for default skin
13101
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
13102
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
13103
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1193413104 "MUL temp.x, temp.x, temp.y;" +
1193513105
1193613106 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12129,7 +13299,7 @@
1212913299 //once = true;
1213013300 }
1213113301
12132
- System.out.print("Program #" + mode + "; length = " + program.length());
13302
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1213313303 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1213413304 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1213513305
....@@ -12227,20 +13397,20 @@
1222713397 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1222813398 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1222913399 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13400
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13401
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1223013402 "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
12231
- "SLT " + src + ".z, " + src + ".x, one.x;" +
12232
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
12233
- "SLT " + src + ".z, " + src + ".y, one.x;" +
12234
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13403
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13404
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1223513405 //"SWZ buffer, temp, w,w,w,w;";
12236
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13406
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1223713407 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1223813408 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1223913409 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
12240
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13410
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1224113411
12242
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
12243
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13412
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13413
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1224413414 }
1224513415
1224613416 String Shadow(String depth, String shadow)
....@@ -12262,12 +13432,16 @@
1226213432
1226313433 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1226413434 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13435
+
13436
+ // Compare fragment depth in light space with shadowmap.
1226513437 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1226613438 "SGE temp.y, temp.x, zero.x;" +
12267
- "SUB " + shadow + ".y, one.x, temp.y;" +
13439
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13440
+
13441
+ // Reverse comparison
1226813442 "SUB temp.x, one.x, temp.x;" +
1226913443 "MUL " + shadow + ".x, temp.x, temp.y;" +
12270
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13444
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1227113445 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1227213446
1227313447 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12281,6 +13455,10 @@
1228113455 // No shadow for backface
1228213456 "DP3 temp.x, normal, lightd;" +
1228313457 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13458
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13459
+
13460
+ // No shadow when out of frustum
13461
+ "SGE temp.x, " + depth + ".z, one.z;" +
1228413462 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1228513463 "";
1228613464 }
....@@ -12427,7 +13605,8 @@
1242713605 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1242813606 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1242913607 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
12430
- Object3D.cVector2[] vector2buffer;
13608
+
13609
+ //Object3D.cVector2[] vector2buffer;
1243113610
1243213611 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1243313612 // OUT : diff, spec
....@@ -12443,9 +13622,10 @@
1244313622 "DP3 " + dest + ".z," + "normals," + "eye;" +
1244413623 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1244513624 //"MOV " + dest + ".w," + "normal.z;" +
12446
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
12447
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
12448
- //"MOV " + dest + ".z," + "params2.w;" +
13625
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13626
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13627
+
13628
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1244913629 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1245013630 "RCP " + dest + ".w," + dest + ".w;" +
1245113631 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -12839,7 +14019,7 @@
1283914019 public void mousePressed(MouseEvent e)
1284014020 {
1284114021 //System.out.println("mousePressed: " + e);
12842
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
14022
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1284314023 }
1284414024
1284514025 static long prevtime = 0;
....@@ -12866,6 +14046,7 @@
1286614046
1286714047 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1286814048
14049
+ if (BUTTONLESSWHEEL)
1286914050 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1287014051 {
1287114052 return;
....@@ -12874,7 +14055,7 @@
1287414055 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1287514056
1287614057 // TIMER
12877
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
14058
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1287814059 {
1287914060 keepboxmode = BOXMODE;
1288014061 keepsupport = SUPPORT;
....@@ -12914,8 +14095,8 @@
1291414095 // mode |= META;
1291514096 //}
1291614097
12917
- SetMouseMode(WHEEL | e.getModifiersEx());
12918
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
14098
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
14099
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1291914100 anchorX = ax;
1292014101 anchorY = ay;
1292114102 prevX = px;
....@@ -12949,6 +14130,7 @@
1294914130 else
1295014131 if (evt.getSource() == AAtimer)
1295114132 {
14133
+ Globals.TIMERRUNNING = false;
1295214134 if (mouseDown)
1295314135 {
1295414136 //new Exception().printStackTrace();
....@@ -12974,6 +14156,10 @@
1297414156 // LIVE = waslive;
1297514157 // wasliveok = true;
1297614158 // waslive = false;
14159
+
14160
+ // May 2019 Forget it:
14161
+ if (true)
14162
+ return;
1297714163
1297814164 // source == timer
1297914165 if (mouseDown)
....@@ -13004,7 +14190,7 @@
1300414190
1300514191 // fev 2014???
1300614192 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13007
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14193
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1300814194 pingthread.StepToTarget(true); // true);
1300914195 }
1301014196 // if (!LIVE)
....@@ -13013,12 +14199,13 @@
1301314199
1301414200 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1301514201
13016
- void clickStart(int x, int y, int modifiers)
14202
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1301714203 {
1301814204 if (!wasliveok)
1301914205 return;
1302014206
1302114207 AAtimer.restart(); //
14208
+ Globals.TIMERRUNNING = true;
1302214209
1302314210 // waslive = LIVE;
1302414211 // LIVE = false;
....@@ -13030,7 +14217,7 @@
1303014217 // touched = true; // main DL
1303114218 if (isRenderer)
1303214219 {
13033
- SetMouseMode(modifiers);
14220
+ SetMouseMode(modifiers, modifiersex);
1303414221 }
1303514222
1303614223 selectX = anchorX = x;
....@@ -13043,7 +14230,7 @@
1304314230 clicked = true;
1304414231 hold = false;
1304514232
13046
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14233
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1304714234 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1304814235 {
1304914236 // System.out.println("RESTART II " + modifiers);
....@@ -13068,14 +14255,15 @@
1306814255 drag = false;
1306914256 //System.out.println("Mouse DOWN");
1307014257 editObj = false;
13071
- ClickInfo info = new ClickInfo();
13072
- info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
13073
- info.pane = this;
13074
- info.camera = renderCamera;
13075
- info.x = x;
13076
- info.y = y;
13077
- info.modifiers = modifiers;
13078
- editObj = object.doEditClick(info, 0);
14258
+ //ClickInfo info = new ClickInfo();
14259
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14260
+ object.clickInfo.pane = this;
14261
+ object.clickInfo.camera = renderCamera;
14262
+ object.clickInfo.x = x;
14263
+ object.clickInfo.y = y;
14264
+ object.clickInfo.modifiers = modifiersex;
14265
+ editObj = object.doEditClick(//info,
14266
+ 0);
1307914267 if (!editObj)
1308014268 {
1308114269 hasMarquee = true;
....@@ -13091,11 +14279,14 @@
1309114279
1309214280 public void mouseDragged(MouseEvent e)
1309314281 {
14282
+ Globals.MOUSEDRAGGED = true;
14283
+
14284
+ //System.out.println("mouseDragged: " + e);
1309414285 if (isRenderer)
1309514286 movingcamera = true;
14287
+
1309614288 //if (drawing)
1309714289 //return;
13098
- //System.out.println("mouseDragged: " + e);
1309914290 if ((e.getModifiersEx() & CTRL) != 0
1310014291 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1310114292 {
....@@ -13103,7 +14294,7 @@
1310314294 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1310414295 }
1310514296 else
13106
- drag(e.getX(), e.getY(), e.getModifiersEx());
14297
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1310714298
1310814299 //try { Thread.sleep(1); } catch (Exception ex) {}
1310914300 }
....@@ -13115,6 +14306,11 @@
1311514306 cVector tmp = new cVector();
1311614307 cVector tmp2 = new cVector();
1311714308 boolean isMoving;
14309
+
14310
+ public cVector TargetLookAt()
14311
+ {
14312
+ return targetLookAt;
14313
+ }
1311814314
1311914315 class PingThread extends Thread
1312014316 {
....@@ -13271,6 +14467,7 @@
1327114467
1327214468 public void run()
1327314469 {
14470
+ new Exception().printStackTrace();
1327414471 System.exit(0);
1327514472 for (;;)
1327614473 {
....@@ -13334,7 +14531,7 @@
1333414531 {
1333514532 Globals.lighttouched = true;
1333614533 }
13337
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14534
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1333814535 }
1333914536 //else
1334014537 }
....@@ -13348,12 +14545,12 @@
1334814545 void GoDown(int mod)
1334914546 {
1335014547 MODIFIERS |= COMMAND;
13351
- /*
14548
+ /**/
1335214549 if((mod&SHIFT) == SHIFT)
1335314550 manipCamera.RotatePosition(0, -speed);
1335414551 else
13355
- manipCamera.BackForth(0, -speed*delta, getWidth());
13356
- */
14552
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14553
+ /**/
1335714554 if ((mod & SHIFT) == SHIFT)
1335814555 {
1335914556 mouseMode = mouseMode; // VR??
....@@ -13369,12 +14566,12 @@
1336914566 void GoUp(int mod)
1337014567 {
1337114568 MODIFIERS |= COMMAND;
13372
- /*
14569
+ /**/
1337314570 if((mod&SHIFT) == SHIFT)
1337414571 manipCamera.RotatePosition(0, speed);
1337514572 else
13376
- manipCamera.BackForth(0, speed*delta, getWidth());
13377
- */
14573
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14574
+ /**/
1337814575 if ((mod & SHIFT) == SHIFT)
1337914576 {
1338014577 mouseMode = mouseMode;
....@@ -13390,12 +14587,12 @@
1339014587 void GoLeft(int mod)
1339114588 {
1339214589 MODIFIERS |= COMMAND;
13393
- /*
14590
+ /**/
1339414591 if((mod&SHIFT) == SHIFT)
13395
- manipCamera.RotatePosition(speed, 0);
13396
- else
1339714592 manipCamera.Translate(speed*delta, 0, getWidth());
13398
- */
14593
+ else
14594
+ manipCamera.RotatePosition(speed, 0);
14595
+ /**/
1339914596 if ((mod & SHIFT) == SHIFT)
1340014597 {
1340114598 mouseMode = mouseMode;
....@@ -13411,12 +14608,12 @@
1341114608 void GoRight(int mod)
1341214609 {
1341314610 MODIFIERS |= COMMAND;
13414
- /*
14611
+ /**/
1341514612 if((mod&SHIFT) == SHIFT)
13416
- manipCamera.RotatePosition(-speed, 0);
13417
- else
1341814613 manipCamera.Translate(-speed*delta, 0, getWidth());
13419
- */
14614
+ else
14615
+ manipCamera.RotatePosition(-speed, 0);
14616
+ /**/
1342014617 if ((mod & SHIFT) == SHIFT)
1342114618 {
1342214619 mouseMode = mouseMode;
....@@ -13434,7 +14631,7 @@
1343414631 int X, Y;
1343514632 boolean SX, SY;
1343614633
13437
- void drag(int x, int y, int modifiers)
14634
+ void drag(int x, int y, int modifiers, int modifiersex)
1343814635 {
1343914636 if (IsFrozen())
1344014637 {
....@@ -13443,17 +14640,17 @@
1344314640
1344414641 drag = true; // NEW
1344514642
13446
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14643
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1344714644
1344814645 X = x;
1344914646 Y = y;
1345014647 // floating state for animation
13451
- MODIFIERS = modifiers;
13452
- modifiers &= ~1024;
14648
+ MODIFIERS = modifiersex;
14649
+ modifiersex &= ~1024;
1345314650 if (false) // modifiers != 0)
1345414651 {
1345514652 //new Exception().printStackTrace();
13456
- System.out.println("mouseDragged: " + modifiers);
14653
+ System.out.println("mouseDragged: " + modifiersex);
1345714654 System.out.println("SHIFT = " + SHIFT);
1345814655 System.out.println("CONTROL = " + COMMAND);
1345914656 System.out.println("META = " + META);
....@@ -13466,14 +14663,16 @@
1346614663 if (editObj)
1346714664 {
1346814665 drag = true;
13469
- ClickInfo info = new ClickInfo();
13470
- info.bounds.setBounds(0, 0,
14666
+ //ClickInfo info = new ClickInfo();
14667
+ object.clickInfo.bounds.setBounds(0, 0,
1347114668 (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
13472
- info.pane = this;
13473
- info.camera = renderCamera;
13474
- info.x = x;
13475
- info.y = y;
13476
- object.editWindow.copy.doEditDrag(info);
14669
+ object.clickInfo.pane = this;
14670
+ object.clickInfo.camera = renderCamera;
14671
+ object.clickInfo.x = x;
14672
+ object.clickInfo.y = y;
14673
+ object //.GetWindow().copy
14674
+ .doEditDrag(//info,
14675
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1347714676 } else
1347814677 {
1347914678 if (x < startX)
....@@ -13622,23 +14821,27 @@
1362214821 }
1362314822 }
1362414823
14824
+// ClickInfo clickInfo = new ClickInfo();
14825
+
1362514826 public void mouseMoved(MouseEvent e)
1362614827 {
1362714828 //System.out.println("mouseMoved: " + e);
13628
-
1362914829 if (isRenderer)
1363014830 return;
1363114831
13632
- ClickInfo ci = new ClickInfo();
13633
- ci.x = e.getX();
13634
- ci.y = e.getY();
13635
- ci.modifiers = e.getModifiersEx();
13636
- ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
13637
- ci.pane = this;
13638
- ci.camera = renderCamera;
14832
+ // Mouse cursor feedback
14833
+ object.clickInfo.x = e.getX();
14834
+ object.clickInfo.y = e.getY();
14835
+ object.clickInfo.modifiers = e.getModifiersEx();
14836
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14837
+ object.clickInfo.pane = this;
14838
+ object.clickInfo.camera = renderCamera;
1363914839 if (!isRenderer)
1364014840 {
13641
- if (object.editWindow.copy.doEditClick(ci, 0))
14841
+ //ObjEditor editWindow = object.editWindow;
14842
+ //Object3D copy = editWindow.copy;
14843
+ if (object.doEditClick(//clickInfo,
14844
+ 0))
1364214845 {
1364314846 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1364414847 } else
....@@ -13650,7 +14853,11 @@
1365014853
1365114854 public void mouseReleased(MouseEvent e)
1365214855 {
14856
+ Globals.MOUSEDRAGGED = false;
14857
+
1365314858 movingcamera = false;
14859
+ X = 0; // getBounds().width/2;
14860
+ Y = 0; // getBounds().height/2;
1365414861 //System.out.println("mouseReleased: " + e);
1365514862 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1365614863 }
....@@ -13673,9 +14880,9 @@
1367314880 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1367414881 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1367514882
13676
- if (control || command || IsFrozen())
14883
+// No delay if (control || command || IsFrozen())
1367714884 timeout = true;
13678
- else
14885
+// ?? May 2019 else
1367914886 // timer.setDelay((modifiers & 128) != 0?0:350);
1368014887 mouseDown = false;
1368114888 if (!control && !command) // june 2013
....@@ -13785,7 +14992,7 @@
1378514992 System.out.println("keyReleased: " + e);
1378614993 }
1378714994
13788
- void SetMouseMode(int modifiers)
14995
+ void SetMouseMode(int modifiers, int modifiersex)
1378914996 {
1379014997 //System.out.println("SetMouseMode = " + modifiers);
1379114998 //modifiers &= ~1024;
....@@ -13797,25 +15004,25 @@
1379715004 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1379815005 // return;
1379915006 //System.out.println("SetMode = " + modifiers);
13800
- if ((modifiers & WHEEL) == WHEEL)
15007
+ if ((modifiersex & WHEEL) == WHEEL)
1380115008 {
1380215009 mouseMode |= ZOOM;
1380315010 }
1380415011
1380515012 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
13806
- if (capsLocked || (modifiers & META) == META)
15013
+ if (capsLocked) // || (modifiers & META) == META)
1380715014 {
1380815015 mouseMode |= VR; // BACKFORTH;
1380915016 }
13810
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
15017
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1381115018 {
1381215019 mouseMode |= SELECT;
1381315020 }
13814
- if ((modifiers & COMMAND) == COMMAND)
15021
+ if ((modifiersex & COMMAND) == COMMAND)
1381515022 {
1381615023 mouseMode |= SELECT;
1381715024 }
13818
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
15025
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1381915026 {
1382015027 mouseMode &= ~VR;
1382115028 mouseMode |= TRANSLATE;
....@@ -13844,10 +15051,10 @@
1384415051
1384515052 if (isRenderer) //
1384615053 {
13847
- SetMouseMode(modifiers);
15054
+ SetMouseMode(0, modifiers);
1384815055 }
1384915056
13850
- theRenderer.keyPressed(key);
15057
+ Globals.theRenderer.keyPressed(key);
1385115058 }
1385215059
1385315060 int kompactbit = 4; // power bit
....@@ -13859,7 +15066,7 @@
1385915066 float SATPOW = 1; // 2; // 0.5f;
1386015067 float BRIPOW = 1; // 0.5f; // 0.5f;
1386115068
13862
- void keyPressed(int key)
15069
+ public void keyPressed(int key)
1386315070 {
1386415071 if (key >= '0' && key <= '5')
1386515072 clampbit = (key-'0');
....@@ -13906,7 +15113,8 @@
1390615113 // break;
1390715114 case 'T':
1390815115 CACHETEXTURE ^= true;
13909
- textures.clear();
15116
+ texturepigment.clear();
15117
+ texturebump.clear();
1391015118 // repaint();
1391115119 break;
1391215120 case 'Y':
....@@ -13991,7 +15199,9 @@
1399115199 case 'E' : COMPACT ^= true;
1399215200 repaint();
1399315201 break;
13994
- case 'W' : DEBUGHSB ^= true;
15202
+ case 'W' : // Wide Window (fullscreen)
15203
+ //DEBUGHSB ^= true;
15204
+ ObjEditor.theFrame.ToggleFullScreen();
1399515205 repaint();
1399615206 break;
1399715207 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14016,8 +15226,8 @@
1401615226 RevertCamera();
1401715227 repaint();
1401815228 break;
14019
- case 'L':
1402015229 case 'l':
15230
+ //case 'L':
1402115231 if (lightMode)
1402215232 {
1402315233 lightMode = false;
....@@ -14160,9 +15370,9 @@
1416015370 case '_':
1416115371 kompactbit = 5;
1416215372 break;
14163
- case '+':
14164
- kompactbit = 6;
14165
- break;
15373
+// case '+':
15374
+// kompactbit = 6;
15375
+// break;
1416615376 case ' ':
1416715377 lightMode ^= true;
1416815378 Globals.lighttouched = true;
....@@ -14174,13 +15384,14 @@
1417415384 case ESC:
1417515385 RENDERPROGRAM += 1;
1417615386 RENDERPROGRAM %= 3;
15387
+
1417715388 repaint();
1417815389 break;
1417915390 case 'Z':
1418015391 //RESIZETEXTURE ^= true;
1418115392 //break;
1418215393 case 'z':
14183
- RENDERSHADOW ^= true;
15394
+ Globals.RENDERSHADOW ^= true;
1418415395 Globals.lighttouched = true;
1418515396 repaint();
1418615397 break;
....@@ -14213,8 +15424,9 @@
1421315424 case DELETE:
1421415425 ClearSelection();
1421515426 break;
14216
- /*
1421715427 case '+':
15428
+
15429
+ /*
1421815430 //fontsize += 1;
1421915431 bbzoom *= 2;
1422015432 repaint();
....@@ -14231,17 +15443,17 @@
1423115443 case '=':
1423215444 IncDepth();
1423315445 //fontsize += 1;
14234
- object.editWindow.refreshContents(true);
15446
+ object.GetWindow().refreshContents(true);
1423515447 maskbit = 6;
1423615448 break;
1423715449 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1423815450 DecDepth();
1423915451 maskbit = 5;
1424015452 //if(fontsize > 1) fontsize -= 1;
14241
- if (object.editWindow == null)
14242
- new Exception().printStackTrace();
14243
- else
14244
- object.editWindow.refreshContents(true);
15453
+// if (object.editWindow == null)
15454
+// new Exception().printStackTrace();
15455
+// else
15456
+ object.GetWindow().refreshContents(true);
1424515457 break;
1424615458 case '{':
1424715459 manipCamera.shaper_fovy /= 1.1;
....@@ -14296,6 +15508,7 @@
1429615508 }
1429715509 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1429815510 }
15511
+
1429915512 static double OCCLUSIONBOOST = 1; // 0.5;
1430015513
1430115514 void keyReleased(int key, int modifiers)
....@@ -14303,11 +15516,11 @@
1430315516 //mode = ROTATE;
1430415517 if ((MODIFIERS & COMMAND) == 0) // VR??
1430515518 {
14306
- SetMouseMode(modifiers);
15519
+ SetMouseMode(0, modifiers);
1430715520 }
1430815521 }
1430915522
14310
- protected void processKeyEvent(KeyEvent e)
15523
+ public void processKeyEvent(KeyEvent e)
1431115524 {
1431215525 switch (e.getID())
1431315526 {
....@@ -14437,8 +15650,9 @@
1443715650
1443815651 protected void processMouseMotionEvent(MouseEvent e)
1443915652 {
14440
- //System.out.println("processMouseMotionEvent: " + mouseMode);
14441
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15653
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15654
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15655
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1444215656 {
1444315657 mouseMoved(e);
1444415658 } else
....@@ -14463,11 +15677,12 @@
1446315677 }
1446415678 */
1446515679
14466
- object.editWindow.EditSelection();
15680
+ object.GetWindow().EditSelection(false);
1446715681 }
1446815682
1446915683 void SelectParent()
1447015684 {
15685
+ new Exception().printStackTrace();
1447115686 System.exit(0);
1447215687 Composite group = (Composite) object;
1447315688 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -14479,10 +15694,10 @@
1447915694 {
1448015695 //selectees.remove(i);
1448115696 System.out.println("select parent of " + elem);
14482
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15697
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1448315698 } else
1448415699 {
14485
- group.editWindow.Select(elem.GetTreePath(), first, true);
15700
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1448615701 }
1448715702
1448815703 first = false;
....@@ -14491,6 +15706,7 @@
1449115706
1449215707 void SelectChildren()
1449315708 {
15709
+ new Exception().printStackTrace();
1449415710 System.exit(0);
1449515711 /*
1449615712 Composite group = (Composite) object;
....@@ -14523,12 +15739,12 @@
1452315739 for (int j = 0; j < group.children.size(); j++)
1452415740 {
1452515741 elem = (Object3D) group.children.elementAt(j);
14526
- object.editWindow.Select(elem.GetTreePath(), first, true);
15742
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1452715743 first = false;
1452815744 }
1452915745 } else
1453015746 {
14531
- object.editWindow.Select(elem.GetTreePath(), first, true);
15747
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1453215748 }
1453315749
1453415750 first = false;
....@@ -14539,21 +15755,21 @@
1453915755 {
1454015756 //Composite group = (Composite) object;
1454115757 Object3D group = object;
14542
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15758
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1454315759 }
1454415760
1454515761 void ResetTransform(int mask)
1454615762 {
1454715763 //Composite group = (Composite) object;
1454815764 Object3D group = object;
14549
- group.editWindow.ResetTransform(mask);
15765
+ group.GetWindow().ResetTransform(mask);
1455015766 }
1455115767
1455215768 void FlipTransform()
1455315769 {
1455415770 //Composite group = (Composite) object;
1455515771 Object3D group = object;
14556
- group.editWindow.FlipTransform();
15772
+ group.GetWindow().FlipTransform();
1455715773 // group.editWindow.ReduceMesh(true);
1455815774 }
1455915775
....@@ -14561,7 +15777,7 @@
1456115777 {
1456215778 //Composite group = (Composite) object;
1456315779 Object3D group = object;
14564
- group.editWindow.PrintMemory();
15780
+ group.GetWindow().PrintMemory();
1456515781 // group.editWindow.ReduceMesh(true);
1456615782 }
1456715783
....@@ -14569,7 +15785,7 @@
1456915785 {
1457015786 //Composite group = (Composite) object;
1457115787 Object3D group = object;
14572
- group.editWindow.ResetCentroid();
15788
+ group.GetWindow().ResetCentroid();
1457315789 }
1457415790
1457515791 void IncDepth()
....@@ -14651,11 +15867,11 @@
1465115867
1465215868 int width = getBounds().width;
1465315869 int height = getBounds().height;
14654
- ClickInfo info = new ClickInfo();
14655
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1465615870 //Image img = CreateImage(width, height);
1465715871 //System.out.println("width = " + width + "; height = " + height + "\n");
15872
+
1465815873 Graphics gr = g; // img.getGraphics();
15874
+
1465915875 if (!hasMarquee)
1466015876 {
1466115877 if (Xmin < Xmax) // !locked)
....@@ -14727,40 +15943,88 @@
1472715943 }
1472815944 if (object != null && !hasMarquee)
1472915945 {
15946
+ if (object.clickInfo == null)
15947
+ object.clickInfo = new ClickInfo();
15948
+ ClickInfo info = object.clickInfo;
15949
+ //ClickInfo info = new ClickInfo();
15950
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
15951
+
1473015952 if (isRenderer)
1473115953 {
14732
- info.flags++;
15954
+ object.clickInfo.flags++;
1473315955 double frameAspect = (double) width / (double) height;
1473415956 if (frameAspect > renderCamera.aspect)
1473515957 {
1473615958 int desired = (int) ((double) height * renderCamera.aspect);
14737
- info.bounds.width -= width - desired;
14738
- info.bounds.x += (width - desired) / 2;
15959
+ object.clickInfo.bounds.width -= width - desired;
15960
+ object.clickInfo.bounds.x += (width - desired) / 2;
1473915961 } else
1474015962 {
1474115963 int desired = (int) ((double) width / renderCamera.aspect);
14742
- info.bounds.height -= height - desired;
14743
- info.bounds.y += (height - desired) / 2;
15964
+ object.clickInfo.bounds.height -= height - desired;
15965
+ object.clickInfo.bounds.y += (height - desired) / 2;
1474415966 }
1474515967 }
14746
- info.g = gr;
14747
- info.camera = renderCamera;
15968
+
15969
+ object.clickInfo.g = gr;
15970
+ object.clickInfo.camera = renderCamera;
1474815971 /*
1474915972 // Memory intensive (brep.verticescopy)
1475015973 if (!(object instanceof Composite))
1475115974 object.draw(info, 0, false); // SLOW :
1475215975 */
14753
- if (!isRenderer)
15976
+ if (!isRenderer) // && drag)
1475415977 {
14755
- object.drawEditHandles(info, 0);
15978
+ Grafreed.Assert(object != null);
15979
+ Grafreed.Assert(object.selection != null);
15980
+ if (object.selection.Size() > 0)
15981
+ {
15982
+ int hitSomething = object.selection.get(0).hitSomething;
15983
+
15984
+ object.clickInfo.DX = 0;
15985
+ object.clickInfo.DY = 0;
15986
+ object.clickInfo.W = 1;
15987
+ if (hitSomething == Object3D.hitCenter)
15988
+ {
15989
+ info.DX = X;
15990
+ if (X != 0)
15991
+ info.DX -= info.bounds.width/2;
15992
+
15993
+ info.DY = Y;
15994
+ if (Y != 0)
15995
+ info.DY -= info.bounds.height/2;
15996
+ }
15997
+
15998
+ object.drawEditHandles(//info,
15999
+ 0);
16000
+
16001
+ if (drag && (X != 0 || Y != 0))
16002
+ {
16003
+ switch (hitSomething)
16004
+ {
16005
+ case Object3D.hitCenter: gr.setColor(Color.pink);
16006
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16007
+ break;
16008
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
16009
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16010
+ break;
16011
+ case Object3D.hitScale: gr.setColor(Color.cyan);
16012
+ gr.drawLine(X, Y, 0, 0);
16013
+ break;
16014
+ }
16015
+
16016
+ }
16017
+ }
1475616018 }
1475716019 }
16020
+
1475816021 if (isRenderer)
1475916022 {
1476016023 //gr.setColor(Color.black);
1476116024 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1476216025 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1476316026 }
16027
+
1476416028 if (hasMarquee)
1476516029 {
1476616030 gr.setXORMode(Color.white);
....@@ -14873,6 +16137,7 @@
1487316137 public boolean mouseDown(Event evt, int x, int y)
1487416138 {
1487516139 System.out.println("mouseDown: " + evt);
16140
+ System.exit(0);
1487616141 /*
1487716142 locked = true;
1487816143 drag = false;
....@@ -14916,7 +16181,7 @@
1491616181 {
1491716182 keyPressed(0, modifiers);
1491816183 }
14919
- clickStart(x, y, modifiers);
16184
+ // clickStart(x, y, modifiers);
1492016185 return true;
1492116186 }
1492216187
....@@ -15034,7 +16299,7 @@
1503416299 {
1503516300 keyReleased(0, 0);
1503616301 }
15037
- drag(x, y, modifiers);
16302
+ drag(x, y, 0, modifiers);
1503816303 return true;
1503916304 }
1504016305
....@@ -15166,7 +16431,7 @@
1516616431 Object3D object;
1516716432 static Object3D trackedobject;
1516816433 Camera renderCamera; // Light or Eye (or Occlusion)
15169
- /*static*/ Camera manipCamera; // Light or Eye
16434
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1517016435 /*static*/ Camera eyeCamera;
1517116436 /*static*/ Camera lightCamera;
1517216437 int cameracount;
....@@ -15451,16 +16716,16 @@
1545116716 cStatic.objectstack[materialdepth++] = checker;
1545216717 //System.out.println("material " + material);
1545316718 //Applet3D.tracein(this, selected);
15454
- vector2buffer = checker.projectedVertices;
16719
+ //vector2buffer = checker.projectedVertices;
1545516720
1545616721 //checker.GetMaterial().Draw(this, false); // true);
15457
- DrawMaterial(checker.GetMaterial(), false); // true);
16722
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1545816723
1545916724 materialdepth -= 1;
1546016725 if (materialdepth > 0)
1546116726 {
15462
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
15463
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16727
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16728
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1546416729 }
1546516730 //checker.GetMaterial().opacity = 1f;
1546616731 ////checker.GetMaterial().ambient = 1f;
....@@ -15546,6 +16811,14 @@
1554616811 }
1554716812 }
1554816813
16814
+ private Object3D GetFolder()
16815
+ {
16816
+ Object3D folder = object.GetWindow().copy;
16817
+ if (object.GetWindow().copy.selection.Size() > 0)
16818
+ folder = object.GetWindow().copy.selection.elementAt(0);
16819
+ return folder;
16820
+ }
16821
+
1554916822 class SelectBuffer implements GLEventListener
1555016823 {
1555116824
....@@ -15604,6 +16877,7 @@
1560416877 {
1560516878 if (!selection)
1560616879 {
16880
+ new Exception().printStackTrace();
1560716881 System.exit(0);
1560816882 return;
1560916883 }
....@@ -15624,6 +16898,17 @@
1562416898
1562516899 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1562616900
16901
+ if (PAINTMODE)
16902
+ {
16903
+ if (object.GetWindow().copy.selection.Size() > 0)
16904
+ {
16905
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16906
+
16907
+ // Make what you paint not selectable.
16908
+ paintobj.ResetSelectable();
16909
+ }
16910
+ }
16911
+
1562716912 //int tmp = selection_view;
1562816913 //selection_view = -1;
1562916914 int temp = DrawMode();
....@@ -15635,6 +16920,17 @@
1563516920 // temp = DEFAULT; // patch for selection debug
1563616921 Globals.drawMode = temp; // WARNING
1563716922
16923
+ if (PAINTMODE)
16924
+ {
16925
+ if (object.GetWindow().copy.selection.Size() > 0)
16926
+ {
16927
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16928
+
16929
+ // Revert.
16930
+ paintobj.RestoreSelectable();
16931
+ }
16932
+ }
16933
+
1563816934 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1563916935
1564016936 // trying different ways of getting the depth info over
....@@ -15682,6 +16978,8 @@
1568216978 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1568316979 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1568416980 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16981
+
16982
+ CreateSelectedPoint();
1568516983
1568616984 // Will fit the mesh !!!
1568716985 selectedpoint.toParent[0][0] = 0.0001;
....@@ -15731,34 +17029,36 @@
1573117029 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]));
1573217030 }
1573317031
15734
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
17032
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1573517033 }
1573617034 }
1573717035
1573817036 if (!movingcamera && !PAINTMODE)
15739
- object.editWindow.ScreenFitPoint(); // fev 2014
17037
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1574017038
15741
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
17039
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1574217040 {
15743
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
17041
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1574417042
15745
- Object3D group = new Object3D("inst" + paintcount++);
17043
+ if (object.GetWindow().copy.selection.Size() > 0)
17044
+ {
17045
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1574617046
15747
- group.CreateMaterial(); // use a void leaf to select instances
15748
-
15749
- group.add(paintobj); // link
15750
-
15751
- object.editWindow.SnapObject(group);
15752
-
15753
- Object3D folder = object.editWindow.copy;
15754
-
15755
- if (object.editWindow.copy.selection.Size() > 0)
15756
- folder = object.editWindow.copy.selection.elementAt(0);
15757
-
15758
- folder.add(group);
15759
-
15760
- object.editWindow.ResetModel();
15761
- object.editWindow.refreshContents();
17047
+ Object3D inst = new Object3D("inst" + paintcount++);
17048
+
17049
+ inst.CreateMaterial(); // use a void leaf to select instances
17050
+
17051
+ inst.add(paintobj); // link
17052
+
17053
+ object.GetWindow().SnapObject(inst);
17054
+
17055
+ Object3D folder = paintFolder; // GetFolder();
17056
+
17057
+ folder.add(inst);
17058
+
17059
+ object.GetWindow().ResetModel();
17060
+ object.GetWindow().refreshContents();
17061
+ }
1576217062 }
1576317063 else
1576417064 paintcount = 0;
....@@ -15797,6 +17097,11 @@
1579717097 //System.out.println("objects[color] = " + objects[color]);
1579817098 //objects[color].Select();
1579917099 indexcount = 0;
17100
+ ObjEditor window = object.GetWindow();
17101
+ if (window != null && deselect)
17102
+ {
17103
+ window.Select(null, deselect, true);
17104
+ }
1580017105 object.Select(color, deselect);
1580117106 }
1580217107
....@@ -15896,7 +17201,7 @@
1589617201 gl.glDisable(gl.GL_CULL_FACE);
1589717202 }
1589817203
15899
- if (!RENDERSHADOW)
17204
+ if (!Globals.RENDERSHADOW)
1590017205 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1590117206
1590217207 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -15906,7 +17211,7 @@
1590617211 //gl.glColorMask(false, false, false, false);
1590717212
1590817213 //render_scene_from_light_view(gl, drawable, 0, 0);
15909
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17214
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1591017215 {
1591117216 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1591217217
....@@ -15966,7 +17271,6 @@
1596617271
1596717272 class AntialiasBuffer implements GLEventListener
1596817273 {
15969
-
1597017274 CameraPane parent = null;
1597117275
1597217276 AntialiasBuffer(CameraPane p)
....@@ -16323,23 +17627,15 @@
1632317627 int AAbuffersize = 0;
1632417628
1632517629 //double[] selectedpoint = new double[3];
16326
- static Superellipsoid selectedpoint = new Superellipsoid();
17630
+ static Superellipsoid selectedpoint;
1632717631 static Sphere previousselectedpoint = null;
16328
- static Sphere debugpointG = new Sphere();
16329
- static Sphere debugpointP = new Sphere();
16330
- static Sphere debugpointC = new Sphere();
16331
- static Sphere debugpointR = new Sphere();
17632
+ static Sphere debugpointG;
17633
+ static Sphere debugpointP;
17634
+ static Sphere debugpointC;
17635
+ static Sphere debugpointR;
1633217636
1633317637 static Sphere debugpoints[] = new Sphere[8];
1633417638
16335
- static
16336
- {
16337
- for (int i=0; i<8; i++)
16338
- {
16339
- debugpoints[i] = new Sphere();
16340
- }
16341
- }
16342
-
1634317639 static void InitPoints(float radius)
1634417640 {
1634517641 for (int i=0; i<8; i++)
....@@ -16359,7 +17655,7 @@
1635917655 }
1636017656 }
1636117657
16362
- static void DrawPoints(CameraPane cpane)
17658
+ static void DrawPoints(iCameraPane cpane)
1636317659 {
1636417660 for (int i=0; i<8; i++) // first and last are red
1636517661 {
....@@ -16391,10 +17687,11 @@
1639117687 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1639217688 // Depth buffer format
1639317689 //private int depth_format;
16394
- static public void NextIndex(Object3D o, GL gl)
17690
+
17691
+ public void NextIndex()
1639517692 {
1639617693 indexcount+=16;
16397
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17694
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1639817695 //objects[indexcount] = o;
1639917696 //System.out.println("indexcount = " + indexcount);
1640017697 }