Normand Briere
2019-08-26 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a
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;
....@@ -76,7 +110,11 @@
76110 //private Mat4f spotlightTransform = new Mat4f();
77111 //private Mat4f spotlightInverseTransform = new Mat4f();
78112 static GLContext glcontext = null;
79
- /*static*/ com.sun.opengl.util.texture.Texture cubemap;
113
+ /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb
114
+ /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom;
115
+ /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb;
116
+ boolean transformMode;
117
+
80118 boolean reverseUP = false;
81119 static boolean frozen = false;
82120 boolean enablebackspace = false; // patch for back buffer refresh
....@@ -92,6 +130,8 @@
92130
93131 static int tickcount = 0; // slow pose issue
94132
133
+static boolean BUTTONLESSWHEEL = false;
134
+static boolean ZOOMBOXMODE = false;
95135 static boolean BOXMODE = false;
96136 static boolean IMAGEFLIP = false;
97137 static boolean SMOOTHFOCUS = false;
....@@ -106,7 +146,7 @@
106146 static boolean OEIL = true;
107147 static boolean OEILONCE = false; // do oeilon then oeiloff
108148 static boolean LOOKAT = true;
109
-static boolean RANDOM = true; // false;
149
+static boolean SWITCH = true; // false;
110150 static boolean HANDLES = false; // selection doesn't work!!
111151 static boolean PAINTMODE = false;
112152
....@@ -128,7 +168,7 @@
128168
129169
130170 // OPTIONS
131
- boolean Skinshader = true;
171
+ boolean Skinshader = false; // true;
132172 boolean cameraLight = false;
133173 boolean UVdebug = false;
134174 boolean Udebug = false;
....@@ -137,7 +177,7 @@
137177 static boolean doublesided = false; // true; // reversed normals are awful for conformance
138178 boolean anisotropy = true;
139179 boolean softshadow = true; // slower but better false;
140
- boolean opacityhalo = false;
180
+ boolean opacityhalo = false; // reverse the halo effect (e.g. glass)
141181
142182 boolean macromode = false;
143183
....@@ -149,12 +189,26 @@
149189 defaultcaps.setAccumBlueBits(16);
150190 defaultcaps.setAccumAlphaBits(16);
151191 }
152
- static CameraPane theRenderer;
192
+
193
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
153194
195
+ public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException
196
+ {
197
+ try
198
+ {
199
+ return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
200
+ } catch (IOException e)
201
+ {
202
+ System.out.println("NAME = " + name);
203
+ e.printStackTrace(); // throw new RuntimeException(e);
204
+ return null;
205
+ }
206
+ }
207
+
154208 void SetAsGLRenderer(boolean b)
155209 {
156210 isRenderer = b;
157
- theRenderer = this;
211
+ Globals.theRenderer = this;
158212 }
159213
160214 CameraPane(Object3D o, Camera cam, boolean withcontext)
....@@ -169,7 +223,8 @@
169223
170224 SetCamera(cam);
171225
172
- SetLight(new Camera(new cVector(10, 10, -20)));
226
+ // Warning: not used.
227
+ SetLight(new Camera(new cVector(15, 10, -20)));
173228
174229 object = o;
175230
....@@ -192,9 +247,43 @@
192247
193248 /// INTERFACE
194249
250
+ public javax.media.opengl.GL GetGL0()
251
+ {
252
+ return null;
253
+ }
254
+
255
+ public int GenList()
256
+ {
257
+ javax.media.opengl.GL gl = GetGL();
258
+ return gl.glGenLists(1);
259
+ }
260
+
261
+ public void NewList(int id)
262
+ {
263
+ javax.media.opengl.GL gl = GetGL();
264
+ gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE);
265
+ }
266
+
267
+ public void CallList(int id)
268
+ {
269
+ javax.media.opengl.GL gl = GetGL();
270
+ gl.glCallList(id);
271
+ }
272
+
273
+ public void EndList()
274
+ {
275
+ javax.media.opengl.GL gl = GetGL();
276
+ gl.glEndList();
277
+ }
278
+
195279 public boolean IsBoxMode()
196280 {
197281 return BOXMODE;
282
+ }
283
+
284
+ public boolean IsZoomBoxMode()
285
+ {
286
+ return ZOOMBOXMODE;
198287 }
199288
200289 public void ClearDepth()
....@@ -236,9 +325,14 @@
236325 return this.ambientOcclusion;
237326 }
238327
328
+ public boolean IsDebugSelection()
329
+ {
330
+ return DEBUG_SELECTION;
331
+ }
332
+
239333 public boolean IsFrozen()
240334 {
241
- boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
335
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
242336
243337 return !selectmode && cameracount == 0; // != 0;
244338 }
....@@ -259,9 +353,19 @@
259353 return lightCamera;
260354 }
261355
356
+ public Camera ManipCamera()
357
+ {
358
+ return manipCamera;
359
+ }
360
+
262361 public Camera RenderCamera()
263362 {
264363 return renderCamera;
364
+ }
365
+
366
+ public Camera[] Cameras()
367
+ {
368
+ return cameras;
265369 }
266370
267371 public void PushMaterial(Object3D obj, boolean selected)
....@@ -277,7 +381,7 @@
277381 cStatic.objectstack[materialdepth++] = obj;
278382 //System.out.println("material " + material);
279383 //Applet3D.tracein(this, selected);
280
- display.vector2buffer = obj.projectedVertices;
384
+ //display.vector2buffer = obj.projectedVertices;
281385 if (obj instanceof Camera)
282386 {
283387 display.options1[0] = material.shift;
....@@ -286,14 +390,28 @@
286390 display.options1[2] = material.shadowbias;
287391 display.options1[3] = material.aniso;
288392 display.options1[4] = material.anisoV;
393
+// System.out.println("display.options1[0] " + display.options1[0]);
394
+// System.out.println("display.options1[1] " + display.options1[1]);
395
+// System.out.println("display.options1[2] " + display.options1[2]);
396
+// System.out.println("display.options1[3] " + display.options1[3]);
397
+// System.out.println("display.options1[4] " + display.options1[4]);
289398 display.options2[0] = material.opacity;
290399 display.options2[1] = material.diffuse;
291400 display.options2[2] = material.factor;
401
+// System.out.println("display.options2[0] " + display.options2[0]);
402
+// System.out.println("display.options2[1] " + display.options2[1]);
403
+// System.out.println("display.options2[2] " + display.options2[2]);
292404
293405 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
406
+// System.out.println("display.options3[0] " + display.options3[0]);
407
+// System.out.println("display.options3[1] " + display.options3[1]);
408
+// System.out.println("display.options3[2] " + display.options3[2]);
294409 display.options4[0] = material.cameralight/0.2f;
295410 display.options4[1] = material.subsurface;
296411 display.options4[2] = material.sheen;
412
+// System.out.println("display.options4[0] " + display.options4[0]);
413
+// System.out.println("display.options4[1] " + display.options4[1]);
414
+// System.out.println("display.options4[2] " + display.options4[2]);
297415
298416 // if (display.CURRENTANTIALIAS > 0)
299417 // display.options3[3] /= 4;
....@@ -309,7 +427,7 @@
309427 /**/
310428 } else
311429 {
312
- DrawMaterial(material, selected);
430
+ DrawMaterial(material, selected, obj.projectedVertices);
313431 }
314432 } else
315433 {
....@@ -333,8 +451,8 @@
333451 cStatic.objectstack[materialdepth++] = obj;
334452 //System.out.println("material " + material);
335453 //Applet3D.tracein("selected ", selected);
336
- display.vector2buffer = obj.projectedVertices;
337
- display.DrawMaterial(material, selected);
454
+ //display.vector2buffer = obj.projectedVertices;
455
+ display.DrawMaterial(material, selected, obj.projectedVertices);
338456 }
339457 }
340458
....@@ -351,8 +469,8 @@
351469 materialdepth -= 1;
352470 if (materialdepth > 0)
353471 {
354
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
355
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
472
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
473
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
356474 }
357475 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
358476 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -372,8 +490,8 @@
372490 materialdepth -= 1;
373491 if (materialdepth > 0)
374492 {
375
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
376
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
493
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
494
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
377495 }
378496 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
379497 //else
....@@ -408,21 +526,24 @@
408526
409527 javax.media.opengl.GL gl = display.GetGL();
410528
411
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
529
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
412530
413531 //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
414532 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
415533 {
416534 //gl.glBegin(gl.GL_TRIANGLES);
417
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
535
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
536
+ // TEST LIVE NORMALS && !obj.dontselect
537
+ ;
418538 if (!hasnorm)
419539 {
420
- // System.out.println("FUCK!!");
540
+ // System.out.println("Mesh normal");
421541 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
422542 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
423543 LA.vecCross(obj.v0, obj.v1, obj.v2);
424544 LA.vecNormalize(obj.v2);
425
- gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
545
+
546
+ SetGLNormal(gl, (float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
426547 }
427548
428549 // P
....@@ -444,7 +565,7 @@
444565 y += ny * obj.NORMALPUSH;
445566 z += nz * obj.NORMALPUSH;
446567
447
- gl.glNormal3f(nx, ny, nz);
568
+ SetGLNormal(gl, nx, ny, nz);
448569 }
449570 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
450571 SetColor(obj, pv);
....@@ -476,7 +597,7 @@
476597 y += ny * obj.NORMALPUSH;
477598 z += nz * obj.NORMALPUSH;
478599
479
- gl.glNormal3f(nx, ny, nz);
600
+ SetGLNormal(gl, nx, ny, nz);
480601 }
481602 //System.out.println("vertexq = " + qv.s + ", " + qv.t);
482603 // boolean locked = false;
....@@ -524,7 +645,7 @@
524645 y += ny * obj.NORMALPUSH;
525646 z += nz * obj.NORMALPUSH;
526647
527
- gl.glNormal3f(nx, ny, nz);
648
+ SetGLNormal(gl, nx, ny, nz);
528649 }
529650
530651 // if ((dot&4) == 0)
....@@ -760,8 +881,630 @@
760881 //// tris.postdraw(this);
761882 }
762883
884
+ static Camera localAOcamera = new Camera();
885
+ static cVector from = new cVector();
886
+ static cVector to = new cVector();
887
+
888
+ public void PrepOcclusion(BoundaryRep br, double[][] transform)
889
+ {
890
+ CameraPane cp = this;
891
+
892
+ Camera keep = cp.RenderCamera();
893
+ cp.renderCamera = localAOcamera;
894
+
895
+ if (br.trimmed)
896
+ {
897
+ float[] colors = new float[br.positions.length / 3];
898
+
899
+ int i3 = 0;
900
+ for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
901
+ {
902
+ if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
903
+ continue;
904
+
905
+ from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
906
+ to.set(br.positions[i3] + br.normals[i3],
907
+ br.positions[i3 + 1] + br.normals[i3 + 1],
908
+ br.positions[i3 + 2] + br.normals[i3 + 2]);
909
+ LA.xformPos(from, transform, from);
910
+ LA.xformPos(to, transform, to); // RIGID ONLY
911
+ localAOcamera.setAim(from, to);
912
+
913
+ CameraPane.occlusionbuffer.display();
914
+
915
+ if (CameraPane.DEBUG_OCCLUSION)
916
+ cp.display(); // debug
917
+
918
+ colors[i] = cp.vertexOcclusion.r;
919
+ //colors[i3 + 1] = cp.vertexOcclusion.g;
920
+ //colors[i3 + 2] = cp.vertexOcclusion.b;
921
+
922
+ if ((i % 100) == 0 && i != 0)
923
+ {
924
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
925
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
926
+ System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
927
+ }
928
+ }
929
+
930
+ br.colors = colors;
931
+ }
932
+ else
933
+ {
934
+ for (int i = 0; i < br.VertexCount(); i++)
935
+ {
936
+ Vertex v = br.GetVertex(i);
937
+
938
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
939
+ continue;
940
+
941
+ from.set(v.x, v.y, v.z);
942
+ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
943
+ LA.xformPos(from, transform, from);
944
+ LA.xformPos(to, transform, to); // RIGID ONLY
945
+ localAOcamera.setAim(from, to);
946
+
947
+ CameraPane.occlusionbuffer.display();
948
+
949
+ if (CameraPane.DEBUG_OCCLUSION)
950
+ cp.display(); // debug
951
+
952
+ v.AO = cp.vertexOcclusion.r;
953
+
954
+ if ((i % 100) == 0 && i != 0)
955
+ {
956
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
957
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
958
+ System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
959
+ }
960
+ }
961
+ }
962
+
963
+ //System.out.println("done.");
964
+
965
+ cp.renderCamera = keep;
966
+ }
967
+
968
+ void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
969
+ {
970
+ CameraPane display = this;
971
+ pointFlow.CreateHT();
972
+
973
+ float r = display.modelParams0[0];
974
+ float g = display.modelParams0[1];
975
+ float b = display.modelParams0[2];
976
+ float opacity = display.modelParams5[1];
977
+
978
+ //final GL gl = GLU.getCurrentGL();
979
+ GL gl = display.GetGL(); // getGL();
980
+
981
+ int s = pointFlow.points.size();
982
+
983
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
984
+ gl.glEnable(gl.GL_CULL_FACE);
985
+
986
+ for (int i=s; --i>=0;)
987
+ //for (int i=0; i<s; i++)
988
+ {
989
+ cVector v = pointFlow.points.get(i);
990
+
991
+ double mindist = Double.MAX_VALUE;
992
+
993
+ double size = pointFlow.minimumSize;
994
+
995
+ double distancenext = 0;
996
+
997
+ if (i > 0)
998
+ {
999
+ cVector w = pointFlow.points.get(i-1);
1000
+
1001
+ double dist = w.distance(v);
1002
+
1003
+ distancenext = dist;
1004
+
1005
+ if (mindist > dist)
1006
+ {
1007
+ mindist = dist;
1008
+ size = mindist*pointFlow.resizefactor;
1009
+ }
1010
+ }
1011
+
1012
+ if (i < s-1)
1013
+ {
1014
+ cVector w = pointFlow.points.get(i+1);
1015
+
1016
+ double dist = w.distance(v);
1017
+
1018
+ if (mindist > dist)
1019
+ {
1020
+ mindist = dist;
1021
+ size = mindist*pointFlow.resizefactor;
1022
+ }
1023
+ }
1024
+
1025
+ if (size < pointFlow.minimumSize)
1026
+ size = pointFlow.minimumSize;
1027
+ if (size > pointFlow.maximumSize)
1028
+ size = pointFlow.maximumSize;
1029
+
1030
+ double tx = v.x;
1031
+ double ty = v.y;
1032
+ double tz = v.z;
1033
+
1034
+ // if (tx == 0 && ty == 0 && tz == 0)
1035
+ // continue;
1036
+
1037
+ gl.glMatrixMode(gl.GL_TEXTURE);
1038
+ gl.glPushMatrix();
1039
+ pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
1040
+
1041
+ gl.glMultMatrixf(pointFlow.texmat, 0);
1042
+
1043
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1044
+ gl.glPushMatrix();
1045
+
1046
+ gl.glTranslated(tx,ty,tz);
1047
+
1048
+ gl.glScaled(size,size,size);
1049
+
1050
+// float cr = colorBuf.get(index4);
1051
+// float cg = colorBuf.get(index4+1);
1052
+// float cb = colorBuf.get(index4+2);
1053
+// float ca = colorBuf.get(index4+3);
1054
+//
1055
+// display.modelParams0[0] = r * cr;
1056
+// display.modelParams0[1] = g * cg;
1057
+// display.modelParams0[2] = b * cb;
1058
+//
1059
+// display.modelParams5[1] = opacity * ca;
1060
+//
1061
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1062
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1063
+//
1064
+// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
1065
+// RandomNode.globalseed2 = RandomNode.globalseed;
1066
+//
1067
+//// gl.glColor4f(cr,cg,cb,ca);
1068
+// // gl.glScalef(1024/16,1024/16,1024/16);
1069
+ pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
1070
+
1071
+ gl.glPopMatrix();
1072
+
1073
+ double step = size/4; //
1074
+
1075
+ if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
1076
+ continue;
1077
+
1078
+ int nbsteps = (int)(distancenext/step);
1079
+
1080
+ step = distancenext/nbsteps;
1081
+
1082
+ cVector next = pointFlow.points.get(i-1);
1083
+
1084
+ tmp.set(next);
1085
+ tmp.sub(v);
1086
+ tmp.normalize();
1087
+ tmp.mul(step);
1088
+
1089
+ // calculate next size
1090
+ mindist = Double.MAX_VALUE;
1091
+
1092
+ double nextsize = pointFlow.minimumSize;
1093
+
1094
+ if (i > 1)
1095
+ {
1096
+ cVector w = pointFlow.points.get(i-2);
1097
+
1098
+ double dist = w.distance(next);
1099
+
1100
+ if (mindist > dist)
1101
+ {
1102
+ mindist = dist;
1103
+ nextsize = mindist*pointFlow.resizefactor;
1104
+ }
1105
+ }
1106
+
1107
+ double dist = v.distance(next);
1108
+
1109
+ if (mindist > dist)
1110
+ {
1111
+ mindist = dist;
1112
+ nextsize = mindist*pointFlow.resizefactor;
1113
+ }
1114
+
1115
+ if (nextsize < pointFlow.minimumSize)
1116
+ nextsize = pointFlow.minimumSize;
1117
+ if (nextsize > pointFlow.maximumSize)
1118
+ nextsize = pointFlow.maximumSize;
1119
+ //
1120
+
1121
+ double count = 0;
1122
+
1123
+ while (distancenext > 0.000000001) // step
1124
+ {
1125
+ gl.glPushMatrix();
1126
+
1127
+ gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
1128
+
1129
+ double K = count/nbsteps;
1130
+
1131
+ double intersize = K*nextsize + (1-K)*size;
1132
+
1133
+ gl.glScaled(intersize,intersize,intersize);
1134
+
1135
+ pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
1136
+
1137
+ count++;
1138
+
1139
+ distancenext -= step;
1140
+
1141
+ gl.glPopMatrix();
1142
+ }
1143
+
1144
+ if (count != nbsteps)
1145
+ assert(count == nbsteps);
1146
+
1147
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
1148
+ //gl.glTranslatef(-tx,-ty,-tz);
1149
+
1150
+ gl.glMatrixMode(gl.GL_TEXTURE);
1151
+ gl.glPopMatrix();
1152
+ }
1153
+
1154
+ if (!cf)
1155
+ gl.glDisable(gl.GL_CULL_FACE);
1156
+
1157
+// display.modelParams0[0] = r;
1158
+// display.modelParams0[1] = g;
1159
+// display.modelParams0[2] = b;
1160
+//
1161
+// display.modelParams5[1] = opacity;
1162
+//
1163
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1164
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1165
+
1166
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1167
+ }
1168
+
1169
+ public void DrawBox(cVector min, cVector max)
1170
+ {
1171
+ javax.media.opengl.GL gl = GetGL();
1172
+ gl.glBegin(gl.GL_LINES);
1173
+
1174
+ gl.glVertex3d(min.x, min.y, min.z);
1175
+ gl.glVertex3d(min.x, min.y, max.z);
1176
+ gl.glVertex3d(min.x, min.y, min.z);
1177
+ gl.glVertex3d(min.x, max.y, min.z);
1178
+ gl.glVertex3d(min.x, min.y, min.z);
1179
+ gl.glVertex3d(max.x, min.y, min.z);
1180
+
1181
+ gl.glVertex3d(max.x, max.y, max.z);
1182
+ gl.glVertex3d(min.x, max.y, max.z);
1183
+ gl.glVertex3d(max.x, max.y, max.z);
1184
+ gl.glVertex3d(max.x, min.y, max.z);
1185
+ gl.glVertex3d(max.x, max.y, max.z);
1186
+ gl.glVertex3d(max.x, max.y, min.z);
1187
+
1188
+ gl.glEnd();
1189
+ }
1190
+
1191
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1192
+ {
1193
+ int[] strips = bRep.getRawIndices();
1194
+
1195
+ javax.media.opengl.GL gl = GetGL();
1196
+
1197
+ // TRIANGLE STRIP ARRAY
1198
+ if (bRep.trimmed)
1199
+ {
1200
+ float[] v = bRep.getRawVertices();
1201
+ float[] n = bRep.getRawNormals();
1202
+ float[] c = bRep.getRawColors();
1203
+ float[] uv = bRep.getRawUVMap();
1204
+
1205
+ int count2 = 0;
1206
+ int count3 = 0;
1207
+
1208
+ if (n.length > 0)
1209
+ {
1210
+ for (int i = 0; i < strips.length; i++)
1211
+ {
1212
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1213
+
1214
+ /*
1215
+ boolean locked = false;
1216
+ float eps = 0.1f;
1217
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1218
+
1219
+ int dot = 0;
1220
+
1221
+ if ((dot&1) == 0)
1222
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1223
+
1224
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1225
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1226
+ else
1227
+ {
1228
+ locked = true;
1229
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1230
+ }
1231
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1232
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1233
+ if (hasnorm)
1234
+ {
1235
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1236
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1237
+ }
1238
+
1239
+ if ((dot&4) == 0)
1240
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1241
+
1242
+ if (wrap || !locked && (dot&8) != 0)
1243
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1244
+ else
1245
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1246
+
1247
+ f.dot = dot;
1248
+ */
1249
+
1250
+ if (!selectmode)
1251
+ {
1252
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1253
+ {
1254
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
1255
+ } else
1256
+ {
1257
+ SetGLNormal(gl, 0, 0, 1);
1258
+ }
1259
+
1260
+ if (c != null)
1261
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1262
+ {
1263
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1264
+ }
1265
+ }
1266
+
1267
+ if (flipV)
1268
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1269
+ else
1270
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1271
+
1272
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1273
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1274
+
1275
+ count2 += 2;
1276
+ count3 += 3;
1277
+ if (!selectmode)
1278
+ {
1279
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1280
+ {
1281
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
1282
+ } else
1283
+ {
1284
+ SetGLNormal(gl, 0, 0, 1);
1285
+ }
1286
+ if (c != null)
1287
+ {
1288
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1289
+ }
1290
+ }
1291
+
1292
+ if (flipV)
1293
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1294
+ else
1295
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1296
+
1297
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1298
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1299
+
1300
+ count2 += 2;
1301
+ count3 += 3;
1302
+ for (int j = 0; j < strips[i] - 2; j++)
1303
+ {
1304
+ //gl.glTexCoord2d(...);
1305
+ if (!selectmode)
1306
+ {
1307
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1308
+ {
1309
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
1310
+ } else
1311
+ {
1312
+ SetGLNormal(gl, 0, 0, 1);
1313
+ }
1314
+ if (c != null)
1315
+ {
1316
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1317
+ }
1318
+ }
1319
+
1320
+ if (flipV)
1321
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1322
+ else
1323
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1324
+
1325
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1326
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1327
+
1328
+ count2 += 2;
1329
+ count3 += 3;
1330
+ }
1331
+
1332
+ gl.glEnd();
1333
+ }
1334
+ }
1335
+
1336
+ assert count3 == v.length;
1337
+ }
1338
+ else // !trimmed
1339
+ {
1340
+ int count = 0;
1341
+ for (int i = 0; i < strips.length; i++)
1342
+ {
1343
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1344
+
1345
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1346
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1347
+
1348
+ drawVertex(gl, p, flipV, selectmode);
1349
+ drawVertex(gl, q, flipV, selectmode);
1350
+
1351
+ for (int j = 0; j < strips[i] - 2; j++)
1352
+ {
1353
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1354
+
1355
+ // if (j%2 == 0)
1356
+ // drawFace(p, q, r, display, null);
1357
+ // else
1358
+ // drawFace(p, r, q, display, null);
1359
+
1360
+ // p = q;
1361
+ // q = r;
1362
+ drawVertex(gl, r, flipV, selectmode);
1363
+ }
1364
+
1365
+ gl.glEnd();
1366
+ }
1367
+ }
1368
+ }
1369
+
1370
+ static cSpring.Point3D temp = new cSpring.Point3D();
1371
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1372
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1373
+
1374
+ public void DrawDynamicMesh(cMesh mesh)
1375
+ {
1376
+ GL gl = GetGL(); // getGL();
1377
+
1378
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1379
+
1380
+ gl.glDisable(gl.GL_LIGHTING);
1381
+
1382
+ gl.glLineWidth(1);
1383
+ gl.glColor3f(1,1,1);
1384
+ gl.glBegin(gl.GL_LINES);
1385
+ double scale = 0;
1386
+ int count = 0;
1387
+ for (int s=0; s<Phys.allSprings.size(); s++)
1388
+ {
1389
+ cSpring.Spring spring = Phys.allSprings.get(s);
1390
+ if(s == 0)
1391
+ {
1392
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1393
+ }
1394
+ if (mesh.showsprings)
1395
+ {
1396
+ temp.set(spring.a.position);
1397
+ temp.add(spring.b.position);
1398
+ temp.mul(0.5);
1399
+ temp2.set(spring.a.position);
1400
+ temp2.sub(spring.b.position);
1401
+ temp2.mul(spring.restLength/2);
1402
+ temp.sub(temp2);
1403
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1404
+ temp.add(temp2);
1405
+ temp.add(temp2);
1406
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1407
+ }
1408
+
1409
+ if (spring.isHandle)
1410
+ continue;
1411
+
1412
+ //if (scale < spring.restLength)
1413
+ scale += spring.restLength;
1414
+ count++;
1415
+ }
1416
+ gl.glEnd();
1417
+
1418
+ if (count == 0)
1419
+ scale = 0.01;
1420
+ else
1421
+ scale /= count * 3;
1422
+
1423
+ //scale = 0.25;
1424
+
1425
+ if (mesh.ShowInfo())
1426
+ {
1427
+ gl.glLineWidth(4);
1428
+ for (int s=0; s<Phys.allNodes.size(); s++)
1429
+ {
1430
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1431
+ if (node.mass == 0)
1432
+ continue;
1433
+
1434
+ int i = node.springs==null?-1:node.springs.size();
1435
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1436
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1437
+ //temp.normalize();
1438
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1439
+ gl.glBegin(gl.GL_LINES);
1440
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1441
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1442
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1443
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1444
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1445
+ gl.glEnd();
1446
+ }
1447
+
1448
+ gl.glLineWidth(8);
1449
+ for (int s=0; s<Phys.allNodes.size(); s++)
1450
+ {
1451
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1452
+
1453
+ if (node.springs != null)
1454
+ {
1455
+ for (int i=0; i<node.springs.size(); i+=1)
1456
+ {
1457
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1458
+
1459
+ int c = i+1;
1460
+ // c = node.springs.get(i).nbcopies;
1461
+
1462
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1463
+ gl.glBegin(gl.GL_LINES);
1464
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1465
+ 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);
1466
+ gl.glEnd();
1467
+ }
1468
+ }
1469
+ }
1470
+
1471
+ gl.glLineWidth(1);
1472
+ }
1473
+
1474
+ gl.glEnable(gl.GL_LIGHTING);
1475
+ }
1476
+
7631477 /// INTERFACE
7641478
1479
+ public void StartTriangles()
1480
+ {
1481
+ javax.media.opengl.GL gl = GetGL();
1482
+ gl.glBegin(gl.GL_TRIANGLES);
1483
+ }
1484
+
1485
+ public void EndTriangles()
1486
+ {
1487
+ GetGL().glEnd();
1488
+ }
1489
+
1490
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1491
+ {
1492
+ if (!selectmode)
1493
+ {
1494
+ SetGLNormal(gl, (float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1495
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1496
+
1497
+ if (flipV)
1498
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1499
+ else
1500
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1501
+ }
1502
+
1503
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1504
+ }
1505
+
1506
+ float[] colorV = new float[4];
1507
+
7651508 void SetColor(Object3D obj, Vertex p0)
7661509 {
7671510 CameraPane display = this;
....@@ -829,8 +1572,6 @@
8291572 {
8301573 return;
8311574 }
832
-
833
- float[] colorV = new float[3];
8341575
8351576 if (false) // marked)
8361577 {
....@@ -939,7 +1680,7 @@
9391680 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
9401681 }
9411682
942
- void DrawMaterial(cMaterial material, boolean selected)
1683
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
9431684 {
9441685 CameraPane display = this;
9451686 //new Exception().printStackTrace();
....@@ -955,18 +1696,18 @@
9551696 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
9561697 if (!material.multiply)
9571698 {
958
- display.color = color;
1699
+ display.color = material.color;
9591700 display.saturation = material.modulation;
9601701 }
9611702 else
9621703 {
963
- display.color *= color*2;
1704
+ display.color *= material.color*2;
9641705 display.saturation *= material.modulation*2;
9651706 }
9661707
9671708 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
9681709
969
- float[] colorV = GrafreeD.colorV;
1710
+ float[] colorV = Grafreed.colorV;
9701711
9711712 /**/
9721713 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -974,7 +1715,7 @@
9741715 colorV[0] = display.modelParams0[0] * material.diffuse;
9751716 colorV[1] = display.modelParams0[1] * material.diffuse;
9761717 colorV[2] = display.modelParams0[2] * material.diffuse;
977
- colorV[3] = material.opacity;
1718
+ colorV[3] = 1; // material.opacity;
9781719
9791720 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
9801721 //System.out.println("Opacity = " + opacity);
....@@ -1079,12 +1820,12 @@
10791820
10801821 display.modelParams7[0] = 0;
10811822 display.modelParams7[1] = 1000;
1082
- display.modelParams7[2] = 0;
1823
+ display.modelParams7[2] = material.parallax;
10831824 display.modelParams7[3] = 0;
10841825
1085
- display.modelParams6[0] = 100; // criss de bug de bump
1826
+ //display.modelParams6[0] = 100; // criss de bug de bump
10861827
1087
- Object3D.cVector2[] extparams = display.vector2buffer;
1828
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
10881829 if (extparams != null && extparams.length > 0 && extparams[0] != null)
10891830 {
10901831 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1226,7 +1967,7 @@
12261967 void PushMatrix(double[][] matrix)
12271968 {
12281969 // GrafreeD.tracein(matrix);
1229
- PushMatrix(matrix,1);
1970
+ PushMatrix(matrix, 1);
12301971 }
12311972
12321973 void PushMatrix()
....@@ -1312,9 +2053,9 @@
13122053 switch(viewcode)
13132054 {
13142055 case 0: return "main";
1315
- case 1: return "one";
1316
- case 2: return "two";
1317
- case 3: return "three";
2056
+ case 1: return "Red";
2057
+ case 2: return "Green";
2058
+ case 3: return "Blue";
13182059 case 4: return "light";
13192060 }
13202061
....@@ -1323,7 +2064,7 @@
13232064
13242065 static int camerachangeframe;
13252066
1326
- boolean SetCamera(Camera cam)
2067
+ public boolean SetCamera(Camera cam)
13272068 {
13282069 // may 2014 if (cam == cameras[0] || cam == cameras[1])
13292070 // return false;
....@@ -1380,7 +2121,7 @@
13802121 //System.err.println("Oeil on");
13812122 OEIL = true;
13822123 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
1383
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2124
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13842125 //pingthread.StepToTarget(true);
13852126 }
13862127
....@@ -1451,33 +2192,6 @@
14512192 mainDL ^= true;
14522193 }
14532194
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
-
14812195 void ToggleFullScreen()
14822196 {
14832197 FULLSCREEN ^= true;
....@@ -1488,72 +2202,94 @@
14882202 Globals.CROWD ^= true;
14892203 }
14902204
1491
- void ToggleInertia()
1492
- {
1493
- INERTIA ^= true;
1494
- }
1495
-
14962205 void ToggleLocal()
14972206 {
14982207 LOCALTRANSFORM ^= true;
14992208 }
15002209
1501
- void ToggleFast()
2210
+ public void ToggleTexture()
2211
+ {
2212
+ textureon ^= true;
2213
+ }
2214
+
2215
+ public void ToggleLive()
2216
+ {
2217
+ Globals.setLIVE(Globals.isLIVE() ^ true);
2218
+
2219
+ System.err.println("LIVE = " + Globals.isLIVE());
2220
+
2221
+ if (!Globals.isLIVE()) // save sound
2222
+ Grafreed.savesound = true; // wav.save();
2223
+ // else
2224
+ repaint(); // start loop // may 2013
2225
+ }
2226
+
2227
+ public void ToggleSupport()
2228
+ {
2229
+ SUPPORT ^= true;
2230
+ }
2231
+
2232
+ public void ToggleAbort()
2233
+ {
2234
+ ABORTMODE ^= true;
2235
+ }
2236
+
2237
+ public void ToggleInertia()
2238
+ {
2239
+ INERTIA ^= true;
2240
+ }
2241
+
2242
+ public void ToggleFast()
15022243 {
15032244 FAST ^= true;
15042245 }
15052246
1506
- void ToggleSlowPose()
2247
+ public void ToggleSlowPose()
15072248 {
15082249 SLOWPOSE ^= true;
15092250 }
15102251
1511
- void ToggleFootContact()
1512
- {
1513
- FOOTCONTACT ^= true;
1514
- }
1515
-
1516
- void ToggleBoxMode()
2252
+ public void ToggleBoxMode()
15172253 {
15182254 BOXMODE ^= true;
15192255 }
15202256
1521
- void ToggleSmoothFocus()
2257
+ public void ToggleZoomBoxMode()
2258
+ {
2259
+ ZOOMBOXMODE ^= true;
2260
+ }
2261
+
2262
+ public void ToggleSmoothFocus()
15222263 {
15232264 SMOOTHFOCUS ^= true;
15242265 }
15252266
1526
- void ToggleImageFlip()
2267
+ public void ToggleImageFlip()
15272268 {
15282269 IMAGEFLIP ^= true;
15292270 }
15302271
1531
- void ToggleSpeakerMocap()
2272
+ public void ToggleSpeakerMocap()
15322273 {
15332274 SPEAKERMOCAP ^= true;
15342275 }
15352276
1536
- void ToggleSpeakerCamera()
2277
+ public void ToggleSpeakerCamera()
15372278 {
15382279 SPEAKERCAMERA ^= true;
15392280 }
15402281
1541
- void ToggleSpeakerFocus()
2282
+ public void ToggleSpeakerFocus()
15422283 {
15432284 SPEAKERFOCUS ^= true;
15442285 }
15452286
1546
- void ToggleDebug()
1547
- {
1548
- DEBUG ^= true;
1549
- }
1550
-
1551
- void ToggleFrustum()
2287
+ public void ToggleFrustum()
15522288 {
15532289 FRUSTUM ^= true;
15542290 }
15552291
1556
- void ToggleTrack()
2292
+ public void ToggleTrack()
15572293 {
15582294 TRACK ^= true;
15592295 if (TRACK)
....@@ -1572,25 +2308,35 @@
15722308 repaint();
15732309 }
15742310
1575
- void ToggleTrackOnce()
2311
+ public void ToggleTrackOnce()
15762312 {
15772313 TRACKONCE ^= true;
15782314 }
15792315
1580
- void ToggleShadowTrack()
2316
+ public void ToggleShadowTrack()
15812317 {
15822318 SHADOWTRACK ^= true;
15832319 repaint();
15842320 }
15852321
1586
- void ToggleOeil()
2322
+ public void ToggleOeil()
15872323 {
15882324 OEIL ^= true;
15892325 }
15902326
1591
- void ToggleOeilOnce()
2327
+ public void ToggleOeilOnce()
15922328 {
15932329 OEILONCE ^= true;
2330
+ }
2331
+
2332
+ void ToggleFootContact()
2333
+ {
2334
+ FOOTCONTACT ^= true;
2335
+ }
2336
+
2337
+ void ToggleDebug()
2338
+ {
2339
+ Globals.DEBUG ^= true;
15942340 }
15952341
15962342 void ToggleLookAt()
....@@ -1598,9 +2344,9 @@
15982344 LOOKAT ^= true;
15992345 }
16002346
1601
- void ToggleRandom()
2347
+ void ToggleSwitch()
16022348 {
1603
- RANDOM ^= true;
2349
+ SWITCH ^= true;
16042350 }
16052351
16062352 void ToggleHandles()
....@@ -1608,10 +2354,17 @@
16082354 HANDLES ^= true;
16092355 }
16102356
2357
+ Object3D paintFolder;
2358
+
16112359 void TogglePaint()
16122360 {
16132361 PAINTMODE ^= true;
16142362 paintcount = 0;
2363
+
2364
+ if (PAINTMODE)
2365
+ {
2366
+ paintFolder = GetFolder();
2367
+ }
16152368 }
16162369
16172370 void SwapCamera(int a, int b)
....@@ -1707,7 +2460,34 @@
17072460 {
17082461 return currentGL;
17092462 }
1710
-
2463
+
2464
+ static private BufferedImage CreateBim(TextureData texturedata)
2465
+ {
2466
+ Grafreed.Assert(texturedata != null);
2467
+
2468
+ int width = texturedata.getWidth();
2469
+ int height = texturedata.getHeight();
2470
+
2471
+ Buffer buffer = texturedata.getBuffer();
2472
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2473
+
2474
+ byte[] bytes = bytebuf.array();
2475
+
2476
+ return CreateBim(bytes, width, height);
2477
+ }
2478
+
2479
+ private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz)
2480
+ {
2481
+ gl.glNormal3f(nx, ny, nz);
2482
+
2483
+ if (ny > 0.9 || ny < -0.9)
2484
+ // Ground or ceiling
2485
+ gl.glVertexAttrib3f(4, 1, 0, 0);
2486
+ else
2487
+ // Walls
2488
+ gl.glVertexAttrib3f(4, 0, 1, 0);
2489
+ }
2490
+
17112491 /**/
17122492 class CacheTexture
17132493 {
....@@ -1716,28 +2496,31 @@
17162496
17172497 int resolution;
17182498
1719
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2499
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
17202500 {
1721
- texture = tex;
2501
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2502
+ texturedata = texdata;
17222503 resolution = res;
17232504 }
17242505 }
17252506 /**/
17262507
17272508 // 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>();
2509
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2510
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2511
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2512
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2513
+
17312514 int pigmentdepth = 0;
17322515 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
17332516 int bumpdepth = 0;
17342517 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
17352518 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
17362519 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
1737
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2520
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
17382521 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
17392522
1740
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2523
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
17412524 {
17422525 TextureData texturedata = null;
17432526
....@@ -1747,7 +2530,7 @@
17472530 com.sun.opengl.util.texture.TextureIO.newTextureData(
17482531 getClass().getClassLoader().getResourceAsStream(name),
17492532 true,
1750
- com.sun.opengl.util.texture.TextureIO.PNG);
2533
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
17512534 } catch (java.io.IOException e)
17522535 {
17532536 throw new javax.media.opengl.GLException(e);
....@@ -1756,13 +2539,34 @@
17562539 if (bump)
17572540 texturedata = ConvertBump(texturedata, false);
17582541
1759
- com.sun.opengl.util.texture.Texture texture =
1760
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2542
+// com.sun.opengl.util.texture.Texture texture =
2543
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
17612544
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);
2545
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2546
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
17642547
1765
- return texture;
2548
+ return texturedata;
2549
+ }
2550
+
2551
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2552
+ {
2553
+ TextureData texturedata = null;
2554
+
2555
+ try
2556
+ {
2557
+ texturedata =
2558
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2559
+ bim,
2560
+ true);
2561
+ } catch (Exception e)
2562
+ {
2563
+ throw new javax.media.opengl.GLException(e);
2564
+ }
2565
+
2566
+ if (bump)
2567
+ texturedata = ConvertBump(texturedata, false);
2568
+
2569
+ return texturedata;
17662570 }
17672571
17682572 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -2835,6 +3639,8 @@
28353639
28363640 System.out.println("LOADING TEXTURE : " + name);
28373641
3642
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3643
+
28383644 //
28393645 if (false) // compressbit > 0)
28403646 {
....@@ -3539,6 +4345,7 @@
35394345
35404346 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
35414347 {
4348
+ new Exception().printStackTrace();
35424349 System.exit(0);
35434350 com.sun.opengl.util.texture.Texture texture = null;
35444351
....@@ -7232,7 +8039,7 @@
72328039 String pigment = Object3D.GetPigment(tex);
72338040 String bump = Object3D.GetBump(tex);
72348041
7235
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8042
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
72368043 {
72378044 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
72388045 // System.out.println("; bump = " + bump);
....@@ -7247,11 +8054,69 @@
72478054 pigment = null;
72488055 }
72498056
7250
- ReleaseTexture(bump, true);
7251
- ReleaseTexture(pigment, false);
8057
+ ReleaseTexture(tex, true);
8058
+ ReleaseTexture(tex, false);
72528059 }
72538060
7254
- void ReleaseTexture(String tex, boolean bump)
8061
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
8062
+ {
8063
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8064
+ {
8065
+ return;
8066
+ }
8067
+
8068
+ if (tex == null)
8069
+ {
8070
+ ReleaseTexture(null, false);
8071
+ return;
8072
+ }
8073
+
8074
+ String pigment = Object3D.GetPigment(tex);
8075
+
8076
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8077
+ {
8078
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8079
+ // System.out.println("; bump = " + bump);
8080
+ }
8081
+
8082
+ if (pigment.equals(""))
8083
+ {
8084
+ pigment = null;
8085
+ }
8086
+
8087
+ ReleaseTexture(tex, false);
8088
+ }
8089
+
8090
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8091
+ {
8092
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8093
+ {
8094
+ return;
8095
+ }
8096
+
8097
+ if (tex == null)
8098
+ {
8099
+ ReleaseTexture(null, true);
8100
+ return;
8101
+ }
8102
+
8103
+ String bump = Object3D.GetBump(tex);
8104
+
8105
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8106
+ {
8107
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8108
+ // System.out.println("; bump = " + bump);
8109
+ }
8110
+
8111
+ if (bump.equals(""))
8112
+ {
8113
+ bump = null;
8114
+ }
8115
+
8116
+ ReleaseTexture(tex, true);
8117
+ }
8118
+
8119
+ void ReleaseTexture(cTexture tex, boolean bump)
72558120 {
72568121 if (// DrawMode() != 0 || /*tex == null ||*/
72578122 ambientOcclusion ) // || !textureon)
....@@ -7262,7 +8127,7 @@
72628127 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
72638128
72648129 if (tex != null)
7265
- texture = textures.get(tex);
8130
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
72668131
72678132 // //assert( texture != null );
72688133 // if (texture == null)
....@@ -7354,7 +8219,55 @@
73548219 }
73558220 }
73568221
7357
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8222
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
8223
+ {
8224
+// if (// DrawMode() != 0 || /*tex == null ||*/
8225
+// ambientOcclusion ) // || !textureon)
8226
+// {
8227
+// return; // false;
8228
+// }
8229
+//
8230
+// if (tex == null)
8231
+// {
8232
+// BindTexture(null,false,resolution);
8233
+// BindTexture(null,true,resolution);
8234
+// return;
8235
+// }
8236
+//
8237
+// String pigment = Object3D.GetPigment(tex);
8238
+// String bump = Object3D.GetBump(tex);
8239
+//
8240
+// usedtextures.add(pigment);
8241
+// usedtextures.add(bump);
8242
+//
8243
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8244
+// {
8245
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8246
+// // System.out.println("; bump = " + bump);
8247
+// }
8248
+//
8249
+// if (bump.equals(""))
8250
+// {
8251
+// bump = null;
8252
+// }
8253
+// if (pigment.equals(""))
8254
+// {
8255
+// pigment = null;
8256
+// }
8257
+//
8258
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8259
+// BindTexture(pigment, false, resolution);
8260
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8261
+// BindTexture(bump, true, resolution);
8262
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8263
+//
8264
+// return; // true;
8265
+
8266
+ BindPigmentTexture(tex, resolution);
8267
+ BindBumpTexture(tex, resolution);
8268
+ }
8269
+
8270
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
73588271 {
73598272 if (// DrawMode() != 0 || /*tex == null ||*/
73608273 ambientOcclusion ) // || !textureon)
....@@ -7365,17 +8278,47 @@
73658278 if (tex == null)
73668279 {
73678280 BindTexture(null,false,resolution);
7368
- BindTexture(null,true,resolution);
73698281 return;
73708282 }
73718283
73728284 String pigment = Object3D.GetPigment(tex);
8285
+
8286
+ usedtextures.add(tex);
8287
+
8288
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8289
+ {
8290
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8291
+ // System.out.println("; bump = " + bump);
8292
+ }
8293
+
8294
+ if (pigment.equals(""))
8295
+ {
8296
+ pigment = null;
8297
+ }
8298
+
8299
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8300
+ BindTexture(tex, false, resolution);
8301
+ }
8302
+
8303
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8304
+ {
8305
+ if (// DrawMode() != 0 || /*tex == null ||*/
8306
+ ambientOcclusion ) // || !textureon)
8307
+ {
8308
+ return; // false;
8309
+ }
8310
+
8311
+ if (tex == null)
8312
+ {
8313
+ BindTexture(null,true,resolution);
8314
+ return;
8315
+ }
8316
+
73738317 String bump = Object3D.GetBump(tex);
73748318
7375
- usedtextures.put(pigment, pigment);
7376
- usedtextures.put(bump, bump);
8319
+ usedtextures.add(tex);
73778320
7378
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8321
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
73798322 {
73808323 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
73818324 // System.out.println("; bump = " + bump);
....@@ -7385,43 +8328,94 @@
73858328 {
73868329 bump = null;
73878330 }
7388
- if (pigment.equals(""))
7389
- {
7390
- pigment = null;
7391
- }
73928331
7393
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
7394
- BindTexture(pigment, false, resolution);
73958332 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
7396
- BindTexture(bump, true, resolution);
8333
+ BindTexture(tex, true, resolution);
73978334 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
7398
-
7399
- return; // true;
74008335 }
74018336
7402
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8337
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8338
+
8339
+ private boolean FileExists(String tex)
74038340 {
7404
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8341
+ if (missingTextures.contains(tex))
8342
+ {
8343
+ return false;
8344
+ }
8345
+
8346
+ boolean fileExists = new File(tex).exists();
8347
+
8348
+ if (!fileExists)
8349
+ {
8350
+ // If file exists, the "new File()" is not executed sgain
8351
+ missingTextures.add(tex);
8352
+ }
8353
+
8354
+ return fileExists;
8355
+ }
8356
+
8357
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
8358
+ {
8359
+ CacheTexture texturecache = null;
74058360
74068361 if (tex != null)
74078362 {
7408
- String texname = tex;
8363
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8364
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
74098365
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;
8366
+ if (texname.equals("") && texdata == null)
8367
+ {
8368
+ return null;
8369
+ }
8370
+
8371
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8372
+
8373
+// String[] split = tex.split("Textures");
8374
+// if (split.length > 1)
8375
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8376
+// else
8377
+// if (!texname.startsWith("/"))
8378
+// texname = "/Users/nbriere/Textures/" + texname;
8379
+ if (!FileExists(texname) && !texname.startsWith("@"))
8380
+ {
8381
+ texname = fallbackTextureName;
8382
+ }
74168383
74178384 if (CACHETEXTURE)
7418
- texture = textures.get(texname); // TEXTURE CACHE
7419
-
7420
- TextureData texturedata = null;
7421
-
7422
- if (texture == null || texture.resolution < resolution)
74238385 {
7424
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8386
+ if (texdata == null)
8387
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8388
+ else
8389
+ texturecache = bimtextures.get(texdata);
8390
+ }
8391
+
8392
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8393
+ {
8394
+ TextureData texturedata = null;
8395
+
8396
+ if (texdata != null && textureon)
8397
+ {
8398
+ BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8399
+
8400
+ try
8401
+ {
8402
+ bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8403
+ }
8404
+ catch (Exception e)
8405
+ {
8406
+ bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8407
+ }
8408
+
8409
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8410
+ bimtextures.put(texdata, texturecache);
8411
+
8412
+ //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8413
+
8414
+ //Object bim2 = CreateBim(texturecache.texturedata);
8415
+ //bim2 = bim;
8416
+ }
8417
+ else
8418
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
74258419 {
74268420 assert(!bump);
74278421 // if (bump)
....@@ -7432,19 +8426,23 @@
74328426 // }
74338427 // else
74348428 // {
7435
- texture = textures.get(tex);
7436
- if (texture == null)
8429
+ // texturecache = textures.get(texname); // suspicious
8430
+ if (texturecache == null)
74378431 {
7438
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8432
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
74398433 }
8434
+ else
8435
+ new Exception().printStackTrace();
74408436 // }
74418437 } else
7442
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8438
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
74438439 {
74448440 assert(bump);
7445
- texture = textures.get(tex);
7446
- if (texture == null)
7447
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8441
+ // texturecache = textures.get(texname); // suspicious
8442
+ if (texturecache == null)
8443
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8444
+ else
8445
+ new Exception().printStackTrace();
74488446 } else
74498447 {
74508448 //if (tex.equals("IMMORTAL"))
....@@ -7452,11 +8450,22 @@
74528450 // texture = GetResourceTexture("default.png");
74538451 //} else
74548452 //{
7455
- if (tex.equals("WHITE_NOISE"))
8453
+ if (texname.endsWith("WHITE_NOISE"))
74568454 {
7457
- texture = textures.get(tex);
7458
- if (texture == null)
7459
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8455
+ // texturecache = textures.get(texname); // suspicious
8456
+ if (texturecache == null)
8457
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8458
+ else
8459
+ new Exception().printStackTrace();
8460
+ } else
8461
+ {
8462
+ if (texname.startsWith("@"))
8463
+ {
8464
+ // texturecache = textures.get(texname); // suspicious
8465
+ if (texturecache == null)
8466
+ texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution);
8467
+ else
8468
+ new Exception().printStackTrace();
74608469 } else
74618470 {
74628471 if (textureon)
....@@ -7481,7 +8490,7 @@
74818490 }
74828491
74838492 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
7484
- if (!new File(cachename).exists())
8493
+ if (!FileExists(cachename))
74858494 cachename = texname;
74868495 else
74878496 processbump = false; // don't process bump map again
....@@ -7503,7 +8512,7 @@
75038512 }
75048513
75058514 cachename = texname.substring(0, texname.length()-4)+ext+".png";
7506
- if (!new File(cachename).exists())
8515
+ if (!FileExists(cachename))
75078516 cachename = texname;
75088517 else
75098518 processbump = false; // don't process bump map again
....@@ -7512,20 +8521,23 @@
75128521 texturedata = GetFileTexture(cachename, processbump, resolution);
75138522
75148523
7515
- if (texturedata != null)
7516
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8524
+ if (texturedata == null)
8525
+ throw new Exception();
8526
+
8527
+ texturecache = new CacheTexture(texturedata,resolution);
75178528 //texture = GetTexture(tex, bump);
75188529 }
8530
+ }
75198531 }
75208532 //}
75218533 }
75228534
7523
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8535
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
75248536 {
75258537 //return false;
75268538
75278539 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
7528
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8540
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
75298541 {
75308542 // String ext = "_highres";
75318543 // if (REDUCETEXTURE)
....@@ -7542,52 +8554,17 @@
75428554 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
75438555 if (!cachefile.exists())
75448556 {
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))
8557
+ //if (texturedata.getWidth() == texturedata.getHeight())
75548558 {
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);
8559
+ BufferedImage rendImage = CreateBim(texturedata);
8560
+
75858561 ImageWriter writer = null;
75868562 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
75878563 if (iter.hasNext()) {
75888564 writer = (ImageWriter)iter.next();
75898565 }
7590
- float compressionQuality = 0.9f;
8566
+
8567
+ float compressionQuality = 0.85f;
75918568 try
75928569 {
75938570 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -7604,18 +8581,20 @@
76048581 }
76058582 }
76068583 }
7607
-
8584
+
8585
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8586
+
76088587 //System.out.println("Texture = " + tex);
7609
- if (textures.containsKey(texname))
8588
+ if (textures.containsKey(tex))
76108589 {
7611
- CacheTexture thetex = textures.get(texname);
8590
+ CacheTexture thetex = textures.get(tex);
76128591 thetex.texture.disable();
76138592 thetex.texture.dispose();
7614
- textures.remove(texname);
8593
+ textures.remove(tex);
76158594 }
76168595
7617
- texture.texturedata = texturedata;
7618
- textures.put(texname, texture);
8596
+ //texture.texturedata = texturedata;
8597
+ textures.put(tex, texturecache);
76198598
76208599 // newtex = true;
76218600 }
....@@ -7631,10 +8610,44 @@
76318610 }
76328611 }
76338612
7634
- return texture;
8613
+ return texturecache;
76358614 }
76368615
7637
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8616
+ static void EmbedTextures(cTexture tex)
8617
+ {
8618
+ if (tex.pigmentdata == null)
8619
+ {
8620
+ //String texname = Object3D.GetPigment(tex);
8621
+
8622
+ CacheTexture texturecache = texturepigment.get(tex);
8623
+
8624
+ if (texturecache != null)
8625
+ {
8626
+ tex.pw = texturecache.texturedata.getWidth();
8627
+ tex.ph = texturecache.texturedata.getHeight();
8628
+ tex.pigmentdata = //CompressJPEG(CreateBim
8629
+ ((ByteBuffer)texturecache.texturedata.getBuffer()).array()
8630
+ ;
8631
+ //, tex.pw, tex.ph), 0.5f);
8632
+ }
8633
+ }
8634
+
8635
+ if (tex.bumpdata == null)
8636
+ {
8637
+ //String texname = Object3D.GetBump(tex);
8638
+
8639
+ CacheTexture texturecache = texturebump.get(tex);
8640
+
8641
+ if (texturecache != null)
8642
+ {
8643
+ tex.bw = texturecache.texturedata.getWidth();
8644
+ tex.bh = texturecache.texturedata.getHeight();
8645
+ tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f);
8646
+ }
8647
+ }
8648
+ }
8649
+
8650
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
76388651 {
76398652 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
76408653
....@@ -7652,21 +8665,21 @@
76528665 return texture!=null?texture.texture:null;
76538666 }
76548667
7655
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8668
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
76568669 {
76578670 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
76588671
76598672 return texture!=null?texture.texturedata:null;
76608673 }
76618674
7662
- boolean BindTexture(String tex, boolean bump, int resolution)
8675
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
76638676 {
76648677 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
76658678 {
76668679 return false;
76678680 }
76688681
7669
- boolean newtex = false;
8682
+ //boolean newtex = false;
76708683
76718684 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
76728685
....@@ -7698,9 +8711,75 @@
76988711 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
76998712 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
77008713
7701
- return newtex;
8714
+ return true; // Warning: not used.
77028715 }
77038716
8717
+ public static byte[] CompressJPEG(BufferedImage image, float quality)
8718
+ {
8719
+ try
8720
+ {
8721
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
8722
+ Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg");
8723
+ ImageWriter writer = writers.next();
8724
+
8725
+ ImageWriteParam param = writer.getDefaultWriteParam();
8726
+ param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
8727
+ param.setCompressionQuality(quality);
8728
+
8729
+ ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
8730
+ writer.setOutput(ios);
8731
+ writer.write(null, new IIOImage(image, null, null), param);
8732
+
8733
+ byte[] data = baos.toByteArray();
8734
+ writer.dispose();
8735
+ return data;
8736
+ }
8737
+ catch (Exception e)
8738
+ {
8739
+ e.printStackTrace();
8740
+ return null;
8741
+ }
8742
+ }
8743
+
8744
+ public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException
8745
+ {
8746
+ ByteArrayInputStream baos = new ByteArrayInputStream(image);
8747
+ Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg");
8748
+ ImageReader reader = writers.next();
8749
+
8750
+ BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
8751
+
8752
+ ImageReadParam param = reader.getDefaultReadParam();
8753
+ param.setDestination(bim);
8754
+ //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB));
8755
+
8756
+ ImageInputStream ios = ImageIO.createImageInputStream(baos);
8757
+ reader.setInput(ios);
8758
+ BufferedImage bim2 = reader.read(0, param);
8759
+ reader.dispose();
8760
+
8761
+// WritableRaster raster = bim2.getRaster();
8762
+// DataBufferByte data = (DataBufferByte) raster.getDataBuffer();
8763
+// byte[] bytes = data.getData();
8764
+//
8765
+// int[] pixels = new int[bytes.length/3];
8766
+// for (int i=pixels.length; --i>=0;)
8767
+// {
8768
+// int i3 = i*3;
8769
+// pixels[i] = 0xFF;
8770
+// pixels[i] <<= 8;
8771
+// pixels[i] |= bytes[i3+2] & 0xFF;
8772
+// pixels[i] <<= 8;
8773
+// pixels[i] |= bytes[i3+1] & 0xFF;
8774
+// pixels[i] <<= 8;
8775
+// pixels[i] |= bytes[i3] & 0xFF;
8776
+// }
8777
+//
8778
+// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w);
8779
+
8780
+ return bim;
8781
+ }
8782
+
77048783 ShadowBuffer shadowPBuf;
77058784 AntialiasBuffer antialiasPBuf;
77068785 int MAXSTACK;
....@@ -7717,10 +8796,12 @@
77178796
77188797 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
77198798 MAXSTACK = temp[0];
7720
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8799
+ if (Globals.DEBUG)
8800
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
77218801 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
77228802 MAXSTACK = temp[0];
7723
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8803
+ if (Globals.DEBUG)
8804
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
77248805
77258806 // Use debug pipeline
77268807 //drawable.setGL(new DebugGL(gl)); //
....@@ -7728,7 +8809,8 @@
77288809 gl = drawable.getGL(); //
77298810
77308811 GL gl3 = getGL();
7731
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8812
+ if (Globals.DEBUG)
8813
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
77328814
77338815
77348816 //float pos[] = { 100, 100, 100, 0 };
....@@ -7893,7 +8975,7 @@
78938975
78948976 if (cubemap == null)
78958977 {
7896
- LoadEnvy(5);
8978
+ //LoadEnvy(1);
78978979 }
78988980
78998981 //cubemap.enable();
....@@ -8169,6 +9251,8 @@
81699251
81709252 void LoadEnvy(int which)
81719253 {
9254
+ assert(false);
9255
+
81729256 String name;
81739257 String ext;
81749258
....@@ -8180,37 +9264,58 @@
81809264 cubemap = null;
81819265 return;
81829266 case 1:
8183
- name = "cubemaps/box_";
8184
- ext = "png";
9267
+ name = "cubemaps/rgb/";
9268
+ ext = "jpg";
81859269 reverseUP = false;
81869270 break;
81879271 case 2:
8188
- name = "cubemaps/uffizi_";
8189
- ext = "png";
8190
- break; // reverseUP = true; break;
9272
+ name = "cubemaps/uffizi/";
9273
+ ext = "jpg";
9274
+ reverseUP = false;
9275
+ break;
81919276 case 3:
8192
- name = "cubemaps/CloudyHills_";
8193
- ext = "tga";
9277
+ name = "cubemaps/CloudyHills/";
9278
+ ext = "jpg";
81949279 reverseUP = false;
81959280 break;
81969281 case 4:
8197
- name = "cubemaps/cornell_";
9282
+ name = "cubemaps/cornell/";
81989283 ext = "png";
81999284 reverseUP = false;
82009285 break;
9286
+ case 5:
9287
+ name = "cubemaps/skycube/";
9288
+ ext = "jpg";
9289
+ reverseUP = false;
9290
+ break;
9291
+ case 6:
9292
+ name = "cubemaps/SaintLazarusChurch3/";
9293
+ ext = "jpg";
9294
+ reverseUP = false;
9295
+ break;
9296
+ case 7:
9297
+ name = "cubemaps/Sodermalmsallen/";
9298
+ ext = "jpg";
9299
+ reverseUP = false;
9300
+ break;
9301
+ case 8:
9302
+ name = "cubemaps/Sodermalmsallen2/";
9303
+ ext = "jpg";
9304
+ reverseUP = false;
9305
+ break;
9306
+ case 9:
9307
+ name = "cubemaps/UnionSquare/";
9308
+ ext = "jpg";
9309
+ reverseUP = false;
9310
+ break;
82019311 default:
8202
- name = "cubemaps/rgb_";
8203
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9312
+ name = "cubemaps/box/";
9313
+ ext = "png"; /*mipmap = true;*/
9314
+ reverseUP = false;
82049315 break;
82059316 }
8206
-
8207
- try
8208
- {
8209
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
8210
- } catch (IOException e)
8211
- {
8212
- throw new RuntimeException(e);
8213
- }
9317
+
9318
+ LoadSkybox(name, ext, mipmap);
82149319 }
82159320
82169321 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -8242,8 +9347,12 @@
82429347 static double[] model = new double[16];
82439348 double[] camera2light = new double[16];
82449349 double[] light2camera = new double[16];
8245
- int newenvy = -1;
8246
- boolean envyoff = true; // false;
9350
+
9351
+ //int newenvy = -1;
9352
+ //boolean envyoff = false;
9353
+
9354
+ String loadedskyboxname;
9355
+
82479356 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
82489357 //float[] light0 = { 0,0,0 };
82499358 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -8536,11 +9645,35 @@
85369645 jy8[3] = 0.5f;
85379646 }
85389647
8539
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9648
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
85409649 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
85419650 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
85429651 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
85439652
9653
+ void ResetOptions()
9654
+ {
9655
+ options1[0] = 100;
9656
+ options1[1] = 0.025f;
9657
+ options1[2] = 0.01f;
9658
+ options1[3] = 0;
9659
+ options1[4] = 0;
9660
+
9661
+ options2[0] = 0;
9662
+ options2[1] = 0.75f;
9663
+ options2[2] = 0;
9664
+ options2[3] = 0;
9665
+
9666
+ options3[0] = 1;
9667
+ options3[1] = 1;
9668
+ options3[2] = 1;
9669
+ options3[3] = 0;
9670
+
9671
+ options4[0] = 1;
9672
+ options4[1] = 0;
9673
+ options4[2] = 1;
9674
+ options4[3] = 0;
9675
+ }
9676
+
85449677 static int imagecount = 0; // movie generation
85459678
85469679 static int jitter = 0;
....@@ -8636,8 +9769,8 @@
86369769 assert (parentcam != renderCamera);
86379770
86389771 if (renderCamera != lightCamera)
8639
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8640
- LA.matConcat(matrix, parentcam.toParent, matrix);
9772
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9773
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
86419774
86429775 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
86439776
....@@ -8652,8 +9785,8 @@
86529785 LA.matCopy(renderCamera.fromScreen, matrix);
86539786
86549787 if (renderCamera != lightCamera)
8655
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8656
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9788
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9789
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
86579790
86589791 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
86599792
....@@ -8699,10 +9832,12 @@
86999832 rati = 1 / rati;
87009833 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
87019834 }
8702
- assert (newenvy == -1);
9835
+
9836
+ //assert (newenvy == -1);
9837
+
87039838 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
87049839 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
8705
- DrawSkyBox(gl);
9840
+ DrawSkyBox(gl, (float)rati);
87069841 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
87079842 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
87089843 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -8725,7 +9860,7 @@
87259860 //gl.glFlush();
87269861 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
87279862
8728
- if (ANIMATION && ABORTED)
9863
+ if (Globals.ANIMATION && ABORTED)
87299864 {
87309865 System.err.println(" ABORTED FRAME");
87319866 break;
....@@ -8755,7 +9890,7 @@
87559890 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
87569891
87579892 // save image
8758
- if (ANIMATION && !ABORTED)
9893
+ if (Globals.ANIMATION && !ABORTED)
87599894 {
87609895 VPwidth = viewport[2];
87619896 VPheight = viewport[3];
....@@ -8866,11 +10001,11 @@
886610001
886710002 // imagecount++;
886810003
8869
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
10004
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
887010005
887110006 if (!BOXMODE)
887210007 {
8873
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
10008
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
887410009 }
887510010
887610011 if (!BOXMODE)
....@@ -8908,7 +10043,7 @@
890810043 ABORTED = false;
890910044 }
891010045 else
8911
- GrafreeD.wav.cursor += 735 * ACSIZE;
10046
+ Grafreed.wav.cursor += 735 * ACSIZE;
891210047
891310048 if (false)
891410049 {
....@@ -9568,14 +10703,23 @@
956810703 static boolean init = false;
956910704
957010705 double[][] matrix = LA.newMatrix();
10706
+
10707
+ // This is to refresh the UI of the material panel.
10708
+ ObjEditor patchMaterial;
957110709
957210710 public void display(GLAutoDrawable drawable)
957310711 {
9574
- if (GrafreeD.savesound && GrafreeD.hassound)
10712
+ if (patchMaterial.patchMaterial)
957510713 {
9576
- GrafreeD.wav.save();
9577
- GrafreeD.savesound = false;
9578
- GrafreeD.hassound = false;
10714
+ patchMaterial.patchMaterial = false;
10715
+ patchMaterial.objectPanel.setSelectedIndex(1);
10716
+ }
10717
+
10718
+ if (Grafreed.savesound && Grafreed.hassound)
10719
+ {
10720
+ Grafreed.wav.save();
10721
+ Grafreed.savesound = false;
10722
+ Grafreed.hassound = false;
957910723 }
958010724 // if (DEBUG_SELECTION)
958110725 // {
....@@ -9651,6 +10795,7 @@
965110795 ANTIALIAS = 0;
965210796 //System.out.println("RESTART");
965310797 AAtimer.restart();
10798
+ Globals.TIMERRUNNING = true;
965410799 }
965510800 }
965610801 }
....@@ -9705,7 +10850,7 @@
970510850 Object3D theobject = object;
970610851 Object3D theparent = object.parent;
970710852 object.parent = null;
9708
- object = (Object3D)GrafreeD.clone(object);
10853
+ object = (Object3D)Grafreed.clone(object);
970910854 object.Stripify();
971010855 if (theobject.selection == null || theobject.selection.Size() == 0)
971110856 theobject.PreprocessOcclusion(this);
....@@ -9718,13 +10863,14 @@
971810863 ambientOcclusion = false;
971910864 }
972010865
9721
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10866
+ if (//Globals.lighttouched &&
10867
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
972210868 {
972310869 //if (RENDERSHADOW) // ?
972410870 if (!IsFrozen())
972510871 {
972610872 // dec 2012
9727
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10873
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
972810874 {
972910875 Globals.framecount++;
973010876 shadowbuffer.display();
....@@ -9737,7 +10883,7 @@
973710883
973810884 if (wait)
973910885 {
9740
- Sleep(500);
10886
+ Sleep(200); // blocks everything
974110887
974210888 wait = false;
974310889 }
....@@ -9851,8 +10997,8 @@
985110997
985210998 // if (parentcam != renderCamera) // not a light
985310999 if (cam != lightCamera)
9854
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9855
- LA.matConcat(matrix, parentcam.toParent, matrix);
11000
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11001
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
985611002
985711003 for (int j = 0; j < 4; j++)
985811004 {
....@@ -9866,8 +11012,8 @@
986611012
986711013 // if (parentcam != renderCamera) // not a light
986811014 if (cam != lightCamera)
9869
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9870
- LA.matConcat(parentcam.fromParent, matrix, matrix);
11015
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11016
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
987111017
987211018 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
987311019
....@@ -9953,13 +11099,43 @@
995311099 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
995411100 }
995511101
9956
- if (newenvy > -1)
11102
+// if (newenvy > -1)
11103
+// {
11104
+// LoadEnvy(newenvy);
11105
+// }
11106
+//
11107
+// newenvy = -1;
11108
+
11109
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
995711110 {
9958
- LoadEnvy(newenvy);
11111
+ if (cubemaprgb == null)
11112
+ {
11113
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
11114
+ }
11115
+
11116
+ cubemap = cubemaprgb;
995911117 }
9960
-
9961
- newenvy = -1;
9962
-
11118
+ else
11119
+ {
11120
+ if (object.skyboxname != null)
11121
+ {
11122
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11123
+ {
11124
+ if (cubemap != null && cubemap != cubemaprgb)
11125
+ cubemap.dispose();
11126
+ cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11127
+ loadedskyboxname = object.skyboxname;
11128
+ }
11129
+ }
11130
+ else
11131
+ {
11132
+ cubemapcustom = null;
11133
+ loadedskyboxname = null;
11134
+ }
11135
+
11136
+ cubemap = cubemapcustom;
11137
+ }
11138
+
996311139 ratio = ((double) getWidth()) / getHeight();
996411140 //System.out.println("ratio = " + ratio);
996511141
....@@ -9975,7 +11151,7 @@
997511151
997611152 if (!IsFrozen() && !ambientOcclusion)
997711153 {
9978
- DrawSkyBox(gl);
11154
+ DrawSkyBox(gl, (float)ratio);
997911155 }
998011156
998111157 //if (selection_view == -1)
....@@ -10126,7 +11302,16 @@
1012611302 // Bump noise
1012711303 gl.glActiveTexture(GL.GL_TEXTURE6);
1012811304 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10129
- BindTexture(NOISE_TEXTURE, false, 2);
11305
+
11306
+ try
11307
+ {
11308
+ BindTexture(NOISE_TEXTURE, false, 2);
11309
+ }
11310
+ catch (Exception e)
11311
+ {
11312
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11313
+ }
11314
+
1013011315
1013111316 gl.glActiveTexture(GL.GL_TEXTURE0);
1013211317 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10149,9 +11334,9 @@
1014911334
1015011335 gl.glMatrixMode(GL.GL_MODELVIEW);
1015111336
10152
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10153
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10154
-//gl.glEnable(gl.GL_MULTISAMPLE);
11337
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11338
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11339
+gl.glEnable(gl.GL_MULTISAMPLE);
1015511340 } else
1015611341 {
1015711342 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10162,7 +11347,7 @@
1016211347 //System.out.println("BLENDING ON");
1016311348 gl.glEnable(GL.GL_BLEND);
1016411349 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10165
-
11350
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1016611351 gl.glMatrixMode(gl.GL_PROJECTION);
1016711352 gl.glLoadIdentity();
1016811353
....@@ -10251,8 +11436,8 @@
1025111436 System.err.println("parentcam != renderCamera");
1025211437
1025311438 // if (cam != lightCamera)
10254
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10255
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11439
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11440
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1025611441 }
1025711442
1025811443 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10273,8 +11458,8 @@
1027311458 if (true) // TODO
1027411459 {
1027511460 if (cam != lightCamera)
10276
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10277
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11461
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11462
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1027811463 }
1027911464
1028011465 LA.xformPos(light0, cam.toScreen, light0);
....@@ -10340,7 +11525,7 @@
1034011525 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
1034111526 //System.out.println("fragmentMode = " + fragmentMode);
1034211527
10343
- if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION)
11528
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
1034411529 {
1034511530 /*
1034611531 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -10411,7 +11596,7 @@
1041111596 }
1041211597 }
1041311598
10414
- if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
11599
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
1041511600 {
1041611601 //gl.glDepthFunc(GL.GL_LEQUAL);
1041711602 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -10419,24 +11604,21 @@
1041911604
1042011605 boolean texon = textureon;
1042111606
10422
- if (RENDERPROGRAM > 0)
10423
- {
10424
- gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
10425
- textureon = false;
10426
- }
11607
+ gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11608
+ textureon = false;
11609
+
1042711610 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
1042811611 //System.out.println("ALLO");
1042911612 gl.glColorMask(false, false, false, false);
1043011613 DrawObject(gl);
10431
- if (RENDERPROGRAM > 0)
10432
- {
10433
- gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
10434
- textureon = texon;
10435
- }
11614
+
11615
+ gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11616
+ textureon = texon;
11617
+
1043611618 gl.glColorMask(true, true, true, true);
1043711619
1043811620 gl.glDepthFunc(GL.GL_EQUAL);
10439
- //gl.glDepthMask(false);
11621
+ gl.glDepthMask(false);
1044011622 }
1044111623
1044211624 if (false) // DrawMode() == SHADOW)
....@@ -10590,8 +11772,14 @@
1059011772 {
1059111773 renderpass++;
1059211774 // System.out.println("Draw object... ");
11775
+ STEP = 1;
1059311776 if (FAST) // in case there is no script
10594
- STEP = 16;
11777
+ STEP = 8;
11778
+
11779
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11780
+ {
11781
+ STEP *= 4;
11782
+ }
1059511783
1059611784 //object.FullInvariants();
1059711785
....@@ -10605,23 +11793,44 @@
1060511793 e.printStackTrace();
1060611794 }
1060711795
10608
- if (GrafreeD.RENDERME > 0)
10609
- GrafreeD.RENDERME--; // mechante magouille
11796
+ if (Grafreed.RENDERME > 0)
11797
+ Grafreed.RENDERME--; // mechante magouille
1061011798
1061111799 Globals.ONESTEP = false;
1061211800 }
1061311801
1061411802 static boolean zoomonce = false;
1061511803
11804
+ static void CreateSelectedPoint()
11805
+ {
11806
+ if (selectedpoint == null)
11807
+ {
11808
+ debugpointG = new Sphere();
11809
+ debugpointP = new Sphere();
11810
+ debugpointC = new Sphere();
11811
+ debugpointR = new Sphere();
11812
+
11813
+ selectedpoint = new Superellipsoid();
11814
+
11815
+ for (int i=0; i<8; i++)
11816
+ {
11817
+ debugpoints[i] = new Sphere();
11818
+ }
11819
+ }
11820
+ }
11821
+
1061611822 void DrawObject(GL gl, boolean draw)
1061711823 {
11824
+ // To clear camera values
11825
+ ResetOptions();
11826
+
1061811827 //System.out.println("DRAW OBJECT " + mouseDown);
1061911828 // DrawMode() = SELECTION;
1062011829 //GL gl = getGL();
1062111830 if ((TRACK || SHADOWTRACK) || zoomonce)
1062211831 {
1062311832 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
10624
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11833
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1062511834 pingthread.StepToTarget(true); // true);
1062611835 // zoomonce = false;
1062711836 }
....@@ -10641,7 +11850,7 @@
1064111850 callist = gl.glGenLists(1);
1064211851 }
1064311852
10644
- boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
11853
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
1064511854
1064611855 boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
1064711856
....@@ -10676,7 +11885,14 @@
1067611885
1067711886 usedtextures.clear();
1067811887
10679
- BindTextures(DEFAULT_TEXTURES, 2);
11888
+ try
11889
+ {
11890
+ BindTextures(DEFAULT_TEXTURES, 2);
11891
+ }
11892
+ catch (Exception e)
11893
+ {
11894
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11895
+ }
1068011896 }
1068111897 //System.out.println("--> " + stackdepth);
1068211898 // GrafreeD.traceon();
....@@ -10686,8 +11902,9 @@
1068611902
1068711903 if (DrawMode() == DEFAULT)
1068811904 {
10689
- if (DEBUG)
11905
+ if (Globals.DEBUG)
1069011906 {
11907
+ CreateSelectedPoint();
1069111908 float radius = 0.05f;
1069211909 if (selectedpoint.radius != radius)
1069311910 {
....@@ -10741,20 +11958,32 @@
1074111958 ReleaseTextures(DEFAULT_TEXTURES);
1074211959
1074311960 if (CLEANCACHE)
10744
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11961
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1074511962 {
10746
- String tex = e.nextElement();
11963
+ cTexture tex = e.nextElement();
1074711964
1074811965 // System.out.println("Texture --------- " + tex);
1074911966
10750
- if (tex.equals("WHITE_NOISE"))
11967
+ if (tex.equals("WHITE_NOISE:"))
1075111968 continue;
1075211969
10753
- if (!usedtextures.containsKey(tex))
11970
+ if (!usedtextures.contains(tex))
1075411971 {
11972
+ CacheTexture gettex = texturepigment.get(tex);
1075511973 // System.out.println("DISPOSE +++++++++++++++ " + tex);
10756
- textures.get(tex).texture.dispose();
10757
- textures.remove(tex);
11974
+ if (gettex != null)
11975
+ {
11976
+ gettex.texture.dispose();
11977
+ texturepigment.remove(tex);
11978
+ }
11979
+
11980
+ gettex = texturebump.get(tex);
11981
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11982
+ if (gettex != null)
11983
+ {
11984
+ gettex.texture.dispose();
11985
+ texturebump.remove(tex);
11986
+ }
1075811987 }
1075911988 }
1076011989 }
....@@ -10767,7 +11996,14 @@
1076711996 if (checker != null && DrawMode() == DEFAULT)
1076811997 {
1076911998 //BindTexture(IMMORTAL_TEXTURE);
10770
- BindTextures(checker.GetTextures(), checker.texres);
11999
+ try
12000
+ {
12001
+ BindTextures(checker.GetTextures(), checker.texres);
12002
+ }
12003
+ catch (Exception e)
12004
+ {
12005
+ System.err.println("FAILED: " + checker.GetTextures());
12006
+ }
1077112007 // NEAREST
1077212008 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1077312009 DrawChecker(gl);
....@@ -10849,7 +12085,7 @@
1084912085 return;
1085012086 }
1085112087
10852
- String string = obj.GetToolTip();
12088
+ String string = obj.toString(); //.GetToolTip();
1085312089
1085412090 GL gl = GetGL();
1085512091
....@@ -11166,8 +12402,8 @@
1116612402 //obj.TransformToWorld(light, light);
1116712403 for (int i = tp.size(); --i >= 0;)
1116812404 {
11169
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11170
- LA.xformPos(light, tp.get(i).toParent, light);
12405
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12406
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1117112407 }
1117212408
1117312409
....@@ -11184,8 +12420,8 @@
1118412420 parentcam = cameras[0];
1118512421 }
1118612422
11187
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11188
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12423
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12424
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1118912425
1119012426 LA.xformPos(light, renderCamera.toScreen, light);
1119112427
....@@ -11275,8 +12511,82 @@
1127512511
1127612512 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1127712513
11278
- String program =
12514
+ String programmin =
12515
+ // Min shader
1127912516 "!!ARBfp1.0\n" +
12517
+ "PARAM zero12t = { 0.0, 1.0, 2, 1.25 };" +
12518
+ "PARAM pow_2 = { 0.5, 0.25, 0.125, 0.0 };" +
12519
+ "PARAM pow2 = { 2, 4, 8, 0.0 };" +
12520
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12521
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12522
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12523
+ "PARAM light2cam0 = program.env[10];" +
12524
+ "PARAM light2cam1 = program.env[11];" +
12525
+ "PARAM light2cam2 = program.env[12];" +
12526
+ "TEMP temp;" +
12527
+ "TEMP light;" +
12528
+ "TEMP ndotl;" +
12529
+ "TEMP normal;" +
12530
+ "TEMP depth;" +
12531
+ "TEMP eye;" +
12532
+ "TEMP pos;" +
12533
+
12534
+ "MAD normal, fragment.color, zero12t.z, -zero12t.y;" +
12535
+ Normalize("normal") +
12536
+ "MOV light, state.light[0].position;" +
12537
+ "DP3 ndotl.x, light, normal;" +
12538
+ "MAX ndotl.x, ndotl.x, zero12t.x;" +
12539
+
12540
+ // shadow
12541
+ "MOV pos, fragment.texcoord[1];" +
12542
+ "MOV temp, pos;" +
12543
+ ShadowTextureFetch("depth", "temp", "1") +
12544
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12545
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
12546
+
12547
+ // No shadow when out of frustum
12548
+ //"SGE temp.y, depth.z, zero123.y;" +
12549
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12550
+
12551
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
12552
+
12553
+ // Backlit
12554
+ "MOV pos.w, zero12t.y;" + // one
12555
+ "DP4 eye.x, pos, light2cam0;" +
12556
+ "DP4 eye.y, pos, light2cam1;" +
12557
+ "DP4 eye.z, pos, light2cam2;" +
12558
+ Normalize("eye") +
12559
+
12560
+ "DP3 ndotl.y, -eye, normal;" +
12561
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12562
+ "POW ndotl.y, ndotl.y, pow2.x;" + // backlit
12563
+ "SUB ndotl.y, zero12t.y, ndotl.y;" + // 1 - y
12564
+ //"POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12565
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12566
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12567
+ "ADD ndotl.y, ndotl.y, one.x;" +
12568
+ "MUL ndotl.y, ndotl.y, pow_2.x;" +
12569
+
12570
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12571
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
12572
+
12573
+ // Pigment
12574
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12575
+ "LRP temp, zero12t.w, temp, one;" + // texture proportion
12576
+ "MUL temp, temp, zero12t.w;" + // Times x
12577
+
12578
+ //"MUL temp, temp, ndotl.y;" +
12579
+ "MAD ndotl.x, pow_2.xxxx, ndotl.yyyy, ndotl.x;" +
12580
+
12581
+ "MUL temp, temp, ndotl.x;" + // lambert
12582
+
12583
+ "MOV temp.w, zero12t.y;" + // reset alpha
12584
+ "MOV result.color, temp;" +
12585
+ "END";
12586
+
12587
+ String programmax =
12588
+ "!!ARBfp1.0\n" +
12589
+
1128012590 //"OPTION ARB_fragment_program_shadow;" +
1128112591 "PARAM light2cam0 = program.env[10];" +
1128212592 "PARAM light2cam1 = program.env[11];" +
....@@ -11302,7 +12612,7 @@
1130212612 "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow
1130312613 "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias
1130412614 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
11305
- "PARAM params7 = program.env[7];" + // noise power, opacity power
12615
+ "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax
1130612616 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
1130712617 "PARAM options1 = program.env[62];" + // fog rgb color
1130812618 "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
....@@ -11391,8 +12701,7 @@
1139112701 "TEMP shininess;" +
1139212702 "\n" +
1139312703 "MOV texSamp, one;" +
11394
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
11395
-
12704
+
1139612705 "MOV mapgrid.x, one2048th.x;" +
1139712706 "MOV temp, fragment.texcoord[1];" +
1139812707 /*
....@@ -11413,20 +12722,20 @@
1141312722 "MUL temp, floor, mapgrid.x;" +
1141412723 //"TEX depth0, temp, texture[1], 2D;" +
1141512724 (((mode & FP_SOFTSHADOW) == 0) ? "" :
11416
- TextureFetch("depth0", "temp", "1") +
12725
+ ShadowTextureFetch("depth0", "temp", "1") +
1141712726 "") +
1141812727 "ADD temp.x, temp.x, mapgrid.x;" +
1141912728 //"TEX depth1, temp, texture[1], 2D;" +
1142012729 (((mode & FP_SOFTSHADOW) == 0) ? "" :
11421
- TextureFetch("depth1", "temp", "1") +
12730
+ ShadowTextureFetch("depth1", "temp", "1") +
1142212731 "") +
1142312732 "ADD temp.y, temp.y, mapgrid.x;" +
1142412733 //"TEX depth2, temp, texture[1], 2D;" +
11425
- TextureFetch("depth2", "temp", "1") +
12734
+ ShadowTextureFetch("depth2", "temp", "1") +
1142612735 "SUB temp.x, temp.x, mapgrid.x;" +
1142712736 //"TEX depth3, temp, texture[1], 2D;" +
1142812737 (((mode & FP_SOFTSHADOW) == 0) ? "" :
11429
- TextureFetch("depth3", "temp", "1") +
12738
+ ShadowTextureFetch("depth3", "temp", "1") +
1143012739 "") +
1143112740 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1143212741 //"MOV params, material;" +
....@@ -11548,7 +12857,7 @@
1154812857 "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut
1154912858 // mar 2013 ??? "KIL alpha.a;" +
1155012859 "MOV alpha, texSamp.aaaa;" + // y;" +
11551
- "KIL alpha.a;" +
12860
+ "KIL alpha.a;" + // not sure with parallax mapping
1155212861 /*
1155312862 "MUL temp.xy, temp, two;" +
1155412863 "TXB bump, temp, texture[0], 2D;" +
....@@ -11634,11 +12943,6 @@
1163412943 "SUB bump0, bump0, half;" +
1163512944 "ADD bump, bump, bump0;" +
1163612945
11637
- "MOV temp.x, texSamp.a;" +
11638
- "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
11639
- //"LRP texSamp0, params5.x, texSamp0, one;" +
11640
- "MOV texSamp.a, temp.x;" +
11641
-
1164212946 // double-sided
1164312947 /**/
1164412948 (doublesided?"DP3 temp.z, normal, eye;" +
....@@ -11648,26 +12952,73 @@
1164812952 "ADD temp.x, temp.x, one.x;" +
1164912953 "MUL normal, normal, temp.xxxx;":""
1165012954 ) +
11651
- /**/
11652
-//// Normalize("normal") +
11653
-//// "MAX normal.z, eps.x, normal.z;" +
11654
-// Normalize("normal") +
11655
- "MOV normald, normal;" +
11656
- "MOV normals, normal;" +
12955
+ /**/
12956
+
12957
+ "MOV temp, fragment.texcoord[4];" +
1165712958
1165812959 // UV base
1165912960 //"DP3 UP.x,state.matrix.modelview.row[0],Y;" +
1166012961 //"DP3 UP.y,state.matrix.modelview.row[1],Y;" +
1166112962 //"DP3 UP.z,state.matrix.modelview.row[2],Y;" +
11662
- "DP3 UP.x,state.matrix.texture[7].row[0],Y;" +
11663
- "DP3 UP.y,state.matrix.texture[7].row[1],Y;" +
11664
- "DP3 UP.z,state.matrix.texture[7].row[2],Y;" +
12963
+ "DP3 UP.x,state.matrix.texture[7].row[0],temp;" +
12964
+ "DP3 UP.y,state.matrix.texture[7].row[1],temp;" +
12965
+ "DP3 UP.z,state.matrix.texture[7].row[2],temp;" +
12966
+ Normalize("UP") +
12967
+
1166512968 "XPD V, normal, UP;" +
1166612969 Normalize("V") +
1166712970 "XPD U, V, normal;" +
1166812971 Normalize("U") +
1166912972
12973
+ "MOV temp, fragment.texcoord[0];" +
12974
+
12975
+// "MAD normal, -temp.x, U, normal;" +
12976
+// "MAD normal, -temp.y, V, normal;" +
12977
+// Normalize("normal") +
12978
+
12979
+//// "MAX normal.z, eps.x, normal.z;" +
12980
+// Normalize("normal") +
12981
+ "MOV normald, normal;" +
12982
+ "MOV normals, normal;" +
12983
+
1167012984 // parallax mapping
12985
+
12986
+ "DP3 temp2.x, V, eye;" +
12987
+ "DP3 temp2.y, U, eye;" +
12988
+ "DP3 temp2.z, normal, eye;" +
12989
+ "RCP temp2.z, temp2.z;" +
12990
+
12991
+ "DP3 temp2.w, texSamp, texSamp;" + // Height
12992
+ "RSQ temp2.w, temp2.w;" +
12993
+ "RCP temp2.w, temp2.w;" +
12994
+
12995
+ "SUB temp2.w, temp2.w, half;" +
12996
+ // "SGE temp.x, temp2.w, eps.x;" +
12997
+ // "MUL temp2.w, temp2.w, temp.x;" +
12998
+
12999
+ // "MOV texSamp, U;" +
13000
+
13001
+ "MUL temp2.z, temp2.z, temp2.w;" +
13002
+ "MUL temp2.z, temp2.z, params7.z;" + // parallax
13003
+
13004
+ "MUL temp2, temp2, temp2.z;" +
13005
+
13006
+ "SUB temp, temp, temp2;" +
13007
+
13008
+ "TEX temp, temp, texture[0], 2D;" +
13009
+ "POW temp.a, temp.a, params6.w;" + // punch through
13010
+
13011
+ "ADD texSamp, temp, texSamp;" +
13012
+ "MUL texSamp.xyz, half, texSamp;" +
13013
+
13014
+ "MOV alpha, texSamp.aaaa;" +
13015
+
13016
+// parallax mapping
13017
+
13018
+ "MOV temp.x, texSamp.a;" +
13019
+ "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
13020
+ //"LRP texSamp0, params5.x, texSamp0, one;" +
13021
+ "MOV texSamp.a, temp.x;" +
1167113022
1167213023 //"MOV temp, fragment.texcoord[0];" +
1167313024 //
....@@ -11797,10 +13148,10 @@
1179713148 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1179813149 "") +
1179913150
11800
- // display shadow only (bump == 0)
13151
+ // display shadow only (fakedepth == 0)
1180113152 "SUB temp.x, half.x, shadow.x;" +
11802
- "MOV temp.y, -params6.x;" +
11803
- "SLT temp.z, temp.y, zero.x;" +
13153
+ "MOV temp.y, -params5.z;" + // params6.x;" +
13154
+ "SLT temp.z, temp.y, -c256i.x;" +
1180413155 "SUB temp.y, one.x, temp.z;" +
1180513156 "MUL temp.x, temp.x, temp.y;" +
1180613157 "KIL temp.x;" +
....@@ -11929,8 +13280,10 @@
1192913280 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1193013281
1193113282 "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
13283
+ // Tuning for default skin
13284
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
13285
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
13286
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1193413287 "MUL temp.x, temp.x, temp.y;" +
1193513288
1193613289 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12129,8 +13482,19 @@
1212913482 //once = true;
1213013483 }
1213113484
12132
- System.out.print("Program #" + mode + "; length = " + program.length());
12133
- System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13485
+ String program = programmax;
13486
+
13487
+ if (Globals.MINSHADER)
13488
+ {
13489
+ program = programmin;
13490
+ }
13491
+
13492
+ if (Globals.DEBUG)
13493
+ {
13494
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13495
+ System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13496
+ }
13497
+
1213413498 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1213513499
1213613500 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -12177,7 +13541,8 @@
1217713541 "\n" +
1217813542 "END\n";
1217913543
12180
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13544
+ if (Globals.DEBUG)
13545
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1218113546 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1218213547
1218313548 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -12222,25 +13587,26 @@
1222213587 return out;
1222313588 }
1222413589
12225
- String TextureFetch(String dest, String src, String unit)
13590
+ // Also does frustum culling
13591
+ String ShadowTextureFetch(String dest, String src, String unit)
1222613592 {
1222713593 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1222813594 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1222913595 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13596
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13597
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1223013598 "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;" +
13599
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13600
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1223513601 //"SWZ buffer, temp, w,w,w,w;";
12236
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13602
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1223713603 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1223813604 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1223913605 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
12240
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13606
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1224113607
12242
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
12243
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13608
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13609
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1224413610 }
1224513611
1224613612 String Shadow(String depth, String shadow)
....@@ -12262,12 +13628,16 @@
1226213628
1226313629 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1226413630 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13631
+
13632
+ // Compare fragment depth in light space with shadowmap.
1226513633 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1226613634 "SGE temp.y, temp.x, zero.x;" +
12267
- "SUB " + shadow + ".y, one.x, temp.y;" +
13635
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13636
+
13637
+ // Reverse comparison
1226813638 "SUB temp.x, one.x, temp.x;" +
1226913639 "MUL " + shadow + ".x, temp.x, temp.y;" +
12270
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13640
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1227113641 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1227213642
1227313643 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12281,6 +13651,10 @@
1228113651 // No shadow for backface
1228213652 "DP3 temp.x, normal, lightd;" +
1228313653 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13654
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13655
+
13656
+ // No shadow when out of frustum
13657
+ "SGE temp.x, " + depth + ".z, one.z;" +
1228413658 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1228513659 "";
1228613660 }
....@@ -12426,8 +13800,9 @@
1242613800 /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow
1242713801 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1242813802 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
12429
- /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
12430
- Object3D.cVector2[] vector2buffer;
13803
+ /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax
13804
+
13805
+ //Object3D.cVector2[] vector2buffer;
1243113806
1243213807 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1243313808 // OUT : diff, spec
....@@ -12443,9 +13818,10 @@
1244313818 "DP3 " + dest + ".z," + "normals," + "eye;" +
1244413819 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1244513820 //"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;" +
13821
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13822
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13823
+
13824
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1244913825 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1245013826 "RCP " + dest + ".w," + dest + ".w;" +
1245113827 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -12591,7 +13967,7 @@
1259113967 "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" +
1259213968 "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" +
1259313969 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
12594
- "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" +
13970
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1259513971 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1259613972 "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" +
1259713973 //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" +
....@@ -12652,7 +14028,7 @@
1265214028 "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" +
1265314029 "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" +
1265414030 "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" +
12655
- //"MOV result.texcoord, vertex.texcoord;" +
14031
+ //"MOV result.texcoord, vertex.fogcoord;" +
1265614032 "MOV result.texcoord, temp;" +
1265714033 // border fade
1265814034 "MOV result.texcoord[3], vertex.texcoord;" +
....@@ -12699,7 +14075,9 @@
1269914075
1270014076 //"ADD temp.z, temp.z, one;" +
1270114077
12702
- "MOV result.color, temp;"
14078
+ "MOV result.texcoord[4], vertex.attrib[4];" + // U dir
14079
+
14080
+ "MOV result.color, temp;" // Normal
1270314081 : "MOV result.color, vertex.color;") +
1270414082 ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;"
1270514083 : "") +
....@@ -12839,7 +14217,7 @@
1283914217 public void mousePressed(MouseEvent e)
1284014218 {
1284114219 //System.out.println("mousePressed: " + e);
12842
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
14220
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1284314221 }
1284414222
1284514223 static long prevtime = 0;
....@@ -12866,6 +14244,7 @@
1286614244
1286714245 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1286814246
14247
+ if (BUTTONLESSWHEEL)
1286914248 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1287014249 {
1287114250 return;
....@@ -12874,7 +14253,7 @@
1287414253 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1287514254
1287614255 // TIMER
12877
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
14256
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1287814257 {
1287914258 keepboxmode = BOXMODE;
1288014259 keepsupport = SUPPORT;
....@@ -12914,8 +14293,8 @@
1291414293 // mode |= META;
1291514294 //}
1291614295
12917
- SetMouseMode(WHEEL | e.getModifiersEx());
12918
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
14296
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
14297
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1291914298 anchorX = ax;
1292014299 anchorY = ay;
1292114300 prevX = px;
....@@ -12949,6 +14328,7 @@
1294914328 else
1295014329 if (evt.getSource() == AAtimer)
1295114330 {
14331
+ Globals.TIMERRUNNING = false;
1295214332 if (mouseDown)
1295314333 {
1295414334 //new Exception().printStackTrace();
....@@ -12974,6 +14354,10 @@
1297414354 // LIVE = waslive;
1297514355 // wasliveok = true;
1297614356 // waslive = false;
14357
+
14358
+ // May 2019 Forget it:
14359
+ if (true)
14360
+ return;
1297714361
1297814362 // source == timer
1297914363 if (mouseDown)
....@@ -13004,7 +14388,7 @@
1300414388
1300514389 // fev 2014???
1300614390 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13007
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14391
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1300814392 pingthread.StepToTarget(true); // true);
1300914393 }
1301014394 // if (!LIVE)
....@@ -13013,12 +14397,13 @@
1301314397
1301414398 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1301514399
13016
- void clickStart(int x, int y, int modifiers)
14400
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1301714401 {
1301814402 if (!wasliveok)
1301914403 return;
1302014404
1302114405 AAtimer.restart(); //
14406
+ Globals.TIMERRUNNING = true;
1302214407
1302314408 // waslive = LIVE;
1302414409 // LIVE = false;
....@@ -13030,7 +14415,7 @@
1303014415 // touched = true; // main DL
1303114416 if (isRenderer)
1303214417 {
13033
- SetMouseMode(modifiers);
14418
+ SetMouseMode(modifiers, modifiersex);
1303414419 }
1303514420
1303614421 selectX = anchorX = x;
....@@ -13043,7 +14428,7 @@
1304314428 clicked = true;
1304414429 hold = false;
1304514430
13046
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14431
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1304714432 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1304814433 {
1304914434 // System.out.println("RESTART II " + modifiers);
....@@ -13068,14 +14453,15 @@
1306814453 drag = false;
1306914454 //System.out.println("Mouse DOWN");
1307014455 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);
14456
+ //ClickInfo info = new ClickInfo();
14457
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14458
+ object.clickInfo.pane = this;
14459
+ object.clickInfo.camera = renderCamera;
14460
+ object.clickInfo.x = x;
14461
+ object.clickInfo.y = y;
14462
+ object.clickInfo.modifiers = modifiersex;
14463
+ editObj = object.doEditClick(//info,
14464
+ 0);
1307914465 if (!editObj)
1308014466 {
1308114467 hasMarquee = true;
....@@ -13091,11 +14477,14 @@
1309114477
1309214478 public void mouseDragged(MouseEvent e)
1309314479 {
14480
+ Globals.MOUSEDRAGGED = true;
14481
+
14482
+ //System.out.println("mouseDragged: " + e);
1309414483 if (isRenderer)
1309514484 movingcamera = true;
14485
+
1309614486 //if (drawing)
1309714487 //return;
13098
- //System.out.println("mouseDragged: " + e);
1309914488 if ((e.getModifiersEx() & CTRL) != 0
1310014489 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1310114490 {
....@@ -13103,7 +14492,7 @@
1310314492 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1310414493 }
1310514494 else
13106
- drag(e.getX(), e.getY(), e.getModifiersEx());
14495
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1310714496
1310814497 //try { Thread.sleep(1); } catch (Exception ex) {}
1310914498 }
....@@ -13115,6 +14504,11 @@
1311514504 cVector tmp = new cVector();
1311614505 cVector tmp2 = new cVector();
1311714506 boolean isMoving;
14507
+
14508
+ public cVector TargetLookAt()
14509
+ {
14510
+ return targetLookAt;
14511
+ }
1311814512
1311914513 class PingThread extends Thread
1312014514 {
....@@ -13271,6 +14665,7 @@
1327114665
1327214666 public void run()
1327314667 {
14668
+ new Exception().printStackTrace();
1327414669 System.exit(0);
1327514670 for (;;)
1327614671 {
....@@ -13334,26 +14729,32 @@
1333414729 {
1333514730 Globals.lighttouched = true;
1333614731 }
13337
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14732
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1333814733 }
1333914734 //else
1334014735 }
1334114736 }
1334214737 }
1334314738 PingThread pingthread = new PingThread();
13344
- int delta = 5;
13345
- int speed = 5;
14739
+ int delta = 2;
14740
+ int speed = 10;
1334614741 boolean autorepeat = false;
1334714742
1334814743 void GoDown(int mod)
1334914744 {
1335014745 MODIFIERS |= COMMAND;
13351
- /*
14746
+ boolean isVR = (mouseMode&VR)!=0;
14747
+ /**/
1335214748 if((mod&SHIFT) == SHIFT)
13353
- manipCamera.RotatePosition(0, -speed);
14749
+ {
14750
+ if (isVR)
14751
+ manipCamera.RotateInterest(0, -speed);
14752
+ else
14753
+ manipCamera.RotatePosition(0, -speed);
14754
+ }
1335414755 else
13355
- manipCamera.BackForth(0, -speed*delta, getWidth());
13356
- */
14756
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
14757
+ /**/
1335714758 if ((mod & SHIFT) == SHIFT)
1335814759 {
1335914760 mouseMode = mouseMode; // VR??
....@@ -13362,6 +14763,8 @@
1336214763 mouseMode |= BACKFORTH;
1336314764 }
1336414765
14766
+ targetLookAt.set(manipCamera.lookAt);
14767
+
1336514768 //prevX = X = anchorX;
1336614769 prevY = Y = anchorY - (int) (renderCamera.Distance());
1336714770 }
....@@ -13369,12 +14772,19 @@
1336914772 void GoUp(int mod)
1337014773 {
1337114774 MODIFIERS |= COMMAND;
13372
- /*
14775
+ /**/
14776
+ boolean isVR = (mouseMode&VR)!=0;
14777
+
1337314778 if((mod&SHIFT) == SHIFT)
13374
- manipCamera.RotatePosition(0, speed);
14779
+ {
14780
+ if (isVR)
14781
+ manipCamera.RotateInterest(0, speed);
14782
+ else
14783
+ manipCamera.RotatePosition(0, speed);
14784
+ }
1337514785 else
13376
- manipCamera.BackForth(0, speed*delta, getWidth());
13377
- */
14786
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
14787
+ /**/
1337814788 if ((mod & SHIFT) == SHIFT)
1337914789 {
1338014790 mouseMode = mouseMode;
....@@ -13383,6 +14793,8 @@
1338314793 mouseMode |= BACKFORTH;
1338414794 }
1338514795
14796
+ targetLookAt.set(manipCamera.lookAt);
14797
+
1338614798 //prevX = X = anchorX;
1338714799 prevY = Y = anchorY + (int) (renderCamera.Distance());
1338814800 }
....@@ -13390,12 +14802,17 @@
1339014802 void GoLeft(int mod)
1339114803 {
1339214804 MODIFIERS |= COMMAND;
13393
- /*
14805
+ /**/
1339414806 if((mod&SHIFT) == SHIFT)
13395
- manipCamera.RotatePosition(speed, 0);
14807
+ manipCamera.Translate(speed*delta, 0, getWidth());
1339614808 else
13397
- manipCamera.Translate(speed*delta, 0, getWidth());
13398
- */
14809
+ {
14810
+ if ((mouseMode&VR)!=0)
14811
+ manipCamera.RotateInterest(-speed, 0);
14812
+ else
14813
+ manipCamera.RotatePosition(speed, 0);
14814
+ }
14815
+ /**/
1339914816 if ((mod & SHIFT) == SHIFT)
1340014817 {
1340114818 mouseMode = mouseMode;
....@@ -13404,6 +14821,8 @@
1340414821 mouseMode |= ROTATE;
1340514822 } // TRANSLATE;
1340614823
14824
+ targetLookAt.set(manipCamera.lookAt);
14825
+
1340714826 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1340814827 prevY = Y = anchorY;
1340914828 }
....@@ -13411,12 +14830,18 @@
1341114830 void GoRight(int mod)
1341214831 {
1341314832 MODIFIERS |= COMMAND;
13414
- /*
14833
+ /**/
1341514834 if((mod&SHIFT) == SHIFT)
13416
- manipCamera.RotatePosition(-speed, 0);
14835
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1341714836 else
13418
- manipCamera.Translate(-speed*delta, 0, getWidth());
13419
- */
14837
+ {
14838
+ if ((mouseMode&VR)!=0)
14839
+ manipCamera.RotateInterest(speed, 0);
14840
+ else
14841
+ manipCamera.RotatePosition(-speed, 0);
14842
+ }
14843
+
14844
+ /**/
1342014845 if ((mod & SHIFT) == SHIFT)
1342114846 {
1342214847 mouseMode = mouseMode;
....@@ -13425,6 +14850,8 @@
1342514850 mouseMode |= ROTATE;
1342614851 } // TRANSLATE;
1342714852
14853
+ targetLookAt.set(manipCamera.lookAt);
14854
+
1342814855 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1342914856 prevY = Y = anchorY;
1343014857 }
....@@ -13434,7 +14861,7 @@
1343414861 int X, Y;
1343514862 boolean SX, SY;
1343614863
13437
- void drag(int x, int y, int modifiers)
14864
+ void drag(int x, int y, int modifiers, int modifiersex)
1343814865 {
1343914866 if (IsFrozen())
1344014867 {
....@@ -13443,17 +14870,17 @@
1344314870
1344414871 drag = true; // NEW
1344514872
13446
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14873
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1344714874
1344814875 X = x;
1344914876 Y = y;
1345014877 // floating state for animation
13451
- MODIFIERS = modifiers;
13452
- modifiers &= ~1024;
14878
+ MODIFIERS = modifiersex;
14879
+ modifiersex &= ~1024;
1345314880 if (false) // modifiers != 0)
1345414881 {
1345514882 //new Exception().printStackTrace();
13456
- System.out.println("mouseDragged: " + modifiers);
14883
+ System.out.println("mouseDragged: " + modifiersex);
1345714884 System.out.println("SHIFT = " + SHIFT);
1345814885 System.out.println("CONTROL = " + COMMAND);
1345914886 System.out.println("META = " + META);
....@@ -13466,14 +14893,16 @@
1346614893 if (editObj)
1346714894 {
1346814895 drag = true;
13469
- ClickInfo info = new ClickInfo();
13470
- info.bounds.setBounds(0, 0,
14896
+ //ClickInfo info = new ClickInfo();
14897
+ object.clickInfo.bounds.setBounds(0, 0,
1347114898 (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);
14899
+ object.clickInfo.pane = this;
14900
+ object.clickInfo.camera = renderCamera;
14901
+ object.clickInfo.x = x;
14902
+ object.clickInfo.y = y;
14903
+ object //.GetWindow().copy
14904
+ .doEditDrag(//info,
14905
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1347714906 } else
1347814907 {
1347914908 if (x < startX)
....@@ -13622,23 +15051,27 @@
1362215051 }
1362315052 }
1362415053
15054
+// ClickInfo clickInfo = new ClickInfo();
15055
+
1362515056 public void mouseMoved(MouseEvent e)
1362615057 {
1362715058 //System.out.println("mouseMoved: " + e);
13628
-
1362915059 if (isRenderer)
1363015060 return;
1363115061
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;
15062
+ // Mouse cursor feedback
15063
+ object.clickInfo.x = e.getX();
15064
+ object.clickInfo.y = e.getY();
15065
+ object.clickInfo.modifiers = e.getModifiersEx();
15066
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
15067
+ object.clickInfo.pane = this;
15068
+ object.clickInfo.camera = renderCamera;
1363915069 if (!isRenderer)
1364015070 {
13641
- if (object.editWindow.copy.doEditClick(ci, 0))
15071
+ //ObjEditor editWindow = object.editWindow;
15072
+ //Object3D copy = editWindow.copy;
15073
+ if (object.doEditClick(//clickInfo,
15074
+ 0))
1364215075 {
1364315076 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1364415077 } else
....@@ -13650,7 +15083,11 @@
1365015083
1365115084 public void mouseReleased(MouseEvent e)
1365215085 {
15086
+ Globals.MOUSEDRAGGED = false;
15087
+
1365315088 movingcamera = false;
15089
+ X = 0; // getBounds().width/2;
15090
+ Y = 0; // getBounds().height/2;
1365415091 //System.out.println("mouseReleased: " + e);
1365515092 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1365615093 }
....@@ -13673,9 +15110,9 @@
1367315110 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1367415111 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1367515112
13676
- if (control || command || IsFrozen())
15113
+// No delay if (control || command || IsFrozen())
1367715114 timeout = true;
13678
- else
15115
+// ?? May 2019 else
1367915116 // timer.setDelay((modifiers & 128) != 0?0:350);
1368015117 mouseDown = false;
1368115118 if (!control && !command) // june 2013
....@@ -13785,7 +15222,7 @@
1378515222 System.out.println("keyReleased: " + e);
1378615223 }
1378715224
13788
- void SetMouseMode(int modifiers)
15225
+ void SetMouseMode(int modifiers, int modifiersex)
1378915226 {
1379015227 //System.out.println("SetMouseMode = " + modifiers);
1379115228 //modifiers &= ~1024;
....@@ -13797,25 +15234,25 @@
1379715234 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1379815235 // return;
1379915236 //System.out.println("SetMode = " + modifiers);
13800
- if ((modifiers & WHEEL) == WHEEL)
15237
+ if ((modifiersex & WHEEL) == WHEEL)
1380115238 {
1380215239 mouseMode |= ZOOM;
1380315240 }
1380415241
1380515242 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
13806
- if (capsLocked || (modifiers & META) == META)
15243
+ if (capsLocked) // || (modifiers & META) == META)
1380715244 {
1380815245 mouseMode |= VR; // BACKFORTH;
1380915246 }
13810
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
15247
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1381115248 {
1381215249 mouseMode |= SELECT;
1381315250 }
13814
- if ((modifiers & COMMAND) == COMMAND)
15251
+ if ((modifiersex & COMMAND) == COMMAND)
1381515252 {
1381615253 mouseMode |= SELECT;
1381715254 }
13818
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
15255
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1381915256 {
1382015257 mouseMode &= ~VR;
1382115258 mouseMode |= TRANSLATE;
....@@ -13844,10 +15281,10 @@
1384415281
1384515282 if (isRenderer) //
1384615283 {
13847
- SetMouseMode(modifiers);
15284
+ SetMouseMode(0, modifiers);
1384815285 }
1384915286
13850
- theRenderer.keyPressed(key);
15287
+ Globals.theRenderer.keyPressed(key);
1385115288 }
1385215289
1385315290 int kompactbit = 4; // power bit
....@@ -13859,7 +15296,7 @@
1385915296 float SATPOW = 1; // 2; // 0.5f;
1386015297 float BRIPOW = 1; // 0.5f; // 0.5f;
1386115298
13862
- void keyPressed(int key)
15299
+ public void keyPressed(int key)
1386315300 {
1386415301 if (key >= '0' && key <= '5')
1386515302 clampbit = (key-'0');
....@@ -13906,7 +15343,8 @@
1390615343 // break;
1390715344 case 'T':
1390815345 CACHETEXTURE ^= true;
13909
- textures.clear();
15346
+ texturepigment.clear();
15347
+ texturebump.clear();
1391015348 // repaint();
1391115349 break;
1391215350 case 'Y':
....@@ -13916,8 +15354,8 @@
1391615354 case 'K':
1391715355 KOMPACTTEXTURE ^= true;
1391815356 //textures.clear();
13919
- break;
13920
- case 'P': // Texture Projection macros
15357
+ // break;
15358
+ //case 'P': // Texture Projection macros
1392115359 // SAVETEXTURE ^= true;
1392215360 macromode = true;
1392315361 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -13991,7 +15429,9 @@
1399115429 case 'E' : COMPACT ^= true;
1399215430 repaint();
1399315431 break;
13994
- case 'W' : DEBUGHSB ^= true;
15432
+ case 'W' : // Wide Window (fullscreen)
15433
+ //DEBUGHSB ^= true;
15434
+ ObjEditor.theFrame.ToggleFullScreen();
1399515435 repaint();
1399615436 break;
1399715437 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14016,8 +15456,8 @@
1401615456 RevertCamera();
1401715457 repaint();
1401815458 break;
14019
- case 'L':
1402015459 case 'l':
15460
+ //case 'L':
1402115461 if (lightMode)
1402215462 {
1402315463 lightMode = false;
....@@ -14036,7 +15476,7 @@
1403615476 targetLookAt.set(manipCamera.lookAt);
1403715477 repaint();
1403815478 break;
14039
- case 'p':
15479
+ case 'P': // p':
1404015480 // c'est quoi ca au juste? spherical ^= true;
1404115481 Skinshader ^= true; programInitialized = false;
1404215482 repaint();
....@@ -14074,27 +15514,31 @@
1407415514 repaint();
1407515515 break;
1407615516 case 'O':
14077
- Globals.drawMode = OCCLUSION; // WARNING
15517
+ // Too dangerous. Use menu. Globals.drawMode = OCCLUSION; // WARNING
1407815518 repaint();
1407915519 break;
1408015520 case 'o':
1408115521 OCCLUSION_CULLING ^= true;
1408215522 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1408315523 break;
14084
- case '0': envyoff ^= true; repaint(); break;
15524
+ //case '0': envyoff ^= true; repaint(); break;
1408515525 case '1':
1408615526 case '2':
1408715527 case '3':
1408815528 case '4':
1408915529 case '5':
14090
- newenvy = Character.getNumericValue(key);
14091
- repaint();
14092
- break;
1409315530 case '6':
1409415531 case '7':
1409515532 case '8':
1409615533 case '9':
14097
- BGcolor = (key - '6')/3.f;
15534
+ if (true) // envyoff)
15535
+ {
15536
+ BGcolor = (key - '1')/8.f;
15537
+ }
15538
+ else
15539
+ {
15540
+ //newenvy = Character.getNumericValue(key);
15541
+ }
1409815542 repaint();
1409915543 break;
1410015544 case '!':
....@@ -14160,9 +15604,9 @@
1416015604 case '_':
1416115605 kompactbit = 5;
1416215606 break;
14163
- case '+':
14164
- kompactbit = 6;
14165
- break;
15607
+// case '+':
15608
+// kompactbit = 6;
15609
+// break;
1416615610 case ' ':
1416715611 lightMode ^= true;
1416815612 Globals.lighttouched = true;
....@@ -14174,13 +15618,14 @@
1417415618 case ESC:
1417515619 RENDERPROGRAM += 1;
1417615620 RENDERPROGRAM %= 3;
15621
+
1417715622 repaint();
1417815623 break;
1417915624 case 'Z':
1418015625 //RESIZETEXTURE ^= true;
1418115626 //break;
1418215627 case 'z':
14183
- RENDERSHADOW ^= true;
15628
+ Globals.RENDERSHADOW ^= true;
1418415629 Globals.lighttouched = true;
1418515630 repaint();
1418615631 break;
....@@ -14213,8 +15658,9 @@
1421315658 case DELETE:
1421415659 ClearSelection();
1421515660 break;
14216
- /*
1421715661 case '+':
15662
+
15663
+ /*
1421815664 //fontsize += 1;
1421915665 bbzoom *= 2;
1422015666 repaint();
....@@ -14231,17 +15677,17 @@
1423115677 case '=':
1423215678 IncDepth();
1423315679 //fontsize += 1;
14234
- object.editWindow.refreshContents(true);
15680
+ object.GetWindow().refreshContents(true);
1423515681 maskbit = 6;
1423615682 break;
1423715683 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1423815684 DecDepth();
1423915685 maskbit = 5;
1424015686 //if(fontsize > 1) fontsize -= 1;
14241
- if (object.editWindow == null)
14242
- new Exception().printStackTrace();
14243
- else
14244
- object.editWindow.refreshContents(true);
15687
+// if (object.editWindow == null)
15688
+// new Exception().printStackTrace();
15689
+// else
15690
+ object.GetWindow().refreshContents(true);
1424515691 break;
1424615692 case '{':
1424715693 manipCamera.shaper_fovy /= 1.1;
....@@ -14296,6 +15742,7 @@
1429615742 }
1429715743 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1429815744 }
15745
+
1429915746 static double OCCLUSIONBOOST = 1; // 0.5;
1430015747
1430115748 void keyReleased(int key, int modifiers)
....@@ -14303,11 +15750,11 @@
1430315750 //mode = ROTATE;
1430415751 if ((MODIFIERS & COMMAND) == 0) // VR??
1430515752 {
14306
- SetMouseMode(modifiers);
15753
+ SetMouseMode(0, modifiers);
1430715754 }
1430815755 }
1430915756
14310
- protected void processKeyEvent(KeyEvent e)
15757
+ public void processKeyEvent(KeyEvent e)
1431115758 {
1431215759 switch (e.getID())
1431315760 {
....@@ -14437,8 +15884,9 @@
1443715884
1443815885 protected void processMouseMotionEvent(MouseEvent e)
1443915886 {
14440
- //System.out.println("processMouseMotionEvent: " + mouseMode);
14441
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15887
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15888
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15889
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1444215890 {
1444315891 mouseMoved(e);
1444415892 } else
....@@ -14463,11 +15911,12 @@
1446315911 }
1446415912 */
1446515913
14466
- object.editWindow.EditSelection();
15914
+ object.GetWindow().EditSelection(false);
1446715915 }
1446815916
1446915917 void SelectParent()
1447015918 {
15919
+ new Exception().printStackTrace();
1447115920 System.exit(0);
1447215921 Composite group = (Composite) object;
1447315922 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -14479,10 +15928,10 @@
1447915928 {
1448015929 //selectees.remove(i);
1448115930 System.out.println("select parent of " + elem);
14482
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15931
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1448315932 } else
1448415933 {
14485
- group.editWindow.Select(elem.GetTreePath(), first, true);
15934
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1448615935 }
1448715936
1448815937 first = false;
....@@ -14491,6 +15940,7 @@
1449115940
1449215941 void SelectChildren()
1449315942 {
15943
+ new Exception().printStackTrace();
1449415944 System.exit(0);
1449515945 /*
1449615946 Composite group = (Composite) object;
....@@ -14523,12 +15973,12 @@
1452315973 for (int j = 0; j < group.children.size(); j++)
1452415974 {
1452515975 elem = (Object3D) group.children.elementAt(j);
14526
- object.editWindow.Select(elem.GetTreePath(), first, true);
15976
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1452715977 first = false;
1452815978 }
1452915979 } else
1453015980 {
14531
- object.editWindow.Select(elem.GetTreePath(), first, true);
15981
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1453215982 }
1453315983
1453415984 first = false;
....@@ -14539,21 +15989,21 @@
1453915989 {
1454015990 //Composite group = (Composite) object;
1454115991 Object3D group = object;
14542
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15992
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1454315993 }
1454415994
1454515995 void ResetTransform(int mask)
1454615996 {
1454715997 //Composite group = (Composite) object;
1454815998 Object3D group = object;
14549
- group.editWindow.ResetTransform(mask);
15999
+ group.GetWindow().ResetTransform(mask);
1455016000 }
1455116001
1455216002 void FlipTransform()
1455316003 {
1455416004 //Composite group = (Composite) object;
1455516005 Object3D group = object;
14556
- group.editWindow.FlipTransform();
16006
+ group.GetWindow().FlipTransform();
1455716007 // group.editWindow.ReduceMesh(true);
1455816008 }
1455916009
....@@ -14561,7 +16011,7 @@
1456116011 {
1456216012 //Composite group = (Composite) object;
1456316013 Object3D group = object;
14564
- group.editWindow.PrintMemory();
16014
+ group.GetWindow().PrintMemory();
1456516015 // group.editWindow.ReduceMesh(true);
1456616016 }
1456716017
....@@ -14569,7 +16019,7 @@
1456916019 {
1457016020 //Composite group = (Composite) object;
1457116021 Object3D group = object;
14572
- group.editWindow.ResetCentroid();
16022
+ group.GetWindow().ResetCentroid();
1457316023 }
1457416024
1457516025 void IncDepth()
....@@ -14651,11 +16101,11 @@
1465116101
1465216102 int width = getBounds().width;
1465316103 int height = getBounds().height;
14654
- ClickInfo info = new ClickInfo();
14655
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1465616104 //Image img = CreateImage(width, height);
1465716105 //System.out.println("width = " + width + "; height = " + height + "\n");
16106
+
1465816107 Graphics gr = g; // img.getGraphics();
16108
+
1465916109 if (!hasMarquee)
1466016110 {
1466116111 if (Xmin < Xmax) // !locked)
....@@ -14727,44 +16177,92 @@
1472716177 }
1472816178 if (object != null && !hasMarquee)
1472916179 {
16180
+ if (object.clickInfo == null)
16181
+ object.clickInfo = new ClickInfo();
16182
+ ClickInfo info = object.clickInfo;
16183
+ //ClickInfo info = new ClickInfo();
16184
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
16185
+
1473016186 if (isRenderer)
1473116187 {
14732
- info.flags++;
16188
+ object.clickInfo.flags++;
1473316189 double frameAspect = (double) width / (double) height;
1473416190 if (frameAspect > renderCamera.aspect)
1473516191 {
1473616192 int desired = (int) ((double) height * renderCamera.aspect);
14737
- info.bounds.width -= width - desired;
14738
- info.bounds.x += (width - desired) / 2;
16193
+ object.clickInfo.bounds.width -= width - desired;
16194
+ object.clickInfo.bounds.x += (width - desired) / 2;
1473916195 } else
1474016196 {
1474116197 int desired = (int) ((double) width / renderCamera.aspect);
14742
- info.bounds.height -= height - desired;
14743
- info.bounds.y += (height - desired) / 2;
16198
+ object.clickInfo.bounds.height -= height - desired;
16199
+ object.clickInfo.bounds.y += (height - desired) / 2;
1474416200 }
1474516201 }
14746
- info.g = gr;
14747
- info.camera = renderCamera;
16202
+
16203
+ object.clickInfo.g = gr;
16204
+ object.clickInfo.camera = renderCamera;
1474816205 /*
1474916206 // Memory intensive (brep.verticescopy)
1475016207 if (!(object instanceof Composite))
1475116208 object.draw(info, 0, false); // SLOW :
1475216209 */
14753
- if (!isRenderer)
16210
+ if (!isRenderer) // && drag)
1475416211 {
14755
- object.drawEditHandles(info, 0);
16212
+ Grafreed.Assert(object != null);
16213
+ Grafreed.Assert(object.selection != null);
16214
+ if (object.selection.Size() > 0)
16215
+ {
16216
+ int hitSomething = object.selection.get(0).hitSomething;
16217
+
16218
+ object.clickInfo.DX = 0;
16219
+ object.clickInfo.DY = 0;
16220
+ object.clickInfo.W = 1;
16221
+ if (hitSomething == Object3D.hitCenter)
16222
+ {
16223
+ info.DX = X;
16224
+ if (X != 0)
16225
+ info.DX -= info.bounds.width/2;
16226
+
16227
+ info.DY = Y;
16228
+ if (Y != 0)
16229
+ info.DY -= info.bounds.height/2;
16230
+ }
16231
+
16232
+ object.drawEditHandles(//info,
16233
+ 0);
16234
+
16235
+ if (drag && (X != 0 || Y != 0))
16236
+ {
16237
+ switch (hitSomething)
16238
+ {
16239
+ case Object3D.hitCenter: gr.setColor(Color.white);
16240
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16241
+ break;
16242
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
16243
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16244
+ break;
16245
+ case Object3D.hitScale: gr.setColor(Color.cyan);
16246
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16247
+ break;
16248
+ }
16249
+
16250
+ }
16251
+ }
1475616252 }
1475716253 }
16254
+
1475816255 if (isRenderer)
1475916256 {
1476016257 //gr.setColor(Color.black);
1476116258 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1476216259 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1476316260 }
16261
+
1476416262 if (hasMarquee)
1476516263 {
1476616264 gr.setXORMode(Color.white);
14767
- gr.setColor(Color.red);
16265
+ gr.setColor(Color.white);
1476816266 if (!firstime)
1476916267 {
1477016268 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -14873,6 +16371,7 @@
1487316371 public boolean mouseDown(Event evt, int x, int y)
1487416372 {
1487516373 System.out.println("mouseDown: " + evt);
16374
+ System.exit(0);
1487616375 /*
1487716376 locked = true;
1487816377 drag = false;
....@@ -14916,7 +16415,7 @@
1491616415 {
1491716416 keyPressed(0, modifiers);
1491816417 }
14919
- clickStart(x, y, modifiers);
16418
+ // clickStart(x, y, modifiers);
1492016419 return true;
1492116420 }
1492216421
....@@ -15034,7 +16533,7 @@
1503416533 {
1503516534 keyReleased(0, 0);
1503616535 }
15037
- drag(x, y, modifiers);
16536
+ drag(x, y, 0, modifiers);
1503816537 return true;
1503916538 }
1504016539
....@@ -15166,7 +16665,7 @@
1516616665 Object3D object;
1516716666 static Object3D trackedobject;
1516816667 Camera renderCamera; // Light or Eye (or Occlusion)
15169
- /*static*/ Camera manipCamera; // Light or Eye
16668
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1517016669 /*static*/ Camera eyeCamera;
1517116670 /*static*/ Camera lightCamera;
1517216671 int cameracount;
....@@ -15230,6 +16729,8 @@
1523016729 private /*static*/ boolean firstime;
1523116730 private /*static*/ cVector newView = new cVector();
1523216731 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16732
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16733
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1523316734 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1523416735 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1523516736 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -15242,29 +16743,67 @@
1524216743 {
1524316744 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1524416745
16746
+ int usedsuf = 0;
16747
+
1524516748 for (int i = 0; i < suffixes.length; i++)
1524616749 {
15247
- String resourceName = basename + suffixes[i] + "." + suffix;
15248
- TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
15249
- mipmapped,
15250
- FileUtil.getFileSuffix(resourceName));
15251
- if (data == null)
16750
+ String[] suffixe = suffixes;
16751
+ String[] fallback = suffixes2;
16752
+ String[] fallfallback = suffixes3;
16753
+
16754
+ for (int c=usedsuf; --c>=0;)
1525216755 {
15253
- throw new IOException("Unable to load texture " + resourceName);
16756
+// String[] temp = suffixe;
16757
+// suffixe = fallback;
16758
+// fallback = fallfallback;
16759
+// fallfallback = temp;
1525416760 }
16761
+
16762
+ String resourceName = basename + suffixe[i] + "." + suffix;
16763
+ TextureData data;
16764
+
16765
+ try
16766
+ {
16767
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16768
+ mipmapped,
16769
+ FileUtil.getFileSuffix(resourceName));
16770
+ }
16771
+ catch (Exception e)
16772
+ {
16773
+ try
16774
+ {
16775
+ resourceName = basename + fallback[i] + "." + suffix;
16776
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16777
+ mipmapped,
16778
+ FileUtil.getFileSuffix(resourceName));
16779
+ }
16780
+ catch (Exception e2)
16781
+ {
16782
+ resourceName = basename + fallfallback[i] + "." + suffix;
16783
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16784
+ mipmapped,
16785
+ FileUtil.getFileSuffix(resourceName));
16786
+ }
16787
+ }
16788
+
1525516789 //System.out.println("Target = " + targets[i]);
1525616790 cubemap.updateImage(data, targets[i]);
1525716791 }
1525816792
1525916793 return cubemap;
1526016794 }
16795
+
1526116796 int bigsphere = -1;
1526216797
1526316798 float BGcolor = 0.5f;
1526416799
15265
- private void DrawSkyBox(GL gl)
16800
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16801
+
16802
+ private void DrawSkyBox(GL gl, float ratio)
1526616803 {
15267
- if (envyoff || cubemap == null)
16804
+ if (//envyoff ||
16805
+ WIREFRAME ||
16806
+ cubemap == null)
1526816807 {
1526916808 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1527016809 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -15279,7 +16818,17 @@
1527916818 // Compensates for ExaminerViewer's modification of modelview matrix
1528016819 gl.glMatrixMode(GL.GL_MODELVIEW);
1528116820 gl.glLoadIdentity();
16821
+ gl.glScalef(1,ratio,1);
1528216822
16823
+// colorV[0] = 2;
16824
+// colorV[1] = 2;
16825
+// colorV[2] = 2;
16826
+// colorV[3] = 1;
16827
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16828
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16829
+//
16830
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16831
+
1528316832 //gl.glActiveTexture(GL.GL_TEXTURE1);
1528416833 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1528516834
....@@ -15311,6 +16860,7 @@
1531116860 {
1531216861 gl.glScalef(1.0f, -1.0f, 1.0f);
1531316862 }
16863
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1531416864 gl.glMultMatrixd(viewrot_1, 0);
1531516865 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1531616866 //viewer.updateInverseRotation(gl);
....@@ -15351,7 +16901,8 @@
1535116901 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1535216902
1535316903 cubemap.disable();
15354
- ////cubemap.unbind();
16904
+ //cubemap.dispose();
16905
+
1535516906 if (CULLFACE)
1535616907 {
1535716908 gl.glEnable(gl.GL_CULL_FACE);
....@@ -15407,7 +16958,7 @@
1540716958 gl.glScalef(1.0f, -1.0f, 1.0f);
1540816959 }
1540916960
15410
- gl.glNormal3f(0.0f, 0.0f, 1.0f);
16961
+ SetGLNormal(gl, 0.0f, 0.0f, 1.0f);
1541116962
1541216963 float step = 2; // 0.1666f; //0.25f;
1541316964 float stepv = 2; // step * 1652 / 998;
....@@ -15451,16 +17002,16 @@
1545117002 cStatic.objectstack[materialdepth++] = checker;
1545217003 //System.out.println("material " + material);
1545317004 //Applet3D.tracein(this, selected);
15454
- vector2buffer = checker.projectedVertices;
17005
+ //vector2buffer = checker.projectedVertices;
1545517006
1545617007 //checker.GetMaterial().Draw(this, false); // true);
15457
- DrawMaterial(checker.GetMaterial(), false); // true);
17008
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1545817009
1545917010 materialdepth -= 1;
1546017011 if (materialdepth > 0)
1546117012 {
15462
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
15463
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
17013
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
17014
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1546417015 }
1546517016 //checker.GetMaterial().opacity = 1f;
1546617017 ////checker.GetMaterial().ambient = 1f;
....@@ -15546,6 +17097,14 @@
1554617097 }
1554717098 }
1554817099
17100
+ private Object3D GetFolder()
17101
+ {
17102
+ Object3D folder = object.GetWindow().copy;
17103
+ if (object.GetWindow().copy.selection.Size() > 0)
17104
+ folder = object.GetWindow().copy.selection.elementAt(0);
17105
+ return folder;
17106
+ }
17107
+
1554917108 class SelectBuffer implements GLEventListener
1555017109 {
1555117110
....@@ -15561,7 +17120,7 @@
1556117120 //new Exception().printStackTrace();
1556217121 System.out.println("select buffer init");
1556317122 // Use debug pipeline
15564
- drawable.setGL(new DebugGL(drawable.getGL()));
17123
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1556517124
1556617125 GL gl = drawable.getGL();
1556717126
....@@ -15604,6 +17163,7 @@
1560417163 {
1560517164 if (!selection)
1560617165 {
17166
+ new Exception().printStackTrace();
1560717167 System.exit(0);
1560817168 return;
1560917169 }
....@@ -15624,6 +17184,17 @@
1562417184
1562517185 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1562617186
17187
+ if (PAINTMODE)
17188
+ {
17189
+ if (object.GetWindow().copy.selection.Size() > 0)
17190
+ {
17191
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
17192
+
17193
+ // Make what you paint not selectable.
17194
+ paintobj.ResetSelectable();
17195
+ }
17196
+ }
17197
+
1562717198 //int tmp = selection_view;
1562817199 //selection_view = -1;
1562917200 int temp = DrawMode();
....@@ -15635,6 +17206,17 @@
1563517206 // temp = DEFAULT; // patch for selection debug
1563617207 Globals.drawMode = temp; // WARNING
1563717208
17209
+ if (PAINTMODE)
17210
+ {
17211
+ if (object.GetWindow().copy.selection.Size() > 0)
17212
+ {
17213
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
17214
+
17215
+ // Revert.
17216
+ paintobj.RestoreSelectable();
17217
+ }
17218
+ }
17219
+
1563817220 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1563917221
1564017222 // trying different ways of getting the depth info over
....@@ -15682,6 +17264,8 @@
1568217264 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1568317265 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1568417266 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
17267
+
17268
+ CreateSelectedPoint();
1568517269
1568617270 // Will fit the mesh !!!
1568717271 selectedpoint.toParent[0][0] = 0.0001;
....@@ -15731,34 +17315,36 @@
1573117315 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]));
1573217316 }
1573317317
15734
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
17318
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1573517319 }
1573617320 }
1573717321
1573817322 if (!movingcamera && !PAINTMODE)
15739
- object.editWindow.ScreenFitPoint(); // fev 2014
17323
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1574017324
15741
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
17325
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1574217326 {
15743
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
17327
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1574417328
15745
- Object3D group = new Object3D("inst" + paintcount++);
17329
+ if (object.GetWindow().copy.selection.Size() > 0)
17330
+ {
17331
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1574617332
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();
17333
+ Object3D inst = new Object3D("inst" + paintcount++);
17334
+
17335
+ inst.CreateMaterial(); // use a void leaf to select instances
17336
+
17337
+ inst.add(paintobj); // link
17338
+
17339
+ object.GetWindow().SnapObject(inst);
17340
+
17341
+ Object3D folder = paintFolder; // GetFolder();
17342
+
17343
+ folder.add(inst);
17344
+
17345
+ object.GetWindow().ResetModel();
17346
+ object.GetWindow().refreshContents();
17347
+ }
1576217348 }
1576317349 else
1576417350 paintcount = 0;
....@@ -15797,6 +17383,11 @@
1579717383 //System.out.println("objects[color] = " + objects[color]);
1579817384 //objects[color].Select();
1579917385 indexcount = 0;
17386
+ ObjEditor window = object.GetWindow();
17387
+ if (window != null && deselect)
17388
+ {
17389
+ window.Select(null, deselect, true);
17390
+ }
1580017391 object.Select(color, deselect);
1580117392 }
1580217393
....@@ -15847,6 +17438,7 @@
1584717438
1584817439 public void init(GLAutoDrawable drawable)
1584917440 {
17441
+ if (Globals.DEBUG)
1585017442 System.out.println("shadow buffer init");
1585117443
1585217444 GL gl = drawable.getGL();
....@@ -15896,7 +17488,7 @@
1589617488 gl.glDisable(gl.GL_CULL_FACE);
1589717489 }
1589817490
15899
- if (!RENDERSHADOW)
17491
+ if (!Globals.RENDERSHADOW)
1590017492 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1590117493
1590217494 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -15906,7 +17498,7 @@
1590617498 //gl.glColorMask(false, false, false, false);
1590717499
1590817500 //render_scene_from_light_view(gl, drawable, 0, 0);
15909
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17501
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1591017502 {
1591117503 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1591217504
....@@ -15966,7 +17558,6 @@
1596617558
1596717559 class AntialiasBuffer implements GLEventListener
1596817560 {
15969
-
1597017561 CameraPane parent = null;
1597117562
1597217563 AntialiasBuffer(CameraPane p)
....@@ -16076,10 +17667,14 @@
1607617667 gl.glFlush();
1607717668
1607817669 /**/
16079
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
17670
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer);
1608017671
16081
- float[] pixels = occlusionsizebuffer.array();
17672
+ float[] depths = occlusiondepthbuffer.array();
1608217673
17674
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
17675
+
17676
+ int[] pixels = selectsizebuffer.array();
17677
+
1608317678 double r = 0, g = 0, b = 0;
1608417679
1608517680 double count = 0;
....@@ -16090,7 +17685,7 @@
1609017685
1609117686 double FACTOR = 1;
1609217687
16093
- for (int i = 0; i < pixels.length; i++)
17688
+ for (int i = 0; i < depths.length; i++)
1609417689 {
1609517690 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1609617691 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -16173,7 +17768,7 @@
1617317768
1617417769 double scale = ray.z; // 1; // cos
1617517770
16176
- float depth = pixels[newindex];
17771
+ float depth = depths[newindex];
1617717772
1617817773 /*
1617917774 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -16323,23 +17918,15 @@
1632317918 int AAbuffersize = 0;
1632417919
1632517920 //double[] selectedpoint = new double[3];
16326
- static Superellipsoid selectedpoint = new Superellipsoid();
17921
+ static Superellipsoid selectedpoint;
1632717922 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();
17923
+ static Sphere debugpointG;
17924
+ static Sphere debugpointP;
17925
+ static Sphere debugpointC;
17926
+ static Sphere debugpointR;
1633217927
1633317928 static Sphere debugpoints[] = new Sphere[8];
1633417929
16335
- static
16336
- {
16337
- for (int i=0; i<8; i++)
16338
- {
16339
- debugpoints[i] = new Sphere();
16340
- }
16341
- }
16342
-
1634317930 static void InitPoints(float radius)
1634417931 {
1634517932 for (int i=0; i<8; i++)
....@@ -16359,7 +17946,7 @@
1635917946 }
1636017947 }
1636117948
16362
- static void DrawPoints(CameraPane cpane)
17949
+ static void DrawPoints(iCameraPane cpane)
1636317950 {
1636417951 for (int i=0; i<8; i++) // first and last are red
1636517952 {
....@@ -16378,11 +17965,14 @@
1637817965 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1637917966 static IntBuffer bigAAbuffer;
1638017967 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
16381
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17968
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1638217969 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1638317970 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1638417971 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
16385
- static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17972
+ static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17973
+
17974
+ static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17975
+
1638617976 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1638717977 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1638817978 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();
....@@ -16391,10 +17981,11 @@
1639117981 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1639217982 // Depth buffer format
1639317983 //private int depth_format;
16394
- static public void NextIndex(Object3D o, GL gl)
17984
+
17985
+ public void NextIndex()
1639517986 {
1639617987 indexcount+=16;
16397
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17988
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1639817989 //objects[indexcount] = o;
1639917990 //System.out.println("indexcount = " + indexcount);
1640017991 }