.. | .. |
---|
31 | 31 | |
---|
32 | 32 | import gleem.linalg.Mat4f; |
---|
33 | 33 | |
---|
34 | | -class CameraPane extends GLCanvas implements Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
| 34 | +class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 35 | { |
---|
| 36 | + static cMaterial[] materialstack = new cMaterial[65536]; |
---|
| 37 | + static boolean[] selectedstack = new boolean[65536]; |
---|
| 38 | + static int materialdepth = 0; |
---|
| 39 | + |
---|
36 | 40 | static boolean DEBUG = false; |
---|
37 | 41 | static boolean FRUSTUM = false; // still bogus true; // frustum culling |
---|
38 | 42 | |
---|
.. | .. |
---|
42 | 46 | |
---|
43 | 47 | static int STEP = 1; |
---|
44 | 48 | |
---|
45 | | - static boolean ONESTEP = false; // do LIVE once |
---|
46 | | - |
---|
47 | | - /** |
---|
48 | | - * @return the LIVE |
---|
49 | | - */ |
---|
50 | | - public static boolean isLIVE() |
---|
51 | | - { |
---|
52 | | - return LIVE || ONESTEP; |
---|
53 | | - } |
---|
54 | | - |
---|
55 | | - /** |
---|
56 | | - * @param aLIVE the LIVE to set |
---|
57 | | - */ |
---|
58 | | - public static void setLIVE(boolean aLIVE) |
---|
59 | | - { |
---|
60 | | - LIVE = aLIVE; |
---|
61 | | - } |
---|
62 | | - |
---|
63 | | - /*static*/ boolean CULLFACE = false; // true; |
---|
| 49 | + /*static*/ private boolean CULLFACE = false; // true; |
---|
64 | 50 | /*static*/ boolean NEAREST = false; // true; |
---|
65 | 51 | /*static*/ boolean WIREFRAME = false; // true; |
---|
66 | 52 | |
---|
.. | .. |
---|
70 | 56 | static int CURRENTANTIALIAS = 0; // 1; |
---|
71 | 57 | /*static*/ boolean RENDERSHADOW = true; |
---|
72 | 58 | /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal |
---|
73 | | - static boolean ANIMATION = false; |
---|
74 | | - static String filename; |
---|
75 | 59 | |
---|
76 | 60 | boolean DISPLAYTEXT = false; |
---|
77 | 61 | //boolean REDUCETEXTURE = true; |
---|
.. | .. |
---|
97 | 81 | |
---|
98 | 82 | static boolean textureon = true; |
---|
99 | 83 | static boolean LOCALTRANSFORM = false; |
---|
100 | | -private static boolean LIVE = false; |
---|
101 | 84 | static boolean FULLSCREEN = false; |
---|
102 | 85 | static boolean SUPPORT = true; |
---|
103 | | -static boolean CROWD = false; |
---|
104 | 86 | static boolean INERTIA = true; |
---|
105 | 87 | static boolean FAST = false; |
---|
106 | 88 | static boolean SLOWPOSE = false; |
---|
.. | .. |
---|
108 | 90 | |
---|
109 | 91 | static int tickcount = 0; // slow pose issue |
---|
110 | 92 | |
---|
| 93 | +static boolean BUTTONLESSWHEEL = false; |
---|
| 94 | +static boolean ZOOMBOXMODE = false; |
---|
111 | 95 | static boolean BOXMODE = false; |
---|
112 | 96 | static boolean IMAGEFLIP = false; |
---|
113 | 97 | static boolean SMOOTHFOCUS = false; |
---|
.. | .. |
---|
122 | 106 | static boolean OEIL = true; |
---|
123 | 107 | static boolean OEILONCE = false; // do oeilon then oeiloff |
---|
124 | 108 | static boolean LOOKAT = true; |
---|
125 | | -static boolean RANDOM = true; // false; |
---|
| 109 | +static boolean SWITCH = true; // false; |
---|
126 | 110 | static boolean HANDLES = false; // selection doesn't work!! |
---|
127 | 111 | static boolean PAINTMODE = false; |
---|
128 | 112 | |
---|
.. | .. |
---|
165 | 149 | defaultcaps.setAccumBlueBits(16); |
---|
166 | 150 | defaultcaps.setAccumAlphaBits(16); |
---|
167 | 151 | } |
---|
168 | | - static CameraPane theRenderer; |
---|
169 | | - |
---|
| 152 | + |
---|
170 | 153 | void SetAsGLRenderer(boolean b) |
---|
171 | 154 | { |
---|
172 | 155 | isRenderer = b; |
---|
173 | | - theRenderer = this; |
---|
| 156 | + Globals.theRenderer = this; |
---|
| 157 | + } |
---|
| 158 | + |
---|
| 159 | + CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
| 160 | + { |
---|
| 161 | + super(defaultcaps, null, withcontext?glcontext:null, null); |
---|
| 162 | + |
---|
| 163 | + //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523)); |
---|
| 164 | + glcontext = getContext(); |
---|
| 165 | + |
---|
| 166 | + cameras = new Camera[2]; |
---|
| 167 | + targetLookAts = new cVector[2]; |
---|
| 168 | + |
---|
| 169 | + SetCamera(cam); |
---|
| 170 | + |
---|
| 171 | + SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 172 | + |
---|
| 173 | + object = o; |
---|
| 174 | + |
---|
| 175 | + setBackground(Color.white); |
---|
| 176 | + |
---|
| 177 | + addKeyListener(this); |
---|
| 178 | + addMouseListener(this); |
---|
| 179 | + addMouseMotionListener(this); |
---|
| 180 | + addMouseWheelListener(this); |
---|
| 181 | + //System.out.println("addGLEventListener: " + this); |
---|
| 182 | + addGLEventListener(this); |
---|
| 183 | + |
---|
| 184 | +// pingthread.start(); // may 2013 |
---|
174 | 185 | } |
---|
175 | 186 | |
---|
176 | 187 | static boolean AntialiasingEnabled() |
---|
.. | .. |
---|
178 | 189 | return CURRENTANTIALIAS > 0; |
---|
179 | 190 | } |
---|
180 | 191 | |
---|
181 | | - void ClearDepth() |
---|
| 192 | + /// INTERFACE |
---|
| 193 | + |
---|
| 194 | + public javax.media.opengl.GL GetGL0() |
---|
| 195 | + { |
---|
| 196 | + return null; |
---|
| 197 | + } |
---|
| 198 | + |
---|
| 199 | + public int GenList() |
---|
| 200 | + { |
---|
| 201 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 202 | + return gl.glGenLists(1); |
---|
| 203 | + } |
---|
| 204 | + |
---|
| 205 | + public void NewList(int id) |
---|
| 206 | + { |
---|
| 207 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 208 | + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 209 | + } |
---|
| 210 | + |
---|
| 211 | + public void CallList(int id) |
---|
| 212 | + { |
---|
| 213 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 214 | + gl.glCallList(id); |
---|
| 215 | + } |
---|
| 216 | + |
---|
| 217 | + public void EndList() |
---|
| 218 | + { |
---|
| 219 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 220 | + gl.glEndList(); |
---|
| 221 | + } |
---|
| 222 | + |
---|
| 223 | + public boolean IsBoxMode() |
---|
| 224 | + { |
---|
| 225 | + return BOXMODE; |
---|
| 226 | + } |
---|
| 227 | + |
---|
| 228 | + public boolean IsZoomBoxMode() |
---|
| 229 | + { |
---|
| 230 | + return ZOOMBOXMODE; |
---|
| 231 | + } |
---|
| 232 | + |
---|
| 233 | + public void ClearDepth() |
---|
182 | 234 | { |
---|
183 | 235 | GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT); |
---|
184 | 236 | } |
---|
185 | 237 | |
---|
186 | | - void DepthTest(boolean depthtest) |
---|
| 238 | + public void DepthTest(boolean depthtest) |
---|
187 | 239 | { |
---|
188 | 240 | if (depthtest) |
---|
189 | 241 | GetGL().glDepthFunc(GL.GL_LEQUAL); |
---|
.. | .. |
---|
191 | 243 | GetGL().glDepthFunc(GL.GL_ALWAYS); |
---|
192 | 244 | } |
---|
193 | 245 | |
---|
194 | | - void DepthWrite(boolean depthwrite) |
---|
| 246 | + public void DepthWrite(boolean depthwrite) |
---|
195 | 247 | { |
---|
196 | 248 | if (depthwrite) |
---|
197 | 249 | GetGL().glDepthMask(true); |
---|
.. | .. |
---|
199 | 251 | GetGL().glDepthMask(false); |
---|
200 | 252 | } |
---|
201 | 253 | |
---|
202 | | - void BackFaceCull(boolean bfc) |
---|
| 254 | + public void BackFaceCull(boolean bfc) |
---|
203 | 255 | { |
---|
204 | 256 | if (bfc) |
---|
205 | 257 | GetGL().glEnable(GetGL().GL_CULL_FACE); |
---|
206 | 258 | else |
---|
207 | 259 | GetGL().glDisable(GetGL().GL_CULL_FACE); |
---|
| 260 | + } |
---|
| 261 | + |
---|
| 262 | + public boolean BackFaceCullMode() |
---|
| 263 | + { |
---|
| 264 | + return this.CULLFACE; |
---|
| 265 | + } |
---|
| 266 | + |
---|
| 267 | + public boolean IsAmbientOcclusionOn() |
---|
| 268 | + { |
---|
| 269 | + return this.ambientOcclusion; |
---|
| 270 | + } |
---|
| 271 | + |
---|
| 272 | + public boolean IsDebugSelection() |
---|
| 273 | + { |
---|
| 274 | + return DEBUG_SELECTION; |
---|
| 275 | + } |
---|
| 276 | + |
---|
| 277 | + public boolean IsFrozen() |
---|
| 278 | + { |
---|
| 279 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
| 280 | + |
---|
| 281 | + return !selectmode && cameracount == 0; // != 0; |
---|
| 282 | + } |
---|
| 283 | + |
---|
| 284 | + // Currently in Globals |
---|
| 285 | + public int DrawMode() |
---|
| 286 | + { |
---|
| 287 | + return Globals.DrawMode(); |
---|
| 288 | + } |
---|
| 289 | + |
---|
| 290 | + public Camera EyeCamera() |
---|
| 291 | + { |
---|
| 292 | + return eyeCamera; |
---|
| 293 | + } |
---|
| 294 | + |
---|
| 295 | + public Camera LightCamera() |
---|
| 296 | + { |
---|
| 297 | + return lightCamera; |
---|
| 298 | + } |
---|
| 299 | + |
---|
| 300 | + public Camera ManipCamera() |
---|
| 301 | + { |
---|
| 302 | + return manipCamera; |
---|
| 303 | + } |
---|
| 304 | + |
---|
| 305 | + public Camera RenderCamera() |
---|
| 306 | + { |
---|
| 307 | + return renderCamera; |
---|
| 308 | + } |
---|
| 309 | + |
---|
| 310 | + public Camera[] Cameras() |
---|
| 311 | + { |
---|
| 312 | + return cameras; |
---|
| 313 | + } |
---|
| 314 | + |
---|
| 315 | + public void PushMaterial(Object3D obj, boolean selected) |
---|
| 316 | + { |
---|
| 317 | + CameraPane display = this; |
---|
| 318 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 319 | + cMaterial material = obj.material; |
---|
| 320 | + |
---|
| 321 | + if (material != null) |
---|
| 322 | + { |
---|
| 323 | + materialstack[materialdepth] = material; |
---|
| 324 | + selectedstack[materialdepth] = selected; |
---|
| 325 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 326 | + //System.out.println("material " + material); |
---|
| 327 | + //Applet3D.tracein(this, selected); |
---|
| 328 | + display.vector2buffer = obj.projectedVertices; |
---|
| 329 | + if (obj instanceof Camera) |
---|
| 330 | + { |
---|
| 331 | + display.options1[0] = material.shift; |
---|
| 332 | + //System.out.println("shift " + material.shift); |
---|
| 333 | + display.options1[1] = material.lightarea; |
---|
| 334 | + display.options1[2] = material.shadowbias; |
---|
| 335 | + display.options1[3] = material.aniso; |
---|
| 336 | + display.options1[4] = material.anisoV; |
---|
| 337 | + display.options2[0] = material.opacity; |
---|
| 338 | + display.options2[1] = material.diffuse; |
---|
| 339 | + display.options2[2] = material.factor; |
---|
| 340 | + |
---|
| 341 | + cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 342 | + display.options4[0] = material.cameralight/0.2f; |
---|
| 343 | + display.options4[1] = material.subsurface; |
---|
| 344 | + display.options4[2] = material.sheen; |
---|
| 345 | + |
---|
| 346 | + // if (display.CURRENTANTIALIAS > 0) |
---|
| 347 | + // display.options3[3] /= 4; |
---|
| 348 | + |
---|
| 349 | + /* |
---|
| 350 | + System.out.println("Focus = " + display.options1[0]); |
---|
| 351 | + System.out.println("Aperture = " + display.options1[1]); |
---|
| 352 | + System.out.println("ShadowBlur = " + display.options1[2]); |
---|
| 353 | + System.out.println("Antialiasing = " + display.options1[3]); |
---|
| 354 | + System.out.println("Fog = " + display.options2[0]); |
---|
| 355 | + System.out.println("Intensity = " + display.options2[1]); |
---|
| 356 | + System.out.println("Elevation = " + display.options2[2]); |
---|
| 357 | + /**/ |
---|
| 358 | + } else |
---|
| 359 | + { |
---|
| 360 | + DrawMaterial(material, selected); |
---|
| 361 | + } |
---|
| 362 | + } else |
---|
| 363 | + { |
---|
| 364 | + if (selected && CameraPane.flash) |
---|
| 365 | + { |
---|
| 366 | + display.modelParams4[1] = 100; |
---|
| 367 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 368 | + } |
---|
| 369 | + } |
---|
| 370 | + } |
---|
| 371 | + |
---|
| 372 | + public void PushMaterial2(Object3D obj, boolean selected) |
---|
| 373 | + { |
---|
| 374 | + CameraPane display = this; |
---|
| 375 | + cMaterial material = obj.material; |
---|
| 376 | + |
---|
| 377 | + if (material != null) |
---|
| 378 | + { |
---|
| 379 | + materialstack[materialdepth] = material; |
---|
| 380 | + selectedstack[materialdepth] = selected; |
---|
| 381 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 382 | + //System.out.println("material " + material); |
---|
| 383 | + //Applet3D.tracein("selected ", selected); |
---|
| 384 | + display.vector2buffer = obj.projectedVertices; |
---|
| 385 | + display.DrawMaterial(material, selected); |
---|
| 386 | + } |
---|
| 387 | + } |
---|
| 388 | + |
---|
| 389 | + public void PopMaterial(Object3D obj, boolean selected) |
---|
| 390 | + { |
---|
| 391 | + CameraPane display = this; |
---|
| 392 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 393 | + cMaterial material = obj.material; |
---|
| 394 | + |
---|
| 395 | + //if (parent != null && parent.GetMaterial() != null) |
---|
| 396 | + // parent.GetMaterial().Draw(display, parent.IsSelected(this)); |
---|
| 397 | + if (material != null) |
---|
| 398 | + { |
---|
| 399 | + materialdepth -= 1; |
---|
| 400 | + if (materialdepth > 0) |
---|
| 401 | + { |
---|
| 402 | + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 403 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 404 | + } |
---|
| 405 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 406 | + } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
| 407 | + { |
---|
| 408 | + display.modelParams4[1] = obj.GetMaterial().cameralight; |
---|
| 409 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 410 | + } |
---|
| 411 | + } |
---|
| 412 | + |
---|
| 413 | + public void PopMaterial2(Object3D obj) |
---|
| 414 | + { |
---|
| 415 | + CameraPane display = this; |
---|
| 416 | + cMaterial material = obj.material; |
---|
| 417 | + |
---|
| 418 | + if (material != null) |
---|
| 419 | + { |
---|
| 420 | + materialdepth -= 1; |
---|
| 421 | + if (materialdepth > 0) |
---|
| 422 | + { |
---|
| 423 | + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 424 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 425 | + } |
---|
| 426 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 427 | + //else |
---|
| 428 | + //material.Draw(display, false); |
---|
| 429 | + } |
---|
| 430 | + } |
---|
| 431 | + |
---|
| 432 | + public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face) |
---|
| 433 | + { |
---|
| 434 | + CameraPane display = this; |
---|
| 435 | + |
---|
| 436 | + if (pv.y == -10000 || |
---|
| 437 | + qv.y == -10000 || |
---|
| 438 | + rv.y == -10000) |
---|
| 439 | + return; |
---|
| 440 | + |
---|
| 441 | +// float b = f.nbiterations & 1; |
---|
| 442 | +// float g = (f.nbiterations>>1) & 1; |
---|
| 443 | +// float r = (f.nbiterations>>2) & 1; |
---|
| 444 | +// |
---|
| 445 | +// //if (f.weight == 10000) |
---|
| 446 | +// //{ |
---|
| 447 | +// // r = 1; g = b = 0; |
---|
| 448 | +// //} |
---|
| 449 | +// //else |
---|
| 450 | +// //{ |
---|
| 451 | +// // assert(f.weight < 10000); |
---|
| 452 | +// r = g = b = (float)bRep.FaceWeight(f)*100; |
---|
| 453 | +// if (r<0) |
---|
| 454 | +// assert(r>=0); |
---|
| 455 | +// //} |
---|
| 456 | + |
---|
| 457 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 458 | + |
---|
| 459 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
| 460 | + |
---|
| 461 | + //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
| 462 | + if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
| 463 | + { |
---|
| 464 | + //gl.glBegin(gl.GL_TRIANGLES); |
---|
| 465 | + boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 466 | + if (!hasnorm) |
---|
| 467 | + { |
---|
| 468 | + // System.out.println("FUCK!!"); |
---|
| 469 | + LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
| 470 | + LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
| 471 | + LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
| 472 | + LA.vecNormalize(obj.v2); |
---|
| 473 | + gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 474 | + } |
---|
| 475 | + |
---|
| 476 | + // P |
---|
| 477 | + float x = (float)pv.x; |
---|
| 478 | + float y = (float)pv.y; |
---|
| 479 | + float z = (float)pv.z; |
---|
| 480 | + |
---|
| 481 | + if (hasnorm) |
---|
| 482 | + { |
---|
| 483 | +// if (!pv.norm.normalized()) |
---|
| 484 | +// assert(pv.norm.normalized()); |
---|
| 485 | + |
---|
| 486 | + //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z); |
---|
| 487 | + float nx = (float)pv.norm.x; |
---|
| 488 | + float ny = (float)pv.norm.y; |
---|
| 489 | + float nz = (float)pv.norm.z; |
---|
| 490 | + |
---|
| 491 | + x += nx * obj.NORMALPUSH; |
---|
| 492 | + y += ny * obj.NORMALPUSH; |
---|
| 493 | + z += nz * obj.NORMALPUSH; |
---|
| 494 | + |
---|
| 495 | + gl.glNormal3f(nx, ny, nz); |
---|
| 496 | + } |
---|
| 497 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 498 | + SetColor(obj, pv); |
---|
| 499 | + //gl.glColor4f(r, g, b, 1); |
---|
| 500 | + //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1); |
---|
| 501 | + if (obj.flipV) |
---|
| 502 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 503 | + else |
---|
| 504 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 505 | + //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z); |
---|
| 506 | + |
---|
| 507 | + gl.glVertex3f(x, y, z); |
---|
| 508 | + |
---|
| 509 | + // Q |
---|
| 510 | + x = (float)qv.x; |
---|
| 511 | + y = (float)qv.y; |
---|
| 512 | + z = (float)qv.z; |
---|
| 513 | + |
---|
| 514 | +// Print(pv); |
---|
| 515 | + if (hasnorm) |
---|
| 516 | + { |
---|
| 517 | +// assert(qv.norm.normalized()); |
---|
| 518 | + //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z); |
---|
| 519 | + float nx = (float)qv.norm.x; |
---|
| 520 | + float ny = (float)qv.norm.y; |
---|
| 521 | + float nz = (float)qv.norm.z; |
---|
| 522 | + |
---|
| 523 | + x += nx * obj.NORMALPUSH; |
---|
| 524 | + y += ny * obj.NORMALPUSH; |
---|
| 525 | + z += nz * obj.NORMALPUSH; |
---|
| 526 | + |
---|
| 527 | + gl.glNormal3f(nx, ny, nz); |
---|
| 528 | + } |
---|
| 529 | + //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
| 530 | + // boolean locked = false; |
---|
| 531 | + // float eps = 0.1f; |
---|
| 532 | + // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 533 | + |
---|
| 534 | + // int dot = 0; //*/ (int)f.dot; |
---|
| 535 | + |
---|
| 536 | + // if ((dot&1) == 0) |
---|
| 537 | + // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 538 | + |
---|
| 539 | + // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 540 | + if (obj.flipV) |
---|
| 541 | + gl.glTexCoord2f((float) qv.s, 1-(float) qv.t); |
---|
| 542 | + else |
---|
| 543 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 544 | + // else |
---|
| 545 | + // { |
---|
| 546 | + // locked = true; |
---|
| 547 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 548 | + // } |
---|
| 549 | + gl.glColor4f(qv.AO, qv.AO, qv.AO, 1); |
---|
| 550 | + SetColor(obj, qv); |
---|
| 551 | + |
---|
| 552 | + gl.glVertex3f(x, y, z); |
---|
| 553 | + //gl.glColor4f(r, g, b, 1); |
---|
| 554 | + //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1); |
---|
| 555 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 556 | +// Print(qv); |
---|
| 557 | + |
---|
| 558 | + // R |
---|
| 559 | + x = (float)rv.x; |
---|
| 560 | + y = (float)rv.y; |
---|
| 561 | + z = (float)rv.z; |
---|
| 562 | + |
---|
| 563 | + if (hasnorm) |
---|
| 564 | + { |
---|
| 565 | +// assert(rv.norm.normalized()); |
---|
| 566 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 567 | + float nx = (float)rv.norm.x; |
---|
| 568 | + float ny = (float)rv.norm.y; |
---|
| 569 | + float nz = (float)rv.norm.z; |
---|
| 570 | + |
---|
| 571 | + x += nx * obj.NORMALPUSH; |
---|
| 572 | + y += ny * obj.NORMALPUSH; |
---|
| 573 | + z += nz * obj.NORMALPUSH; |
---|
| 574 | + |
---|
| 575 | + gl.glNormal3f(nx, ny, nz); |
---|
| 576 | + } |
---|
| 577 | + |
---|
| 578 | + // if ((dot&4) == 0) |
---|
| 579 | + // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 580 | + |
---|
| 581 | + // if (wrap || !locked && (dot&8) != 0) |
---|
| 582 | + if (obj.flipV) |
---|
| 583 | + gl.glTexCoord2f((float) rv.s, 1-(float) rv.t); |
---|
| 584 | + else |
---|
| 585 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 586 | + // else |
---|
| 587 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 588 | + |
---|
| 589 | + // f.dot = dot; |
---|
| 590 | + |
---|
| 591 | + gl.glColor4f(rv.AO, rv.AO, rv.AO, 1); |
---|
| 592 | + SetColor(obj, rv); |
---|
| 593 | + //gl.glColor4f(r, g, b, 1); |
---|
| 594 | + //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1); |
---|
| 595 | + //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z); |
---|
| 596 | + gl.glVertex3f(x, y, z); |
---|
| 597 | +// Print(rv); |
---|
| 598 | + //gl.glEnd(); |
---|
| 599 | + } |
---|
| 600 | + else |
---|
| 601 | + { |
---|
| 602 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 603 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 604 | + gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z); |
---|
| 605 | + |
---|
| 606 | + } |
---|
| 607 | + |
---|
| 608 | + if (false) // (attributes & WIREFRAME) != 0) |
---|
| 609 | + { |
---|
| 610 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 611 | + |
---|
| 612 | + gl.glBegin(gl.GL_LINE_LOOP); |
---|
| 613 | + gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z); |
---|
| 614 | + gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z); |
---|
| 615 | + gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z); |
---|
| 616 | + gl.glEnd(); |
---|
| 617 | + |
---|
| 618 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 619 | + } |
---|
| 620 | + } |
---|
| 621 | + |
---|
| 622 | + /** |
---|
| 623 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 624 | + * it's normals, colors, textures and vertices. |
---|
| 625 | + * |
---|
| 626 | + * @see Renderer#draw(TriMesh) |
---|
| 627 | + * @param tris |
---|
| 628 | + * the mesh to render. |
---|
| 629 | + */ |
---|
| 630 | + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 631 | + { |
---|
| 632 | + CameraPane display = this; |
---|
| 633 | + |
---|
| 634 | + float r = display.modelParams0[0]; |
---|
| 635 | + float g = display.modelParams0[1]; |
---|
| 636 | + float b = display.modelParams0[2]; |
---|
| 637 | + float opacity = display.modelParams5[1]; |
---|
| 638 | + |
---|
| 639 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 640 | + GL gl = display.GetGL(); // getGL(); |
---|
| 641 | + |
---|
| 642 | + FloatBuffer vertBuf = geo.vertBuf; |
---|
| 643 | + |
---|
| 644 | + int v = vertBuf.capacity(); |
---|
| 645 | + |
---|
| 646 | + int count = 0; |
---|
| 647 | + |
---|
| 648 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 649 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 650 | + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
| 651 | + for (int i=0; i<v/3; i++) |
---|
| 652 | + { |
---|
| 653 | + int index3 = i*3; |
---|
| 654 | + |
---|
| 655 | + if (geo.sizeBuf.get(index3+1) == 0) |
---|
| 656 | + continue; |
---|
| 657 | + |
---|
| 658 | + count++; |
---|
| 659 | + |
---|
| 660 | + int index4 = i*4; |
---|
| 661 | + |
---|
| 662 | + float tx = vertBuf.get(index3); |
---|
| 663 | + float ty = vertBuf.get(index3+1); |
---|
| 664 | + float tz = vertBuf.get(index3+2); |
---|
| 665 | + |
---|
| 666 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 667 | + // continue; |
---|
| 668 | + |
---|
| 669 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 670 | + gl.glPushMatrix(); |
---|
| 671 | + |
---|
| 672 | + float[] texmat = geo.texmat; |
---|
| 673 | + texmat[12] = texmat[13] = texmat[14] = i; |
---|
| 674 | + |
---|
| 675 | + gl.glMultMatrixf(texmat, 0); |
---|
| 676 | + |
---|
| 677 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 678 | + gl.glPushMatrix(); |
---|
| 679 | + |
---|
| 680 | + gl.glTranslatef(tx,ty,tz); |
---|
| 681 | + |
---|
| 682 | + if (rotate) |
---|
| 683 | + gl.glRotatef(i, 0, 1, 0); |
---|
| 684 | + |
---|
| 685 | + float size = geo.sizeBuf.get(index3) / 100; |
---|
| 686 | + gl.glScalef(size,size,size); |
---|
| 687 | + |
---|
| 688 | + float cr = geo.colorBuf.get(index4); |
---|
| 689 | + float cg = geo.colorBuf.get(index4+1); |
---|
| 690 | + float cb = geo.colorBuf.get(index4+2); |
---|
| 691 | + float ca = geo.colorBuf.get(index4+3); |
---|
| 692 | + |
---|
| 693 | + display.modelParams0[0] = r * cr; |
---|
| 694 | + display.modelParams0[1] = g * cg; |
---|
| 695 | + display.modelParams0[2] = b * cb; |
---|
| 696 | + |
---|
| 697 | + display.modelParams5[1] = opacity * ca; |
---|
| 698 | + |
---|
| 699 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 700 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 701 | + |
---|
| 702 | + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; |
---|
| 703 | + RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 704 | + |
---|
| 705 | +// gl.glColor4f(cr,cg,cb,ca); |
---|
| 706 | + // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 707 | + shape.Draw/*Node*/(display,null,selected,false); // blocked |
---|
| 708 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 709 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 710 | + gl.glPopMatrix(); |
---|
| 711 | + |
---|
| 712 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 713 | + gl.glPopMatrix(); |
---|
| 714 | + } |
---|
| 715 | + // gl.glScalef(1024,1024,1024); |
---|
| 716 | + if (!cf) |
---|
| 717 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 718 | + |
---|
| 719 | + display.modelParams0[0] = r; |
---|
| 720 | + display.modelParams0[1] = g; |
---|
| 721 | + display.modelParams0[2] = b; |
---|
| 722 | + |
---|
| 723 | + display.modelParams5[1] = opacity; |
---|
| 724 | + |
---|
| 725 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 726 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 727 | + |
---|
| 728 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 729 | + |
---|
| 730 | +// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
| 731 | + if (true) |
---|
| 732 | + return; |
---|
| 733 | + |
---|
| 734 | +//// if (!tris.predraw(this)) |
---|
| 735 | +//// { |
---|
| 736 | +//// return; |
---|
| 737 | +//// } |
---|
| 738 | +//// if (Debug.stats) |
---|
| 739 | +//// { |
---|
| 740 | +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
| 741 | +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
| 742 | +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
| 743 | +//// } |
---|
| 744 | +//// |
---|
| 745 | +//// if (tris.getDisplayListID() != -1) |
---|
| 746 | +//// { |
---|
| 747 | +//// renderDisplayList(tris); |
---|
| 748 | +//// return; |
---|
| 749 | +//// } |
---|
| 750 | +//// |
---|
| 751 | +//// if (!generatingDisplayList) |
---|
| 752 | +//// { |
---|
| 753 | +//// applyStates(tris.states, tris); |
---|
| 754 | +//// } |
---|
| 755 | +//// if (Debug.stats) |
---|
| 756 | +//// { |
---|
| 757 | +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
| 758 | +//// } |
---|
| 759 | +//// boolean transformed = doTransforms(tris); |
---|
| 760 | +// |
---|
| 761 | +// int glMode = GL.GL_TRIANGLES; |
---|
| 762 | +// switch (getMode()) |
---|
| 763 | +// { |
---|
| 764 | +// case Triangles: |
---|
| 765 | +// glMode = GL.GL_TRIANGLES; |
---|
| 766 | +// break; |
---|
| 767 | +// case Strip: |
---|
| 768 | +// glMode = GL.GL_TRIANGLE_STRIP; |
---|
| 769 | +// break; |
---|
| 770 | +// case Fan: |
---|
| 771 | +// glMode = GL.GL_TRIANGLE_FAN; |
---|
| 772 | +// break; |
---|
| 773 | +// } |
---|
| 774 | +// |
---|
| 775 | +// if (!predrawGeometry(gl)) |
---|
| 776 | +// { |
---|
| 777 | +// // make sure only the necessary indices are sent through on old |
---|
| 778 | +// // cards. |
---|
| 779 | +// IntBuffer indices = this.getIndexBuffer(); |
---|
| 780 | +// if (indices == null) |
---|
| 781 | +// { |
---|
| 782 | +// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
| 783 | +// } else |
---|
| 784 | +// { |
---|
| 785 | +// indices.rewind(); |
---|
| 786 | +// indices.limit(this.getMaxIndex()); |
---|
| 787 | +// |
---|
| 788 | +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
| 789 | +// |
---|
| 790 | +// indices.clear(); |
---|
| 791 | +// } |
---|
| 792 | +// } else |
---|
| 793 | +// { |
---|
| 794 | +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
| 795 | +// GL.GL_UNSIGNED_INT, 0); |
---|
| 796 | +// } |
---|
| 797 | +// |
---|
| 798 | +//// postdrawGeometry(tris); |
---|
| 799 | +//// if (transformed) |
---|
| 800 | +//// { |
---|
| 801 | +//// undoTransforms(tris); |
---|
| 802 | +//// } |
---|
| 803 | +//// |
---|
| 804 | +//// if (Debug.stats) |
---|
| 805 | +//// { |
---|
| 806 | +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
| 807 | +//// } |
---|
| 808 | +//// tris.postdraw(this); |
---|
| 809 | + } |
---|
| 810 | + |
---|
| 811 | + static Camera localcamera = new Camera(); |
---|
| 812 | + static cVector from = new cVector(); |
---|
| 813 | + static cVector to = new cVector(); |
---|
| 814 | + |
---|
| 815 | + public void PrepOcclusion(BoundaryRep br, double[][] transform) |
---|
| 816 | + { |
---|
| 817 | + CameraPane cp = this; |
---|
| 818 | + |
---|
| 819 | + Camera keep = cp.RenderCamera(); |
---|
| 820 | + cp.renderCamera = localcamera; |
---|
| 821 | + |
---|
| 822 | + if (br.trimmed) |
---|
| 823 | + { |
---|
| 824 | + float[] colors = new float[br.positions.length / 3]; |
---|
| 825 | + |
---|
| 826 | + int i3 = 0; |
---|
| 827 | + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) |
---|
| 828 | + { |
---|
| 829 | + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) |
---|
| 830 | + continue; |
---|
| 831 | + |
---|
| 832 | + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); |
---|
| 833 | + to.set(br.positions[i3] + br.normals[i3], |
---|
| 834 | + br.positions[i3 + 1] + br.normals[i3 + 1], |
---|
| 835 | + br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
| 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 | + colors[i] = cp.vertexOcclusion.r; |
---|
| 846 | + //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
| 847 | + //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
| 848 | + |
---|
| 849 | + if ((i % 100) == 0 && i != 0) |
---|
| 850 | + { |
---|
| 851 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 852 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 853 | + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); |
---|
| 854 | + } |
---|
| 855 | + } |
---|
| 856 | + |
---|
| 857 | + br.colors = colors; |
---|
| 858 | + } |
---|
| 859 | + else |
---|
| 860 | + { |
---|
| 861 | + for (int i = 0; i < br.VertexCount(); i++) |
---|
| 862 | + { |
---|
| 863 | + Vertex v = br.GetVertex(i); |
---|
| 864 | + |
---|
| 865 | + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
| 866 | + continue; |
---|
| 867 | + |
---|
| 868 | + from.set(v.x, v.y, v.z); |
---|
| 869 | + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
| 870 | + LA.xformPos(from, transform, from); |
---|
| 871 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 872 | + localcamera.setAim(from, to); |
---|
| 873 | + |
---|
| 874 | + CameraPane.occlusionbuffer.display(); |
---|
| 875 | + |
---|
| 876 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 877 | + cp.display(); // debug |
---|
| 878 | + |
---|
| 879 | + v.AO = cp.vertexOcclusion.r; |
---|
| 880 | + |
---|
| 881 | + if ((i % 100) == 0 && i != 0) |
---|
| 882 | + { |
---|
| 883 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 884 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 885 | + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); |
---|
| 886 | + } |
---|
| 887 | + } |
---|
| 888 | + } |
---|
| 889 | + |
---|
| 890 | + //System.out.println("done."); |
---|
| 891 | + |
---|
| 892 | + cp.renderCamera = keep; |
---|
| 893 | + } |
---|
| 894 | + |
---|
| 895 | + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 896 | + { |
---|
| 897 | + CameraPane display = this; |
---|
| 898 | + pointFlow.CreateHT(); |
---|
| 899 | + |
---|
| 900 | + float r = display.modelParams0[0]; |
---|
| 901 | + float g = display.modelParams0[1]; |
---|
| 902 | + float b = display.modelParams0[2]; |
---|
| 903 | + float opacity = display.modelParams5[1]; |
---|
| 904 | + |
---|
| 905 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 906 | + GL gl = display.GetGL(); // getGL(); |
---|
| 907 | + |
---|
| 908 | + int s = pointFlow.points.size(); |
---|
| 909 | + |
---|
| 910 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 911 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 912 | + |
---|
| 913 | + for (int i=s; --i>=0;) |
---|
| 914 | + //for (int i=0; i<s; i++) |
---|
| 915 | + { |
---|
| 916 | + cVector v = pointFlow.points.get(i); |
---|
| 917 | + |
---|
| 918 | + double mindist = Double.MAX_VALUE; |
---|
| 919 | + |
---|
| 920 | + double size = pointFlow.minimumSize; |
---|
| 921 | + |
---|
| 922 | + double distancenext = 0; |
---|
| 923 | + |
---|
| 924 | + if (i > 0) |
---|
| 925 | + { |
---|
| 926 | + cVector w = pointFlow.points.get(i-1); |
---|
| 927 | + |
---|
| 928 | + double dist = w.distance(v); |
---|
| 929 | + |
---|
| 930 | + distancenext = dist; |
---|
| 931 | + |
---|
| 932 | + if (mindist > dist) |
---|
| 933 | + { |
---|
| 934 | + mindist = dist; |
---|
| 935 | + size = mindist*pointFlow.resizefactor; |
---|
| 936 | + } |
---|
| 937 | + } |
---|
| 938 | + |
---|
| 939 | + if (i < s-1) |
---|
| 940 | + { |
---|
| 941 | + cVector w = pointFlow.points.get(i+1); |
---|
| 942 | + |
---|
| 943 | + double dist = w.distance(v); |
---|
| 944 | + |
---|
| 945 | + if (mindist > dist) |
---|
| 946 | + { |
---|
| 947 | + mindist = dist; |
---|
| 948 | + size = mindist*pointFlow.resizefactor; |
---|
| 949 | + } |
---|
| 950 | + } |
---|
| 951 | + |
---|
| 952 | + if (size < pointFlow.minimumSize) |
---|
| 953 | + size = pointFlow.minimumSize; |
---|
| 954 | + if (size > pointFlow.maximumSize) |
---|
| 955 | + size = pointFlow.maximumSize; |
---|
| 956 | + |
---|
| 957 | + double tx = v.x; |
---|
| 958 | + double ty = v.y; |
---|
| 959 | + double tz = v.z; |
---|
| 960 | + |
---|
| 961 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 962 | + // continue; |
---|
| 963 | + |
---|
| 964 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 965 | + gl.glPushMatrix(); |
---|
| 966 | + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; |
---|
| 967 | + |
---|
| 968 | + gl.glMultMatrixf(pointFlow.texmat, 0); |
---|
| 969 | + |
---|
| 970 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 971 | + gl.glPushMatrix(); |
---|
| 972 | + |
---|
| 973 | + gl.glTranslated(tx,ty,tz); |
---|
| 974 | + |
---|
| 975 | + gl.glScaled(size,size,size); |
---|
| 976 | + |
---|
| 977 | +// float cr = colorBuf.get(index4); |
---|
| 978 | +// float cg = colorBuf.get(index4+1); |
---|
| 979 | +// float cb = colorBuf.get(index4+2); |
---|
| 980 | +// float ca = colorBuf.get(index4+3); |
---|
| 981 | +// |
---|
| 982 | +// display.modelParams0[0] = r * cr; |
---|
| 983 | +// display.modelParams0[1] = g * cg; |
---|
| 984 | +// display.modelParams0[2] = b * cb; |
---|
| 985 | +// |
---|
| 986 | +// display.modelParams5[1] = opacity * ca; |
---|
| 987 | +// |
---|
| 988 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 989 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 990 | +// |
---|
| 991 | +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
| 992 | +// RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 993 | +// |
---|
| 994 | +//// gl.glColor4f(cr,cg,cb,ca); |
---|
| 995 | +// // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 996 | + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); |
---|
| 997 | + |
---|
| 998 | + gl.glPopMatrix(); |
---|
| 999 | + |
---|
| 1000 | + double step = size/4; // |
---|
| 1001 | + |
---|
| 1002 | + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) |
---|
| 1003 | + continue; |
---|
| 1004 | + |
---|
| 1005 | + int nbsteps = (int)(distancenext/step); |
---|
| 1006 | + |
---|
| 1007 | + step = distancenext/nbsteps; |
---|
| 1008 | + |
---|
| 1009 | + cVector next = pointFlow.points.get(i-1); |
---|
| 1010 | + |
---|
| 1011 | + tmp.set(next); |
---|
| 1012 | + tmp.sub(v); |
---|
| 1013 | + tmp.normalize(); |
---|
| 1014 | + tmp.mul(step); |
---|
| 1015 | + |
---|
| 1016 | + // calculate next size |
---|
| 1017 | + mindist = Double.MAX_VALUE; |
---|
| 1018 | + |
---|
| 1019 | + double nextsize = pointFlow.minimumSize; |
---|
| 1020 | + |
---|
| 1021 | + if (i > 1) |
---|
| 1022 | + { |
---|
| 1023 | + cVector w = pointFlow.points.get(i-2); |
---|
| 1024 | + |
---|
| 1025 | + double dist = w.distance(next); |
---|
| 1026 | + |
---|
| 1027 | + if (mindist > dist) |
---|
| 1028 | + { |
---|
| 1029 | + mindist = dist; |
---|
| 1030 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1031 | + } |
---|
| 1032 | + } |
---|
| 1033 | + |
---|
| 1034 | + double dist = v.distance(next); |
---|
| 1035 | + |
---|
| 1036 | + if (mindist > dist) |
---|
| 1037 | + { |
---|
| 1038 | + mindist = dist; |
---|
| 1039 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1040 | + } |
---|
| 1041 | + |
---|
| 1042 | + if (nextsize < pointFlow.minimumSize) |
---|
| 1043 | + nextsize = pointFlow.minimumSize; |
---|
| 1044 | + if (nextsize > pointFlow.maximumSize) |
---|
| 1045 | + nextsize = pointFlow.maximumSize; |
---|
| 1046 | + // |
---|
| 1047 | + |
---|
| 1048 | + double count = 0; |
---|
| 1049 | + |
---|
| 1050 | + while (distancenext > 0.000000001) // step |
---|
| 1051 | + { |
---|
| 1052 | + gl.glPushMatrix(); |
---|
| 1053 | + |
---|
| 1054 | + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); |
---|
| 1055 | + |
---|
| 1056 | + double K = count/nbsteps; |
---|
| 1057 | + |
---|
| 1058 | + double intersize = K*nextsize + (1-K)*size; |
---|
| 1059 | + |
---|
| 1060 | + gl.glScaled(intersize,intersize,intersize); |
---|
| 1061 | + |
---|
| 1062 | + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); |
---|
| 1063 | + |
---|
| 1064 | + count++; |
---|
| 1065 | + |
---|
| 1066 | + distancenext -= step; |
---|
| 1067 | + |
---|
| 1068 | + gl.glPopMatrix(); |
---|
| 1069 | + } |
---|
| 1070 | + |
---|
| 1071 | + if (count != nbsteps) |
---|
| 1072 | + assert(count == nbsteps); |
---|
| 1073 | + |
---|
| 1074 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 1075 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 1076 | + |
---|
| 1077 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1078 | + gl.glPopMatrix(); |
---|
| 1079 | + } |
---|
| 1080 | + |
---|
| 1081 | + if (!cf) |
---|
| 1082 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 1083 | + |
---|
| 1084 | +// display.modelParams0[0] = r; |
---|
| 1085 | +// display.modelParams0[1] = g; |
---|
| 1086 | +// display.modelParams0[2] = b; |
---|
| 1087 | +// |
---|
| 1088 | +// display.modelParams5[1] = opacity; |
---|
| 1089 | +// |
---|
| 1090 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1091 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1092 | + |
---|
| 1093 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1094 | + } |
---|
| 1095 | + |
---|
| 1096 | + public void DrawBox(cVector min, cVector max) |
---|
| 1097 | + { |
---|
| 1098 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1099 | + gl.glBegin(gl.GL_LINES); |
---|
| 1100 | + |
---|
| 1101 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1102 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1103 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1104 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1105 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1106 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1107 | + |
---|
| 1108 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1109 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1110 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1111 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1112 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1113 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1114 | + |
---|
| 1115 | + gl.glEnd(); |
---|
| 1116 | + } |
---|
| 1117 | + |
---|
| 1118 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1119 | + { |
---|
| 1120 | + int[] strips = bRep.getRawIndices(); |
---|
| 1121 | + |
---|
| 1122 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1123 | + |
---|
| 1124 | + // TRIANGLE STRIP ARRAY |
---|
| 1125 | + if (bRep.trimmed) |
---|
| 1126 | + { |
---|
| 1127 | + float[] v = bRep.getRawVertices(); |
---|
| 1128 | + float[] n = bRep.getRawNormals(); |
---|
| 1129 | + float[] c = bRep.getRawColors(); |
---|
| 1130 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1131 | + |
---|
| 1132 | + int count2 = 0; |
---|
| 1133 | + int count3 = 0; |
---|
| 1134 | + |
---|
| 1135 | + if (n.length > 0) |
---|
| 1136 | + { |
---|
| 1137 | + for (int i = 0; i < strips.length; i++) |
---|
| 1138 | + { |
---|
| 1139 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1140 | + |
---|
| 1141 | + /* |
---|
| 1142 | + boolean locked = false; |
---|
| 1143 | + float eps = 0.1f; |
---|
| 1144 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1145 | + |
---|
| 1146 | + int dot = 0; |
---|
| 1147 | + |
---|
| 1148 | + if ((dot&1) == 0) |
---|
| 1149 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1150 | + |
---|
| 1151 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1152 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1153 | + else |
---|
| 1154 | + { |
---|
| 1155 | + locked = true; |
---|
| 1156 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1157 | + } |
---|
| 1158 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1159 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1160 | + if (hasnorm) |
---|
| 1161 | + { |
---|
| 1162 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1163 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1164 | + } |
---|
| 1165 | + |
---|
| 1166 | + if ((dot&4) == 0) |
---|
| 1167 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1168 | + |
---|
| 1169 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1170 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1171 | + else |
---|
| 1172 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1173 | + |
---|
| 1174 | + f.dot = dot; |
---|
| 1175 | + */ |
---|
| 1176 | + |
---|
| 1177 | + if (!selectmode) |
---|
| 1178 | + { |
---|
| 1179 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1180 | + { |
---|
| 1181 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1182 | + } else |
---|
| 1183 | + { |
---|
| 1184 | + gl.glNormal3f(0, 0, 1); |
---|
| 1185 | + } |
---|
| 1186 | + |
---|
| 1187 | + if (c != null) |
---|
| 1188 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1189 | + { |
---|
| 1190 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1191 | + } |
---|
| 1192 | + } |
---|
| 1193 | + if (flipV) |
---|
| 1194 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1195 | + else |
---|
| 1196 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1197 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1198 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1199 | + |
---|
| 1200 | + count2 += 2; |
---|
| 1201 | + count3 += 3; |
---|
| 1202 | + if (!selectmode) |
---|
| 1203 | + { |
---|
| 1204 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1205 | + { |
---|
| 1206 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1207 | + } else |
---|
| 1208 | + { |
---|
| 1209 | + gl.glNormal3f(0, 0, 1); |
---|
| 1210 | + } |
---|
| 1211 | + if (c != null) |
---|
| 1212 | + { |
---|
| 1213 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1214 | + } |
---|
| 1215 | + } |
---|
| 1216 | + if (flipV) |
---|
| 1217 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1218 | + else |
---|
| 1219 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1220 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1221 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1222 | + |
---|
| 1223 | + count2 += 2; |
---|
| 1224 | + count3 += 3; |
---|
| 1225 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1226 | + { |
---|
| 1227 | + //gl.glTexCoord2d(...); |
---|
| 1228 | + if (!selectmode) |
---|
| 1229 | + { |
---|
| 1230 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1231 | + { |
---|
| 1232 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1233 | + } else |
---|
| 1234 | + { |
---|
| 1235 | + gl.glNormal3f(0, 0, 1); |
---|
| 1236 | + } |
---|
| 1237 | + if (c != null) |
---|
| 1238 | + { |
---|
| 1239 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1240 | + } |
---|
| 1241 | + } |
---|
| 1242 | + |
---|
| 1243 | + if (flipV) |
---|
| 1244 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1245 | + else |
---|
| 1246 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1247 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1248 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1249 | + count2 += 2; |
---|
| 1250 | + count3 += 3; |
---|
| 1251 | + } |
---|
| 1252 | + |
---|
| 1253 | + gl.glEnd(); |
---|
| 1254 | + } |
---|
| 1255 | + } |
---|
| 1256 | + |
---|
| 1257 | + assert count3 == v.length; |
---|
| 1258 | + } |
---|
| 1259 | + else // !trimmed |
---|
| 1260 | + { |
---|
| 1261 | + int count = 0; |
---|
| 1262 | + for (int i = 0; i < strips.length; i++) |
---|
| 1263 | + { |
---|
| 1264 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1265 | + |
---|
| 1266 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1267 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1268 | + |
---|
| 1269 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1270 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1271 | + |
---|
| 1272 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1273 | + { |
---|
| 1274 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1275 | + |
---|
| 1276 | + // if (j%2 == 0) |
---|
| 1277 | + // drawFace(p, q, r, display, null); |
---|
| 1278 | + // else |
---|
| 1279 | + // drawFace(p, r, q, display, null); |
---|
| 1280 | + |
---|
| 1281 | + // p = q; |
---|
| 1282 | + // q = r; |
---|
| 1283 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1284 | + } |
---|
| 1285 | + |
---|
| 1286 | + gl.glEnd(); |
---|
| 1287 | + } |
---|
| 1288 | + } |
---|
| 1289 | + } |
---|
| 1290 | + |
---|
| 1291 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1292 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1293 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1294 | + |
---|
| 1295 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1296 | + { |
---|
| 1297 | + GL gl = GetGL(); // getGL(); |
---|
| 1298 | + |
---|
| 1299 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1300 | + |
---|
| 1301 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1302 | + |
---|
| 1303 | + gl.glLineWidth(1); |
---|
| 1304 | + gl.glColor3f(1,1,1); |
---|
| 1305 | + gl.glBegin(gl.GL_LINES); |
---|
| 1306 | + double scale = 0; |
---|
| 1307 | + int count = 0; |
---|
| 1308 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1309 | + { |
---|
| 1310 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1311 | + if(s == 0) |
---|
| 1312 | + { |
---|
| 1313 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1314 | + } |
---|
| 1315 | + if (mesh.showsprings) |
---|
| 1316 | + { |
---|
| 1317 | + temp.set(spring.a.position); |
---|
| 1318 | + temp.add(spring.b.position); |
---|
| 1319 | + temp.mul(0.5); |
---|
| 1320 | + temp2.set(spring.a.position); |
---|
| 1321 | + temp2.sub(spring.b.position); |
---|
| 1322 | + temp2.mul(spring.restLength/2); |
---|
| 1323 | + temp.sub(temp2); |
---|
| 1324 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1325 | + temp.add(temp2); |
---|
| 1326 | + temp.add(temp2); |
---|
| 1327 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1328 | + } |
---|
| 1329 | + |
---|
| 1330 | + if (spring.isHandle) |
---|
| 1331 | + continue; |
---|
| 1332 | + |
---|
| 1333 | + //if (scale < spring.restLength) |
---|
| 1334 | + scale += spring.restLength; |
---|
| 1335 | + count++; |
---|
| 1336 | + } |
---|
| 1337 | + gl.glEnd(); |
---|
| 1338 | + |
---|
| 1339 | + if (count == 0) |
---|
| 1340 | + scale = 0.01; |
---|
| 1341 | + else |
---|
| 1342 | + scale /= count * 3; |
---|
| 1343 | + |
---|
| 1344 | + //scale = 0.25; |
---|
| 1345 | + |
---|
| 1346 | + if (mesh.ShowInfo()) |
---|
| 1347 | + { |
---|
| 1348 | + gl.glLineWidth(4); |
---|
| 1349 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1350 | + { |
---|
| 1351 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1352 | + if (node.mass == 0) |
---|
| 1353 | + continue; |
---|
| 1354 | + |
---|
| 1355 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1356 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1357 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1358 | + //temp.normalize(); |
---|
| 1359 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1360 | + gl.glBegin(gl.GL_LINES); |
---|
| 1361 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1362 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1363 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1364 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1365 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1366 | + gl.glEnd(); |
---|
| 1367 | + } |
---|
| 1368 | + |
---|
| 1369 | + gl.glLineWidth(8); |
---|
| 1370 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1371 | + { |
---|
| 1372 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1373 | + |
---|
| 1374 | + if (node.springs != null) |
---|
| 1375 | + { |
---|
| 1376 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1377 | + { |
---|
| 1378 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1379 | + |
---|
| 1380 | + int c = i+1; |
---|
| 1381 | + // c = node.springs.get(i).nbcopies; |
---|
| 1382 | + |
---|
| 1383 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1384 | + gl.glBegin(gl.GL_LINES); |
---|
| 1385 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1386 | + gl.glVertex3d(f.position.x/3+node.position.x*2/3, f.position.y/3+node.position.y*2/3, f.position.z/3+node.position.z*2/3); |
---|
| 1387 | + gl.glEnd(); |
---|
| 1388 | + } |
---|
| 1389 | + } |
---|
| 1390 | + } |
---|
| 1391 | + |
---|
| 1392 | + gl.glLineWidth(1); |
---|
| 1393 | + } |
---|
| 1394 | + |
---|
| 1395 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1396 | + } |
---|
| 1397 | + |
---|
| 1398 | + /// INTERFACE |
---|
| 1399 | + |
---|
| 1400 | + public void StartTriangles() |
---|
| 1401 | + { |
---|
| 1402 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1403 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1404 | + } |
---|
| 1405 | + |
---|
| 1406 | + public void EndTriangles() |
---|
| 1407 | + { |
---|
| 1408 | + GetGL().glEnd(); |
---|
| 1409 | + } |
---|
| 1410 | + |
---|
| 1411 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1412 | + { |
---|
| 1413 | + if (!selectmode) |
---|
| 1414 | + { |
---|
| 1415 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1416 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1417 | + |
---|
| 1418 | + if (flipV) |
---|
| 1419 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1420 | + else |
---|
| 1421 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1422 | + } |
---|
| 1423 | + |
---|
| 1424 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1425 | + } |
---|
| 1426 | + |
---|
| 1427 | + void SetColor(Object3D obj, Vertex p0) |
---|
| 1428 | + { |
---|
| 1429 | + CameraPane display = this; |
---|
| 1430 | + BoundaryRep bRep = obj.bRep; |
---|
| 1431 | + |
---|
| 1432 | + if (RENDERPROGRAM == 0) |
---|
| 1433 | + { |
---|
| 1434 | + float r = 0; |
---|
| 1435 | + if (bRep != null) |
---|
| 1436 | + { |
---|
| 1437 | + if (bRep.stripified) |
---|
| 1438 | + { |
---|
| 1439 | + r = 1; |
---|
| 1440 | + } |
---|
| 1441 | + } |
---|
| 1442 | + float g = 0; |
---|
| 1443 | + if (bRep != null) |
---|
| 1444 | + { |
---|
| 1445 | + if (bRep.trimmed) |
---|
| 1446 | + { |
---|
| 1447 | + g = 1; |
---|
| 1448 | + } |
---|
| 1449 | + } |
---|
| 1450 | + float b = 0; |
---|
| 1451 | + if (obj.support != null && obj.link2master) |
---|
| 1452 | + { |
---|
| 1453 | + b = 1; |
---|
| 1454 | + } |
---|
| 1455 | + display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO); |
---|
| 1456 | + return; |
---|
| 1457 | + } |
---|
| 1458 | + |
---|
| 1459 | + if (display.DrawMode() != CameraPane.SHADOW) |
---|
| 1460 | + return; |
---|
| 1461 | + |
---|
| 1462 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1463 | +// if (true) return; |
---|
| 1464 | +// float ao = p.AO; |
---|
| 1465 | +// |
---|
| 1466 | +// // if (ao == 0 && !bRep.AOdone) // transient problem! |
---|
| 1467 | +// // ao = 1; |
---|
| 1468 | +// |
---|
| 1469 | +// gl.glColor4f(ao, ao, ao, 1); |
---|
| 1470 | + |
---|
| 1471 | +// CameraPane.selectedpoint. |
---|
| 1472 | +// getAverage(cStatic.point1, true); |
---|
| 1473 | + if (CameraPane.pointflow == null) // !random) // live) |
---|
| 1474 | + { |
---|
| 1475 | + return; |
---|
| 1476 | + } |
---|
| 1477 | + |
---|
| 1478 | + cStatic.point1.set(0,0,0); |
---|
| 1479 | + LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1); |
---|
| 1480 | + |
---|
| 1481 | + cStatic.point1.sub(p0); |
---|
| 1482 | + |
---|
| 1483 | + |
---|
| 1484 | +// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta? |
---|
| 1485 | +// { |
---|
| 1486 | +// return; |
---|
| 1487 | +// } |
---|
| 1488 | + |
---|
| 1489 | + //if (true) |
---|
| 1490 | + if (cStatic.point1.dot(cStatic.point1) > 0.000001) |
---|
| 1491 | + { |
---|
| 1492 | + return; |
---|
| 1493 | + } |
---|
| 1494 | + |
---|
| 1495 | + float[] colorV = new float[3]; |
---|
| 1496 | + |
---|
| 1497 | + if (false) // marked) |
---|
| 1498 | + { |
---|
| 1499 | + // debug rigging weights |
---|
| 1500 | + for (int object = 0; object < p0.vertexlinks.length; object++) |
---|
| 1501 | + { |
---|
| 1502 | + float weight = p0.weights[object] / p0.totalweight; |
---|
| 1503 | + |
---|
| 1504 | + // if (weight < 0.1) |
---|
| 1505 | + // { |
---|
| 1506 | + // assert(weight == 0); |
---|
| 1507 | + // continue; |
---|
| 1508 | + // } |
---|
| 1509 | + |
---|
| 1510 | + if (p0.vertexlinks[object] == -1) |
---|
| 1511 | + continue; |
---|
| 1512 | + |
---|
| 1513 | + Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]); |
---|
| 1514 | + |
---|
| 1515 | + int color = //1 << object; // |
---|
| 1516 | + //p.vertexlinks.length; |
---|
| 1517 | + obj.support.bRep.supports[p0.closestsupport].links[object]; |
---|
| 1518 | + colorV[2] += (color & 1) * weight; |
---|
| 1519 | + colorV[1] += ((color & 2) >> 1) * weight; |
---|
| 1520 | + colorV[0] += ((color & 4) >> 2) * weight; |
---|
| 1521 | + } |
---|
| 1522 | + } |
---|
| 1523 | + else |
---|
| 1524 | + { |
---|
| 1525 | + if (obj.drawingstarted) |
---|
| 1526 | + { |
---|
| 1527 | + // find next point |
---|
| 1528 | + if (bRep.GetVertex(0).faceindices == null) |
---|
| 1529 | + { |
---|
| 1530 | + bRep.InitFaceIndices(); |
---|
| 1531 | + } |
---|
| 1532 | + |
---|
| 1533 | + double ymin = p0.y; |
---|
| 1534 | + |
---|
| 1535 | + Vertex newp = p0; |
---|
| 1536 | + |
---|
| 1537 | + for (int fii = 0; fii < p0.faceindices.length; fii++) |
---|
| 1538 | + { |
---|
| 1539 | + int fi = p0.faceindices[fii]; |
---|
| 1540 | + |
---|
| 1541 | + if (fi == -1) |
---|
| 1542 | + break; |
---|
| 1543 | + |
---|
| 1544 | + Face f = bRep.GetFace(fi); |
---|
| 1545 | + |
---|
| 1546 | + Vertex p = bRep.GetVertex(f.p); |
---|
| 1547 | + Vertex q = bRep.GetVertex(f.q); |
---|
| 1548 | + Vertex r = bRep.GetVertex(f.r); |
---|
| 1549 | + |
---|
| 1550 | + int swap = (int)(Math.random()*3); |
---|
| 1551 | + |
---|
| 1552 | +// for (int s=swap; --s>=0;) |
---|
| 1553 | +// { |
---|
| 1554 | +// Vertex t = p; |
---|
| 1555 | +// p = q; |
---|
| 1556 | +// q = r; |
---|
| 1557 | +// r = t; |
---|
| 1558 | +// } |
---|
| 1559 | + if (ymin > p.y) |
---|
| 1560 | + { |
---|
| 1561 | + ymin = p.y; |
---|
| 1562 | + newp = p; |
---|
| 1563 | +// break; |
---|
| 1564 | + } |
---|
| 1565 | + if (ymin > q.y) |
---|
| 1566 | + { |
---|
| 1567 | + ymin = q.y; |
---|
| 1568 | + newp = q; |
---|
| 1569 | +// break; |
---|
| 1570 | + } |
---|
| 1571 | + if (ymin > r.y) |
---|
| 1572 | + { |
---|
| 1573 | + ymin = r.y; |
---|
| 1574 | + newp = r; |
---|
| 1575 | +// break; |
---|
| 1576 | + } |
---|
| 1577 | + } |
---|
| 1578 | + |
---|
| 1579 | + CameraPane.selectedpoint.toParent[3][0] = newp.x; |
---|
| 1580 | + CameraPane.selectedpoint.toParent[3][1] = newp.y; |
---|
| 1581 | + CameraPane.selectedpoint.toParent[3][2] = newp.z; |
---|
| 1582 | + |
---|
| 1583 | + obj.drawingstarted = false; |
---|
| 1584 | + |
---|
| 1585 | + // return; |
---|
| 1586 | + } |
---|
| 1587 | + |
---|
| 1588 | + if (false) // CameraPane.DRAW |
---|
| 1589 | + { |
---|
| 1590 | + p0.AO = colorV[0] = 2; |
---|
| 1591 | + colorV[1] = 2; |
---|
| 1592 | + colorV[2] = 2; |
---|
| 1593 | + } |
---|
| 1594 | + |
---|
| 1595 | + CameraPane.pointflow.add(p0); |
---|
| 1596 | + CameraPane.pointflow.Touch(); |
---|
| 1597 | + } |
---|
| 1598 | + |
---|
| 1599 | +// gl.glColor3f(colorV[0], colorV[1], colorV[2]); |
---|
| 1600 | +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1601 | +// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1602 | + } |
---|
| 1603 | + |
---|
| 1604 | + void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1605 | + { |
---|
| 1606 | + CameraPane display = this; |
---|
| 1607 | + //new Exception().printStackTrace(); |
---|
| 1608 | + |
---|
| 1609 | + if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW) |
---|
| 1610 | + { |
---|
| 1611 | + return; |
---|
| 1612 | + } |
---|
| 1613 | + |
---|
| 1614 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1615 | + |
---|
| 1616 | + //Color col = Color.getHSBColor(color,modulation,1); |
---|
| 1617 | + //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
| 1618 | + if (!material.multiply) |
---|
| 1619 | + { |
---|
| 1620 | + display.color = material.color; |
---|
| 1621 | + display.saturation = material.modulation; |
---|
| 1622 | + } |
---|
| 1623 | + else |
---|
| 1624 | + { |
---|
| 1625 | + display.color *= material.color*2; |
---|
| 1626 | + display.saturation *= material.modulation*2; |
---|
| 1627 | + } |
---|
| 1628 | + |
---|
| 1629 | + cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
| 1630 | + |
---|
| 1631 | + float[] colorV = GrafreeD.colorV; |
---|
| 1632 | + |
---|
| 1633 | + /**/ |
---|
| 1634 | + if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
| 1635 | + { |
---|
| 1636 | + colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
| 1637 | + colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
| 1638 | + colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
| 1639 | + colorV[3] = material.opacity; |
---|
| 1640 | + |
---|
| 1641 | + gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
| 1642 | + //System.out.println("Opacity = " + opacity); |
---|
| 1643 | + |
---|
| 1644 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1645 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1646 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1647 | + |
---|
| 1648 | + float amb = material.ambient; |
---|
| 1649 | + if (amb < material.cameralight) |
---|
| 1650 | + { |
---|
| 1651 | + amb = material.cameralight; |
---|
| 1652 | + } |
---|
| 1653 | + colorV[0] = display.modelParams0[0] * material.diffuse * amb; |
---|
| 1654 | + colorV[1] = display.modelParams0[1] * material.diffuse * amb; |
---|
| 1655 | + colorV[2] = display.modelParams0[2] * material.diffuse * amb; |
---|
| 1656 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0); |
---|
| 1657 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1658 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 1659 | + |
---|
| 1660 | + /**/ |
---|
| 1661 | + colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular; |
---|
| 1662 | + colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular; |
---|
| 1663 | + colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular; |
---|
| 1664 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0); |
---|
| 1665 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1666 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0); |
---|
| 1667 | + colorV[0] = 10 / material.shininess; // 1/0.005f; |
---|
| 1668 | + //System.out.println("shininess = " + colorV[0]); |
---|
| 1669 | + if (colorV[0] > 128) |
---|
| 1670 | + { |
---|
| 1671 | + colorV[0] = 128; |
---|
| 1672 | + } |
---|
| 1673 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0); |
---|
| 1674 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0); |
---|
| 1675 | + /**/ |
---|
| 1676 | + } |
---|
| 1677 | + /**/ |
---|
| 1678 | + |
---|
| 1679 | + //selected = false; |
---|
| 1680 | + selected = selected && display.flash; |
---|
| 1681 | + |
---|
| 1682 | + //display.modelParams0[0] = 0; // pigment.r; |
---|
| 1683 | + //display.modelParams0[1] = 0; // pigment.g; |
---|
| 1684 | + //display.modelParams0[2] = 0; // pigment.b; |
---|
| 1685 | + if (!material.multiply) |
---|
| 1686 | + { |
---|
| 1687 | + display.modelParams0[3] = material.metalness; |
---|
| 1688 | + display.modelParams1[0] = material.diffuse; |
---|
| 1689 | + display.modelParams1[1] = material.specular; |
---|
| 1690 | + display.modelParams1[2] = 1 / material.shininess; |
---|
| 1691 | + display.modelParams1[3] = material.shift; |
---|
| 1692 | + display.modelParams2[0] = material.ambient; |
---|
| 1693 | + display.modelParams2[1] = material.lightarea; |
---|
| 1694 | + //System.out.println("light area = " + lightarea); |
---|
| 1695 | + display.modelParams2[2] = 1 / material.factor; // diffuseness |
---|
| 1696 | + display.modelParams2[3] = material.velvet; |
---|
| 1697 | + display.modelParams3[0] = material.sheen; |
---|
| 1698 | + display.modelParams3[1] = material.subsurface; |
---|
| 1699 | + display.modelParams3[2] = material.bump; // backlit |
---|
| 1700 | + display.modelParams3[3] = material.aniso; |
---|
| 1701 | + display.modelParams4[0] = material.anisoV; |
---|
| 1702 | + display.modelParams4[1] = selected ? 100 : material.cameralight; |
---|
| 1703 | + //System.out.println("selected = " + selected); |
---|
| 1704 | + display.modelParams4[2] = material.diffuseness; |
---|
| 1705 | + display.modelParams4[3] = material.shadow; |
---|
| 1706 | + display.modelParams5[0] = material.texture; |
---|
| 1707 | + display.modelParams5[1] = material.opacity; |
---|
| 1708 | + display.modelParams5[2] = material.fakedepth; |
---|
| 1709 | + display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10; |
---|
| 1710 | + } |
---|
| 1711 | + else |
---|
| 1712 | + { |
---|
| 1713 | + display.modelParams0[3] *= material.metalness*2; |
---|
| 1714 | + display.modelParams1[0] *= material.diffuse*2; |
---|
| 1715 | + display.modelParams1[1] *= material.specular*2; |
---|
| 1716 | + display.modelParams1[2] *= material.shininess*2; |
---|
| 1717 | + display.modelParams1[3] *= material.shift*2; |
---|
| 1718 | + display.modelParams2[0] *= material.ambient*2; |
---|
| 1719 | + display.modelParams2[1] *= material.lightarea*2; |
---|
| 1720 | + display.modelParams2[2] *= material.factor*2; |
---|
| 1721 | + display.modelParams2[3] *= material.velvet*2; |
---|
| 1722 | + display.modelParams3[0] *= material.sheen*2; |
---|
| 1723 | + display.modelParams3[1] *= material.subsurface*2; |
---|
| 1724 | + display.modelParams3[2] *= material.bump*2; |
---|
| 1725 | + display.modelParams3[3] *= material.aniso*2; |
---|
| 1726 | + display.modelParams4[0] *= material.anisoV*2; |
---|
| 1727 | + display.modelParams4[1] *= material.cameralight*2; |
---|
| 1728 | + //System.out.println("selected = " + selected); |
---|
| 1729 | + display.modelParams4[2] *= material.diffuseness*2; |
---|
| 1730 | + display.modelParams4[3] *= material.shadow*2; |
---|
| 1731 | + display.modelParams5[0] *= material.texture*2; |
---|
| 1732 | + display.modelParams5[1] *= material.opacity*2; |
---|
| 1733 | + display.modelParams5[2] *= material.fakedepth*2; |
---|
| 1734 | + display.modelParams5[3] *= material.shadowbias*2; |
---|
| 1735 | + } |
---|
| 1736 | + |
---|
| 1737 | + display.modelParams6[0] = 0; |
---|
| 1738 | + display.modelParams6[1] = 0; |
---|
| 1739 | + display.modelParams6[2] = 0; |
---|
| 1740 | + display.modelParams6[3] = 0; |
---|
| 1741 | + |
---|
| 1742 | + display.modelParams7[0] = 0; |
---|
| 1743 | + display.modelParams7[1] = 1000; |
---|
| 1744 | + display.modelParams7[2] = 0; |
---|
| 1745 | + display.modelParams7[3] = 0; |
---|
| 1746 | + |
---|
| 1747 | + display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1748 | + |
---|
| 1749 | + Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1750 | + if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
| 1751 | + { |
---|
| 1752 | + display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
| 1753 | + display.modelParams6[1] = extparams[0].y / 1000.0f; // noise |
---|
| 1754 | + if (extparams.length > 1) |
---|
| 1755 | + { |
---|
| 1756 | + display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade |
---|
| 1757 | + display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough |
---|
| 1758 | + if (extparams.length > 2) |
---|
| 1759 | + { |
---|
| 1760 | + display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power |
---|
| 1761 | + float x = extparams[2].y / 1000.0f; |
---|
| 1762 | + //if (x == 0) |
---|
| 1763 | + // x = 1f; |
---|
| 1764 | + 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 |
---|
| 1765 | + if (extparams[2].y > 0) |
---|
| 1766 | + { |
---|
| 1767 | + //System.out.println("extparams[1].y = " + extparams[1].y); |
---|
| 1768 | + //System.out.println("extparams[2].y = " + extparams[2].y); |
---|
| 1769 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1770 | + } |
---|
| 1771 | + } |
---|
| 1772 | + } |
---|
| 1773 | + } |
---|
| 1774 | + |
---|
| 1775 | + //if (display.modelParams6[2] != 0) |
---|
| 1776 | + /* |
---|
| 1777 | + System.out.println("modelParams0[0] = " + display.modelParams0[0]); |
---|
| 1778 | + System.out.println("modelParams0[1] = " + display.modelParams0[1]); |
---|
| 1779 | + System.out.println("modelParams0[2] = " + display.modelParams0[2]); |
---|
| 1780 | + System.out.println("modelParams0[3] = " + display.modelParams0[3]); |
---|
| 1781 | + System.out.println("modelParams1[0] = " + display.modelParams1[0]); |
---|
| 1782 | + System.out.println("modelParams1[1] = " + display.modelParams1[1]); |
---|
| 1783 | + System.out.println("modelParams1[2] = " + display.modelParams1[2]); |
---|
| 1784 | + System.out.println("modelParams1[3] = " + display.modelParams1[3]); |
---|
| 1785 | + System.out.println("modelParams2[0] = " + display.modelParams2[0]); |
---|
| 1786 | + System.out.println("modelParams2[1] = " + display.modelParams2[1]); |
---|
| 1787 | + System.out.println("modelParams2[2] = " + display.modelParams2[2]); |
---|
| 1788 | + System.out.println("modelParams2[3] = " + display.modelParams2[3]); |
---|
| 1789 | + System.out.println("modelParams3[0] = " + display.modelParams3[0]); |
---|
| 1790 | + System.out.println("modelParams3[1] = " + display.modelParams3[1]); |
---|
| 1791 | + System.out.println("modelParams3[2] = " + display.modelParams3[2]); |
---|
| 1792 | + System.out.println("modelParams3[3] = " + display.modelParams3[3]); |
---|
| 1793 | + System.out.println("modelParams4[0] = " + display.modelParams4[0]); |
---|
| 1794 | + System.out.println("modelParams4[1] = " + display.modelParams4[1]); |
---|
| 1795 | + System.out.println("modelParams4[2] = " + display.modelParams4[2]); |
---|
| 1796 | + System.out.println("modelParams4[3] = " + display.modelParams4[3]); |
---|
| 1797 | + System.out.println("modelParams5[0] = " + display.modelParams5[0]); |
---|
| 1798 | + System.out.println("modelParams5[1] = " + display.modelParams5[1]); |
---|
| 1799 | + System.out.println("modelParams5[2] = " + display.modelParams5[2]); |
---|
| 1800 | + System.out.println("modelParams5[3] = " + display.modelParams5[3]); |
---|
| 1801 | + System.out.println("modelParams6[0] = " + display.modelParams6[0]); |
---|
| 1802 | + System.out.println("modelParams6[1] = " + display.modelParams6[1]); |
---|
| 1803 | + System.out.println("modelParams6[2] = " + display.modelParams6[2]); |
---|
| 1804 | + System.out.println("modelParams6[3] = " + display.modelParams6[3]); |
---|
| 1805 | + System.out.println("modelParams7[0] = " + display.modelParams7[0]); |
---|
| 1806 | + System.out.println("modelParams7[1] = " + display.modelParams7[1]); |
---|
| 1807 | + System.out.println("modelParams7[2] = " + display.modelParams7[2]); |
---|
| 1808 | + System.out.println("modelParams7[3] = " + display.modelParams7[3]); |
---|
| 1809 | + /**/ |
---|
| 1810 | + //assert (display.modelParams6[2] == 0); |
---|
| 1811 | + |
---|
| 1812 | + //System.out.println("noise power = " + display.modelParams7[0]); |
---|
| 1813 | + //System.out.println("shadowbias = " + shadowbias); |
---|
| 1814 | + |
---|
| 1815 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1816 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0); |
---|
| 1817 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0); |
---|
| 1818 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0); |
---|
| 1819 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 1820 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1821 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0); |
---|
| 1822 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0); |
---|
| 1823 | + |
---|
| 1824 | + int mode = display.FP_SHADER; |
---|
| 1825 | + |
---|
| 1826 | + if (material.aniso != material.anisoV || material.aniso > 0.002) |
---|
| 1827 | + { |
---|
| 1828 | + mode |= display.FP_ANISO; |
---|
| 1829 | + } |
---|
| 1830 | + |
---|
| 1831 | + display.EnableProgram(mode); |
---|
| 1832 | + |
---|
| 1833 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1834 | + |
---|
| 1835 | + if (!material.multiply) |
---|
| 1836 | + { |
---|
| 1837 | + if (Globals.drawMode == CameraPane.SHADOW) |
---|
| 1838 | + gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1); |
---|
| 1839 | + else |
---|
| 1840 | + gl.glDepthMask(material.opacity >= 0.99); |
---|
| 1841 | + } |
---|
208 | 1842 | } |
---|
209 | 1843 | |
---|
210 | 1844 | int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0; |
---|
.. | .. |
---|
225 | 1859 | currentGL.glMultMatrixd(model, 0); |
---|
226 | 1860 | } |
---|
227 | 1861 | |
---|
228 | | - void PushMatrix(double[][] matrix, int count) |
---|
| 1862 | + public void PushMatrix(double[][] matrix, int count) // INTERFACE |
---|
229 | 1863 | { |
---|
230 | 1864 | matrixdepth++; |
---|
231 | 1865 | // GrafreeD.tracein(matrix); |
---|
.. | .. |
---|
270 | 1904 | |
---|
271 | 1905 | double[][] tmpmat = new double[4][4]; |
---|
272 | 1906 | |
---|
273 | | - void PopMatrix(double[][] inverse) |
---|
| 1907 | + public void PopMatrix(double[][] inverse) // INTERFACE |
---|
274 | 1908 | { |
---|
275 | 1909 | --matrixdepth; |
---|
276 | 1910 | |
---|
.. | .. |
---|
310 | 1944 | PushTextureMatrix(matrix, 1); |
---|
311 | 1945 | } |
---|
312 | 1946 | |
---|
313 | | - void PushTextureMatrix(double[][] matrix, int count) |
---|
| 1947 | + public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE |
---|
314 | 1948 | { |
---|
315 | 1949 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
316 | 1950 | |
---|
.. | .. |
---|
324 | 1958 | currentGL.glMatrixMode(GetGL().GL_MODELVIEW); |
---|
325 | 1959 | } |
---|
326 | 1960 | |
---|
327 | | - void PopTextureMatrix(double[][] inverse) |
---|
| 1961 | + public void PopTextureMatrix(double[][] inverse) // INTERFACE |
---|
328 | 1962 | { |
---|
329 | 1963 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
330 | 1964 | currentGL.glMatrixMode(GetGL().GL_TEXTURE); |
---|
.. | .. |
---|
351 | 1985 | |
---|
352 | 1986 | static int camerachangeframe; |
---|
353 | 1987 | |
---|
354 | | - boolean SetCamera(Camera cam) |
---|
| 1988 | + public boolean SetCamera(Camera cam) |
---|
355 | 1989 | { |
---|
356 | 1990 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
357 | 1991 | // return false; |
---|
358 | 1992 | |
---|
359 | | - if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount) |
---|
| 1993 | + if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount) |
---|
360 | 1994 | { |
---|
361 | 1995 | // check for last change |
---|
362 | | - if (framecount < camerachangeframe + 400) // 120 == 1 second |
---|
| 1996 | + if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second |
---|
363 | 1997 | { |
---|
364 | 1998 | // refuse the camera change |
---|
365 | 1999 | System.err.println("Camera " + cam + " REFUSED"); |
---|
.. | .. |
---|
367 | 2001 | } |
---|
368 | 2002 | } |
---|
369 | 2003 | |
---|
370 | | - camerachangeframe = framecount; |
---|
| 2004 | + camerachangeframe = Globals.framecount; |
---|
371 | 2005 | |
---|
372 | 2006 | cam.hAspect = -1; // Read only |
---|
373 | 2007 | |
---|
.. | .. |
---|
398 | 2032 | { |
---|
399 | 2033 | //System.err.println("Oeil on"); |
---|
400 | 2034 | TRACK = true; |
---|
401 | | -// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 2035 | +// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
402 | 2036 | // object.editWindow.ScreenFit(trackedobject); |
---|
403 | 2037 | //pingthread.StepToTarget(true); |
---|
404 | 2038 | } |
---|
.. | .. |
---|
407 | 2041 | { |
---|
408 | 2042 | //System.err.println("Oeil on"); |
---|
409 | 2043 | OEIL = true; |
---|
410 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 2044 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
411 | 2045 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
412 | 2046 | //pingthread.StepToTarget(true); |
---|
413 | 2047 | } |
---|
.. | .. |
---|
471 | 2105 | { |
---|
472 | 2106 | frozen ^= true; |
---|
473 | 2107 | // Weird... |
---|
474 | | - lighttouched = true; |
---|
| 2108 | + Globals.lighttouched = true; |
---|
475 | 2109 | } |
---|
476 | 2110 | |
---|
477 | 2111 | void ToggleDL() |
---|
478 | 2112 | { |
---|
479 | 2113 | mainDL ^= true; |
---|
480 | | - } |
---|
481 | | - |
---|
482 | | - void ToggleTexture() |
---|
483 | | - { |
---|
484 | | - textureon ^= true; |
---|
485 | | - } |
---|
486 | | - |
---|
487 | | - void ToggleLive() |
---|
488 | | - { |
---|
489 | | - setLIVE(isLIVE() ^ true); |
---|
490 | | - |
---|
491 | | - System.err.println("LIVE = " + isLIVE()); |
---|
492 | | - |
---|
493 | | - if (!isLIVE()) // save sound |
---|
494 | | - GrafreeD.savesound = true; // wav.save(); |
---|
495 | | - // else |
---|
496 | | - repaint(); // start loop // may 2013 |
---|
497 | | - } |
---|
498 | | - |
---|
499 | | - void ToggleSupport() |
---|
500 | | - { |
---|
501 | | - SUPPORT ^= true; |
---|
502 | | - } |
---|
503 | | - |
---|
504 | | - void ToggleAbort() |
---|
505 | | - { |
---|
506 | | - ABORTMODE ^= true; |
---|
507 | 2114 | } |
---|
508 | 2115 | |
---|
509 | 2116 | void ToggleFullScreen() |
---|
.. | .. |
---|
513 | 2120 | |
---|
514 | 2121 | void ToggleCrowd() |
---|
515 | 2122 | { |
---|
516 | | - CROWD ^= true; |
---|
517 | | - } |
---|
518 | | - |
---|
519 | | - void ToggleInertia() |
---|
520 | | - { |
---|
521 | | - INERTIA ^= true; |
---|
| 2123 | + Globals.CROWD ^= true; |
---|
522 | 2124 | } |
---|
523 | 2125 | |
---|
524 | 2126 | void ToggleLocal() |
---|
.. | .. |
---|
526 | 2128 | LOCALTRANSFORM ^= true; |
---|
527 | 2129 | } |
---|
528 | 2130 | |
---|
529 | | - void ToggleFast() |
---|
| 2131 | + public void ToggleTexture() |
---|
| 2132 | + { |
---|
| 2133 | + textureon ^= true; |
---|
| 2134 | + } |
---|
| 2135 | + |
---|
| 2136 | + public void ToggleLive() |
---|
| 2137 | + { |
---|
| 2138 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
| 2139 | + |
---|
| 2140 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
| 2141 | + |
---|
| 2142 | + if (!Globals.isLIVE()) // save sound |
---|
| 2143 | + GrafreeD.savesound = true; // wav.save(); |
---|
| 2144 | + // else |
---|
| 2145 | + repaint(); // start loop // may 2013 |
---|
| 2146 | + } |
---|
| 2147 | + |
---|
| 2148 | + public void ToggleSupport() |
---|
| 2149 | + { |
---|
| 2150 | + SUPPORT ^= true; |
---|
| 2151 | + } |
---|
| 2152 | + |
---|
| 2153 | + public void ToggleAbort() |
---|
| 2154 | + { |
---|
| 2155 | + ABORTMODE ^= true; |
---|
| 2156 | + } |
---|
| 2157 | + |
---|
| 2158 | + public void ToggleInertia() |
---|
| 2159 | + { |
---|
| 2160 | + INERTIA ^= true; |
---|
| 2161 | + } |
---|
| 2162 | + |
---|
| 2163 | + public void ToggleFast() |
---|
530 | 2164 | { |
---|
531 | 2165 | FAST ^= true; |
---|
532 | 2166 | } |
---|
533 | 2167 | |
---|
534 | | - void ToggleSlowPose() |
---|
| 2168 | + public void ToggleSlowPose() |
---|
535 | 2169 | { |
---|
536 | 2170 | SLOWPOSE ^= true; |
---|
537 | 2171 | } |
---|
538 | 2172 | |
---|
539 | | - void ToggleFootContact() |
---|
540 | | - { |
---|
541 | | - FOOTCONTACT ^= true; |
---|
542 | | - } |
---|
543 | | - |
---|
544 | | - void ToggleBoxMode() |
---|
| 2173 | + public void ToggleBoxMode() |
---|
545 | 2174 | { |
---|
546 | 2175 | BOXMODE ^= true; |
---|
547 | 2176 | } |
---|
548 | 2177 | |
---|
549 | | - void ToggleSmoothFocus() |
---|
| 2178 | + public void ToggleZoomBoxMode() |
---|
| 2179 | + { |
---|
| 2180 | + ZOOMBOXMODE ^= true; |
---|
| 2181 | + } |
---|
| 2182 | + |
---|
| 2183 | + public void ToggleSmoothFocus() |
---|
550 | 2184 | { |
---|
551 | 2185 | SMOOTHFOCUS ^= true; |
---|
552 | 2186 | } |
---|
553 | 2187 | |
---|
554 | | - void ToggleImageFlip() |
---|
| 2188 | + public void ToggleImageFlip() |
---|
555 | 2189 | { |
---|
556 | 2190 | IMAGEFLIP ^= true; |
---|
557 | 2191 | } |
---|
558 | 2192 | |
---|
559 | | - void ToggleSpeakerMocap() |
---|
| 2193 | + public void ToggleSpeakerMocap() |
---|
560 | 2194 | { |
---|
561 | 2195 | SPEAKERMOCAP ^= true; |
---|
562 | 2196 | } |
---|
563 | 2197 | |
---|
564 | | - void ToggleSpeakerCamera() |
---|
| 2198 | + public void ToggleSpeakerCamera() |
---|
565 | 2199 | { |
---|
566 | 2200 | SPEAKERCAMERA ^= true; |
---|
567 | 2201 | } |
---|
568 | 2202 | |
---|
569 | | - void ToggleSpeakerFocus() |
---|
| 2203 | + public void ToggleSpeakerFocus() |
---|
570 | 2204 | { |
---|
571 | 2205 | SPEAKERFOCUS ^= true; |
---|
572 | 2206 | } |
---|
573 | 2207 | |
---|
574 | | - void ToggleDebug() |
---|
575 | | - { |
---|
576 | | - DEBUG ^= true; |
---|
577 | | - } |
---|
578 | | - |
---|
579 | | - void ToggleFrustum() |
---|
| 2208 | + public void ToggleFrustum() |
---|
580 | 2209 | { |
---|
581 | 2210 | FRUSTUM ^= true; |
---|
582 | 2211 | } |
---|
583 | 2212 | |
---|
584 | | - void ToggleTrack() |
---|
| 2213 | + public void ToggleTrack() |
---|
585 | 2214 | { |
---|
586 | 2215 | TRACK ^= true; |
---|
587 | 2216 | if (TRACK) |
---|
.. | .. |
---|
600 | 2229 | repaint(); |
---|
601 | 2230 | } |
---|
602 | 2231 | |
---|
603 | | - void ToggleTrackOnce() |
---|
| 2232 | + public void ToggleTrackOnce() |
---|
604 | 2233 | { |
---|
605 | 2234 | TRACKONCE ^= true; |
---|
606 | 2235 | } |
---|
607 | 2236 | |
---|
608 | | - void ToggleShadowTrack() |
---|
| 2237 | + public void ToggleShadowTrack() |
---|
609 | 2238 | { |
---|
610 | 2239 | SHADOWTRACK ^= true; |
---|
611 | 2240 | repaint(); |
---|
612 | 2241 | } |
---|
613 | 2242 | |
---|
614 | | - void ToggleOeil() |
---|
| 2243 | + public void ToggleOeil() |
---|
615 | 2244 | { |
---|
616 | 2245 | OEIL ^= true; |
---|
617 | 2246 | } |
---|
618 | 2247 | |
---|
619 | | - void ToggleOeilOnce() |
---|
| 2248 | + public void ToggleOeilOnce() |
---|
620 | 2249 | { |
---|
621 | 2250 | OEILONCE ^= true; |
---|
| 2251 | + } |
---|
| 2252 | + |
---|
| 2253 | + void ToggleFootContact() |
---|
| 2254 | + { |
---|
| 2255 | + FOOTCONTACT ^= true; |
---|
| 2256 | + } |
---|
| 2257 | + |
---|
| 2258 | + void ToggleDebug() |
---|
| 2259 | + { |
---|
| 2260 | + DEBUG ^= true; |
---|
622 | 2261 | } |
---|
623 | 2262 | |
---|
624 | 2263 | void ToggleLookAt() |
---|
.. | .. |
---|
628 | 2267 | |
---|
629 | 2268 | void ToggleRandom() |
---|
630 | 2269 | { |
---|
631 | | - RANDOM ^= true; |
---|
| 2270 | + SWITCH ^= true; |
---|
632 | 2271 | } |
---|
633 | 2272 | |
---|
634 | 2273 | void ToggleHandles() |
---|
.. | .. |
---|
672 | 2311 | //assert (cam.hAspect == 0); |
---|
673 | 2312 | cam.hAspect = 0; |
---|
674 | 2313 | 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 | 2314 | } |
---|
704 | 2315 | |
---|
705 | 2316 | private static void ApplyTransform(GL gl, Mat4f xform) |
---|
.. | .. |
---|
759 | 2370 | |
---|
760 | 2371 | GL currentGL; |
---|
761 | 2372 | |
---|
762 | | - GL GetGL() |
---|
| 2373 | + public GL GetGL() // INTERFACE |
---|
763 | 2374 | { |
---|
764 | 2375 | return currentGL; |
---|
765 | 2376 | } |
---|
.. | .. |
---|
2595 | 4206 | |
---|
2596 | 4207 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
2597 | 4208 | { |
---|
| 4209 | + new Exception().printStackTrace(); |
---|
2598 | 4210 | System.exit(0); |
---|
2599 | 4211 | com.sun.opengl.util.texture.Texture texture = null; |
---|
2600 | 4212 | |
---|
.. | .. |
---|
6271 | 7883 | return null; |
---|
6272 | 7884 | } |
---|
6273 | 7885 | |
---|
6274 | | - void ReleaseTextures(cTexture tex) |
---|
| 7886 | + public void ReleaseTextures(cTexture tex) // INTERFACE |
---|
6275 | 7887 | { |
---|
6276 | 7888 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6277 | 7889 | { |
---|
.. | .. |
---|
6309 | 7921 | |
---|
6310 | 7922 | void ReleaseTexture(String tex, boolean bump) |
---|
6311 | 7923 | { |
---|
6312 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 7924 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6313 | 7925 | ambientOcclusion ) // || !textureon) |
---|
6314 | 7926 | { |
---|
6315 | 7927 | return; |
---|
.. | .. |
---|
6410 | 8022 | } |
---|
6411 | 8023 | } |
---|
6412 | 8024 | |
---|
6413 | | - /*boolean*/ void BindTextures(cTexture tex, int resolution) |
---|
| 8025 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
6414 | 8026 | { |
---|
6415 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 8027 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6416 | 8028 | ambientOcclusion ) // || !textureon) |
---|
6417 | 8029 | { |
---|
6418 | 8030 | return; // false; |
---|
.. | .. |
---|
6463 | 8075 | { |
---|
6464 | 8076 | String texname = tex; |
---|
6465 | 8077 | |
---|
6466 | | - String[] split = tex.split("Textures"); |
---|
6467 | | - if (split.length > 1) |
---|
6468 | | - texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
6469 | | - else |
---|
6470 | | - if (!texname.startsWith("/")) |
---|
6471 | | - texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8078 | +// String[] split = tex.split("Textures"); |
---|
| 8079 | +// if (split.length > 1) |
---|
| 8080 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8081 | +// else |
---|
| 8082 | +// if (!texname.startsWith("/")) |
---|
| 8083 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8084 | + if (!new File(tex).exists()) |
---|
| 8085 | + { |
---|
| 8086 | + texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname; |
---|
| 8087 | + } |
---|
6472 | 8088 | |
---|
6473 | 8089 | if (CACHETEXTURE) |
---|
6474 | 8090 | texture = textures.get(texname); // TEXTURE CACHE |
---|
.. | .. |
---|
6708 | 8324 | return texture!=null?texture.texture:null; |
---|
6709 | 8325 | } |
---|
6710 | 8326 | |
---|
6711 | | - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8327 | + public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
6712 | 8328 | { |
---|
6713 | 8329 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
6714 | 8330 | |
---|
.. | .. |
---|
7312 | 8928 | static boolean occlusionInitialized = false; |
---|
7313 | 8929 | boolean selection = false; |
---|
7314 | 8930 | boolean pointselection = false; |
---|
7315 | | - /*static*/ boolean lighttouched = true; |
---|
| 8931 | + ///*static*/ boolean lighttouched = true; |
---|
7316 | 8932 | boolean deselect; |
---|
7317 | | - boolean ambientOcclusion = false; |
---|
| 8933 | + private boolean ambientOcclusion = false; |
---|
7318 | 8934 | static boolean flash = false; |
---|
7319 | 8935 | /*static*/ boolean wait = false; |
---|
7320 | 8936 | boolean displaydone = false; // after repaint() calls |
---|
.. | .. |
---|
7444 | 9060 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
7445 | 9061 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
7446 | 9062 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 9063 | +// PATCH FILLE AUX JEANS |
---|
| 9064 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
7447 | 9065 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
7448 | 9066 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
7449 | 9067 | |
---|
.. | .. |
---|
7601 | 9219 | |
---|
7602 | 9220 | boolean restartframe = false; |
---|
7603 | 9221 | |
---|
7604 | | - static int framecount = 0; // general-purpose global count |
---|
7605 | | - |
---|
7606 | 9222 | void displayAntiAliased(javax.media.opengl.GL gl) |
---|
7607 | 9223 | { |
---|
7608 | 9224 | //gl.glGetIntegerv(gl.GL_ACCUM_RED_BITS, viewport, 0); |
---|
.. | .. |
---|
7633 | 9249 | gl.glClear(gl.GL_ACCUM_BUFFER_BIT); |
---|
7634 | 9250 | for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0) |
---|
7635 | 9251 | { |
---|
7636 | | - framecount++; |
---|
| 9252 | + Globals.framecount++; |
---|
7637 | 9253 | |
---|
7638 | 9254 | if (CameraPane.tickcount > 0) |
---|
7639 | 9255 | CameraPane.tickcount--; |
---|
.. | .. |
---|
7671 | 9287 | |
---|
7672 | 9288 | gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0); |
---|
7673 | 9289 | */ |
---|
7674 | | - lighttouched = true; |
---|
| 9290 | + Globals.lighttouched = true; |
---|
7675 | 9291 | //System.err.println(" shadowbuffer: " + jitter); |
---|
7676 | 9292 | shadowbuffer.display(); |
---|
7677 | 9293 | |
---|
.. | .. |
---|
7693 | 9309 | |
---|
7694 | 9310 | if (renderCamera != lightCamera) |
---|
7695 | 9311 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7696 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 9312 | + LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
7697 | 9313 | |
---|
7698 | 9314 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
7699 | 9315 | |
---|
.. | .. |
---|
7709 | 9325 | |
---|
7710 | 9326 | if (renderCamera != lightCamera) |
---|
7711 | 9327 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7712 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 9328 | + LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
7713 | 9329 | |
---|
7714 | 9330 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
7715 | 9331 | |
---|
.. | .. |
---|
7781 | 9397 | //gl.glFlush(); |
---|
7782 | 9398 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
7783 | 9399 | |
---|
7784 | | - if (ANIMATION && ABORTED) |
---|
| 9400 | + if (Globals.ANIMATION && ABORTED) |
---|
7785 | 9401 | { |
---|
7786 | 9402 | System.err.println(" ABORTED FRAME"); |
---|
7787 | 9403 | break; |
---|
.. | .. |
---|
7811 | 9427 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
7812 | 9428 | |
---|
7813 | 9429 | // save image |
---|
7814 | | - if (ANIMATION && !ABORTED) |
---|
| 9430 | + if (Globals.ANIMATION && !ABORTED) |
---|
7815 | 9431 | { |
---|
7816 | 9432 | VPwidth = viewport[2]; |
---|
7817 | 9433 | VPheight = viewport[3]; |
---|
.. | .. |
---|
7922 | 9538 | |
---|
7923 | 9539 | // imagecount++; |
---|
7924 | 9540 | |
---|
7925 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9541 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
7926 | 9542 | |
---|
7927 | 9543 | if (!BOXMODE) |
---|
7928 | 9544 | { |
---|
.. | .. |
---|
8618 | 10234 | } |
---|
8619 | 10235 | } |
---|
8620 | 10236 | |
---|
8621 | | - boolean IsFrozen() |
---|
8622 | | - { |
---|
8623 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
8624 | | - |
---|
8625 | | - return !selectmode && cameracount == 0; // != 0; |
---|
8626 | | - } |
---|
8627 | | - |
---|
8628 | 10237 | boolean niceon = false; |
---|
8629 | 10238 | javax.swing.Timer AAtimer = new javax.swing.Timer(750, this); |
---|
8630 | 10239 | boolean currentlydrawing = false; |
---|
.. | .. |
---|
8642 | 10251 | } |
---|
8643 | 10252 | // if (DEBUG_SELECTION) |
---|
8644 | 10253 | // { |
---|
8645 | | -// if (drawMode != SELECTION) |
---|
8646 | | -// drawMode = SELECTION; |
---|
| 10254 | +// if (DrawMode() != SELECTION) |
---|
| 10255 | +// DrawMode() = SELECTION; |
---|
8647 | 10256 | // } |
---|
8648 | 10257 | |
---|
8649 | 10258 | if (!isRenderer) |
---|
.. | .. |
---|
8699 | 10308 | |
---|
8700 | 10309 | //ANTIALIAS = 0; |
---|
8701 | 10310 | |
---|
8702 | | - if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
| 10311 | + if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
8703 | 10312 | { |
---|
8704 | | - if (niceon || isLIVE()) |
---|
| 10313 | + if (niceon || Globals.isLIVE()) |
---|
8705 | 10314 | { |
---|
8706 | 10315 | //if(active == 0) |
---|
8707 | 10316 | // antialiaser = null; |
---|
.. | .. |
---|
8726 | 10335 | assert eyeCamera.shaper_zFar == 1E5f; // 500.0f; |
---|
8727 | 10336 | */ |
---|
8728 | 10337 | |
---|
8729 | | - if (drawMode == DEFAULT) |
---|
| 10338 | + if (DrawMode() == DEFAULT) |
---|
8730 | 10339 | { |
---|
8731 | 10340 | currentlydrawing = true; |
---|
8732 | 10341 | } |
---|
.. | .. |
---|
8757 | 10366 | |
---|
8758 | 10367 | // if(Applet3D.clipboard != null) |
---|
8759 | 10368 | // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent); |
---|
8760 | | -//drawMode = SELECTION; |
---|
| 10369 | +//DrawMode() = SELECTION; |
---|
8761 | 10370 | indexcount = 0; |
---|
8762 | 10371 | |
---|
8763 | | - if (drawMode == OCCLUSION) |
---|
| 10372 | + if (DrawMode() == OCCLUSION) |
---|
8764 | 10373 | { |
---|
8765 | | - drawMode = DEFAULT; |
---|
| 10374 | + Globals.drawMode = DEFAULT; // WARNING |
---|
8766 | 10375 | ambientOcclusion = true; |
---|
8767 | 10376 | setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
---|
8768 | 10377 | Object3D theobject = object; |
---|
.. | .. |
---|
8781 | 10390 | ambientOcclusion = false; |
---|
8782 | 10391 | } |
---|
8783 | 10392 | |
---|
8784 | | - if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10393 | + if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
8785 | 10394 | { |
---|
8786 | 10395 | //if (RENDERSHADOW) // ? |
---|
8787 | 10396 | if (!IsFrozen()) |
---|
8788 | 10397 | { |
---|
8789 | 10398 | // dec 2012 |
---|
8790 | | - if (!ambientOcclusion && !(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)) |
---|
| 10399 | + if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
8791 | 10400 | { |
---|
8792 | | - framecount++; |
---|
| 10401 | + Globals.framecount++; |
---|
8793 | 10402 | shadowbuffer.display(); |
---|
8794 | 10403 | } |
---|
8795 | 10404 | } |
---|
8796 | | - lighttouched = false; // ?? |
---|
| 10405 | + Globals.lighttouched = false; // ?? |
---|
8797 | 10406 | //drawing = true; |
---|
8798 | 10407 | //lighttouched = true; |
---|
8799 | 10408 | } |
---|
.. | .. |
---|
8814 | 10423 | //eyeCamera.shaper_fovy = 1; |
---|
8815 | 10424 | } |
---|
8816 | 10425 | |
---|
8817 | | - if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION) |
---|
| 10426 | + if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION) |
---|
8818 | 10427 | { |
---|
8819 | | - //System.out.println("drawMode = " + drawMode); |
---|
| 10428 | + //System.out.println("DrawMode() = " + DrawMode()); |
---|
8820 | 10429 | vertexMode |= VP_PASS; |
---|
8821 | 10430 | //vertexMode |= VP_PROJECTION; |
---|
8822 | 10431 | if (!ambientOcclusion) |
---|
.. | .. |
---|
8876 | 10485 | Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera; |
---|
8877 | 10486 | //Camera lightcam = new Camera(light0); |
---|
8878 | 10487 | |
---|
8879 | | - if (drawMode == SHADOW) |
---|
| 10488 | + if (DrawMode() == SHADOW) |
---|
8880 | 10489 | { |
---|
8881 | 10490 | /* |
---|
8882 | 10491 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
.. | .. |
---|
8915 | 10524 | // if (parentcam != renderCamera) // not a light |
---|
8916 | 10525 | if (cam != lightCamera) |
---|
8917 | 10526 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8918 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 10527 | + LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
8919 | 10528 | |
---|
8920 | 10529 | for (int j = 0; j < 4; j++) |
---|
8921 | 10530 | { |
---|
.. | .. |
---|
8930 | 10539 | // if (parentcam != renderCamera) // not a light |
---|
8931 | 10540 | if (cam != lightCamera) |
---|
8932 | 10541 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8933 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 10542 | + LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
8934 | 10543 | |
---|
8935 | 10544 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
8936 | 10545 | |
---|
.. | .. |
---|
8966 | 10575 | gl.glClear(gl.GL_DEPTH_BUFFER_BIT); |
---|
8967 | 10576 | } else |
---|
8968 | 10577 | { |
---|
8969 | | - if (drawMode != DEFAULT) |
---|
| 10578 | + if (DrawMode() != DEFAULT) |
---|
8970 | 10579 | { |
---|
8971 | 10580 | gl.glClearColor(1, 1, 1, 0); |
---|
8972 | 10581 | } // 1); |
---|
.. | .. |
---|
9031 | 10640 | |
---|
9032 | 10641 | fast &= !ambientOcclusion; |
---|
9033 | 10642 | |
---|
9034 | | - if (drawMode == DEFAULT) |
---|
| 10643 | + if (DrawMode() == DEFAULT) |
---|
9035 | 10644 | { |
---|
9036 | 10645 | //gl.glEnable(gl.GL_ALPHA_TEST); |
---|
9037 | 10646 | //gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
.. | .. |
---|
9092 | 10701 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
9093 | 10702 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9094 | 10703 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 10704 | +// PATCH FILLE AUX JEANS |
---|
| 10705 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9095 | 10706 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9096 | 10707 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9097 | 10708 | |
---|
.. | .. |
---|
9227 | 10838 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
9228 | 10839 | gl.glLoadIdentity(); |
---|
9229 | 10840 | |
---|
9230 | | - if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
| 10841 | + if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
9231 | 10842 | { |
---|
9232 | 10843 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9233 | 10844 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 10845 | +// PATCH FILLE AUX JEANS |
---|
| 10846 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9234 | 10847 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9235 | 10848 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9236 | 10849 | //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE); |
---|
.. | .. |
---|
9283 | 10896 | //gl.glPushMatrix(); |
---|
9284 | 10897 | gl.glLoadIdentity(); |
---|
9285 | 10898 | |
---|
9286 | | - if (!ambientOcclusion) // drawMode != OCCLUSION) |
---|
| 10899 | + if (!ambientOcclusion) // DrawMode() != OCCLUSION) |
---|
9287 | 10900 | { |
---|
9288 | 10901 | //LA.xformPos(light0, lightCamera.fromScreen, light); |
---|
9289 | 10902 | LA.xformDir(dirlight, lightCamera.fromScreen, lightposition); |
---|
.. | .. |
---|
9370 | 10983 | } |
---|
9371 | 10984 | |
---|
9372 | 10985 | /**/ |
---|
9373 | | - if (true) // drawMode == SELECTION) // != DEFAULT) |
---|
| 10986 | + if (true) // DrawMode() == SELECTION) // != DEFAULT) |
---|
9374 | 10987 | gl.glDisable(gl.GL_LIGHTING); |
---|
9375 | 10988 | else |
---|
9376 | 10989 | gl.glEnable(gl.GL_LIGHTING); |
---|
.. | .. |
---|
9388 | 11001 | |
---|
9389 | 11002 | lightslot = 64; |
---|
9390 | 11003 | |
---|
9391 | | - if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT) |
---|
| 11004 | + if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT) |
---|
9392 | 11005 | { |
---|
9393 | 11006 | DrawLights(object); |
---|
9394 | 11007 | } |
---|
.. | .. |
---|
9399 | 11012 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
9400 | 11013 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
9401 | 11014 | |
---|
9402 | | - if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION) |
---|
| 11015 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
9403 | 11016 | { |
---|
9404 | 11017 | /* |
---|
9405 | 11018 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
9432 | 11045 | } |
---|
9433 | 11046 | } |
---|
9434 | 11047 | |
---|
9435 | | - if (drawMode == DEFAULT) |
---|
| 11048 | + if (DrawMode() == DEFAULT) |
---|
9436 | 11049 | { |
---|
9437 | 11050 | if (WIREFRAME && !ambientOcclusion) |
---|
9438 | 11051 | { |
---|
.. | .. |
---|
9450 | 11063 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9451 | 11064 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9452 | 11065 | |
---|
9453 | | - if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) // |
---|
| 11066 | + if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) // |
---|
9454 | 11067 | { |
---|
9455 | 11068 | if (vertexMode != 0) // && !fast) |
---|
9456 | 11069 | { |
---|
.. | .. |
---|
9470 | 11083 | } |
---|
9471 | 11084 | } |
---|
9472 | 11085 | |
---|
9473 | | - if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion) |
---|
| 11086 | + if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
9474 | 11087 | { |
---|
9475 | 11088 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
9476 | 11089 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
9498 | 11111 | //gl.glDepthMask(false); |
---|
9499 | 11112 | } |
---|
9500 | 11113 | |
---|
9501 | | - if (false) // drawMode == SHADOW) |
---|
| 11114 | + if (false) // DrawMode() == SHADOW) |
---|
9502 | 11115 | { |
---|
9503 | 11116 | //SetColumnMajorData(cameraInverseTransform, view_1); |
---|
9504 | 11117 | //System.out.println("light = " + cameraInverseTransform); |
---|
.. | .. |
---|
9512 | 11125 | //System.out.println("object = " + object); |
---|
9513 | 11126 | if (!frozen && !imageLocked) |
---|
9514 | 11127 | { |
---|
9515 | | - if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0) |
---|
| 11128 | + if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0) |
---|
9516 | 11129 | { |
---|
9517 | 11130 | displayAntiAliased(gl); |
---|
9518 | 11131 | } else |
---|
9519 | 11132 | { |
---|
9520 | 11133 | programcount = 0; |
---|
9521 | | - int keepmode = drawMode; |
---|
| 11134 | + int keepmode = DrawMode(); |
---|
9522 | 11135 | // if (DEBUG_SELECTION) |
---|
9523 | 11136 | // { |
---|
9524 | | -// drawMode = SELECTION; |
---|
| 11137 | +// DrawMode() = SELECTION; |
---|
9525 | 11138 | // } |
---|
9526 | 11139 | // for point selection |
---|
9527 | 11140 | // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0); |
---|
.. | .. |
---|
9531 | 11144 | DrawObject(gl); |
---|
9532 | 11145 | |
---|
9533 | 11146 | // jan 2013 System.err.println("RESET ABORT (display)"); |
---|
9534 | | - // if (drawMode == DEFAULT) |
---|
| 11147 | + // if (DrawMode() == DEFAULT) |
---|
9535 | 11148 | // ABORTED = false; |
---|
9536 | 11149 | fullreset = false; |
---|
9537 | | - drawMode = keepmode; |
---|
| 11150 | + Globals.drawMode = keepmode; // WARNING |
---|
9538 | 11151 | //System.out.println("PROGRAM SWITCH " + programcount); |
---|
9539 | 11152 | } |
---|
9540 | 11153 | } |
---|
.. | .. |
---|
9542 | 11155 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9543 | 11156 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9544 | 11157 | |
---|
9545 | | - if (drawMode == DEFAULT) |
---|
| 11158 | + if (DrawMode() == DEFAULT) |
---|
9546 | 11159 | { |
---|
9547 | 11160 | ReleaseTexture(NOISE_TEXTURE, false); |
---|
9548 | 11161 | } |
---|
9549 | | - //if (drawMode == DEFAULT) |
---|
| 11162 | + //if (DrawMode() == DEFAULT) |
---|
9550 | 11163 | { |
---|
9551 | 11164 | |
---|
9552 | 11165 | gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
.. | .. |
---|
9558 | 11171 | //else |
---|
9559 | 11172 | //gl.glDisable(gl.GL_TEXTURE_2D); |
---|
9560 | 11173 | //gl.glPopMatrix(); |
---|
9561 | | - if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
| 11174 | + if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
9562 | 11175 | { |
---|
9563 | 11176 | //new Exception().printStackTrace(); |
---|
9564 | 11177 | //System.out.println("Draw image " + width + ", " + height); |
---|
.. | .. |
---|
9600 | 11213 | //gl.glFlush(); |
---|
9601 | 11214 | } |
---|
9602 | 11215 | |
---|
9603 | | - if (flash && drawMode == DEFAULT) |
---|
| 11216 | + if (flash && DrawMode() == DEFAULT) |
---|
9604 | 11217 | { |
---|
9605 | 11218 | flash = false; |
---|
9606 | 11219 | wait = true; |
---|
.. | .. |
---|
9608 | 11221 | } |
---|
9609 | 11222 | |
---|
9610 | 11223 | //drawing = false; |
---|
9611 | | - //if(drawMode == DEFAULT) |
---|
| 11224 | + //if(DrawMode() == DEFAULT) |
---|
9612 | 11225 | // niceon = false; |
---|
9613 | | - if (drawMode == DEFAULT) |
---|
| 11226 | + if (DrawMode() == DEFAULT) |
---|
9614 | 11227 | { |
---|
9615 | 11228 | currentlydrawing = false; |
---|
9616 | 11229 | } |
---|
.. | .. |
---|
9630 | 11243 | repaint(); |
---|
9631 | 11244 | } |
---|
9632 | 11245 | |
---|
9633 | | - if (isLIVE() && drawMode == DEFAULT) // may 2013 |
---|
| 11246 | + if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 |
---|
9634 | 11247 | repaint(); |
---|
9635 | 11248 | |
---|
9636 | 11249 | displaydone = true; |
---|
.. | .. |
---|
9649 | 11262 | { |
---|
9650 | 11263 | renderpass++; |
---|
9651 | 11264 | // System.out.println("Draw object... "); |
---|
| 11265 | + STEP = 1; |
---|
9652 | 11266 | if (FAST) // in case there is no script |
---|
9653 | | - STEP = 16; |
---|
| 11267 | + STEP = 8; |
---|
| 11268 | + |
---|
| 11269 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11270 | + { |
---|
| 11271 | + STEP *= 4; |
---|
| 11272 | + } |
---|
9654 | 11273 | |
---|
9655 | 11274 | //object.FullInvariants(); |
---|
9656 | 11275 | |
---|
.. | .. |
---|
9667 | 11286 | if (GrafreeD.RENDERME > 0) |
---|
9668 | 11287 | GrafreeD.RENDERME--; // mechante magouille |
---|
9669 | 11288 | |
---|
9670 | | - ONESTEP = false; |
---|
| 11289 | + Globals.ONESTEP = false; |
---|
9671 | 11290 | } |
---|
9672 | 11291 | |
---|
9673 | 11292 | static boolean zoomonce = false; |
---|
.. | .. |
---|
9675 | 11294 | void DrawObject(GL gl, boolean draw) |
---|
9676 | 11295 | { |
---|
9677 | 11296 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
9678 | | -// drawMode = SELECTION; |
---|
| 11297 | +// DrawMode() = SELECTION; |
---|
9679 | 11298 | //GL gl = getGL(); |
---|
9680 | 11299 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
9681 | 11300 | { |
---|
9682 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 11301 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
9683 | 11302 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
9684 | 11303 | pingthread.StepToTarget(true); // true); |
---|
9685 | 11304 | // zoomonce = false; |
---|
.. | .. |
---|
9700 | 11319 | callist = gl.glGenLists(1); |
---|
9701 | 11320 | } |
---|
9702 | 11321 | |
---|
9703 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11322 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
9704 | 11323 | |
---|
9705 | | - boolean active = !selectmode; // drawMode != SELECTION; // mouseDown; |
---|
| 11324 | + boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
9706 | 11325 | |
---|
9707 | 11326 | if (!mainDL || !active || touched) |
---|
9708 | 11327 | { |
---|
.. | .. |
---|
9729 | 11348 | PushMatrix(ClickInfo.matbuffer); |
---|
9730 | 11349 | } |
---|
9731 | 11350 | |
---|
9732 | | - if (drawMode == 0) |
---|
| 11351 | + if (DrawMode() == 0) |
---|
9733 | 11352 | { |
---|
9734 | 11353 | // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++"); |
---|
9735 | 11354 | |
---|
.. | .. |
---|
9743 | 11362 | // DRAW |
---|
9744 | 11363 | object.draw(this, /*(Composite)*/ object, false, false); |
---|
9745 | 11364 | |
---|
9746 | | - if (drawMode == DEFAULT) |
---|
| 11365 | + if (DrawMode() == DEFAULT) |
---|
9747 | 11366 | { |
---|
9748 | 11367 | if (DEBUG) |
---|
9749 | 11368 | { |
---|
.. | .. |
---|
9754 | 11373 | selectedpoint.radius = radius; |
---|
9755 | 11374 | selectedpoint.recalculate(); |
---|
9756 | 11375 | selectedpoint.material = new cMaterial(); |
---|
9757 | | - selectedpoint.material.color = 0.25f; |
---|
| 11376 | + selectedpoint.material.color = 0.15f; // Yellow |
---|
9758 | 11377 | selectedpoint.material.modulation = 0.75f; |
---|
9759 | 11378 | |
---|
9760 | | - debugpoint.radius = radius; |
---|
9761 | | - debugpoint.recalculate(); |
---|
9762 | | - debugpoint.material = new cMaterial(); |
---|
9763 | | - debugpoint.material.color = 0.25f; |
---|
9764 | | - debugpoint.material.modulation = 0.75f; |
---|
| 11379 | + debugpointG.radius = radius; |
---|
| 11380 | + debugpointG.recalculate(); |
---|
| 11381 | + debugpointG.material = new cMaterial(); |
---|
| 11382 | + debugpointG.material.color = 0.25f; // Green |
---|
| 11383 | + debugpointG.material.modulation = 0.75f; |
---|
9765 | 11384 | |
---|
9766 | | - debugpoint2.radius = radius; |
---|
9767 | | - debugpoint2.recalculate(); |
---|
9768 | | - debugpoint2.material = new cMaterial(); |
---|
9769 | | - debugpoint2.material.color = 0.75f; |
---|
9770 | | - debugpoint2.material.modulation = 0.75f; |
---|
| 11385 | + debugpointP.radius = radius; |
---|
| 11386 | + debugpointP.recalculate(); |
---|
| 11387 | + debugpointP.material = new cMaterial(); |
---|
| 11388 | + debugpointP.material.color = 0.75f; // Purple |
---|
| 11389 | + debugpointP.material.modulation = 0.75f; |
---|
9771 | 11390 | |
---|
9772 | | - debugpoint3.radius = radius; |
---|
9773 | | - debugpoint3.recalculate(); |
---|
9774 | | - debugpoint3.material = new cMaterial(); |
---|
9775 | | - debugpoint3.material.color = 0.5f; |
---|
9776 | | - debugpoint3.material.modulation = 0.75f; |
---|
| 11391 | + debugpointC.radius = radius; |
---|
| 11392 | + debugpointC.recalculate(); |
---|
| 11393 | + debugpointC.material = new cMaterial(); |
---|
| 11394 | + debugpointC.material.color = 0.5f; // Cyan |
---|
| 11395 | + debugpointC.material.modulation = 0.75f; |
---|
9777 | 11396 | |
---|
9778 | | - debugpoint4.radius = radius; |
---|
9779 | | - debugpoint4.recalculate(); |
---|
9780 | | - debugpoint4.material = new cMaterial(); |
---|
9781 | | - debugpoint4.material.color = 0f; |
---|
9782 | | - debugpoint4.material.modulation = 0.75f; |
---|
| 11397 | + debugpointR.radius = radius; |
---|
| 11398 | + debugpointR.recalculate(); |
---|
| 11399 | + debugpointR.material = new cMaterial(); |
---|
| 11400 | + debugpointR.material.color = 0f; // Red |
---|
| 11401 | + debugpointR.material.modulation = 0.75f; |
---|
9783 | 11402 | |
---|
9784 | 11403 | InitPoints(radius); |
---|
9785 | 11404 | } |
---|
9786 | 11405 | selectedpoint.draw(this, /*(Composite)*/ null, false, false); |
---|
9787 | | - debugpoint.draw(this, /*(Composite)*/ null, false,false); |
---|
9788 | | - debugpoint2.draw(this, /*(Composite)*/ null, false,false); |
---|
9789 | | - debugpoint3.draw(this, /*(Composite)*/ null, false,false); |
---|
9790 | | - debugpoint4.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11406 | + debugpointG.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11407 | + debugpointP.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11408 | + debugpointC.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11409 | + debugpointR.draw(this, /*(Composite)*/ null, false,false); |
---|
9791 | 11410 | // DrawPoints(this); |
---|
9792 | 11411 | } |
---|
9793 | 11412 | |
---|
.. | .. |
---|
9795 | 11414 | } |
---|
9796 | 11415 | // GrafreeD.traceoff(); |
---|
9797 | 11416 | //System.out.println(stackdepth); |
---|
9798 | | - if (drawMode == 0) |
---|
| 11417 | + if (DrawMode() == 0) |
---|
9799 | 11418 | { |
---|
9800 | 11419 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
9801 | 11420 | |
---|
.. | .. |
---|
9820 | 11439 | |
---|
9821 | 11440 | checker = null; |
---|
9822 | 11441 | |
---|
9823 | | - if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT) |
---|
| 11442 | + if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT) |
---|
9824 | 11443 | FindChecker(object); |
---|
9825 | 11444 | |
---|
9826 | | - if (checker != null && drawMode == DEFAULT) |
---|
| 11445 | + if (checker != null && DrawMode() == DEFAULT) |
---|
9827 | 11446 | { |
---|
9828 | | - // BindTexture(IMMORTAL_TEXTURE); |
---|
| 11447 | + //BindTexture(IMMORTAL_TEXTURE); |
---|
| 11448 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
9829 | 11449 | // NEAREST |
---|
9830 | 11450 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
9831 | 11451 | DrawChecker(gl); |
---|
9832 | 11452 | //checker.Draw(this, null, false); |
---|
9833 | 11453 | // ReleaseTexture(IMMORTAL_TEXTURE); |
---|
| 11454 | + ReleaseTextures(checker.GetTextures()); |
---|
9834 | 11455 | } |
---|
9835 | 11456 | |
---|
9836 | 11457 | if (object.parent != null) |
---|
.. | .. |
---|
9843 | 11464 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9844 | 11465 | //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9845 | 11466 | |
---|
9846 | | - if (DISPLAYTEXT && drawMode == DEFAULT) |
---|
| 11467 | + if (DISPLAYTEXT && DrawMode() == DEFAULT) |
---|
9847 | 11468 | { |
---|
9848 | 11469 | // Draw it once, then use the raster |
---|
9849 | 11470 | Balloon(gl, balloon.createGraphics()); |
---|
.. | .. |
---|
9899 | 11520 | int[] xs = new int[3]; |
---|
9900 | 11521 | int[] ys = new int[3]; |
---|
9901 | 11522 | |
---|
9902 | | - void DrawString(Object3D obj) // String string) |
---|
| 11523 | + public void DrawString(Object3D obj) // String string) // INTERFACE |
---|
9903 | 11524 | { |
---|
9904 | | - if (!DISPLAYTEXT || drawMode != DEFAULT) |
---|
| 11525 | + if (!DISPLAYTEXT || DrawMode() != DEFAULT) |
---|
9905 | 11526 | { |
---|
9906 | 11527 | return; |
---|
9907 | 11528 | } |
---|
.. | .. |
---|
10388 | 12009 | "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" + |
---|
10389 | 12010 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
10390 | 12011 | "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" + |
---|
| 12012 | + "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" + |
---|
10391 | 12013 | "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" + |
---|
10392 | 12014 | "PARAM c256 = { 256, 256, 256, 1.0 };" + |
---|
10393 | 12015 | "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" + |
---|
.. | .. |
---|
10985 | 12607 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
10986 | 12608 | |
---|
10987 | 12609 | "SUB temp.x, one.x, ndotl.x;" + |
---|
10988 | | - "ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
10989 | | - "ADD temp.y, one.y, options2.y;" + // sursurface |
---|
| 12610 | + // Tuning for default skin |
---|
| 12611 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 12612 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 12613 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
10990 | 12614 | "MUL temp.x, temp.x, temp.y;" + |
---|
10991 | 12615 | |
---|
10992 | 12616 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
11134 | 12758 | "MUL final.y, fragment.texcoord[0].x, c256;" + |
---|
11135 | 12759 | "FLR final.x, final.y;" + |
---|
11136 | 12760 | "SUB final.y, final.y, final.x;" + |
---|
11137 | | - "MUL final.x, final.x, c256i;" + |
---|
| 12761 | + //"MUL final.x, final.x, c256i;" + |
---|
11138 | 12762 | "MOV final.z, zero.x;" + |
---|
11139 | 12763 | "MOV final.a, one.w;":"" |
---|
11140 | 12764 | ) + |
---|
.. | .. |
---|
11142 | 12766 | "MUL final.y, fragment.texcoord[0].y, c256;" + |
---|
11143 | 12767 | "FLR final.x, final.y;" + |
---|
11144 | 12768 | "SUB final.y, final.y, final.x;" + |
---|
11145 | | - "MUL final.x, final.x, c256i;" + |
---|
| 12769 | + //"MUL final.x, final.x, c256i;" + |
---|
11146 | 12770 | "MOV final.z, zero.x;" + |
---|
11147 | 12771 | "MOV final.a, one.w;":"" |
---|
11148 | 12772 | ) + |
---|
.. | .. |
---|
11302 | 12926 | String Shadow(String depth, String shadow) |
---|
11303 | 12927 | { |
---|
11304 | 12928 | return "MAX temp.x, ndotl.x, one64th.x;" + |
---|
| 12929 | + "MIN temp.x, temp.x, ninetenth.x;" + |
---|
11305 | 12930 | /**/ |
---|
11306 | 12931 | // Sine |
---|
11307 | 12932 | "MUL temp.y, temp.x, temp.x;" + |
---|
.. | .. |
---|
11921 | 13546 | |
---|
11922 | 13547 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
11923 | 13548 | |
---|
| 13549 | + if (BUTTONLESSWHEEL) |
---|
11924 | 13550 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
11925 | 13551 | { |
---|
11926 | 13552 | return; |
---|
11927 | 13553 | } |
---|
11928 | 13554 | |
---|
| 13555 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
11929 | 13556 | |
---|
11930 | 13557 | // TIMER |
---|
11931 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR |
---|
| 13558 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
11932 | 13559 | { |
---|
11933 | 13560 | keepboxmode = BOXMODE; |
---|
11934 | 13561 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
12057 | 13684 | // ObjEditor.tweenManager.update(1f / 60f); |
---|
12058 | 13685 | |
---|
12059 | 13686 | // fev 2014??? |
---|
12060 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode) |
---|
| 13687 | + if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
12061 | 13688 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
12062 | 13689 | pingthread.StepToTarget(true); // true); |
---|
12063 | 13690 | } |
---|
.. | .. |
---|
12145 | 13772 | |
---|
12146 | 13773 | public void mouseDragged(MouseEvent e) |
---|
12147 | 13774 | { |
---|
| 13775 | + //System.out.println("mouseDragged: " + e); |
---|
12148 | 13776 | if (isRenderer) |
---|
12149 | 13777 | movingcamera = true; |
---|
12150 | 13778 | //if (drawing) |
---|
12151 | 13779 | //return; |
---|
12152 | | - //System.out.println("mouseDragged: " + e); |
---|
12153 | 13780 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
12154 | 13781 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
12155 | 13782 | { |
---|
.. | .. |
---|
12169 | 13796 | cVector tmp = new cVector(); |
---|
12170 | 13797 | cVector tmp2 = new cVector(); |
---|
12171 | 13798 | boolean isMoving; |
---|
| 13799 | + |
---|
| 13800 | + public cVector TargetLookAt() |
---|
| 13801 | + { |
---|
| 13802 | + return targetLookAt; |
---|
| 13803 | + } |
---|
12172 | 13804 | |
---|
12173 | 13805 | class PingThread extends Thread |
---|
12174 | 13806 | { |
---|
.. | .. |
---|
12308 | 13940 | //System.out.println("---------------- ---------- Paint " + tmp.length2()); |
---|
12309 | 13941 | if (lightMode) |
---|
12310 | 13942 | { |
---|
12311 | | - lighttouched = true; |
---|
| 13943 | + Globals.lighttouched = true; |
---|
12312 | 13944 | } |
---|
12313 | 13945 | |
---|
12314 | 13946 | if (OEILONCE && OEIL) |
---|
.. | .. |
---|
12325 | 13957 | |
---|
12326 | 13958 | public void run() |
---|
12327 | 13959 | { |
---|
| 13960 | + new Exception().printStackTrace(); |
---|
12328 | 13961 | System.exit(0); |
---|
12329 | 13962 | for (;;) |
---|
12330 | 13963 | { |
---|
.. | .. |
---|
12366 | 13999 | mouseDown = false; |
---|
12367 | 14000 | if (lightMode) |
---|
12368 | 14001 | { |
---|
12369 | | - lighttouched = true; |
---|
| 14002 | + Globals.lighttouched = true; |
---|
12370 | 14003 | } |
---|
12371 | 14004 | repaint(); |
---|
12372 | 14005 | alreadypainted = true; |
---|
.. | .. |
---|
12374 | 14007 | isMoving = false; |
---|
12375 | 14008 | } //?? |
---|
12376 | 14009 | |
---|
12377 | | - if (isLIVE() && !alreadypainted) |
---|
| 14010 | + if (Globals.isLIVE() && !alreadypainted) |
---|
12378 | 14011 | { |
---|
12379 | 14012 | // FOR DEBUG BREAKPOINT USING PAUSE: while (true) |
---|
12380 | 14013 | repaint(); |
---|
.. | .. |
---|
12386 | 14019 | { |
---|
12387 | 14020 | if (lightMode) |
---|
12388 | 14021 | { |
---|
12389 | | - lighttouched = true; |
---|
| 14022 | + Globals.lighttouched = true; |
---|
12390 | 14023 | } |
---|
12391 | 14024 | drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
12392 | 14025 | } |
---|
.. | .. |
---|
12629 | 14262 | { |
---|
12630 | 14263 | manipCamera.Translate(dx, dy, getWidth()); |
---|
12631 | 14264 | } |
---|
| 14265 | + else |
---|
12632 | 14266 | if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0) |
---|
12633 | 14267 | { |
---|
12634 | 14268 | manipCamera.RotateInterest(dx, dy); |
---|
.. | .. |
---|
12639 | 14273 | |
---|
12640 | 14274 | if (manipCamera == lightCamera) |
---|
12641 | 14275 | { |
---|
12642 | | - lighttouched = true; |
---|
| 14276 | + Globals.lighttouched = true; |
---|
12643 | 14277 | } |
---|
12644 | 14278 | /* |
---|
12645 | 14279 | switch (mode) |
---|
.. | .. |
---|
12678 | 14312 | public void mouseMoved(MouseEvent e) |
---|
12679 | 14313 | { |
---|
12680 | 14314 | //System.out.println("mouseMoved: " + e); |
---|
12681 | | - |
---|
12682 | 14315 | if (isRenderer) |
---|
12683 | 14316 | return; |
---|
12684 | 14317 | |
---|
.. | .. |
---|
12862 | 14495 | } |
---|
12863 | 14496 | if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
12864 | 14497 | { |
---|
12865 | | - mouseMode |= SELECT; // BACKFORTH; |
---|
| 14498 | + mouseMode |= SELECT; |
---|
12866 | 14499 | } |
---|
12867 | 14500 | if ((modifiers & COMMAND) == COMMAND) |
---|
12868 | 14501 | { |
---|
.. | .. |
---|
12900 | 14533 | SetMouseMode(modifiers); |
---|
12901 | 14534 | } |
---|
12902 | 14535 | |
---|
12903 | | - theRenderer.keyPressed(key); |
---|
| 14536 | + Globals.theRenderer.keyPressed(key); |
---|
12904 | 14537 | } |
---|
12905 | 14538 | |
---|
12906 | 14539 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
12912 | 14545 | float SATPOW = 1; // 2; // 0.5f; |
---|
12913 | 14546 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
12914 | 14547 | |
---|
12915 | | - void keyPressed(int key) |
---|
| 14548 | + public void keyPressed(int key) |
---|
12916 | 14549 | { |
---|
12917 | 14550 | if (key >= '0' && key <= '5') |
---|
12918 | 14551 | clampbit = (key-'0'); |
---|
.. | .. |
---|
13027 | 14660 | case 'B': |
---|
13028 | 14661 | BRISMOOTH ^= true; |
---|
13029 | 14662 | SHADOWCULLFACE ^= true; |
---|
13030 | | - lighttouched = true; |
---|
| 14663 | + Globals.lighttouched = true; |
---|
13031 | 14664 | repaint(); |
---|
13032 | 14665 | break; |
---|
13033 | 14666 | case 'b': |
---|
.. | .. |
---|
13127 | 14760 | repaint(); |
---|
13128 | 14761 | break; |
---|
13129 | 14762 | case 'O': |
---|
13130 | | - drawMode = OCCLUSION; |
---|
| 14763 | + Globals.drawMode = OCCLUSION; // WARNING |
---|
13131 | 14764 | repaint(); |
---|
13132 | 14765 | break; |
---|
13133 | 14766 | case 'o': |
---|
.. | .. |
---|
13218 | 14851 | break; |
---|
13219 | 14852 | case ' ': |
---|
13220 | 14853 | lightMode ^= true; |
---|
13221 | | - lighttouched = true; |
---|
| 14854 | + Globals.lighttouched = true; |
---|
13222 | 14855 | manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
13223 | 14856 | targetLookAt.set(manipCamera.lookAt); |
---|
13224 | 14857 | repaint(); |
---|
.. | .. |
---|
13230 | 14863 | repaint(); |
---|
13231 | 14864 | break; |
---|
13232 | 14865 | case 'Z': |
---|
13233 | | - RESIZETEXTURE ^= true; |
---|
13234 | | - break; |
---|
| 14866 | + //RESIZETEXTURE ^= true; |
---|
| 14867 | + //break; |
---|
13235 | 14868 | case 'z': |
---|
13236 | 14869 | RENDERSHADOW ^= true; |
---|
13237 | | - lighttouched = true; |
---|
| 14870 | + Globals.lighttouched = true; |
---|
13238 | 14871 | repaint(); |
---|
13239 | 14872 | break; |
---|
13240 | 14873 | //case UP: |
---|
.. | .. |
---|
13349 | 14982 | } |
---|
13350 | 14983 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
13351 | 14984 | } |
---|
| 14985 | + |
---|
13352 | 14986 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
13353 | 14987 | |
---|
13354 | 14988 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
13360 | 14994 | } |
---|
13361 | 14995 | } |
---|
13362 | 14996 | |
---|
13363 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 14997 | + public void processKeyEvent(KeyEvent e) |
---|
13364 | 14998 | { |
---|
13365 | 14999 | switch (e.getID()) |
---|
13366 | 15000 | { |
---|
.. | .. |
---|
13490 | 15124 | |
---|
13491 | 15125 | protected void processMouseMotionEvent(MouseEvent e) |
---|
13492 | 15126 | { |
---|
13493 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
13494 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15127 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15128 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15129 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
13495 | 15130 | { |
---|
13496 | 15131 | mouseMoved(e); |
---|
13497 | 15132 | } else |
---|
.. | .. |
---|
13521 | 15156 | |
---|
13522 | 15157 | void SelectParent() |
---|
13523 | 15158 | { |
---|
| 15159 | + new Exception().printStackTrace(); |
---|
13524 | 15160 | System.exit(0); |
---|
13525 | 15161 | Composite group = (Composite) object; |
---|
13526 | 15162 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
13544 | 15180 | |
---|
13545 | 15181 | void SelectChildren() |
---|
13546 | 15182 | { |
---|
| 15183 | + new Exception().printStackTrace(); |
---|
13547 | 15184 | System.exit(0); |
---|
13548 | 15185 | /* |
---|
13549 | 15186 | Composite group = (Composite) object; |
---|
.. | .. |
---|
13836 | 15473 | //if (g != gr) g.drawImage(img, 0, 0, width, height, null); |
---|
13837 | 15474 | } |
---|
13838 | 15475 | |
---|
| 15476 | + // To avoid clear. |
---|
13839 | 15477 | public void update(Graphics g) |
---|
13840 | 15478 | { |
---|
13841 | 15479 | paint(g); |
---|
.. | .. |
---|
14438 | 16076 | gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS); |
---|
14439 | 16077 | gl.glPushMatrix(); |
---|
14440 | 16078 | gl.glLoadIdentity(); |
---|
14441 | | - PushMatrix(checker.toParent); |
---|
| 16079 | + //PushMatrix(checker.toParent); |
---|
14442 | 16080 | |
---|
14443 | 16081 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
14444 | 16082 | gl.glPushMatrix(); |
---|
.. | .. |
---|
14461 | 16099 | |
---|
14462 | 16100 | gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
14463 | 16101 | |
---|
14464 | | - float step = 0.1666f; //0.25f; |
---|
14465 | | - float stepv = step * 1652 / 998; |
---|
| 16102 | + float step = 2; // 0.1666f; //0.25f; |
---|
| 16103 | + float stepv = 2; // step * 1652 / 998; |
---|
14466 | 16104 | |
---|
14467 | 16105 | int i0 = 0; |
---|
14468 | 16106 | /* |
---|
.. | .. |
---|
14498 | 16136 | /**/ |
---|
14499 | 16137 | //checker.GetMaterial().opacity = 1.1f; |
---|
14500 | 16138 | ////checker.GetMaterial().ambient = 0.99f; |
---|
14501 | | - Object3D.materialstack[Object3D.materialdepth] = checker.material; |
---|
14502 | | - Object3D.selectedstack[Object3D.materialdepth] = false; |
---|
14503 | | - cStatic.objectstack[Object3D.materialdepth++] = checker; |
---|
| 16139 | + materialstack[materialdepth] = checker.material; |
---|
| 16140 | + selectedstack[materialdepth] = false; |
---|
| 16141 | + cStatic.objectstack[materialdepth++] = checker; |
---|
14504 | 16142 | //System.out.println("material " + material); |
---|
14505 | 16143 | //Applet3D.tracein(this, selected); |
---|
14506 | 16144 | vector2buffer = checker.projectedVertices; |
---|
14507 | 16145 | |
---|
14508 | | - checker.GetMaterial().Draw(this, false); // true); |
---|
| 16146 | + //checker.GetMaterial().Draw(this, false); // true); |
---|
| 16147 | + DrawMaterial(checker.GetMaterial(), false); // true); |
---|
14509 | 16148 | |
---|
14510 | | - Object3D.materialdepth -= 1; |
---|
14511 | | - if (Object3D.materialdepth > 0) |
---|
| 16149 | + materialdepth -= 1; |
---|
| 16150 | + if (materialdepth > 0) |
---|
14512 | 16151 | { |
---|
14513 | | - vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices; |
---|
14514 | | - Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]); |
---|
| 16152 | + vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16153 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
14515 | 16154 | } |
---|
14516 | 16155 | //checker.GetMaterial().opacity = 1f; |
---|
14517 | 16156 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
14532 | 16171 | |
---|
14533 | 16172 | //float u = (i+1)/2; |
---|
14534 | 16173 | //float v = (j+1)/2; |
---|
14535 | | - gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
| 16174 | + if (checker.flipV) |
---|
| 16175 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2); |
---|
| 16176 | + else |
---|
| 16177 | + gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
14536 | 16178 | gl.glVertex3f(i, j, -0.5f); |
---|
14537 | 16179 | |
---|
| 16180 | + if (checker.flipV) |
---|
| 16181 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
| 16182 | + else |
---|
14538 | 16183 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
14539 | 16184 | gl.glVertex3f(i + step, j, -0.5f); |
---|
14540 | 16185 | |
---|
| 16186 | + if (checker.flipV) |
---|
| 16187 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
| 16188 | + else |
---|
14541 | 16189 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
14542 | 16190 | gl.glVertex3f(i + step, j + stepv, -0.5f); |
---|
14543 | 16191 | |
---|
| 16192 | + if (checker.flipV) |
---|
| 16193 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
| 16194 | + else |
---|
14544 | 16195 | gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
14545 | 16196 | gl.glVertex3f(i, j + stepv, -0.5f); |
---|
14546 | 16197 | } |
---|
.. | .. |
---|
14552 | 16203 | gl.glMatrixMode(GL.GL_PROJECTION); |
---|
14553 | 16204 | gl.glPopMatrix(); |
---|
14554 | 16205 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
14555 | | - PopMatrix(null); // checker.toParent); // null); |
---|
| 16206 | + //PopMatrix(null); // checker.toParent); // null); |
---|
14556 | 16207 | gl.glPopMatrix(); |
---|
14557 | 16208 | PopTextureMatrix(checker.toParent); |
---|
14558 | 16209 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
.. | .. |
---|
14643 | 16294 | { |
---|
14644 | 16295 | if (!selection) |
---|
14645 | 16296 | { |
---|
| 16297 | + new Exception().printStackTrace(); |
---|
14646 | 16298 | System.exit(0); |
---|
14647 | 16299 | return; |
---|
14648 | 16300 | } |
---|
.. | .. |
---|
14665 | 16317 | |
---|
14666 | 16318 | //int tmp = selection_view; |
---|
14667 | 16319 | //selection_view = -1; |
---|
14668 | | - int temp = drawMode; |
---|
14669 | | - drawMode = SELECTION; |
---|
| 16320 | + int temp = DrawMode(); |
---|
| 16321 | + Globals.drawMode = SELECTION; // WARNING |
---|
14670 | 16322 | indexcount = 0; |
---|
14671 | 16323 | parent.display(drawable); |
---|
14672 | 16324 | //selection_view = tmp; |
---|
14673 | 16325 | //if (temp == SELECTION) |
---|
14674 | 16326 | // temp = DEFAULT; // patch for selection debug |
---|
14675 | | - drawMode = temp; |
---|
| 16327 | + Globals.drawMode = temp; // WARNING |
---|
14676 | 16328 | |
---|
14677 | 16329 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
14678 | 16330 | |
---|
.. | .. |
---|
14945 | 16597 | //gl.glColorMask(false, false, false, false); |
---|
14946 | 16598 | |
---|
14947 | 16599 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
14948 | | - if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 16600 | + if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
14949 | 16601 | { |
---|
14950 | 16602 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14951 | 16603 | |
---|
14952 | | - int temp = drawMode; |
---|
14953 | | - drawMode = SHADOW; |
---|
| 16604 | + int temp = DrawMode(); |
---|
| 16605 | + Globals.drawMode = SHADOW; // WARNING |
---|
14954 | 16606 | parent.display(drawable); |
---|
14955 | | - drawMode = temp; |
---|
| 16607 | + Globals.drawMode = temp; // WARNING |
---|
14956 | 16608 | } |
---|
14957 | 16609 | |
---|
14958 | 16610 | gl.glCullFace(gl.GL_BACK); |
---|
.. | .. |
---|
15005 | 16657 | |
---|
15006 | 16658 | class AntialiasBuffer implements GLEventListener |
---|
15007 | 16659 | { |
---|
15008 | | - |
---|
15009 | 16660 | CameraPane parent = null; |
---|
15010 | 16661 | |
---|
15011 | 16662 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
15115 | 16766 | gl.glFlush(); |
---|
15116 | 16767 | |
---|
15117 | 16768 | /**/ |
---|
15118 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer); |
---|
| 16769 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
15119 | 16770 | |
---|
15120 | | - int[] pixels = occlusionsizebuffer.array(); |
---|
| 16771 | + float[] pixels = occlusionsizebuffer.array(); |
---|
15121 | 16772 | |
---|
15122 | 16773 | double r = 0, g = 0, b = 0; |
---|
15123 | 16774 | |
---|
15124 | 16775 | double count = 0; |
---|
| 16776 | + |
---|
| 16777 | + gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0); |
---|
| 16778 | + |
---|
| 16779 | + float mindepth = 1; |
---|
| 16780 | + |
---|
| 16781 | + double FACTOR = 1; |
---|
15125 | 16782 | |
---|
15126 | 16783 | for (int i = 0; i < pixels.length; i++) |
---|
15127 | 16784 | { |
---|
.. | .. |
---|
15206 | 16863 | |
---|
15207 | 16864 | double scale = ray.z; // 1; // cos |
---|
15208 | 16865 | |
---|
15209 | | - int p = pixels[newindex]; |
---|
| 16866 | + float depth = pixels[newindex]; |
---|
15210 | 16867 | |
---|
15211 | 16868 | /* |
---|
15212 | 16869 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
15230 | 16887 | scale = (1 - modu) * modv; |
---|
15231 | 16888 | */ |
---|
15232 | 16889 | |
---|
15233 | | - r += ((p >> 16) & 0xFF) * scale / 255; |
---|
15234 | | - g += ((p >> 8) & 0xFF) * scale / 255; |
---|
15235 | | - b += (p & 0xFF) * scale / 255; |
---|
| 16890 | + //r += ((p >> 16) & 0xFF) * scale / 255; |
---|
| 16891 | + //g += ((p >> 8) & 0xFF) * scale / 255; |
---|
| 16892 | + //b += (p & 0xFF) * scale / 255; |
---|
| 16893 | + |
---|
| 16894 | + if (mindepth > depth) |
---|
| 16895 | + { |
---|
| 16896 | + mindepth = depth; |
---|
| 16897 | + } |
---|
15236 | 16898 | |
---|
| 16899 | + double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]); |
---|
| 16900 | + |
---|
| 16901 | + double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR); |
---|
| 16902 | + |
---|
| 16903 | + r += factor * scale; |
---|
| 16904 | + g += factor * scale; |
---|
| 16905 | + b += factor * scale; |
---|
| 16906 | + |
---|
15237 | 16907 | count += scale; |
---|
15238 | 16908 | } |
---|
15239 | 16909 | |
---|
.. | .. |
---|
15331 | 17001 | GLUT glut = new GLUT(); |
---|
15332 | 17002 | |
---|
15333 | 17003 | |
---|
15334 | | - static final public int DEFAULT = 0; |
---|
15335 | | - static final public int SELECTION = 1; |
---|
15336 | | - static final public int SHADOW = 2; |
---|
15337 | | - static final public int OCCLUSION = 3; |
---|
15338 | | - static |
---|
15339 | | - public int drawMode = DEFAULT; |
---|
15340 | 17004 | public boolean spherical = false; |
---|
15341 | 17005 | static boolean DEBUG_OCCLUSION = false; |
---|
15342 | 17006 | static boolean DEBUG_SELECTION = false; |
---|
.. | .. |
---|
15351 | 17015 | //double[] selectedpoint = new double[3]; |
---|
15352 | 17016 | static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
15353 | 17017 | static Sphere previousselectedpoint = null; |
---|
15354 | | - static Sphere debugpoint = new Sphere(); |
---|
15355 | | - static Sphere debugpoint2 = new Sphere(); |
---|
15356 | | - static Sphere debugpoint3 = new Sphere(); |
---|
15357 | | - static Sphere debugpoint4 = new Sphere(); |
---|
| 17018 | + static Sphere debugpointG = new Sphere(); |
---|
| 17019 | + static Sphere debugpointP = new Sphere(); |
---|
| 17020 | + static Sphere debugpointC = new Sphere(); |
---|
| 17021 | + static Sphere debugpointR = new Sphere(); |
---|
15358 | 17022 | |
---|
15359 | 17023 | static Sphere debugpoints[] = new Sphere[8]; |
---|
15360 | 17024 | |
---|
.. | .. |
---|
15385 | 17049 | } |
---|
15386 | 17050 | } |
---|
15387 | 17051 | |
---|
15388 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17052 | + static void DrawPoints(iCameraPane cpane) |
---|
15389 | 17053 | { |
---|
15390 | 17054 | for (int i=0; i<8; i++) // first and last are red |
---|
15391 | 17055 | { |
---|
.. | .. |
---|
15407 | 17071 | static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
15408 | 17072 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15409 | 17073 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15410 | | - static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17074 | + //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17075 | + static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
15411 | 17076 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
15412 | 17077 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
15413 | 17078 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|
.. | .. |
---|
15416 | 17081 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
15417 | 17082 | // Depth buffer format |
---|
15418 | 17083 | //private int depth_format; |
---|
15419 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17084 | + |
---|
| 17085 | + public void NextIndex() |
---|
15420 | 17086 | { |
---|
15421 | 17087 | indexcount+=16; |
---|
15422 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17088 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
15423 | 17089 | //objects[indexcount] = o; |
---|
15424 | 17090 | //System.out.println("indexcount = " + indexcount); |
---|
15425 | 17091 | } |
---|