.. | .. |
---|
31 | 31 | |
---|
32 | 32 | import gleem.linalg.Mat4f; |
---|
33 | 33 | |
---|
34 | | -class CameraPane extends GLCanvas implements Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
| 34 | +class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 35 | { |
---|
| 36 | + static cMaterial[] materialstack = new cMaterial[65536]; |
---|
| 37 | + static boolean[] selectedstack = new boolean[65536]; |
---|
| 38 | + static int materialdepth = 0; |
---|
| 39 | + |
---|
36 | 40 | static boolean DEBUG = false; |
---|
37 | 41 | static boolean FRUSTUM = false; // still bogus true; // frustum culling |
---|
38 | 42 | |
---|
.. | .. |
---|
42 | 46 | |
---|
43 | 47 | static int STEP = 1; |
---|
44 | 48 | |
---|
45 | | - static boolean ONESTEP = false; // do LIVE once |
---|
46 | | - |
---|
47 | | - /** |
---|
48 | | - * @return the LIVE |
---|
49 | | - */ |
---|
50 | | - public static boolean isLIVE() |
---|
51 | | - { |
---|
52 | | - return LIVE || ONESTEP; |
---|
53 | | - } |
---|
54 | | - |
---|
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; |
---|
| 49 | + /*static*/ private boolean CULLFACE = false; // true; |
---|
64 | 50 | /*static*/ boolean NEAREST = false; // true; |
---|
65 | 51 | /*static*/ boolean WIREFRAME = false; // true; |
---|
66 | 52 | |
---|
.. | .. |
---|
70 | 56 | static int CURRENTANTIALIAS = 0; // 1; |
---|
71 | 57 | /*static*/ boolean RENDERSHADOW = true; |
---|
72 | 58 | /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal |
---|
73 | | - static boolean ANIMATION = false; |
---|
74 | | - static String filename; |
---|
75 | 59 | |
---|
76 | 60 | boolean DISPLAYTEXT = false; |
---|
77 | 61 | //boolean REDUCETEXTURE = true; |
---|
.. | .. |
---|
97 | 81 | |
---|
98 | 82 | static boolean textureon = true; |
---|
99 | 83 | static boolean LOCALTRANSFORM = false; |
---|
100 | | -private static boolean LIVE = false; |
---|
101 | 84 | static boolean FULLSCREEN = false; |
---|
102 | 85 | static boolean SUPPORT = true; |
---|
103 | | -static boolean CROWD = false; |
---|
104 | 86 | static boolean INERTIA = true; |
---|
105 | 87 | static boolean FAST = false; |
---|
106 | 88 | static boolean SLOWPOSE = false; |
---|
.. | .. |
---|
108 | 90 | |
---|
109 | 91 | static int tickcount = 0; // slow pose issue |
---|
110 | 92 | |
---|
| 93 | +static boolean BUTTONLESSWHEEL = false; |
---|
| 94 | +static boolean ZOOMBOXMODE = false; |
---|
111 | 95 | static boolean BOXMODE = false; |
---|
112 | 96 | static boolean IMAGEFLIP = false; |
---|
113 | 97 | static boolean SMOOTHFOCUS = false; |
---|
.. | .. |
---|
122 | 106 | static boolean OEIL = true; |
---|
123 | 107 | static boolean OEILONCE = false; // do oeilon then oeiloff |
---|
124 | 108 | static boolean LOOKAT = true; |
---|
125 | | -static boolean RANDOM = true; // false; |
---|
| 109 | +static boolean SWITCH = true; // false; |
---|
126 | 110 | static boolean HANDLES = false; // selection doesn't work!! |
---|
127 | 111 | static boolean PAINTMODE = false; |
---|
128 | 112 | |
---|
.. | .. |
---|
165 | 149 | defaultcaps.setAccumBlueBits(16); |
---|
166 | 150 | defaultcaps.setAccumAlphaBits(16); |
---|
167 | 151 | } |
---|
168 | | - static CameraPane theRenderer; |
---|
169 | | - |
---|
| 152 | + |
---|
| 153 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 154 | + |
---|
170 | 155 | void SetAsGLRenderer(boolean b) |
---|
171 | 156 | { |
---|
172 | 157 | isRenderer = b; |
---|
173 | | - theRenderer = this; |
---|
| 158 | + Globals.theRenderer = this; |
---|
174 | 159 | } |
---|
175 | 160 | |
---|
176 | 161 | CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
.. | .. |
---|
206 | 191 | return CURRENTANTIALIAS > 0; |
---|
207 | 192 | } |
---|
208 | 193 | |
---|
209 | | - void ClearDepth() |
---|
| 194 | + /// INTERFACE |
---|
| 195 | + |
---|
| 196 | + public javax.media.opengl.GL GetGL0() |
---|
| 197 | + { |
---|
| 198 | + return null; |
---|
| 199 | + } |
---|
| 200 | + |
---|
| 201 | + public int GenList() |
---|
| 202 | + { |
---|
| 203 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 204 | + return gl.glGenLists(1); |
---|
| 205 | + } |
---|
| 206 | + |
---|
| 207 | + public void NewList(int id) |
---|
| 208 | + { |
---|
| 209 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 210 | + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 211 | + } |
---|
| 212 | + |
---|
| 213 | + public void CallList(int id) |
---|
| 214 | + { |
---|
| 215 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 216 | + gl.glCallList(id); |
---|
| 217 | + } |
---|
| 218 | + |
---|
| 219 | + public void EndList() |
---|
| 220 | + { |
---|
| 221 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 222 | + gl.glEndList(); |
---|
| 223 | + } |
---|
| 224 | + |
---|
| 225 | + public boolean IsBoxMode() |
---|
| 226 | + { |
---|
| 227 | + return BOXMODE; |
---|
| 228 | + } |
---|
| 229 | + |
---|
| 230 | + public boolean IsZoomBoxMode() |
---|
| 231 | + { |
---|
| 232 | + return ZOOMBOXMODE; |
---|
| 233 | + } |
---|
| 234 | + |
---|
| 235 | + public void ClearDepth() |
---|
210 | 236 | { |
---|
211 | 237 | GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT); |
---|
212 | 238 | } |
---|
213 | 239 | |
---|
214 | | - void DepthTest(boolean depthtest) |
---|
| 240 | + public void DepthTest(boolean depthtest) |
---|
215 | 241 | { |
---|
216 | 242 | if (depthtest) |
---|
217 | 243 | GetGL().glDepthFunc(GL.GL_LEQUAL); |
---|
.. | .. |
---|
219 | 245 | GetGL().glDepthFunc(GL.GL_ALWAYS); |
---|
220 | 246 | } |
---|
221 | 247 | |
---|
222 | | - void DepthWrite(boolean depthwrite) |
---|
| 248 | + public void DepthWrite(boolean depthwrite) |
---|
223 | 249 | { |
---|
224 | 250 | if (depthwrite) |
---|
225 | 251 | GetGL().glDepthMask(true); |
---|
.. | .. |
---|
227 | 253 | GetGL().glDepthMask(false); |
---|
228 | 254 | } |
---|
229 | 255 | |
---|
230 | | - void BackFaceCull(boolean bfc) |
---|
| 256 | + public void BackFaceCull(boolean bfc) |
---|
231 | 257 | { |
---|
232 | 258 | if (bfc) |
---|
233 | 259 | GetGL().glEnable(GetGL().GL_CULL_FACE); |
---|
234 | 260 | else |
---|
235 | 261 | GetGL().glDisable(GetGL().GL_CULL_FACE); |
---|
| 262 | + } |
---|
| 263 | + |
---|
| 264 | + public boolean BackFaceCullMode() |
---|
| 265 | + { |
---|
| 266 | + return this.CULLFACE; |
---|
| 267 | + } |
---|
| 268 | + |
---|
| 269 | + public boolean IsAmbientOcclusionOn() |
---|
| 270 | + { |
---|
| 271 | + return this.ambientOcclusion; |
---|
| 272 | + } |
---|
| 273 | + |
---|
| 274 | + public boolean IsDebugSelection() |
---|
| 275 | + { |
---|
| 276 | + return DEBUG_SELECTION; |
---|
| 277 | + } |
---|
| 278 | + |
---|
| 279 | + public boolean IsFrozen() |
---|
| 280 | + { |
---|
| 281 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
| 282 | + |
---|
| 283 | + return !selectmode && cameracount == 0; // != 0; |
---|
| 284 | + } |
---|
| 285 | + |
---|
| 286 | + // Currently in Globals |
---|
| 287 | + public int DrawMode() |
---|
| 288 | + { |
---|
| 289 | + return Globals.DrawMode(); |
---|
| 290 | + } |
---|
| 291 | + |
---|
| 292 | + public Camera EyeCamera() |
---|
| 293 | + { |
---|
| 294 | + return eyeCamera; |
---|
| 295 | + } |
---|
| 296 | + |
---|
| 297 | + public Camera LightCamera() |
---|
| 298 | + { |
---|
| 299 | + return lightCamera; |
---|
| 300 | + } |
---|
| 301 | + |
---|
| 302 | + public Camera ManipCamera() |
---|
| 303 | + { |
---|
| 304 | + return manipCamera; |
---|
| 305 | + } |
---|
| 306 | + |
---|
| 307 | + public Camera RenderCamera() |
---|
| 308 | + { |
---|
| 309 | + return renderCamera; |
---|
| 310 | + } |
---|
| 311 | + |
---|
| 312 | + public Camera[] Cameras() |
---|
| 313 | + { |
---|
| 314 | + return cameras; |
---|
| 315 | + } |
---|
| 316 | + |
---|
| 317 | + public void PushMaterial(Object3D obj, boolean selected) |
---|
| 318 | + { |
---|
| 319 | + CameraPane display = this; |
---|
| 320 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 321 | + cMaterial material = obj.material; |
---|
| 322 | + |
---|
| 323 | + if (material != null) |
---|
| 324 | + { |
---|
| 325 | + materialstack[materialdepth] = material; |
---|
| 326 | + selectedstack[materialdepth] = selected; |
---|
| 327 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 328 | + //System.out.println("material " + material); |
---|
| 329 | + //Applet3D.tracein(this, selected); |
---|
| 330 | + display.vector2buffer = obj.projectedVertices; |
---|
| 331 | + if (obj instanceof Camera) |
---|
| 332 | + { |
---|
| 333 | + display.options1[0] = material.shift; |
---|
| 334 | + //System.out.println("shift " + material.shift); |
---|
| 335 | + display.options1[1] = material.lightarea; |
---|
| 336 | + display.options1[2] = material.shadowbias; |
---|
| 337 | + display.options1[3] = material.aniso; |
---|
| 338 | + display.options1[4] = material.anisoV; |
---|
| 339 | + display.options2[0] = material.opacity; |
---|
| 340 | + display.options2[1] = material.diffuse; |
---|
| 341 | + display.options2[2] = material.factor; |
---|
| 342 | + |
---|
| 343 | + cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 344 | + display.options4[0] = material.cameralight/0.2f; |
---|
| 345 | + display.options4[1] = material.subsurface; |
---|
| 346 | + display.options4[2] = material.sheen; |
---|
| 347 | + |
---|
| 348 | + // if (display.CURRENTANTIALIAS > 0) |
---|
| 349 | + // display.options3[3] /= 4; |
---|
| 350 | + |
---|
| 351 | + /* |
---|
| 352 | + System.out.println("Focus = " + display.options1[0]); |
---|
| 353 | + System.out.println("Aperture = " + display.options1[1]); |
---|
| 354 | + System.out.println("ShadowBlur = " + display.options1[2]); |
---|
| 355 | + System.out.println("Antialiasing = " + display.options1[3]); |
---|
| 356 | + System.out.println("Fog = " + display.options2[0]); |
---|
| 357 | + System.out.println("Intensity = " + display.options2[1]); |
---|
| 358 | + System.out.println("Elevation = " + display.options2[2]); |
---|
| 359 | + /**/ |
---|
| 360 | + } else |
---|
| 361 | + { |
---|
| 362 | + DrawMaterial(material, selected); |
---|
| 363 | + } |
---|
| 364 | + } else |
---|
| 365 | + { |
---|
| 366 | + if (selected && CameraPane.flash) |
---|
| 367 | + { |
---|
| 368 | + display.modelParams4[1] = 100; |
---|
| 369 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 370 | + } |
---|
| 371 | + } |
---|
| 372 | + } |
---|
| 373 | + |
---|
| 374 | + public void PushMaterial2(Object3D obj, boolean selected) |
---|
| 375 | + { |
---|
| 376 | + CameraPane display = this; |
---|
| 377 | + cMaterial material = obj.material; |
---|
| 378 | + |
---|
| 379 | + if (material != null) |
---|
| 380 | + { |
---|
| 381 | + materialstack[materialdepth] = material; |
---|
| 382 | + selectedstack[materialdepth] = selected; |
---|
| 383 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 384 | + //System.out.println("material " + material); |
---|
| 385 | + //Applet3D.tracein("selected ", selected); |
---|
| 386 | + display.vector2buffer = obj.projectedVertices; |
---|
| 387 | + display.DrawMaterial(material, selected); |
---|
| 388 | + } |
---|
| 389 | + } |
---|
| 390 | + |
---|
| 391 | + public void PopMaterial(Object3D obj, boolean selected) |
---|
| 392 | + { |
---|
| 393 | + CameraPane display = this; |
---|
| 394 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 395 | + cMaterial material = obj.material; |
---|
| 396 | + |
---|
| 397 | + //if (parent != null && parent.GetMaterial() != null) |
---|
| 398 | + // parent.GetMaterial().Draw(display, parent.IsSelected(this)); |
---|
| 399 | + if (material != null) |
---|
| 400 | + { |
---|
| 401 | + materialdepth -= 1; |
---|
| 402 | + if (materialdepth > 0) |
---|
| 403 | + { |
---|
| 404 | + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 405 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 406 | + } |
---|
| 407 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 408 | + } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
| 409 | + { |
---|
| 410 | + display.modelParams4[1] = obj.GetMaterial().cameralight; |
---|
| 411 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 412 | + } |
---|
| 413 | + } |
---|
| 414 | + |
---|
| 415 | + public void PopMaterial2(Object3D obj) |
---|
| 416 | + { |
---|
| 417 | + CameraPane display = this; |
---|
| 418 | + cMaterial material = obj.material; |
---|
| 419 | + |
---|
| 420 | + if (material != null) |
---|
| 421 | + { |
---|
| 422 | + materialdepth -= 1; |
---|
| 423 | + if (materialdepth > 0) |
---|
| 424 | + { |
---|
| 425 | + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 426 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 427 | + } |
---|
| 428 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 429 | + //else |
---|
| 430 | + //material.Draw(display, false); |
---|
| 431 | + } |
---|
| 432 | + } |
---|
| 433 | + |
---|
| 434 | + public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face) |
---|
| 435 | + { |
---|
| 436 | + CameraPane display = this; |
---|
| 437 | + |
---|
| 438 | + if (pv.y == -10000 || |
---|
| 439 | + qv.y == -10000 || |
---|
| 440 | + rv.y == -10000) |
---|
| 441 | + return; |
---|
| 442 | + |
---|
| 443 | +// float b = f.nbiterations & 1; |
---|
| 444 | +// float g = (f.nbiterations>>1) & 1; |
---|
| 445 | +// float r = (f.nbiterations>>2) & 1; |
---|
| 446 | +// |
---|
| 447 | +// //if (f.weight == 10000) |
---|
| 448 | +// //{ |
---|
| 449 | +// // r = 1; g = b = 0; |
---|
| 450 | +// //} |
---|
| 451 | +// //else |
---|
| 452 | +// //{ |
---|
| 453 | +// // assert(f.weight < 10000); |
---|
| 454 | +// r = g = b = (float)bRep.FaceWeight(f)*100; |
---|
| 455 | +// if (r<0) |
---|
| 456 | +// assert(r>=0); |
---|
| 457 | +// //} |
---|
| 458 | + |
---|
| 459 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 460 | + |
---|
| 461 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
| 462 | + |
---|
| 463 | + //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
| 464 | + if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
| 465 | + { |
---|
| 466 | + //gl.glBegin(gl.GL_TRIANGLES); |
---|
| 467 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 468 | + if (!hasnorm) |
---|
| 469 | + { |
---|
| 470 | + // System.out.println("FUCK!!"); |
---|
| 471 | + LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
| 472 | + LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
| 473 | + LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
| 474 | + LA.vecNormalize(obj.v2); |
---|
| 475 | + gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 476 | + } |
---|
| 477 | + |
---|
| 478 | + // P |
---|
| 479 | + float x = (float)pv.x; |
---|
| 480 | + float y = (float)pv.y; |
---|
| 481 | + float z = (float)pv.z; |
---|
| 482 | + |
---|
| 483 | + if (hasnorm) |
---|
| 484 | + { |
---|
| 485 | +// if (!pv.norm.normalized()) |
---|
| 486 | +// assert(pv.norm.normalized()); |
---|
| 487 | + |
---|
| 488 | + //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z); |
---|
| 489 | + float nx = (float)pv.norm.x; |
---|
| 490 | + float ny = (float)pv.norm.y; |
---|
| 491 | + float nz = (float)pv.norm.z; |
---|
| 492 | + |
---|
| 493 | + x += nx * obj.NORMALPUSH; |
---|
| 494 | + y += ny * obj.NORMALPUSH; |
---|
| 495 | + z += nz * obj.NORMALPUSH; |
---|
| 496 | + |
---|
| 497 | + gl.glNormal3f(nx, ny, nz); |
---|
| 498 | + } |
---|
| 499 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 500 | + SetColor(obj, pv); |
---|
| 501 | + //gl.glColor4f(r, g, b, 1); |
---|
| 502 | + //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1); |
---|
| 503 | + if (obj.flipV) |
---|
| 504 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 505 | + else |
---|
| 506 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 507 | + //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z); |
---|
| 508 | + |
---|
| 509 | + gl.glVertex3f(x, y, z); |
---|
| 510 | + |
---|
| 511 | + // Q |
---|
| 512 | + x = (float)qv.x; |
---|
| 513 | + y = (float)qv.y; |
---|
| 514 | + z = (float)qv.z; |
---|
| 515 | + |
---|
| 516 | +// Print(pv); |
---|
| 517 | + if (hasnorm) |
---|
| 518 | + { |
---|
| 519 | +// assert(qv.norm.normalized()); |
---|
| 520 | + //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z); |
---|
| 521 | + float nx = (float)qv.norm.x; |
---|
| 522 | + float ny = (float)qv.norm.y; |
---|
| 523 | + float nz = (float)qv.norm.z; |
---|
| 524 | + |
---|
| 525 | + x += nx * obj.NORMALPUSH; |
---|
| 526 | + y += ny * obj.NORMALPUSH; |
---|
| 527 | + z += nz * obj.NORMALPUSH; |
---|
| 528 | + |
---|
| 529 | + gl.glNormal3f(nx, ny, nz); |
---|
| 530 | + } |
---|
| 531 | + //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
| 532 | + // boolean locked = false; |
---|
| 533 | + // float eps = 0.1f; |
---|
| 534 | + // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 535 | + |
---|
| 536 | + // int dot = 0; //*/ (int)f.dot; |
---|
| 537 | + |
---|
| 538 | + // if ((dot&1) == 0) |
---|
| 539 | + // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 540 | + |
---|
| 541 | + // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 542 | + if (obj.flipV) |
---|
| 543 | + gl.glTexCoord2f((float) qv.s, 1-(float) qv.t); |
---|
| 544 | + else |
---|
| 545 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 546 | + // else |
---|
| 547 | + // { |
---|
| 548 | + // locked = true; |
---|
| 549 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 550 | + // } |
---|
| 551 | + gl.glColor4f(qv.AO, qv.AO, qv.AO, 1); |
---|
| 552 | + SetColor(obj, qv); |
---|
| 553 | + |
---|
| 554 | + gl.glVertex3f(x, y, z); |
---|
| 555 | + //gl.glColor4f(r, g, b, 1); |
---|
| 556 | + //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1); |
---|
| 557 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 558 | +// Print(qv); |
---|
| 559 | + |
---|
| 560 | + // R |
---|
| 561 | + x = (float)rv.x; |
---|
| 562 | + y = (float)rv.y; |
---|
| 563 | + z = (float)rv.z; |
---|
| 564 | + |
---|
| 565 | + if (hasnorm) |
---|
| 566 | + { |
---|
| 567 | +// assert(rv.norm.normalized()); |
---|
| 568 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 569 | + float nx = (float)rv.norm.x; |
---|
| 570 | + float ny = (float)rv.norm.y; |
---|
| 571 | + float nz = (float)rv.norm.z; |
---|
| 572 | + |
---|
| 573 | + x += nx * obj.NORMALPUSH; |
---|
| 574 | + y += ny * obj.NORMALPUSH; |
---|
| 575 | + z += nz * obj.NORMALPUSH; |
---|
| 576 | + |
---|
| 577 | + gl.glNormal3f(nx, ny, nz); |
---|
| 578 | + } |
---|
| 579 | + |
---|
| 580 | + // if ((dot&4) == 0) |
---|
| 581 | + // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 582 | + |
---|
| 583 | + // if (wrap || !locked && (dot&8) != 0) |
---|
| 584 | + if (obj.flipV) |
---|
| 585 | + gl.glTexCoord2f((float) rv.s, 1-(float) rv.t); |
---|
| 586 | + else |
---|
| 587 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 588 | + // else |
---|
| 589 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 590 | + |
---|
| 591 | + // f.dot = dot; |
---|
| 592 | + |
---|
| 593 | + gl.glColor4f(rv.AO, rv.AO, rv.AO, 1); |
---|
| 594 | + SetColor(obj, rv); |
---|
| 595 | + //gl.glColor4f(r, g, b, 1); |
---|
| 596 | + //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1); |
---|
| 597 | + //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z); |
---|
| 598 | + gl.glVertex3f(x, y, z); |
---|
| 599 | +// Print(rv); |
---|
| 600 | + //gl.glEnd(); |
---|
| 601 | + } |
---|
| 602 | + else |
---|
| 603 | + { |
---|
| 604 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 605 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 606 | + gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z); |
---|
| 607 | + |
---|
| 608 | + } |
---|
| 609 | + |
---|
| 610 | + if (false) // (attributes & WIREFRAME) != 0) |
---|
| 611 | + { |
---|
| 612 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 613 | + |
---|
| 614 | + gl.glBegin(gl.GL_LINE_LOOP); |
---|
| 615 | + gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z); |
---|
| 616 | + gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z); |
---|
| 617 | + gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z); |
---|
| 618 | + gl.glEnd(); |
---|
| 619 | + |
---|
| 620 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 621 | + } |
---|
| 622 | + } |
---|
| 623 | + |
---|
| 624 | + /** |
---|
| 625 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 626 | + * it's normals, colors, textures and vertices. |
---|
| 627 | + * |
---|
| 628 | + * @see Renderer#draw(TriMesh) |
---|
| 629 | + * @param tris |
---|
| 630 | + * the mesh to render. |
---|
| 631 | + */ |
---|
| 632 | + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 633 | + { |
---|
| 634 | + CameraPane display = this; |
---|
| 635 | + |
---|
| 636 | + float r = display.modelParams0[0]; |
---|
| 637 | + float g = display.modelParams0[1]; |
---|
| 638 | + float b = display.modelParams0[2]; |
---|
| 639 | + float opacity = display.modelParams5[1]; |
---|
| 640 | + |
---|
| 641 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 642 | + GL gl = display.GetGL(); // getGL(); |
---|
| 643 | + |
---|
| 644 | + FloatBuffer vertBuf = geo.vertBuf; |
---|
| 645 | + |
---|
| 646 | + int v = vertBuf.capacity(); |
---|
| 647 | + |
---|
| 648 | + int count = 0; |
---|
| 649 | + |
---|
| 650 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 651 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 652 | + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
| 653 | + for (int i=0; i<v/3; i++) |
---|
| 654 | + { |
---|
| 655 | + int index3 = i*3; |
---|
| 656 | + |
---|
| 657 | + if (geo.sizeBuf.get(index3+1) == 0) |
---|
| 658 | + continue; |
---|
| 659 | + |
---|
| 660 | + count++; |
---|
| 661 | + |
---|
| 662 | + int index4 = i*4; |
---|
| 663 | + |
---|
| 664 | + float tx = vertBuf.get(index3); |
---|
| 665 | + float ty = vertBuf.get(index3+1); |
---|
| 666 | + float tz = vertBuf.get(index3+2); |
---|
| 667 | + |
---|
| 668 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 669 | + // continue; |
---|
| 670 | + |
---|
| 671 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 672 | + gl.glPushMatrix(); |
---|
| 673 | + |
---|
| 674 | + float[] texmat = geo.texmat; |
---|
| 675 | + texmat[12] = texmat[13] = texmat[14] = i; |
---|
| 676 | + |
---|
| 677 | + gl.glMultMatrixf(texmat, 0); |
---|
| 678 | + |
---|
| 679 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 680 | + gl.glPushMatrix(); |
---|
| 681 | + |
---|
| 682 | + gl.glTranslatef(tx,ty,tz); |
---|
| 683 | + |
---|
| 684 | + if (rotate) |
---|
| 685 | + gl.glRotatef(i, 0, 1, 0); |
---|
| 686 | + |
---|
| 687 | + float size = geo.sizeBuf.get(index3) / 100; |
---|
| 688 | + gl.glScalef(size,size,size); |
---|
| 689 | + |
---|
| 690 | + float cr = geo.colorBuf.get(index4); |
---|
| 691 | + float cg = geo.colorBuf.get(index4+1); |
---|
| 692 | + float cb = geo.colorBuf.get(index4+2); |
---|
| 693 | + float ca = geo.colorBuf.get(index4+3); |
---|
| 694 | + |
---|
| 695 | + display.modelParams0[0] = r * cr; |
---|
| 696 | + display.modelParams0[1] = g * cg; |
---|
| 697 | + display.modelParams0[2] = b * cb; |
---|
| 698 | + |
---|
| 699 | + display.modelParams5[1] = opacity * ca; |
---|
| 700 | + |
---|
| 701 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 702 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 703 | + |
---|
| 704 | + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; |
---|
| 705 | + RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 706 | + |
---|
| 707 | +// gl.glColor4f(cr,cg,cb,ca); |
---|
| 708 | + // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 709 | + shape.Draw/*Node*/(display,null,selected,false); // blocked |
---|
| 710 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 711 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 712 | + gl.glPopMatrix(); |
---|
| 713 | + |
---|
| 714 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 715 | + gl.glPopMatrix(); |
---|
| 716 | + } |
---|
| 717 | + // gl.glScalef(1024,1024,1024); |
---|
| 718 | + if (!cf) |
---|
| 719 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 720 | + |
---|
| 721 | + display.modelParams0[0] = r; |
---|
| 722 | + display.modelParams0[1] = g; |
---|
| 723 | + display.modelParams0[2] = b; |
---|
| 724 | + |
---|
| 725 | + display.modelParams5[1] = opacity; |
---|
| 726 | + |
---|
| 727 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 728 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 729 | + |
---|
| 730 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 731 | + |
---|
| 732 | +// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
| 733 | + if (true) |
---|
| 734 | + return; |
---|
| 735 | + |
---|
| 736 | +//// if (!tris.predraw(this)) |
---|
| 737 | +//// { |
---|
| 738 | +//// return; |
---|
| 739 | +//// } |
---|
| 740 | +//// if (Debug.stats) |
---|
| 741 | +//// { |
---|
| 742 | +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
| 743 | +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
| 744 | +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
| 745 | +//// } |
---|
| 746 | +//// |
---|
| 747 | +//// if (tris.getDisplayListID() != -1) |
---|
| 748 | +//// { |
---|
| 749 | +//// renderDisplayList(tris); |
---|
| 750 | +//// return; |
---|
| 751 | +//// } |
---|
| 752 | +//// |
---|
| 753 | +//// if (!generatingDisplayList) |
---|
| 754 | +//// { |
---|
| 755 | +//// applyStates(tris.states, tris); |
---|
| 756 | +//// } |
---|
| 757 | +//// if (Debug.stats) |
---|
| 758 | +//// { |
---|
| 759 | +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
| 760 | +//// } |
---|
| 761 | +//// boolean transformed = doTransforms(tris); |
---|
| 762 | +// |
---|
| 763 | +// int glMode = GL.GL_TRIANGLES; |
---|
| 764 | +// switch (getMode()) |
---|
| 765 | +// { |
---|
| 766 | +// case Triangles: |
---|
| 767 | +// glMode = GL.GL_TRIANGLES; |
---|
| 768 | +// break; |
---|
| 769 | +// case Strip: |
---|
| 770 | +// glMode = GL.GL_TRIANGLE_STRIP; |
---|
| 771 | +// break; |
---|
| 772 | +// case Fan: |
---|
| 773 | +// glMode = GL.GL_TRIANGLE_FAN; |
---|
| 774 | +// break; |
---|
| 775 | +// } |
---|
| 776 | +// |
---|
| 777 | +// if (!predrawGeometry(gl)) |
---|
| 778 | +// { |
---|
| 779 | +// // make sure only the necessary indices are sent through on old |
---|
| 780 | +// // cards. |
---|
| 781 | +// IntBuffer indices = this.getIndexBuffer(); |
---|
| 782 | +// if (indices == null) |
---|
| 783 | +// { |
---|
| 784 | +// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
| 785 | +// } else |
---|
| 786 | +// { |
---|
| 787 | +// indices.rewind(); |
---|
| 788 | +// indices.limit(this.getMaxIndex()); |
---|
| 789 | +// |
---|
| 790 | +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
| 791 | +// |
---|
| 792 | +// indices.clear(); |
---|
| 793 | +// } |
---|
| 794 | +// } else |
---|
| 795 | +// { |
---|
| 796 | +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
| 797 | +// GL.GL_UNSIGNED_INT, 0); |
---|
| 798 | +// } |
---|
| 799 | +// |
---|
| 800 | +//// postdrawGeometry(tris); |
---|
| 801 | +//// if (transformed) |
---|
| 802 | +//// { |
---|
| 803 | +//// undoTransforms(tris); |
---|
| 804 | +//// } |
---|
| 805 | +//// |
---|
| 806 | +//// if (Debug.stats) |
---|
| 807 | +//// { |
---|
| 808 | +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
| 809 | +//// } |
---|
| 810 | +//// tris.postdraw(this); |
---|
| 811 | + } |
---|
| 812 | + |
---|
| 813 | + static Camera localcamera = new Camera(); |
---|
| 814 | + static cVector from = new cVector(); |
---|
| 815 | + static cVector to = new cVector(); |
---|
| 816 | + |
---|
| 817 | + public void PrepOcclusion(BoundaryRep br, double[][] transform) |
---|
| 818 | + { |
---|
| 819 | + CameraPane cp = this; |
---|
| 820 | + |
---|
| 821 | + Camera keep = cp.RenderCamera(); |
---|
| 822 | + cp.renderCamera = localcamera; |
---|
| 823 | + |
---|
| 824 | + if (br.trimmed) |
---|
| 825 | + { |
---|
| 826 | + float[] colors = new float[br.positions.length / 3]; |
---|
| 827 | + |
---|
| 828 | + int i3 = 0; |
---|
| 829 | + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) |
---|
| 830 | + { |
---|
| 831 | + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) |
---|
| 832 | + continue; |
---|
| 833 | + |
---|
| 834 | + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); |
---|
| 835 | + to.set(br.positions[i3] + br.normals[i3], |
---|
| 836 | + br.positions[i3 + 1] + br.normals[i3 + 1], |
---|
| 837 | + br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
| 838 | + LA.xformPos(from, transform, from); |
---|
| 839 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 840 | + localcamera.setAim(from, to); |
---|
| 841 | + |
---|
| 842 | + CameraPane.occlusionbuffer.display(); |
---|
| 843 | + |
---|
| 844 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 845 | + cp.display(); // debug |
---|
| 846 | + |
---|
| 847 | + colors[i] = cp.vertexOcclusion.r; |
---|
| 848 | + //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
| 849 | + //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
| 850 | + |
---|
| 851 | + if ((i % 100) == 0 && i != 0) |
---|
| 852 | + { |
---|
| 853 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 854 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 855 | + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); |
---|
| 856 | + } |
---|
| 857 | + } |
---|
| 858 | + |
---|
| 859 | + br.colors = colors; |
---|
| 860 | + } |
---|
| 861 | + else |
---|
| 862 | + { |
---|
| 863 | + for (int i = 0; i < br.VertexCount(); i++) |
---|
| 864 | + { |
---|
| 865 | + Vertex v = br.GetVertex(i); |
---|
| 866 | + |
---|
| 867 | + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
| 868 | + continue; |
---|
| 869 | + |
---|
| 870 | + from.set(v.x, v.y, v.z); |
---|
| 871 | + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
| 872 | + LA.xformPos(from, transform, from); |
---|
| 873 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 874 | + localcamera.setAim(from, to); |
---|
| 875 | + |
---|
| 876 | + CameraPane.occlusionbuffer.display(); |
---|
| 877 | + |
---|
| 878 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 879 | + cp.display(); // debug |
---|
| 880 | + |
---|
| 881 | + v.AO = cp.vertexOcclusion.r; |
---|
| 882 | + |
---|
| 883 | + if ((i % 100) == 0 && i != 0) |
---|
| 884 | + { |
---|
| 885 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 886 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 887 | + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); |
---|
| 888 | + } |
---|
| 889 | + } |
---|
| 890 | + } |
---|
| 891 | + |
---|
| 892 | + //System.out.println("done."); |
---|
| 893 | + |
---|
| 894 | + cp.renderCamera = keep; |
---|
| 895 | + } |
---|
| 896 | + |
---|
| 897 | + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 898 | + { |
---|
| 899 | + CameraPane display = this; |
---|
| 900 | + pointFlow.CreateHT(); |
---|
| 901 | + |
---|
| 902 | + float r = display.modelParams0[0]; |
---|
| 903 | + float g = display.modelParams0[1]; |
---|
| 904 | + float b = display.modelParams0[2]; |
---|
| 905 | + float opacity = display.modelParams5[1]; |
---|
| 906 | + |
---|
| 907 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 908 | + GL gl = display.GetGL(); // getGL(); |
---|
| 909 | + |
---|
| 910 | + int s = pointFlow.points.size(); |
---|
| 911 | + |
---|
| 912 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 913 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 914 | + |
---|
| 915 | + for (int i=s; --i>=0;) |
---|
| 916 | + //for (int i=0; i<s; i++) |
---|
| 917 | + { |
---|
| 918 | + cVector v = pointFlow.points.get(i); |
---|
| 919 | + |
---|
| 920 | + double mindist = Double.MAX_VALUE; |
---|
| 921 | + |
---|
| 922 | + double size = pointFlow.minimumSize; |
---|
| 923 | + |
---|
| 924 | + double distancenext = 0; |
---|
| 925 | + |
---|
| 926 | + if (i > 0) |
---|
| 927 | + { |
---|
| 928 | + cVector w = pointFlow.points.get(i-1); |
---|
| 929 | + |
---|
| 930 | + double dist = w.distance(v); |
---|
| 931 | + |
---|
| 932 | + distancenext = dist; |
---|
| 933 | + |
---|
| 934 | + if (mindist > dist) |
---|
| 935 | + { |
---|
| 936 | + mindist = dist; |
---|
| 937 | + size = mindist*pointFlow.resizefactor; |
---|
| 938 | + } |
---|
| 939 | + } |
---|
| 940 | + |
---|
| 941 | + if (i < s-1) |
---|
| 942 | + { |
---|
| 943 | + cVector w = pointFlow.points.get(i+1); |
---|
| 944 | + |
---|
| 945 | + double dist = w.distance(v); |
---|
| 946 | + |
---|
| 947 | + if (mindist > dist) |
---|
| 948 | + { |
---|
| 949 | + mindist = dist; |
---|
| 950 | + size = mindist*pointFlow.resizefactor; |
---|
| 951 | + } |
---|
| 952 | + } |
---|
| 953 | + |
---|
| 954 | + if (size < pointFlow.minimumSize) |
---|
| 955 | + size = pointFlow.minimumSize; |
---|
| 956 | + if (size > pointFlow.maximumSize) |
---|
| 957 | + size = pointFlow.maximumSize; |
---|
| 958 | + |
---|
| 959 | + double tx = v.x; |
---|
| 960 | + double ty = v.y; |
---|
| 961 | + double tz = v.z; |
---|
| 962 | + |
---|
| 963 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 964 | + // continue; |
---|
| 965 | + |
---|
| 966 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 967 | + gl.glPushMatrix(); |
---|
| 968 | + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; |
---|
| 969 | + |
---|
| 970 | + gl.glMultMatrixf(pointFlow.texmat, 0); |
---|
| 971 | + |
---|
| 972 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 973 | + gl.glPushMatrix(); |
---|
| 974 | + |
---|
| 975 | + gl.glTranslated(tx,ty,tz); |
---|
| 976 | + |
---|
| 977 | + gl.glScaled(size,size,size); |
---|
| 978 | + |
---|
| 979 | +// float cr = colorBuf.get(index4); |
---|
| 980 | +// float cg = colorBuf.get(index4+1); |
---|
| 981 | +// float cb = colorBuf.get(index4+2); |
---|
| 982 | +// float ca = colorBuf.get(index4+3); |
---|
| 983 | +// |
---|
| 984 | +// display.modelParams0[0] = r * cr; |
---|
| 985 | +// display.modelParams0[1] = g * cg; |
---|
| 986 | +// display.modelParams0[2] = b * cb; |
---|
| 987 | +// |
---|
| 988 | +// display.modelParams5[1] = opacity * ca; |
---|
| 989 | +// |
---|
| 990 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 991 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 992 | +// |
---|
| 993 | +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
| 994 | +// RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 995 | +// |
---|
| 996 | +//// gl.glColor4f(cr,cg,cb,ca); |
---|
| 997 | +// // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 998 | + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); |
---|
| 999 | + |
---|
| 1000 | + gl.glPopMatrix(); |
---|
| 1001 | + |
---|
| 1002 | + double step = size/4; // |
---|
| 1003 | + |
---|
| 1004 | + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) |
---|
| 1005 | + continue; |
---|
| 1006 | + |
---|
| 1007 | + int nbsteps = (int)(distancenext/step); |
---|
| 1008 | + |
---|
| 1009 | + step = distancenext/nbsteps; |
---|
| 1010 | + |
---|
| 1011 | + cVector next = pointFlow.points.get(i-1); |
---|
| 1012 | + |
---|
| 1013 | + tmp.set(next); |
---|
| 1014 | + tmp.sub(v); |
---|
| 1015 | + tmp.normalize(); |
---|
| 1016 | + tmp.mul(step); |
---|
| 1017 | + |
---|
| 1018 | + // calculate next size |
---|
| 1019 | + mindist = Double.MAX_VALUE; |
---|
| 1020 | + |
---|
| 1021 | + double nextsize = pointFlow.minimumSize; |
---|
| 1022 | + |
---|
| 1023 | + if (i > 1) |
---|
| 1024 | + { |
---|
| 1025 | + cVector w = pointFlow.points.get(i-2); |
---|
| 1026 | + |
---|
| 1027 | + double dist = w.distance(next); |
---|
| 1028 | + |
---|
| 1029 | + if (mindist > dist) |
---|
| 1030 | + { |
---|
| 1031 | + mindist = dist; |
---|
| 1032 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1033 | + } |
---|
| 1034 | + } |
---|
| 1035 | + |
---|
| 1036 | + double dist = v.distance(next); |
---|
| 1037 | + |
---|
| 1038 | + if (mindist > dist) |
---|
| 1039 | + { |
---|
| 1040 | + mindist = dist; |
---|
| 1041 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1042 | + } |
---|
| 1043 | + |
---|
| 1044 | + if (nextsize < pointFlow.minimumSize) |
---|
| 1045 | + nextsize = pointFlow.minimumSize; |
---|
| 1046 | + if (nextsize > pointFlow.maximumSize) |
---|
| 1047 | + nextsize = pointFlow.maximumSize; |
---|
| 1048 | + // |
---|
| 1049 | + |
---|
| 1050 | + double count = 0; |
---|
| 1051 | + |
---|
| 1052 | + while (distancenext > 0.000000001) // step |
---|
| 1053 | + { |
---|
| 1054 | + gl.glPushMatrix(); |
---|
| 1055 | + |
---|
| 1056 | + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); |
---|
| 1057 | + |
---|
| 1058 | + double K = count/nbsteps; |
---|
| 1059 | + |
---|
| 1060 | + double intersize = K*nextsize + (1-K)*size; |
---|
| 1061 | + |
---|
| 1062 | + gl.glScaled(intersize,intersize,intersize); |
---|
| 1063 | + |
---|
| 1064 | + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); |
---|
| 1065 | + |
---|
| 1066 | + count++; |
---|
| 1067 | + |
---|
| 1068 | + distancenext -= step; |
---|
| 1069 | + |
---|
| 1070 | + gl.glPopMatrix(); |
---|
| 1071 | + } |
---|
| 1072 | + |
---|
| 1073 | + if (count != nbsteps) |
---|
| 1074 | + assert(count == nbsteps); |
---|
| 1075 | + |
---|
| 1076 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 1077 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 1078 | + |
---|
| 1079 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1080 | + gl.glPopMatrix(); |
---|
| 1081 | + } |
---|
| 1082 | + |
---|
| 1083 | + if (!cf) |
---|
| 1084 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 1085 | + |
---|
| 1086 | +// display.modelParams0[0] = r; |
---|
| 1087 | +// display.modelParams0[1] = g; |
---|
| 1088 | +// display.modelParams0[2] = b; |
---|
| 1089 | +// |
---|
| 1090 | +// display.modelParams5[1] = opacity; |
---|
| 1091 | +// |
---|
| 1092 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1093 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1094 | + |
---|
| 1095 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1096 | + } |
---|
| 1097 | + |
---|
| 1098 | + public void DrawBox(cVector min, cVector max) |
---|
| 1099 | + { |
---|
| 1100 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1101 | + gl.glBegin(gl.GL_LINES); |
---|
| 1102 | + |
---|
| 1103 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1104 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1105 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1106 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1107 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1108 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1109 | + |
---|
| 1110 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1111 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1112 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1113 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1114 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1115 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1116 | + |
---|
| 1117 | + gl.glEnd(); |
---|
| 1118 | + } |
---|
| 1119 | + |
---|
| 1120 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1121 | + { |
---|
| 1122 | + int[] strips = bRep.getRawIndices(); |
---|
| 1123 | + |
---|
| 1124 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1125 | + |
---|
| 1126 | + // TRIANGLE STRIP ARRAY |
---|
| 1127 | + if (bRep.trimmed) |
---|
| 1128 | + { |
---|
| 1129 | + float[] v = bRep.getRawVertices(); |
---|
| 1130 | + float[] n = bRep.getRawNormals(); |
---|
| 1131 | + float[] c = bRep.getRawColors(); |
---|
| 1132 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1133 | + |
---|
| 1134 | + int count2 = 0; |
---|
| 1135 | + int count3 = 0; |
---|
| 1136 | + |
---|
| 1137 | + if (n.length > 0) |
---|
| 1138 | + { |
---|
| 1139 | + for (int i = 0; i < strips.length; i++) |
---|
| 1140 | + { |
---|
| 1141 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1142 | + |
---|
| 1143 | + /* |
---|
| 1144 | + boolean locked = false; |
---|
| 1145 | + float eps = 0.1f; |
---|
| 1146 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1147 | + |
---|
| 1148 | + int dot = 0; |
---|
| 1149 | + |
---|
| 1150 | + if ((dot&1) == 0) |
---|
| 1151 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1152 | + |
---|
| 1153 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1154 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1155 | + else |
---|
| 1156 | + { |
---|
| 1157 | + locked = true; |
---|
| 1158 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1159 | + } |
---|
| 1160 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1161 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1162 | + if (hasnorm) |
---|
| 1163 | + { |
---|
| 1164 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1165 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1166 | + } |
---|
| 1167 | + |
---|
| 1168 | + if ((dot&4) == 0) |
---|
| 1169 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1170 | + |
---|
| 1171 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1172 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1173 | + else |
---|
| 1174 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1175 | + |
---|
| 1176 | + f.dot = dot; |
---|
| 1177 | + */ |
---|
| 1178 | + |
---|
| 1179 | + if (!selectmode) |
---|
| 1180 | + { |
---|
| 1181 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1182 | + { |
---|
| 1183 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1184 | + } else |
---|
| 1185 | + { |
---|
| 1186 | + gl.glNormal3f(0, 0, 1); |
---|
| 1187 | + } |
---|
| 1188 | + |
---|
| 1189 | + if (c != null) |
---|
| 1190 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1191 | + { |
---|
| 1192 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1193 | + } |
---|
| 1194 | + } |
---|
| 1195 | + if (flipV) |
---|
| 1196 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1197 | + else |
---|
| 1198 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1199 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1200 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1201 | + |
---|
| 1202 | + count2 += 2; |
---|
| 1203 | + count3 += 3; |
---|
| 1204 | + if (!selectmode) |
---|
| 1205 | + { |
---|
| 1206 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1207 | + { |
---|
| 1208 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1209 | + } else |
---|
| 1210 | + { |
---|
| 1211 | + gl.glNormal3f(0, 0, 1); |
---|
| 1212 | + } |
---|
| 1213 | + if (c != null) |
---|
| 1214 | + { |
---|
| 1215 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1216 | + } |
---|
| 1217 | + } |
---|
| 1218 | + if (flipV) |
---|
| 1219 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1220 | + else |
---|
| 1221 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1222 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1223 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1224 | + |
---|
| 1225 | + count2 += 2; |
---|
| 1226 | + count3 += 3; |
---|
| 1227 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1228 | + { |
---|
| 1229 | + //gl.glTexCoord2d(...); |
---|
| 1230 | + if (!selectmode) |
---|
| 1231 | + { |
---|
| 1232 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1233 | + { |
---|
| 1234 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1235 | + } else |
---|
| 1236 | + { |
---|
| 1237 | + gl.glNormal3f(0, 0, 1); |
---|
| 1238 | + } |
---|
| 1239 | + if (c != null) |
---|
| 1240 | + { |
---|
| 1241 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1242 | + } |
---|
| 1243 | + } |
---|
| 1244 | + |
---|
| 1245 | + if (flipV) |
---|
| 1246 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1247 | + else |
---|
| 1248 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1249 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1250 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1251 | + count2 += 2; |
---|
| 1252 | + count3 += 3; |
---|
| 1253 | + } |
---|
| 1254 | + |
---|
| 1255 | + gl.glEnd(); |
---|
| 1256 | + } |
---|
| 1257 | + } |
---|
| 1258 | + |
---|
| 1259 | + assert count3 == v.length; |
---|
| 1260 | + } |
---|
| 1261 | + else // !trimmed |
---|
| 1262 | + { |
---|
| 1263 | + int count = 0; |
---|
| 1264 | + for (int i = 0; i < strips.length; i++) |
---|
| 1265 | + { |
---|
| 1266 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1267 | + |
---|
| 1268 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1269 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1270 | + |
---|
| 1271 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1272 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1273 | + |
---|
| 1274 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1275 | + { |
---|
| 1276 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1277 | + |
---|
| 1278 | + // if (j%2 == 0) |
---|
| 1279 | + // drawFace(p, q, r, display, null); |
---|
| 1280 | + // else |
---|
| 1281 | + // drawFace(p, r, q, display, null); |
---|
| 1282 | + |
---|
| 1283 | + // p = q; |
---|
| 1284 | + // q = r; |
---|
| 1285 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1286 | + } |
---|
| 1287 | + |
---|
| 1288 | + gl.glEnd(); |
---|
| 1289 | + } |
---|
| 1290 | + } |
---|
| 1291 | + } |
---|
| 1292 | + |
---|
| 1293 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1294 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1295 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1296 | + |
---|
| 1297 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1298 | + { |
---|
| 1299 | + GL gl = GetGL(); // getGL(); |
---|
| 1300 | + |
---|
| 1301 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1302 | + |
---|
| 1303 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1304 | + |
---|
| 1305 | + gl.glLineWidth(1); |
---|
| 1306 | + gl.glColor3f(1,1,1); |
---|
| 1307 | + gl.glBegin(gl.GL_LINES); |
---|
| 1308 | + double scale = 0; |
---|
| 1309 | + int count = 0; |
---|
| 1310 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1311 | + { |
---|
| 1312 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1313 | + if(s == 0) |
---|
| 1314 | + { |
---|
| 1315 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1316 | + } |
---|
| 1317 | + if (mesh.showsprings) |
---|
| 1318 | + { |
---|
| 1319 | + temp.set(spring.a.position); |
---|
| 1320 | + temp.add(spring.b.position); |
---|
| 1321 | + temp.mul(0.5); |
---|
| 1322 | + temp2.set(spring.a.position); |
---|
| 1323 | + temp2.sub(spring.b.position); |
---|
| 1324 | + temp2.mul(spring.restLength/2); |
---|
| 1325 | + temp.sub(temp2); |
---|
| 1326 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1327 | + temp.add(temp2); |
---|
| 1328 | + temp.add(temp2); |
---|
| 1329 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1330 | + } |
---|
| 1331 | + |
---|
| 1332 | + if (spring.isHandle) |
---|
| 1333 | + continue; |
---|
| 1334 | + |
---|
| 1335 | + //if (scale < spring.restLength) |
---|
| 1336 | + scale += spring.restLength; |
---|
| 1337 | + count++; |
---|
| 1338 | + } |
---|
| 1339 | + gl.glEnd(); |
---|
| 1340 | + |
---|
| 1341 | + if (count == 0) |
---|
| 1342 | + scale = 0.01; |
---|
| 1343 | + else |
---|
| 1344 | + scale /= count * 3; |
---|
| 1345 | + |
---|
| 1346 | + //scale = 0.25; |
---|
| 1347 | + |
---|
| 1348 | + if (mesh.ShowInfo()) |
---|
| 1349 | + { |
---|
| 1350 | + gl.glLineWidth(4); |
---|
| 1351 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1352 | + { |
---|
| 1353 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1354 | + if (node.mass == 0) |
---|
| 1355 | + continue; |
---|
| 1356 | + |
---|
| 1357 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1358 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1359 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1360 | + //temp.normalize(); |
---|
| 1361 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1362 | + gl.glBegin(gl.GL_LINES); |
---|
| 1363 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1364 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1365 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1366 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1367 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1368 | + gl.glEnd(); |
---|
| 1369 | + } |
---|
| 1370 | + |
---|
| 1371 | + gl.glLineWidth(8); |
---|
| 1372 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1373 | + { |
---|
| 1374 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1375 | + |
---|
| 1376 | + if (node.springs != null) |
---|
| 1377 | + { |
---|
| 1378 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1379 | + { |
---|
| 1380 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1381 | + |
---|
| 1382 | + int c = i+1; |
---|
| 1383 | + // c = node.springs.get(i).nbcopies; |
---|
| 1384 | + |
---|
| 1385 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1386 | + gl.glBegin(gl.GL_LINES); |
---|
| 1387 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1388 | + 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); |
---|
| 1389 | + gl.glEnd(); |
---|
| 1390 | + } |
---|
| 1391 | + } |
---|
| 1392 | + } |
---|
| 1393 | + |
---|
| 1394 | + gl.glLineWidth(1); |
---|
| 1395 | + } |
---|
| 1396 | + |
---|
| 1397 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1398 | + } |
---|
| 1399 | + |
---|
| 1400 | + /// INTERFACE |
---|
| 1401 | + |
---|
| 1402 | + public void StartTriangles() |
---|
| 1403 | + { |
---|
| 1404 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1405 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1406 | + } |
---|
| 1407 | + |
---|
| 1408 | + public void EndTriangles() |
---|
| 1409 | + { |
---|
| 1410 | + GetGL().glEnd(); |
---|
| 1411 | + } |
---|
| 1412 | + |
---|
| 1413 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1414 | + { |
---|
| 1415 | + if (!selectmode) |
---|
| 1416 | + { |
---|
| 1417 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1418 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1419 | + |
---|
| 1420 | + if (flipV) |
---|
| 1421 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1422 | + else |
---|
| 1423 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1424 | + } |
---|
| 1425 | + |
---|
| 1426 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1427 | + } |
---|
| 1428 | + |
---|
| 1429 | + void SetColor(Object3D obj, Vertex p0) |
---|
| 1430 | + { |
---|
| 1431 | + CameraPane display = this; |
---|
| 1432 | + BoundaryRep bRep = obj.bRep; |
---|
| 1433 | + |
---|
| 1434 | + if (RENDERPROGRAM == 0) |
---|
| 1435 | + { |
---|
| 1436 | + float r = 0; |
---|
| 1437 | + if (bRep != null) |
---|
| 1438 | + { |
---|
| 1439 | + if (bRep.stripified) |
---|
| 1440 | + { |
---|
| 1441 | + r = 1; |
---|
| 1442 | + } |
---|
| 1443 | + } |
---|
| 1444 | + float g = 0; |
---|
| 1445 | + if (bRep != null) |
---|
| 1446 | + { |
---|
| 1447 | + if (bRep.trimmed) |
---|
| 1448 | + { |
---|
| 1449 | + g = 1; |
---|
| 1450 | + } |
---|
| 1451 | + } |
---|
| 1452 | + float b = 0; |
---|
| 1453 | + if (obj.support != null && obj.link2master) |
---|
| 1454 | + { |
---|
| 1455 | + b = 1; |
---|
| 1456 | + } |
---|
| 1457 | + display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO); |
---|
| 1458 | + return; |
---|
| 1459 | + } |
---|
| 1460 | + |
---|
| 1461 | + if (display.DrawMode() != CameraPane.SHADOW) |
---|
| 1462 | + return; |
---|
| 1463 | + |
---|
| 1464 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1465 | +// if (true) return; |
---|
| 1466 | +// float ao = p.AO; |
---|
| 1467 | +// |
---|
| 1468 | +// // if (ao == 0 && !bRep.AOdone) // transient problem! |
---|
| 1469 | +// // ao = 1; |
---|
| 1470 | +// |
---|
| 1471 | +// gl.glColor4f(ao, ao, ao, 1); |
---|
| 1472 | + |
---|
| 1473 | +// CameraPane.selectedpoint. |
---|
| 1474 | +// getAverage(cStatic.point1, true); |
---|
| 1475 | + if (CameraPane.pointflow == null) // !random) // live) |
---|
| 1476 | + { |
---|
| 1477 | + return; |
---|
| 1478 | + } |
---|
| 1479 | + |
---|
| 1480 | + cStatic.point1.set(0,0,0); |
---|
| 1481 | + LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1); |
---|
| 1482 | + |
---|
| 1483 | + cStatic.point1.sub(p0); |
---|
| 1484 | + |
---|
| 1485 | + |
---|
| 1486 | +// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta? |
---|
| 1487 | +// { |
---|
| 1488 | +// return; |
---|
| 1489 | +// } |
---|
| 1490 | + |
---|
| 1491 | + //if (true) |
---|
| 1492 | + if (cStatic.point1.dot(cStatic.point1) > 0.000001) |
---|
| 1493 | + { |
---|
| 1494 | + return; |
---|
| 1495 | + } |
---|
| 1496 | + |
---|
| 1497 | + float[] colorV = new float[3]; |
---|
| 1498 | + |
---|
| 1499 | + if (false) // marked) |
---|
| 1500 | + { |
---|
| 1501 | + // debug rigging weights |
---|
| 1502 | + for (int object = 0; object < p0.vertexlinks.length; object++) |
---|
| 1503 | + { |
---|
| 1504 | + float weight = p0.weights[object] / p0.totalweight; |
---|
| 1505 | + |
---|
| 1506 | + // if (weight < 0.1) |
---|
| 1507 | + // { |
---|
| 1508 | + // assert(weight == 0); |
---|
| 1509 | + // continue; |
---|
| 1510 | + // } |
---|
| 1511 | + |
---|
| 1512 | + if (p0.vertexlinks[object] == -1) |
---|
| 1513 | + continue; |
---|
| 1514 | + |
---|
| 1515 | + Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]); |
---|
| 1516 | + |
---|
| 1517 | + int color = //1 << object; // |
---|
| 1518 | + //p.vertexlinks.length; |
---|
| 1519 | + obj.support.bRep.supports[p0.closestsupport].links[object]; |
---|
| 1520 | + colorV[2] += (color & 1) * weight; |
---|
| 1521 | + colorV[1] += ((color & 2) >> 1) * weight; |
---|
| 1522 | + colorV[0] += ((color & 4) >> 2) * weight; |
---|
| 1523 | + } |
---|
| 1524 | + } |
---|
| 1525 | + else |
---|
| 1526 | + { |
---|
| 1527 | + if (obj.drawingstarted) |
---|
| 1528 | + { |
---|
| 1529 | + // find next point |
---|
| 1530 | + if (bRep.GetVertex(0).faceindices == null) |
---|
| 1531 | + { |
---|
| 1532 | + bRep.InitFaceIndices(); |
---|
| 1533 | + } |
---|
| 1534 | + |
---|
| 1535 | + double ymin = p0.y; |
---|
| 1536 | + |
---|
| 1537 | + Vertex newp = p0; |
---|
| 1538 | + |
---|
| 1539 | + for (int fii = 0; fii < p0.faceindices.length; fii++) |
---|
| 1540 | + { |
---|
| 1541 | + int fi = p0.faceindices[fii]; |
---|
| 1542 | + |
---|
| 1543 | + if (fi == -1) |
---|
| 1544 | + break; |
---|
| 1545 | + |
---|
| 1546 | + Face f = bRep.GetFace(fi); |
---|
| 1547 | + |
---|
| 1548 | + Vertex p = bRep.GetVertex(f.p); |
---|
| 1549 | + Vertex q = bRep.GetVertex(f.q); |
---|
| 1550 | + Vertex r = bRep.GetVertex(f.r); |
---|
| 1551 | + |
---|
| 1552 | + int swap = (int)(Math.random()*3); |
---|
| 1553 | + |
---|
| 1554 | +// for (int s=swap; --s>=0;) |
---|
| 1555 | +// { |
---|
| 1556 | +// Vertex t = p; |
---|
| 1557 | +// p = q; |
---|
| 1558 | +// q = r; |
---|
| 1559 | +// r = t; |
---|
| 1560 | +// } |
---|
| 1561 | + if (ymin > p.y) |
---|
| 1562 | + { |
---|
| 1563 | + ymin = p.y; |
---|
| 1564 | + newp = p; |
---|
| 1565 | +// break; |
---|
| 1566 | + } |
---|
| 1567 | + if (ymin > q.y) |
---|
| 1568 | + { |
---|
| 1569 | + ymin = q.y; |
---|
| 1570 | + newp = q; |
---|
| 1571 | +// break; |
---|
| 1572 | + } |
---|
| 1573 | + if (ymin > r.y) |
---|
| 1574 | + { |
---|
| 1575 | + ymin = r.y; |
---|
| 1576 | + newp = r; |
---|
| 1577 | +// break; |
---|
| 1578 | + } |
---|
| 1579 | + } |
---|
| 1580 | + |
---|
| 1581 | + CameraPane.selectedpoint.toParent[3][0] = newp.x; |
---|
| 1582 | + CameraPane.selectedpoint.toParent[3][1] = newp.y; |
---|
| 1583 | + CameraPane.selectedpoint.toParent[3][2] = newp.z; |
---|
| 1584 | + |
---|
| 1585 | + obj.drawingstarted = false; |
---|
| 1586 | + |
---|
| 1587 | + // return; |
---|
| 1588 | + } |
---|
| 1589 | + |
---|
| 1590 | + if (false) // CameraPane.DRAW |
---|
| 1591 | + { |
---|
| 1592 | + p0.AO = colorV[0] = 2; |
---|
| 1593 | + colorV[1] = 2; |
---|
| 1594 | + colorV[2] = 2; |
---|
| 1595 | + } |
---|
| 1596 | + |
---|
| 1597 | + CameraPane.pointflow.add(p0); |
---|
| 1598 | + CameraPane.pointflow.Touch(); |
---|
| 1599 | + } |
---|
| 1600 | + |
---|
| 1601 | +// gl.glColor3f(colorV[0], colorV[1], colorV[2]); |
---|
| 1602 | +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1603 | +// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1604 | + } |
---|
| 1605 | + |
---|
| 1606 | + void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1607 | + { |
---|
| 1608 | + CameraPane display = this; |
---|
| 1609 | + //new Exception().printStackTrace(); |
---|
| 1610 | + |
---|
| 1611 | + if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW) |
---|
| 1612 | + { |
---|
| 1613 | + return; |
---|
| 1614 | + } |
---|
| 1615 | + |
---|
| 1616 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1617 | + |
---|
| 1618 | + //Color col = Color.getHSBColor(color,modulation,1); |
---|
| 1619 | + //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
| 1620 | + if (!material.multiply) |
---|
| 1621 | + { |
---|
| 1622 | + display.color = material.color; |
---|
| 1623 | + display.saturation = material.modulation; |
---|
| 1624 | + } |
---|
| 1625 | + else |
---|
| 1626 | + { |
---|
| 1627 | + display.color *= material.color*2; |
---|
| 1628 | + display.saturation *= material.modulation*2; |
---|
| 1629 | + } |
---|
| 1630 | + |
---|
| 1631 | + cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
| 1632 | + |
---|
| 1633 | + float[] colorV = Grafreed.colorV; |
---|
| 1634 | + |
---|
| 1635 | + /**/ |
---|
| 1636 | + if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
| 1637 | + { |
---|
| 1638 | + colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
| 1639 | + colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
| 1640 | + colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
| 1641 | + colorV[3] = material.opacity; |
---|
| 1642 | + |
---|
| 1643 | + gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
| 1644 | + //System.out.println("Opacity = " + opacity); |
---|
| 1645 | + |
---|
| 1646 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1647 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1648 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1649 | + |
---|
| 1650 | + float amb = material.ambient; |
---|
| 1651 | + if (amb < material.cameralight) |
---|
| 1652 | + { |
---|
| 1653 | + amb = material.cameralight; |
---|
| 1654 | + } |
---|
| 1655 | + colorV[0] = display.modelParams0[0] * material.diffuse * amb; |
---|
| 1656 | + colorV[1] = display.modelParams0[1] * material.diffuse * amb; |
---|
| 1657 | + colorV[2] = display.modelParams0[2] * material.diffuse * amb; |
---|
| 1658 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0); |
---|
| 1659 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1660 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 1661 | + |
---|
| 1662 | + /**/ |
---|
| 1663 | + colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular; |
---|
| 1664 | + colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular; |
---|
| 1665 | + colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular; |
---|
| 1666 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0); |
---|
| 1667 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1668 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0); |
---|
| 1669 | + colorV[0] = 10 / material.shininess; // 1/0.005f; |
---|
| 1670 | + //System.out.println("shininess = " + colorV[0]); |
---|
| 1671 | + if (colorV[0] > 128) |
---|
| 1672 | + { |
---|
| 1673 | + colorV[0] = 128; |
---|
| 1674 | + } |
---|
| 1675 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0); |
---|
| 1676 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0); |
---|
| 1677 | + /**/ |
---|
| 1678 | + } |
---|
| 1679 | + /**/ |
---|
| 1680 | + |
---|
| 1681 | + //selected = false; |
---|
| 1682 | + selected = selected && display.flash; |
---|
| 1683 | + |
---|
| 1684 | + //display.modelParams0[0] = 0; // pigment.r; |
---|
| 1685 | + //display.modelParams0[1] = 0; // pigment.g; |
---|
| 1686 | + //display.modelParams0[2] = 0; // pigment.b; |
---|
| 1687 | + if (!material.multiply) |
---|
| 1688 | + { |
---|
| 1689 | + display.modelParams0[3] = material.metalness; |
---|
| 1690 | + display.modelParams1[0] = material.diffuse; |
---|
| 1691 | + display.modelParams1[1] = material.specular; |
---|
| 1692 | + display.modelParams1[2] = 1 / material.shininess; |
---|
| 1693 | + display.modelParams1[3] = material.shift; |
---|
| 1694 | + display.modelParams2[0] = material.ambient; |
---|
| 1695 | + display.modelParams2[1] = material.lightarea; |
---|
| 1696 | + //System.out.println("light area = " + lightarea); |
---|
| 1697 | + display.modelParams2[2] = 1 / material.factor; // diffuseness |
---|
| 1698 | + display.modelParams2[3] = material.velvet; |
---|
| 1699 | + display.modelParams3[0] = material.sheen; |
---|
| 1700 | + display.modelParams3[1] = material.subsurface; |
---|
| 1701 | + display.modelParams3[2] = material.bump; // backlit |
---|
| 1702 | + display.modelParams3[3] = material.aniso; |
---|
| 1703 | + display.modelParams4[0] = material.anisoV; |
---|
| 1704 | + display.modelParams4[1] = selected ? 100 : material.cameralight; |
---|
| 1705 | + //System.out.println("selected = " + selected); |
---|
| 1706 | + display.modelParams4[2] = material.diffuseness; |
---|
| 1707 | + display.modelParams4[3] = material.shadow; |
---|
| 1708 | + display.modelParams5[0] = material.texture; |
---|
| 1709 | + display.modelParams5[1] = material.opacity; |
---|
| 1710 | + display.modelParams5[2] = material.fakedepth; |
---|
| 1711 | + display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10; |
---|
| 1712 | + } |
---|
| 1713 | + else |
---|
| 1714 | + { |
---|
| 1715 | + display.modelParams0[3] *= material.metalness*2; |
---|
| 1716 | + display.modelParams1[0] *= material.diffuse*2; |
---|
| 1717 | + display.modelParams1[1] *= material.specular*2; |
---|
| 1718 | + display.modelParams1[2] *= material.shininess*2; |
---|
| 1719 | + display.modelParams1[3] *= material.shift*2; |
---|
| 1720 | + display.modelParams2[0] *= material.ambient*2; |
---|
| 1721 | + display.modelParams2[1] *= material.lightarea*2; |
---|
| 1722 | + display.modelParams2[2] *= material.factor*2; |
---|
| 1723 | + display.modelParams2[3] *= material.velvet*2; |
---|
| 1724 | + display.modelParams3[0] *= material.sheen*2; |
---|
| 1725 | + display.modelParams3[1] *= material.subsurface*2; |
---|
| 1726 | + display.modelParams3[2] *= material.bump*2; |
---|
| 1727 | + display.modelParams3[3] *= material.aniso*2; |
---|
| 1728 | + display.modelParams4[0] *= material.anisoV*2; |
---|
| 1729 | + display.modelParams4[1] *= material.cameralight*2; |
---|
| 1730 | + //System.out.println("selected = " + selected); |
---|
| 1731 | + display.modelParams4[2] *= material.diffuseness*2; |
---|
| 1732 | + display.modelParams4[3] *= material.shadow*2; |
---|
| 1733 | + display.modelParams5[0] *= material.texture*2; |
---|
| 1734 | + display.modelParams5[1] *= material.opacity*2; |
---|
| 1735 | + display.modelParams5[2] *= material.fakedepth*2; |
---|
| 1736 | + display.modelParams5[3] *= material.shadowbias*2; |
---|
| 1737 | + } |
---|
| 1738 | + |
---|
| 1739 | + display.modelParams6[0] = 0; |
---|
| 1740 | + display.modelParams6[1] = 0; |
---|
| 1741 | + display.modelParams6[2] = 0; |
---|
| 1742 | + display.modelParams6[3] = 0; |
---|
| 1743 | + |
---|
| 1744 | + display.modelParams7[0] = 0; |
---|
| 1745 | + display.modelParams7[1] = 1000; |
---|
| 1746 | + display.modelParams7[2] = 0; |
---|
| 1747 | + display.modelParams7[3] = 0; |
---|
| 1748 | + |
---|
| 1749 | + display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1750 | + |
---|
| 1751 | + Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1752 | + if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
| 1753 | + { |
---|
| 1754 | + display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
| 1755 | + display.modelParams6[1] = extparams[0].y / 1000.0f; // noise |
---|
| 1756 | + if (extparams.length > 1) |
---|
| 1757 | + { |
---|
| 1758 | + display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade |
---|
| 1759 | + display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough |
---|
| 1760 | + if (extparams.length > 2) |
---|
| 1761 | + { |
---|
| 1762 | + display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power |
---|
| 1763 | + float x = extparams[2].y / 1000.0f; |
---|
| 1764 | + //if (x == 0) |
---|
| 1765 | + // x = 1f; |
---|
| 1766 | + 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 |
---|
| 1767 | + if (extparams[2].y > 0) |
---|
| 1768 | + { |
---|
| 1769 | + //System.out.println("extparams[1].y = " + extparams[1].y); |
---|
| 1770 | + //System.out.println("extparams[2].y = " + extparams[2].y); |
---|
| 1771 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1772 | + } |
---|
| 1773 | + } |
---|
| 1774 | + } |
---|
| 1775 | + } |
---|
| 1776 | + |
---|
| 1777 | + //if (display.modelParams6[2] != 0) |
---|
| 1778 | + /* |
---|
| 1779 | + System.out.println("modelParams0[0] = " + display.modelParams0[0]); |
---|
| 1780 | + System.out.println("modelParams0[1] = " + display.modelParams0[1]); |
---|
| 1781 | + System.out.println("modelParams0[2] = " + display.modelParams0[2]); |
---|
| 1782 | + System.out.println("modelParams0[3] = " + display.modelParams0[3]); |
---|
| 1783 | + System.out.println("modelParams1[0] = " + display.modelParams1[0]); |
---|
| 1784 | + System.out.println("modelParams1[1] = " + display.modelParams1[1]); |
---|
| 1785 | + System.out.println("modelParams1[2] = " + display.modelParams1[2]); |
---|
| 1786 | + System.out.println("modelParams1[3] = " + display.modelParams1[3]); |
---|
| 1787 | + System.out.println("modelParams2[0] = " + display.modelParams2[0]); |
---|
| 1788 | + System.out.println("modelParams2[1] = " + display.modelParams2[1]); |
---|
| 1789 | + System.out.println("modelParams2[2] = " + display.modelParams2[2]); |
---|
| 1790 | + System.out.println("modelParams2[3] = " + display.modelParams2[3]); |
---|
| 1791 | + System.out.println("modelParams3[0] = " + display.modelParams3[0]); |
---|
| 1792 | + System.out.println("modelParams3[1] = " + display.modelParams3[1]); |
---|
| 1793 | + System.out.println("modelParams3[2] = " + display.modelParams3[2]); |
---|
| 1794 | + System.out.println("modelParams3[3] = " + display.modelParams3[3]); |
---|
| 1795 | + System.out.println("modelParams4[0] = " + display.modelParams4[0]); |
---|
| 1796 | + System.out.println("modelParams4[1] = " + display.modelParams4[1]); |
---|
| 1797 | + System.out.println("modelParams4[2] = " + display.modelParams4[2]); |
---|
| 1798 | + System.out.println("modelParams4[3] = " + display.modelParams4[3]); |
---|
| 1799 | + System.out.println("modelParams5[0] = " + display.modelParams5[0]); |
---|
| 1800 | + System.out.println("modelParams5[1] = " + display.modelParams5[1]); |
---|
| 1801 | + System.out.println("modelParams5[2] = " + display.modelParams5[2]); |
---|
| 1802 | + System.out.println("modelParams5[3] = " + display.modelParams5[3]); |
---|
| 1803 | + System.out.println("modelParams6[0] = " + display.modelParams6[0]); |
---|
| 1804 | + System.out.println("modelParams6[1] = " + display.modelParams6[1]); |
---|
| 1805 | + System.out.println("modelParams6[2] = " + display.modelParams6[2]); |
---|
| 1806 | + System.out.println("modelParams6[3] = " + display.modelParams6[3]); |
---|
| 1807 | + System.out.println("modelParams7[0] = " + display.modelParams7[0]); |
---|
| 1808 | + System.out.println("modelParams7[1] = " + display.modelParams7[1]); |
---|
| 1809 | + System.out.println("modelParams7[2] = " + display.modelParams7[2]); |
---|
| 1810 | + System.out.println("modelParams7[3] = " + display.modelParams7[3]); |
---|
| 1811 | + /**/ |
---|
| 1812 | + //assert (display.modelParams6[2] == 0); |
---|
| 1813 | + |
---|
| 1814 | + //System.out.println("noise power = " + display.modelParams7[0]); |
---|
| 1815 | + //System.out.println("shadowbias = " + shadowbias); |
---|
| 1816 | + |
---|
| 1817 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1818 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0); |
---|
| 1819 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0); |
---|
| 1820 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0); |
---|
| 1821 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 1822 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1823 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0); |
---|
| 1824 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0); |
---|
| 1825 | + |
---|
| 1826 | + int mode = display.FP_SHADER; |
---|
| 1827 | + |
---|
| 1828 | + if (material.aniso != material.anisoV || material.aniso > 0.002) |
---|
| 1829 | + { |
---|
| 1830 | + mode |= display.FP_ANISO; |
---|
| 1831 | + } |
---|
| 1832 | + |
---|
| 1833 | + display.EnableProgram(mode); |
---|
| 1834 | + |
---|
| 1835 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1836 | + |
---|
| 1837 | + if (!material.multiply) |
---|
| 1838 | + { |
---|
| 1839 | + if (Globals.drawMode == CameraPane.SHADOW) |
---|
| 1840 | + gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1); |
---|
| 1841 | + else |
---|
| 1842 | + gl.glDepthMask(material.opacity >= 0.99); |
---|
| 1843 | + } |
---|
236 | 1844 | } |
---|
237 | 1845 | |
---|
238 | 1846 | int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0; |
---|
.. | .. |
---|
253 | 1861 | currentGL.glMultMatrixd(model, 0); |
---|
254 | 1862 | } |
---|
255 | 1863 | |
---|
256 | | - void PushMatrix(double[][] matrix, int count) |
---|
| 1864 | + public void PushMatrix(double[][] matrix, int count) // INTERFACE |
---|
257 | 1865 | { |
---|
258 | 1866 | matrixdepth++; |
---|
259 | 1867 | // GrafreeD.tracein(matrix); |
---|
.. | .. |
---|
282 | 1890 | void PushMatrix(double[][] matrix) |
---|
283 | 1891 | { |
---|
284 | 1892 | // GrafreeD.tracein(matrix); |
---|
285 | | - PushMatrix(matrix,1); |
---|
| 1893 | + PushMatrix(matrix, 1); |
---|
286 | 1894 | } |
---|
287 | 1895 | |
---|
288 | 1896 | void PushMatrix() |
---|
.. | .. |
---|
298 | 1906 | |
---|
299 | 1907 | double[][] tmpmat = new double[4][4]; |
---|
300 | 1908 | |
---|
301 | | - void PopMatrix(double[][] inverse) |
---|
| 1909 | + public void PopMatrix(double[][] inverse) // INTERFACE |
---|
302 | 1910 | { |
---|
303 | 1911 | --matrixdepth; |
---|
304 | 1912 | |
---|
.. | .. |
---|
338 | 1946 | PushTextureMatrix(matrix, 1); |
---|
339 | 1947 | } |
---|
340 | 1948 | |
---|
341 | | - void PushTextureMatrix(double[][] matrix, int count) |
---|
| 1949 | + public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE |
---|
342 | 1950 | { |
---|
343 | 1951 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
344 | 1952 | |
---|
.. | .. |
---|
352 | 1960 | currentGL.glMatrixMode(GetGL().GL_MODELVIEW); |
---|
353 | 1961 | } |
---|
354 | 1962 | |
---|
355 | | - void PopTextureMatrix(double[][] inverse) |
---|
| 1963 | + public void PopTextureMatrix(double[][] inverse) // INTERFACE |
---|
356 | 1964 | { |
---|
357 | 1965 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
358 | 1966 | currentGL.glMatrixMode(GetGL().GL_TEXTURE); |
---|
.. | .. |
---|
379 | 1987 | |
---|
380 | 1988 | static int camerachangeframe; |
---|
381 | 1989 | |
---|
382 | | - boolean SetCamera(Camera cam) |
---|
| 1990 | + public boolean SetCamera(Camera cam) |
---|
383 | 1991 | { |
---|
384 | 1992 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
385 | 1993 | // return false; |
---|
386 | 1994 | |
---|
387 | | - if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount) |
---|
| 1995 | + if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount) |
---|
388 | 1996 | { |
---|
389 | 1997 | // check for last change |
---|
390 | | - if (framecount < camerachangeframe + 400) // 120 == 1 second |
---|
| 1998 | + if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second |
---|
391 | 1999 | { |
---|
392 | 2000 | // refuse the camera change |
---|
393 | 2001 | System.err.println("Camera " + cam + " REFUSED"); |
---|
.. | .. |
---|
395 | 2003 | } |
---|
396 | 2004 | } |
---|
397 | 2005 | |
---|
398 | | - camerachangeframe = framecount; |
---|
| 2006 | + camerachangeframe = Globals.framecount; |
---|
399 | 2007 | |
---|
400 | 2008 | cam.hAspect = -1; // Read only |
---|
401 | 2009 | |
---|
.. | .. |
---|
426 | 2034 | { |
---|
427 | 2035 | //System.err.println("Oeil on"); |
---|
428 | 2036 | TRACK = true; |
---|
429 | | -// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 2037 | +// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
430 | 2038 | // object.editWindow.ScreenFit(trackedobject); |
---|
431 | 2039 | //pingthread.StepToTarget(true); |
---|
432 | 2040 | } |
---|
.. | .. |
---|
435 | 2043 | { |
---|
436 | 2044 | //System.err.println("Oeil on"); |
---|
437 | 2045 | OEIL = true; |
---|
438 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 2046 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
439 | 2047 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
440 | 2048 | //pingthread.StepToTarget(true); |
---|
441 | 2049 | } |
---|
.. | .. |
---|
499 | 2107 | { |
---|
500 | 2108 | frozen ^= true; |
---|
501 | 2109 | // Weird... |
---|
502 | | - lighttouched = true; |
---|
| 2110 | + Globals.lighttouched = true; |
---|
503 | 2111 | } |
---|
504 | 2112 | |
---|
505 | 2113 | void ToggleDL() |
---|
506 | 2114 | { |
---|
507 | 2115 | mainDL ^= true; |
---|
508 | | - } |
---|
509 | | - |
---|
510 | | - void ToggleTexture() |
---|
511 | | - { |
---|
512 | | - textureon ^= true; |
---|
513 | | - } |
---|
514 | | - |
---|
515 | | - void ToggleLive() |
---|
516 | | - { |
---|
517 | | - setLIVE(isLIVE() ^ true); |
---|
518 | | - |
---|
519 | | - System.err.println("LIVE = " + isLIVE()); |
---|
520 | | - |
---|
521 | | - if (!isLIVE()) // save sound |
---|
522 | | - GrafreeD.savesound = true; // wav.save(); |
---|
523 | | - // else |
---|
524 | | - repaint(); // start loop // may 2013 |
---|
525 | | - } |
---|
526 | | - |
---|
527 | | - void ToggleSupport() |
---|
528 | | - { |
---|
529 | | - SUPPORT ^= true; |
---|
530 | | - } |
---|
531 | | - |
---|
532 | | - void ToggleAbort() |
---|
533 | | - { |
---|
534 | | - ABORTMODE ^= true; |
---|
535 | 2116 | } |
---|
536 | 2117 | |
---|
537 | 2118 | void ToggleFullScreen() |
---|
.. | .. |
---|
541 | 2122 | |
---|
542 | 2123 | void ToggleCrowd() |
---|
543 | 2124 | { |
---|
544 | | - CROWD ^= true; |
---|
545 | | - } |
---|
546 | | - |
---|
547 | | - void ToggleInertia() |
---|
548 | | - { |
---|
549 | | - INERTIA ^= true; |
---|
| 2125 | + Globals.CROWD ^= true; |
---|
550 | 2126 | } |
---|
551 | 2127 | |
---|
552 | 2128 | void ToggleLocal() |
---|
.. | .. |
---|
554 | 2130 | LOCALTRANSFORM ^= true; |
---|
555 | 2131 | } |
---|
556 | 2132 | |
---|
557 | | - void ToggleFast() |
---|
| 2133 | + public void ToggleTexture() |
---|
| 2134 | + { |
---|
| 2135 | + textureon ^= true; |
---|
| 2136 | + } |
---|
| 2137 | + |
---|
| 2138 | + public void ToggleLive() |
---|
| 2139 | + { |
---|
| 2140 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
| 2141 | + |
---|
| 2142 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
| 2143 | + |
---|
| 2144 | + if (!Globals.isLIVE()) // save sound |
---|
| 2145 | + Grafreed.savesound = true; // wav.save(); |
---|
| 2146 | + // else |
---|
| 2147 | + repaint(); // start loop // may 2013 |
---|
| 2148 | + } |
---|
| 2149 | + |
---|
| 2150 | + public void ToggleSupport() |
---|
| 2151 | + { |
---|
| 2152 | + SUPPORT ^= true; |
---|
| 2153 | + } |
---|
| 2154 | + |
---|
| 2155 | + public void ToggleAbort() |
---|
| 2156 | + { |
---|
| 2157 | + ABORTMODE ^= true; |
---|
| 2158 | + } |
---|
| 2159 | + |
---|
| 2160 | + public void ToggleInertia() |
---|
| 2161 | + { |
---|
| 2162 | + INERTIA ^= true; |
---|
| 2163 | + } |
---|
| 2164 | + |
---|
| 2165 | + public void ToggleFast() |
---|
558 | 2166 | { |
---|
559 | 2167 | FAST ^= true; |
---|
560 | 2168 | } |
---|
561 | 2169 | |
---|
562 | | - void ToggleSlowPose() |
---|
| 2170 | + public void ToggleSlowPose() |
---|
563 | 2171 | { |
---|
564 | 2172 | SLOWPOSE ^= true; |
---|
565 | 2173 | } |
---|
566 | 2174 | |
---|
567 | | - void ToggleFootContact() |
---|
568 | | - { |
---|
569 | | - FOOTCONTACT ^= true; |
---|
570 | | - } |
---|
571 | | - |
---|
572 | | - void ToggleBoxMode() |
---|
| 2175 | + public void ToggleBoxMode() |
---|
573 | 2176 | { |
---|
574 | 2177 | BOXMODE ^= true; |
---|
575 | 2178 | } |
---|
576 | 2179 | |
---|
577 | | - void ToggleSmoothFocus() |
---|
| 2180 | + public void ToggleZoomBoxMode() |
---|
| 2181 | + { |
---|
| 2182 | + ZOOMBOXMODE ^= true; |
---|
| 2183 | + } |
---|
| 2184 | + |
---|
| 2185 | + public void ToggleSmoothFocus() |
---|
578 | 2186 | { |
---|
579 | 2187 | SMOOTHFOCUS ^= true; |
---|
580 | 2188 | } |
---|
581 | 2189 | |
---|
582 | | - void ToggleImageFlip() |
---|
| 2190 | + public void ToggleImageFlip() |
---|
583 | 2191 | { |
---|
584 | 2192 | IMAGEFLIP ^= true; |
---|
585 | 2193 | } |
---|
586 | 2194 | |
---|
587 | | - void ToggleSpeakerMocap() |
---|
| 2195 | + public void ToggleSpeakerMocap() |
---|
588 | 2196 | { |
---|
589 | 2197 | SPEAKERMOCAP ^= true; |
---|
590 | 2198 | } |
---|
591 | 2199 | |
---|
592 | | - void ToggleSpeakerCamera() |
---|
| 2200 | + public void ToggleSpeakerCamera() |
---|
593 | 2201 | { |
---|
594 | 2202 | SPEAKERCAMERA ^= true; |
---|
595 | 2203 | } |
---|
596 | 2204 | |
---|
597 | | - void ToggleSpeakerFocus() |
---|
| 2205 | + public void ToggleSpeakerFocus() |
---|
598 | 2206 | { |
---|
599 | 2207 | SPEAKERFOCUS ^= true; |
---|
600 | 2208 | } |
---|
601 | 2209 | |
---|
602 | | - void ToggleDebug() |
---|
603 | | - { |
---|
604 | | - DEBUG ^= true; |
---|
605 | | - } |
---|
606 | | - |
---|
607 | | - void ToggleFrustum() |
---|
| 2210 | + public void ToggleFrustum() |
---|
608 | 2211 | { |
---|
609 | 2212 | FRUSTUM ^= true; |
---|
610 | 2213 | } |
---|
611 | 2214 | |
---|
612 | | - void ToggleTrack() |
---|
| 2215 | + public void ToggleTrack() |
---|
613 | 2216 | { |
---|
614 | 2217 | TRACK ^= true; |
---|
615 | 2218 | if (TRACK) |
---|
.. | .. |
---|
628 | 2231 | repaint(); |
---|
629 | 2232 | } |
---|
630 | 2233 | |
---|
631 | | - void ToggleTrackOnce() |
---|
| 2234 | + public void ToggleTrackOnce() |
---|
632 | 2235 | { |
---|
633 | 2236 | TRACKONCE ^= true; |
---|
634 | 2237 | } |
---|
635 | 2238 | |
---|
636 | | - void ToggleShadowTrack() |
---|
| 2239 | + public void ToggleShadowTrack() |
---|
637 | 2240 | { |
---|
638 | 2241 | SHADOWTRACK ^= true; |
---|
639 | 2242 | repaint(); |
---|
640 | 2243 | } |
---|
641 | 2244 | |
---|
642 | | - void ToggleOeil() |
---|
| 2245 | + public void ToggleOeil() |
---|
643 | 2246 | { |
---|
644 | 2247 | OEIL ^= true; |
---|
645 | 2248 | } |
---|
646 | 2249 | |
---|
647 | | - void ToggleOeilOnce() |
---|
| 2250 | + public void ToggleOeilOnce() |
---|
648 | 2251 | { |
---|
649 | 2252 | OEILONCE ^= true; |
---|
| 2253 | + } |
---|
| 2254 | + |
---|
| 2255 | + void ToggleFootContact() |
---|
| 2256 | + { |
---|
| 2257 | + FOOTCONTACT ^= true; |
---|
| 2258 | + } |
---|
| 2259 | + |
---|
| 2260 | + void ToggleDebug() |
---|
| 2261 | + { |
---|
| 2262 | + DEBUG ^= true; |
---|
650 | 2263 | } |
---|
651 | 2264 | |
---|
652 | 2265 | void ToggleLookAt() |
---|
.. | .. |
---|
654 | 2267 | LOOKAT ^= true; |
---|
655 | 2268 | } |
---|
656 | 2269 | |
---|
657 | | - void ToggleRandom() |
---|
| 2270 | + void ToggleSwitch() |
---|
658 | 2271 | { |
---|
659 | | - RANDOM ^= true; |
---|
| 2272 | + SWITCH ^= true; |
---|
660 | 2273 | } |
---|
661 | 2274 | |
---|
662 | 2275 | void ToggleHandles() |
---|
.. | .. |
---|
759 | 2372 | |
---|
760 | 2373 | GL currentGL; |
---|
761 | 2374 | |
---|
762 | | - GL GetGL() |
---|
| 2375 | + public GL GetGL() // INTERFACE |
---|
763 | 2376 | { |
---|
764 | 2377 | return currentGL; |
---|
765 | 2378 | } |
---|
766 | | - |
---|
| 2379 | + |
---|
767 | 2380 | /**/ |
---|
768 | 2381 | class CacheTexture |
---|
769 | 2382 | { |
---|
.. | .. |
---|
2595 | 4208 | |
---|
2596 | 4209 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
2597 | 4210 | { |
---|
| 4211 | + new Exception().printStackTrace(); |
---|
2598 | 4212 | System.exit(0); |
---|
2599 | 4213 | com.sun.opengl.util.texture.Texture texture = null; |
---|
2600 | 4214 | |
---|
.. | .. |
---|
6271 | 7885 | return null; |
---|
6272 | 7886 | } |
---|
6273 | 7887 | |
---|
6274 | | - void ReleaseTextures(cTexture tex) |
---|
| 7888 | + public void ReleaseTextures(cTexture tex) // INTERFACE |
---|
6275 | 7889 | { |
---|
6276 | 7890 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6277 | 7891 | { |
---|
.. | .. |
---|
6309 | 7923 | |
---|
6310 | 7924 | void ReleaseTexture(String tex, boolean bump) |
---|
6311 | 7925 | { |
---|
6312 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 7926 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6313 | 7927 | ambientOcclusion ) // || !textureon) |
---|
6314 | 7928 | { |
---|
6315 | 7929 | return; |
---|
.. | .. |
---|
6410 | 8024 | } |
---|
6411 | 8025 | } |
---|
6412 | 8026 | |
---|
6413 | | - /*boolean*/ void BindTextures(cTexture tex, int resolution) |
---|
| 8027 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
6414 | 8028 | { |
---|
6415 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 8029 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6416 | 8030 | ambientOcclusion ) // || !textureon) |
---|
6417 | 8031 | { |
---|
6418 | 8032 | return; // false; |
---|
.. | .. |
---|
6455 | 8069 | return; // true; |
---|
6456 | 8070 | } |
---|
6457 | 8071 | |
---|
6458 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8072 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8073 | + |
---|
| 8074 | + private boolean FileExists(String tex) |
---|
| 8075 | + { |
---|
| 8076 | + if (missingTextures.contains(tex)) |
---|
| 8077 | + { |
---|
| 8078 | + return false; |
---|
| 8079 | + } |
---|
| 8080 | + |
---|
| 8081 | + boolean fileExists = new File(tex).exists(); |
---|
| 8082 | + |
---|
| 8083 | + if (!fileExists) |
---|
| 8084 | + { |
---|
| 8085 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8086 | + missingTextures.add(tex); |
---|
| 8087 | + } |
---|
| 8088 | + |
---|
| 8089 | + return fileExists; |
---|
| 8090 | + } |
---|
| 8091 | + |
---|
| 8092 | + CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
6459 | 8093 | { |
---|
6460 | 8094 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
6461 | 8095 | |
---|
.. | .. |
---|
6463 | 8097 | { |
---|
6464 | 8098 | String texname = tex; |
---|
6465 | 8099 | |
---|
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; |
---|
| 8100 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8101 | + |
---|
| 8102 | +// String[] split = tex.split("Textures"); |
---|
| 8103 | +// if (split.length > 1) |
---|
| 8104 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8105 | +// else |
---|
| 8106 | +// if (!texname.startsWith("/")) |
---|
| 8107 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8108 | + if (!FileExists(tex)) |
---|
| 8109 | + { |
---|
| 8110 | + texname = fallbackTextureName; |
---|
| 8111 | + } |
---|
6472 | 8112 | |
---|
6473 | 8113 | if (CACHETEXTURE) |
---|
6474 | 8114 | texture = textures.get(texname); // TEXTURE CACHE |
---|
.. | .. |
---|
6537 | 8177 | } |
---|
6538 | 8178 | |
---|
6539 | 8179 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
6540 | | - if (!new File(cachename).exists()) |
---|
| 8180 | + if (!FileExists(cachename)) |
---|
6541 | 8181 | cachename = texname; |
---|
6542 | 8182 | else |
---|
6543 | 8183 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
6559 | 8199 | } |
---|
6560 | 8200 | |
---|
6561 | 8201 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
6562 | | - if (!new File(cachename).exists()) |
---|
| 8202 | + if (!FileExists(cachename)) |
---|
6563 | 8203 | cachename = texname; |
---|
6564 | 8204 | else |
---|
6565 | 8205 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
6568 | 8208 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
6569 | 8209 | |
---|
6570 | 8210 | |
---|
6571 | | - if (texturedata != null) |
---|
| 8211 | + if (texturedata == null) |
---|
| 8212 | + throw new Exception(); |
---|
| 8213 | + |
---|
6572 | 8214 | texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
6573 | 8215 | //texture = GetTexture(tex, bump); |
---|
6574 | 8216 | } |
---|
.. | .. |
---|
6690 | 8332 | return texture; |
---|
6691 | 8333 | } |
---|
6692 | 8334 | |
---|
6693 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8335 | + com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
6694 | 8336 | { |
---|
6695 | 8337 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
6696 | 8338 | |
---|
.. | .. |
---|
6708 | 8350 | return texture!=null?texture.texture:null; |
---|
6709 | 8351 | } |
---|
6710 | 8352 | |
---|
6711 | | - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8353 | + public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
6712 | 8354 | { |
---|
6713 | 8355 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
6714 | 8356 | |
---|
6715 | 8357 | return texture!=null?texture.texturedata:null; |
---|
6716 | 8358 | } |
---|
6717 | 8359 | |
---|
6718 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8360 | + boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
6719 | 8361 | { |
---|
6720 | 8362 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6721 | 8363 | { |
---|
.. | .. |
---|
7312 | 8954 | static boolean occlusionInitialized = false; |
---|
7313 | 8955 | boolean selection = false; |
---|
7314 | 8956 | boolean pointselection = false; |
---|
7315 | | - /*static*/ boolean lighttouched = true; |
---|
| 8957 | + ///*static*/ boolean lighttouched = true; |
---|
7316 | 8958 | boolean deselect; |
---|
7317 | | - boolean ambientOcclusion = false; |
---|
| 8959 | + private boolean ambientOcclusion = false; |
---|
7318 | 8960 | static boolean flash = false; |
---|
7319 | 8961 | /*static*/ boolean wait = false; |
---|
7320 | 8962 | boolean displaydone = false; // after repaint() calls |
---|
.. | .. |
---|
7603 | 9245 | |
---|
7604 | 9246 | boolean restartframe = false; |
---|
7605 | 9247 | |
---|
7606 | | - static int framecount = 0; // general-purpose global count |
---|
7607 | | - |
---|
7608 | 9248 | void displayAntiAliased(javax.media.opengl.GL gl) |
---|
7609 | 9249 | { |
---|
7610 | 9250 | //gl.glGetIntegerv(gl.GL_ACCUM_RED_BITS, viewport, 0); |
---|
.. | .. |
---|
7635 | 9275 | gl.glClear(gl.GL_ACCUM_BUFFER_BIT); |
---|
7636 | 9276 | for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0) |
---|
7637 | 9277 | { |
---|
7638 | | - framecount++; |
---|
| 9278 | + Globals.framecount++; |
---|
7639 | 9279 | |
---|
7640 | 9280 | if (CameraPane.tickcount > 0) |
---|
7641 | 9281 | CameraPane.tickcount--; |
---|
.. | .. |
---|
7673 | 9313 | |
---|
7674 | 9314 | gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0); |
---|
7675 | 9315 | */ |
---|
7676 | | - lighttouched = true; |
---|
| 9316 | + Globals.lighttouched = true; |
---|
7677 | 9317 | //System.err.println(" shadowbuffer: " + jitter); |
---|
7678 | 9318 | shadowbuffer.display(); |
---|
7679 | 9319 | |
---|
.. | .. |
---|
7694 | 9334 | assert (parentcam != renderCamera); |
---|
7695 | 9335 | |
---|
7696 | 9336 | if (renderCamera != lightCamera) |
---|
7697 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7698 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9337 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9338 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
7699 | 9339 | |
---|
7700 | 9340 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
7701 | 9341 | |
---|
.. | .. |
---|
7710 | 9350 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
7711 | 9351 | |
---|
7712 | 9352 | if (renderCamera != lightCamera) |
---|
7713 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7714 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9353 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9354 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
7715 | 9355 | |
---|
7716 | 9356 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
7717 | 9357 | |
---|
.. | .. |
---|
7783 | 9423 | //gl.glFlush(); |
---|
7784 | 9424 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
7785 | 9425 | |
---|
7786 | | - if (ANIMATION && ABORTED) |
---|
| 9426 | + if (Globals.ANIMATION && ABORTED) |
---|
7787 | 9427 | { |
---|
7788 | 9428 | System.err.println(" ABORTED FRAME"); |
---|
7789 | 9429 | break; |
---|
.. | .. |
---|
7813 | 9453 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
7814 | 9454 | |
---|
7815 | 9455 | // save image |
---|
7816 | | - if (ANIMATION && !ABORTED) |
---|
| 9456 | + if (Globals.ANIMATION && !ABORTED) |
---|
7817 | 9457 | { |
---|
7818 | 9458 | VPwidth = viewport[2]; |
---|
7819 | 9459 | VPheight = viewport[3]; |
---|
.. | .. |
---|
7924 | 9564 | |
---|
7925 | 9565 | // imagecount++; |
---|
7926 | 9566 | |
---|
7927 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9567 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
7928 | 9568 | |
---|
7929 | 9569 | if (!BOXMODE) |
---|
7930 | 9570 | { |
---|
7931 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9571 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
7932 | 9572 | } |
---|
7933 | 9573 | |
---|
7934 | 9574 | if (!BOXMODE) |
---|
.. | .. |
---|
7966 | 9606 | ABORTED = false; |
---|
7967 | 9607 | } |
---|
7968 | 9608 | else |
---|
7969 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 9609 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
7970 | 9610 | |
---|
7971 | 9611 | if (false) |
---|
7972 | 9612 | { |
---|
.. | .. |
---|
8620 | 10260 | } |
---|
8621 | 10261 | } |
---|
8622 | 10262 | |
---|
8623 | | - boolean IsFrozen() |
---|
8624 | | - { |
---|
8625 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
8626 | | - |
---|
8627 | | - return !selectmode && cameracount == 0; // != 0; |
---|
8628 | | - } |
---|
8629 | | - |
---|
8630 | 10263 | boolean niceon = false; |
---|
8631 | 10264 | javax.swing.Timer AAtimer = new javax.swing.Timer(750, this); |
---|
8632 | 10265 | boolean currentlydrawing = false; |
---|
.. | .. |
---|
8636 | 10269 | |
---|
8637 | 10270 | public void display(GLAutoDrawable drawable) |
---|
8638 | 10271 | { |
---|
8639 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10272 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
8640 | 10273 | { |
---|
8641 | | - GrafreeD.wav.save(); |
---|
8642 | | - GrafreeD.savesound = false; |
---|
8643 | | - GrafreeD.hassound = false; |
---|
| 10274 | + Grafreed.wav.save(); |
---|
| 10275 | + Grafreed.savesound = false; |
---|
| 10276 | + Grafreed.hassound = false; |
---|
8644 | 10277 | } |
---|
8645 | 10278 | // if (DEBUG_SELECTION) |
---|
8646 | 10279 | // { |
---|
8647 | | -// if (drawMode != SELECTION) |
---|
8648 | | -// drawMode = SELECTION; |
---|
| 10280 | +// if (DrawMode() != SELECTION) |
---|
| 10281 | +// DrawMode() = SELECTION; |
---|
8649 | 10282 | // } |
---|
8650 | 10283 | |
---|
8651 | 10284 | if (!isRenderer) |
---|
.. | .. |
---|
8701 | 10334 | |
---|
8702 | 10335 | //ANTIALIAS = 0; |
---|
8703 | 10336 | |
---|
8704 | | - if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
| 10337 | + if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
8705 | 10338 | { |
---|
8706 | | - if (niceon || isLIVE()) |
---|
| 10339 | + if (niceon || Globals.isLIVE()) |
---|
8707 | 10340 | { |
---|
8708 | 10341 | //if(active == 0) |
---|
8709 | 10342 | // antialiaser = null; |
---|
.. | .. |
---|
8728 | 10361 | assert eyeCamera.shaper_zFar == 1E5f; // 500.0f; |
---|
8729 | 10362 | */ |
---|
8730 | 10363 | |
---|
8731 | | - if (drawMode == DEFAULT) |
---|
| 10364 | + if (DrawMode() == DEFAULT) |
---|
8732 | 10365 | { |
---|
8733 | 10366 | currentlydrawing = true; |
---|
8734 | 10367 | } |
---|
.. | .. |
---|
8759 | 10392 | |
---|
8760 | 10393 | // if(Applet3D.clipboard != null) |
---|
8761 | 10394 | // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent); |
---|
8762 | | -//drawMode = SELECTION; |
---|
| 10395 | +//DrawMode() = SELECTION; |
---|
8763 | 10396 | indexcount = 0; |
---|
8764 | 10397 | |
---|
8765 | | - if (drawMode == OCCLUSION) |
---|
| 10398 | + if (DrawMode() == OCCLUSION) |
---|
8766 | 10399 | { |
---|
8767 | | - drawMode = DEFAULT; |
---|
| 10400 | + Globals.drawMode = DEFAULT; // WARNING |
---|
8768 | 10401 | ambientOcclusion = true; |
---|
8769 | 10402 | setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
---|
8770 | 10403 | Object3D theobject = object; |
---|
8771 | 10404 | Object3D theparent = object.parent; |
---|
8772 | 10405 | object.parent = null; |
---|
8773 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10406 | + object = (Object3D)Grafreed.clone(object); |
---|
8774 | 10407 | object.Stripify(); |
---|
8775 | 10408 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
8776 | 10409 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
8783 | 10416 | ambientOcclusion = false; |
---|
8784 | 10417 | } |
---|
8785 | 10418 | |
---|
8786 | | - if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10419 | + if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
8787 | 10420 | { |
---|
8788 | 10421 | //if (RENDERSHADOW) // ? |
---|
8789 | 10422 | if (!IsFrozen()) |
---|
8790 | 10423 | { |
---|
8791 | 10424 | // dec 2012 |
---|
8792 | | - if (!ambientOcclusion && !(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)) |
---|
| 10425 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
8793 | 10426 | { |
---|
8794 | | - framecount++; |
---|
| 10427 | + Globals.framecount++; |
---|
8795 | 10428 | shadowbuffer.display(); |
---|
8796 | 10429 | } |
---|
8797 | 10430 | } |
---|
8798 | | - lighttouched = false; // ?? |
---|
| 10431 | + Globals.lighttouched = false; // ?? |
---|
8799 | 10432 | //drawing = true; |
---|
8800 | 10433 | //lighttouched = true; |
---|
8801 | 10434 | } |
---|
.. | .. |
---|
8816 | 10449 | //eyeCamera.shaper_fovy = 1; |
---|
8817 | 10450 | } |
---|
8818 | 10451 | |
---|
8819 | | - if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION) |
---|
| 10452 | + if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION) |
---|
8820 | 10453 | { |
---|
8821 | | - //System.out.println("drawMode = " + drawMode); |
---|
| 10454 | + //System.out.println("DrawMode() = " + DrawMode()); |
---|
8822 | 10455 | vertexMode |= VP_PASS; |
---|
8823 | 10456 | //vertexMode |= VP_PROJECTION; |
---|
8824 | 10457 | if (!ambientOcclusion) |
---|
.. | .. |
---|
8878 | 10511 | Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera; |
---|
8879 | 10512 | //Camera lightcam = new Camera(light0); |
---|
8880 | 10513 | |
---|
8881 | | - if (drawMode == SHADOW) |
---|
| 10514 | + if (DrawMode() == SHADOW) |
---|
8882 | 10515 | { |
---|
8883 | 10516 | /* |
---|
8884 | 10517 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
.. | .. |
---|
8916 | 10549 | |
---|
8917 | 10550 | // if (parentcam != renderCamera) // not a light |
---|
8918 | 10551 | if (cam != lightCamera) |
---|
8919 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8920 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10552 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10553 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
8921 | 10554 | |
---|
8922 | 10555 | for (int j = 0; j < 4; j++) |
---|
8923 | 10556 | { |
---|
.. | .. |
---|
8931 | 10564 | |
---|
8932 | 10565 | // if (parentcam != renderCamera) // not a light |
---|
8933 | 10566 | if (cam != lightCamera) |
---|
8934 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8935 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10567 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10568 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
8936 | 10569 | |
---|
8937 | 10570 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
8938 | 10571 | |
---|
.. | .. |
---|
8968 | 10601 | gl.glClear(gl.GL_DEPTH_BUFFER_BIT); |
---|
8969 | 10602 | } else |
---|
8970 | 10603 | { |
---|
8971 | | - if (drawMode != DEFAULT) |
---|
| 10604 | + if (DrawMode() != DEFAULT) |
---|
8972 | 10605 | { |
---|
8973 | 10606 | gl.glClearColor(1, 1, 1, 0); |
---|
8974 | 10607 | } // 1); |
---|
.. | .. |
---|
9033 | 10666 | |
---|
9034 | 10667 | fast &= !ambientOcclusion; |
---|
9035 | 10668 | |
---|
9036 | | - if (drawMode == DEFAULT) |
---|
| 10669 | + if (DrawMode() == DEFAULT) |
---|
9037 | 10670 | { |
---|
9038 | 10671 | //gl.glEnable(gl.GL_ALPHA_TEST); |
---|
9039 | 10672 | //gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
.. | .. |
---|
9191 | 10824 | // Bump noise |
---|
9192 | 10825 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
9193 | 10826 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
9194 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 10827 | + |
---|
| 10828 | + try |
---|
| 10829 | + { |
---|
| 10830 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 10831 | + } |
---|
| 10832 | + catch (Exception e) |
---|
| 10833 | + { |
---|
| 10834 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 10835 | + } |
---|
| 10836 | + |
---|
9195 | 10837 | |
---|
9196 | 10838 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
9197 | 10839 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9231 | 10873 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
9232 | 10874 | gl.glLoadIdentity(); |
---|
9233 | 10875 | |
---|
9234 | | - if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
| 10876 | + if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
9235 | 10877 | { |
---|
9236 | 10878 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9237 | 10879 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
.. | .. |
---|
9289 | 10931 | //gl.glPushMatrix(); |
---|
9290 | 10932 | gl.glLoadIdentity(); |
---|
9291 | 10933 | |
---|
9292 | | - if (!ambientOcclusion) // drawMode != OCCLUSION) |
---|
| 10934 | + if (!ambientOcclusion) // DrawMode() != OCCLUSION) |
---|
9293 | 10935 | { |
---|
9294 | 10936 | //LA.xformPos(light0, lightCamera.fromScreen, light); |
---|
9295 | 10937 | LA.xformDir(dirlight, lightCamera.fromScreen, lightposition); |
---|
.. | .. |
---|
9316 | 10958 | System.err.println("parentcam != renderCamera"); |
---|
9317 | 10959 | |
---|
9318 | 10960 | // if (cam != lightCamera) |
---|
9319 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9320 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 10961 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10962 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
9321 | 10963 | } |
---|
9322 | 10964 | |
---|
9323 | 10965 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
9338 | 10980 | if (true) // TODO |
---|
9339 | 10981 | { |
---|
9340 | 10982 | if (cam != lightCamera) |
---|
9341 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9342 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 10983 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10984 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
9343 | 10985 | } |
---|
9344 | 10986 | |
---|
9345 | 10987 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
9376 | 11018 | } |
---|
9377 | 11019 | |
---|
9378 | 11020 | /**/ |
---|
9379 | | - if (true) // drawMode == SELECTION) // != DEFAULT) |
---|
| 11021 | + if (true) // DrawMode() == SELECTION) // != DEFAULT) |
---|
9380 | 11022 | gl.glDisable(gl.GL_LIGHTING); |
---|
9381 | 11023 | else |
---|
9382 | 11024 | gl.glEnable(gl.GL_LIGHTING); |
---|
.. | .. |
---|
9394 | 11036 | |
---|
9395 | 11037 | lightslot = 64; |
---|
9396 | 11038 | |
---|
9397 | | - if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT) |
---|
| 11039 | + if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT) |
---|
9398 | 11040 | { |
---|
9399 | 11041 | DrawLights(object); |
---|
9400 | 11042 | } |
---|
.. | .. |
---|
9405 | 11047 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
9406 | 11048 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
9407 | 11049 | |
---|
9408 | | - if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION) |
---|
| 11050 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
9409 | 11051 | { |
---|
9410 | 11052 | /* |
---|
9411 | 11053 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
9438 | 11080 | } |
---|
9439 | 11081 | } |
---|
9440 | 11082 | |
---|
9441 | | - if (drawMode == DEFAULT) |
---|
| 11083 | + if (DrawMode() == DEFAULT) |
---|
9442 | 11084 | { |
---|
9443 | 11085 | if (WIREFRAME && !ambientOcclusion) |
---|
9444 | 11086 | { |
---|
.. | .. |
---|
9456 | 11098 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9457 | 11099 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9458 | 11100 | |
---|
9459 | | - if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) // |
---|
| 11101 | + if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) // |
---|
9460 | 11102 | { |
---|
9461 | 11103 | if (vertexMode != 0) // && !fast) |
---|
9462 | 11104 | { |
---|
.. | .. |
---|
9476 | 11118 | } |
---|
9477 | 11119 | } |
---|
9478 | 11120 | |
---|
9479 | | - if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion) |
---|
| 11121 | + if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
9480 | 11122 | { |
---|
9481 | 11123 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
9482 | 11124 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
9504 | 11146 | //gl.glDepthMask(false); |
---|
9505 | 11147 | } |
---|
9506 | 11148 | |
---|
9507 | | - if (false) // drawMode == SHADOW) |
---|
| 11149 | + if (false) // DrawMode() == SHADOW) |
---|
9508 | 11150 | { |
---|
9509 | 11151 | //SetColumnMajorData(cameraInverseTransform, view_1); |
---|
9510 | 11152 | //System.out.println("light = " + cameraInverseTransform); |
---|
.. | .. |
---|
9518 | 11160 | //System.out.println("object = " + object); |
---|
9519 | 11161 | if (!frozen && !imageLocked) |
---|
9520 | 11162 | { |
---|
9521 | | - if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0) |
---|
| 11163 | + if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0) |
---|
9522 | 11164 | { |
---|
9523 | 11165 | displayAntiAliased(gl); |
---|
9524 | 11166 | } else |
---|
9525 | 11167 | { |
---|
9526 | 11168 | programcount = 0; |
---|
9527 | | - int keepmode = drawMode; |
---|
| 11169 | + int keepmode = DrawMode(); |
---|
9528 | 11170 | // if (DEBUG_SELECTION) |
---|
9529 | 11171 | // { |
---|
9530 | | -// drawMode = SELECTION; |
---|
| 11172 | +// DrawMode() = SELECTION; |
---|
9531 | 11173 | // } |
---|
9532 | 11174 | // for point selection |
---|
9533 | 11175 | // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0); |
---|
.. | .. |
---|
9537 | 11179 | DrawObject(gl); |
---|
9538 | 11180 | |
---|
9539 | 11181 | // jan 2013 System.err.println("RESET ABORT (display)"); |
---|
9540 | | - // if (drawMode == DEFAULT) |
---|
| 11182 | + // if (DrawMode() == DEFAULT) |
---|
9541 | 11183 | // ABORTED = false; |
---|
9542 | 11184 | fullreset = false; |
---|
9543 | | - drawMode = keepmode; |
---|
| 11185 | + Globals.drawMode = keepmode; // WARNING |
---|
9544 | 11186 | //System.out.println("PROGRAM SWITCH " + programcount); |
---|
9545 | 11187 | } |
---|
9546 | 11188 | } |
---|
.. | .. |
---|
9548 | 11190 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9549 | 11191 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9550 | 11192 | |
---|
9551 | | - if (drawMode == DEFAULT) |
---|
| 11193 | + if (DrawMode() == DEFAULT) |
---|
9552 | 11194 | { |
---|
9553 | 11195 | ReleaseTexture(NOISE_TEXTURE, false); |
---|
9554 | 11196 | } |
---|
9555 | | - //if (drawMode == DEFAULT) |
---|
| 11197 | + //if (DrawMode() == DEFAULT) |
---|
9556 | 11198 | { |
---|
9557 | 11199 | |
---|
9558 | 11200 | gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
.. | .. |
---|
9564 | 11206 | //else |
---|
9565 | 11207 | //gl.glDisable(gl.GL_TEXTURE_2D); |
---|
9566 | 11208 | //gl.glPopMatrix(); |
---|
9567 | | - if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
| 11209 | + if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
9568 | 11210 | { |
---|
9569 | 11211 | //new Exception().printStackTrace(); |
---|
9570 | 11212 | //System.out.println("Draw image " + width + ", " + height); |
---|
.. | .. |
---|
9606 | 11248 | //gl.glFlush(); |
---|
9607 | 11249 | } |
---|
9608 | 11250 | |
---|
9609 | | - if (flash && drawMode == DEFAULT) |
---|
| 11251 | + if (flash && DrawMode() == DEFAULT) |
---|
9610 | 11252 | { |
---|
9611 | 11253 | flash = false; |
---|
9612 | 11254 | wait = true; |
---|
.. | .. |
---|
9614 | 11256 | } |
---|
9615 | 11257 | |
---|
9616 | 11258 | //drawing = false; |
---|
9617 | | - //if(drawMode == DEFAULT) |
---|
| 11259 | + //if(DrawMode() == DEFAULT) |
---|
9618 | 11260 | // niceon = false; |
---|
9619 | | - if (drawMode == DEFAULT) |
---|
| 11261 | + if (DrawMode() == DEFAULT) |
---|
9620 | 11262 | { |
---|
9621 | 11263 | currentlydrawing = false; |
---|
9622 | 11264 | } |
---|
.. | .. |
---|
9636 | 11278 | repaint(); |
---|
9637 | 11279 | } |
---|
9638 | 11280 | |
---|
9639 | | - if (isLIVE() && drawMode == DEFAULT) // may 2013 |
---|
| 11281 | + if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 |
---|
9640 | 11282 | repaint(); |
---|
9641 | 11283 | |
---|
9642 | 11284 | displaydone = true; |
---|
.. | .. |
---|
9655 | 11297 | { |
---|
9656 | 11298 | renderpass++; |
---|
9657 | 11299 | // System.out.println("Draw object... "); |
---|
| 11300 | + STEP = 1; |
---|
9658 | 11301 | if (FAST) // in case there is no script |
---|
9659 | | - STEP = 16; |
---|
| 11302 | + STEP = 8; |
---|
| 11303 | + |
---|
| 11304 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11305 | + { |
---|
| 11306 | + STEP *= 4; |
---|
| 11307 | + } |
---|
9660 | 11308 | |
---|
9661 | 11309 | //object.FullInvariants(); |
---|
9662 | 11310 | |
---|
.. | .. |
---|
9670 | 11318 | e.printStackTrace(); |
---|
9671 | 11319 | } |
---|
9672 | 11320 | |
---|
9673 | | - if (GrafreeD.RENDERME > 0) |
---|
9674 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11321 | + if (Grafreed.RENDERME > 0) |
---|
| 11322 | + Grafreed.RENDERME--; // mechante magouille |
---|
9675 | 11323 | |
---|
9676 | | - ONESTEP = false; |
---|
| 11324 | + Globals.ONESTEP = false; |
---|
9677 | 11325 | } |
---|
9678 | 11326 | |
---|
9679 | 11327 | static boolean zoomonce = false; |
---|
.. | .. |
---|
9681 | 11329 | void DrawObject(GL gl, boolean draw) |
---|
9682 | 11330 | { |
---|
9683 | 11331 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
9684 | | -// drawMode = SELECTION; |
---|
| 11332 | +// DrawMode() = SELECTION; |
---|
9685 | 11333 | //GL gl = getGL(); |
---|
9686 | 11334 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
9687 | 11335 | { |
---|
9688 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 11336 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
9689 | 11337 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
9690 | 11338 | pingthread.StepToTarget(true); // true); |
---|
9691 | 11339 | // zoomonce = false; |
---|
.. | .. |
---|
9706 | 11354 | callist = gl.glGenLists(1); |
---|
9707 | 11355 | } |
---|
9708 | 11356 | |
---|
9709 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11357 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
9710 | 11358 | |
---|
9711 | | - boolean active = !selectmode; // drawMode != SELECTION; // mouseDown; |
---|
| 11359 | + boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
9712 | 11360 | |
---|
9713 | 11361 | if (!mainDL || !active || touched) |
---|
9714 | 11362 | { |
---|
.. | .. |
---|
9735 | 11383 | PushMatrix(ClickInfo.matbuffer); |
---|
9736 | 11384 | } |
---|
9737 | 11385 | |
---|
9738 | | - if (drawMode == 0) |
---|
| 11386 | + if (DrawMode() == 0) |
---|
9739 | 11387 | { |
---|
9740 | 11388 | // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++"); |
---|
9741 | 11389 | |
---|
9742 | 11390 | usedtextures.clear(); |
---|
9743 | 11391 | |
---|
9744 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11392 | + try |
---|
| 11393 | + { |
---|
| 11394 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11395 | + } |
---|
| 11396 | + catch (Exception e) |
---|
| 11397 | + { |
---|
| 11398 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11399 | + } |
---|
9745 | 11400 | } |
---|
9746 | 11401 | //System.out.println("--> " + stackdepth); |
---|
9747 | 11402 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
9749 | 11404 | // DRAW |
---|
9750 | 11405 | object.draw(this, /*(Composite)*/ object, false, false); |
---|
9751 | 11406 | |
---|
9752 | | - if (drawMode == DEFAULT) |
---|
| 11407 | + if (DrawMode() == DEFAULT) |
---|
9753 | 11408 | { |
---|
9754 | 11409 | if (DEBUG) |
---|
9755 | 11410 | { |
---|
.. | .. |
---|
9801 | 11456 | } |
---|
9802 | 11457 | // GrafreeD.traceoff(); |
---|
9803 | 11458 | //System.out.println(stackdepth); |
---|
9804 | | - if (drawMode == 0) |
---|
| 11459 | + if (DrawMode() == 0) |
---|
9805 | 11460 | { |
---|
9806 | 11461 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
9807 | 11462 | |
---|
.. | .. |
---|
9826 | 11481 | |
---|
9827 | 11482 | checker = null; |
---|
9828 | 11483 | |
---|
9829 | | - if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT) |
---|
| 11484 | + if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT) |
---|
9830 | 11485 | FindChecker(object); |
---|
9831 | 11486 | |
---|
9832 | | - if (checker != null && drawMode == DEFAULT) |
---|
| 11487 | + if (checker != null && DrawMode() == DEFAULT) |
---|
9833 | 11488 | { |
---|
9834 | 11489 | //BindTexture(IMMORTAL_TEXTURE); |
---|
9835 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11490 | + try |
---|
| 11491 | + { |
---|
| 11492 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11493 | + } |
---|
| 11494 | + catch (Exception e) |
---|
| 11495 | + { |
---|
| 11496 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11497 | + } |
---|
9836 | 11498 | // NEAREST |
---|
9837 | 11499 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
9838 | 11500 | DrawChecker(gl); |
---|
.. | .. |
---|
9851 | 11513 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9852 | 11514 | //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9853 | 11515 | |
---|
9854 | | - if (DISPLAYTEXT && drawMode == DEFAULT) |
---|
| 11516 | + if (DISPLAYTEXT && DrawMode() == DEFAULT) |
---|
9855 | 11517 | { |
---|
9856 | 11518 | // Draw it once, then use the raster |
---|
9857 | 11519 | Balloon(gl, balloon.createGraphics()); |
---|
.. | .. |
---|
9907 | 11569 | int[] xs = new int[3]; |
---|
9908 | 11570 | int[] ys = new int[3]; |
---|
9909 | 11571 | |
---|
9910 | | - void DrawString(Object3D obj) // String string) |
---|
| 11572 | + public void DrawString(Object3D obj) // String string) // INTERFACE |
---|
9911 | 11573 | { |
---|
9912 | | - if (!DISPLAYTEXT || drawMode != DEFAULT) |
---|
| 11574 | + if (!DISPLAYTEXT || DrawMode() != DEFAULT) |
---|
9913 | 11575 | { |
---|
9914 | 11576 | return; |
---|
9915 | 11577 | } |
---|
9916 | 11578 | |
---|
9917 | | - String string = obj.GetToolTip(); |
---|
| 11579 | + String string = obj.toString(); //.GetToolTip(); |
---|
9918 | 11580 | |
---|
9919 | 11581 | GL gl = GetGL(); |
---|
9920 | 11582 | |
---|
.. | .. |
---|
10231 | 11893 | //obj.TransformToWorld(light, light); |
---|
10232 | 11894 | for (int i = tp.size(); --i >= 0;) |
---|
10233 | 11895 | { |
---|
10234 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
10235 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 11896 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 11897 | + LA.xformPos(light, tp.get(i).GlobalTransform(), light); |
---|
10236 | 11898 | } |
---|
10237 | 11899 | |
---|
10238 | 11900 | |
---|
.. | .. |
---|
10249 | 11911 | parentcam = cameras[0]; |
---|
10250 | 11912 | } |
---|
10251 | 11913 | |
---|
10252 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10253 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 11914 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11915 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
10254 | 11916 | |
---|
10255 | 11917 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
10256 | 11918 | |
---|
.. | .. |
---|
10864 | 12526 | |
---|
10865 | 12527 | // display shadow only (bump == 0) |
---|
10866 | 12528 | "SUB temp.x, half.x, shadow.x;" + |
---|
10867 | | - "MOV temp.y, -params6.x;" + |
---|
10868 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12529 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12530 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
10869 | 12531 | "SUB temp.y, one.x, temp.z;" + |
---|
10870 | 12532 | "MUL temp.x, temp.x, temp.y;" + |
---|
10871 | 12533 | "KIL temp.x;" + |
---|
.. | .. |
---|
10994 | 12656 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
10995 | 12657 | |
---|
10996 | 12658 | "SUB temp.x, one.x, ndotl.x;" + |
---|
10997 | | - "ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
10998 | | - "ADD temp.y, one.y, options2.y;" + // sursurface |
---|
| 12659 | + // Tuning for default skin |
---|
| 12660 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 12661 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 12662 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
10999 | 12663 | "MUL temp.x, temp.x, temp.y;" + |
---|
11000 | 12664 | |
---|
11001 | 12665 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
11194 | 12858 | //once = true; |
---|
11195 | 12859 | } |
---|
11196 | 12860 | |
---|
11197 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 12861 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
11198 | 12862 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
11199 | 12863 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
11200 | 12864 | |
---|
.. | .. |
---|
11327 | 12991 | |
---|
11328 | 12992 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
11329 | 12993 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 12994 | + |
---|
| 12995 | + // Compare fragment depth in light space with shadowmap. |
---|
11330 | 12996 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
11331 | 12997 | "SGE temp.y, temp.x, zero.x;" + |
---|
11332 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 12998 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 12999 | + |
---|
| 13000 | + // Reverse comparison |
---|
11333 | 13001 | "SUB temp.x, one.x, temp.x;" + |
---|
11334 | 13002 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
11335 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13003 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
11336 | 13004 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
11337 | 13005 | |
---|
11338 | 13006 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
11346 | 13014 | // No shadow for backface |
---|
11347 | 13015 | "DP3 temp.x, normal, lightd;" + |
---|
11348 | 13016 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13017 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13018 | + |
---|
| 13019 | + // No shadow when out of frustrum |
---|
| 13020 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
11349 | 13021 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
11350 | 13022 | ""; |
---|
11351 | 13023 | } |
---|
.. | .. |
---|
11904 | 13576 | public void mousePressed(MouseEvent e) |
---|
11905 | 13577 | { |
---|
11906 | 13578 | //System.out.println("mousePressed: " + e); |
---|
11907 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 13579 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
11908 | 13580 | } |
---|
11909 | 13581 | |
---|
11910 | 13582 | static long prevtime = 0; |
---|
.. | .. |
---|
11931 | 13603 | |
---|
11932 | 13604 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
11933 | 13605 | |
---|
| 13606 | + if (BUTTONLESSWHEEL) |
---|
11934 | 13607 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
11935 | 13608 | { |
---|
11936 | 13609 | return; |
---|
.. | .. |
---|
11939 | 13612 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
11940 | 13613 | |
---|
11941 | 13614 | // TIMER |
---|
11942 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 13615 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
11943 | 13616 | { |
---|
11944 | 13617 | keepboxmode = BOXMODE; |
---|
11945 | 13618 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
11979 | 13652 | // mode |= META; |
---|
11980 | 13653 | //} |
---|
11981 | 13654 | |
---|
11982 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
11983 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 13655 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 13656 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
11984 | 13657 | anchorX = ax; |
---|
11985 | 13658 | anchorY = ay; |
---|
11986 | 13659 | prevX = px; |
---|
.. | .. |
---|
12040 | 13713 | // wasliveok = true; |
---|
12041 | 13714 | // waslive = false; |
---|
12042 | 13715 | |
---|
| 13716 | + // May 2019 Forget it: |
---|
| 13717 | + if (true) |
---|
| 13718 | + return; |
---|
| 13719 | + |
---|
12043 | 13720 | // source == timer |
---|
12044 | 13721 | if (mouseDown) |
---|
12045 | 13722 | { |
---|
.. | .. |
---|
12068 | 13745 | // ObjEditor.tweenManager.update(1f / 60f); |
---|
12069 | 13746 | |
---|
12070 | 13747 | // fev 2014??? |
---|
12071 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode) |
---|
| 13748 | + if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
12072 | 13749 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
12073 | 13750 | pingthread.StepToTarget(true); // true); |
---|
12074 | 13751 | } |
---|
.. | .. |
---|
12078 | 13755 | |
---|
12079 | 13756 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
12080 | 13757 | |
---|
12081 | | - void clickStart(int x, int y, int modifiers) |
---|
| 13758 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
12082 | 13759 | { |
---|
12083 | 13760 | if (!wasliveok) |
---|
12084 | 13761 | return; |
---|
.. | .. |
---|
12095 | 13772 | // touched = true; // main DL |
---|
12096 | 13773 | if (isRenderer) |
---|
12097 | 13774 | { |
---|
12098 | | - SetMouseMode(modifiers); |
---|
| 13775 | + SetMouseMode(modifiers, modifiersex); |
---|
12099 | 13776 | } |
---|
12100 | 13777 | |
---|
12101 | 13778 | selectX = anchorX = x; |
---|
.. | .. |
---|
12108 | 13785 | clicked = true; |
---|
12109 | 13786 | hold = false; |
---|
12110 | 13787 | |
---|
12111 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 13788 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
12112 | 13789 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
12113 | 13790 | { |
---|
12114 | 13791 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
12139 | 13816 | info.camera = renderCamera; |
---|
12140 | 13817 | info.x = x; |
---|
12141 | 13818 | info.y = y; |
---|
12142 | | - info.modifiers = modifiers; |
---|
| 13819 | + info.modifiers = modifiersex; |
---|
12143 | 13820 | editObj = object.doEditClick(info, 0); |
---|
12144 | 13821 | if (!editObj) |
---|
12145 | 13822 | { |
---|
.. | .. |
---|
12156 | 13833 | |
---|
12157 | 13834 | public void mouseDragged(MouseEvent e) |
---|
12158 | 13835 | { |
---|
| 13836 | + Globals.MOUSEDRAGGED = true; |
---|
| 13837 | + |
---|
| 13838 | + //System.out.println("mouseDragged: " + e); |
---|
12159 | 13839 | if (isRenderer) |
---|
12160 | 13840 | movingcamera = true; |
---|
| 13841 | + |
---|
12161 | 13842 | //if (drawing) |
---|
12162 | 13843 | //return; |
---|
12163 | | - //System.out.println("mouseDragged: " + e); |
---|
12164 | 13844 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
12165 | 13845 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
12166 | 13846 | { |
---|
.. | .. |
---|
12168 | 13848 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12169 | 13849 | } |
---|
12170 | 13850 | else |
---|
12171 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 13851 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12172 | 13852 | |
---|
12173 | 13853 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
12174 | 13854 | } |
---|
.. | .. |
---|
12180 | 13860 | cVector tmp = new cVector(); |
---|
12181 | 13861 | cVector tmp2 = new cVector(); |
---|
12182 | 13862 | boolean isMoving; |
---|
| 13863 | + |
---|
| 13864 | + public cVector TargetLookAt() |
---|
| 13865 | + { |
---|
| 13866 | + return targetLookAt; |
---|
| 13867 | + } |
---|
12183 | 13868 | |
---|
12184 | 13869 | class PingThread extends Thread |
---|
12185 | 13870 | { |
---|
.. | .. |
---|
12319 | 14004 | //System.out.println("---------------- ---------- Paint " + tmp.length2()); |
---|
12320 | 14005 | if (lightMode) |
---|
12321 | 14006 | { |
---|
12322 | | - lighttouched = true; |
---|
| 14007 | + Globals.lighttouched = true; |
---|
12323 | 14008 | } |
---|
12324 | 14009 | |
---|
12325 | 14010 | if (OEILONCE && OEIL) |
---|
.. | .. |
---|
12336 | 14021 | |
---|
12337 | 14022 | public void run() |
---|
12338 | 14023 | { |
---|
| 14024 | + new Exception().printStackTrace(); |
---|
12339 | 14025 | System.exit(0); |
---|
12340 | 14026 | for (;;) |
---|
12341 | 14027 | { |
---|
.. | .. |
---|
12377 | 14063 | mouseDown = false; |
---|
12378 | 14064 | if (lightMode) |
---|
12379 | 14065 | { |
---|
12380 | | - lighttouched = true; |
---|
| 14066 | + Globals.lighttouched = true; |
---|
12381 | 14067 | } |
---|
12382 | 14068 | repaint(); |
---|
12383 | 14069 | alreadypainted = true; |
---|
.. | .. |
---|
12385 | 14071 | isMoving = false; |
---|
12386 | 14072 | } //?? |
---|
12387 | 14073 | |
---|
12388 | | - if (isLIVE() && !alreadypainted) |
---|
| 14074 | + if (Globals.isLIVE() && !alreadypainted) |
---|
12389 | 14075 | { |
---|
12390 | 14076 | // FOR DEBUG BREAKPOINT USING PAUSE: while (true) |
---|
12391 | 14077 | repaint(); |
---|
.. | .. |
---|
12397 | 14083 | { |
---|
12398 | 14084 | if (lightMode) |
---|
12399 | 14085 | { |
---|
12400 | | - lighttouched = true; |
---|
| 14086 | + Globals.lighttouched = true; |
---|
12401 | 14087 | } |
---|
12402 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14088 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
12403 | 14089 | } |
---|
12404 | 14090 | //else |
---|
12405 | 14091 | } |
---|
.. | .. |
---|
12499 | 14185 | int X, Y; |
---|
12500 | 14186 | boolean SX, SY; |
---|
12501 | 14187 | |
---|
12502 | | - void drag(int x, int y, int modifiers) |
---|
| 14188 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
12503 | 14189 | { |
---|
12504 | 14190 | if (IsFrozen()) |
---|
12505 | 14191 | { |
---|
.. | .. |
---|
12508 | 14194 | |
---|
12509 | 14195 | drag = true; // NEW |
---|
12510 | 14196 | |
---|
12511 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14197 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
12512 | 14198 | |
---|
12513 | 14199 | X = x; |
---|
12514 | 14200 | Y = y; |
---|
12515 | 14201 | // floating state for animation |
---|
12516 | | - MODIFIERS = modifiers; |
---|
12517 | | - modifiers &= ~1024; |
---|
| 14202 | + MODIFIERS = modifiersex; |
---|
| 14203 | + modifiersex &= ~1024; |
---|
12518 | 14204 | if (false) // modifiers != 0) |
---|
12519 | 14205 | { |
---|
12520 | 14206 | //new Exception().printStackTrace(); |
---|
12521 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14207 | + System.out.println("mouseDragged: " + modifiersex); |
---|
12522 | 14208 | System.out.println("SHIFT = " + SHIFT); |
---|
12523 | 14209 | System.out.println("CONTROL = " + COMMAND); |
---|
12524 | 14210 | System.out.println("META = " + META); |
---|
.. | .. |
---|
12538 | 14224 | info.camera = renderCamera; |
---|
12539 | 14225 | info.x = x; |
---|
12540 | 14226 | info.y = y; |
---|
12541 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14227 | + object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
12542 | 14228 | } else |
---|
12543 | 14229 | { |
---|
12544 | 14230 | if (x < startX) |
---|
.. | .. |
---|
12651 | 14337 | |
---|
12652 | 14338 | if (manipCamera == lightCamera) |
---|
12653 | 14339 | { |
---|
12654 | | - lighttouched = true; |
---|
| 14340 | + Globals.lighttouched = true; |
---|
12655 | 14341 | } |
---|
12656 | 14342 | /* |
---|
12657 | 14343 | switch (mode) |
---|
.. | .. |
---|
12690 | 14376 | public void mouseMoved(MouseEvent e) |
---|
12691 | 14377 | { |
---|
12692 | 14378 | //System.out.println("mouseMoved: " + e); |
---|
12693 | | - |
---|
12694 | 14379 | if (isRenderer) |
---|
12695 | 14380 | return; |
---|
12696 | 14381 | |
---|
.. | .. |
---|
12715 | 14400 | |
---|
12716 | 14401 | public void mouseReleased(MouseEvent e) |
---|
12717 | 14402 | { |
---|
| 14403 | + Globals.MOUSEDRAGGED = false; |
---|
| 14404 | + |
---|
12718 | 14405 | movingcamera = false; |
---|
| 14406 | + X = Y = 0; |
---|
12719 | 14407 | //System.out.println("mouseReleased: " + e); |
---|
12720 | 14408 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12721 | 14409 | } |
---|
.. | .. |
---|
12738 | 14426 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
12739 | 14427 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
12740 | 14428 | |
---|
12741 | | - if (control || command || IsFrozen()) |
---|
| 14429 | +// No delay if (control || command || IsFrozen()) |
---|
12742 | 14430 | timeout = true; |
---|
12743 | | - else |
---|
| 14431 | +// ?? May 2019 else |
---|
12744 | 14432 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
12745 | 14433 | mouseDown = false; |
---|
12746 | 14434 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
12850 | 14538 | System.out.println("keyReleased: " + e); |
---|
12851 | 14539 | } |
---|
12852 | 14540 | |
---|
12853 | | - void SetMouseMode(int modifiers) |
---|
| 14541 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
12854 | 14542 | { |
---|
12855 | 14543 | //System.out.println("SetMouseMode = " + modifiers); |
---|
12856 | 14544 | //modifiers &= ~1024; |
---|
.. | .. |
---|
12862 | 14550 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
12863 | 14551 | // return; |
---|
12864 | 14552 | //System.out.println("SetMode = " + modifiers); |
---|
12865 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 14553 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
12866 | 14554 | { |
---|
12867 | 14555 | mouseMode |= ZOOM; |
---|
12868 | 14556 | } |
---|
12869 | 14557 | |
---|
12870 | 14558 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
12871 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 14559 | + if (capsLocked) // || (modifiers & META) == META) |
---|
12872 | 14560 | { |
---|
12873 | 14561 | mouseMode |= VR; // BACKFORTH; |
---|
12874 | 14562 | } |
---|
12875 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
| 14563 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
12876 | 14564 | { |
---|
12877 | 14565 | mouseMode |= SELECT; |
---|
12878 | 14566 | } |
---|
12879 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 14567 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
12880 | 14568 | { |
---|
12881 | 14569 | mouseMode |= SELECT; |
---|
12882 | 14570 | } |
---|
12883 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 14571 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
12884 | 14572 | { |
---|
12885 | 14573 | mouseMode &= ~VR; |
---|
12886 | 14574 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
12909 | 14597 | |
---|
12910 | 14598 | if (isRenderer) // |
---|
12911 | 14599 | { |
---|
12912 | | - SetMouseMode(modifiers); |
---|
| 14600 | + SetMouseMode(0, modifiers); |
---|
12913 | 14601 | } |
---|
12914 | 14602 | |
---|
12915 | | - theRenderer.keyPressed(key); |
---|
| 14603 | + Globals.theRenderer.keyPressed(key); |
---|
12916 | 14604 | } |
---|
12917 | 14605 | |
---|
12918 | 14606 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
12924 | 14612 | float SATPOW = 1; // 2; // 0.5f; |
---|
12925 | 14613 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
12926 | 14614 | |
---|
12927 | | - void keyPressed(int key) |
---|
| 14615 | + public void keyPressed(int key) |
---|
12928 | 14616 | { |
---|
12929 | 14617 | if (key >= '0' && key <= '5') |
---|
12930 | 14618 | clampbit = (key-'0'); |
---|
.. | .. |
---|
13039 | 14727 | case 'B': |
---|
13040 | 14728 | BRISMOOTH ^= true; |
---|
13041 | 14729 | SHADOWCULLFACE ^= true; |
---|
13042 | | - lighttouched = true; |
---|
| 14730 | + Globals.lighttouched = true; |
---|
13043 | 14731 | repaint(); |
---|
13044 | 14732 | break; |
---|
13045 | 14733 | case 'b': |
---|
.. | .. |
---|
13139 | 14827 | repaint(); |
---|
13140 | 14828 | break; |
---|
13141 | 14829 | case 'O': |
---|
13142 | | - drawMode = OCCLUSION; |
---|
| 14830 | + Globals.drawMode = OCCLUSION; // WARNING |
---|
13143 | 14831 | repaint(); |
---|
13144 | 14832 | break; |
---|
13145 | 14833 | case 'o': |
---|
.. | .. |
---|
13230 | 14918 | break; |
---|
13231 | 14919 | case ' ': |
---|
13232 | 14920 | lightMode ^= true; |
---|
13233 | | - lighttouched = true; |
---|
| 14921 | + Globals.lighttouched = true; |
---|
13234 | 14922 | manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
13235 | 14923 | targetLookAt.set(manipCamera.lookAt); |
---|
13236 | 14924 | repaint(); |
---|
.. | .. |
---|
13245 | 14933 | //RESIZETEXTURE ^= true; |
---|
13246 | 14934 | //break; |
---|
13247 | 14935 | case 'z': |
---|
13248 | | - RENDERSHADOW ^= true; |
---|
13249 | | - lighttouched = true; |
---|
| 14936 | + Globals.RENDERSHADOW ^= true; |
---|
| 14937 | + Globals.lighttouched = true; |
---|
13250 | 14938 | repaint(); |
---|
13251 | 14939 | break; |
---|
13252 | 14940 | //case UP: |
---|
.. | .. |
---|
13361 | 15049 | } |
---|
13362 | 15050 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
13363 | 15051 | } |
---|
| 15052 | + |
---|
13364 | 15053 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
13365 | 15054 | |
---|
13366 | 15055 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
13368 | 15057 | //mode = ROTATE; |
---|
13369 | 15058 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
13370 | 15059 | { |
---|
13371 | | - SetMouseMode(modifiers); |
---|
| 15060 | + SetMouseMode(0, modifiers); |
---|
13372 | 15061 | } |
---|
13373 | 15062 | } |
---|
13374 | 15063 | |
---|
13375 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 15064 | + public void processKeyEvent(KeyEvent e) |
---|
13376 | 15065 | { |
---|
13377 | 15066 | switch (e.getID()) |
---|
13378 | 15067 | { |
---|
.. | .. |
---|
13502 | 15191 | |
---|
13503 | 15192 | protected void processMouseMotionEvent(MouseEvent e) |
---|
13504 | 15193 | { |
---|
13505 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
13506 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15194 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15195 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15196 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
13507 | 15197 | { |
---|
13508 | 15198 | mouseMoved(e); |
---|
13509 | 15199 | } else |
---|
.. | .. |
---|
13533 | 15223 | |
---|
13534 | 15224 | void SelectParent() |
---|
13535 | 15225 | { |
---|
| 15226 | + new Exception().printStackTrace(); |
---|
13536 | 15227 | System.exit(0); |
---|
13537 | 15228 | Composite group = (Composite) object; |
---|
13538 | 15229 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
13556 | 15247 | |
---|
13557 | 15248 | void SelectChildren() |
---|
13558 | 15249 | { |
---|
| 15250 | + new Exception().printStackTrace(); |
---|
13559 | 15251 | System.exit(0); |
---|
13560 | 15252 | /* |
---|
13561 | 15253 | Composite group = (Composite) object; |
---|
.. | .. |
---|
13720 | 15412 | info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
13721 | 15413 | //Image img = CreateImage(width, height); |
---|
13722 | 15414 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15415 | + |
---|
13723 | 15416 | Graphics gr = g; // img.getGraphics(); |
---|
| 15417 | + |
---|
13724 | 15418 | if (!hasMarquee) |
---|
13725 | 15419 | { |
---|
13726 | 15420 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
13818 | 15512 | if (!isRenderer) |
---|
13819 | 15513 | { |
---|
13820 | 15514 | object.drawEditHandles(info, 0); |
---|
| 15515 | + |
---|
| 15516 | + if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 15517 | + { |
---|
| 15518 | + switch (object.selection.get(0).hitSomething) |
---|
| 15519 | + { |
---|
| 15520 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15521 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15522 | + break; |
---|
| 15523 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15524 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15525 | + break; |
---|
| 15526 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 15527 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15528 | + break; |
---|
| 15529 | + } |
---|
| 15530 | + |
---|
| 15531 | + } |
---|
13821 | 15532 | } |
---|
13822 | 15533 | } |
---|
| 15534 | + |
---|
13823 | 15535 | if (isRenderer) |
---|
13824 | 15536 | { |
---|
13825 | 15537 | //gr.setColor(Color.black); |
---|
13826 | 15538 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
13827 | 15539 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
13828 | 15540 | } |
---|
| 15541 | + |
---|
13829 | 15542 | if (hasMarquee) |
---|
13830 | 15543 | { |
---|
13831 | 15544 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
13848 | 15561 | //if (g != gr) g.drawImage(img, 0, 0, width, height, null); |
---|
13849 | 15562 | } |
---|
13850 | 15563 | |
---|
| 15564 | + // To avoid clear. |
---|
13851 | 15565 | public void update(Graphics g) |
---|
13852 | 15566 | { |
---|
13853 | 15567 | paint(g); |
---|
.. | .. |
---|
13937 | 15651 | public boolean mouseDown(Event evt, int x, int y) |
---|
13938 | 15652 | { |
---|
13939 | 15653 | System.out.println("mouseDown: " + evt); |
---|
| 15654 | + System.exit(0); |
---|
13940 | 15655 | /* |
---|
13941 | 15656 | locked = true; |
---|
13942 | 15657 | drag = false; |
---|
.. | .. |
---|
13980 | 15695 | { |
---|
13981 | 15696 | keyPressed(0, modifiers); |
---|
13982 | 15697 | } |
---|
13983 | | - clickStart(x, y, modifiers); |
---|
| 15698 | + // clickStart(x, y, modifiers); |
---|
13984 | 15699 | return true; |
---|
13985 | 15700 | } |
---|
13986 | 15701 | |
---|
.. | .. |
---|
14098 | 15813 | { |
---|
14099 | 15814 | keyReleased(0, 0); |
---|
14100 | 15815 | } |
---|
14101 | | - drag(x, y, modifiers); |
---|
| 15816 | + drag(x, y, 0, modifiers); |
---|
14102 | 15817 | return true; |
---|
14103 | 15818 | } |
---|
14104 | 15819 | |
---|
.. | .. |
---|
14230 | 15945 | Object3D object; |
---|
14231 | 15946 | static Object3D trackedobject; |
---|
14232 | 15947 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
14233 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 15948 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
14234 | 15949 | /*static*/ Camera eyeCamera; |
---|
14235 | 15950 | /*static*/ Camera lightCamera; |
---|
14236 | 15951 | int cameracount; |
---|
.. | .. |
---|
14510 | 16225 | /**/ |
---|
14511 | 16226 | //checker.GetMaterial().opacity = 1.1f; |
---|
14512 | 16227 | ////checker.GetMaterial().ambient = 0.99f; |
---|
14513 | | - Object3D.materialstack[Object3D.materialdepth] = checker.material; |
---|
14514 | | - Object3D.selectedstack[Object3D.materialdepth] = false; |
---|
14515 | | - cStatic.objectstack[Object3D.materialdepth++] = checker; |
---|
| 16228 | + materialstack[materialdepth] = checker.material; |
---|
| 16229 | + selectedstack[materialdepth] = false; |
---|
| 16230 | + cStatic.objectstack[materialdepth++] = checker; |
---|
14516 | 16231 | //System.out.println("material " + material); |
---|
14517 | 16232 | //Applet3D.tracein(this, selected); |
---|
14518 | 16233 | vector2buffer = checker.projectedVertices; |
---|
14519 | 16234 | |
---|
14520 | | - checker.GetMaterial().Draw(this, false); // true); |
---|
| 16235 | + //checker.GetMaterial().Draw(this, false); // true); |
---|
| 16236 | + DrawMaterial(checker.GetMaterial(), false); // true); |
---|
14521 | 16237 | |
---|
14522 | | - Object3D.materialdepth -= 1; |
---|
14523 | | - if (Object3D.materialdepth > 0) |
---|
| 16238 | + materialdepth -= 1; |
---|
| 16239 | + if (materialdepth > 0) |
---|
14524 | 16240 | { |
---|
14525 | | - vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices; |
---|
14526 | | - Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]); |
---|
| 16241 | + vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16242 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
14527 | 16243 | } |
---|
14528 | 16244 | //checker.GetMaterial().opacity = 1f; |
---|
14529 | 16245 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
14667 | 16383 | { |
---|
14668 | 16384 | if (!selection) |
---|
14669 | 16385 | { |
---|
| 16386 | + new Exception().printStackTrace(); |
---|
14670 | 16387 | System.exit(0); |
---|
14671 | 16388 | return; |
---|
14672 | 16389 | } |
---|
.. | .. |
---|
14689 | 16406 | |
---|
14690 | 16407 | //int tmp = selection_view; |
---|
14691 | 16408 | //selection_view = -1; |
---|
14692 | | - int temp = drawMode; |
---|
14693 | | - drawMode = SELECTION; |
---|
| 16409 | + int temp = DrawMode(); |
---|
| 16410 | + Globals.drawMode = SELECTION; // WARNING |
---|
14694 | 16411 | indexcount = 0; |
---|
14695 | 16412 | parent.display(drawable); |
---|
14696 | 16413 | //selection_view = tmp; |
---|
14697 | 16414 | //if (temp == SELECTION) |
---|
14698 | 16415 | // temp = DEFAULT; // patch for selection debug |
---|
14699 | | - drawMode = temp; |
---|
| 16416 | + Globals.drawMode = temp; // WARNING |
---|
14700 | 16417 | |
---|
14701 | 16418 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
14702 | 16419 | |
---|
.. | .. |
---|
14794 | 16511 | 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])); |
---|
14795 | 16512 | } |
---|
14796 | 16513 | |
---|
14797 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 16514 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
14798 | 16515 | } |
---|
14799 | 16516 | } |
---|
14800 | 16517 | |
---|
14801 | 16518 | if (!movingcamera && !PAINTMODE) |
---|
14802 | 16519 | object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
14803 | 16520 | |
---|
14804 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 16521 | + if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
14805 | 16522 | { |
---|
14806 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 16523 | + Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
14807 | 16524 | |
---|
14808 | 16525 | Object3D group = new Object3D("inst" + paintcount++); |
---|
14809 | 16526 | |
---|
.. | .. |
---|
14959 | 16676 | gl.glDisable(gl.GL_CULL_FACE); |
---|
14960 | 16677 | } |
---|
14961 | 16678 | |
---|
14962 | | - if (!RENDERSHADOW) |
---|
| 16679 | + if (!Globals.RENDERSHADOW) |
---|
14963 | 16680 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14964 | 16681 | |
---|
14965 | 16682 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
14969 | 16686 | //gl.glColorMask(false, false, false, false); |
---|
14970 | 16687 | |
---|
14971 | 16688 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
14972 | | - if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 16689 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
14973 | 16690 | { |
---|
14974 | 16691 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14975 | 16692 | |
---|
14976 | | - int temp = drawMode; |
---|
14977 | | - drawMode = SHADOW; |
---|
| 16693 | + int temp = DrawMode(); |
---|
| 16694 | + Globals.drawMode = SHADOW; // WARNING |
---|
14978 | 16695 | parent.display(drawable); |
---|
14979 | | - drawMode = temp; |
---|
| 16696 | + Globals.drawMode = temp; // WARNING |
---|
14980 | 16697 | } |
---|
14981 | 16698 | |
---|
14982 | 16699 | gl.glCullFace(gl.GL_BACK); |
---|
.. | .. |
---|
15029 | 16746 | |
---|
15030 | 16747 | class AntialiasBuffer implements GLEventListener |
---|
15031 | 16748 | { |
---|
15032 | | - |
---|
15033 | 16749 | CameraPane parent = null; |
---|
15034 | 16750 | |
---|
15035 | 16751 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
15374 | 17090 | GLUT glut = new GLUT(); |
---|
15375 | 17091 | |
---|
15376 | 17092 | |
---|
15377 | | - static final public int DEFAULT = 0; |
---|
15378 | | - static final public int SELECTION = 1; |
---|
15379 | | - static final public int SHADOW = 2; |
---|
15380 | | - static final public int OCCLUSION = 3; |
---|
15381 | | - static |
---|
15382 | | - public int drawMode = DEFAULT; |
---|
15383 | 17093 | public boolean spherical = false; |
---|
15384 | 17094 | static boolean DEBUG_OCCLUSION = false; |
---|
15385 | 17095 | static boolean DEBUG_SELECTION = false; |
---|
.. | .. |
---|
15428 | 17138 | } |
---|
15429 | 17139 | } |
---|
15430 | 17140 | |
---|
15431 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17141 | + static void DrawPoints(iCameraPane cpane) |
---|
15432 | 17142 | { |
---|
15433 | 17143 | for (int i=0; i<8; i++) // first and last are red |
---|
15434 | 17144 | { |
---|
.. | .. |
---|
15460 | 17170 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
15461 | 17171 | // Depth buffer format |
---|
15462 | 17172 | //private int depth_format; |
---|
15463 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17173 | + |
---|
| 17174 | + public void NextIndex() |
---|
15464 | 17175 | { |
---|
15465 | 17176 | indexcount+=16; |
---|
15466 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17177 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
15467 | 17178 | //objects[indexcount] = o; |
---|
15468 | 17179 | //System.out.println("indexcount = " + indexcount); |
---|
15469 | 17180 | } |
---|