.. | .. |
---|
31 | 31 | |
---|
32 | 32 | import gleem.linalg.Mat4f; |
---|
33 | 33 | |
---|
34 | | -class CameraPane extends GLCanvas implements Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
| 34 | +class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 35 | { |
---|
| 36 | + static cMaterial[] materialstack = new cMaterial[65536]; |
---|
| 37 | + static boolean[] selectedstack = new boolean[65536]; |
---|
| 38 | + static int materialdepth = 0; |
---|
| 39 | + |
---|
36 | 40 | static boolean DEBUG = false; |
---|
37 | 41 | static boolean FRUSTUM = false; // still bogus true; // frustum culling |
---|
38 | 42 | |
---|
.. | .. |
---|
42 | 46 | |
---|
43 | 47 | static int STEP = 1; |
---|
44 | 48 | |
---|
45 | | - static boolean ONESTEP = false; // do LIVE once |
---|
46 | | - |
---|
47 | | - /** |
---|
48 | | - * @return the LIVE |
---|
49 | | - */ |
---|
50 | | - public static boolean isLIVE() |
---|
51 | | - { |
---|
52 | | - return LIVE || ONESTEP; |
---|
53 | | - } |
---|
54 | | - |
---|
55 | | - /** |
---|
56 | | - * @param aLIVE the LIVE to set |
---|
57 | | - */ |
---|
58 | | - public static void setLIVE(boolean aLIVE) |
---|
59 | | - { |
---|
60 | | - LIVE = aLIVE; |
---|
61 | | - } |
---|
62 | | - |
---|
63 | | - /*static*/ boolean CULLFACE = false; // true; |
---|
| 49 | + /*static*/ private boolean CULLFACE = false; // true; |
---|
64 | 50 | /*static*/ boolean NEAREST = false; // true; |
---|
65 | 51 | /*static*/ boolean WIREFRAME = false; // true; |
---|
66 | 52 | |
---|
.. | .. |
---|
97 | 83 | |
---|
98 | 84 | static boolean textureon = true; |
---|
99 | 85 | static boolean LOCALTRANSFORM = false; |
---|
100 | | -private static boolean LIVE = false; |
---|
101 | 86 | static boolean FULLSCREEN = false; |
---|
102 | 87 | static boolean SUPPORT = true; |
---|
103 | | -static boolean CROWD = false; |
---|
104 | 88 | static boolean INERTIA = true; |
---|
105 | 89 | static boolean FAST = false; |
---|
106 | 90 | static boolean SLOWPOSE = false; |
---|
.. | .. |
---|
165 | 149 | defaultcaps.setAccumBlueBits(16); |
---|
166 | 150 | defaultcaps.setAccumAlphaBits(16); |
---|
167 | 151 | } |
---|
168 | | - static CameraPane theRenderer; |
---|
169 | | - |
---|
| 152 | + |
---|
170 | 153 | void SetAsGLRenderer(boolean b) |
---|
171 | 154 | { |
---|
172 | 155 | isRenderer = b; |
---|
173 | | - theRenderer = this; |
---|
| 156 | + Globals.theRenderer = this; |
---|
| 157 | + } |
---|
| 158 | + |
---|
| 159 | + CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
| 160 | + { |
---|
| 161 | + super(defaultcaps, null, withcontext?glcontext:null, null); |
---|
| 162 | + |
---|
| 163 | + //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523)); |
---|
| 164 | + glcontext = getContext(); |
---|
| 165 | + |
---|
| 166 | + cameras = new Camera[2]; |
---|
| 167 | + targetLookAts = new cVector[2]; |
---|
| 168 | + |
---|
| 169 | + SetCamera(cam); |
---|
| 170 | + |
---|
| 171 | + SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 172 | + |
---|
| 173 | + object = o; |
---|
| 174 | + |
---|
| 175 | + setBackground(Color.white); |
---|
| 176 | + |
---|
| 177 | + addKeyListener(this); |
---|
| 178 | + addMouseListener(this); |
---|
| 179 | + addMouseMotionListener(this); |
---|
| 180 | + addMouseWheelListener(this); |
---|
| 181 | + //System.out.println("addGLEventListener: " + this); |
---|
| 182 | + addGLEventListener(this); |
---|
| 183 | + |
---|
| 184 | +// pingthread.start(); // may 2013 |
---|
174 | 185 | } |
---|
175 | 186 | |
---|
176 | 187 | static boolean AntialiasingEnabled() |
---|
.. | .. |
---|
178 | 189 | return CURRENTANTIALIAS > 0; |
---|
179 | 190 | } |
---|
180 | 191 | |
---|
181 | | - void ClearDepth() |
---|
| 192 | + /// INTERFACE |
---|
| 193 | + |
---|
| 194 | + public boolean IsBoxMode() |
---|
| 195 | + { |
---|
| 196 | + return BOXMODE; |
---|
| 197 | + } |
---|
| 198 | + |
---|
| 199 | + public void ClearDepth() |
---|
182 | 200 | { |
---|
183 | 201 | GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT); |
---|
184 | 202 | } |
---|
185 | 203 | |
---|
186 | | - void DepthTest(boolean depthtest) |
---|
| 204 | + public void DepthTest(boolean depthtest) |
---|
187 | 205 | { |
---|
188 | 206 | if (depthtest) |
---|
189 | 207 | GetGL().glDepthFunc(GL.GL_LEQUAL); |
---|
.. | .. |
---|
191 | 209 | GetGL().glDepthFunc(GL.GL_ALWAYS); |
---|
192 | 210 | } |
---|
193 | 211 | |
---|
194 | | - void DepthWrite(boolean depthwrite) |
---|
| 212 | + public void DepthWrite(boolean depthwrite) |
---|
195 | 213 | { |
---|
196 | 214 | if (depthwrite) |
---|
197 | 215 | GetGL().glDepthMask(true); |
---|
.. | .. |
---|
199 | 217 | GetGL().glDepthMask(false); |
---|
200 | 218 | } |
---|
201 | 219 | |
---|
202 | | - void BackFaceCull(boolean bfc) |
---|
| 220 | + public void BackFaceCull(boolean bfc) |
---|
203 | 221 | { |
---|
204 | 222 | if (bfc) |
---|
205 | 223 | GetGL().glEnable(GetGL().GL_CULL_FACE); |
---|
206 | 224 | else |
---|
207 | 225 | GetGL().glDisable(GetGL().GL_CULL_FACE); |
---|
| 226 | + } |
---|
| 227 | + |
---|
| 228 | + public boolean BackFaceCullMode() |
---|
| 229 | + { |
---|
| 230 | + return this.CULLFACE; |
---|
| 231 | + } |
---|
| 232 | + |
---|
| 233 | + public boolean IsAmbientOcclusionOn() |
---|
| 234 | + { |
---|
| 235 | + return this.ambientOcclusion; |
---|
| 236 | + } |
---|
| 237 | + |
---|
| 238 | + public boolean IsDebugSelection() |
---|
| 239 | + { |
---|
| 240 | + return DEBUG_SELECTION; |
---|
| 241 | + } |
---|
| 242 | + |
---|
| 243 | + public boolean IsFrozen() |
---|
| 244 | + { |
---|
| 245 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
| 246 | + |
---|
| 247 | + return !selectmode && cameracount == 0; // != 0; |
---|
| 248 | + } |
---|
| 249 | + |
---|
| 250 | + // Currently in Globals |
---|
| 251 | + public int DrawMode() |
---|
| 252 | + { |
---|
| 253 | + return Globals.DrawMode(); |
---|
| 254 | + } |
---|
| 255 | + |
---|
| 256 | + public Camera EyeCamera() |
---|
| 257 | + { |
---|
| 258 | + return eyeCamera; |
---|
| 259 | + } |
---|
| 260 | + |
---|
| 261 | + public Camera LightCamera() |
---|
| 262 | + { |
---|
| 263 | + return lightCamera; |
---|
| 264 | + } |
---|
| 265 | + |
---|
| 266 | + public Camera ManipCamera() |
---|
| 267 | + { |
---|
| 268 | + return manipCamera; |
---|
| 269 | + } |
---|
| 270 | + |
---|
| 271 | + public Camera RenderCamera() |
---|
| 272 | + { |
---|
| 273 | + return renderCamera; |
---|
| 274 | + } |
---|
| 275 | + |
---|
| 276 | + public Camera[] Cameras() |
---|
| 277 | + { |
---|
| 278 | + return cameras; |
---|
| 279 | + } |
---|
| 280 | + |
---|
| 281 | + public void PushMaterial(Object3D obj, boolean selected) |
---|
| 282 | + { |
---|
| 283 | + CameraPane display = this; |
---|
| 284 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 285 | + cMaterial material = obj.material; |
---|
| 286 | + |
---|
| 287 | + if (material != null) |
---|
| 288 | + { |
---|
| 289 | + materialstack[materialdepth] = material; |
---|
| 290 | + selectedstack[materialdepth] = selected; |
---|
| 291 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 292 | + //System.out.println("material " + material); |
---|
| 293 | + //Applet3D.tracein(this, selected); |
---|
| 294 | + display.vector2buffer = obj.projectedVertices; |
---|
| 295 | + if (obj instanceof Camera) |
---|
| 296 | + { |
---|
| 297 | + display.options1[0] = material.shift; |
---|
| 298 | + //System.out.println("shift " + material.shift); |
---|
| 299 | + display.options1[1] = material.lightarea; |
---|
| 300 | + display.options1[2] = material.shadowbias; |
---|
| 301 | + display.options1[3] = material.aniso; |
---|
| 302 | + display.options1[4] = material.anisoV; |
---|
| 303 | + display.options2[0] = material.opacity; |
---|
| 304 | + display.options2[1] = material.diffuse; |
---|
| 305 | + display.options2[2] = material.factor; |
---|
| 306 | + |
---|
| 307 | + cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 308 | + display.options4[0] = material.cameralight/0.2f; |
---|
| 309 | + display.options4[1] = material.subsurface; |
---|
| 310 | + display.options4[2] = material.sheen; |
---|
| 311 | + |
---|
| 312 | + // if (display.CURRENTANTIALIAS > 0) |
---|
| 313 | + // display.options3[3] /= 4; |
---|
| 314 | + |
---|
| 315 | + /* |
---|
| 316 | + System.out.println("Focus = " + display.options1[0]); |
---|
| 317 | + System.out.println("Aperture = " + display.options1[1]); |
---|
| 318 | + System.out.println("ShadowBlur = " + display.options1[2]); |
---|
| 319 | + System.out.println("Antialiasing = " + display.options1[3]); |
---|
| 320 | + System.out.println("Fog = " + display.options2[0]); |
---|
| 321 | + System.out.println("Intensity = " + display.options2[1]); |
---|
| 322 | + System.out.println("Elevation = " + display.options2[2]); |
---|
| 323 | + /**/ |
---|
| 324 | + } else |
---|
| 325 | + { |
---|
| 326 | + DrawMaterial(material, selected); |
---|
| 327 | + } |
---|
| 328 | + } else |
---|
| 329 | + { |
---|
| 330 | + if (selected && CameraPane.flash) |
---|
| 331 | + { |
---|
| 332 | + display.modelParams4[1] = 100; |
---|
| 333 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 334 | + } |
---|
| 335 | + } |
---|
| 336 | + } |
---|
| 337 | + |
---|
| 338 | + public void PushMaterial2(Object3D obj, boolean selected) |
---|
| 339 | + { |
---|
| 340 | + CameraPane display = this; |
---|
| 341 | + cMaterial material = obj.material; |
---|
| 342 | + |
---|
| 343 | + if (material != null) |
---|
| 344 | + { |
---|
| 345 | + materialstack[materialdepth] = material; |
---|
| 346 | + selectedstack[materialdepth] = selected; |
---|
| 347 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 348 | + //System.out.println("material " + material); |
---|
| 349 | + //Applet3D.tracein("selected ", selected); |
---|
| 350 | + display.vector2buffer = obj.projectedVertices; |
---|
| 351 | + display.DrawMaterial(material, selected); |
---|
| 352 | + } |
---|
| 353 | + } |
---|
| 354 | + |
---|
| 355 | + public void PopMaterial(Object3D obj, boolean selected) |
---|
| 356 | + { |
---|
| 357 | + CameraPane display = this; |
---|
| 358 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 359 | + cMaterial material = obj.material; |
---|
| 360 | + |
---|
| 361 | + //if (parent != null && parent.GetMaterial() != null) |
---|
| 362 | + // parent.GetMaterial().Draw(display, parent.IsSelected(this)); |
---|
| 363 | + if (material != null) |
---|
| 364 | + { |
---|
| 365 | + materialdepth -= 1; |
---|
| 366 | + if (materialdepth > 0) |
---|
| 367 | + { |
---|
| 368 | + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 369 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 370 | + } |
---|
| 371 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 372 | + } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
| 373 | + { |
---|
| 374 | + display.modelParams4[1] = obj.GetMaterial().cameralight; |
---|
| 375 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 376 | + } |
---|
| 377 | + } |
---|
| 378 | + |
---|
| 379 | + public void PopMaterial2(Object3D obj) |
---|
| 380 | + { |
---|
| 381 | + CameraPane display = this; |
---|
| 382 | + cMaterial material = obj.material; |
---|
| 383 | + |
---|
| 384 | + if (material != null) |
---|
| 385 | + { |
---|
| 386 | + materialdepth -= 1; |
---|
| 387 | + if (materialdepth > 0) |
---|
| 388 | + { |
---|
| 389 | + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 390 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 391 | + } |
---|
| 392 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 393 | + //else |
---|
| 394 | + //material.Draw(display, false); |
---|
| 395 | + } |
---|
| 396 | + } |
---|
| 397 | + |
---|
| 398 | + public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face) |
---|
| 399 | + { |
---|
| 400 | + CameraPane display = this; |
---|
| 401 | + |
---|
| 402 | + if (pv.y == -10000 || |
---|
| 403 | + qv.y == -10000 || |
---|
| 404 | + rv.y == -10000) |
---|
| 405 | + return; |
---|
| 406 | + |
---|
| 407 | +// float b = f.nbiterations & 1; |
---|
| 408 | +// float g = (f.nbiterations>>1) & 1; |
---|
| 409 | +// float r = (f.nbiterations>>2) & 1; |
---|
| 410 | +// |
---|
| 411 | +// //if (f.weight == 10000) |
---|
| 412 | +// //{ |
---|
| 413 | +// // r = 1; g = b = 0; |
---|
| 414 | +// //} |
---|
| 415 | +// //else |
---|
| 416 | +// //{ |
---|
| 417 | +// // assert(f.weight < 10000); |
---|
| 418 | +// r = g = b = (float)bRep.FaceWeight(f)*100; |
---|
| 419 | +// if (r<0) |
---|
| 420 | +// assert(r>=0); |
---|
| 421 | +// //} |
---|
| 422 | + |
---|
| 423 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 424 | + |
---|
| 425 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
| 426 | + |
---|
| 427 | + //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
| 428 | + if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
| 429 | + { |
---|
| 430 | + //gl.glBegin(gl.GL_TRIANGLES); |
---|
| 431 | + boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 432 | + if (!hasnorm) |
---|
| 433 | + { |
---|
| 434 | + // System.out.println("FUCK!!"); |
---|
| 435 | + LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
| 436 | + LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
| 437 | + LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
| 438 | + LA.vecNormalize(obj.v2); |
---|
| 439 | + gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 440 | + } |
---|
| 441 | + |
---|
| 442 | + // P |
---|
| 443 | + float x = (float)pv.x; |
---|
| 444 | + float y = (float)pv.y; |
---|
| 445 | + float z = (float)pv.z; |
---|
| 446 | + |
---|
| 447 | + if (hasnorm) |
---|
| 448 | + { |
---|
| 449 | +// if (!pv.norm.normalized()) |
---|
| 450 | +// assert(pv.norm.normalized()); |
---|
| 451 | + |
---|
| 452 | + //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z); |
---|
| 453 | + float nx = (float)pv.norm.x; |
---|
| 454 | + float ny = (float)pv.norm.y; |
---|
| 455 | + float nz = (float)pv.norm.z; |
---|
| 456 | + |
---|
| 457 | + x += nx * obj.NORMALPUSH; |
---|
| 458 | + y += ny * obj.NORMALPUSH; |
---|
| 459 | + z += nz * obj.NORMALPUSH; |
---|
| 460 | + |
---|
| 461 | + gl.glNormal3f(nx, ny, nz); |
---|
| 462 | + } |
---|
| 463 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 464 | + SetColor(obj, pv); |
---|
| 465 | + //gl.glColor4f(r, g, b, 1); |
---|
| 466 | + //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1); |
---|
| 467 | + if (obj.flipV) |
---|
| 468 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 469 | + else |
---|
| 470 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 471 | + //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z); |
---|
| 472 | + |
---|
| 473 | + gl.glVertex3f(x, y, z); |
---|
| 474 | + |
---|
| 475 | + // Q |
---|
| 476 | + x = (float)qv.x; |
---|
| 477 | + y = (float)qv.y; |
---|
| 478 | + z = (float)qv.z; |
---|
| 479 | + |
---|
| 480 | +// Print(pv); |
---|
| 481 | + if (hasnorm) |
---|
| 482 | + { |
---|
| 483 | +// assert(qv.norm.normalized()); |
---|
| 484 | + //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z); |
---|
| 485 | + float nx = (float)qv.norm.x; |
---|
| 486 | + float ny = (float)qv.norm.y; |
---|
| 487 | + float nz = (float)qv.norm.z; |
---|
| 488 | + |
---|
| 489 | + x += nx * obj.NORMALPUSH; |
---|
| 490 | + y += ny * obj.NORMALPUSH; |
---|
| 491 | + z += nz * obj.NORMALPUSH; |
---|
| 492 | + |
---|
| 493 | + gl.glNormal3f(nx, ny, nz); |
---|
| 494 | + } |
---|
| 495 | + //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
| 496 | + // boolean locked = false; |
---|
| 497 | + // float eps = 0.1f; |
---|
| 498 | + // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 499 | + |
---|
| 500 | + // int dot = 0; //*/ (int)f.dot; |
---|
| 501 | + |
---|
| 502 | + // if ((dot&1) == 0) |
---|
| 503 | + // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 504 | + |
---|
| 505 | + // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 506 | + if (obj.flipV) |
---|
| 507 | + gl.glTexCoord2f((float) qv.s, 1-(float) qv.t); |
---|
| 508 | + else |
---|
| 509 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 510 | + // else |
---|
| 511 | + // { |
---|
| 512 | + // locked = true; |
---|
| 513 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 514 | + // } |
---|
| 515 | + gl.glColor4f(qv.AO, qv.AO, qv.AO, 1); |
---|
| 516 | + SetColor(obj, qv); |
---|
| 517 | + |
---|
| 518 | + gl.glVertex3f(x, y, z); |
---|
| 519 | + //gl.glColor4f(r, g, b, 1); |
---|
| 520 | + //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1); |
---|
| 521 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 522 | +// Print(qv); |
---|
| 523 | + |
---|
| 524 | + // R |
---|
| 525 | + x = (float)rv.x; |
---|
| 526 | + y = (float)rv.y; |
---|
| 527 | + z = (float)rv.z; |
---|
| 528 | + |
---|
| 529 | + if (hasnorm) |
---|
| 530 | + { |
---|
| 531 | +// assert(rv.norm.normalized()); |
---|
| 532 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 533 | + float nx = (float)rv.norm.x; |
---|
| 534 | + float ny = (float)rv.norm.y; |
---|
| 535 | + float nz = (float)rv.norm.z; |
---|
| 536 | + |
---|
| 537 | + x += nx * obj.NORMALPUSH; |
---|
| 538 | + y += ny * obj.NORMALPUSH; |
---|
| 539 | + z += nz * obj.NORMALPUSH; |
---|
| 540 | + |
---|
| 541 | + gl.glNormal3f(nx, ny, nz); |
---|
| 542 | + } |
---|
| 543 | + |
---|
| 544 | + // if ((dot&4) == 0) |
---|
| 545 | + // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 546 | + |
---|
| 547 | + // if (wrap || !locked && (dot&8) != 0) |
---|
| 548 | + if (obj.flipV) |
---|
| 549 | + gl.glTexCoord2f((float) rv.s, 1-(float) rv.t); |
---|
| 550 | + else |
---|
| 551 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 552 | + // else |
---|
| 553 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 554 | + |
---|
| 555 | + // f.dot = dot; |
---|
| 556 | + |
---|
| 557 | + gl.glColor4f(rv.AO, rv.AO, rv.AO, 1); |
---|
| 558 | + SetColor(obj, rv); |
---|
| 559 | + //gl.glColor4f(r, g, b, 1); |
---|
| 560 | + //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1); |
---|
| 561 | + //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z); |
---|
| 562 | + gl.glVertex3f(x, y, z); |
---|
| 563 | +// Print(rv); |
---|
| 564 | + //gl.glEnd(); |
---|
| 565 | + } |
---|
| 566 | + else |
---|
| 567 | + { |
---|
| 568 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 569 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 570 | + gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z); |
---|
| 571 | + |
---|
| 572 | + } |
---|
| 573 | + |
---|
| 574 | + if (false) // (attributes & WIREFRAME) != 0) |
---|
| 575 | + { |
---|
| 576 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 577 | + |
---|
| 578 | + gl.glBegin(gl.GL_LINE_LOOP); |
---|
| 579 | + gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z); |
---|
| 580 | + gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z); |
---|
| 581 | + gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z); |
---|
| 582 | + gl.glEnd(); |
---|
| 583 | + |
---|
| 584 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 585 | + } |
---|
| 586 | + } |
---|
| 587 | + |
---|
| 588 | + /** |
---|
| 589 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 590 | + * it's normals, colors, textures and vertices. |
---|
| 591 | + * |
---|
| 592 | + * @see Renderer#draw(TriMesh) |
---|
| 593 | + * @param tris |
---|
| 594 | + * the mesh to render. |
---|
| 595 | + */ |
---|
| 596 | + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 597 | + { |
---|
| 598 | + CameraPane display = this; |
---|
| 599 | + |
---|
| 600 | + float r = display.modelParams0[0]; |
---|
| 601 | + float g = display.modelParams0[1]; |
---|
| 602 | + float b = display.modelParams0[2]; |
---|
| 603 | + float opacity = display.modelParams5[1]; |
---|
| 604 | + |
---|
| 605 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 606 | + GL gl = display.GetGL(); // getGL(); |
---|
| 607 | + |
---|
| 608 | + FloatBuffer vertBuf = geo.vertBuf; |
---|
| 609 | + |
---|
| 610 | + int v = vertBuf.capacity(); |
---|
| 611 | + |
---|
| 612 | + int count = 0; |
---|
| 613 | + |
---|
| 614 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 615 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 616 | + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
| 617 | + for (int i=0; i<v/3; i++) |
---|
| 618 | + { |
---|
| 619 | + int index3 = i*3; |
---|
| 620 | + |
---|
| 621 | + if (geo.sizeBuf.get(index3+1) == 0) |
---|
| 622 | + continue; |
---|
| 623 | + |
---|
| 624 | + count++; |
---|
| 625 | + |
---|
| 626 | + int index4 = i*4; |
---|
| 627 | + |
---|
| 628 | + float tx = vertBuf.get(index3); |
---|
| 629 | + float ty = vertBuf.get(index3+1); |
---|
| 630 | + float tz = vertBuf.get(index3+2); |
---|
| 631 | + |
---|
| 632 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 633 | + // continue; |
---|
| 634 | + |
---|
| 635 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 636 | + gl.glPushMatrix(); |
---|
| 637 | + |
---|
| 638 | + float[] texmat = geo.texmat; |
---|
| 639 | + texmat[12] = texmat[13] = texmat[14] = i; |
---|
| 640 | + |
---|
| 641 | + gl.glMultMatrixf(texmat, 0); |
---|
| 642 | + |
---|
| 643 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 644 | + gl.glPushMatrix(); |
---|
| 645 | + |
---|
| 646 | + gl.glTranslatef(tx,ty,tz); |
---|
| 647 | + |
---|
| 648 | + if (rotate) |
---|
| 649 | + gl.glRotatef(i, 0, 1, 0); |
---|
| 650 | + |
---|
| 651 | + float size = geo.sizeBuf.get(index3) / 100; |
---|
| 652 | + gl.glScalef(size,size,size); |
---|
| 653 | + |
---|
| 654 | + float cr = geo.colorBuf.get(index4); |
---|
| 655 | + float cg = geo.colorBuf.get(index4+1); |
---|
| 656 | + float cb = geo.colorBuf.get(index4+2); |
---|
| 657 | + float ca = geo.colorBuf.get(index4+3); |
---|
| 658 | + |
---|
| 659 | + display.modelParams0[0] = r * cr; |
---|
| 660 | + display.modelParams0[1] = g * cg; |
---|
| 661 | + display.modelParams0[2] = b * cb; |
---|
| 662 | + |
---|
| 663 | + display.modelParams5[1] = opacity * ca; |
---|
| 664 | + |
---|
| 665 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 666 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 667 | + |
---|
| 668 | + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; |
---|
| 669 | + RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 670 | + |
---|
| 671 | +// gl.glColor4f(cr,cg,cb,ca); |
---|
| 672 | + // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 673 | + shape.Draw/*Node*/(display,null,selected,false); // blocked |
---|
| 674 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 675 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 676 | + gl.glPopMatrix(); |
---|
| 677 | + |
---|
| 678 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 679 | + gl.glPopMatrix(); |
---|
| 680 | + } |
---|
| 681 | + // gl.glScalef(1024,1024,1024); |
---|
| 682 | + if (!cf) |
---|
| 683 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 684 | + |
---|
| 685 | + display.modelParams0[0] = r; |
---|
| 686 | + display.modelParams0[1] = g; |
---|
| 687 | + display.modelParams0[2] = b; |
---|
| 688 | + |
---|
| 689 | + display.modelParams5[1] = opacity; |
---|
| 690 | + |
---|
| 691 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 692 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 693 | + |
---|
| 694 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 695 | + |
---|
| 696 | +// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
| 697 | + if (true) |
---|
| 698 | + return; |
---|
| 699 | + |
---|
| 700 | +//// if (!tris.predraw(this)) |
---|
| 701 | +//// { |
---|
| 702 | +//// return; |
---|
| 703 | +//// } |
---|
| 704 | +//// if (Debug.stats) |
---|
| 705 | +//// { |
---|
| 706 | +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
| 707 | +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
| 708 | +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
| 709 | +//// } |
---|
| 710 | +//// |
---|
| 711 | +//// if (tris.getDisplayListID() != -1) |
---|
| 712 | +//// { |
---|
| 713 | +//// renderDisplayList(tris); |
---|
| 714 | +//// return; |
---|
| 715 | +//// } |
---|
| 716 | +//// |
---|
| 717 | +//// if (!generatingDisplayList) |
---|
| 718 | +//// { |
---|
| 719 | +//// applyStates(tris.states, tris); |
---|
| 720 | +//// } |
---|
| 721 | +//// if (Debug.stats) |
---|
| 722 | +//// { |
---|
| 723 | +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
| 724 | +//// } |
---|
| 725 | +//// boolean transformed = doTransforms(tris); |
---|
| 726 | +// |
---|
| 727 | +// int glMode = GL.GL_TRIANGLES; |
---|
| 728 | +// switch (getMode()) |
---|
| 729 | +// { |
---|
| 730 | +// case Triangles: |
---|
| 731 | +// glMode = GL.GL_TRIANGLES; |
---|
| 732 | +// break; |
---|
| 733 | +// case Strip: |
---|
| 734 | +// glMode = GL.GL_TRIANGLE_STRIP; |
---|
| 735 | +// break; |
---|
| 736 | +// case Fan: |
---|
| 737 | +// glMode = GL.GL_TRIANGLE_FAN; |
---|
| 738 | +// break; |
---|
| 739 | +// } |
---|
| 740 | +// |
---|
| 741 | +// if (!predrawGeometry(gl)) |
---|
| 742 | +// { |
---|
| 743 | +// // make sure only the necessary indices are sent through on old |
---|
| 744 | +// // cards. |
---|
| 745 | +// IntBuffer indices = this.getIndexBuffer(); |
---|
| 746 | +// if (indices == null) |
---|
| 747 | +// { |
---|
| 748 | +// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
| 749 | +// } else |
---|
| 750 | +// { |
---|
| 751 | +// indices.rewind(); |
---|
| 752 | +// indices.limit(this.getMaxIndex()); |
---|
| 753 | +// |
---|
| 754 | +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
| 755 | +// |
---|
| 756 | +// indices.clear(); |
---|
| 757 | +// } |
---|
| 758 | +// } else |
---|
| 759 | +// { |
---|
| 760 | +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
| 761 | +// GL.GL_UNSIGNED_INT, 0); |
---|
| 762 | +// } |
---|
| 763 | +// |
---|
| 764 | +//// postdrawGeometry(tris); |
---|
| 765 | +//// if (transformed) |
---|
| 766 | +//// { |
---|
| 767 | +//// undoTransforms(tris); |
---|
| 768 | +//// } |
---|
| 769 | +//// |
---|
| 770 | +//// if (Debug.stats) |
---|
| 771 | +//// { |
---|
| 772 | +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
| 773 | +//// } |
---|
| 774 | +//// tris.postdraw(this); |
---|
| 775 | + } |
---|
| 776 | + |
---|
| 777 | + static Camera localcamera = new Camera(); |
---|
| 778 | + static cVector from = new cVector(); |
---|
| 779 | + static cVector to = new cVector(); |
---|
| 780 | + |
---|
| 781 | + public void PrepOcclusion(BoundaryRep br, double[][] transform) |
---|
| 782 | + { |
---|
| 783 | + CameraPane cp = this; |
---|
| 784 | + |
---|
| 785 | + Camera keep = cp.RenderCamera(); |
---|
| 786 | + cp.renderCamera = localcamera; |
---|
| 787 | + |
---|
| 788 | + if (br.trimmed) |
---|
| 789 | + { |
---|
| 790 | + float[] colors = new float[br.positions.length / 3]; |
---|
| 791 | + |
---|
| 792 | + int i3 = 0; |
---|
| 793 | + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) |
---|
| 794 | + { |
---|
| 795 | + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) |
---|
| 796 | + continue; |
---|
| 797 | + |
---|
| 798 | + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); |
---|
| 799 | + to.set(br.positions[i3] + br.normals[i3], |
---|
| 800 | + br.positions[i3 + 1] + br.normals[i3 + 1], |
---|
| 801 | + br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
| 802 | + LA.xformPos(from, transform, from); |
---|
| 803 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 804 | + localcamera.setAim(from, to); |
---|
| 805 | + |
---|
| 806 | + CameraPane.occlusionbuffer.display(); |
---|
| 807 | + |
---|
| 808 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 809 | + cp.display(); // debug |
---|
| 810 | + |
---|
| 811 | + colors[i] = cp.vertexOcclusion.r; |
---|
| 812 | + //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
| 813 | + //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
| 814 | + |
---|
| 815 | + if ((i % 100) == 0 && i != 0) |
---|
| 816 | + { |
---|
| 817 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 818 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 819 | + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); |
---|
| 820 | + } |
---|
| 821 | + } |
---|
| 822 | + |
---|
| 823 | + br.colors = colors; |
---|
| 824 | + } |
---|
| 825 | + else |
---|
| 826 | + { |
---|
| 827 | + for (int i = 0; i < br.VertexCount(); i++) |
---|
| 828 | + { |
---|
| 829 | + Vertex v = br.GetVertex(i); |
---|
| 830 | + |
---|
| 831 | + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
| 832 | + continue; |
---|
| 833 | + |
---|
| 834 | + from.set(v.x, v.y, v.z); |
---|
| 835 | + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
| 836 | + LA.xformPos(from, transform, from); |
---|
| 837 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 838 | + localcamera.setAim(from, to); |
---|
| 839 | + |
---|
| 840 | + CameraPane.occlusionbuffer.display(); |
---|
| 841 | + |
---|
| 842 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 843 | + cp.display(); // debug |
---|
| 844 | + |
---|
| 845 | + v.AO = cp.vertexOcclusion.r; |
---|
| 846 | + |
---|
| 847 | + if ((i % 100) == 0 && i != 0) |
---|
| 848 | + { |
---|
| 849 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 850 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 851 | + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); |
---|
| 852 | + } |
---|
| 853 | + } |
---|
| 854 | + } |
---|
| 855 | + |
---|
| 856 | + //System.out.println("done."); |
---|
| 857 | + |
---|
| 858 | + cp.renderCamera = keep; |
---|
| 859 | + } |
---|
| 860 | + |
---|
| 861 | + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 862 | + { |
---|
| 863 | + CameraPane display = this; |
---|
| 864 | + pointFlow.CreateHT(); |
---|
| 865 | + |
---|
| 866 | + float r = display.modelParams0[0]; |
---|
| 867 | + float g = display.modelParams0[1]; |
---|
| 868 | + float b = display.modelParams0[2]; |
---|
| 869 | + float opacity = display.modelParams5[1]; |
---|
| 870 | + |
---|
| 871 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 872 | + GL gl = display.GetGL(); // getGL(); |
---|
| 873 | + |
---|
| 874 | + int s = pointFlow.points.size(); |
---|
| 875 | + |
---|
| 876 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 877 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 878 | + |
---|
| 879 | + for (int i=s; --i>=0;) |
---|
| 880 | + //for (int i=0; i<s; i++) |
---|
| 881 | + { |
---|
| 882 | + cVector v = pointFlow.points.get(i); |
---|
| 883 | + |
---|
| 884 | + double mindist = Double.MAX_VALUE; |
---|
| 885 | + |
---|
| 886 | + double size = pointFlow.minimumSize; |
---|
| 887 | + |
---|
| 888 | + double distancenext = 0; |
---|
| 889 | + |
---|
| 890 | + if (i > 0) |
---|
| 891 | + { |
---|
| 892 | + cVector w = pointFlow.points.get(i-1); |
---|
| 893 | + |
---|
| 894 | + double dist = w.distance(v); |
---|
| 895 | + |
---|
| 896 | + distancenext = dist; |
---|
| 897 | + |
---|
| 898 | + if (mindist > dist) |
---|
| 899 | + { |
---|
| 900 | + mindist = dist; |
---|
| 901 | + size = mindist*pointFlow.resizefactor; |
---|
| 902 | + } |
---|
| 903 | + } |
---|
| 904 | + |
---|
| 905 | + if (i < s-1) |
---|
| 906 | + { |
---|
| 907 | + cVector w = pointFlow.points.get(i+1); |
---|
| 908 | + |
---|
| 909 | + double dist = w.distance(v); |
---|
| 910 | + |
---|
| 911 | + if (mindist > dist) |
---|
| 912 | + { |
---|
| 913 | + mindist = dist; |
---|
| 914 | + size = mindist*pointFlow.resizefactor; |
---|
| 915 | + } |
---|
| 916 | + } |
---|
| 917 | + |
---|
| 918 | + if (size < pointFlow.minimumSize) |
---|
| 919 | + size = pointFlow.minimumSize; |
---|
| 920 | + if (size > pointFlow.maximumSize) |
---|
| 921 | + size = pointFlow.maximumSize; |
---|
| 922 | + |
---|
| 923 | + double tx = v.x; |
---|
| 924 | + double ty = v.y; |
---|
| 925 | + double tz = v.z; |
---|
| 926 | + |
---|
| 927 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 928 | + // continue; |
---|
| 929 | + |
---|
| 930 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 931 | + gl.glPushMatrix(); |
---|
| 932 | + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; |
---|
| 933 | + |
---|
| 934 | + gl.glMultMatrixf(pointFlow.texmat, 0); |
---|
| 935 | + |
---|
| 936 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 937 | + gl.glPushMatrix(); |
---|
| 938 | + |
---|
| 939 | + gl.glTranslated(tx,ty,tz); |
---|
| 940 | + |
---|
| 941 | + gl.glScaled(size,size,size); |
---|
| 942 | + |
---|
| 943 | +// float cr = colorBuf.get(index4); |
---|
| 944 | +// float cg = colorBuf.get(index4+1); |
---|
| 945 | +// float cb = colorBuf.get(index4+2); |
---|
| 946 | +// float ca = colorBuf.get(index4+3); |
---|
| 947 | +// |
---|
| 948 | +// display.modelParams0[0] = r * cr; |
---|
| 949 | +// display.modelParams0[1] = g * cg; |
---|
| 950 | +// display.modelParams0[2] = b * cb; |
---|
| 951 | +// |
---|
| 952 | +// display.modelParams5[1] = opacity * ca; |
---|
| 953 | +// |
---|
| 954 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 955 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 956 | +// |
---|
| 957 | +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
| 958 | +// RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 959 | +// |
---|
| 960 | +//// gl.glColor4f(cr,cg,cb,ca); |
---|
| 961 | +// // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 962 | + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); |
---|
| 963 | + |
---|
| 964 | + gl.glPopMatrix(); |
---|
| 965 | + |
---|
| 966 | + double step = size/4; // |
---|
| 967 | + |
---|
| 968 | + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) |
---|
| 969 | + continue; |
---|
| 970 | + |
---|
| 971 | + int nbsteps = (int)(distancenext/step); |
---|
| 972 | + |
---|
| 973 | + step = distancenext/nbsteps; |
---|
| 974 | + |
---|
| 975 | + cVector next = pointFlow.points.get(i-1); |
---|
| 976 | + |
---|
| 977 | + tmp.set(next); |
---|
| 978 | + tmp.sub(v); |
---|
| 979 | + tmp.normalize(); |
---|
| 980 | + tmp.mul(step); |
---|
| 981 | + |
---|
| 982 | + // calculate next size |
---|
| 983 | + mindist = Double.MAX_VALUE; |
---|
| 984 | + |
---|
| 985 | + double nextsize = pointFlow.minimumSize; |
---|
| 986 | + |
---|
| 987 | + if (i > 1) |
---|
| 988 | + { |
---|
| 989 | + cVector w = pointFlow.points.get(i-2); |
---|
| 990 | + |
---|
| 991 | + double dist = w.distance(next); |
---|
| 992 | + |
---|
| 993 | + if (mindist > dist) |
---|
| 994 | + { |
---|
| 995 | + mindist = dist; |
---|
| 996 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 997 | + } |
---|
| 998 | + } |
---|
| 999 | + |
---|
| 1000 | + double dist = v.distance(next); |
---|
| 1001 | + |
---|
| 1002 | + if (mindist > dist) |
---|
| 1003 | + { |
---|
| 1004 | + mindist = dist; |
---|
| 1005 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1006 | + } |
---|
| 1007 | + |
---|
| 1008 | + if (nextsize < pointFlow.minimumSize) |
---|
| 1009 | + nextsize = pointFlow.minimumSize; |
---|
| 1010 | + if (nextsize > pointFlow.maximumSize) |
---|
| 1011 | + nextsize = pointFlow.maximumSize; |
---|
| 1012 | + // |
---|
| 1013 | + |
---|
| 1014 | + double count = 0; |
---|
| 1015 | + |
---|
| 1016 | + while (distancenext > 0.000000001) // step |
---|
| 1017 | + { |
---|
| 1018 | + gl.glPushMatrix(); |
---|
| 1019 | + |
---|
| 1020 | + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); |
---|
| 1021 | + |
---|
| 1022 | + double K = count/nbsteps; |
---|
| 1023 | + |
---|
| 1024 | + double intersize = K*nextsize + (1-K)*size; |
---|
| 1025 | + |
---|
| 1026 | + gl.glScaled(intersize,intersize,intersize); |
---|
| 1027 | + |
---|
| 1028 | + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); |
---|
| 1029 | + |
---|
| 1030 | + count++; |
---|
| 1031 | + |
---|
| 1032 | + distancenext -= step; |
---|
| 1033 | + |
---|
| 1034 | + gl.glPopMatrix(); |
---|
| 1035 | + } |
---|
| 1036 | + |
---|
| 1037 | + if (count != nbsteps) |
---|
| 1038 | + assert(count == nbsteps); |
---|
| 1039 | + |
---|
| 1040 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 1041 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 1042 | + |
---|
| 1043 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1044 | + gl.glPopMatrix(); |
---|
| 1045 | + } |
---|
| 1046 | + |
---|
| 1047 | + if (!cf) |
---|
| 1048 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 1049 | + |
---|
| 1050 | +// display.modelParams0[0] = r; |
---|
| 1051 | +// display.modelParams0[1] = g; |
---|
| 1052 | +// display.modelParams0[2] = b; |
---|
| 1053 | +// |
---|
| 1054 | +// display.modelParams5[1] = opacity; |
---|
| 1055 | +// |
---|
| 1056 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1057 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1058 | + |
---|
| 1059 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1060 | + } |
---|
| 1061 | + |
---|
| 1062 | + /// INTERFACE |
---|
| 1063 | + |
---|
| 1064 | + void SetColor(Object3D obj, Vertex p0) |
---|
| 1065 | + { |
---|
| 1066 | + CameraPane display = this; |
---|
| 1067 | + BoundaryRep bRep = obj.bRep; |
---|
| 1068 | + |
---|
| 1069 | + if (RENDERPROGRAM == 0) |
---|
| 1070 | + { |
---|
| 1071 | + float r = 0; |
---|
| 1072 | + if (bRep != null) |
---|
| 1073 | + { |
---|
| 1074 | + if (bRep.stripified) |
---|
| 1075 | + { |
---|
| 1076 | + r = 1; |
---|
| 1077 | + } |
---|
| 1078 | + } |
---|
| 1079 | + float g = 0; |
---|
| 1080 | + if (bRep != null) |
---|
| 1081 | + { |
---|
| 1082 | + if (bRep.trimmed) |
---|
| 1083 | + { |
---|
| 1084 | + g = 1; |
---|
| 1085 | + } |
---|
| 1086 | + } |
---|
| 1087 | + float b = 0; |
---|
| 1088 | + if (obj.support != null && obj.link2master) |
---|
| 1089 | + { |
---|
| 1090 | + b = 1; |
---|
| 1091 | + } |
---|
| 1092 | + display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO); |
---|
| 1093 | + return; |
---|
| 1094 | + } |
---|
| 1095 | + |
---|
| 1096 | + if (display.DrawMode() != CameraPane.SHADOW) |
---|
| 1097 | + return; |
---|
| 1098 | + |
---|
| 1099 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1100 | +// if (true) return; |
---|
| 1101 | +// float ao = p.AO; |
---|
| 1102 | +// |
---|
| 1103 | +// // if (ao == 0 && !bRep.AOdone) // transient problem! |
---|
| 1104 | +// // ao = 1; |
---|
| 1105 | +// |
---|
| 1106 | +// gl.glColor4f(ao, ao, ao, 1); |
---|
| 1107 | + |
---|
| 1108 | +// CameraPane.selectedpoint. |
---|
| 1109 | +// getAverage(cStatic.point1, true); |
---|
| 1110 | + if (CameraPane.pointflow == null) // !random) // live) |
---|
| 1111 | + { |
---|
| 1112 | + return; |
---|
| 1113 | + } |
---|
| 1114 | + |
---|
| 1115 | + cStatic.point1.set(0,0,0); |
---|
| 1116 | + LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1); |
---|
| 1117 | + |
---|
| 1118 | + cStatic.point1.sub(p0); |
---|
| 1119 | + |
---|
| 1120 | + |
---|
| 1121 | +// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta? |
---|
| 1122 | +// { |
---|
| 1123 | +// return; |
---|
| 1124 | +// } |
---|
| 1125 | + |
---|
| 1126 | + //if (true) |
---|
| 1127 | + if (cStatic.point1.dot(cStatic.point1) > 0.000001) |
---|
| 1128 | + { |
---|
| 1129 | + return; |
---|
| 1130 | + } |
---|
| 1131 | + |
---|
| 1132 | + float[] colorV = new float[3]; |
---|
| 1133 | + |
---|
| 1134 | + if (false) // marked) |
---|
| 1135 | + { |
---|
| 1136 | + // debug rigging weights |
---|
| 1137 | + for (int object = 0; object < p0.vertexlinks.length; object++) |
---|
| 1138 | + { |
---|
| 1139 | + float weight = p0.weights[object] / p0.totalweight; |
---|
| 1140 | + |
---|
| 1141 | + // if (weight < 0.1) |
---|
| 1142 | + // { |
---|
| 1143 | + // assert(weight == 0); |
---|
| 1144 | + // continue; |
---|
| 1145 | + // } |
---|
| 1146 | + |
---|
| 1147 | + if (p0.vertexlinks[object] == -1) |
---|
| 1148 | + continue; |
---|
| 1149 | + |
---|
| 1150 | + Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]); |
---|
| 1151 | + |
---|
| 1152 | + int color = //1 << object; // |
---|
| 1153 | + //p.vertexlinks.length; |
---|
| 1154 | + obj.support.bRep.supports[p0.closestsupport].links[object]; |
---|
| 1155 | + colorV[2] += (color & 1) * weight; |
---|
| 1156 | + colorV[1] += ((color & 2) >> 1) * weight; |
---|
| 1157 | + colorV[0] += ((color & 4) >> 2) * weight; |
---|
| 1158 | + } |
---|
| 1159 | + } |
---|
| 1160 | + else |
---|
| 1161 | + { |
---|
| 1162 | + if (obj.drawingstarted) |
---|
| 1163 | + { |
---|
| 1164 | + // find next point |
---|
| 1165 | + if (bRep.GetVertex(0).faceindices == null) |
---|
| 1166 | + { |
---|
| 1167 | + bRep.InitFaceIndices(); |
---|
| 1168 | + } |
---|
| 1169 | + |
---|
| 1170 | + double ymin = p0.y; |
---|
| 1171 | + |
---|
| 1172 | + Vertex newp = p0; |
---|
| 1173 | + |
---|
| 1174 | + for (int fii = 0; fii < p0.faceindices.length; fii++) |
---|
| 1175 | + { |
---|
| 1176 | + int fi = p0.faceindices[fii]; |
---|
| 1177 | + |
---|
| 1178 | + if (fi == -1) |
---|
| 1179 | + break; |
---|
| 1180 | + |
---|
| 1181 | + Face f = bRep.GetFace(fi); |
---|
| 1182 | + |
---|
| 1183 | + Vertex p = bRep.GetVertex(f.p); |
---|
| 1184 | + Vertex q = bRep.GetVertex(f.q); |
---|
| 1185 | + Vertex r = bRep.GetVertex(f.r); |
---|
| 1186 | + |
---|
| 1187 | + int swap = (int)(Math.random()*3); |
---|
| 1188 | + |
---|
| 1189 | +// for (int s=swap; --s>=0;) |
---|
| 1190 | +// { |
---|
| 1191 | +// Vertex t = p; |
---|
| 1192 | +// p = q; |
---|
| 1193 | +// q = r; |
---|
| 1194 | +// r = t; |
---|
| 1195 | +// } |
---|
| 1196 | + if (ymin > p.y) |
---|
| 1197 | + { |
---|
| 1198 | + ymin = p.y; |
---|
| 1199 | + newp = p; |
---|
| 1200 | +// break; |
---|
| 1201 | + } |
---|
| 1202 | + if (ymin > q.y) |
---|
| 1203 | + { |
---|
| 1204 | + ymin = q.y; |
---|
| 1205 | + newp = q; |
---|
| 1206 | +// break; |
---|
| 1207 | + } |
---|
| 1208 | + if (ymin > r.y) |
---|
| 1209 | + { |
---|
| 1210 | + ymin = r.y; |
---|
| 1211 | + newp = r; |
---|
| 1212 | +// break; |
---|
| 1213 | + } |
---|
| 1214 | + } |
---|
| 1215 | + |
---|
| 1216 | + CameraPane.selectedpoint.toParent[3][0] = newp.x; |
---|
| 1217 | + CameraPane.selectedpoint.toParent[3][1] = newp.y; |
---|
| 1218 | + CameraPane.selectedpoint.toParent[3][2] = newp.z; |
---|
| 1219 | + |
---|
| 1220 | + obj.drawingstarted = false; |
---|
| 1221 | + |
---|
| 1222 | + // return; |
---|
| 1223 | + } |
---|
| 1224 | + |
---|
| 1225 | + if (false) // CameraPane.DRAW |
---|
| 1226 | + { |
---|
| 1227 | + p0.AO = colorV[0] = 2; |
---|
| 1228 | + colorV[1] = 2; |
---|
| 1229 | + colorV[2] = 2; |
---|
| 1230 | + } |
---|
| 1231 | + |
---|
| 1232 | + CameraPane.pointflow.add(p0); |
---|
| 1233 | + CameraPane.pointflow.Touch(); |
---|
| 1234 | + } |
---|
| 1235 | + |
---|
| 1236 | +// gl.glColor3f(colorV[0], colorV[1], colorV[2]); |
---|
| 1237 | +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1238 | +// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1239 | + } |
---|
| 1240 | + |
---|
| 1241 | + void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1242 | + { |
---|
| 1243 | + CameraPane display = this; |
---|
| 1244 | + //new Exception().printStackTrace(); |
---|
| 1245 | + |
---|
| 1246 | + if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW) |
---|
| 1247 | + { |
---|
| 1248 | + return; |
---|
| 1249 | + } |
---|
| 1250 | + |
---|
| 1251 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1252 | + |
---|
| 1253 | + //Color col = Color.getHSBColor(color,modulation,1); |
---|
| 1254 | + //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
| 1255 | + if (!material.multiply) |
---|
| 1256 | + { |
---|
| 1257 | + display.color = color; |
---|
| 1258 | + display.saturation = material.modulation; |
---|
| 1259 | + } |
---|
| 1260 | + else |
---|
| 1261 | + { |
---|
| 1262 | + display.color *= color*2; |
---|
| 1263 | + display.saturation *= material.modulation*2; |
---|
| 1264 | + } |
---|
| 1265 | + |
---|
| 1266 | + cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
| 1267 | + |
---|
| 1268 | + float[] colorV = GrafreeD.colorV; |
---|
| 1269 | + |
---|
| 1270 | + /**/ |
---|
| 1271 | + if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
| 1272 | + { |
---|
| 1273 | + colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
| 1274 | + colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
| 1275 | + colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
| 1276 | + colorV[3] = material.opacity; |
---|
| 1277 | + |
---|
| 1278 | + gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
| 1279 | + //System.out.println("Opacity = " + opacity); |
---|
| 1280 | + |
---|
| 1281 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1282 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1283 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1284 | + |
---|
| 1285 | + float amb = material.ambient; |
---|
| 1286 | + if (amb < material.cameralight) |
---|
| 1287 | + { |
---|
| 1288 | + amb = material.cameralight; |
---|
| 1289 | + } |
---|
| 1290 | + colorV[0] = display.modelParams0[0] * material.diffuse * amb; |
---|
| 1291 | + colorV[1] = display.modelParams0[1] * material.diffuse * amb; |
---|
| 1292 | + colorV[2] = display.modelParams0[2] * material.diffuse * amb; |
---|
| 1293 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0); |
---|
| 1294 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1295 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 1296 | + |
---|
| 1297 | + /**/ |
---|
| 1298 | + colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular; |
---|
| 1299 | + colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular; |
---|
| 1300 | + colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular; |
---|
| 1301 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0); |
---|
| 1302 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1303 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0); |
---|
| 1304 | + colorV[0] = 10 / material.shininess; // 1/0.005f; |
---|
| 1305 | + //System.out.println("shininess = " + colorV[0]); |
---|
| 1306 | + if (colorV[0] > 128) |
---|
| 1307 | + { |
---|
| 1308 | + colorV[0] = 128; |
---|
| 1309 | + } |
---|
| 1310 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0); |
---|
| 1311 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0); |
---|
| 1312 | + /**/ |
---|
| 1313 | + } |
---|
| 1314 | + /**/ |
---|
| 1315 | + |
---|
| 1316 | + //selected = false; |
---|
| 1317 | + selected = selected && display.flash; |
---|
| 1318 | + |
---|
| 1319 | + //display.modelParams0[0] = 0; // pigment.r; |
---|
| 1320 | + //display.modelParams0[1] = 0; // pigment.g; |
---|
| 1321 | + //display.modelParams0[2] = 0; // pigment.b; |
---|
| 1322 | + if (!material.multiply) |
---|
| 1323 | + { |
---|
| 1324 | + display.modelParams0[3] = material.metalness; |
---|
| 1325 | + display.modelParams1[0] = material.diffuse; |
---|
| 1326 | + display.modelParams1[1] = material.specular; |
---|
| 1327 | + display.modelParams1[2] = 1 / material.shininess; |
---|
| 1328 | + display.modelParams1[3] = material.shift; |
---|
| 1329 | + display.modelParams2[0] = material.ambient; |
---|
| 1330 | + display.modelParams2[1] = material.lightarea; |
---|
| 1331 | + //System.out.println("light area = " + lightarea); |
---|
| 1332 | + display.modelParams2[2] = 1 / material.factor; // diffuseness |
---|
| 1333 | + display.modelParams2[3] = material.velvet; |
---|
| 1334 | + display.modelParams3[0] = material.sheen; |
---|
| 1335 | + display.modelParams3[1] = material.subsurface; |
---|
| 1336 | + display.modelParams3[2] = material.bump; // backlit |
---|
| 1337 | + display.modelParams3[3] = material.aniso; |
---|
| 1338 | + display.modelParams4[0] = material.anisoV; |
---|
| 1339 | + display.modelParams4[1] = selected ? 100 : material.cameralight; |
---|
| 1340 | + //System.out.println("selected = " + selected); |
---|
| 1341 | + display.modelParams4[2] = material.diffuseness; |
---|
| 1342 | + display.modelParams4[3] = material.shadow; |
---|
| 1343 | + display.modelParams5[0] = material.texture; |
---|
| 1344 | + display.modelParams5[1] = material.opacity; |
---|
| 1345 | + display.modelParams5[2] = material.fakedepth; |
---|
| 1346 | + display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10; |
---|
| 1347 | + } |
---|
| 1348 | + else |
---|
| 1349 | + { |
---|
| 1350 | + display.modelParams0[3] *= material.metalness*2; |
---|
| 1351 | + display.modelParams1[0] *= material.diffuse*2; |
---|
| 1352 | + display.modelParams1[1] *= material.specular*2; |
---|
| 1353 | + display.modelParams1[2] *= material.shininess*2; |
---|
| 1354 | + display.modelParams1[3] *= material.shift*2; |
---|
| 1355 | + display.modelParams2[0] *= material.ambient*2; |
---|
| 1356 | + display.modelParams2[1] *= material.lightarea*2; |
---|
| 1357 | + display.modelParams2[2] *= material.factor*2; |
---|
| 1358 | + display.modelParams2[3] *= material.velvet*2; |
---|
| 1359 | + display.modelParams3[0] *= material.sheen*2; |
---|
| 1360 | + display.modelParams3[1] *= material.subsurface*2; |
---|
| 1361 | + display.modelParams3[2] *= material.bump*2; |
---|
| 1362 | + display.modelParams3[3] *= material.aniso*2; |
---|
| 1363 | + display.modelParams4[0] *= material.anisoV*2; |
---|
| 1364 | + display.modelParams4[1] *= material.cameralight*2; |
---|
| 1365 | + //System.out.println("selected = " + selected); |
---|
| 1366 | + display.modelParams4[2] *= material.diffuseness*2; |
---|
| 1367 | + display.modelParams4[3] *= material.shadow*2; |
---|
| 1368 | + display.modelParams5[0] *= material.texture*2; |
---|
| 1369 | + display.modelParams5[1] *= material.opacity*2; |
---|
| 1370 | + display.modelParams5[2] *= material.fakedepth*2; |
---|
| 1371 | + display.modelParams5[3] *= material.shadowbias*2; |
---|
| 1372 | + } |
---|
| 1373 | + |
---|
| 1374 | + display.modelParams6[0] = 0; |
---|
| 1375 | + display.modelParams6[1] = 0; |
---|
| 1376 | + display.modelParams6[2] = 0; |
---|
| 1377 | + display.modelParams6[3] = 0; |
---|
| 1378 | + |
---|
| 1379 | + display.modelParams7[0] = 0; |
---|
| 1380 | + display.modelParams7[1] = 1000; |
---|
| 1381 | + display.modelParams7[2] = 0; |
---|
| 1382 | + display.modelParams7[3] = 0; |
---|
| 1383 | + |
---|
| 1384 | + display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1385 | + |
---|
| 1386 | + Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1387 | + if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
| 1388 | + { |
---|
| 1389 | + display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
| 1390 | + display.modelParams6[1] = extparams[0].y / 1000.0f; // noise |
---|
| 1391 | + if (extparams.length > 1) |
---|
| 1392 | + { |
---|
| 1393 | + display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade |
---|
| 1394 | + display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough |
---|
| 1395 | + if (extparams.length > 2) |
---|
| 1396 | + { |
---|
| 1397 | + display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power |
---|
| 1398 | + float x = extparams[2].y / 1000.0f; |
---|
| 1399 | + //if (x == 0) |
---|
| 1400 | + // x = 1f; |
---|
| 1401 | + 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 |
---|
| 1402 | + if (extparams[2].y > 0) |
---|
| 1403 | + { |
---|
| 1404 | + //System.out.println("extparams[1].y = " + extparams[1].y); |
---|
| 1405 | + //System.out.println("extparams[2].y = " + extparams[2].y); |
---|
| 1406 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1407 | + } |
---|
| 1408 | + } |
---|
| 1409 | + } |
---|
| 1410 | + } |
---|
| 1411 | + |
---|
| 1412 | + //if (display.modelParams6[2] != 0) |
---|
| 1413 | + /* |
---|
| 1414 | + System.out.println("modelParams0[0] = " + display.modelParams0[0]); |
---|
| 1415 | + System.out.println("modelParams0[1] = " + display.modelParams0[1]); |
---|
| 1416 | + System.out.println("modelParams0[2] = " + display.modelParams0[2]); |
---|
| 1417 | + System.out.println("modelParams0[3] = " + display.modelParams0[3]); |
---|
| 1418 | + System.out.println("modelParams1[0] = " + display.modelParams1[0]); |
---|
| 1419 | + System.out.println("modelParams1[1] = " + display.modelParams1[1]); |
---|
| 1420 | + System.out.println("modelParams1[2] = " + display.modelParams1[2]); |
---|
| 1421 | + System.out.println("modelParams1[3] = " + display.modelParams1[3]); |
---|
| 1422 | + System.out.println("modelParams2[0] = " + display.modelParams2[0]); |
---|
| 1423 | + System.out.println("modelParams2[1] = " + display.modelParams2[1]); |
---|
| 1424 | + System.out.println("modelParams2[2] = " + display.modelParams2[2]); |
---|
| 1425 | + System.out.println("modelParams2[3] = " + display.modelParams2[3]); |
---|
| 1426 | + System.out.println("modelParams3[0] = " + display.modelParams3[0]); |
---|
| 1427 | + System.out.println("modelParams3[1] = " + display.modelParams3[1]); |
---|
| 1428 | + System.out.println("modelParams3[2] = " + display.modelParams3[2]); |
---|
| 1429 | + System.out.println("modelParams3[3] = " + display.modelParams3[3]); |
---|
| 1430 | + System.out.println("modelParams4[0] = " + display.modelParams4[0]); |
---|
| 1431 | + System.out.println("modelParams4[1] = " + display.modelParams4[1]); |
---|
| 1432 | + System.out.println("modelParams4[2] = " + display.modelParams4[2]); |
---|
| 1433 | + System.out.println("modelParams4[3] = " + display.modelParams4[3]); |
---|
| 1434 | + System.out.println("modelParams5[0] = " + display.modelParams5[0]); |
---|
| 1435 | + System.out.println("modelParams5[1] = " + display.modelParams5[1]); |
---|
| 1436 | + System.out.println("modelParams5[2] = " + display.modelParams5[2]); |
---|
| 1437 | + System.out.println("modelParams5[3] = " + display.modelParams5[3]); |
---|
| 1438 | + System.out.println("modelParams6[0] = " + display.modelParams6[0]); |
---|
| 1439 | + System.out.println("modelParams6[1] = " + display.modelParams6[1]); |
---|
| 1440 | + System.out.println("modelParams6[2] = " + display.modelParams6[2]); |
---|
| 1441 | + System.out.println("modelParams6[3] = " + display.modelParams6[3]); |
---|
| 1442 | + System.out.println("modelParams7[0] = " + display.modelParams7[0]); |
---|
| 1443 | + System.out.println("modelParams7[1] = " + display.modelParams7[1]); |
---|
| 1444 | + System.out.println("modelParams7[2] = " + display.modelParams7[2]); |
---|
| 1445 | + System.out.println("modelParams7[3] = " + display.modelParams7[3]); |
---|
| 1446 | + /**/ |
---|
| 1447 | + //assert (display.modelParams6[2] == 0); |
---|
| 1448 | + |
---|
| 1449 | + //System.out.println("noise power = " + display.modelParams7[0]); |
---|
| 1450 | + //System.out.println("shadowbias = " + shadowbias); |
---|
| 1451 | + |
---|
| 1452 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1453 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0); |
---|
| 1454 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0); |
---|
| 1455 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0); |
---|
| 1456 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 1457 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1458 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0); |
---|
| 1459 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0); |
---|
| 1460 | + |
---|
| 1461 | + int mode = display.FP_SHADER; |
---|
| 1462 | + |
---|
| 1463 | + if (material.aniso != material.anisoV || material.aniso > 0.002) |
---|
| 1464 | + { |
---|
| 1465 | + mode |= display.FP_ANISO; |
---|
| 1466 | + } |
---|
| 1467 | + |
---|
| 1468 | + display.EnableProgram(mode); |
---|
| 1469 | + |
---|
| 1470 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1471 | + |
---|
| 1472 | + if (!material.multiply) |
---|
| 1473 | + { |
---|
| 1474 | + if (Globals.drawMode == CameraPane.SHADOW) |
---|
| 1475 | + gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1); |
---|
| 1476 | + else |
---|
| 1477 | + gl.glDepthMask(material.opacity >= 0.99); |
---|
| 1478 | + } |
---|
208 | 1479 | } |
---|
209 | 1480 | |
---|
210 | 1481 | int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0; |
---|
.. | .. |
---|
225 | 1496 | currentGL.glMultMatrixd(model, 0); |
---|
226 | 1497 | } |
---|
227 | 1498 | |
---|
228 | | - void PushMatrix(double[][] matrix, int count) |
---|
| 1499 | + public void PushMatrix(double[][] matrix, int count) // INTERFACE |
---|
229 | 1500 | { |
---|
230 | 1501 | matrixdepth++; |
---|
231 | | - // GraphreeD.tracein(matrix); |
---|
| 1502 | + // GrafreeD.tracein(matrix); |
---|
232 | 1503 | if (matrix == null) |
---|
233 | 1504 | return; // Identity |
---|
234 | 1505 | |
---|
.. | .. |
---|
253 | 1524 | |
---|
254 | 1525 | void PushMatrix(double[][] matrix) |
---|
255 | 1526 | { |
---|
256 | | - // GraphreeD.tracein(matrix); |
---|
| 1527 | + // GrafreeD.tracein(matrix); |
---|
257 | 1528 | PushMatrix(matrix,1); |
---|
258 | 1529 | } |
---|
259 | 1530 | |
---|
260 | 1531 | void PushMatrix() |
---|
261 | 1532 | { |
---|
262 | | - // GraphreeD.tracein(null); |
---|
| 1533 | + // GrafreeD.tracein(null); |
---|
263 | 1534 | if (matrixdepth++ < MAXSTACK - 1) |
---|
264 | 1535 | { |
---|
265 | 1536 | currentGL.glPushMatrix(); |
---|
.. | .. |
---|
270 | 1541 | |
---|
271 | 1542 | double[][] tmpmat = new double[4][4]; |
---|
272 | 1543 | |
---|
273 | | - void PopMatrix(double[][] inverse) |
---|
| 1544 | + public void PopMatrix(double[][] inverse) // INTERFACE |
---|
274 | 1545 | { |
---|
275 | 1546 | --matrixdepth; |
---|
276 | 1547 | |
---|
277 | | - // GraphreeD.traceout(inverse); |
---|
| 1548 | + // GrafreeD.traceout(inverse); |
---|
278 | 1549 | if (inverse == null) |
---|
279 | 1550 | return; // Identity |
---|
280 | 1551 | |
---|
.. | .. |
---|
292 | 1563 | |
---|
293 | 1564 | void PopMatrix() |
---|
294 | 1565 | { |
---|
295 | | - // GraphreeD.traceout(null); |
---|
| 1566 | + // GrafreeD.traceout(null); |
---|
296 | 1567 | // inverse == null?? |
---|
297 | 1568 | if (--matrixdepth < MAXSTACK - 1) |
---|
298 | 1569 | { |
---|
.. | .. |
---|
310 | 1581 | PushTextureMatrix(matrix, 1); |
---|
311 | 1582 | } |
---|
312 | 1583 | |
---|
313 | | - void PushTextureMatrix(double[][] matrix, int count) |
---|
| 1584 | + public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE |
---|
314 | 1585 | { |
---|
315 | 1586 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
316 | 1587 | |
---|
.. | .. |
---|
324 | 1595 | currentGL.glMatrixMode(GetGL().GL_MODELVIEW); |
---|
325 | 1596 | } |
---|
326 | 1597 | |
---|
327 | | - void PopTextureMatrix(double[][] inverse) |
---|
| 1598 | + public void PopTextureMatrix(double[][] inverse) // INTERFACE |
---|
328 | 1599 | { |
---|
329 | 1600 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
330 | 1601 | currentGL.glMatrixMode(GetGL().GL_TEXTURE); |
---|
.. | .. |
---|
351 | 1622 | |
---|
352 | 1623 | static int camerachangeframe; |
---|
353 | 1624 | |
---|
354 | | - boolean SetCamera(Camera cam) |
---|
| 1625 | + public boolean SetCamera(Camera cam) |
---|
355 | 1626 | { |
---|
356 | 1627 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
357 | 1628 | // return false; |
---|
358 | 1629 | |
---|
359 | | - if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount) |
---|
| 1630 | + if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount) |
---|
360 | 1631 | { |
---|
361 | 1632 | // check for last change |
---|
362 | | - if (framecount < camerachangeframe + 400) // 120 == 1 second |
---|
| 1633 | + if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second |
---|
363 | 1634 | { |
---|
364 | 1635 | // refuse the camera change |
---|
365 | 1636 | System.err.println("Camera " + cam + " REFUSED"); |
---|
.. | .. |
---|
367 | 1638 | } |
---|
368 | 1639 | } |
---|
369 | 1640 | |
---|
370 | | - camerachangeframe = framecount; |
---|
| 1641 | + camerachangeframe = Globals.framecount; |
---|
371 | 1642 | |
---|
372 | 1643 | cam.hAspect = -1; // Read only |
---|
373 | 1644 | |
---|
.. | .. |
---|
398 | 1669 | { |
---|
399 | 1670 | //System.err.println("Oeil on"); |
---|
400 | 1671 | TRACK = true; |
---|
401 | | -// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 1672 | +// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
402 | 1673 | // object.editWindow.ScreenFit(trackedobject); |
---|
403 | 1674 | //pingthread.StepToTarget(true); |
---|
404 | 1675 | } |
---|
.. | .. |
---|
407 | 1678 | { |
---|
408 | 1679 | //System.err.println("Oeil on"); |
---|
409 | 1680 | OEIL = true; |
---|
410 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 1681 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
411 | 1682 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
412 | 1683 | //pingthread.StepToTarget(true); |
---|
413 | 1684 | } |
---|
.. | .. |
---|
471 | 1742 | { |
---|
472 | 1743 | frozen ^= true; |
---|
473 | 1744 | // Weird... |
---|
474 | | - lighttouched = true; |
---|
| 1745 | + Globals.lighttouched = true; |
---|
475 | 1746 | } |
---|
476 | 1747 | |
---|
477 | 1748 | void ToggleDL() |
---|
478 | 1749 | { |
---|
479 | 1750 | mainDL ^= true; |
---|
480 | | - } |
---|
481 | | - |
---|
482 | | - void ToggleTexture() |
---|
483 | | - { |
---|
484 | | - textureon ^= true; |
---|
485 | | - } |
---|
486 | | - |
---|
487 | | - void ToggleLive() |
---|
488 | | - { |
---|
489 | | - setLIVE(isLIVE() ^ true); |
---|
490 | | - |
---|
491 | | - System.err.println("LIVE = " + isLIVE()); |
---|
492 | | - |
---|
493 | | - if (!isLIVE()) // save sound |
---|
494 | | - GraphreeD.savesound = true; // wav.save(); |
---|
495 | | - // else |
---|
496 | | - repaint(); // start loop // may 2013 |
---|
497 | | - } |
---|
498 | | - |
---|
499 | | - void ToggleSupport() |
---|
500 | | - { |
---|
501 | | - SUPPORT ^= true; |
---|
502 | | - } |
---|
503 | | - |
---|
504 | | - void ToggleAbort() |
---|
505 | | - { |
---|
506 | | - ABORTMODE ^= true; |
---|
507 | 1751 | } |
---|
508 | 1752 | |
---|
509 | 1753 | void ToggleFullScreen() |
---|
.. | .. |
---|
513 | 1757 | |
---|
514 | 1758 | void ToggleCrowd() |
---|
515 | 1759 | { |
---|
516 | | - CROWD ^= true; |
---|
517 | | - } |
---|
518 | | - |
---|
519 | | - void ToggleInertia() |
---|
520 | | - { |
---|
521 | | - INERTIA ^= true; |
---|
| 1760 | + Globals.CROWD ^= true; |
---|
522 | 1761 | } |
---|
523 | 1762 | |
---|
524 | 1763 | void ToggleLocal() |
---|
.. | .. |
---|
526 | 1765 | LOCALTRANSFORM ^= true; |
---|
527 | 1766 | } |
---|
528 | 1767 | |
---|
529 | | - void ToggleFast() |
---|
| 1768 | + public void ToggleTexture() |
---|
| 1769 | + { |
---|
| 1770 | + textureon ^= true; |
---|
| 1771 | + } |
---|
| 1772 | + |
---|
| 1773 | + public void ToggleLive() |
---|
| 1774 | + { |
---|
| 1775 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
| 1776 | + |
---|
| 1777 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
| 1778 | + |
---|
| 1779 | + if (!Globals.isLIVE()) // save sound |
---|
| 1780 | + GrafreeD.savesound = true; // wav.save(); |
---|
| 1781 | + // else |
---|
| 1782 | + repaint(); // start loop // may 2013 |
---|
| 1783 | + } |
---|
| 1784 | + |
---|
| 1785 | + public void ToggleSupport() |
---|
| 1786 | + { |
---|
| 1787 | + SUPPORT ^= true; |
---|
| 1788 | + } |
---|
| 1789 | + |
---|
| 1790 | + public void ToggleAbort() |
---|
| 1791 | + { |
---|
| 1792 | + ABORTMODE ^= true; |
---|
| 1793 | + } |
---|
| 1794 | + |
---|
| 1795 | + public void ToggleInertia() |
---|
| 1796 | + { |
---|
| 1797 | + INERTIA ^= true; |
---|
| 1798 | + } |
---|
| 1799 | + |
---|
| 1800 | + public void ToggleFast() |
---|
530 | 1801 | { |
---|
531 | 1802 | FAST ^= true; |
---|
532 | 1803 | } |
---|
533 | 1804 | |
---|
534 | | - void ToggleSlowPose() |
---|
| 1805 | + public void ToggleSlowPose() |
---|
535 | 1806 | { |
---|
536 | 1807 | SLOWPOSE ^= true; |
---|
537 | 1808 | } |
---|
538 | 1809 | |
---|
539 | | - void ToggleFootContact() |
---|
540 | | - { |
---|
541 | | - FOOTCONTACT ^= true; |
---|
542 | | - } |
---|
543 | | - |
---|
544 | | - void ToggleBoxMode() |
---|
| 1810 | + public void ToggleBoxMode() |
---|
545 | 1811 | { |
---|
546 | 1812 | BOXMODE ^= true; |
---|
547 | 1813 | } |
---|
548 | 1814 | |
---|
549 | | - void ToggleSmoothFocus() |
---|
| 1815 | + public void ToggleSmoothFocus() |
---|
550 | 1816 | { |
---|
551 | 1817 | SMOOTHFOCUS ^= true; |
---|
552 | 1818 | } |
---|
553 | 1819 | |
---|
554 | | - void ToggleImageFlip() |
---|
| 1820 | + public void ToggleImageFlip() |
---|
555 | 1821 | { |
---|
556 | 1822 | IMAGEFLIP ^= true; |
---|
557 | 1823 | } |
---|
558 | 1824 | |
---|
559 | | - void ToggleSpeakerMocap() |
---|
| 1825 | + public void ToggleSpeakerMocap() |
---|
560 | 1826 | { |
---|
561 | 1827 | SPEAKERMOCAP ^= true; |
---|
562 | 1828 | } |
---|
563 | 1829 | |
---|
564 | | - void ToggleSpeakerCamera() |
---|
| 1830 | + public void ToggleSpeakerCamera() |
---|
565 | 1831 | { |
---|
566 | 1832 | SPEAKERCAMERA ^= true; |
---|
567 | 1833 | } |
---|
568 | 1834 | |
---|
569 | | - void ToggleSpeakerFocus() |
---|
| 1835 | + public void ToggleSpeakerFocus() |
---|
570 | 1836 | { |
---|
571 | 1837 | SPEAKERFOCUS ^= true; |
---|
572 | 1838 | } |
---|
573 | 1839 | |
---|
574 | | - void ToggleDebug() |
---|
575 | | - { |
---|
576 | | - DEBUG ^= true; |
---|
577 | | - } |
---|
578 | | - |
---|
579 | | - void ToggleFrustum() |
---|
| 1840 | + public void ToggleFrustum() |
---|
580 | 1841 | { |
---|
581 | 1842 | FRUSTUM ^= true; |
---|
582 | 1843 | } |
---|
583 | 1844 | |
---|
584 | | - void ToggleTrack() |
---|
| 1845 | + public void ToggleTrack() |
---|
585 | 1846 | { |
---|
586 | 1847 | TRACK ^= true; |
---|
587 | 1848 | if (TRACK) |
---|
.. | .. |
---|
600 | 1861 | repaint(); |
---|
601 | 1862 | } |
---|
602 | 1863 | |
---|
603 | | - void ToggleTrackOnce() |
---|
| 1864 | + public void ToggleTrackOnce() |
---|
604 | 1865 | { |
---|
605 | 1866 | TRACKONCE ^= true; |
---|
606 | 1867 | } |
---|
607 | 1868 | |
---|
608 | | - void ToggleShadowTrack() |
---|
| 1869 | + public void ToggleShadowTrack() |
---|
609 | 1870 | { |
---|
610 | 1871 | SHADOWTRACK ^= true; |
---|
611 | 1872 | repaint(); |
---|
612 | 1873 | } |
---|
613 | 1874 | |
---|
614 | | - void ToggleOeil() |
---|
| 1875 | + public void ToggleOeil() |
---|
615 | 1876 | { |
---|
616 | 1877 | OEIL ^= true; |
---|
617 | 1878 | } |
---|
618 | 1879 | |
---|
619 | | - void ToggleOeilOnce() |
---|
| 1880 | + public void ToggleOeilOnce() |
---|
620 | 1881 | { |
---|
621 | 1882 | OEILONCE ^= true; |
---|
| 1883 | + } |
---|
| 1884 | + |
---|
| 1885 | + void ToggleFootContact() |
---|
| 1886 | + { |
---|
| 1887 | + FOOTCONTACT ^= true; |
---|
| 1888 | + } |
---|
| 1889 | + |
---|
| 1890 | + void ToggleDebug() |
---|
| 1891 | + { |
---|
| 1892 | + DEBUG ^= true; |
---|
622 | 1893 | } |
---|
623 | 1894 | |
---|
624 | 1895 | void ToggleLookAt() |
---|
.. | .. |
---|
672 | 1943 | //assert (cam.hAspect == 0); |
---|
673 | 1944 | cam.hAspect = 0; |
---|
674 | 1945 | lightCamera = cam; |
---|
675 | | - } |
---|
676 | | - |
---|
677 | | - CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
678 | | - { |
---|
679 | | - super(defaultcaps, null, withcontext?glcontext:null, null); |
---|
680 | | - |
---|
681 | | - //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523)); |
---|
682 | | - glcontext = getContext(); |
---|
683 | | - |
---|
684 | | - cameras = new Camera[2]; |
---|
685 | | - targetLookAts = new cVector[2]; |
---|
686 | | - |
---|
687 | | - SetCamera(cam); |
---|
688 | | - |
---|
689 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
690 | | - |
---|
691 | | - object = o; |
---|
692 | | - |
---|
693 | | - setBackground(Color.white); |
---|
694 | | - |
---|
695 | | - addKeyListener(this); |
---|
696 | | - addMouseListener(this); |
---|
697 | | - addMouseMotionListener(this); |
---|
698 | | - addMouseWheelListener(this); |
---|
699 | | - //System.out.println("addGLEventListener: " + this); |
---|
700 | | - addGLEventListener(this); |
---|
701 | | - |
---|
702 | | -// pingthread.start(); // may 2013 |
---|
703 | 1946 | } |
---|
704 | 1947 | |
---|
705 | 1948 | private static void ApplyTransform(GL gl, Mat4f xform) |
---|
.. | .. |
---|
759 | 2002 | |
---|
760 | 2003 | GL currentGL; |
---|
761 | 2004 | |
---|
762 | | - GL GetGL() |
---|
| 2005 | + public GL GetGL() // INTERFACE |
---|
763 | 2006 | { |
---|
764 | 2007 | return currentGL; |
---|
765 | 2008 | } |
---|
.. | .. |
---|
768 | 2011 | class CacheTexture |
---|
769 | 2012 | { |
---|
770 | 2013 | com.sun.opengl.util.texture.Texture texture; |
---|
| 2014 | + com.sun.opengl.util.texture.TextureData texturedata; |
---|
| 2015 | + |
---|
771 | 2016 | int resolution; |
---|
772 | 2017 | |
---|
773 | 2018 | CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
.. | .. |
---|
1998 | 3243 | */ |
---|
1999 | 3244 | TextureData ReduceTexture(TextureData texturedata, int resolution) // String name) |
---|
2000 | 3245 | { |
---|
| 3246 | + int pixelformat = texturedata.getPixelFormat(); |
---|
| 3247 | + |
---|
2001 | 3248 | int stride = 1; |
---|
2002 | | - if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE) |
---|
| 3249 | + if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE) |
---|
2003 | 3250 | stride = 3; |
---|
2004 | | - if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA) |
---|
| 3251 | + if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA) |
---|
2005 | 3252 | stride = 4; |
---|
2006 | 3253 | |
---|
2007 | 3254 | int width = texturedata.getWidth(); |
---|
.. | .. |
---|
6267 | 7514 | return null; |
---|
6268 | 7515 | } |
---|
6269 | 7516 | |
---|
6270 | | - void ReleaseTextures(cTexture tex) |
---|
| 7517 | + public void ReleaseTextures(cTexture tex) // INTERFACE |
---|
6271 | 7518 | { |
---|
6272 | 7519 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6273 | 7520 | { |
---|
.. | .. |
---|
6305 | 7552 | |
---|
6306 | 7553 | void ReleaseTexture(String tex, boolean bump) |
---|
6307 | 7554 | { |
---|
6308 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 7555 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6309 | 7556 | ambientOcclusion ) // || !textureon) |
---|
6310 | 7557 | { |
---|
6311 | 7558 | return; |
---|
.. | .. |
---|
6331 | 7578 | { |
---|
6332 | 7579 | bumpdepth--; |
---|
6333 | 7580 | |
---|
6334 | | - // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture); |
---|
| 7581 | + // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture); |
---|
6335 | 7582 | if (bumpstack[bumpdepth] != (texture!=null?texture.texture:null)) |
---|
6336 | 7583 | { |
---|
6337 | 7584 | // assert (bumpstack[bumpdepth] == texture); |
---|
.. | .. |
---|
6361 | 7608 | { |
---|
6362 | 7609 | pigmentdepth--; |
---|
6363 | 7610 | |
---|
6364 | | - // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture); |
---|
| 7611 | + // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture); |
---|
6365 | 7612 | if (pigmentstack[pigmentdepth] != (texture!=null?texture.texture:null)) |
---|
6366 | 7613 | { |
---|
6367 | 7614 | // assert (pigmentstack[pigmentdepth] == texture); |
---|
.. | .. |
---|
6406 | 7653 | } |
---|
6407 | 7654 | } |
---|
6408 | 7655 | |
---|
6409 | | - /*boolean*/ void BindTextures(cTexture tex, int resolution) |
---|
| 7656 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
6410 | 7657 | { |
---|
6411 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 7658 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6412 | 7659 | ambientOcclusion ) // || !textureon) |
---|
6413 | 7660 | { |
---|
6414 | 7661 | return; // false; |
---|
.. | .. |
---|
6451 | 7698 | return; // true; |
---|
6452 | 7699 | } |
---|
6453 | 7700 | |
---|
6454 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 7701 | + CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
6455 | 7702 | { |
---|
6456 | 7703 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
6457 | 7704 | |
---|
.. | .. |
---|
6665 | 7912 | thetex.texture.dispose(); |
---|
6666 | 7913 | textures.remove(texname); |
---|
6667 | 7914 | } |
---|
| 7915 | + |
---|
| 7916 | + texture.texturedata = texturedata; |
---|
6668 | 7917 | textures.put(texname, texture); |
---|
6669 | 7918 | |
---|
6670 | 7919 | // newtex = true; |
---|
.. | .. |
---|
6681 | 7930 | } |
---|
6682 | 7931 | } |
---|
6683 | 7932 | |
---|
| 7933 | + return texture; |
---|
| 7934 | + } |
---|
| 7935 | + |
---|
| 7936 | + com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 7937 | + { |
---|
| 7938 | + CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
| 7939 | + |
---|
6684 | 7940 | if (bump) |
---|
6685 | 7941 | { |
---|
6686 | | - // GraphreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture); |
---|
| 7942 | + // GrafreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture); |
---|
6687 | 7943 | bumpstack[bumpdepth++] = texture!=null?texture.texture:null; |
---|
6688 | 7944 | } |
---|
6689 | 7945 | else |
---|
6690 | 7946 | { |
---|
6691 | | - // GraphreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture); |
---|
| 7947 | + // GrafreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture); |
---|
6692 | 7948 | pigmentstack[pigmentdepth++] = texture!=null?texture.texture:null; |
---|
6693 | 7949 | } |
---|
6694 | 7950 | |
---|
6695 | 7951 | return texture!=null?texture.texture:null; |
---|
| 7952 | + } |
---|
| 7953 | + |
---|
| 7954 | + public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 7955 | + { |
---|
| 7956 | + CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
| 7957 | + |
---|
| 7958 | + return texture!=null?texture.texturedata:null; |
---|
6696 | 7959 | } |
---|
6697 | 7960 | |
---|
6698 | 7961 | boolean BindTexture(String tex, boolean bump, int resolution) |
---|
.. | .. |
---|
7292 | 8555 | static boolean occlusionInitialized = false; |
---|
7293 | 8556 | boolean selection = false; |
---|
7294 | 8557 | boolean pointselection = false; |
---|
7295 | | - /*static*/ boolean lighttouched = true; |
---|
| 8558 | + ///*static*/ boolean lighttouched = true; |
---|
7296 | 8559 | boolean deselect; |
---|
7297 | | - boolean ambientOcclusion = false; |
---|
| 8560 | + private boolean ambientOcclusion = false; |
---|
7298 | 8561 | static boolean flash = false; |
---|
7299 | 8562 | /*static*/ boolean wait = false; |
---|
7300 | 8563 | boolean displaydone = false; // after repaint() calls |
---|
.. | .. |
---|
7424 | 8687 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
7425 | 8688 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
7426 | 8689 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 8690 | +// PATCH FILLE AUX JEANS |
---|
| 8691 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
7427 | 8692 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
7428 | 8693 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
7429 | 8694 | |
---|
.. | .. |
---|
7572 | 8837 | |
---|
7573 | 8838 | float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
7574 | 8839 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
7575 | | - float[] options3 = new float[]{1, 1, 1, 1}; // fog color. image intensity |
---|
| 8840 | + float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
| 8841 | + float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
7576 | 8842 | |
---|
7577 | 8843 | static int imagecount = 0; // movie generation |
---|
7578 | 8844 | |
---|
7579 | 8845 | static int jitter = 0; |
---|
7580 | 8846 | |
---|
7581 | 8847 | boolean restartframe = false; |
---|
7582 | | - |
---|
7583 | | - static int framecount = 0; // general-purpose global count |
---|
7584 | 8848 | |
---|
7585 | 8849 | void displayAntiAliased(javax.media.opengl.GL gl) |
---|
7586 | 8850 | { |
---|
.. | .. |
---|
7610 | 8874 | |
---|
7611 | 8875 | //System.out.println("start frame"); |
---|
7612 | 8876 | gl.glClear(gl.GL_ACCUM_BUFFER_BIT); |
---|
7613 | | - for (jitter = 0; jitter < ACSIZE; jitter++) //, GraphreeD.wav.cursor += LIVE ? 735 : 0) |
---|
| 8877 | + for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0) |
---|
7614 | 8878 | { |
---|
7615 | | - framecount++; |
---|
| 8879 | + Globals.framecount++; |
---|
7616 | 8880 | |
---|
7617 | 8881 | if (CameraPane.tickcount > 0) |
---|
7618 | 8882 | CameraPane.tickcount--; |
---|
7619 | 8883 | |
---|
7620 | | -// GraphreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits) |
---|
| 8884 | +// GrafreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits) |
---|
7621 | 8885 | // restartframe = true; |
---|
7622 | 8886 | if (options1[2] > 100 && (jitter%2==0)) |
---|
7623 | 8887 | { |
---|
.. | .. |
---|
7650 | 8914 | |
---|
7651 | 8915 | gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0); |
---|
7652 | 8916 | */ |
---|
7653 | | - lighttouched = true; |
---|
| 8917 | + Globals.lighttouched = true; |
---|
7654 | 8918 | //System.err.println(" shadowbuffer: " + jitter); |
---|
7655 | 8919 | shadowbuffer.display(); |
---|
7656 | 8920 | |
---|
.. | .. |
---|
7672 | 8936 | |
---|
7673 | 8937 | if (renderCamera != lightCamera) |
---|
7674 | 8938 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7675 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 8939 | + LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
7676 | 8940 | |
---|
7677 | 8941 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
7678 | 8942 | |
---|
.. | .. |
---|
7688 | 8952 | |
---|
7689 | 8953 | if (renderCamera != lightCamera) |
---|
7690 | 8954 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7691 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 8955 | + LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
7692 | 8956 | |
---|
7693 | 8957 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
7694 | 8958 | |
---|
.. | .. |
---|
7905 | 9169 | |
---|
7906 | 9170 | if (!BOXMODE) |
---|
7907 | 9171 | { |
---|
7908 | | - System.out.println("image: " + fullname + " (" + (GraphreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9172 | + System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
7909 | 9173 | } |
---|
7910 | 9174 | |
---|
7911 | 9175 | if (!BOXMODE) |
---|
.. | .. |
---|
7933 | 9197 | { |
---|
7934 | 9198 | if (ACSIZE > 1) |
---|
7935 | 9199 | { |
---|
7936 | | - // System.err.println("image #" + (GraphreeD.wav.cursor / 735 / 4)); |
---|
| 9200 | + // System.err.println("image #" + (GrafreeD.wav.cursor / 735 / 4)); |
---|
7937 | 9201 | } |
---|
7938 | 9202 | } |
---|
7939 | 9203 | |
---|
.. | .. |
---|
7943 | 9207 | ABORTED = false; |
---|
7944 | 9208 | } |
---|
7945 | 9209 | else |
---|
7946 | | - GraphreeD.wav.cursor += 735 * ACSIZE; |
---|
| 9210 | + GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
7947 | 9211 | |
---|
7948 | 9212 | if (false) |
---|
7949 | 9213 | { |
---|
.. | .. |
---|
8597 | 9861 | } |
---|
8598 | 9862 | } |
---|
8599 | 9863 | |
---|
8600 | | - boolean IsFrozen() |
---|
8601 | | - { |
---|
8602 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
8603 | | - |
---|
8604 | | - return !selectmode && cameracount == 0; // != 0; |
---|
8605 | | - } |
---|
8606 | | - |
---|
8607 | 9864 | boolean niceon = false; |
---|
8608 | 9865 | javax.swing.Timer AAtimer = new javax.swing.Timer(750, this); |
---|
8609 | 9866 | boolean currentlydrawing = false; |
---|
.. | .. |
---|
8613 | 9870 | |
---|
8614 | 9871 | public void display(GLAutoDrawable drawable) |
---|
8615 | 9872 | { |
---|
8616 | | - if (GraphreeD.savesound && GraphreeD.hassound) |
---|
| 9873 | + if (GrafreeD.savesound && GrafreeD.hassound) |
---|
8617 | 9874 | { |
---|
8618 | | - GraphreeD.wav.save(); |
---|
8619 | | - GraphreeD.savesound = false; |
---|
8620 | | - GraphreeD.hassound = false; |
---|
| 9875 | + GrafreeD.wav.save(); |
---|
| 9876 | + GrafreeD.savesound = false; |
---|
| 9877 | + GrafreeD.hassound = false; |
---|
8621 | 9878 | } |
---|
8622 | 9879 | // if (DEBUG_SELECTION) |
---|
8623 | 9880 | // { |
---|
8624 | | -// if (drawMode != SELECTION) |
---|
8625 | | -// drawMode = SELECTION; |
---|
| 9881 | +// if (DrawMode() != SELECTION) |
---|
| 9882 | +// DrawMode() = SELECTION; |
---|
8626 | 9883 | // } |
---|
8627 | 9884 | |
---|
8628 | 9885 | if (!isRenderer) |
---|
.. | .. |
---|
8678 | 9935 | |
---|
8679 | 9936 | //ANTIALIAS = 0; |
---|
8680 | 9937 | |
---|
8681 | | - if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
| 9938 | + if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
8682 | 9939 | { |
---|
8683 | | - if (niceon || isLIVE()) |
---|
| 9940 | + if (niceon || Globals.isLIVE()) |
---|
8684 | 9941 | { |
---|
8685 | 9942 | //if(active == 0) |
---|
8686 | 9943 | // antialiaser = null; |
---|
.. | .. |
---|
8705 | 9962 | assert eyeCamera.shaper_zFar == 1E5f; // 500.0f; |
---|
8706 | 9963 | */ |
---|
8707 | 9964 | |
---|
8708 | | - if (drawMode == DEFAULT) |
---|
| 9965 | + if (DrawMode() == DEFAULT) |
---|
8709 | 9966 | { |
---|
8710 | 9967 | currentlydrawing = true; |
---|
8711 | 9968 | } |
---|
.. | .. |
---|
8736 | 9993 | |
---|
8737 | 9994 | // if(Applet3D.clipboard != null) |
---|
8738 | 9995 | // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent); |
---|
8739 | | -//drawMode = SELECTION; |
---|
| 9996 | +//DrawMode() = SELECTION; |
---|
8740 | 9997 | indexcount = 0; |
---|
8741 | 9998 | |
---|
8742 | | - if (drawMode == OCCLUSION) |
---|
| 9999 | + if (DrawMode() == OCCLUSION) |
---|
8743 | 10000 | { |
---|
8744 | | - drawMode = DEFAULT; |
---|
| 10001 | + Globals.drawMode = DEFAULT; // WARNING |
---|
8745 | 10002 | ambientOcclusion = true; |
---|
8746 | 10003 | setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
---|
8747 | 10004 | Object3D theobject = object; |
---|
8748 | 10005 | Object3D theparent = object.parent; |
---|
8749 | 10006 | object.parent = null; |
---|
8750 | | - object = (Object3D)GraphreeD.clone(object); |
---|
| 10007 | + object = (Object3D)GrafreeD.clone(object); |
---|
8751 | 10008 | object.Stripify(); |
---|
8752 | 10009 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
8753 | 10010 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
8760 | 10017 | ambientOcclusion = false; |
---|
8761 | 10018 | } |
---|
8762 | 10019 | |
---|
8763 | | - if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10020 | + if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
8764 | 10021 | { |
---|
8765 | 10022 | //if (RENDERSHADOW) // ? |
---|
8766 | 10023 | if (!IsFrozen()) |
---|
8767 | 10024 | { |
---|
8768 | 10025 | // dec 2012 |
---|
8769 | | - if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)) |
---|
| 10026 | + if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
8770 | 10027 | { |
---|
8771 | | - framecount++; |
---|
| 10028 | + Globals.framecount++; |
---|
8772 | 10029 | shadowbuffer.display(); |
---|
8773 | 10030 | } |
---|
8774 | 10031 | } |
---|
8775 | | - lighttouched = false; // ?? |
---|
| 10032 | + Globals.lighttouched = false; // ?? |
---|
8776 | 10033 | //drawing = true; |
---|
8777 | 10034 | //lighttouched = true; |
---|
8778 | 10035 | } |
---|
.. | .. |
---|
8793 | 10050 | //eyeCamera.shaper_fovy = 1; |
---|
8794 | 10051 | } |
---|
8795 | 10052 | |
---|
8796 | | - if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION) |
---|
| 10053 | + if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION) |
---|
8797 | 10054 | { |
---|
8798 | | - //System.out.println("drawMode = " + drawMode); |
---|
| 10055 | + //System.out.println("DrawMode() = " + DrawMode()); |
---|
8799 | 10056 | vertexMode |= VP_PASS; |
---|
8800 | 10057 | //vertexMode |= VP_PROJECTION; |
---|
8801 | 10058 | if (!ambientOcclusion) |
---|
.. | .. |
---|
8855 | 10112 | Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera; |
---|
8856 | 10113 | //Camera lightcam = new Camera(light0); |
---|
8857 | 10114 | |
---|
8858 | | - if (drawMode == SHADOW) |
---|
| 10115 | + if (DrawMode() == SHADOW) |
---|
8859 | 10116 | { |
---|
8860 | 10117 | /* |
---|
8861 | 10118 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
.. | .. |
---|
8894 | 10151 | // if (parentcam != renderCamera) // not a light |
---|
8895 | 10152 | if (cam != lightCamera) |
---|
8896 | 10153 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8897 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 10154 | + LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
8898 | 10155 | |
---|
8899 | 10156 | for (int j = 0; j < 4; j++) |
---|
8900 | 10157 | { |
---|
.. | .. |
---|
8909 | 10166 | // if (parentcam != renderCamera) // not a light |
---|
8910 | 10167 | if (cam != lightCamera) |
---|
8911 | 10168 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8912 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 10169 | + LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
8913 | 10170 | |
---|
8914 | 10171 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
8915 | 10172 | |
---|
.. | .. |
---|
8945 | 10202 | gl.glClear(gl.GL_DEPTH_BUFFER_BIT); |
---|
8946 | 10203 | } else |
---|
8947 | 10204 | { |
---|
8948 | | - if (drawMode != DEFAULT) |
---|
| 10205 | + if (DrawMode() != DEFAULT) |
---|
8949 | 10206 | { |
---|
8950 | 10207 | gl.glClearColor(1, 1, 1, 0); |
---|
8951 | 10208 | } // 1); |
---|
.. | .. |
---|
9010 | 10267 | |
---|
9011 | 10268 | fast &= !ambientOcclusion; |
---|
9012 | 10269 | |
---|
9013 | | - if (drawMode == DEFAULT) |
---|
| 10270 | + if (DrawMode() == DEFAULT) |
---|
9014 | 10271 | { |
---|
9015 | 10272 | //gl.glEnable(gl.GL_ALPHA_TEST); |
---|
9016 | 10273 | //gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
.. | .. |
---|
9071 | 10328 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
9072 | 10329 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9073 | 10330 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 10331 | +// PATCH FILLE AUX JEANS |
---|
| 10332 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9074 | 10333 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9075 | 10334 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9076 | 10335 | |
---|
.. | .. |
---|
9206 | 10465 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
9207 | 10466 | gl.glLoadIdentity(); |
---|
9208 | 10467 | |
---|
9209 | | - if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
| 10468 | + if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
9210 | 10469 | { |
---|
9211 | 10470 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9212 | 10471 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 10472 | +// PATCH FILLE AUX JEANS |
---|
| 10473 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9213 | 10474 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9214 | 10475 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9215 | 10476 | //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE); |
---|
.. | .. |
---|
9262 | 10523 | //gl.glPushMatrix(); |
---|
9263 | 10524 | gl.glLoadIdentity(); |
---|
9264 | 10525 | |
---|
9265 | | - if (!ambientOcclusion) // drawMode != OCCLUSION) |
---|
| 10526 | + if (!ambientOcclusion) // DrawMode() != OCCLUSION) |
---|
9266 | 10527 | { |
---|
9267 | 10528 | //LA.xformPos(light0, lightCamera.fromScreen, light); |
---|
9268 | 10529 | LA.xformDir(dirlight, lightCamera.fromScreen, lightposition); |
---|
.. | .. |
---|
9349 | 10610 | } |
---|
9350 | 10611 | |
---|
9351 | 10612 | /**/ |
---|
9352 | | - if (true) // drawMode == SELECTION) // != DEFAULT) |
---|
| 10613 | + if (true) // DrawMode() == SELECTION) // != DEFAULT) |
---|
9353 | 10614 | gl.glDisable(gl.GL_LIGHTING); |
---|
9354 | 10615 | else |
---|
9355 | 10616 | gl.glEnable(gl.GL_LIGHTING); |
---|
.. | .. |
---|
9361 | 10622 | |
---|
9362 | 10623 | gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0); |
---|
9363 | 10624 | gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0); |
---|
| 10625 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0); |
---|
9364 | 10626 | |
---|
9365 | 10627 | options2[0] *= renderCamera.Distance(); |
---|
9366 | 10628 | |
---|
9367 | 10629 | lightslot = 64; |
---|
9368 | 10630 | |
---|
9369 | | - if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT) |
---|
| 10631 | + if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT) |
---|
9370 | 10632 | { |
---|
9371 | 10633 | DrawLights(object); |
---|
9372 | 10634 | } |
---|
.. | .. |
---|
9377 | 10639 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
9378 | 10640 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
9379 | 10641 | |
---|
9380 | | - if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION) |
---|
| 10642 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
9381 | 10643 | { |
---|
9382 | 10644 | /* |
---|
9383 | 10645 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
9410 | 10672 | } |
---|
9411 | 10673 | } |
---|
9412 | 10674 | |
---|
9413 | | - if (drawMode == DEFAULT) |
---|
| 10675 | + if (DrawMode() == DEFAULT) |
---|
9414 | 10676 | { |
---|
9415 | 10677 | if (WIREFRAME && !ambientOcclusion) |
---|
9416 | 10678 | { |
---|
.. | .. |
---|
9428 | 10690 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9429 | 10691 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9430 | 10692 | |
---|
9431 | | - if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) // |
---|
| 10693 | + if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) // |
---|
9432 | 10694 | { |
---|
9433 | 10695 | if (vertexMode != 0) // && !fast) |
---|
9434 | 10696 | { |
---|
.. | .. |
---|
9448 | 10710 | } |
---|
9449 | 10711 | } |
---|
9450 | 10712 | |
---|
9451 | | - if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion) |
---|
| 10713 | + if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
9452 | 10714 | { |
---|
9453 | 10715 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
9454 | 10716 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
9476 | 10738 | //gl.glDepthMask(false); |
---|
9477 | 10739 | } |
---|
9478 | 10740 | |
---|
9479 | | - if (false) // drawMode == SHADOW) |
---|
| 10741 | + if (false) // DrawMode() == SHADOW) |
---|
9480 | 10742 | { |
---|
9481 | 10743 | //SetColumnMajorData(cameraInverseTransform, view_1); |
---|
9482 | 10744 | //System.out.println("light = " + cameraInverseTransform); |
---|
.. | .. |
---|
9490 | 10752 | //System.out.println("object = " + object); |
---|
9491 | 10753 | if (!frozen && !imageLocked) |
---|
9492 | 10754 | { |
---|
9493 | | - if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0) |
---|
| 10755 | + if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0) |
---|
9494 | 10756 | { |
---|
9495 | 10757 | displayAntiAliased(gl); |
---|
9496 | 10758 | } else |
---|
9497 | 10759 | { |
---|
9498 | 10760 | programcount = 0; |
---|
9499 | | - int keepmode = drawMode; |
---|
| 10761 | + int keepmode = DrawMode(); |
---|
9500 | 10762 | // if (DEBUG_SELECTION) |
---|
9501 | 10763 | // { |
---|
9502 | | -// drawMode = SELECTION; |
---|
| 10764 | +// DrawMode() = SELECTION; |
---|
9503 | 10765 | // } |
---|
9504 | 10766 | // for point selection |
---|
9505 | 10767 | // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0); |
---|
.. | .. |
---|
9509 | 10771 | DrawObject(gl); |
---|
9510 | 10772 | |
---|
9511 | 10773 | // jan 2013 System.err.println("RESET ABORT (display)"); |
---|
9512 | | - // if (drawMode == DEFAULT) |
---|
| 10774 | + // if (DrawMode() == DEFAULT) |
---|
9513 | 10775 | // ABORTED = false; |
---|
9514 | 10776 | fullreset = false; |
---|
9515 | | - drawMode = keepmode; |
---|
| 10777 | + Globals.drawMode = keepmode; // WARNING |
---|
9516 | 10778 | //System.out.println("PROGRAM SWITCH " + programcount); |
---|
9517 | 10779 | } |
---|
9518 | 10780 | } |
---|
.. | .. |
---|
9520 | 10782 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9521 | 10783 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9522 | 10784 | |
---|
9523 | | - if (drawMode == DEFAULT) |
---|
| 10785 | + if (DrawMode() == DEFAULT) |
---|
9524 | 10786 | { |
---|
9525 | 10787 | ReleaseTexture(NOISE_TEXTURE, false); |
---|
9526 | 10788 | } |
---|
9527 | | - //if (drawMode == DEFAULT) |
---|
| 10789 | + //if (DrawMode() == DEFAULT) |
---|
9528 | 10790 | { |
---|
9529 | 10791 | |
---|
9530 | 10792 | gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
.. | .. |
---|
9536 | 10798 | //else |
---|
9537 | 10799 | //gl.glDisable(gl.GL_TEXTURE_2D); |
---|
9538 | 10800 | //gl.glPopMatrix(); |
---|
9539 | | - if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
| 10801 | + if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
9540 | 10802 | { |
---|
9541 | 10803 | //new Exception().printStackTrace(); |
---|
9542 | 10804 | //System.out.println("Draw image " + width + ", " + height); |
---|
.. | .. |
---|
9578 | 10840 | //gl.glFlush(); |
---|
9579 | 10841 | } |
---|
9580 | 10842 | |
---|
9581 | | - if (flash && drawMode == DEFAULT) |
---|
| 10843 | + if (flash && DrawMode() == DEFAULT) |
---|
9582 | 10844 | { |
---|
9583 | 10845 | flash = false; |
---|
9584 | 10846 | wait = true; |
---|
.. | .. |
---|
9586 | 10848 | } |
---|
9587 | 10849 | |
---|
9588 | 10850 | //drawing = false; |
---|
9589 | | - //if(drawMode == DEFAULT) |
---|
| 10851 | + //if(DrawMode() == DEFAULT) |
---|
9590 | 10852 | // niceon = false; |
---|
9591 | | - if (drawMode == DEFAULT) |
---|
| 10853 | + if (DrawMode() == DEFAULT) |
---|
9592 | 10854 | { |
---|
9593 | 10855 | currentlydrawing = false; |
---|
9594 | 10856 | } |
---|
.. | .. |
---|
9608 | 10870 | repaint(); |
---|
9609 | 10871 | } |
---|
9610 | 10872 | |
---|
9611 | | - if (isLIVE() && drawMode == DEFAULT) // may 2013 |
---|
| 10873 | + if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 |
---|
9612 | 10874 | repaint(); |
---|
9613 | 10875 | |
---|
9614 | 10876 | displaydone = true; |
---|
.. | .. |
---|
9642 | 10904 | e.printStackTrace(); |
---|
9643 | 10905 | } |
---|
9644 | 10906 | |
---|
9645 | | - if (GraphreeD.RENDERME > 0) |
---|
9646 | | - GraphreeD.RENDERME--; // mechante magouille |
---|
| 10907 | + if (GrafreeD.RENDERME > 0) |
---|
| 10908 | + GrafreeD.RENDERME--; // mechante magouille |
---|
9647 | 10909 | |
---|
9648 | | - ONESTEP = false; |
---|
| 10910 | + Globals.ONESTEP = false; |
---|
9649 | 10911 | } |
---|
9650 | 10912 | |
---|
9651 | 10913 | static boolean zoomonce = false; |
---|
.. | .. |
---|
9653 | 10915 | void DrawObject(GL gl, boolean draw) |
---|
9654 | 10916 | { |
---|
9655 | 10917 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
9656 | | -// drawMode = SELECTION; |
---|
| 10918 | +// DrawMode() = SELECTION; |
---|
9657 | 10919 | //GL gl = getGL(); |
---|
9658 | 10920 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
9659 | 10921 | { |
---|
9660 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 10922 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
9661 | 10923 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
9662 | 10924 | pingthread.StepToTarget(true); // true); |
---|
9663 | 10925 | // zoomonce = false; |
---|
.. | .. |
---|
9678 | 10940 | callist = gl.glGenLists(1); |
---|
9679 | 10941 | } |
---|
9680 | 10942 | |
---|
9681 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 10943 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
9682 | 10944 | |
---|
9683 | | - boolean active = !selectmode; // drawMode != SELECTION; // mouseDown; |
---|
| 10945 | + boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
9684 | 10946 | |
---|
9685 | 10947 | if (!mainDL || !active || touched) |
---|
9686 | 10948 | { |
---|
.. | .. |
---|
9707 | 10969 | PushMatrix(ClickInfo.matbuffer); |
---|
9708 | 10970 | } |
---|
9709 | 10971 | |
---|
9710 | | - if (drawMode == 0) |
---|
| 10972 | + if (DrawMode() == 0) |
---|
9711 | 10973 | { |
---|
9712 | 10974 | // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++"); |
---|
9713 | 10975 | |
---|
.. | .. |
---|
9716 | 10978 | BindTextures(DEFAULT_TEXTURES, 2); |
---|
9717 | 10979 | } |
---|
9718 | 10980 | //System.out.println("--> " + stackdepth); |
---|
9719 | | -// GraphreeD.traceon(); |
---|
| 10981 | +// GrafreeD.traceon(); |
---|
9720 | 10982 | |
---|
9721 | 10983 | // DRAW |
---|
9722 | 10984 | object.draw(this, /*(Composite)*/ object, false, false); |
---|
9723 | 10985 | |
---|
9724 | | - if (drawMode == DEFAULT) |
---|
| 10986 | + if (DrawMode() == DEFAULT) |
---|
9725 | 10987 | { |
---|
9726 | 10988 | if (DEBUG) |
---|
9727 | 10989 | { |
---|
.. | .. |
---|
9732 | 10994 | selectedpoint.radius = radius; |
---|
9733 | 10995 | selectedpoint.recalculate(); |
---|
9734 | 10996 | selectedpoint.material = new cMaterial(); |
---|
9735 | | - selectedpoint.material.color = 0.25f; |
---|
| 10997 | + selectedpoint.material.color = 0.15f; // Yellow |
---|
9736 | 10998 | selectedpoint.material.modulation = 0.75f; |
---|
9737 | 10999 | |
---|
9738 | | - debugpoint.radius = radius; |
---|
9739 | | - debugpoint.recalculate(); |
---|
9740 | | - debugpoint.material = new cMaterial(); |
---|
9741 | | - debugpoint.material.color = 0.25f; |
---|
9742 | | - debugpoint.material.modulation = 0.75f; |
---|
| 11000 | + debugpointG.radius = radius; |
---|
| 11001 | + debugpointG.recalculate(); |
---|
| 11002 | + debugpointG.material = new cMaterial(); |
---|
| 11003 | + debugpointG.material.color = 0.25f; // Green |
---|
| 11004 | + debugpointG.material.modulation = 0.75f; |
---|
9743 | 11005 | |
---|
9744 | | - debugpoint2.radius = radius; |
---|
9745 | | - debugpoint2.recalculate(); |
---|
9746 | | - debugpoint2.material = new cMaterial(); |
---|
9747 | | - debugpoint2.material.color = 0.75f; |
---|
9748 | | - debugpoint2.material.modulation = 0.75f; |
---|
| 11006 | + debugpointP.radius = radius; |
---|
| 11007 | + debugpointP.recalculate(); |
---|
| 11008 | + debugpointP.material = new cMaterial(); |
---|
| 11009 | + debugpointP.material.color = 0.75f; // Purple |
---|
| 11010 | + debugpointP.material.modulation = 0.75f; |
---|
| 11011 | + |
---|
| 11012 | + debugpointC.radius = radius; |
---|
| 11013 | + debugpointC.recalculate(); |
---|
| 11014 | + debugpointC.material = new cMaterial(); |
---|
| 11015 | + debugpointC.material.color = 0.5f; // Cyan |
---|
| 11016 | + debugpointC.material.modulation = 0.75f; |
---|
| 11017 | + |
---|
| 11018 | + debugpointR.radius = radius; |
---|
| 11019 | + debugpointR.recalculate(); |
---|
| 11020 | + debugpointR.material = new cMaterial(); |
---|
| 11021 | + debugpointR.material.color = 0f; // Red |
---|
| 11022 | + debugpointR.material.modulation = 0.75f; |
---|
9749 | 11023 | |
---|
9750 | 11024 | InitPoints(radius); |
---|
9751 | 11025 | } |
---|
9752 | 11026 | selectedpoint.draw(this, /*(Composite)*/ null, false, false); |
---|
9753 | | - //debugpoint.draw(this, /*(Composite)*/ null, false); |
---|
9754 | | - //debugpoint2.draw(this, /*(Composite)*/ null, false); |
---|
9755 | | - DrawPoints(this); |
---|
| 11027 | + debugpointG.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11028 | + debugpointP.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11029 | + debugpointC.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11030 | + debugpointR.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11031 | + // DrawPoints(this); |
---|
9756 | 11032 | } |
---|
9757 | 11033 | |
---|
9758 | 11034 | // debugstuff.draw(this, /*(Composite)*/ null, false); |
---|
9759 | 11035 | } |
---|
9760 | | -// GraphreeD.traceoff(); |
---|
| 11036 | +// GrafreeD.traceoff(); |
---|
9761 | 11037 | //System.out.println(stackdepth); |
---|
9762 | | - if (drawMode == 0) |
---|
| 11038 | + if (DrawMode() == 0) |
---|
9763 | 11039 | { |
---|
9764 | 11040 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
9765 | 11041 | |
---|
.. | .. |
---|
9784 | 11060 | |
---|
9785 | 11061 | checker = null; |
---|
9786 | 11062 | |
---|
9787 | | - if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT) |
---|
| 11063 | + if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT) |
---|
9788 | 11064 | FindChecker(object); |
---|
9789 | 11065 | |
---|
9790 | | - if (checker != null && drawMode == DEFAULT) |
---|
| 11066 | + if (checker != null && DrawMode() == DEFAULT) |
---|
9791 | 11067 | { |
---|
9792 | | - // BindTexture(IMMORTAL_TEXTURE); |
---|
| 11068 | + //BindTexture(IMMORTAL_TEXTURE); |
---|
| 11069 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
9793 | 11070 | // NEAREST |
---|
9794 | 11071 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
9795 | 11072 | DrawChecker(gl); |
---|
9796 | 11073 | //checker.Draw(this, null, false); |
---|
9797 | 11074 | // ReleaseTexture(IMMORTAL_TEXTURE); |
---|
| 11075 | + ReleaseTextures(checker.GetTextures()); |
---|
9798 | 11076 | } |
---|
9799 | 11077 | |
---|
9800 | 11078 | if (object.parent != null) |
---|
.. | .. |
---|
9807 | 11085 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9808 | 11086 | //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9809 | 11087 | |
---|
9810 | | - if (DISPLAYTEXT && drawMode == DEFAULT) |
---|
| 11088 | + if (DISPLAYTEXT && DrawMode() == DEFAULT) |
---|
9811 | 11089 | { |
---|
9812 | 11090 | // Draw it once, then use the raster |
---|
9813 | 11091 | Balloon(gl, balloon.createGraphics()); |
---|
.. | .. |
---|
9863 | 11141 | int[] xs = new int[3]; |
---|
9864 | 11142 | int[] ys = new int[3]; |
---|
9865 | 11143 | |
---|
9866 | | - void DrawString(Object3D obj) // String string) |
---|
| 11144 | + public void DrawString(Object3D obj) // String string) // INTERFACE |
---|
9867 | 11145 | { |
---|
9868 | | - if (!DISPLAYTEXT || drawMode != DEFAULT) |
---|
| 11146 | + if (!DISPLAYTEXT || DrawMode() != DEFAULT) |
---|
9869 | 11147 | { |
---|
9870 | 11148 | return; |
---|
9871 | 11149 | } |
---|
.. | .. |
---|
10253 | 11531 | return; |
---|
10254 | 11532 | } |
---|
10255 | 11533 | |
---|
10256 | | - if (obj instanceof CheckerIG) |
---|
| 11534 | + if (obj instanceof Checker) |
---|
10257 | 11535 | { |
---|
10258 | 11536 | checker = obj; |
---|
10259 | 11537 | |
---|
.. | .. |
---|
10325 | 11603 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
10326 | 11604 | "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
10327 | 11605 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
10328 | | - "PARAM options1 = program.env[62];" + // fog rgb color, image intensity |
---|
| 11606 | + "PARAM options1 = program.env[62];" + // fog rgb color |
---|
| 11607 | + "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
10329 | 11608 | "PARAM pointlight = program.env[127];" + // ... |
---|
10330 | 11609 | "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" + |
---|
10331 | 11610 | "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" + |
---|
10332 | 11611 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
| 11612 | + "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" + |
---|
10333 | 11613 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
10334 | 11614 | "PARAM ten = { 10, 10, 10, 1.0 };" + |
---|
10335 | 11615 | "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" + |
---|
.. | .. |
---|
10350 | 11630 | "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" + |
---|
10351 | 11631 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
10352 | 11632 | "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" + |
---|
| 11633 | + "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" + |
---|
10353 | 11634 | "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" + |
---|
10354 | 11635 | "PARAM c256 = { 256, 256, 256, 1.0 };" + |
---|
10355 | 11636 | "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" + |
---|
.. | .. |
---|
10390 | 11671 | "TEMP R1;" + |
---|
10391 | 11672 | "TEMP R2;" + |
---|
10392 | 11673 | "TEMP R3;" + |
---|
| 11674 | + "TEMP min;" + |
---|
| 11675 | + "TEMP max;" + |
---|
| 11676 | + "TEMP average;" + |
---|
| 11677 | + "TEMP saturation;" + |
---|
10393 | 11678 | "TEMP keep1;" + |
---|
10394 | 11679 | "TEMP keep2;" + |
---|
10395 | 11680 | "TEMP keep3;" + |
---|
.. | .. |
---|
10920 | 12205 | |
---|
10921 | 12206 | // skin? |
---|
10922 | 12207 | // Saturation for skin |
---|
10923 | | - /**/ // c'est ici |
---|
10924 | | - (Skinshader? "DP3 temp.x, final,one;" + |
---|
| 12208 | + /**/ |
---|
| 12209 | + (Skinshader? |
---|
| 12210 | + "DP3 average.x, final,one;" + |
---|
| 12211 | + "MUL average, one3rd.xxxx,average.xxxx;" + |
---|
| 12212 | + |
---|
| 12213 | + "MIN min.x, final.x,final.y;" + |
---|
| 12214 | + "MIN min.x, min.x,final.z;" + |
---|
| 12215 | + |
---|
| 12216 | + "MAX max.x, final.x,final.y;" + |
---|
| 12217 | + "MAX max.x, max.x,final.z;" + |
---|
| 12218 | + "MOV max, max.xxxx;" + |
---|
| 12219 | + |
---|
| 12220 | + "SUB saturation, max, final;" + |
---|
| 12221 | + |
---|
| 12222 | + "ADD temp.x, max.x, one10th.x;" + |
---|
| 12223 | + "RCP temp.x, temp.x;" + |
---|
| 12224 | + "MUL temp.x, temp.x, half.x;" + |
---|
| 12225 | + "MUL saturation, saturation, temp.xxxx;" + |
---|
| 12226 | + |
---|
| 12227 | + "DP3 ndotl.x, normald, light;" + |
---|
| 12228 | + "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
| 12229 | + |
---|
| 12230 | + "SUB temp.x, one.x, ndotl.x;" + |
---|
| 12231 | + "ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 12232 | + "ADD temp.y, one.y, options2.y;" + // sursurface |
---|
| 12233 | + "MUL temp.x, temp.x, temp.y;" + |
---|
| 12234 | + |
---|
| 12235 | + "MUL saturation, saturation, temp.xxxx;" + |
---|
| 12236 | + "SUB_SAT temp, max, saturation;" + |
---|
| 12237 | +/** |
---|
| 12238 | + "DP3 temp.x, final,one;" + |
---|
10925 | 12239 | "MUL R2, one3rd.xxxx,temp.xxxx;" + |
---|
10926 | | - "SUB temp, final,R2;" + |
---|
| 12240 | + "SUB temp, final, R2;" + |
---|
| 12241 | + |
---|
10927 | 12242 | // using light angle |
---|
10928 | 12243 | "DP3 ndotl.x, normald,light;" + |
---|
10929 | 12244 | //"SLT ndotl.y, ndotl.x, zero.x;" + |
---|
.. | .. |
---|
10936 | 12251 | // using light intensity |
---|
10937 | 12252 | "MOV ndotl.z, R2.x;" + |
---|
10938 | 12253 | "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning... |
---|
10939 | | - |
---|
10940 | 12254 | // june 2014 |
---|
10941 | 12255 | "MAD R1.x, ndotl.z,slope.y,one.x;" + |
---|
10942 | 12256 | // "SUB ndotl.x, one.x, ndotl.x;" + |
---|
.. | .. |
---|
10948 | 12262 | //"MUL R2.y, shadow.x,R2.y;" + // avril 2014 |
---|
10949 | 12263 | |
---|
10950 | 12264 | "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin) |
---|
| 12265 | +/**/ |
---|
10951 | 12266 | |
---|
10952 | 12267 | // "ADD final, R2,temp;" + |
---|
10953 | 12268 | "MOV final, temp;" |
---|
.. | .. |
---|
11037 | 12352 | /**/ |
---|
11038 | 12353 | // HDR |
---|
11039 | 12354 | "MOV temp.z, final.a;" + |
---|
11040 | | - "MUL final, final,options1.w;" + |
---|
| 12355 | + "MUL final, final,options2.x;" + |
---|
11041 | 12356 | "MOV final.a, temp.z;" + |
---|
11042 | 12357 | /**/ |
---|
11043 | 12358 | |
---|
.. | .. |
---|
11074 | 12389 | "MOV final.z, zero.x;" + |
---|
11075 | 12390 | "MOV final.a, one.w;":"" |
---|
11076 | 12391 | ) + |
---|
| 12392 | + /* |
---|
11077 | 12393 | (NORMALdebug?"MOV final.x, normal.x;" + |
---|
11078 | 12394 | "MOV final.y, normal.y;" + |
---|
11079 | 12395 | "MOV final.z, normal.z;" + |
---|
11080 | 12396 | "MOV final.a, one.w;":"" |
---|
| 12397 | + ) + |
---|
| 12398 | + */ |
---|
| 12399 | + (NORMALdebug?"SUB final.x, one.x, final.x;" + |
---|
| 12400 | + "SUB final.y, one.x, final.y;" + |
---|
| 12401 | + "SUB final.z, one.x, final.z;" + |
---|
| 12402 | + "MOV final.a, final.a;":"" |
---|
11081 | 12403 | ) + |
---|
11082 | 12404 | // "MOV final, bumpmap;" + |
---|
11083 | 12405 | "MOV result.color, final;" + |
---|
.. | .. |
---|
11223 | 12545 | String Shadow(String depth, String shadow) |
---|
11224 | 12546 | { |
---|
11225 | 12547 | return "MAX temp.x, ndotl.x, one64th.x;" + |
---|
| 12548 | + "MIN temp.x, temp.x, ninetenth.x;" + |
---|
11226 | 12549 | /**/ |
---|
11227 | 12550 | // Sine |
---|
11228 | 12551 | "MUL temp.y, temp.x, temp.x;" + |
---|
.. | .. |
---|
11847 | 13170 | return; |
---|
11848 | 13171 | } |
---|
11849 | 13172 | |
---|
| 13173 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
11850 | 13174 | |
---|
11851 | 13175 | // TIMER |
---|
11852 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR |
---|
| 13176 | + if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
11853 | 13177 | { |
---|
11854 | 13178 | keepboxmode = BOXMODE; |
---|
11855 | 13179 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
11978 | 13302 | // ObjEditor.tweenManager.update(1f / 60f); |
---|
11979 | 13303 | |
---|
11980 | 13304 | // fev 2014??? |
---|
11981 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode) |
---|
| 13305 | + if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
11982 | 13306 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11983 | 13307 | pingthread.StepToTarget(true); // true); |
---|
11984 | 13308 | } |
---|
.. | .. |
---|
12090 | 13414 | cVector tmp = new cVector(); |
---|
12091 | 13415 | cVector tmp2 = new cVector(); |
---|
12092 | 13416 | boolean isMoving; |
---|
| 13417 | + |
---|
| 13418 | + public cVector TargetLookAt() |
---|
| 13419 | + { |
---|
| 13420 | + return targetLookAt; |
---|
| 13421 | + } |
---|
12093 | 13422 | |
---|
12094 | 13423 | class PingThread extends Thread |
---|
12095 | 13424 | { |
---|
.. | .. |
---|
12229 | 13558 | //System.out.println("---------------- ---------- Paint " + tmp.length2()); |
---|
12230 | 13559 | if (lightMode) |
---|
12231 | 13560 | { |
---|
12232 | | - lighttouched = true; |
---|
| 13561 | + Globals.lighttouched = true; |
---|
12233 | 13562 | } |
---|
12234 | 13563 | |
---|
12235 | 13564 | if (OEILONCE && OEIL) |
---|
.. | .. |
---|
12287 | 13616 | mouseDown = false; |
---|
12288 | 13617 | if (lightMode) |
---|
12289 | 13618 | { |
---|
12290 | | - lighttouched = true; |
---|
| 13619 | + Globals.lighttouched = true; |
---|
12291 | 13620 | } |
---|
12292 | 13621 | repaint(); |
---|
12293 | 13622 | alreadypainted = true; |
---|
.. | .. |
---|
12295 | 13624 | isMoving = false; |
---|
12296 | 13625 | } //?? |
---|
12297 | 13626 | |
---|
12298 | | - if (isLIVE() && !alreadypainted) |
---|
| 13627 | + if (Globals.isLIVE() && !alreadypainted) |
---|
12299 | 13628 | { |
---|
12300 | 13629 | // FOR DEBUG BREAKPOINT USING PAUSE: while (true) |
---|
12301 | 13630 | repaint(); |
---|
.. | .. |
---|
12307 | 13636 | { |
---|
12308 | 13637 | if (lightMode) |
---|
12309 | 13638 | { |
---|
12310 | | - lighttouched = true; |
---|
| 13639 | + Globals.lighttouched = true; |
---|
12311 | 13640 | } |
---|
12312 | 13641 | drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
12313 | 13642 | } |
---|
.. | .. |
---|
12550 | 13879 | { |
---|
12551 | 13880 | manipCamera.Translate(dx, dy, getWidth()); |
---|
12552 | 13881 | } |
---|
| 13882 | + else |
---|
12553 | 13883 | if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0) |
---|
12554 | 13884 | { |
---|
12555 | 13885 | manipCamera.RotateInterest(dx, dy); |
---|
.. | .. |
---|
12560 | 13890 | |
---|
12561 | 13891 | if (manipCamera == lightCamera) |
---|
12562 | 13892 | { |
---|
12563 | | - lighttouched = true; |
---|
| 13893 | + Globals.lighttouched = true; |
---|
12564 | 13894 | } |
---|
12565 | 13895 | /* |
---|
12566 | 13896 | switch (mode) |
---|
.. | .. |
---|
12775 | 14105 | { |
---|
12776 | 14106 | mouseMode |= ZOOM; |
---|
12777 | 14107 | } |
---|
12778 | | - if ((modifiers & META) == META) |
---|
| 14108 | + |
---|
| 14109 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
| 14110 | + if (capsLocked || (modifiers & META) == META) |
---|
12779 | 14111 | { |
---|
12780 | 14112 | mouseMode |= VR; // BACKFORTH; |
---|
12781 | 14113 | } |
---|
12782 | 14114 | if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
12783 | 14115 | { |
---|
12784 | | - mouseMode |= SELECT; // BACKFORTH; |
---|
| 14116 | + mouseMode |= SELECT; |
---|
12785 | 14117 | } |
---|
12786 | 14118 | if ((modifiers & COMMAND) == COMMAND) |
---|
12787 | 14119 | { |
---|
.. | .. |
---|
12789 | 14121 | } |
---|
12790 | 14122 | if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
12791 | 14123 | { |
---|
| 14124 | + mouseMode &= ~VR; |
---|
12792 | 14125 | mouseMode |= TRANSLATE; |
---|
12793 | 14126 | } |
---|
12794 | 14127 | // if ((modifiers & SHIFT_META) == SHIFT_META) |
---|
.. | .. |
---|
12818 | 14151 | SetMouseMode(modifiers); |
---|
12819 | 14152 | } |
---|
12820 | 14153 | |
---|
12821 | | - theRenderer.keyPressed(key); |
---|
| 14154 | + Globals.theRenderer.keyPressed(key); |
---|
12822 | 14155 | } |
---|
12823 | 14156 | |
---|
12824 | 14157 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
12830 | 14163 | float SATPOW = 1; // 2; // 0.5f; |
---|
12831 | 14164 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
12832 | 14165 | |
---|
12833 | | - void keyPressed(int key) |
---|
| 14166 | + public void keyPressed(int key) |
---|
12834 | 14167 | { |
---|
12835 | 14168 | if (key >= '0' && key <= '5') |
---|
12836 | 14169 | clampbit = (key-'0'); |
---|
.. | .. |
---|
12945 | 14278 | case 'B': |
---|
12946 | 14279 | BRISMOOTH ^= true; |
---|
12947 | 14280 | SHADOWCULLFACE ^= true; |
---|
12948 | | - lighttouched = true; |
---|
| 14281 | + Globals.lighttouched = true; |
---|
12949 | 14282 | repaint(); |
---|
12950 | 14283 | break; |
---|
12951 | 14284 | case 'b': |
---|
.. | .. |
---|
13045 | 14378 | repaint(); |
---|
13046 | 14379 | break; |
---|
13047 | 14380 | case 'O': |
---|
13048 | | - drawMode = OCCLUSION; |
---|
| 14381 | + Globals.drawMode = OCCLUSION; // WARNING |
---|
13049 | 14382 | repaint(); |
---|
13050 | 14383 | break; |
---|
13051 | 14384 | case 'o': |
---|
.. | .. |
---|
13136 | 14469 | break; |
---|
13137 | 14470 | case ' ': |
---|
13138 | 14471 | lightMode ^= true; |
---|
13139 | | - lighttouched = true; |
---|
| 14472 | + Globals.lighttouched = true; |
---|
13140 | 14473 | manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
13141 | 14474 | targetLookAt.set(manipCamera.lookAt); |
---|
13142 | 14475 | repaint(); |
---|
.. | .. |
---|
13148 | 14481 | repaint(); |
---|
13149 | 14482 | break; |
---|
13150 | 14483 | case 'Z': |
---|
13151 | | - RESIZETEXTURE ^= true; |
---|
13152 | | - break; |
---|
| 14484 | + //RESIZETEXTURE ^= true; |
---|
| 14485 | + //break; |
---|
13153 | 14486 | case 'z': |
---|
13154 | 14487 | RENDERSHADOW ^= true; |
---|
13155 | | - lighttouched = true; |
---|
| 14488 | + Globals.lighttouched = true; |
---|
13156 | 14489 | repaint(); |
---|
13157 | 14490 | break; |
---|
13158 | 14491 | //case UP: |
---|
.. | .. |
---|
13178 | 14511 | FlipTransform(); |
---|
13179 | 14512 | break; |
---|
13180 | 14513 | case ENTER: |
---|
13181 | | - object.editWindow.ScreenFit(); // Edit(); |
---|
| 14514 | + // object.editWindow.ScreenFit(); // Edit(); |
---|
| 14515 | + ToggleLive(); |
---|
13182 | 14516 | break; |
---|
13183 | 14517 | case DELETE: |
---|
13184 | 14518 | ClearSelection(); |
---|
.. | .. |
---|
13266 | 14600 | } |
---|
13267 | 14601 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
13268 | 14602 | } |
---|
| 14603 | + |
---|
13269 | 14604 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
13270 | 14605 | |
---|
13271 | 14606 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
13277 | 14612 | } |
---|
13278 | 14613 | } |
---|
13279 | 14614 | |
---|
13280 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 14615 | + public void processKeyEvent(KeyEvent e) |
---|
13281 | 14616 | { |
---|
13282 | 14617 | switch (e.getID()) |
---|
13283 | 14618 | { |
---|
.. | .. |
---|
13753 | 15088 | //if (g != gr) g.drawImage(img, 0, 0, width, height, null); |
---|
13754 | 15089 | } |
---|
13755 | 15090 | |
---|
| 15091 | + // To avoid clear. |
---|
13756 | 15092 | public void update(Graphics g) |
---|
13757 | 15093 | { |
---|
13758 | 15094 | paint(g); |
---|
.. | .. |
---|
14355 | 15691 | gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS); |
---|
14356 | 15692 | gl.glPushMatrix(); |
---|
14357 | 15693 | gl.glLoadIdentity(); |
---|
14358 | | - PushMatrix(checker.toParent); |
---|
| 15694 | + //PushMatrix(checker.toParent); |
---|
14359 | 15695 | |
---|
14360 | 15696 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
14361 | 15697 | gl.glPushMatrix(); |
---|
.. | .. |
---|
14378 | 15714 | |
---|
14379 | 15715 | gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
14380 | 15716 | |
---|
14381 | | - float step = 0.1666f; //0.25f; |
---|
14382 | | - float stepv = step * 1652 / 998; |
---|
| 15717 | + float step = 2; // 0.1666f; //0.25f; |
---|
| 15718 | + float stepv = 2; // step * 1652 / 998; |
---|
14383 | 15719 | |
---|
14384 | 15720 | int i0 = 0; |
---|
14385 | 15721 | /* |
---|
.. | .. |
---|
14415 | 15751 | /**/ |
---|
14416 | 15752 | //checker.GetMaterial().opacity = 1.1f; |
---|
14417 | 15753 | ////checker.GetMaterial().ambient = 0.99f; |
---|
14418 | | - Object3D.materialstack[Object3D.materialdepth] = checker.material; |
---|
14419 | | - Object3D.selectedstack[Object3D.materialdepth] = false; |
---|
14420 | | - cStatic.objectstack[Object3D.materialdepth++] = checker; |
---|
| 15754 | + materialstack[materialdepth] = checker.material; |
---|
| 15755 | + selectedstack[materialdepth] = false; |
---|
| 15756 | + cStatic.objectstack[materialdepth++] = checker; |
---|
14421 | 15757 | //System.out.println("material " + material); |
---|
14422 | 15758 | //Applet3D.tracein(this, selected); |
---|
14423 | 15759 | vector2buffer = checker.projectedVertices; |
---|
14424 | 15760 | |
---|
14425 | | - checker.GetMaterial().Draw(this, false); // true); |
---|
| 15761 | + //checker.GetMaterial().Draw(this, false); // true); |
---|
| 15762 | + DrawMaterial(checker.GetMaterial(), false); // true); |
---|
14426 | 15763 | |
---|
14427 | | - Object3D.materialdepth -= 1; |
---|
14428 | | - if (Object3D.materialdepth > 0) |
---|
| 15764 | + materialdepth -= 1; |
---|
| 15765 | + if (materialdepth > 0) |
---|
14429 | 15766 | { |
---|
14430 | | - vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices; |
---|
14431 | | - Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]); |
---|
| 15767 | + vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 15768 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
14432 | 15769 | } |
---|
14433 | 15770 | //checker.GetMaterial().opacity = 1f; |
---|
14434 | 15771 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
14449 | 15786 | |
---|
14450 | 15787 | //float u = (i+1)/2; |
---|
14451 | 15788 | //float v = (j+1)/2; |
---|
14452 | | - gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
| 15789 | + if (checker.flipV) |
---|
| 15790 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2); |
---|
| 15791 | + else |
---|
| 15792 | + gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
14453 | 15793 | gl.glVertex3f(i, j, -0.5f); |
---|
14454 | 15794 | |
---|
| 15795 | + if (checker.flipV) |
---|
| 15796 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
| 15797 | + else |
---|
14455 | 15798 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
14456 | 15799 | gl.glVertex3f(i + step, j, -0.5f); |
---|
14457 | 15800 | |
---|
| 15801 | + if (checker.flipV) |
---|
| 15802 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
| 15803 | + else |
---|
14458 | 15804 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
14459 | 15805 | gl.glVertex3f(i + step, j + stepv, -0.5f); |
---|
14460 | 15806 | |
---|
| 15807 | + if (checker.flipV) |
---|
| 15808 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
| 15809 | + else |
---|
14461 | 15810 | gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
14462 | 15811 | gl.glVertex3f(i, j + stepv, -0.5f); |
---|
14463 | 15812 | } |
---|
.. | .. |
---|
14469 | 15818 | gl.glMatrixMode(GL.GL_PROJECTION); |
---|
14470 | 15819 | gl.glPopMatrix(); |
---|
14471 | 15820 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
14472 | | - PopMatrix(null); // checker.toParent); // null); |
---|
| 15821 | + //PopMatrix(null); // checker.toParent); // null); |
---|
14473 | 15822 | gl.glPopMatrix(); |
---|
14474 | 15823 | PopTextureMatrix(checker.toParent); |
---|
14475 | 15824 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
.. | .. |
---|
14582 | 15931 | |
---|
14583 | 15932 | //int tmp = selection_view; |
---|
14584 | 15933 | //selection_view = -1; |
---|
14585 | | - int temp = drawMode; |
---|
14586 | | - drawMode = SELECTION; |
---|
| 15934 | + int temp = DrawMode(); |
---|
| 15935 | + Globals.drawMode = SELECTION; // WARNING |
---|
14587 | 15936 | indexcount = 0; |
---|
14588 | 15937 | parent.display(drawable); |
---|
14589 | 15938 | //selection_view = tmp; |
---|
14590 | 15939 | //if (temp == SELECTION) |
---|
14591 | 15940 | // temp = DEFAULT; // patch for selection debug |
---|
14592 | | - drawMode = temp; |
---|
| 15941 | + Globals.drawMode = temp; // WARNING |
---|
14593 | 15942 | |
---|
14594 | 15943 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
14595 | 15944 | |
---|
.. | .. |
---|
14639 | 15988 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
14640 | 15989 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
14641 | 15990 | |
---|
| 15991 | + // Will fit the mesh !!! |
---|
| 15992 | + selectedpoint.toParent[0][0] = 0.0001; |
---|
| 15993 | + selectedpoint.toParent[1][1] = 0.0001; |
---|
| 15994 | + selectedpoint.toParent[2][2] = 0.0001; |
---|
| 15995 | + |
---|
14642 | 15996 | glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0); |
---|
14643 | 15997 | |
---|
14644 | 15998 | // if (object.selection != null && object.selection.Size() > 0) |
---|
.. | .. |
---|
14682 | 16036 | System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2])); |
---|
14683 | 16037 | } |
---|
14684 | 16038 | |
---|
14685 | | - previousselectedpoint = (Sphere) GraphreeD.clone(selectedpoint); |
---|
| 16039 | + previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
14686 | 16040 | } |
---|
14687 | 16041 | } |
---|
14688 | 16042 | |
---|
14689 | 16043 | if (!movingcamera && !PAINTMODE) |
---|
14690 | 16044 | object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
14691 | 16045 | |
---|
14692 | | - if (PAINTMODE && GraphreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 16046 | + if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
14693 | 16047 | { |
---|
14694 | | - Object3D paintobj = GraphreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 16048 | + Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
14695 | 16049 | |
---|
14696 | 16050 | Object3D group = new Object3D("inst" + paintcount++); |
---|
14697 | 16051 | |
---|
.. | .. |
---|
14857 | 16211 | //gl.glColorMask(false, false, false, false); |
---|
14858 | 16212 | |
---|
14859 | 16213 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
14860 | | - if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 16214 | + if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
14861 | 16215 | { |
---|
14862 | 16216 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14863 | 16217 | |
---|
14864 | | - int temp = drawMode; |
---|
14865 | | - drawMode = SHADOW; |
---|
| 16218 | + int temp = DrawMode(); |
---|
| 16219 | + Globals.drawMode = SHADOW; // WARNING |
---|
14866 | 16220 | parent.display(drawable); |
---|
14867 | | - drawMode = temp; |
---|
| 16221 | + Globals.drawMode = temp; // WARNING |
---|
14868 | 16222 | } |
---|
14869 | 16223 | |
---|
14870 | 16224 | gl.glCullFace(gl.GL_BACK); |
---|
.. | .. |
---|
14917 | 16271 | |
---|
14918 | 16272 | class AntialiasBuffer implements GLEventListener |
---|
14919 | 16273 | { |
---|
14920 | | - |
---|
14921 | 16274 | CameraPane parent = null; |
---|
14922 | 16275 | |
---|
14923 | 16276 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
15027 | 16380 | gl.glFlush(); |
---|
15028 | 16381 | |
---|
15029 | 16382 | /**/ |
---|
15030 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer); |
---|
| 16383 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
15031 | 16384 | |
---|
15032 | | - int[] pixels = occlusionsizebuffer.array(); |
---|
| 16385 | + float[] pixels = occlusionsizebuffer.array(); |
---|
15033 | 16386 | |
---|
15034 | 16387 | double r = 0, g = 0, b = 0; |
---|
15035 | 16388 | |
---|
15036 | 16389 | double count = 0; |
---|
| 16390 | + |
---|
| 16391 | + gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0); |
---|
| 16392 | + |
---|
| 16393 | + float mindepth = 1; |
---|
| 16394 | + |
---|
| 16395 | + double FACTOR = 1; |
---|
15037 | 16396 | |
---|
15038 | 16397 | for (int i = 0; i < pixels.length; i++) |
---|
15039 | 16398 | { |
---|
.. | .. |
---|
15118 | 16477 | |
---|
15119 | 16478 | double scale = ray.z; // 1; // cos |
---|
15120 | 16479 | |
---|
15121 | | - int p = pixels[newindex]; |
---|
| 16480 | + float depth = pixels[newindex]; |
---|
15122 | 16481 | |
---|
15123 | 16482 | /* |
---|
15124 | 16483 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
15142 | 16501 | scale = (1 - modu) * modv; |
---|
15143 | 16502 | */ |
---|
15144 | 16503 | |
---|
15145 | | - r += ((p >> 16) & 0xFF) * scale / 255; |
---|
15146 | | - g += ((p >> 8) & 0xFF) * scale / 255; |
---|
15147 | | - b += (p & 0xFF) * scale / 255; |
---|
| 16504 | + //r += ((p >> 16) & 0xFF) * scale / 255; |
---|
| 16505 | + //g += ((p >> 8) & 0xFF) * scale / 255; |
---|
| 16506 | + //b += (p & 0xFF) * scale / 255; |
---|
| 16507 | + |
---|
| 16508 | + if (mindepth > depth) |
---|
| 16509 | + { |
---|
| 16510 | + mindepth = depth; |
---|
| 16511 | + } |
---|
15148 | 16512 | |
---|
| 16513 | + double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]); |
---|
| 16514 | + |
---|
| 16515 | + double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR); |
---|
| 16516 | + |
---|
| 16517 | + r += factor * scale; |
---|
| 16518 | + g += factor * scale; |
---|
| 16519 | + b += factor * scale; |
---|
| 16520 | + |
---|
15149 | 16521 | count += scale; |
---|
15150 | 16522 | } |
---|
15151 | 16523 | |
---|
.. | .. |
---|
15243 | 16615 | GLUT glut = new GLUT(); |
---|
15244 | 16616 | |
---|
15245 | 16617 | |
---|
15246 | | - static final public int DEFAULT = 0; |
---|
15247 | | - static final public int SELECTION = 1; |
---|
15248 | | - static final public int SHADOW = 2; |
---|
15249 | | - static final public int OCCLUSION = 3; |
---|
15250 | | - static |
---|
15251 | | - public int drawMode = DEFAULT; |
---|
15252 | 16618 | public boolean spherical = false; |
---|
15253 | 16619 | static boolean DEBUG_OCCLUSION = false; |
---|
15254 | 16620 | static boolean DEBUG_SELECTION = false; |
---|
.. | .. |
---|
15261 | 16627 | int AAbuffersize = 0; |
---|
15262 | 16628 | |
---|
15263 | 16629 | //double[] selectedpoint = new double[3]; |
---|
15264 | | - static Sphere selectedpoint = new Sphere(); |
---|
| 16630 | + static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
15265 | 16631 | static Sphere previousselectedpoint = null; |
---|
15266 | | - static Sphere debugpoint = new Sphere(); |
---|
15267 | | - static Sphere debugpoint2 = new Sphere(); |
---|
| 16632 | + static Sphere debugpointG = new Sphere(); |
---|
| 16633 | + static Sphere debugpointP = new Sphere(); |
---|
| 16634 | + static Sphere debugpointC = new Sphere(); |
---|
| 16635 | + static Sphere debugpointR = new Sphere(); |
---|
15268 | 16636 | |
---|
15269 | 16637 | static Sphere debugpoints[] = new Sphere[8]; |
---|
15270 | 16638 | |
---|
.. | .. |
---|
15295 | 16663 | } |
---|
15296 | 16664 | } |
---|
15297 | 16665 | |
---|
15298 | | - static void DrawPoints(CameraPane cpane) |
---|
| 16666 | + static void DrawPoints(iCameraPane cpane) |
---|
15299 | 16667 | { |
---|
15300 | 16668 | for (int i=0; i<8; i++) // first and last are red |
---|
15301 | 16669 | { |
---|
.. | .. |
---|
15317 | 16685 | static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
15318 | 16686 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15319 | 16687 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15320 | | - static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 16688 | + //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 16689 | + static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
15321 | 16690 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
15322 | 16691 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
15323 | 16692 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|