.. | .. |
---|
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 boolean IsBoxMode() |
---|
| 196 | + { |
---|
| 197 | + return BOXMODE; |
---|
| 198 | + } |
---|
| 199 | + |
---|
| 200 | + public void ClearDepth() |
---|
182 | 201 | { |
---|
183 | 202 | GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT); |
---|
184 | 203 | } |
---|
185 | 204 | |
---|
186 | | - void DepthTest(boolean depthtest) |
---|
| 205 | + public void DepthTest(boolean depthtest) |
---|
187 | 206 | { |
---|
188 | 207 | if (depthtest) |
---|
189 | 208 | GetGL().glDepthFunc(GL.GL_LEQUAL); |
---|
.. | .. |
---|
191 | 210 | GetGL().glDepthFunc(GL.GL_ALWAYS); |
---|
192 | 211 | } |
---|
193 | 212 | |
---|
194 | | - void DepthWrite(boolean depthwrite) |
---|
| 213 | + public void DepthWrite(boolean depthwrite) |
---|
195 | 214 | { |
---|
196 | 215 | if (depthwrite) |
---|
197 | 216 | GetGL().glDepthMask(true); |
---|
.. | .. |
---|
199 | 218 | GetGL().glDepthMask(false); |
---|
200 | 219 | } |
---|
201 | 220 | |
---|
202 | | - void BackFaceCull(boolean bfc) |
---|
| 221 | + public void BackFaceCull(boolean bfc) |
---|
203 | 222 | { |
---|
204 | 223 | if (bfc) |
---|
205 | 224 | GetGL().glEnable(GetGL().GL_CULL_FACE); |
---|
206 | 225 | else |
---|
207 | 226 | GetGL().glDisable(GetGL().GL_CULL_FACE); |
---|
| 227 | + } |
---|
| 228 | + |
---|
| 229 | + public boolean BackFaceCullMode() |
---|
| 230 | + { |
---|
| 231 | + return this.CULLFACE; |
---|
| 232 | + } |
---|
| 233 | + |
---|
| 234 | + public boolean IsAmbientOcclusionOn() |
---|
| 235 | + { |
---|
| 236 | + return this.ambientOcclusion; |
---|
| 237 | + } |
---|
| 238 | + |
---|
| 239 | + public boolean IsFrozen() |
---|
| 240 | + { |
---|
| 241 | + boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 242 | + |
---|
| 243 | + return !selectmode && cameracount == 0; // != 0; |
---|
| 244 | + } |
---|
| 245 | + |
---|
| 246 | + // Currently in Globals |
---|
| 247 | + public int DrawMode() |
---|
| 248 | + { |
---|
| 249 | + return Globals.DrawMode(); |
---|
| 250 | + } |
---|
| 251 | + |
---|
| 252 | + public Camera EyeCamera() |
---|
| 253 | + { |
---|
| 254 | + return eyeCamera; |
---|
| 255 | + } |
---|
| 256 | + |
---|
| 257 | + public Camera LightCamera() |
---|
| 258 | + { |
---|
| 259 | + return lightCamera; |
---|
| 260 | + } |
---|
| 261 | + |
---|
| 262 | + public Camera RenderCamera() |
---|
| 263 | + { |
---|
| 264 | + return renderCamera; |
---|
| 265 | + } |
---|
| 266 | + |
---|
| 267 | + public void PushMaterial(Object3D obj, boolean selected) |
---|
| 268 | + { |
---|
| 269 | + CameraPane display = this; |
---|
| 270 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 271 | + cMaterial material = obj.material; |
---|
| 272 | + |
---|
| 273 | + if (material != null) |
---|
| 274 | + { |
---|
| 275 | + materialstack[materialdepth] = material; |
---|
| 276 | + selectedstack[materialdepth] = selected; |
---|
| 277 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 278 | + //System.out.println("material " + material); |
---|
| 279 | + //Applet3D.tracein(this, selected); |
---|
| 280 | + display.vector2buffer = obj.projectedVertices; |
---|
| 281 | + if (obj instanceof Camera) |
---|
| 282 | + { |
---|
| 283 | + display.options1[0] = material.shift; |
---|
| 284 | + //System.out.println("shift " + material.shift); |
---|
| 285 | + display.options1[1] = material.lightarea; |
---|
| 286 | + display.options1[2] = material.shadowbias; |
---|
| 287 | + display.options1[3] = material.aniso; |
---|
| 288 | + display.options1[4] = material.anisoV; |
---|
| 289 | + display.options2[0] = material.opacity; |
---|
| 290 | + display.options2[1] = material.diffuse; |
---|
| 291 | + display.options2[2] = material.factor; |
---|
| 292 | + |
---|
| 293 | + cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 294 | + display.options4[0] = material.cameralight/0.2f; |
---|
| 295 | + display.options4[1] = material.subsurface; |
---|
| 296 | + display.options4[2] = material.sheen; |
---|
| 297 | + |
---|
| 298 | + // if (display.CURRENTANTIALIAS > 0) |
---|
| 299 | + // display.options3[3] /= 4; |
---|
| 300 | + |
---|
| 301 | + /* |
---|
| 302 | + System.out.println("Focus = " + display.options1[0]); |
---|
| 303 | + System.out.println("Aperture = " + display.options1[1]); |
---|
| 304 | + System.out.println("ShadowBlur = " + display.options1[2]); |
---|
| 305 | + System.out.println("Antialiasing = " + display.options1[3]); |
---|
| 306 | + System.out.println("Fog = " + display.options2[0]); |
---|
| 307 | + System.out.println("Intensity = " + display.options2[1]); |
---|
| 308 | + System.out.println("Elevation = " + display.options2[2]); |
---|
| 309 | + /**/ |
---|
| 310 | + } else |
---|
| 311 | + { |
---|
| 312 | + DrawMaterial(material, selected); |
---|
| 313 | + } |
---|
| 314 | + } else |
---|
| 315 | + { |
---|
| 316 | + if (selected && CameraPane.flash) |
---|
| 317 | + { |
---|
| 318 | + display.modelParams4[1] = 100; |
---|
| 319 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 320 | + } |
---|
| 321 | + } |
---|
| 322 | + } |
---|
| 323 | + |
---|
| 324 | + public void PushMaterial2(Object3D obj, boolean selected) |
---|
| 325 | + { |
---|
| 326 | + CameraPane display = this; |
---|
| 327 | + cMaterial material = obj.material; |
---|
| 328 | + |
---|
| 329 | + if (material != null) |
---|
| 330 | + { |
---|
| 331 | + materialstack[materialdepth] = material; |
---|
| 332 | + selectedstack[materialdepth] = selected; |
---|
| 333 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 334 | + //System.out.println("material " + material); |
---|
| 335 | + //Applet3D.tracein("selected ", selected); |
---|
| 336 | + display.vector2buffer = obj.projectedVertices; |
---|
| 337 | + display.DrawMaterial(material, selected); |
---|
| 338 | + } |
---|
| 339 | + } |
---|
| 340 | + |
---|
| 341 | + public void PopMaterial(Object3D obj, boolean selected) |
---|
| 342 | + { |
---|
| 343 | + CameraPane display = this; |
---|
| 344 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 345 | + cMaterial material = obj.material; |
---|
| 346 | + |
---|
| 347 | + //if (parent != null && parent.GetMaterial() != null) |
---|
| 348 | + // parent.GetMaterial().Draw(display, parent.IsSelected(this)); |
---|
| 349 | + if (material != null) |
---|
| 350 | + { |
---|
| 351 | + materialdepth -= 1; |
---|
| 352 | + if (materialdepth > 0) |
---|
| 353 | + { |
---|
| 354 | + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 355 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 356 | + } |
---|
| 357 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 358 | + } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
| 359 | + { |
---|
| 360 | + display.modelParams4[1] = obj.GetMaterial().cameralight; |
---|
| 361 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 362 | + } |
---|
| 363 | + } |
---|
| 364 | + |
---|
| 365 | + public void PopMaterial2(Object3D obj) |
---|
| 366 | + { |
---|
| 367 | + CameraPane display = this; |
---|
| 368 | + cMaterial material = obj.material; |
---|
| 369 | + |
---|
| 370 | + if (material != null) |
---|
| 371 | + { |
---|
| 372 | + materialdepth -= 1; |
---|
| 373 | + if (materialdepth > 0) |
---|
| 374 | + { |
---|
| 375 | + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 376 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 377 | + } |
---|
| 378 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 379 | + //else |
---|
| 380 | + //material.Draw(display, false); |
---|
| 381 | + } |
---|
| 382 | + } |
---|
| 383 | + |
---|
| 384 | + public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face) |
---|
| 385 | + { |
---|
| 386 | + CameraPane display = this; |
---|
| 387 | + |
---|
| 388 | + if (pv.y == -10000 || |
---|
| 389 | + qv.y == -10000 || |
---|
| 390 | + rv.y == -10000) |
---|
| 391 | + return; |
---|
| 392 | + |
---|
| 393 | +// float b = f.nbiterations & 1; |
---|
| 394 | +// float g = (f.nbiterations>>1) & 1; |
---|
| 395 | +// float r = (f.nbiterations>>2) & 1; |
---|
| 396 | +// |
---|
| 397 | +// //if (f.weight == 10000) |
---|
| 398 | +// //{ |
---|
| 399 | +// // r = 1; g = b = 0; |
---|
| 400 | +// //} |
---|
| 401 | +// //else |
---|
| 402 | +// //{ |
---|
| 403 | +// // assert(f.weight < 10000); |
---|
| 404 | +// r = g = b = (float)bRep.FaceWeight(f)*100; |
---|
| 405 | +// if (r<0) |
---|
| 406 | +// assert(r>=0); |
---|
| 407 | +// //} |
---|
| 408 | + |
---|
| 409 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 410 | + |
---|
| 411 | + boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 412 | + |
---|
| 413 | + //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
| 414 | + if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
| 415 | + { |
---|
| 416 | + //gl.glBegin(gl.GL_TRIANGLES); |
---|
| 417 | + boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 418 | + if (!hasnorm) |
---|
| 419 | + { |
---|
| 420 | + // System.out.println("FUCK!!"); |
---|
| 421 | + LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
| 422 | + LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
| 423 | + LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
| 424 | + LA.vecNormalize(obj.v2); |
---|
| 425 | + gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 426 | + } |
---|
| 427 | + |
---|
| 428 | + // P |
---|
| 429 | + float x = (float)pv.x; |
---|
| 430 | + float y = (float)pv.y; |
---|
| 431 | + float z = (float)pv.z; |
---|
| 432 | + |
---|
| 433 | + if (hasnorm) |
---|
| 434 | + { |
---|
| 435 | +// if (!pv.norm.normalized()) |
---|
| 436 | +// assert(pv.norm.normalized()); |
---|
| 437 | + |
---|
| 438 | + //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z); |
---|
| 439 | + float nx = (float)pv.norm.x; |
---|
| 440 | + float ny = (float)pv.norm.y; |
---|
| 441 | + float nz = (float)pv.norm.z; |
---|
| 442 | + |
---|
| 443 | + x += nx * obj.NORMALPUSH; |
---|
| 444 | + y += ny * obj.NORMALPUSH; |
---|
| 445 | + z += nz * obj.NORMALPUSH; |
---|
| 446 | + |
---|
| 447 | + gl.glNormal3f(nx, ny, nz); |
---|
| 448 | + } |
---|
| 449 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 450 | + SetColor(obj, pv); |
---|
| 451 | + //gl.glColor4f(r, g, b, 1); |
---|
| 452 | + //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1); |
---|
| 453 | + if (obj.flipV) |
---|
| 454 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 455 | + else |
---|
| 456 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 457 | + //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z); |
---|
| 458 | + |
---|
| 459 | + gl.glVertex3f(x, y, z); |
---|
| 460 | + |
---|
| 461 | + // Q |
---|
| 462 | + x = (float)qv.x; |
---|
| 463 | + y = (float)qv.y; |
---|
| 464 | + z = (float)qv.z; |
---|
| 465 | + |
---|
| 466 | +// Print(pv); |
---|
| 467 | + if (hasnorm) |
---|
| 468 | + { |
---|
| 469 | +// assert(qv.norm.normalized()); |
---|
| 470 | + //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z); |
---|
| 471 | + float nx = (float)qv.norm.x; |
---|
| 472 | + float ny = (float)qv.norm.y; |
---|
| 473 | + float nz = (float)qv.norm.z; |
---|
| 474 | + |
---|
| 475 | + x += nx * obj.NORMALPUSH; |
---|
| 476 | + y += ny * obj.NORMALPUSH; |
---|
| 477 | + z += nz * obj.NORMALPUSH; |
---|
| 478 | + |
---|
| 479 | + gl.glNormal3f(nx, ny, nz); |
---|
| 480 | + } |
---|
| 481 | + //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
| 482 | + // boolean locked = false; |
---|
| 483 | + // float eps = 0.1f; |
---|
| 484 | + // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 485 | + |
---|
| 486 | + // int dot = 0; //*/ (int)f.dot; |
---|
| 487 | + |
---|
| 488 | + // if ((dot&1) == 0) |
---|
| 489 | + // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 490 | + |
---|
| 491 | + // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 492 | + if (obj.flipV) |
---|
| 493 | + gl.glTexCoord2f((float) qv.s, 1-(float) qv.t); |
---|
| 494 | + else |
---|
| 495 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 496 | + // else |
---|
| 497 | + // { |
---|
| 498 | + // locked = true; |
---|
| 499 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 500 | + // } |
---|
| 501 | + gl.glColor4f(qv.AO, qv.AO, qv.AO, 1); |
---|
| 502 | + SetColor(obj, qv); |
---|
| 503 | + |
---|
| 504 | + gl.glVertex3f(x, y, z); |
---|
| 505 | + //gl.glColor4f(r, g, b, 1); |
---|
| 506 | + //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1); |
---|
| 507 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 508 | +// Print(qv); |
---|
| 509 | + |
---|
| 510 | + // R |
---|
| 511 | + x = (float)rv.x; |
---|
| 512 | + y = (float)rv.y; |
---|
| 513 | + z = (float)rv.z; |
---|
| 514 | + |
---|
| 515 | + if (hasnorm) |
---|
| 516 | + { |
---|
| 517 | +// assert(rv.norm.normalized()); |
---|
| 518 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 519 | + float nx = (float)rv.norm.x; |
---|
| 520 | + float ny = (float)rv.norm.y; |
---|
| 521 | + float nz = (float)rv.norm.z; |
---|
| 522 | + |
---|
| 523 | + x += nx * obj.NORMALPUSH; |
---|
| 524 | + y += ny * obj.NORMALPUSH; |
---|
| 525 | + z += nz * obj.NORMALPUSH; |
---|
| 526 | + |
---|
| 527 | + gl.glNormal3f(nx, ny, nz); |
---|
| 528 | + } |
---|
| 529 | + |
---|
| 530 | + // if ((dot&4) == 0) |
---|
| 531 | + // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 532 | + |
---|
| 533 | + // if (wrap || !locked && (dot&8) != 0) |
---|
| 534 | + if (obj.flipV) |
---|
| 535 | + gl.glTexCoord2f((float) rv.s, 1-(float) rv.t); |
---|
| 536 | + else |
---|
| 537 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 538 | + // else |
---|
| 539 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 540 | + |
---|
| 541 | + // f.dot = dot; |
---|
| 542 | + |
---|
| 543 | + gl.glColor4f(rv.AO, rv.AO, rv.AO, 1); |
---|
| 544 | + SetColor(obj, rv); |
---|
| 545 | + //gl.glColor4f(r, g, b, 1); |
---|
| 546 | + //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1); |
---|
| 547 | + //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z); |
---|
| 548 | + gl.glVertex3f(x, y, z); |
---|
| 549 | +// Print(rv); |
---|
| 550 | + //gl.glEnd(); |
---|
| 551 | + } |
---|
| 552 | + else |
---|
| 553 | + { |
---|
| 554 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 555 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 556 | + gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z); |
---|
| 557 | + |
---|
| 558 | + } |
---|
| 559 | + |
---|
| 560 | + if (false) // (attributes & WIREFRAME) != 0) |
---|
| 561 | + { |
---|
| 562 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 563 | + |
---|
| 564 | + gl.glBegin(gl.GL_LINE_LOOP); |
---|
| 565 | + gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z); |
---|
| 566 | + gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z); |
---|
| 567 | + gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z); |
---|
| 568 | + gl.glEnd(); |
---|
| 569 | + |
---|
| 570 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 571 | + } |
---|
| 572 | + } |
---|
| 573 | + |
---|
| 574 | + /** |
---|
| 575 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 576 | + * it's normals, colors, textures and vertices. |
---|
| 577 | + * |
---|
| 578 | + * @see Renderer#draw(TriMesh) |
---|
| 579 | + * @param tris |
---|
| 580 | + * the mesh to render. |
---|
| 581 | + */ |
---|
| 582 | + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 583 | + { |
---|
| 584 | + CameraPane display = this; |
---|
| 585 | + |
---|
| 586 | + float r = display.modelParams0[0]; |
---|
| 587 | + float g = display.modelParams0[1]; |
---|
| 588 | + float b = display.modelParams0[2]; |
---|
| 589 | + float opacity = display.modelParams5[1]; |
---|
| 590 | + |
---|
| 591 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 592 | + GL gl = display.GetGL(); // getGL(); |
---|
| 593 | + |
---|
| 594 | + FloatBuffer vertBuf = geo.vertBuf; |
---|
| 595 | + |
---|
| 596 | + int v = vertBuf.capacity(); |
---|
| 597 | + |
---|
| 598 | + int count = 0; |
---|
| 599 | + |
---|
| 600 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 601 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 602 | + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
| 603 | + for (int i=0; i<v/3; i++) |
---|
| 604 | + { |
---|
| 605 | + int index3 = i*3; |
---|
| 606 | + |
---|
| 607 | + if (geo.sizeBuf.get(index3+1) == 0) |
---|
| 608 | + continue; |
---|
| 609 | + |
---|
| 610 | + count++; |
---|
| 611 | + |
---|
| 612 | + int index4 = i*4; |
---|
| 613 | + |
---|
| 614 | + float tx = vertBuf.get(index3); |
---|
| 615 | + float ty = vertBuf.get(index3+1); |
---|
| 616 | + float tz = vertBuf.get(index3+2); |
---|
| 617 | + |
---|
| 618 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 619 | + // continue; |
---|
| 620 | + |
---|
| 621 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 622 | + gl.glPushMatrix(); |
---|
| 623 | + |
---|
| 624 | + float[] texmat = geo.texmat; |
---|
| 625 | + texmat[12] = texmat[13] = texmat[14] = i; |
---|
| 626 | + |
---|
| 627 | + gl.glMultMatrixf(texmat, 0); |
---|
| 628 | + |
---|
| 629 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 630 | + gl.glPushMatrix(); |
---|
| 631 | + |
---|
| 632 | + gl.glTranslatef(tx,ty,tz); |
---|
| 633 | + |
---|
| 634 | + if (rotate) |
---|
| 635 | + gl.glRotatef(i, 0, 1, 0); |
---|
| 636 | + |
---|
| 637 | + float size = geo.sizeBuf.get(index3) / 100; |
---|
| 638 | + gl.glScalef(size,size,size); |
---|
| 639 | + |
---|
| 640 | + float cr = geo.colorBuf.get(index4); |
---|
| 641 | + float cg = geo.colorBuf.get(index4+1); |
---|
| 642 | + float cb = geo.colorBuf.get(index4+2); |
---|
| 643 | + float ca = geo.colorBuf.get(index4+3); |
---|
| 644 | + |
---|
| 645 | + display.modelParams0[0] = r * cr; |
---|
| 646 | + display.modelParams0[1] = g * cg; |
---|
| 647 | + display.modelParams0[2] = b * cb; |
---|
| 648 | + |
---|
| 649 | + display.modelParams5[1] = opacity * ca; |
---|
| 650 | + |
---|
| 651 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 652 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 653 | + |
---|
| 654 | + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; |
---|
| 655 | + RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 656 | + |
---|
| 657 | +// gl.glColor4f(cr,cg,cb,ca); |
---|
| 658 | + // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 659 | + shape.Draw/*Node*/(display,null,selected,false); // blocked |
---|
| 660 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 661 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 662 | + gl.glPopMatrix(); |
---|
| 663 | + |
---|
| 664 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 665 | + gl.glPopMatrix(); |
---|
| 666 | + } |
---|
| 667 | + // gl.glScalef(1024,1024,1024); |
---|
| 668 | + if (!cf) |
---|
| 669 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 670 | + |
---|
| 671 | + display.modelParams0[0] = r; |
---|
| 672 | + display.modelParams0[1] = g; |
---|
| 673 | + display.modelParams0[2] = b; |
---|
| 674 | + |
---|
| 675 | + display.modelParams5[1] = opacity; |
---|
| 676 | + |
---|
| 677 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 678 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 679 | + |
---|
| 680 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 681 | + |
---|
| 682 | +// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
| 683 | + if (true) |
---|
| 684 | + return; |
---|
| 685 | + |
---|
| 686 | +//// if (!tris.predraw(this)) |
---|
| 687 | +//// { |
---|
| 688 | +//// return; |
---|
| 689 | +//// } |
---|
| 690 | +//// if (Debug.stats) |
---|
| 691 | +//// { |
---|
| 692 | +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
| 693 | +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
| 694 | +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
| 695 | +//// } |
---|
| 696 | +//// |
---|
| 697 | +//// if (tris.getDisplayListID() != -1) |
---|
| 698 | +//// { |
---|
| 699 | +//// renderDisplayList(tris); |
---|
| 700 | +//// return; |
---|
| 701 | +//// } |
---|
| 702 | +//// |
---|
| 703 | +//// if (!generatingDisplayList) |
---|
| 704 | +//// { |
---|
| 705 | +//// applyStates(tris.states, tris); |
---|
| 706 | +//// } |
---|
| 707 | +//// if (Debug.stats) |
---|
| 708 | +//// { |
---|
| 709 | +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
| 710 | +//// } |
---|
| 711 | +//// boolean transformed = doTransforms(tris); |
---|
| 712 | +// |
---|
| 713 | +// int glMode = GL.GL_TRIANGLES; |
---|
| 714 | +// switch (getMode()) |
---|
| 715 | +// { |
---|
| 716 | +// case Triangles: |
---|
| 717 | +// glMode = GL.GL_TRIANGLES; |
---|
| 718 | +// break; |
---|
| 719 | +// case Strip: |
---|
| 720 | +// glMode = GL.GL_TRIANGLE_STRIP; |
---|
| 721 | +// break; |
---|
| 722 | +// case Fan: |
---|
| 723 | +// glMode = GL.GL_TRIANGLE_FAN; |
---|
| 724 | +// break; |
---|
| 725 | +// } |
---|
| 726 | +// |
---|
| 727 | +// if (!predrawGeometry(gl)) |
---|
| 728 | +// { |
---|
| 729 | +// // make sure only the necessary indices are sent through on old |
---|
| 730 | +// // cards. |
---|
| 731 | +// IntBuffer indices = this.getIndexBuffer(); |
---|
| 732 | +// if (indices == null) |
---|
| 733 | +// { |
---|
| 734 | +// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
| 735 | +// } else |
---|
| 736 | +// { |
---|
| 737 | +// indices.rewind(); |
---|
| 738 | +// indices.limit(this.getMaxIndex()); |
---|
| 739 | +// |
---|
| 740 | +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
| 741 | +// |
---|
| 742 | +// indices.clear(); |
---|
| 743 | +// } |
---|
| 744 | +// } else |
---|
| 745 | +// { |
---|
| 746 | +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
| 747 | +// GL.GL_UNSIGNED_INT, 0); |
---|
| 748 | +// } |
---|
| 749 | +// |
---|
| 750 | +//// postdrawGeometry(tris); |
---|
| 751 | +//// if (transformed) |
---|
| 752 | +//// { |
---|
| 753 | +//// undoTransforms(tris); |
---|
| 754 | +//// } |
---|
| 755 | +//// |
---|
| 756 | +//// if (Debug.stats) |
---|
| 757 | +//// { |
---|
| 758 | +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
| 759 | +//// } |
---|
| 760 | +//// tris.postdraw(this); |
---|
| 761 | + } |
---|
| 762 | + |
---|
| 763 | + /// INTERFACE |
---|
| 764 | + |
---|
| 765 | + void SetColor(Object3D obj, Vertex p0) |
---|
| 766 | + { |
---|
| 767 | + CameraPane display = this; |
---|
| 768 | + BoundaryRep bRep = obj.bRep; |
---|
| 769 | + |
---|
| 770 | + if (RENDERPROGRAM == 0) |
---|
| 771 | + { |
---|
| 772 | + float r = 0; |
---|
| 773 | + if (bRep != null) |
---|
| 774 | + { |
---|
| 775 | + if (bRep.stripified) |
---|
| 776 | + { |
---|
| 777 | + r = 1; |
---|
| 778 | + } |
---|
| 779 | + } |
---|
| 780 | + float g = 0; |
---|
| 781 | + if (bRep != null) |
---|
| 782 | + { |
---|
| 783 | + if (bRep.trimmed) |
---|
| 784 | + { |
---|
| 785 | + g = 1; |
---|
| 786 | + } |
---|
| 787 | + } |
---|
| 788 | + float b = 0; |
---|
| 789 | + if (obj.support != null && obj.link2master) |
---|
| 790 | + { |
---|
| 791 | + b = 1; |
---|
| 792 | + } |
---|
| 793 | + display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO); |
---|
| 794 | + return; |
---|
| 795 | + } |
---|
| 796 | + |
---|
| 797 | + if (display.DrawMode() != CameraPane.SHADOW) |
---|
| 798 | + return; |
---|
| 799 | + |
---|
| 800 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 801 | +// if (true) return; |
---|
| 802 | +// float ao = p.AO; |
---|
| 803 | +// |
---|
| 804 | +// // if (ao == 0 && !bRep.AOdone) // transient problem! |
---|
| 805 | +// // ao = 1; |
---|
| 806 | +// |
---|
| 807 | +// gl.glColor4f(ao, ao, ao, 1); |
---|
| 808 | + |
---|
| 809 | +// CameraPane.selectedpoint. |
---|
| 810 | +// getAverage(cStatic.point1, true); |
---|
| 811 | + if (CameraPane.pointflow == null) // !random) // live) |
---|
| 812 | + { |
---|
| 813 | + return; |
---|
| 814 | + } |
---|
| 815 | + |
---|
| 816 | + cStatic.point1.set(0,0,0); |
---|
| 817 | + LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1); |
---|
| 818 | + |
---|
| 819 | + cStatic.point1.sub(p0); |
---|
| 820 | + |
---|
| 821 | + |
---|
| 822 | +// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta? |
---|
| 823 | +// { |
---|
| 824 | +// return; |
---|
| 825 | +// } |
---|
| 826 | + |
---|
| 827 | + //if (true) |
---|
| 828 | + if (cStatic.point1.dot(cStatic.point1) > 0.000001) |
---|
| 829 | + { |
---|
| 830 | + return; |
---|
| 831 | + } |
---|
| 832 | + |
---|
| 833 | + float[] colorV = new float[3]; |
---|
| 834 | + |
---|
| 835 | + if (false) // marked) |
---|
| 836 | + { |
---|
| 837 | + // debug rigging weights |
---|
| 838 | + for (int object = 0; object < p0.vertexlinks.length; object++) |
---|
| 839 | + { |
---|
| 840 | + float weight = p0.weights[object] / p0.totalweight; |
---|
| 841 | + |
---|
| 842 | + // if (weight < 0.1) |
---|
| 843 | + // { |
---|
| 844 | + // assert(weight == 0); |
---|
| 845 | + // continue; |
---|
| 846 | + // } |
---|
| 847 | + |
---|
| 848 | + if (p0.vertexlinks[object] == -1) |
---|
| 849 | + continue; |
---|
| 850 | + |
---|
| 851 | + Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]); |
---|
| 852 | + |
---|
| 853 | + int color = //1 << object; // |
---|
| 854 | + //p.vertexlinks.length; |
---|
| 855 | + obj.support.bRep.supports[p0.closestsupport].links[object]; |
---|
| 856 | + colorV[2] += (color & 1) * weight; |
---|
| 857 | + colorV[1] += ((color & 2) >> 1) * weight; |
---|
| 858 | + colorV[0] += ((color & 4) >> 2) * weight; |
---|
| 859 | + } |
---|
| 860 | + } |
---|
| 861 | + else |
---|
| 862 | + { |
---|
| 863 | + if (obj.drawingstarted) |
---|
| 864 | + { |
---|
| 865 | + // find next point |
---|
| 866 | + if (bRep.GetVertex(0).faceindices == null) |
---|
| 867 | + { |
---|
| 868 | + bRep.InitFaceIndices(); |
---|
| 869 | + } |
---|
| 870 | + |
---|
| 871 | + double ymin = p0.y; |
---|
| 872 | + |
---|
| 873 | + Vertex newp = p0; |
---|
| 874 | + |
---|
| 875 | + for (int fii = 0; fii < p0.faceindices.length; fii++) |
---|
| 876 | + { |
---|
| 877 | + int fi = p0.faceindices[fii]; |
---|
| 878 | + |
---|
| 879 | + if (fi == -1) |
---|
| 880 | + break; |
---|
| 881 | + |
---|
| 882 | + Face f = bRep.GetFace(fi); |
---|
| 883 | + |
---|
| 884 | + Vertex p = bRep.GetVertex(f.p); |
---|
| 885 | + Vertex q = bRep.GetVertex(f.q); |
---|
| 886 | + Vertex r = bRep.GetVertex(f.r); |
---|
| 887 | + |
---|
| 888 | + int swap = (int)(Math.random()*3); |
---|
| 889 | + |
---|
| 890 | +// for (int s=swap; --s>=0;) |
---|
| 891 | +// { |
---|
| 892 | +// Vertex t = p; |
---|
| 893 | +// p = q; |
---|
| 894 | +// q = r; |
---|
| 895 | +// r = t; |
---|
| 896 | +// } |
---|
| 897 | + if (ymin > p.y) |
---|
| 898 | + { |
---|
| 899 | + ymin = p.y; |
---|
| 900 | + newp = p; |
---|
| 901 | +// break; |
---|
| 902 | + } |
---|
| 903 | + if (ymin > q.y) |
---|
| 904 | + { |
---|
| 905 | + ymin = q.y; |
---|
| 906 | + newp = q; |
---|
| 907 | +// break; |
---|
| 908 | + } |
---|
| 909 | + if (ymin > r.y) |
---|
| 910 | + { |
---|
| 911 | + ymin = r.y; |
---|
| 912 | + newp = r; |
---|
| 913 | +// break; |
---|
| 914 | + } |
---|
| 915 | + } |
---|
| 916 | + |
---|
| 917 | + CameraPane.selectedpoint.toParent[3][0] = newp.x; |
---|
| 918 | + CameraPane.selectedpoint.toParent[3][1] = newp.y; |
---|
| 919 | + CameraPane.selectedpoint.toParent[3][2] = newp.z; |
---|
| 920 | + |
---|
| 921 | + obj.drawingstarted = false; |
---|
| 922 | + |
---|
| 923 | + // return; |
---|
| 924 | + } |
---|
| 925 | + |
---|
| 926 | + if (false) // CameraPane.DRAW |
---|
| 927 | + { |
---|
| 928 | + p0.AO = colorV[0] = 2; |
---|
| 929 | + colorV[1] = 2; |
---|
| 930 | + colorV[2] = 2; |
---|
| 931 | + } |
---|
| 932 | + |
---|
| 933 | + CameraPane.pointflow.add(p0); |
---|
| 934 | + CameraPane.pointflow.Touch(); |
---|
| 935 | + } |
---|
| 936 | + |
---|
| 937 | +// gl.glColor3f(colorV[0], colorV[1], colorV[2]); |
---|
| 938 | +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 939 | +// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 940 | + } |
---|
| 941 | + |
---|
| 942 | + void DrawMaterial(cMaterial material, boolean selected) |
---|
| 943 | + { |
---|
| 944 | + CameraPane display = this; |
---|
| 945 | + //new Exception().printStackTrace(); |
---|
| 946 | + |
---|
| 947 | + if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW) |
---|
| 948 | + { |
---|
| 949 | + return; |
---|
| 950 | + } |
---|
| 951 | + |
---|
| 952 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 953 | + |
---|
| 954 | + //Color col = Color.getHSBColor(color,modulation,1); |
---|
| 955 | + //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
| 956 | + if (!material.multiply) |
---|
| 957 | + { |
---|
| 958 | + display.color = color; |
---|
| 959 | + display.saturation = material.modulation; |
---|
| 960 | + } |
---|
| 961 | + else |
---|
| 962 | + { |
---|
| 963 | + display.color *= color*2; |
---|
| 964 | + display.saturation *= material.modulation*2; |
---|
| 965 | + } |
---|
| 966 | + |
---|
| 967 | + cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
| 968 | + |
---|
| 969 | + float[] colorV = GrafreeD.colorV; |
---|
| 970 | + |
---|
| 971 | + /**/ |
---|
| 972 | + if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
| 973 | + { |
---|
| 974 | + colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
| 975 | + colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
| 976 | + colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
| 977 | + colorV[3] = material.opacity; |
---|
| 978 | + |
---|
| 979 | + gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
| 980 | + //System.out.println("Opacity = " + opacity); |
---|
| 981 | + |
---|
| 982 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 983 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 984 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 985 | + |
---|
| 986 | + float amb = material.ambient; |
---|
| 987 | + if (amb < material.cameralight) |
---|
| 988 | + { |
---|
| 989 | + amb = material.cameralight; |
---|
| 990 | + } |
---|
| 991 | + colorV[0] = display.modelParams0[0] * material.diffuse * amb; |
---|
| 992 | + colorV[1] = display.modelParams0[1] * material.diffuse * amb; |
---|
| 993 | + colorV[2] = display.modelParams0[2] * material.diffuse * amb; |
---|
| 994 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0); |
---|
| 995 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 996 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 997 | + |
---|
| 998 | + /**/ |
---|
| 999 | + colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular; |
---|
| 1000 | + colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular; |
---|
| 1001 | + colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular; |
---|
| 1002 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0); |
---|
| 1003 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1004 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0); |
---|
| 1005 | + colorV[0] = 10 / material.shininess; // 1/0.005f; |
---|
| 1006 | + //System.out.println("shininess = " + colorV[0]); |
---|
| 1007 | + if (colorV[0] > 128) |
---|
| 1008 | + { |
---|
| 1009 | + colorV[0] = 128; |
---|
| 1010 | + } |
---|
| 1011 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0); |
---|
| 1012 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0); |
---|
| 1013 | + /**/ |
---|
| 1014 | + } |
---|
| 1015 | + /**/ |
---|
| 1016 | + |
---|
| 1017 | + //selected = false; |
---|
| 1018 | + selected = selected && display.flash; |
---|
| 1019 | + |
---|
| 1020 | + //display.modelParams0[0] = 0; // pigment.r; |
---|
| 1021 | + //display.modelParams0[1] = 0; // pigment.g; |
---|
| 1022 | + //display.modelParams0[2] = 0; // pigment.b; |
---|
| 1023 | + if (!material.multiply) |
---|
| 1024 | + { |
---|
| 1025 | + display.modelParams0[3] = material.metalness; |
---|
| 1026 | + display.modelParams1[0] = material.diffuse; |
---|
| 1027 | + display.modelParams1[1] = material.specular; |
---|
| 1028 | + display.modelParams1[2] = 1 / material.shininess; |
---|
| 1029 | + display.modelParams1[3] = material.shift; |
---|
| 1030 | + display.modelParams2[0] = material.ambient; |
---|
| 1031 | + display.modelParams2[1] = material.lightarea; |
---|
| 1032 | + //System.out.println("light area = " + lightarea); |
---|
| 1033 | + display.modelParams2[2] = 1 / material.factor; // diffuseness |
---|
| 1034 | + display.modelParams2[3] = material.velvet; |
---|
| 1035 | + display.modelParams3[0] = material.sheen; |
---|
| 1036 | + display.modelParams3[1] = material.subsurface; |
---|
| 1037 | + display.modelParams3[2] = material.bump; // backlit |
---|
| 1038 | + display.modelParams3[3] = material.aniso; |
---|
| 1039 | + display.modelParams4[0] = material.anisoV; |
---|
| 1040 | + display.modelParams4[1] = selected ? 100 : material.cameralight; |
---|
| 1041 | + //System.out.println("selected = " + selected); |
---|
| 1042 | + display.modelParams4[2] = material.diffuseness; |
---|
| 1043 | + display.modelParams4[3] = material.shadow; |
---|
| 1044 | + display.modelParams5[0] = material.texture; |
---|
| 1045 | + display.modelParams5[1] = material.opacity; |
---|
| 1046 | + display.modelParams5[2] = material.fakedepth; |
---|
| 1047 | + display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10; |
---|
| 1048 | + } |
---|
| 1049 | + else |
---|
| 1050 | + { |
---|
| 1051 | + display.modelParams0[3] *= material.metalness*2; |
---|
| 1052 | + display.modelParams1[0] *= material.diffuse*2; |
---|
| 1053 | + display.modelParams1[1] *= material.specular*2; |
---|
| 1054 | + display.modelParams1[2] *= material.shininess*2; |
---|
| 1055 | + display.modelParams1[3] *= material.shift*2; |
---|
| 1056 | + display.modelParams2[0] *= material.ambient*2; |
---|
| 1057 | + display.modelParams2[1] *= material.lightarea*2; |
---|
| 1058 | + display.modelParams2[2] *= material.factor*2; |
---|
| 1059 | + display.modelParams2[3] *= material.velvet*2; |
---|
| 1060 | + display.modelParams3[0] *= material.sheen*2; |
---|
| 1061 | + display.modelParams3[1] *= material.subsurface*2; |
---|
| 1062 | + display.modelParams3[2] *= material.bump*2; |
---|
| 1063 | + display.modelParams3[3] *= material.aniso*2; |
---|
| 1064 | + display.modelParams4[0] *= material.anisoV*2; |
---|
| 1065 | + display.modelParams4[1] *= material.cameralight*2; |
---|
| 1066 | + //System.out.println("selected = " + selected); |
---|
| 1067 | + display.modelParams4[2] *= material.diffuseness*2; |
---|
| 1068 | + display.modelParams4[3] *= material.shadow*2; |
---|
| 1069 | + display.modelParams5[0] *= material.texture*2; |
---|
| 1070 | + display.modelParams5[1] *= material.opacity*2; |
---|
| 1071 | + display.modelParams5[2] *= material.fakedepth*2; |
---|
| 1072 | + display.modelParams5[3] *= material.shadowbias*2; |
---|
| 1073 | + } |
---|
| 1074 | + |
---|
| 1075 | + display.modelParams6[0] = 0; |
---|
| 1076 | + display.modelParams6[1] = 0; |
---|
| 1077 | + display.modelParams6[2] = 0; |
---|
| 1078 | + display.modelParams6[3] = 0; |
---|
| 1079 | + |
---|
| 1080 | + display.modelParams7[0] = 0; |
---|
| 1081 | + display.modelParams7[1] = 1000; |
---|
| 1082 | + display.modelParams7[2] = 0; |
---|
| 1083 | + display.modelParams7[3] = 0; |
---|
| 1084 | + |
---|
| 1085 | + display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1086 | + |
---|
| 1087 | + Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1088 | + if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
| 1089 | + { |
---|
| 1090 | + display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
| 1091 | + display.modelParams6[1] = extparams[0].y / 1000.0f; // noise |
---|
| 1092 | + if (extparams.length > 1) |
---|
| 1093 | + { |
---|
| 1094 | + display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade |
---|
| 1095 | + display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough |
---|
| 1096 | + if (extparams.length > 2) |
---|
| 1097 | + { |
---|
| 1098 | + display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power |
---|
| 1099 | + float x = extparams[2].y / 1000.0f; |
---|
| 1100 | + //if (x == 0) |
---|
| 1101 | + // x = 1f; |
---|
| 1102 | + 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 |
---|
| 1103 | + if (extparams[2].y > 0) |
---|
| 1104 | + { |
---|
| 1105 | + //System.out.println("extparams[1].y = " + extparams[1].y); |
---|
| 1106 | + //System.out.println("extparams[2].y = " + extparams[2].y); |
---|
| 1107 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1108 | + } |
---|
| 1109 | + } |
---|
| 1110 | + } |
---|
| 1111 | + } |
---|
| 1112 | + |
---|
| 1113 | + //if (display.modelParams6[2] != 0) |
---|
| 1114 | + /* |
---|
| 1115 | + System.out.println("modelParams0[0] = " + display.modelParams0[0]); |
---|
| 1116 | + System.out.println("modelParams0[1] = " + display.modelParams0[1]); |
---|
| 1117 | + System.out.println("modelParams0[2] = " + display.modelParams0[2]); |
---|
| 1118 | + System.out.println("modelParams0[3] = " + display.modelParams0[3]); |
---|
| 1119 | + System.out.println("modelParams1[0] = " + display.modelParams1[0]); |
---|
| 1120 | + System.out.println("modelParams1[1] = " + display.modelParams1[1]); |
---|
| 1121 | + System.out.println("modelParams1[2] = " + display.modelParams1[2]); |
---|
| 1122 | + System.out.println("modelParams1[3] = " + display.modelParams1[3]); |
---|
| 1123 | + System.out.println("modelParams2[0] = " + display.modelParams2[0]); |
---|
| 1124 | + System.out.println("modelParams2[1] = " + display.modelParams2[1]); |
---|
| 1125 | + System.out.println("modelParams2[2] = " + display.modelParams2[2]); |
---|
| 1126 | + System.out.println("modelParams2[3] = " + display.modelParams2[3]); |
---|
| 1127 | + System.out.println("modelParams3[0] = " + display.modelParams3[0]); |
---|
| 1128 | + System.out.println("modelParams3[1] = " + display.modelParams3[1]); |
---|
| 1129 | + System.out.println("modelParams3[2] = " + display.modelParams3[2]); |
---|
| 1130 | + System.out.println("modelParams3[3] = " + display.modelParams3[3]); |
---|
| 1131 | + System.out.println("modelParams4[0] = " + display.modelParams4[0]); |
---|
| 1132 | + System.out.println("modelParams4[1] = " + display.modelParams4[1]); |
---|
| 1133 | + System.out.println("modelParams4[2] = " + display.modelParams4[2]); |
---|
| 1134 | + System.out.println("modelParams4[3] = " + display.modelParams4[3]); |
---|
| 1135 | + System.out.println("modelParams5[0] = " + display.modelParams5[0]); |
---|
| 1136 | + System.out.println("modelParams5[1] = " + display.modelParams5[1]); |
---|
| 1137 | + System.out.println("modelParams5[2] = " + display.modelParams5[2]); |
---|
| 1138 | + System.out.println("modelParams5[3] = " + display.modelParams5[3]); |
---|
| 1139 | + System.out.println("modelParams6[0] = " + display.modelParams6[0]); |
---|
| 1140 | + System.out.println("modelParams6[1] = " + display.modelParams6[1]); |
---|
| 1141 | + System.out.println("modelParams6[2] = " + display.modelParams6[2]); |
---|
| 1142 | + System.out.println("modelParams6[3] = " + display.modelParams6[3]); |
---|
| 1143 | + System.out.println("modelParams7[0] = " + display.modelParams7[0]); |
---|
| 1144 | + System.out.println("modelParams7[1] = " + display.modelParams7[1]); |
---|
| 1145 | + System.out.println("modelParams7[2] = " + display.modelParams7[2]); |
---|
| 1146 | + System.out.println("modelParams7[3] = " + display.modelParams7[3]); |
---|
| 1147 | + /**/ |
---|
| 1148 | + //assert (display.modelParams6[2] == 0); |
---|
| 1149 | + |
---|
| 1150 | + //System.out.println("noise power = " + display.modelParams7[0]); |
---|
| 1151 | + //System.out.println("shadowbias = " + shadowbias); |
---|
| 1152 | + |
---|
| 1153 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1154 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0); |
---|
| 1155 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0); |
---|
| 1156 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0); |
---|
| 1157 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 1158 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1159 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0); |
---|
| 1160 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0); |
---|
| 1161 | + |
---|
| 1162 | + int mode = display.FP_SHADER; |
---|
| 1163 | + |
---|
| 1164 | + if (material.aniso != material.anisoV || material.aniso > 0.002) |
---|
| 1165 | + { |
---|
| 1166 | + mode |= display.FP_ANISO; |
---|
| 1167 | + } |
---|
| 1168 | + |
---|
| 1169 | + display.EnableProgram(mode); |
---|
| 1170 | + |
---|
| 1171 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1172 | + |
---|
| 1173 | + if (!material.multiply) |
---|
| 1174 | + { |
---|
| 1175 | + if (Globals.drawMode == CameraPane.SHADOW) |
---|
| 1176 | + gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1); |
---|
| 1177 | + else |
---|
| 1178 | + gl.glDepthMask(material.opacity >= 0.99); |
---|
| 1179 | + } |
---|
208 | 1180 | } |
---|
209 | 1181 | |
---|
210 | 1182 | int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0; |
---|
.. | .. |
---|
225 | 1197 | currentGL.glMultMatrixd(model, 0); |
---|
226 | 1198 | } |
---|
227 | 1199 | |
---|
228 | | - void PushMatrix(double[][] matrix, int count) |
---|
| 1200 | + public void PushMatrix(double[][] matrix, int count) // INTERFACE |
---|
229 | 1201 | { |
---|
230 | 1202 | matrixdepth++; |
---|
231 | 1203 | // GrafreeD.tracein(matrix); |
---|
.. | .. |
---|
270 | 1242 | |
---|
271 | 1243 | double[][] tmpmat = new double[4][4]; |
---|
272 | 1244 | |
---|
273 | | - void PopMatrix(double[][] inverse) |
---|
| 1245 | + public void PopMatrix(double[][] inverse) // INTERFACE |
---|
274 | 1246 | { |
---|
275 | 1247 | --matrixdepth; |
---|
276 | 1248 | |
---|
.. | .. |
---|
310 | 1282 | PushTextureMatrix(matrix, 1); |
---|
311 | 1283 | } |
---|
312 | 1284 | |
---|
313 | | - void PushTextureMatrix(double[][] matrix, int count) |
---|
| 1285 | + public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE |
---|
314 | 1286 | { |
---|
315 | 1287 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
316 | 1288 | |
---|
.. | .. |
---|
324 | 1296 | currentGL.glMatrixMode(GetGL().GL_MODELVIEW); |
---|
325 | 1297 | } |
---|
326 | 1298 | |
---|
327 | | - void PopTextureMatrix(double[][] inverse) |
---|
| 1299 | + public void PopTextureMatrix(double[][] inverse) // INTERFACE |
---|
328 | 1300 | { |
---|
329 | 1301 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
330 | 1302 | currentGL.glMatrixMode(GetGL().GL_TEXTURE); |
---|
.. | .. |
---|
356 | 1328 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
357 | 1329 | // return false; |
---|
358 | 1330 | |
---|
359 | | - if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount) |
---|
| 1331 | + if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount) |
---|
360 | 1332 | { |
---|
361 | 1333 | // check for last change |
---|
362 | | - if (framecount < camerachangeframe + 400) // 120 == 1 second |
---|
| 1334 | + if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second |
---|
363 | 1335 | { |
---|
364 | 1336 | // refuse the camera change |
---|
365 | 1337 | System.err.println("Camera " + cam + " REFUSED"); |
---|
.. | .. |
---|
367 | 1339 | } |
---|
368 | 1340 | } |
---|
369 | 1341 | |
---|
370 | | - camerachangeframe = framecount; |
---|
| 1342 | + camerachangeframe = Globals.framecount; |
---|
371 | 1343 | |
---|
372 | 1344 | cam.hAspect = -1; // Read only |
---|
373 | 1345 | |
---|
.. | .. |
---|
398 | 1370 | { |
---|
399 | 1371 | //System.err.println("Oeil on"); |
---|
400 | 1372 | TRACK = true; |
---|
401 | | -// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 1373 | +// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
402 | 1374 | // object.editWindow.ScreenFit(trackedobject); |
---|
403 | 1375 | //pingthread.StepToTarget(true); |
---|
404 | 1376 | } |
---|
.. | .. |
---|
407 | 1379 | { |
---|
408 | 1380 | //System.err.println("Oeil on"); |
---|
409 | 1381 | OEIL = true; |
---|
410 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 1382 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
411 | 1383 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
412 | 1384 | //pingthread.StepToTarget(true); |
---|
413 | 1385 | } |
---|
.. | .. |
---|
471 | 1443 | { |
---|
472 | 1444 | frozen ^= true; |
---|
473 | 1445 | // Weird... |
---|
474 | | - lighttouched = true; |
---|
| 1446 | + Globals.lighttouched = true; |
---|
475 | 1447 | } |
---|
476 | 1448 | |
---|
477 | 1449 | void ToggleDL() |
---|
.. | .. |
---|
486 | 1458 | |
---|
487 | 1459 | void ToggleLive() |
---|
488 | 1460 | { |
---|
489 | | - setLIVE(isLIVE() ^ true); |
---|
| 1461 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
490 | 1462 | |
---|
491 | | - System.err.println("LIVE = " + isLIVE()); |
---|
| 1463 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
492 | 1464 | |
---|
493 | | - if (!isLIVE()) // save sound |
---|
| 1465 | + if (!Globals.isLIVE()) // save sound |
---|
494 | 1466 | GrafreeD.savesound = true; // wav.save(); |
---|
495 | 1467 | // else |
---|
496 | 1468 | repaint(); // start loop // may 2013 |
---|
.. | .. |
---|
513 | 1485 | |
---|
514 | 1486 | void ToggleCrowd() |
---|
515 | 1487 | { |
---|
516 | | - CROWD ^= true; |
---|
| 1488 | + Globals.CROWD ^= true; |
---|
517 | 1489 | } |
---|
518 | 1490 | |
---|
519 | 1491 | void ToggleInertia() |
---|
.. | .. |
---|
674 | 1646 | lightCamera = cam; |
---|
675 | 1647 | } |
---|
676 | 1648 | |
---|
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 | 1649 | private static void ApplyTransform(GL gl, Mat4f xform) |
---|
706 | 1650 | { |
---|
707 | 1651 | float[] data = new float[16]; |
---|
.. | .. |
---|
759 | 1703 | |
---|
760 | 1704 | GL currentGL; |
---|
761 | 1705 | |
---|
762 | | - GL GetGL() |
---|
| 1706 | + public GL GetGL() // INTERFACE |
---|
763 | 1707 | { |
---|
764 | 1708 | return currentGL; |
---|
765 | 1709 | } |
---|
.. | .. |
---|
2000 | 2944 | */ |
---|
2001 | 2945 | TextureData ReduceTexture(TextureData texturedata, int resolution) // String name) |
---|
2002 | 2946 | { |
---|
| 2947 | + int pixelformat = texturedata.getPixelFormat(); |
---|
| 2948 | + |
---|
2003 | 2949 | int stride = 1; |
---|
2004 | | - if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE) |
---|
| 2950 | + if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE) |
---|
2005 | 2951 | stride = 3; |
---|
2006 | | - if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA) |
---|
| 2952 | + if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA) |
---|
2007 | 2953 | stride = 4; |
---|
2008 | 2954 | |
---|
2009 | 2955 | int width = texturedata.getWidth(); |
---|
.. | .. |
---|
6269 | 7215 | return null; |
---|
6270 | 7216 | } |
---|
6271 | 7217 | |
---|
6272 | | - void ReleaseTextures(cTexture tex) |
---|
| 7218 | + public void ReleaseTextures(cTexture tex) // INTERFACE |
---|
6273 | 7219 | { |
---|
6274 | 7220 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6275 | 7221 | { |
---|
.. | .. |
---|
6307 | 7253 | |
---|
6308 | 7254 | void ReleaseTexture(String tex, boolean bump) |
---|
6309 | 7255 | { |
---|
6310 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 7256 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6311 | 7257 | ambientOcclusion ) // || !textureon) |
---|
6312 | 7258 | { |
---|
6313 | 7259 | return; |
---|
.. | .. |
---|
6408 | 7354 | } |
---|
6409 | 7355 | } |
---|
6410 | 7356 | |
---|
6411 | | - /*boolean*/ void BindTextures(cTexture tex, int resolution) |
---|
| 7357 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
6412 | 7358 | { |
---|
6413 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 7359 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6414 | 7360 | ambientOcclusion ) // || !textureon) |
---|
6415 | 7361 | { |
---|
6416 | 7362 | return; // false; |
---|
.. | .. |
---|
7310 | 8256 | static boolean occlusionInitialized = false; |
---|
7311 | 8257 | boolean selection = false; |
---|
7312 | 8258 | boolean pointselection = false; |
---|
7313 | | - /*static*/ boolean lighttouched = true; |
---|
| 8259 | + ///*static*/ boolean lighttouched = true; |
---|
7314 | 8260 | boolean deselect; |
---|
7315 | | - boolean ambientOcclusion = false; |
---|
| 8261 | + private boolean ambientOcclusion = false; |
---|
7316 | 8262 | static boolean flash = false; |
---|
7317 | 8263 | /*static*/ boolean wait = false; |
---|
7318 | 8264 | boolean displaydone = false; // after repaint() calls |
---|
.. | .. |
---|
7442 | 8388 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
7443 | 8389 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
7444 | 8390 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 8391 | +// PATCH FILLE AUX JEANS |
---|
| 8392 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
7445 | 8393 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
7446 | 8394 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
7447 | 8395 | |
---|
.. | .. |
---|
7590 | 8538 | |
---|
7591 | 8539 | float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
7592 | 8540 | 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 |
---|
| 8541 | + float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
| 8542 | + float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
7594 | 8543 | |
---|
7595 | 8544 | static int imagecount = 0; // movie generation |
---|
7596 | 8545 | |
---|
7597 | 8546 | static int jitter = 0; |
---|
7598 | 8547 | |
---|
7599 | 8548 | boolean restartframe = false; |
---|
7600 | | - |
---|
7601 | | - static int framecount = 0; // general-purpose global count |
---|
7602 | 8549 | |
---|
7603 | 8550 | void displayAntiAliased(javax.media.opengl.GL gl) |
---|
7604 | 8551 | { |
---|
.. | .. |
---|
7630 | 8577 | gl.glClear(gl.GL_ACCUM_BUFFER_BIT); |
---|
7631 | 8578 | for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0) |
---|
7632 | 8579 | { |
---|
7633 | | - framecount++; |
---|
| 8580 | + Globals.framecount++; |
---|
7634 | 8581 | |
---|
7635 | 8582 | if (CameraPane.tickcount > 0) |
---|
7636 | 8583 | CameraPane.tickcount--; |
---|
.. | .. |
---|
7668 | 8615 | |
---|
7669 | 8616 | gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0); |
---|
7670 | 8617 | */ |
---|
7671 | | - lighttouched = true; |
---|
| 8618 | + Globals.lighttouched = true; |
---|
7672 | 8619 | //System.err.println(" shadowbuffer: " + jitter); |
---|
7673 | 8620 | shadowbuffer.display(); |
---|
7674 | 8621 | |
---|
.. | .. |
---|
7690 | 8637 | |
---|
7691 | 8638 | if (renderCamera != lightCamera) |
---|
7692 | 8639 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7693 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 8640 | + LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
7694 | 8641 | |
---|
7695 | 8642 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
7696 | 8643 | |
---|
.. | .. |
---|
7706 | 8653 | |
---|
7707 | 8654 | if (renderCamera != lightCamera) |
---|
7708 | 8655 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7709 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 8656 | + LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
7710 | 8657 | |
---|
7711 | 8658 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
7712 | 8659 | |
---|
.. | .. |
---|
8615 | 9562 | } |
---|
8616 | 9563 | } |
---|
8617 | 9564 | |
---|
8618 | | - boolean IsFrozen() |
---|
8619 | | - { |
---|
8620 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
8621 | | - |
---|
8622 | | - return !selectmode && cameracount == 0; // != 0; |
---|
8623 | | - } |
---|
8624 | | - |
---|
8625 | 9565 | boolean niceon = false; |
---|
8626 | 9566 | javax.swing.Timer AAtimer = new javax.swing.Timer(750, this); |
---|
8627 | 9567 | boolean currentlydrawing = false; |
---|
.. | .. |
---|
8639 | 9579 | } |
---|
8640 | 9580 | // if (DEBUG_SELECTION) |
---|
8641 | 9581 | // { |
---|
8642 | | -// if (drawMode != SELECTION) |
---|
8643 | | -// drawMode = SELECTION; |
---|
| 9582 | +// if (DrawMode() != SELECTION) |
---|
| 9583 | +// DrawMode() = SELECTION; |
---|
8644 | 9584 | // } |
---|
8645 | 9585 | |
---|
8646 | 9586 | if (!isRenderer) |
---|
.. | .. |
---|
8696 | 9636 | |
---|
8697 | 9637 | //ANTIALIAS = 0; |
---|
8698 | 9638 | |
---|
8699 | | - if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
| 9639 | + if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
8700 | 9640 | { |
---|
8701 | | - if (niceon || isLIVE()) |
---|
| 9641 | + if (niceon || Globals.isLIVE()) |
---|
8702 | 9642 | { |
---|
8703 | 9643 | //if(active == 0) |
---|
8704 | 9644 | // antialiaser = null; |
---|
.. | .. |
---|
8723 | 9663 | assert eyeCamera.shaper_zFar == 1E5f; // 500.0f; |
---|
8724 | 9664 | */ |
---|
8725 | 9665 | |
---|
8726 | | - if (drawMode == DEFAULT) |
---|
| 9666 | + if (DrawMode() == DEFAULT) |
---|
8727 | 9667 | { |
---|
8728 | 9668 | currentlydrawing = true; |
---|
8729 | 9669 | } |
---|
.. | .. |
---|
8754 | 9694 | |
---|
8755 | 9695 | // if(Applet3D.clipboard != null) |
---|
8756 | 9696 | // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent); |
---|
8757 | | -//drawMode = SELECTION; |
---|
| 9697 | +//DrawMode() = SELECTION; |
---|
8758 | 9698 | indexcount = 0; |
---|
8759 | 9699 | |
---|
8760 | | - if (drawMode == OCCLUSION) |
---|
| 9700 | + if (DrawMode() == OCCLUSION) |
---|
8761 | 9701 | { |
---|
8762 | | - drawMode = DEFAULT; |
---|
| 9702 | + Globals.drawMode = DEFAULT; // WARNING |
---|
8763 | 9703 | ambientOcclusion = true; |
---|
8764 | 9704 | setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
---|
8765 | 9705 | Object3D theobject = object; |
---|
.. | .. |
---|
8778 | 9718 | ambientOcclusion = false; |
---|
8779 | 9719 | } |
---|
8780 | 9720 | |
---|
8781 | | - if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 9721 | + if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
8782 | 9722 | { |
---|
8783 | 9723 | //if (RENDERSHADOW) // ? |
---|
8784 | 9724 | if (!IsFrozen()) |
---|
8785 | 9725 | { |
---|
8786 | 9726 | // dec 2012 |
---|
8787 | | - if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)) |
---|
| 9727 | + if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
8788 | 9728 | { |
---|
8789 | | - framecount++; |
---|
| 9729 | + Globals.framecount++; |
---|
8790 | 9730 | shadowbuffer.display(); |
---|
8791 | 9731 | } |
---|
8792 | 9732 | } |
---|
8793 | | - lighttouched = false; // ?? |
---|
| 9733 | + Globals.lighttouched = false; // ?? |
---|
8794 | 9734 | //drawing = true; |
---|
8795 | 9735 | //lighttouched = true; |
---|
8796 | 9736 | } |
---|
.. | .. |
---|
8811 | 9751 | //eyeCamera.shaper_fovy = 1; |
---|
8812 | 9752 | } |
---|
8813 | 9753 | |
---|
8814 | | - if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION) |
---|
| 9754 | + if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION) |
---|
8815 | 9755 | { |
---|
8816 | | - //System.out.println("drawMode = " + drawMode); |
---|
| 9756 | + //System.out.println("DrawMode() = " + DrawMode()); |
---|
8817 | 9757 | vertexMode |= VP_PASS; |
---|
8818 | 9758 | //vertexMode |= VP_PROJECTION; |
---|
8819 | 9759 | if (!ambientOcclusion) |
---|
.. | .. |
---|
8873 | 9813 | Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera; |
---|
8874 | 9814 | //Camera lightcam = new Camera(light0); |
---|
8875 | 9815 | |
---|
8876 | | - if (drawMode == SHADOW) |
---|
| 9816 | + if (DrawMode() == SHADOW) |
---|
8877 | 9817 | { |
---|
8878 | 9818 | /* |
---|
8879 | 9819 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
.. | .. |
---|
8912 | 9852 | // if (parentcam != renderCamera) // not a light |
---|
8913 | 9853 | if (cam != lightCamera) |
---|
8914 | 9854 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8915 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 9855 | + LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
8916 | 9856 | |
---|
8917 | 9857 | for (int j = 0; j < 4; j++) |
---|
8918 | 9858 | { |
---|
.. | .. |
---|
8927 | 9867 | // if (parentcam != renderCamera) // not a light |
---|
8928 | 9868 | if (cam != lightCamera) |
---|
8929 | 9869 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8930 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 9870 | + LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
8931 | 9871 | |
---|
8932 | 9872 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
8933 | 9873 | |
---|
.. | .. |
---|
8963 | 9903 | gl.glClear(gl.GL_DEPTH_BUFFER_BIT); |
---|
8964 | 9904 | } else |
---|
8965 | 9905 | { |
---|
8966 | | - if (drawMode != DEFAULT) |
---|
| 9906 | + if (DrawMode() != DEFAULT) |
---|
8967 | 9907 | { |
---|
8968 | 9908 | gl.glClearColor(1, 1, 1, 0); |
---|
8969 | 9909 | } // 1); |
---|
.. | .. |
---|
9028 | 9968 | |
---|
9029 | 9969 | fast &= !ambientOcclusion; |
---|
9030 | 9970 | |
---|
9031 | | - if (drawMode == DEFAULT) |
---|
| 9971 | + if (DrawMode() == DEFAULT) |
---|
9032 | 9972 | { |
---|
9033 | 9973 | //gl.glEnable(gl.GL_ALPHA_TEST); |
---|
9034 | 9974 | //gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
.. | .. |
---|
9089 | 10029 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
9090 | 10030 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9091 | 10031 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 10032 | +// PATCH FILLE AUX JEANS |
---|
| 10033 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9092 | 10034 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9093 | 10035 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9094 | 10036 | |
---|
.. | .. |
---|
9224 | 10166 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
9225 | 10167 | gl.glLoadIdentity(); |
---|
9226 | 10168 | |
---|
9227 | | - if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
| 10169 | + if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
9228 | 10170 | { |
---|
9229 | 10171 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9230 | 10172 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 10173 | +// PATCH FILLE AUX JEANS |
---|
| 10174 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9231 | 10175 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9232 | 10176 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9233 | 10177 | //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE); |
---|
.. | .. |
---|
9280 | 10224 | //gl.glPushMatrix(); |
---|
9281 | 10225 | gl.glLoadIdentity(); |
---|
9282 | 10226 | |
---|
9283 | | - if (!ambientOcclusion) // drawMode != OCCLUSION) |
---|
| 10227 | + if (!ambientOcclusion) // DrawMode() != OCCLUSION) |
---|
9284 | 10228 | { |
---|
9285 | 10229 | //LA.xformPos(light0, lightCamera.fromScreen, light); |
---|
9286 | 10230 | LA.xformDir(dirlight, lightCamera.fromScreen, lightposition); |
---|
.. | .. |
---|
9367 | 10311 | } |
---|
9368 | 10312 | |
---|
9369 | 10313 | /**/ |
---|
9370 | | - if (true) // drawMode == SELECTION) // != DEFAULT) |
---|
| 10314 | + if (true) // DrawMode() == SELECTION) // != DEFAULT) |
---|
9371 | 10315 | gl.glDisable(gl.GL_LIGHTING); |
---|
9372 | 10316 | else |
---|
9373 | 10317 | gl.glEnable(gl.GL_LIGHTING); |
---|
.. | .. |
---|
9379 | 10323 | |
---|
9380 | 10324 | gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0); |
---|
9381 | 10325 | gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0); |
---|
| 10326 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0); |
---|
9382 | 10327 | |
---|
9383 | 10328 | options2[0] *= renderCamera.Distance(); |
---|
9384 | 10329 | |
---|
9385 | 10330 | lightslot = 64; |
---|
9386 | 10331 | |
---|
9387 | | - if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT) |
---|
| 10332 | + if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT) |
---|
9388 | 10333 | { |
---|
9389 | 10334 | DrawLights(object); |
---|
9390 | 10335 | } |
---|
.. | .. |
---|
9395 | 10340 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
9396 | 10341 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
9397 | 10342 | |
---|
9398 | | - if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION) |
---|
| 10343 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION) |
---|
9399 | 10344 | { |
---|
9400 | 10345 | /* |
---|
9401 | 10346 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
9428 | 10373 | } |
---|
9429 | 10374 | } |
---|
9430 | 10375 | |
---|
9431 | | - if (drawMode == DEFAULT) |
---|
| 10376 | + if (DrawMode() == DEFAULT) |
---|
9432 | 10377 | { |
---|
9433 | 10378 | if (WIREFRAME && !ambientOcclusion) |
---|
9434 | 10379 | { |
---|
.. | .. |
---|
9446 | 10391 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9447 | 10392 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9448 | 10393 | |
---|
9449 | | - if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) // |
---|
| 10394 | + if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) // |
---|
9450 | 10395 | { |
---|
9451 | 10396 | if (vertexMode != 0) // && !fast) |
---|
9452 | 10397 | { |
---|
.. | .. |
---|
9466 | 10411 | } |
---|
9467 | 10412 | } |
---|
9468 | 10413 | |
---|
9469 | | - if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion) |
---|
| 10414 | + if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
9470 | 10415 | { |
---|
9471 | 10416 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
9472 | 10417 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
9494 | 10439 | //gl.glDepthMask(false); |
---|
9495 | 10440 | } |
---|
9496 | 10441 | |
---|
9497 | | - if (false) // drawMode == SHADOW) |
---|
| 10442 | + if (false) // DrawMode() == SHADOW) |
---|
9498 | 10443 | { |
---|
9499 | 10444 | //SetColumnMajorData(cameraInverseTransform, view_1); |
---|
9500 | 10445 | //System.out.println("light = " + cameraInverseTransform); |
---|
.. | .. |
---|
9508 | 10453 | //System.out.println("object = " + object); |
---|
9509 | 10454 | if (!frozen && !imageLocked) |
---|
9510 | 10455 | { |
---|
9511 | | - if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0) |
---|
| 10456 | + if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0) |
---|
9512 | 10457 | { |
---|
9513 | 10458 | displayAntiAliased(gl); |
---|
9514 | 10459 | } else |
---|
9515 | 10460 | { |
---|
9516 | 10461 | programcount = 0; |
---|
9517 | | - int keepmode = drawMode; |
---|
| 10462 | + int keepmode = DrawMode(); |
---|
9518 | 10463 | // if (DEBUG_SELECTION) |
---|
9519 | 10464 | // { |
---|
9520 | | -// drawMode = SELECTION; |
---|
| 10465 | +// DrawMode() = SELECTION; |
---|
9521 | 10466 | // } |
---|
9522 | 10467 | // for point selection |
---|
9523 | 10468 | // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0); |
---|
.. | .. |
---|
9527 | 10472 | DrawObject(gl); |
---|
9528 | 10473 | |
---|
9529 | 10474 | // jan 2013 System.err.println("RESET ABORT (display)"); |
---|
9530 | | - // if (drawMode == DEFAULT) |
---|
| 10475 | + // if (DrawMode() == DEFAULT) |
---|
9531 | 10476 | // ABORTED = false; |
---|
9532 | 10477 | fullreset = false; |
---|
9533 | | - drawMode = keepmode; |
---|
| 10478 | + Globals.drawMode = keepmode; // WARNING |
---|
9534 | 10479 | //System.out.println("PROGRAM SWITCH " + programcount); |
---|
9535 | 10480 | } |
---|
9536 | 10481 | } |
---|
.. | .. |
---|
9538 | 10483 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9539 | 10484 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9540 | 10485 | |
---|
9541 | | - if (drawMode == DEFAULT) |
---|
| 10486 | + if (DrawMode() == DEFAULT) |
---|
9542 | 10487 | { |
---|
9543 | 10488 | ReleaseTexture(NOISE_TEXTURE, false); |
---|
9544 | 10489 | } |
---|
9545 | | - //if (drawMode == DEFAULT) |
---|
| 10490 | + //if (DrawMode() == DEFAULT) |
---|
9546 | 10491 | { |
---|
9547 | 10492 | |
---|
9548 | 10493 | gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
.. | .. |
---|
9554 | 10499 | //else |
---|
9555 | 10500 | //gl.glDisable(gl.GL_TEXTURE_2D); |
---|
9556 | 10501 | //gl.glPopMatrix(); |
---|
9557 | | - if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
| 10502 | + if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
9558 | 10503 | { |
---|
9559 | 10504 | //new Exception().printStackTrace(); |
---|
9560 | 10505 | //System.out.println("Draw image " + width + ", " + height); |
---|
.. | .. |
---|
9596 | 10541 | //gl.glFlush(); |
---|
9597 | 10542 | } |
---|
9598 | 10543 | |
---|
9599 | | - if (flash && drawMode == DEFAULT) |
---|
| 10544 | + if (flash && DrawMode() == DEFAULT) |
---|
9600 | 10545 | { |
---|
9601 | 10546 | flash = false; |
---|
9602 | 10547 | wait = true; |
---|
.. | .. |
---|
9604 | 10549 | } |
---|
9605 | 10550 | |
---|
9606 | 10551 | //drawing = false; |
---|
9607 | | - //if(drawMode == DEFAULT) |
---|
| 10552 | + //if(DrawMode() == DEFAULT) |
---|
9608 | 10553 | // niceon = false; |
---|
9609 | | - if (drawMode == DEFAULT) |
---|
| 10554 | + if (DrawMode() == DEFAULT) |
---|
9610 | 10555 | { |
---|
9611 | 10556 | currentlydrawing = false; |
---|
9612 | 10557 | } |
---|
.. | .. |
---|
9626 | 10571 | repaint(); |
---|
9627 | 10572 | } |
---|
9628 | 10573 | |
---|
9629 | | - if (isLIVE() && drawMode == DEFAULT) // may 2013 |
---|
| 10574 | + if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 |
---|
9630 | 10575 | repaint(); |
---|
9631 | 10576 | |
---|
9632 | 10577 | displaydone = true; |
---|
.. | .. |
---|
9663 | 10608 | if (GrafreeD.RENDERME > 0) |
---|
9664 | 10609 | GrafreeD.RENDERME--; // mechante magouille |
---|
9665 | 10610 | |
---|
9666 | | - ONESTEP = false; |
---|
| 10611 | + Globals.ONESTEP = false; |
---|
9667 | 10612 | } |
---|
9668 | 10613 | |
---|
9669 | 10614 | static boolean zoomonce = false; |
---|
.. | .. |
---|
9671 | 10616 | void DrawObject(GL gl, boolean draw) |
---|
9672 | 10617 | { |
---|
9673 | 10618 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
9674 | | -// drawMode = SELECTION; |
---|
| 10619 | +// DrawMode() = SELECTION; |
---|
9675 | 10620 | //GL gl = getGL(); |
---|
9676 | 10621 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
9677 | 10622 | { |
---|
9678 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 10623 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
9679 | 10624 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
9680 | 10625 | pingthread.StepToTarget(true); // true); |
---|
9681 | 10626 | // zoomonce = false; |
---|
.. | .. |
---|
9696 | 10641 | callist = gl.glGenLists(1); |
---|
9697 | 10642 | } |
---|
9698 | 10643 | |
---|
9699 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 10644 | + boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
9700 | 10645 | |
---|
9701 | | - boolean active = !selectmode; // drawMode != SELECTION; // mouseDown; |
---|
| 10646 | + boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
9702 | 10647 | |
---|
9703 | 10648 | if (!mainDL || !active || touched) |
---|
9704 | 10649 | { |
---|
.. | .. |
---|
9725 | 10670 | PushMatrix(ClickInfo.matbuffer); |
---|
9726 | 10671 | } |
---|
9727 | 10672 | |
---|
9728 | | - if (drawMode == 0) |
---|
| 10673 | + if (DrawMode() == 0) |
---|
9729 | 10674 | { |
---|
9730 | 10675 | // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++"); |
---|
9731 | 10676 | |
---|
.. | .. |
---|
9739 | 10684 | // DRAW |
---|
9740 | 10685 | object.draw(this, /*(Composite)*/ object, false, false); |
---|
9741 | 10686 | |
---|
9742 | | - if (drawMode == DEFAULT) |
---|
| 10687 | + if (DrawMode() == DEFAULT) |
---|
9743 | 10688 | { |
---|
9744 | 10689 | if (DEBUG) |
---|
9745 | 10690 | { |
---|
.. | .. |
---|
9750 | 10695 | selectedpoint.radius = radius; |
---|
9751 | 10696 | selectedpoint.recalculate(); |
---|
9752 | 10697 | selectedpoint.material = new cMaterial(); |
---|
9753 | | - selectedpoint.material.color = 0.25f; |
---|
| 10698 | + selectedpoint.material.color = 0.15f; // Yellow |
---|
9754 | 10699 | selectedpoint.material.modulation = 0.75f; |
---|
9755 | 10700 | |
---|
9756 | | - debugpoint.radius = radius; |
---|
9757 | | - debugpoint.recalculate(); |
---|
9758 | | - debugpoint.material = new cMaterial(); |
---|
9759 | | - debugpoint.material.color = 0.25f; |
---|
9760 | | - debugpoint.material.modulation = 0.75f; |
---|
| 10701 | + debugpointG.radius = radius; |
---|
| 10702 | + debugpointG.recalculate(); |
---|
| 10703 | + debugpointG.material = new cMaterial(); |
---|
| 10704 | + debugpointG.material.color = 0.25f; // Green |
---|
| 10705 | + debugpointG.material.modulation = 0.75f; |
---|
9761 | 10706 | |
---|
9762 | | - debugpoint2.radius = radius; |
---|
9763 | | - debugpoint2.recalculate(); |
---|
9764 | | - debugpoint2.material = new cMaterial(); |
---|
9765 | | - debugpoint2.material.color = 0.75f; |
---|
9766 | | - debugpoint2.material.modulation = 0.75f; |
---|
| 10707 | + debugpointP.radius = radius; |
---|
| 10708 | + debugpointP.recalculate(); |
---|
| 10709 | + debugpointP.material = new cMaterial(); |
---|
| 10710 | + debugpointP.material.color = 0.75f; // Purple |
---|
| 10711 | + debugpointP.material.modulation = 0.75f; |
---|
9767 | 10712 | |
---|
9768 | | - debugpoint3.radius = radius; |
---|
9769 | | - debugpoint3.recalculate(); |
---|
9770 | | - debugpoint3.material = new cMaterial(); |
---|
9771 | | - debugpoint3.material.color = 0.5f; |
---|
9772 | | - debugpoint3.material.modulation = 0.75f; |
---|
| 10713 | + debugpointC.radius = radius; |
---|
| 10714 | + debugpointC.recalculate(); |
---|
| 10715 | + debugpointC.material = new cMaterial(); |
---|
| 10716 | + debugpointC.material.color = 0.5f; // Cyan |
---|
| 10717 | + debugpointC.material.modulation = 0.75f; |
---|
9773 | 10718 | |
---|
9774 | | - debugpoint4.radius = radius; |
---|
9775 | | - debugpoint4.recalculate(); |
---|
9776 | | - debugpoint4.material = new cMaterial(); |
---|
9777 | | - debugpoint4.material.color = 0f; |
---|
9778 | | - debugpoint4.material.modulation = 0.75f; |
---|
| 10719 | + debugpointR.radius = radius; |
---|
| 10720 | + debugpointR.recalculate(); |
---|
| 10721 | + debugpointR.material = new cMaterial(); |
---|
| 10722 | + debugpointR.material.color = 0f; // Red |
---|
| 10723 | + debugpointR.material.modulation = 0.75f; |
---|
9779 | 10724 | |
---|
9780 | 10725 | InitPoints(radius); |
---|
9781 | 10726 | } |
---|
9782 | 10727 | 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); |
---|
| 10728 | + debugpointG.draw(this, /*(Composite)*/ null, false,false); |
---|
| 10729 | + debugpointP.draw(this, /*(Composite)*/ null, false,false); |
---|
| 10730 | + debugpointC.draw(this, /*(Composite)*/ null, false,false); |
---|
| 10731 | + debugpointR.draw(this, /*(Composite)*/ null, false,false); |
---|
9787 | 10732 | // DrawPoints(this); |
---|
9788 | 10733 | } |
---|
9789 | 10734 | |
---|
.. | .. |
---|
9791 | 10736 | } |
---|
9792 | 10737 | // GrafreeD.traceoff(); |
---|
9793 | 10738 | //System.out.println(stackdepth); |
---|
9794 | | - if (drawMode == 0) |
---|
| 10739 | + if (DrawMode() == 0) |
---|
9795 | 10740 | { |
---|
9796 | 10741 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
9797 | 10742 | |
---|
.. | .. |
---|
9816 | 10761 | |
---|
9817 | 10762 | checker = null; |
---|
9818 | 10763 | |
---|
9819 | | - if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT) |
---|
| 10764 | + if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT) |
---|
9820 | 10765 | FindChecker(object); |
---|
9821 | 10766 | |
---|
9822 | | - if (checker != null && drawMode == DEFAULT) |
---|
| 10767 | + if (checker != null && DrawMode() == DEFAULT) |
---|
9823 | 10768 | { |
---|
9824 | | - // BindTexture(IMMORTAL_TEXTURE); |
---|
| 10769 | + //BindTexture(IMMORTAL_TEXTURE); |
---|
| 10770 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
9825 | 10771 | // NEAREST |
---|
9826 | 10772 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
9827 | 10773 | DrawChecker(gl); |
---|
9828 | 10774 | //checker.Draw(this, null, false); |
---|
9829 | 10775 | // ReleaseTexture(IMMORTAL_TEXTURE); |
---|
| 10776 | + ReleaseTextures(checker.GetTextures()); |
---|
9830 | 10777 | } |
---|
9831 | 10778 | |
---|
9832 | 10779 | if (object.parent != null) |
---|
.. | .. |
---|
9839 | 10786 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9840 | 10787 | //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9841 | 10788 | |
---|
9842 | | - if (DISPLAYTEXT && drawMode == DEFAULT) |
---|
| 10789 | + if (DISPLAYTEXT && DrawMode() == DEFAULT) |
---|
9843 | 10790 | { |
---|
9844 | 10791 | // Draw it once, then use the raster |
---|
9845 | 10792 | Balloon(gl, balloon.createGraphics()); |
---|
.. | .. |
---|
9895 | 10842 | int[] xs = new int[3]; |
---|
9896 | 10843 | int[] ys = new int[3]; |
---|
9897 | 10844 | |
---|
9898 | | - void DrawString(Object3D obj) // String string) |
---|
| 10845 | + public void DrawString(Object3D obj) // String string) // INTERFACE |
---|
9899 | 10846 | { |
---|
9900 | | - if (!DISPLAYTEXT || drawMode != DEFAULT) |
---|
| 10847 | + if (!DISPLAYTEXT || DrawMode() != DEFAULT) |
---|
9901 | 10848 | { |
---|
9902 | 10849 | return; |
---|
9903 | 10850 | } |
---|
.. | .. |
---|
10357 | 11304 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
10358 | 11305 | "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
10359 | 11306 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
10360 | | - "PARAM options1 = program.env[62];" + // fog rgb color, image intensity |
---|
| 11307 | + "PARAM options1 = program.env[62];" + // fog rgb color |
---|
| 11308 | + "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
10361 | 11309 | "PARAM pointlight = program.env[127];" + // ... |
---|
10362 | 11310 | "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" + |
---|
10363 | 11311 | "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" + |
---|
10364 | 11312 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
| 11313 | + "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" + |
---|
10365 | 11314 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
10366 | 11315 | "PARAM ten = { 10, 10, 10, 1.0 };" + |
---|
10367 | 11316 | "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" + |
---|
.. | .. |
---|
10382 | 11331 | "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" + |
---|
10383 | 11332 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
10384 | 11333 | "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" + |
---|
| 11334 | + "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" + |
---|
10385 | 11335 | "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" + |
---|
10386 | 11336 | "PARAM c256 = { 256, 256, 256, 1.0 };" + |
---|
10387 | 11337 | "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" + |
---|
.. | .. |
---|
10422 | 11372 | "TEMP R1;" + |
---|
10423 | 11373 | "TEMP R2;" + |
---|
10424 | 11374 | "TEMP R3;" + |
---|
| 11375 | + "TEMP min;" + |
---|
| 11376 | + "TEMP max;" + |
---|
| 11377 | + "TEMP average;" + |
---|
| 11378 | + "TEMP saturation;" + |
---|
10425 | 11379 | "TEMP keep1;" + |
---|
10426 | 11380 | "TEMP keep2;" + |
---|
10427 | 11381 | "TEMP keep3;" + |
---|
.. | .. |
---|
10952 | 11906 | |
---|
10953 | 11907 | // skin? |
---|
10954 | 11908 | // Saturation for skin |
---|
10955 | | - /**/ // c'est ici |
---|
10956 | | - (Skinshader? "DP3 temp.x, final,one;" + |
---|
| 11909 | + /**/ |
---|
| 11910 | + (Skinshader? |
---|
| 11911 | + "DP3 average.x, final,one;" + |
---|
| 11912 | + "MUL average, one3rd.xxxx,average.xxxx;" + |
---|
| 11913 | + |
---|
| 11914 | + "MIN min.x, final.x,final.y;" + |
---|
| 11915 | + "MIN min.x, min.x,final.z;" + |
---|
| 11916 | + |
---|
| 11917 | + "MAX max.x, final.x,final.y;" + |
---|
| 11918 | + "MAX max.x, max.x,final.z;" + |
---|
| 11919 | + "MOV max, max.xxxx;" + |
---|
| 11920 | + |
---|
| 11921 | + "SUB saturation, max, final;" + |
---|
| 11922 | + |
---|
| 11923 | + "ADD temp.x, max.x, one10th.x;" + |
---|
| 11924 | + "RCP temp.x, temp.x;" + |
---|
| 11925 | + "MUL temp.x, temp.x, half.x;" + |
---|
| 11926 | + "MUL saturation, saturation, temp.xxxx;" + |
---|
| 11927 | + |
---|
| 11928 | + "DP3 ndotl.x, normald, light;" + |
---|
| 11929 | + "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
| 11930 | + |
---|
| 11931 | + "SUB temp.x, one.x, ndotl.x;" + |
---|
| 11932 | + "ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 11933 | + "ADD temp.y, one.y, options2.y;" + // sursurface |
---|
| 11934 | + "MUL temp.x, temp.x, temp.y;" + |
---|
| 11935 | + |
---|
| 11936 | + "MUL saturation, saturation, temp.xxxx;" + |
---|
| 11937 | + "SUB_SAT temp, max, saturation;" + |
---|
| 11938 | +/** |
---|
| 11939 | + "DP3 temp.x, final,one;" + |
---|
10957 | 11940 | "MUL R2, one3rd.xxxx,temp.xxxx;" + |
---|
10958 | | - "SUB temp, final,R2;" + |
---|
| 11941 | + "SUB temp, final, R2;" + |
---|
| 11942 | + |
---|
10959 | 11943 | // using light angle |
---|
10960 | 11944 | "DP3 ndotl.x, normald,light;" + |
---|
10961 | 11945 | //"SLT ndotl.y, ndotl.x, zero.x;" + |
---|
.. | .. |
---|
10968 | 11952 | // using light intensity |
---|
10969 | 11953 | "MOV ndotl.z, R2.x;" + |
---|
10970 | 11954 | "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning... |
---|
10971 | | - |
---|
10972 | 11955 | // june 2014 |
---|
10973 | 11956 | "MAD R1.x, ndotl.z,slope.y,one.x;" + |
---|
10974 | 11957 | // "SUB ndotl.x, one.x, ndotl.x;" + |
---|
.. | .. |
---|
10980 | 11963 | //"MUL R2.y, shadow.x,R2.y;" + // avril 2014 |
---|
10981 | 11964 | |
---|
10982 | 11965 | "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin) |
---|
| 11966 | +/**/ |
---|
10983 | 11967 | |
---|
10984 | 11968 | // "ADD final, R2,temp;" + |
---|
10985 | 11969 | "MOV final, temp;" |
---|
.. | .. |
---|
11069 | 12053 | /**/ |
---|
11070 | 12054 | // HDR |
---|
11071 | 12055 | "MOV temp.z, final.a;" + |
---|
11072 | | - "MUL final, final,options1.w;" + |
---|
| 12056 | + "MUL final, final,options2.x;" + |
---|
11073 | 12057 | "MOV final.a, temp.z;" + |
---|
11074 | 12058 | /**/ |
---|
11075 | 12059 | |
---|
.. | .. |
---|
11262 | 12246 | String Shadow(String depth, String shadow) |
---|
11263 | 12247 | { |
---|
11264 | 12248 | return "MAX temp.x, ndotl.x, one64th.x;" + |
---|
| 12249 | + "MIN temp.x, temp.x, ninetenth.x;" + |
---|
11265 | 12250 | /**/ |
---|
11266 | 12251 | // Sine |
---|
11267 | 12252 | "MUL temp.y, temp.x, temp.x;" + |
---|
.. | .. |
---|
11886 | 12871 | return; |
---|
11887 | 12872 | } |
---|
11888 | 12873 | |
---|
| 12874 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
11889 | 12875 | |
---|
11890 | 12876 | // TIMER |
---|
11891 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR |
---|
| 12877 | + if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
11892 | 12878 | { |
---|
11893 | 12879 | keepboxmode = BOXMODE; |
---|
11894 | 12880 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
12017 | 13003 | // ObjEditor.tweenManager.update(1f / 60f); |
---|
12018 | 13004 | |
---|
12019 | 13005 | // fev 2014??? |
---|
12020 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode) |
---|
| 13006 | + if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
12021 | 13007 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
12022 | 13008 | pingthread.StepToTarget(true); // true); |
---|
12023 | 13009 | } |
---|
.. | .. |
---|
12268 | 13254 | //System.out.println("---------------- ---------- Paint " + tmp.length2()); |
---|
12269 | 13255 | if (lightMode) |
---|
12270 | 13256 | { |
---|
12271 | | - lighttouched = true; |
---|
| 13257 | + Globals.lighttouched = true; |
---|
12272 | 13258 | } |
---|
12273 | 13259 | |
---|
12274 | 13260 | if (OEILONCE && OEIL) |
---|
.. | .. |
---|
12326 | 13312 | mouseDown = false; |
---|
12327 | 13313 | if (lightMode) |
---|
12328 | 13314 | { |
---|
12329 | | - lighttouched = true; |
---|
| 13315 | + Globals.lighttouched = true; |
---|
12330 | 13316 | } |
---|
12331 | 13317 | repaint(); |
---|
12332 | 13318 | alreadypainted = true; |
---|
.. | .. |
---|
12334 | 13320 | isMoving = false; |
---|
12335 | 13321 | } //?? |
---|
12336 | 13322 | |
---|
12337 | | - if (isLIVE() && !alreadypainted) |
---|
| 13323 | + if (Globals.isLIVE() && !alreadypainted) |
---|
12338 | 13324 | { |
---|
12339 | 13325 | // FOR DEBUG BREAKPOINT USING PAUSE: while (true) |
---|
12340 | 13326 | repaint(); |
---|
.. | .. |
---|
12346 | 13332 | { |
---|
12347 | 13333 | if (lightMode) |
---|
12348 | 13334 | { |
---|
12349 | | - lighttouched = true; |
---|
| 13335 | + Globals.lighttouched = true; |
---|
12350 | 13336 | } |
---|
12351 | 13337 | drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
12352 | 13338 | } |
---|
.. | .. |
---|
12589 | 13575 | { |
---|
12590 | 13576 | manipCamera.Translate(dx, dy, getWidth()); |
---|
12591 | 13577 | } |
---|
| 13578 | + else |
---|
12592 | 13579 | if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0) |
---|
12593 | 13580 | { |
---|
12594 | 13581 | manipCamera.RotateInterest(dx, dy); |
---|
.. | .. |
---|
12599 | 13586 | |
---|
12600 | 13587 | if (manipCamera == lightCamera) |
---|
12601 | 13588 | { |
---|
12602 | | - lighttouched = true; |
---|
| 13589 | + Globals.lighttouched = true; |
---|
12603 | 13590 | } |
---|
12604 | 13591 | /* |
---|
12605 | 13592 | switch (mode) |
---|
.. | .. |
---|
12814 | 13801 | { |
---|
12815 | 13802 | mouseMode |= ZOOM; |
---|
12816 | 13803 | } |
---|
12817 | | - if ((modifiers & META) == META) |
---|
| 13804 | + |
---|
| 13805 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
| 13806 | + if (capsLocked || (modifiers & META) == META) |
---|
12818 | 13807 | { |
---|
12819 | 13808 | mouseMode |= VR; // BACKFORTH; |
---|
12820 | 13809 | } |
---|
12821 | 13810 | if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
12822 | 13811 | { |
---|
12823 | | - mouseMode |= SELECT; // BACKFORTH; |
---|
| 13812 | + mouseMode |= SELECT; |
---|
12824 | 13813 | } |
---|
12825 | 13814 | if ((modifiers & COMMAND) == COMMAND) |
---|
12826 | 13815 | { |
---|
.. | .. |
---|
12828 | 13817 | } |
---|
12829 | 13818 | if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
12830 | 13819 | { |
---|
| 13820 | + mouseMode &= ~VR; |
---|
12831 | 13821 | mouseMode |= TRANSLATE; |
---|
12832 | 13822 | } |
---|
12833 | 13823 | // if ((modifiers & SHIFT_META) == SHIFT_META) |
---|
.. | .. |
---|
12984 | 13974 | case 'B': |
---|
12985 | 13975 | BRISMOOTH ^= true; |
---|
12986 | 13976 | SHADOWCULLFACE ^= true; |
---|
12987 | | - lighttouched = true; |
---|
| 13977 | + Globals.lighttouched = true; |
---|
12988 | 13978 | repaint(); |
---|
12989 | 13979 | break; |
---|
12990 | 13980 | case 'b': |
---|
.. | .. |
---|
13084 | 14074 | repaint(); |
---|
13085 | 14075 | break; |
---|
13086 | 14076 | case 'O': |
---|
13087 | | - drawMode = OCCLUSION; |
---|
| 14077 | + Globals.drawMode = OCCLUSION; // WARNING |
---|
13088 | 14078 | repaint(); |
---|
13089 | 14079 | break; |
---|
13090 | 14080 | case 'o': |
---|
.. | .. |
---|
13175 | 14165 | break; |
---|
13176 | 14166 | case ' ': |
---|
13177 | 14167 | lightMode ^= true; |
---|
13178 | | - lighttouched = true; |
---|
| 14168 | + Globals.lighttouched = true; |
---|
13179 | 14169 | manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
13180 | 14170 | targetLookAt.set(manipCamera.lookAt); |
---|
13181 | 14171 | repaint(); |
---|
.. | .. |
---|
13187 | 14177 | repaint(); |
---|
13188 | 14178 | break; |
---|
13189 | 14179 | case 'Z': |
---|
13190 | | - RESIZETEXTURE ^= true; |
---|
13191 | | - break; |
---|
| 14180 | + //RESIZETEXTURE ^= true; |
---|
| 14181 | + //break; |
---|
13192 | 14182 | case 'z': |
---|
13193 | 14183 | RENDERSHADOW ^= true; |
---|
13194 | | - lighttouched = true; |
---|
| 14184 | + Globals.lighttouched = true; |
---|
13195 | 14185 | repaint(); |
---|
13196 | 14186 | break; |
---|
13197 | 14187 | //case UP: |
---|
.. | .. |
---|
13217 | 14207 | FlipTransform(); |
---|
13218 | 14208 | break; |
---|
13219 | 14209 | case ENTER: |
---|
13220 | | - object.editWindow.ScreenFit(); // Edit(); |
---|
| 14210 | + // object.editWindow.ScreenFit(); // Edit(); |
---|
| 14211 | + ToggleLive(); |
---|
13221 | 14212 | break; |
---|
13222 | 14213 | case DELETE: |
---|
13223 | 14214 | ClearSelection(); |
---|
.. | .. |
---|
13792 | 14783 | //if (g != gr) g.drawImage(img, 0, 0, width, height, null); |
---|
13793 | 14784 | } |
---|
13794 | 14785 | |
---|
| 14786 | + // To avoid clear. |
---|
13795 | 14787 | public void update(Graphics g) |
---|
13796 | 14788 | { |
---|
13797 | 14789 | paint(g); |
---|
.. | .. |
---|
14394 | 15386 | gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS); |
---|
14395 | 15387 | gl.glPushMatrix(); |
---|
14396 | 15388 | gl.glLoadIdentity(); |
---|
14397 | | - PushMatrix(checker.toParent); |
---|
| 15389 | + //PushMatrix(checker.toParent); |
---|
14398 | 15390 | |
---|
14399 | 15391 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
14400 | 15392 | gl.glPushMatrix(); |
---|
.. | .. |
---|
14417 | 15409 | |
---|
14418 | 15410 | gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
14419 | 15411 | |
---|
14420 | | - float step = 0.1666f; //0.25f; |
---|
14421 | | - float stepv = step * 1652 / 998; |
---|
| 15412 | + float step = 2; // 0.1666f; //0.25f; |
---|
| 15413 | + float stepv = 2; // step * 1652 / 998; |
---|
14422 | 15414 | |
---|
14423 | 15415 | int i0 = 0; |
---|
14424 | 15416 | /* |
---|
.. | .. |
---|
14454 | 15446 | /**/ |
---|
14455 | 15447 | //checker.GetMaterial().opacity = 1.1f; |
---|
14456 | 15448 | ////checker.GetMaterial().ambient = 0.99f; |
---|
14457 | | - Object3D.materialstack[Object3D.materialdepth] = checker.material; |
---|
14458 | | - Object3D.selectedstack[Object3D.materialdepth] = false; |
---|
14459 | | - cStatic.objectstack[Object3D.materialdepth++] = checker; |
---|
| 15449 | + materialstack[materialdepth] = checker.material; |
---|
| 15450 | + selectedstack[materialdepth] = false; |
---|
| 15451 | + cStatic.objectstack[materialdepth++] = checker; |
---|
14460 | 15452 | //System.out.println("material " + material); |
---|
14461 | 15453 | //Applet3D.tracein(this, selected); |
---|
14462 | 15454 | vector2buffer = checker.projectedVertices; |
---|
14463 | 15455 | |
---|
14464 | | - checker.GetMaterial().Draw(this, false); // true); |
---|
| 15456 | + //checker.GetMaterial().Draw(this, false); // true); |
---|
| 15457 | + DrawMaterial(checker.GetMaterial(), false); // true); |
---|
14465 | 15458 | |
---|
14466 | | - Object3D.materialdepth -= 1; |
---|
14467 | | - if (Object3D.materialdepth > 0) |
---|
| 15459 | + materialdepth -= 1; |
---|
| 15460 | + if (materialdepth > 0) |
---|
14468 | 15461 | { |
---|
14469 | | - vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices; |
---|
14470 | | - Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]); |
---|
| 15462 | + vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 15463 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
14471 | 15464 | } |
---|
14472 | 15465 | //checker.GetMaterial().opacity = 1f; |
---|
14473 | 15466 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
14488 | 15481 | |
---|
14489 | 15482 | //float u = (i+1)/2; |
---|
14490 | 15483 | //float v = (j+1)/2; |
---|
14491 | | - gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
| 15484 | + if (checker.flipV) |
---|
| 15485 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2); |
---|
| 15486 | + else |
---|
| 15487 | + gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
14492 | 15488 | gl.glVertex3f(i, j, -0.5f); |
---|
14493 | 15489 | |
---|
| 15490 | + if (checker.flipV) |
---|
| 15491 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
| 15492 | + else |
---|
14494 | 15493 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
14495 | 15494 | gl.glVertex3f(i + step, j, -0.5f); |
---|
14496 | 15495 | |
---|
| 15496 | + if (checker.flipV) |
---|
| 15497 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
| 15498 | + else |
---|
14497 | 15499 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
14498 | 15500 | gl.glVertex3f(i + step, j + stepv, -0.5f); |
---|
14499 | 15501 | |
---|
| 15502 | + if (checker.flipV) |
---|
| 15503 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
| 15504 | + else |
---|
14500 | 15505 | gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
14501 | 15506 | gl.glVertex3f(i, j + stepv, -0.5f); |
---|
14502 | 15507 | } |
---|
.. | .. |
---|
14508 | 15513 | gl.glMatrixMode(GL.GL_PROJECTION); |
---|
14509 | 15514 | gl.glPopMatrix(); |
---|
14510 | 15515 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
14511 | | - PopMatrix(null); // checker.toParent); // null); |
---|
| 15516 | + //PopMatrix(null); // checker.toParent); // null); |
---|
14512 | 15517 | gl.glPopMatrix(); |
---|
14513 | 15518 | PopTextureMatrix(checker.toParent); |
---|
14514 | 15519 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
.. | .. |
---|
14621 | 15626 | |
---|
14622 | 15627 | //int tmp = selection_view; |
---|
14623 | 15628 | //selection_view = -1; |
---|
14624 | | - int temp = drawMode; |
---|
14625 | | - drawMode = SELECTION; |
---|
| 15629 | + int temp = DrawMode(); |
---|
| 15630 | + Globals.drawMode = SELECTION; // WARNING |
---|
14626 | 15631 | indexcount = 0; |
---|
14627 | 15632 | parent.display(drawable); |
---|
14628 | 15633 | //selection_view = tmp; |
---|
14629 | 15634 | //if (temp == SELECTION) |
---|
14630 | 15635 | // temp = DEFAULT; // patch for selection debug |
---|
14631 | | - drawMode = temp; |
---|
| 15636 | + Globals.drawMode = temp; // WARNING |
---|
14632 | 15637 | |
---|
14633 | 15638 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
14634 | 15639 | |
---|
.. | .. |
---|
14677 | 15682 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
14678 | 15683 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
14679 | 15684 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 15685 | + |
---|
| 15686 | + // Will fit the mesh !!! |
---|
| 15687 | + selectedpoint.toParent[0][0] = 0.0001; |
---|
| 15688 | + selectedpoint.toParent[1][1] = 0.0001; |
---|
| 15689 | + selectedpoint.toParent[2][2] = 0.0001; |
---|
14680 | 15690 | |
---|
14681 | 15691 | glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0); |
---|
14682 | 15692 | |
---|
.. | .. |
---|
14896 | 15906 | //gl.glColorMask(false, false, false, false); |
---|
14897 | 15907 | |
---|
14898 | 15908 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
14899 | | - if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 15909 | + if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
14900 | 15910 | { |
---|
14901 | 15911 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14902 | 15912 | |
---|
14903 | | - int temp = drawMode; |
---|
14904 | | - drawMode = SHADOW; |
---|
| 15913 | + int temp = DrawMode(); |
---|
| 15914 | + Globals.drawMode = SHADOW; // WARNING |
---|
14905 | 15915 | parent.display(drawable); |
---|
14906 | | - drawMode = temp; |
---|
| 15916 | + Globals.drawMode = temp; // WARNING |
---|
14907 | 15917 | } |
---|
14908 | 15918 | |
---|
14909 | 15919 | gl.glCullFace(gl.GL_BACK); |
---|
.. | .. |
---|
15066 | 16076 | gl.glFlush(); |
---|
15067 | 16077 | |
---|
15068 | 16078 | /**/ |
---|
15069 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer); |
---|
| 16079 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
15070 | 16080 | |
---|
15071 | | - int[] pixels = occlusionsizebuffer.array(); |
---|
| 16081 | + float[] pixels = occlusionsizebuffer.array(); |
---|
15072 | 16082 | |
---|
15073 | 16083 | double r = 0, g = 0, b = 0; |
---|
15074 | 16084 | |
---|
15075 | 16085 | double count = 0; |
---|
| 16086 | + |
---|
| 16087 | + gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0); |
---|
| 16088 | + |
---|
| 16089 | + float mindepth = 1; |
---|
| 16090 | + |
---|
| 16091 | + double FACTOR = 1; |
---|
15076 | 16092 | |
---|
15077 | 16093 | for (int i = 0; i < pixels.length; i++) |
---|
15078 | 16094 | { |
---|
.. | .. |
---|
15157 | 16173 | |
---|
15158 | 16174 | double scale = ray.z; // 1; // cos |
---|
15159 | 16175 | |
---|
15160 | | - int p = pixels[newindex]; |
---|
| 16176 | + float depth = pixels[newindex]; |
---|
15161 | 16177 | |
---|
15162 | 16178 | /* |
---|
15163 | 16179 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
15181 | 16197 | scale = (1 - modu) * modv; |
---|
15182 | 16198 | */ |
---|
15183 | 16199 | |
---|
15184 | | - r += ((p >> 16) & 0xFF) * scale / 255; |
---|
15185 | | - g += ((p >> 8) & 0xFF) * scale / 255; |
---|
15186 | | - b += (p & 0xFF) * scale / 255; |
---|
| 16200 | + //r += ((p >> 16) & 0xFF) * scale / 255; |
---|
| 16201 | + //g += ((p >> 8) & 0xFF) * scale / 255; |
---|
| 16202 | + //b += (p & 0xFF) * scale / 255; |
---|
| 16203 | + |
---|
| 16204 | + if (mindepth > depth) |
---|
| 16205 | + { |
---|
| 16206 | + mindepth = depth; |
---|
| 16207 | + } |
---|
15187 | 16208 | |
---|
| 16209 | + double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]); |
---|
| 16210 | + |
---|
| 16211 | + double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR); |
---|
| 16212 | + |
---|
| 16213 | + r += factor * scale; |
---|
| 16214 | + g += factor * scale; |
---|
| 16215 | + b += factor * scale; |
---|
| 16216 | + |
---|
15188 | 16217 | count += scale; |
---|
15189 | 16218 | } |
---|
15190 | 16219 | |
---|
.. | .. |
---|
15282 | 16311 | GLUT glut = new GLUT(); |
---|
15283 | 16312 | |
---|
15284 | 16313 | |
---|
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 | 16314 | public boolean spherical = false; |
---|
15292 | 16315 | static boolean DEBUG_OCCLUSION = false; |
---|
15293 | 16316 | static boolean DEBUG_SELECTION = false; |
---|
.. | .. |
---|
15300 | 16323 | int AAbuffersize = 0; |
---|
15301 | 16324 | |
---|
15302 | 16325 | //double[] selectedpoint = new double[3]; |
---|
15303 | | - static Sphere selectedpoint = new Sphere(); |
---|
| 16326 | + static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
15304 | 16327 | 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(); |
---|
| 16328 | + static Sphere debugpointG = new Sphere(); |
---|
| 16329 | + static Sphere debugpointP = new Sphere(); |
---|
| 16330 | + static Sphere debugpointC = new Sphere(); |
---|
| 16331 | + static Sphere debugpointR = new Sphere(); |
---|
15309 | 16332 | |
---|
15310 | 16333 | static Sphere debugpoints[] = new Sphere[8]; |
---|
15311 | 16334 | |
---|
.. | .. |
---|
15358 | 16381 | static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
15359 | 16382 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15360 | 16383 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15361 | | - static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 16384 | + //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 16385 | + static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
15362 | 16386 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
15363 | 16387 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
15364 | 16388 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|