.. | .. |
---|
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 | | -class CameraPane extends GLCanvas implements Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
| 38 | +class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 39 | { |
---|
36 | | - static boolean DEBUG = false; |
---|
| 40 | + static cMaterial[] materialstack = new cMaterial[65536]; |
---|
| 41 | + static boolean[] selectedstack = new boolean[65536]; |
---|
| 42 | + static int materialdepth = 0; |
---|
| 43 | + |
---|
37 | 44 | static boolean FRUSTUM = false; // still bogus true; // frustum culling |
---|
38 | 45 | |
---|
39 | 46 | // camera change fix |
---|
.. | .. |
---|
42 | 49 | |
---|
43 | 50 | static int STEP = 1; |
---|
44 | 51 | |
---|
45 | | - static boolean ONESTEP = false; // do LIVE once |
---|
46 | | - |
---|
47 | | - /** |
---|
48 | | - * @return the LIVE |
---|
49 | | - */ |
---|
50 | | - public static boolean isLIVE() |
---|
| 52 | + private static BufferedImage CreateBim(byte[] bytes, int width, int height) |
---|
51 | 53 | { |
---|
52 | | - return LIVE || ONESTEP; |
---|
| 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; |
---|
53 | 83 | } |
---|
54 | 84 | |
---|
55 | | - /** |
---|
56 | | - * @param aLIVE the LIVE to set |
---|
57 | | - */ |
---|
58 | | - public static void setLIVE(boolean aLIVE) |
---|
59 | | - { |
---|
60 | | - LIVE = aLIVE; |
---|
61 | | - } |
---|
62 | | - |
---|
63 | | - /*static*/ boolean CULLFACE = false; // true; |
---|
| 85 | + /*static*/ private boolean CULLFACE = false; // true; |
---|
64 | 86 | /*static*/ boolean NEAREST = false; // true; |
---|
65 | 87 | /*static*/ boolean WIREFRAME = false; // true; |
---|
66 | 88 | |
---|
.. | .. |
---|
70 | 92 | static int CURRENTANTIALIAS = 0; // 1; |
---|
71 | 93 | /*static*/ boolean RENDERSHADOW = true; |
---|
72 | 94 | /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal |
---|
73 | | - static boolean ANIMATION = false; |
---|
74 | | - static String filename; |
---|
75 | 95 | |
---|
76 | 96 | boolean DISPLAYTEXT = false; |
---|
77 | 97 | //boolean REDUCETEXTURE = true; |
---|
78 | 98 | boolean CACHETEXTURE = true; |
---|
79 | 99 | boolean CLEANCACHE = false; // true; |
---|
80 | | - boolean MIPMAP = false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
81 | 101 | boolean COMPRESSTEXTURE = false; |
---|
82 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
83 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
97 | 117 | |
---|
98 | 118 | static boolean textureon = true; |
---|
99 | 119 | static boolean LOCALTRANSFORM = false; |
---|
100 | | -private static boolean LIVE = false; |
---|
101 | 120 | static boolean FULLSCREEN = false; |
---|
102 | 121 | static boolean SUPPORT = true; |
---|
103 | | -static boolean CROWD = false; |
---|
104 | 122 | static boolean INERTIA = true; |
---|
105 | 123 | static boolean FAST = false; |
---|
106 | 124 | static boolean SLOWPOSE = false; |
---|
.. | .. |
---|
108 | 126 | |
---|
109 | 127 | static int tickcount = 0; // slow pose issue |
---|
110 | 128 | |
---|
| 129 | +static boolean BUTTONLESSWHEEL = false; |
---|
| 130 | +static boolean ZOOMBOXMODE = false; |
---|
111 | 131 | static boolean BOXMODE = false; |
---|
112 | 132 | static boolean IMAGEFLIP = false; |
---|
113 | 133 | static boolean SMOOTHFOCUS = false; |
---|
.. | .. |
---|
122 | 142 | static boolean OEIL = true; |
---|
123 | 143 | static boolean OEILONCE = false; // do oeilon then oeiloff |
---|
124 | 144 | static boolean LOOKAT = true; |
---|
125 | | -static boolean RANDOM = true; // false; |
---|
| 145 | +static boolean SWITCH = true; // false; |
---|
126 | 146 | static boolean HANDLES = false; // selection doesn't work!! |
---|
127 | 147 | static boolean PAINTMODE = false; |
---|
128 | 148 | |
---|
.. | .. |
---|
165 | 185 | defaultcaps.setAccumBlueBits(16); |
---|
166 | 186 | defaultcaps.setAccumAlphaBits(16); |
---|
167 | 187 | } |
---|
168 | | - static CameraPane theRenderer; |
---|
| 188 | + |
---|
| 189 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
169 | 190 | |
---|
| 191 | + public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 192 | + { |
---|
| 193 | + try |
---|
| 194 | + { |
---|
| 195 | + cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 196 | + } catch (IOException e) |
---|
| 197 | + { |
---|
| 198 | + System.out.println("NAME = " + name); |
---|
| 199 | + e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 200 | + } |
---|
| 201 | + } |
---|
| 202 | + |
---|
170 | 203 | void SetAsGLRenderer(boolean b) |
---|
171 | 204 | { |
---|
172 | 205 | isRenderer = b; |
---|
173 | | - theRenderer = this; |
---|
| 206 | + Globals.theRenderer = this; |
---|
| 207 | + } |
---|
| 208 | + |
---|
| 209 | + CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
| 210 | + { |
---|
| 211 | + super(defaultcaps, null, withcontext?glcontext:null, null); |
---|
| 212 | + |
---|
| 213 | + //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523)); |
---|
| 214 | + glcontext = getContext(); |
---|
| 215 | + |
---|
| 216 | + cameras = new Camera[2]; |
---|
| 217 | + targetLookAts = new cVector[2]; |
---|
| 218 | + |
---|
| 219 | + SetCamera(cam); |
---|
| 220 | + |
---|
| 221 | + // Warning: not used. |
---|
| 222 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
| 223 | + |
---|
| 224 | + object = o; |
---|
| 225 | + |
---|
| 226 | + setBackground(Color.white); |
---|
| 227 | + |
---|
| 228 | + addKeyListener(this); |
---|
| 229 | + addMouseListener(this); |
---|
| 230 | + addMouseMotionListener(this); |
---|
| 231 | + addMouseWheelListener(this); |
---|
| 232 | + //System.out.println("addGLEventListener: " + this); |
---|
| 233 | + addGLEventListener(this); |
---|
| 234 | + |
---|
| 235 | +// pingthread.start(); // may 2013 |
---|
174 | 236 | } |
---|
175 | 237 | |
---|
176 | 238 | static boolean AntialiasingEnabled() |
---|
.. | .. |
---|
178 | 240 | return CURRENTANTIALIAS > 0; |
---|
179 | 241 | } |
---|
180 | 242 | |
---|
181 | | - void ClearDepth() |
---|
| 243 | + /// INTERFACE |
---|
| 244 | + |
---|
| 245 | + public javax.media.opengl.GL GetGL0() |
---|
| 246 | + { |
---|
| 247 | + return null; |
---|
| 248 | + } |
---|
| 249 | + |
---|
| 250 | + public int GenList() |
---|
| 251 | + { |
---|
| 252 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 253 | + return gl.glGenLists(1); |
---|
| 254 | + } |
---|
| 255 | + |
---|
| 256 | + public void NewList(int id) |
---|
| 257 | + { |
---|
| 258 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 259 | + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 260 | + } |
---|
| 261 | + |
---|
| 262 | + public void CallList(int id) |
---|
| 263 | + { |
---|
| 264 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 265 | + gl.glCallList(id); |
---|
| 266 | + } |
---|
| 267 | + |
---|
| 268 | + public void EndList() |
---|
| 269 | + { |
---|
| 270 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 271 | + gl.glEndList(); |
---|
| 272 | + } |
---|
| 273 | + |
---|
| 274 | + public boolean IsBoxMode() |
---|
| 275 | + { |
---|
| 276 | + return BOXMODE; |
---|
| 277 | + } |
---|
| 278 | + |
---|
| 279 | + public boolean IsZoomBoxMode() |
---|
| 280 | + { |
---|
| 281 | + return ZOOMBOXMODE; |
---|
| 282 | + } |
---|
| 283 | + |
---|
| 284 | + public void ClearDepth() |
---|
182 | 285 | { |
---|
183 | 286 | GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT); |
---|
184 | 287 | } |
---|
185 | 288 | |
---|
186 | | - void DepthTest(boolean depthtest) |
---|
| 289 | + public void DepthTest(boolean depthtest) |
---|
187 | 290 | { |
---|
188 | 291 | if (depthtest) |
---|
189 | 292 | GetGL().glDepthFunc(GL.GL_LEQUAL); |
---|
.. | .. |
---|
191 | 294 | GetGL().glDepthFunc(GL.GL_ALWAYS); |
---|
192 | 295 | } |
---|
193 | 296 | |
---|
194 | | - void DepthWrite(boolean depthwrite) |
---|
| 297 | + public void DepthWrite(boolean depthwrite) |
---|
195 | 298 | { |
---|
196 | 299 | if (depthwrite) |
---|
197 | 300 | GetGL().glDepthMask(true); |
---|
.. | .. |
---|
199 | 302 | GetGL().glDepthMask(false); |
---|
200 | 303 | } |
---|
201 | 304 | |
---|
202 | | - void BackFaceCull(boolean bfc) |
---|
| 305 | + public void BackFaceCull(boolean bfc) |
---|
203 | 306 | { |
---|
204 | 307 | if (bfc) |
---|
205 | 308 | GetGL().glEnable(GetGL().GL_CULL_FACE); |
---|
206 | 309 | else |
---|
207 | 310 | GetGL().glDisable(GetGL().GL_CULL_FACE); |
---|
| 311 | + } |
---|
| 312 | + |
---|
| 313 | + public boolean BackFaceCullMode() |
---|
| 314 | + { |
---|
| 315 | + return this.CULLFACE; |
---|
| 316 | + } |
---|
| 317 | + |
---|
| 318 | + public boolean IsAmbientOcclusionOn() |
---|
| 319 | + { |
---|
| 320 | + return this.ambientOcclusion; |
---|
| 321 | + } |
---|
| 322 | + |
---|
| 323 | + public boolean IsDebugSelection() |
---|
| 324 | + { |
---|
| 325 | + return DEBUG_SELECTION; |
---|
| 326 | + } |
---|
| 327 | + |
---|
| 328 | + public boolean IsFrozen() |
---|
| 329 | + { |
---|
| 330 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
| 331 | + |
---|
| 332 | + return !selectmode && cameracount == 0; // != 0; |
---|
| 333 | + } |
---|
| 334 | + |
---|
| 335 | + // Currently in Globals |
---|
| 336 | + public int DrawMode() |
---|
| 337 | + { |
---|
| 338 | + return Globals.DrawMode(); |
---|
| 339 | + } |
---|
| 340 | + |
---|
| 341 | + public Camera EyeCamera() |
---|
| 342 | + { |
---|
| 343 | + return eyeCamera; |
---|
| 344 | + } |
---|
| 345 | + |
---|
| 346 | + public Camera LightCamera() |
---|
| 347 | + { |
---|
| 348 | + return lightCamera; |
---|
| 349 | + } |
---|
| 350 | + |
---|
| 351 | + public Camera ManipCamera() |
---|
| 352 | + { |
---|
| 353 | + return manipCamera; |
---|
| 354 | + } |
---|
| 355 | + |
---|
| 356 | + public Camera RenderCamera() |
---|
| 357 | + { |
---|
| 358 | + return renderCamera; |
---|
| 359 | + } |
---|
| 360 | + |
---|
| 361 | + public Camera[] Cameras() |
---|
| 362 | + { |
---|
| 363 | + return cameras; |
---|
| 364 | + } |
---|
| 365 | + |
---|
| 366 | + public void PushMaterial(Object3D obj, boolean selected) |
---|
| 367 | + { |
---|
| 368 | + CameraPane display = this; |
---|
| 369 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 370 | + cMaterial material = obj.material; |
---|
| 371 | + |
---|
| 372 | + if (material != null) |
---|
| 373 | + { |
---|
| 374 | + materialstack[materialdepth] = material; |
---|
| 375 | + selectedstack[materialdepth] = selected; |
---|
| 376 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 377 | + //System.out.println("material " + material); |
---|
| 378 | + //Applet3D.tracein(this, selected); |
---|
| 379 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 380 | + if (obj instanceof Camera) |
---|
| 381 | + { |
---|
| 382 | + display.options1[0] = material.shift; |
---|
| 383 | + //System.out.println("shift " + material.shift); |
---|
| 384 | + display.options1[1] = material.lightarea; |
---|
| 385 | + display.options1[2] = material.shadowbias; |
---|
| 386 | + display.options1[3] = material.aniso; |
---|
| 387 | + display.options1[4] = material.anisoV; |
---|
| 388 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 389 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 390 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 391 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 392 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
| 393 | + display.options2[0] = material.opacity; |
---|
| 394 | + display.options2[1] = material.diffuse; |
---|
| 395 | + display.options2[2] = material.factor; |
---|
| 396 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 397 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 398 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
| 399 | + |
---|
| 400 | + cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 401 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 402 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 403 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
| 404 | + display.options4[0] = material.cameralight/0.2f; |
---|
| 405 | + display.options4[1] = material.subsurface; |
---|
| 406 | + display.options4[2] = material.sheen; |
---|
| 407 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 408 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 409 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
| 410 | + |
---|
| 411 | + // if (display.CURRENTANTIALIAS > 0) |
---|
| 412 | + // display.options3[3] /= 4; |
---|
| 413 | + |
---|
| 414 | + /* |
---|
| 415 | + System.out.println("Focus = " + display.options1[0]); |
---|
| 416 | + System.out.println("Aperture = " + display.options1[1]); |
---|
| 417 | + System.out.println("ShadowBlur = " + display.options1[2]); |
---|
| 418 | + System.out.println("Antialiasing = " + display.options1[3]); |
---|
| 419 | + System.out.println("Fog = " + display.options2[0]); |
---|
| 420 | + System.out.println("Intensity = " + display.options2[1]); |
---|
| 421 | + System.out.println("Elevation = " + display.options2[2]); |
---|
| 422 | + /**/ |
---|
| 423 | + } else |
---|
| 424 | + { |
---|
| 425 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
| 426 | + } |
---|
| 427 | + } else |
---|
| 428 | + { |
---|
| 429 | + if (selected && CameraPane.flash) |
---|
| 430 | + { |
---|
| 431 | + display.modelParams4[1] = 100; |
---|
| 432 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 433 | + } |
---|
| 434 | + } |
---|
| 435 | + } |
---|
| 436 | + |
---|
| 437 | + public void PushMaterial2(Object3D obj, boolean selected) |
---|
| 438 | + { |
---|
| 439 | + CameraPane display = this; |
---|
| 440 | + cMaterial material = obj.material; |
---|
| 441 | + |
---|
| 442 | + if (material != null) |
---|
| 443 | + { |
---|
| 444 | + materialstack[materialdepth] = material; |
---|
| 445 | + selectedstack[materialdepth] = selected; |
---|
| 446 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 447 | + //System.out.println("material " + material); |
---|
| 448 | + //Applet3D.tracein("selected ", selected); |
---|
| 449 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 450 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
| 451 | + } |
---|
| 452 | + } |
---|
| 453 | + |
---|
| 454 | + public void PopMaterial(Object3D obj, boolean selected) |
---|
| 455 | + { |
---|
| 456 | + CameraPane display = this; |
---|
| 457 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 458 | + cMaterial material = obj.material; |
---|
| 459 | + |
---|
| 460 | + //if (parent != null && parent.GetMaterial() != null) |
---|
| 461 | + // parent.GetMaterial().Draw(display, parent.IsSelected(this)); |
---|
| 462 | + if (material != null) |
---|
| 463 | + { |
---|
| 464 | + materialdepth -= 1; |
---|
| 465 | + if (materialdepth > 0) |
---|
| 466 | + { |
---|
| 467 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 468 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
| 469 | + } |
---|
| 470 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 471 | + } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
| 472 | + { |
---|
| 473 | + display.modelParams4[1] = obj.GetMaterial().cameralight; |
---|
| 474 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 475 | + } |
---|
| 476 | + } |
---|
| 477 | + |
---|
| 478 | + public void PopMaterial2(Object3D obj) |
---|
| 479 | + { |
---|
| 480 | + CameraPane display = this; |
---|
| 481 | + cMaterial material = obj.material; |
---|
| 482 | + |
---|
| 483 | + if (material != null) |
---|
| 484 | + { |
---|
| 485 | + materialdepth -= 1; |
---|
| 486 | + if (materialdepth > 0) |
---|
| 487 | + { |
---|
| 488 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 489 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
| 490 | + } |
---|
| 491 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 492 | + //else |
---|
| 493 | + //material.Draw(display, false); |
---|
| 494 | + } |
---|
| 495 | + } |
---|
| 496 | + |
---|
| 497 | + public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face) |
---|
| 498 | + { |
---|
| 499 | + CameraPane display = this; |
---|
| 500 | + |
---|
| 501 | + if (pv.y == -10000 || |
---|
| 502 | + qv.y == -10000 || |
---|
| 503 | + rv.y == -10000) |
---|
| 504 | + return; |
---|
| 505 | + |
---|
| 506 | +// float b = f.nbiterations & 1; |
---|
| 507 | +// float g = (f.nbiterations>>1) & 1; |
---|
| 508 | +// float r = (f.nbiterations>>2) & 1; |
---|
| 509 | +// |
---|
| 510 | +// //if (f.weight == 10000) |
---|
| 511 | +// //{ |
---|
| 512 | +// // r = 1; g = b = 0; |
---|
| 513 | +// //} |
---|
| 514 | +// //else |
---|
| 515 | +// //{ |
---|
| 516 | +// // assert(f.weight < 10000); |
---|
| 517 | +// r = g = b = (float)bRep.FaceWeight(f)*100; |
---|
| 518 | +// if (r<0) |
---|
| 519 | +// assert(r>=0); |
---|
| 520 | +// //} |
---|
| 521 | + |
---|
| 522 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 523 | + |
---|
| 524 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
| 525 | + |
---|
| 526 | + //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
| 527 | + if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
| 528 | + { |
---|
| 529 | + //gl.glBegin(gl.GL_TRIANGLES); |
---|
| 530 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 531 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 532 | + ; |
---|
| 533 | + if (!hasnorm) |
---|
| 534 | + { |
---|
| 535 | + // System.out.println("Mesh normal"); |
---|
| 536 | + LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
| 537 | + LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
| 538 | + LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
| 539 | + LA.vecNormalize(obj.v2); |
---|
| 540 | + gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 541 | + } |
---|
| 542 | + |
---|
| 543 | + // P |
---|
| 544 | + float x = (float)pv.x; |
---|
| 545 | + float y = (float)pv.y; |
---|
| 546 | + float z = (float)pv.z; |
---|
| 547 | + |
---|
| 548 | + if (hasnorm) |
---|
| 549 | + { |
---|
| 550 | +// if (!pv.norm.normalized()) |
---|
| 551 | +// assert(pv.norm.normalized()); |
---|
| 552 | + |
---|
| 553 | + //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z); |
---|
| 554 | + float nx = (float)pv.norm.x; |
---|
| 555 | + float ny = (float)pv.norm.y; |
---|
| 556 | + float nz = (float)pv.norm.z; |
---|
| 557 | + |
---|
| 558 | + x += nx * obj.NORMALPUSH; |
---|
| 559 | + y += ny * obj.NORMALPUSH; |
---|
| 560 | + z += nz * obj.NORMALPUSH; |
---|
| 561 | + |
---|
| 562 | + gl.glNormal3f(nx, ny, nz); |
---|
| 563 | + } |
---|
| 564 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 565 | + SetColor(obj, pv); |
---|
| 566 | + //gl.glColor4f(r, g, b, 1); |
---|
| 567 | + //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1); |
---|
| 568 | + if (obj.flipV) |
---|
| 569 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 570 | + else |
---|
| 571 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 572 | + //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z); |
---|
| 573 | + |
---|
| 574 | + gl.glVertex3f(x, y, z); |
---|
| 575 | + |
---|
| 576 | + // Q |
---|
| 577 | + x = (float)qv.x; |
---|
| 578 | + y = (float)qv.y; |
---|
| 579 | + z = (float)qv.z; |
---|
| 580 | + |
---|
| 581 | +// Print(pv); |
---|
| 582 | + if (hasnorm) |
---|
| 583 | + { |
---|
| 584 | +// assert(qv.norm.normalized()); |
---|
| 585 | + //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z); |
---|
| 586 | + float nx = (float)qv.norm.x; |
---|
| 587 | + float ny = (float)qv.norm.y; |
---|
| 588 | + float nz = (float)qv.norm.z; |
---|
| 589 | + |
---|
| 590 | + x += nx * obj.NORMALPUSH; |
---|
| 591 | + y += ny * obj.NORMALPUSH; |
---|
| 592 | + z += nz * obj.NORMALPUSH; |
---|
| 593 | + |
---|
| 594 | + gl.glNormal3f(nx, ny, nz); |
---|
| 595 | + } |
---|
| 596 | + //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
| 597 | + // boolean locked = false; |
---|
| 598 | + // float eps = 0.1f; |
---|
| 599 | + // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 600 | + |
---|
| 601 | + // int dot = 0; //*/ (int)f.dot; |
---|
| 602 | + |
---|
| 603 | + // if ((dot&1) == 0) |
---|
| 604 | + // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 605 | + |
---|
| 606 | + // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 607 | + if (obj.flipV) |
---|
| 608 | + gl.glTexCoord2f((float) qv.s, 1-(float) qv.t); |
---|
| 609 | + else |
---|
| 610 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 611 | + // else |
---|
| 612 | + // { |
---|
| 613 | + // locked = true; |
---|
| 614 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 615 | + // } |
---|
| 616 | + gl.glColor4f(qv.AO, qv.AO, qv.AO, 1); |
---|
| 617 | + SetColor(obj, qv); |
---|
| 618 | + |
---|
| 619 | + gl.glVertex3f(x, y, z); |
---|
| 620 | + //gl.glColor4f(r, g, b, 1); |
---|
| 621 | + //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1); |
---|
| 622 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 623 | +// Print(qv); |
---|
| 624 | + |
---|
| 625 | + // R |
---|
| 626 | + x = (float)rv.x; |
---|
| 627 | + y = (float)rv.y; |
---|
| 628 | + z = (float)rv.z; |
---|
| 629 | + |
---|
| 630 | + if (hasnorm) |
---|
| 631 | + { |
---|
| 632 | +// assert(rv.norm.normalized()); |
---|
| 633 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 634 | + float nx = (float)rv.norm.x; |
---|
| 635 | + float ny = (float)rv.norm.y; |
---|
| 636 | + float nz = (float)rv.norm.z; |
---|
| 637 | + |
---|
| 638 | + x += nx * obj.NORMALPUSH; |
---|
| 639 | + y += ny * obj.NORMALPUSH; |
---|
| 640 | + z += nz * obj.NORMALPUSH; |
---|
| 641 | + |
---|
| 642 | + gl.glNormal3f(nx, ny, nz); |
---|
| 643 | + } |
---|
| 644 | + |
---|
| 645 | + // if ((dot&4) == 0) |
---|
| 646 | + // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 647 | + |
---|
| 648 | + // if (wrap || !locked && (dot&8) != 0) |
---|
| 649 | + if (obj.flipV) |
---|
| 650 | + gl.glTexCoord2f((float) rv.s, 1-(float) rv.t); |
---|
| 651 | + else |
---|
| 652 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 653 | + // else |
---|
| 654 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 655 | + |
---|
| 656 | + // f.dot = dot; |
---|
| 657 | + |
---|
| 658 | + gl.glColor4f(rv.AO, rv.AO, rv.AO, 1); |
---|
| 659 | + SetColor(obj, rv); |
---|
| 660 | + //gl.glColor4f(r, g, b, 1); |
---|
| 661 | + //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1); |
---|
| 662 | + //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z); |
---|
| 663 | + gl.glVertex3f(x, y, z); |
---|
| 664 | +// Print(rv); |
---|
| 665 | + //gl.glEnd(); |
---|
| 666 | + } |
---|
| 667 | + else |
---|
| 668 | + { |
---|
| 669 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 670 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 671 | + gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z); |
---|
| 672 | + |
---|
| 673 | + } |
---|
| 674 | + |
---|
| 675 | + if (false) // (attributes & WIREFRAME) != 0) |
---|
| 676 | + { |
---|
| 677 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 678 | + |
---|
| 679 | + gl.glBegin(gl.GL_LINE_LOOP); |
---|
| 680 | + gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z); |
---|
| 681 | + gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z); |
---|
| 682 | + gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z); |
---|
| 683 | + gl.glEnd(); |
---|
| 684 | + |
---|
| 685 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 686 | + } |
---|
| 687 | + } |
---|
| 688 | + |
---|
| 689 | + /** |
---|
| 690 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 691 | + * it's normals, colors, textures and vertices. |
---|
| 692 | + * |
---|
| 693 | + * @see Renderer#draw(TriMesh) |
---|
| 694 | + * @param tris |
---|
| 695 | + * the mesh to render. |
---|
| 696 | + */ |
---|
| 697 | + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 698 | + { |
---|
| 699 | + CameraPane display = this; |
---|
| 700 | + |
---|
| 701 | + float r = display.modelParams0[0]; |
---|
| 702 | + float g = display.modelParams0[1]; |
---|
| 703 | + float b = display.modelParams0[2]; |
---|
| 704 | + float opacity = display.modelParams5[1]; |
---|
| 705 | + |
---|
| 706 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 707 | + GL gl = display.GetGL(); // getGL(); |
---|
| 708 | + |
---|
| 709 | + FloatBuffer vertBuf = geo.vertBuf; |
---|
| 710 | + |
---|
| 711 | + int v = vertBuf.capacity(); |
---|
| 712 | + |
---|
| 713 | + int count = 0; |
---|
| 714 | + |
---|
| 715 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 716 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 717 | + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
| 718 | + for (int i=0; i<v/3; i++) |
---|
| 719 | + { |
---|
| 720 | + int index3 = i*3; |
---|
| 721 | + |
---|
| 722 | + if (geo.sizeBuf.get(index3+1) == 0) |
---|
| 723 | + continue; |
---|
| 724 | + |
---|
| 725 | + count++; |
---|
| 726 | + |
---|
| 727 | + int index4 = i*4; |
---|
| 728 | + |
---|
| 729 | + float tx = vertBuf.get(index3); |
---|
| 730 | + float ty = vertBuf.get(index3+1); |
---|
| 731 | + float tz = vertBuf.get(index3+2); |
---|
| 732 | + |
---|
| 733 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 734 | + // continue; |
---|
| 735 | + |
---|
| 736 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 737 | + gl.glPushMatrix(); |
---|
| 738 | + |
---|
| 739 | + float[] texmat = geo.texmat; |
---|
| 740 | + texmat[12] = texmat[13] = texmat[14] = i; |
---|
| 741 | + |
---|
| 742 | + gl.glMultMatrixf(texmat, 0); |
---|
| 743 | + |
---|
| 744 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 745 | + gl.glPushMatrix(); |
---|
| 746 | + |
---|
| 747 | + gl.glTranslatef(tx,ty,tz); |
---|
| 748 | + |
---|
| 749 | + if (rotate) |
---|
| 750 | + gl.glRotatef(i, 0, 1, 0); |
---|
| 751 | + |
---|
| 752 | + float size = geo.sizeBuf.get(index3) / 100; |
---|
| 753 | + gl.glScalef(size,size,size); |
---|
| 754 | + |
---|
| 755 | + float cr = geo.colorBuf.get(index4); |
---|
| 756 | + float cg = geo.colorBuf.get(index4+1); |
---|
| 757 | + float cb = geo.colorBuf.get(index4+2); |
---|
| 758 | + float ca = geo.colorBuf.get(index4+3); |
---|
| 759 | + |
---|
| 760 | + display.modelParams0[0] = r * cr; |
---|
| 761 | + display.modelParams0[1] = g * cg; |
---|
| 762 | + display.modelParams0[2] = b * cb; |
---|
| 763 | + |
---|
| 764 | + display.modelParams5[1] = opacity * ca; |
---|
| 765 | + |
---|
| 766 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 767 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 768 | + |
---|
| 769 | + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; |
---|
| 770 | + RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 771 | + |
---|
| 772 | +// gl.glColor4f(cr,cg,cb,ca); |
---|
| 773 | + // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 774 | + shape.Draw/*Node*/(display,null,selected,false); // blocked |
---|
| 775 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 776 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 777 | + gl.glPopMatrix(); |
---|
| 778 | + |
---|
| 779 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 780 | + gl.glPopMatrix(); |
---|
| 781 | + } |
---|
| 782 | + // gl.glScalef(1024,1024,1024); |
---|
| 783 | + if (!cf) |
---|
| 784 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 785 | + |
---|
| 786 | + display.modelParams0[0] = r; |
---|
| 787 | + display.modelParams0[1] = g; |
---|
| 788 | + display.modelParams0[2] = b; |
---|
| 789 | + |
---|
| 790 | + display.modelParams5[1] = opacity; |
---|
| 791 | + |
---|
| 792 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 793 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 794 | + |
---|
| 795 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 796 | + |
---|
| 797 | +// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
| 798 | + if (true) |
---|
| 799 | + return; |
---|
| 800 | + |
---|
| 801 | +//// if (!tris.predraw(this)) |
---|
| 802 | +//// { |
---|
| 803 | +//// return; |
---|
| 804 | +//// } |
---|
| 805 | +//// if (Debug.stats) |
---|
| 806 | +//// { |
---|
| 807 | +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
| 808 | +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
| 809 | +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
| 810 | +//// } |
---|
| 811 | +//// |
---|
| 812 | +//// if (tris.getDisplayListID() != -1) |
---|
| 813 | +//// { |
---|
| 814 | +//// renderDisplayList(tris); |
---|
| 815 | +//// return; |
---|
| 816 | +//// } |
---|
| 817 | +//// |
---|
| 818 | +//// if (!generatingDisplayList) |
---|
| 819 | +//// { |
---|
| 820 | +//// applyStates(tris.states, tris); |
---|
| 821 | +//// } |
---|
| 822 | +//// if (Debug.stats) |
---|
| 823 | +//// { |
---|
| 824 | +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
| 825 | +//// } |
---|
| 826 | +//// boolean transformed = doTransforms(tris); |
---|
| 827 | +// |
---|
| 828 | +// int glMode = GL.GL_TRIANGLES; |
---|
| 829 | +// switch (getMode()) |
---|
| 830 | +// { |
---|
| 831 | +// case Triangles: |
---|
| 832 | +// glMode = GL.GL_TRIANGLES; |
---|
| 833 | +// break; |
---|
| 834 | +// case Strip: |
---|
| 835 | +// glMode = GL.GL_TRIANGLE_STRIP; |
---|
| 836 | +// break; |
---|
| 837 | +// case Fan: |
---|
| 838 | +// glMode = GL.GL_TRIANGLE_FAN; |
---|
| 839 | +// break; |
---|
| 840 | +// } |
---|
| 841 | +// |
---|
| 842 | +// if (!predrawGeometry(gl)) |
---|
| 843 | +// { |
---|
| 844 | +// // make sure only the necessary indices are sent through on old |
---|
| 845 | +// // cards. |
---|
| 846 | +// IntBuffer indices = this.getIndexBuffer(); |
---|
| 847 | +// if (indices == null) |
---|
| 848 | +// { |
---|
| 849 | +// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
| 850 | +// } else |
---|
| 851 | +// { |
---|
| 852 | +// indices.rewind(); |
---|
| 853 | +// indices.limit(this.getMaxIndex()); |
---|
| 854 | +// |
---|
| 855 | +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
| 856 | +// |
---|
| 857 | +// indices.clear(); |
---|
| 858 | +// } |
---|
| 859 | +// } else |
---|
| 860 | +// { |
---|
| 861 | +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
| 862 | +// GL.GL_UNSIGNED_INT, 0); |
---|
| 863 | +// } |
---|
| 864 | +// |
---|
| 865 | +//// postdrawGeometry(tris); |
---|
| 866 | +//// if (transformed) |
---|
| 867 | +//// { |
---|
| 868 | +//// undoTransforms(tris); |
---|
| 869 | +//// } |
---|
| 870 | +//// |
---|
| 871 | +//// if (Debug.stats) |
---|
| 872 | +//// { |
---|
| 873 | +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
| 874 | +//// } |
---|
| 875 | +//// tris.postdraw(this); |
---|
| 876 | + } |
---|
| 877 | + |
---|
| 878 | + static Camera localcamera = new Camera(); |
---|
| 879 | + static cVector from = new cVector(); |
---|
| 880 | + static cVector to = new cVector(); |
---|
| 881 | + |
---|
| 882 | + public void PrepOcclusion(BoundaryRep br, double[][] transform) |
---|
| 883 | + { |
---|
| 884 | + CameraPane cp = this; |
---|
| 885 | + |
---|
| 886 | + Camera keep = cp.RenderCamera(); |
---|
| 887 | + cp.renderCamera = localcamera; |
---|
| 888 | + |
---|
| 889 | + if (br.trimmed) |
---|
| 890 | + { |
---|
| 891 | + float[] colors = new float[br.positions.length / 3]; |
---|
| 892 | + |
---|
| 893 | + int i3 = 0; |
---|
| 894 | + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) |
---|
| 895 | + { |
---|
| 896 | + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) |
---|
| 897 | + continue; |
---|
| 898 | + |
---|
| 899 | + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); |
---|
| 900 | + to.set(br.positions[i3] + br.normals[i3], |
---|
| 901 | + br.positions[i3 + 1] + br.normals[i3 + 1], |
---|
| 902 | + br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
| 903 | + LA.xformPos(from, transform, from); |
---|
| 904 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 905 | + localcamera.setAim(from, to); |
---|
| 906 | + |
---|
| 907 | + CameraPane.occlusionbuffer.display(); |
---|
| 908 | + |
---|
| 909 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 910 | + cp.display(); // debug |
---|
| 911 | + |
---|
| 912 | + colors[i] = cp.vertexOcclusion.r; |
---|
| 913 | + //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
| 914 | + //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
| 915 | + |
---|
| 916 | + if ((i % 100) == 0 && i != 0) |
---|
| 917 | + { |
---|
| 918 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 919 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 920 | + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); |
---|
| 921 | + } |
---|
| 922 | + } |
---|
| 923 | + |
---|
| 924 | + br.colors = colors; |
---|
| 925 | + } |
---|
| 926 | + else |
---|
| 927 | + { |
---|
| 928 | + for (int i = 0; i < br.VertexCount(); i++) |
---|
| 929 | + { |
---|
| 930 | + Vertex v = br.GetVertex(i); |
---|
| 931 | + |
---|
| 932 | + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
| 933 | + continue; |
---|
| 934 | + |
---|
| 935 | + from.set(v.x, v.y, v.z); |
---|
| 936 | + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
| 937 | + LA.xformPos(from, transform, from); |
---|
| 938 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 939 | + localcamera.setAim(from, to); |
---|
| 940 | + |
---|
| 941 | + CameraPane.occlusionbuffer.display(); |
---|
| 942 | + |
---|
| 943 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 944 | + cp.display(); // debug |
---|
| 945 | + |
---|
| 946 | + v.AO = cp.vertexOcclusion.r; |
---|
| 947 | + |
---|
| 948 | + if ((i % 100) == 0 && i != 0) |
---|
| 949 | + { |
---|
| 950 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 951 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 952 | + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); |
---|
| 953 | + } |
---|
| 954 | + } |
---|
| 955 | + } |
---|
| 956 | + |
---|
| 957 | + //System.out.println("done."); |
---|
| 958 | + |
---|
| 959 | + cp.renderCamera = keep; |
---|
| 960 | + } |
---|
| 961 | + |
---|
| 962 | + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 963 | + { |
---|
| 964 | + CameraPane display = this; |
---|
| 965 | + pointFlow.CreateHT(); |
---|
| 966 | + |
---|
| 967 | + float r = display.modelParams0[0]; |
---|
| 968 | + float g = display.modelParams0[1]; |
---|
| 969 | + float b = display.modelParams0[2]; |
---|
| 970 | + float opacity = display.modelParams5[1]; |
---|
| 971 | + |
---|
| 972 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 973 | + GL gl = display.GetGL(); // getGL(); |
---|
| 974 | + |
---|
| 975 | + int s = pointFlow.points.size(); |
---|
| 976 | + |
---|
| 977 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 978 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 979 | + |
---|
| 980 | + for (int i=s; --i>=0;) |
---|
| 981 | + //for (int i=0; i<s; i++) |
---|
| 982 | + { |
---|
| 983 | + cVector v = pointFlow.points.get(i); |
---|
| 984 | + |
---|
| 985 | + double mindist = Double.MAX_VALUE; |
---|
| 986 | + |
---|
| 987 | + double size = pointFlow.minimumSize; |
---|
| 988 | + |
---|
| 989 | + double distancenext = 0; |
---|
| 990 | + |
---|
| 991 | + if (i > 0) |
---|
| 992 | + { |
---|
| 993 | + cVector w = pointFlow.points.get(i-1); |
---|
| 994 | + |
---|
| 995 | + double dist = w.distance(v); |
---|
| 996 | + |
---|
| 997 | + distancenext = dist; |
---|
| 998 | + |
---|
| 999 | + if (mindist > dist) |
---|
| 1000 | + { |
---|
| 1001 | + mindist = dist; |
---|
| 1002 | + size = mindist*pointFlow.resizefactor; |
---|
| 1003 | + } |
---|
| 1004 | + } |
---|
| 1005 | + |
---|
| 1006 | + if (i < s-1) |
---|
| 1007 | + { |
---|
| 1008 | + cVector w = pointFlow.points.get(i+1); |
---|
| 1009 | + |
---|
| 1010 | + double dist = w.distance(v); |
---|
| 1011 | + |
---|
| 1012 | + if (mindist > dist) |
---|
| 1013 | + { |
---|
| 1014 | + mindist = dist; |
---|
| 1015 | + size = mindist*pointFlow.resizefactor; |
---|
| 1016 | + } |
---|
| 1017 | + } |
---|
| 1018 | + |
---|
| 1019 | + if (size < pointFlow.minimumSize) |
---|
| 1020 | + size = pointFlow.minimumSize; |
---|
| 1021 | + if (size > pointFlow.maximumSize) |
---|
| 1022 | + size = pointFlow.maximumSize; |
---|
| 1023 | + |
---|
| 1024 | + double tx = v.x; |
---|
| 1025 | + double ty = v.y; |
---|
| 1026 | + double tz = v.z; |
---|
| 1027 | + |
---|
| 1028 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 1029 | + // continue; |
---|
| 1030 | + |
---|
| 1031 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1032 | + gl.glPushMatrix(); |
---|
| 1033 | + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; |
---|
| 1034 | + |
---|
| 1035 | + gl.glMultMatrixf(pointFlow.texmat, 0); |
---|
| 1036 | + |
---|
| 1037 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1038 | + gl.glPushMatrix(); |
---|
| 1039 | + |
---|
| 1040 | + gl.glTranslated(tx,ty,tz); |
---|
| 1041 | + |
---|
| 1042 | + gl.glScaled(size,size,size); |
---|
| 1043 | + |
---|
| 1044 | +// float cr = colorBuf.get(index4); |
---|
| 1045 | +// float cg = colorBuf.get(index4+1); |
---|
| 1046 | +// float cb = colorBuf.get(index4+2); |
---|
| 1047 | +// float ca = colorBuf.get(index4+3); |
---|
| 1048 | +// |
---|
| 1049 | +// display.modelParams0[0] = r * cr; |
---|
| 1050 | +// display.modelParams0[1] = g * cg; |
---|
| 1051 | +// display.modelParams0[2] = b * cb; |
---|
| 1052 | +// |
---|
| 1053 | +// display.modelParams5[1] = opacity * ca; |
---|
| 1054 | +// |
---|
| 1055 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1056 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1057 | +// |
---|
| 1058 | +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
| 1059 | +// RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 1060 | +// |
---|
| 1061 | +//// gl.glColor4f(cr,cg,cb,ca); |
---|
| 1062 | +// // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 1063 | + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); |
---|
| 1064 | + |
---|
| 1065 | + gl.glPopMatrix(); |
---|
| 1066 | + |
---|
| 1067 | + double step = size/4; // |
---|
| 1068 | + |
---|
| 1069 | + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) |
---|
| 1070 | + continue; |
---|
| 1071 | + |
---|
| 1072 | + int nbsteps = (int)(distancenext/step); |
---|
| 1073 | + |
---|
| 1074 | + step = distancenext/nbsteps; |
---|
| 1075 | + |
---|
| 1076 | + cVector next = pointFlow.points.get(i-1); |
---|
| 1077 | + |
---|
| 1078 | + tmp.set(next); |
---|
| 1079 | + tmp.sub(v); |
---|
| 1080 | + tmp.normalize(); |
---|
| 1081 | + tmp.mul(step); |
---|
| 1082 | + |
---|
| 1083 | + // calculate next size |
---|
| 1084 | + mindist = Double.MAX_VALUE; |
---|
| 1085 | + |
---|
| 1086 | + double nextsize = pointFlow.minimumSize; |
---|
| 1087 | + |
---|
| 1088 | + if (i > 1) |
---|
| 1089 | + { |
---|
| 1090 | + cVector w = pointFlow.points.get(i-2); |
---|
| 1091 | + |
---|
| 1092 | + double dist = w.distance(next); |
---|
| 1093 | + |
---|
| 1094 | + if (mindist > dist) |
---|
| 1095 | + { |
---|
| 1096 | + mindist = dist; |
---|
| 1097 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1098 | + } |
---|
| 1099 | + } |
---|
| 1100 | + |
---|
| 1101 | + double dist = v.distance(next); |
---|
| 1102 | + |
---|
| 1103 | + if (mindist > dist) |
---|
| 1104 | + { |
---|
| 1105 | + mindist = dist; |
---|
| 1106 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1107 | + } |
---|
| 1108 | + |
---|
| 1109 | + if (nextsize < pointFlow.minimumSize) |
---|
| 1110 | + nextsize = pointFlow.minimumSize; |
---|
| 1111 | + if (nextsize > pointFlow.maximumSize) |
---|
| 1112 | + nextsize = pointFlow.maximumSize; |
---|
| 1113 | + // |
---|
| 1114 | + |
---|
| 1115 | + double count = 0; |
---|
| 1116 | + |
---|
| 1117 | + while (distancenext > 0.000000001) // step |
---|
| 1118 | + { |
---|
| 1119 | + gl.glPushMatrix(); |
---|
| 1120 | + |
---|
| 1121 | + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); |
---|
| 1122 | + |
---|
| 1123 | + double K = count/nbsteps; |
---|
| 1124 | + |
---|
| 1125 | + double intersize = K*nextsize + (1-K)*size; |
---|
| 1126 | + |
---|
| 1127 | + gl.glScaled(intersize,intersize,intersize); |
---|
| 1128 | + |
---|
| 1129 | + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); |
---|
| 1130 | + |
---|
| 1131 | + count++; |
---|
| 1132 | + |
---|
| 1133 | + distancenext -= step; |
---|
| 1134 | + |
---|
| 1135 | + gl.glPopMatrix(); |
---|
| 1136 | + } |
---|
| 1137 | + |
---|
| 1138 | + if (count != nbsteps) |
---|
| 1139 | + assert(count == nbsteps); |
---|
| 1140 | + |
---|
| 1141 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 1142 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 1143 | + |
---|
| 1144 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1145 | + gl.glPopMatrix(); |
---|
| 1146 | + } |
---|
| 1147 | + |
---|
| 1148 | + if (!cf) |
---|
| 1149 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 1150 | + |
---|
| 1151 | +// display.modelParams0[0] = r; |
---|
| 1152 | +// display.modelParams0[1] = g; |
---|
| 1153 | +// display.modelParams0[2] = b; |
---|
| 1154 | +// |
---|
| 1155 | +// display.modelParams5[1] = opacity; |
---|
| 1156 | +// |
---|
| 1157 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1158 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1159 | + |
---|
| 1160 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1161 | + } |
---|
| 1162 | + |
---|
| 1163 | + public void DrawBox(cVector min, cVector max) |
---|
| 1164 | + { |
---|
| 1165 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1166 | + gl.glBegin(gl.GL_LINES); |
---|
| 1167 | + |
---|
| 1168 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1169 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1170 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1171 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1172 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1173 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1174 | + |
---|
| 1175 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1176 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1177 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1178 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1179 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1180 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1181 | + |
---|
| 1182 | + gl.glEnd(); |
---|
| 1183 | + } |
---|
| 1184 | + |
---|
| 1185 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1186 | + { |
---|
| 1187 | + int[] strips = bRep.getRawIndices(); |
---|
| 1188 | + |
---|
| 1189 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1190 | + |
---|
| 1191 | + // TRIANGLE STRIP ARRAY |
---|
| 1192 | + if (bRep.trimmed) |
---|
| 1193 | + { |
---|
| 1194 | + float[] v = bRep.getRawVertices(); |
---|
| 1195 | + float[] n = bRep.getRawNormals(); |
---|
| 1196 | + float[] c = bRep.getRawColors(); |
---|
| 1197 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1198 | + |
---|
| 1199 | + int count2 = 0; |
---|
| 1200 | + int count3 = 0; |
---|
| 1201 | + |
---|
| 1202 | + if (n.length > 0) |
---|
| 1203 | + { |
---|
| 1204 | + for (int i = 0; i < strips.length; i++) |
---|
| 1205 | + { |
---|
| 1206 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1207 | + |
---|
| 1208 | + /* |
---|
| 1209 | + boolean locked = false; |
---|
| 1210 | + float eps = 0.1f; |
---|
| 1211 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1212 | + |
---|
| 1213 | + int dot = 0; |
---|
| 1214 | + |
---|
| 1215 | + if ((dot&1) == 0) |
---|
| 1216 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1217 | + |
---|
| 1218 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1219 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1220 | + else |
---|
| 1221 | + { |
---|
| 1222 | + locked = true; |
---|
| 1223 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1224 | + } |
---|
| 1225 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1226 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1227 | + if (hasnorm) |
---|
| 1228 | + { |
---|
| 1229 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1230 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1231 | + } |
---|
| 1232 | + |
---|
| 1233 | + if ((dot&4) == 0) |
---|
| 1234 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1235 | + |
---|
| 1236 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1237 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1238 | + else |
---|
| 1239 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1240 | + |
---|
| 1241 | + f.dot = dot; |
---|
| 1242 | + */ |
---|
| 1243 | + |
---|
| 1244 | + if (!selectmode) |
---|
| 1245 | + { |
---|
| 1246 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1247 | + { |
---|
| 1248 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1249 | + } else |
---|
| 1250 | + { |
---|
| 1251 | + gl.glNormal3f(0, 0, 1); |
---|
| 1252 | + } |
---|
| 1253 | + |
---|
| 1254 | + if (c != null) |
---|
| 1255 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1256 | + { |
---|
| 1257 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1258 | + } |
---|
| 1259 | + } |
---|
| 1260 | + |
---|
| 1261 | + if (flipV) |
---|
| 1262 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1263 | + else |
---|
| 1264 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1265 | + |
---|
| 1266 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1267 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1268 | + |
---|
| 1269 | + count2 += 2; |
---|
| 1270 | + count3 += 3; |
---|
| 1271 | + if (!selectmode) |
---|
| 1272 | + { |
---|
| 1273 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1274 | + { |
---|
| 1275 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1276 | + } else |
---|
| 1277 | + { |
---|
| 1278 | + gl.glNormal3f(0, 0, 1); |
---|
| 1279 | + } |
---|
| 1280 | + if (c != null) |
---|
| 1281 | + { |
---|
| 1282 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1283 | + } |
---|
| 1284 | + } |
---|
| 1285 | + |
---|
| 1286 | + if (flipV) |
---|
| 1287 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1288 | + else |
---|
| 1289 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1290 | + |
---|
| 1291 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1292 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1293 | + |
---|
| 1294 | + count2 += 2; |
---|
| 1295 | + count3 += 3; |
---|
| 1296 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1297 | + { |
---|
| 1298 | + //gl.glTexCoord2d(...); |
---|
| 1299 | + if (!selectmode) |
---|
| 1300 | + { |
---|
| 1301 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1302 | + { |
---|
| 1303 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1304 | + } else |
---|
| 1305 | + { |
---|
| 1306 | + gl.glNormal3f(0, 0, 1); |
---|
| 1307 | + } |
---|
| 1308 | + if (c != null) |
---|
| 1309 | + { |
---|
| 1310 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1311 | + } |
---|
| 1312 | + } |
---|
| 1313 | + |
---|
| 1314 | + if (flipV) |
---|
| 1315 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1316 | + else |
---|
| 1317 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1318 | + |
---|
| 1319 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1320 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1321 | + |
---|
| 1322 | + count2 += 2; |
---|
| 1323 | + count3 += 3; |
---|
| 1324 | + } |
---|
| 1325 | + |
---|
| 1326 | + gl.glEnd(); |
---|
| 1327 | + } |
---|
| 1328 | + } |
---|
| 1329 | + |
---|
| 1330 | + assert count3 == v.length; |
---|
| 1331 | + } |
---|
| 1332 | + else // !trimmed |
---|
| 1333 | + { |
---|
| 1334 | + int count = 0; |
---|
| 1335 | + for (int i = 0; i < strips.length; i++) |
---|
| 1336 | + { |
---|
| 1337 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1338 | + |
---|
| 1339 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1340 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1341 | + |
---|
| 1342 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1343 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1344 | + |
---|
| 1345 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1346 | + { |
---|
| 1347 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1348 | + |
---|
| 1349 | + // if (j%2 == 0) |
---|
| 1350 | + // drawFace(p, q, r, display, null); |
---|
| 1351 | + // else |
---|
| 1352 | + // drawFace(p, r, q, display, null); |
---|
| 1353 | + |
---|
| 1354 | + // p = q; |
---|
| 1355 | + // q = r; |
---|
| 1356 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1357 | + } |
---|
| 1358 | + |
---|
| 1359 | + gl.glEnd(); |
---|
| 1360 | + } |
---|
| 1361 | + } |
---|
| 1362 | + } |
---|
| 1363 | + |
---|
| 1364 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1365 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1366 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1367 | + |
---|
| 1368 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1369 | + { |
---|
| 1370 | + GL gl = GetGL(); // getGL(); |
---|
| 1371 | + |
---|
| 1372 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1373 | + |
---|
| 1374 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1375 | + |
---|
| 1376 | + gl.glLineWidth(1); |
---|
| 1377 | + gl.glColor3f(1,1,1); |
---|
| 1378 | + gl.glBegin(gl.GL_LINES); |
---|
| 1379 | + double scale = 0; |
---|
| 1380 | + int count = 0; |
---|
| 1381 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1382 | + { |
---|
| 1383 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1384 | + if(s == 0) |
---|
| 1385 | + { |
---|
| 1386 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1387 | + } |
---|
| 1388 | + if (mesh.showsprings) |
---|
| 1389 | + { |
---|
| 1390 | + temp.set(spring.a.position); |
---|
| 1391 | + temp.add(spring.b.position); |
---|
| 1392 | + temp.mul(0.5); |
---|
| 1393 | + temp2.set(spring.a.position); |
---|
| 1394 | + temp2.sub(spring.b.position); |
---|
| 1395 | + temp2.mul(spring.restLength/2); |
---|
| 1396 | + temp.sub(temp2); |
---|
| 1397 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1398 | + temp.add(temp2); |
---|
| 1399 | + temp.add(temp2); |
---|
| 1400 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1401 | + } |
---|
| 1402 | + |
---|
| 1403 | + if (spring.isHandle) |
---|
| 1404 | + continue; |
---|
| 1405 | + |
---|
| 1406 | + //if (scale < spring.restLength) |
---|
| 1407 | + scale += spring.restLength; |
---|
| 1408 | + count++; |
---|
| 1409 | + } |
---|
| 1410 | + gl.glEnd(); |
---|
| 1411 | + |
---|
| 1412 | + if (count == 0) |
---|
| 1413 | + scale = 0.01; |
---|
| 1414 | + else |
---|
| 1415 | + scale /= count * 3; |
---|
| 1416 | + |
---|
| 1417 | + //scale = 0.25; |
---|
| 1418 | + |
---|
| 1419 | + if (mesh.ShowInfo()) |
---|
| 1420 | + { |
---|
| 1421 | + gl.glLineWidth(4); |
---|
| 1422 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1423 | + { |
---|
| 1424 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1425 | + if (node.mass == 0) |
---|
| 1426 | + continue; |
---|
| 1427 | + |
---|
| 1428 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1429 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1430 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1431 | + //temp.normalize(); |
---|
| 1432 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1433 | + gl.glBegin(gl.GL_LINES); |
---|
| 1434 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1435 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1436 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1437 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1438 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1439 | + gl.glEnd(); |
---|
| 1440 | + } |
---|
| 1441 | + |
---|
| 1442 | + gl.glLineWidth(8); |
---|
| 1443 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1444 | + { |
---|
| 1445 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1446 | + |
---|
| 1447 | + if (node.springs != null) |
---|
| 1448 | + { |
---|
| 1449 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1450 | + { |
---|
| 1451 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1452 | + |
---|
| 1453 | + int c = i+1; |
---|
| 1454 | + // c = node.springs.get(i).nbcopies; |
---|
| 1455 | + |
---|
| 1456 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1457 | + gl.glBegin(gl.GL_LINES); |
---|
| 1458 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1459 | + 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); |
---|
| 1460 | + gl.glEnd(); |
---|
| 1461 | + } |
---|
| 1462 | + } |
---|
| 1463 | + } |
---|
| 1464 | + |
---|
| 1465 | + gl.glLineWidth(1); |
---|
| 1466 | + } |
---|
| 1467 | + |
---|
| 1468 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1469 | + } |
---|
| 1470 | + |
---|
| 1471 | + /// INTERFACE |
---|
| 1472 | + |
---|
| 1473 | + public void StartTriangles() |
---|
| 1474 | + { |
---|
| 1475 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1476 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1477 | + } |
---|
| 1478 | + |
---|
| 1479 | + public void EndTriangles() |
---|
| 1480 | + { |
---|
| 1481 | + GetGL().glEnd(); |
---|
| 1482 | + } |
---|
| 1483 | + |
---|
| 1484 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1485 | + { |
---|
| 1486 | + if (!selectmode) |
---|
| 1487 | + { |
---|
| 1488 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1489 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1490 | + |
---|
| 1491 | + if (flipV) |
---|
| 1492 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1493 | + else |
---|
| 1494 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1495 | + } |
---|
| 1496 | + |
---|
| 1497 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1498 | + } |
---|
| 1499 | + |
---|
| 1500 | + float[] colorV = new float[4]; |
---|
| 1501 | + |
---|
| 1502 | + void SetColor(Object3D obj, Vertex p0) |
---|
| 1503 | + { |
---|
| 1504 | + CameraPane display = this; |
---|
| 1505 | + BoundaryRep bRep = obj.bRep; |
---|
| 1506 | + |
---|
| 1507 | + if (RENDERPROGRAM == 0) |
---|
| 1508 | + { |
---|
| 1509 | + float r = 0; |
---|
| 1510 | + if (bRep != null) |
---|
| 1511 | + { |
---|
| 1512 | + if (bRep.stripified) |
---|
| 1513 | + { |
---|
| 1514 | + r = 1; |
---|
| 1515 | + } |
---|
| 1516 | + } |
---|
| 1517 | + float g = 0; |
---|
| 1518 | + if (bRep != null) |
---|
| 1519 | + { |
---|
| 1520 | + if (bRep.trimmed) |
---|
| 1521 | + { |
---|
| 1522 | + g = 1; |
---|
| 1523 | + } |
---|
| 1524 | + } |
---|
| 1525 | + float b = 0; |
---|
| 1526 | + if (obj.support != null && obj.link2master) |
---|
| 1527 | + { |
---|
| 1528 | + b = 1; |
---|
| 1529 | + } |
---|
| 1530 | + display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO); |
---|
| 1531 | + return; |
---|
| 1532 | + } |
---|
| 1533 | + |
---|
| 1534 | + if (display.DrawMode() != CameraPane.SHADOW) |
---|
| 1535 | + return; |
---|
| 1536 | + |
---|
| 1537 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1538 | +// if (true) return; |
---|
| 1539 | +// float ao = p.AO; |
---|
| 1540 | +// |
---|
| 1541 | +// // if (ao == 0 && !bRep.AOdone) // transient problem! |
---|
| 1542 | +// // ao = 1; |
---|
| 1543 | +// |
---|
| 1544 | +// gl.glColor4f(ao, ao, ao, 1); |
---|
| 1545 | + |
---|
| 1546 | +// CameraPane.selectedpoint. |
---|
| 1547 | +// getAverage(cStatic.point1, true); |
---|
| 1548 | + if (CameraPane.pointflow == null) // !random) // live) |
---|
| 1549 | + { |
---|
| 1550 | + return; |
---|
| 1551 | + } |
---|
| 1552 | + |
---|
| 1553 | + cStatic.point1.set(0,0,0); |
---|
| 1554 | + LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1); |
---|
| 1555 | + |
---|
| 1556 | + cStatic.point1.sub(p0); |
---|
| 1557 | + |
---|
| 1558 | + |
---|
| 1559 | +// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta? |
---|
| 1560 | +// { |
---|
| 1561 | +// return; |
---|
| 1562 | +// } |
---|
| 1563 | + |
---|
| 1564 | + //if (true) |
---|
| 1565 | + if (cStatic.point1.dot(cStatic.point1) > 0.000001) |
---|
| 1566 | + { |
---|
| 1567 | + return; |
---|
| 1568 | + } |
---|
| 1569 | + |
---|
| 1570 | + if (false) // marked) |
---|
| 1571 | + { |
---|
| 1572 | + // debug rigging weights |
---|
| 1573 | + for (int object = 0; object < p0.vertexlinks.length; object++) |
---|
| 1574 | + { |
---|
| 1575 | + float weight = p0.weights[object] / p0.totalweight; |
---|
| 1576 | + |
---|
| 1577 | + // if (weight < 0.1) |
---|
| 1578 | + // { |
---|
| 1579 | + // assert(weight == 0); |
---|
| 1580 | + // continue; |
---|
| 1581 | + // } |
---|
| 1582 | + |
---|
| 1583 | + if (p0.vertexlinks[object] == -1) |
---|
| 1584 | + continue; |
---|
| 1585 | + |
---|
| 1586 | + Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]); |
---|
| 1587 | + |
---|
| 1588 | + int color = //1 << object; // |
---|
| 1589 | + //p.vertexlinks.length; |
---|
| 1590 | + obj.support.bRep.supports[p0.closestsupport].links[object]; |
---|
| 1591 | + colorV[2] += (color & 1) * weight; |
---|
| 1592 | + colorV[1] += ((color & 2) >> 1) * weight; |
---|
| 1593 | + colorV[0] += ((color & 4) >> 2) * weight; |
---|
| 1594 | + } |
---|
| 1595 | + } |
---|
| 1596 | + else |
---|
| 1597 | + { |
---|
| 1598 | + if (obj.drawingstarted) |
---|
| 1599 | + { |
---|
| 1600 | + // find next point |
---|
| 1601 | + if (bRep.GetVertex(0).faceindices == null) |
---|
| 1602 | + { |
---|
| 1603 | + bRep.InitFaceIndices(); |
---|
| 1604 | + } |
---|
| 1605 | + |
---|
| 1606 | + double ymin = p0.y; |
---|
| 1607 | + |
---|
| 1608 | + Vertex newp = p0; |
---|
| 1609 | + |
---|
| 1610 | + for (int fii = 0; fii < p0.faceindices.length; fii++) |
---|
| 1611 | + { |
---|
| 1612 | + int fi = p0.faceindices[fii]; |
---|
| 1613 | + |
---|
| 1614 | + if (fi == -1) |
---|
| 1615 | + break; |
---|
| 1616 | + |
---|
| 1617 | + Face f = bRep.GetFace(fi); |
---|
| 1618 | + |
---|
| 1619 | + Vertex p = bRep.GetVertex(f.p); |
---|
| 1620 | + Vertex q = bRep.GetVertex(f.q); |
---|
| 1621 | + Vertex r = bRep.GetVertex(f.r); |
---|
| 1622 | + |
---|
| 1623 | + int swap = (int)(Math.random()*3); |
---|
| 1624 | + |
---|
| 1625 | +// for (int s=swap; --s>=0;) |
---|
| 1626 | +// { |
---|
| 1627 | +// Vertex t = p; |
---|
| 1628 | +// p = q; |
---|
| 1629 | +// q = r; |
---|
| 1630 | +// r = t; |
---|
| 1631 | +// } |
---|
| 1632 | + if (ymin > p.y) |
---|
| 1633 | + { |
---|
| 1634 | + ymin = p.y; |
---|
| 1635 | + newp = p; |
---|
| 1636 | +// break; |
---|
| 1637 | + } |
---|
| 1638 | + if (ymin > q.y) |
---|
| 1639 | + { |
---|
| 1640 | + ymin = q.y; |
---|
| 1641 | + newp = q; |
---|
| 1642 | +// break; |
---|
| 1643 | + } |
---|
| 1644 | + if (ymin > r.y) |
---|
| 1645 | + { |
---|
| 1646 | + ymin = r.y; |
---|
| 1647 | + newp = r; |
---|
| 1648 | +// break; |
---|
| 1649 | + } |
---|
| 1650 | + } |
---|
| 1651 | + |
---|
| 1652 | + CameraPane.selectedpoint.toParent[3][0] = newp.x; |
---|
| 1653 | + CameraPane.selectedpoint.toParent[3][1] = newp.y; |
---|
| 1654 | + CameraPane.selectedpoint.toParent[3][2] = newp.z; |
---|
| 1655 | + |
---|
| 1656 | + obj.drawingstarted = false; |
---|
| 1657 | + |
---|
| 1658 | + // return; |
---|
| 1659 | + } |
---|
| 1660 | + |
---|
| 1661 | + if (false) // CameraPane.DRAW |
---|
| 1662 | + { |
---|
| 1663 | + p0.AO = colorV[0] = 2; |
---|
| 1664 | + colorV[1] = 2; |
---|
| 1665 | + colorV[2] = 2; |
---|
| 1666 | + } |
---|
| 1667 | + |
---|
| 1668 | + CameraPane.pointflow.add(p0); |
---|
| 1669 | + CameraPane.pointflow.Touch(); |
---|
| 1670 | + } |
---|
| 1671 | + |
---|
| 1672 | +// gl.glColor3f(colorV[0], colorV[1], colorV[2]); |
---|
| 1673 | +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1674 | +// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1675 | + } |
---|
| 1676 | + |
---|
| 1677 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
| 1678 | + { |
---|
| 1679 | + CameraPane display = this; |
---|
| 1680 | + //new Exception().printStackTrace(); |
---|
| 1681 | + |
---|
| 1682 | + if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW) |
---|
| 1683 | + { |
---|
| 1684 | + return; |
---|
| 1685 | + } |
---|
| 1686 | + |
---|
| 1687 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1688 | + |
---|
| 1689 | + //Color col = Color.getHSBColor(color,modulation,1); |
---|
| 1690 | + //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
| 1691 | + if (!material.multiply) |
---|
| 1692 | + { |
---|
| 1693 | + display.color = material.color; |
---|
| 1694 | + display.saturation = material.modulation; |
---|
| 1695 | + } |
---|
| 1696 | + else |
---|
| 1697 | + { |
---|
| 1698 | + display.color *= material.color*2; |
---|
| 1699 | + display.saturation *= material.modulation*2; |
---|
| 1700 | + } |
---|
| 1701 | + |
---|
| 1702 | + cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
| 1703 | + |
---|
| 1704 | + float[] colorV = Grafreed.colorV; |
---|
| 1705 | + |
---|
| 1706 | + /**/ |
---|
| 1707 | + if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
| 1708 | + { |
---|
| 1709 | + colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
| 1710 | + colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
| 1711 | + colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
| 1712 | + colorV[3] = 1; // material.opacity; |
---|
| 1713 | + |
---|
| 1714 | + gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
| 1715 | + //System.out.println("Opacity = " + opacity); |
---|
| 1716 | + |
---|
| 1717 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1718 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1719 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1720 | + |
---|
| 1721 | + float amb = material.ambient; |
---|
| 1722 | + if (amb < material.cameralight) |
---|
| 1723 | + { |
---|
| 1724 | + amb = material.cameralight; |
---|
| 1725 | + } |
---|
| 1726 | + colorV[0] = display.modelParams0[0] * material.diffuse * amb; |
---|
| 1727 | + colorV[1] = display.modelParams0[1] * material.diffuse * amb; |
---|
| 1728 | + colorV[2] = display.modelParams0[2] * material.diffuse * amb; |
---|
| 1729 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0); |
---|
| 1730 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1731 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 1732 | + |
---|
| 1733 | + /**/ |
---|
| 1734 | + colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular; |
---|
| 1735 | + colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular; |
---|
| 1736 | + colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular; |
---|
| 1737 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0); |
---|
| 1738 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1739 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0); |
---|
| 1740 | + colorV[0] = 10 / material.shininess; // 1/0.005f; |
---|
| 1741 | + //System.out.println("shininess = " + colorV[0]); |
---|
| 1742 | + if (colorV[0] > 128) |
---|
| 1743 | + { |
---|
| 1744 | + colorV[0] = 128; |
---|
| 1745 | + } |
---|
| 1746 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0); |
---|
| 1747 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0); |
---|
| 1748 | + /**/ |
---|
| 1749 | + } |
---|
| 1750 | + /**/ |
---|
| 1751 | + |
---|
| 1752 | + //selected = false; |
---|
| 1753 | + selected = selected && display.flash; |
---|
| 1754 | + |
---|
| 1755 | + //display.modelParams0[0] = 0; // pigment.r; |
---|
| 1756 | + //display.modelParams0[1] = 0; // pigment.g; |
---|
| 1757 | + //display.modelParams0[2] = 0; // pigment.b; |
---|
| 1758 | + if (!material.multiply) |
---|
| 1759 | + { |
---|
| 1760 | + display.modelParams0[3] = material.metalness; |
---|
| 1761 | + display.modelParams1[0] = material.diffuse; |
---|
| 1762 | + display.modelParams1[1] = material.specular; |
---|
| 1763 | + display.modelParams1[2] = 1 / material.shininess; |
---|
| 1764 | + display.modelParams1[3] = material.shift; |
---|
| 1765 | + display.modelParams2[0] = material.ambient; |
---|
| 1766 | + display.modelParams2[1] = material.lightarea; |
---|
| 1767 | + //System.out.println("light area = " + lightarea); |
---|
| 1768 | + display.modelParams2[2] = 1 / material.factor; // diffuseness |
---|
| 1769 | + display.modelParams2[3] = material.velvet; |
---|
| 1770 | + display.modelParams3[0] = material.sheen; |
---|
| 1771 | + display.modelParams3[1] = material.subsurface; |
---|
| 1772 | + display.modelParams3[2] = material.bump; // backlit |
---|
| 1773 | + display.modelParams3[3] = material.aniso; |
---|
| 1774 | + display.modelParams4[0] = material.anisoV; |
---|
| 1775 | + display.modelParams4[1] = selected ? 100 : material.cameralight; |
---|
| 1776 | + //System.out.println("selected = " + selected); |
---|
| 1777 | + display.modelParams4[2] = material.diffuseness; |
---|
| 1778 | + display.modelParams4[3] = material.shadow; |
---|
| 1779 | + display.modelParams5[0] = material.texture; |
---|
| 1780 | + display.modelParams5[1] = material.opacity; |
---|
| 1781 | + display.modelParams5[2] = material.fakedepth; |
---|
| 1782 | + display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10; |
---|
| 1783 | + } |
---|
| 1784 | + else |
---|
| 1785 | + { |
---|
| 1786 | + display.modelParams0[3] *= material.metalness*2; |
---|
| 1787 | + display.modelParams1[0] *= material.diffuse*2; |
---|
| 1788 | + display.modelParams1[1] *= material.specular*2; |
---|
| 1789 | + display.modelParams1[2] *= material.shininess*2; |
---|
| 1790 | + display.modelParams1[3] *= material.shift*2; |
---|
| 1791 | + display.modelParams2[0] *= material.ambient*2; |
---|
| 1792 | + display.modelParams2[1] *= material.lightarea*2; |
---|
| 1793 | + display.modelParams2[2] *= material.factor*2; |
---|
| 1794 | + display.modelParams2[3] *= material.velvet*2; |
---|
| 1795 | + display.modelParams3[0] *= material.sheen*2; |
---|
| 1796 | + display.modelParams3[1] *= material.subsurface*2; |
---|
| 1797 | + display.modelParams3[2] *= material.bump*2; |
---|
| 1798 | + display.modelParams3[3] *= material.aniso*2; |
---|
| 1799 | + display.modelParams4[0] *= material.anisoV*2; |
---|
| 1800 | + display.modelParams4[1] *= material.cameralight*2; |
---|
| 1801 | + //System.out.println("selected = " + selected); |
---|
| 1802 | + display.modelParams4[2] *= material.diffuseness*2; |
---|
| 1803 | + display.modelParams4[3] *= material.shadow*2; |
---|
| 1804 | + display.modelParams5[0] *= material.texture*2; |
---|
| 1805 | + display.modelParams5[1] *= material.opacity*2; |
---|
| 1806 | + display.modelParams5[2] *= material.fakedepth*2; |
---|
| 1807 | + display.modelParams5[3] *= material.shadowbias*2; |
---|
| 1808 | + } |
---|
| 1809 | + |
---|
| 1810 | + display.modelParams6[0] = 0; |
---|
| 1811 | + display.modelParams6[1] = 0; |
---|
| 1812 | + display.modelParams6[2] = 0; |
---|
| 1813 | + display.modelParams6[3] = 0; |
---|
| 1814 | + |
---|
| 1815 | + display.modelParams7[0] = 0; |
---|
| 1816 | + display.modelParams7[1] = 1000; |
---|
| 1817 | + display.modelParams7[2] = 0; |
---|
| 1818 | + display.modelParams7[3] = 0; |
---|
| 1819 | + |
---|
| 1820 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1821 | + |
---|
| 1822 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
| 1823 | + if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
| 1824 | + { |
---|
| 1825 | + display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
| 1826 | + display.modelParams6[1] = extparams[0].y / 1000.0f; // noise |
---|
| 1827 | + if (extparams.length > 1) |
---|
| 1828 | + { |
---|
| 1829 | + display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade |
---|
| 1830 | + display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough |
---|
| 1831 | + if (extparams.length > 2) |
---|
| 1832 | + { |
---|
| 1833 | + display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power |
---|
| 1834 | + float x = extparams[2].y / 1000.0f; |
---|
| 1835 | + //if (x == 0) |
---|
| 1836 | + // x = 1f; |
---|
| 1837 | + display.modelParams7[1] = 1 / x / x / x / x / x / x / x / x / x / x / x / x / x; // (float)Math.pow(-Math.log((extparams[2].y+0.00) / 1000.0f), 1); // opacity power |
---|
| 1838 | + if (extparams[2].y > 0) |
---|
| 1839 | + { |
---|
| 1840 | + //System.out.println("extparams[1].y = " + extparams[1].y); |
---|
| 1841 | + //System.out.println("extparams[2].y = " + extparams[2].y); |
---|
| 1842 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1843 | + } |
---|
| 1844 | + } |
---|
| 1845 | + } |
---|
| 1846 | + } |
---|
| 1847 | + |
---|
| 1848 | + //if (display.modelParams6[2] != 0) |
---|
| 1849 | + /* |
---|
| 1850 | + System.out.println("modelParams0[0] = " + display.modelParams0[0]); |
---|
| 1851 | + System.out.println("modelParams0[1] = " + display.modelParams0[1]); |
---|
| 1852 | + System.out.println("modelParams0[2] = " + display.modelParams0[2]); |
---|
| 1853 | + System.out.println("modelParams0[3] = " + display.modelParams0[3]); |
---|
| 1854 | + System.out.println("modelParams1[0] = " + display.modelParams1[0]); |
---|
| 1855 | + System.out.println("modelParams1[1] = " + display.modelParams1[1]); |
---|
| 1856 | + System.out.println("modelParams1[2] = " + display.modelParams1[2]); |
---|
| 1857 | + System.out.println("modelParams1[3] = " + display.modelParams1[3]); |
---|
| 1858 | + System.out.println("modelParams2[0] = " + display.modelParams2[0]); |
---|
| 1859 | + System.out.println("modelParams2[1] = " + display.modelParams2[1]); |
---|
| 1860 | + System.out.println("modelParams2[2] = " + display.modelParams2[2]); |
---|
| 1861 | + System.out.println("modelParams2[3] = " + display.modelParams2[3]); |
---|
| 1862 | + System.out.println("modelParams3[0] = " + display.modelParams3[0]); |
---|
| 1863 | + System.out.println("modelParams3[1] = " + display.modelParams3[1]); |
---|
| 1864 | + System.out.println("modelParams3[2] = " + display.modelParams3[2]); |
---|
| 1865 | + System.out.println("modelParams3[3] = " + display.modelParams3[3]); |
---|
| 1866 | + System.out.println("modelParams4[0] = " + display.modelParams4[0]); |
---|
| 1867 | + System.out.println("modelParams4[1] = " + display.modelParams4[1]); |
---|
| 1868 | + System.out.println("modelParams4[2] = " + display.modelParams4[2]); |
---|
| 1869 | + System.out.println("modelParams4[3] = " + display.modelParams4[3]); |
---|
| 1870 | + System.out.println("modelParams5[0] = " + display.modelParams5[0]); |
---|
| 1871 | + System.out.println("modelParams5[1] = " + display.modelParams5[1]); |
---|
| 1872 | + System.out.println("modelParams5[2] = " + display.modelParams5[2]); |
---|
| 1873 | + System.out.println("modelParams5[3] = " + display.modelParams5[3]); |
---|
| 1874 | + System.out.println("modelParams6[0] = " + display.modelParams6[0]); |
---|
| 1875 | + System.out.println("modelParams6[1] = " + display.modelParams6[1]); |
---|
| 1876 | + System.out.println("modelParams6[2] = " + display.modelParams6[2]); |
---|
| 1877 | + System.out.println("modelParams6[3] = " + display.modelParams6[3]); |
---|
| 1878 | + System.out.println("modelParams7[0] = " + display.modelParams7[0]); |
---|
| 1879 | + System.out.println("modelParams7[1] = " + display.modelParams7[1]); |
---|
| 1880 | + System.out.println("modelParams7[2] = " + display.modelParams7[2]); |
---|
| 1881 | + System.out.println("modelParams7[3] = " + display.modelParams7[3]); |
---|
| 1882 | + /**/ |
---|
| 1883 | + //assert (display.modelParams6[2] == 0); |
---|
| 1884 | + |
---|
| 1885 | + //System.out.println("noise power = " + display.modelParams7[0]); |
---|
| 1886 | + //System.out.println("shadowbias = " + shadowbias); |
---|
| 1887 | + |
---|
| 1888 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1889 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0); |
---|
| 1890 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0); |
---|
| 1891 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0); |
---|
| 1892 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 1893 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1894 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0); |
---|
| 1895 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0); |
---|
| 1896 | + |
---|
| 1897 | + int mode = display.FP_SHADER; |
---|
| 1898 | + |
---|
| 1899 | + if (material.aniso != material.anisoV || material.aniso > 0.002) |
---|
| 1900 | + { |
---|
| 1901 | + mode |= display.FP_ANISO; |
---|
| 1902 | + } |
---|
| 1903 | + |
---|
| 1904 | + display.EnableProgram(mode); |
---|
| 1905 | + |
---|
| 1906 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1907 | + |
---|
| 1908 | + if (!material.multiply) |
---|
| 1909 | + { |
---|
| 1910 | + if (Globals.drawMode == CameraPane.SHADOW) |
---|
| 1911 | + gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1); |
---|
| 1912 | + else |
---|
| 1913 | + gl.glDepthMask(material.opacity >= 0.99); |
---|
| 1914 | + } |
---|
208 | 1915 | } |
---|
209 | 1916 | |
---|
210 | 1917 | int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0; |
---|
.. | .. |
---|
225 | 1932 | currentGL.glMultMatrixd(model, 0); |
---|
226 | 1933 | } |
---|
227 | 1934 | |
---|
228 | | - void PushMatrix(double[][] matrix, int count) |
---|
| 1935 | + public void PushMatrix(double[][] matrix, int count) // INTERFACE |
---|
229 | 1936 | { |
---|
230 | 1937 | matrixdepth++; |
---|
231 | 1938 | // GrafreeD.tracein(matrix); |
---|
.. | .. |
---|
254 | 1961 | void PushMatrix(double[][] matrix) |
---|
255 | 1962 | { |
---|
256 | 1963 | // GrafreeD.tracein(matrix); |
---|
257 | | - PushMatrix(matrix,1); |
---|
| 1964 | + PushMatrix(matrix, 1); |
---|
258 | 1965 | } |
---|
259 | 1966 | |
---|
260 | 1967 | void PushMatrix() |
---|
.. | .. |
---|
270 | 1977 | |
---|
271 | 1978 | double[][] tmpmat = new double[4][4]; |
---|
272 | 1979 | |
---|
273 | | - void PopMatrix(double[][] inverse) |
---|
| 1980 | + public void PopMatrix(double[][] inverse) // INTERFACE |
---|
274 | 1981 | { |
---|
275 | 1982 | --matrixdepth; |
---|
276 | 1983 | |
---|
.. | .. |
---|
310 | 2017 | PushTextureMatrix(matrix, 1); |
---|
311 | 2018 | } |
---|
312 | 2019 | |
---|
313 | | - void PushTextureMatrix(double[][] matrix, int count) |
---|
| 2020 | + public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE |
---|
314 | 2021 | { |
---|
315 | 2022 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
316 | 2023 | |
---|
.. | .. |
---|
324 | 2031 | currentGL.glMatrixMode(GetGL().GL_MODELVIEW); |
---|
325 | 2032 | } |
---|
326 | 2033 | |
---|
327 | | - void PopTextureMatrix(double[][] inverse) |
---|
| 2034 | + public void PopTextureMatrix(double[][] inverse) // INTERFACE |
---|
328 | 2035 | { |
---|
329 | 2036 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
330 | 2037 | currentGL.glMatrixMode(GetGL().GL_TEXTURE); |
---|
.. | .. |
---|
351 | 2058 | |
---|
352 | 2059 | static int camerachangeframe; |
---|
353 | 2060 | |
---|
354 | | - boolean SetCamera(Camera cam) |
---|
| 2061 | + public boolean SetCamera(Camera cam) |
---|
355 | 2062 | { |
---|
356 | 2063 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
357 | 2064 | // return false; |
---|
358 | 2065 | |
---|
359 | | - if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount) |
---|
| 2066 | + if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount) |
---|
360 | 2067 | { |
---|
361 | 2068 | // check for last change |
---|
362 | | - if (framecount < camerachangeframe + 400) // 120 == 1 second |
---|
| 2069 | + if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second |
---|
363 | 2070 | { |
---|
364 | 2071 | // refuse the camera change |
---|
365 | 2072 | System.err.println("Camera " + cam + " REFUSED"); |
---|
.. | .. |
---|
367 | 2074 | } |
---|
368 | 2075 | } |
---|
369 | 2076 | |
---|
370 | | - camerachangeframe = framecount; |
---|
| 2077 | + camerachangeframe = Globals.framecount; |
---|
371 | 2078 | |
---|
372 | 2079 | cam.hAspect = -1; // Read only |
---|
373 | 2080 | |
---|
.. | .. |
---|
398 | 2105 | { |
---|
399 | 2106 | //System.err.println("Oeil on"); |
---|
400 | 2107 | TRACK = true; |
---|
401 | | -// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 2108 | +// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
402 | 2109 | // object.editWindow.ScreenFit(trackedobject); |
---|
403 | 2110 | //pingthread.StepToTarget(true); |
---|
404 | 2111 | } |
---|
.. | .. |
---|
407 | 2114 | { |
---|
408 | 2115 | //System.err.println("Oeil on"); |
---|
409 | 2116 | OEIL = true; |
---|
410 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
411 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2117 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
| 2118 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
412 | 2119 | //pingthread.StepToTarget(true); |
---|
413 | 2120 | } |
---|
414 | 2121 | |
---|
.. | .. |
---|
471 | 2178 | { |
---|
472 | 2179 | frozen ^= true; |
---|
473 | 2180 | // Weird... |
---|
474 | | - lighttouched = true; |
---|
| 2181 | + Globals.lighttouched = true; |
---|
475 | 2182 | } |
---|
476 | 2183 | |
---|
477 | 2184 | void ToggleDL() |
---|
478 | 2185 | { |
---|
479 | 2186 | mainDL ^= true; |
---|
480 | | - } |
---|
481 | | - |
---|
482 | | - void ToggleTexture() |
---|
483 | | - { |
---|
484 | | - textureon ^= true; |
---|
485 | | - } |
---|
486 | | - |
---|
487 | | - void ToggleLive() |
---|
488 | | - { |
---|
489 | | - setLIVE(isLIVE() ^ true); |
---|
490 | | - |
---|
491 | | - System.err.println("LIVE = " + isLIVE()); |
---|
492 | | - |
---|
493 | | - if (!isLIVE()) // save sound |
---|
494 | | - GrafreeD.savesound = true; // wav.save(); |
---|
495 | | - // else |
---|
496 | | - repaint(); // start loop // may 2013 |
---|
497 | | - } |
---|
498 | | - |
---|
499 | | - void ToggleSupport() |
---|
500 | | - { |
---|
501 | | - SUPPORT ^= true; |
---|
502 | | - } |
---|
503 | | - |
---|
504 | | - void ToggleAbort() |
---|
505 | | - { |
---|
506 | | - ABORTMODE ^= true; |
---|
507 | 2187 | } |
---|
508 | 2188 | |
---|
509 | 2189 | void ToggleFullScreen() |
---|
.. | .. |
---|
513 | 2193 | |
---|
514 | 2194 | void ToggleCrowd() |
---|
515 | 2195 | { |
---|
516 | | - CROWD ^= true; |
---|
517 | | - } |
---|
518 | | - |
---|
519 | | - void ToggleInertia() |
---|
520 | | - { |
---|
521 | | - INERTIA ^= true; |
---|
| 2196 | + Globals.CROWD ^= true; |
---|
522 | 2197 | } |
---|
523 | 2198 | |
---|
524 | 2199 | void ToggleLocal() |
---|
.. | .. |
---|
526 | 2201 | LOCALTRANSFORM ^= true; |
---|
527 | 2202 | } |
---|
528 | 2203 | |
---|
529 | | - void ToggleFast() |
---|
| 2204 | + public void ToggleTexture() |
---|
| 2205 | + { |
---|
| 2206 | + textureon ^= true; |
---|
| 2207 | + } |
---|
| 2208 | + |
---|
| 2209 | + public void ToggleLive() |
---|
| 2210 | + { |
---|
| 2211 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
| 2212 | + |
---|
| 2213 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
| 2214 | + |
---|
| 2215 | + if (!Globals.isLIVE()) // save sound |
---|
| 2216 | + Grafreed.savesound = true; // wav.save(); |
---|
| 2217 | + // else |
---|
| 2218 | + repaint(); // start loop // may 2013 |
---|
| 2219 | + } |
---|
| 2220 | + |
---|
| 2221 | + public void ToggleSupport() |
---|
| 2222 | + { |
---|
| 2223 | + SUPPORT ^= true; |
---|
| 2224 | + } |
---|
| 2225 | + |
---|
| 2226 | + public void ToggleAbort() |
---|
| 2227 | + { |
---|
| 2228 | + ABORTMODE ^= true; |
---|
| 2229 | + } |
---|
| 2230 | + |
---|
| 2231 | + public void ToggleInertia() |
---|
| 2232 | + { |
---|
| 2233 | + INERTIA ^= true; |
---|
| 2234 | + } |
---|
| 2235 | + |
---|
| 2236 | + public void ToggleFast() |
---|
530 | 2237 | { |
---|
531 | 2238 | FAST ^= true; |
---|
532 | 2239 | } |
---|
533 | 2240 | |
---|
534 | | - void ToggleSlowPose() |
---|
| 2241 | + public void ToggleSlowPose() |
---|
535 | 2242 | { |
---|
536 | 2243 | SLOWPOSE ^= true; |
---|
537 | 2244 | } |
---|
538 | 2245 | |
---|
539 | | - void ToggleFootContact() |
---|
540 | | - { |
---|
541 | | - FOOTCONTACT ^= true; |
---|
542 | | - } |
---|
543 | | - |
---|
544 | | - void ToggleBoxMode() |
---|
| 2246 | + public void ToggleBoxMode() |
---|
545 | 2247 | { |
---|
546 | 2248 | BOXMODE ^= true; |
---|
547 | 2249 | } |
---|
548 | 2250 | |
---|
549 | | - void ToggleSmoothFocus() |
---|
| 2251 | + public void ToggleZoomBoxMode() |
---|
| 2252 | + { |
---|
| 2253 | + ZOOMBOXMODE ^= true; |
---|
| 2254 | + } |
---|
| 2255 | + |
---|
| 2256 | + public void ToggleSmoothFocus() |
---|
550 | 2257 | { |
---|
551 | 2258 | SMOOTHFOCUS ^= true; |
---|
552 | 2259 | } |
---|
553 | 2260 | |
---|
554 | | - void ToggleImageFlip() |
---|
| 2261 | + public void ToggleImageFlip() |
---|
555 | 2262 | { |
---|
556 | 2263 | IMAGEFLIP ^= true; |
---|
557 | 2264 | } |
---|
558 | 2265 | |
---|
559 | | - void ToggleSpeakerMocap() |
---|
| 2266 | + public void ToggleSpeakerMocap() |
---|
560 | 2267 | { |
---|
561 | 2268 | SPEAKERMOCAP ^= true; |
---|
562 | 2269 | } |
---|
563 | 2270 | |
---|
564 | | - void ToggleSpeakerCamera() |
---|
| 2271 | + public void ToggleSpeakerCamera() |
---|
565 | 2272 | { |
---|
566 | 2273 | SPEAKERCAMERA ^= true; |
---|
567 | 2274 | } |
---|
568 | 2275 | |
---|
569 | | - void ToggleSpeakerFocus() |
---|
| 2276 | + public void ToggleSpeakerFocus() |
---|
570 | 2277 | { |
---|
571 | 2278 | SPEAKERFOCUS ^= true; |
---|
572 | 2279 | } |
---|
573 | 2280 | |
---|
574 | | - void ToggleDebug() |
---|
575 | | - { |
---|
576 | | - DEBUG ^= true; |
---|
577 | | - } |
---|
578 | | - |
---|
579 | | - void ToggleFrustum() |
---|
| 2281 | + public void ToggleFrustum() |
---|
580 | 2282 | { |
---|
581 | 2283 | FRUSTUM ^= true; |
---|
582 | 2284 | } |
---|
583 | 2285 | |
---|
584 | | - void ToggleTrack() |
---|
| 2286 | + public void ToggleTrack() |
---|
585 | 2287 | { |
---|
586 | 2288 | TRACK ^= true; |
---|
587 | 2289 | if (TRACK) |
---|
.. | .. |
---|
600 | 2302 | repaint(); |
---|
601 | 2303 | } |
---|
602 | 2304 | |
---|
603 | | - void ToggleTrackOnce() |
---|
| 2305 | + public void ToggleTrackOnce() |
---|
604 | 2306 | { |
---|
605 | 2307 | TRACKONCE ^= true; |
---|
606 | 2308 | } |
---|
607 | 2309 | |
---|
608 | | - void ToggleShadowTrack() |
---|
| 2310 | + public void ToggleShadowTrack() |
---|
609 | 2311 | { |
---|
610 | 2312 | SHADOWTRACK ^= true; |
---|
611 | 2313 | repaint(); |
---|
612 | 2314 | } |
---|
613 | 2315 | |
---|
614 | | - void ToggleOeil() |
---|
| 2316 | + public void ToggleOeil() |
---|
615 | 2317 | { |
---|
616 | 2318 | OEIL ^= true; |
---|
617 | 2319 | } |
---|
618 | 2320 | |
---|
619 | | - void ToggleOeilOnce() |
---|
| 2321 | + public void ToggleOeilOnce() |
---|
620 | 2322 | { |
---|
621 | 2323 | OEILONCE ^= true; |
---|
| 2324 | + } |
---|
| 2325 | + |
---|
| 2326 | + void ToggleFootContact() |
---|
| 2327 | + { |
---|
| 2328 | + FOOTCONTACT ^= true; |
---|
| 2329 | + } |
---|
| 2330 | + |
---|
| 2331 | + void ToggleDebug() |
---|
| 2332 | + { |
---|
| 2333 | + Globals.DEBUG ^= true; |
---|
622 | 2334 | } |
---|
623 | 2335 | |
---|
624 | 2336 | void ToggleLookAt() |
---|
.. | .. |
---|
626 | 2338 | LOOKAT ^= true; |
---|
627 | 2339 | } |
---|
628 | 2340 | |
---|
629 | | - void ToggleRandom() |
---|
| 2341 | + void ToggleSwitch() |
---|
630 | 2342 | { |
---|
631 | | - RANDOM ^= true; |
---|
| 2343 | + SWITCH ^= true; |
---|
632 | 2344 | } |
---|
633 | 2345 | |
---|
634 | 2346 | void ToggleHandles() |
---|
.. | .. |
---|
636 | 2348 | HANDLES ^= true; |
---|
637 | 2349 | } |
---|
638 | 2350 | |
---|
| 2351 | + Object3D paintFolder; |
---|
| 2352 | + |
---|
639 | 2353 | void TogglePaint() |
---|
640 | 2354 | { |
---|
641 | 2355 | PAINTMODE ^= true; |
---|
642 | 2356 | paintcount = 0; |
---|
| 2357 | + |
---|
| 2358 | + if (PAINTMODE) |
---|
| 2359 | + { |
---|
| 2360 | + paintFolder = GetFolder(); |
---|
| 2361 | + } |
---|
643 | 2362 | } |
---|
644 | 2363 | |
---|
645 | 2364 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
672 | 2391 | //assert (cam.hAspect == 0); |
---|
673 | 2392 | cam.hAspect = 0; |
---|
674 | 2393 | lightCamera = cam; |
---|
675 | | - } |
---|
676 | | - |
---|
677 | | - CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
678 | | - { |
---|
679 | | - super(defaultcaps, null, withcontext?glcontext:null, null); |
---|
680 | | - |
---|
681 | | - //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523)); |
---|
682 | | - glcontext = getContext(); |
---|
683 | | - |
---|
684 | | - cameras = new Camera[2]; |
---|
685 | | - targetLookAts = new cVector[2]; |
---|
686 | | - |
---|
687 | | - SetCamera(cam); |
---|
688 | | - |
---|
689 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
690 | | - |
---|
691 | | - object = o; |
---|
692 | | - |
---|
693 | | - setBackground(Color.white); |
---|
694 | | - |
---|
695 | | - addKeyListener(this); |
---|
696 | | - addMouseListener(this); |
---|
697 | | - addMouseMotionListener(this); |
---|
698 | | - addMouseWheelListener(this); |
---|
699 | | - //System.out.println("addGLEventListener: " + this); |
---|
700 | | - addGLEventListener(this); |
---|
701 | | - |
---|
702 | | -// pingthread.start(); // may 2013 |
---|
703 | 2394 | } |
---|
704 | 2395 | |
---|
705 | 2396 | private static void ApplyTransform(GL gl, Mat4f xform) |
---|
.. | .. |
---|
759 | 2450 | |
---|
760 | 2451 | GL currentGL; |
---|
761 | 2452 | |
---|
762 | | - GL GetGL() |
---|
| 2453 | + public GL GetGL() // INTERFACE |
---|
763 | 2454 | { |
---|
764 | 2455 | return currentGL; |
---|
765 | 2456 | } |
---|
766 | | - |
---|
| 2457 | + |
---|
| 2458 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2459 | + { |
---|
| 2460 | + Grafreed.Assert(texturedata != null); |
---|
| 2461 | + |
---|
| 2462 | + int width = texturedata.getWidth(); |
---|
| 2463 | + int height = texturedata.getHeight(); |
---|
| 2464 | + |
---|
| 2465 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2466 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2467 | + |
---|
| 2468 | + byte[] bytes = bytebuf.array(); |
---|
| 2469 | + |
---|
| 2470 | + return CreateBim(bytes, width, height); |
---|
| 2471 | + } |
---|
| 2472 | + |
---|
767 | 2473 | /**/ |
---|
768 | 2474 | class CacheTexture |
---|
769 | 2475 | { |
---|
.. | .. |
---|
772 | 2478 | |
---|
773 | 2479 | int resolution; |
---|
774 | 2480 | |
---|
775 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2481 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
776 | 2482 | { |
---|
777 | | - texture = tex; |
---|
| 2483 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2484 | + texturedata = texdata; |
---|
778 | 2485 | resolution = res; |
---|
779 | 2486 | } |
---|
780 | 2487 | } |
---|
781 | 2488 | /**/ |
---|
782 | 2489 | |
---|
783 | 2490 | // TEXTURE static Texture texture; |
---|
784 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
785 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
786 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2491 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2492 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2493 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2494 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2495 | + |
---|
787 | 2496 | int pigmentdepth = 0; |
---|
788 | 2497 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
789 | 2498 | int bumpdepth = 0; |
---|
790 | 2499 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
791 | 2500 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
792 | 2501 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
793 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2502 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
794 | 2503 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
795 | 2504 | |
---|
796 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2505 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
797 | 2506 | { |
---|
798 | 2507 | TextureData texturedata = null; |
---|
799 | 2508 | |
---|
.. | .. |
---|
812 | 2521 | if (bump) |
---|
813 | 2522 | texturedata = ConvertBump(texturedata, false); |
---|
814 | 2523 | |
---|
815 | | - com.sun.opengl.util.texture.Texture texture = |
---|
816 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2524 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2525 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
817 | 2526 | |
---|
818 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
819 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2527 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2528 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
820 | 2529 | |
---|
821 | | - return texture; |
---|
| 2530 | + return texturedata; |
---|
| 2531 | + } |
---|
| 2532 | + |
---|
| 2533 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2534 | + { |
---|
| 2535 | + TextureData texturedata = null; |
---|
| 2536 | + |
---|
| 2537 | + try |
---|
| 2538 | + { |
---|
| 2539 | + texturedata = |
---|
| 2540 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2541 | + bim, |
---|
| 2542 | + true); |
---|
| 2543 | + } catch (Exception e) |
---|
| 2544 | + { |
---|
| 2545 | + throw new javax.media.opengl.GLException(e); |
---|
| 2546 | + } |
---|
| 2547 | + |
---|
| 2548 | + if (bump) |
---|
| 2549 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2550 | + |
---|
| 2551 | + return texturedata; |
---|
822 | 2552 | } |
---|
823 | 2553 | |
---|
824 | 2554 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
1891 | 3621 | |
---|
1892 | 3622 | System.out.println("LOADING TEXTURE : " + name); |
---|
1893 | 3623 | |
---|
| 3624 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3625 | + |
---|
1894 | 3626 | // |
---|
1895 | 3627 | if (false) // compressbit > 0) |
---|
1896 | 3628 | { |
---|
.. | .. |
---|
2595 | 4327 | |
---|
2596 | 4328 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
2597 | 4329 | { |
---|
| 4330 | + new Exception().printStackTrace(); |
---|
2598 | 4331 | System.exit(0); |
---|
2599 | 4332 | com.sun.opengl.util.texture.Texture texture = null; |
---|
2600 | 4333 | |
---|
.. | .. |
---|
6271 | 8004 | return null; |
---|
6272 | 8005 | } |
---|
6273 | 8006 | |
---|
6274 | | - void ReleaseTextures(cTexture tex) |
---|
| 8007 | + public void ReleaseTextures(cTexture tex) // INTERFACE |
---|
6275 | 8008 | { |
---|
6276 | 8009 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6277 | 8010 | { |
---|
.. | .. |
---|
6288 | 8021 | String pigment = Object3D.GetPigment(tex); |
---|
6289 | 8022 | String bump = Object3D.GetBump(tex); |
---|
6290 | 8023 | |
---|
6291 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8024 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
6292 | 8025 | { |
---|
6293 | 8026 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
6294 | 8027 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
6303 | 8036 | pigment = null; |
---|
6304 | 8037 | } |
---|
6305 | 8038 | |
---|
6306 | | - ReleaseTexture(bump, true); |
---|
6307 | | - ReleaseTexture(pigment, false); |
---|
| 8039 | + ReleaseTexture(tex, true); |
---|
| 8040 | + ReleaseTexture(tex, false); |
---|
6308 | 8041 | } |
---|
6309 | 8042 | |
---|
6310 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8043 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
6311 | 8044 | { |
---|
6312 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 8045 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8046 | + { |
---|
| 8047 | + return; |
---|
| 8048 | + } |
---|
| 8049 | + |
---|
| 8050 | + if (tex == null) |
---|
| 8051 | + { |
---|
| 8052 | + ReleaseTexture(null, false); |
---|
| 8053 | + return; |
---|
| 8054 | + } |
---|
| 8055 | + |
---|
| 8056 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8057 | + |
---|
| 8058 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8059 | + { |
---|
| 8060 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8061 | + // System.out.println("; bump = " + bump); |
---|
| 8062 | + } |
---|
| 8063 | + |
---|
| 8064 | + if (pigment.equals("")) |
---|
| 8065 | + { |
---|
| 8066 | + pigment = null; |
---|
| 8067 | + } |
---|
| 8068 | + |
---|
| 8069 | + ReleaseTexture(tex, false); |
---|
| 8070 | + } |
---|
| 8071 | + |
---|
| 8072 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8073 | + { |
---|
| 8074 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8075 | + { |
---|
| 8076 | + return; |
---|
| 8077 | + } |
---|
| 8078 | + |
---|
| 8079 | + if (tex == null) |
---|
| 8080 | + { |
---|
| 8081 | + ReleaseTexture(null, true); |
---|
| 8082 | + return; |
---|
| 8083 | + } |
---|
| 8084 | + |
---|
| 8085 | + String bump = Object3D.GetBump(tex); |
---|
| 8086 | + |
---|
| 8087 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8088 | + { |
---|
| 8089 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8090 | + // System.out.println("; bump = " + bump); |
---|
| 8091 | + } |
---|
| 8092 | + |
---|
| 8093 | + if (bump.equals("")) |
---|
| 8094 | + { |
---|
| 8095 | + bump = null; |
---|
| 8096 | + } |
---|
| 8097 | + |
---|
| 8098 | + ReleaseTexture(tex, true); |
---|
| 8099 | + } |
---|
| 8100 | + |
---|
| 8101 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
| 8102 | + { |
---|
| 8103 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6313 | 8104 | ambientOcclusion ) // || !textureon) |
---|
6314 | 8105 | { |
---|
6315 | 8106 | return; |
---|
.. | .. |
---|
6318 | 8109 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
6319 | 8110 | |
---|
6320 | 8111 | if (tex != null) |
---|
6321 | | - texture = textures.get(tex); |
---|
| 8112 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
6322 | 8113 | |
---|
6323 | 8114 | // //assert( texture != null ); |
---|
6324 | 8115 | // if (texture == null) |
---|
.. | .. |
---|
6410 | 8201 | } |
---|
6411 | 8202 | } |
---|
6412 | 8203 | |
---|
6413 | | - /*boolean*/ void BindTextures(cTexture tex, int resolution) |
---|
| 8204 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
6414 | 8205 | { |
---|
6415 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 8206 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8207 | +// ambientOcclusion ) // || !textureon) |
---|
| 8208 | +// { |
---|
| 8209 | +// return; // false; |
---|
| 8210 | +// } |
---|
| 8211 | +// |
---|
| 8212 | +// if (tex == null) |
---|
| 8213 | +// { |
---|
| 8214 | +// BindTexture(null,false,resolution); |
---|
| 8215 | +// BindTexture(null,true,resolution); |
---|
| 8216 | +// return; |
---|
| 8217 | +// } |
---|
| 8218 | +// |
---|
| 8219 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8220 | +// String bump = Object3D.GetBump(tex); |
---|
| 8221 | +// |
---|
| 8222 | +// usedtextures.add(pigment); |
---|
| 8223 | +// usedtextures.add(bump); |
---|
| 8224 | +// |
---|
| 8225 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8226 | +// { |
---|
| 8227 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8228 | +// // System.out.println("; bump = " + bump); |
---|
| 8229 | +// } |
---|
| 8230 | +// |
---|
| 8231 | +// if (bump.equals("")) |
---|
| 8232 | +// { |
---|
| 8233 | +// bump = null; |
---|
| 8234 | +// } |
---|
| 8235 | +// if (pigment.equals("")) |
---|
| 8236 | +// { |
---|
| 8237 | +// pigment = null; |
---|
| 8238 | +// } |
---|
| 8239 | +// |
---|
| 8240 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8241 | +// BindTexture(pigment, false, resolution); |
---|
| 8242 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8243 | +// BindTexture(bump, true, resolution); |
---|
| 8244 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8245 | +// |
---|
| 8246 | +// return; // true; |
---|
| 8247 | + |
---|
| 8248 | + BindPigmentTexture(tex, resolution); |
---|
| 8249 | + BindBumpTexture(tex, resolution); |
---|
| 8250 | + } |
---|
| 8251 | + |
---|
| 8252 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8253 | + { |
---|
| 8254 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6416 | 8255 | ambientOcclusion ) // || !textureon) |
---|
6417 | 8256 | { |
---|
6418 | 8257 | return; // false; |
---|
.. | .. |
---|
6421 | 8260 | if (tex == null) |
---|
6422 | 8261 | { |
---|
6423 | 8262 | BindTexture(null,false,resolution); |
---|
6424 | | - BindTexture(null,true,resolution); |
---|
6425 | 8263 | return; |
---|
6426 | 8264 | } |
---|
6427 | 8265 | |
---|
6428 | 8266 | String pigment = Object3D.GetPigment(tex); |
---|
| 8267 | + |
---|
| 8268 | + usedtextures.add(tex); |
---|
| 8269 | + |
---|
| 8270 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8271 | + { |
---|
| 8272 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8273 | + // System.out.println("; bump = " + bump); |
---|
| 8274 | + } |
---|
| 8275 | + |
---|
| 8276 | + if (pigment.equals("")) |
---|
| 8277 | + { |
---|
| 8278 | + pigment = null; |
---|
| 8279 | + } |
---|
| 8280 | + |
---|
| 8281 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8282 | + BindTexture(tex, false, resolution); |
---|
| 8283 | + } |
---|
| 8284 | + |
---|
| 8285 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8286 | + { |
---|
| 8287 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8288 | + ambientOcclusion ) // || !textureon) |
---|
| 8289 | + { |
---|
| 8290 | + return; // false; |
---|
| 8291 | + } |
---|
| 8292 | + |
---|
| 8293 | + if (tex == null) |
---|
| 8294 | + { |
---|
| 8295 | + BindTexture(null,true,resolution); |
---|
| 8296 | + return; |
---|
| 8297 | + } |
---|
| 8298 | + |
---|
6429 | 8299 | String bump = Object3D.GetBump(tex); |
---|
6430 | 8300 | |
---|
6431 | | - usedtextures.put(pigment, pigment); |
---|
6432 | | - usedtextures.put(bump, bump); |
---|
| 8301 | + usedtextures.add(tex); |
---|
6433 | 8302 | |
---|
6434 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8303 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
6435 | 8304 | { |
---|
6436 | 8305 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
6437 | 8306 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
6441 | 8310 | { |
---|
6442 | 8311 | bump = null; |
---|
6443 | 8312 | } |
---|
6444 | | - if (pigment.equals("")) |
---|
6445 | | - { |
---|
6446 | | - pigment = null; |
---|
6447 | | - } |
---|
6448 | 8313 | |
---|
6449 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
6450 | | - BindTexture(pigment, false, resolution); |
---|
6451 | 8314 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
6452 | | - BindTexture(bump, true, resolution); |
---|
| 8315 | + BindTexture(tex, true, resolution); |
---|
6453 | 8316 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
6454 | | - |
---|
6455 | | - return; // true; |
---|
6456 | 8317 | } |
---|
6457 | 8318 | |
---|
6458 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8319 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8320 | + |
---|
| 8321 | + private boolean FileExists(String tex) |
---|
6459 | 8322 | { |
---|
6460 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8323 | + if (missingTextures.contains(tex)) |
---|
| 8324 | + { |
---|
| 8325 | + return false; |
---|
| 8326 | + } |
---|
| 8327 | + |
---|
| 8328 | + boolean fileExists = new File(tex).exists(); |
---|
| 8329 | + |
---|
| 8330 | + if (!fileExists) |
---|
| 8331 | + { |
---|
| 8332 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8333 | + missingTextures.add(tex); |
---|
| 8334 | + } |
---|
| 8335 | + |
---|
| 8336 | + return fileExists; |
---|
| 8337 | + } |
---|
| 8338 | + |
---|
| 8339 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
| 8340 | + { |
---|
| 8341 | + CacheTexture texturecache = null; |
---|
6461 | 8342 | |
---|
6462 | 8343 | if (tex != null) |
---|
6463 | 8344 | { |
---|
6464 | | - String texname = tex; |
---|
| 8345 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8346 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
6465 | 8347 | |
---|
6466 | | - String[] split = tex.split("Textures"); |
---|
6467 | | - if (split.length > 1) |
---|
6468 | | - texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
6469 | | - else |
---|
6470 | | - if (!texname.startsWith("/")) |
---|
6471 | | - texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8348 | + if (texname.equals("") && texdata == null) |
---|
| 8349 | + { |
---|
| 8350 | + return null; |
---|
| 8351 | + } |
---|
| 8352 | + |
---|
| 8353 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8354 | + |
---|
| 8355 | +// String[] split = tex.split("Textures"); |
---|
| 8356 | +// if (split.length > 1) |
---|
| 8357 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8358 | +// else |
---|
| 8359 | +// if (!texname.startsWith("/")) |
---|
| 8360 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8361 | + if (!FileExists(texname)) |
---|
| 8362 | + { |
---|
| 8363 | + texname = fallbackTextureName; |
---|
| 8364 | + } |
---|
6472 | 8365 | |
---|
6473 | 8366 | if (CACHETEXTURE) |
---|
6474 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
6475 | | - |
---|
6476 | | - TextureData texturedata = null; |
---|
6477 | | - |
---|
6478 | | - if (texture == null || texture.resolution < resolution) |
---|
6479 | 8367 | { |
---|
6480 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8368 | + if (texdata == null) |
---|
| 8369 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8370 | + else |
---|
| 8371 | + texturecache = bimtextures.get(texdata); |
---|
| 8372 | + } |
---|
| 8373 | + |
---|
| 8374 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8375 | + { |
---|
| 8376 | + TextureData texturedata = null; |
---|
| 8377 | + |
---|
| 8378 | + if (texdata != null && textureon) |
---|
| 8379 | + { |
---|
| 8380 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8381 | + |
---|
| 8382 | + try |
---|
| 8383 | + { |
---|
| 8384 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8385 | + } |
---|
| 8386 | + catch (Exception e) |
---|
| 8387 | + { |
---|
| 8388 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8389 | + } |
---|
| 8390 | + |
---|
| 8391 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8392 | + bimtextures.put(texdata, texturecache); |
---|
| 8393 | + |
---|
| 8394 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8395 | + |
---|
| 8396 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8397 | + //bim2 = bim; |
---|
| 8398 | + } |
---|
| 8399 | + else |
---|
| 8400 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
6481 | 8401 | { |
---|
6482 | 8402 | assert(!bump); |
---|
6483 | 8403 | // if (bump) |
---|
.. | .. |
---|
6488 | 8408 | // } |
---|
6489 | 8409 | // else |
---|
6490 | 8410 | // { |
---|
6491 | | - texture = textures.get(tex); |
---|
6492 | | - if (texture == null) |
---|
| 8411 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8412 | + if (texturecache == null) |
---|
6493 | 8413 | { |
---|
6494 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8414 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
6495 | 8415 | } |
---|
| 8416 | + else |
---|
| 8417 | + new Exception().printStackTrace(); |
---|
6496 | 8418 | // } |
---|
6497 | 8419 | } else |
---|
6498 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8420 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
6499 | 8421 | { |
---|
6500 | 8422 | assert(bump); |
---|
6501 | | - texture = textures.get(tex); |
---|
6502 | | - if (texture == null) |
---|
6503 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8423 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8424 | + if (texturecache == null) |
---|
| 8425 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8426 | + else |
---|
| 8427 | + new Exception().printStackTrace(); |
---|
6504 | 8428 | } else |
---|
6505 | 8429 | { |
---|
6506 | 8430 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
6508 | 8432 | // texture = GetResourceTexture("default.png"); |
---|
6509 | 8433 | //} else |
---|
6510 | 8434 | //{ |
---|
6511 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8435 | + if (texname.endsWith("WHITE_NOISE")) |
---|
6512 | 8436 | { |
---|
6513 | | - texture = textures.get(tex); |
---|
6514 | | - if (texture == null) |
---|
6515 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8437 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8438 | + if (texturecache == null) |
---|
| 8439 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8440 | + else |
---|
| 8441 | + new Exception().printStackTrace(); |
---|
6516 | 8442 | } else |
---|
6517 | 8443 | { |
---|
6518 | 8444 | if (textureon) |
---|
.. | .. |
---|
6537 | 8463 | } |
---|
6538 | 8464 | |
---|
6539 | 8465 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
6540 | | - if (!new File(cachename).exists()) |
---|
| 8466 | + if (!FileExists(cachename)) |
---|
6541 | 8467 | cachename = texname; |
---|
6542 | 8468 | else |
---|
6543 | 8469 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
6559 | 8485 | } |
---|
6560 | 8486 | |
---|
6561 | 8487 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
6562 | | - if (!new File(cachename).exists()) |
---|
| 8488 | + if (!FileExists(cachename)) |
---|
6563 | 8489 | cachename = texname; |
---|
6564 | 8490 | else |
---|
6565 | 8491 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
6568 | 8494 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
6569 | 8495 | |
---|
6570 | 8496 | |
---|
6571 | | - if (texturedata != null) |
---|
6572 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8497 | + if (texturedata == null) |
---|
| 8498 | + throw new Exception(); |
---|
| 8499 | + |
---|
| 8500 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
6573 | 8501 | //texture = GetTexture(tex, bump); |
---|
6574 | 8502 | } |
---|
6575 | 8503 | } |
---|
6576 | 8504 | //} |
---|
6577 | 8505 | } |
---|
6578 | 8506 | |
---|
6579 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8507 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
6580 | 8508 | { |
---|
6581 | 8509 | //return false; |
---|
6582 | 8510 | |
---|
6583 | 8511 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
6584 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8512 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
6585 | 8513 | { |
---|
6586 | 8514 | // String ext = "_highres"; |
---|
6587 | 8515 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
6598 | 8526 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
6599 | 8527 | if (!cachefile.exists()) |
---|
6600 | 8528 | { |
---|
6601 | | - // cache to disk |
---|
6602 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
6603 | | - //buffers[0]. |
---|
6604 | | - |
---|
6605 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
6606 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
6607 | | - |
---|
6608 | | - // squared size heuristic... |
---|
6609 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8529 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
6610 | 8530 | { |
---|
6611 | | - for (int i=pixels.length; --i>=0;) |
---|
6612 | | - { |
---|
6613 | | - int i3 = i*3; |
---|
6614 | | - pixels[i] = 0xFF; |
---|
6615 | | - pixels[i] <<= 8; |
---|
6616 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
6617 | | - pixels[i] <<= 8; |
---|
6618 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
6619 | | - pixels[i] <<= 8; |
---|
6620 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
6621 | | - } |
---|
6622 | | - |
---|
6623 | | - /* |
---|
6624 | | - int r=0,g=0,b=0,a=0; |
---|
6625 | | - for (int i=0; i<width; i++) |
---|
6626 | | - for (int j=0; j<height; j++) |
---|
6627 | | - { |
---|
6628 | | - int index = j*width+i; |
---|
6629 | | - int p = pixels[index]; |
---|
6630 | | - a = ((p>>24) & 0xFF); |
---|
6631 | | - r = ((p>>16) & 0xFF); |
---|
6632 | | - g = ((p>>8) & 0xFF); |
---|
6633 | | - b = (p & 0xFF); |
---|
6634 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
6635 | | - } |
---|
6636 | | - /**/ |
---|
6637 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
6638 | | - int height = width; |
---|
6639 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
6640 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8531 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8532 | + |
---|
6641 | 8533 | ImageWriter writer = null; |
---|
6642 | 8534 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
6643 | 8535 | if (iter.hasNext()) { |
---|
6644 | 8536 | writer = (ImageWriter)iter.next(); |
---|
6645 | 8537 | } |
---|
6646 | | - float compressionQuality = 0.9f; |
---|
| 8538 | + |
---|
| 8539 | + float compressionQuality = 0.85f; |
---|
6647 | 8540 | try |
---|
6648 | 8541 | { |
---|
6649 | 8542 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
6660 | 8553 | } |
---|
6661 | 8554 | } |
---|
6662 | 8555 | } |
---|
6663 | | - |
---|
| 8556 | + |
---|
| 8557 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8558 | + |
---|
6664 | 8559 | //System.out.println("Texture = " + tex); |
---|
6665 | | - if (textures.containsKey(texname)) |
---|
| 8560 | + if (textures.containsKey(tex)) |
---|
6666 | 8561 | { |
---|
6667 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8562 | + CacheTexture thetex = textures.get(tex); |
---|
6668 | 8563 | thetex.texture.disable(); |
---|
6669 | 8564 | thetex.texture.dispose(); |
---|
6670 | | - textures.remove(texname); |
---|
| 8565 | + textures.remove(tex); |
---|
6671 | 8566 | } |
---|
6672 | 8567 | |
---|
6673 | | - texture.texturedata = texturedata; |
---|
6674 | | - textures.put(texname, texture); |
---|
| 8568 | + //texture.texturedata = texturedata; |
---|
| 8569 | + textures.put(tex, texturecache); |
---|
6675 | 8570 | |
---|
6676 | 8571 | // newtex = true; |
---|
6677 | 8572 | } |
---|
.. | .. |
---|
6687 | 8582 | } |
---|
6688 | 8583 | } |
---|
6689 | 8584 | |
---|
6690 | | - return texture; |
---|
| 8585 | + return texturecache; |
---|
6691 | 8586 | } |
---|
6692 | 8587 | |
---|
6693 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8588 | + static void EmbedTextures(cTexture tex) |
---|
| 8589 | + { |
---|
| 8590 | + if (tex.pigmentdata == null) |
---|
| 8591 | + { |
---|
| 8592 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8593 | + |
---|
| 8594 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8595 | + |
---|
| 8596 | + if (texturecache != null) |
---|
| 8597 | + { |
---|
| 8598 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8599 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8600 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8601 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8602 | + ; |
---|
| 8603 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8604 | + } |
---|
| 8605 | + } |
---|
| 8606 | + |
---|
| 8607 | + if (tex.bumpdata == null) |
---|
| 8608 | + { |
---|
| 8609 | + //String texname = Object3D.GetBump(tex); |
---|
| 8610 | + |
---|
| 8611 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8612 | + |
---|
| 8613 | + if (texturecache != null) |
---|
| 8614 | + { |
---|
| 8615 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8616 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8617 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8618 | + } |
---|
| 8619 | + } |
---|
| 8620 | + } |
---|
| 8621 | + |
---|
| 8622 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
6694 | 8623 | { |
---|
6695 | 8624 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
6696 | 8625 | |
---|
.. | .. |
---|
6708 | 8637 | return texture!=null?texture.texture:null; |
---|
6709 | 8638 | } |
---|
6710 | 8639 | |
---|
6711 | | - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8640 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
6712 | 8641 | { |
---|
6713 | 8642 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
6714 | 8643 | |
---|
6715 | 8644 | return texture!=null?texture.texturedata:null; |
---|
6716 | 8645 | } |
---|
6717 | 8646 | |
---|
6718 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8647 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
6719 | 8648 | { |
---|
6720 | 8649 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6721 | 8650 | { |
---|
6722 | 8651 | return false; |
---|
6723 | 8652 | } |
---|
6724 | 8653 | |
---|
6725 | | - boolean newtex = false; |
---|
| 8654 | + //boolean newtex = false; |
---|
6726 | 8655 | |
---|
6727 | 8656 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
6728 | 8657 | |
---|
.. | .. |
---|
6754 | 8683 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
6755 | 8684 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
6756 | 8685 | |
---|
6757 | | - return newtex; |
---|
| 8686 | + return true; // Warning: not used. |
---|
6758 | 8687 | } |
---|
6759 | 8688 | |
---|
| 8689 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8690 | + { |
---|
| 8691 | + try |
---|
| 8692 | + { |
---|
| 8693 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8694 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8695 | + ImageWriter writer = writers.next(); |
---|
| 8696 | + |
---|
| 8697 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8698 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8699 | + param.setCompressionQuality(quality); |
---|
| 8700 | + |
---|
| 8701 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8702 | + writer.setOutput(ios); |
---|
| 8703 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8704 | + |
---|
| 8705 | + byte[] data = baos.toByteArray(); |
---|
| 8706 | + writer.dispose(); |
---|
| 8707 | + return data; |
---|
| 8708 | + } |
---|
| 8709 | + catch (Exception e) |
---|
| 8710 | + { |
---|
| 8711 | + e.printStackTrace(); |
---|
| 8712 | + return null; |
---|
| 8713 | + } |
---|
| 8714 | + } |
---|
| 8715 | + |
---|
| 8716 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8717 | + { |
---|
| 8718 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8719 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8720 | + ImageReader reader = writers.next(); |
---|
| 8721 | + |
---|
| 8722 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8723 | + |
---|
| 8724 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8725 | + param.setDestination(bim); |
---|
| 8726 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8727 | + |
---|
| 8728 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8729 | + reader.setInput(ios); |
---|
| 8730 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8731 | + reader.dispose(); |
---|
| 8732 | + |
---|
| 8733 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8734 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8735 | +// byte[] bytes = data.getData(); |
---|
| 8736 | +// |
---|
| 8737 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8738 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8739 | +// { |
---|
| 8740 | +// int i3 = i*3; |
---|
| 8741 | +// pixels[i] = 0xFF; |
---|
| 8742 | +// pixels[i] <<= 8; |
---|
| 8743 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8744 | +// pixels[i] <<= 8; |
---|
| 8745 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8746 | +// pixels[i] <<= 8; |
---|
| 8747 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8748 | +// } |
---|
| 8749 | +// |
---|
| 8750 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8751 | + |
---|
| 8752 | + return bim; |
---|
| 8753 | + } |
---|
| 8754 | + |
---|
6760 | 8755 | ShadowBuffer shadowPBuf; |
---|
6761 | 8756 | AntialiasBuffer antialiasPBuf; |
---|
6762 | 8757 | int MAXSTACK; |
---|
.. | .. |
---|
6949 | 8944 | |
---|
6950 | 8945 | if (cubemap == null) |
---|
6951 | 8946 | { |
---|
6952 | | - LoadEnvy(5); |
---|
| 8947 | + //LoadEnvy(1); |
---|
6953 | 8948 | } |
---|
6954 | 8949 | |
---|
6955 | 8950 | //cubemap.enable(); |
---|
.. | .. |
---|
7236 | 9231 | cubemap = null; |
---|
7237 | 9232 | return; |
---|
7238 | 9233 | case 1: |
---|
7239 | | - name = "cubemaps/box_"; |
---|
7240 | | - ext = "png"; |
---|
| 9234 | + name = "cubemaps/rgb/"; |
---|
| 9235 | + ext = "jpg"; |
---|
7241 | 9236 | reverseUP = false; |
---|
7242 | 9237 | break; |
---|
7243 | 9238 | case 2: |
---|
7244 | | - name = "cubemaps/uffizi_"; |
---|
7245 | | - ext = "png"; |
---|
7246 | | - break; // reverseUP = true; break; |
---|
| 9239 | + name = "cubemaps/uffizi/"; |
---|
| 9240 | + ext = "jpg"; |
---|
| 9241 | + reverseUP = false; |
---|
| 9242 | + break; |
---|
7247 | 9243 | case 3: |
---|
7248 | | - name = "cubemaps/CloudyHills_"; |
---|
7249 | | - ext = "tga"; |
---|
| 9244 | + name = "cubemaps/CloudyHills/"; |
---|
| 9245 | + ext = "jpg"; |
---|
7250 | 9246 | reverseUP = false; |
---|
7251 | 9247 | break; |
---|
7252 | 9248 | case 4: |
---|
7253 | | - name = "cubemaps/cornell_"; |
---|
| 9249 | + name = "cubemaps/cornell/"; |
---|
7254 | 9250 | ext = "png"; |
---|
7255 | 9251 | reverseUP = false; |
---|
7256 | 9252 | break; |
---|
| 9253 | + case 5: |
---|
| 9254 | + name = "cubemaps/skycube/"; |
---|
| 9255 | + ext = "jpg"; |
---|
| 9256 | + reverseUP = false; |
---|
| 9257 | + break; |
---|
| 9258 | + case 6: |
---|
| 9259 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9260 | + ext = "jpg"; |
---|
| 9261 | + reverseUP = false; |
---|
| 9262 | + break; |
---|
| 9263 | + case 7: |
---|
| 9264 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9265 | + ext = "jpg"; |
---|
| 9266 | + reverseUP = false; |
---|
| 9267 | + break; |
---|
| 9268 | + case 8: |
---|
| 9269 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9270 | + ext = "jpg"; |
---|
| 9271 | + reverseUP = false; |
---|
| 9272 | + break; |
---|
| 9273 | + case 9: |
---|
| 9274 | + name = "cubemaps/UnionSquare/"; |
---|
| 9275 | + ext = "jpg"; |
---|
| 9276 | + reverseUP = false; |
---|
| 9277 | + break; |
---|
7257 | 9278 | default: |
---|
7258 | | - name = "cubemaps/rgb_"; |
---|
7259 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9279 | + name = "cubemaps/box/"; |
---|
| 9280 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9281 | + reverseUP = false; |
---|
7260 | 9282 | break; |
---|
7261 | 9283 | } |
---|
7262 | | - |
---|
7263 | | - try |
---|
7264 | | - { |
---|
7265 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
7266 | | - } catch (IOException e) |
---|
7267 | | - { |
---|
7268 | | - throw new RuntimeException(e); |
---|
7269 | | - } |
---|
| 9284 | + |
---|
| 9285 | + LoadSkybox(name, ext, mipmap); |
---|
7270 | 9286 | } |
---|
7271 | 9287 | |
---|
7272 | 9288 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
7298 | 9314 | static double[] model = new double[16]; |
---|
7299 | 9315 | double[] camera2light = new double[16]; |
---|
7300 | 9316 | double[] light2camera = new double[16]; |
---|
7301 | | - int newenvy = -1; |
---|
7302 | | - boolean envyoff = true; // false; |
---|
| 9317 | + |
---|
| 9318 | + //int newenvy = -1; |
---|
| 9319 | + //boolean envyoff = false; |
---|
| 9320 | + |
---|
| 9321 | + String loadedskyboxname; |
---|
| 9322 | + |
---|
7303 | 9323 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
7304 | 9324 | //float[] light0 = { 0,0,0 }; |
---|
7305 | 9325 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
7312 | 9332 | static boolean occlusionInitialized = false; |
---|
7313 | 9333 | boolean selection = false; |
---|
7314 | 9334 | boolean pointselection = false; |
---|
7315 | | - /*static*/ boolean lighttouched = true; |
---|
| 9335 | + ///*static*/ boolean lighttouched = true; |
---|
7316 | 9336 | boolean deselect; |
---|
7317 | | - boolean ambientOcclusion = false; |
---|
| 9337 | + private boolean ambientOcclusion = false; |
---|
7318 | 9338 | static boolean flash = false; |
---|
7319 | 9339 | /*static*/ boolean wait = false; |
---|
7320 | 9340 | boolean displaydone = false; // after repaint() calls |
---|
.. | .. |
---|
7444 | 9464 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
7445 | 9465 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
7446 | 9466 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 9467 | +// PATCH FILLE AUX JEANS |
---|
| 9468 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
7447 | 9469 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
7448 | 9470 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
7449 | 9471 | |
---|
.. | .. |
---|
7590 | 9612 | jy8[3] = 0.5f; |
---|
7591 | 9613 | } |
---|
7592 | 9614 | |
---|
7593 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9615 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
7594 | 9616 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
7595 | 9617 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
7596 | 9618 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
7597 | 9619 | |
---|
| 9620 | + void ResetOptions() |
---|
| 9621 | + { |
---|
| 9622 | + options1[0] = 100; |
---|
| 9623 | + options1[1] = 0.025f; |
---|
| 9624 | + options1[2] = 0.01f; |
---|
| 9625 | + options1[3] = 0; |
---|
| 9626 | + options1[4] = 0; |
---|
| 9627 | + |
---|
| 9628 | + options2[0] = 0; |
---|
| 9629 | + options2[1] = 0.75f; |
---|
| 9630 | + options2[2] = 0; |
---|
| 9631 | + options2[3] = 0; |
---|
| 9632 | + |
---|
| 9633 | + options3[0] = 1; |
---|
| 9634 | + options3[1] = 1; |
---|
| 9635 | + options3[2] = 1; |
---|
| 9636 | + options3[3] = 0; |
---|
| 9637 | + |
---|
| 9638 | + options4[0] = 1; |
---|
| 9639 | + options4[1] = 0; |
---|
| 9640 | + options4[2] = 1; |
---|
| 9641 | + options4[3] = 0; |
---|
| 9642 | + } |
---|
| 9643 | + |
---|
7598 | 9644 | static int imagecount = 0; // movie generation |
---|
7599 | 9645 | |
---|
7600 | 9646 | static int jitter = 0; |
---|
7601 | 9647 | |
---|
7602 | 9648 | boolean restartframe = false; |
---|
7603 | | - |
---|
7604 | | - static int framecount = 0; // general-purpose global count |
---|
7605 | 9649 | |
---|
7606 | 9650 | void displayAntiAliased(javax.media.opengl.GL gl) |
---|
7607 | 9651 | { |
---|
.. | .. |
---|
7633 | 9677 | gl.glClear(gl.GL_ACCUM_BUFFER_BIT); |
---|
7634 | 9678 | for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0) |
---|
7635 | 9679 | { |
---|
7636 | | - framecount++; |
---|
| 9680 | + Globals.framecount++; |
---|
7637 | 9681 | |
---|
7638 | 9682 | if (CameraPane.tickcount > 0) |
---|
7639 | 9683 | CameraPane.tickcount--; |
---|
.. | .. |
---|
7671 | 9715 | |
---|
7672 | 9716 | gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0); |
---|
7673 | 9717 | */ |
---|
7674 | | - lighttouched = true; |
---|
| 9718 | + Globals.lighttouched = true; |
---|
7675 | 9719 | //System.err.println(" shadowbuffer: " + jitter); |
---|
7676 | 9720 | shadowbuffer.display(); |
---|
7677 | 9721 | |
---|
.. | .. |
---|
7692 | 9736 | assert (parentcam != renderCamera); |
---|
7693 | 9737 | |
---|
7694 | 9738 | if (renderCamera != lightCamera) |
---|
7695 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7696 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 9739 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9740 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
7697 | 9741 | |
---|
7698 | 9742 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
7699 | 9743 | |
---|
.. | .. |
---|
7708 | 9752 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
7709 | 9753 | |
---|
7710 | 9754 | if (renderCamera != lightCamera) |
---|
7711 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7712 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 9755 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9756 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
7713 | 9757 | |
---|
7714 | 9758 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
7715 | 9759 | |
---|
.. | .. |
---|
7755 | 9799 | rati = 1 / rati; |
---|
7756 | 9800 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
7757 | 9801 | } |
---|
7758 | | - assert (newenvy == -1); |
---|
| 9802 | + |
---|
| 9803 | + //assert (newenvy == -1); |
---|
| 9804 | + |
---|
7759 | 9805 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
7760 | 9806 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
7761 | | - DrawSkyBox(gl); |
---|
| 9807 | + DrawSkyBox(gl, (float)rati); |
---|
7762 | 9808 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
7763 | 9809 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
7764 | 9810 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
7781 | 9827 | //gl.glFlush(); |
---|
7782 | 9828 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
7783 | 9829 | |
---|
7784 | | - if (ANIMATION && ABORTED) |
---|
| 9830 | + if (Globals.ANIMATION && ABORTED) |
---|
7785 | 9831 | { |
---|
7786 | 9832 | System.err.println(" ABORTED FRAME"); |
---|
7787 | 9833 | break; |
---|
.. | .. |
---|
7811 | 9857 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
7812 | 9858 | |
---|
7813 | 9859 | // save image |
---|
7814 | | - if (ANIMATION && !ABORTED) |
---|
| 9860 | + if (Globals.ANIMATION && !ABORTED) |
---|
7815 | 9861 | { |
---|
7816 | 9862 | VPwidth = viewport[2]; |
---|
7817 | 9863 | VPheight = viewport[3]; |
---|
.. | .. |
---|
7922 | 9968 | |
---|
7923 | 9969 | // imagecount++; |
---|
7924 | 9970 | |
---|
7925 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9971 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
7926 | 9972 | |
---|
7927 | 9973 | if (!BOXMODE) |
---|
7928 | 9974 | { |
---|
7929 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9975 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
7930 | 9976 | } |
---|
7931 | 9977 | |
---|
7932 | 9978 | if (!BOXMODE) |
---|
.. | .. |
---|
7964 | 10010 | ABORTED = false; |
---|
7965 | 10011 | } |
---|
7966 | 10012 | else |
---|
7967 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 10013 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
7968 | 10014 | |
---|
7969 | 10015 | if (false) |
---|
7970 | 10016 | { |
---|
.. | .. |
---|
8618 | 10664 | } |
---|
8619 | 10665 | } |
---|
8620 | 10666 | |
---|
8621 | | - boolean IsFrozen() |
---|
8622 | | - { |
---|
8623 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
8624 | | - |
---|
8625 | | - return !selectmode && cameracount == 0; // != 0; |
---|
8626 | | - } |
---|
8627 | | - |
---|
8628 | 10667 | boolean niceon = false; |
---|
8629 | 10668 | javax.swing.Timer AAtimer = new javax.swing.Timer(750, this); |
---|
8630 | 10669 | boolean currentlydrawing = false; |
---|
.. | .. |
---|
8634 | 10673 | |
---|
8635 | 10674 | public void display(GLAutoDrawable drawable) |
---|
8636 | 10675 | { |
---|
8637 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10676 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
8638 | 10677 | { |
---|
8639 | | - GrafreeD.wav.save(); |
---|
8640 | | - GrafreeD.savesound = false; |
---|
8641 | | - GrafreeD.hassound = false; |
---|
| 10678 | + Grafreed.wav.save(); |
---|
| 10679 | + Grafreed.savesound = false; |
---|
| 10680 | + Grafreed.hassound = false; |
---|
8642 | 10681 | } |
---|
8643 | 10682 | // if (DEBUG_SELECTION) |
---|
8644 | 10683 | // { |
---|
8645 | | -// if (drawMode != SELECTION) |
---|
8646 | | -// drawMode = SELECTION; |
---|
| 10684 | +// if (DrawMode() != SELECTION) |
---|
| 10685 | +// DrawMode() = SELECTION; |
---|
8647 | 10686 | // } |
---|
8648 | 10687 | |
---|
8649 | 10688 | if (!isRenderer) |
---|
.. | .. |
---|
8699 | 10738 | |
---|
8700 | 10739 | //ANTIALIAS = 0; |
---|
8701 | 10740 | |
---|
8702 | | - if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
| 10741 | + if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
8703 | 10742 | { |
---|
8704 | | - if (niceon || isLIVE()) |
---|
| 10743 | + if (niceon || Globals.isLIVE()) |
---|
8705 | 10744 | { |
---|
8706 | 10745 | //if(active == 0) |
---|
8707 | 10746 | // antialiaser = null; |
---|
.. | .. |
---|
8714 | 10753 | ANTIALIAS = 0; |
---|
8715 | 10754 | //System.out.println("RESTART"); |
---|
8716 | 10755 | AAtimer.restart(); |
---|
| 10756 | + Globals.TIMERRUNNING = true; |
---|
8717 | 10757 | } |
---|
8718 | 10758 | } |
---|
8719 | 10759 | } |
---|
.. | .. |
---|
8726 | 10766 | assert eyeCamera.shaper_zFar == 1E5f; // 500.0f; |
---|
8727 | 10767 | */ |
---|
8728 | 10768 | |
---|
8729 | | - if (drawMode == DEFAULT) |
---|
| 10769 | + if (DrawMode() == DEFAULT) |
---|
8730 | 10770 | { |
---|
8731 | 10771 | currentlydrawing = true; |
---|
8732 | 10772 | } |
---|
.. | .. |
---|
8757 | 10797 | |
---|
8758 | 10798 | // if(Applet3D.clipboard != null) |
---|
8759 | 10799 | // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent); |
---|
8760 | | -//drawMode = SELECTION; |
---|
| 10800 | +//DrawMode() = SELECTION; |
---|
8761 | 10801 | indexcount = 0; |
---|
8762 | 10802 | |
---|
8763 | | - if (drawMode == OCCLUSION) |
---|
| 10803 | + if (DrawMode() == OCCLUSION) |
---|
8764 | 10804 | { |
---|
8765 | | - drawMode = DEFAULT; |
---|
| 10805 | + Globals.drawMode = DEFAULT; // WARNING |
---|
8766 | 10806 | ambientOcclusion = true; |
---|
8767 | 10807 | setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
---|
8768 | 10808 | Object3D theobject = object; |
---|
8769 | 10809 | Object3D theparent = object.parent; |
---|
8770 | 10810 | object.parent = null; |
---|
8771 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10811 | + object = (Object3D)Grafreed.clone(object); |
---|
8772 | 10812 | object.Stripify(); |
---|
8773 | 10813 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
8774 | 10814 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
8781 | 10821 | ambientOcclusion = false; |
---|
8782 | 10822 | } |
---|
8783 | 10823 | |
---|
8784 | | - if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10824 | + if (//Globals.lighttouched && |
---|
| 10825 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
8785 | 10826 | { |
---|
8786 | 10827 | //if (RENDERSHADOW) // ? |
---|
8787 | 10828 | if (!IsFrozen()) |
---|
8788 | 10829 | { |
---|
8789 | 10830 | // dec 2012 |
---|
8790 | | - if (!ambientOcclusion && !(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)) |
---|
| 10831 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
8791 | 10832 | { |
---|
8792 | | - framecount++; |
---|
| 10833 | + Globals.framecount++; |
---|
8793 | 10834 | shadowbuffer.display(); |
---|
8794 | 10835 | } |
---|
8795 | 10836 | } |
---|
8796 | | - lighttouched = false; // ?? |
---|
| 10837 | + Globals.lighttouched = false; // ?? |
---|
8797 | 10838 | //drawing = true; |
---|
8798 | 10839 | //lighttouched = true; |
---|
8799 | 10840 | } |
---|
.. | .. |
---|
8814 | 10855 | //eyeCamera.shaper_fovy = 1; |
---|
8815 | 10856 | } |
---|
8816 | 10857 | |
---|
8817 | | - if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION) |
---|
| 10858 | + if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION) |
---|
8818 | 10859 | { |
---|
8819 | | - //System.out.println("drawMode = " + drawMode); |
---|
| 10860 | + //System.out.println("DrawMode() = " + DrawMode()); |
---|
8820 | 10861 | vertexMode |= VP_PASS; |
---|
8821 | 10862 | //vertexMode |= VP_PROJECTION; |
---|
8822 | 10863 | if (!ambientOcclusion) |
---|
.. | .. |
---|
8876 | 10917 | Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera; |
---|
8877 | 10918 | //Camera lightcam = new Camera(light0); |
---|
8878 | 10919 | |
---|
8879 | | - if (drawMode == SHADOW) |
---|
| 10920 | + if (DrawMode() == SHADOW) |
---|
8880 | 10921 | { |
---|
8881 | 10922 | /* |
---|
8882 | 10923 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
.. | .. |
---|
8914 | 10955 | |
---|
8915 | 10956 | // if (parentcam != renderCamera) // not a light |
---|
8916 | 10957 | if (cam != lightCamera) |
---|
8917 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8918 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 10958 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10959 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
8919 | 10960 | |
---|
8920 | 10961 | for (int j = 0; j < 4; j++) |
---|
8921 | 10962 | { |
---|
.. | .. |
---|
8929 | 10970 | |
---|
8930 | 10971 | // if (parentcam != renderCamera) // not a light |
---|
8931 | 10972 | if (cam != lightCamera) |
---|
8932 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8933 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 10973 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10974 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
8934 | 10975 | |
---|
8935 | 10976 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
8936 | 10977 | |
---|
.. | .. |
---|
8966 | 11007 | gl.glClear(gl.GL_DEPTH_BUFFER_BIT); |
---|
8967 | 11008 | } else |
---|
8968 | 11009 | { |
---|
8969 | | - if (drawMode != DEFAULT) |
---|
| 11010 | + if (DrawMode() != DEFAULT) |
---|
8970 | 11011 | { |
---|
8971 | 11012 | gl.glClearColor(1, 1, 1, 0); |
---|
8972 | 11013 | } // 1); |
---|
.. | .. |
---|
9016 | 11057 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
9017 | 11058 | } |
---|
9018 | 11059 | |
---|
9019 | | - if (newenvy > -1) |
---|
| 11060 | +// if (newenvy > -1) |
---|
| 11061 | +// { |
---|
| 11062 | +// LoadEnvy(newenvy); |
---|
| 11063 | +// } |
---|
| 11064 | +// |
---|
| 11065 | +// newenvy = -1; |
---|
| 11066 | + |
---|
| 11067 | + if (object.skyboxname != null) |
---|
9020 | 11068 | { |
---|
9021 | | - LoadEnvy(newenvy); |
---|
| 11069 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11070 | + { |
---|
| 11071 | + LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11072 | + loadedskyboxname = object.skyboxname; |
---|
| 11073 | + } |
---|
9022 | 11074 | } |
---|
9023 | | - |
---|
9024 | | - newenvy = -1; |
---|
9025 | | - |
---|
| 11075 | + else |
---|
| 11076 | + { |
---|
| 11077 | + cubemap = null; |
---|
| 11078 | + loadedskyboxname = null; |
---|
| 11079 | + } |
---|
| 11080 | + |
---|
9026 | 11081 | ratio = ((double) getWidth()) / getHeight(); |
---|
9027 | 11082 | //System.out.println("ratio = " + ratio); |
---|
9028 | 11083 | |
---|
.. | .. |
---|
9031 | 11086 | |
---|
9032 | 11087 | fast &= !ambientOcclusion; |
---|
9033 | 11088 | |
---|
9034 | | - if (drawMode == DEFAULT) |
---|
| 11089 | + if (DrawMode() == DEFAULT) |
---|
9035 | 11090 | { |
---|
9036 | 11091 | //gl.glEnable(gl.GL_ALPHA_TEST); |
---|
9037 | 11092 | //gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
9038 | 11093 | |
---|
9039 | 11094 | if (!IsFrozen() && !ambientOcclusion) |
---|
9040 | 11095 | { |
---|
9041 | | - DrawSkyBox(gl); |
---|
| 11096 | + DrawSkyBox(gl, (float)ratio); |
---|
9042 | 11097 | } |
---|
9043 | 11098 | |
---|
9044 | 11099 | //if (selection_view == -1) |
---|
.. | .. |
---|
9092 | 11147 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
9093 | 11148 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9094 | 11149 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 11150 | +// PATCH FILLE AUX JEANS |
---|
| 11151 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9095 | 11152 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9096 | 11153 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9097 | 11154 | |
---|
.. | .. |
---|
9187 | 11244 | // Bump noise |
---|
9188 | 11245 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
9189 | 11246 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
9190 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11247 | + |
---|
| 11248 | + try |
---|
| 11249 | + { |
---|
| 11250 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11251 | + } |
---|
| 11252 | + catch (Exception e) |
---|
| 11253 | + { |
---|
| 11254 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11255 | + } |
---|
| 11256 | + |
---|
9191 | 11257 | |
---|
9192 | 11258 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
9193 | 11259 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9210 | 11276 | |
---|
9211 | 11277 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
9212 | 11278 | |
---|
9213 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
9214 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
9215 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11279 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11280 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11281 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
9216 | 11282 | } else |
---|
9217 | 11283 | { |
---|
9218 | 11284 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9223 | 11289 | //System.out.println("BLENDING ON"); |
---|
9224 | 11290 | gl.glEnable(GL.GL_BLEND); |
---|
9225 | 11291 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
9226 | | - |
---|
| 11292 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
9227 | 11293 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
9228 | 11294 | gl.glLoadIdentity(); |
---|
9229 | 11295 | |
---|
9230 | | - if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
| 11296 | + if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
9231 | 11297 | { |
---|
9232 | 11298 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9233 | 11299 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 11300 | +// PATCH FILLE AUX JEANS |
---|
| 11301 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9234 | 11302 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9235 | 11303 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9236 | 11304 | //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE); |
---|
.. | .. |
---|
9283 | 11351 | //gl.glPushMatrix(); |
---|
9284 | 11352 | gl.glLoadIdentity(); |
---|
9285 | 11353 | |
---|
9286 | | - if (!ambientOcclusion) // drawMode != OCCLUSION) |
---|
| 11354 | + if (!ambientOcclusion) // DrawMode() != OCCLUSION) |
---|
9287 | 11355 | { |
---|
9288 | 11356 | //LA.xformPos(light0, lightCamera.fromScreen, light); |
---|
9289 | 11357 | LA.xformDir(dirlight, lightCamera.fromScreen, lightposition); |
---|
.. | .. |
---|
9310 | 11378 | System.err.println("parentcam != renderCamera"); |
---|
9311 | 11379 | |
---|
9312 | 11380 | // if (cam != lightCamera) |
---|
9313 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9314 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11381 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11382 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
9315 | 11383 | } |
---|
9316 | 11384 | |
---|
9317 | 11385 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
9332 | 11400 | if (true) // TODO |
---|
9333 | 11401 | { |
---|
9334 | 11402 | if (cam != lightCamera) |
---|
9335 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9336 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11403 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11404 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
9337 | 11405 | } |
---|
9338 | 11406 | |
---|
9339 | 11407 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
9370 | 11438 | } |
---|
9371 | 11439 | |
---|
9372 | 11440 | /**/ |
---|
9373 | | - if (true) // drawMode == SELECTION) // != DEFAULT) |
---|
| 11441 | + if (true) // DrawMode() == SELECTION) // != DEFAULT) |
---|
9374 | 11442 | gl.glDisable(gl.GL_LIGHTING); |
---|
9375 | 11443 | else |
---|
9376 | 11444 | gl.glEnable(gl.GL_LIGHTING); |
---|
.. | .. |
---|
9388 | 11456 | |
---|
9389 | 11457 | lightslot = 64; |
---|
9390 | 11458 | |
---|
9391 | | - if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT) |
---|
| 11459 | + if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT) |
---|
9392 | 11460 | { |
---|
9393 | 11461 | DrawLights(object); |
---|
9394 | 11462 | } |
---|
.. | .. |
---|
9399 | 11467 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
9400 | 11468 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
9401 | 11469 | |
---|
9402 | | - if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION) |
---|
| 11470 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
9403 | 11471 | { |
---|
9404 | 11472 | /* |
---|
9405 | 11473 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
9432 | 11500 | } |
---|
9433 | 11501 | } |
---|
9434 | 11502 | |
---|
9435 | | - if (drawMode == DEFAULT) |
---|
| 11503 | + if (DrawMode() == DEFAULT) |
---|
9436 | 11504 | { |
---|
9437 | 11505 | if (WIREFRAME && !ambientOcclusion) |
---|
9438 | 11506 | { |
---|
.. | .. |
---|
9450 | 11518 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9451 | 11519 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9452 | 11520 | |
---|
9453 | | - if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) // |
---|
| 11521 | + if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) // |
---|
9454 | 11522 | { |
---|
9455 | 11523 | if (vertexMode != 0) // && !fast) |
---|
9456 | 11524 | { |
---|
.. | .. |
---|
9470 | 11538 | } |
---|
9471 | 11539 | } |
---|
9472 | 11540 | |
---|
9473 | | - if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion) |
---|
| 11541 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
9474 | 11542 | { |
---|
9475 | 11543 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
9476 | 11544 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
9478 | 11546 | |
---|
9479 | 11547 | boolean texon = textureon; |
---|
9480 | 11548 | |
---|
9481 | | - if (RENDERPROGRAM > 0) |
---|
9482 | | - { |
---|
9483 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9484 | | - textureon = false; |
---|
9485 | | - } |
---|
| 11549 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11550 | + textureon = false; |
---|
| 11551 | + |
---|
9486 | 11552 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9487 | 11553 | //System.out.println("ALLO"); |
---|
9488 | 11554 | gl.glColorMask(false, false, false, false); |
---|
9489 | 11555 | DrawObject(gl); |
---|
9490 | | - if (RENDERPROGRAM > 0) |
---|
9491 | | - { |
---|
9492 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9493 | | - textureon = texon; |
---|
9494 | | - } |
---|
| 11556 | + |
---|
| 11557 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11558 | + textureon = texon; |
---|
| 11559 | + |
---|
9495 | 11560 | gl.glColorMask(true, true, true, true); |
---|
9496 | 11561 | |
---|
9497 | 11562 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
9498 | | - //gl.glDepthMask(false); |
---|
| 11563 | + gl.glDepthMask(false); |
---|
9499 | 11564 | } |
---|
9500 | 11565 | |
---|
9501 | | - if (false) // drawMode == SHADOW) |
---|
| 11566 | + if (false) // DrawMode() == SHADOW) |
---|
9502 | 11567 | { |
---|
9503 | 11568 | //SetColumnMajorData(cameraInverseTransform, view_1); |
---|
9504 | 11569 | //System.out.println("light = " + cameraInverseTransform); |
---|
.. | .. |
---|
9512 | 11577 | //System.out.println("object = " + object); |
---|
9513 | 11578 | if (!frozen && !imageLocked) |
---|
9514 | 11579 | { |
---|
9515 | | - if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0) |
---|
| 11580 | + if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0) |
---|
9516 | 11581 | { |
---|
9517 | 11582 | displayAntiAliased(gl); |
---|
9518 | 11583 | } else |
---|
9519 | 11584 | { |
---|
9520 | 11585 | programcount = 0; |
---|
9521 | | - int keepmode = drawMode; |
---|
| 11586 | + int keepmode = DrawMode(); |
---|
9522 | 11587 | // if (DEBUG_SELECTION) |
---|
9523 | 11588 | // { |
---|
9524 | | -// drawMode = SELECTION; |
---|
| 11589 | +// DrawMode() = SELECTION; |
---|
9525 | 11590 | // } |
---|
9526 | 11591 | // for point selection |
---|
9527 | 11592 | // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0); |
---|
.. | .. |
---|
9531 | 11596 | DrawObject(gl); |
---|
9532 | 11597 | |
---|
9533 | 11598 | // jan 2013 System.err.println("RESET ABORT (display)"); |
---|
9534 | | - // if (drawMode == DEFAULT) |
---|
| 11599 | + // if (DrawMode() == DEFAULT) |
---|
9535 | 11600 | // ABORTED = false; |
---|
9536 | 11601 | fullreset = false; |
---|
9537 | | - drawMode = keepmode; |
---|
| 11602 | + Globals.drawMode = keepmode; // WARNING |
---|
9538 | 11603 | //System.out.println("PROGRAM SWITCH " + programcount); |
---|
9539 | 11604 | } |
---|
9540 | 11605 | } |
---|
.. | .. |
---|
9542 | 11607 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9543 | 11608 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9544 | 11609 | |
---|
9545 | | - if (drawMode == DEFAULT) |
---|
| 11610 | + if (DrawMode() == DEFAULT) |
---|
9546 | 11611 | { |
---|
9547 | 11612 | ReleaseTexture(NOISE_TEXTURE, false); |
---|
9548 | 11613 | } |
---|
9549 | | - //if (drawMode == DEFAULT) |
---|
| 11614 | + //if (DrawMode() == DEFAULT) |
---|
9550 | 11615 | { |
---|
9551 | 11616 | |
---|
9552 | 11617 | gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
.. | .. |
---|
9558 | 11623 | //else |
---|
9559 | 11624 | //gl.glDisable(gl.GL_TEXTURE_2D); |
---|
9560 | 11625 | //gl.glPopMatrix(); |
---|
9561 | | - if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
| 11626 | + if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
9562 | 11627 | { |
---|
9563 | 11628 | //new Exception().printStackTrace(); |
---|
9564 | 11629 | //System.out.println("Draw image " + width + ", " + height); |
---|
.. | .. |
---|
9600 | 11665 | //gl.glFlush(); |
---|
9601 | 11666 | } |
---|
9602 | 11667 | |
---|
9603 | | - if (flash && drawMode == DEFAULT) |
---|
| 11668 | + if (flash && DrawMode() == DEFAULT) |
---|
9604 | 11669 | { |
---|
9605 | 11670 | flash = false; |
---|
9606 | 11671 | wait = true; |
---|
.. | .. |
---|
9608 | 11673 | } |
---|
9609 | 11674 | |
---|
9610 | 11675 | //drawing = false; |
---|
9611 | | - //if(drawMode == DEFAULT) |
---|
| 11676 | + //if(DrawMode() == DEFAULT) |
---|
9612 | 11677 | // niceon = false; |
---|
9613 | | - if (drawMode == DEFAULT) |
---|
| 11678 | + if (DrawMode() == DEFAULT) |
---|
9614 | 11679 | { |
---|
9615 | 11680 | currentlydrawing = false; |
---|
9616 | 11681 | } |
---|
.. | .. |
---|
9630 | 11695 | repaint(); |
---|
9631 | 11696 | } |
---|
9632 | 11697 | |
---|
9633 | | - if (isLIVE() && drawMode == DEFAULT) // may 2013 |
---|
| 11698 | + if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 |
---|
9634 | 11699 | repaint(); |
---|
9635 | 11700 | |
---|
9636 | 11701 | displaydone = true; |
---|
.. | .. |
---|
9649 | 11714 | { |
---|
9650 | 11715 | renderpass++; |
---|
9651 | 11716 | // System.out.println("Draw object... "); |
---|
| 11717 | + STEP = 1; |
---|
9652 | 11718 | if (FAST) // in case there is no script |
---|
9653 | | - STEP = 16; |
---|
| 11719 | + STEP = 8; |
---|
| 11720 | + |
---|
| 11721 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11722 | + { |
---|
| 11723 | + STEP *= 4; |
---|
| 11724 | + } |
---|
9654 | 11725 | |
---|
9655 | 11726 | //object.FullInvariants(); |
---|
9656 | 11727 | |
---|
.. | .. |
---|
9664 | 11735 | e.printStackTrace(); |
---|
9665 | 11736 | } |
---|
9666 | 11737 | |
---|
9667 | | - if (GrafreeD.RENDERME > 0) |
---|
9668 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11738 | + if (Grafreed.RENDERME > 0) |
---|
| 11739 | + Grafreed.RENDERME--; // mechante magouille |
---|
9669 | 11740 | |
---|
9670 | | - ONESTEP = false; |
---|
| 11741 | + Globals.ONESTEP = false; |
---|
9671 | 11742 | } |
---|
9672 | 11743 | |
---|
9673 | 11744 | static boolean zoomonce = false; |
---|
9674 | 11745 | |
---|
| 11746 | + static void CreateSelectedPoint() |
---|
| 11747 | + { |
---|
| 11748 | + if (selectedpoint == null) |
---|
| 11749 | + { |
---|
| 11750 | + debugpointG = new Sphere(); |
---|
| 11751 | + debugpointP = new Sphere(); |
---|
| 11752 | + debugpointC = new Sphere(); |
---|
| 11753 | + debugpointR = new Sphere(); |
---|
| 11754 | + |
---|
| 11755 | + selectedpoint = new Superellipsoid(); |
---|
| 11756 | + |
---|
| 11757 | + for (int i=0; i<8; i++) |
---|
| 11758 | + { |
---|
| 11759 | + debugpoints[i] = new Sphere(); |
---|
| 11760 | + } |
---|
| 11761 | + } |
---|
| 11762 | + } |
---|
| 11763 | + |
---|
9675 | 11764 | void DrawObject(GL gl, boolean draw) |
---|
9676 | 11765 | { |
---|
| 11766 | + // To clear camera values |
---|
| 11767 | + ResetOptions(); |
---|
| 11768 | + |
---|
9677 | 11769 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
9678 | | -// drawMode = SELECTION; |
---|
| 11770 | +// DrawMode() = SELECTION; |
---|
9679 | 11771 | //GL gl = getGL(); |
---|
9680 | 11772 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
9681 | 11773 | { |
---|
9682 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
9683 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11774 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
| 11775 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
9684 | 11776 | pingthread.StepToTarget(true); // true); |
---|
9685 | 11777 | // zoomonce = false; |
---|
9686 | 11778 | } |
---|
.. | .. |
---|
9700 | 11792 | callist = gl.glGenLists(1); |
---|
9701 | 11793 | } |
---|
9702 | 11794 | |
---|
9703 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11795 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
9704 | 11796 | |
---|
9705 | | - boolean active = !selectmode; // drawMode != SELECTION; // mouseDown; |
---|
| 11797 | + boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
9706 | 11798 | |
---|
9707 | 11799 | if (!mainDL || !active || touched) |
---|
9708 | 11800 | { |
---|
.. | .. |
---|
9729 | 11821 | PushMatrix(ClickInfo.matbuffer); |
---|
9730 | 11822 | } |
---|
9731 | 11823 | |
---|
9732 | | - if (drawMode == 0) |
---|
| 11824 | + if (DrawMode() == 0) |
---|
9733 | 11825 | { |
---|
9734 | 11826 | // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++"); |
---|
9735 | 11827 | |
---|
9736 | 11828 | usedtextures.clear(); |
---|
9737 | 11829 | |
---|
9738 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11830 | + try |
---|
| 11831 | + { |
---|
| 11832 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11833 | + } |
---|
| 11834 | + catch (Exception e) |
---|
| 11835 | + { |
---|
| 11836 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11837 | + } |
---|
9739 | 11838 | } |
---|
9740 | 11839 | //System.out.println("--> " + stackdepth); |
---|
9741 | 11840 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
9743 | 11842 | // DRAW |
---|
9744 | 11843 | object.draw(this, /*(Composite)*/ object, false, false); |
---|
9745 | 11844 | |
---|
9746 | | - if (drawMode == DEFAULT) |
---|
| 11845 | + if (DrawMode() == DEFAULT) |
---|
9747 | 11846 | { |
---|
9748 | | - if (DEBUG) |
---|
| 11847 | + if (Globals.DEBUG) |
---|
9749 | 11848 | { |
---|
| 11849 | + CreateSelectedPoint(); |
---|
9750 | 11850 | float radius = 0.05f; |
---|
9751 | 11851 | if (selectedpoint.radius != radius) |
---|
9752 | 11852 | { |
---|
.. | .. |
---|
9754 | 11854 | selectedpoint.radius = radius; |
---|
9755 | 11855 | selectedpoint.recalculate(); |
---|
9756 | 11856 | selectedpoint.material = new cMaterial(); |
---|
9757 | | - selectedpoint.material.color = 0.15f; |
---|
| 11857 | + selectedpoint.material.color = 0.15f; // Yellow |
---|
9758 | 11858 | selectedpoint.material.modulation = 0.75f; |
---|
9759 | 11859 | |
---|
9760 | | - debugpoint.radius = radius; |
---|
9761 | | - debugpoint.recalculate(); |
---|
9762 | | - debugpoint.material = new cMaterial(); |
---|
9763 | | - debugpoint.material.color = 0.25f; |
---|
9764 | | - debugpoint.material.modulation = 0.75f; |
---|
| 11860 | + debugpointG.radius = radius; |
---|
| 11861 | + debugpointG.recalculate(); |
---|
| 11862 | + debugpointG.material = new cMaterial(); |
---|
| 11863 | + debugpointG.material.color = 0.25f; // Green |
---|
| 11864 | + debugpointG.material.modulation = 0.75f; |
---|
9765 | 11865 | |
---|
9766 | | - debugpoint2.radius = radius; |
---|
9767 | | - debugpoint2.recalculate(); |
---|
9768 | | - debugpoint2.material = new cMaterial(); |
---|
9769 | | - debugpoint2.material.color = 0.75f; |
---|
9770 | | - debugpoint2.material.modulation = 0.75f; |
---|
| 11866 | + debugpointP.radius = radius; |
---|
| 11867 | + debugpointP.recalculate(); |
---|
| 11868 | + debugpointP.material = new cMaterial(); |
---|
| 11869 | + debugpointP.material.color = 0.75f; // Purple |
---|
| 11870 | + debugpointP.material.modulation = 0.75f; |
---|
9771 | 11871 | |
---|
9772 | | - debugpoint3.radius = radius; |
---|
9773 | | - debugpoint3.recalculate(); |
---|
9774 | | - debugpoint3.material = new cMaterial(); |
---|
9775 | | - debugpoint3.material.color = 0.5f; |
---|
9776 | | - debugpoint3.material.modulation = 0.75f; |
---|
| 11872 | + debugpointC.radius = radius; |
---|
| 11873 | + debugpointC.recalculate(); |
---|
| 11874 | + debugpointC.material = new cMaterial(); |
---|
| 11875 | + debugpointC.material.color = 0.5f; // Cyan |
---|
| 11876 | + debugpointC.material.modulation = 0.75f; |
---|
9777 | 11877 | |
---|
9778 | | - debugpoint4.radius = radius; |
---|
9779 | | - debugpoint4.recalculate(); |
---|
9780 | | - debugpoint4.material = new cMaterial(); |
---|
9781 | | - debugpoint4.material.color = 0f; |
---|
9782 | | - debugpoint4.material.modulation = 0.75f; |
---|
| 11878 | + debugpointR.radius = radius; |
---|
| 11879 | + debugpointR.recalculate(); |
---|
| 11880 | + debugpointR.material = new cMaterial(); |
---|
| 11881 | + debugpointR.material.color = 0f; // Red |
---|
| 11882 | + debugpointR.material.modulation = 0.75f; |
---|
9783 | 11883 | |
---|
9784 | 11884 | InitPoints(radius); |
---|
9785 | 11885 | } |
---|
9786 | 11886 | selectedpoint.draw(this, /*(Composite)*/ null, false, false); |
---|
9787 | | - debugpoint.draw(this, /*(Composite)*/ null, false,false); |
---|
9788 | | - debugpoint2.draw(this, /*(Composite)*/ null, false,false); |
---|
9789 | | - debugpoint3.draw(this, /*(Composite)*/ null, false,false); |
---|
9790 | | - debugpoint4.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11887 | + debugpointG.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11888 | + debugpointP.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11889 | + debugpointC.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11890 | + debugpointR.draw(this, /*(Composite)*/ null, false,false); |
---|
9791 | 11891 | // DrawPoints(this); |
---|
9792 | 11892 | } |
---|
9793 | 11893 | |
---|
.. | .. |
---|
9795 | 11895 | } |
---|
9796 | 11896 | // GrafreeD.traceoff(); |
---|
9797 | 11897 | //System.out.println(stackdepth); |
---|
9798 | | - if (drawMode == 0) |
---|
| 11898 | + if (DrawMode() == 0) |
---|
9799 | 11899 | { |
---|
9800 | 11900 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
9801 | 11901 | |
---|
9802 | 11902 | if (CLEANCACHE) |
---|
9803 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11903 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
9804 | 11904 | { |
---|
9805 | | - String tex = e.nextElement(); |
---|
| 11905 | + cTexture tex = e.nextElement(); |
---|
9806 | 11906 | |
---|
9807 | 11907 | // System.out.println("Texture --------- " + tex); |
---|
9808 | 11908 | |
---|
9809 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11909 | + if (tex.equals("WHITE_NOISE:")) |
---|
9810 | 11910 | continue; |
---|
9811 | 11911 | |
---|
9812 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11912 | + if (!usedtextures.contains(tex)) |
---|
9813 | 11913 | { |
---|
| 11914 | + CacheTexture gettex = texturepigment.get(tex); |
---|
9814 | 11915 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
9815 | | - textures.get(tex).texture.dispose(); |
---|
9816 | | - textures.remove(tex); |
---|
| 11916 | + if (gettex != null) |
---|
| 11917 | + { |
---|
| 11918 | + gettex.texture.dispose(); |
---|
| 11919 | + texturepigment.remove(tex); |
---|
| 11920 | + } |
---|
| 11921 | + |
---|
| 11922 | + gettex = texturebump.get(tex); |
---|
| 11923 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11924 | + if (gettex != null) |
---|
| 11925 | + { |
---|
| 11926 | + gettex.texture.dispose(); |
---|
| 11927 | + texturebump.remove(tex); |
---|
| 11928 | + } |
---|
9817 | 11929 | } |
---|
9818 | 11930 | } |
---|
9819 | 11931 | } |
---|
9820 | 11932 | |
---|
9821 | 11933 | checker = null; |
---|
9822 | 11934 | |
---|
9823 | | - if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT) |
---|
| 11935 | + if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT) |
---|
9824 | 11936 | FindChecker(object); |
---|
9825 | 11937 | |
---|
9826 | | - if (checker != null && drawMode == DEFAULT) |
---|
| 11938 | + if (checker != null && DrawMode() == DEFAULT) |
---|
9827 | 11939 | { |
---|
9828 | | - // BindTexture(IMMORTAL_TEXTURE); |
---|
| 11940 | + //BindTexture(IMMORTAL_TEXTURE); |
---|
| 11941 | + try |
---|
| 11942 | + { |
---|
| 11943 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11944 | + } |
---|
| 11945 | + catch (Exception e) |
---|
| 11946 | + { |
---|
| 11947 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11948 | + } |
---|
9829 | 11949 | // NEAREST |
---|
9830 | 11950 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
9831 | 11951 | DrawChecker(gl); |
---|
9832 | 11952 | //checker.Draw(this, null, false); |
---|
9833 | 11953 | // ReleaseTexture(IMMORTAL_TEXTURE); |
---|
| 11954 | + ReleaseTextures(checker.GetTextures()); |
---|
9834 | 11955 | } |
---|
9835 | 11956 | |
---|
9836 | 11957 | if (object.parent != null) |
---|
.. | .. |
---|
9843 | 11964 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9844 | 11965 | //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9845 | 11966 | |
---|
9846 | | - if (DISPLAYTEXT && drawMode == DEFAULT) |
---|
| 11967 | + if (DISPLAYTEXT && DrawMode() == DEFAULT) |
---|
9847 | 11968 | { |
---|
9848 | 11969 | // Draw it once, then use the raster |
---|
9849 | 11970 | Balloon(gl, balloon.createGraphics()); |
---|
.. | .. |
---|
9899 | 12020 | int[] xs = new int[3]; |
---|
9900 | 12021 | int[] ys = new int[3]; |
---|
9901 | 12022 | |
---|
9902 | | - void DrawString(Object3D obj) // String string) |
---|
| 12023 | + public void DrawString(Object3D obj) // String string) // INTERFACE |
---|
9903 | 12024 | { |
---|
9904 | | - if (!DISPLAYTEXT || drawMode != DEFAULT) |
---|
| 12025 | + if (!DISPLAYTEXT || DrawMode() != DEFAULT) |
---|
9905 | 12026 | { |
---|
9906 | 12027 | return; |
---|
9907 | 12028 | } |
---|
9908 | 12029 | |
---|
9909 | | - String string = obj.GetToolTip(); |
---|
| 12030 | + String string = obj.toString(); //.GetToolTip(); |
---|
9910 | 12031 | |
---|
9911 | 12032 | GL gl = GetGL(); |
---|
9912 | 12033 | |
---|
.. | .. |
---|
10223 | 12344 | //obj.TransformToWorld(light, light); |
---|
10224 | 12345 | for (int i = tp.size(); --i >= 0;) |
---|
10225 | 12346 | { |
---|
10226 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
10227 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12347 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12348 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
10228 | 12349 | } |
---|
10229 | 12350 | |
---|
10230 | 12351 | |
---|
.. | .. |
---|
10241 | 12362 | parentcam = cameras[0]; |
---|
10242 | 12363 | } |
---|
10243 | 12364 | |
---|
10244 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10245 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12365 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12366 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
10246 | 12367 | |
---|
10247 | 12368 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
10248 | 12369 | |
---|
.. | .. |
---|
10332 | 12453 | |
---|
10333 | 12454 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
10334 | 12455 | |
---|
10335 | | - String program = |
---|
| 12456 | + String programmin = |
---|
| 12457 | + // Min shader |
---|
10336 | 12458 | "!!ARBfp1.0\n" + |
---|
| 12459 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12460 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12461 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12462 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12463 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12464 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12465 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12466 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12467 | + "TEMP temp;" + |
---|
| 12468 | + "TEMP light;" + |
---|
| 12469 | + "TEMP ndotl;" + |
---|
| 12470 | + "TEMP normal;" + |
---|
| 12471 | + "TEMP depth;" + |
---|
| 12472 | + "TEMP eye;" + |
---|
| 12473 | + "TEMP pos;" + |
---|
| 12474 | + |
---|
| 12475 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12476 | + Normalize("normal") + |
---|
| 12477 | + "MOV light, state.light[0].position;" + |
---|
| 12478 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12479 | + |
---|
| 12480 | + // shadow |
---|
| 12481 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12482 | + "MOV temp, pos;" + |
---|
| 12483 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12484 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12485 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12486 | + |
---|
| 12487 | + // No shadow when out of frustum |
---|
| 12488 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12489 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12490 | + |
---|
| 12491 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12492 | + |
---|
| 12493 | + // Backlit |
---|
| 12494 | + "MOV pos.w, zero123.y;" + |
---|
| 12495 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12496 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12497 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12498 | + Normalize("eye") + |
---|
| 12499 | + |
---|
| 12500 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12501 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12502 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12503 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12504 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12505 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12506 | + |
---|
| 12507 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12508 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12509 | + |
---|
| 12510 | + // Pigment |
---|
| 12511 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12512 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12513 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12514 | + |
---|
| 12515 | + "MUL temp, temp, zero123.z;" + |
---|
| 12516 | + |
---|
| 12517 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12518 | + |
---|
| 12519 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12520 | + "MOV result.color, temp;" + |
---|
| 12521 | + "END"; |
---|
| 12522 | + |
---|
| 12523 | + String programmax = |
---|
| 12524 | + "!!ARBfp1.0\n" + |
---|
| 12525 | + |
---|
10337 | 12526 | //"OPTION ARB_fragment_program_shadow;" + |
---|
10338 | 12527 | "PARAM light2cam0 = program.env[10];" + |
---|
10339 | 12528 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
10388 | 12577 | "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" + |
---|
10389 | 12578 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
10390 | 12579 | "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" + |
---|
| 12580 | + "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" + |
---|
10391 | 12581 | "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" + |
---|
10392 | 12582 | "PARAM c256 = { 256, 256, 256, 1.0 };" + |
---|
10393 | 12583 | "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" + |
---|
.. | .. |
---|
10447 | 12637 | "TEMP shininess;" + |
---|
10448 | 12638 | "\n" + |
---|
10449 | 12639 | "MOV texSamp, one;" + |
---|
10450 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
10451 | | - |
---|
| 12640 | + |
---|
10452 | 12641 | "MOV mapgrid.x, one2048th.x;" + |
---|
10453 | 12642 | "MOV temp, fragment.texcoord[1];" + |
---|
10454 | 12643 | /* |
---|
.. | .. |
---|
10469 | 12658 | "MUL temp, floor, mapgrid.x;" + |
---|
10470 | 12659 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
10471 | 12660 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
10472 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12661 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
10473 | 12662 | "") + |
---|
10474 | 12663 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
10475 | 12664 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
10476 | 12665 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
10477 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12666 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
10478 | 12667 | "") + |
---|
10479 | 12668 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
10480 | 12669 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
10481 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12670 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
10482 | 12671 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
10483 | 12672 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
10484 | 12673 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
10485 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12674 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
10486 | 12675 | "") + |
---|
10487 | 12676 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
10488 | 12677 | //"MOV params, material;" + |
---|
.. | .. |
---|
10853 | 13042 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
10854 | 13043 | "") + |
---|
10855 | 13044 | |
---|
10856 | | - // display shadow only (bump == 0) |
---|
| 13045 | + // display shadow only (fakedepth == 0) |
---|
10857 | 13046 | "SUB temp.x, half.x, shadow.x;" + |
---|
10858 | | - "MOV temp.y, -params6.x;" + |
---|
10859 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 13047 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 13048 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
10860 | 13049 | "SUB temp.y, one.x, temp.z;" + |
---|
10861 | 13050 | "MUL temp.x, temp.x, temp.y;" + |
---|
10862 | 13051 | "KIL temp.x;" + |
---|
.. | .. |
---|
10985 | 13174 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
10986 | 13175 | |
---|
10987 | 13176 | "SUB temp.x, one.x, ndotl.x;" + |
---|
10988 | | - "ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
10989 | | - "ADD temp.y, one.y, options2.y;" + // sursurface |
---|
| 13177 | + // Tuning for default skin |
---|
| 13178 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 13179 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 13180 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
10990 | 13181 | "MUL temp.x, temp.x, temp.y;" + |
---|
10991 | 13182 | |
---|
10992 | 13183 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
11185 | 13376 | //once = true; |
---|
11186 | 13377 | } |
---|
11187 | 13378 | |
---|
11188 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 13379 | + String program = programmax; |
---|
| 13380 | + |
---|
| 13381 | + if (Globals.MINSHADER) |
---|
| 13382 | + { |
---|
| 13383 | + program = programmin; |
---|
| 13384 | + } |
---|
| 13385 | + |
---|
| 13386 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
11189 | 13387 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
11190 | 13388 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
11191 | 13389 | |
---|
.. | .. |
---|
11278 | 13476 | return out; |
---|
11279 | 13477 | } |
---|
11280 | 13478 | |
---|
11281 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13479 | + // Also does frustum culling |
---|
| 13480 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
11282 | 13481 | { |
---|
11283 | 13482 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
11284 | 13483 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
11285 | 13484 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13485 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13486 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
11286 | 13487 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
11287 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
11288 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
11289 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
11290 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13488 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13489 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
11291 | 13490 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
11292 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13491 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
11293 | 13492 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
11294 | 13493 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
11295 | 13494 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
11296 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13495 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
11297 | 13496 | |
---|
11298 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
11299 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13497 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13498 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
11300 | 13499 | } |
---|
11301 | 13500 | |
---|
11302 | 13501 | String Shadow(String depth, String shadow) |
---|
11303 | 13502 | { |
---|
11304 | 13503 | return "MAX temp.x, ndotl.x, one64th.x;" + |
---|
| 13504 | + "MIN temp.x, temp.x, ninetenth.x;" + |
---|
11305 | 13505 | /**/ |
---|
11306 | 13506 | // Sine |
---|
11307 | 13507 | "MUL temp.y, temp.x, temp.x;" + |
---|
.. | .. |
---|
11317 | 13517 | |
---|
11318 | 13518 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
11319 | 13519 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13520 | + |
---|
| 13521 | + // Compare fragment depth in light space with shadowmap. |
---|
11320 | 13522 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
11321 | 13523 | "SGE temp.y, temp.x, zero.x;" + |
---|
11322 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13524 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13525 | + |
---|
| 13526 | + // Reverse comparison |
---|
11323 | 13527 | "SUB temp.x, one.x, temp.x;" + |
---|
11324 | 13528 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
11325 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13529 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
11326 | 13530 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
11327 | 13531 | |
---|
11328 | 13532 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
11336 | 13540 | // No shadow for backface |
---|
11337 | 13541 | "DP3 temp.x, normal, lightd;" + |
---|
11338 | 13542 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13543 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13544 | + |
---|
| 13545 | + // No shadow when out of frustum |
---|
| 13546 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
11339 | 13547 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
11340 | 13548 | ""; |
---|
11341 | 13549 | } |
---|
.. | .. |
---|
11482 | 13690 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
11483 | 13691 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
11484 | 13692 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
11485 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13693 | + |
---|
| 13694 | + //Object3D.cVector2[] vector2buffer; |
---|
11486 | 13695 | |
---|
11487 | 13696 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
11488 | 13697 | // OUT : diff, spec |
---|
.. | .. |
---|
11498 | 13707 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
11499 | 13708 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
11500 | 13709 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
11501 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
11502 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
11503 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13710 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13711 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13712 | + |
---|
| 13713 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
11504 | 13714 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
11505 | 13715 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
11506 | 13716 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
11894 | 14104 | public void mousePressed(MouseEvent e) |
---|
11895 | 14105 | { |
---|
11896 | 14106 | //System.out.println("mousePressed: " + e); |
---|
11897 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14107 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
11898 | 14108 | } |
---|
11899 | 14109 | |
---|
11900 | 14110 | static long prevtime = 0; |
---|
.. | .. |
---|
11921 | 14131 | |
---|
11922 | 14132 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
11923 | 14133 | |
---|
| 14134 | + if (BUTTONLESSWHEEL) |
---|
11924 | 14135 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
11925 | 14136 | { |
---|
11926 | 14137 | return; |
---|
11927 | 14138 | } |
---|
11928 | 14139 | |
---|
| 14140 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
11929 | 14141 | |
---|
11930 | 14142 | // TIMER |
---|
11931 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR |
---|
| 14143 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
11932 | 14144 | { |
---|
11933 | 14145 | keepboxmode = BOXMODE; |
---|
11934 | 14146 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
11968 | 14180 | // mode |= META; |
---|
11969 | 14181 | //} |
---|
11970 | 14182 | |
---|
11971 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
11972 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 14183 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 14184 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
11973 | 14185 | anchorX = ax; |
---|
11974 | 14186 | anchorY = ay; |
---|
11975 | 14187 | prevX = px; |
---|
.. | .. |
---|
12003 | 14215 | else |
---|
12004 | 14216 | if (evt.getSource() == AAtimer) |
---|
12005 | 14217 | { |
---|
| 14218 | + Globals.TIMERRUNNING = false; |
---|
12006 | 14219 | if (mouseDown) |
---|
12007 | 14220 | { |
---|
12008 | 14221 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
12028 | 14241 | // LIVE = waslive; |
---|
12029 | 14242 | // wasliveok = true; |
---|
12030 | 14243 | // waslive = false; |
---|
| 14244 | + |
---|
| 14245 | + // May 2019 Forget it: |
---|
| 14246 | + if (true) |
---|
| 14247 | + return; |
---|
12031 | 14248 | |
---|
12032 | 14249 | // source == timer |
---|
12033 | 14250 | if (mouseDown) |
---|
.. | .. |
---|
12057 | 14274 | // ObjEditor.tweenManager.update(1f / 60f); |
---|
12058 | 14275 | |
---|
12059 | 14276 | // fev 2014??? |
---|
12060 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode) |
---|
12061 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14277 | + if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
| 14278 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
12062 | 14279 | pingthread.StepToTarget(true); // true); |
---|
12063 | 14280 | } |
---|
12064 | 14281 | // if (!LIVE) |
---|
.. | .. |
---|
12067 | 14284 | |
---|
12068 | 14285 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
12069 | 14286 | |
---|
12070 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14287 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
12071 | 14288 | { |
---|
12072 | 14289 | if (!wasliveok) |
---|
12073 | 14290 | return; |
---|
12074 | 14291 | |
---|
12075 | 14292 | AAtimer.restart(); // |
---|
| 14293 | + Globals.TIMERRUNNING = true; |
---|
12076 | 14294 | |
---|
12077 | 14295 | // waslive = LIVE; |
---|
12078 | 14296 | // LIVE = false; |
---|
.. | .. |
---|
12084 | 14302 | // touched = true; // main DL |
---|
12085 | 14303 | if (isRenderer) |
---|
12086 | 14304 | { |
---|
12087 | | - SetMouseMode(modifiers); |
---|
| 14305 | + SetMouseMode(modifiers, modifiersex); |
---|
12088 | 14306 | } |
---|
12089 | 14307 | |
---|
12090 | 14308 | selectX = anchorX = x; |
---|
.. | .. |
---|
12097 | 14315 | clicked = true; |
---|
12098 | 14316 | hold = false; |
---|
12099 | 14317 | |
---|
12100 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14318 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
12101 | 14319 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
12102 | 14320 | { |
---|
12103 | 14321 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
12122 | 14340 | drag = false; |
---|
12123 | 14341 | //System.out.println("Mouse DOWN"); |
---|
12124 | 14342 | editObj = false; |
---|
12125 | | - ClickInfo info = new ClickInfo(); |
---|
12126 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
12127 | | - info.pane = this; |
---|
12128 | | - info.camera = renderCamera; |
---|
12129 | | - info.x = x; |
---|
12130 | | - info.y = y; |
---|
12131 | | - info.modifiers = modifiers; |
---|
12132 | | - editObj = object.doEditClick(info, 0); |
---|
| 14343 | + //ClickInfo info = new ClickInfo(); |
---|
| 14344 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14345 | + object.clickInfo.pane = this; |
---|
| 14346 | + object.clickInfo.camera = renderCamera; |
---|
| 14347 | + object.clickInfo.x = x; |
---|
| 14348 | + object.clickInfo.y = y; |
---|
| 14349 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14350 | + editObj = object.doEditClick(//info, |
---|
| 14351 | + 0); |
---|
12133 | 14352 | if (!editObj) |
---|
12134 | 14353 | { |
---|
12135 | 14354 | hasMarquee = true; |
---|
.. | .. |
---|
12145 | 14364 | |
---|
12146 | 14365 | public void mouseDragged(MouseEvent e) |
---|
12147 | 14366 | { |
---|
| 14367 | + Globals.MOUSEDRAGGED = true; |
---|
| 14368 | + |
---|
| 14369 | + //System.out.println("mouseDragged: " + e); |
---|
12148 | 14370 | if (isRenderer) |
---|
12149 | 14371 | movingcamera = true; |
---|
| 14372 | + |
---|
12150 | 14373 | //if (drawing) |
---|
12151 | 14374 | //return; |
---|
12152 | | - //System.out.println("mouseDragged: " + e); |
---|
12153 | 14375 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
12154 | 14376 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
12155 | 14377 | { |
---|
.. | .. |
---|
12157 | 14379 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12158 | 14380 | } |
---|
12159 | 14381 | else |
---|
12160 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14382 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12161 | 14383 | |
---|
12162 | 14384 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
12163 | 14385 | } |
---|
.. | .. |
---|
12169 | 14391 | cVector tmp = new cVector(); |
---|
12170 | 14392 | cVector tmp2 = new cVector(); |
---|
12171 | 14393 | boolean isMoving; |
---|
| 14394 | + |
---|
| 14395 | + public cVector TargetLookAt() |
---|
| 14396 | + { |
---|
| 14397 | + return targetLookAt; |
---|
| 14398 | + } |
---|
12172 | 14399 | |
---|
12173 | 14400 | class PingThread extends Thread |
---|
12174 | 14401 | { |
---|
.. | .. |
---|
12308 | 14535 | //System.out.println("---------------- ---------- Paint " + tmp.length2()); |
---|
12309 | 14536 | if (lightMode) |
---|
12310 | 14537 | { |
---|
12311 | | - lighttouched = true; |
---|
| 14538 | + Globals.lighttouched = true; |
---|
12312 | 14539 | } |
---|
12313 | 14540 | |
---|
12314 | 14541 | if (OEILONCE && OEIL) |
---|
.. | .. |
---|
12325 | 14552 | |
---|
12326 | 14553 | public void run() |
---|
12327 | 14554 | { |
---|
| 14555 | + new Exception().printStackTrace(); |
---|
12328 | 14556 | System.exit(0); |
---|
12329 | 14557 | for (;;) |
---|
12330 | 14558 | { |
---|
.. | .. |
---|
12366 | 14594 | mouseDown = false; |
---|
12367 | 14595 | if (lightMode) |
---|
12368 | 14596 | { |
---|
12369 | | - lighttouched = true; |
---|
| 14597 | + Globals.lighttouched = true; |
---|
12370 | 14598 | } |
---|
12371 | 14599 | repaint(); |
---|
12372 | 14600 | alreadypainted = true; |
---|
.. | .. |
---|
12374 | 14602 | isMoving = false; |
---|
12375 | 14603 | } //?? |
---|
12376 | 14604 | |
---|
12377 | | - if (isLIVE() && !alreadypainted) |
---|
| 14605 | + if (Globals.isLIVE() && !alreadypainted) |
---|
12378 | 14606 | { |
---|
12379 | 14607 | // FOR DEBUG BREAKPOINT USING PAUSE: while (true) |
---|
12380 | 14608 | repaint(); |
---|
.. | .. |
---|
12386 | 14614 | { |
---|
12387 | 14615 | if (lightMode) |
---|
12388 | 14616 | { |
---|
12389 | | - lighttouched = true; |
---|
| 14617 | + Globals.lighttouched = true; |
---|
12390 | 14618 | } |
---|
12391 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14619 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
12392 | 14620 | } |
---|
12393 | 14621 | //else |
---|
12394 | 14622 | } |
---|
.. | .. |
---|
12402 | 14630 | void GoDown(int mod) |
---|
12403 | 14631 | { |
---|
12404 | 14632 | MODIFIERS |= COMMAND; |
---|
12405 | | - /* |
---|
| 14633 | + /**/ |
---|
12406 | 14634 | if((mod&SHIFT) == SHIFT) |
---|
12407 | 14635 | manipCamera.RotatePosition(0, -speed); |
---|
12408 | 14636 | else |
---|
12409 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
12410 | | - */ |
---|
| 14637 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14638 | + /**/ |
---|
12411 | 14639 | if ((mod & SHIFT) == SHIFT) |
---|
12412 | 14640 | { |
---|
12413 | 14641 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
12423 | 14651 | void GoUp(int mod) |
---|
12424 | 14652 | { |
---|
12425 | 14653 | MODIFIERS |= COMMAND; |
---|
12426 | | - /* |
---|
| 14654 | + /**/ |
---|
12427 | 14655 | if((mod&SHIFT) == SHIFT) |
---|
12428 | 14656 | manipCamera.RotatePosition(0, speed); |
---|
12429 | 14657 | else |
---|
12430 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
12431 | | - */ |
---|
| 14658 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14659 | + /**/ |
---|
12432 | 14660 | if ((mod & SHIFT) == SHIFT) |
---|
12433 | 14661 | { |
---|
12434 | 14662 | mouseMode = mouseMode; |
---|
.. | .. |
---|
12444 | 14672 | void GoLeft(int mod) |
---|
12445 | 14673 | { |
---|
12446 | 14674 | MODIFIERS |= COMMAND; |
---|
12447 | | - /* |
---|
| 14675 | + /**/ |
---|
12448 | 14676 | if((mod&SHIFT) == SHIFT) |
---|
12449 | | - manipCamera.RotatePosition(speed, 0); |
---|
12450 | | - else |
---|
12451 | 14677 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
12452 | | - */ |
---|
| 14678 | + else |
---|
| 14679 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14680 | + /**/ |
---|
12453 | 14681 | if ((mod & SHIFT) == SHIFT) |
---|
12454 | 14682 | { |
---|
12455 | 14683 | mouseMode = mouseMode; |
---|
.. | .. |
---|
12465 | 14693 | void GoRight(int mod) |
---|
12466 | 14694 | { |
---|
12467 | 14695 | MODIFIERS |= COMMAND; |
---|
12468 | | - /* |
---|
| 14696 | + /**/ |
---|
12469 | 14697 | if((mod&SHIFT) == SHIFT) |
---|
12470 | | - manipCamera.RotatePosition(-speed, 0); |
---|
12471 | | - else |
---|
12472 | 14698 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
12473 | | - */ |
---|
| 14699 | + else |
---|
| 14700 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14701 | + /**/ |
---|
12474 | 14702 | if ((mod & SHIFT) == SHIFT) |
---|
12475 | 14703 | { |
---|
12476 | 14704 | mouseMode = mouseMode; |
---|
.. | .. |
---|
12488 | 14716 | int X, Y; |
---|
12489 | 14717 | boolean SX, SY; |
---|
12490 | 14718 | |
---|
12491 | | - void drag(int x, int y, int modifiers) |
---|
| 14719 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
12492 | 14720 | { |
---|
12493 | 14721 | if (IsFrozen()) |
---|
12494 | 14722 | { |
---|
.. | .. |
---|
12497 | 14725 | |
---|
12498 | 14726 | drag = true; // NEW |
---|
12499 | 14727 | |
---|
12500 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14728 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
12501 | 14729 | |
---|
12502 | 14730 | X = x; |
---|
12503 | 14731 | Y = y; |
---|
12504 | 14732 | // floating state for animation |
---|
12505 | | - MODIFIERS = modifiers; |
---|
12506 | | - modifiers &= ~1024; |
---|
| 14733 | + MODIFIERS = modifiersex; |
---|
| 14734 | + modifiersex &= ~1024; |
---|
12507 | 14735 | if (false) // modifiers != 0) |
---|
12508 | 14736 | { |
---|
12509 | 14737 | //new Exception().printStackTrace(); |
---|
12510 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14738 | + System.out.println("mouseDragged: " + modifiersex); |
---|
12511 | 14739 | System.out.println("SHIFT = " + SHIFT); |
---|
12512 | 14740 | System.out.println("CONTROL = " + COMMAND); |
---|
12513 | 14741 | System.out.println("META = " + META); |
---|
.. | .. |
---|
12520 | 14748 | if (editObj) |
---|
12521 | 14749 | { |
---|
12522 | 14750 | drag = true; |
---|
12523 | | - ClickInfo info = new ClickInfo(); |
---|
12524 | | - info.bounds.setBounds(0, 0, |
---|
| 14751 | + //ClickInfo info = new ClickInfo(); |
---|
| 14752 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
12525 | 14753 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
12526 | | - info.pane = this; |
---|
12527 | | - info.camera = renderCamera; |
---|
12528 | | - info.x = x; |
---|
12529 | | - info.y = y; |
---|
12530 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14754 | + object.clickInfo.pane = this; |
---|
| 14755 | + object.clickInfo.camera = renderCamera; |
---|
| 14756 | + object.clickInfo.x = x; |
---|
| 14757 | + object.clickInfo.y = y; |
---|
| 14758 | + object //.GetWindow().copy |
---|
| 14759 | + .doEditDrag(//info, |
---|
| 14760 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
12531 | 14761 | } else |
---|
12532 | 14762 | { |
---|
12533 | 14763 | if (x < startX) |
---|
.. | .. |
---|
12629 | 14859 | { |
---|
12630 | 14860 | manipCamera.Translate(dx, dy, getWidth()); |
---|
12631 | 14861 | } |
---|
| 14862 | + else |
---|
12632 | 14863 | if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0) |
---|
12633 | 14864 | { |
---|
12634 | 14865 | manipCamera.RotateInterest(dx, dy); |
---|
.. | .. |
---|
12639 | 14870 | |
---|
12640 | 14871 | if (manipCamera == lightCamera) |
---|
12641 | 14872 | { |
---|
12642 | | - lighttouched = true; |
---|
| 14873 | + Globals.lighttouched = true; |
---|
12643 | 14874 | } |
---|
12644 | 14875 | /* |
---|
12645 | 14876 | switch (mode) |
---|
.. | .. |
---|
12675 | 14906 | } |
---|
12676 | 14907 | } |
---|
12677 | 14908 | |
---|
| 14909 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14910 | + |
---|
12678 | 14911 | public void mouseMoved(MouseEvent e) |
---|
12679 | 14912 | { |
---|
12680 | 14913 | //System.out.println("mouseMoved: " + e); |
---|
12681 | | - |
---|
12682 | 14914 | if (isRenderer) |
---|
12683 | 14915 | return; |
---|
12684 | 14916 | |
---|
12685 | | - ClickInfo ci = new ClickInfo(); |
---|
12686 | | - ci.x = e.getX(); |
---|
12687 | | - ci.y = e.getY(); |
---|
12688 | | - ci.modifiers = e.getModifiersEx(); |
---|
12689 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
12690 | | - ci.pane = this; |
---|
12691 | | - ci.camera = renderCamera; |
---|
| 14917 | + // Mouse cursor feedback |
---|
| 14918 | + object.clickInfo.x = e.getX(); |
---|
| 14919 | + object.clickInfo.y = e.getY(); |
---|
| 14920 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14921 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14922 | + object.clickInfo.pane = this; |
---|
| 14923 | + object.clickInfo.camera = renderCamera; |
---|
12692 | 14924 | if (!isRenderer) |
---|
12693 | 14925 | { |
---|
12694 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14926 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14927 | + //Object3D copy = editWindow.copy; |
---|
| 14928 | + if (object.doEditClick(//clickInfo, |
---|
| 14929 | + 0)) |
---|
12695 | 14930 | { |
---|
12696 | 14931 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
12697 | 14932 | } else |
---|
.. | .. |
---|
12703 | 14938 | |
---|
12704 | 14939 | public void mouseReleased(MouseEvent e) |
---|
12705 | 14940 | { |
---|
| 14941 | + Globals.MOUSEDRAGGED = false; |
---|
| 14942 | + |
---|
12706 | 14943 | movingcamera = false; |
---|
| 14944 | + X = 0; // getBounds().width/2; |
---|
| 14945 | + Y = 0; // getBounds().height/2; |
---|
12707 | 14946 | //System.out.println("mouseReleased: " + e); |
---|
12708 | 14947 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12709 | 14948 | } |
---|
.. | .. |
---|
12726 | 14965 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
12727 | 14966 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
12728 | 14967 | |
---|
12729 | | - if (control || command || IsFrozen()) |
---|
| 14968 | +// No delay if (control || command || IsFrozen()) |
---|
12730 | 14969 | timeout = true; |
---|
12731 | | - else |
---|
| 14970 | +// ?? May 2019 else |
---|
12732 | 14971 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
12733 | 14972 | mouseDown = false; |
---|
12734 | 14973 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
12838 | 15077 | System.out.println("keyReleased: " + e); |
---|
12839 | 15078 | } |
---|
12840 | 15079 | |
---|
12841 | | - void SetMouseMode(int modifiers) |
---|
| 15080 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
12842 | 15081 | { |
---|
12843 | 15082 | //System.out.println("SetMouseMode = " + modifiers); |
---|
12844 | 15083 | //modifiers &= ~1024; |
---|
.. | .. |
---|
12850 | 15089 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
12851 | 15090 | // return; |
---|
12852 | 15091 | //System.out.println("SetMode = " + modifiers); |
---|
12853 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 15092 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
12854 | 15093 | { |
---|
12855 | 15094 | mouseMode |= ZOOM; |
---|
12856 | 15095 | } |
---|
12857 | 15096 | |
---|
12858 | 15097 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
12859 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 15098 | + if (capsLocked) // || (modifiers & META) == META) |
---|
12860 | 15099 | { |
---|
12861 | 15100 | mouseMode |= VR; // BACKFORTH; |
---|
12862 | 15101 | } |
---|
12863 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
12864 | | - { |
---|
12865 | | - mouseMode |= SELECT; // BACKFORTH; |
---|
12866 | | - } |
---|
12867 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 15102 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
12868 | 15103 | { |
---|
12869 | 15104 | mouseMode |= SELECT; |
---|
12870 | 15105 | } |
---|
12871 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 15106 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
| 15107 | + { |
---|
| 15108 | + mouseMode |= SELECT; |
---|
| 15109 | + } |
---|
| 15110 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
12872 | 15111 | { |
---|
12873 | 15112 | mouseMode &= ~VR; |
---|
12874 | 15113 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
12897 | 15136 | |
---|
12898 | 15137 | if (isRenderer) // |
---|
12899 | 15138 | { |
---|
12900 | | - SetMouseMode(modifiers); |
---|
| 15139 | + SetMouseMode(0, modifiers); |
---|
12901 | 15140 | } |
---|
12902 | 15141 | |
---|
12903 | | - theRenderer.keyPressed(key); |
---|
| 15142 | + Globals.theRenderer.keyPressed(key); |
---|
12904 | 15143 | } |
---|
12905 | 15144 | |
---|
12906 | 15145 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
12912 | 15151 | float SATPOW = 1; // 2; // 0.5f; |
---|
12913 | 15152 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
12914 | 15153 | |
---|
12915 | | - void keyPressed(int key) |
---|
| 15154 | + public void keyPressed(int key) |
---|
12916 | 15155 | { |
---|
12917 | 15156 | if (key >= '0' && key <= '5') |
---|
12918 | 15157 | clampbit = (key-'0'); |
---|
.. | .. |
---|
12959 | 15198 | // break; |
---|
12960 | 15199 | case 'T': |
---|
12961 | 15200 | CACHETEXTURE ^= true; |
---|
12962 | | - textures.clear(); |
---|
| 15201 | + texturepigment.clear(); |
---|
| 15202 | + texturebump.clear(); |
---|
12963 | 15203 | // repaint(); |
---|
12964 | 15204 | break; |
---|
12965 | 15205 | case 'Y': |
---|
.. | .. |
---|
13027 | 15267 | case 'B': |
---|
13028 | 15268 | BRISMOOTH ^= true; |
---|
13029 | 15269 | SHADOWCULLFACE ^= true; |
---|
13030 | | - lighttouched = true; |
---|
| 15270 | + Globals.lighttouched = true; |
---|
13031 | 15271 | repaint(); |
---|
13032 | 15272 | break; |
---|
13033 | 15273 | case 'b': |
---|
.. | .. |
---|
13044 | 15284 | case 'E' : COMPACT ^= true; |
---|
13045 | 15285 | repaint(); |
---|
13046 | 15286 | break; |
---|
13047 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15287 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15288 | + //DEBUGHSB ^= true; |
---|
| 15289 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
13048 | 15290 | repaint(); |
---|
13049 | 15291 | break; |
---|
13050 | 15292 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
13069 | 15311 | RevertCamera(); |
---|
13070 | 15312 | repaint(); |
---|
13071 | 15313 | break; |
---|
13072 | | - case 'L': |
---|
13073 | 15314 | case 'l': |
---|
| 15315 | + //case 'L': |
---|
13074 | 15316 | if (lightMode) |
---|
13075 | 15317 | { |
---|
13076 | 15318 | lightMode = false; |
---|
.. | .. |
---|
13127 | 15369 | repaint(); |
---|
13128 | 15370 | break; |
---|
13129 | 15371 | case 'O': |
---|
13130 | | - drawMode = OCCLUSION; |
---|
| 15372 | + Globals.drawMode = OCCLUSION; // WARNING |
---|
13131 | 15373 | repaint(); |
---|
13132 | 15374 | break; |
---|
13133 | 15375 | case 'o': |
---|
13134 | 15376 | OCCLUSION_CULLING ^= true; |
---|
13135 | 15377 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
13136 | 15378 | break; |
---|
13137 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15379 | + //case '0': envyoff ^= true; repaint(); break; |
---|
13138 | 15380 | case '1': |
---|
13139 | 15381 | case '2': |
---|
13140 | 15382 | case '3': |
---|
13141 | 15383 | case '4': |
---|
13142 | 15384 | case '5': |
---|
13143 | | - newenvy = Character.getNumericValue(key); |
---|
13144 | | - repaint(); |
---|
13145 | | - break; |
---|
13146 | 15385 | case '6': |
---|
13147 | 15386 | case '7': |
---|
13148 | 15387 | case '8': |
---|
13149 | 15388 | case '9': |
---|
13150 | | - BGcolor = (key - '6')/3.f; |
---|
| 15389 | + if (true) // envyoff) |
---|
| 15390 | + { |
---|
| 15391 | + BGcolor = (key - '1')/8.f; |
---|
| 15392 | + } |
---|
| 15393 | + else |
---|
| 15394 | + { |
---|
| 15395 | + //newenvy = Character.getNumericValue(key); |
---|
| 15396 | + } |
---|
13151 | 15397 | repaint(); |
---|
13152 | 15398 | break; |
---|
13153 | 15399 | case '!': |
---|
.. | .. |
---|
13213 | 15459 | case '_': |
---|
13214 | 15460 | kompactbit = 5; |
---|
13215 | 15461 | break; |
---|
13216 | | - case '+': |
---|
13217 | | - kompactbit = 6; |
---|
13218 | | - break; |
---|
| 15462 | +// case '+': |
---|
| 15463 | +// kompactbit = 6; |
---|
| 15464 | +// break; |
---|
13219 | 15465 | case ' ': |
---|
13220 | 15466 | lightMode ^= true; |
---|
13221 | | - lighttouched = true; |
---|
| 15467 | + Globals.lighttouched = true; |
---|
13222 | 15468 | manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
13223 | 15469 | targetLookAt.set(manipCamera.lookAt); |
---|
13224 | 15470 | repaint(); |
---|
.. | .. |
---|
13227 | 15473 | case ESC: |
---|
13228 | 15474 | RENDERPROGRAM += 1; |
---|
13229 | 15475 | RENDERPROGRAM %= 3; |
---|
| 15476 | + |
---|
13230 | 15477 | repaint(); |
---|
13231 | 15478 | break; |
---|
13232 | 15479 | case 'Z': |
---|
13233 | | - RESIZETEXTURE ^= true; |
---|
13234 | | - break; |
---|
| 15480 | + //RESIZETEXTURE ^= true; |
---|
| 15481 | + //break; |
---|
13235 | 15482 | case 'z': |
---|
13236 | | - RENDERSHADOW ^= true; |
---|
13237 | | - lighttouched = true; |
---|
| 15483 | + Globals.RENDERSHADOW ^= true; |
---|
| 15484 | + Globals.lighttouched = true; |
---|
13238 | 15485 | repaint(); |
---|
13239 | 15486 | break; |
---|
13240 | 15487 | //case UP: |
---|
.. | .. |
---|
13266 | 15513 | case DELETE: |
---|
13267 | 15514 | ClearSelection(); |
---|
13268 | 15515 | break; |
---|
13269 | | - /* |
---|
13270 | 15516 | case '+': |
---|
| 15517 | + |
---|
| 15518 | + /* |
---|
13271 | 15519 | //fontsize += 1; |
---|
13272 | 15520 | bbzoom *= 2; |
---|
13273 | 15521 | repaint(); |
---|
.. | .. |
---|
13284 | 15532 | case '=': |
---|
13285 | 15533 | IncDepth(); |
---|
13286 | 15534 | //fontsize += 1; |
---|
13287 | | - object.editWindow.refreshContents(true); |
---|
| 15535 | + object.GetWindow().refreshContents(true); |
---|
13288 | 15536 | maskbit = 6; |
---|
13289 | 15537 | break; |
---|
13290 | 15538 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
13291 | 15539 | DecDepth(); |
---|
13292 | 15540 | maskbit = 5; |
---|
13293 | 15541 | //if(fontsize > 1) fontsize -= 1; |
---|
13294 | | - if (object.editWindow == null) |
---|
13295 | | - new Exception().printStackTrace(); |
---|
13296 | | - else |
---|
13297 | | - object.editWindow.refreshContents(true); |
---|
| 15542 | +// if (object.editWindow == null) |
---|
| 15543 | +// new Exception().printStackTrace(); |
---|
| 15544 | +// else |
---|
| 15545 | + object.GetWindow().refreshContents(true); |
---|
13298 | 15546 | break; |
---|
13299 | 15547 | case '{': |
---|
13300 | 15548 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
13349 | 15597 | } |
---|
13350 | 15598 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
13351 | 15599 | } |
---|
| 15600 | + |
---|
13352 | 15601 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
13353 | 15602 | |
---|
13354 | 15603 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
13356 | 15605 | //mode = ROTATE; |
---|
13357 | 15606 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
13358 | 15607 | { |
---|
13359 | | - SetMouseMode(modifiers); |
---|
| 15608 | + SetMouseMode(0, modifiers); |
---|
13360 | 15609 | } |
---|
13361 | 15610 | } |
---|
13362 | 15611 | |
---|
13363 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 15612 | + public void processKeyEvent(KeyEvent e) |
---|
13364 | 15613 | { |
---|
13365 | 15614 | switch (e.getID()) |
---|
13366 | 15615 | { |
---|
.. | .. |
---|
13490 | 15739 | |
---|
13491 | 15740 | protected void processMouseMotionEvent(MouseEvent e) |
---|
13492 | 15741 | { |
---|
13493 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
13494 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15742 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15743 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15744 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
13495 | 15745 | { |
---|
13496 | 15746 | mouseMoved(e); |
---|
13497 | 15747 | } else |
---|
.. | .. |
---|
13516 | 15766 | } |
---|
13517 | 15767 | */ |
---|
13518 | 15768 | |
---|
13519 | | - object.editWindow.EditSelection(); |
---|
| 15769 | + object.GetWindow().EditSelection(false); |
---|
13520 | 15770 | } |
---|
13521 | 15771 | |
---|
13522 | 15772 | void SelectParent() |
---|
13523 | 15773 | { |
---|
| 15774 | + new Exception().printStackTrace(); |
---|
13524 | 15775 | System.exit(0); |
---|
13525 | 15776 | Composite group = (Composite) object; |
---|
13526 | 15777 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
13532 | 15783 | { |
---|
13533 | 15784 | //selectees.remove(i); |
---|
13534 | 15785 | System.out.println("select parent of " + elem); |
---|
13535 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15786 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
13536 | 15787 | } else |
---|
13537 | 15788 | { |
---|
13538 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15789 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
13539 | 15790 | } |
---|
13540 | 15791 | |
---|
13541 | 15792 | first = false; |
---|
.. | .. |
---|
13544 | 15795 | |
---|
13545 | 15796 | void SelectChildren() |
---|
13546 | 15797 | { |
---|
| 15798 | + new Exception().printStackTrace(); |
---|
13547 | 15799 | System.exit(0); |
---|
13548 | 15800 | /* |
---|
13549 | 15801 | Composite group = (Composite) object; |
---|
.. | .. |
---|
13576 | 15828 | for (int j = 0; j < group.children.size(); j++) |
---|
13577 | 15829 | { |
---|
13578 | 15830 | elem = (Object3D) group.children.elementAt(j); |
---|
13579 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15831 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
13580 | 15832 | first = false; |
---|
13581 | 15833 | } |
---|
13582 | 15834 | } else |
---|
13583 | 15835 | { |
---|
13584 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15836 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
13585 | 15837 | } |
---|
13586 | 15838 | |
---|
13587 | 15839 | first = false; |
---|
.. | .. |
---|
13592 | 15844 | { |
---|
13593 | 15845 | //Composite group = (Composite) object; |
---|
13594 | 15846 | Object3D group = object; |
---|
13595 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15847 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
13596 | 15848 | } |
---|
13597 | 15849 | |
---|
13598 | 15850 | void ResetTransform(int mask) |
---|
13599 | 15851 | { |
---|
13600 | 15852 | //Composite group = (Composite) object; |
---|
13601 | 15853 | Object3D group = object; |
---|
13602 | | - group.editWindow.ResetTransform(mask); |
---|
| 15854 | + group.GetWindow().ResetTransform(mask); |
---|
13603 | 15855 | } |
---|
13604 | 15856 | |
---|
13605 | 15857 | void FlipTransform() |
---|
13606 | 15858 | { |
---|
13607 | 15859 | //Composite group = (Composite) object; |
---|
13608 | 15860 | Object3D group = object; |
---|
13609 | | - group.editWindow.FlipTransform(); |
---|
| 15861 | + group.GetWindow().FlipTransform(); |
---|
13610 | 15862 | // group.editWindow.ReduceMesh(true); |
---|
13611 | 15863 | } |
---|
13612 | 15864 | |
---|
.. | .. |
---|
13614 | 15866 | { |
---|
13615 | 15867 | //Composite group = (Composite) object; |
---|
13616 | 15868 | Object3D group = object; |
---|
13617 | | - group.editWindow.PrintMemory(); |
---|
| 15869 | + group.GetWindow().PrintMemory(); |
---|
13618 | 15870 | // group.editWindow.ReduceMesh(true); |
---|
13619 | 15871 | } |
---|
13620 | 15872 | |
---|
.. | .. |
---|
13622 | 15874 | { |
---|
13623 | 15875 | //Composite group = (Composite) object; |
---|
13624 | 15876 | Object3D group = object; |
---|
13625 | | - group.editWindow.ResetCentroid(); |
---|
| 15877 | + group.GetWindow().ResetCentroid(); |
---|
13626 | 15878 | } |
---|
13627 | 15879 | |
---|
13628 | 15880 | void IncDepth() |
---|
.. | .. |
---|
13704 | 15956 | |
---|
13705 | 15957 | int width = getBounds().width; |
---|
13706 | 15958 | int height = getBounds().height; |
---|
13707 | | - ClickInfo info = new ClickInfo(); |
---|
13708 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
13709 | 15959 | //Image img = CreateImage(width, height); |
---|
13710 | 15960 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15961 | + |
---|
13711 | 15962 | Graphics gr = g; // img.getGraphics(); |
---|
| 15963 | + |
---|
13712 | 15964 | if (!hasMarquee) |
---|
13713 | 15965 | { |
---|
13714 | 15966 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
13780 | 16032 | } |
---|
13781 | 16033 | if (object != null && !hasMarquee) |
---|
13782 | 16034 | { |
---|
| 16035 | + if (object.clickInfo == null) |
---|
| 16036 | + object.clickInfo = new ClickInfo(); |
---|
| 16037 | + ClickInfo info = object.clickInfo; |
---|
| 16038 | + //ClickInfo info = new ClickInfo(); |
---|
| 16039 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16040 | + |
---|
13783 | 16041 | if (isRenderer) |
---|
13784 | 16042 | { |
---|
13785 | | - info.flags++; |
---|
| 16043 | + object.clickInfo.flags++; |
---|
13786 | 16044 | double frameAspect = (double) width / (double) height; |
---|
13787 | 16045 | if (frameAspect > renderCamera.aspect) |
---|
13788 | 16046 | { |
---|
13789 | 16047 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
13790 | | - info.bounds.width -= width - desired; |
---|
13791 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16048 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16049 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
13792 | 16050 | } else |
---|
13793 | 16051 | { |
---|
13794 | 16052 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
13795 | | - info.bounds.height -= height - desired; |
---|
13796 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16053 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16054 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
13797 | 16055 | } |
---|
13798 | 16056 | } |
---|
13799 | | - info.g = gr; |
---|
13800 | | - info.camera = renderCamera; |
---|
| 16057 | + |
---|
| 16058 | + object.clickInfo.g = gr; |
---|
| 16059 | + object.clickInfo.camera = renderCamera; |
---|
13801 | 16060 | /* |
---|
13802 | 16061 | // Memory intensive (brep.verticescopy) |
---|
13803 | 16062 | if (!(object instanceof Composite)) |
---|
13804 | 16063 | object.draw(info, 0, false); // SLOW : |
---|
13805 | 16064 | */ |
---|
13806 | | - if (!isRenderer) |
---|
| 16065 | + if (!isRenderer) // && drag) |
---|
13807 | 16066 | { |
---|
13808 | | - object.drawEditHandles(info, 0); |
---|
| 16067 | + Grafreed.Assert(object != null); |
---|
| 16068 | + Grafreed.Assert(object.selection != null); |
---|
| 16069 | + if (object.selection.Size() > 0) |
---|
| 16070 | + { |
---|
| 16071 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16072 | + |
---|
| 16073 | + object.clickInfo.DX = 0; |
---|
| 16074 | + object.clickInfo.DY = 0; |
---|
| 16075 | + object.clickInfo.W = 1; |
---|
| 16076 | + if (hitSomething == Object3D.hitCenter) |
---|
| 16077 | + { |
---|
| 16078 | + info.DX = X; |
---|
| 16079 | + if (X != 0) |
---|
| 16080 | + info.DX -= info.bounds.width/2; |
---|
| 16081 | + |
---|
| 16082 | + info.DY = Y; |
---|
| 16083 | + if (Y != 0) |
---|
| 16084 | + info.DY -= info.bounds.height/2; |
---|
| 16085 | + } |
---|
| 16086 | + |
---|
| 16087 | + object.drawEditHandles(//info, |
---|
| 16088 | + 0); |
---|
| 16089 | + |
---|
| 16090 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16091 | + { |
---|
| 16092 | + switch (hitSomething) |
---|
| 16093 | + { |
---|
| 16094 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16095 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16096 | + break; |
---|
| 16097 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16098 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16099 | + break; |
---|
| 16100 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16101 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16102 | + break; |
---|
| 16103 | + } |
---|
| 16104 | + |
---|
| 16105 | + } |
---|
| 16106 | + } |
---|
13809 | 16107 | } |
---|
13810 | 16108 | } |
---|
| 16109 | + |
---|
13811 | 16110 | if (isRenderer) |
---|
13812 | 16111 | { |
---|
13813 | 16112 | //gr.setColor(Color.black); |
---|
13814 | 16113 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
13815 | 16114 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
13816 | 16115 | } |
---|
| 16116 | + |
---|
13817 | 16117 | if (hasMarquee) |
---|
13818 | 16118 | { |
---|
13819 | 16119 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
13836 | 16136 | //if (g != gr) g.drawImage(img, 0, 0, width, height, null); |
---|
13837 | 16137 | } |
---|
13838 | 16138 | |
---|
| 16139 | + // To avoid clear. |
---|
13839 | 16140 | public void update(Graphics g) |
---|
13840 | 16141 | { |
---|
13841 | 16142 | paint(g); |
---|
.. | .. |
---|
13925 | 16226 | public boolean mouseDown(Event evt, int x, int y) |
---|
13926 | 16227 | { |
---|
13927 | 16228 | System.out.println("mouseDown: " + evt); |
---|
| 16229 | + System.exit(0); |
---|
13928 | 16230 | /* |
---|
13929 | 16231 | locked = true; |
---|
13930 | 16232 | drag = false; |
---|
.. | .. |
---|
13968 | 16270 | { |
---|
13969 | 16271 | keyPressed(0, modifiers); |
---|
13970 | 16272 | } |
---|
13971 | | - clickStart(x, y, modifiers); |
---|
| 16273 | + // clickStart(x, y, modifiers); |
---|
13972 | 16274 | return true; |
---|
13973 | 16275 | } |
---|
13974 | 16276 | |
---|
.. | .. |
---|
14086 | 16388 | { |
---|
14087 | 16389 | keyReleased(0, 0); |
---|
14088 | 16390 | } |
---|
14089 | | - drag(x, y, modifiers); |
---|
| 16391 | + drag(x, y, 0, modifiers); |
---|
14090 | 16392 | return true; |
---|
14091 | 16393 | } |
---|
14092 | 16394 | |
---|
.. | .. |
---|
14218 | 16520 | Object3D object; |
---|
14219 | 16521 | static Object3D trackedobject; |
---|
14220 | 16522 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
14221 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16523 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
14222 | 16524 | /*static*/ Camera eyeCamera; |
---|
14223 | 16525 | /*static*/ Camera lightCamera; |
---|
14224 | 16526 | int cameracount; |
---|
.. | .. |
---|
14282 | 16584 | private /*static*/ boolean firstime; |
---|
14283 | 16585 | private /*static*/ cVector newView = new cVector(); |
---|
14284 | 16586 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16587 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16588 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
14285 | 16589 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
14286 | 16590 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
14287 | 16591 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
14294 | 16598 | { |
---|
14295 | 16599 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
14296 | 16600 | |
---|
| 16601 | + int usedsuf = 0; |
---|
| 16602 | + |
---|
14297 | 16603 | for (int i = 0; i < suffixes.length; i++) |
---|
14298 | 16604 | { |
---|
14299 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
14300 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
14301 | | - mipmapped, |
---|
14302 | | - FileUtil.getFileSuffix(resourceName)); |
---|
14303 | | - if (data == null) |
---|
| 16605 | + String[] suffixe = suffixes; |
---|
| 16606 | + String[] fallback = suffixes2; |
---|
| 16607 | + String[] fallfallback = suffixes3; |
---|
| 16608 | + |
---|
| 16609 | + for (int c=usedsuf; --c>=0;) |
---|
14304 | 16610 | { |
---|
14305 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16611 | +// String[] temp = suffixe; |
---|
| 16612 | +// suffixe = fallback; |
---|
| 16613 | +// fallback = fallfallback; |
---|
| 16614 | +// fallfallback = temp; |
---|
14306 | 16615 | } |
---|
| 16616 | + |
---|
| 16617 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16618 | + TextureData data; |
---|
| 16619 | + |
---|
| 16620 | + try |
---|
| 16621 | + { |
---|
| 16622 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16623 | + mipmapped, |
---|
| 16624 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16625 | + } |
---|
| 16626 | + catch (Exception e) |
---|
| 16627 | + { |
---|
| 16628 | + try |
---|
| 16629 | + { |
---|
| 16630 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16631 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16632 | + mipmapped, |
---|
| 16633 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16634 | + } |
---|
| 16635 | + catch (Exception e2) |
---|
| 16636 | + { |
---|
| 16637 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16638 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16639 | + mipmapped, |
---|
| 16640 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16641 | + } |
---|
| 16642 | + } |
---|
| 16643 | + |
---|
14307 | 16644 | //System.out.println("Target = " + targets[i]); |
---|
14308 | 16645 | cubemap.updateImage(data, targets[i]); |
---|
14309 | 16646 | } |
---|
14310 | 16647 | |
---|
14311 | 16648 | return cubemap; |
---|
14312 | 16649 | } |
---|
| 16650 | + |
---|
14313 | 16651 | int bigsphere = -1; |
---|
14314 | 16652 | |
---|
14315 | 16653 | float BGcolor = 0.5f; |
---|
14316 | 16654 | |
---|
14317 | | - private void DrawSkyBox(GL gl) |
---|
| 16655 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16656 | + |
---|
| 16657 | + private void DrawSkyBox(GL gl, float ratio) |
---|
14318 | 16658 | { |
---|
14319 | | - if (envyoff || cubemap == null) |
---|
| 16659 | + if (//envyoff || |
---|
| 16660 | + cubemap == null) |
---|
14320 | 16661 | { |
---|
14321 | 16662 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
14322 | 16663 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
14331 | 16672 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
14332 | 16673 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
14333 | 16674 | gl.glLoadIdentity(); |
---|
| 16675 | + gl.glScalef(1,ratio,1); |
---|
14334 | 16676 | |
---|
| 16677 | +// colorV[0] = 2; |
---|
| 16678 | +// colorV[1] = 2; |
---|
| 16679 | +// colorV[2] = 2; |
---|
| 16680 | +// colorV[3] = 1; |
---|
| 16681 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16682 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16683 | +// |
---|
| 16684 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16685 | + |
---|
14335 | 16686 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
14336 | 16687 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
14337 | 16688 | |
---|
.. | .. |
---|
14363 | 16714 | { |
---|
14364 | 16715 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
14365 | 16716 | } |
---|
| 16717 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
14366 | 16718 | gl.glMultMatrixd(viewrot_1, 0); |
---|
14367 | 16719 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
14368 | 16720 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
14438 | 16790 | gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS); |
---|
14439 | 16791 | gl.glPushMatrix(); |
---|
14440 | 16792 | gl.glLoadIdentity(); |
---|
14441 | | - PushMatrix(checker.toParent); |
---|
| 16793 | + //PushMatrix(checker.toParent); |
---|
14442 | 16794 | |
---|
14443 | 16795 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
14444 | 16796 | gl.glPushMatrix(); |
---|
.. | .. |
---|
14461 | 16813 | |
---|
14462 | 16814 | gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
14463 | 16815 | |
---|
14464 | | - float step = 0.1666f; //0.25f; |
---|
14465 | | - float stepv = step * 1652 / 998; |
---|
| 16816 | + float step = 2; // 0.1666f; //0.25f; |
---|
| 16817 | + float stepv = 2; // step * 1652 / 998; |
---|
14466 | 16818 | |
---|
14467 | 16819 | int i0 = 0; |
---|
14468 | 16820 | /* |
---|
.. | .. |
---|
14498 | 16850 | /**/ |
---|
14499 | 16851 | //checker.GetMaterial().opacity = 1.1f; |
---|
14500 | 16852 | ////checker.GetMaterial().ambient = 0.99f; |
---|
14501 | | - Object3D.materialstack[Object3D.materialdepth] = checker.material; |
---|
14502 | | - Object3D.selectedstack[Object3D.materialdepth] = false; |
---|
14503 | | - cStatic.objectstack[Object3D.materialdepth++] = checker; |
---|
| 16853 | + materialstack[materialdepth] = checker.material; |
---|
| 16854 | + selectedstack[materialdepth] = false; |
---|
| 16855 | + cStatic.objectstack[materialdepth++] = checker; |
---|
14504 | 16856 | //System.out.println("material " + material); |
---|
14505 | 16857 | //Applet3D.tracein(this, selected); |
---|
14506 | | - vector2buffer = checker.projectedVertices; |
---|
| 16858 | + //vector2buffer = checker.projectedVertices; |
---|
14507 | 16859 | |
---|
14508 | | - checker.GetMaterial().Draw(this, false); // true); |
---|
| 16860 | + //checker.GetMaterial().Draw(this, false); // true); |
---|
| 16861 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
14509 | 16862 | |
---|
14510 | | - Object3D.materialdepth -= 1; |
---|
14511 | | - if (Object3D.materialdepth > 0) |
---|
| 16863 | + materialdepth -= 1; |
---|
| 16864 | + if (materialdepth > 0) |
---|
14512 | 16865 | { |
---|
14513 | | - vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices; |
---|
14514 | | - Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]); |
---|
| 16866 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16867 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
14515 | 16868 | } |
---|
14516 | 16869 | //checker.GetMaterial().opacity = 1f; |
---|
14517 | 16870 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
14532 | 16885 | |
---|
14533 | 16886 | //float u = (i+1)/2; |
---|
14534 | 16887 | //float v = (j+1)/2; |
---|
14535 | | - gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
| 16888 | + if (checker.flipV) |
---|
| 16889 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2); |
---|
| 16890 | + else |
---|
| 16891 | + gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
14536 | 16892 | gl.glVertex3f(i, j, -0.5f); |
---|
14537 | 16893 | |
---|
| 16894 | + if (checker.flipV) |
---|
| 16895 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
| 16896 | + else |
---|
14538 | 16897 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
14539 | 16898 | gl.glVertex3f(i + step, j, -0.5f); |
---|
14540 | 16899 | |
---|
| 16900 | + if (checker.flipV) |
---|
| 16901 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
| 16902 | + else |
---|
14541 | 16903 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
14542 | 16904 | gl.glVertex3f(i + step, j + stepv, -0.5f); |
---|
14543 | 16905 | |
---|
| 16906 | + if (checker.flipV) |
---|
| 16907 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
| 16908 | + else |
---|
14544 | 16909 | gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
14545 | 16910 | gl.glVertex3f(i, j + stepv, -0.5f); |
---|
14546 | 16911 | } |
---|
.. | .. |
---|
14552 | 16917 | gl.glMatrixMode(GL.GL_PROJECTION); |
---|
14553 | 16918 | gl.glPopMatrix(); |
---|
14554 | 16919 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
14555 | | - PopMatrix(null); // checker.toParent); // null); |
---|
| 16920 | + //PopMatrix(null); // checker.toParent); // null); |
---|
14556 | 16921 | gl.glPopMatrix(); |
---|
14557 | 16922 | PopTextureMatrix(checker.toParent); |
---|
14558 | 16923 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
.. | .. |
---|
14585 | 16950 | } |
---|
14586 | 16951 | } |
---|
14587 | 16952 | |
---|
| 16953 | + private Object3D GetFolder() |
---|
| 16954 | + { |
---|
| 16955 | + Object3D folder = object.GetWindow().copy; |
---|
| 16956 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16957 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16958 | + return folder; |
---|
| 16959 | + } |
---|
| 16960 | + |
---|
14588 | 16961 | class SelectBuffer implements GLEventListener |
---|
14589 | 16962 | { |
---|
14590 | 16963 | |
---|
.. | .. |
---|
14600 | 16973 | //new Exception().printStackTrace(); |
---|
14601 | 16974 | System.out.println("select buffer init"); |
---|
14602 | 16975 | // Use debug pipeline |
---|
14603 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 16976 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
14604 | 16977 | |
---|
14605 | 16978 | GL gl = drawable.getGL(); |
---|
14606 | 16979 | |
---|
.. | .. |
---|
14643 | 17016 | { |
---|
14644 | 17017 | if (!selection) |
---|
14645 | 17018 | { |
---|
| 17019 | + new Exception().printStackTrace(); |
---|
14646 | 17020 | System.exit(0); |
---|
14647 | 17021 | return; |
---|
14648 | 17022 | } |
---|
.. | .. |
---|
14663 | 17037 | |
---|
14664 | 17038 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
14665 | 17039 | |
---|
| 17040 | + if (PAINTMODE) |
---|
| 17041 | + { |
---|
| 17042 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17043 | + { |
---|
| 17044 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17045 | + |
---|
| 17046 | + // Make what you paint not selectable. |
---|
| 17047 | + paintobj.ResetSelectable(); |
---|
| 17048 | + } |
---|
| 17049 | + } |
---|
| 17050 | + |
---|
14666 | 17051 | //int tmp = selection_view; |
---|
14667 | 17052 | //selection_view = -1; |
---|
14668 | | - int temp = drawMode; |
---|
14669 | | - drawMode = SELECTION; |
---|
| 17053 | + int temp = DrawMode(); |
---|
| 17054 | + Globals.drawMode = SELECTION; // WARNING |
---|
14670 | 17055 | indexcount = 0; |
---|
14671 | 17056 | parent.display(drawable); |
---|
14672 | 17057 | //selection_view = tmp; |
---|
14673 | 17058 | //if (temp == SELECTION) |
---|
14674 | 17059 | // temp = DEFAULT; // patch for selection debug |
---|
14675 | | - drawMode = temp; |
---|
| 17060 | + Globals.drawMode = temp; // WARNING |
---|
14676 | 17061 | |
---|
| 17062 | + if (PAINTMODE) |
---|
| 17063 | + { |
---|
| 17064 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17065 | + { |
---|
| 17066 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17067 | + |
---|
| 17068 | + // Revert. |
---|
| 17069 | + paintobj.RestoreSelectable(); |
---|
| 17070 | + } |
---|
| 17071 | + } |
---|
| 17072 | + |
---|
14677 | 17073 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
14678 | 17074 | |
---|
14679 | 17075 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
14721 | 17117 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
14722 | 17118 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
14723 | 17119 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 17120 | + |
---|
| 17121 | + CreateSelectedPoint(); |
---|
14724 | 17122 | |
---|
14725 | 17123 | // Will fit the mesh !!! |
---|
14726 | 17124 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
14770 | 17168 | 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])); |
---|
14771 | 17169 | } |
---|
14772 | 17170 | |
---|
14773 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 17171 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
14774 | 17172 | } |
---|
14775 | 17173 | } |
---|
14776 | 17174 | |
---|
14777 | 17175 | if (!movingcamera && !PAINTMODE) |
---|
14778 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17176 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
14779 | 17177 | |
---|
14780 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17178 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
14781 | 17179 | { |
---|
14782 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17180 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
14783 | 17181 | |
---|
14784 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17182 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17183 | + { |
---|
| 17184 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
14785 | 17185 | |
---|
14786 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
14787 | | - |
---|
14788 | | - group.add(paintobj); // link |
---|
14789 | | - |
---|
14790 | | - object.editWindow.SnapObject(group); |
---|
14791 | | - |
---|
14792 | | - Object3D folder = object.editWindow.copy; |
---|
14793 | | - |
---|
14794 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
14795 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
14796 | | - |
---|
14797 | | - folder.add(group); |
---|
14798 | | - |
---|
14799 | | - object.editWindow.ResetModel(); |
---|
14800 | | - object.editWindow.refreshContents(); |
---|
| 17186 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17187 | + |
---|
| 17188 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17189 | + |
---|
| 17190 | + inst.add(paintobj); // link |
---|
| 17191 | + |
---|
| 17192 | + object.GetWindow().SnapObject(inst); |
---|
| 17193 | + |
---|
| 17194 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17195 | + |
---|
| 17196 | + folder.add(inst); |
---|
| 17197 | + |
---|
| 17198 | + object.GetWindow().ResetModel(); |
---|
| 17199 | + object.GetWindow().refreshContents(); |
---|
| 17200 | + } |
---|
14801 | 17201 | } |
---|
14802 | 17202 | else |
---|
14803 | 17203 | paintcount = 0; |
---|
.. | .. |
---|
14836 | 17236 | //System.out.println("objects[color] = " + objects[color]); |
---|
14837 | 17237 | //objects[color].Select(); |
---|
14838 | 17238 | indexcount = 0; |
---|
| 17239 | + ObjEditor window = object.GetWindow(); |
---|
| 17240 | + if (window != null && deselect) |
---|
| 17241 | + { |
---|
| 17242 | + window.Select(null, deselect, true); |
---|
| 17243 | + } |
---|
14839 | 17244 | object.Select(color, deselect); |
---|
14840 | 17245 | } |
---|
14841 | 17246 | |
---|
.. | .. |
---|
14935 | 17340 | gl.glDisable(gl.GL_CULL_FACE); |
---|
14936 | 17341 | } |
---|
14937 | 17342 | |
---|
14938 | | - if (!RENDERSHADOW) |
---|
| 17343 | + if (!Globals.RENDERSHADOW) |
---|
14939 | 17344 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14940 | 17345 | |
---|
14941 | 17346 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
14945 | 17350 | //gl.glColorMask(false, false, false, false); |
---|
14946 | 17351 | |
---|
14947 | 17352 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
14948 | | - if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17353 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
14949 | 17354 | { |
---|
14950 | 17355 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14951 | 17356 | |
---|
14952 | | - int temp = drawMode; |
---|
14953 | | - drawMode = SHADOW; |
---|
| 17357 | + int temp = DrawMode(); |
---|
| 17358 | + Globals.drawMode = SHADOW; // WARNING |
---|
14954 | 17359 | parent.display(drawable); |
---|
14955 | | - drawMode = temp; |
---|
| 17360 | + Globals.drawMode = temp; // WARNING |
---|
14956 | 17361 | } |
---|
14957 | 17362 | |
---|
14958 | 17363 | gl.glCullFace(gl.GL_BACK); |
---|
.. | .. |
---|
15005 | 17410 | |
---|
15006 | 17411 | class AntialiasBuffer implements GLEventListener |
---|
15007 | 17412 | { |
---|
15008 | | - |
---|
15009 | 17413 | CameraPane parent = null; |
---|
15010 | 17414 | |
---|
15011 | 17415 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
15115 | 17519 | gl.glFlush(); |
---|
15116 | 17520 | |
---|
15117 | 17521 | /**/ |
---|
15118 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer); |
---|
| 17522 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
15119 | 17523 | |
---|
15120 | | - int[] pixels = occlusionsizebuffer.array(); |
---|
| 17524 | + float[] pixels = occlusionsizebuffer.array(); |
---|
15121 | 17525 | |
---|
15122 | 17526 | double r = 0, g = 0, b = 0; |
---|
15123 | 17527 | |
---|
15124 | 17528 | double count = 0; |
---|
| 17529 | + |
---|
| 17530 | + gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0); |
---|
| 17531 | + |
---|
| 17532 | + float mindepth = 1; |
---|
| 17533 | + |
---|
| 17534 | + double FACTOR = 1; |
---|
15125 | 17535 | |
---|
15126 | 17536 | for (int i = 0; i < pixels.length; i++) |
---|
15127 | 17537 | { |
---|
.. | .. |
---|
15206 | 17616 | |
---|
15207 | 17617 | double scale = ray.z; // 1; // cos |
---|
15208 | 17618 | |
---|
15209 | | - int p = pixels[newindex]; |
---|
| 17619 | + float depth = pixels[newindex]; |
---|
15210 | 17620 | |
---|
15211 | 17621 | /* |
---|
15212 | 17622 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
15230 | 17640 | scale = (1 - modu) * modv; |
---|
15231 | 17641 | */ |
---|
15232 | 17642 | |
---|
15233 | | - r += ((p >> 16) & 0xFF) * scale / 255; |
---|
15234 | | - g += ((p >> 8) & 0xFF) * scale / 255; |
---|
15235 | | - b += (p & 0xFF) * scale / 255; |
---|
| 17643 | + //r += ((p >> 16) & 0xFF) * scale / 255; |
---|
| 17644 | + //g += ((p >> 8) & 0xFF) * scale / 255; |
---|
| 17645 | + //b += (p & 0xFF) * scale / 255; |
---|
| 17646 | + |
---|
| 17647 | + if (mindepth > depth) |
---|
| 17648 | + { |
---|
| 17649 | + mindepth = depth; |
---|
| 17650 | + } |
---|
15236 | 17651 | |
---|
| 17652 | + double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]); |
---|
| 17653 | + |
---|
| 17654 | + double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR); |
---|
| 17655 | + |
---|
| 17656 | + r += factor * scale; |
---|
| 17657 | + g += factor * scale; |
---|
| 17658 | + b += factor * scale; |
---|
| 17659 | + |
---|
15237 | 17660 | count += scale; |
---|
15238 | 17661 | } |
---|
15239 | 17662 | |
---|
.. | .. |
---|
15331 | 17754 | GLUT glut = new GLUT(); |
---|
15332 | 17755 | |
---|
15333 | 17756 | |
---|
15334 | | - static final public int DEFAULT = 0; |
---|
15335 | | - static final public int SELECTION = 1; |
---|
15336 | | - static final public int SHADOW = 2; |
---|
15337 | | - static final public int OCCLUSION = 3; |
---|
15338 | | - static |
---|
15339 | | - public int drawMode = DEFAULT; |
---|
15340 | 17757 | public boolean spherical = false; |
---|
15341 | 17758 | static boolean DEBUG_OCCLUSION = false; |
---|
15342 | 17759 | static boolean DEBUG_SELECTION = false; |
---|
.. | .. |
---|
15349 | 17766 | int AAbuffersize = 0; |
---|
15350 | 17767 | |
---|
15351 | 17768 | //double[] selectedpoint = new double[3]; |
---|
15352 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17769 | + static Superellipsoid selectedpoint; |
---|
15353 | 17770 | static Sphere previousselectedpoint = null; |
---|
15354 | | - static Sphere debugpoint = new Sphere(); |
---|
15355 | | - static Sphere debugpoint2 = new Sphere(); |
---|
15356 | | - static Sphere debugpoint3 = new Sphere(); |
---|
15357 | | - static Sphere debugpoint4 = new Sphere(); |
---|
| 17771 | + static Sphere debugpointG; |
---|
| 17772 | + static Sphere debugpointP; |
---|
| 17773 | + static Sphere debugpointC; |
---|
| 17774 | + static Sphere debugpointR; |
---|
15358 | 17775 | |
---|
15359 | 17776 | static Sphere debugpoints[] = new Sphere[8]; |
---|
15360 | 17777 | |
---|
15361 | | - static |
---|
15362 | | - { |
---|
15363 | | - for (int i=0; i<8; i++) |
---|
15364 | | - { |
---|
15365 | | - debugpoints[i] = new Sphere(); |
---|
15366 | | - } |
---|
15367 | | - } |
---|
15368 | | - |
---|
15369 | 17778 | static void InitPoints(float radius) |
---|
15370 | 17779 | { |
---|
15371 | 17780 | for (int i=0; i<8; i++) |
---|
.. | .. |
---|
15385 | 17794 | } |
---|
15386 | 17795 | } |
---|
15387 | 17796 | |
---|
15388 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17797 | + static void DrawPoints(iCameraPane cpane) |
---|
15389 | 17798 | { |
---|
15390 | 17799 | for (int i=0; i<8; i++) // first and last are red |
---|
15391 | 17800 | { |
---|
.. | .. |
---|
15407 | 17816 | static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
15408 | 17817 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15409 | 17818 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15410 | | - static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17819 | + //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17820 | + static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
15411 | 17821 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
15412 | 17822 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
15413 | 17823 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|
.. | .. |
---|
15416 | 17826 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
15417 | 17827 | // Depth buffer format |
---|
15418 | 17828 | //private int depth_format; |
---|
15419 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17829 | + |
---|
| 17830 | + public void NextIndex() |
---|
15420 | 17831 | { |
---|
15421 | 17832 | indexcount+=16; |
---|
15422 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17833 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
15423 | 17834 | //objects[indexcount] = o; |
---|
15424 | 17835 | //System.out.println("indexcount = " + indexcount); |
---|
15425 | 17836 | } |
---|