.. | .. |
---|
60 | 60 | //boolean REDUCETEXTURE = true; |
---|
61 | 61 | boolean CACHETEXTURE = true; |
---|
62 | 62 | boolean CLEANCACHE = false; // true; |
---|
63 | | - boolean MIPMAP = false; // true; |
---|
| 63 | + boolean MIPMAP = true; // false; // true; |
---|
64 | 64 | boolean COMPRESSTEXTURE = false; |
---|
65 | 65 | boolean KOMPACTTEXTURE = false; // true; |
---|
66 | 66 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
335 | 335 | display.options1[2] = material.shadowbias; |
---|
336 | 336 | display.options1[3] = material.aniso; |
---|
337 | 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]); |
---|
338 | 343 | display.options2[0] = material.opacity; |
---|
339 | 344 | display.options2[1] = material.diffuse; |
---|
340 | 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]); |
---|
341 | 349 | |
---|
342 | 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]); |
---|
343 | 354 | display.options4[0] = material.cameralight/0.2f; |
---|
344 | 355 | display.options4[1] = material.subsurface; |
---|
345 | 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]); |
---|
346 | 360 | |
---|
347 | 361 | // if (display.CURRENTANTIALIAS > 0) |
---|
348 | 362 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
2051 | 2065 | //System.err.println("Oeil on"); |
---|
2052 | 2066 | OEIL = true; |
---|
2053 | 2067 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2054 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2068 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2055 | 2069 | //pingthread.StepToTarget(true); |
---|
2056 | 2070 | } |
---|
2057 | 2071 | |
---|
.. | .. |
---|
2284 | 2298 | HANDLES ^= true; |
---|
2285 | 2299 | } |
---|
2286 | 2300 | |
---|
| 2301 | + Object3D paintFolder; |
---|
| 2302 | + |
---|
2287 | 2303 | void TogglePaint() |
---|
2288 | 2304 | { |
---|
2289 | 2305 | PAINTMODE ^= true; |
---|
2290 | 2306 | paintcount = 0; |
---|
| 2307 | + |
---|
| 2308 | + if (PAINTMODE) |
---|
| 2309 | + { |
---|
| 2310 | + paintFolder = GetFolder(); |
---|
| 2311 | + } |
---|
2291 | 2312 | } |
---|
2292 | 2313 | |
---|
2293 | 2314 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2384 | 2405 | return currentGL; |
---|
2385 | 2406 | } |
---|
2386 | 2407 | |
---|
| 2408 | + private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2409 | + { |
---|
| 2410 | + // cache to disk |
---|
| 2411 | + Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
| 2412 | + //buffers[0]. |
---|
| 2413 | + ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
| 2414 | + int[] pixels = new int[bytebuf.capacity()/3]; |
---|
| 2415 | + int width = texturedata.getWidth(); //(int)Math.sqrt(pixels.length); // squared |
---|
| 2416 | + int height = width; |
---|
| 2417 | + for (int i=pixels.length; --i>=0;) |
---|
| 2418 | + { |
---|
| 2419 | + int i3 = i*3; |
---|
| 2420 | + pixels[i] = 0xFF; |
---|
| 2421 | + pixels[i] <<= 8; |
---|
| 2422 | + pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
| 2423 | + pixels[i] <<= 8; |
---|
| 2424 | + pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
| 2425 | + pixels[i] <<= 8; |
---|
| 2426 | + pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
| 2427 | + } |
---|
| 2428 | + /* |
---|
| 2429 | + int r=0,g=0,b=0,a=0; |
---|
| 2430 | + for (int i=0; i<width; i++) |
---|
| 2431 | + for (int j=0; j<height; j++) |
---|
| 2432 | + { |
---|
| 2433 | + int index = j*width+i; |
---|
| 2434 | + int p = pixels[index]; |
---|
| 2435 | + a = ((p>>24) & 0xFF); |
---|
| 2436 | + r = ((p>>16) & 0xFF); |
---|
| 2437 | + g = ((p>>8) & 0xFF); |
---|
| 2438 | + b = (p & 0xFF); |
---|
| 2439 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
| 2440 | + } |
---|
| 2441 | + /**/ |
---|
| 2442 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 2443 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 2444 | + return rendImage; |
---|
| 2445 | + } |
---|
| 2446 | + |
---|
2387 | 2447 | /**/ |
---|
2388 | 2448 | class CacheTexture |
---|
2389 | 2449 | { |
---|
.. | .. |
---|
2401 | 2461 | /**/ |
---|
2402 | 2462 | |
---|
2403 | 2463 | // TEXTURE static Texture texture; |
---|
2404 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2405 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2406 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2464 | + static public java.util.Hashtable<String, CacheTexture> textures = new java.util.Hashtable<String, CacheTexture>(); |
---|
| 2465 | + static public java.util.Hashtable<BufferedImage, CacheTexture> bimtextures = new java.util.Hashtable<BufferedImage, CacheTexture>(); |
---|
| 2466 | + static public java.util.HashSet<String> usedtextures = new java.util.HashSet<String>(); |
---|
| 2467 | + |
---|
2407 | 2468 | int pigmentdepth = 0; |
---|
2408 | 2469 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2409 | 2470 | int bumpdepth = 0; |
---|
.. | .. |
---|
2425 | 2486 | true, |
---|
2426 | 2487 | com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2427 | 2488 | } catch (java.io.IOException e) |
---|
| 2489 | + { |
---|
| 2490 | + throw new javax.media.opengl.GLException(e); |
---|
| 2491 | + } |
---|
| 2492 | + |
---|
| 2493 | + if (bump) |
---|
| 2494 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2495 | + |
---|
| 2496 | + com.sun.opengl.util.texture.Texture texture = |
---|
| 2497 | + com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2498 | + |
---|
| 2499 | + texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2500 | + texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2501 | + |
---|
| 2502 | + return texture; |
---|
| 2503 | + } |
---|
| 2504 | + |
---|
| 2505 | + com.sun.opengl.util.texture.Texture GetBimTexture(BufferedImage name, boolean bump) |
---|
| 2506 | + { |
---|
| 2507 | + TextureData texturedata = null; |
---|
| 2508 | + |
---|
| 2509 | + try |
---|
| 2510 | + { |
---|
| 2511 | + texturedata = |
---|
| 2512 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2513 | + name, |
---|
| 2514 | + true); |
---|
| 2515 | + } catch (Exception e) |
---|
2428 | 2516 | { |
---|
2429 | 2517 | throw new javax.media.opengl.GLException(e); |
---|
2430 | 2518 | } |
---|
.. | .. |
---|
3511 | 3599 | |
---|
3512 | 3600 | System.out.println("LOADING TEXTURE : " + name); |
---|
3513 | 3601 | |
---|
| 3602 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3603 | + |
---|
3514 | 3604 | // |
---|
3515 | 3605 | if (false) // compressbit > 0) |
---|
3516 | 3606 | { |
---|
.. | .. |
---|
7909 | 7999 | String pigment = Object3D.GetPigment(tex); |
---|
7910 | 8000 | String bump = Object3D.GetBump(tex); |
---|
7911 | 8001 | |
---|
7912 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8002 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7913 | 8003 | { |
---|
7914 | 8004 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7915 | 8005 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7943 | 8033 | |
---|
7944 | 8034 | String pigment = Object3D.GetPigment(tex); |
---|
7945 | 8035 | |
---|
7946 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8036 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7947 | 8037 | { |
---|
7948 | 8038 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7949 | 8039 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7972 | 8062 | |
---|
7973 | 8063 | String bump = Object3D.GetBump(tex); |
---|
7974 | 8064 | |
---|
7975 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8065 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7976 | 8066 | { |
---|
7977 | 8067 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7978 | 8068 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8091 | 8181 | |
---|
8092 | 8182 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8093 | 8183 | { |
---|
8094 | | - if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8095 | | - ambientOcclusion ) // || !textureon) |
---|
8096 | | - { |
---|
8097 | | - return; // false; |
---|
8098 | | - } |
---|
8099 | | - |
---|
8100 | | - if (tex == null) |
---|
8101 | | - { |
---|
8102 | | - BindTexture(null,false,resolution); |
---|
8103 | | - BindTexture(null,true,resolution); |
---|
8104 | | - return; |
---|
8105 | | - } |
---|
| 8184 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8185 | +// ambientOcclusion ) // || !textureon) |
---|
| 8186 | +// { |
---|
| 8187 | +// return; // false; |
---|
| 8188 | +// } |
---|
| 8189 | +// |
---|
| 8190 | +// if (tex == null) |
---|
| 8191 | +// { |
---|
| 8192 | +// BindTexture(null,false,resolution); |
---|
| 8193 | +// BindTexture(null,true,resolution); |
---|
| 8194 | +// return; |
---|
| 8195 | +// } |
---|
| 8196 | +// |
---|
| 8197 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8198 | +// String bump = Object3D.GetBump(tex); |
---|
| 8199 | +// |
---|
| 8200 | +// usedtextures.add(pigment); |
---|
| 8201 | +// usedtextures.add(bump); |
---|
| 8202 | +// |
---|
| 8203 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8204 | +// { |
---|
| 8205 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8206 | +// // System.out.println("; bump = " + bump); |
---|
| 8207 | +// } |
---|
| 8208 | +// |
---|
| 8209 | +// if (bump.equals("")) |
---|
| 8210 | +// { |
---|
| 8211 | +// bump = null; |
---|
| 8212 | +// } |
---|
| 8213 | +// if (pigment.equals("")) |
---|
| 8214 | +// { |
---|
| 8215 | +// pigment = null; |
---|
| 8216 | +// } |
---|
| 8217 | +// |
---|
| 8218 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8219 | +// BindTexture(pigment, false, resolution); |
---|
| 8220 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8221 | +// BindTexture(bump, true, resolution); |
---|
| 8222 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8223 | +// |
---|
| 8224 | +// return; // true; |
---|
8106 | 8225 | |
---|
8107 | | - String pigment = Object3D.GetPigment(tex); |
---|
8108 | | - String bump = Object3D.GetBump(tex); |
---|
8109 | | - |
---|
8110 | | - usedtextures.put(pigment, pigment); |
---|
8111 | | - usedtextures.put(bump, bump); |
---|
8112 | | - |
---|
8113 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8114 | | - { |
---|
8115 | | - // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8116 | | - // System.out.println("; bump = " + bump); |
---|
8117 | | - } |
---|
8118 | | - |
---|
8119 | | - if (bump.equals("")) |
---|
8120 | | - { |
---|
8121 | | - bump = null; |
---|
8122 | | - } |
---|
8123 | | - if (pigment.equals("")) |
---|
8124 | | - { |
---|
8125 | | - pigment = null; |
---|
8126 | | - } |
---|
8127 | | - |
---|
8128 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8129 | | - BindTexture(pigment, false, resolution); |
---|
8130 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8131 | | - BindTexture(bump, true, resolution); |
---|
8132 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8133 | | - |
---|
8134 | | - return; // true; |
---|
| 8226 | + BindPigmentTexture(tex, resolution); |
---|
| 8227 | + BindBumpTexture(tex, resolution); |
---|
8135 | 8228 | } |
---|
8136 | 8229 | |
---|
8137 | 8230 | /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8144 | 8237 | |
---|
8145 | 8238 | if (tex == null) |
---|
8146 | 8239 | { |
---|
8147 | | - BindTexture(null,false,resolution); |
---|
| 8240 | + BindTexture(null, null,false,resolution); |
---|
8148 | 8241 | return; |
---|
8149 | 8242 | } |
---|
8150 | 8243 | |
---|
8151 | 8244 | String pigment = Object3D.GetPigment(tex); |
---|
8152 | 8245 | |
---|
8153 | | - usedtextures.put(pigment, pigment); |
---|
| 8246 | + usedtextures.add(pigment); |
---|
8154 | 8247 | |
---|
8155 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8248 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8156 | 8249 | { |
---|
8157 | 8250 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8158 | 8251 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8164 | 8257 | } |
---|
8165 | 8258 | |
---|
8166 | 8259 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8167 | | - BindTexture(pigment, false, resolution); |
---|
| 8260 | + BindTexture(tex.pigmenttexture, pigment, false, resolution); |
---|
8168 | 8261 | } |
---|
8169 | 8262 | |
---|
8170 | 8263 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8177 | 8270 | |
---|
8178 | 8271 | if (tex == null) |
---|
8179 | 8272 | { |
---|
8180 | | - BindTexture(null,true,resolution); |
---|
| 8273 | + BindTexture(null, null,true,resolution); |
---|
8181 | 8274 | return; |
---|
8182 | 8275 | } |
---|
8183 | 8276 | |
---|
8184 | 8277 | String bump = Object3D.GetBump(tex); |
---|
8185 | 8278 | |
---|
8186 | | - usedtextures.put(bump, bump); |
---|
| 8279 | + usedtextures.add(bump); |
---|
8187 | 8280 | |
---|
8188 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8281 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8189 | 8282 | { |
---|
8190 | 8283 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8191 | 8284 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8197 | 8290 | } |
---|
8198 | 8291 | |
---|
8199 | 8292 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8200 | | - BindTexture(bump, true, resolution); |
---|
| 8293 | + BindTexture(tex.bumptexture, bump, true, resolution); |
---|
8201 | 8294 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8202 | 8295 | } |
---|
8203 | 8296 | |
---|
.. | .. |
---|
8221 | 8314 | return fileExists; |
---|
8222 | 8315 | } |
---|
8223 | 8316 | |
---|
8224 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8317 | + CacheTexture GetCacheTexture(java.awt.image.BufferedImage bim, String tex, boolean bump, int resolution) throws Exception |
---|
8225 | 8318 | { |
---|
8226 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8319 | + CacheTexture texturecache = null; |
---|
8227 | 8320 | |
---|
8228 | 8321 | if (tex != null) |
---|
8229 | 8322 | { |
---|
.. | .. |
---|
8243 | 8336 | } |
---|
8244 | 8337 | |
---|
8245 | 8338 | if (CACHETEXTURE) |
---|
8246 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8247 | | - |
---|
8248 | | - TextureData texturedata = null; |
---|
8249 | | - |
---|
8250 | | - if (texture == null || texture.resolution < resolution) |
---|
8251 | 8339 | { |
---|
| 8340 | + if (bim == null) |
---|
| 8341 | + texturecache = textures.get(texname); // TEXTURE CACHE |
---|
| 8342 | + else |
---|
| 8343 | + texturecache = bimtextures.get(bim); // TEXTURE CACHE |
---|
| 8344 | + } |
---|
| 8345 | + |
---|
| 8346 | + if (texturecache == null || texturecache.resolution < resolution) |
---|
| 8347 | + { |
---|
| 8348 | + TextureData texturedata = null; |
---|
| 8349 | + |
---|
| 8350 | + if (bim != null) |
---|
| 8351 | + { |
---|
| 8352 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8353 | + } |
---|
| 8354 | + else |
---|
8252 | 8355 | if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8253 | 8356 | { |
---|
8254 | 8357 | assert(!bump); |
---|
.. | .. |
---|
8260 | 8363 | // } |
---|
8261 | 8364 | // else |
---|
8262 | 8365 | // { |
---|
8263 | | - texture = textures.get(tex); |
---|
8264 | | - if (texture == null) |
---|
| 8366 | + texturecache = textures.get(tex); |
---|
| 8367 | + if (texturecache == null) |
---|
8265 | 8368 | { |
---|
8266 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8369 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8267 | 8370 | } |
---|
| 8371 | + else |
---|
| 8372 | + new Exception().printStackTrace(); |
---|
8268 | 8373 | // } |
---|
8269 | 8374 | } else |
---|
8270 | 8375 | if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8271 | 8376 | { |
---|
8272 | 8377 | assert(bump); |
---|
8273 | | - texture = textures.get(tex); |
---|
8274 | | - if (texture == null) |
---|
8275 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8378 | + texturecache = textures.get(tex); |
---|
| 8379 | + if (texturecache == null) |
---|
| 8380 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8381 | + else |
---|
| 8382 | + new Exception().printStackTrace(); |
---|
8276 | 8383 | } else |
---|
8277 | 8384 | { |
---|
8278 | 8385 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8282 | 8389 | //{ |
---|
8283 | 8390 | if (tex.equals("WHITE_NOISE")) |
---|
8284 | 8391 | { |
---|
8285 | | - texture = textures.get(tex); |
---|
8286 | | - if (texture == null) |
---|
8287 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8392 | + texturecache = textures.get(tex); |
---|
| 8393 | + if (texturecache == null) |
---|
| 8394 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8395 | + else |
---|
| 8396 | + new Exception().printStackTrace(); |
---|
8288 | 8397 | } else |
---|
8289 | 8398 | { |
---|
8290 | 8399 | if (textureon) |
---|
.. | .. |
---|
8343 | 8452 | if (texturedata == null) |
---|
8344 | 8453 | throw new Exception(); |
---|
8345 | 8454 | |
---|
8346 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8455 | + texturecache = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
8347 | 8456 | //texture = GetTexture(tex, bump); |
---|
8348 | 8457 | } |
---|
8349 | 8458 | } |
---|
8350 | 8459 | //} |
---|
8351 | 8460 | } |
---|
8352 | 8461 | |
---|
8353 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8462 | + if (/*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8354 | 8463 | { |
---|
8355 | 8464 | //return false; |
---|
| 8465 | + assert(bim == null); |
---|
8356 | 8466 | |
---|
8357 | 8467 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8358 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8468 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8359 | 8469 | { |
---|
8360 | 8470 | // String ext = "_highres"; |
---|
8361 | 8471 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8372 | 8482 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8373 | 8483 | if (!cachefile.exists()) |
---|
8374 | 8484 | { |
---|
8375 | | - // cache to disk |
---|
8376 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8377 | | - //buffers[0]. |
---|
8378 | | - |
---|
8379 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8380 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8381 | | - |
---|
8382 | | - // squared size heuristic... |
---|
8383 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8485 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8384 | 8486 | { |
---|
8385 | | - for (int i=pixels.length; --i>=0;) |
---|
8386 | | - { |
---|
8387 | | - int i3 = i*3; |
---|
8388 | | - pixels[i] = 0xFF; |
---|
8389 | | - pixels[i] <<= 8; |
---|
8390 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8391 | | - pixels[i] <<= 8; |
---|
8392 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8393 | | - pixels[i] <<= 8; |
---|
8394 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8395 | | - } |
---|
8396 | | - |
---|
8397 | | - /* |
---|
8398 | | - int r=0,g=0,b=0,a=0; |
---|
8399 | | - for (int i=0; i<width; i++) |
---|
8400 | | - for (int j=0; j<height; j++) |
---|
8401 | | - { |
---|
8402 | | - int index = j*width+i; |
---|
8403 | | - int p = pixels[index]; |
---|
8404 | | - a = ((p>>24) & 0xFF); |
---|
8405 | | - r = ((p>>16) & 0xFF); |
---|
8406 | | - g = ((p>>8) & 0xFF); |
---|
8407 | | - b = (p & 0xFF); |
---|
8408 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8409 | | - } |
---|
8410 | | - /**/ |
---|
8411 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8412 | | - int height = width; |
---|
8413 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8414 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8487 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8488 | + |
---|
8415 | 8489 | ImageWriter writer = null; |
---|
8416 | 8490 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8417 | 8491 | if (iter.hasNext()) { |
---|
8418 | 8492 | writer = (ImageWriter)iter.next(); |
---|
8419 | 8493 | } |
---|
8420 | | - float compressionQuality = 0.9f; |
---|
| 8494 | + |
---|
| 8495 | + float compressionQuality = 0.85f; |
---|
8421 | 8496 | try |
---|
8422 | 8497 | { |
---|
8423 | 8498 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8444 | 8519 | textures.remove(texname); |
---|
8445 | 8520 | } |
---|
8446 | 8521 | |
---|
8447 | | - texture.texturedata = texturedata; |
---|
8448 | | - textures.put(texname, texture); |
---|
| 8522 | + //texture.texturedata = texturedata; |
---|
| 8523 | + textures.put(texname, texturecache); |
---|
8449 | 8524 | |
---|
8450 | 8525 | // newtex = true; |
---|
8451 | 8526 | } |
---|
.. | .. |
---|
8461 | 8536 | } |
---|
8462 | 8537 | } |
---|
8463 | 8538 | |
---|
8464 | | - return texture; |
---|
| 8539 | + return texturecache; |
---|
8465 | 8540 | } |
---|
8466 | 8541 | |
---|
8467 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8542 | + static void EmbedTextures(cTexture tex) |
---|
8468 | 8543 | { |
---|
8469 | | - CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
| 8544 | + |
---|
| 8545 | + } |
---|
| 8546 | + |
---|
| 8547 | + com.sun.opengl.util.texture.Texture GetTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
| 8548 | + { |
---|
| 8549 | + CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution); |
---|
8470 | 8550 | |
---|
8471 | 8551 | if (bump) |
---|
8472 | 8552 | { |
---|
.. | .. |
---|
8482 | 8562 | return texture!=null?texture.texture:null; |
---|
8483 | 8563 | } |
---|
8484 | 8564 | |
---|
8485 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
| 8565 | + public com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
8486 | 8566 | { |
---|
8487 | | - CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
| 8567 | + CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution); |
---|
8488 | 8568 | |
---|
8489 | 8569 | return texture!=null?texture.texturedata:null; |
---|
8490 | 8570 | } |
---|
8491 | 8571 | |
---|
8492 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8572 | + boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
8493 | 8573 | { |
---|
8494 | 8574 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8495 | 8575 | { |
---|
8496 | 8576 | return false; |
---|
8497 | 8577 | } |
---|
8498 | 8578 | |
---|
8499 | | - boolean newtex = false; |
---|
| 8579 | + //boolean newtex = false; |
---|
8500 | 8580 | |
---|
8501 | | - com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
| 8581 | + com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution); |
---|
8502 | 8582 | |
---|
8503 | 8583 | if (texture == null) |
---|
8504 | 8584 | return false; |
---|
.. | .. |
---|
8528 | 8608 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8529 | 8609 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8530 | 8610 | |
---|
8531 | | - return newtex; |
---|
| 8611 | + return true; // Warning: not used. |
---|
8532 | 8612 | } |
---|
8533 | 8613 | |
---|
8534 | 8614 | ShadowBuffer shadowPBuf; |
---|
.. | .. |
---|
9366 | 9446 | jy8[3] = 0.5f; |
---|
9367 | 9447 | } |
---|
9368 | 9448 | |
---|
9369 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9449 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9370 | 9450 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9371 | 9451 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9372 | 9452 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9373 | 9453 | |
---|
| 9454 | + void ResetOptions() |
---|
| 9455 | + { |
---|
| 9456 | + options1[0] = 100; |
---|
| 9457 | + options1[1] = 0.025f; |
---|
| 9458 | + options1[2] = 0.01f; |
---|
| 9459 | + options1[3] = 0; |
---|
| 9460 | + options1[4] = 0; |
---|
| 9461 | + |
---|
| 9462 | + options2[0] = 0; |
---|
| 9463 | + options2[1] = 0.75f; |
---|
| 9464 | + options2[2] = 0; |
---|
| 9465 | + options2[3] = 0; |
---|
| 9466 | + |
---|
| 9467 | + options3[0] = 1; |
---|
| 9468 | + options3[1] = 1; |
---|
| 9469 | + options3[2] = 1; |
---|
| 9470 | + options3[3] = 0; |
---|
| 9471 | + |
---|
| 9472 | + options4[0] = 1; |
---|
| 9473 | + options4[1] = 0; |
---|
| 9474 | + options4[2] = 1; |
---|
| 9475 | + options4[3] = 0; |
---|
| 9476 | + } |
---|
| 9477 | + |
---|
9374 | 9478 | static int imagecount = 0; // movie generation |
---|
9375 | 9479 | |
---|
9376 | 9480 | static int jitter = 0; |
---|
.. | .. |
---|
10961 | 11065 | |
---|
10962 | 11066 | try |
---|
10963 | 11067 | { |
---|
10964 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11068 | + BindTexture(null, NOISE_TEXTURE, false, 2); |
---|
10965 | 11069 | } |
---|
10966 | 11070 | catch (Exception e) |
---|
10967 | 11071 | { |
---|
.. | .. |
---|
10990 | 11094 | |
---|
10991 | 11095 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10992 | 11096 | |
---|
10993 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10994 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10995 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11097 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11098 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11099 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10996 | 11100 | } else |
---|
10997 | 11101 | { |
---|
10998 | 11102 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
11003 | 11107 | //System.out.println("BLENDING ON"); |
---|
11004 | 11108 | gl.glEnable(GL.GL_BLEND); |
---|
11005 | 11109 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
11006 | | - |
---|
| 11110 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
11007 | 11111 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
11008 | 11112 | gl.glLoadIdentity(); |
---|
11009 | 11113 | |
---|
.. | .. |
---|
11480 | 11584 | |
---|
11481 | 11585 | void DrawObject(GL gl, boolean draw) |
---|
11482 | 11586 | { |
---|
| 11587 | + // To clear camera values |
---|
| 11588 | + ResetOptions(); |
---|
| 11589 | + |
---|
11483 | 11590 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11484 | 11591 | // DrawMode() = SELECTION; |
---|
11485 | 11592 | //GL gl = getGL(); |
---|
11486 | 11593 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11487 | 11594 | { |
---|
11488 | 11595 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11489 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11596 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11490 | 11597 | pingthread.StepToTarget(true); // true); |
---|
11491 | 11598 | // zoomonce = false; |
---|
11492 | 11599 | } |
---|
.. | .. |
---|
11623 | 11730 | if (tex.equals("WHITE_NOISE")) |
---|
11624 | 11731 | continue; |
---|
11625 | 11732 | |
---|
11626 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11733 | + if (!usedtextures.contains(tex)) |
---|
11627 | 11734 | { |
---|
11628 | 11735 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11629 | 11736 | textures.get(tex).texture.dispose(); |
---|
.. | .. |
---|
12047 | 12154 | for (int i = tp.size(); --i >= 0;) |
---|
12048 | 12155 | { |
---|
12049 | 12156 | //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
12050 | | - LA.xformPos(light, tp.get(i).GlobalTransform(), light); |
---|
| 12157 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
12051 | 12158 | } |
---|
12052 | 12159 | |
---|
12053 | 12160 | |
---|
.. | .. |
---|
13334 | 13441 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13335 | 13442 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13336 | 13443 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
13337 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
13338 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
13339 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13444 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13445 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13446 | + |
---|
| 13447 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13340 | 13448 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13341 | 13449 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13342 | 13450 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13901 | 14009 | |
---|
13902 | 14010 | // fev 2014??? |
---|
13903 | 14011 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13904 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14012 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13905 | 14013 | pingthread.StepToTarget(true); // true); |
---|
13906 | 14014 | } |
---|
13907 | 14015 | // if (!LIVE) |
---|
.. | .. |
---|
14255 | 14363 | void GoDown(int mod) |
---|
14256 | 14364 | { |
---|
14257 | 14365 | MODIFIERS |= COMMAND; |
---|
14258 | | - /* |
---|
| 14366 | + /**/ |
---|
14259 | 14367 | if((mod&SHIFT) == SHIFT) |
---|
14260 | 14368 | manipCamera.RotatePosition(0, -speed); |
---|
14261 | 14369 | else |
---|
14262 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14263 | | - */ |
---|
| 14370 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14371 | + /**/ |
---|
14264 | 14372 | if ((mod & SHIFT) == SHIFT) |
---|
14265 | 14373 | { |
---|
14266 | 14374 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14276 | 14384 | void GoUp(int mod) |
---|
14277 | 14385 | { |
---|
14278 | 14386 | MODIFIERS |= COMMAND; |
---|
14279 | | - /* |
---|
| 14387 | + /**/ |
---|
14280 | 14388 | if((mod&SHIFT) == SHIFT) |
---|
14281 | 14389 | manipCamera.RotatePosition(0, speed); |
---|
14282 | 14390 | else |
---|
14283 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14284 | | - */ |
---|
| 14391 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14392 | + /**/ |
---|
14285 | 14393 | if ((mod & SHIFT) == SHIFT) |
---|
14286 | 14394 | { |
---|
14287 | 14395 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14297 | 14405 | void GoLeft(int mod) |
---|
14298 | 14406 | { |
---|
14299 | 14407 | MODIFIERS |= COMMAND; |
---|
14300 | | - /* |
---|
| 14408 | + /**/ |
---|
14301 | 14409 | if((mod&SHIFT) == SHIFT) |
---|
14302 | | - manipCamera.RotatePosition(speed, 0); |
---|
14303 | | - else |
---|
14304 | 14410 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14305 | | - */ |
---|
| 14411 | + else |
---|
| 14412 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14413 | + /**/ |
---|
14306 | 14414 | if ((mod & SHIFT) == SHIFT) |
---|
14307 | 14415 | { |
---|
14308 | 14416 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14318 | 14426 | void GoRight(int mod) |
---|
14319 | 14427 | { |
---|
14320 | 14428 | MODIFIERS |= COMMAND; |
---|
14321 | | - /* |
---|
| 14429 | + /**/ |
---|
14322 | 14430 | if((mod&SHIFT) == SHIFT) |
---|
14323 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14324 | | - else |
---|
14325 | 14431 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14326 | | - */ |
---|
| 14432 | + else |
---|
| 14433 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14434 | + /**/ |
---|
14327 | 14435 | if ((mod & SHIFT) == SHIFT) |
---|
14328 | 14436 | { |
---|
14329 | 14437 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14562 | 14670 | Globals.MOUSEDRAGGED = false; |
---|
14563 | 14671 | |
---|
14564 | 14672 | movingcamera = false; |
---|
14565 | | - X = Y = 0; |
---|
| 14673 | + X = 0; // getBounds().width/2; |
---|
| 14674 | + Y = 0; // getBounds().height/2; |
---|
14566 | 14675 | //System.out.println("mouseReleased: " + e); |
---|
14567 | 14676 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14568 | 14677 | } |
---|
.. | .. |
---|
14903 | 15012 | case 'E' : COMPACT ^= true; |
---|
14904 | 15013 | repaint(); |
---|
14905 | 15014 | break; |
---|
14906 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15015 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15016 | + //DEBUGHSB ^= true; |
---|
| 15017 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14907 | 15018 | repaint(); |
---|
14908 | 15019 | break; |
---|
14909 | 15020 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14929 | 15040 | repaint(); |
---|
14930 | 15041 | break; |
---|
14931 | 15042 | case 'l': |
---|
14932 | | - lightMode ^= true; |
---|
14933 | | - Globals.lighttouched = true; |
---|
14934 | | - manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
14935 | | - targetLookAt.set(manipCamera.lookAt); |
---|
14936 | | - repaint(); |
---|
14937 | | - break; |
---|
14938 | | - case 'L': |
---|
| 15043 | + //case 'L': |
---|
14939 | 15044 | if (lightMode) |
---|
14940 | 15045 | { |
---|
14941 | 15046 | lightMode = false; |
---|
.. | .. |
---|
15078 | 15183 | case '_': |
---|
15079 | 15184 | kompactbit = 5; |
---|
15080 | 15185 | break; |
---|
15081 | | - case '+': |
---|
15082 | | - kompactbit = 6; |
---|
15083 | | - break; |
---|
| 15186 | +// case '+': |
---|
| 15187 | +// kompactbit = 6; |
---|
| 15188 | +// break; |
---|
15084 | 15189 | case ' ': |
---|
15085 | | - ObjEditor.theFrame.ToggleFullScreen(); |
---|
| 15190 | + lightMode ^= true; |
---|
| 15191 | + Globals.lighttouched = true; |
---|
| 15192 | + manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
| 15193 | + targetLookAt.set(manipCamera.lookAt); |
---|
15086 | 15194 | repaint(); |
---|
15087 | 15195 | break; |
---|
15088 | 15196 | //case '`' : |
---|
.. | .. |
---|
15129 | 15237 | case DELETE: |
---|
15130 | 15238 | ClearSelection(); |
---|
15131 | 15239 | break; |
---|
15132 | | - /* |
---|
15133 | 15240 | case '+': |
---|
| 15241 | + |
---|
| 15242 | + /* |
---|
15134 | 15243 | //fontsize += 1; |
---|
15135 | 15244 | bbzoom *= 2; |
---|
15136 | 15245 | repaint(); |
---|
.. | .. |
---|
15147 | 15256 | case '=': |
---|
15148 | 15257 | IncDepth(); |
---|
15149 | 15258 | //fontsize += 1; |
---|
15150 | | - object.editWindow.refreshContents(true); |
---|
| 15259 | + object.GetWindow().refreshContents(true); |
---|
15151 | 15260 | maskbit = 6; |
---|
15152 | 15261 | break; |
---|
15153 | 15262 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
15154 | 15263 | DecDepth(); |
---|
15155 | 15264 | maskbit = 5; |
---|
15156 | 15265 | //if(fontsize > 1) fontsize -= 1; |
---|
15157 | | - if (object.editWindow == null) |
---|
15158 | | - new Exception().printStackTrace(); |
---|
15159 | | - else |
---|
15160 | | - object.editWindow.refreshContents(true); |
---|
| 15266 | +// if (object.editWindow == null) |
---|
| 15267 | +// new Exception().printStackTrace(); |
---|
| 15268 | +// else |
---|
| 15269 | + object.GetWindow().refreshContents(true); |
---|
15161 | 15270 | break; |
---|
15162 | 15271 | case '{': |
---|
15163 | 15272 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15381 | 15490 | } |
---|
15382 | 15491 | */ |
---|
15383 | 15492 | |
---|
15384 | | - object.editWindow.EditSelection(false); |
---|
| 15493 | + object.GetWindow().EditSelection(false); |
---|
15385 | 15494 | } |
---|
15386 | 15495 | |
---|
15387 | 15496 | void SelectParent() |
---|
.. | .. |
---|
15398 | 15507 | { |
---|
15399 | 15508 | //selectees.remove(i); |
---|
15400 | 15509 | System.out.println("select parent of " + elem); |
---|
15401 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15510 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15402 | 15511 | } else |
---|
15403 | 15512 | { |
---|
15404 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15513 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15405 | 15514 | } |
---|
15406 | 15515 | |
---|
15407 | 15516 | first = false; |
---|
.. | .. |
---|
15443 | 15552 | for (int j = 0; j < group.children.size(); j++) |
---|
15444 | 15553 | { |
---|
15445 | 15554 | elem = (Object3D) group.children.elementAt(j); |
---|
15446 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15555 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15447 | 15556 | first = false; |
---|
15448 | 15557 | } |
---|
15449 | 15558 | } else |
---|
15450 | 15559 | { |
---|
15451 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15560 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15452 | 15561 | } |
---|
15453 | 15562 | |
---|
15454 | 15563 | first = false; |
---|
.. | .. |
---|
15459 | 15568 | { |
---|
15460 | 15569 | //Composite group = (Composite) object; |
---|
15461 | 15570 | Object3D group = object; |
---|
15462 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15571 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15463 | 15572 | } |
---|
15464 | 15573 | |
---|
15465 | 15574 | void ResetTransform(int mask) |
---|
15466 | 15575 | { |
---|
15467 | 15576 | //Composite group = (Composite) object; |
---|
15468 | 15577 | Object3D group = object; |
---|
15469 | | - group.editWindow.ResetTransform(mask); |
---|
| 15578 | + group.GetWindow().ResetTransform(mask); |
---|
15470 | 15579 | } |
---|
15471 | 15580 | |
---|
15472 | 15581 | void FlipTransform() |
---|
15473 | 15582 | { |
---|
15474 | 15583 | //Composite group = (Composite) object; |
---|
15475 | 15584 | Object3D group = object; |
---|
15476 | | - group.editWindow.FlipTransform(); |
---|
| 15585 | + group.GetWindow().FlipTransform(); |
---|
15477 | 15586 | // group.editWindow.ReduceMesh(true); |
---|
15478 | 15587 | } |
---|
15479 | 15588 | |
---|
.. | .. |
---|
15481 | 15590 | { |
---|
15482 | 15591 | //Composite group = (Composite) object; |
---|
15483 | 15592 | Object3D group = object; |
---|
15484 | | - group.editWindow.PrintMemory(); |
---|
| 15593 | + group.GetWindow().PrintMemory(); |
---|
15485 | 15594 | // group.editWindow.ReduceMesh(true); |
---|
15486 | 15595 | } |
---|
15487 | 15596 | |
---|
.. | .. |
---|
15489 | 15598 | { |
---|
15490 | 15599 | //Composite group = (Composite) object; |
---|
15491 | 15600 | Object3D group = object; |
---|
15492 | | - group.editWindow.ResetCentroid(); |
---|
| 15601 | + group.GetWindow().ResetCentroid(); |
---|
15493 | 15602 | } |
---|
15494 | 15603 | |
---|
15495 | 15604 | void IncDepth() |
---|
.. | .. |
---|
15665 | 15774 | info.bounds.y += (height - desired) / 2; |
---|
15666 | 15775 | } |
---|
15667 | 15776 | } |
---|
| 15777 | + |
---|
15668 | 15778 | info.g = gr; |
---|
15669 | 15779 | info.camera = renderCamera; |
---|
15670 | 15780 | /* |
---|
.. | .. |
---|
15674 | 15784 | */ |
---|
15675 | 15785 | if (!isRenderer) |
---|
15676 | 15786 | { |
---|
15677 | | - object.drawEditHandles(info, 0); |
---|
15678 | | - |
---|
15679 | | - if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 15787 | + Grafreed.Assert(object != null); |
---|
| 15788 | + Grafreed.Assert(object.selection != null); |
---|
| 15789 | + if (object.selection.Size() > 0) |
---|
15680 | 15790 | { |
---|
15681 | | - switch (object.selection.get(0).hitSomething) |
---|
| 15791 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 15792 | + |
---|
| 15793 | + info.DX = 0; |
---|
| 15794 | + info.DY = 0; |
---|
| 15795 | + info.W = 1; |
---|
| 15796 | + if (hitSomething == Object3D.hitCenter) |
---|
15682 | 15797 | { |
---|
15683 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
15684 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15685 | | - break; |
---|
15686 | | - case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
15687 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15688 | | - break; |
---|
15689 | | - case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15690 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15691 | | - break; |
---|
| 15798 | + info.DX = X; |
---|
| 15799 | + if (X != 0) |
---|
| 15800 | + info.DX -= info.bounds.width/2; |
---|
| 15801 | + |
---|
| 15802 | + info.DY = Y; |
---|
| 15803 | + if (Y != 0) |
---|
| 15804 | + info.DY -= info.bounds.height/2; |
---|
15692 | 15805 | } |
---|
15693 | | - |
---|
| 15806 | + |
---|
| 15807 | + object.drawEditHandles(info, 0); |
---|
| 15808 | + |
---|
| 15809 | + if (drag && (X != 0 || Y != 0)) |
---|
| 15810 | + { |
---|
| 15811 | + switch (hitSomething) |
---|
| 15812 | + { |
---|
| 15813 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15814 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15815 | + break; |
---|
| 15816 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15817 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15818 | + break; |
---|
| 15819 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 15820 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15821 | + break; |
---|
| 15822 | + } |
---|
| 15823 | + |
---|
| 15824 | + } |
---|
15694 | 15825 | } |
---|
15695 | 15826 | } |
---|
15696 | 15827 | } |
---|
.. | .. |
---|
16488 | 16619 | } |
---|
16489 | 16620 | } |
---|
16490 | 16621 | |
---|
| 16622 | + private Object3D GetFolder() |
---|
| 16623 | + { |
---|
| 16624 | + Object3D folder = object.GetWindow().copy; |
---|
| 16625 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16626 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16627 | + return folder; |
---|
| 16628 | + } |
---|
| 16629 | + |
---|
16491 | 16630 | class SelectBuffer implements GLEventListener |
---|
16492 | 16631 | { |
---|
16493 | 16632 | |
---|
.. | .. |
---|
16567 | 16706 | |
---|
16568 | 16707 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16569 | 16708 | |
---|
| 16709 | + if (PAINTMODE) |
---|
| 16710 | + { |
---|
| 16711 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16712 | + { |
---|
| 16713 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16714 | + |
---|
| 16715 | + // Make what you paint not selectable. |
---|
| 16716 | + paintobj.ResetSelectable(); |
---|
| 16717 | + } |
---|
| 16718 | + } |
---|
| 16719 | + |
---|
16570 | 16720 | //int tmp = selection_view; |
---|
16571 | 16721 | //selection_view = -1; |
---|
16572 | 16722 | int temp = DrawMode(); |
---|
.. | .. |
---|
16578 | 16728 | // temp = DEFAULT; // patch for selection debug |
---|
16579 | 16729 | Globals.drawMode = temp; // WARNING |
---|
16580 | 16730 | |
---|
| 16731 | + if (PAINTMODE) |
---|
| 16732 | + { |
---|
| 16733 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16734 | + { |
---|
| 16735 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16736 | + |
---|
| 16737 | + // Revert. |
---|
| 16738 | + paintobj.RestoreSelectable(); |
---|
| 16739 | + } |
---|
| 16740 | + } |
---|
| 16741 | + |
---|
16581 | 16742 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16582 | 16743 | |
---|
16583 | 16744 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16681 | 16842 | } |
---|
16682 | 16843 | |
---|
16683 | 16844 | if (!movingcamera && !PAINTMODE) |
---|
16684 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 16845 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16685 | 16846 | |
---|
16686 | | - if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 16847 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16687 | 16848 | { |
---|
16688 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 16849 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16689 | 16850 | |
---|
16690 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 16851 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16852 | + { |
---|
| 16853 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16691 | 16854 | |
---|
16692 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16693 | | - |
---|
16694 | | - group.add(paintobj); // link |
---|
16695 | | - |
---|
16696 | | - object.editWindow.SnapObject(group); |
---|
16697 | | - |
---|
16698 | | - Object3D folder = object.editWindow.copy; |
---|
16699 | | - |
---|
16700 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16701 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16702 | | - |
---|
16703 | | - folder.add(group); |
---|
16704 | | - |
---|
16705 | | - object.editWindow.ResetModel(); |
---|
16706 | | - object.editWindow.refreshContents(); |
---|
| 16855 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 16856 | + |
---|
| 16857 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 16858 | + |
---|
| 16859 | + inst.add(paintobj); // link |
---|
| 16860 | + |
---|
| 16861 | + object.GetWindow().SnapObject(inst); |
---|
| 16862 | + |
---|
| 16863 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 16864 | + |
---|
| 16865 | + folder.add(inst); |
---|
| 16866 | + |
---|
| 16867 | + object.GetWindow().ResetModel(); |
---|
| 16868 | + object.GetWindow().refreshContents(); |
---|
| 16869 | + } |
---|
16707 | 16870 | } |
---|
16708 | 16871 | else |
---|
16709 | 16872 | paintcount = 0; |
---|
.. | .. |
---|
16742 | 16905 | //System.out.println("objects[color] = " + objects[color]); |
---|
16743 | 16906 | //objects[color].Select(); |
---|
16744 | 16907 | indexcount = 0; |
---|
| 16908 | + ObjEditor window = object.GetWindow(); |
---|
| 16909 | + if (window != null && deselect) |
---|
| 16910 | + { |
---|
| 16911 | + window.Select(null, deselect, true); |
---|
| 16912 | + } |
---|
16745 | 16913 | object.Select(color, deselect); |
---|
16746 | 16914 | } |
---|
16747 | 16915 | |
---|