.. | .. |
---|
18 | 18 | import javax.imageio.ImageIO; |
---|
19 | 19 | import javax.imageio.ImageWriteParam; |
---|
20 | 20 | import javax.imageio.ImageWriter; |
---|
| 21 | +import javax.imageio.ImageReadParam; |
---|
| 22 | +import javax.imageio.ImageReader; |
---|
21 | 23 | import javax.imageio.plugins.jpeg.JPEGImageWriteParam; |
---|
| 24 | +import javax.imageio.stream.ImageInputStream; |
---|
22 | 25 | import javax.imageio.stream.ImageOutputStream; |
---|
23 | 26 | import javax.imageio.ImageWriteParam; |
---|
24 | 27 | |
---|
.. | .. |
---|
30 | 33 | import java.nio.*; |
---|
31 | 34 | |
---|
32 | 35 | import gleem.linalg.Mat4f; |
---|
| 36 | +import javax.imageio.ImageTypeSpecifier; |
---|
33 | 37 | |
---|
34 | 38 | class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 39 | { |
---|
.. | .. |
---|
37 | 41 | static boolean[] selectedstack = new boolean[65536]; |
---|
38 | 42 | static int materialdepth = 0; |
---|
39 | 43 | |
---|
40 | | - static boolean DEBUG = false; |
---|
41 | 44 | static boolean FRUSTUM = false; // still bogus true; // frustum culling |
---|
42 | 45 | |
---|
43 | 46 | // camera change fix |
---|
.. | .. |
---|
45 | 48 | static boolean ABORTED = false; |
---|
46 | 49 | |
---|
47 | 50 | 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 | + } |
---|
48 | 84 | |
---|
49 | 85 | /*static*/ private boolean CULLFACE = false; // true; |
---|
50 | 86 | /*static*/ boolean NEAREST = false; // true; |
---|
.. | .. |
---|
56 | 92 | static int CURRENTANTIALIAS = 0; // 1; |
---|
57 | 93 | /*static*/ boolean RENDERSHADOW = true; |
---|
58 | 94 | /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal |
---|
59 | | - static boolean ANIMATION = false; |
---|
60 | | - static String filename; |
---|
61 | 95 | |
---|
62 | 96 | boolean DISPLAYTEXT = false; |
---|
63 | 97 | //boolean REDUCETEXTURE = true; |
---|
64 | 98 | boolean CACHETEXTURE = true; |
---|
65 | 99 | boolean CLEANCACHE = false; // true; |
---|
66 | | - boolean MIPMAP = false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
67 | 101 | boolean COMPRESSTEXTURE = false; |
---|
68 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
69 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
92 | 126 | |
---|
93 | 127 | static int tickcount = 0; // slow pose issue |
---|
94 | 128 | |
---|
| 129 | +static boolean BUTTONLESSWHEEL = false; |
---|
| 130 | +static boolean ZOOMBOXMODE = false; |
---|
95 | 131 | static boolean BOXMODE = false; |
---|
96 | 132 | static boolean IMAGEFLIP = false; |
---|
97 | 133 | static boolean SMOOTHFOCUS = false; |
---|
.. | .. |
---|
106 | 142 | static boolean OEIL = true; |
---|
107 | 143 | static boolean OEILONCE = false; // do oeilon then oeiloff |
---|
108 | 144 | static boolean LOOKAT = true; |
---|
109 | | -static boolean RANDOM = true; // false; |
---|
| 145 | +static boolean SWITCH = true; // false; |
---|
110 | 146 | static boolean HANDLES = false; // selection doesn't work!! |
---|
111 | 147 | static boolean PAINTMODE = false; |
---|
112 | 148 | |
---|
.. | .. |
---|
150 | 186 | defaultcaps.setAccumAlphaBits(16); |
---|
151 | 187 | } |
---|
152 | 188 | |
---|
| 189 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 190 | + |
---|
153 | 191 | void SetAsGLRenderer(boolean b) |
---|
154 | 192 | { |
---|
155 | 193 | isRenderer = b; |
---|
.. | .. |
---|
191 | 229 | |
---|
192 | 230 | /// INTERFACE |
---|
193 | 231 | |
---|
| 232 | + public javax.media.opengl.GL GetGL0() |
---|
| 233 | + { |
---|
| 234 | + return null; |
---|
| 235 | + } |
---|
| 236 | + |
---|
| 237 | + public int GenList() |
---|
| 238 | + { |
---|
| 239 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 240 | + return gl.glGenLists(1); |
---|
| 241 | + } |
---|
| 242 | + |
---|
| 243 | + public void NewList(int id) |
---|
| 244 | + { |
---|
| 245 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 246 | + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 247 | + } |
---|
| 248 | + |
---|
| 249 | + public void CallList(int id) |
---|
| 250 | + { |
---|
| 251 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 252 | + gl.glCallList(id); |
---|
| 253 | + } |
---|
| 254 | + |
---|
| 255 | + public void EndList() |
---|
| 256 | + { |
---|
| 257 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 258 | + gl.glEndList(); |
---|
| 259 | + } |
---|
| 260 | + |
---|
194 | 261 | public boolean IsBoxMode() |
---|
195 | 262 | { |
---|
196 | 263 | return BOXMODE; |
---|
| 264 | + } |
---|
| 265 | + |
---|
| 266 | + public boolean IsZoomBoxMode() |
---|
| 267 | + { |
---|
| 268 | + return ZOOMBOXMODE; |
---|
197 | 269 | } |
---|
198 | 270 | |
---|
199 | 271 | public void ClearDepth() |
---|
.. | .. |
---|
291 | 363 | cStatic.objectstack[materialdepth++] = obj; |
---|
292 | 364 | //System.out.println("material " + material); |
---|
293 | 365 | //Applet3D.tracein(this, selected); |
---|
294 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 366 | + //display.vector2buffer = obj.projectedVertices; |
---|
295 | 367 | if (obj instanceof Camera) |
---|
296 | 368 | { |
---|
297 | 369 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
300 | 372 | display.options1[2] = material.shadowbias; |
---|
301 | 373 | display.options1[3] = material.aniso; |
---|
302 | 374 | display.options1[4] = material.anisoV; |
---|
| 375 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 376 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 377 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 378 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 379 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
303 | 380 | display.options2[0] = material.opacity; |
---|
304 | 381 | display.options2[1] = material.diffuse; |
---|
305 | 382 | display.options2[2] = material.factor; |
---|
| 383 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 384 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 385 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
306 | 386 | |
---|
307 | 387 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 388 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 389 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 390 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
308 | 391 | display.options4[0] = material.cameralight/0.2f; |
---|
309 | 392 | display.options4[1] = material.subsurface; |
---|
310 | 393 | display.options4[2] = material.sheen; |
---|
| 394 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 395 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 396 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
311 | 397 | |
---|
312 | 398 | // if (display.CURRENTANTIALIAS > 0) |
---|
313 | 399 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
323 | 409 | /**/ |
---|
324 | 410 | } else |
---|
325 | 411 | { |
---|
326 | | - DrawMaterial(material, selected); |
---|
| 412 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
327 | 413 | } |
---|
328 | 414 | } else |
---|
329 | 415 | { |
---|
.. | .. |
---|
347 | 433 | cStatic.objectstack[materialdepth++] = obj; |
---|
348 | 434 | //System.out.println("material " + material); |
---|
349 | 435 | //Applet3D.tracein("selected ", selected); |
---|
350 | | - display.vector2buffer = obj.projectedVertices; |
---|
351 | | - display.DrawMaterial(material, selected); |
---|
| 436 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 437 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
352 | 438 | } |
---|
353 | 439 | } |
---|
354 | 440 | |
---|
.. | .. |
---|
365 | 451 | materialdepth -= 1; |
---|
366 | 452 | if (materialdepth > 0) |
---|
367 | 453 | { |
---|
368 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
369 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 454 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 455 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
370 | 456 | } |
---|
371 | 457 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
372 | 458 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
386 | 472 | materialdepth -= 1; |
---|
387 | 473 | if (materialdepth > 0) |
---|
388 | 474 | { |
---|
389 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
390 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 475 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 476 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
391 | 477 | } |
---|
392 | 478 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
393 | 479 | //else |
---|
.. | .. |
---|
428 | 514 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
429 | 515 | { |
---|
430 | 516 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
431 | | - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 517 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 518 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 519 | + ; |
---|
432 | 520 | if (!hasnorm) |
---|
433 | 521 | { |
---|
434 | | - // System.out.println("FUCK!!"); |
---|
| 522 | + // System.out.println("Mesh normal"); |
---|
435 | 523 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
436 | 524 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
437 | 525 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
1059 | 1147 | gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
1060 | 1148 | } |
---|
1061 | 1149 | |
---|
| 1150 | + public void DrawBox(cVector min, cVector max) |
---|
| 1151 | + { |
---|
| 1152 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1153 | + gl.glBegin(gl.GL_LINES); |
---|
| 1154 | + |
---|
| 1155 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1156 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1157 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1158 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1159 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1160 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1161 | + |
---|
| 1162 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1163 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1164 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1165 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1166 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1167 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1168 | + |
---|
| 1169 | + gl.glEnd(); |
---|
| 1170 | + } |
---|
| 1171 | + |
---|
| 1172 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1173 | + { |
---|
| 1174 | + int[] strips = bRep.getRawIndices(); |
---|
| 1175 | + |
---|
| 1176 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1177 | + |
---|
| 1178 | + // TRIANGLE STRIP ARRAY |
---|
| 1179 | + if (bRep.trimmed) |
---|
| 1180 | + { |
---|
| 1181 | + float[] v = bRep.getRawVertices(); |
---|
| 1182 | + float[] n = bRep.getRawNormals(); |
---|
| 1183 | + float[] c = bRep.getRawColors(); |
---|
| 1184 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1185 | + |
---|
| 1186 | + int count2 = 0; |
---|
| 1187 | + int count3 = 0; |
---|
| 1188 | + |
---|
| 1189 | + if (n.length > 0) |
---|
| 1190 | + { |
---|
| 1191 | + for (int i = 0; i < strips.length; i++) |
---|
| 1192 | + { |
---|
| 1193 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1194 | + |
---|
| 1195 | + /* |
---|
| 1196 | + boolean locked = false; |
---|
| 1197 | + float eps = 0.1f; |
---|
| 1198 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1199 | + |
---|
| 1200 | + int dot = 0; |
---|
| 1201 | + |
---|
| 1202 | + if ((dot&1) == 0) |
---|
| 1203 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1204 | + |
---|
| 1205 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1206 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1207 | + else |
---|
| 1208 | + { |
---|
| 1209 | + locked = true; |
---|
| 1210 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1211 | + } |
---|
| 1212 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1213 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1214 | + if (hasnorm) |
---|
| 1215 | + { |
---|
| 1216 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1217 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1218 | + } |
---|
| 1219 | + |
---|
| 1220 | + if ((dot&4) == 0) |
---|
| 1221 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1222 | + |
---|
| 1223 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1224 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1225 | + else |
---|
| 1226 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1227 | + |
---|
| 1228 | + f.dot = dot; |
---|
| 1229 | + */ |
---|
| 1230 | + |
---|
| 1231 | + if (!selectmode) |
---|
| 1232 | + { |
---|
| 1233 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1234 | + { |
---|
| 1235 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1236 | + } else |
---|
| 1237 | + { |
---|
| 1238 | + gl.glNormal3f(0, 0, 1); |
---|
| 1239 | + } |
---|
| 1240 | + |
---|
| 1241 | + if (c != null) |
---|
| 1242 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1243 | + { |
---|
| 1244 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1245 | + } |
---|
| 1246 | + } |
---|
| 1247 | + |
---|
| 1248 | + if (flipV) |
---|
| 1249 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1250 | + else |
---|
| 1251 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1252 | + |
---|
| 1253 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1254 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1255 | + |
---|
| 1256 | + count2 += 2; |
---|
| 1257 | + count3 += 3; |
---|
| 1258 | + if (!selectmode) |
---|
| 1259 | + { |
---|
| 1260 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1261 | + { |
---|
| 1262 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1263 | + } else |
---|
| 1264 | + { |
---|
| 1265 | + gl.glNormal3f(0, 0, 1); |
---|
| 1266 | + } |
---|
| 1267 | + if (c != null) |
---|
| 1268 | + { |
---|
| 1269 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1270 | + } |
---|
| 1271 | + } |
---|
| 1272 | + |
---|
| 1273 | + if (flipV) |
---|
| 1274 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1275 | + else |
---|
| 1276 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1277 | + |
---|
| 1278 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1279 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1280 | + |
---|
| 1281 | + count2 += 2; |
---|
| 1282 | + count3 += 3; |
---|
| 1283 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1284 | + { |
---|
| 1285 | + //gl.glTexCoord2d(...); |
---|
| 1286 | + if (!selectmode) |
---|
| 1287 | + { |
---|
| 1288 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1289 | + { |
---|
| 1290 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1291 | + } else |
---|
| 1292 | + { |
---|
| 1293 | + gl.glNormal3f(0, 0, 1); |
---|
| 1294 | + } |
---|
| 1295 | + if (c != null) |
---|
| 1296 | + { |
---|
| 1297 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1298 | + } |
---|
| 1299 | + } |
---|
| 1300 | + |
---|
| 1301 | + if (flipV) |
---|
| 1302 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1303 | + else |
---|
| 1304 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1305 | + |
---|
| 1306 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1307 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1308 | + |
---|
| 1309 | + count2 += 2; |
---|
| 1310 | + count3 += 3; |
---|
| 1311 | + } |
---|
| 1312 | + |
---|
| 1313 | + gl.glEnd(); |
---|
| 1314 | + } |
---|
| 1315 | + } |
---|
| 1316 | + |
---|
| 1317 | + assert count3 == v.length; |
---|
| 1318 | + } |
---|
| 1319 | + else // !trimmed |
---|
| 1320 | + { |
---|
| 1321 | + int count = 0; |
---|
| 1322 | + for (int i = 0; i < strips.length; i++) |
---|
| 1323 | + { |
---|
| 1324 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1325 | + |
---|
| 1326 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1327 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1328 | + |
---|
| 1329 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1330 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1331 | + |
---|
| 1332 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1333 | + { |
---|
| 1334 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1335 | + |
---|
| 1336 | + // if (j%2 == 0) |
---|
| 1337 | + // drawFace(p, q, r, display, null); |
---|
| 1338 | + // else |
---|
| 1339 | + // drawFace(p, r, q, display, null); |
---|
| 1340 | + |
---|
| 1341 | + // p = q; |
---|
| 1342 | + // q = r; |
---|
| 1343 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1344 | + } |
---|
| 1345 | + |
---|
| 1346 | + gl.glEnd(); |
---|
| 1347 | + } |
---|
| 1348 | + } |
---|
| 1349 | + } |
---|
| 1350 | + |
---|
| 1351 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1352 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1353 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1354 | + |
---|
| 1355 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1356 | + { |
---|
| 1357 | + GL gl = GetGL(); // getGL(); |
---|
| 1358 | + |
---|
| 1359 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1360 | + |
---|
| 1361 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1362 | + |
---|
| 1363 | + gl.glLineWidth(1); |
---|
| 1364 | + gl.glColor3f(1,1,1); |
---|
| 1365 | + gl.glBegin(gl.GL_LINES); |
---|
| 1366 | + double scale = 0; |
---|
| 1367 | + int count = 0; |
---|
| 1368 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1369 | + { |
---|
| 1370 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1371 | + if(s == 0) |
---|
| 1372 | + { |
---|
| 1373 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1374 | + } |
---|
| 1375 | + if (mesh.showsprings) |
---|
| 1376 | + { |
---|
| 1377 | + temp.set(spring.a.position); |
---|
| 1378 | + temp.add(spring.b.position); |
---|
| 1379 | + temp.mul(0.5); |
---|
| 1380 | + temp2.set(spring.a.position); |
---|
| 1381 | + temp2.sub(spring.b.position); |
---|
| 1382 | + temp2.mul(spring.restLength/2); |
---|
| 1383 | + temp.sub(temp2); |
---|
| 1384 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1385 | + temp.add(temp2); |
---|
| 1386 | + temp.add(temp2); |
---|
| 1387 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1388 | + } |
---|
| 1389 | + |
---|
| 1390 | + if (spring.isHandle) |
---|
| 1391 | + continue; |
---|
| 1392 | + |
---|
| 1393 | + //if (scale < spring.restLength) |
---|
| 1394 | + scale += spring.restLength; |
---|
| 1395 | + count++; |
---|
| 1396 | + } |
---|
| 1397 | + gl.glEnd(); |
---|
| 1398 | + |
---|
| 1399 | + if (count == 0) |
---|
| 1400 | + scale = 0.01; |
---|
| 1401 | + else |
---|
| 1402 | + scale /= count * 3; |
---|
| 1403 | + |
---|
| 1404 | + //scale = 0.25; |
---|
| 1405 | + |
---|
| 1406 | + if (mesh.ShowInfo()) |
---|
| 1407 | + { |
---|
| 1408 | + gl.glLineWidth(4); |
---|
| 1409 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1410 | + { |
---|
| 1411 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1412 | + if (node.mass == 0) |
---|
| 1413 | + continue; |
---|
| 1414 | + |
---|
| 1415 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1416 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1417 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1418 | + //temp.normalize(); |
---|
| 1419 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1420 | + gl.glBegin(gl.GL_LINES); |
---|
| 1421 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1422 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1423 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1424 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1425 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1426 | + gl.glEnd(); |
---|
| 1427 | + } |
---|
| 1428 | + |
---|
| 1429 | + gl.glLineWidth(8); |
---|
| 1430 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1431 | + { |
---|
| 1432 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1433 | + |
---|
| 1434 | + if (node.springs != null) |
---|
| 1435 | + { |
---|
| 1436 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1437 | + { |
---|
| 1438 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1439 | + |
---|
| 1440 | + int c = i+1; |
---|
| 1441 | + // c = node.springs.get(i).nbcopies; |
---|
| 1442 | + |
---|
| 1443 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1444 | + gl.glBegin(gl.GL_LINES); |
---|
| 1445 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1446 | + gl.glVertex3d(f.position.x/3+node.position.x*2/3, f.position.y/3+node.position.y*2/3, f.position.z/3+node.position.z*2/3); |
---|
| 1447 | + gl.glEnd(); |
---|
| 1448 | + } |
---|
| 1449 | + } |
---|
| 1450 | + } |
---|
| 1451 | + |
---|
| 1452 | + gl.glLineWidth(1); |
---|
| 1453 | + } |
---|
| 1454 | + |
---|
| 1455 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1456 | + } |
---|
| 1457 | + |
---|
1062 | 1458 | /// INTERFACE |
---|
| 1459 | + |
---|
| 1460 | + public void StartTriangles() |
---|
| 1461 | + { |
---|
| 1462 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1463 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1464 | + } |
---|
| 1465 | + |
---|
| 1466 | + public void EndTriangles() |
---|
| 1467 | + { |
---|
| 1468 | + GetGL().glEnd(); |
---|
| 1469 | + } |
---|
| 1470 | + |
---|
| 1471 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1472 | + { |
---|
| 1473 | + if (!selectmode) |
---|
| 1474 | + { |
---|
| 1475 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1476 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1477 | + |
---|
| 1478 | + if (flipV) |
---|
| 1479 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1480 | + else |
---|
| 1481 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1482 | + } |
---|
| 1483 | + |
---|
| 1484 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1485 | + } |
---|
1063 | 1486 | |
---|
1064 | 1487 | void SetColor(Object3D obj, Vertex p0) |
---|
1065 | 1488 | { |
---|
.. | .. |
---|
1238 | 1661 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
1239 | 1662 | } |
---|
1240 | 1663 | |
---|
1241 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1664 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
1242 | 1665 | { |
---|
1243 | 1666 | CameraPane display = this; |
---|
1244 | 1667 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1254 | 1677 | //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
1255 | 1678 | if (!material.multiply) |
---|
1256 | 1679 | { |
---|
1257 | | - display.color = color; |
---|
| 1680 | + display.color = material.color; |
---|
1258 | 1681 | display.saturation = material.modulation; |
---|
1259 | 1682 | } |
---|
1260 | 1683 | else |
---|
1261 | 1684 | { |
---|
1262 | | - display.color *= color*2; |
---|
| 1685 | + display.color *= material.color*2; |
---|
1263 | 1686 | display.saturation *= material.modulation*2; |
---|
1264 | 1687 | } |
---|
1265 | 1688 | |
---|
1266 | 1689 | cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
1267 | 1690 | |
---|
1268 | | - float[] colorV = GrafreeD.colorV; |
---|
| 1691 | + float[] colorV = Grafreed.colorV; |
---|
1269 | 1692 | |
---|
1270 | 1693 | /**/ |
---|
1271 | 1694 | if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
.. | .. |
---|
1273 | 1696 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
1274 | 1697 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
1275 | 1698 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
1276 | | - colorV[3] = material.opacity; |
---|
| 1699 | + colorV[3] = 1; // material.opacity; |
---|
1277 | 1700 | |
---|
1278 | 1701 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
1279 | 1702 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1381 | 1804 | display.modelParams7[2] = 0; |
---|
1382 | 1805 | display.modelParams7[3] = 0; |
---|
1383 | 1806 | |
---|
1384 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1807 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1385 | 1808 | |
---|
1386 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1809 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1387 | 1810 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1388 | 1811 | { |
---|
1389 | 1812 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1525 | 1948 | void PushMatrix(double[][] matrix) |
---|
1526 | 1949 | { |
---|
1527 | 1950 | // GrafreeD.tracein(matrix); |
---|
1528 | | - PushMatrix(matrix,1); |
---|
| 1951 | + PushMatrix(matrix, 1); |
---|
1529 | 1952 | } |
---|
1530 | 1953 | |
---|
1531 | 1954 | void PushMatrix() |
---|
.. | .. |
---|
1679 | 2102 | //System.err.println("Oeil on"); |
---|
1680 | 2103 | OEIL = true; |
---|
1681 | 2104 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
1682 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2105 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
1683 | 2106 | //pingthread.StepToTarget(true); |
---|
1684 | 2107 | } |
---|
1685 | 2108 | |
---|
.. | .. |
---|
1777 | 2200 | System.err.println("LIVE = " + Globals.isLIVE()); |
---|
1778 | 2201 | |
---|
1779 | 2202 | if (!Globals.isLIVE()) // save sound |
---|
1780 | | - GrafreeD.savesound = true; // wav.save(); |
---|
| 2203 | + Grafreed.savesound = true; // wav.save(); |
---|
1781 | 2204 | // else |
---|
1782 | 2205 | repaint(); // start loop // may 2013 |
---|
1783 | 2206 | } |
---|
.. | .. |
---|
1810 | 2233 | public void ToggleBoxMode() |
---|
1811 | 2234 | { |
---|
1812 | 2235 | BOXMODE ^= true; |
---|
| 2236 | + } |
---|
| 2237 | + |
---|
| 2238 | + public void ToggleZoomBoxMode() |
---|
| 2239 | + { |
---|
| 2240 | + ZOOMBOXMODE ^= true; |
---|
1813 | 2241 | } |
---|
1814 | 2242 | |
---|
1815 | 2243 | public void ToggleSmoothFocus() |
---|
.. | .. |
---|
1889 | 2317 | |
---|
1890 | 2318 | void ToggleDebug() |
---|
1891 | 2319 | { |
---|
1892 | | - DEBUG ^= true; |
---|
| 2320 | + Globals.DEBUG ^= true; |
---|
1893 | 2321 | } |
---|
1894 | 2322 | |
---|
1895 | 2323 | void ToggleLookAt() |
---|
.. | .. |
---|
1897 | 2325 | LOOKAT ^= true; |
---|
1898 | 2326 | } |
---|
1899 | 2327 | |
---|
1900 | | - void ToggleRandom() |
---|
| 2328 | + void ToggleSwitch() |
---|
1901 | 2329 | { |
---|
1902 | | - RANDOM ^= true; |
---|
| 2330 | + SWITCH ^= true; |
---|
1903 | 2331 | } |
---|
1904 | 2332 | |
---|
1905 | 2333 | void ToggleHandles() |
---|
.. | .. |
---|
1907 | 2335 | HANDLES ^= true; |
---|
1908 | 2336 | } |
---|
1909 | 2337 | |
---|
| 2338 | + Object3D paintFolder; |
---|
| 2339 | + |
---|
1910 | 2340 | void TogglePaint() |
---|
1911 | 2341 | { |
---|
1912 | 2342 | PAINTMODE ^= true; |
---|
1913 | 2343 | paintcount = 0; |
---|
| 2344 | + |
---|
| 2345 | + if (PAINTMODE) |
---|
| 2346 | + { |
---|
| 2347 | + paintFolder = GetFolder(); |
---|
| 2348 | + } |
---|
1914 | 2349 | } |
---|
1915 | 2350 | |
---|
1916 | 2351 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2006 | 2441 | { |
---|
2007 | 2442 | return currentGL; |
---|
2008 | 2443 | } |
---|
2009 | | - |
---|
| 2444 | + |
---|
| 2445 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2446 | + { |
---|
| 2447 | + Grafreed.Assert(texturedata != null); |
---|
| 2448 | + |
---|
| 2449 | + int width = texturedata.getWidth(); |
---|
| 2450 | + int height = texturedata.getHeight(); |
---|
| 2451 | + |
---|
| 2452 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2453 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2454 | + |
---|
| 2455 | + byte[] bytes = bytebuf.array(); |
---|
| 2456 | + |
---|
| 2457 | + return CreateBim(bytes, width, height); |
---|
| 2458 | + } |
---|
| 2459 | + |
---|
2010 | 2460 | /**/ |
---|
2011 | 2461 | class CacheTexture |
---|
2012 | 2462 | { |
---|
.. | .. |
---|
2015 | 2465 | |
---|
2016 | 2466 | int resolution; |
---|
2017 | 2467 | |
---|
2018 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2468 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2019 | 2469 | { |
---|
2020 | | - texture = tex; |
---|
| 2470 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2471 | + texturedata = texdata; |
---|
2021 | 2472 | resolution = res; |
---|
2022 | 2473 | } |
---|
2023 | 2474 | } |
---|
2024 | 2475 | /**/ |
---|
2025 | 2476 | |
---|
2026 | 2477 | // TEXTURE static Texture texture; |
---|
2027 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2028 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2029 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2478 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2479 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2480 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2481 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2482 | + |
---|
2030 | 2483 | int pigmentdepth = 0; |
---|
2031 | 2484 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2032 | 2485 | int bumpdepth = 0; |
---|
2033 | 2486 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2034 | 2487 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2035 | 2488 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2036 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2489 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2037 | 2490 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2038 | 2491 | |
---|
2039 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2492 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2040 | 2493 | { |
---|
2041 | 2494 | TextureData texturedata = null; |
---|
2042 | 2495 | |
---|
.. | .. |
---|
2055 | 2508 | if (bump) |
---|
2056 | 2509 | texturedata = ConvertBump(texturedata, false); |
---|
2057 | 2510 | |
---|
2058 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2059 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2511 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2512 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2060 | 2513 | |
---|
2061 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2062 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2514 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2515 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2063 | 2516 | |
---|
2064 | | - return texture; |
---|
| 2517 | + return texturedata; |
---|
| 2518 | + } |
---|
| 2519 | + |
---|
| 2520 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2521 | + { |
---|
| 2522 | + TextureData texturedata = null; |
---|
| 2523 | + |
---|
| 2524 | + try |
---|
| 2525 | + { |
---|
| 2526 | + texturedata = |
---|
| 2527 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2528 | + bim, |
---|
| 2529 | + true); |
---|
| 2530 | + } catch (Exception e) |
---|
| 2531 | + { |
---|
| 2532 | + throw new javax.media.opengl.GLException(e); |
---|
| 2533 | + } |
---|
| 2534 | + |
---|
| 2535 | + if (bump) |
---|
| 2536 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2537 | + |
---|
| 2538 | + return texturedata; |
---|
2065 | 2539 | } |
---|
2066 | 2540 | |
---|
2067 | 2541 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3134 | 3608 | |
---|
3135 | 3609 | System.out.println("LOADING TEXTURE : " + name); |
---|
3136 | 3610 | |
---|
| 3611 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3612 | + |
---|
3137 | 3613 | // |
---|
3138 | 3614 | if (false) // compressbit > 0) |
---|
3139 | 3615 | { |
---|
.. | .. |
---|
3838 | 4314 | |
---|
3839 | 4315 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
3840 | 4316 | { |
---|
| 4317 | + new Exception().printStackTrace(); |
---|
3841 | 4318 | System.exit(0); |
---|
3842 | 4319 | com.sun.opengl.util.texture.Texture texture = null; |
---|
3843 | 4320 | |
---|
.. | .. |
---|
7531 | 8008 | String pigment = Object3D.GetPigment(tex); |
---|
7532 | 8009 | String bump = Object3D.GetBump(tex); |
---|
7533 | 8010 | |
---|
7534 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8011 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7535 | 8012 | { |
---|
7536 | 8013 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7537 | 8014 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7546 | 8023 | pigment = null; |
---|
7547 | 8024 | } |
---|
7548 | 8025 | |
---|
7549 | | - ReleaseTexture(bump, true); |
---|
7550 | | - ReleaseTexture(pigment, false); |
---|
| 8026 | + ReleaseTexture(tex, true); |
---|
| 8027 | + ReleaseTexture(tex, false); |
---|
7551 | 8028 | } |
---|
7552 | 8029 | |
---|
7553 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8030 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 8031 | + { |
---|
| 8032 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8033 | + { |
---|
| 8034 | + return; |
---|
| 8035 | + } |
---|
| 8036 | + |
---|
| 8037 | + if (tex == null) |
---|
| 8038 | + { |
---|
| 8039 | + ReleaseTexture(null, false); |
---|
| 8040 | + return; |
---|
| 8041 | + } |
---|
| 8042 | + |
---|
| 8043 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8044 | + |
---|
| 8045 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8046 | + { |
---|
| 8047 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8048 | + // System.out.println("; bump = " + bump); |
---|
| 8049 | + } |
---|
| 8050 | + |
---|
| 8051 | + if (pigment.equals("")) |
---|
| 8052 | + { |
---|
| 8053 | + pigment = null; |
---|
| 8054 | + } |
---|
| 8055 | + |
---|
| 8056 | + ReleaseTexture(tex, false); |
---|
| 8057 | + } |
---|
| 8058 | + |
---|
| 8059 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8060 | + { |
---|
| 8061 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8062 | + { |
---|
| 8063 | + return; |
---|
| 8064 | + } |
---|
| 8065 | + |
---|
| 8066 | + if (tex == null) |
---|
| 8067 | + { |
---|
| 8068 | + ReleaseTexture(null, true); |
---|
| 8069 | + return; |
---|
| 8070 | + } |
---|
| 8071 | + |
---|
| 8072 | + String bump = Object3D.GetBump(tex); |
---|
| 8073 | + |
---|
| 8074 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8075 | + { |
---|
| 8076 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8077 | + // System.out.println("; bump = " + bump); |
---|
| 8078 | + } |
---|
| 8079 | + |
---|
| 8080 | + if (bump.equals("")) |
---|
| 8081 | + { |
---|
| 8082 | + bump = null; |
---|
| 8083 | + } |
---|
| 8084 | + |
---|
| 8085 | + ReleaseTexture(tex, true); |
---|
| 8086 | + } |
---|
| 8087 | + |
---|
| 8088 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7554 | 8089 | { |
---|
7555 | 8090 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7556 | 8091 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7561 | 8096 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7562 | 8097 | |
---|
7563 | 8098 | if (tex != null) |
---|
7564 | | - texture = textures.get(tex); |
---|
| 8099 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7565 | 8100 | |
---|
7566 | 8101 | // //assert( texture != null ); |
---|
7567 | 8102 | // if (texture == null) |
---|
.. | .. |
---|
7653 | 8188 | } |
---|
7654 | 8189 | } |
---|
7655 | 8190 | |
---|
7656 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8191 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8192 | + { |
---|
| 8193 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8194 | +// ambientOcclusion ) // || !textureon) |
---|
| 8195 | +// { |
---|
| 8196 | +// return; // false; |
---|
| 8197 | +// } |
---|
| 8198 | +// |
---|
| 8199 | +// if (tex == null) |
---|
| 8200 | +// { |
---|
| 8201 | +// BindTexture(null,false,resolution); |
---|
| 8202 | +// BindTexture(null,true,resolution); |
---|
| 8203 | +// return; |
---|
| 8204 | +// } |
---|
| 8205 | +// |
---|
| 8206 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8207 | +// String bump = Object3D.GetBump(tex); |
---|
| 8208 | +// |
---|
| 8209 | +// usedtextures.add(pigment); |
---|
| 8210 | +// usedtextures.add(bump); |
---|
| 8211 | +// |
---|
| 8212 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8213 | +// { |
---|
| 8214 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8215 | +// // System.out.println("; bump = " + bump); |
---|
| 8216 | +// } |
---|
| 8217 | +// |
---|
| 8218 | +// if (bump.equals("")) |
---|
| 8219 | +// { |
---|
| 8220 | +// bump = null; |
---|
| 8221 | +// } |
---|
| 8222 | +// if (pigment.equals("")) |
---|
| 8223 | +// { |
---|
| 8224 | +// pigment = null; |
---|
| 8225 | +// } |
---|
| 8226 | +// |
---|
| 8227 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8228 | +// BindTexture(pigment, false, resolution); |
---|
| 8229 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8230 | +// BindTexture(bump, true, resolution); |
---|
| 8231 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8232 | +// |
---|
| 8233 | +// return; // true; |
---|
| 8234 | + |
---|
| 8235 | + BindPigmentTexture(tex, resolution); |
---|
| 8236 | + BindBumpTexture(tex, resolution); |
---|
| 8237 | + } |
---|
| 8238 | + |
---|
| 8239 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
7657 | 8240 | { |
---|
7658 | 8241 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7659 | 8242 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7664 | 8247 | if (tex == null) |
---|
7665 | 8248 | { |
---|
7666 | 8249 | BindTexture(null,false,resolution); |
---|
7667 | | - BindTexture(null,true,resolution); |
---|
7668 | 8250 | return; |
---|
7669 | 8251 | } |
---|
7670 | 8252 | |
---|
7671 | 8253 | String pigment = Object3D.GetPigment(tex); |
---|
| 8254 | + |
---|
| 8255 | + usedtextures.add(tex); |
---|
| 8256 | + |
---|
| 8257 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8258 | + { |
---|
| 8259 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8260 | + // System.out.println("; bump = " + bump); |
---|
| 8261 | + } |
---|
| 8262 | + |
---|
| 8263 | + if (pigment.equals("")) |
---|
| 8264 | + { |
---|
| 8265 | + pigment = null; |
---|
| 8266 | + } |
---|
| 8267 | + |
---|
| 8268 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8269 | + BindTexture(tex, false, resolution); |
---|
| 8270 | + } |
---|
| 8271 | + |
---|
| 8272 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8273 | + { |
---|
| 8274 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8275 | + ambientOcclusion ) // || !textureon) |
---|
| 8276 | + { |
---|
| 8277 | + return; // false; |
---|
| 8278 | + } |
---|
| 8279 | + |
---|
| 8280 | + if (tex == null) |
---|
| 8281 | + { |
---|
| 8282 | + BindTexture(null,true,resolution); |
---|
| 8283 | + return; |
---|
| 8284 | + } |
---|
| 8285 | + |
---|
7672 | 8286 | String bump = Object3D.GetBump(tex); |
---|
7673 | 8287 | |
---|
7674 | | - usedtextures.put(pigment, pigment); |
---|
7675 | | - usedtextures.put(bump, bump); |
---|
| 8288 | + usedtextures.add(tex); |
---|
7676 | 8289 | |
---|
7677 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8290 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7678 | 8291 | { |
---|
7679 | 8292 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
7680 | 8293 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7684 | 8297 | { |
---|
7685 | 8298 | bump = null; |
---|
7686 | 8299 | } |
---|
7687 | | - if (pigment.equals("")) |
---|
7688 | | - { |
---|
7689 | | - pigment = null; |
---|
7690 | | - } |
---|
7691 | 8300 | |
---|
7692 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7693 | | - BindTexture(pigment, false, resolution); |
---|
7694 | 8301 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
7695 | | - BindTexture(bump, true, resolution); |
---|
| 8302 | + BindTexture(tex, true, resolution); |
---|
7696 | 8303 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7697 | | - |
---|
7698 | | - return; // true; |
---|
7699 | 8304 | } |
---|
7700 | 8305 | |
---|
7701 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8306 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8307 | + |
---|
| 8308 | + private boolean FileExists(String tex) |
---|
7702 | 8309 | { |
---|
7703 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8310 | + if (missingTextures.contains(tex)) |
---|
| 8311 | + { |
---|
| 8312 | + return false; |
---|
| 8313 | + } |
---|
| 8314 | + |
---|
| 8315 | + boolean fileExists = new File(tex).exists(); |
---|
| 8316 | + |
---|
| 8317 | + if (!fileExists) |
---|
| 8318 | + { |
---|
| 8319 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8320 | + missingTextures.add(tex); |
---|
| 8321 | + } |
---|
| 8322 | + |
---|
| 8323 | + return fileExists; |
---|
| 8324 | + } |
---|
| 8325 | + |
---|
| 8326 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
| 8327 | + { |
---|
| 8328 | + CacheTexture texturecache = null; |
---|
7704 | 8329 | |
---|
7705 | 8330 | if (tex != null) |
---|
7706 | 8331 | { |
---|
7707 | | - String texname = tex; |
---|
| 8332 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8333 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
7708 | 8334 | |
---|
7709 | | - String[] split = tex.split("Textures"); |
---|
7710 | | - if (split.length > 1) |
---|
7711 | | - texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
7712 | | - else |
---|
7713 | | - if (!texname.startsWith("/")) |
---|
7714 | | - texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8335 | + if (texname.equals("") && texdata == null) |
---|
| 8336 | + { |
---|
| 8337 | + return null; |
---|
| 8338 | + } |
---|
| 8339 | + |
---|
| 8340 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8341 | + |
---|
| 8342 | +// String[] split = tex.split("Textures"); |
---|
| 8343 | +// if (split.length > 1) |
---|
| 8344 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8345 | +// else |
---|
| 8346 | +// if (!texname.startsWith("/")) |
---|
| 8347 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8348 | + if (!FileExists(texname)) |
---|
| 8349 | + { |
---|
| 8350 | + texname = fallbackTextureName; |
---|
| 8351 | + } |
---|
7715 | 8352 | |
---|
7716 | 8353 | if (CACHETEXTURE) |
---|
7717 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
7718 | | - |
---|
7719 | | - TextureData texturedata = null; |
---|
7720 | | - |
---|
7721 | | - if (texture == null || texture.resolution < resolution) |
---|
7722 | 8354 | { |
---|
7723 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8355 | + if (texdata == null) |
---|
| 8356 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8357 | + else |
---|
| 8358 | + texturecache = bimtextures.get(texdata); |
---|
| 8359 | + } |
---|
| 8360 | + |
---|
| 8361 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8362 | + { |
---|
| 8363 | + TextureData texturedata = null; |
---|
| 8364 | + |
---|
| 8365 | + if (texdata != null && textureon) |
---|
| 8366 | + { |
---|
| 8367 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8368 | + |
---|
| 8369 | + try |
---|
| 8370 | + { |
---|
| 8371 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8372 | + } |
---|
| 8373 | + catch (Exception e) |
---|
| 8374 | + { |
---|
| 8375 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8376 | + } |
---|
| 8377 | + |
---|
| 8378 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8379 | + bimtextures.put(texdata, texturecache); |
---|
| 8380 | + |
---|
| 8381 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8382 | + |
---|
| 8383 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8384 | + //bim2 = bim; |
---|
| 8385 | + } |
---|
| 8386 | + else |
---|
| 8387 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
7724 | 8388 | { |
---|
7725 | 8389 | assert(!bump); |
---|
7726 | 8390 | // if (bump) |
---|
.. | .. |
---|
7731 | 8395 | // } |
---|
7732 | 8396 | // else |
---|
7733 | 8397 | // { |
---|
7734 | | - texture = textures.get(tex); |
---|
7735 | | - if (texture == null) |
---|
| 8398 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8399 | + if (texturecache == null) |
---|
7736 | 8400 | { |
---|
7737 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8401 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
7738 | 8402 | } |
---|
| 8403 | + else |
---|
| 8404 | + new Exception().printStackTrace(); |
---|
7739 | 8405 | // } |
---|
7740 | 8406 | } else |
---|
7741 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8407 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
7742 | 8408 | { |
---|
7743 | 8409 | assert(bump); |
---|
7744 | | - texture = textures.get(tex); |
---|
7745 | | - if (texture == null) |
---|
7746 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8410 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8411 | + if (texturecache == null) |
---|
| 8412 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8413 | + else |
---|
| 8414 | + new Exception().printStackTrace(); |
---|
7747 | 8415 | } else |
---|
7748 | 8416 | { |
---|
7749 | 8417 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
7751 | 8419 | // texture = GetResourceTexture("default.png"); |
---|
7752 | 8420 | //} else |
---|
7753 | 8421 | //{ |
---|
7754 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8422 | + if (texname.endsWith("WHITE_NOISE")) |
---|
7755 | 8423 | { |
---|
7756 | | - texture = textures.get(tex); |
---|
7757 | | - if (texture == null) |
---|
7758 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8424 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8425 | + if (texturecache == null) |
---|
| 8426 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8427 | + else |
---|
| 8428 | + new Exception().printStackTrace(); |
---|
7759 | 8429 | } else |
---|
7760 | 8430 | { |
---|
7761 | 8431 | if (textureon) |
---|
.. | .. |
---|
7780 | 8450 | } |
---|
7781 | 8451 | |
---|
7782 | 8452 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
7783 | | - if (!new File(cachename).exists()) |
---|
| 8453 | + if (!FileExists(cachename)) |
---|
7784 | 8454 | cachename = texname; |
---|
7785 | 8455 | else |
---|
7786 | 8456 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7802 | 8472 | } |
---|
7803 | 8473 | |
---|
7804 | 8474 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
7805 | | - if (!new File(cachename).exists()) |
---|
| 8475 | + if (!FileExists(cachename)) |
---|
7806 | 8476 | cachename = texname; |
---|
7807 | 8477 | else |
---|
7808 | 8478 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7811 | 8481 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
7812 | 8482 | |
---|
7813 | 8483 | |
---|
7814 | | - if (texturedata != null) |
---|
7815 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8484 | + if (texturedata == null) |
---|
| 8485 | + throw new Exception(); |
---|
| 8486 | + |
---|
| 8487 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
7816 | 8488 | //texture = GetTexture(tex, bump); |
---|
7817 | 8489 | } |
---|
7818 | 8490 | } |
---|
7819 | 8491 | //} |
---|
7820 | 8492 | } |
---|
7821 | 8493 | |
---|
7822 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8494 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
7823 | 8495 | { |
---|
7824 | 8496 | //return false; |
---|
7825 | 8497 | |
---|
7826 | 8498 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
7827 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8499 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
7828 | 8500 | { |
---|
7829 | 8501 | // String ext = "_highres"; |
---|
7830 | 8502 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
7841 | 8513 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
7842 | 8514 | if (!cachefile.exists()) |
---|
7843 | 8515 | { |
---|
7844 | | - // cache to disk |
---|
7845 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
7846 | | - //buffers[0]. |
---|
7847 | | - |
---|
7848 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
7849 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
7850 | | - |
---|
7851 | | - // squared size heuristic... |
---|
7852 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8516 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
7853 | 8517 | { |
---|
7854 | | - for (int i=pixels.length; --i>=0;) |
---|
7855 | | - { |
---|
7856 | | - int i3 = i*3; |
---|
7857 | | - pixels[i] = 0xFF; |
---|
7858 | | - pixels[i] <<= 8; |
---|
7859 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
7860 | | - pixels[i] <<= 8; |
---|
7861 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
7862 | | - pixels[i] <<= 8; |
---|
7863 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
7864 | | - } |
---|
7865 | | - |
---|
7866 | | - /* |
---|
7867 | | - int r=0,g=0,b=0,a=0; |
---|
7868 | | - for (int i=0; i<width; i++) |
---|
7869 | | - for (int j=0; j<height; j++) |
---|
7870 | | - { |
---|
7871 | | - int index = j*width+i; |
---|
7872 | | - int p = pixels[index]; |
---|
7873 | | - a = ((p>>24) & 0xFF); |
---|
7874 | | - r = ((p>>16) & 0xFF); |
---|
7875 | | - g = ((p>>8) & 0xFF); |
---|
7876 | | - b = (p & 0xFF); |
---|
7877 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
7878 | | - } |
---|
7879 | | - /**/ |
---|
7880 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
7881 | | - int height = width; |
---|
7882 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
7883 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8518 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8519 | + |
---|
7884 | 8520 | ImageWriter writer = null; |
---|
7885 | 8521 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
7886 | 8522 | if (iter.hasNext()) { |
---|
7887 | 8523 | writer = (ImageWriter)iter.next(); |
---|
7888 | 8524 | } |
---|
7889 | | - float compressionQuality = 0.9f; |
---|
| 8525 | + |
---|
| 8526 | + float compressionQuality = 0.85f; |
---|
7890 | 8527 | try |
---|
7891 | 8528 | { |
---|
7892 | 8529 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
7903 | 8540 | } |
---|
7904 | 8541 | } |
---|
7905 | 8542 | } |
---|
7906 | | - |
---|
| 8543 | + |
---|
| 8544 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8545 | + |
---|
7907 | 8546 | //System.out.println("Texture = " + tex); |
---|
7908 | | - if (textures.containsKey(texname)) |
---|
| 8547 | + if (textures.containsKey(tex)) |
---|
7909 | 8548 | { |
---|
7910 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8549 | + CacheTexture thetex = textures.get(tex); |
---|
7911 | 8550 | thetex.texture.disable(); |
---|
7912 | 8551 | thetex.texture.dispose(); |
---|
7913 | | - textures.remove(texname); |
---|
| 8552 | + textures.remove(tex); |
---|
7914 | 8553 | } |
---|
7915 | 8554 | |
---|
7916 | | - texture.texturedata = texturedata; |
---|
7917 | | - textures.put(texname, texture); |
---|
| 8555 | + //texture.texturedata = texturedata; |
---|
| 8556 | + textures.put(tex, texturecache); |
---|
7918 | 8557 | |
---|
7919 | 8558 | // newtex = true; |
---|
7920 | 8559 | } |
---|
.. | .. |
---|
7930 | 8569 | } |
---|
7931 | 8570 | } |
---|
7932 | 8571 | |
---|
7933 | | - return texture; |
---|
| 8572 | + return texturecache; |
---|
7934 | 8573 | } |
---|
7935 | 8574 | |
---|
7936 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8575 | + static void EmbedTextures(cTexture tex) |
---|
| 8576 | + { |
---|
| 8577 | + if (tex.pigmentdata == null) |
---|
| 8578 | + { |
---|
| 8579 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8580 | + |
---|
| 8581 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8582 | + |
---|
| 8583 | + if (texturecache != null) |
---|
| 8584 | + { |
---|
| 8585 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8586 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8587 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8588 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8589 | + ; |
---|
| 8590 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8591 | + } |
---|
| 8592 | + } |
---|
| 8593 | + |
---|
| 8594 | + if (tex.bumpdata == null) |
---|
| 8595 | + { |
---|
| 8596 | + //String texname = Object3D.GetBump(tex); |
---|
| 8597 | + |
---|
| 8598 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8599 | + |
---|
| 8600 | + if (texturecache != null) |
---|
| 8601 | + { |
---|
| 8602 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8603 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8604 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8605 | + } |
---|
| 8606 | + } |
---|
| 8607 | + } |
---|
| 8608 | + |
---|
| 8609 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7937 | 8610 | { |
---|
7938 | 8611 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7939 | 8612 | |
---|
.. | .. |
---|
7951 | 8624 | return texture!=null?texture.texture:null; |
---|
7952 | 8625 | } |
---|
7953 | 8626 | |
---|
7954 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8627 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7955 | 8628 | { |
---|
7956 | 8629 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7957 | 8630 | |
---|
7958 | 8631 | return texture!=null?texture.texturedata:null; |
---|
7959 | 8632 | } |
---|
7960 | 8633 | |
---|
7961 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8634 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7962 | 8635 | { |
---|
7963 | 8636 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
7964 | 8637 | { |
---|
7965 | 8638 | return false; |
---|
7966 | 8639 | } |
---|
7967 | 8640 | |
---|
7968 | | - boolean newtex = false; |
---|
| 8641 | + //boolean newtex = false; |
---|
7969 | 8642 | |
---|
7970 | 8643 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
7971 | 8644 | |
---|
.. | .. |
---|
7997 | 8670 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
7998 | 8671 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
7999 | 8672 | |
---|
8000 | | - return newtex; |
---|
| 8673 | + return true; // Warning: not used. |
---|
8001 | 8674 | } |
---|
8002 | 8675 | |
---|
| 8676 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8677 | + { |
---|
| 8678 | + try |
---|
| 8679 | + { |
---|
| 8680 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8681 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8682 | + ImageWriter writer = writers.next(); |
---|
| 8683 | + |
---|
| 8684 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8685 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8686 | + param.setCompressionQuality(quality); |
---|
| 8687 | + |
---|
| 8688 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8689 | + writer.setOutput(ios); |
---|
| 8690 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8691 | + |
---|
| 8692 | + byte[] data = baos.toByteArray(); |
---|
| 8693 | + writer.dispose(); |
---|
| 8694 | + return data; |
---|
| 8695 | + } |
---|
| 8696 | + catch (Exception e) |
---|
| 8697 | + { |
---|
| 8698 | + e.printStackTrace(); |
---|
| 8699 | + return null; |
---|
| 8700 | + } |
---|
| 8701 | + } |
---|
| 8702 | + |
---|
| 8703 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8704 | + { |
---|
| 8705 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8706 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8707 | + ImageReader reader = writers.next(); |
---|
| 8708 | + |
---|
| 8709 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8710 | + |
---|
| 8711 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8712 | + param.setDestination(bim); |
---|
| 8713 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8714 | + |
---|
| 8715 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8716 | + reader.setInput(ios); |
---|
| 8717 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8718 | + reader.dispose(); |
---|
| 8719 | + |
---|
| 8720 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8721 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8722 | +// byte[] bytes = data.getData(); |
---|
| 8723 | +// |
---|
| 8724 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8725 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8726 | +// { |
---|
| 8727 | +// int i3 = i*3; |
---|
| 8728 | +// pixels[i] = 0xFF; |
---|
| 8729 | +// pixels[i] <<= 8; |
---|
| 8730 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8731 | +// pixels[i] <<= 8; |
---|
| 8732 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8733 | +// pixels[i] <<= 8; |
---|
| 8734 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8735 | +// } |
---|
| 8736 | +// |
---|
| 8737 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8738 | + |
---|
| 8739 | + return bim; |
---|
| 8740 | + } |
---|
| 8741 | + |
---|
8003 | 8742 | ShadowBuffer shadowPBuf; |
---|
8004 | 8743 | AntialiasBuffer antialiasPBuf; |
---|
8005 | 8744 | int MAXSTACK; |
---|
.. | .. |
---|
8835 | 9574 | jy8[3] = 0.5f; |
---|
8836 | 9575 | } |
---|
8837 | 9576 | |
---|
8838 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9577 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
8839 | 9578 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
8840 | 9579 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
8841 | 9580 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
8842 | 9581 | |
---|
| 9582 | + void ResetOptions() |
---|
| 9583 | + { |
---|
| 9584 | + options1[0] = 100; |
---|
| 9585 | + options1[1] = 0.025f; |
---|
| 9586 | + options1[2] = 0.01f; |
---|
| 9587 | + options1[3] = 0; |
---|
| 9588 | + options1[4] = 0; |
---|
| 9589 | + |
---|
| 9590 | + options2[0] = 0; |
---|
| 9591 | + options2[1] = 0.75f; |
---|
| 9592 | + options2[2] = 0; |
---|
| 9593 | + options2[3] = 0; |
---|
| 9594 | + |
---|
| 9595 | + options3[0] = 1; |
---|
| 9596 | + options3[1] = 1; |
---|
| 9597 | + options3[2] = 1; |
---|
| 9598 | + options3[3] = 0; |
---|
| 9599 | + |
---|
| 9600 | + options4[0] = 1; |
---|
| 9601 | + options4[1] = 0; |
---|
| 9602 | + options4[2] = 1; |
---|
| 9603 | + options4[3] = 0; |
---|
| 9604 | + } |
---|
| 9605 | + |
---|
8843 | 9606 | static int imagecount = 0; // movie generation |
---|
8844 | 9607 | |
---|
8845 | 9608 | static int jitter = 0; |
---|
.. | .. |
---|
8935 | 9698 | assert (parentcam != renderCamera); |
---|
8936 | 9699 | |
---|
8937 | 9700 | if (renderCamera != lightCamera) |
---|
8938 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8939 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9701 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9702 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
8940 | 9703 | |
---|
8941 | 9704 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
8942 | 9705 | |
---|
.. | .. |
---|
8951 | 9714 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
8952 | 9715 | |
---|
8953 | 9716 | if (renderCamera != lightCamera) |
---|
8954 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8955 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9717 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9718 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
8956 | 9719 | |
---|
8957 | 9720 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
8958 | 9721 | |
---|
.. | .. |
---|
9024 | 9787 | //gl.glFlush(); |
---|
9025 | 9788 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
9026 | 9789 | |
---|
9027 | | - if (ANIMATION && ABORTED) |
---|
| 9790 | + if (Globals.ANIMATION && ABORTED) |
---|
9028 | 9791 | { |
---|
9029 | 9792 | System.err.println(" ABORTED FRAME"); |
---|
9030 | 9793 | break; |
---|
.. | .. |
---|
9054 | 9817 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
9055 | 9818 | |
---|
9056 | 9819 | // save image |
---|
9057 | | - if (ANIMATION && !ABORTED) |
---|
| 9820 | + if (Globals.ANIMATION && !ABORTED) |
---|
9058 | 9821 | { |
---|
9059 | 9822 | VPwidth = viewport[2]; |
---|
9060 | 9823 | VPheight = viewport[3]; |
---|
.. | .. |
---|
9165 | 9928 | |
---|
9166 | 9929 | // imagecount++; |
---|
9167 | 9930 | |
---|
9168 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9931 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
9169 | 9932 | |
---|
9170 | 9933 | if (!BOXMODE) |
---|
9171 | 9934 | { |
---|
9172 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9935 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
9173 | 9936 | } |
---|
9174 | 9937 | |
---|
9175 | 9938 | if (!BOXMODE) |
---|
.. | .. |
---|
9207 | 9970 | ABORTED = false; |
---|
9208 | 9971 | } |
---|
9209 | 9972 | else |
---|
9210 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 9973 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
9211 | 9974 | |
---|
9212 | 9975 | if (false) |
---|
9213 | 9976 | { |
---|
.. | .. |
---|
9870 | 10633 | |
---|
9871 | 10634 | public void display(GLAutoDrawable drawable) |
---|
9872 | 10635 | { |
---|
9873 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10636 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
9874 | 10637 | { |
---|
9875 | | - GrafreeD.wav.save(); |
---|
9876 | | - GrafreeD.savesound = false; |
---|
9877 | | - GrafreeD.hassound = false; |
---|
| 10638 | + Grafreed.wav.save(); |
---|
| 10639 | + Grafreed.savesound = false; |
---|
| 10640 | + Grafreed.hassound = false; |
---|
9878 | 10641 | } |
---|
9879 | 10642 | // if (DEBUG_SELECTION) |
---|
9880 | 10643 | // { |
---|
.. | .. |
---|
9950 | 10713 | ANTIALIAS = 0; |
---|
9951 | 10714 | //System.out.println("RESTART"); |
---|
9952 | 10715 | AAtimer.restart(); |
---|
| 10716 | + Globals.TIMERRUNNING = true; |
---|
9953 | 10717 | } |
---|
9954 | 10718 | } |
---|
9955 | 10719 | } |
---|
.. | .. |
---|
10004 | 10768 | Object3D theobject = object; |
---|
10005 | 10769 | Object3D theparent = object.parent; |
---|
10006 | 10770 | object.parent = null; |
---|
10007 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10771 | + object = (Object3D)Grafreed.clone(object); |
---|
10008 | 10772 | object.Stripify(); |
---|
10009 | 10773 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
10010 | 10774 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
10017 | 10781 | ambientOcclusion = false; |
---|
10018 | 10782 | } |
---|
10019 | 10783 | |
---|
10020 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10784 | + if (//Globals.lighttouched && |
---|
| 10785 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10021 | 10786 | { |
---|
10022 | 10787 | //if (RENDERSHADOW) // ? |
---|
10023 | 10788 | if (!IsFrozen()) |
---|
10024 | 10789 | { |
---|
10025 | 10790 | // dec 2012 |
---|
10026 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10791 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
10027 | 10792 | { |
---|
10028 | 10793 | Globals.framecount++; |
---|
10029 | 10794 | shadowbuffer.display(); |
---|
.. | .. |
---|
10150 | 10915 | |
---|
10151 | 10916 | // if (parentcam != renderCamera) // not a light |
---|
10152 | 10917 | if (cam != lightCamera) |
---|
10153 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10154 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10918 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10919 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
10155 | 10920 | |
---|
10156 | 10921 | for (int j = 0; j < 4; j++) |
---|
10157 | 10922 | { |
---|
.. | .. |
---|
10165 | 10930 | |
---|
10166 | 10931 | // if (parentcam != renderCamera) // not a light |
---|
10167 | 10932 | if (cam != lightCamera) |
---|
10168 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10169 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10933 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10934 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
10170 | 10935 | |
---|
10171 | 10936 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10172 | 10937 | |
---|
.. | .. |
---|
10425 | 11190 | // Bump noise |
---|
10426 | 11191 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
10427 | 11192 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
10428 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11193 | + |
---|
| 11194 | + try |
---|
| 11195 | + { |
---|
| 11196 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11197 | + } |
---|
| 11198 | + catch (Exception e) |
---|
| 11199 | + { |
---|
| 11200 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11201 | + } |
---|
| 11202 | + |
---|
10429 | 11203 | |
---|
10430 | 11204 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
10431 | 11205 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10448 | 11222 | |
---|
10449 | 11223 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10450 | 11224 | |
---|
10451 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10452 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10453 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11225 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11226 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11227 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10454 | 11228 | } else |
---|
10455 | 11229 | { |
---|
10456 | 11230 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10461 | 11235 | //System.out.println("BLENDING ON"); |
---|
10462 | 11236 | gl.glEnable(GL.GL_BLEND); |
---|
10463 | 11237 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10464 | | - |
---|
| 11238 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10465 | 11239 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10466 | 11240 | gl.glLoadIdentity(); |
---|
10467 | 11241 | |
---|
.. | .. |
---|
10550 | 11324 | System.err.println("parentcam != renderCamera"); |
---|
10551 | 11325 | |
---|
10552 | 11326 | // if (cam != lightCamera) |
---|
10553 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10554 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11327 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11328 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10555 | 11329 | } |
---|
10556 | 11330 | |
---|
10557 | 11331 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10572 | 11346 | if (true) // TODO |
---|
10573 | 11347 | { |
---|
10574 | 11348 | if (cam != lightCamera) |
---|
10575 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10576 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11349 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11350 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10577 | 11351 | } |
---|
10578 | 11352 | |
---|
10579 | 11353 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
10710 | 11484 | } |
---|
10711 | 11485 | } |
---|
10712 | 11486 | |
---|
10713 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11487 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
10714 | 11488 | { |
---|
10715 | 11489 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
10716 | 11490 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
10718 | 11492 | |
---|
10719 | 11493 | boolean texon = textureon; |
---|
10720 | 11494 | |
---|
10721 | | - if (RENDERPROGRAM > 0) |
---|
10722 | | - { |
---|
10723 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
10724 | | - textureon = false; |
---|
10725 | | - } |
---|
| 11495 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11496 | + textureon = false; |
---|
| 11497 | + |
---|
10726 | 11498 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
10727 | 11499 | //System.out.println("ALLO"); |
---|
10728 | 11500 | gl.glColorMask(false, false, false, false); |
---|
10729 | 11501 | DrawObject(gl); |
---|
10730 | | - if (RENDERPROGRAM > 0) |
---|
10731 | | - { |
---|
10732 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
10733 | | - textureon = texon; |
---|
10734 | | - } |
---|
| 11502 | + |
---|
| 11503 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11504 | + textureon = texon; |
---|
| 11505 | + |
---|
10735 | 11506 | gl.glColorMask(true, true, true, true); |
---|
10736 | 11507 | |
---|
10737 | 11508 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
10738 | | - //gl.glDepthMask(false); |
---|
| 11509 | + gl.glDepthMask(false); |
---|
10739 | 11510 | } |
---|
10740 | 11511 | |
---|
10741 | 11512 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
10889 | 11660 | { |
---|
10890 | 11661 | renderpass++; |
---|
10891 | 11662 | // System.out.println("Draw object... "); |
---|
| 11663 | + STEP = 1; |
---|
10892 | 11664 | if (FAST) // in case there is no script |
---|
10893 | | - STEP = 16; |
---|
| 11665 | + STEP = 8; |
---|
| 11666 | + |
---|
| 11667 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11668 | + { |
---|
| 11669 | + STEP *= 4; |
---|
| 11670 | + } |
---|
10894 | 11671 | |
---|
10895 | 11672 | //object.FullInvariants(); |
---|
10896 | 11673 | |
---|
.. | .. |
---|
10904 | 11681 | e.printStackTrace(); |
---|
10905 | 11682 | } |
---|
10906 | 11683 | |
---|
10907 | | - if (GrafreeD.RENDERME > 0) |
---|
10908 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11684 | + if (Grafreed.RENDERME > 0) |
---|
| 11685 | + Grafreed.RENDERME--; // mechante magouille |
---|
10909 | 11686 | |
---|
10910 | 11687 | Globals.ONESTEP = false; |
---|
10911 | 11688 | } |
---|
10912 | 11689 | |
---|
10913 | 11690 | static boolean zoomonce = false; |
---|
10914 | 11691 | |
---|
| 11692 | + static void CreateSelectedPoint() |
---|
| 11693 | + { |
---|
| 11694 | + if (selectedpoint == null) |
---|
| 11695 | + { |
---|
| 11696 | + debugpointG = new Sphere(); |
---|
| 11697 | + debugpointP = new Sphere(); |
---|
| 11698 | + debugpointC = new Sphere(); |
---|
| 11699 | + debugpointR = new Sphere(); |
---|
| 11700 | + |
---|
| 11701 | + selectedpoint = new Superellipsoid(); |
---|
| 11702 | + |
---|
| 11703 | + for (int i=0; i<8; i++) |
---|
| 11704 | + { |
---|
| 11705 | + debugpoints[i] = new Sphere(); |
---|
| 11706 | + } |
---|
| 11707 | + } |
---|
| 11708 | + } |
---|
| 11709 | + |
---|
10915 | 11710 | void DrawObject(GL gl, boolean draw) |
---|
10916 | 11711 | { |
---|
| 11712 | + // To clear camera values |
---|
| 11713 | + ResetOptions(); |
---|
| 11714 | + |
---|
10917 | 11715 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
10918 | 11716 | // DrawMode() = SELECTION; |
---|
10919 | 11717 | //GL gl = getGL(); |
---|
10920 | 11718 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
10921 | 11719 | { |
---|
10922 | 11720 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
10923 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11721 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
10924 | 11722 | pingthread.StepToTarget(true); // true); |
---|
10925 | 11723 | // zoomonce = false; |
---|
10926 | 11724 | } |
---|
.. | .. |
---|
10975 | 11773 | |
---|
10976 | 11774 | usedtextures.clear(); |
---|
10977 | 11775 | |
---|
10978 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11776 | + try |
---|
| 11777 | + { |
---|
| 11778 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11779 | + } |
---|
| 11780 | + catch (Exception e) |
---|
| 11781 | + { |
---|
| 11782 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11783 | + } |
---|
10979 | 11784 | } |
---|
10980 | 11785 | //System.out.println("--> " + stackdepth); |
---|
10981 | 11786 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
10985 | 11790 | |
---|
10986 | 11791 | if (DrawMode() == DEFAULT) |
---|
10987 | 11792 | { |
---|
10988 | | - if (DEBUG) |
---|
| 11793 | + if (Globals.DEBUG) |
---|
10989 | 11794 | { |
---|
| 11795 | + CreateSelectedPoint(); |
---|
10990 | 11796 | float radius = 0.05f; |
---|
10991 | 11797 | if (selectedpoint.radius != radius) |
---|
10992 | 11798 | { |
---|
.. | .. |
---|
11040 | 11846 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11041 | 11847 | |
---|
11042 | 11848 | if (CLEANCACHE) |
---|
11043 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11849 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11044 | 11850 | { |
---|
11045 | | - String tex = e.nextElement(); |
---|
| 11851 | + cTexture tex = e.nextElement(); |
---|
11046 | 11852 | |
---|
11047 | 11853 | // System.out.println("Texture --------- " + tex); |
---|
11048 | 11854 | |
---|
11049 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11855 | + if (tex.equals("WHITE_NOISE:")) |
---|
11050 | 11856 | continue; |
---|
11051 | 11857 | |
---|
11052 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11858 | + if (!usedtextures.contains(tex)) |
---|
11053 | 11859 | { |
---|
| 11860 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11054 | 11861 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11055 | | - textures.get(tex).texture.dispose(); |
---|
11056 | | - textures.remove(tex); |
---|
| 11862 | + if (gettex != null) |
---|
| 11863 | + { |
---|
| 11864 | + gettex.texture.dispose(); |
---|
| 11865 | + texturepigment.remove(tex); |
---|
| 11866 | + } |
---|
| 11867 | + |
---|
| 11868 | + gettex = texturebump.get(tex); |
---|
| 11869 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11870 | + if (gettex != null) |
---|
| 11871 | + { |
---|
| 11872 | + gettex.texture.dispose(); |
---|
| 11873 | + texturebump.remove(tex); |
---|
| 11874 | + } |
---|
11057 | 11875 | } |
---|
11058 | 11876 | } |
---|
11059 | 11877 | } |
---|
.. | .. |
---|
11066 | 11884 | if (checker != null && DrawMode() == DEFAULT) |
---|
11067 | 11885 | { |
---|
11068 | 11886 | //BindTexture(IMMORTAL_TEXTURE); |
---|
11069 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11887 | + try |
---|
| 11888 | + { |
---|
| 11889 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11890 | + } |
---|
| 11891 | + catch (Exception e) |
---|
| 11892 | + { |
---|
| 11893 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11894 | + } |
---|
11070 | 11895 | // NEAREST |
---|
11071 | 11896 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
11072 | 11897 | DrawChecker(gl); |
---|
.. | .. |
---|
11148 | 11973 | return; |
---|
11149 | 11974 | } |
---|
11150 | 11975 | |
---|
11151 | | - String string = obj.GetToolTip(); |
---|
| 11976 | + String string = obj.toString(); //.GetToolTip(); |
---|
11152 | 11977 | |
---|
11153 | 11978 | GL gl = GetGL(); |
---|
11154 | 11979 | |
---|
.. | .. |
---|
11465 | 12290 | //obj.TransformToWorld(light, light); |
---|
11466 | 12291 | for (int i = tp.size(); --i >= 0;) |
---|
11467 | 12292 | { |
---|
11468 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11469 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12293 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12294 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
11470 | 12295 | } |
---|
11471 | 12296 | |
---|
11472 | 12297 | |
---|
.. | .. |
---|
11483 | 12308 | parentcam = cameras[0]; |
---|
11484 | 12309 | } |
---|
11485 | 12310 | |
---|
11486 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11487 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12311 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12312 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11488 | 12313 | |
---|
11489 | 12314 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11490 | 12315 | |
---|
.. | .. |
---|
11575 | 12400 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
11576 | 12401 | |
---|
11577 | 12402 | String program = |
---|
| 12403 | + // Min shader |
---|
11578 | 12404 | "!!ARBfp1.0\n" + |
---|
| 12405 | + "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" + |
---|
| 12406 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12407 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12408 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12409 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12410 | + "TEMP temp;" + |
---|
| 12411 | + "TEMP light;" + |
---|
| 12412 | + "TEMP ndotl;" + |
---|
| 12413 | + "TEMP normal;" + |
---|
| 12414 | + "TEMP depth;" + |
---|
| 12415 | + |
---|
| 12416 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12417 | + |
---|
| 12418 | + "MOV light, state.light[0].position;" + |
---|
| 12419 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12420 | + |
---|
| 12421 | + // shadow |
---|
| 12422 | + "MOV temp, fragment.texcoord[1];" + |
---|
| 12423 | + TextureFetch("depth", "temp", "1") + |
---|
| 12424 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12425 | + "SLT temp.x, fragment.texcoord[1].z, depth.z;" + |
---|
| 12426 | + |
---|
| 12427 | + |
---|
| 12428 | + // No shadow when out of frustum |
---|
| 12429 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12430 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12431 | + |
---|
| 12432 | + "MUL ndotl.x, ndotl.x, temp.x;" + |
---|
| 12433 | + "MAX ndotl.x, ndotl.x, pow2.y;" + |
---|
| 12434 | + |
---|
| 12435 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12436 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12437 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12438 | + |
---|
| 12439 | + "MUL temp, temp, zero123.z;" + |
---|
| 12440 | + |
---|
| 12441 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12442 | + |
---|
| 12443 | + "MOV result.color, temp;" + |
---|
| 12444 | + "END"; |
---|
| 12445 | + |
---|
| 12446 | + String program2 = |
---|
| 12447 | + "!!ARBfp1.0\n" + |
---|
| 12448 | + |
---|
11579 | 12449 | //"OPTION ARB_fragment_program_shadow;" + |
---|
11580 | 12450 | "PARAM light2cam0 = program.env[10];" + |
---|
11581 | 12451 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
11690 | 12560 | "TEMP shininess;" + |
---|
11691 | 12561 | "\n" + |
---|
11692 | 12562 | "MOV texSamp, one;" + |
---|
11693 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
11694 | | - |
---|
| 12563 | + |
---|
11695 | 12564 | "MOV mapgrid.x, one2048th.x;" + |
---|
11696 | 12565 | "MOV temp, fragment.texcoord[1];" + |
---|
11697 | 12566 | /* |
---|
.. | .. |
---|
12096 | 12965 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12097 | 12966 | "") + |
---|
12098 | 12967 | |
---|
12099 | | - // display shadow only (bump == 0) |
---|
| 12968 | + // display shadow only (fakedepth == 0) |
---|
12100 | 12969 | "SUB temp.x, half.x, shadow.x;" + |
---|
12101 | | - "MOV temp.y, -params6.x;" + |
---|
12102 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12970 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12971 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
12103 | 12972 | "SUB temp.y, one.x, temp.z;" + |
---|
12104 | 12973 | "MUL temp.x, temp.x, temp.y;" + |
---|
12105 | 12974 | "KIL temp.x;" + |
---|
.. | .. |
---|
12228 | 13097 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
12229 | 13098 | |
---|
12230 | 13099 | "SUB temp.x, one.x, ndotl.x;" + |
---|
12231 | | - "ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
12232 | | - "ADD temp.y, one.y, options2.y;" + // sursurface |
---|
| 13100 | + // Tuning for default skin |
---|
| 13101 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 13102 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 13103 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
12233 | 13104 | "MUL temp.x, temp.x, temp.y;" + |
---|
12234 | 13105 | |
---|
12235 | 13106 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
12428 | 13299 | //once = true; |
---|
12429 | 13300 | } |
---|
12430 | 13301 | |
---|
12431 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 13302 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
12432 | 13303 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
12433 | 13304 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12434 | 13305 | |
---|
.. | .. |
---|
12526 | 13397 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
12527 | 13398 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
12528 | 13399 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13400 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13401 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
12529 | 13402 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12530 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
12531 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12532 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
12533 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13403 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13404 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
12534 | 13405 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
12535 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13406 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
12536 | 13407 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
12537 | 13408 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
12538 | 13409 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
12539 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13410 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12540 | 13411 | |
---|
12541 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
12542 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13412 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13413 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12543 | 13414 | } |
---|
12544 | 13415 | |
---|
12545 | 13416 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
12561 | 13432 | |
---|
12562 | 13433 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12563 | 13434 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13435 | + |
---|
| 13436 | + // Compare fragment depth in light space with shadowmap. |
---|
12564 | 13437 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12565 | 13438 | "SGE temp.y, temp.x, zero.x;" + |
---|
12566 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13439 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13440 | + |
---|
| 13441 | + // Reverse comparison |
---|
12567 | 13442 | "SUB temp.x, one.x, temp.x;" + |
---|
12568 | 13443 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12569 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13444 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12570 | 13445 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12571 | 13446 | |
---|
12572 | 13447 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12580 | 13455 | // No shadow for backface |
---|
12581 | 13456 | "DP3 temp.x, normal, lightd;" + |
---|
12582 | 13457 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13458 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13459 | + |
---|
| 13460 | + // No shadow when out of frustum |
---|
| 13461 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12583 | 13462 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12584 | 13463 | ""; |
---|
12585 | 13464 | } |
---|
.. | .. |
---|
12726 | 13605 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
12727 | 13606 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
12728 | 13607 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
12729 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13608 | + |
---|
| 13609 | + //Object3D.cVector2[] vector2buffer; |
---|
12730 | 13610 | |
---|
12731 | 13611 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
12732 | 13612 | // OUT : diff, spec |
---|
.. | .. |
---|
12742 | 13622 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
12743 | 13623 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
12744 | 13624 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
12745 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
12746 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
12747 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13625 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13626 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13627 | + |
---|
| 13628 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
12748 | 13629 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
12749 | 13630 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
12750 | 13631 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13138 | 14019 | public void mousePressed(MouseEvent e) |
---|
13139 | 14020 | { |
---|
13140 | 14021 | //System.out.println("mousePressed: " + e); |
---|
13141 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14022 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13142 | 14023 | } |
---|
13143 | 14024 | |
---|
13144 | 14025 | static long prevtime = 0; |
---|
.. | .. |
---|
13165 | 14046 | |
---|
13166 | 14047 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
13167 | 14048 | |
---|
| 14049 | + if (BUTTONLESSWHEEL) |
---|
13168 | 14050 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
13169 | 14051 | { |
---|
13170 | 14052 | return; |
---|
.. | .. |
---|
13173 | 14055 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
13174 | 14056 | |
---|
13175 | 14057 | // TIMER |
---|
13176 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 14058 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
13177 | 14059 | { |
---|
13178 | 14060 | keepboxmode = BOXMODE; |
---|
13179 | 14061 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
13213 | 14095 | // mode |= META; |
---|
13214 | 14096 | //} |
---|
13215 | 14097 | |
---|
13216 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
13217 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 14098 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 14099 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
13218 | 14100 | anchorX = ax; |
---|
13219 | 14101 | anchorY = ay; |
---|
13220 | 14102 | prevX = px; |
---|
.. | .. |
---|
13248 | 14130 | else |
---|
13249 | 14131 | if (evt.getSource() == AAtimer) |
---|
13250 | 14132 | { |
---|
| 14133 | + Globals.TIMERRUNNING = false; |
---|
13251 | 14134 | if (mouseDown) |
---|
13252 | 14135 | { |
---|
13253 | 14136 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13273 | 14156 | // LIVE = waslive; |
---|
13274 | 14157 | // wasliveok = true; |
---|
13275 | 14158 | // waslive = false; |
---|
| 14159 | + |
---|
| 14160 | + // May 2019 Forget it: |
---|
| 14161 | + if (true) |
---|
| 14162 | + return; |
---|
13276 | 14163 | |
---|
13277 | 14164 | // source == timer |
---|
13278 | 14165 | if (mouseDown) |
---|
.. | .. |
---|
13303 | 14190 | |
---|
13304 | 14191 | // fev 2014??? |
---|
13305 | 14192 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13306 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14193 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13307 | 14194 | pingthread.StepToTarget(true); // true); |
---|
13308 | 14195 | } |
---|
13309 | 14196 | // if (!LIVE) |
---|
.. | .. |
---|
13312 | 14199 | |
---|
13313 | 14200 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
13314 | 14201 | |
---|
13315 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14202 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
13316 | 14203 | { |
---|
13317 | 14204 | if (!wasliveok) |
---|
13318 | 14205 | return; |
---|
13319 | 14206 | |
---|
13320 | 14207 | AAtimer.restart(); // |
---|
| 14208 | + Globals.TIMERRUNNING = true; |
---|
13321 | 14209 | |
---|
13322 | 14210 | // waslive = LIVE; |
---|
13323 | 14211 | // LIVE = false; |
---|
.. | .. |
---|
13329 | 14217 | // touched = true; // main DL |
---|
13330 | 14218 | if (isRenderer) |
---|
13331 | 14219 | { |
---|
13332 | | - SetMouseMode(modifiers); |
---|
| 14220 | + SetMouseMode(modifiers, modifiersex); |
---|
13333 | 14221 | } |
---|
13334 | 14222 | |
---|
13335 | 14223 | selectX = anchorX = x; |
---|
.. | .. |
---|
13342 | 14230 | clicked = true; |
---|
13343 | 14231 | hold = false; |
---|
13344 | 14232 | |
---|
13345 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14233 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
13346 | 14234 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
13347 | 14235 | { |
---|
13348 | 14236 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
13367 | 14255 | drag = false; |
---|
13368 | 14256 | //System.out.println("Mouse DOWN"); |
---|
13369 | 14257 | editObj = false; |
---|
13370 | | - ClickInfo info = new ClickInfo(); |
---|
13371 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13372 | | - info.pane = this; |
---|
13373 | | - info.camera = renderCamera; |
---|
13374 | | - info.x = x; |
---|
13375 | | - info.y = y; |
---|
13376 | | - info.modifiers = modifiers; |
---|
13377 | | - editObj = object.doEditClick(info, 0); |
---|
| 14258 | + //ClickInfo info = new ClickInfo(); |
---|
| 14259 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14260 | + object.clickInfo.pane = this; |
---|
| 14261 | + object.clickInfo.camera = renderCamera; |
---|
| 14262 | + object.clickInfo.x = x; |
---|
| 14263 | + object.clickInfo.y = y; |
---|
| 14264 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14265 | + editObj = object.doEditClick(//info, |
---|
| 14266 | + 0); |
---|
13378 | 14267 | if (!editObj) |
---|
13379 | 14268 | { |
---|
13380 | 14269 | hasMarquee = true; |
---|
.. | .. |
---|
13390 | 14279 | |
---|
13391 | 14280 | public void mouseDragged(MouseEvent e) |
---|
13392 | 14281 | { |
---|
| 14282 | + Globals.MOUSEDRAGGED = true; |
---|
| 14283 | + |
---|
| 14284 | + //System.out.println("mouseDragged: " + e); |
---|
13393 | 14285 | if (isRenderer) |
---|
13394 | 14286 | movingcamera = true; |
---|
| 14287 | + |
---|
13395 | 14288 | //if (drawing) |
---|
13396 | 14289 | //return; |
---|
13397 | | - //System.out.println("mouseDragged: " + e); |
---|
13398 | 14290 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
13399 | 14291 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
13400 | 14292 | { |
---|
.. | .. |
---|
13402 | 14294 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13403 | 14295 | } |
---|
13404 | 14296 | else |
---|
13405 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14297 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13406 | 14298 | |
---|
13407 | 14299 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
13408 | 14300 | } |
---|
.. | .. |
---|
13575 | 14467 | |
---|
13576 | 14468 | public void run() |
---|
13577 | 14469 | { |
---|
| 14470 | + new Exception().printStackTrace(); |
---|
13578 | 14471 | System.exit(0); |
---|
13579 | 14472 | for (;;) |
---|
13580 | 14473 | { |
---|
.. | .. |
---|
13638 | 14531 | { |
---|
13639 | 14532 | Globals.lighttouched = true; |
---|
13640 | 14533 | } |
---|
13641 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14534 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
13642 | 14535 | } |
---|
13643 | 14536 | //else |
---|
13644 | 14537 | } |
---|
.. | .. |
---|
13652 | 14545 | void GoDown(int mod) |
---|
13653 | 14546 | { |
---|
13654 | 14547 | MODIFIERS |= COMMAND; |
---|
13655 | | - /* |
---|
| 14548 | + /**/ |
---|
13656 | 14549 | if((mod&SHIFT) == SHIFT) |
---|
13657 | 14550 | manipCamera.RotatePosition(0, -speed); |
---|
13658 | 14551 | else |
---|
13659 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
13660 | | - */ |
---|
| 14552 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14553 | + /**/ |
---|
13661 | 14554 | if ((mod & SHIFT) == SHIFT) |
---|
13662 | 14555 | { |
---|
13663 | 14556 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
13673 | 14566 | void GoUp(int mod) |
---|
13674 | 14567 | { |
---|
13675 | 14568 | MODIFIERS |= COMMAND; |
---|
13676 | | - /* |
---|
| 14569 | + /**/ |
---|
13677 | 14570 | if((mod&SHIFT) == SHIFT) |
---|
13678 | 14571 | manipCamera.RotatePosition(0, speed); |
---|
13679 | 14572 | else |
---|
13680 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
13681 | | - */ |
---|
| 14573 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14574 | + /**/ |
---|
13682 | 14575 | if ((mod & SHIFT) == SHIFT) |
---|
13683 | 14576 | { |
---|
13684 | 14577 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13694 | 14587 | void GoLeft(int mod) |
---|
13695 | 14588 | { |
---|
13696 | 14589 | MODIFIERS |= COMMAND; |
---|
13697 | | - /* |
---|
| 14590 | + /**/ |
---|
13698 | 14591 | if((mod&SHIFT) == SHIFT) |
---|
13699 | | - manipCamera.RotatePosition(speed, 0); |
---|
13700 | | - else |
---|
13701 | 14592 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
13702 | | - */ |
---|
| 14593 | + else |
---|
| 14594 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14595 | + /**/ |
---|
13703 | 14596 | if ((mod & SHIFT) == SHIFT) |
---|
13704 | 14597 | { |
---|
13705 | 14598 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13715 | 14608 | void GoRight(int mod) |
---|
13716 | 14609 | { |
---|
13717 | 14610 | MODIFIERS |= COMMAND; |
---|
13718 | | - /* |
---|
| 14611 | + /**/ |
---|
13719 | 14612 | if((mod&SHIFT) == SHIFT) |
---|
13720 | | - manipCamera.RotatePosition(-speed, 0); |
---|
13721 | | - else |
---|
13722 | 14613 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
13723 | | - */ |
---|
| 14614 | + else |
---|
| 14615 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14616 | + /**/ |
---|
13724 | 14617 | if ((mod & SHIFT) == SHIFT) |
---|
13725 | 14618 | { |
---|
13726 | 14619 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13738 | 14631 | int X, Y; |
---|
13739 | 14632 | boolean SX, SY; |
---|
13740 | 14633 | |
---|
13741 | | - void drag(int x, int y, int modifiers) |
---|
| 14634 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
13742 | 14635 | { |
---|
13743 | 14636 | if (IsFrozen()) |
---|
13744 | 14637 | { |
---|
.. | .. |
---|
13747 | 14640 | |
---|
13748 | 14641 | drag = true; // NEW |
---|
13749 | 14642 | |
---|
13750 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14643 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
13751 | 14644 | |
---|
13752 | 14645 | X = x; |
---|
13753 | 14646 | Y = y; |
---|
13754 | 14647 | // floating state for animation |
---|
13755 | | - MODIFIERS = modifiers; |
---|
13756 | | - modifiers &= ~1024; |
---|
| 14648 | + MODIFIERS = modifiersex; |
---|
| 14649 | + modifiersex &= ~1024; |
---|
13757 | 14650 | if (false) // modifiers != 0) |
---|
13758 | 14651 | { |
---|
13759 | 14652 | //new Exception().printStackTrace(); |
---|
13760 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14653 | + System.out.println("mouseDragged: " + modifiersex); |
---|
13761 | 14654 | System.out.println("SHIFT = " + SHIFT); |
---|
13762 | 14655 | System.out.println("CONTROL = " + COMMAND); |
---|
13763 | 14656 | System.out.println("META = " + META); |
---|
.. | .. |
---|
13770 | 14663 | if (editObj) |
---|
13771 | 14664 | { |
---|
13772 | 14665 | drag = true; |
---|
13773 | | - ClickInfo info = new ClickInfo(); |
---|
13774 | | - info.bounds.setBounds(0, 0, |
---|
| 14666 | + //ClickInfo info = new ClickInfo(); |
---|
| 14667 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
13775 | 14668 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13776 | | - info.pane = this; |
---|
13777 | | - info.camera = renderCamera; |
---|
13778 | | - info.x = x; |
---|
13779 | | - info.y = y; |
---|
13780 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14669 | + object.clickInfo.pane = this; |
---|
| 14670 | + object.clickInfo.camera = renderCamera; |
---|
| 14671 | + object.clickInfo.x = x; |
---|
| 14672 | + object.clickInfo.y = y; |
---|
| 14673 | + object //.GetWindow().copy |
---|
| 14674 | + .doEditDrag(//info, |
---|
| 14675 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
13781 | 14676 | } else |
---|
13782 | 14677 | { |
---|
13783 | 14678 | if (x < startX) |
---|
.. | .. |
---|
13926 | 14821 | } |
---|
13927 | 14822 | } |
---|
13928 | 14823 | |
---|
| 14824 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14825 | + |
---|
13929 | 14826 | public void mouseMoved(MouseEvent e) |
---|
13930 | 14827 | { |
---|
13931 | 14828 | //System.out.println("mouseMoved: " + e); |
---|
13932 | | - |
---|
13933 | 14829 | if (isRenderer) |
---|
13934 | 14830 | return; |
---|
13935 | 14831 | |
---|
13936 | | - ClickInfo ci = new ClickInfo(); |
---|
13937 | | - ci.x = e.getX(); |
---|
13938 | | - ci.y = e.getY(); |
---|
13939 | | - ci.modifiers = e.getModifiersEx(); |
---|
13940 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13941 | | - ci.pane = this; |
---|
13942 | | - ci.camera = renderCamera; |
---|
| 14832 | + // Mouse cursor feedback |
---|
| 14833 | + object.clickInfo.x = e.getX(); |
---|
| 14834 | + object.clickInfo.y = e.getY(); |
---|
| 14835 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14836 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14837 | + object.clickInfo.pane = this; |
---|
| 14838 | + object.clickInfo.camera = renderCamera; |
---|
13943 | 14839 | if (!isRenderer) |
---|
13944 | 14840 | { |
---|
13945 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14841 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14842 | + //Object3D copy = editWindow.copy; |
---|
| 14843 | + if (object.doEditClick(//clickInfo, |
---|
| 14844 | + 0)) |
---|
13946 | 14845 | { |
---|
13947 | 14846 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
13948 | 14847 | } else |
---|
.. | .. |
---|
13954 | 14853 | |
---|
13955 | 14854 | public void mouseReleased(MouseEvent e) |
---|
13956 | 14855 | { |
---|
| 14856 | + Globals.MOUSEDRAGGED = false; |
---|
| 14857 | + |
---|
13957 | 14858 | movingcamera = false; |
---|
| 14859 | + X = 0; // getBounds().width/2; |
---|
| 14860 | + Y = 0; // getBounds().height/2; |
---|
13958 | 14861 | //System.out.println("mouseReleased: " + e); |
---|
13959 | 14862 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13960 | 14863 | } |
---|
.. | .. |
---|
13977 | 14880 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
13978 | 14881 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
13979 | 14882 | |
---|
13980 | | - if (control || command || IsFrozen()) |
---|
| 14883 | +// No delay if (control || command || IsFrozen()) |
---|
13981 | 14884 | timeout = true; |
---|
13982 | | - else |
---|
| 14885 | +// ?? May 2019 else |
---|
13983 | 14886 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
13984 | 14887 | mouseDown = false; |
---|
13985 | 14888 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
14089 | 14992 | System.out.println("keyReleased: " + e); |
---|
14090 | 14993 | } |
---|
14091 | 14994 | |
---|
14092 | | - void SetMouseMode(int modifiers) |
---|
| 14995 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
14093 | 14996 | { |
---|
14094 | 14997 | //System.out.println("SetMouseMode = " + modifiers); |
---|
14095 | 14998 | //modifiers &= ~1024; |
---|
.. | .. |
---|
14101 | 15004 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
14102 | 15005 | // return; |
---|
14103 | 15006 | //System.out.println("SetMode = " + modifiers); |
---|
14104 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 15007 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
14105 | 15008 | { |
---|
14106 | 15009 | mouseMode |= ZOOM; |
---|
14107 | 15010 | } |
---|
14108 | 15011 | |
---|
14109 | 15012 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
14110 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 15013 | + if (capsLocked) // || (modifiers & META) == META) |
---|
14111 | 15014 | { |
---|
14112 | 15015 | mouseMode |= VR; // BACKFORTH; |
---|
14113 | 15016 | } |
---|
14114 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
| 15017 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
14115 | 15018 | { |
---|
14116 | 15019 | mouseMode |= SELECT; |
---|
14117 | 15020 | } |
---|
14118 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 15021 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
14119 | 15022 | { |
---|
14120 | 15023 | mouseMode |= SELECT; |
---|
14121 | 15024 | } |
---|
14122 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 15025 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
14123 | 15026 | { |
---|
14124 | 15027 | mouseMode &= ~VR; |
---|
14125 | 15028 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
14148 | 15051 | |
---|
14149 | 15052 | if (isRenderer) // |
---|
14150 | 15053 | { |
---|
14151 | | - SetMouseMode(modifiers); |
---|
| 15054 | + SetMouseMode(0, modifiers); |
---|
14152 | 15055 | } |
---|
14153 | 15056 | |
---|
14154 | 15057 | Globals.theRenderer.keyPressed(key); |
---|
.. | .. |
---|
14210 | 15113 | // break; |
---|
14211 | 15114 | case 'T': |
---|
14212 | 15115 | CACHETEXTURE ^= true; |
---|
14213 | | - textures.clear(); |
---|
| 15116 | + texturepigment.clear(); |
---|
| 15117 | + texturebump.clear(); |
---|
14214 | 15118 | // repaint(); |
---|
14215 | 15119 | break; |
---|
14216 | 15120 | case 'Y': |
---|
.. | .. |
---|
14295 | 15199 | case 'E' : COMPACT ^= true; |
---|
14296 | 15200 | repaint(); |
---|
14297 | 15201 | break; |
---|
14298 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15202 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15203 | + //DEBUGHSB ^= true; |
---|
| 15204 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14299 | 15205 | repaint(); |
---|
14300 | 15206 | break; |
---|
14301 | 15207 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14320 | 15226 | RevertCamera(); |
---|
14321 | 15227 | repaint(); |
---|
14322 | 15228 | break; |
---|
14323 | | - case 'L': |
---|
14324 | 15229 | case 'l': |
---|
| 15230 | + //case 'L': |
---|
14325 | 15231 | if (lightMode) |
---|
14326 | 15232 | { |
---|
14327 | 15233 | lightMode = false; |
---|
.. | .. |
---|
14464 | 15370 | case '_': |
---|
14465 | 15371 | kompactbit = 5; |
---|
14466 | 15372 | break; |
---|
14467 | | - case '+': |
---|
14468 | | - kompactbit = 6; |
---|
14469 | | - break; |
---|
| 15373 | +// case '+': |
---|
| 15374 | +// kompactbit = 6; |
---|
| 15375 | +// break; |
---|
14470 | 15376 | case ' ': |
---|
14471 | 15377 | lightMode ^= true; |
---|
14472 | 15378 | Globals.lighttouched = true; |
---|
.. | .. |
---|
14478 | 15384 | case ESC: |
---|
14479 | 15385 | RENDERPROGRAM += 1; |
---|
14480 | 15386 | RENDERPROGRAM %= 3; |
---|
| 15387 | + |
---|
14481 | 15388 | repaint(); |
---|
14482 | 15389 | break; |
---|
14483 | 15390 | case 'Z': |
---|
14484 | 15391 | //RESIZETEXTURE ^= true; |
---|
14485 | 15392 | //break; |
---|
14486 | 15393 | case 'z': |
---|
14487 | | - RENDERSHADOW ^= true; |
---|
| 15394 | + Globals.RENDERSHADOW ^= true; |
---|
14488 | 15395 | Globals.lighttouched = true; |
---|
14489 | 15396 | repaint(); |
---|
14490 | 15397 | break; |
---|
.. | .. |
---|
14517 | 15424 | case DELETE: |
---|
14518 | 15425 | ClearSelection(); |
---|
14519 | 15426 | break; |
---|
14520 | | - /* |
---|
14521 | 15427 | case '+': |
---|
| 15428 | + |
---|
| 15429 | + /* |
---|
14522 | 15430 | //fontsize += 1; |
---|
14523 | 15431 | bbzoom *= 2; |
---|
14524 | 15432 | repaint(); |
---|
.. | .. |
---|
14535 | 15443 | case '=': |
---|
14536 | 15444 | IncDepth(); |
---|
14537 | 15445 | //fontsize += 1; |
---|
14538 | | - object.editWindow.refreshContents(true); |
---|
| 15446 | + object.GetWindow().refreshContents(true); |
---|
14539 | 15447 | maskbit = 6; |
---|
14540 | 15448 | break; |
---|
14541 | 15449 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14542 | 15450 | DecDepth(); |
---|
14543 | 15451 | maskbit = 5; |
---|
14544 | 15452 | //if(fontsize > 1) fontsize -= 1; |
---|
14545 | | - if (object.editWindow == null) |
---|
14546 | | - new Exception().printStackTrace(); |
---|
14547 | | - else |
---|
14548 | | - object.editWindow.refreshContents(true); |
---|
| 15453 | +// if (object.editWindow == null) |
---|
| 15454 | +// new Exception().printStackTrace(); |
---|
| 15455 | +// else |
---|
| 15456 | + object.GetWindow().refreshContents(true); |
---|
14549 | 15457 | break; |
---|
14550 | 15458 | case '{': |
---|
14551 | 15459 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
14608 | 15516 | //mode = ROTATE; |
---|
14609 | 15517 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
14610 | 15518 | { |
---|
14611 | | - SetMouseMode(modifiers); |
---|
| 15519 | + SetMouseMode(0, modifiers); |
---|
14612 | 15520 | } |
---|
14613 | 15521 | } |
---|
14614 | 15522 | |
---|
.. | .. |
---|
14742 | 15650 | |
---|
14743 | 15651 | protected void processMouseMotionEvent(MouseEvent e) |
---|
14744 | 15652 | { |
---|
14745 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
14746 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15653 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15654 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15655 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
14747 | 15656 | { |
---|
14748 | 15657 | mouseMoved(e); |
---|
14749 | 15658 | } else |
---|
.. | .. |
---|
14768 | 15677 | } |
---|
14769 | 15678 | */ |
---|
14770 | 15679 | |
---|
14771 | | - object.editWindow.EditSelection(); |
---|
| 15680 | + object.GetWindow().EditSelection(false); |
---|
14772 | 15681 | } |
---|
14773 | 15682 | |
---|
14774 | 15683 | void SelectParent() |
---|
14775 | 15684 | { |
---|
| 15685 | + new Exception().printStackTrace(); |
---|
14776 | 15686 | System.exit(0); |
---|
14777 | 15687 | Composite group = (Composite) object; |
---|
14778 | 15688 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
14784 | 15694 | { |
---|
14785 | 15695 | //selectees.remove(i); |
---|
14786 | 15696 | System.out.println("select parent of " + elem); |
---|
14787 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15697 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
14788 | 15698 | } else |
---|
14789 | 15699 | { |
---|
14790 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15700 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14791 | 15701 | } |
---|
14792 | 15702 | |
---|
14793 | 15703 | first = false; |
---|
.. | .. |
---|
14796 | 15706 | |
---|
14797 | 15707 | void SelectChildren() |
---|
14798 | 15708 | { |
---|
| 15709 | + new Exception().printStackTrace(); |
---|
14799 | 15710 | System.exit(0); |
---|
14800 | 15711 | /* |
---|
14801 | 15712 | Composite group = (Composite) object; |
---|
.. | .. |
---|
14828 | 15739 | for (int j = 0; j < group.children.size(); j++) |
---|
14829 | 15740 | { |
---|
14830 | 15741 | elem = (Object3D) group.children.elementAt(j); |
---|
14831 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15742 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14832 | 15743 | first = false; |
---|
14833 | 15744 | } |
---|
14834 | 15745 | } else |
---|
14835 | 15746 | { |
---|
14836 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15747 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14837 | 15748 | } |
---|
14838 | 15749 | |
---|
14839 | 15750 | first = false; |
---|
.. | .. |
---|
14844 | 15755 | { |
---|
14845 | 15756 | //Composite group = (Composite) object; |
---|
14846 | 15757 | Object3D group = object; |
---|
14847 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15758 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
14848 | 15759 | } |
---|
14849 | 15760 | |
---|
14850 | 15761 | void ResetTransform(int mask) |
---|
14851 | 15762 | { |
---|
14852 | 15763 | //Composite group = (Composite) object; |
---|
14853 | 15764 | Object3D group = object; |
---|
14854 | | - group.editWindow.ResetTransform(mask); |
---|
| 15765 | + group.GetWindow().ResetTransform(mask); |
---|
14855 | 15766 | } |
---|
14856 | 15767 | |
---|
14857 | 15768 | void FlipTransform() |
---|
14858 | 15769 | { |
---|
14859 | 15770 | //Composite group = (Composite) object; |
---|
14860 | 15771 | Object3D group = object; |
---|
14861 | | - group.editWindow.FlipTransform(); |
---|
| 15772 | + group.GetWindow().FlipTransform(); |
---|
14862 | 15773 | // group.editWindow.ReduceMesh(true); |
---|
14863 | 15774 | } |
---|
14864 | 15775 | |
---|
.. | .. |
---|
14866 | 15777 | { |
---|
14867 | 15778 | //Composite group = (Composite) object; |
---|
14868 | 15779 | Object3D group = object; |
---|
14869 | | - group.editWindow.PrintMemory(); |
---|
| 15780 | + group.GetWindow().PrintMemory(); |
---|
14870 | 15781 | // group.editWindow.ReduceMesh(true); |
---|
14871 | 15782 | } |
---|
14872 | 15783 | |
---|
.. | .. |
---|
14874 | 15785 | { |
---|
14875 | 15786 | //Composite group = (Composite) object; |
---|
14876 | 15787 | Object3D group = object; |
---|
14877 | | - group.editWindow.ResetCentroid(); |
---|
| 15788 | + group.GetWindow().ResetCentroid(); |
---|
14878 | 15789 | } |
---|
14879 | 15790 | |
---|
14880 | 15791 | void IncDepth() |
---|
.. | .. |
---|
14956 | 15867 | |
---|
14957 | 15868 | int width = getBounds().width; |
---|
14958 | 15869 | int height = getBounds().height; |
---|
14959 | | - ClickInfo info = new ClickInfo(); |
---|
14960 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
14961 | 15870 | //Image img = CreateImage(width, height); |
---|
14962 | 15871 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15872 | + |
---|
14963 | 15873 | Graphics gr = g; // img.getGraphics(); |
---|
| 15874 | + |
---|
14964 | 15875 | if (!hasMarquee) |
---|
14965 | 15876 | { |
---|
14966 | 15877 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
15032 | 15943 | } |
---|
15033 | 15944 | if (object != null && !hasMarquee) |
---|
15034 | 15945 | { |
---|
| 15946 | + if (object.clickInfo == null) |
---|
| 15947 | + object.clickInfo = new ClickInfo(); |
---|
| 15948 | + ClickInfo info = object.clickInfo; |
---|
| 15949 | + //ClickInfo info = new ClickInfo(); |
---|
| 15950 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 15951 | + |
---|
15035 | 15952 | if (isRenderer) |
---|
15036 | 15953 | { |
---|
15037 | | - info.flags++; |
---|
| 15954 | + object.clickInfo.flags++; |
---|
15038 | 15955 | double frameAspect = (double) width / (double) height; |
---|
15039 | 15956 | if (frameAspect > renderCamera.aspect) |
---|
15040 | 15957 | { |
---|
15041 | 15958 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15042 | | - info.bounds.width -= width - desired; |
---|
15043 | | - info.bounds.x += (width - desired) / 2; |
---|
| 15959 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 15960 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15044 | 15961 | } else |
---|
15045 | 15962 | { |
---|
15046 | 15963 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15047 | | - info.bounds.height -= height - desired; |
---|
15048 | | - info.bounds.y += (height - desired) / 2; |
---|
| 15964 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 15965 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15049 | 15966 | } |
---|
15050 | 15967 | } |
---|
15051 | | - info.g = gr; |
---|
15052 | | - info.camera = renderCamera; |
---|
| 15968 | + |
---|
| 15969 | + object.clickInfo.g = gr; |
---|
| 15970 | + object.clickInfo.camera = renderCamera; |
---|
15053 | 15971 | /* |
---|
15054 | 15972 | // Memory intensive (brep.verticescopy) |
---|
15055 | 15973 | if (!(object instanceof Composite)) |
---|
15056 | 15974 | object.draw(info, 0, false); // SLOW : |
---|
15057 | 15975 | */ |
---|
15058 | | - if (!isRenderer) |
---|
| 15976 | + if (!isRenderer) // && drag) |
---|
15059 | 15977 | { |
---|
15060 | | - object.drawEditHandles(info, 0); |
---|
| 15978 | + Grafreed.Assert(object != null); |
---|
| 15979 | + Grafreed.Assert(object.selection != null); |
---|
| 15980 | + if (object.selection.Size() > 0) |
---|
| 15981 | + { |
---|
| 15982 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 15983 | + |
---|
| 15984 | + object.clickInfo.DX = 0; |
---|
| 15985 | + object.clickInfo.DY = 0; |
---|
| 15986 | + object.clickInfo.W = 1; |
---|
| 15987 | + if (hitSomething == Object3D.hitCenter) |
---|
| 15988 | + { |
---|
| 15989 | + info.DX = X; |
---|
| 15990 | + if (X != 0) |
---|
| 15991 | + info.DX -= info.bounds.width/2; |
---|
| 15992 | + |
---|
| 15993 | + info.DY = Y; |
---|
| 15994 | + if (Y != 0) |
---|
| 15995 | + info.DY -= info.bounds.height/2; |
---|
| 15996 | + } |
---|
| 15997 | + |
---|
| 15998 | + object.drawEditHandles(//info, |
---|
| 15999 | + 0); |
---|
| 16000 | + |
---|
| 16001 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16002 | + { |
---|
| 16003 | + switch (hitSomething) |
---|
| 16004 | + { |
---|
| 16005 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16006 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16007 | + break; |
---|
| 16008 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16009 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16010 | + break; |
---|
| 16011 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16012 | + gr.drawLine(X, Y, 0, 0); |
---|
| 16013 | + break; |
---|
| 16014 | + } |
---|
| 16015 | + |
---|
| 16016 | + } |
---|
| 16017 | + } |
---|
15061 | 16018 | } |
---|
15062 | 16019 | } |
---|
| 16020 | + |
---|
15063 | 16021 | if (isRenderer) |
---|
15064 | 16022 | { |
---|
15065 | 16023 | //gr.setColor(Color.black); |
---|
15066 | 16024 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
15067 | 16025 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
15068 | 16026 | } |
---|
| 16027 | + |
---|
15069 | 16028 | if (hasMarquee) |
---|
15070 | 16029 | { |
---|
15071 | 16030 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
15178 | 16137 | public boolean mouseDown(Event evt, int x, int y) |
---|
15179 | 16138 | { |
---|
15180 | 16139 | System.out.println("mouseDown: " + evt); |
---|
| 16140 | + System.exit(0); |
---|
15181 | 16141 | /* |
---|
15182 | 16142 | locked = true; |
---|
15183 | 16143 | drag = false; |
---|
.. | .. |
---|
15221 | 16181 | { |
---|
15222 | 16182 | keyPressed(0, modifiers); |
---|
15223 | 16183 | } |
---|
15224 | | - clickStart(x, y, modifiers); |
---|
| 16184 | + // clickStart(x, y, modifiers); |
---|
15225 | 16185 | return true; |
---|
15226 | 16186 | } |
---|
15227 | 16187 | |
---|
.. | .. |
---|
15339 | 16299 | { |
---|
15340 | 16300 | keyReleased(0, 0); |
---|
15341 | 16301 | } |
---|
15342 | | - drag(x, y, modifiers); |
---|
| 16302 | + drag(x, y, 0, modifiers); |
---|
15343 | 16303 | return true; |
---|
15344 | 16304 | } |
---|
15345 | 16305 | |
---|
.. | .. |
---|
15471 | 16431 | Object3D object; |
---|
15472 | 16432 | static Object3D trackedobject; |
---|
15473 | 16433 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15474 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16434 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15475 | 16435 | /*static*/ Camera eyeCamera; |
---|
15476 | 16436 | /*static*/ Camera lightCamera; |
---|
15477 | 16437 | int cameracount; |
---|
.. | .. |
---|
15756 | 16716 | cStatic.objectstack[materialdepth++] = checker; |
---|
15757 | 16717 | //System.out.println("material " + material); |
---|
15758 | 16718 | //Applet3D.tracein(this, selected); |
---|
15759 | | - vector2buffer = checker.projectedVertices; |
---|
| 16719 | + //vector2buffer = checker.projectedVertices; |
---|
15760 | 16720 | |
---|
15761 | 16721 | //checker.GetMaterial().Draw(this, false); // true); |
---|
15762 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16722 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
15763 | 16723 | |
---|
15764 | 16724 | materialdepth -= 1; |
---|
15765 | 16725 | if (materialdepth > 0) |
---|
15766 | 16726 | { |
---|
15767 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
15768 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16727 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16728 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
15769 | 16729 | } |
---|
15770 | 16730 | //checker.GetMaterial().opacity = 1f; |
---|
15771 | 16731 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
15851 | 16811 | } |
---|
15852 | 16812 | } |
---|
15853 | 16813 | |
---|
| 16814 | + private Object3D GetFolder() |
---|
| 16815 | + { |
---|
| 16816 | + Object3D folder = object.GetWindow().copy; |
---|
| 16817 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16818 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16819 | + return folder; |
---|
| 16820 | + } |
---|
| 16821 | + |
---|
15854 | 16822 | class SelectBuffer implements GLEventListener |
---|
15855 | 16823 | { |
---|
15856 | 16824 | |
---|
.. | .. |
---|
15909 | 16877 | { |
---|
15910 | 16878 | if (!selection) |
---|
15911 | 16879 | { |
---|
| 16880 | + new Exception().printStackTrace(); |
---|
15912 | 16881 | System.exit(0); |
---|
15913 | 16882 | return; |
---|
15914 | 16883 | } |
---|
.. | .. |
---|
15929 | 16898 | |
---|
15930 | 16899 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
15931 | 16900 | |
---|
| 16901 | + if (PAINTMODE) |
---|
| 16902 | + { |
---|
| 16903 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16904 | + { |
---|
| 16905 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16906 | + |
---|
| 16907 | + // Make what you paint not selectable. |
---|
| 16908 | + paintobj.ResetSelectable(); |
---|
| 16909 | + } |
---|
| 16910 | + } |
---|
| 16911 | + |
---|
15932 | 16912 | //int tmp = selection_view; |
---|
15933 | 16913 | //selection_view = -1; |
---|
15934 | 16914 | int temp = DrawMode(); |
---|
.. | .. |
---|
15940 | 16920 | // temp = DEFAULT; // patch for selection debug |
---|
15941 | 16921 | Globals.drawMode = temp; // WARNING |
---|
15942 | 16922 | |
---|
| 16923 | + if (PAINTMODE) |
---|
| 16924 | + { |
---|
| 16925 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16926 | + { |
---|
| 16927 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16928 | + |
---|
| 16929 | + // Revert. |
---|
| 16930 | + paintobj.RestoreSelectable(); |
---|
| 16931 | + } |
---|
| 16932 | + } |
---|
| 16933 | + |
---|
15943 | 16934 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
15944 | 16935 | |
---|
15945 | 16936 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
15987 | 16978 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
15988 | 16979 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
15989 | 16980 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 16981 | + |
---|
| 16982 | + CreateSelectedPoint(); |
---|
15990 | 16983 | |
---|
15991 | 16984 | // Will fit the mesh !!! |
---|
15992 | 16985 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
16036 | 17029 | 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])); |
---|
16037 | 17030 | } |
---|
16038 | 17031 | |
---|
16039 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 17032 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
16040 | 17033 | } |
---|
16041 | 17034 | } |
---|
16042 | 17035 | |
---|
16043 | 17036 | if (!movingcamera && !PAINTMODE) |
---|
16044 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17037 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16045 | 17038 | |
---|
16046 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17039 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16047 | 17040 | { |
---|
16048 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17041 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16049 | 17042 | |
---|
16050 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17043 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17044 | + { |
---|
| 17045 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16051 | 17046 | |
---|
16052 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16053 | | - |
---|
16054 | | - group.add(paintobj); // link |
---|
16055 | | - |
---|
16056 | | - object.editWindow.SnapObject(group); |
---|
16057 | | - |
---|
16058 | | - Object3D folder = object.editWindow.copy; |
---|
16059 | | - |
---|
16060 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16061 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16062 | | - |
---|
16063 | | - folder.add(group); |
---|
16064 | | - |
---|
16065 | | - object.editWindow.ResetModel(); |
---|
16066 | | - object.editWindow.refreshContents(); |
---|
| 17047 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17048 | + |
---|
| 17049 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17050 | + |
---|
| 17051 | + inst.add(paintobj); // link |
---|
| 17052 | + |
---|
| 17053 | + object.GetWindow().SnapObject(inst); |
---|
| 17054 | + |
---|
| 17055 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17056 | + |
---|
| 17057 | + folder.add(inst); |
---|
| 17058 | + |
---|
| 17059 | + object.GetWindow().ResetModel(); |
---|
| 17060 | + object.GetWindow().refreshContents(); |
---|
| 17061 | + } |
---|
16067 | 17062 | } |
---|
16068 | 17063 | else |
---|
16069 | 17064 | paintcount = 0; |
---|
.. | .. |
---|
16102 | 17097 | //System.out.println("objects[color] = " + objects[color]); |
---|
16103 | 17098 | //objects[color].Select(); |
---|
16104 | 17099 | indexcount = 0; |
---|
| 17100 | + ObjEditor window = object.GetWindow(); |
---|
| 17101 | + if (window != null && deselect) |
---|
| 17102 | + { |
---|
| 17103 | + window.Select(null, deselect, true); |
---|
| 17104 | + } |
---|
16105 | 17105 | object.Select(color, deselect); |
---|
16106 | 17106 | } |
---|
16107 | 17107 | |
---|
.. | .. |
---|
16201 | 17201 | gl.glDisable(gl.GL_CULL_FACE); |
---|
16202 | 17202 | } |
---|
16203 | 17203 | |
---|
16204 | | - if (!RENDERSHADOW) |
---|
| 17204 | + if (!Globals.RENDERSHADOW) |
---|
16205 | 17205 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16206 | 17206 | |
---|
16207 | 17207 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
16211 | 17211 | //gl.glColorMask(false, false, false, false); |
---|
16212 | 17212 | |
---|
16213 | 17213 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
16214 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17214 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
16215 | 17215 | { |
---|
16216 | 17216 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16217 | 17217 | |
---|
.. | .. |
---|
16627 | 17627 | int AAbuffersize = 0; |
---|
16628 | 17628 | |
---|
16629 | 17629 | //double[] selectedpoint = new double[3]; |
---|
16630 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17630 | + static Superellipsoid selectedpoint; |
---|
16631 | 17631 | static Sphere previousselectedpoint = null; |
---|
16632 | | - static Sphere debugpointG = new Sphere(); |
---|
16633 | | - static Sphere debugpointP = new Sphere(); |
---|
16634 | | - static Sphere debugpointC = new Sphere(); |
---|
16635 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17632 | + static Sphere debugpointG; |
---|
| 17633 | + static Sphere debugpointP; |
---|
| 17634 | + static Sphere debugpointC; |
---|
| 17635 | + static Sphere debugpointR; |
---|
16636 | 17636 | |
---|
16637 | 17637 | static Sphere debugpoints[] = new Sphere[8]; |
---|
16638 | 17638 | |
---|
16639 | | - static |
---|
16640 | | - { |
---|
16641 | | - for (int i=0; i<8; i++) |
---|
16642 | | - { |
---|
16643 | | - debugpoints[i] = new Sphere(); |
---|
16644 | | - } |
---|
16645 | | - } |
---|
16646 | | - |
---|
16647 | 17639 | static void InitPoints(float radius) |
---|
16648 | 17640 | { |
---|
16649 | 17641 | for (int i=0; i<8; i++) |
---|
.. | .. |
---|
16695 | 17687 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
16696 | 17688 | // Depth buffer format |
---|
16697 | 17689 | //private int depth_format; |
---|
16698 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17690 | + |
---|
| 17691 | + public void NextIndex() |
---|
16699 | 17692 | { |
---|
16700 | 17693 | indexcount+=16; |
---|
16701 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17694 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
16702 | 17695 | //objects[indexcount] = o; |
---|
16703 | 17696 | //System.out.println("indexcount = " + indexcount); |
---|
16704 | 17697 | } |
---|