.. | .. |
---|
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 | |
---|
.. | .. |
---|
97 | 83 | |
---|
98 | 84 | static boolean textureon = true; |
---|
99 | 85 | static boolean LOCALTRANSFORM = false; |
---|
100 | | -private static boolean LIVE = false; |
---|
101 | 86 | static boolean FULLSCREEN = false; |
---|
102 | 87 | static boolean SUPPORT = true; |
---|
103 | | -static boolean CROWD = false; |
---|
104 | 88 | static boolean INERTIA = true; |
---|
105 | 89 | static boolean FAST = false; |
---|
106 | 90 | static boolean SLOWPOSE = false; |
---|
.. | .. |
---|
165 | 149 | defaultcaps.setAccumBlueBits(16); |
---|
166 | 150 | defaultcaps.setAccumAlphaBits(16); |
---|
167 | 151 | } |
---|
168 | | - static CameraPane theRenderer; |
---|
169 | | - |
---|
| 152 | + |
---|
170 | 153 | void SetAsGLRenderer(boolean b) |
---|
171 | 154 | { |
---|
172 | 155 | isRenderer = b; |
---|
173 | | - theRenderer = this; |
---|
| 156 | + Globals.theRenderer = this; |
---|
| 157 | + } |
---|
| 158 | + |
---|
| 159 | + CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
| 160 | + { |
---|
| 161 | + super(defaultcaps, null, withcontext?glcontext:null, null); |
---|
| 162 | + |
---|
| 163 | + //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523)); |
---|
| 164 | + glcontext = getContext(); |
---|
| 165 | + |
---|
| 166 | + cameras = new Camera[2]; |
---|
| 167 | + targetLookAts = new cVector[2]; |
---|
| 168 | + |
---|
| 169 | + SetCamera(cam); |
---|
| 170 | + |
---|
| 171 | + SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 172 | + |
---|
| 173 | + object = o; |
---|
| 174 | + |
---|
| 175 | + setBackground(Color.white); |
---|
| 176 | + |
---|
| 177 | + addKeyListener(this); |
---|
| 178 | + addMouseListener(this); |
---|
| 179 | + addMouseMotionListener(this); |
---|
| 180 | + addMouseWheelListener(this); |
---|
| 181 | + //System.out.println("addGLEventListener: " + this); |
---|
| 182 | + addGLEventListener(this); |
---|
| 183 | + |
---|
| 184 | +// pingthread.start(); // may 2013 |
---|
174 | 185 | } |
---|
175 | 186 | |
---|
176 | 187 | static boolean AntialiasingEnabled() |
---|
.. | .. |
---|
178 | 189 | return CURRENTANTIALIAS > 0; |
---|
179 | 190 | } |
---|
180 | 191 | |
---|
181 | | - void ClearDepth() |
---|
| 192 | + /// INTERFACE |
---|
| 193 | + |
---|
| 194 | + public javax.media.opengl.GL GetGL0() |
---|
| 195 | + { |
---|
| 196 | + return null; |
---|
| 197 | + } |
---|
| 198 | + |
---|
| 199 | + public int GenList() |
---|
| 200 | + { |
---|
| 201 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 202 | + return gl.glGenLists(1); |
---|
| 203 | + } |
---|
| 204 | + |
---|
| 205 | + public void NewList(int id) |
---|
| 206 | + { |
---|
| 207 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 208 | + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 209 | + } |
---|
| 210 | + |
---|
| 211 | + public void CallList(int id) |
---|
| 212 | + { |
---|
| 213 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 214 | + gl.glCallList(id); |
---|
| 215 | + } |
---|
| 216 | + |
---|
| 217 | + public void EndList() |
---|
| 218 | + { |
---|
| 219 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 220 | + gl.glEndList(); |
---|
| 221 | + } |
---|
| 222 | + |
---|
| 223 | + public boolean IsBoxMode() |
---|
| 224 | + { |
---|
| 225 | + return BOXMODE; |
---|
| 226 | + } |
---|
| 227 | + |
---|
| 228 | + public void ClearDepth() |
---|
182 | 229 | { |
---|
183 | 230 | GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT); |
---|
184 | 231 | } |
---|
185 | 232 | |
---|
186 | | - void DepthTest(boolean depthtest) |
---|
| 233 | + public void DepthTest(boolean depthtest) |
---|
187 | 234 | { |
---|
188 | 235 | if (depthtest) |
---|
189 | 236 | GetGL().glDepthFunc(GL.GL_LEQUAL); |
---|
.. | .. |
---|
191 | 238 | GetGL().glDepthFunc(GL.GL_ALWAYS); |
---|
192 | 239 | } |
---|
193 | 240 | |
---|
194 | | - void DepthWrite(boolean depthwrite) |
---|
| 241 | + public void DepthWrite(boolean depthwrite) |
---|
195 | 242 | { |
---|
196 | 243 | if (depthwrite) |
---|
197 | 244 | GetGL().glDepthMask(true); |
---|
.. | .. |
---|
199 | 246 | GetGL().glDepthMask(false); |
---|
200 | 247 | } |
---|
201 | 248 | |
---|
202 | | - void BackFaceCull(boolean bfc) |
---|
| 249 | + public void BackFaceCull(boolean bfc) |
---|
203 | 250 | { |
---|
204 | 251 | if (bfc) |
---|
205 | 252 | GetGL().glEnable(GetGL().GL_CULL_FACE); |
---|
206 | 253 | else |
---|
207 | 254 | GetGL().glDisable(GetGL().GL_CULL_FACE); |
---|
| 255 | + } |
---|
| 256 | + |
---|
| 257 | + public boolean BackFaceCullMode() |
---|
| 258 | + { |
---|
| 259 | + return this.CULLFACE; |
---|
| 260 | + } |
---|
| 261 | + |
---|
| 262 | + public boolean IsAmbientOcclusionOn() |
---|
| 263 | + { |
---|
| 264 | + return this.ambientOcclusion; |
---|
| 265 | + } |
---|
| 266 | + |
---|
| 267 | + public boolean IsDebugSelection() |
---|
| 268 | + { |
---|
| 269 | + return DEBUG_SELECTION; |
---|
| 270 | + } |
---|
| 271 | + |
---|
| 272 | + public boolean IsFrozen() |
---|
| 273 | + { |
---|
| 274 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
| 275 | + |
---|
| 276 | + return !selectmode && cameracount == 0; // != 0; |
---|
| 277 | + } |
---|
| 278 | + |
---|
| 279 | + // Currently in Globals |
---|
| 280 | + public int DrawMode() |
---|
| 281 | + { |
---|
| 282 | + return Globals.DrawMode(); |
---|
| 283 | + } |
---|
| 284 | + |
---|
| 285 | + public Camera EyeCamera() |
---|
| 286 | + { |
---|
| 287 | + return eyeCamera; |
---|
| 288 | + } |
---|
| 289 | + |
---|
| 290 | + public Camera LightCamera() |
---|
| 291 | + { |
---|
| 292 | + return lightCamera; |
---|
| 293 | + } |
---|
| 294 | + |
---|
| 295 | + public Camera ManipCamera() |
---|
| 296 | + { |
---|
| 297 | + return manipCamera; |
---|
| 298 | + } |
---|
| 299 | + |
---|
| 300 | + public Camera RenderCamera() |
---|
| 301 | + { |
---|
| 302 | + return renderCamera; |
---|
| 303 | + } |
---|
| 304 | + |
---|
| 305 | + public Camera[] Cameras() |
---|
| 306 | + { |
---|
| 307 | + return cameras; |
---|
| 308 | + } |
---|
| 309 | + |
---|
| 310 | + public void PushMaterial(Object3D obj, boolean selected) |
---|
| 311 | + { |
---|
| 312 | + CameraPane display = this; |
---|
| 313 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 314 | + cMaterial material = obj.material; |
---|
| 315 | + |
---|
| 316 | + if (material != null) |
---|
| 317 | + { |
---|
| 318 | + materialstack[materialdepth] = material; |
---|
| 319 | + selectedstack[materialdepth] = selected; |
---|
| 320 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 321 | + //System.out.println("material " + material); |
---|
| 322 | + //Applet3D.tracein(this, selected); |
---|
| 323 | + display.vector2buffer = obj.projectedVertices; |
---|
| 324 | + if (obj instanceof Camera) |
---|
| 325 | + { |
---|
| 326 | + display.options1[0] = material.shift; |
---|
| 327 | + //System.out.println("shift " + material.shift); |
---|
| 328 | + display.options1[1] = material.lightarea; |
---|
| 329 | + display.options1[2] = material.shadowbias; |
---|
| 330 | + display.options1[3] = material.aniso; |
---|
| 331 | + display.options1[4] = material.anisoV; |
---|
| 332 | + display.options2[0] = material.opacity; |
---|
| 333 | + display.options2[1] = material.diffuse; |
---|
| 334 | + display.options2[2] = material.factor; |
---|
| 335 | + |
---|
| 336 | + cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 337 | + display.options4[0] = material.cameralight/0.2f; |
---|
| 338 | + display.options4[1] = material.subsurface; |
---|
| 339 | + display.options4[2] = material.sheen; |
---|
| 340 | + |
---|
| 341 | + // if (display.CURRENTANTIALIAS > 0) |
---|
| 342 | + // display.options3[3] /= 4; |
---|
| 343 | + |
---|
| 344 | + /* |
---|
| 345 | + System.out.println("Focus = " + display.options1[0]); |
---|
| 346 | + System.out.println("Aperture = " + display.options1[1]); |
---|
| 347 | + System.out.println("ShadowBlur = " + display.options1[2]); |
---|
| 348 | + System.out.println("Antialiasing = " + display.options1[3]); |
---|
| 349 | + System.out.println("Fog = " + display.options2[0]); |
---|
| 350 | + System.out.println("Intensity = " + display.options2[1]); |
---|
| 351 | + System.out.println("Elevation = " + display.options2[2]); |
---|
| 352 | + /**/ |
---|
| 353 | + } else |
---|
| 354 | + { |
---|
| 355 | + DrawMaterial(material, selected); |
---|
| 356 | + } |
---|
| 357 | + } else |
---|
| 358 | + { |
---|
| 359 | + if (selected && CameraPane.flash) |
---|
| 360 | + { |
---|
| 361 | + display.modelParams4[1] = 100; |
---|
| 362 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 363 | + } |
---|
| 364 | + } |
---|
| 365 | + } |
---|
| 366 | + |
---|
| 367 | + public void PushMaterial2(Object3D obj, boolean selected) |
---|
| 368 | + { |
---|
| 369 | + CameraPane display = this; |
---|
| 370 | + cMaterial material = obj.material; |
---|
| 371 | + |
---|
| 372 | + if (material != null) |
---|
| 373 | + { |
---|
| 374 | + materialstack[materialdepth] = material; |
---|
| 375 | + selectedstack[materialdepth] = selected; |
---|
| 376 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 377 | + //System.out.println("material " + material); |
---|
| 378 | + //Applet3D.tracein("selected ", selected); |
---|
| 379 | + display.vector2buffer = obj.projectedVertices; |
---|
| 380 | + display.DrawMaterial(material, selected); |
---|
| 381 | + } |
---|
| 382 | + } |
---|
| 383 | + |
---|
| 384 | + public void PopMaterial(Object3D obj, boolean selected) |
---|
| 385 | + { |
---|
| 386 | + CameraPane display = this; |
---|
| 387 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 388 | + cMaterial material = obj.material; |
---|
| 389 | + |
---|
| 390 | + //if (parent != null && parent.GetMaterial() != null) |
---|
| 391 | + // parent.GetMaterial().Draw(display, parent.IsSelected(this)); |
---|
| 392 | + if (material != null) |
---|
| 393 | + { |
---|
| 394 | + materialdepth -= 1; |
---|
| 395 | + if (materialdepth > 0) |
---|
| 396 | + { |
---|
| 397 | + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 398 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 399 | + } |
---|
| 400 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 401 | + } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
| 402 | + { |
---|
| 403 | + display.modelParams4[1] = obj.GetMaterial().cameralight; |
---|
| 404 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 405 | + } |
---|
| 406 | + } |
---|
| 407 | + |
---|
| 408 | + public void PopMaterial2(Object3D obj) |
---|
| 409 | + { |
---|
| 410 | + CameraPane display = this; |
---|
| 411 | + cMaterial material = obj.material; |
---|
| 412 | + |
---|
| 413 | + if (material != null) |
---|
| 414 | + { |
---|
| 415 | + materialdepth -= 1; |
---|
| 416 | + if (materialdepth > 0) |
---|
| 417 | + { |
---|
| 418 | + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 419 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 420 | + } |
---|
| 421 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 422 | + //else |
---|
| 423 | + //material.Draw(display, false); |
---|
| 424 | + } |
---|
| 425 | + } |
---|
| 426 | + |
---|
| 427 | + public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face) |
---|
| 428 | + { |
---|
| 429 | + CameraPane display = this; |
---|
| 430 | + |
---|
| 431 | + if (pv.y == -10000 || |
---|
| 432 | + qv.y == -10000 || |
---|
| 433 | + rv.y == -10000) |
---|
| 434 | + return; |
---|
| 435 | + |
---|
| 436 | +// float b = f.nbiterations & 1; |
---|
| 437 | +// float g = (f.nbiterations>>1) & 1; |
---|
| 438 | +// float r = (f.nbiterations>>2) & 1; |
---|
| 439 | +// |
---|
| 440 | +// //if (f.weight == 10000) |
---|
| 441 | +// //{ |
---|
| 442 | +// // r = 1; g = b = 0; |
---|
| 443 | +// //} |
---|
| 444 | +// //else |
---|
| 445 | +// //{ |
---|
| 446 | +// // assert(f.weight < 10000); |
---|
| 447 | +// r = g = b = (float)bRep.FaceWeight(f)*100; |
---|
| 448 | +// if (r<0) |
---|
| 449 | +// assert(r>=0); |
---|
| 450 | +// //} |
---|
| 451 | + |
---|
| 452 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 453 | + |
---|
| 454 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
| 455 | + |
---|
| 456 | + //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
| 457 | + if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
| 458 | + { |
---|
| 459 | + //gl.glBegin(gl.GL_TRIANGLES); |
---|
| 460 | + boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 461 | + if (!hasnorm) |
---|
| 462 | + { |
---|
| 463 | + // System.out.println("FUCK!!"); |
---|
| 464 | + LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
| 465 | + LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
| 466 | + LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
| 467 | + LA.vecNormalize(obj.v2); |
---|
| 468 | + gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 469 | + } |
---|
| 470 | + |
---|
| 471 | + // P |
---|
| 472 | + float x = (float)pv.x; |
---|
| 473 | + float y = (float)pv.y; |
---|
| 474 | + float z = (float)pv.z; |
---|
| 475 | + |
---|
| 476 | + if (hasnorm) |
---|
| 477 | + { |
---|
| 478 | +// if (!pv.norm.normalized()) |
---|
| 479 | +// assert(pv.norm.normalized()); |
---|
| 480 | + |
---|
| 481 | + //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z); |
---|
| 482 | + float nx = (float)pv.norm.x; |
---|
| 483 | + float ny = (float)pv.norm.y; |
---|
| 484 | + float nz = (float)pv.norm.z; |
---|
| 485 | + |
---|
| 486 | + x += nx * obj.NORMALPUSH; |
---|
| 487 | + y += ny * obj.NORMALPUSH; |
---|
| 488 | + z += nz * obj.NORMALPUSH; |
---|
| 489 | + |
---|
| 490 | + gl.glNormal3f(nx, ny, nz); |
---|
| 491 | + } |
---|
| 492 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 493 | + SetColor(obj, pv); |
---|
| 494 | + //gl.glColor4f(r, g, b, 1); |
---|
| 495 | + //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1); |
---|
| 496 | + if (obj.flipV) |
---|
| 497 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 498 | + else |
---|
| 499 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 500 | + //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z); |
---|
| 501 | + |
---|
| 502 | + gl.glVertex3f(x, y, z); |
---|
| 503 | + |
---|
| 504 | + // Q |
---|
| 505 | + x = (float)qv.x; |
---|
| 506 | + y = (float)qv.y; |
---|
| 507 | + z = (float)qv.z; |
---|
| 508 | + |
---|
| 509 | +// Print(pv); |
---|
| 510 | + if (hasnorm) |
---|
| 511 | + { |
---|
| 512 | +// assert(qv.norm.normalized()); |
---|
| 513 | + //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z); |
---|
| 514 | + float nx = (float)qv.norm.x; |
---|
| 515 | + float ny = (float)qv.norm.y; |
---|
| 516 | + float nz = (float)qv.norm.z; |
---|
| 517 | + |
---|
| 518 | + x += nx * obj.NORMALPUSH; |
---|
| 519 | + y += ny * obj.NORMALPUSH; |
---|
| 520 | + z += nz * obj.NORMALPUSH; |
---|
| 521 | + |
---|
| 522 | + gl.glNormal3f(nx, ny, nz); |
---|
| 523 | + } |
---|
| 524 | + //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
| 525 | + // boolean locked = false; |
---|
| 526 | + // float eps = 0.1f; |
---|
| 527 | + // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 528 | + |
---|
| 529 | + // int dot = 0; //*/ (int)f.dot; |
---|
| 530 | + |
---|
| 531 | + // if ((dot&1) == 0) |
---|
| 532 | + // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 533 | + |
---|
| 534 | + // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 535 | + if (obj.flipV) |
---|
| 536 | + gl.glTexCoord2f((float) qv.s, 1-(float) qv.t); |
---|
| 537 | + else |
---|
| 538 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 539 | + // else |
---|
| 540 | + // { |
---|
| 541 | + // locked = true; |
---|
| 542 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 543 | + // } |
---|
| 544 | + gl.glColor4f(qv.AO, qv.AO, qv.AO, 1); |
---|
| 545 | + SetColor(obj, qv); |
---|
| 546 | + |
---|
| 547 | + gl.glVertex3f(x, y, z); |
---|
| 548 | + //gl.glColor4f(r, g, b, 1); |
---|
| 549 | + //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1); |
---|
| 550 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 551 | +// Print(qv); |
---|
| 552 | + |
---|
| 553 | + // R |
---|
| 554 | + x = (float)rv.x; |
---|
| 555 | + y = (float)rv.y; |
---|
| 556 | + z = (float)rv.z; |
---|
| 557 | + |
---|
| 558 | + if (hasnorm) |
---|
| 559 | + { |
---|
| 560 | +// assert(rv.norm.normalized()); |
---|
| 561 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 562 | + float nx = (float)rv.norm.x; |
---|
| 563 | + float ny = (float)rv.norm.y; |
---|
| 564 | + float nz = (float)rv.norm.z; |
---|
| 565 | + |
---|
| 566 | + x += nx * obj.NORMALPUSH; |
---|
| 567 | + y += ny * obj.NORMALPUSH; |
---|
| 568 | + z += nz * obj.NORMALPUSH; |
---|
| 569 | + |
---|
| 570 | + gl.glNormal3f(nx, ny, nz); |
---|
| 571 | + } |
---|
| 572 | + |
---|
| 573 | + // if ((dot&4) == 0) |
---|
| 574 | + // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 575 | + |
---|
| 576 | + // if (wrap || !locked && (dot&8) != 0) |
---|
| 577 | + if (obj.flipV) |
---|
| 578 | + gl.glTexCoord2f((float) rv.s, 1-(float) rv.t); |
---|
| 579 | + else |
---|
| 580 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 581 | + // else |
---|
| 582 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 583 | + |
---|
| 584 | + // f.dot = dot; |
---|
| 585 | + |
---|
| 586 | + gl.glColor4f(rv.AO, rv.AO, rv.AO, 1); |
---|
| 587 | + SetColor(obj, rv); |
---|
| 588 | + //gl.glColor4f(r, g, b, 1); |
---|
| 589 | + //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1); |
---|
| 590 | + //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z); |
---|
| 591 | + gl.glVertex3f(x, y, z); |
---|
| 592 | +// Print(rv); |
---|
| 593 | + //gl.glEnd(); |
---|
| 594 | + } |
---|
| 595 | + else |
---|
| 596 | + { |
---|
| 597 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 598 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 599 | + gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z); |
---|
| 600 | + |
---|
| 601 | + } |
---|
| 602 | + |
---|
| 603 | + if (false) // (attributes & WIREFRAME) != 0) |
---|
| 604 | + { |
---|
| 605 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 606 | + |
---|
| 607 | + gl.glBegin(gl.GL_LINE_LOOP); |
---|
| 608 | + gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z); |
---|
| 609 | + gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z); |
---|
| 610 | + gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z); |
---|
| 611 | + gl.glEnd(); |
---|
| 612 | + |
---|
| 613 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 614 | + } |
---|
| 615 | + } |
---|
| 616 | + |
---|
| 617 | + /** |
---|
| 618 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 619 | + * it's normals, colors, textures and vertices. |
---|
| 620 | + * |
---|
| 621 | + * @see Renderer#draw(TriMesh) |
---|
| 622 | + * @param tris |
---|
| 623 | + * the mesh to render. |
---|
| 624 | + */ |
---|
| 625 | + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 626 | + { |
---|
| 627 | + CameraPane display = this; |
---|
| 628 | + |
---|
| 629 | + float r = display.modelParams0[0]; |
---|
| 630 | + float g = display.modelParams0[1]; |
---|
| 631 | + float b = display.modelParams0[2]; |
---|
| 632 | + float opacity = display.modelParams5[1]; |
---|
| 633 | + |
---|
| 634 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 635 | + GL gl = display.GetGL(); // getGL(); |
---|
| 636 | + |
---|
| 637 | + FloatBuffer vertBuf = geo.vertBuf; |
---|
| 638 | + |
---|
| 639 | + int v = vertBuf.capacity(); |
---|
| 640 | + |
---|
| 641 | + int count = 0; |
---|
| 642 | + |
---|
| 643 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 644 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 645 | + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
| 646 | + for (int i=0; i<v/3; i++) |
---|
| 647 | + { |
---|
| 648 | + int index3 = i*3; |
---|
| 649 | + |
---|
| 650 | + if (geo.sizeBuf.get(index3+1) == 0) |
---|
| 651 | + continue; |
---|
| 652 | + |
---|
| 653 | + count++; |
---|
| 654 | + |
---|
| 655 | + int index4 = i*4; |
---|
| 656 | + |
---|
| 657 | + float tx = vertBuf.get(index3); |
---|
| 658 | + float ty = vertBuf.get(index3+1); |
---|
| 659 | + float tz = vertBuf.get(index3+2); |
---|
| 660 | + |
---|
| 661 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 662 | + // continue; |
---|
| 663 | + |
---|
| 664 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 665 | + gl.glPushMatrix(); |
---|
| 666 | + |
---|
| 667 | + float[] texmat = geo.texmat; |
---|
| 668 | + texmat[12] = texmat[13] = texmat[14] = i; |
---|
| 669 | + |
---|
| 670 | + gl.glMultMatrixf(texmat, 0); |
---|
| 671 | + |
---|
| 672 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 673 | + gl.glPushMatrix(); |
---|
| 674 | + |
---|
| 675 | + gl.glTranslatef(tx,ty,tz); |
---|
| 676 | + |
---|
| 677 | + if (rotate) |
---|
| 678 | + gl.glRotatef(i, 0, 1, 0); |
---|
| 679 | + |
---|
| 680 | + float size = geo.sizeBuf.get(index3) / 100; |
---|
| 681 | + gl.glScalef(size,size,size); |
---|
| 682 | + |
---|
| 683 | + float cr = geo.colorBuf.get(index4); |
---|
| 684 | + float cg = geo.colorBuf.get(index4+1); |
---|
| 685 | + float cb = geo.colorBuf.get(index4+2); |
---|
| 686 | + float ca = geo.colorBuf.get(index4+3); |
---|
| 687 | + |
---|
| 688 | + display.modelParams0[0] = r * cr; |
---|
| 689 | + display.modelParams0[1] = g * cg; |
---|
| 690 | + display.modelParams0[2] = b * cb; |
---|
| 691 | + |
---|
| 692 | + display.modelParams5[1] = opacity * ca; |
---|
| 693 | + |
---|
| 694 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 695 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 696 | + |
---|
| 697 | + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; |
---|
| 698 | + RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 699 | + |
---|
| 700 | +// gl.glColor4f(cr,cg,cb,ca); |
---|
| 701 | + // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 702 | + shape.Draw/*Node*/(display,null,selected,false); // blocked |
---|
| 703 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 704 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 705 | + gl.glPopMatrix(); |
---|
| 706 | + |
---|
| 707 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 708 | + gl.glPopMatrix(); |
---|
| 709 | + } |
---|
| 710 | + // gl.glScalef(1024,1024,1024); |
---|
| 711 | + if (!cf) |
---|
| 712 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 713 | + |
---|
| 714 | + display.modelParams0[0] = r; |
---|
| 715 | + display.modelParams0[1] = g; |
---|
| 716 | + display.modelParams0[2] = b; |
---|
| 717 | + |
---|
| 718 | + display.modelParams5[1] = opacity; |
---|
| 719 | + |
---|
| 720 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 721 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 722 | + |
---|
| 723 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 724 | + |
---|
| 725 | +// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
| 726 | + if (true) |
---|
| 727 | + return; |
---|
| 728 | + |
---|
| 729 | +//// if (!tris.predraw(this)) |
---|
| 730 | +//// { |
---|
| 731 | +//// return; |
---|
| 732 | +//// } |
---|
| 733 | +//// if (Debug.stats) |
---|
| 734 | +//// { |
---|
| 735 | +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
| 736 | +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
| 737 | +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
| 738 | +//// } |
---|
| 739 | +//// |
---|
| 740 | +//// if (tris.getDisplayListID() != -1) |
---|
| 741 | +//// { |
---|
| 742 | +//// renderDisplayList(tris); |
---|
| 743 | +//// return; |
---|
| 744 | +//// } |
---|
| 745 | +//// |
---|
| 746 | +//// if (!generatingDisplayList) |
---|
| 747 | +//// { |
---|
| 748 | +//// applyStates(tris.states, tris); |
---|
| 749 | +//// } |
---|
| 750 | +//// if (Debug.stats) |
---|
| 751 | +//// { |
---|
| 752 | +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
| 753 | +//// } |
---|
| 754 | +//// boolean transformed = doTransforms(tris); |
---|
| 755 | +// |
---|
| 756 | +// int glMode = GL.GL_TRIANGLES; |
---|
| 757 | +// switch (getMode()) |
---|
| 758 | +// { |
---|
| 759 | +// case Triangles: |
---|
| 760 | +// glMode = GL.GL_TRIANGLES; |
---|
| 761 | +// break; |
---|
| 762 | +// case Strip: |
---|
| 763 | +// glMode = GL.GL_TRIANGLE_STRIP; |
---|
| 764 | +// break; |
---|
| 765 | +// case Fan: |
---|
| 766 | +// glMode = GL.GL_TRIANGLE_FAN; |
---|
| 767 | +// break; |
---|
| 768 | +// } |
---|
| 769 | +// |
---|
| 770 | +// if (!predrawGeometry(gl)) |
---|
| 771 | +// { |
---|
| 772 | +// // make sure only the necessary indices are sent through on old |
---|
| 773 | +// // cards. |
---|
| 774 | +// IntBuffer indices = this.getIndexBuffer(); |
---|
| 775 | +// if (indices == null) |
---|
| 776 | +// { |
---|
| 777 | +// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
| 778 | +// } else |
---|
| 779 | +// { |
---|
| 780 | +// indices.rewind(); |
---|
| 781 | +// indices.limit(this.getMaxIndex()); |
---|
| 782 | +// |
---|
| 783 | +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
| 784 | +// |
---|
| 785 | +// indices.clear(); |
---|
| 786 | +// } |
---|
| 787 | +// } else |
---|
| 788 | +// { |
---|
| 789 | +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
| 790 | +// GL.GL_UNSIGNED_INT, 0); |
---|
| 791 | +// } |
---|
| 792 | +// |
---|
| 793 | +//// postdrawGeometry(tris); |
---|
| 794 | +//// if (transformed) |
---|
| 795 | +//// { |
---|
| 796 | +//// undoTransforms(tris); |
---|
| 797 | +//// } |
---|
| 798 | +//// |
---|
| 799 | +//// if (Debug.stats) |
---|
| 800 | +//// { |
---|
| 801 | +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
| 802 | +//// } |
---|
| 803 | +//// tris.postdraw(this); |
---|
| 804 | + } |
---|
| 805 | + |
---|
| 806 | + static Camera localcamera = new Camera(); |
---|
| 807 | + static cVector from = new cVector(); |
---|
| 808 | + static cVector to = new cVector(); |
---|
| 809 | + |
---|
| 810 | + public void PrepOcclusion(BoundaryRep br, double[][] transform) |
---|
| 811 | + { |
---|
| 812 | + CameraPane cp = this; |
---|
| 813 | + |
---|
| 814 | + Camera keep = cp.RenderCamera(); |
---|
| 815 | + cp.renderCamera = localcamera; |
---|
| 816 | + |
---|
| 817 | + if (br.trimmed) |
---|
| 818 | + { |
---|
| 819 | + float[] colors = new float[br.positions.length / 3]; |
---|
| 820 | + |
---|
| 821 | + int i3 = 0; |
---|
| 822 | + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) |
---|
| 823 | + { |
---|
| 824 | + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) |
---|
| 825 | + continue; |
---|
| 826 | + |
---|
| 827 | + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); |
---|
| 828 | + to.set(br.positions[i3] + br.normals[i3], |
---|
| 829 | + br.positions[i3 + 1] + br.normals[i3 + 1], |
---|
| 830 | + br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
| 831 | + LA.xformPos(from, transform, from); |
---|
| 832 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 833 | + localcamera.setAim(from, to); |
---|
| 834 | + |
---|
| 835 | + CameraPane.occlusionbuffer.display(); |
---|
| 836 | + |
---|
| 837 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 838 | + cp.display(); // debug |
---|
| 839 | + |
---|
| 840 | + colors[i] = cp.vertexOcclusion.r; |
---|
| 841 | + //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
| 842 | + //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
| 843 | + |
---|
| 844 | + if ((i % 100) == 0 && i != 0) |
---|
| 845 | + { |
---|
| 846 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 847 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 848 | + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); |
---|
| 849 | + } |
---|
| 850 | + } |
---|
| 851 | + |
---|
| 852 | + br.colors = colors; |
---|
| 853 | + } |
---|
| 854 | + else |
---|
| 855 | + { |
---|
| 856 | + for (int i = 0; i < br.VertexCount(); i++) |
---|
| 857 | + { |
---|
| 858 | + Vertex v = br.GetVertex(i); |
---|
| 859 | + |
---|
| 860 | + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
| 861 | + continue; |
---|
| 862 | + |
---|
| 863 | + from.set(v.x, v.y, v.z); |
---|
| 864 | + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
| 865 | + LA.xformPos(from, transform, from); |
---|
| 866 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 867 | + localcamera.setAim(from, to); |
---|
| 868 | + |
---|
| 869 | + CameraPane.occlusionbuffer.display(); |
---|
| 870 | + |
---|
| 871 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 872 | + cp.display(); // debug |
---|
| 873 | + |
---|
| 874 | + v.AO = cp.vertexOcclusion.r; |
---|
| 875 | + |
---|
| 876 | + if ((i % 100) == 0 && i != 0) |
---|
| 877 | + { |
---|
| 878 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 879 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 880 | + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); |
---|
| 881 | + } |
---|
| 882 | + } |
---|
| 883 | + } |
---|
| 884 | + |
---|
| 885 | + //System.out.println("done."); |
---|
| 886 | + |
---|
| 887 | + cp.renderCamera = keep; |
---|
| 888 | + } |
---|
| 889 | + |
---|
| 890 | + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 891 | + { |
---|
| 892 | + CameraPane display = this; |
---|
| 893 | + pointFlow.CreateHT(); |
---|
| 894 | + |
---|
| 895 | + float r = display.modelParams0[0]; |
---|
| 896 | + float g = display.modelParams0[1]; |
---|
| 897 | + float b = display.modelParams0[2]; |
---|
| 898 | + float opacity = display.modelParams5[1]; |
---|
| 899 | + |
---|
| 900 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 901 | + GL gl = display.GetGL(); // getGL(); |
---|
| 902 | + |
---|
| 903 | + int s = pointFlow.points.size(); |
---|
| 904 | + |
---|
| 905 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 906 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 907 | + |
---|
| 908 | + for (int i=s; --i>=0;) |
---|
| 909 | + //for (int i=0; i<s; i++) |
---|
| 910 | + { |
---|
| 911 | + cVector v = pointFlow.points.get(i); |
---|
| 912 | + |
---|
| 913 | + double mindist = Double.MAX_VALUE; |
---|
| 914 | + |
---|
| 915 | + double size = pointFlow.minimumSize; |
---|
| 916 | + |
---|
| 917 | + double distancenext = 0; |
---|
| 918 | + |
---|
| 919 | + if (i > 0) |
---|
| 920 | + { |
---|
| 921 | + cVector w = pointFlow.points.get(i-1); |
---|
| 922 | + |
---|
| 923 | + double dist = w.distance(v); |
---|
| 924 | + |
---|
| 925 | + distancenext = dist; |
---|
| 926 | + |
---|
| 927 | + if (mindist > dist) |
---|
| 928 | + { |
---|
| 929 | + mindist = dist; |
---|
| 930 | + size = mindist*pointFlow.resizefactor; |
---|
| 931 | + } |
---|
| 932 | + } |
---|
| 933 | + |
---|
| 934 | + if (i < s-1) |
---|
| 935 | + { |
---|
| 936 | + cVector w = pointFlow.points.get(i+1); |
---|
| 937 | + |
---|
| 938 | + double dist = w.distance(v); |
---|
| 939 | + |
---|
| 940 | + if (mindist > dist) |
---|
| 941 | + { |
---|
| 942 | + mindist = dist; |
---|
| 943 | + size = mindist*pointFlow.resizefactor; |
---|
| 944 | + } |
---|
| 945 | + } |
---|
| 946 | + |
---|
| 947 | + if (size < pointFlow.minimumSize) |
---|
| 948 | + size = pointFlow.minimumSize; |
---|
| 949 | + if (size > pointFlow.maximumSize) |
---|
| 950 | + size = pointFlow.maximumSize; |
---|
| 951 | + |
---|
| 952 | + double tx = v.x; |
---|
| 953 | + double ty = v.y; |
---|
| 954 | + double tz = v.z; |
---|
| 955 | + |
---|
| 956 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 957 | + // continue; |
---|
| 958 | + |
---|
| 959 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 960 | + gl.glPushMatrix(); |
---|
| 961 | + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; |
---|
| 962 | + |
---|
| 963 | + gl.glMultMatrixf(pointFlow.texmat, 0); |
---|
| 964 | + |
---|
| 965 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 966 | + gl.glPushMatrix(); |
---|
| 967 | + |
---|
| 968 | + gl.glTranslated(tx,ty,tz); |
---|
| 969 | + |
---|
| 970 | + gl.glScaled(size,size,size); |
---|
| 971 | + |
---|
| 972 | +// float cr = colorBuf.get(index4); |
---|
| 973 | +// float cg = colorBuf.get(index4+1); |
---|
| 974 | +// float cb = colorBuf.get(index4+2); |
---|
| 975 | +// float ca = colorBuf.get(index4+3); |
---|
| 976 | +// |
---|
| 977 | +// display.modelParams0[0] = r * cr; |
---|
| 978 | +// display.modelParams0[1] = g * cg; |
---|
| 979 | +// display.modelParams0[2] = b * cb; |
---|
| 980 | +// |
---|
| 981 | +// display.modelParams5[1] = opacity * ca; |
---|
| 982 | +// |
---|
| 983 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 984 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 985 | +// |
---|
| 986 | +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
| 987 | +// RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 988 | +// |
---|
| 989 | +//// gl.glColor4f(cr,cg,cb,ca); |
---|
| 990 | +// // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 991 | + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); |
---|
| 992 | + |
---|
| 993 | + gl.glPopMatrix(); |
---|
| 994 | + |
---|
| 995 | + double step = size/4; // |
---|
| 996 | + |
---|
| 997 | + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) |
---|
| 998 | + continue; |
---|
| 999 | + |
---|
| 1000 | + int nbsteps = (int)(distancenext/step); |
---|
| 1001 | + |
---|
| 1002 | + step = distancenext/nbsteps; |
---|
| 1003 | + |
---|
| 1004 | + cVector next = pointFlow.points.get(i-1); |
---|
| 1005 | + |
---|
| 1006 | + tmp.set(next); |
---|
| 1007 | + tmp.sub(v); |
---|
| 1008 | + tmp.normalize(); |
---|
| 1009 | + tmp.mul(step); |
---|
| 1010 | + |
---|
| 1011 | + // calculate next size |
---|
| 1012 | + mindist = Double.MAX_VALUE; |
---|
| 1013 | + |
---|
| 1014 | + double nextsize = pointFlow.minimumSize; |
---|
| 1015 | + |
---|
| 1016 | + if (i > 1) |
---|
| 1017 | + { |
---|
| 1018 | + cVector w = pointFlow.points.get(i-2); |
---|
| 1019 | + |
---|
| 1020 | + double dist = w.distance(next); |
---|
| 1021 | + |
---|
| 1022 | + if (mindist > dist) |
---|
| 1023 | + { |
---|
| 1024 | + mindist = dist; |
---|
| 1025 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1026 | + } |
---|
| 1027 | + } |
---|
| 1028 | + |
---|
| 1029 | + double dist = v.distance(next); |
---|
| 1030 | + |
---|
| 1031 | + if (mindist > dist) |
---|
| 1032 | + { |
---|
| 1033 | + mindist = dist; |
---|
| 1034 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1035 | + } |
---|
| 1036 | + |
---|
| 1037 | + if (nextsize < pointFlow.minimumSize) |
---|
| 1038 | + nextsize = pointFlow.minimumSize; |
---|
| 1039 | + if (nextsize > pointFlow.maximumSize) |
---|
| 1040 | + nextsize = pointFlow.maximumSize; |
---|
| 1041 | + // |
---|
| 1042 | + |
---|
| 1043 | + double count = 0; |
---|
| 1044 | + |
---|
| 1045 | + while (distancenext > 0.000000001) // step |
---|
| 1046 | + { |
---|
| 1047 | + gl.glPushMatrix(); |
---|
| 1048 | + |
---|
| 1049 | + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); |
---|
| 1050 | + |
---|
| 1051 | + double K = count/nbsteps; |
---|
| 1052 | + |
---|
| 1053 | + double intersize = K*nextsize + (1-K)*size; |
---|
| 1054 | + |
---|
| 1055 | + gl.glScaled(intersize,intersize,intersize); |
---|
| 1056 | + |
---|
| 1057 | + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); |
---|
| 1058 | + |
---|
| 1059 | + count++; |
---|
| 1060 | + |
---|
| 1061 | + distancenext -= step; |
---|
| 1062 | + |
---|
| 1063 | + gl.glPopMatrix(); |
---|
| 1064 | + } |
---|
| 1065 | + |
---|
| 1066 | + if (count != nbsteps) |
---|
| 1067 | + assert(count == nbsteps); |
---|
| 1068 | + |
---|
| 1069 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 1070 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 1071 | + |
---|
| 1072 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1073 | + gl.glPopMatrix(); |
---|
| 1074 | + } |
---|
| 1075 | + |
---|
| 1076 | + if (!cf) |
---|
| 1077 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 1078 | + |
---|
| 1079 | +// display.modelParams0[0] = r; |
---|
| 1080 | +// display.modelParams0[1] = g; |
---|
| 1081 | +// display.modelParams0[2] = b; |
---|
| 1082 | +// |
---|
| 1083 | +// display.modelParams5[1] = opacity; |
---|
| 1084 | +// |
---|
| 1085 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1086 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1087 | + |
---|
| 1088 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1089 | + } |
---|
| 1090 | + |
---|
| 1091 | + public void DrawBox(cVector min, cVector max) |
---|
| 1092 | + { |
---|
| 1093 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1094 | + gl.glBegin(gl.GL_LINES); |
---|
| 1095 | + |
---|
| 1096 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1097 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1098 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1099 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1100 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1101 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1102 | + |
---|
| 1103 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1104 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1105 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1106 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1107 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1108 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1109 | + |
---|
| 1110 | + gl.glEnd(); |
---|
| 1111 | + } |
---|
| 1112 | + |
---|
| 1113 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1114 | + { |
---|
| 1115 | + int[] strips = bRep.getRawIndices(); |
---|
| 1116 | + |
---|
| 1117 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1118 | + |
---|
| 1119 | + // TRIANGLE STRIP ARRAY |
---|
| 1120 | + if (bRep.trimmed) |
---|
| 1121 | + { |
---|
| 1122 | + float[] v = bRep.getRawVertices(); |
---|
| 1123 | + float[] n = bRep.getRawNormals(); |
---|
| 1124 | + float[] c = bRep.getRawColors(); |
---|
| 1125 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1126 | + |
---|
| 1127 | + int count2 = 0; |
---|
| 1128 | + int count3 = 0; |
---|
| 1129 | + |
---|
| 1130 | + if (n.length > 0) |
---|
| 1131 | + { |
---|
| 1132 | + for (int i = 0; i < strips.length; i++) |
---|
| 1133 | + { |
---|
| 1134 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1135 | + |
---|
| 1136 | + /* |
---|
| 1137 | + boolean locked = false; |
---|
| 1138 | + float eps = 0.1f; |
---|
| 1139 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1140 | + |
---|
| 1141 | + int dot = 0; |
---|
| 1142 | + |
---|
| 1143 | + if ((dot&1) == 0) |
---|
| 1144 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1145 | + |
---|
| 1146 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1147 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1148 | + else |
---|
| 1149 | + { |
---|
| 1150 | + locked = true; |
---|
| 1151 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1152 | + } |
---|
| 1153 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1154 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1155 | + if (hasnorm) |
---|
| 1156 | + { |
---|
| 1157 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1158 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1159 | + } |
---|
| 1160 | + |
---|
| 1161 | + if ((dot&4) == 0) |
---|
| 1162 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1163 | + |
---|
| 1164 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1165 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1166 | + else |
---|
| 1167 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1168 | + |
---|
| 1169 | + f.dot = dot; |
---|
| 1170 | + */ |
---|
| 1171 | + |
---|
| 1172 | + if (!selectmode) |
---|
| 1173 | + { |
---|
| 1174 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1175 | + { |
---|
| 1176 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1177 | + } else |
---|
| 1178 | + { |
---|
| 1179 | + gl.glNormal3f(0, 0, 1); |
---|
| 1180 | + } |
---|
| 1181 | + |
---|
| 1182 | + if (c != null) |
---|
| 1183 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1184 | + { |
---|
| 1185 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1186 | + } |
---|
| 1187 | + } |
---|
| 1188 | + if (flipV) |
---|
| 1189 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1190 | + else |
---|
| 1191 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1192 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1193 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1194 | + |
---|
| 1195 | + count2 += 2; |
---|
| 1196 | + count3 += 3; |
---|
| 1197 | + if (!selectmode) |
---|
| 1198 | + { |
---|
| 1199 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1200 | + { |
---|
| 1201 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1202 | + } else |
---|
| 1203 | + { |
---|
| 1204 | + gl.glNormal3f(0, 0, 1); |
---|
| 1205 | + } |
---|
| 1206 | + if (c != null) |
---|
| 1207 | + { |
---|
| 1208 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1209 | + } |
---|
| 1210 | + } |
---|
| 1211 | + if (flipV) |
---|
| 1212 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1213 | + else |
---|
| 1214 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1215 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1216 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1217 | + |
---|
| 1218 | + count2 += 2; |
---|
| 1219 | + count3 += 3; |
---|
| 1220 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1221 | + { |
---|
| 1222 | + //gl.glTexCoord2d(...); |
---|
| 1223 | + if (!selectmode) |
---|
| 1224 | + { |
---|
| 1225 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1226 | + { |
---|
| 1227 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1228 | + } else |
---|
| 1229 | + { |
---|
| 1230 | + gl.glNormal3f(0, 0, 1); |
---|
| 1231 | + } |
---|
| 1232 | + if (c != null) |
---|
| 1233 | + { |
---|
| 1234 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1235 | + } |
---|
| 1236 | + } |
---|
| 1237 | + |
---|
| 1238 | + if (flipV) |
---|
| 1239 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1240 | + else |
---|
| 1241 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1242 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1243 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1244 | + count2 += 2; |
---|
| 1245 | + count3 += 3; |
---|
| 1246 | + } |
---|
| 1247 | + |
---|
| 1248 | + gl.glEnd(); |
---|
| 1249 | + } |
---|
| 1250 | + } |
---|
| 1251 | + |
---|
| 1252 | + assert count3 == v.length; |
---|
| 1253 | + } |
---|
| 1254 | + else // !trimmed |
---|
| 1255 | + { |
---|
| 1256 | + int count = 0; |
---|
| 1257 | + for (int i = 0; i < strips.length; i++) |
---|
| 1258 | + { |
---|
| 1259 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1260 | + |
---|
| 1261 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1262 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1263 | + |
---|
| 1264 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1265 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1266 | + |
---|
| 1267 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1268 | + { |
---|
| 1269 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1270 | + |
---|
| 1271 | + // if (j%2 == 0) |
---|
| 1272 | + // drawFace(p, q, r, display, null); |
---|
| 1273 | + // else |
---|
| 1274 | + // drawFace(p, r, q, display, null); |
---|
| 1275 | + |
---|
| 1276 | + // p = q; |
---|
| 1277 | + // q = r; |
---|
| 1278 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1279 | + } |
---|
| 1280 | + |
---|
| 1281 | + gl.glEnd(); |
---|
| 1282 | + } |
---|
| 1283 | + } |
---|
| 1284 | + } |
---|
| 1285 | + |
---|
| 1286 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1287 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1288 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1289 | + |
---|
| 1290 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1291 | + { |
---|
| 1292 | + GL gl = GetGL(); // getGL(); |
---|
| 1293 | + |
---|
| 1294 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1295 | + |
---|
| 1296 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1297 | + |
---|
| 1298 | + gl.glLineWidth(1); |
---|
| 1299 | + gl.glColor3f(1,1,1); |
---|
| 1300 | + gl.glBegin(gl.GL_LINES); |
---|
| 1301 | + double scale = 0; |
---|
| 1302 | + int count = 0; |
---|
| 1303 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1304 | + { |
---|
| 1305 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1306 | + if(s == 0) |
---|
| 1307 | + { |
---|
| 1308 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1309 | + } |
---|
| 1310 | + if (mesh.showsprings) |
---|
| 1311 | + { |
---|
| 1312 | + temp.set(spring.a.position); |
---|
| 1313 | + temp.add(spring.b.position); |
---|
| 1314 | + temp.mul(0.5); |
---|
| 1315 | + temp2.set(spring.a.position); |
---|
| 1316 | + temp2.sub(spring.b.position); |
---|
| 1317 | + temp2.mul(spring.restLength/2); |
---|
| 1318 | + temp.sub(temp2); |
---|
| 1319 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1320 | + temp.add(temp2); |
---|
| 1321 | + temp.add(temp2); |
---|
| 1322 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1323 | + } |
---|
| 1324 | + |
---|
| 1325 | + if (spring.isHandle) |
---|
| 1326 | + continue; |
---|
| 1327 | + |
---|
| 1328 | + //if (scale < spring.restLength) |
---|
| 1329 | + scale += spring.restLength; |
---|
| 1330 | + count++; |
---|
| 1331 | + } |
---|
| 1332 | + gl.glEnd(); |
---|
| 1333 | + |
---|
| 1334 | + if (count == 0) |
---|
| 1335 | + scale = 0.01; |
---|
| 1336 | + else |
---|
| 1337 | + scale /= count * 3; |
---|
| 1338 | + |
---|
| 1339 | + //scale = 0.25; |
---|
| 1340 | + |
---|
| 1341 | + if (mesh.ShowInfo()) |
---|
| 1342 | + { |
---|
| 1343 | + gl.glLineWidth(4); |
---|
| 1344 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1345 | + { |
---|
| 1346 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1347 | + if (node.mass == 0) |
---|
| 1348 | + continue; |
---|
| 1349 | + |
---|
| 1350 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1351 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1352 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1353 | + //temp.normalize(); |
---|
| 1354 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1355 | + gl.glBegin(gl.GL_LINES); |
---|
| 1356 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1357 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1358 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1359 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1360 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1361 | + gl.glEnd(); |
---|
| 1362 | + } |
---|
| 1363 | + |
---|
| 1364 | + gl.glLineWidth(8); |
---|
| 1365 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1366 | + { |
---|
| 1367 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1368 | + |
---|
| 1369 | + if (node.springs != null) |
---|
| 1370 | + { |
---|
| 1371 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1372 | + { |
---|
| 1373 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1374 | + |
---|
| 1375 | + int c = i+1; |
---|
| 1376 | + // c = node.springs.get(i).nbcopies; |
---|
| 1377 | + |
---|
| 1378 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1379 | + gl.glBegin(gl.GL_LINES); |
---|
| 1380 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1381 | + 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); |
---|
| 1382 | + gl.glEnd(); |
---|
| 1383 | + } |
---|
| 1384 | + } |
---|
| 1385 | + } |
---|
| 1386 | + |
---|
| 1387 | + gl.glLineWidth(1); |
---|
| 1388 | + } |
---|
| 1389 | + |
---|
| 1390 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1391 | + } |
---|
| 1392 | + |
---|
| 1393 | + /// INTERFACE |
---|
| 1394 | + |
---|
| 1395 | + public void StartTriangles() |
---|
| 1396 | + { |
---|
| 1397 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1398 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1399 | + } |
---|
| 1400 | + |
---|
| 1401 | + public void EndTriangles() |
---|
| 1402 | + { |
---|
| 1403 | + GetGL().glEnd(); |
---|
| 1404 | + } |
---|
| 1405 | + |
---|
| 1406 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1407 | + { |
---|
| 1408 | + if (!selectmode) |
---|
| 1409 | + { |
---|
| 1410 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1411 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1412 | + |
---|
| 1413 | + if (flipV) |
---|
| 1414 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1415 | + else |
---|
| 1416 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1417 | + } |
---|
| 1418 | + |
---|
| 1419 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1420 | + } |
---|
| 1421 | + |
---|
| 1422 | + void SetColor(Object3D obj, Vertex p0) |
---|
| 1423 | + { |
---|
| 1424 | + CameraPane display = this; |
---|
| 1425 | + BoundaryRep bRep = obj.bRep; |
---|
| 1426 | + |
---|
| 1427 | + if (RENDERPROGRAM == 0) |
---|
| 1428 | + { |
---|
| 1429 | + float r = 0; |
---|
| 1430 | + if (bRep != null) |
---|
| 1431 | + { |
---|
| 1432 | + if (bRep.stripified) |
---|
| 1433 | + { |
---|
| 1434 | + r = 1; |
---|
| 1435 | + } |
---|
| 1436 | + } |
---|
| 1437 | + float g = 0; |
---|
| 1438 | + if (bRep != null) |
---|
| 1439 | + { |
---|
| 1440 | + if (bRep.trimmed) |
---|
| 1441 | + { |
---|
| 1442 | + g = 1; |
---|
| 1443 | + } |
---|
| 1444 | + } |
---|
| 1445 | + float b = 0; |
---|
| 1446 | + if (obj.support != null && obj.link2master) |
---|
| 1447 | + { |
---|
| 1448 | + b = 1; |
---|
| 1449 | + } |
---|
| 1450 | + display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO); |
---|
| 1451 | + return; |
---|
| 1452 | + } |
---|
| 1453 | + |
---|
| 1454 | + if (display.DrawMode() != CameraPane.SHADOW) |
---|
| 1455 | + return; |
---|
| 1456 | + |
---|
| 1457 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1458 | +// if (true) return; |
---|
| 1459 | +// float ao = p.AO; |
---|
| 1460 | +// |
---|
| 1461 | +// // if (ao == 0 && !bRep.AOdone) // transient problem! |
---|
| 1462 | +// // ao = 1; |
---|
| 1463 | +// |
---|
| 1464 | +// gl.glColor4f(ao, ao, ao, 1); |
---|
| 1465 | + |
---|
| 1466 | +// CameraPane.selectedpoint. |
---|
| 1467 | +// getAverage(cStatic.point1, true); |
---|
| 1468 | + if (CameraPane.pointflow == null) // !random) // live) |
---|
| 1469 | + { |
---|
| 1470 | + return; |
---|
| 1471 | + } |
---|
| 1472 | + |
---|
| 1473 | + cStatic.point1.set(0,0,0); |
---|
| 1474 | + LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1); |
---|
| 1475 | + |
---|
| 1476 | + cStatic.point1.sub(p0); |
---|
| 1477 | + |
---|
| 1478 | + |
---|
| 1479 | +// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta? |
---|
| 1480 | +// { |
---|
| 1481 | +// return; |
---|
| 1482 | +// } |
---|
| 1483 | + |
---|
| 1484 | + //if (true) |
---|
| 1485 | + if (cStatic.point1.dot(cStatic.point1) > 0.000001) |
---|
| 1486 | + { |
---|
| 1487 | + return; |
---|
| 1488 | + } |
---|
| 1489 | + |
---|
| 1490 | + float[] colorV = new float[3]; |
---|
| 1491 | + |
---|
| 1492 | + if (false) // marked) |
---|
| 1493 | + { |
---|
| 1494 | + // debug rigging weights |
---|
| 1495 | + for (int object = 0; object < p0.vertexlinks.length; object++) |
---|
| 1496 | + { |
---|
| 1497 | + float weight = p0.weights[object] / p0.totalweight; |
---|
| 1498 | + |
---|
| 1499 | + // if (weight < 0.1) |
---|
| 1500 | + // { |
---|
| 1501 | + // assert(weight == 0); |
---|
| 1502 | + // continue; |
---|
| 1503 | + // } |
---|
| 1504 | + |
---|
| 1505 | + if (p0.vertexlinks[object] == -1) |
---|
| 1506 | + continue; |
---|
| 1507 | + |
---|
| 1508 | + Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]); |
---|
| 1509 | + |
---|
| 1510 | + int color = //1 << object; // |
---|
| 1511 | + //p.vertexlinks.length; |
---|
| 1512 | + obj.support.bRep.supports[p0.closestsupport].links[object]; |
---|
| 1513 | + colorV[2] += (color & 1) * weight; |
---|
| 1514 | + colorV[1] += ((color & 2) >> 1) * weight; |
---|
| 1515 | + colorV[0] += ((color & 4) >> 2) * weight; |
---|
| 1516 | + } |
---|
| 1517 | + } |
---|
| 1518 | + else |
---|
| 1519 | + { |
---|
| 1520 | + if (obj.drawingstarted) |
---|
| 1521 | + { |
---|
| 1522 | + // find next point |
---|
| 1523 | + if (bRep.GetVertex(0).faceindices == null) |
---|
| 1524 | + { |
---|
| 1525 | + bRep.InitFaceIndices(); |
---|
| 1526 | + } |
---|
| 1527 | + |
---|
| 1528 | + double ymin = p0.y; |
---|
| 1529 | + |
---|
| 1530 | + Vertex newp = p0; |
---|
| 1531 | + |
---|
| 1532 | + for (int fii = 0; fii < p0.faceindices.length; fii++) |
---|
| 1533 | + { |
---|
| 1534 | + int fi = p0.faceindices[fii]; |
---|
| 1535 | + |
---|
| 1536 | + if (fi == -1) |
---|
| 1537 | + break; |
---|
| 1538 | + |
---|
| 1539 | + Face f = bRep.GetFace(fi); |
---|
| 1540 | + |
---|
| 1541 | + Vertex p = bRep.GetVertex(f.p); |
---|
| 1542 | + Vertex q = bRep.GetVertex(f.q); |
---|
| 1543 | + Vertex r = bRep.GetVertex(f.r); |
---|
| 1544 | + |
---|
| 1545 | + int swap = (int)(Math.random()*3); |
---|
| 1546 | + |
---|
| 1547 | +// for (int s=swap; --s>=0;) |
---|
| 1548 | +// { |
---|
| 1549 | +// Vertex t = p; |
---|
| 1550 | +// p = q; |
---|
| 1551 | +// q = r; |
---|
| 1552 | +// r = t; |
---|
| 1553 | +// } |
---|
| 1554 | + if (ymin > p.y) |
---|
| 1555 | + { |
---|
| 1556 | + ymin = p.y; |
---|
| 1557 | + newp = p; |
---|
| 1558 | +// break; |
---|
| 1559 | + } |
---|
| 1560 | + if (ymin > q.y) |
---|
| 1561 | + { |
---|
| 1562 | + ymin = q.y; |
---|
| 1563 | + newp = q; |
---|
| 1564 | +// break; |
---|
| 1565 | + } |
---|
| 1566 | + if (ymin > r.y) |
---|
| 1567 | + { |
---|
| 1568 | + ymin = r.y; |
---|
| 1569 | + newp = r; |
---|
| 1570 | +// break; |
---|
| 1571 | + } |
---|
| 1572 | + } |
---|
| 1573 | + |
---|
| 1574 | + CameraPane.selectedpoint.toParent[3][0] = newp.x; |
---|
| 1575 | + CameraPane.selectedpoint.toParent[3][1] = newp.y; |
---|
| 1576 | + CameraPane.selectedpoint.toParent[3][2] = newp.z; |
---|
| 1577 | + |
---|
| 1578 | + obj.drawingstarted = false; |
---|
| 1579 | + |
---|
| 1580 | + // return; |
---|
| 1581 | + } |
---|
| 1582 | + |
---|
| 1583 | + if (false) // CameraPane.DRAW |
---|
| 1584 | + { |
---|
| 1585 | + p0.AO = colorV[0] = 2; |
---|
| 1586 | + colorV[1] = 2; |
---|
| 1587 | + colorV[2] = 2; |
---|
| 1588 | + } |
---|
| 1589 | + |
---|
| 1590 | + CameraPane.pointflow.add(p0); |
---|
| 1591 | + CameraPane.pointflow.Touch(); |
---|
| 1592 | + } |
---|
| 1593 | + |
---|
| 1594 | +// gl.glColor3f(colorV[0], colorV[1], colorV[2]); |
---|
| 1595 | +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1596 | +// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1597 | + } |
---|
| 1598 | + |
---|
| 1599 | + void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1600 | + { |
---|
| 1601 | + CameraPane display = this; |
---|
| 1602 | + //new Exception().printStackTrace(); |
---|
| 1603 | + |
---|
| 1604 | + if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW) |
---|
| 1605 | + { |
---|
| 1606 | + return; |
---|
| 1607 | + } |
---|
| 1608 | + |
---|
| 1609 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1610 | + |
---|
| 1611 | + //Color col = Color.getHSBColor(color,modulation,1); |
---|
| 1612 | + //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
| 1613 | + if (!material.multiply) |
---|
| 1614 | + { |
---|
| 1615 | + display.color = color; |
---|
| 1616 | + display.saturation = material.modulation; |
---|
| 1617 | + } |
---|
| 1618 | + else |
---|
| 1619 | + { |
---|
| 1620 | + display.color *= color*2; |
---|
| 1621 | + display.saturation *= material.modulation*2; |
---|
| 1622 | + } |
---|
| 1623 | + |
---|
| 1624 | + cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
| 1625 | + |
---|
| 1626 | + float[] colorV = GrafreeD.colorV; |
---|
| 1627 | + |
---|
| 1628 | + /**/ |
---|
| 1629 | + if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
| 1630 | + { |
---|
| 1631 | + colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
| 1632 | + colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
| 1633 | + colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
| 1634 | + colorV[3] = material.opacity; |
---|
| 1635 | + |
---|
| 1636 | + gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
| 1637 | + //System.out.println("Opacity = " + opacity); |
---|
| 1638 | + |
---|
| 1639 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1640 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1641 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1642 | + |
---|
| 1643 | + float amb = material.ambient; |
---|
| 1644 | + if (amb < material.cameralight) |
---|
| 1645 | + { |
---|
| 1646 | + amb = material.cameralight; |
---|
| 1647 | + } |
---|
| 1648 | + colorV[0] = display.modelParams0[0] * material.diffuse * amb; |
---|
| 1649 | + colorV[1] = display.modelParams0[1] * material.diffuse * amb; |
---|
| 1650 | + colorV[2] = display.modelParams0[2] * material.diffuse * amb; |
---|
| 1651 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0); |
---|
| 1652 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1653 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 1654 | + |
---|
| 1655 | + /**/ |
---|
| 1656 | + colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular; |
---|
| 1657 | + colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular; |
---|
| 1658 | + colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular; |
---|
| 1659 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0); |
---|
| 1660 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1661 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0); |
---|
| 1662 | + colorV[0] = 10 / material.shininess; // 1/0.005f; |
---|
| 1663 | + //System.out.println("shininess = " + colorV[0]); |
---|
| 1664 | + if (colorV[0] > 128) |
---|
| 1665 | + { |
---|
| 1666 | + colorV[0] = 128; |
---|
| 1667 | + } |
---|
| 1668 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0); |
---|
| 1669 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0); |
---|
| 1670 | + /**/ |
---|
| 1671 | + } |
---|
| 1672 | + /**/ |
---|
| 1673 | + |
---|
| 1674 | + //selected = false; |
---|
| 1675 | + selected = selected && display.flash; |
---|
| 1676 | + |
---|
| 1677 | + //display.modelParams0[0] = 0; // pigment.r; |
---|
| 1678 | + //display.modelParams0[1] = 0; // pigment.g; |
---|
| 1679 | + //display.modelParams0[2] = 0; // pigment.b; |
---|
| 1680 | + if (!material.multiply) |
---|
| 1681 | + { |
---|
| 1682 | + display.modelParams0[3] = material.metalness; |
---|
| 1683 | + display.modelParams1[0] = material.diffuse; |
---|
| 1684 | + display.modelParams1[1] = material.specular; |
---|
| 1685 | + display.modelParams1[2] = 1 / material.shininess; |
---|
| 1686 | + display.modelParams1[3] = material.shift; |
---|
| 1687 | + display.modelParams2[0] = material.ambient; |
---|
| 1688 | + display.modelParams2[1] = material.lightarea; |
---|
| 1689 | + //System.out.println("light area = " + lightarea); |
---|
| 1690 | + display.modelParams2[2] = 1 / material.factor; // diffuseness |
---|
| 1691 | + display.modelParams2[3] = material.velvet; |
---|
| 1692 | + display.modelParams3[0] = material.sheen; |
---|
| 1693 | + display.modelParams3[1] = material.subsurface; |
---|
| 1694 | + display.modelParams3[2] = material.bump; // backlit |
---|
| 1695 | + display.modelParams3[3] = material.aniso; |
---|
| 1696 | + display.modelParams4[0] = material.anisoV; |
---|
| 1697 | + display.modelParams4[1] = selected ? 100 : material.cameralight; |
---|
| 1698 | + //System.out.println("selected = " + selected); |
---|
| 1699 | + display.modelParams4[2] = material.diffuseness; |
---|
| 1700 | + display.modelParams4[3] = material.shadow; |
---|
| 1701 | + display.modelParams5[0] = material.texture; |
---|
| 1702 | + display.modelParams5[1] = material.opacity; |
---|
| 1703 | + display.modelParams5[2] = material.fakedepth; |
---|
| 1704 | + display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10; |
---|
| 1705 | + } |
---|
| 1706 | + else |
---|
| 1707 | + { |
---|
| 1708 | + display.modelParams0[3] *= material.metalness*2; |
---|
| 1709 | + display.modelParams1[0] *= material.diffuse*2; |
---|
| 1710 | + display.modelParams1[1] *= material.specular*2; |
---|
| 1711 | + display.modelParams1[2] *= material.shininess*2; |
---|
| 1712 | + display.modelParams1[3] *= material.shift*2; |
---|
| 1713 | + display.modelParams2[0] *= material.ambient*2; |
---|
| 1714 | + display.modelParams2[1] *= material.lightarea*2; |
---|
| 1715 | + display.modelParams2[2] *= material.factor*2; |
---|
| 1716 | + display.modelParams2[3] *= material.velvet*2; |
---|
| 1717 | + display.modelParams3[0] *= material.sheen*2; |
---|
| 1718 | + display.modelParams3[1] *= material.subsurface*2; |
---|
| 1719 | + display.modelParams3[2] *= material.bump*2; |
---|
| 1720 | + display.modelParams3[3] *= material.aniso*2; |
---|
| 1721 | + display.modelParams4[0] *= material.anisoV*2; |
---|
| 1722 | + display.modelParams4[1] *= material.cameralight*2; |
---|
| 1723 | + //System.out.println("selected = " + selected); |
---|
| 1724 | + display.modelParams4[2] *= material.diffuseness*2; |
---|
| 1725 | + display.modelParams4[3] *= material.shadow*2; |
---|
| 1726 | + display.modelParams5[0] *= material.texture*2; |
---|
| 1727 | + display.modelParams5[1] *= material.opacity*2; |
---|
| 1728 | + display.modelParams5[2] *= material.fakedepth*2; |
---|
| 1729 | + display.modelParams5[3] *= material.shadowbias*2; |
---|
| 1730 | + } |
---|
| 1731 | + |
---|
| 1732 | + display.modelParams6[0] = 0; |
---|
| 1733 | + display.modelParams6[1] = 0; |
---|
| 1734 | + display.modelParams6[2] = 0; |
---|
| 1735 | + display.modelParams6[3] = 0; |
---|
| 1736 | + |
---|
| 1737 | + display.modelParams7[0] = 0; |
---|
| 1738 | + display.modelParams7[1] = 1000; |
---|
| 1739 | + display.modelParams7[2] = 0; |
---|
| 1740 | + display.modelParams7[3] = 0; |
---|
| 1741 | + |
---|
| 1742 | + display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1743 | + |
---|
| 1744 | + Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1745 | + if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
| 1746 | + { |
---|
| 1747 | + display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
| 1748 | + display.modelParams6[1] = extparams[0].y / 1000.0f; // noise |
---|
| 1749 | + if (extparams.length > 1) |
---|
| 1750 | + { |
---|
| 1751 | + display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade |
---|
| 1752 | + display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough |
---|
| 1753 | + if (extparams.length > 2) |
---|
| 1754 | + { |
---|
| 1755 | + display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power |
---|
| 1756 | + float x = extparams[2].y / 1000.0f; |
---|
| 1757 | + //if (x == 0) |
---|
| 1758 | + // x = 1f; |
---|
| 1759 | + 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 |
---|
| 1760 | + if (extparams[2].y > 0) |
---|
| 1761 | + { |
---|
| 1762 | + //System.out.println("extparams[1].y = " + extparams[1].y); |
---|
| 1763 | + //System.out.println("extparams[2].y = " + extparams[2].y); |
---|
| 1764 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1765 | + } |
---|
| 1766 | + } |
---|
| 1767 | + } |
---|
| 1768 | + } |
---|
| 1769 | + |
---|
| 1770 | + //if (display.modelParams6[2] != 0) |
---|
| 1771 | + /* |
---|
| 1772 | + System.out.println("modelParams0[0] = " + display.modelParams0[0]); |
---|
| 1773 | + System.out.println("modelParams0[1] = " + display.modelParams0[1]); |
---|
| 1774 | + System.out.println("modelParams0[2] = " + display.modelParams0[2]); |
---|
| 1775 | + System.out.println("modelParams0[3] = " + display.modelParams0[3]); |
---|
| 1776 | + System.out.println("modelParams1[0] = " + display.modelParams1[0]); |
---|
| 1777 | + System.out.println("modelParams1[1] = " + display.modelParams1[1]); |
---|
| 1778 | + System.out.println("modelParams1[2] = " + display.modelParams1[2]); |
---|
| 1779 | + System.out.println("modelParams1[3] = " + display.modelParams1[3]); |
---|
| 1780 | + System.out.println("modelParams2[0] = " + display.modelParams2[0]); |
---|
| 1781 | + System.out.println("modelParams2[1] = " + display.modelParams2[1]); |
---|
| 1782 | + System.out.println("modelParams2[2] = " + display.modelParams2[2]); |
---|
| 1783 | + System.out.println("modelParams2[3] = " + display.modelParams2[3]); |
---|
| 1784 | + System.out.println("modelParams3[0] = " + display.modelParams3[0]); |
---|
| 1785 | + System.out.println("modelParams3[1] = " + display.modelParams3[1]); |
---|
| 1786 | + System.out.println("modelParams3[2] = " + display.modelParams3[2]); |
---|
| 1787 | + System.out.println("modelParams3[3] = " + display.modelParams3[3]); |
---|
| 1788 | + System.out.println("modelParams4[0] = " + display.modelParams4[0]); |
---|
| 1789 | + System.out.println("modelParams4[1] = " + display.modelParams4[1]); |
---|
| 1790 | + System.out.println("modelParams4[2] = " + display.modelParams4[2]); |
---|
| 1791 | + System.out.println("modelParams4[3] = " + display.modelParams4[3]); |
---|
| 1792 | + System.out.println("modelParams5[0] = " + display.modelParams5[0]); |
---|
| 1793 | + System.out.println("modelParams5[1] = " + display.modelParams5[1]); |
---|
| 1794 | + System.out.println("modelParams5[2] = " + display.modelParams5[2]); |
---|
| 1795 | + System.out.println("modelParams5[3] = " + display.modelParams5[3]); |
---|
| 1796 | + System.out.println("modelParams6[0] = " + display.modelParams6[0]); |
---|
| 1797 | + System.out.println("modelParams6[1] = " + display.modelParams6[1]); |
---|
| 1798 | + System.out.println("modelParams6[2] = " + display.modelParams6[2]); |
---|
| 1799 | + System.out.println("modelParams6[3] = " + display.modelParams6[3]); |
---|
| 1800 | + System.out.println("modelParams7[0] = " + display.modelParams7[0]); |
---|
| 1801 | + System.out.println("modelParams7[1] = " + display.modelParams7[1]); |
---|
| 1802 | + System.out.println("modelParams7[2] = " + display.modelParams7[2]); |
---|
| 1803 | + System.out.println("modelParams7[3] = " + display.modelParams7[3]); |
---|
| 1804 | + /**/ |
---|
| 1805 | + //assert (display.modelParams6[2] == 0); |
---|
| 1806 | + |
---|
| 1807 | + //System.out.println("noise power = " + display.modelParams7[0]); |
---|
| 1808 | + //System.out.println("shadowbias = " + shadowbias); |
---|
| 1809 | + |
---|
| 1810 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1811 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0); |
---|
| 1812 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0); |
---|
| 1813 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0); |
---|
| 1814 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 1815 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1816 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0); |
---|
| 1817 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0); |
---|
| 1818 | + |
---|
| 1819 | + int mode = display.FP_SHADER; |
---|
| 1820 | + |
---|
| 1821 | + if (material.aniso != material.anisoV || material.aniso > 0.002) |
---|
| 1822 | + { |
---|
| 1823 | + mode |= display.FP_ANISO; |
---|
| 1824 | + } |
---|
| 1825 | + |
---|
| 1826 | + display.EnableProgram(mode); |
---|
| 1827 | + |
---|
| 1828 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1829 | + |
---|
| 1830 | + if (!material.multiply) |
---|
| 1831 | + { |
---|
| 1832 | + if (Globals.drawMode == CameraPane.SHADOW) |
---|
| 1833 | + gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1); |
---|
| 1834 | + else |
---|
| 1835 | + gl.glDepthMask(material.opacity >= 0.99); |
---|
| 1836 | + } |
---|
208 | 1837 | } |
---|
209 | 1838 | |
---|
210 | 1839 | int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0; |
---|
.. | .. |
---|
225 | 1854 | currentGL.glMultMatrixd(model, 0); |
---|
226 | 1855 | } |
---|
227 | 1856 | |
---|
228 | | - void PushMatrix(double[][] matrix, int count) |
---|
| 1857 | + public void PushMatrix(double[][] matrix, int count) // INTERFACE |
---|
229 | 1858 | { |
---|
230 | 1859 | matrixdepth++; |
---|
231 | 1860 | // GrafreeD.tracein(matrix); |
---|
.. | .. |
---|
270 | 1899 | |
---|
271 | 1900 | double[][] tmpmat = new double[4][4]; |
---|
272 | 1901 | |
---|
273 | | - void PopMatrix(double[][] inverse) |
---|
| 1902 | + public void PopMatrix(double[][] inverse) // INTERFACE |
---|
274 | 1903 | { |
---|
275 | 1904 | --matrixdepth; |
---|
276 | 1905 | |
---|
.. | .. |
---|
310 | 1939 | PushTextureMatrix(matrix, 1); |
---|
311 | 1940 | } |
---|
312 | 1941 | |
---|
313 | | - void PushTextureMatrix(double[][] matrix, int count) |
---|
| 1942 | + public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE |
---|
314 | 1943 | { |
---|
315 | 1944 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
316 | 1945 | |
---|
.. | .. |
---|
324 | 1953 | currentGL.glMatrixMode(GetGL().GL_MODELVIEW); |
---|
325 | 1954 | } |
---|
326 | 1955 | |
---|
327 | | - void PopTextureMatrix(double[][] inverse) |
---|
| 1956 | + public void PopTextureMatrix(double[][] inverse) // INTERFACE |
---|
328 | 1957 | { |
---|
329 | 1958 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
330 | 1959 | currentGL.glMatrixMode(GetGL().GL_TEXTURE); |
---|
.. | .. |
---|
351 | 1980 | |
---|
352 | 1981 | static int camerachangeframe; |
---|
353 | 1982 | |
---|
354 | | - boolean SetCamera(Camera cam) |
---|
| 1983 | + public boolean SetCamera(Camera cam) |
---|
355 | 1984 | { |
---|
356 | 1985 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
357 | 1986 | // return false; |
---|
358 | 1987 | |
---|
359 | | - if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount) |
---|
| 1988 | + if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount) |
---|
360 | 1989 | { |
---|
361 | 1990 | // check for last change |
---|
362 | | - if (framecount < camerachangeframe + 400) // 120 == 1 second |
---|
| 1991 | + if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second |
---|
363 | 1992 | { |
---|
364 | 1993 | // refuse the camera change |
---|
365 | 1994 | System.err.println("Camera " + cam + " REFUSED"); |
---|
.. | .. |
---|
367 | 1996 | } |
---|
368 | 1997 | } |
---|
369 | 1998 | |
---|
370 | | - camerachangeframe = framecount; |
---|
| 1999 | + camerachangeframe = Globals.framecount; |
---|
371 | 2000 | |
---|
372 | 2001 | cam.hAspect = -1; // Read only |
---|
373 | 2002 | |
---|
.. | .. |
---|
398 | 2027 | { |
---|
399 | 2028 | //System.err.println("Oeil on"); |
---|
400 | 2029 | TRACK = true; |
---|
401 | | -// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 2030 | +// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
402 | 2031 | // object.editWindow.ScreenFit(trackedobject); |
---|
403 | 2032 | //pingthread.StepToTarget(true); |
---|
404 | 2033 | } |
---|
.. | .. |
---|
407 | 2036 | { |
---|
408 | 2037 | //System.err.println("Oeil on"); |
---|
409 | 2038 | OEIL = true; |
---|
410 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 2039 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
411 | 2040 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
412 | 2041 | //pingthread.StepToTarget(true); |
---|
413 | 2042 | } |
---|
.. | .. |
---|
471 | 2100 | { |
---|
472 | 2101 | frozen ^= true; |
---|
473 | 2102 | // Weird... |
---|
474 | | - lighttouched = true; |
---|
| 2103 | + Globals.lighttouched = true; |
---|
475 | 2104 | } |
---|
476 | 2105 | |
---|
477 | 2106 | void ToggleDL() |
---|
478 | 2107 | { |
---|
479 | 2108 | mainDL ^= true; |
---|
480 | | - } |
---|
481 | | - |
---|
482 | | - void ToggleTexture() |
---|
483 | | - { |
---|
484 | | - textureon ^= true; |
---|
485 | | - } |
---|
486 | | - |
---|
487 | | - void ToggleLive() |
---|
488 | | - { |
---|
489 | | - setLIVE(isLIVE() ^ true); |
---|
490 | | - |
---|
491 | | - System.err.println("LIVE = " + isLIVE()); |
---|
492 | | - |
---|
493 | | - if (!isLIVE()) // save sound |
---|
494 | | - GrafreeD.savesound = true; // wav.save(); |
---|
495 | | - // else |
---|
496 | | - repaint(); // start loop // may 2013 |
---|
497 | | - } |
---|
498 | | - |
---|
499 | | - void ToggleSupport() |
---|
500 | | - { |
---|
501 | | - SUPPORT ^= true; |
---|
502 | | - } |
---|
503 | | - |
---|
504 | | - void ToggleAbort() |
---|
505 | | - { |
---|
506 | | - ABORTMODE ^= true; |
---|
507 | 2109 | } |
---|
508 | 2110 | |
---|
509 | 2111 | void ToggleFullScreen() |
---|
.. | .. |
---|
513 | 2115 | |
---|
514 | 2116 | void ToggleCrowd() |
---|
515 | 2117 | { |
---|
516 | | - CROWD ^= true; |
---|
517 | | - } |
---|
518 | | - |
---|
519 | | - void ToggleInertia() |
---|
520 | | - { |
---|
521 | | - INERTIA ^= true; |
---|
| 2118 | + Globals.CROWD ^= true; |
---|
522 | 2119 | } |
---|
523 | 2120 | |
---|
524 | 2121 | void ToggleLocal() |
---|
.. | .. |
---|
526 | 2123 | LOCALTRANSFORM ^= true; |
---|
527 | 2124 | } |
---|
528 | 2125 | |
---|
529 | | - void ToggleFast() |
---|
| 2126 | + public void ToggleTexture() |
---|
| 2127 | + { |
---|
| 2128 | + textureon ^= true; |
---|
| 2129 | + } |
---|
| 2130 | + |
---|
| 2131 | + public void ToggleLive() |
---|
| 2132 | + { |
---|
| 2133 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
| 2134 | + |
---|
| 2135 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
| 2136 | + |
---|
| 2137 | + if (!Globals.isLIVE()) // save sound |
---|
| 2138 | + GrafreeD.savesound = true; // wav.save(); |
---|
| 2139 | + // else |
---|
| 2140 | + repaint(); // start loop // may 2013 |
---|
| 2141 | + } |
---|
| 2142 | + |
---|
| 2143 | + public void ToggleSupport() |
---|
| 2144 | + { |
---|
| 2145 | + SUPPORT ^= true; |
---|
| 2146 | + } |
---|
| 2147 | + |
---|
| 2148 | + public void ToggleAbort() |
---|
| 2149 | + { |
---|
| 2150 | + ABORTMODE ^= true; |
---|
| 2151 | + } |
---|
| 2152 | + |
---|
| 2153 | + public void ToggleInertia() |
---|
| 2154 | + { |
---|
| 2155 | + INERTIA ^= true; |
---|
| 2156 | + } |
---|
| 2157 | + |
---|
| 2158 | + public void ToggleFast() |
---|
530 | 2159 | { |
---|
531 | 2160 | FAST ^= true; |
---|
532 | 2161 | } |
---|
533 | 2162 | |
---|
534 | | - void ToggleSlowPose() |
---|
| 2163 | + public void ToggleSlowPose() |
---|
535 | 2164 | { |
---|
536 | 2165 | SLOWPOSE ^= true; |
---|
537 | 2166 | } |
---|
538 | 2167 | |
---|
539 | | - void ToggleFootContact() |
---|
540 | | - { |
---|
541 | | - FOOTCONTACT ^= true; |
---|
542 | | - } |
---|
543 | | - |
---|
544 | | - void ToggleBoxMode() |
---|
| 2168 | + public void ToggleBoxMode() |
---|
545 | 2169 | { |
---|
546 | 2170 | BOXMODE ^= true; |
---|
547 | 2171 | } |
---|
548 | 2172 | |
---|
549 | | - void ToggleSmoothFocus() |
---|
| 2173 | + public void ToggleSmoothFocus() |
---|
550 | 2174 | { |
---|
551 | 2175 | SMOOTHFOCUS ^= true; |
---|
552 | 2176 | } |
---|
553 | 2177 | |
---|
554 | | - void ToggleImageFlip() |
---|
| 2178 | + public void ToggleImageFlip() |
---|
555 | 2179 | { |
---|
556 | 2180 | IMAGEFLIP ^= true; |
---|
557 | 2181 | } |
---|
558 | 2182 | |
---|
559 | | - void ToggleSpeakerMocap() |
---|
| 2183 | + public void ToggleSpeakerMocap() |
---|
560 | 2184 | { |
---|
561 | 2185 | SPEAKERMOCAP ^= true; |
---|
562 | 2186 | } |
---|
563 | 2187 | |
---|
564 | | - void ToggleSpeakerCamera() |
---|
| 2188 | + public void ToggleSpeakerCamera() |
---|
565 | 2189 | { |
---|
566 | 2190 | SPEAKERCAMERA ^= true; |
---|
567 | 2191 | } |
---|
568 | 2192 | |
---|
569 | | - void ToggleSpeakerFocus() |
---|
| 2193 | + public void ToggleSpeakerFocus() |
---|
570 | 2194 | { |
---|
571 | 2195 | SPEAKERFOCUS ^= true; |
---|
572 | 2196 | } |
---|
573 | 2197 | |
---|
574 | | - void ToggleDebug() |
---|
575 | | - { |
---|
576 | | - DEBUG ^= true; |
---|
577 | | - } |
---|
578 | | - |
---|
579 | | - void ToggleFrustum() |
---|
| 2198 | + public void ToggleFrustum() |
---|
580 | 2199 | { |
---|
581 | 2200 | FRUSTUM ^= true; |
---|
582 | 2201 | } |
---|
583 | 2202 | |
---|
584 | | - void ToggleTrack() |
---|
| 2203 | + public void ToggleTrack() |
---|
585 | 2204 | { |
---|
586 | 2205 | TRACK ^= true; |
---|
587 | 2206 | if (TRACK) |
---|
.. | .. |
---|
600 | 2219 | repaint(); |
---|
601 | 2220 | } |
---|
602 | 2221 | |
---|
603 | | - void ToggleTrackOnce() |
---|
| 2222 | + public void ToggleTrackOnce() |
---|
604 | 2223 | { |
---|
605 | 2224 | TRACKONCE ^= true; |
---|
606 | 2225 | } |
---|
607 | 2226 | |
---|
608 | | - void ToggleShadowTrack() |
---|
| 2227 | + public void ToggleShadowTrack() |
---|
609 | 2228 | { |
---|
610 | 2229 | SHADOWTRACK ^= true; |
---|
611 | 2230 | repaint(); |
---|
612 | 2231 | } |
---|
613 | 2232 | |
---|
614 | | - void ToggleOeil() |
---|
| 2233 | + public void ToggleOeil() |
---|
615 | 2234 | { |
---|
616 | 2235 | OEIL ^= true; |
---|
617 | 2236 | } |
---|
618 | 2237 | |
---|
619 | | - void ToggleOeilOnce() |
---|
| 2238 | + public void ToggleOeilOnce() |
---|
620 | 2239 | { |
---|
621 | 2240 | OEILONCE ^= true; |
---|
| 2241 | + } |
---|
| 2242 | + |
---|
| 2243 | + void ToggleFootContact() |
---|
| 2244 | + { |
---|
| 2245 | + FOOTCONTACT ^= true; |
---|
| 2246 | + } |
---|
| 2247 | + |
---|
| 2248 | + void ToggleDebug() |
---|
| 2249 | + { |
---|
| 2250 | + DEBUG ^= true; |
---|
622 | 2251 | } |
---|
623 | 2252 | |
---|
624 | 2253 | void ToggleLookAt() |
---|
.. | .. |
---|
672 | 2301 | //assert (cam.hAspect == 0); |
---|
673 | 2302 | cam.hAspect = 0; |
---|
674 | 2303 | lightCamera = cam; |
---|
675 | | - } |
---|
676 | | - |
---|
677 | | - CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
678 | | - { |
---|
679 | | - super(defaultcaps, null, withcontext?glcontext:null, null); |
---|
680 | | - |
---|
681 | | - //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523)); |
---|
682 | | - glcontext = getContext(); |
---|
683 | | - |
---|
684 | | - cameras = new Camera[2]; |
---|
685 | | - targetLookAts = new cVector[2]; |
---|
686 | | - |
---|
687 | | - SetCamera(cam); |
---|
688 | | - |
---|
689 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
690 | | - |
---|
691 | | - object = o; |
---|
692 | | - |
---|
693 | | - setBackground(Color.white); |
---|
694 | | - |
---|
695 | | - addKeyListener(this); |
---|
696 | | - addMouseListener(this); |
---|
697 | | - addMouseMotionListener(this); |
---|
698 | | - addMouseWheelListener(this); |
---|
699 | | - //System.out.println("addGLEventListener: " + this); |
---|
700 | | - addGLEventListener(this); |
---|
701 | | - |
---|
702 | | -// pingthread.start(); // may 2013 |
---|
703 | 2304 | } |
---|
704 | 2305 | |
---|
705 | 2306 | private static void ApplyTransform(GL gl, Mat4f xform) |
---|
.. | .. |
---|
759 | 2360 | |
---|
760 | 2361 | GL currentGL; |
---|
761 | 2362 | |
---|
762 | | - GL GetGL() |
---|
| 2363 | + public GL GetGL() // INTERFACE |
---|
763 | 2364 | { |
---|
764 | 2365 | return currentGL; |
---|
765 | 2366 | } |
---|
.. | .. |
---|
6271 | 7872 | return null; |
---|
6272 | 7873 | } |
---|
6273 | 7874 | |
---|
6274 | | - void ReleaseTextures(cTexture tex) |
---|
| 7875 | + public void ReleaseTextures(cTexture tex) // INTERFACE |
---|
6275 | 7876 | { |
---|
6276 | 7877 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6277 | 7878 | { |
---|
.. | .. |
---|
6309 | 7910 | |
---|
6310 | 7911 | void ReleaseTexture(String tex, boolean bump) |
---|
6311 | 7912 | { |
---|
6312 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 7913 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6313 | 7914 | ambientOcclusion ) // || !textureon) |
---|
6314 | 7915 | { |
---|
6315 | 7916 | return; |
---|
.. | .. |
---|
6410 | 8011 | } |
---|
6411 | 8012 | } |
---|
6412 | 8013 | |
---|
6413 | | - /*boolean*/ void BindTextures(cTexture tex, int resolution) |
---|
| 8014 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
6414 | 8015 | { |
---|
6415 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 8016 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6416 | 8017 | ambientOcclusion ) // || !textureon) |
---|
6417 | 8018 | { |
---|
6418 | 8019 | return; // false; |
---|
.. | .. |
---|
6708 | 8309 | return texture!=null?texture.texture:null; |
---|
6709 | 8310 | } |
---|
6710 | 8311 | |
---|
6711 | | - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8312 | + public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
6712 | 8313 | { |
---|
6713 | 8314 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
6714 | 8315 | |
---|
.. | .. |
---|
7312 | 8913 | static boolean occlusionInitialized = false; |
---|
7313 | 8914 | boolean selection = false; |
---|
7314 | 8915 | boolean pointselection = false; |
---|
7315 | | - /*static*/ boolean lighttouched = true; |
---|
| 8916 | + ///*static*/ boolean lighttouched = true; |
---|
7316 | 8917 | boolean deselect; |
---|
7317 | | - boolean ambientOcclusion = false; |
---|
| 8918 | + private boolean ambientOcclusion = false; |
---|
7318 | 8919 | static boolean flash = false; |
---|
7319 | 8920 | /*static*/ boolean wait = false; |
---|
7320 | 8921 | boolean displaydone = false; // after repaint() calls |
---|
.. | .. |
---|
7444 | 9045 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
7445 | 9046 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
7446 | 9047 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 9048 | +// PATCH FILLE AUX JEANS |
---|
| 9049 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
7447 | 9050 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
7448 | 9051 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
7449 | 9052 | |
---|
.. | .. |
---|
7601 | 9204 | |
---|
7602 | 9205 | boolean restartframe = false; |
---|
7603 | 9206 | |
---|
7604 | | - static int framecount = 0; // general-purpose global count |
---|
7605 | | - |
---|
7606 | 9207 | void displayAntiAliased(javax.media.opengl.GL gl) |
---|
7607 | 9208 | { |
---|
7608 | 9209 | //gl.glGetIntegerv(gl.GL_ACCUM_RED_BITS, viewport, 0); |
---|
.. | .. |
---|
7633 | 9234 | gl.glClear(gl.GL_ACCUM_BUFFER_BIT); |
---|
7634 | 9235 | for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0) |
---|
7635 | 9236 | { |
---|
7636 | | - framecount++; |
---|
| 9237 | + Globals.framecount++; |
---|
7637 | 9238 | |
---|
7638 | 9239 | if (CameraPane.tickcount > 0) |
---|
7639 | 9240 | CameraPane.tickcount--; |
---|
.. | .. |
---|
7671 | 9272 | |
---|
7672 | 9273 | gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0); |
---|
7673 | 9274 | */ |
---|
7674 | | - lighttouched = true; |
---|
| 9275 | + Globals.lighttouched = true; |
---|
7675 | 9276 | //System.err.println(" shadowbuffer: " + jitter); |
---|
7676 | 9277 | shadowbuffer.display(); |
---|
7677 | 9278 | |
---|
.. | .. |
---|
7693 | 9294 | |
---|
7694 | 9295 | if (renderCamera != lightCamera) |
---|
7695 | 9296 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7696 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 9297 | + LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
7697 | 9298 | |
---|
7698 | 9299 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
7699 | 9300 | |
---|
.. | .. |
---|
7709 | 9310 | |
---|
7710 | 9311 | if (renderCamera != lightCamera) |
---|
7711 | 9312 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7712 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 9313 | + LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
7713 | 9314 | |
---|
7714 | 9315 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
7715 | 9316 | |
---|
.. | .. |
---|
8618 | 10219 | } |
---|
8619 | 10220 | } |
---|
8620 | 10221 | |
---|
8621 | | - boolean IsFrozen() |
---|
8622 | | - { |
---|
8623 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
8624 | | - |
---|
8625 | | - return !selectmode && cameracount == 0; // != 0; |
---|
8626 | | - } |
---|
8627 | | - |
---|
8628 | 10222 | boolean niceon = false; |
---|
8629 | 10223 | javax.swing.Timer AAtimer = new javax.swing.Timer(750, this); |
---|
8630 | 10224 | boolean currentlydrawing = false; |
---|
.. | .. |
---|
8642 | 10236 | } |
---|
8643 | 10237 | // if (DEBUG_SELECTION) |
---|
8644 | 10238 | // { |
---|
8645 | | -// if (drawMode != SELECTION) |
---|
8646 | | -// drawMode = SELECTION; |
---|
| 10239 | +// if (DrawMode() != SELECTION) |
---|
| 10240 | +// DrawMode() = SELECTION; |
---|
8647 | 10241 | // } |
---|
8648 | 10242 | |
---|
8649 | 10243 | if (!isRenderer) |
---|
.. | .. |
---|
8699 | 10293 | |
---|
8700 | 10294 | //ANTIALIAS = 0; |
---|
8701 | 10295 | |
---|
8702 | | - if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
| 10296 | + if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
8703 | 10297 | { |
---|
8704 | | - if (niceon || isLIVE()) |
---|
| 10298 | + if (niceon || Globals.isLIVE()) |
---|
8705 | 10299 | { |
---|
8706 | 10300 | //if(active == 0) |
---|
8707 | 10301 | // antialiaser = null; |
---|
.. | .. |
---|
8726 | 10320 | assert eyeCamera.shaper_zFar == 1E5f; // 500.0f; |
---|
8727 | 10321 | */ |
---|
8728 | 10322 | |
---|
8729 | | - if (drawMode == DEFAULT) |
---|
| 10323 | + if (DrawMode() == DEFAULT) |
---|
8730 | 10324 | { |
---|
8731 | 10325 | currentlydrawing = true; |
---|
8732 | 10326 | } |
---|
.. | .. |
---|
8757 | 10351 | |
---|
8758 | 10352 | // if(Applet3D.clipboard != null) |
---|
8759 | 10353 | // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent); |
---|
8760 | | -//drawMode = SELECTION; |
---|
| 10354 | +//DrawMode() = SELECTION; |
---|
8761 | 10355 | indexcount = 0; |
---|
8762 | 10356 | |
---|
8763 | | - if (drawMode == OCCLUSION) |
---|
| 10357 | + if (DrawMode() == OCCLUSION) |
---|
8764 | 10358 | { |
---|
8765 | | - drawMode = DEFAULT; |
---|
| 10359 | + Globals.drawMode = DEFAULT; // WARNING |
---|
8766 | 10360 | ambientOcclusion = true; |
---|
8767 | 10361 | setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
---|
8768 | 10362 | Object3D theobject = object; |
---|
.. | .. |
---|
8781 | 10375 | ambientOcclusion = false; |
---|
8782 | 10376 | } |
---|
8783 | 10377 | |
---|
8784 | | - if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10378 | + if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
8785 | 10379 | { |
---|
8786 | 10380 | //if (RENDERSHADOW) // ? |
---|
8787 | 10381 | if (!IsFrozen()) |
---|
8788 | 10382 | { |
---|
8789 | 10383 | // dec 2012 |
---|
8790 | | - if (!ambientOcclusion && !(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)) |
---|
| 10384 | + if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
8791 | 10385 | { |
---|
8792 | | - framecount++; |
---|
| 10386 | + Globals.framecount++; |
---|
8793 | 10387 | shadowbuffer.display(); |
---|
8794 | 10388 | } |
---|
8795 | 10389 | } |
---|
8796 | | - lighttouched = false; // ?? |
---|
| 10390 | + Globals.lighttouched = false; // ?? |
---|
8797 | 10391 | //drawing = true; |
---|
8798 | 10392 | //lighttouched = true; |
---|
8799 | 10393 | } |
---|
.. | .. |
---|
8814 | 10408 | //eyeCamera.shaper_fovy = 1; |
---|
8815 | 10409 | } |
---|
8816 | 10410 | |
---|
8817 | | - if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION) |
---|
| 10411 | + if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION) |
---|
8818 | 10412 | { |
---|
8819 | | - //System.out.println("drawMode = " + drawMode); |
---|
| 10413 | + //System.out.println("DrawMode() = " + DrawMode()); |
---|
8820 | 10414 | vertexMode |= VP_PASS; |
---|
8821 | 10415 | //vertexMode |= VP_PROJECTION; |
---|
8822 | 10416 | if (!ambientOcclusion) |
---|
.. | .. |
---|
8876 | 10470 | Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera; |
---|
8877 | 10471 | //Camera lightcam = new Camera(light0); |
---|
8878 | 10472 | |
---|
8879 | | - if (drawMode == SHADOW) |
---|
| 10473 | + if (DrawMode() == SHADOW) |
---|
8880 | 10474 | { |
---|
8881 | 10475 | /* |
---|
8882 | 10476 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
.. | .. |
---|
8915 | 10509 | // if (parentcam != renderCamera) // not a light |
---|
8916 | 10510 | if (cam != lightCamera) |
---|
8917 | 10511 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8918 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 10512 | + LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
8919 | 10513 | |
---|
8920 | 10514 | for (int j = 0; j < 4; j++) |
---|
8921 | 10515 | { |
---|
.. | .. |
---|
8930 | 10524 | // if (parentcam != renderCamera) // not a light |
---|
8931 | 10525 | if (cam != lightCamera) |
---|
8932 | 10526 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8933 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 10527 | + LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
8934 | 10528 | |
---|
8935 | 10529 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
8936 | 10530 | |
---|
.. | .. |
---|
8966 | 10560 | gl.glClear(gl.GL_DEPTH_BUFFER_BIT); |
---|
8967 | 10561 | } else |
---|
8968 | 10562 | { |
---|
8969 | | - if (drawMode != DEFAULT) |
---|
| 10563 | + if (DrawMode() != DEFAULT) |
---|
8970 | 10564 | { |
---|
8971 | 10565 | gl.glClearColor(1, 1, 1, 0); |
---|
8972 | 10566 | } // 1); |
---|
.. | .. |
---|
9031 | 10625 | |
---|
9032 | 10626 | fast &= !ambientOcclusion; |
---|
9033 | 10627 | |
---|
9034 | | - if (drawMode == DEFAULT) |
---|
| 10628 | + if (DrawMode() == DEFAULT) |
---|
9035 | 10629 | { |
---|
9036 | 10630 | //gl.glEnable(gl.GL_ALPHA_TEST); |
---|
9037 | 10631 | //gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
.. | .. |
---|
9092 | 10686 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
9093 | 10687 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9094 | 10688 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 10689 | +// PATCH FILLE AUX JEANS |
---|
| 10690 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9095 | 10691 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9096 | 10692 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9097 | 10693 | |
---|
.. | .. |
---|
9227 | 10823 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
9228 | 10824 | gl.glLoadIdentity(); |
---|
9229 | 10825 | |
---|
9230 | | - if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
| 10826 | + if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
9231 | 10827 | { |
---|
9232 | 10828 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9233 | 10829 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 10830 | +// PATCH FILLE AUX JEANS |
---|
| 10831 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9234 | 10832 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9235 | 10833 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9236 | 10834 | //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE); |
---|
.. | .. |
---|
9283 | 10881 | //gl.glPushMatrix(); |
---|
9284 | 10882 | gl.glLoadIdentity(); |
---|
9285 | 10883 | |
---|
9286 | | - if (!ambientOcclusion) // drawMode != OCCLUSION) |
---|
| 10884 | + if (!ambientOcclusion) // DrawMode() != OCCLUSION) |
---|
9287 | 10885 | { |
---|
9288 | 10886 | //LA.xformPos(light0, lightCamera.fromScreen, light); |
---|
9289 | 10887 | LA.xformDir(dirlight, lightCamera.fromScreen, lightposition); |
---|
.. | .. |
---|
9370 | 10968 | } |
---|
9371 | 10969 | |
---|
9372 | 10970 | /**/ |
---|
9373 | | - if (true) // drawMode == SELECTION) // != DEFAULT) |
---|
| 10971 | + if (true) // DrawMode() == SELECTION) // != DEFAULT) |
---|
9374 | 10972 | gl.glDisable(gl.GL_LIGHTING); |
---|
9375 | 10973 | else |
---|
9376 | 10974 | gl.glEnable(gl.GL_LIGHTING); |
---|
.. | .. |
---|
9388 | 10986 | |
---|
9389 | 10987 | lightslot = 64; |
---|
9390 | 10988 | |
---|
9391 | | - if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT) |
---|
| 10989 | + if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT) |
---|
9392 | 10990 | { |
---|
9393 | 10991 | DrawLights(object); |
---|
9394 | 10992 | } |
---|
.. | .. |
---|
9399 | 10997 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
9400 | 10998 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
9401 | 10999 | |
---|
9402 | | - if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION) |
---|
| 11000 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
9403 | 11001 | { |
---|
9404 | 11002 | /* |
---|
9405 | 11003 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
9432 | 11030 | } |
---|
9433 | 11031 | } |
---|
9434 | 11032 | |
---|
9435 | | - if (drawMode == DEFAULT) |
---|
| 11033 | + if (DrawMode() == DEFAULT) |
---|
9436 | 11034 | { |
---|
9437 | 11035 | if (WIREFRAME && !ambientOcclusion) |
---|
9438 | 11036 | { |
---|
.. | .. |
---|
9450 | 11048 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9451 | 11049 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9452 | 11050 | |
---|
9453 | | - if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) // |
---|
| 11051 | + if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) // |
---|
9454 | 11052 | { |
---|
9455 | 11053 | if (vertexMode != 0) // && !fast) |
---|
9456 | 11054 | { |
---|
.. | .. |
---|
9470 | 11068 | } |
---|
9471 | 11069 | } |
---|
9472 | 11070 | |
---|
9473 | | - if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion) |
---|
| 11071 | + if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
9474 | 11072 | { |
---|
9475 | 11073 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
9476 | 11074 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
9498 | 11096 | //gl.glDepthMask(false); |
---|
9499 | 11097 | } |
---|
9500 | 11098 | |
---|
9501 | | - if (false) // drawMode == SHADOW) |
---|
| 11099 | + if (false) // DrawMode() == SHADOW) |
---|
9502 | 11100 | { |
---|
9503 | 11101 | //SetColumnMajorData(cameraInverseTransform, view_1); |
---|
9504 | 11102 | //System.out.println("light = " + cameraInverseTransform); |
---|
.. | .. |
---|
9512 | 11110 | //System.out.println("object = " + object); |
---|
9513 | 11111 | if (!frozen && !imageLocked) |
---|
9514 | 11112 | { |
---|
9515 | | - if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0) |
---|
| 11113 | + if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0) |
---|
9516 | 11114 | { |
---|
9517 | 11115 | displayAntiAliased(gl); |
---|
9518 | 11116 | } else |
---|
9519 | 11117 | { |
---|
9520 | 11118 | programcount = 0; |
---|
9521 | | - int keepmode = drawMode; |
---|
| 11119 | + int keepmode = DrawMode(); |
---|
9522 | 11120 | // if (DEBUG_SELECTION) |
---|
9523 | 11121 | // { |
---|
9524 | | -// drawMode = SELECTION; |
---|
| 11122 | +// DrawMode() = SELECTION; |
---|
9525 | 11123 | // } |
---|
9526 | 11124 | // for point selection |
---|
9527 | 11125 | // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0); |
---|
.. | .. |
---|
9531 | 11129 | DrawObject(gl); |
---|
9532 | 11130 | |
---|
9533 | 11131 | // jan 2013 System.err.println("RESET ABORT (display)"); |
---|
9534 | | - // if (drawMode == DEFAULT) |
---|
| 11132 | + // if (DrawMode() == DEFAULT) |
---|
9535 | 11133 | // ABORTED = false; |
---|
9536 | 11134 | fullreset = false; |
---|
9537 | | - drawMode = keepmode; |
---|
| 11135 | + Globals.drawMode = keepmode; // WARNING |
---|
9538 | 11136 | //System.out.println("PROGRAM SWITCH " + programcount); |
---|
9539 | 11137 | } |
---|
9540 | 11138 | } |
---|
.. | .. |
---|
9542 | 11140 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9543 | 11141 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9544 | 11142 | |
---|
9545 | | - if (drawMode == DEFAULT) |
---|
| 11143 | + if (DrawMode() == DEFAULT) |
---|
9546 | 11144 | { |
---|
9547 | 11145 | ReleaseTexture(NOISE_TEXTURE, false); |
---|
9548 | 11146 | } |
---|
9549 | | - //if (drawMode == DEFAULT) |
---|
| 11147 | + //if (DrawMode() == DEFAULT) |
---|
9550 | 11148 | { |
---|
9551 | 11149 | |
---|
9552 | 11150 | gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
.. | .. |
---|
9558 | 11156 | //else |
---|
9559 | 11157 | //gl.glDisable(gl.GL_TEXTURE_2D); |
---|
9560 | 11158 | //gl.glPopMatrix(); |
---|
9561 | | - if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
| 11159 | + if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
9562 | 11160 | { |
---|
9563 | 11161 | //new Exception().printStackTrace(); |
---|
9564 | 11162 | //System.out.println("Draw image " + width + ", " + height); |
---|
.. | .. |
---|
9600 | 11198 | //gl.glFlush(); |
---|
9601 | 11199 | } |
---|
9602 | 11200 | |
---|
9603 | | - if (flash && drawMode == DEFAULT) |
---|
| 11201 | + if (flash && DrawMode() == DEFAULT) |
---|
9604 | 11202 | { |
---|
9605 | 11203 | flash = false; |
---|
9606 | 11204 | wait = true; |
---|
.. | .. |
---|
9608 | 11206 | } |
---|
9609 | 11207 | |
---|
9610 | 11208 | //drawing = false; |
---|
9611 | | - //if(drawMode == DEFAULT) |
---|
| 11209 | + //if(DrawMode() == DEFAULT) |
---|
9612 | 11210 | // niceon = false; |
---|
9613 | | - if (drawMode == DEFAULT) |
---|
| 11211 | + if (DrawMode() == DEFAULT) |
---|
9614 | 11212 | { |
---|
9615 | 11213 | currentlydrawing = false; |
---|
9616 | 11214 | } |
---|
.. | .. |
---|
9630 | 11228 | repaint(); |
---|
9631 | 11229 | } |
---|
9632 | 11230 | |
---|
9633 | | - if (isLIVE() && drawMode == DEFAULT) // may 2013 |
---|
| 11231 | + if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 |
---|
9634 | 11232 | repaint(); |
---|
9635 | 11233 | |
---|
9636 | 11234 | displaydone = true; |
---|
.. | .. |
---|
9667 | 11265 | if (GrafreeD.RENDERME > 0) |
---|
9668 | 11266 | GrafreeD.RENDERME--; // mechante magouille |
---|
9669 | 11267 | |
---|
9670 | | - ONESTEP = false; |
---|
| 11268 | + Globals.ONESTEP = false; |
---|
9671 | 11269 | } |
---|
9672 | 11270 | |
---|
9673 | 11271 | static boolean zoomonce = false; |
---|
.. | .. |
---|
9675 | 11273 | void DrawObject(GL gl, boolean draw) |
---|
9676 | 11274 | { |
---|
9677 | 11275 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
9678 | | -// drawMode = SELECTION; |
---|
| 11276 | +// DrawMode() = SELECTION; |
---|
9679 | 11277 | //GL gl = getGL(); |
---|
9680 | 11278 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
9681 | 11279 | { |
---|
9682 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 11280 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
9683 | 11281 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
9684 | 11282 | pingthread.StepToTarget(true); // true); |
---|
9685 | 11283 | // zoomonce = false; |
---|
.. | .. |
---|
9700 | 11298 | callist = gl.glGenLists(1); |
---|
9701 | 11299 | } |
---|
9702 | 11300 | |
---|
9703 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11301 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
9704 | 11302 | |
---|
9705 | | - boolean active = !selectmode; // drawMode != SELECTION; // mouseDown; |
---|
| 11303 | + boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
9706 | 11304 | |
---|
9707 | 11305 | if (!mainDL || !active || touched) |
---|
9708 | 11306 | { |
---|
.. | .. |
---|
9729 | 11327 | PushMatrix(ClickInfo.matbuffer); |
---|
9730 | 11328 | } |
---|
9731 | 11329 | |
---|
9732 | | - if (drawMode == 0) |
---|
| 11330 | + if (DrawMode() == 0) |
---|
9733 | 11331 | { |
---|
9734 | 11332 | // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++"); |
---|
9735 | 11333 | |
---|
.. | .. |
---|
9743 | 11341 | // DRAW |
---|
9744 | 11342 | object.draw(this, /*(Composite)*/ object, false, false); |
---|
9745 | 11343 | |
---|
9746 | | - if (drawMode == DEFAULT) |
---|
| 11344 | + if (DrawMode() == DEFAULT) |
---|
9747 | 11345 | { |
---|
9748 | 11346 | if (DEBUG) |
---|
9749 | 11347 | { |
---|
.. | .. |
---|
9754 | 11352 | selectedpoint.radius = radius; |
---|
9755 | 11353 | selectedpoint.recalculate(); |
---|
9756 | 11354 | selectedpoint.material = new cMaterial(); |
---|
9757 | | - selectedpoint.material.color = 0.25f; |
---|
| 11355 | + selectedpoint.material.color = 0.15f; // Yellow |
---|
9758 | 11356 | selectedpoint.material.modulation = 0.75f; |
---|
9759 | 11357 | |
---|
9760 | | - debugpoint.radius = radius; |
---|
9761 | | - debugpoint.recalculate(); |
---|
9762 | | - debugpoint.material = new cMaterial(); |
---|
9763 | | - debugpoint.material.color = 0.25f; |
---|
9764 | | - debugpoint.material.modulation = 0.75f; |
---|
| 11358 | + debugpointG.radius = radius; |
---|
| 11359 | + debugpointG.recalculate(); |
---|
| 11360 | + debugpointG.material = new cMaterial(); |
---|
| 11361 | + debugpointG.material.color = 0.25f; // Green |
---|
| 11362 | + debugpointG.material.modulation = 0.75f; |
---|
9765 | 11363 | |
---|
9766 | | - debugpoint2.radius = radius; |
---|
9767 | | - debugpoint2.recalculate(); |
---|
9768 | | - debugpoint2.material = new cMaterial(); |
---|
9769 | | - debugpoint2.material.color = 0.75f; |
---|
9770 | | - debugpoint2.material.modulation = 0.75f; |
---|
| 11364 | + debugpointP.radius = radius; |
---|
| 11365 | + debugpointP.recalculate(); |
---|
| 11366 | + debugpointP.material = new cMaterial(); |
---|
| 11367 | + debugpointP.material.color = 0.75f; // Purple |
---|
| 11368 | + debugpointP.material.modulation = 0.75f; |
---|
9771 | 11369 | |
---|
9772 | | - debugpoint3.radius = radius; |
---|
9773 | | - debugpoint3.recalculate(); |
---|
9774 | | - debugpoint3.material = new cMaterial(); |
---|
9775 | | - debugpoint3.material.color = 0.5f; |
---|
9776 | | - debugpoint3.material.modulation = 0.75f; |
---|
| 11370 | + debugpointC.radius = radius; |
---|
| 11371 | + debugpointC.recalculate(); |
---|
| 11372 | + debugpointC.material = new cMaterial(); |
---|
| 11373 | + debugpointC.material.color = 0.5f; // Cyan |
---|
| 11374 | + debugpointC.material.modulation = 0.75f; |
---|
9777 | 11375 | |
---|
9778 | | - debugpoint4.radius = radius; |
---|
9779 | | - debugpoint4.recalculate(); |
---|
9780 | | - debugpoint4.material = new cMaterial(); |
---|
9781 | | - debugpoint4.material.color = 0f; |
---|
9782 | | - debugpoint4.material.modulation = 0.75f; |
---|
| 11376 | + debugpointR.radius = radius; |
---|
| 11377 | + debugpointR.recalculate(); |
---|
| 11378 | + debugpointR.material = new cMaterial(); |
---|
| 11379 | + debugpointR.material.color = 0f; // Red |
---|
| 11380 | + debugpointR.material.modulation = 0.75f; |
---|
9783 | 11381 | |
---|
9784 | 11382 | InitPoints(radius); |
---|
9785 | 11383 | } |
---|
9786 | 11384 | selectedpoint.draw(this, /*(Composite)*/ null, false, false); |
---|
9787 | | - debugpoint.draw(this, /*(Composite)*/ null, false,false); |
---|
9788 | | - debugpoint2.draw(this, /*(Composite)*/ null, false,false); |
---|
9789 | | - debugpoint3.draw(this, /*(Composite)*/ null, false,false); |
---|
9790 | | - debugpoint4.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11385 | + debugpointG.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11386 | + debugpointP.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11387 | + debugpointC.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11388 | + debugpointR.draw(this, /*(Composite)*/ null, false,false); |
---|
9791 | 11389 | // DrawPoints(this); |
---|
9792 | 11390 | } |
---|
9793 | 11391 | |
---|
.. | .. |
---|
9795 | 11393 | } |
---|
9796 | 11394 | // GrafreeD.traceoff(); |
---|
9797 | 11395 | //System.out.println(stackdepth); |
---|
9798 | | - if (drawMode == 0) |
---|
| 11396 | + if (DrawMode() == 0) |
---|
9799 | 11397 | { |
---|
9800 | 11398 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
9801 | 11399 | |
---|
.. | .. |
---|
9820 | 11418 | |
---|
9821 | 11419 | checker = null; |
---|
9822 | 11420 | |
---|
9823 | | - if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT) |
---|
| 11421 | + if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT) |
---|
9824 | 11422 | FindChecker(object); |
---|
9825 | 11423 | |
---|
9826 | | - if (checker != null && drawMode == DEFAULT) |
---|
| 11424 | + if (checker != null && DrawMode() == DEFAULT) |
---|
9827 | 11425 | { |
---|
9828 | | - // BindTexture(IMMORTAL_TEXTURE); |
---|
| 11426 | + //BindTexture(IMMORTAL_TEXTURE); |
---|
| 11427 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
9829 | 11428 | // NEAREST |
---|
9830 | 11429 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
9831 | 11430 | DrawChecker(gl); |
---|
9832 | 11431 | //checker.Draw(this, null, false); |
---|
9833 | 11432 | // ReleaseTexture(IMMORTAL_TEXTURE); |
---|
| 11433 | + ReleaseTextures(checker.GetTextures()); |
---|
9834 | 11434 | } |
---|
9835 | 11435 | |
---|
9836 | 11436 | if (object.parent != null) |
---|
.. | .. |
---|
9843 | 11443 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9844 | 11444 | //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9845 | 11445 | |
---|
9846 | | - if (DISPLAYTEXT && drawMode == DEFAULT) |
---|
| 11446 | + if (DISPLAYTEXT && DrawMode() == DEFAULT) |
---|
9847 | 11447 | { |
---|
9848 | 11448 | // Draw it once, then use the raster |
---|
9849 | 11449 | Balloon(gl, balloon.createGraphics()); |
---|
.. | .. |
---|
9899 | 11499 | int[] xs = new int[3]; |
---|
9900 | 11500 | int[] ys = new int[3]; |
---|
9901 | 11501 | |
---|
9902 | | - void DrawString(Object3D obj) // String string) |
---|
| 11502 | + public void DrawString(Object3D obj) // String string) // INTERFACE |
---|
9903 | 11503 | { |
---|
9904 | | - if (!DISPLAYTEXT || drawMode != DEFAULT) |
---|
| 11504 | + if (!DISPLAYTEXT || DrawMode() != DEFAULT) |
---|
9905 | 11505 | { |
---|
9906 | 11506 | return; |
---|
9907 | 11507 | } |
---|
.. | .. |
---|
10388 | 11988 | "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" + |
---|
10389 | 11989 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
10390 | 11990 | "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" + |
---|
| 11991 | + "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" + |
---|
10391 | 11992 | "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" + |
---|
10392 | 11993 | "PARAM c256 = { 256, 256, 256, 1.0 };" + |
---|
10393 | 11994 | "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" + |
---|
.. | .. |
---|
11302 | 12903 | String Shadow(String depth, String shadow) |
---|
11303 | 12904 | { |
---|
11304 | 12905 | return "MAX temp.x, ndotl.x, one64th.x;" + |
---|
| 12906 | + "MIN temp.x, temp.x, ninetenth.x;" + |
---|
11305 | 12907 | /**/ |
---|
11306 | 12908 | // Sine |
---|
11307 | 12909 | "MUL temp.y, temp.x, temp.x;" + |
---|
.. | .. |
---|
11926 | 13528 | return; |
---|
11927 | 13529 | } |
---|
11928 | 13530 | |
---|
| 13531 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
11929 | 13532 | |
---|
11930 | 13533 | // TIMER |
---|
11931 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR |
---|
| 13534 | + if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
11932 | 13535 | { |
---|
11933 | 13536 | keepboxmode = BOXMODE; |
---|
11934 | 13537 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
12057 | 13660 | // ObjEditor.tweenManager.update(1f / 60f); |
---|
12058 | 13661 | |
---|
12059 | 13662 | // fev 2014??? |
---|
12060 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode) |
---|
| 13663 | + if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
12061 | 13664 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
12062 | 13665 | pingthread.StepToTarget(true); // true); |
---|
12063 | 13666 | } |
---|
.. | .. |
---|
12169 | 13772 | cVector tmp = new cVector(); |
---|
12170 | 13773 | cVector tmp2 = new cVector(); |
---|
12171 | 13774 | boolean isMoving; |
---|
| 13775 | + |
---|
| 13776 | + public cVector TargetLookAt() |
---|
| 13777 | + { |
---|
| 13778 | + return targetLookAt; |
---|
| 13779 | + } |
---|
12172 | 13780 | |
---|
12173 | 13781 | class PingThread extends Thread |
---|
12174 | 13782 | { |
---|
.. | .. |
---|
12308 | 13916 | //System.out.println("---------------- ---------- Paint " + tmp.length2()); |
---|
12309 | 13917 | if (lightMode) |
---|
12310 | 13918 | { |
---|
12311 | | - lighttouched = true; |
---|
| 13919 | + Globals.lighttouched = true; |
---|
12312 | 13920 | } |
---|
12313 | 13921 | |
---|
12314 | 13922 | if (OEILONCE && OEIL) |
---|
.. | .. |
---|
12366 | 13974 | mouseDown = false; |
---|
12367 | 13975 | if (lightMode) |
---|
12368 | 13976 | { |
---|
12369 | | - lighttouched = true; |
---|
| 13977 | + Globals.lighttouched = true; |
---|
12370 | 13978 | } |
---|
12371 | 13979 | repaint(); |
---|
12372 | 13980 | alreadypainted = true; |
---|
.. | .. |
---|
12374 | 13982 | isMoving = false; |
---|
12375 | 13983 | } //?? |
---|
12376 | 13984 | |
---|
12377 | | - if (isLIVE() && !alreadypainted) |
---|
| 13985 | + if (Globals.isLIVE() && !alreadypainted) |
---|
12378 | 13986 | { |
---|
12379 | 13987 | // FOR DEBUG BREAKPOINT USING PAUSE: while (true) |
---|
12380 | 13988 | repaint(); |
---|
.. | .. |
---|
12386 | 13994 | { |
---|
12387 | 13995 | if (lightMode) |
---|
12388 | 13996 | { |
---|
12389 | | - lighttouched = true; |
---|
| 13997 | + Globals.lighttouched = true; |
---|
12390 | 13998 | } |
---|
12391 | 13999 | drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
12392 | 14000 | } |
---|
.. | .. |
---|
12629 | 14237 | { |
---|
12630 | 14238 | manipCamera.Translate(dx, dy, getWidth()); |
---|
12631 | 14239 | } |
---|
| 14240 | + else |
---|
12632 | 14241 | if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0) |
---|
12633 | 14242 | { |
---|
12634 | 14243 | manipCamera.RotateInterest(dx, dy); |
---|
.. | .. |
---|
12639 | 14248 | |
---|
12640 | 14249 | if (manipCamera == lightCamera) |
---|
12641 | 14250 | { |
---|
12642 | | - lighttouched = true; |
---|
| 14251 | + Globals.lighttouched = true; |
---|
12643 | 14252 | } |
---|
12644 | 14253 | /* |
---|
12645 | 14254 | switch (mode) |
---|
.. | .. |
---|
12854 | 14463 | { |
---|
12855 | 14464 | mouseMode |= ZOOM; |
---|
12856 | 14465 | } |
---|
12857 | | - if ((modifiers & META) == META) |
---|
| 14466 | + |
---|
| 14467 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
| 14468 | + if (capsLocked || (modifiers & META) == META) |
---|
12858 | 14469 | { |
---|
12859 | 14470 | mouseMode |= VR; // BACKFORTH; |
---|
12860 | 14471 | } |
---|
12861 | 14472 | if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
12862 | 14473 | { |
---|
12863 | | - mouseMode |= SELECT; // BACKFORTH; |
---|
| 14474 | + mouseMode |= SELECT; |
---|
12864 | 14475 | } |
---|
12865 | 14476 | if ((modifiers & COMMAND) == COMMAND) |
---|
12866 | 14477 | { |
---|
.. | .. |
---|
12868 | 14479 | } |
---|
12869 | 14480 | if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
12870 | 14481 | { |
---|
| 14482 | + mouseMode &= ~VR; |
---|
12871 | 14483 | mouseMode |= TRANSLATE; |
---|
12872 | 14484 | } |
---|
12873 | 14485 | // if ((modifiers & SHIFT_META) == SHIFT_META) |
---|
.. | .. |
---|
12897 | 14509 | SetMouseMode(modifiers); |
---|
12898 | 14510 | } |
---|
12899 | 14511 | |
---|
12900 | | - theRenderer.keyPressed(key); |
---|
| 14512 | + Globals.theRenderer.keyPressed(key); |
---|
12901 | 14513 | } |
---|
12902 | 14514 | |
---|
12903 | 14515 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
12909 | 14521 | float SATPOW = 1; // 2; // 0.5f; |
---|
12910 | 14522 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
12911 | 14523 | |
---|
12912 | | - void keyPressed(int key) |
---|
| 14524 | + public void keyPressed(int key) |
---|
12913 | 14525 | { |
---|
12914 | 14526 | if (key >= '0' && key <= '5') |
---|
12915 | 14527 | clampbit = (key-'0'); |
---|
.. | .. |
---|
13024 | 14636 | case 'B': |
---|
13025 | 14637 | BRISMOOTH ^= true; |
---|
13026 | 14638 | SHADOWCULLFACE ^= true; |
---|
13027 | | - lighttouched = true; |
---|
| 14639 | + Globals.lighttouched = true; |
---|
13028 | 14640 | repaint(); |
---|
13029 | 14641 | break; |
---|
13030 | 14642 | case 'b': |
---|
.. | .. |
---|
13124 | 14736 | repaint(); |
---|
13125 | 14737 | break; |
---|
13126 | 14738 | case 'O': |
---|
13127 | | - drawMode = OCCLUSION; |
---|
| 14739 | + Globals.drawMode = OCCLUSION; // WARNING |
---|
13128 | 14740 | repaint(); |
---|
13129 | 14741 | break; |
---|
13130 | 14742 | case 'o': |
---|
.. | .. |
---|
13215 | 14827 | break; |
---|
13216 | 14828 | case ' ': |
---|
13217 | 14829 | lightMode ^= true; |
---|
13218 | | - lighttouched = true; |
---|
| 14830 | + Globals.lighttouched = true; |
---|
13219 | 14831 | manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
13220 | 14832 | targetLookAt.set(manipCamera.lookAt); |
---|
13221 | 14833 | repaint(); |
---|
.. | .. |
---|
13227 | 14839 | repaint(); |
---|
13228 | 14840 | break; |
---|
13229 | 14841 | case 'Z': |
---|
13230 | | - RESIZETEXTURE ^= true; |
---|
13231 | | - break; |
---|
| 14842 | + //RESIZETEXTURE ^= true; |
---|
| 14843 | + //break; |
---|
13232 | 14844 | case 'z': |
---|
13233 | 14845 | RENDERSHADOW ^= true; |
---|
13234 | | - lighttouched = true; |
---|
| 14846 | + Globals.lighttouched = true; |
---|
13235 | 14847 | repaint(); |
---|
13236 | 14848 | break; |
---|
13237 | 14849 | //case UP: |
---|
.. | .. |
---|
13346 | 14958 | } |
---|
13347 | 14959 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
13348 | 14960 | } |
---|
| 14961 | + |
---|
13349 | 14962 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
13350 | 14963 | |
---|
13351 | 14964 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
13357 | 14970 | } |
---|
13358 | 14971 | } |
---|
13359 | 14972 | |
---|
13360 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 14973 | + public void processKeyEvent(KeyEvent e) |
---|
13361 | 14974 | { |
---|
13362 | 14975 | switch (e.getID()) |
---|
13363 | 14976 | { |
---|
.. | .. |
---|
13833 | 15446 | //if (g != gr) g.drawImage(img, 0, 0, width, height, null); |
---|
13834 | 15447 | } |
---|
13835 | 15448 | |
---|
| 15449 | + // To avoid clear. |
---|
13836 | 15450 | public void update(Graphics g) |
---|
13837 | 15451 | { |
---|
13838 | 15452 | paint(g); |
---|
.. | .. |
---|
14435 | 16049 | gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS); |
---|
14436 | 16050 | gl.glPushMatrix(); |
---|
14437 | 16051 | gl.glLoadIdentity(); |
---|
14438 | | - PushMatrix(checker.toParent); |
---|
| 16052 | + //PushMatrix(checker.toParent); |
---|
14439 | 16053 | |
---|
14440 | 16054 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
14441 | 16055 | gl.glPushMatrix(); |
---|
.. | .. |
---|
14458 | 16072 | |
---|
14459 | 16073 | gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
14460 | 16074 | |
---|
14461 | | - float step = 0.1666f; //0.25f; |
---|
14462 | | - float stepv = step * 1652 / 998; |
---|
| 16075 | + float step = 2; // 0.1666f; //0.25f; |
---|
| 16076 | + float stepv = 2; // step * 1652 / 998; |
---|
14463 | 16077 | |
---|
14464 | 16078 | int i0 = 0; |
---|
14465 | 16079 | /* |
---|
.. | .. |
---|
14495 | 16109 | /**/ |
---|
14496 | 16110 | //checker.GetMaterial().opacity = 1.1f; |
---|
14497 | 16111 | ////checker.GetMaterial().ambient = 0.99f; |
---|
14498 | | - Object3D.materialstack[Object3D.materialdepth] = checker.material; |
---|
14499 | | - Object3D.selectedstack[Object3D.materialdepth] = false; |
---|
14500 | | - cStatic.objectstack[Object3D.materialdepth++] = checker; |
---|
| 16112 | + materialstack[materialdepth] = checker.material; |
---|
| 16113 | + selectedstack[materialdepth] = false; |
---|
| 16114 | + cStatic.objectstack[materialdepth++] = checker; |
---|
14501 | 16115 | //System.out.println("material " + material); |
---|
14502 | 16116 | //Applet3D.tracein(this, selected); |
---|
14503 | 16117 | vector2buffer = checker.projectedVertices; |
---|
14504 | 16118 | |
---|
14505 | | - checker.GetMaterial().Draw(this, false); // true); |
---|
| 16119 | + //checker.GetMaterial().Draw(this, false); // true); |
---|
| 16120 | + DrawMaterial(checker.GetMaterial(), false); // true); |
---|
14506 | 16121 | |
---|
14507 | | - Object3D.materialdepth -= 1; |
---|
14508 | | - if (Object3D.materialdepth > 0) |
---|
| 16122 | + materialdepth -= 1; |
---|
| 16123 | + if (materialdepth > 0) |
---|
14509 | 16124 | { |
---|
14510 | | - vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices; |
---|
14511 | | - Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]); |
---|
| 16125 | + vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16126 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
14512 | 16127 | } |
---|
14513 | 16128 | //checker.GetMaterial().opacity = 1f; |
---|
14514 | 16129 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
14529 | 16144 | |
---|
14530 | 16145 | //float u = (i+1)/2; |
---|
14531 | 16146 | //float v = (j+1)/2; |
---|
14532 | | - gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
| 16147 | + if (checker.flipV) |
---|
| 16148 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2); |
---|
| 16149 | + else |
---|
| 16150 | + gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
14533 | 16151 | gl.glVertex3f(i, j, -0.5f); |
---|
14534 | 16152 | |
---|
| 16153 | + if (checker.flipV) |
---|
| 16154 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
| 16155 | + else |
---|
14535 | 16156 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
14536 | 16157 | gl.glVertex3f(i + step, j, -0.5f); |
---|
14537 | 16158 | |
---|
| 16159 | + if (checker.flipV) |
---|
| 16160 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
| 16161 | + else |
---|
14538 | 16162 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
14539 | 16163 | gl.glVertex3f(i + step, j + stepv, -0.5f); |
---|
14540 | 16164 | |
---|
| 16165 | + if (checker.flipV) |
---|
| 16166 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
| 16167 | + else |
---|
14541 | 16168 | gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
14542 | 16169 | gl.glVertex3f(i, j + stepv, -0.5f); |
---|
14543 | 16170 | } |
---|
.. | .. |
---|
14549 | 16176 | gl.glMatrixMode(GL.GL_PROJECTION); |
---|
14550 | 16177 | gl.glPopMatrix(); |
---|
14551 | 16178 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
14552 | | - PopMatrix(null); // checker.toParent); // null); |
---|
| 16179 | + //PopMatrix(null); // checker.toParent); // null); |
---|
14553 | 16180 | gl.glPopMatrix(); |
---|
14554 | 16181 | PopTextureMatrix(checker.toParent); |
---|
14555 | 16182 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
.. | .. |
---|
14662 | 16289 | |
---|
14663 | 16290 | //int tmp = selection_view; |
---|
14664 | 16291 | //selection_view = -1; |
---|
14665 | | - int temp = drawMode; |
---|
14666 | | - drawMode = SELECTION; |
---|
| 16292 | + int temp = DrawMode(); |
---|
| 16293 | + Globals.drawMode = SELECTION; // WARNING |
---|
14667 | 16294 | indexcount = 0; |
---|
14668 | 16295 | parent.display(drawable); |
---|
14669 | 16296 | //selection_view = tmp; |
---|
14670 | 16297 | //if (temp == SELECTION) |
---|
14671 | 16298 | // temp = DEFAULT; // patch for selection debug |
---|
14672 | | - drawMode = temp; |
---|
| 16299 | + Globals.drawMode = temp; // WARNING |
---|
14673 | 16300 | |
---|
14674 | 16301 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
14675 | 16302 | |
---|
.. | .. |
---|
14718 | 16345 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
14719 | 16346 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
14720 | 16347 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 16348 | + |
---|
| 16349 | + // Will fit the mesh !!! |
---|
| 16350 | + selectedpoint.toParent[0][0] = 0.0001; |
---|
| 16351 | + selectedpoint.toParent[1][1] = 0.0001; |
---|
| 16352 | + selectedpoint.toParent[2][2] = 0.0001; |
---|
14721 | 16353 | |
---|
14722 | 16354 | glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0); |
---|
14723 | 16355 | |
---|
.. | .. |
---|
14937 | 16569 | //gl.glColorMask(false, false, false, false); |
---|
14938 | 16570 | |
---|
14939 | 16571 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
14940 | | - if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 16572 | + if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
14941 | 16573 | { |
---|
14942 | 16574 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14943 | 16575 | |
---|
14944 | | - int temp = drawMode; |
---|
14945 | | - drawMode = SHADOW; |
---|
| 16576 | + int temp = DrawMode(); |
---|
| 16577 | + Globals.drawMode = SHADOW; // WARNING |
---|
14946 | 16578 | parent.display(drawable); |
---|
14947 | | - drawMode = temp; |
---|
| 16579 | + Globals.drawMode = temp; // WARNING |
---|
14948 | 16580 | } |
---|
14949 | 16581 | |
---|
14950 | 16582 | gl.glCullFace(gl.GL_BACK); |
---|
.. | .. |
---|
14997 | 16629 | |
---|
14998 | 16630 | class AntialiasBuffer implements GLEventListener |
---|
14999 | 16631 | { |
---|
15000 | | - |
---|
15001 | 16632 | CameraPane parent = null; |
---|
15002 | 16633 | |
---|
15003 | 16634 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
15107 | 16738 | gl.glFlush(); |
---|
15108 | 16739 | |
---|
15109 | 16740 | /**/ |
---|
15110 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer); |
---|
| 16741 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
15111 | 16742 | |
---|
15112 | | - int[] pixels = occlusionsizebuffer.array(); |
---|
| 16743 | + float[] pixels = occlusionsizebuffer.array(); |
---|
15113 | 16744 | |
---|
15114 | 16745 | double r = 0, g = 0, b = 0; |
---|
15115 | 16746 | |
---|
15116 | 16747 | double count = 0; |
---|
| 16748 | + |
---|
| 16749 | + gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0); |
---|
| 16750 | + |
---|
| 16751 | + float mindepth = 1; |
---|
| 16752 | + |
---|
| 16753 | + double FACTOR = 1; |
---|
15117 | 16754 | |
---|
15118 | 16755 | for (int i = 0; i < pixels.length; i++) |
---|
15119 | 16756 | { |
---|
.. | .. |
---|
15198 | 16835 | |
---|
15199 | 16836 | double scale = ray.z; // 1; // cos |
---|
15200 | 16837 | |
---|
15201 | | - int p = pixels[newindex]; |
---|
| 16838 | + float depth = pixels[newindex]; |
---|
15202 | 16839 | |
---|
15203 | 16840 | /* |
---|
15204 | 16841 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
15222 | 16859 | scale = (1 - modu) * modv; |
---|
15223 | 16860 | */ |
---|
15224 | 16861 | |
---|
15225 | | - r += ((p >> 16) & 0xFF) * scale / 255; |
---|
15226 | | - g += ((p >> 8) & 0xFF) * scale / 255; |
---|
15227 | | - b += (p & 0xFF) * scale / 255; |
---|
| 16862 | + //r += ((p >> 16) & 0xFF) * scale / 255; |
---|
| 16863 | + //g += ((p >> 8) & 0xFF) * scale / 255; |
---|
| 16864 | + //b += (p & 0xFF) * scale / 255; |
---|
| 16865 | + |
---|
| 16866 | + if (mindepth > depth) |
---|
| 16867 | + { |
---|
| 16868 | + mindepth = depth; |
---|
| 16869 | + } |
---|
15228 | 16870 | |
---|
| 16871 | + double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]); |
---|
| 16872 | + |
---|
| 16873 | + double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR); |
---|
| 16874 | + |
---|
| 16875 | + r += factor * scale; |
---|
| 16876 | + g += factor * scale; |
---|
| 16877 | + b += factor * scale; |
---|
| 16878 | + |
---|
15229 | 16879 | count += scale; |
---|
15230 | 16880 | } |
---|
15231 | 16881 | |
---|
.. | .. |
---|
15323 | 16973 | GLUT glut = new GLUT(); |
---|
15324 | 16974 | |
---|
15325 | 16975 | |
---|
15326 | | - static final public int DEFAULT = 0; |
---|
15327 | | - static final public int SELECTION = 1; |
---|
15328 | | - static final public int SHADOW = 2; |
---|
15329 | | - static final public int OCCLUSION = 3; |
---|
15330 | | - static |
---|
15331 | | - public int drawMode = DEFAULT; |
---|
15332 | 16976 | public boolean spherical = false; |
---|
15333 | 16977 | static boolean DEBUG_OCCLUSION = false; |
---|
15334 | 16978 | static boolean DEBUG_SELECTION = false; |
---|
.. | .. |
---|
15341 | 16985 | int AAbuffersize = 0; |
---|
15342 | 16986 | |
---|
15343 | 16987 | //double[] selectedpoint = new double[3]; |
---|
15344 | | - static Sphere selectedpoint = new Sphere(); |
---|
| 16988 | + static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
15345 | 16989 | static Sphere previousselectedpoint = null; |
---|
15346 | | - static Sphere debugpoint = new Sphere(); |
---|
15347 | | - static Sphere debugpoint2 = new Sphere(); |
---|
15348 | | - static Sphere debugpoint3 = new Sphere(); |
---|
15349 | | - static Sphere debugpoint4 = new Sphere(); |
---|
| 16990 | + static Sphere debugpointG = new Sphere(); |
---|
| 16991 | + static Sphere debugpointP = new Sphere(); |
---|
| 16992 | + static Sphere debugpointC = new Sphere(); |
---|
| 16993 | + static Sphere debugpointR = new Sphere(); |
---|
15350 | 16994 | |
---|
15351 | 16995 | static Sphere debugpoints[] = new Sphere[8]; |
---|
15352 | 16996 | |
---|
.. | .. |
---|
15377 | 17021 | } |
---|
15378 | 17022 | } |
---|
15379 | 17023 | |
---|
15380 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17024 | + static void DrawPoints(iCameraPane cpane) |
---|
15381 | 17025 | { |
---|
15382 | 17026 | for (int i=0; i<8; i++) // first and last are red |
---|
15383 | 17027 | { |
---|
.. | .. |
---|
15399 | 17043 | static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
15400 | 17044 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15401 | 17045 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15402 | | - static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17046 | + //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17047 | + static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
15403 | 17048 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
15404 | 17049 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
15405 | 17050 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|
.. | .. |
---|
15408 | 17053 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
15409 | 17054 | // Depth buffer format |
---|
15410 | 17055 | //private int depth_format; |
---|
15411 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17056 | + |
---|
| 17057 | + public void NextIndex() |
---|
15412 | 17058 | { |
---|
15413 | 17059 | indexcount+=16; |
---|
15414 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17060 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
15415 | 17061 | //objects[indexcount] = o; |
---|
15416 | 17062 | //System.out.println("indexcount = " + indexcount); |
---|
15417 | 17063 | } |
---|