.. | .. |
---|
37 | 37 | static boolean[] selectedstack = new boolean[65536]; |
---|
38 | 38 | static int materialdepth = 0; |
---|
39 | 39 | |
---|
40 | | - static boolean DEBUG = false; |
---|
41 | 40 | static boolean FRUSTUM = false; // still bogus true; // frustum culling |
---|
42 | 41 | |
---|
43 | 42 | // camera change fix |
---|
.. | .. |
---|
149 | 148 | defaultcaps.setAccumBlueBits(16); |
---|
150 | 149 | defaultcaps.setAccumAlphaBits(16); |
---|
151 | 150 | } |
---|
| 151 | + |
---|
| 152 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
152 | 153 | |
---|
153 | 154 | void SetAsGLRenderer(boolean b) |
---|
154 | 155 | { |
---|
.. | .. |
---|
325 | 326 | cStatic.objectstack[materialdepth++] = obj; |
---|
326 | 327 | //System.out.println("material " + material); |
---|
327 | 328 | //Applet3D.tracein(this, selected); |
---|
328 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 329 | + //display.vector2buffer = obj.projectedVertices; |
---|
329 | 330 | if (obj instanceof Camera) |
---|
330 | 331 | { |
---|
331 | 332 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
334 | 335 | display.options1[2] = material.shadowbias; |
---|
335 | 336 | display.options1[3] = material.aniso; |
---|
336 | 337 | display.options1[4] = material.anisoV; |
---|
| 338 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 339 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 340 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 341 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 342 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
337 | 343 | display.options2[0] = material.opacity; |
---|
338 | 344 | display.options2[1] = material.diffuse; |
---|
339 | 345 | display.options2[2] = material.factor; |
---|
| 346 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 347 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 348 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
340 | 349 | |
---|
341 | 350 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 351 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 352 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 353 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
342 | 354 | display.options4[0] = material.cameralight/0.2f; |
---|
343 | 355 | display.options4[1] = material.subsurface; |
---|
344 | 356 | display.options4[2] = material.sheen; |
---|
| 357 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 358 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 359 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
345 | 360 | |
---|
346 | 361 | // if (display.CURRENTANTIALIAS > 0) |
---|
347 | 362 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
357 | 372 | /**/ |
---|
358 | 373 | } else |
---|
359 | 374 | { |
---|
360 | | - DrawMaterial(material, selected); |
---|
| 375 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
361 | 376 | } |
---|
362 | 377 | } else |
---|
363 | 378 | { |
---|
.. | .. |
---|
381 | 396 | cStatic.objectstack[materialdepth++] = obj; |
---|
382 | 397 | //System.out.println("material " + material); |
---|
383 | 398 | //Applet3D.tracein("selected ", selected); |
---|
384 | | - display.vector2buffer = obj.projectedVertices; |
---|
385 | | - display.DrawMaterial(material, selected); |
---|
| 399 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 400 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
386 | 401 | } |
---|
387 | 402 | } |
---|
388 | 403 | |
---|
.. | .. |
---|
399 | 414 | materialdepth -= 1; |
---|
400 | 415 | if (materialdepth > 0) |
---|
401 | 416 | { |
---|
402 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
403 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 417 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 418 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
404 | 419 | } |
---|
405 | 420 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
406 | 421 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
420 | 435 | materialdepth -= 1; |
---|
421 | 436 | if (materialdepth > 0) |
---|
422 | 437 | { |
---|
423 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
424 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 438 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 439 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
425 | 440 | } |
---|
426 | 441 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
427 | 442 | //else |
---|
.. | .. |
---|
462 | 477 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
463 | 478 | { |
---|
464 | 479 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
465 | | - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 480 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 481 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 482 | + ; |
---|
466 | 483 | if (!hasnorm) |
---|
467 | 484 | { |
---|
468 | | - // System.out.println("FUCK!!"); |
---|
| 485 | + // System.out.println("Mesh normal"); |
---|
469 | 486 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
470 | 487 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
471 | 488 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
1190 | 1207 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1191 | 1208 | } |
---|
1192 | 1209 | } |
---|
| 1210 | + |
---|
1193 | 1211 | if (flipV) |
---|
1194 | 1212 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1195 | 1213 | else |
---|
1196 | 1214 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1215 | + |
---|
1197 | 1216 | //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1198 | 1217 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1199 | 1218 | |
---|
.. | .. |
---|
1213 | 1232 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1214 | 1233 | } |
---|
1215 | 1234 | } |
---|
| 1235 | + |
---|
1216 | 1236 | if (flipV) |
---|
1217 | 1237 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1218 | 1238 | else |
---|
1219 | 1239 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1240 | + |
---|
1220 | 1241 | //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1221 | 1242 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1222 | 1243 | |
---|
.. | .. |
---|
1244 | 1265 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1245 | 1266 | else |
---|
1246 | 1267 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1268 | + |
---|
1247 | 1269 | //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
1248 | 1270 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1271 | + |
---|
1249 | 1272 | count2 += 2; |
---|
1250 | 1273 | count3 += 3; |
---|
1251 | 1274 | } |
---|
.. | .. |
---|
1601 | 1624 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
1602 | 1625 | } |
---|
1603 | 1626 | |
---|
1604 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1627 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
1605 | 1628 | { |
---|
1606 | 1629 | CameraPane display = this; |
---|
1607 | 1630 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1636 | 1659 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
1637 | 1660 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
1638 | 1661 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
1639 | | - colorV[3] = material.opacity; |
---|
| 1662 | + colorV[3] = 1; // material.opacity; |
---|
1640 | 1663 | |
---|
1641 | 1664 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
1642 | 1665 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1744 | 1767 | display.modelParams7[2] = 0; |
---|
1745 | 1768 | display.modelParams7[3] = 0; |
---|
1746 | 1769 | |
---|
1747 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1770 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1748 | 1771 | |
---|
1749 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1772 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1750 | 1773 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1751 | 1774 | { |
---|
1752 | 1775 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1888 | 1911 | void PushMatrix(double[][] matrix) |
---|
1889 | 1912 | { |
---|
1890 | 1913 | // GrafreeD.tracein(matrix); |
---|
1891 | | - PushMatrix(matrix,1); |
---|
| 1914 | + PushMatrix(matrix, 1); |
---|
1892 | 1915 | } |
---|
1893 | 1916 | |
---|
1894 | 1917 | void PushMatrix() |
---|
.. | .. |
---|
2257 | 2280 | |
---|
2258 | 2281 | void ToggleDebug() |
---|
2259 | 2282 | { |
---|
2260 | | - DEBUG ^= true; |
---|
| 2283 | + Globals.DEBUG ^= true; |
---|
2261 | 2284 | } |
---|
2262 | 2285 | |
---|
2263 | 2286 | void ToggleLookAt() |
---|
.. | .. |
---|
2374 | 2397 | { |
---|
2375 | 2398 | return currentGL; |
---|
2376 | 2399 | } |
---|
2377 | | - |
---|
| 2400 | + |
---|
2378 | 2401 | /**/ |
---|
2379 | 2402 | class CacheTexture |
---|
2380 | 2403 | { |
---|
.. | .. |
---|
7919 | 7942 | ReleaseTexture(pigment, false); |
---|
7920 | 7943 | } |
---|
7921 | 7944 | |
---|
| 7945 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 7946 | + { |
---|
| 7947 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 7948 | + { |
---|
| 7949 | + return; |
---|
| 7950 | + } |
---|
| 7951 | + |
---|
| 7952 | + if (tex == null) |
---|
| 7953 | + { |
---|
| 7954 | + ReleaseTexture(null, false); |
---|
| 7955 | + return; |
---|
| 7956 | + } |
---|
| 7957 | + |
---|
| 7958 | + String pigment = Object3D.GetPigment(tex); |
---|
| 7959 | + |
---|
| 7960 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 7961 | + { |
---|
| 7962 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 7963 | + // System.out.println("; bump = " + bump); |
---|
| 7964 | + } |
---|
| 7965 | + |
---|
| 7966 | + if (pigment.equals("")) |
---|
| 7967 | + { |
---|
| 7968 | + pigment = null; |
---|
| 7969 | + } |
---|
| 7970 | + |
---|
| 7971 | + ReleaseTexture(pigment, false); |
---|
| 7972 | + } |
---|
| 7973 | + |
---|
| 7974 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 7975 | + { |
---|
| 7976 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 7977 | + { |
---|
| 7978 | + return; |
---|
| 7979 | + } |
---|
| 7980 | + |
---|
| 7981 | + if (tex == null) |
---|
| 7982 | + { |
---|
| 7983 | + ReleaseTexture(null, true); |
---|
| 7984 | + return; |
---|
| 7985 | + } |
---|
| 7986 | + |
---|
| 7987 | + String bump = Object3D.GetBump(tex); |
---|
| 7988 | + |
---|
| 7989 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 7990 | + { |
---|
| 7991 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 7992 | + // System.out.println("; bump = " + bump); |
---|
| 7993 | + } |
---|
| 7994 | + |
---|
| 7995 | + if (bump.equals("")) |
---|
| 7996 | + { |
---|
| 7997 | + bump = null; |
---|
| 7998 | + } |
---|
| 7999 | + |
---|
| 8000 | + ReleaseTexture(bump, true); |
---|
| 8001 | + } |
---|
| 8002 | + |
---|
7922 | 8003 | void ReleaseTexture(String tex, boolean bump) |
---|
7923 | 8004 | { |
---|
7924 | 8005 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
.. | .. |
---|
8067 | 8148 | return; // true; |
---|
8068 | 8149 | } |
---|
8069 | 8150 | |
---|
| 8151 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8152 | + { |
---|
| 8153 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8154 | + ambientOcclusion ) // || !textureon) |
---|
| 8155 | + { |
---|
| 8156 | + return; // false; |
---|
| 8157 | + } |
---|
| 8158 | + |
---|
| 8159 | + if (tex == null) |
---|
| 8160 | + { |
---|
| 8161 | + BindTexture(null,false,resolution); |
---|
| 8162 | + return; |
---|
| 8163 | + } |
---|
| 8164 | + |
---|
| 8165 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8166 | + |
---|
| 8167 | + usedtextures.put(pigment, pigment); |
---|
| 8168 | + |
---|
| 8169 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8170 | + { |
---|
| 8171 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8172 | + // System.out.println("; bump = " + bump); |
---|
| 8173 | + } |
---|
| 8174 | + |
---|
| 8175 | + if (pigment.equals("")) |
---|
| 8176 | + { |
---|
| 8177 | + pigment = null; |
---|
| 8178 | + } |
---|
| 8179 | + |
---|
| 8180 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8181 | + BindTexture(pigment, false, resolution); |
---|
| 8182 | + } |
---|
| 8183 | + |
---|
| 8184 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8185 | + { |
---|
| 8186 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8187 | + ambientOcclusion ) // || !textureon) |
---|
| 8188 | + { |
---|
| 8189 | + return; // false; |
---|
| 8190 | + } |
---|
| 8191 | + |
---|
| 8192 | + if (tex == null) |
---|
| 8193 | + { |
---|
| 8194 | + BindTexture(null,true,resolution); |
---|
| 8195 | + return; |
---|
| 8196 | + } |
---|
| 8197 | + |
---|
| 8198 | + String bump = Object3D.GetBump(tex); |
---|
| 8199 | + |
---|
| 8200 | + usedtextures.put(bump, bump); |
---|
| 8201 | + |
---|
| 8202 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8203 | + { |
---|
| 8204 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8205 | + // System.out.println("; bump = " + bump); |
---|
| 8206 | + } |
---|
| 8207 | + |
---|
| 8208 | + if (bump.equals("")) |
---|
| 8209 | + { |
---|
| 8210 | + bump = null; |
---|
| 8211 | + } |
---|
| 8212 | + |
---|
| 8213 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8214 | + BindTexture(bump, true, resolution); |
---|
| 8215 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8216 | + } |
---|
| 8217 | + |
---|
| 8218 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8219 | + |
---|
| 8220 | + private boolean FileExists(String tex) |
---|
| 8221 | + { |
---|
| 8222 | + if (missingTextures.contains(tex)) |
---|
| 8223 | + { |
---|
| 8224 | + return false; |
---|
| 8225 | + } |
---|
| 8226 | + |
---|
| 8227 | + boolean fileExists = new File(tex).exists(); |
---|
| 8228 | + |
---|
| 8229 | + if (!fileExists) |
---|
| 8230 | + { |
---|
| 8231 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8232 | + missingTextures.add(tex); |
---|
| 8233 | + } |
---|
| 8234 | + |
---|
| 8235 | + return fileExists; |
---|
| 8236 | + } |
---|
| 8237 | + |
---|
8070 | 8238 | CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
8071 | 8239 | { |
---|
8072 | 8240 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
.. | .. |
---|
8075 | 8243 | { |
---|
8076 | 8244 | String texname = tex; |
---|
8077 | 8245 | |
---|
| 8246 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8247 | + |
---|
8078 | 8248 | // String[] split = tex.split("Textures"); |
---|
8079 | 8249 | // if (split.length > 1) |
---|
8080 | 8250 | // texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
8081 | 8251 | // else |
---|
8082 | 8252 | // if (!texname.startsWith("/")) |
---|
8083 | 8253 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8084 | | - if (!new File(tex).exists()) |
---|
| 8254 | + if (!FileExists(tex)) |
---|
8085 | 8255 | { |
---|
8086 | | - texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname; |
---|
| 8256 | + texname = fallbackTextureName; |
---|
8087 | 8257 | } |
---|
8088 | 8258 | |
---|
8089 | 8259 | if (CACHETEXTURE) |
---|
.. | .. |
---|
8153 | 8323 | } |
---|
8154 | 8324 | |
---|
8155 | 8325 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
8156 | | - if (!new File(cachename).exists()) |
---|
| 8326 | + if (!FileExists(cachename)) |
---|
8157 | 8327 | cachename = texname; |
---|
8158 | 8328 | else |
---|
8159 | 8329 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8175 | 8345 | } |
---|
8176 | 8346 | |
---|
8177 | 8347 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
8178 | | - if (!new File(cachename).exists()) |
---|
| 8348 | + if (!FileExists(cachename)) |
---|
8179 | 8349 | cachename = texname; |
---|
8180 | 8350 | else |
---|
8181 | 8351 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
9210 | 9380 | jy8[3] = 0.5f; |
---|
9211 | 9381 | } |
---|
9212 | 9382 | |
---|
9213 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9383 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9214 | 9384 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9215 | 9385 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9216 | 9386 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9217 | 9387 | |
---|
| 9388 | + void ResetOptions() |
---|
| 9389 | + { |
---|
| 9390 | + options1[0] = 100; |
---|
| 9391 | + options1[1] = 0.025f; |
---|
| 9392 | + options1[2] = 0.01f; |
---|
| 9393 | + options1[3] = 0; |
---|
| 9394 | + options1[4] = 0; |
---|
| 9395 | + |
---|
| 9396 | + options2[0] = 0; |
---|
| 9397 | + options2[1] = 0.75f; |
---|
| 9398 | + options2[2] = 0; |
---|
| 9399 | + options2[3] = 0; |
---|
| 9400 | + |
---|
| 9401 | + options3[0] = 1; |
---|
| 9402 | + options3[1] = 1; |
---|
| 9403 | + options3[2] = 1; |
---|
| 9404 | + options3[3] = 0; |
---|
| 9405 | + |
---|
| 9406 | + options4[0] = 1; |
---|
| 9407 | + options4[1] = 0; |
---|
| 9408 | + options4[2] = 1; |
---|
| 9409 | + options4[3] = 0; |
---|
| 9410 | + } |
---|
| 9411 | + |
---|
9218 | 9412 | static int imagecount = 0; // movie generation |
---|
9219 | 9413 | |
---|
9220 | 9414 | static int jitter = 0; |
---|
.. | .. |
---|
9310 | 9504 | assert (parentcam != renderCamera); |
---|
9311 | 9505 | |
---|
9312 | 9506 | if (renderCamera != lightCamera) |
---|
9313 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9314 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9507 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9508 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
9315 | 9509 | |
---|
9316 | 9510 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9317 | 9511 | |
---|
.. | .. |
---|
9326 | 9520 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
9327 | 9521 | |
---|
9328 | 9522 | if (renderCamera != lightCamera) |
---|
9329 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9330 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9523 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9524 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
9331 | 9525 | |
---|
9332 | 9526 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9333 | 9527 | |
---|
.. | .. |
---|
10325 | 10519 | ANTIALIAS = 0; |
---|
10326 | 10520 | //System.out.println("RESTART"); |
---|
10327 | 10521 | AAtimer.restart(); |
---|
| 10522 | + Globals.TIMERRUNNING = true; |
---|
10328 | 10523 | } |
---|
10329 | 10524 | } |
---|
10330 | 10525 | } |
---|
.. | .. |
---|
10392 | 10587 | ambientOcclusion = false; |
---|
10393 | 10588 | } |
---|
10394 | 10589 | |
---|
10395 | | - if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
| 10590 | + if (//Globals.lighttouched && |
---|
| 10591 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10396 | 10592 | { |
---|
10397 | 10593 | //if (RENDERSHADOW) // ? |
---|
10398 | 10594 | if (!IsFrozen()) |
---|
.. | .. |
---|
10525 | 10721 | |
---|
10526 | 10722 | // if (parentcam != renderCamera) // not a light |
---|
10527 | 10723 | if (cam != lightCamera) |
---|
10528 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10529 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10724 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10725 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
10530 | 10726 | |
---|
10531 | 10727 | for (int j = 0; j < 4; j++) |
---|
10532 | 10728 | { |
---|
.. | .. |
---|
10540 | 10736 | |
---|
10541 | 10737 | // if (parentcam != renderCamera) // not a light |
---|
10542 | 10738 | if (cam != lightCamera) |
---|
10543 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10544 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10739 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10740 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
10545 | 10741 | |
---|
10546 | 10742 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10547 | 10743 | |
---|
.. | .. |
---|
10934 | 11130 | System.err.println("parentcam != renderCamera"); |
---|
10935 | 11131 | |
---|
10936 | 11132 | // if (cam != lightCamera) |
---|
10937 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10938 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11133 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11134 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10939 | 11135 | } |
---|
10940 | 11136 | |
---|
10941 | 11137 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10956 | 11152 | if (true) // TODO |
---|
10957 | 11153 | { |
---|
10958 | 11154 | if (cam != lightCamera) |
---|
10959 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10960 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11155 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11156 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10961 | 11157 | } |
---|
10962 | 11158 | |
---|
10963 | 11159 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11302 | 11498 | |
---|
11303 | 11499 | static boolean zoomonce = false; |
---|
11304 | 11500 | |
---|
| 11501 | + static void CreateSelectedPoint() |
---|
| 11502 | + { |
---|
| 11503 | + if (selectedpoint == null) |
---|
| 11504 | + { |
---|
| 11505 | + debugpointG = new Sphere(); |
---|
| 11506 | + debugpointP = new Sphere(); |
---|
| 11507 | + debugpointC = new Sphere(); |
---|
| 11508 | + debugpointR = new Sphere(); |
---|
| 11509 | + |
---|
| 11510 | + selectedpoint = new Superellipsoid(); |
---|
| 11511 | + |
---|
| 11512 | + for (int i=0; i<8; i++) |
---|
| 11513 | + { |
---|
| 11514 | + debugpoints[i] = new Sphere(); |
---|
| 11515 | + } |
---|
| 11516 | + } |
---|
| 11517 | + } |
---|
| 11518 | + |
---|
11305 | 11519 | void DrawObject(GL gl, boolean draw) |
---|
11306 | 11520 | { |
---|
| 11521 | + // To clear camera values |
---|
| 11522 | + ResetOptions(); |
---|
| 11523 | + |
---|
11307 | 11524 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11308 | 11525 | // DrawMode() = SELECTION; |
---|
11309 | 11526 | //GL gl = getGL(); |
---|
.. | .. |
---|
11382 | 11599 | |
---|
11383 | 11600 | if (DrawMode() == DEFAULT) |
---|
11384 | 11601 | { |
---|
11385 | | - if (DEBUG) |
---|
| 11602 | + if (Globals.DEBUG) |
---|
11386 | 11603 | { |
---|
| 11604 | + CreateSelectedPoint(); |
---|
11387 | 11605 | float radius = 0.05f; |
---|
11388 | 11606 | if (selectedpoint.radius != radius) |
---|
11389 | 11607 | { |
---|
.. | .. |
---|
11869 | 12087 | //obj.TransformToWorld(light, light); |
---|
11870 | 12088 | for (int i = tp.size(); --i >= 0;) |
---|
11871 | 12089 | { |
---|
11872 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11873 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12090 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12091 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
11874 | 12092 | } |
---|
11875 | 12093 | |
---|
11876 | 12094 | |
---|
.. | .. |
---|
11887 | 12105 | parentcam = cameras[0]; |
---|
11888 | 12106 | } |
---|
11889 | 12107 | |
---|
11890 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11891 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12108 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12109 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11892 | 12110 | |
---|
11893 | 12111 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11894 | 12112 | |
---|
.. | .. |
---|
13140 | 13358 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13141 | 13359 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13142 | 13360 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
13143 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13361 | + |
---|
| 13362 | + //Object3D.cVector2[] vector2buffer; |
---|
13144 | 13363 | |
---|
13145 | 13364 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
13146 | 13365 | // OUT : diff, spec |
---|
.. | .. |
---|
13663 | 13882 | else |
---|
13664 | 13883 | if (evt.getSource() == AAtimer) |
---|
13665 | 13884 | { |
---|
| 13885 | + Globals.TIMERRUNNING = false; |
---|
13666 | 13886 | if (mouseDown) |
---|
13667 | 13887 | { |
---|
13668 | 13888 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13737 | 13957 | return; |
---|
13738 | 13958 | |
---|
13739 | 13959 | AAtimer.restart(); // |
---|
| 13960 | + Globals.TIMERRUNNING = true; |
---|
13740 | 13961 | |
---|
13741 | 13962 | // waslive = LIVE; |
---|
13742 | 13963 | // LIVE = false; |
---|
.. | .. |
---|
13809 | 14030 | |
---|
13810 | 14031 | public void mouseDragged(MouseEvent e) |
---|
13811 | 14032 | { |
---|
| 14033 | + Globals.MOUSEDRAGGED = true; |
---|
| 14034 | + |
---|
13812 | 14035 | //System.out.println("mouseDragged: " + e); |
---|
13813 | 14036 | if (isRenderer) |
---|
13814 | 14037 | movingcamera = true; |
---|
| 14038 | + |
---|
13815 | 14039 | //if (drawing) |
---|
13816 | 14040 | //return; |
---|
13817 | 14041 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
.. | .. |
---|
14197 | 14421 | info.camera = renderCamera; |
---|
14198 | 14422 | info.x = x; |
---|
14199 | 14423 | info.y = y; |
---|
14200 | | - object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14424 | + object.GetWindow().copy |
---|
| 14425 | + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14201 | 14426 | } else |
---|
14202 | 14427 | { |
---|
14203 | 14428 | if (x < startX) |
---|
.. | .. |
---|
14361 | 14586 | ci.camera = renderCamera; |
---|
14362 | 14587 | if (!isRenderer) |
---|
14363 | 14588 | { |
---|
14364 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14589 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14590 | + //Object3D copy = editWindow.copy; |
---|
| 14591 | + if (object.doEditClick(ci, 0)) |
---|
14365 | 14592 | { |
---|
14366 | 14593 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14367 | 14594 | } else |
---|
.. | .. |
---|
14373 | 14600 | |
---|
14374 | 14601 | public void mouseReleased(MouseEvent e) |
---|
14375 | 14602 | { |
---|
| 14603 | + Globals.MOUSEDRAGGED = false; |
---|
| 14604 | + |
---|
14376 | 14605 | movingcamera = false; |
---|
14377 | 14606 | X = Y = 0; |
---|
14378 | 14607 | //System.out.println("mouseReleased: " + e); |
---|
.. | .. |
---|
14740 | 14969 | RevertCamera(); |
---|
14741 | 14970 | repaint(); |
---|
14742 | 14971 | break; |
---|
14743 | | - case 'L': |
---|
14744 | 14972 | case 'l': |
---|
| 14973 | + lightMode ^= true; |
---|
| 14974 | + Globals.lighttouched = true; |
---|
| 14975 | + manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
| 14976 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14977 | + repaint(); |
---|
| 14978 | + break; |
---|
| 14979 | + case 'L': |
---|
14745 | 14980 | if (lightMode) |
---|
14746 | 14981 | { |
---|
14747 | 14982 | lightMode = false; |
---|
.. | .. |
---|
14888 | 15123 | kompactbit = 6; |
---|
14889 | 15124 | break; |
---|
14890 | 15125 | case ' ': |
---|
14891 | | - lightMode ^= true; |
---|
14892 | | - Globals.lighttouched = true; |
---|
14893 | | - manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
14894 | | - targetLookAt.set(manipCamera.lookAt); |
---|
| 15126 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14895 | 15127 | repaint(); |
---|
14896 | 15128 | break; |
---|
14897 | 15129 | //case '`' : |
---|
14898 | 15130 | case ESC: |
---|
14899 | 15131 | RENDERPROGRAM += 1; |
---|
14900 | 15132 | RENDERPROGRAM %= 3; |
---|
| 15133 | + |
---|
14901 | 15134 | repaint(); |
---|
14902 | 15135 | break; |
---|
14903 | 15136 | case 'Z': |
---|
.. | .. |
---|
15189 | 15422 | } |
---|
15190 | 15423 | */ |
---|
15191 | 15424 | |
---|
15192 | | - object.editWindow.EditSelection(); |
---|
| 15425 | + object.editWindow.EditSelection(false); |
---|
15193 | 15426 | } |
---|
15194 | 15427 | |
---|
15195 | 15428 | void SelectParent() |
---|
.. | .. |
---|
15488 | 15721 | { |
---|
15489 | 15722 | switch (object.selection.get(0).hitSomething) |
---|
15490 | 15723 | { |
---|
15491 | | - case Object3D.hitCenter: gr.setColor(Color.pink); break; |
---|
15492 | | - case Object3D.hitRotate: gr.setColor(Color.green); break; |
---|
15493 | | - case Object3D.hitScale: gr.setColor(Color.cyan); break; |
---|
| 15724 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15725 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15726 | + break; |
---|
| 15727 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15728 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15729 | + break; |
---|
| 15730 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 15731 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15732 | + break; |
---|
15494 | 15733 | } |
---|
15495 | 15734 | |
---|
15496 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15497 | 15735 | } |
---|
15498 | 15736 | } |
---|
15499 | 15737 | } |
---|
.. | .. |
---|
15911 | 16149 | Object3D object; |
---|
15912 | 16150 | static Object3D trackedobject; |
---|
15913 | 16151 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15914 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16152 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15915 | 16153 | /*static*/ Camera eyeCamera; |
---|
15916 | 16154 | /*static*/ Camera lightCamera; |
---|
15917 | 16155 | int cameracount; |
---|
.. | .. |
---|
16196 | 16434 | cStatic.objectstack[materialdepth++] = checker; |
---|
16197 | 16435 | //System.out.println("material " + material); |
---|
16198 | 16436 | //Applet3D.tracein(this, selected); |
---|
16199 | | - vector2buffer = checker.projectedVertices; |
---|
| 16437 | + //vector2buffer = checker.projectedVertices; |
---|
16200 | 16438 | |
---|
16201 | 16439 | //checker.GetMaterial().Draw(this, false); // true); |
---|
16202 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16440 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
16203 | 16441 | |
---|
16204 | 16442 | materialdepth -= 1; |
---|
16205 | 16443 | if (materialdepth > 0) |
---|
16206 | 16444 | { |
---|
16207 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
16208 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16445 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16446 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
16209 | 16447 | } |
---|
16210 | 16448 | //checker.GetMaterial().opacity = 1f; |
---|
16211 | 16449 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
16428 | 16666 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
16429 | 16667 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
16430 | 16668 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 16669 | + |
---|
| 16670 | + CreateSelectedPoint(); |
---|
16431 | 16671 | |
---|
16432 | 16672 | // Will fit the mesh !!! |
---|
16433 | 16673 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
17068 | 17308 | int AAbuffersize = 0; |
---|
17069 | 17309 | |
---|
17070 | 17310 | //double[] selectedpoint = new double[3]; |
---|
17071 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17311 | + static Superellipsoid selectedpoint; |
---|
17072 | 17312 | static Sphere previousselectedpoint = null; |
---|
17073 | | - static Sphere debugpointG = new Sphere(); |
---|
17074 | | - static Sphere debugpointP = new Sphere(); |
---|
17075 | | - static Sphere debugpointC = new Sphere(); |
---|
17076 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17313 | + static Sphere debugpointG; |
---|
| 17314 | + static Sphere debugpointP; |
---|
| 17315 | + static Sphere debugpointC; |
---|
| 17316 | + static Sphere debugpointR; |
---|
17077 | 17317 | |
---|
17078 | 17318 | static Sphere debugpoints[] = new Sphere[8]; |
---|
17079 | 17319 | |
---|
17080 | | - static |
---|
17081 | | - { |
---|
17082 | | - for (int i=0; i<8; i++) |
---|
17083 | | - { |
---|
17084 | | - debugpoints[i] = new Sphere(); |
---|
17085 | | - } |
---|
17086 | | - } |
---|
17087 | | - |
---|
17088 | 17320 | static void InitPoints(float radius) |
---|
17089 | 17321 | { |
---|
17090 | 17322 | for (int i=0; i<8; i++) |
---|