.. | .. |
---|
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; |
---|
.. | .. |
---|
173 | 157 | theRenderer = this; |
---|
174 | 158 | } |
---|
175 | 159 | |
---|
| 160 | + CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
| 161 | + { |
---|
| 162 | + super(defaultcaps, null, withcontext?glcontext:null, null); |
---|
| 163 | + |
---|
| 164 | + //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523)); |
---|
| 165 | + glcontext = getContext(); |
---|
| 166 | + |
---|
| 167 | + cameras = new Camera[2]; |
---|
| 168 | + targetLookAts = new cVector[2]; |
---|
| 169 | + |
---|
| 170 | + SetCamera(cam); |
---|
| 171 | + |
---|
| 172 | + SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 173 | + |
---|
| 174 | + object = o; |
---|
| 175 | + |
---|
| 176 | + setBackground(Color.white); |
---|
| 177 | + |
---|
| 178 | + addKeyListener(this); |
---|
| 179 | + addMouseListener(this); |
---|
| 180 | + addMouseMotionListener(this); |
---|
| 181 | + addMouseWheelListener(this); |
---|
| 182 | + //System.out.println("addGLEventListener: " + this); |
---|
| 183 | + addGLEventListener(this); |
---|
| 184 | + |
---|
| 185 | +// pingthread.start(); // may 2013 |
---|
| 186 | + } |
---|
| 187 | + |
---|
176 | 188 | static boolean AntialiasingEnabled() |
---|
177 | 189 | { |
---|
178 | 190 | return CURRENTANTIALIAS > 0; |
---|
179 | 191 | } |
---|
180 | 192 | |
---|
181 | | - void ClearDepth() |
---|
| 193 | + /// INTERFACE |
---|
| 194 | + |
---|
| 195 | + public void ClearDepth() |
---|
182 | 196 | { |
---|
183 | 197 | GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT); |
---|
184 | 198 | } |
---|
185 | 199 | |
---|
186 | | - void DepthTest(boolean depthtest) |
---|
| 200 | + public void DepthTest(boolean depthtest) |
---|
187 | 201 | { |
---|
188 | 202 | if (depthtest) |
---|
189 | 203 | GetGL().glDepthFunc(GL.GL_LEQUAL); |
---|
.. | .. |
---|
191 | 205 | GetGL().glDepthFunc(GL.GL_ALWAYS); |
---|
192 | 206 | } |
---|
193 | 207 | |
---|
194 | | - void DepthWrite(boolean depthwrite) |
---|
| 208 | + public void DepthWrite(boolean depthwrite) |
---|
195 | 209 | { |
---|
196 | 210 | if (depthwrite) |
---|
197 | 211 | GetGL().glDepthMask(true); |
---|
.. | .. |
---|
199 | 213 | GetGL().glDepthMask(false); |
---|
200 | 214 | } |
---|
201 | 215 | |
---|
202 | | - void BackFaceCull(boolean bfc) |
---|
| 216 | + public void BackFaceCull(boolean bfc) |
---|
203 | 217 | { |
---|
204 | 218 | if (bfc) |
---|
205 | 219 | GetGL().glEnable(GetGL().GL_CULL_FACE); |
---|
206 | 220 | else |
---|
207 | 221 | GetGL().glDisable(GetGL().GL_CULL_FACE); |
---|
| 222 | + } |
---|
| 223 | + |
---|
| 224 | + public boolean BackFaceCullMode() |
---|
| 225 | + { |
---|
| 226 | + return this.CULLFACE; |
---|
| 227 | + } |
---|
| 228 | + |
---|
| 229 | + public boolean IsAmbientOcclusionOn() |
---|
| 230 | + { |
---|
| 231 | + return this.ambientOcclusion; |
---|
| 232 | + } |
---|
| 233 | + |
---|
| 234 | + public boolean IsFrozen() |
---|
| 235 | + { |
---|
| 236 | + boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 237 | + |
---|
| 238 | + return !selectmode && cameracount == 0; // != 0; |
---|
| 239 | + } |
---|
| 240 | + |
---|
| 241 | + // Currently in Globals |
---|
| 242 | + public int DrawMode() |
---|
| 243 | + { |
---|
| 244 | + return Globals.DrawMode(); |
---|
| 245 | + } |
---|
| 246 | + |
---|
| 247 | + public Camera EyeCamera() |
---|
| 248 | + { |
---|
| 249 | + return eyeCamera; |
---|
| 250 | + } |
---|
| 251 | + |
---|
| 252 | + public Camera LightCamera() |
---|
| 253 | + { |
---|
| 254 | + return lightCamera; |
---|
| 255 | + } |
---|
| 256 | + |
---|
| 257 | + public Camera RenderCamera() |
---|
| 258 | + { |
---|
| 259 | + return renderCamera; |
---|
| 260 | + } |
---|
| 261 | + |
---|
| 262 | + public void PushMaterial(Object3D obj, boolean selected) |
---|
| 263 | + { |
---|
| 264 | + CameraPane display = this; |
---|
| 265 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 266 | + cMaterial material = obj.material; |
---|
| 267 | + |
---|
| 268 | + if (material != null) |
---|
| 269 | + { |
---|
| 270 | + materialstack[materialdepth] = material; |
---|
| 271 | + selectedstack[materialdepth] = selected; |
---|
| 272 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 273 | + //System.out.println("material " + material); |
---|
| 274 | + //Applet3D.tracein(this, selected); |
---|
| 275 | + display.vector2buffer = obj.projectedVertices; |
---|
| 276 | + if (obj instanceof Camera) |
---|
| 277 | + { |
---|
| 278 | + display.options1[0] = material.shift; |
---|
| 279 | + //System.out.println("shift " + material.shift); |
---|
| 280 | + display.options1[1] = material.lightarea; |
---|
| 281 | + display.options1[2] = material.shadowbias; |
---|
| 282 | + display.options1[3] = material.aniso; |
---|
| 283 | + display.options1[4] = material.anisoV; |
---|
| 284 | + display.options2[0] = material.opacity; |
---|
| 285 | + display.options2[1] = material.diffuse; |
---|
| 286 | + display.options2[2] = material.factor; |
---|
| 287 | + |
---|
| 288 | + cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 289 | + display.options4[0] = material.cameralight/0.2f; |
---|
| 290 | + display.options4[1] = material.subsurface; |
---|
| 291 | + display.options4[2] = material.sheen; |
---|
| 292 | + |
---|
| 293 | + // if (display.CURRENTANTIALIAS > 0) |
---|
| 294 | + // display.options3[3] /= 4; |
---|
| 295 | + |
---|
| 296 | + /* |
---|
| 297 | + System.out.println("Focus = " + display.options1[0]); |
---|
| 298 | + System.out.println("Aperture = " + display.options1[1]); |
---|
| 299 | + System.out.println("ShadowBlur = " + display.options1[2]); |
---|
| 300 | + System.out.println("Antialiasing = " + display.options1[3]); |
---|
| 301 | + System.out.println("Fog = " + display.options2[0]); |
---|
| 302 | + System.out.println("Intensity = " + display.options2[1]); |
---|
| 303 | + System.out.println("Elevation = " + display.options2[2]); |
---|
| 304 | + /**/ |
---|
| 305 | + } else |
---|
| 306 | + { |
---|
| 307 | + DrawMaterial(material, selected); |
---|
| 308 | + } |
---|
| 309 | + } else |
---|
| 310 | + { |
---|
| 311 | + if (selected && CameraPane.flash) |
---|
| 312 | + { |
---|
| 313 | + display.modelParams4[1] = 100; |
---|
| 314 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 315 | + } |
---|
| 316 | + } |
---|
| 317 | + } |
---|
| 318 | + |
---|
| 319 | + public void PushMaterial2(Object3D obj, boolean selected) |
---|
| 320 | + { |
---|
| 321 | + CameraPane display = this; |
---|
| 322 | + cMaterial material = obj.material; |
---|
| 323 | + |
---|
| 324 | + if (material != null) |
---|
| 325 | + { |
---|
| 326 | + materialstack[materialdepth] = material; |
---|
| 327 | + selectedstack[materialdepth] = selected; |
---|
| 328 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 329 | + //System.out.println("material " + material); |
---|
| 330 | + //Applet3D.tracein("selected ", selected); |
---|
| 331 | + display.vector2buffer = obj.projectedVertices; |
---|
| 332 | + display.DrawMaterial(material, selected); |
---|
| 333 | + } |
---|
| 334 | + } |
---|
| 335 | + |
---|
| 336 | + public void PopMaterial(Object3D obj, boolean selected) |
---|
| 337 | + { |
---|
| 338 | + CameraPane display = this; |
---|
| 339 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 340 | + cMaterial material = obj.material; |
---|
| 341 | + |
---|
| 342 | + //if (parent != null && parent.GetMaterial() != null) |
---|
| 343 | + // parent.GetMaterial().Draw(display, parent.IsSelected(this)); |
---|
| 344 | + if (material != null) |
---|
| 345 | + { |
---|
| 346 | + materialdepth -= 1; |
---|
| 347 | + if (materialdepth > 0) |
---|
| 348 | + { |
---|
| 349 | + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 350 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 351 | + } |
---|
| 352 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 353 | + } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
| 354 | + { |
---|
| 355 | + display.modelParams4[1] = obj.GetMaterial().cameralight; |
---|
| 356 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 357 | + } |
---|
| 358 | + } |
---|
| 359 | + |
---|
| 360 | + public void PopMaterial2(Object3D obj) |
---|
| 361 | + { |
---|
| 362 | + CameraPane display = this; |
---|
| 363 | + cMaterial material = obj.material; |
---|
| 364 | + |
---|
| 365 | + if (material != null) |
---|
| 366 | + { |
---|
| 367 | + materialdepth -= 1; |
---|
| 368 | + if (materialdepth > 0) |
---|
| 369 | + { |
---|
| 370 | + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 371 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 372 | + } |
---|
| 373 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 374 | + //else |
---|
| 375 | + //material.Draw(display, false); |
---|
| 376 | + } |
---|
| 377 | + } |
---|
| 378 | + |
---|
| 379 | + public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face) |
---|
| 380 | + { |
---|
| 381 | + CameraPane display = this; |
---|
| 382 | + |
---|
| 383 | + if (pv.y == -10000 || |
---|
| 384 | + qv.y == -10000 || |
---|
| 385 | + rv.y == -10000) |
---|
| 386 | + return; |
---|
| 387 | + |
---|
| 388 | +// float b = f.nbiterations & 1; |
---|
| 389 | +// float g = (f.nbiterations>>1) & 1; |
---|
| 390 | +// float r = (f.nbiterations>>2) & 1; |
---|
| 391 | +// |
---|
| 392 | +// //if (f.weight == 10000) |
---|
| 393 | +// //{ |
---|
| 394 | +// // r = 1; g = b = 0; |
---|
| 395 | +// //} |
---|
| 396 | +// //else |
---|
| 397 | +// //{ |
---|
| 398 | +// // assert(f.weight < 10000); |
---|
| 399 | +// r = g = b = (float)bRep.FaceWeight(f)*100; |
---|
| 400 | +// if (r<0) |
---|
| 401 | +// assert(r>=0); |
---|
| 402 | +// //} |
---|
| 403 | + |
---|
| 404 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 405 | + |
---|
| 406 | + boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 407 | + |
---|
| 408 | + //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
| 409 | + if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
| 410 | + { |
---|
| 411 | + //gl.glBegin(gl.GL_TRIANGLES); |
---|
| 412 | + boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 413 | + if (!hasnorm) |
---|
| 414 | + { |
---|
| 415 | + // System.out.println("FUCK!!"); |
---|
| 416 | + LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
| 417 | + LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
| 418 | + LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
| 419 | + LA.vecNormalize(obj.v2); |
---|
| 420 | + gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 421 | + } |
---|
| 422 | + |
---|
| 423 | + // P |
---|
| 424 | + float x = (float)pv.x; |
---|
| 425 | + float y = (float)pv.y; |
---|
| 426 | + float z = (float)pv.z; |
---|
| 427 | + |
---|
| 428 | + if (hasnorm) |
---|
| 429 | + { |
---|
| 430 | +// if (!pv.norm.normalized()) |
---|
| 431 | +// assert(pv.norm.normalized()); |
---|
| 432 | + |
---|
| 433 | + //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z); |
---|
| 434 | + float nx = (float)pv.norm.x; |
---|
| 435 | + float ny = (float)pv.norm.y; |
---|
| 436 | + float nz = (float)pv.norm.z; |
---|
| 437 | + |
---|
| 438 | + x += nx * obj.NORMALPUSH; |
---|
| 439 | + y += ny * obj.NORMALPUSH; |
---|
| 440 | + z += nz * obj.NORMALPUSH; |
---|
| 441 | + |
---|
| 442 | + gl.glNormal3f(nx, ny, nz); |
---|
| 443 | + } |
---|
| 444 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 445 | + SetColor(obj, pv); |
---|
| 446 | + //gl.glColor4f(r, g, b, 1); |
---|
| 447 | + //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1); |
---|
| 448 | + if (obj.flipV) |
---|
| 449 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 450 | + else |
---|
| 451 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 452 | + //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z); |
---|
| 453 | + |
---|
| 454 | + gl.glVertex3f(x, y, z); |
---|
| 455 | + |
---|
| 456 | + // Q |
---|
| 457 | + x = (float)qv.x; |
---|
| 458 | + y = (float)qv.y; |
---|
| 459 | + z = (float)qv.z; |
---|
| 460 | + |
---|
| 461 | +// Print(pv); |
---|
| 462 | + if (hasnorm) |
---|
| 463 | + { |
---|
| 464 | +// assert(qv.norm.normalized()); |
---|
| 465 | + //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z); |
---|
| 466 | + float nx = (float)qv.norm.x; |
---|
| 467 | + float ny = (float)qv.norm.y; |
---|
| 468 | + float nz = (float)qv.norm.z; |
---|
| 469 | + |
---|
| 470 | + x += nx * obj.NORMALPUSH; |
---|
| 471 | + y += ny * obj.NORMALPUSH; |
---|
| 472 | + z += nz * obj.NORMALPUSH; |
---|
| 473 | + |
---|
| 474 | + gl.glNormal3f(nx, ny, nz); |
---|
| 475 | + } |
---|
| 476 | + //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
| 477 | + // boolean locked = false; |
---|
| 478 | + // float eps = 0.1f; |
---|
| 479 | + // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 480 | + |
---|
| 481 | + // int dot = 0; //*/ (int)f.dot; |
---|
| 482 | + |
---|
| 483 | + // if ((dot&1) == 0) |
---|
| 484 | + // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 485 | + |
---|
| 486 | + // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 487 | + if (obj.flipV) |
---|
| 488 | + gl.glTexCoord2f((float) qv.s, 1-(float) qv.t); |
---|
| 489 | + else |
---|
| 490 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 491 | + // else |
---|
| 492 | + // { |
---|
| 493 | + // locked = true; |
---|
| 494 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 495 | + // } |
---|
| 496 | + gl.glColor4f(qv.AO, qv.AO, qv.AO, 1); |
---|
| 497 | + SetColor(obj, qv); |
---|
| 498 | + |
---|
| 499 | + gl.glVertex3f(x, y, z); |
---|
| 500 | + //gl.glColor4f(r, g, b, 1); |
---|
| 501 | + //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1); |
---|
| 502 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 503 | +// Print(qv); |
---|
| 504 | + |
---|
| 505 | + // R |
---|
| 506 | + x = (float)rv.x; |
---|
| 507 | + y = (float)rv.y; |
---|
| 508 | + z = (float)rv.z; |
---|
| 509 | + |
---|
| 510 | + if (hasnorm) |
---|
| 511 | + { |
---|
| 512 | +// assert(rv.norm.normalized()); |
---|
| 513 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 514 | + float nx = (float)rv.norm.x; |
---|
| 515 | + float ny = (float)rv.norm.y; |
---|
| 516 | + float nz = (float)rv.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 | + |
---|
| 525 | + // if ((dot&4) == 0) |
---|
| 526 | + // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 527 | + |
---|
| 528 | + // if (wrap || !locked && (dot&8) != 0) |
---|
| 529 | + if (obj.flipV) |
---|
| 530 | + gl.glTexCoord2f((float) rv.s, 1-(float) rv.t); |
---|
| 531 | + else |
---|
| 532 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 533 | + // else |
---|
| 534 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 535 | + |
---|
| 536 | + // f.dot = dot; |
---|
| 537 | + |
---|
| 538 | + gl.glColor4f(rv.AO, rv.AO, rv.AO, 1); |
---|
| 539 | + SetColor(obj, rv); |
---|
| 540 | + //gl.glColor4f(r, g, b, 1); |
---|
| 541 | + //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1); |
---|
| 542 | + //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z); |
---|
| 543 | + gl.glVertex3f(x, y, z); |
---|
| 544 | +// Print(rv); |
---|
| 545 | + //gl.glEnd(); |
---|
| 546 | + } |
---|
| 547 | + else |
---|
| 548 | + { |
---|
| 549 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 550 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 551 | + gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z); |
---|
| 552 | + |
---|
| 553 | + } |
---|
| 554 | + |
---|
| 555 | + if (false) // (attributes & WIREFRAME) != 0) |
---|
| 556 | + { |
---|
| 557 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 558 | + |
---|
| 559 | + gl.glBegin(gl.GL_LINE_LOOP); |
---|
| 560 | + gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z); |
---|
| 561 | + gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z); |
---|
| 562 | + gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z); |
---|
| 563 | + gl.glEnd(); |
---|
| 564 | + |
---|
| 565 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 566 | + } |
---|
| 567 | + } |
---|
| 568 | + |
---|
| 569 | + /// INTERFACE |
---|
| 570 | + |
---|
| 571 | + void SetColor(Object3D obj, Vertex p0) |
---|
| 572 | + { |
---|
| 573 | + CameraPane display = this; |
---|
| 574 | + BoundaryRep bRep = obj.bRep; |
---|
| 575 | + |
---|
| 576 | + if (RENDERPROGRAM == 0) |
---|
| 577 | + { |
---|
| 578 | + float r = 0; |
---|
| 579 | + if (bRep != null) |
---|
| 580 | + { |
---|
| 581 | + if (bRep.stripified) |
---|
| 582 | + { |
---|
| 583 | + r = 1; |
---|
| 584 | + } |
---|
| 585 | + } |
---|
| 586 | + float g = 0; |
---|
| 587 | + if (bRep != null) |
---|
| 588 | + { |
---|
| 589 | + if (bRep.trimmed) |
---|
| 590 | + { |
---|
| 591 | + g = 1; |
---|
| 592 | + } |
---|
| 593 | + } |
---|
| 594 | + float b = 0; |
---|
| 595 | + if (obj.support != null && obj.link2master) |
---|
| 596 | + { |
---|
| 597 | + b = 1; |
---|
| 598 | + } |
---|
| 599 | + display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO); |
---|
| 600 | + return; |
---|
| 601 | + } |
---|
| 602 | + |
---|
| 603 | + if (display.DrawMode() != CameraPane.SHADOW) |
---|
| 604 | + return; |
---|
| 605 | + |
---|
| 606 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 607 | +// if (true) return; |
---|
| 608 | +// float ao = p.AO; |
---|
| 609 | +// |
---|
| 610 | +// // if (ao == 0 && !bRep.AOdone) // transient problem! |
---|
| 611 | +// // ao = 1; |
---|
| 612 | +// |
---|
| 613 | +// gl.glColor4f(ao, ao, ao, 1); |
---|
| 614 | + |
---|
| 615 | +// CameraPane.selectedpoint. |
---|
| 616 | +// getAverage(cStatic.point1, true); |
---|
| 617 | + if (CameraPane.pointflow == null) // !random) // live) |
---|
| 618 | + { |
---|
| 619 | + return; |
---|
| 620 | + } |
---|
| 621 | + |
---|
| 622 | + cStatic.point1.set(0,0,0); |
---|
| 623 | + LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1); |
---|
| 624 | + |
---|
| 625 | + cStatic.point1.sub(p0); |
---|
| 626 | + |
---|
| 627 | + |
---|
| 628 | +// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta? |
---|
| 629 | +// { |
---|
| 630 | +// return; |
---|
| 631 | +// } |
---|
| 632 | + |
---|
| 633 | + //if (true) |
---|
| 634 | + if (cStatic.point1.dot(cStatic.point1) > 0.000001) |
---|
| 635 | + { |
---|
| 636 | + return; |
---|
| 637 | + } |
---|
| 638 | + |
---|
| 639 | + float[] colorV = new float[3]; |
---|
| 640 | + |
---|
| 641 | + if (false) // marked) |
---|
| 642 | + { |
---|
| 643 | + // debug rigging weights |
---|
| 644 | + for (int object = 0; object < p0.vertexlinks.length; object++) |
---|
| 645 | + { |
---|
| 646 | + float weight = p0.weights[object] / p0.totalweight; |
---|
| 647 | + |
---|
| 648 | + // if (weight < 0.1) |
---|
| 649 | + // { |
---|
| 650 | + // assert(weight == 0); |
---|
| 651 | + // continue; |
---|
| 652 | + // } |
---|
| 653 | + |
---|
| 654 | + if (p0.vertexlinks[object] == -1) |
---|
| 655 | + continue; |
---|
| 656 | + |
---|
| 657 | + Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]); |
---|
| 658 | + |
---|
| 659 | + int color = //1 << object; // |
---|
| 660 | + //p.vertexlinks.length; |
---|
| 661 | + obj.support.bRep.supports[p0.closestsupport].links[object]; |
---|
| 662 | + colorV[2] += (color & 1) * weight; |
---|
| 663 | + colorV[1] += ((color & 2) >> 1) * weight; |
---|
| 664 | + colorV[0] += ((color & 4) >> 2) * weight; |
---|
| 665 | + } |
---|
| 666 | + } |
---|
| 667 | + else |
---|
| 668 | + { |
---|
| 669 | + if (obj.drawingstarted) |
---|
| 670 | + { |
---|
| 671 | + // find next point |
---|
| 672 | + if (bRep.GetVertex(0).faceindices == null) |
---|
| 673 | + { |
---|
| 674 | + bRep.InitFaceIndices(); |
---|
| 675 | + } |
---|
| 676 | + |
---|
| 677 | + double ymin = p0.y; |
---|
| 678 | + |
---|
| 679 | + Vertex newp = p0; |
---|
| 680 | + |
---|
| 681 | + for (int fii = 0; fii < p0.faceindices.length; fii++) |
---|
| 682 | + { |
---|
| 683 | + int fi = p0.faceindices[fii]; |
---|
| 684 | + |
---|
| 685 | + if (fi == -1) |
---|
| 686 | + break; |
---|
| 687 | + |
---|
| 688 | + Face f = bRep.GetFace(fi); |
---|
| 689 | + |
---|
| 690 | + Vertex p = bRep.GetVertex(f.p); |
---|
| 691 | + Vertex q = bRep.GetVertex(f.q); |
---|
| 692 | + Vertex r = bRep.GetVertex(f.r); |
---|
| 693 | + |
---|
| 694 | + int swap = (int)(Math.random()*3); |
---|
| 695 | + |
---|
| 696 | +// for (int s=swap; --s>=0;) |
---|
| 697 | +// { |
---|
| 698 | +// Vertex t = p; |
---|
| 699 | +// p = q; |
---|
| 700 | +// q = r; |
---|
| 701 | +// r = t; |
---|
| 702 | +// } |
---|
| 703 | + if (ymin > p.y) |
---|
| 704 | + { |
---|
| 705 | + ymin = p.y; |
---|
| 706 | + newp = p; |
---|
| 707 | +// break; |
---|
| 708 | + } |
---|
| 709 | + if (ymin > q.y) |
---|
| 710 | + { |
---|
| 711 | + ymin = q.y; |
---|
| 712 | + newp = q; |
---|
| 713 | +// break; |
---|
| 714 | + } |
---|
| 715 | + if (ymin > r.y) |
---|
| 716 | + { |
---|
| 717 | + ymin = r.y; |
---|
| 718 | + newp = r; |
---|
| 719 | +// break; |
---|
| 720 | + } |
---|
| 721 | + } |
---|
| 722 | + |
---|
| 723 | + CameraPane.selectedpoint.toParent[3][0] = newp.x; |
---|
| 724 | + CameraPane.selectedpoint.toParent[3][1] = newp.y; |
---|
| 725 | + CameraPane.selectedpoint.toParent[3][2] = newp.z; |
---|
| 726 | + |
---|
| 727 | + obj.drawingstarted = false; |
---|
| 728 | + |
---|
| 729 | + // return; |
---|
| 730 | + } |
---|
| 731 | + |
---|
| 732 | + if (false) // CameraPane.DRAW |
---|
| 733 | + { |
---|
| 734 | + p0.AO = colorV[0] = 2; |
---|
| 735 | + colorV[1] = 2; |
---|
| 736 | + colorV[2] = 2; |
---|
| 737 | + } |
---|
| 738 | + |
---|
| 739 | + CameraPane.pointflow.add(p0); |
---|
| 740 | + CameraPane.pointflow.Touch(); |
---|
| 741 | + } |
---|
| 742 | + |
---|
| 743 | +// gl.glColor3f(colorV[0], colorV[1], colorV[2]); |
---|
| 744 | +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 745 | +// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 746 | + } |
---|
| 747 | + |
---|
| 748 | + void DrawMaterial(cMaterial material, boolean selected) |
---|
| 749 | + { |
---|
| 750 | + CameraPane display = this; |
---|
| 751 | + //new Exception().printStackTrace(); |
---|
| 752 | + |
---|
| 753 | + if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW) |
---|
| 754 | + { |
---|
| 755 | + return; |
---|
| 756 | + } |
---|
| 757 | + |
---|
| 758 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 759 | + |
---|
| 760 | + //Color col = Color.getHSBColor(color,modulation,1); |
---|
| 761 | + //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
| 762 | + if (!material.multiply) |
---|
| 763 | + { |
---|
| 764 | + display.color = color; |
---|
| 765 | + display.saturation = material.modulation; |
---|
| 766 | + } |
---|
| 767 | + else |
---|
| 768 | + { |
---|
| 769 | + display.color *= color*2; |
---|
| 770 | + display.saturation *= material.modulation*2; |
---|
| 771 | + } |
---|
| 772 | + |
---|
| 773 | + cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
| 774 | + |
---|
| 775 | + float[] colorV = GrafreeD.colorV; |
---|
| 776 | + |
---|
| 777 | + /**/ |
---|
| 778 | + if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
| 779 | + { |
---|
| 780 | + colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
| 781 | + colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
| 782 | + colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
| 783 | + colorV[3] = material.opacity; |
---|
| 784 | + |
---|
| 785 | + gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
| 786 | + //System.out.println("Opacity = " + opacity); |
---|
| 787 | + |
---|
| 788 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 789 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 790 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 791 | + |
---|
| 792 | + float amb = material.ambient; |
---|
| 793 | + if (amb < material.cameralight) |
---|
| 794 | + { |
---|
| 795 | + amb = material.cameralight; |
---|
| 796 | + } |
---|
| 797 | + colorV[0] = display.modelParams0[0] * material.diffuse * amb; |
---|
| 798 | + colorV[1] = display.modelParams0[1] * material.diffuse * amb; |
---|
| 799 | + colorV[2] = display.modelParams0[2] * material.diffuse * amb; |
---|
| 800 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0); |
---|
| 801 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 802 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 803 | + |
---|
| 804 | + /**/ |
---|
| 805 | + colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular; |
---|
| 806 | + colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular; |
---|
| 807 | + colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular; |
---|
| 808 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0); |
---|
| 809 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 810 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0); |
---|
| 811 | + colorV[0] = 10 / material.shininess; // 1/0.005f; |
---|
| 812 | + //System.out.println("shininess = " + colorV[0]); |
---|
| 813 | + if (colorV[0] > 128) |
---|
| 814 | + { |
---|
| 815 | + colorV[0] = 128; |
---|
| 816 | + } |
---|
| 817 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0); |
---|
| 818 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0); |
---|
| 819 | + /**/ |
---|
| 820 | + } |
---|
| 821 | + /**/ |
---|
| 822 | + |
---|
| 823 | + //selected = false; |
---|
| 824 | + selected = selected && display.flash; |
---|
| 825 | + |
---|
| 826 | + //display.modelParams0[0] = 0; // pigment.r; |
---|
| 827 | + //display.modelParams0[1] = 0; // pigment.g; |
---|
| 828 | + //display.modelParams0[2] = 0; // pigment.b; |
---|
| 829 | + if (!material.multiply) |
---|
| 830 | + { |
---|
| 831 | + display.modelParams0[3] = material.metalness; |
---|
| 832 | + display.modelParams1[0] = material.diffuse; |
---|
| 833 | + display.modelParams1[1] = material.specular; |
---|
| 834 | + display.modelParams1[2] = 1 / material.shininess; |
---|
| 835 | + display.modelParams1[3] = material.shift; |
---|
| 836 | + display.modelParams2[0] = material.ambient; |
---|
| 837 | + display.modelParams2[1] = material.lightarea; |
---|
| 838 | + //System.out.println("light area = " + lightarea); |
---|
| 839 | + display.modelParams2[2] = 1 / material.factor; // diffuseness |
---|
| 840 | + display.modelParams2[3] = material.velvet; |
---|
| 841 | + display.modelParams3[0] = material.sheen; |
---|
| 842 | + display.modelParams3[1] = material.subsurface; |
---|
| 843 | + display.modelParams3[2] = material.bump; // backlit |
---|
| 844 | + display.modelParams3[3] = material.aniso; |
---|
| 845 | + display.modelParams4[0] = material.anisoV; |
---|
| 846 | + display.modelParams4[1] = selected ? 100 : material.cameralight; |
---|
| 847 | + //System.out.println("selected = " + selected); |
---|
| 848 | + display.modelParams4[2] = material.diffuseness; |
---|
| 849 | + display.modelParams4[3] = material.shadow; |
---|
| 850 | + display.modelParams5[0] = material.texture; |
---|
| 851 | + display.modelParams5[1] = material.opacity; |
---|
| 852 | + display.modelParams5[2] = material.fakedepth; |
---|
| 853 | + display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10; |
---|
| 854 | + } |
---|
| 855 | + else |
---|
| 856 | + { |
---|
| 857 | + display.modelParams0[3] *= material.metalness*2; |
---|
| 858 | + display.modelParams1[0] *= material.diffuse*2; |
---|
| 859 | + display.modelParams1[1] *= material.specular*2; |
---|
| 860 | + display.modelParams1[2] *= material.shininess*2; |
---|
| 861 | + display.modelParams1[3] *= material.shift*2; |
---|
| 862 | + display.modelParams2[0] *= material.ambient*2; |
---|
| 863 | + display.modelParams2[1] *= material.lightarea*2; |
---|
| 864 | + display.modelParams2[2] *= material.factor*2; |
---|
| 865 | + display.modelParams2[3] *= material.velvet*2; |
---|
| 866 | + display.modelParams3[0] *= material.sheen*2; |
---|
| 867 | + display.modelParams3[1] *= material.subsurface*2; |
---|
| 868 | + display.modelParams3[2] *= material.bump*2; |
---|
| 869 | + display.modelParams3[3] *= material.aniso*2; |
---|
| 870 | + display.modelParams4[0] *= material.anisoV*2; |
---|
| 871 | + display.modelParams4[1] *= material.cameralight*2; |
---|
| 872 | + //System.out.println("selected = " + selected); |
---|
| 873 | + display.modelParams4[2] *= material.diffuseness*2; |
---|
| 874 | + display.modelParams4[3] *= material.shadow*2; |
---|
| 875 | + display.modelParams5[0] *= material.texture*2; |
---|
| 876 | + display.modelParams5[1] *= material.opacity*2; |
---|
| 877 | + display.modelParams5[2] *= material.fakedepth*2; |
---|
| 878 | + display.modelParams5[3] *= material.shadowbias*2; |
---|
| 879 | + } |
---|
| 880 | + |
---|
| 881 | + display.modelParams6[0] = 0; |
---|
| 882 | + display.modelParams6[1] = 0; |
---|
| 883 | + display.modelParams6[2] = 0; |
---|
| 884 | + display.modelParams6[3] = 0; |
---|
| 885 | + |
---|
| 886 | + display.modelParams7[0] = 0; |
---|
| 887 | + display.modelParams7[1] = 1000; |
---|
| 888 | + display.modelParams7[2] = 0; |
---|
| 889 | + display.modelParams7[3] = 0; |
---|
| 890 | + |
---|
| 891 | + display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 892 | + |
---|
| 893 | + Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 894 | + if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
| 895 | + { |
---|
| 896 | + display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
| 897 | + display.modelParams6[1] = extparams[0].y / 1000.0f; // noise |
---|
| 898 | + if (extparams.length > 1) |
---|
| 899 | + { |
---|
| 900 | + display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade |
---|
| 901 | + display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough |
---|
| 902 | + if (extparams.length > 2) |
---|
| 903 | + { |
---|
| 904 | + display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power |
---|
| 905 | + float x = extparams[2].y / 1000.0f; |
---|
| 906 | + //if (x == 0) |
---|
| 907 | + // x = 1f; |
---|
| 908 | + 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 |
---|
| 909 | + if (extparams[2].y > 0) |
---|
| 910 | + { |
---|
| 911 | + //System.out.println("extparams[1].y = " + extparams[1].y); |
---|
| 912 | + //System.out.println("extparams[2].y = " + extparams[2].y); |
---|
| 913 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 914 | + } |
---|
| 915 | + } |
---|
| 916 | + } |
---|
| 917 | + } |
---|
| 918 | + |
---|
| 919 | + //if (display.modelParams6[2] != 0) |
---|
| 920 | + /* |
---|
| 921 | + System.out.println("modelParams0[0] = " + display.modelParams0[0]); |
---|
| 922 | + System.out.println("modelParams0[1] = " + display.modelParams0[1]); |
---|
| 923 | + System.out.println("modelParams0[2] = " + display.modelParams0[2]); |
---|
| 924 | + System.out.println("modelParams0[3] = " + display.modelParams0[3]); |
---|
| 925 | + System.out.println("modelParams1[0] = " + display.modelParams1[0]); |
---|
| 926 | + System.out.println("modelParams1[1] = " + display.modelParams1[1]); |
---|
| 927 | + System.out.println("modelParams1[2] = " + display.modelParams1[2]); |
---|
| 928 | + System.out.println("modelParams1[3] = " + display.modelParams1[3]); |
---|
| 929 | + System.out.println("modelParams2[0] = " + display.modelParams2[0]); |
---|
| 930 | + System.out.println("modelParams2[1] = " + display.modelParams2[1]); |
---|
| 931 | + System.out.println("modelParams2[2] = " + display.modelParams2[2]); |
---|
| 932 | + System.out.println("modelParams2[3] = " + display.modelParams2[3]); |
---|
| 933 | + System.out.println("modelParams3[0] = " + display.modelParams3[0]); |
---|
| 934 | + System.out.println("modelParams3[1] = " + display.modelParams3[1]); |
---|
| 935 | + System.out.println("modelParams3[2] = " + display.modelParams3[2]); |
---|
| 936 | + System.out.println("modelParams3[3] = " + display.modelParams3[3]); |
---|
| 937 | + System.out.println("modelParams4[0] = " + display.modelParams4[0]); |
---|
| 938 | + System.out.println("modelParams4[1] = " + display.modelParams4[1]); |
---|
| 939 | + System.out.println("modelParams4[2] = " + display.modelParams4[2]); |
---|
| 940 | + System.out.println("modelParams4[3] = " + display.modelParams4[3]); |
---|
| 941 | + System.out.println("modelParams5[0] = " + display.modelParams5[0]); |
---|
| 942 | + System.out.println("modelParams5[1] = " + display.modelParams5[1]); |
---|
| 943 | + System.out.println("modelParams5[2] = " + display.modelParams5[2]); |
---|
| 944 | + System.out.println("modelParams5[3] = " + display.modelParams5[3]); |
---|
| 945 | + System.out.println("modelParams6[0] = " + display.modelParams6[0]); |
---|
| 946 | + System.out.println("modelParams6[1] = " + display.modelParams6[1]); |
---|
| 947 | + System.out.println("modelParams6[2] = " + display.modelParams6[2]); |
---|
| 948 | + System.out.println("modelParams6[3] = " + display.modelParams6[3]); |
---|
| 949 | + System.out.println("modelParams7[0] = " + display.modelParams7[0]); |
---|
| 950 | + System.out.println("modelParams7[1] = " + display.modelParams7[1]); |
---|
| 951 | + System.out.println("modelParams7[2] = " + display.modelParams7[2]); |
---|
| 952 | + System.out.println("modelParams7[3] = " + display.modelParams7[3]); |
---|
| 953 | + /**/ |
---|
| 954 | + //assert (display.modelParams6[2] == 0); |
---|
| 955 | + |
---|
| 956 | + //System.out.println("noise power = " + display.modelParams7[0]); |
---|
| 957 | + //System.out.println("shadowbias = " + shadowbias); |
---|
| 958 | + |
---|
| 959 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 960 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0); |
---|
| 961 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0); |
---|
| 962 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0); |
---|
| 963 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 964 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 965 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0); |
---|
| 966 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0); |
---|
| 967 | + |
---|
| 968 | + int mode = display.FP_SHADER; |
---|
| 969 | + |
---|
| 970 | + if (material.aniso != material.anisoV || material.aniso > 0.002) |
---|
| 971 | + { |
---|
| 972 | + mode |= display.FP_ANISO; |
---|
| 973 | + } |
---|
| 974 | + |
---|
| 975 | + display.EnableProgram(mode); |
---|
| 976 | + |
---|
| 977 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 978 | + |
---|
| 979 | + if (!material.multiply) |
---|
| 980 | + { |
---|
| 981 | + if (Globals.drawMode == CameraPane.SHADOW) |
---|
| 982 | + gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1); |
---|
| 983 | + else |
---|
| 984 | + gl.glDepthMask(material.opacity >= 0.99); |
---|
| 985 | + } |
---|
208 | 986 | } |
---|
209 | 987 | |
---|
210 | 988 | int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0; |
---|
.. | .. |
---|
225 | 1003 | currentGL.glMultMatrixd(model, 0); |
---|
226 | 1004 | } |
---|
227 | 1005 | |
---|
228 | | - void PushMatrix(double[][] matrix, int count) |
---|
| 1006 | + public void PushMatrix(double[][] matrix, int count) // INTERFACE |
---|
229 | 1007 | { |
---|
230 | 1008 | matrixdepth++; |
---|
231 | 1009 | // GrafreeD.tracein(matrix); |
---|
.. | .. |
---|
270 | 1048 | |
---|
271 | 1049 | double[][] tmpmat = new double[4][4]; |
---|
272 | 1050 | |
---|
273 | | - void PopMatrix(double[][] inverse) |
---|
| 1051 | + public void PopMatrix(double[][] inverse) // INTERFACE |
---|
274 | 1052 | { |
---|
275 | 1053 | --matrixdepth; |
---|
276 | 1054 | |
---|
.. | .. |
---|
310 | 1088 | PushTextureMatrix(matrix, 1); |
---|
311 | 1089 | } |
---|
312 | 1090 | |
---|
313 | | - void PushTextureMatrix(double[][] matrix, int count) |
---|
| 1091 | + public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE |
---|
314 | 1092 | { |
---|
315 | 1093 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
316 | 1094 | |
---|
.. | .. |
---|
324 | 1102 | currentGL.glMatrixMode(GetGL().GL_MODELVIEW); |
---|
325 | 1103 | } |
---|
326 | 1104 | |
---|
327 | | - void PopTextureMatrix(double[][] inverse) |
---|
| 1105 | + public void PopTextureMatrix(double[][] inverse) // INTERFACE |
---|
328 | 1106 | { |
---|
329 | 1107 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
330 | 1108 | currentGL.glMatrixMode(GetGL().GL_TEXTURE); |
---|
.. | .. |
---|
356 | 1134 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
357 | 1135 | // return false; |
---|
358 | 1136 | |
---|
359 | | - if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount) |
---|
| 1137 | + if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount) |
---|
360 | 1138 | { |
---|
361 | 1139 | // check for last change |
---|
362 | | - if (framecount < camerachangeframe + 400) // 120 == 1 second |
---|
| 1140 | + if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second |
---|
363 | 1141 | { |
---|
364 | 1142 | // refuse the camera change |
---|
365 | 1143 | System.err.println("Camera " + cam + " REFUSED"); |
---|
.. | .. |
---|
367 | 1145 | } |
---|
368 | 1146 | } |
---|
369 | 1147 | |
---|
370 | | - camerachangeframe = framecount; |
---|
| 1148 | + camerachangeframe = Globals.framecount; |
---|
371 | 1149 | |
---|
372 | 1150 | cam.hAspect = -1; // Read only |
---|
373 | 1151 | |
---|
.. | .. |
---|
398 | 1176 | { |
---|
399 | 1177 | //System.err.println("Oeil on"); |
---|
400 | 1178 | TRACK = true; |
---|
401 | | -// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 1179 | +// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
402 | 1180 | // object.editWindow.ScreenFit(trackedobject); |
---|
403 | 1181 | //pingthread.StepToTarget(true); |
---|
404 | 1182 | } |
---|
.. | .. |
---|
407 | 1185 | { |
---|
408 | 1186 | //System.err.println("Oeil on"); |
---|
409 | 1187 | OEIL = true; |
---|
410 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 1188 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
411 | 1189 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
412 | 1190 | //pingthread.StepToTarget(true); |
---|
413 | 1191 | } |
---|
.. | .. |
---|
471 | 1249 | { |
---|
472 | 1250 | frozen ^= true; |
---|
473 | 1251 | // Weird... |
---|
474 | | - lighttouched = true; |
---|
| 1252 | + Globals.lighttouched = true; |
---|
475 | 1253 | } |
---|
476 | 1254 | |
---|
477 | 1255 | void ToggleDL() |
---|
.. | .. |
---|
486 | 1264 | |
---|
487 | 1265 | void ToggleLive() |
---|
488 | 1266 | { |
---|
489 | | - setLIVE(isLIVE() ^ true); |
---|
| 1267 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
490 | 1268 | |
---|
491 | | - System.err.println("LIVE = " + isLIVE()); |
---|
| 1269 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
492 | 1270 | |
---|
493 | | - if (!isLIVE()) // save sound |
---|
| 1271 | + if (!Globals.isLIVE()) // save sound |
---|
494 | 1272 | GrafreeD.savesound = true; // wav.save(); |
---|
495 | 1273 | // else |
---|
496 | 1274 | repaint(); // start loop // may 2013 |
---|
.. | .. |
---|
513 | 1291 | |
---|
514 | 1292 | void ToggleCrowd() |
---|
515 | 1293 | { |
---|
516 | | - CROWD ^= true; |
---|
| 1294 | + Globals.CROWD ^= true; |
---|
517 | 1295 | } |
---|
518 | 1296 | |
---|
519 | 1297 | void ToggleInertia() |
---|
.. | .. |
---|
674 | 1452 | lightCamera = cam; |
---|
675 | 1453 | } |
---|
676 | 1454 | |
---|
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 | | - } |
---|
704 | | - |
---|
705 | 1455 | private static void ApplyTransform(GL gl, Mat4f xform) |
---|
706 | 1456 | { |
---|
707 | 1457 | float[] data = new float[16]; |
---|
.. | .. |
---|
759 | 1509 | |
---|
760 | 1510 | GL currentGL; |
---|
761 | 1511 | |
---|
762 | | - GL GetGL() |
---|
| 1512 | + public GL GetGL() // INTERFACE |
---|
763 | 1513 | { |
---|
764 | 1514 | return currentGL; |
---|
765 | 1515 | } |
---|
.. | .. |
---|
2000 | 2750 | */ |
---|
2001 | 2751 | TextureData ReduceTexture(TextureData texturedata, int resolution) // String name) |
---|
2002 | 2752 | { |
---|
| 2753 | + int pixelformat = texturedata.getPixelFormat(); |
---|
| 2754 | + |
---|
2003 | 2755 | int stride = 1; |
---|
2004 | | - if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE) |
---|
| 2756 | + if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE) |
---|
2005 | 2757 | stride = 3; |
---|
2006 | | - if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA) |
---|
| 2758 | + if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA) |
---|
2007 | 2759 | stride = 4; |
---|
2008 | 2760 | |
---|
2009 | 2761 | int width = texturedata.getWidth(); |
---|
.. | .. |
---|
6269 | 7021 | return null; |
---|
6270 | 7022 | } |
---|
6271 | 7023 | |
---|
6272 | | - void ReleaseTextures(cTexture tex) |
---|
| 7024 | + public void ReleaseTextures(cTexture tex) // INTERFACE |
---|
6273 | 7025 | { |
---|
6274 | 7026 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6275 | 7027 | { |
---|
.. | .. |
---|
6307 | 7059 | |
---|
6308 | 7060 | void ReleaseTexture(String tex, boolean bump) |
---|
6309 | 7061 | { |
---|
6310 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 7062 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6311 | 7063 | ambientOcclusion ) // || !textureon) |
---|
6312 | 7064 | { |
---|
6313 | 7065 | return; |
---|
.. | .. |
---|
6408 | 7160 | } |
---|
6409 | 7161 | } |
---|
6410 | 7162 | |
---|
6411 | | - /*boolean*/ void BindTextures(cTexture tex, int resolution) |
---|
| 7163 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
6412 | 7164 | { |
---|
6413 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 7165 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6414 | 7166 | ambientOcclusion ) // || !textureon) |
---|
6415 | 7167 | { |
---|
6416 | 7168 | return; // false; |
---|
.. | .. |
---|
7310 | 8062 | static boolean occlusionInitialized = false; |
---|
7311 | 8063 | boolean selection = false; |
---|
7312 | 8064 | boolean pointselection = false; |
---|
7313 | | - /*static*/ boolean lighttouched = true; |
---|
| 8065 | + ///*static*/ boolean lighttouched = true; |
---|
7314 | 8066 | boolean deselect; |
---|
7315 | | - boolean ambientOcclusion = false; |
---|
| 8067 | + private boolean ambientOcclusion = false; |
---|
7316 | 8068 | static boolean flash = false; |
---|
7317 | 8069 | /*static*/ boolean wait = false; |
---|
7318 | 8070 | boolean displaydone = false; // after repaint() calls |
---|
.. | .. |
---|
7442 | 8194 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
7443 | 8195 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
7444 | 8196 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 8197 | +// PATCH FILLE AUX JEANS |
---|
| 8198 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
7445 | 8199 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
7446 | 8200 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
7447 | 8201 | |
---|
.. | .. |
---|
7590 | 8344 | |
---|
7591 | 8345 | float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
7592 | 8346 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
7593 | | - float[] options3 = new float[]{1, 1, 1, 1}; // fog color. image intensity |
---|
| 8347 | + float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
| 8348 | + float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
7594 | 8349 | |
---|
7595 | 8350 | static int imagecount = 0; // movie generation |
---|
7596 | 8351 | |
---|
7597 | 8352 | static int jitter = 0; |
---|
7598 | 8353 | |
---|
7599 | 8354 | boolean restartframe = false; |
---|
7600 | | - |
---|
7601 | | - static int framecount = 0; // general-purpose global count |
---|
7602 | 8355 | |
---|
7603 | 8356 | void displayAntiAliased(javax.media.opengl.GL gl) |
---|
7604 | 8357 | { |
---|
.. | .. |
---|
7630 | 8383 | gl.glClear(gl.GL_ACCUM_BUFFER_BIT); |
---|
7631 | 8384 | for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0) |
---|
7632 | 8385 | { |
---|
7633 | | - framecount++; |
---|
| 8386 | + Globals.framecount++; |
---|
7634 | 8387 | |
---|
7635 | 8388 | if (CameraPane.tickcount > 0) |
---|
7636 | 8389 | CameraPane.tickcount--; |
---|
.. | .. |
---|
7668 | 8421 | |
---|
7669 | 8422 | gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0); |
---|
7670 | 8423 | */ |
---|
7671 | | - lighttouched = true; |
---|
| 8424 | + Globals.lighttouched = true; |
---|
7672 | 8425 | //System.err.println(" shadowbuffer: " + jitter); |
---|
7673 | 8426 | shadowbuffer.display(); |
---|
7674 | 8427 | |
---|
.. | .. |
---|
7690 | 8443 | |
---|
7691 | 8444 | if (renderCamera != lightCamera) |
---|
7692 | 8445 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7693 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 8446 | + LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
7694 | 8447 | |
---|
7695 | 8448 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
7696 | 8449 | |
---|
.. | .. |
---|
7706 | 8459 | |
---|
7707 | 8460 | if (renderCamera != lightCamera) |
---|
7708 | 8461 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7709 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 8462 | + LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
7710 | 8463 | |
---|
7711 | 8464 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
7712 | 8465 | |
---|
.. | .. |
---|
7923 | 8676 | |
---|
7924 | 8677 | if (!BOXMODE) |
---|
7925 | 8678 | { |
---|
7926 | | - System.out.println("image: " + fullname + " (" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 8679 | + System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
7927 | 8680 | } |
---|
7928 | 8681 | |
---|
7929 | 8682 | if (!BOXMODE) |
---|
.. | .. |
---|
8615 | 9368 | } |
---|
8616 | 9369 | } |
---|
8617 | 9370 | |
---|
8618 | | - boolean IsFrozen() |
---|
8619 | | - { |
---|
8620 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
8621 | | - |
---|
8622 | | - return !selectmode && cameracount == 0; // != 0; |
---|
8623 | | - } |
---|
8624 | | - |
---|
8625 | 9371 | boolean niceon = false; |
---|
8626 | 9372 | javax.swing.Timer AAtimer = new javax.swing.Timer(750, this); |
---|
8627 | 9373 | boolean currentlydrawing = false; |
---|
.. | .. |
---|
8639 | 9385 | } |
---|
8640 | 9386 | // if (DEBUG_SELECTION) |
---|
8641 | 9387 | // { |
---|
8642 | | -// if (drawMode != SELECTION) |
---|
8643 | | -// drawMode = SELECTION; |
---|
| 9388 | +// if (DrawMode() != SELECTION) |
---|
| 9389 | +// DrawMode() = SELECTION; |
---|
8644 | 9390 | // } |
---|
8645 | 9391 | |
---|
8646 | 9392 | if (!isRenderer) |
---|
.. | .. |
---|
8696 | 9442 | |
---|
8697 | 9443 | //ANTIALIAS = 0; |
---|
8698 | 9444 | |
---|
8699 | | - if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
| 9445 | + if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
8700 | 9446 | { |
---|
8701 | | - if (niceon || isLIVE()) |
---|
| 9447 | + if (niceon || Globals.isLIVE()) |
---|
8702 | 9448 | { |
---|
8703 | 9449 | //if(active == 0) |
---|
8704 | 9450 | // antialiaser = null; |
---|
.. | .. |
---|
8723 | 9469 | assert eyeCamera.shaper_zFar == 1E5f; // 500.0f; |
---|
8724 | 9470 | */ |
---|
8725 | 9471 | |
---|
8726 | | - if (drawMode == DEFAULT) |
---|
| 9472 | + if (DrawMode() == DEFAULT) |
---|
8727 | 9473 | { |
---|
8728 | 9474 | currentlydrawing = true; |
---|
8729 | 9475 | } |
---|
.. | .. |
---|
8754 | 9500 | |
---|
8755 | 9501 | // if(Applet3D.clipboard != null) |
---|
8756 | 9502 | // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent); |
---|
8757 | | -//drawMode = SELECTION; |
---|
| 9503 | +//DrawMode() = SELECTION; |
---|
8758 | 9504 | indexcount = 0; |
---|
8759 | 9505 | |
---|
8760 | | - if (drawMode == OCCLUSION) |
---|
| 9506 | + if (DrawMode() == OCCLUSION) |
---|
8761 | 9507 | { |
---|
8762 | | - drawMode = DEFAULT; |
---|
| 9508 | + Globals.drawMode = DEFAULT; // WARNING |
---|
8763 | 9509 | ambientOcclusion = true; |
---|
8764 | 9510 | setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
---|
8765 | 9511 | Object3D theobject = object; |
---|
.. | .. |
---|
8778 | 9524 | ambientOcclusion = false; |
---|
8779 | 9525 | } |
---|
8780 | 9526 | |
---|
8781 | | - if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 9527 | + if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
8782 | 9528 | { |
---|
8783 | 9529 | //if (RENDERSHADOW) // ? |
---|
8784 | 9530 | if (!IsFrozen()) |
---|
8785 | 9531 | { |
---|
8786 | 9532 | // dec 2012 |
---|
8787 | | - if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)) |
---|
| 9533 | + if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
8788 | 9534 | { |
---|
8789 | | - framecount++; |
---|
| 9535 | + Globals.framecount++; |
---|
8790 | 9536 | shadowbuffer.display(); |
---|
8791 | 9537 | } |
---|
8792 | 9538 | } |
---|
8793 | | - lighttouched = false; // ?? |
---|
| 9539 | + Globals.lighttouched = false; // ?? |
---|
8794 | 9540 | //drawing = true; |
---|
8795 | 9541 | //lighttouched = true; |
---|
8796 | 9542 | } |
---|
.. | .. |
---|
8811 | 9557 | //eyeCamera.shaper_fovy = 1; |
---|
8812 | 9558 | } |
---|
8813 | 9559 | |
---|
8814 | | - if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION) |
---|
| 9560 | + if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION) |
---|
8815 | 9561 | { |
---|
8816 | | - //System.out.println("drawMode = " + drawMode); |
---|
| 9562 | + //System.out.println("DrawMode() = " + DrawMode()); |
---|
8817 | 9563 | vertexMode |= VP_PASS; |
---|
8818 | 9564 | //vertexMode |= VP_PROJECTION; |
---|
8819 | 9565 | if (!ambientOcclusion) |
---|
.. | .. |
---|
8873 | 9619 | Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera; |
---|
8874 | 9620 | //Camera lightcam = new Camera(light0); |
---|
8875 | 9621 | |
---|
8876 | | - if (drawMode == SHADOW) |
---|
| 9622 | + if (DrawMode() == SHADOW) |
---|
8877 | 9623 | { |
---|
8878 | 9624 | /* |
---|
8879 | 9625 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
.. | .. |
---|
8912 | 9658 | // if (parentcam != renderCamera) // not a light |
---|
8913 | 9659 | if (cam != lightCamera) |
---|
8914 | 9660 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8915 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 9661 | + LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
8916 | 9662 | |
---|
8917 | 9663 | for (int j = 0; j < 4; j++) |
---|
8918 | 9664 | { |
---|
.. | .. |
---|
8927 | 9673 | // if (parentcam != renderCamera) // not a light |
---|
8928 | 9674 | if (cam != lightCamera) |
---|
8929 | 9675 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8930 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 9676 | + LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
8931 | 9677 | |
---|
8932 | 9678 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
8933 | 9679 | |
---|
.. | .. |
---|
8963 | 9709 | gl.glClear(gl.GL_DEPTH_BUFFER_BIT); |
---|
8964 | 9710 | } else |
---|
8965 | 9711 | { |
---|
8966 | | - if (drawMode != DEFAULT) |
---|
| 9712 | + if (DrawMode() != DEFAULT) |
---|
8967 | 9713 | { |
---|
8968 | 9714 | gl.glClearColor(1, 1, 1, 0); |
---|
8969 | 9715 | } // 1); |
---|
.. | .. |
---|
9028 | 9774 | |
---|
9029 | 9775 | fast &= !ambientOcclusion; |
---|
9030 | 9776 | |
---|
9031 | | - if (drawMode == DEFAULT) |
---|
| 9777 | + if (DrawMode() == DEFAULT) |
---|
9032 | 9778 | { |
---|
9033 | 9779 | //gl.glEnable(gl.GL_ALPHA_TEST); |
---|
9034 | 9780 | //gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
.. | .. |
---|
9089 | 9835 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
9090 | 9836 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9091 | 9837 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 9838 | +// PATCH FILLE AUX JEANS |
---|
| 9839 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9092 | 9840 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9093 | 9841 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9094 | 9842 | |
---|
.. | .. |
---|
9224 | 9972 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
9225 | 9973 | gl.glLoadIdentity(); |
---|
9226 | 9974 | |
---|
9227 | | - if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
| 9975 | + if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
9228 | 9976 | { |
---|
9229 | 9977 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9230 | 9978 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 9979 | +// PATCH FILLE AUX JEANS |
---|
| 9980 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9231 | 9981 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9232 | 9982 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9233 | 9983 | //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE); |
---|
.. | .. |
---|
9280 | 10030 | //gl.glPushMatrix(); |
---|
9281 | 10031 | gl.glLoadIdentity(); |
---|
9282 | 10032 | |
---|
9283 | | - if (!ambientOcclusion) // drawMode != OCCLUSION) |
---|
| 10033 | + if (!ambientOcclusion) // DrawMode() != OCCLUSION) |
---|
9284 | 10034 | { |
---|
9285 | 10035 | //LA.xformPos(light0, lightCamera.fromScreen, light); |
---|
9286 | 10036 | LA.xformDir(dirlight, lightCamera.fromScreen, lightposition); |
---|
.. | .. |
---|
9367 | 10117 | } |
---|
9368 | 10118 | |
---|
9369 | 10119 | /**/ |
---|
9370 | | - if (true) // drawMode == SELECTION) // != DEFAULT) |
---|
| 10120 | + if (true) // DrawMode() == SELECTION) // != DEFAULT) |
---|
9371 | 10121 | gl.glDisable(gl.GL_LIGHTING); |
---|
9372 | 10122 | else |
---|
9373 | 10123 | gl.glEnable(gl.GL_LIGHTING); |
---|
.. | .. |
---|
9379 | 10129 | |
---|
9380 | 10130 | gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0); |
---|
9381 | 10131 | gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0); |
---|
| 10132 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0); |
---|
9382 | 10133 | |
---|
9383 | 10134 | options2[0] *= renderCamera.Distance(); |
---|
9384 | 10135 | |
---|
9385 | 10136 | lightslot = 64; |
---|
9386 | 10137 | |
---|
9387 | | - if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT) |
---|
| 10138 | + if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT) |
---|
9388 | 10139 | { |
---|
9389 | 10140 | DrawLights(object); |
---|
9390 | 10141 | } |
---|
.. | .. |
---|
9395 | 10146 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
9396 | 10147 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
9397 | 10148 | |
---|
9398 | | - if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION) |
---|
| 10149 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION) |
---|
9399 | 10150 | { |
---|
9400 | 10151 | /* |
---|
9401 | 10152 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
9428 | 10179 | } |
---|
9429 | 10180 | } |
---|
9430 | 10181 | |
---|
9431 | | - if (drawMode == DEFAULT) |
---|
| 10182 | + if (DrawMode() == DEFAULT) |
---|
9432 | 10183 | { |
---|
9433 | 10184 | if (WIREFRAME && !ambientOcclusion) |
---|
9434 | 10185 | { |
---|
.. | .. |
---|
9446 | 10197 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9447 | 10198 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9448 | 10199 | |
---|
9449 | | - if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) // |
---|
| 10200 | + if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) // |
---|
9450 | 10201 | { |
---|
9451 | 10202 | if (vertexMode != 0) // && !fast) |
---|
9452 | 10203 | { |
---|
.. | .. |
---|
9466 | 10217 | } |
---|
9467 | 10218 | } |
---|
9468 | 10219 | |
---|
9469 | | - if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion) |
---|
| 10220 | + if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
9470 | 10221 | { |
---|
9471 | 10222 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
9472 | 10223 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
9494 | 10245 | //gl.glDepthMask(false); |
---|
9495 | 10246 | } |
---|
9496 | 10247 | |
---|
9497 | | - if (false) // drawMode == SHADOW) |
---|
| 10248 | + if (false) // DrawMode() == SHADOW) |
---|
9498 | 10249 | { |
---|
9499 | 10250 | //SetColumnMajorData(cameraInverseTransform, view_1); |
---|
9500 | 10251 | //System.out.println("light = " + cameraInverseTransform); |
---|
.. | .. |
---|
9508 | 10259 | //System.out.println("object = " + object); |
---|
9509 | 10260 | if (!frozen && !imageLocked) |
---|
9510 | 10261 | { |
---|
9511 | | - if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0) |
---|
| 10262 | + if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0) |
---|
9512 | 10263 | { |
---|
9513 | 10264 | displayAntiAliased(gl); |
---|
9514 | 10265 | } else |
---|
9515 | 10266 | { |
---|
9516 | 10267 | programcount = 0; |
---|
9517 | | - int keepmode = drawMode; |
---|
| 10268 | + int keepmode = DrawMode(); |
---|
9518 | 10269 | // if (DEBUG_SELECTION) |
---|
9519 | 10270 | // { |
---|
9520 | | -// drawMode = SELECTION; |
---|
| 10271 | +// DrawMode() = SELECTION; |
---|
9521 | 10272 | // } |
---|
9522 | 10273 | // for point selection |
---|
9523 | 10274 | // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0); |
---|
.. | .. |
---|
9527 | 10278 | DrawObject(gl); |
---|
9528 | 10279 | |
---|
9529 | 10280 | // jan 2013 System.err.println("RESET ABORT (display)"); |
---|
9530 | | - // if (drawMode == DEFAULT) |
---|
| 10281 | + // if (DrawMode() == DEFAULT) |
---|
9531 | 10282 | // ABORTED = false; |
---|
9532 | 10283 | fullreset = false; |
---|
9533 | | - drawMode = keepmode; |
---|
| 10284 | + Globals.drawMode = keepmode; // WARNING |
---|
9534 | 10285 | //System.out.println("PROGRAM SWITCH " + programcount); |
---|
9535 | 10286 | } |
---|
9536 | 10287 | } |
---|
.. | .. |
---|
9538 | 10289 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9539 | 10290 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9540 | 10291 | |
---|
9541 | | - if (drawMode == DEFAULT) |
---|
| 10292 | + if (DrawMode() == DEFAULT) |
---|
9542 | 10293 | { |
---|
9543 | 10294 | ReleaseTexture(NOISE_TEXTURE, false); |
---|
9544 | 10295 | } |
---|
9545 | | - //if (drawMode == DEFAULT) |
---|
| 10296 | + //if (DrawMode() == DEFAULT) |
---|
9546 | 10297 | { |
---|
9547 | 10298 | |
---|
9548 | 10299 | gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
.. | .. |
---|
9554 | 10305 | //else |
---|
9555 | 10306 | //gl.glDisable(gl.GL_TEXTURE_2D); |
---|
9556 | 10307 | //gl.glPopMatrix(); |
---|
9557 | | - if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
| 10308 | + if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
9558 | 10309 | { |
---|
9559 | 10310 | //new Exception().printStackTrace(); |
---|
9560 | 10311 | //System.out.println("Draw image " + width + ", " + height); |
---|
.. | .. |
---|
9596 | 10347 | //gl.glFlush(); |
---|
9597 | 10348 | } |
---|
9598 | 10349 | |
---|
9599 | | - if (flash && drawMode == DEFAULT) |
---|
| 10350 | + if (flash && DrawMode() == DEFAULT) |
---|
9600 | 10351 | { |
---|
9601 | 10352 | flash = false; |
---|
9602 | 10353 | wait = true; |
---|
.. | .. |
---|
9604 | 10355 | } |
---|
9605 | 10356 | |
---|
9606 | 10357 | //drawing = false; |
---|
9607 | | - //if(drawMode == DEFAULT) |
---|
| 10358 | + //if(DrawMode() == DEFAULT) |
---|
9608 | 10359 | // niceon = false; |
---|
9609 | | - if (drawMode == DEFAULT) |
---|
| 10360 | + if (DrawMode() == DEFAULT) |
---|
9610 | 10361 | { |
---|
9611 | 10362 | currentlydrawing = false; |
---|
9612 | 10363 | } |
---|
.. | .. |
---|
9626 | 10377 | repaint(); |
---|
9627 | 10378 | } |
---|
9628 | 10379 | |
---|
9629 | | - if (isLIVE() && drawMode == DEFAULT) // may 2013 |
---|
| 10380 | + if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 |
---|
9630 | 10381 | repaint(); |
---|
9631 | 10382 | |
---|
9632 | 10383 | displaydone = true; |
---|
.. | .. |
---|
9663 | 10414 | if (GrafreeD.RENDERME > 0) |
---|
9664 | 10415 | GrafreeD.RENDERME--; // mechante magouille |
---|
9665 | 10416 | |
---|
9666 | | - ONESTEP = false; |
---|
| 10417 | + Globals.ONESTEP = false; |
---|
9667 | 10418 | } |
---|
9668 | 10419 | |
---|
9669 | 10420 | static boolean zoomonce = false; |
---|
.. | .. |
---|
9671 | 10422 | void DrawObject(GL gl, boolean draw) |
---|
9672 | 10423 | { |
---|
9673 | 10424 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
9674 | | -// drawMode = SELECTION; |
---|
| 10425 | +// DrawMode() = SELECTION; |
---|
9675 | 10426 | //GL gl = getGL(); |
---|
9676 | 10427 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
9677 | 10428 | { |
---|
9678 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 10429 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
9679 | 10430 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
9680 | 10431 | pingthread.StepToTarget(true); // true); |
---|
9681 | 10432 | // zoomonce = false; |
---|
.. | .. |
---|
9696 | 10447 | callist = gl.glGenLists(1); |
---|
9697 | 10448 | } |
---|
9698 | 10449 | |
---|
9699 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 10450 | + boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
9700 | 10451 | |
---|
9701 | | - boolean active = !selectmode; // drawMode != SELECTION; // mouseDown; |
---|
| 10452 | + boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
9702 | 10453 | |
---|
9703 | 10454 | if (!mainDL || !active || touched) |
---|
9704 | 10455 | { |
---|
.. | .. |
---|
9725 | 10476 | PushMatrix(ClickInfo.matbuffer); |
---|
9726 | 10477 | } |
---|
9727 | 10478 | |
---|
9728 | | - if (drawMode == 0) |
---|
| 10479 | + if (DrawMode() == 0) |
---|
9729 | 10480 | { |
---|
9730 | 10481 | // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++"); |
---|
9731 | 10482 | |
---|
.. | .. |
---|
9739 | 10490 | // DRAW |
---|
9740 | 10491 | object.draw(this, /*(Composite)*/ object, false, false); |
---|
9741 | 10492 | |
---|
9742 | | - if (drawMode == DEFAULT) |
---|
| 10493 | + if (DrawMode() == DEFAULT) |
---|
9743 | 10494 | { |
---|
9744 | 10495 | if (DEBUG) |
---|
9745 | 10496 | { |
---|
.. | .. |
---|
9750 | 10501 | selectedpoint.radius = radius; |
---|
9751 | 10502 | selectedpoint.recalculate(); |
---|
9752 | 10503 | selectedpoint.material = new cMaterial(); |
---|
9753 | | - selectedpoint.material.color = 0.25f; |
---|
| 10504 | + selectedpoint.material.color = 0.15f; // Yellow |
---|
9754 | 10505 | selectedpoint.material.modulation = 0.75f; |
---|
9755 | 10506 | |
---|
9756 | | - debugpoint.radius = radius; |
---|
9757 | | - debugpoint.recalculate(); |
---|
9758 | | - debugpoint.material = new cMaterial(); |
---|
9759 | | - debugpoint.material.color = 0.25f; |
---|
9760 | | - debugpoint.material.modulation = 0.75f; |
---|
| 10507 | + debugpointG.radius = radius; |
---|
| 10508 | + debugpointG.recalculate(); |
---|
| 10509 | + debugpointG.material = new cMaterial(); |
---|
| 10510 | + debugpointG.material.color = 0.25f; // Green |
---|
| 10511 | + debugpointG.material.modulation = 0.75f; |
---|
9761 | 10512 | |
---|
9762 | | - debugpoint2.radius = radius; |
---|
9763 | | - debugpoint2.recalculate(); |
---|
9764 | | - debugpoint2.material = new cMaterial(); |
---|
9765 | | - debugpoint2.material.color = 0.75f; |
---|
9766 | | - debugpoint2.material.modulation = 0.75f; |
---|
| 10513 | + debugpointP.radius = radius; |
---|
| 10514 | + debugpointP.recalculate(); |
---|
| 10515 | + debugpointP.material = new cMaterial(); |
---|
| 10516 | + debugpointP.material.color = 0.75f; // Purple |
---|
| 10517 | + debugpointP.material.modulation = 0.75f; |
---|
9767 | 10518 | |
---|
9768 | | - debugpoint3.radius = radius; |
---|
9769 | | - debugpoint3.recalculate(); |
---|
9770 | | - debugpoint3.material = new cMaterial(); |
---|
9771 | | - debugpoint3.material.color = 0.5f; |
---|
9772 | | - debugpoint3.material.modulation = 0.75f; |
---|
| 10519 | + debugpointC.radius = radius; |
---|
| 10520 | + debugpointC.recalculate(); |
---|
| 10521 | + debugpointC.material = new cMaterial(); |
---|
| 10522 | + debugpointC.material.color = 0.5f; // Cyan |
---|
| 10523 | + debugpointC.material.modulation = 0.75f; |
---|
9773 | 10524 | |
---|
9774 | | - debugpoint4.radius = radius; |
---|
9775 | | - debugpoint4.recalculate(); |
---|
9776 | | - debugpoint4.material = new cMaterial(); |
---|
9777 | | - debugpoint4.material.color = 0f; |
---|
9778 | | - debugpoint4.material.modulation = 0.75f; |
---|
| 10525 | + debugpointR.radius = radius; |
---|
| 10526 | + debugpointR.recalculate(); |
---|
| 10527 | + debugpointR.material = new cMaterial(); |
---|
| 10528 | + debugpointR.material.color = 0f; // Red |
---|
| 10529 | + debugpointR.material.modulation = 0.75f; |
---|
9779 | 10530 | |
---|
9780 | 10531 | InitPoints(radius); |
---|
9781 | 10532 | } |
---|
9782 | 10533 | selectedpoint.draw(this, /*(Composite)*/ null, false, false); |
---|
9783 | | - debugpoint.draw(this, /*(Composite)*/ null, false,false); |
---|
9784 | | - debugpoint2.draw(this, /*(Composite)*/ null, false,false); |
---|
9785 | | - debugpoint3.draw(this, /*(Composite)*/ null, false,false); |
---|
9786 | | - debugpoint4.draw(this, /*(Composite)*/ null, false,false); |
---|
| 10534 | + debugpointG.draw(this, /*(Composite)*/ null, false,false); |
---|
| 10535 | + debugpointP.draw(this, /*(Composite)*/ null, false,false); |
---|
| 10536 | + debugpointC.draw(this, /*(Composite)*/ null, false,false); |
---|
| 10537 | + debugpointR.draw(this, /*(Composite)*/ null, false,false); |
---|
9787 | 10538 | // DrawPoints(this); |
---|
9788 | 10539 | } |
---|
9789 | 10540 | |
---|
.. | .. |
---|
9791 | 10542 | } |
---|
9792 | 10543 | // GrafreeD.traceoff(); |
---|
9793 | 10544 | //System.out.println(stackdepth); |
---|
9794 | | - if (drawMode == 0) |
---|
| 10545 | + if (DrawMode() == 0) |
---|
9795 | 10546 | { |
---|
9796 | 10547 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
9797 | 10548 | |
---|
.. | .. |
---|
9816 | 10567 | |
---|
9817 | 10568 | checker = null; |
---|
9818 | 10569 | |
---|
9819 | | - if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT) |
---|
| 10570 | + if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT) |
---|
9820 | 10571 | FindChecker(object); |
---|
9821 | 10572 | |
---|
9822 | | - if (checker != null && drawMode == DEFAULT) |
---|
| 10573 | + if (checker != null && DrawMode() == DEFAULT) |
---|
9823 | 10574 | { |
---|
9824 | | - // BindTexture(IMMORTAL_TEXTURE); |
---|
| 10575 | + //BindTexture(IMMORTAL_TEXTURE); |
---|
| 10576 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
9825 | 10577 | // NEAREST |
---|
9826 | 10578 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
9827 | 10579 | DrawChecker(gl); |
---|
9828 | 10580 | //checker.Draw(this, null, false); |
---|
9829 | 10581 | // ReleaseTexture(IMMORTAL_TEXTURE); |
---|
| 10582 | + ReleaseTextures(checker.GetTextures()); |
---|
9830 | 10583 | } |
---|
9831 | 10584 | |
---|
9832 | 10585 | if (object.parent != null) |
---|
.. | .. |
---|
9839 | 10592 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9840 | 10593 | //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9841 | 10594 | |
---|
9842 | | - if (DISPLAYTEXT && drawMode == DEFAULT) |
---|
| 10595 | + if (DISPLAYTEXT && DrawMode() == DEFAULT) |
---|
9843 | 10596 | { |
---|
9844 | 10597 | // Draw it once, then use the raster |
---|
9845 | 10598 | Balloon(gl, balloon.createGraphics()); |
---|
.. | .. |
---|
9895 | 10648 | int[] xs = new int[3]; |
---|
9896 | 10649 | int[] ys = new int[3]; |
---|
9897 | 10650 | |
---|
9898 | | - void DrawString(Object3D obj) // String string) |
---|
| 10651 | + public void DrawString(Object3D obj) // String string) // INTERFACE |
---|
9899 | 10652 | { |
---|
9900 | | - if (!DISPLAYTEXT || drawMode != DEFAULT) |
---|
| 10653 | + if (!DISPLAYTEXT || DrawMode() != DEFAULT) |
---|
9901 | 10654 | { |
---|
9902 | 10655 | return; |
---|
9903 | 10656 | } |
---|
.. | .. |
---|
10357 | 11110 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
10358 | 11111 | "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
10359 | 11112 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
10360 | | - "PARAM options1 = program.env[62];" + // fog rgb color, image intensity |
---|
| 11113 | + "PARAM options1 = program.env[62];" + // fog rgb color |
---|
| 11114 | + "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
10361 | 11115 | "PARAM pointlight = program.env[127];" + // ... |
---|
10362 | 11116 | "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" + |
---|
10363 | 11117 | "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" + |
---|
10364 | 11118 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
| 11119 | + "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" + |
---|
10365 | 11120 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
10366 | 11121 | "PARAM ten = { 10, 10, 10, 1.0 };" + |
---|
10367 | 11122 | "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" + |
---|
.. | .. |
---|
10382 | 11137 | "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" + |
---|
10383 | 11138 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
10384 | 11139 | "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" + |
---|
| 11140 | + "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" + |
---|
10385 | 11141 | "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" + |
---|
10386 | 11142 | "PARAM c256 = { 256, 256, 256, 1.0 };" + |
---|
10387 | 11143 | "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" + |
---|
.. | .. |
---|
10422 | 11178 | "TEMP R1;" + |
---|
10423 | 11179 | "TEMP R2;" + |
---|
10424 | 11180 | "TEMP R3;" + |
---|
| 11181 | + "TEMP min;" + |
---|
| 11182 | + "TEMP max;" + |
---|
| 11183 | + "TEMP average;" + |
---|
| 11184 | + "TEMP saturation;" + |
---|
10425 | 11185 | "TEMP keep1;" + |
---|
10426 | 11186 | "TEMP keep2;" + |
---|
10427 | 11187 | "TEMP keep3;" + |
---|
.. | .. |
---|
10952 | 11712 | |
---|
10953 | 11713 | // skin? |
---|
10954 | 11714 | // Saturation for skin |
---|
10955 | | - /**/ // c'est ici |
---|
10956 | | - (Skinshader? "DP3 temp.x, final,one;" + |
---|
| 11715 | + /**/ |
---|
| 11716 | + (Skinshader? |
---|
| 11717 | + "DP3 average.x, final,one;" + |
---|
| 11718 | + "MUL average, one3rd.xxxx,average.xxxx;" + |
---|
| 11719 | + |
---|
| 11720 | + "MIN min.x, final.x,final.y;" + |
---|
| 11721 | + "MIN min.x, min.x,final.z;" + |
---|
| 11722 | + |
---|
| 11723 | + "MAX max.x, final.x,final.y;" + |
---|
| 11724 | + "MAX max.x, max.x,final.z;" + |
---|
| 11725 | + "MOV max, max.xxxx;" + |
---|
| 11726 | + |
---|
| 11727 | + "SUB saturation, max, final;" + |
---|
| 11728 | + |
---|
| 11729 | + "ADD temp.x, max.x, one10th.x;" + |
---|
| 11730 | + "RCP temp.x, temp.x;" + |
---|
| 11731 | + "MUL temp.x, temp.x, half.x;" + |
---|
| 11732 | + "MUL saturation, saturation, temp.xxxx;" + |
---|
| 11733 | + |
---|
| 11734 | + "DP3 ndotl.x, normald, light;" + |
---|
| 11735 | + "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
| 11736 | + |
---|
| 11737 | + "SUB temp.x, one.x, ndotl.x;" + |
---|
| 11738 | + "ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 11739 | + "ADD temp.y, one.y, options2.y;" + // sursurface |
---|
| 11740 | + "MUL temp.x, temp.x, temp.y;" + |
---|
| 11741 | + |
---|
| 11742 | + "MUL saturation, saturation, temp.xxxx;" + |
---|
| 11743 | + "SUB_SAT temp, max, saturation;" + |
---|
| 11744 | +/** |
---|
| 11745 | + "DP3 temp.x, final,one;" + |
---|
10957 | 11746 | "MUL R2, one3rd.xxxx,temp.xxxx;" + |
---|
10958 | | - "SUB temp, final,R2;" + |
---|
| 11747 | + "SUB temp, final, R2;" + |
---|
| 11748 | + |
---|
10959 | 11749 | // using light angle |
---|
10960 | 11750 | "DP3 ndotl.x, normald,light;" + |
---|
10961 | 11751 | //"SLT ndotl.y, ndotl.x, zero.x;" + |
---|
.. | .. |
---|
10968 | 11758 | // using light intensity |
---|
10969 | 11759 | "MOV ndotl.z, R2.x;" + |
---|
10970 | 11760 | "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning... |
---|
10971 | | - |
---|
10972 | 11761 | // june 2014 |
---|
10973 | 11762 | "MAD R1.x, ndotl.z,slope.y,one.x;" + |
---|
10974 | 11763 | // "SUB ndotl.x, one.x, ndotl.x;" + |
---|
.. | .. |
---|
10980 | 11769 | //"MUL R2.y, shadow.x,R2.y;" + // avril 2014 |
---|
10981 | 11770 | |
---|
10982 | 11771 | "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin) |
---|
| 11772 | +/**/ |
---|
10983 | 11773 | |
---|
10984 | 11774 | // "ADD final, R2,temp;" + |
---|
10985 | 11775 | "MOV final, temp;" |
---|
.. | .. |
---|
11069 | 11859 | /**/ |
---|
11070 | 11860 | // HDR |
---|
11071 | 11861 | "MOV temp.z, final.a;" + |
---|
11072 | | - "MUL final, final,options1.w;" + |
---|
| 11862 | + "MUL final, final,options2.x;" + |
---|
11073 | 11863 | "MOV final.a, temp.z;" + |
---|
11074 | 11864 | /**/ |
---|
11075 | 11865 | |
---|
.. | .. |
---|
11262 | 12052 | String Shadow(String depth, String shadow) |
---|
11263 | 12053 | { |
---|
11264 | 12054 | return "MAX temp.x, ndotl.x, one64th.x;" + |
---|
| 12055 | + "MIN temp.x, temp.x, ninetenth.x;" + |
---|
11265 | 12056 | /**/ |
---|
11266 | 12057 | // Sine |
---|
11267 | 12058 | "MUL temp.y, temp.x, temp.x;" + |
---|
.. | .. |
---|
11886 | 12677 | return; |
---|
11887 | 12678 | } |
---|
11888 | 12679 | |
---|
| 12680 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
11889 | 12681 | |
---|
11890 | 12682 | // TIMER |
---|
11891 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR |
---|
| 12683 | + if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
11892 | 12684 | { |
---|
11893 | 12685 | keepboxmode = BOXMODE; |
---|
11894 | 12686 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
12017 | 12809 | // ObjEditor.tweenManager.update(1f / 60f); |
---|
12018 | 12810 | |
---|
12019 | 12811 | // fev 2014??? |
---|
12020 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode) |
---|
| 12812 | + if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
12021 | 12813 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
12022 | 12814 | pingthread.StepToTarget(true); // true); |
---|
12023 | 12815 | } |
---|
.. | .. |
---|
12268 | 13060 | //System.out.println("---------------- ---------- Paint " + tmp.length2()); |
---|
12269 | 13061 | if (lightMode) |
---|
12270 | 13062 | { |
---|
12271 | | - lighttouched = true; |
---|
| 13063 | + Globals.lighttouched = true; |
---|
12272 | 13064 | } |
---|
12273 | 13065 | |
---|
12274 | 13066 | if (OEILONCE && OEIL) |
---|
.. | .. |
---|
12326 | 13118 | mouseDown = false; |
---|
12327 | 13119 | if (lightMode) |
---|
12328 | 13120 | { |
---|
12329 | | - lighttouched = true; |
---|
| 13121 | + Globals.lighttouched = true; |
---|
12330 | 13122 | } |
---|
12331 | 13123 | repaint(); |
---|
12332 | 13124 | alreadypainted = true; |
---|
.. | .. |
---|
12334 | 13126 | isMoving = false; |
---|
12335 | 13127 | } //?? |
---|
12336 | 13128 | |
---|
12337 | | - if (isLIVE() && !alreadypainted) |
---|
| 13129 | + if (Globals.isLIVE() && !alreadypainted) |
---|
12338 | 13130 | { |
---|
12339 | 13131 | // FOR DEBUG BREAKPOINT USING PAUSE: while (true) |
---|
12340 | 13132 | repaint(); |
---|
.. | .. |
---|
12346 | 13138 | { |
---|
12347 | 13139 | if (lightMode) |
---|
12348 | 13140 | { |
---|
12349 | | - lighttouched = true; |
---|
| 13141 | + Globals.lighttouched = true; |
---|
12350 | 13142 | } |
---|
12351 | 13143 | drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
12352 | 13144 | } |
---|
.. | .. |
---|
12589 | 13381 | { |
---|
12590 | 13382 | manipCamera.Translate(dx, dy, getWidth()); |
---|
12591 | 13383 | } |
---|
| 13384 | + else |
---|
12592 | 13385 | if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0) |
---|
12593 | 13386 | { |
---|
12594 | 13387 | manipCamera.RotateInterest(dx, dy); |
---|
.. | .. |
---|
12599 | 13392 | |
---|
12600 | 13393 | if (manipCamera == lightCamera) |
---|
12601 | 13394 | { |
---|
12602 | | - lighttouched = true; |
---|
| 13395 | + Globals.lighttouched = true; |
---|
12603 | 13396 | } |
---|
12604 | 13397 | /* |
---|
12605 | 13398 | switch (mode) |
---|
.. | .. |
---|
12814 | 13607 | { |
---|
12815 | 13608 | mouseMode |= ZOOM; |
---|
12816 | 13609 | } |
---|
12817 | | - if ((modifiers & META) == META) |
---|
| 13610 | + |
---|
| 13611 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
| 13612 | + if (capsLocked || (modifiers & META) == META) |
---|
12818 | 13613 | { |
---|
12819 | 13614 | mouseMode |= VR; // BACKFORTH; |
---|
12820 | 13615 | } |
---|
12821 | 13616 | if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
12822 | 13617 | { |
---|
12823 | | - mouseMode |= SELECT; // BACKFORTH; |
---|
| 13618 | + mouseMode |= SELECT; |
---|
12824 | 13619 | } |
---|
12825 | 13620 | if ((modifiers & COMMAND) == COMMAND) |
---|
12826 | 13621 | { |
---|
.. | .. |
---|
12828 | 13623 | } |
---|
12829 | 13624 | if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
12830 | 13625 | { |
---|
| 13626 | + mouseMode &= ~VR; |
---|
12831 | 13627 | mouseMode |= TRANSLATE; |
---|
12832 | 13628 | } |
---|
12833 | 13629 | // if ((modifiers & SHIFT_META) == SHIFT_META) |
---|
.. | .. |
---|
12984 | 13780 | case 'B': |
---|
12985 | 13781 | BRISMOOTH ^= true; |
---|
12986 | 13782 | SHADOWCULLFACE ^= true; |
---|
12987 | | - lighttouched = true; |
---|
| 13783 | + Globals.lighttouched = true; |
---|
12988 | 13784 | repaint(); |
---|
12989 | 13785 | break; |
---|
12990 | 13786 | case 'b': |
---|
.. | .. |
---|
13084 | 13880 | repaint(); |
---|
13085 | 13881 | break; |
---|
13086 | 13882 | case 'O': |
---|
13087 | | - drawMode = OCCLUSION; |
---|
| 13883 | + Globals.drawMode = OCCLUSION; // WARNING |
---|
13088 | 13884 | repaint(); |
---|
13089 | 13885 | break; |
---|
13090 | 13886 | case 'o': |
---|
.. | .. |
---|
13175 | 13971 | break; |
---|
13176 | 13972 | case ' ': |
---|
13177 | 13973 | lightMode ^= true; |
---|
13178 | | - lighttouched = true; |
---|
| 13974 | + Globals.lighttouched = true; |
---|
13179 | 13975 | manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
13180 | 13976 | targetLookAt.set(manipCamera.lookAt); |
---|
13181 | 13977 | repaint(); |
---|
.. | .. |
---|
13187 | 13983 | repaint(); |
---|
13188 | 13984 | break; |
---|
13189 | 13985 | case 'Z': |
---|
13190 | | - RESIZETEXTURE ^= true; |
---|
13191 | | - break; |
---|
| 13986 | + //RESIZETEXTURE ^= true; |
---|
| 13987 | + //break; |
---|
13192 | 13988 | case 'z': |
---|
13193 | 13989 | RENDERSHADOW ^= true; |
---|
13194 | | - lighttouched = true; |
---|
| 13990 | + Globals.lighttouched = true; |
---|
13195 | 13991 | repaint(); |
---|
13196 | 13992 | break; |
---|
13197 | 13993 | //case UP: |
---|
.. | .. |
---|
13217 | 14013 | FlipTransform(); |
---|
13218 | 14014 | break; |
---|
13219 | 14015 | case ENTER: |
---|
13220 | | - object.editWindow.ScreenFit(); // Edit(); |
---|
| 14016 | + // object.editWindow.ScreenFit(); // Edit(); |
---|
| 14017 | + ToggleLive(); |
---|
13221 | 14018 | break; |
---|
13222 | 14019 | case DELETE: |
---|
13223 | 14020 | ClearSelection(); |
---|
.. | .. |
---|
13792 | 14589 | //if (g != gr) g.drawImage(img, 0, 0, width, height, null); |
---|
13793 | 14590 | } |
---|
13794 | 14591 | |
---|
| 14592 | + // To avoid clear. |
---|
13795 | 14593 | public void update(Graphics g) |
---|
13796 | 14594 | { |
---|
13797 | 14595 | paint(g); |
---|
.. | .. |
---|
14394 | 15192 | gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS); |
---|
14395 | 15193 | gl.glPushMatrix(); |
---|
14396 | 15194 | gl.glLoadIdentity(); |
---|
14397 | | - PushMatrix(checker.toParent); |
---|
| 15195 | + //PushMatrix(checker.toParent); |
---|
14398 | 15196 | |
---|
14399 | 15197 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
14400 | 15198 | gl.glPushMatrix(); |
---|
.. | .. |
---|
14417 | 15215 | |
---|
14418 | 15216 | gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
14419 | 15217 | |
---|
14420 | | - float step = 0.1666f; //0.25f; |
---|
14421 | | - float stepv = step * 1652 / 998; |
---|
| 15218 | + float step = 2; // 0.1666f; //0.25f; |
---|
| 15219 | + float stepv = 2; // step * 1652 / 998; |
---|
14422 | 15220 | |
---|
14423 | 15221 | int i0 = 0; |
---|
14424 | 15222 | /* |
---|
.. | .. |
---|
14454 | 15252 | /**/ |
---|
14455 | 15253 | //checker.GetMaterial().opacity = 1.1f; |
---|
14456 | 15254 | ////checker.GetMaterial().ambient = 0.99f; |
---|
14457 | | - Object3D.materialstack[Object3D.materialdepth] = checker.material; |
---|
14458 | | - Object3D.selectedstack[Object3D.materialdepth] = false; |
---|
14459 | | - cStatic.objectstack[Object3D.materialdepth++] = checker; |
---|
| 15255 | + materialstack[materialdepth] = checker.material; |
---|
| 15256 | + selectedstack[materialdepth] = false; |
---|
| 15257 | + cStatic.objectstack[materialdepth++] = checker; |
---|
14460 | 15258 | //System.out.println("material " + material); |
---|
14461 | 15259 | //Applet3D.tracein(this, selected); |
---|
14462 | 15260 | vector2buffer = checker.projectedVertices; |
---|
14463 | 15261 | |
---|
14464 | | - checker.GetMaterial().Draw(this, false); // true); |
---|
| 15262 | + //checker.GetMaterial().Draw(this, false); // true); |
---|
| 15263 | + DrawMaterial(checker.GetMaterial(), false); // true); |
---|
14465 | 15264 | |
---|
14466 | | - Object3D.materialdepth -= 1; |
---|
14467 | | - if (Object3D.materialdepth > 0) |
---|
| 15265 | + materialdepth -= 1; |
---|
| 15266 | + if (materialdepth > 0) |
---|
14468 | 15267 | { |
---|
14469 | | - vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices; |
---|
14470 | | - Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]); |
---|
| 15268 | + vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 15269 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
14471 | 15270 | } |
---|
14472 | 15271 | //checker.GetMaterial().opacity = 1f; |
---|
14473 | 15272 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
14488 | 15287 | |
---|
14489 | 15288 | //float u = (i+1)/2; |
---|
14490 | 15289 | //float v = (j+1)/2; |
---|
14491 | | - gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
| 15290 | + if (checker.flipV) |
---|
| 15291 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2); |
---|
| 15292 | + else |
---|
| 15293 | + gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
14492 | 15294 | gl.glVertex3f(i, j, -0.5f); |
---|
14493 | 15295 | |
---|
| 15296 | + if (checker.flipV) |
---|
| 15297 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
| 15298 | + else |
---|
14494 | 15299 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
14495 | 15300 | gl.glVertex3f(i + step, j, -0.5f); |
---|
14496 | 15301 | |
---|
| 15302 | + if (checker.flipV) |
---|
| 15303 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
| 15304 | + else |
---|
14497 | 15305 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
14498 | 15306 | gl.glVertex3f(i + step, j + stepv, -0.5f); |
---|
14499 | 15307 | |
---|
| 15308 | + if (checker.flipV) |
---|
| 15309 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
| 15310 | + else |
---|
14500 | 15311 | gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
14501 | 15312 | gl.glVertex3f(i, j + stepv, -0.5f); |
---|
14502 | 15313 | } |
---|
.. | .. |
---|
14508 | 15319 | gl.glMatrixMode(GL.GL_PROJECTION); |
---|
14509 | 15320 | gl.glPopMatrix(); |
---|
14510 | 15321 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
14511 | | - PopMatrix(null); // checker.toParent); // null); |
---|
| 15322 | + //PopMatrix(null); // checker.toParent); // null); |
---|
14512 | 15323 | gl.glPopMatrix(); |
---|
14513 | 15324 | PopTextureMatrix(checker.toParent); |
---|
14514 | 15325 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
.. | .. |
---|
14621 | 15432 | |
---|
14622 | 15433 | //int tmp = selection_view; |
---|
14623 | 15434 | //selection_view = -1; |
---|
14624 | | - int temp = drawMode; |
---|
14625 | | - drawMode = SELECTION; |
---|
| 15435 | + int temp = DrawMode(); |
---|
| 15436 | + Globals.drawMode = SELECTION; // WARNING |
---|
14626 | 15437 | indexcount = 0; |
---|
14627 | 15438 | parent.display(drawable); |
---|
14628 | 15439 | //selection_view = tmp; |
---|
14629 | 15440 | //if (temp == SELECTION) |
---|
14630 | 15441 | // temp = DEFAULT; // patch for selection debug |
---|
14631 | | - drawMode = temp; |
---|
| 15442 | + Globals.drawMode = temp; // WARNING |
---|
14632 | 15443 | |
---|
14633 | 15444 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
14634 | 15445 | |
---|
.. | .. |
---|
14677 | 15488 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
14678 | 15489 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
14679 | 15490 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 15491 | + |
---|
| 15492 | + // Will fit the mesh !!! |
---|
| 15493 | + selectedpoint.toParent[0][0] = 0.0001; |
---|
| 15494 | + selectedpoint.toParent[1][1] = 0.0001; |
---|
| 15495 | + selectedpoint.toParent[2][2] = 0.0001; |
---|
14680 | 15496 | |
---|
14681 | 15497 | glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0); |
---|
14682 | 15498 | |
---|
.. | .. |
---|
14896 | 15712 | //gl.glColorMask(false, false, false, false); |
---|
14897 | 15713 | |
---|
14898 | 15714 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
14899 | | - if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 15715 | + if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
14900 | 15716 | { |
---|
14901 | 15717 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14902 | 15718 | |
---|
14903 | | - int temp = drawMode; |
---|
14904 | | - drawMode = SHADOW; |
---|
| 15719 | + int temp = DrawMode(); |
---|
| 15720 | + Globals.drawMode = SHADOW; // WARNING |
---|
14905 | 15721 | parent.display(drawable); |
---|
14906 | | - drawMode = temp; |
---|
| 15722 | + Globals.drawMode = temp; // WARNING |
---|
14907 | 15723 | } |
---|
14908 | 15724 | |
---|
14909 | 15725 | gl.glCullFace(gl.GL_BACK); |
---|
.. | .. |
---|
15066 | 15882 | gl.glFlush(); |
---|
15067 | 15883 | |
---|
15068 | 15884 | /**/ |
---|
15069 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer); |
---|
| 15885 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
15070 | 15886 | |
---|
15071 | | - int[] pixels = occlusionsizebuffer.array(); |
---|
| 15887 | + float[] pixels = occlusionsizebuffer.array(); |
---|
15072 | 15888 | |
---|
15073 | 15889 | double r = 0, g = 0, b = 0; |
---|
15074 | 15890 | |
---|
15075 | 15891 | double count = 0; |
---|
| 15892 | + |
---|
| 15893 | + gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0); |
---|
| 15894 | + |
---|
| 15895 | + float mindepth = 1; |
---|
| 15896 | + |
---|
| 15897 | + double FACTOR = 1; |
---|
15076 | 15898 | |
---|
15077 | 15899 | for (int i = 0; i < pixels.length; i++) |
---|
15078 | 15900 | { |
---|
.. | .. |
---|
15157 | 15979 | |
---|
15158 | 15980 | double scale = ray.z; // 1; // cos |
---|
15159 | 15981 | |
---|
15160 | | - int p = pixels[newindex]; |
---|
| 15982 | + float depth = pixels[newindex]; |
---|
15161 | 15983 | |
---|
15162 | 15984 | /* |
---|
15163 | 15985 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
15181 | 16003 | scale = (1 - modu) * modv; |
---|
15182 | 16004 | */ |
---|
15183 | 16005 | |
---|
15184 | | - r += ((p >> 16) & 0xFF) * scale / 255; |
---|
15185 | | - g += ((p >> 8) & 0xFF) * scale / 255; |
---|
15186 | | - b += (p & 0xFF) * scale / 255; |
---|
| 16006 | + //r += ((p >> 16) & 0xFF) * scale / 255; |
---|
| 16007 | + //g += ((p >> 8) & 0xFF) * scale / 255; |
---|
| 16008 | + //b += (p & 0xFF) * scale / 255; |
---|
| 16009 | + |
---|
| 16010 | + if (mindepth > depth) |
---|
| 16011 | + { |
---|
| 16012 | + mindepth = depth; |
---|
| 16013 | + } |
---|
15187 | 16014 | |
---|
| 16015 | + double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]); |
---|
| 16016 | + |
---|
| 16017 | + double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR); |
---|
| 16018 | + |
---|
| 16019 | + r += factor * scale; |
---|
| 16020 | + g += factor * scale; |
---|
| 16021 | + b += factor * scale; |
---|
| 16022 | + |
---|
15188 | 16023 | count += scale; |
---|
15189 | 16024 | } |
---|
15190 | 16025 | |
---|
.. | .. |
---|
15282 | 16117 | GLUT glut = new GLUT(); |
---|
15283 | 16118 | |
---|
15284 | 16119 | |
---|
15285 | | - static final public int DEFAULT = 0; |
---|
15286 | | - static final public int SELECTION = 1; |
---|
15287 | | - static final public int SHADOW = 2; |
---|
15288 | | - static final public int OCCLUSION = 3; |
---|
15289 | | - static |
---|
15290 | | - public int drawMode = DEFAULT; |
---|
15291 | 16120 | public boolean spherical = false; |
---|
15292 | 16121 | static boolean DEBUG_OCCLUSION = false; |
---|
15293 | 16122 | static boolean DEBUG_SELECTION = false; |
---|
.. | .. |
---|
15300 | 16129 | int AAbuffersize = 0; |
---|
15301 | 16130 | |
---|
15302 | 16131 | //double[] selectedpoint = new double[3]; |
---|
15303 | | - static Sphere selectedpoint = new Sphere(); |
---|
| 16132 | + static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
15304 | 16133 | static Sphere previousselectedpoint = null; |
---|
15305 | | - static Sphere debugpoint = new Sphere(); |
---|
15306 | | - static Sphere debugpoint2 = new Sphere(); |
---|
15307 | | - static Sphere debugpoint3 = new Sphere(); |
---|
15308 | | - static Sphere debugpoint4 = new Sphere(); |
---|
| 16134 | + static Sphere debugpointG = new Sphere(); |
---|
| 16135 | + static Sphere debugpointP = new Sphere(); |
---|
| 16136 | + static Sphere debugpointC = new Sphere(); |
---|
| 16137 | + static Sphere debugpointR = new Sphere(); |
---|
15309 | 16138 | |
---|
15310 | 16139 | static Sphere debugpoints[] = new Sphere[8]; |
---|
15311 | 16140 | |
---|
.. | .. |
---|
15358 | 16187 | static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
15359 | 16188 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15360 | 16189 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15361 | | - static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 16190 | + //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 16191 | + static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
15362 | 16192 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
15363 | 16193 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
15364 | 16194 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|