.. | .. |
---|
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 | + |
---|
| 153 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 154 | + |
---|
170 | 155 | void SetAsGLRenderer(boolean b) |
---|
171 | 156 | { |
---|
172 | 157 | isRenderer = b; |
---|
173 | | - theRenderer = this; |
---|
| 158 | + Globals.theRenderer = this; |
---|
| 159 | + } |
---|
| 160 | + |
---|
| 161 | + CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
| 162 | + { |
---|
| 163 | + super(defaultcaps, null, withcontext?glcontext:null, null); |
---|
| 164 | + |
---|
| 165 | + //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523)); |
---|
| 166 | + glcontext = getContext(); |
---|
| 167 | + |
---|
| 168 | + cameras = new Camera[2]; |
---|
| 169 | + targetLookAts = new cVector[2]; |
---|
| 170 | + |
---|
| 171 | + SetCamera(cam); |
---|
| 172 | + |
---|
| 173 | + SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 174 | + |
---|
| 175 | + object = o; |
---|
| 176 | + |
---|
| 177 | + setBackground(Color.white); |
---|
| 178 | + |
---|
| 179 | + addKeyListener(this); |
---|
| 180 | + addMouseListener(this); |
---|
| 181 | + addMouseMotionListener(this); |
---|
| 182 | + addMouseWheelListener(this); |
---|
| 183 | + //System.out.println("addGLEventListener: " + this); |
---|
| 184 | + addGLEventListener(this); |
---|
| 185 | + |
---|
| 186 | +// pingthread.start(); // may 2013 |
---|
174 | 187 | } |
---|
175 | 188 | |
---|
176 | 189 | static boolean AntialiasingEnabled() |
---|
.. | .. |
---|
178 | 191 | return CURRENTANTIALIAS > 0; |
---|
179 | 192 | } |
---|
180 | 193 | |
---|
181 | | - void ClearDepth() |
---|
| 194 | + /// INTERFACE |
---|
| 195 | + |
---|
| 196 | + public javax.media.opengl.GL GetGL0() |
---|
| 197 | + { |
---|
| 198 | + return null; |
---|
| 199 | + } |
---|
| 200 | + |
---|
| 201 | + public int GenList() |
---|
| 202 | + { |
---|
| 203 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 204 | + return gl.glGenLists(1); |
---|
| 205 | + } |
---|
| 206 | + |
---|
| 207 | + public void NewList(int id) |
---|
| 208 | + { |
---|
| 209 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 210 | + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 211 | + } |
---|
| 212 | + |
---|
| 213 | + public void CallList(int id) |
---|
| 214 | + { |
---|
| 215 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 216 | + gl.glCallList(id); |
---|
| 217 | + } |
---|
| 218 | + |
---|
| 219 | + public void EndList() |
---|
| 220 | + { |
---|
| 221 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 222 | + gl.glEndList(); |
---|
| 223 | + } |
---|
| 224 | + |
---|
| 225 | + public boolean IsBoxMode() |
---|
| 226 | + { |
---|
| 227 | + return BOXMODE; |
---|
| 228 | + } |
---|
| 229 | + |
---|
| 230 | + public boolean IsZoomBoxMode() |
---|
| 231 | + { |
---|
| 232 | + return ZOOMBOXMODE; |
---|
| 233 | + } |
---|
| 234 | + |
---|
| 235 | + public void ClearDepth() |
---|
182 | 236 | { |
---|
183 | 237 | GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT); |
---|
184 | 238 | } |
---|
185 | 239 | |
---|
186 | | - void DepthTest(boolean depthtest) |
---|
| 240 | + public void DepthTest(boolean depthtest) |
---|
187 | 241 | { |
---|
188 | 242 | if (depthtest) |
---|
189 | 243 | GetGL().glDepthFunc(GL.GL_LEQUAL); |
---|
.. | .. |
---|
191 | 245 | GetGL().glDepthFunc(GL.GL_ALWAYS); |
---|
192 | 246 | } |
---|
193 | 247 | |
---|
194 | | - void DepthWrite(boolean depthwrite) |
---|
| 248 | + public void DepthWrite(boolean depthwrite) |
---|
195 | 249 | { |
---|
196 | 250 | if (depthwrite) |
---|
197 | 251 | GetGL().glDepthMask(true); |
---|
.. | .. |
---|
199 | 253 | GetGL().glDepthMask(false); |
---|
200 | 254 | } |
---|
201 | 255 | |
---|
202 | | - void BackFaceCull(boolean bfc) |
---|
| 256 | + public void BackFaceCull(boolean bfc) |
---|
203 | 257 | { |
---|
204 | 258 | if (bfc) |
---|
205 | 259 | GetGL().glEnable(GetGL().GL_CULL_FACE); |
---|
206 | 260 | else |
---|
207 | 261 | GetGL().glDisable(GetGL().GL_CULL_FACE); |
---|
| 262 | + } |
---|
| 263 | + |
---|
| 264 | + public boolean BackFaceCullMode() |
---|
| 265 | + { |
---|
| 266 | + return this.CULLFACE; |
---|
| 267 | + } |
---|
| 268 | + |
---|
| 269 | + public boolean IsAmbientOcclusionOn() |
---|
| 270 | + { |
---|
| 271 | + return this.ambientOcclusion; |
---|
| 272 | + } |
---|
| 273 | + |
---|
| 274 | + public boolean IsDebugSelection() |
---|
| 275 | + { |
---|
| 276 | + return DEBUG_SELECTION; |
---|
| 277 | + } |
---|
| 278 | + |
---|
| 279 | + public boolean IsFrozen() |
---|
| 280 | + { |
---|
| 281 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
| 282 | + |
---|
| 283 | + return !selectmode && cameracount == 0; // != 0; |
---|
| 284 | + } |
---|
| 285 | + |
---|
| 286 | + // Currently in Globals |
---|
| 287 | + public int DrawMode() |
---|
| 288 | + { |
---|
| 289 | + return Globals.DrawMode(); |
---|
| 290 | + } |
---|
| 291 | + |
---|
| 292 | + public Camera EyeCamera() |
---|
| 293 | + { |
---|
| 294 | + return eyeCamera; |
---|
| 295 | + } |
---|
| 296 | + |
---|
| 297 | + public Camera LightCamera() |
---|
| 298 | + { |
---|
| 299 | + return lightCamera; |
---|
| 300 | + } |
---|
| 301 | + |
---|
| 302 | + public Camera ManipCamera() |
---|
| 303 | + { |
---|
| 304 | + return manipCamera; |
---|
| 305 | + } |
---|
| 306 | + |
---|
| 307 | + public Camera RenderCamera() |
---|
| 308 | + { |
---|
| 309 | + return renderCamera; |
---|
| 310 | + } |
---|
| 311 | + |
---|
| 312 | + public Camera[] Cameras() |
---|
| 313 | + { |
---|
| 314 | + return cameras; |
---|
| 315 | + } |
---|
| 316 | + |
---|
| 317 | + public void PushMaterial(Object3D obj, boolean selected) |
---|
| 318 | + { |
---|
| 319 | + CameraPane display = this; |
---|
| 320 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 321 | + cMaterial material = obj.material; |
---|
| 322 | + |
---|
| 323 | + if (material != null) |
---|
| 324 | + { |
---|
| 325 | + materialstack[materialdepth] = material; |
---|
| 326 | + selectedstack[materialdepth] = selected; |
---|
| 327 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 328 | + //System.out.println("material " + material); |
---|
| 329 | + //Applet3D.tracein(this, selected); |
---|
| 330 | + display.vector2buffer = obj.projectedVertices; |
---|
| 331 | + if (obj instanceof Camera) |
---|
| 332 | + { |
---|
| 333 | + display.options1[0] = material.shift; |
---|
| 334 | + //System.out.println("shift " + material.shift); |
---|
| 335 | + display.options1[1] = material.lightarea; |
---|
| 336 | + display.options1[2] = material.shadowbias; |
---|
| 337 | + display.options1[3] = material.aniso; |
---|
| 338 | + display.options1[4] = material.anisoV; |
---|
| 339 | + display.options2[0] = material.opacity; |
---|
| 340 | + display.options2[1] = material.diffuse; |
---|
| 341 | + display.options2[2] = material.factor; |
---|
| 342 | + |
---|
| 343 | + cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 344 | + display.options4[0] = material.cameralight/0.2f; |
---|
| 345 | + display.options4[1] = material.subsurface; |
---|
| 346 | + display.options4[2] = material.sheen; |
---|
| 347 | + |
---|
| 348 | + // if (display.CURRENTANTIALIAS > 0) |
---|
| 349 | + // display.options3[3] /= 4; |
---|
| 350 | + |
---|
| 351 | + /* |
---|
| 352 | + System.out.println("Focus = " + display.options1[0]); |
---|
| 353 | + System.out.println("Aperture = " + display.options1[1]); |
---|
| 354 | + System.out.println("ShadowBlur = " + display.options1[2]); |
---|
| 355 | + System.out.println("Antialiasing = " + display.options1[3]); |
---|
| 356 | + System.out.println("Fog = " + display.options2[0]); |
---|
| 357 | + System.out.println("Intensity = " + display.options2[1]); |
---|
| 358 | + System.out.println("Elevation = " + display.options2[2]); |
---|
| 359 | + /**/ |
---|
| 360 | + } else |
---|
| 361 | + { |
---|
| 362 | + DrawMaterial(material, selected); |
---|
| 363 | + } |
---|
| 364 | + } else |
---|
| 365 | + { |
---|
| 366 | + if (selected && CameraPane.flash) |
---|
| 367 | + { |
---|
| 368 | + display.modelParams4[1] = 100; |
---|
| 369 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 370 | + } |
---|
| 371 | + } |
---|
| 372 | + } |
---|
| 373 | + |
---|
| 374 | + public void PushMaterial2(Object3D obj, boolean selected) |
---|
| 375 | + { |
---|
| 376 | + CameraPane display = this; |
---|
| 377 | + cMaterial material = obj.material; |
---|
| 378 | + |
---|
| 379 | + if (material != null) |
---|
| 380 | + { |
---|
| 381 | + materialstack[materialdepth] = material; |
---|
| 382 | + selectedstack[materialdepth] = selected; |
---|
| 383 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 384 | + //System.out.println("material " + material); |
---|
| 385 | + //Applet3D.tracein("selected ", selected); |
---|
| 386 | + display.vector2buffer = obj.projectedVertices; |
---|
| 387 | + display.DrawMaterial(material, selected); |
---|
| 388 | + } |
---|
| 389 | + } |
---|
| 390 | + |
---|
| 391 | + public void PopMaterial(Object3D obj, boolean selected) |
---|
| 392 | + { |
---|
| 393 | + CameraPane display = this; |
---|
| 394 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 395 | + cMaterial material = obj.material; |
---|
| 396 | + |
---|
| 397 | + //if (parent != null && parent.GetMaterial() != null) |
---|
| 398 | + // parent.GetMaterial().Draw(display, parent.IsSelected(this)); |
---|
| 399 | + if (material != null) |
---|
| 400 | + { |
---|
| 401 | + materialdepth -= 1; |
---|
| 402 | + if (materialdepth > 0) |
---|
| 403 | + { |
---|
| 404 | + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 405 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 406 | + } |
---|
| 407 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 408 | + } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
| 409 | + { |
---|
| 410 | + display.modelParams4[1] = obj.GetMaterial().cameralight; |
---|
| 411 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 412 | + } |
---|
| 413 | + } |
---|
| 414 | + |
---|
| 415 | + public void PopMaterial2(Object3D obj) |
---|
| 416 | + { |
---|
| 417 | + CameraPane display = this; |
---|
| 418 | + cMaterial material = obj.material; |
---|
| 419 | + |
---|
| 420 | + if (material != null) |
---|
| 421 | + { |
---|
| 422 | + materialdepth -= 1; |
---|
| 423 | + if (materialdepth > 0) |
---|
| 424 | + { |
---|
| 425 | + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 426 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 427 | + } |
---|
| 428 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 429 | + //else |
---|
| 430 | + //material.Draw(display, false); |
---|
| 431 | + } |
---|
| 432 | + } |
---|
| 433 | + |
---|
| 434 | + public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face) |
---|
| 435 | + { |
---|
| 436 | + CameraPane display = this; |
---|
| 437 | + |
---|
| 438 | + if (pv.y == -10000 || |
---|
| 439 | + qv.y == -10000 || |
---|
| 440 | + rv.y == -10000) |
---|
| 441 | + return; |
---|
| 442 | + |
---|
| 443 | +// float b = f.nbiterations & 1; |
---|
| 444 | +// float g = (f.nbiterations>>1) & 1; |
---|
| 445 | +// float r = (f.nbiterations>>2) & 1; |
---|
| 446 | +// |
---|
| 447 | +// //if (f.weight == 10000) |
---|
| 448 | +// //{ |
---|
| 449 | +// // r = 1; g = b = 0; |
---|
| 450 | +// //} |
---|
| 451 | +// //else |
---|
| 452 | +// //{ |
---|
| 453 | +// // assert(f.weight < 10000); |
---|
| 454 | +// r = g = b = (float)bRep.FaceWeight(f)*100; |
---|
| 455 | +// if (r<0) |
---|
| 456 | +// assert(r>=0); |
---|
| 457 | +// //} |
---|
| 458 | + |
---|
| 459 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 460 | + |
---|
| 461 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
| 462 | + |
---|
| 463 | + //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
| 464 | + if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
| 465 | + { |
---|
| 466 | + //gl.glBegin(gl.GL_TRIANGLES); |
---|
| 467 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 468 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 469 | + ; |
---|
| 470 | + if (!hasnorm) |
---|
| 471 | + { |
---|
| 472 | + // System.out.println("Mesh normal"); |
---|
| 473 | + LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
| 474 | + LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
| 475 | + LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
| 476 | + LA.vecNormalize(obj.v2); |
---|
| 477 | + gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 478 | + } |
---|
| 479 | + |
---|
| 480 | + // P |
---|
| 481 | + float x = (float)pv.x; |
---|
| 482 | + float y = (float)pv.y; |
---|
| 483 | + float z = (float)pv.z; |
---|
| 484 | + |
---|
| 485 | + if (hasnorm) |
---|
| 486 | + { |
---|
| 487 | +// if (!pv.norm.normalized()) |
---|
| 488 | +// assert(pv.norm.normalized()); |
---|
| 489 | + |
---|
| 490 | + //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z); |
---|
| 491 | + float nx = (float)pv.norm.x; |
---|
| 492 | + float ny = (float)pv.norm.y; |
---|
| 493 | + float nz = (float)pv.norm.z; |
---|
| 494 | + |
---|
| 495 | + x += nx * obj.NORMALPUSH; |
---|
| 496 | + y += ny * obj.NORMALPUSH; |
---|
| 497 | + z += nz * obj.NORMALPUSH; |
---|
| 498 | + |
---|
| 499 | + gl.glNormal3f(nx, ny, nz); |
---|
| 500 | + } |
---|
| 501 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 502 | + SetColor(obj, pv); |
---|
| 503 | + //gl.glColor4f(r, g, b, 1); |
---|
| 504 | + //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1); |
---|
| 505 | + if (obj.flipV) |
---|
| 506 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 507 | + else |
---|
| 508 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 509 | + //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z); |
---|
| 510 | + |
---|
| 511 | + gl.glVertex3f(x, y, z); |
---|
| 512 | + |
---|
| 513 | + // Q |
---|
| 514 | + x = (float)qv.x; |
---|
| 515 | + y = (float)qv.y; |
---|
| 516 | + z = (float)qv.z; |
---|
| 517 | + |
---|
| 518 | +// Print(pv); |
---|
| 519 | + if (hasnorm) |
---|
| 520 | + { |
---|
| 521 | +// assert(qv.norm.normalized()); |
---|
| 522 | + //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z); |
---|
| 523 | + float nx = (float)qv.norm.x; |
---|
| 524 | + float ny = (float)qv.norm.y; |
---|
| 525 | + float nz = (float)qv.norm.z; |
---|
| 526 | + |
---|
| 527 | + x += nx * obj.NORMALPUSH; |
---|
| 528 | + y += ny * obj.NORMALPUSH; |
---|
| 529 | + z += nz * obj.NORMALPUSH; |
---|
| 530 | + |
---|
| 531 | + gl.glNormal3f(nx, ny, nz); |
---|
| 532 | + } |
---|
| 533 | + //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
| 534 | + // boolean locked = false; |
---|
| 535 | + // float eps = 0.1f; |
---|
| 536 | + // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 537 | + |
---|
| 538 | + // int dot = 0; //*/ (int)f.dot; |
---|
| 539 | + |
---|
| 540 | + // if ((dot&1) == 0) |
---|
| 541 | + // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 542 | + |
---|
| 543 | + // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 544 | + if (obj.flipV) |
---|
| 545 | + gl.glTexCoord2f((float) qv.s, 1-(float) qv.t); |
---|
| 546 | + else |
---|
| 547 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 548 | + // else |
---|
| 549 | + // { |
---|
| 550 | + // locked = true; |
---|
| 551 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 552 | + // } |
---|
| 553 | + gl.glColor4f(qv.AO, qv.AO, qv.AO, 1); |
---|
| 554 | + SetColor(obj, qv); |
---|
| 555 | + |
---|
| 556 | + gl.glVertex3f(x, y, z); |
---|
| 557 | + //gl.glColor4f(r, g, b, 1); |
---|
| 558 | + //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1); |
---|
| 559 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 560 | +// Print(qv); |
---|
| 561 | + |
---|
| 562 | + // R |
---|
| 563 | + x = (float)rv.x; |
---|
| 564 | + y = (float)rv.y; |
---|
| 565 | + z = (float)rv.z; |
---|
| 566 | + |
---|
| 567 | + if (hasnorm) |
---|
| 568 | + { |
---|
| 569 | +// assert(rv.norm.normalized()); |
---|
| 570 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 571 | + float nx = (float)rv.norm.x; |
---|
| 572 | + float ny = (float)rv.norm.y; |
---|
| 573 | + float nz = (float)rv.norm.z; |
---|
| 574 | + |
---|
| 575 | + x += nx * obj.NORMALPUSH; |
---|
| 576 | + y += ny * obj.NORMALPUSH; |
---|
| 577 | + z += nz * obj.NORMALPUSH; |
---|
| 578 | + |
---|
| 579 | + gl.glNormal3f(nx, ny, nz); |
---|
| 580 | + } |
---|
| 581 | + |
---|
| 582 | + // if ((dot&4) == 0) |
---|
| 583 | + // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 584 | + |
---|
| 585 | + // if (wrap || !locked && (dot&8) != 0) |
---|
| 586 | + if (obj.flipV) |
---|
| 587 | + gl.glTexCoord2f((float) rv.s, 1-(float) rv.t); |
---|
| 588 | + else |
---|
| 589 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 590 | + // else |
---|
| 591 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 592 | + |
---|
| 593 | + // f.dot = dot; |
---|
| 594 | + |
---|
| 595 | + gl.glColor4f(rv.AO, rv.AO, rv.AO, 1); |
---|
| 596 | + SetColor(obj, rv); |
---|
| 597 | + //gl.glColor4f(r, g, b, 1); |
---|
| 598 | + //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1); |
---|
| 599 | + //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z); |
---|
| 600 | + gl.glVertex3f(x, y, z); |
---|
| 601 | +// Print(rv); |
---|
| 602 | + //gl.glEnd(); |
---|
| 603 | + } |
---|
| 604 | + else |
---|
| 605 | + { |
---|
| 606 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 607 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 608 | + gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z); |
---|
| 609 | + |
---|
| 610 | + } |
---|
| 611 | + |
---|
| 612 | + if (false) // (attributes & WIREFRAME) != 0) |
---|
| 613 | + { |
---|
| 614 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 615 | + |
---|
| 616 | + gl.glBegin(gl.GL_LINE_LOOP); |
---|
| 617 | + gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z); |
---|
| 618 | + gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z); |
---|
| 619 | + gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z); |
---|
| 620 | + gl.glEnd(); |
---|
| 621 | + |
---|
| 622 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 623 | + } |
---|
| 624 | + } |
---|
| 625 | + |
---|
| 626 | + /** |
---|
| 627 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 628 | + * it's normals, colors, textures and vertices. |
---|
| 629 | + * |
---|
| 630 | + * @see Renderer#draw(TriMesh) |
---|
| 631 | + * @param tris |
---|
| 632 | + * the mesh to render. |
---|
| 633 | + */ |
---|
| 634 | + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 635 | + { |
---|
| 636 | + CameraPane display = this; |
---|
| 637 | + |
---|
| 638 | + float r = display.modelParams0[0]; |
---|
| 639 | + float g = display.modelParams0[1]; |
---|
| 640 | + float b = display.modelParams0[2]; |
---|
| 641 | + float opacity = display.modelParams5[1]; |
---|
| 642 | + |
---|
| 643 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 644 | + GL gl = display.GetGL(); // getGL(); |
---|
| 645 | + |
---|
| 646 | + FloatBuffer vertBuf = geo.vertBuf; |
---|
| 647 | + |
---|
| 648 | + int v = vertBuf.capacity(); |
---|
| 649 | + |
---|
| 650 | + int count = 0; |
---|
| 651 | + |
---|
| 652 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 653 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 654 | + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
| 655 | + for (int i=0; i<v/3; i++) |
---|
| 656 | + { |
---|
| 657 | + int index3 = i*3; |
---|
| 658 | + |
---|
| 659 | + if (geo.sizeBuf.get(index3+1) == 0) |
---|
| 660 | + continue; |
---|
| 661 | + |
---|
| 662 | + count++; |
---|
| 663 | + |
---|
| 664 | + int index4 = i*4; |
---|
| 665 | + |
---|
| 666 | + float tx = vertBuf.get(index3); |
---|
| 667 | + float ty = vertBuf.get(index3+1); |
---|
| 668 | + float tz = vertBuf.get(index3+2); |
---|
| 669 | + |
---|
| 670 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 671 | + // continue; |
---|
| 672 | + |
---|
| 673 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 674 | + gl.glPushMatrix(); |
---|
| 675 | + |
---|
| 676 | + float[] texmat = geo.texmat; |
---|
| 677 | + texmat[12] = texmat[13] = texmat[14] = i; |
---|
| 678 | + |
---|
| 679 | + gl.glMultMatrixf(texmat, 0); |
---|
| 680 | + |
---|
| 681 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 682 | + gl.glPushMatrix(); |
---|
| 683 | + |
---|
| 684 | + gl.glTranslatef(tx,ty,tz); |
---|
| 685 | + |
---|
| 686 | + if (rotate) |
---|
| 687 | + gl.glRotatef(i, 0, 1, 0); |
---|
| 688 | + |
---|
| 689 | + float size = geo.sizeBuf.get(index3) / 100; |
---|
| 690 | + gl.glScalef(size,size,size); |
---|
| 691 | + |
---|
| 692 | + float cr = geo.colorBuf.get(index4); |
---|
| 693 | + float cg = geo.colorBuf.get(index4+1); |
---|
| 694 | + float cb = geo.colorBuf.get(index4+2); |
---|
| 695 | + float ca = geo.colorBuf.get(index4+3); |
---|
| 696 | + |
---|
| 697 | + display.modelParams0[0] = r * cr; |
---|
| 698 | + display.modelParams0[1] = g * cg; |
---|
| 699 | + display.modelParams0[2] = b * cb; |
---|
| 700 | + |
---|
| 701 | + display.modelParams5[1] = opacity * ca; |
---|
| 702 | + |
---|
| 703 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 704 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 705 | + |
---|
| 706 | + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; |
---|
| 707 | + RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 708 | + |
---|
| 709 | +// gl.glColor4f(cr,cg,cb,ca); |
---|
| 710 | + // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 711 | + shape.Draw/*Node*/(display,null,selected,false); // blocked |
---|
| 712 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 713 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 714 | + gl.glPopMatrix(); |
---|
| 715 | + |
---|
| 716 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 717 | + gl.glPopMatrix(); |
---|
| 718 | + } |
---|
| 719 | + // gl.glScalef(1024,1024,1024); |
---|
| 720 | + if (!cf) |
---|
| 721 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 722 | + |
---|
| 723 | + display.modelParams0[0] = r; |
---|
| 724 | + display.modelParams0[1] = g; |
---|
| 725 | + display.modelParams0[2] = b; |
---|
| 726 | + |
---|
| 727 | + display.modelParams5[1] = opacity; |
---|
| 728 | + |
---|
| 729 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 730 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 731 | + |
---|
| 732 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 733 | + |
---|
| 734 | +// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
| 735 | + if (true) |
---|
| 736 | + return; |
---|
| 737 | + |
---|
| 738 | +//// if (!tris.predraw(this)) |
---|
| 739 | +//// { |
---|
| 740 | +//// return; |
---|
| 741 | +//// } |
---|
| 742 | +//// if (Debug.stats) |
---|
| 743 | +//// { |
---|
| 744 | +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
| 745 | +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
| 746 | +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
| 747 | +//// } |
---|
| 748 | +//// |
---|
| 749 | +//// if (tris.getDisplayListID() != -1) |
---|
| 750 | +//// { |
---|
| 751 | +//// renderDisplayList(tris); |
---|
| 752 | +//// return; |
---|
| 753 | +//// } |
---|
| 754 | +//// |
---|
| 755 | +//// if (!generatingDisplayList) |
---|
| 756 | +//// { |
---|
| 757 | +//// applyStates(tris.states, tris); |
---|
| 758 | +//// } |
---|
| 759 | +//// if (Debug.stats) |
---|
| 760 | +//// { |
---|
| 761 | +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
| 762 | +//// } |
---|
| 763 | +//// boolean transformed = doTransforms(tris); |
---|
| 764 | +// |
---|
| 765 | +// int glMode = GL.GL_TRIANGLES; |
---|
| 766 | +// switch (getMode()) |
---|
| 767 | +// { |
---|
| 768 | +// case Triangles: |
---|
| 769 | +// glMode = GL.GL_TRIANGLES; |
---|
| 770 | +// break; |
---|
| 771 | +// case Strip: |
---|
| 772 | +// glMode = GL.GL_TRIANGLE_STRIP; |
---|
| 773 | +// break; |
---|
| 774 | +// case Fan: |
---|
| 775 | +// glMode = GL.GL_TRIANGLE_FAN; |
---|
| 776 | +// break; |
---|
| 777 | +// } |
---|
| 778 | +// |
---|
| 779 | +// if (!predrawGeometry(gl)) |
---|
| 780 | +// { |
---|
| 781 | +// // make sure only the necessary indices are sent through on old |
---|
| 782 | +// // cards. |
---|
| 783 | +// IntBuffer indices = this.getIndexBuffer(); |
---|
| 784 | +// if (indices == null) |
---|
| 785 | +// { |
---|
| 786 | +// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
| 787 | +// } else |
---|
| 788 | +// { |
---|
| 789 | +// indices.rewind(); |
---|
| 790 | +// indices.limit(this.getMaxIndex()); |
---|
| 791 | +// |
---|
| 792 | +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
| 793 | +// |
---|
| 794 | +// indices.clear(); |
---|
| 795 | +// } |
---|
| 796 | +// } else |
---|
| 797 | +// { |
---|
| 798 | +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
| 799 | +// GL.GL_UNSIGNED_INT, 0); |
---|
| 800 | +// } |
---|
| 801 | +// |
---|
| 802 | +//// postdrawGeometry(tris); |
---|
| 803 | +//// if (transformed) |
---|
| 804 | +//// { |
---|
| 805 | +//// undoTransforms(tris); |
---|
| 806 | +//// } |
---|
| 807 | +//// |
---|
| 808 | +//// if (Debug.stats) |
---|
| 809 | +//// { |
---|
| 810 | +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
| 811 | +//// } |
---|
| 812 | +//// tris.postdraw(this); |
---|
| 813 | + } |
---|
| 814 | + |
---|
| 815 | + static Camera localcamera = new Camera(); |
---|
| 816 | + static cVector from = new cVector(); |
---|
| 817 | + static cVector to = new cVector(); |
---|
| 818 | + |
---|
| 819 | + public void PrepOcclusion(BoundaryRep br, double[][] transform) |
---|
| 820 | + { |
---|
| 821 | + CameraPane cp = this; |
---|
| 822 | + |
---|
| 823 | + Camera keep = cp.RenderCamera(); |
---|
| 824 | + cp.renderCamera = localcamera; |
---|
| 825 | + |
---|
| 826 | + if (br.trimmed) |
---|
| 827 | + { |
---|
| 828 | + float[] colors = new float[br.positions.length / 3]; |
---|
| 829 | + |
---|
| 830 | + int i3 = 0; |
---|
| 831 | + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) |
---|
| 832 | + { |
---|
| 833 | + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) |
---|
| 834 | + continue; |
---|
| 835 | + |
---|
| 836 | + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); |
---|
| 837 | + to.set(br.positions[i3] + br.normals[i3], |
---|
| 838 | + br.positions[i3 + 1] + br.normals[i3 + 1], |
---|
| 839 | + br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
| 840 | + LA.xformPos(from, transform, from); |
---|
| 841 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 842 | + localcamera.setAim(from, to); |
---|
| 843 | + |
---|
| 844 | + CameraPane.occlusionbuffer.display(); |
---|
| 845 | + |
---|
| 846 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 847 | + cp.display(); // debug |
---|
| 848 | + |
---|
| 849 | + colors[i] = cp.vertexOcclusion.r; |
---|
| 850 | + //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
| 851 | + //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
| 852 | + |
---|
| 853 | + if ((i % 100) == 0 && i != 0) |
---|
| 854 | + { |
---|
| 855 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 856 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 857 | + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); |
---|
| 858 | + } |
---|
| 859 | + } |
---|
| 860 | + |
---|
| 861 | + br.colors = colors; |
---|
| 862 | + } |
---|
| 863 | + else |
---|
| 864 | + { |
---|
| 865 | + for (int i = 0; i < br.VertexCount(); i++) |
---|
| 866 | + { |
---|
| 867 | + Vertex v = br.GetVertex(i); |
---|
| 868 | + |
---|
| 869 | + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
| 870 | + continue; |
---|
| 871 | + |
---|
| 872 | + from.set(v.x, v.y, v.z); |
---|
| 873 | + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
| 874 | + LA.xformPos(from, transform, from); |
---|
| 875 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 876 | + localcamera.setAim(from, to); |
---|
| 877 | + |
---|
| 878 | + CameraPane.occlusionbuffer.display(); |
---|
| 879 | + |
---|
| 880 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 881 | + cp.display(); // debug |
---|
| 882 | + |
---|
| 883 | + v.AO = cp.vertexOcclusion.r; |
---|
| 884 | + |
---|
| 885 | + if ((i % 100) == 0 && i != 0) |
---|
| 886 | + { |
---|
| 887 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 888 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 889 | + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); |
---|
| 890 | + } |
---|
| 891 | + } |
---|
| 892 | + } |
---|
| 893 | + |
---|
| 894 | + //System.out.println("done."); |
---|
| 895 | + |
---|
| 896 | + cp.renderCamera = keep; |
---|
| 897 | + } |
---|
| 898 | + |
---|
| 899 | + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 900 | + { |
---|
| 901 | + CameraPane display = this; |
---|
| 902 | + pointFlow.CreateHT(); |
---|
| 903 | + |
---|
| 904 | + float r = display.modelParams0[0]; |
---|
| 905 | + float g = display.modelParams0[1]; |
---|
| 906 | + float b = display.modelParams0[2]; |
---|
| 907 | + float opacity = display.modelParams5[1]; |
---|
| 908 | + |
---|
| 909 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 910 | + GL gl = display.GetGL(); // getGL(); |
---|
| 911 | + |
---|
| 912 | + int s = pointFlow.points.size(); |
---|
| 913 | + |
---|
| 914 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 915 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 916 | + |
---|
| 917 | + for (int i=s; --i>=0;) |
---|
| 918 | + //for (int i=0; i<s; i++) |
---|
| 919 | + { |
---|
| 920 | + cVector v = pointFlow.points.get(i); |
---|
| 921 | + |
---|
| 922 | + double mindist = Double.MAX_VALUE; |
---|
| 923 | + |
---|
| 924 | + double size = pointFlow.minimumSize; |
---|
| 925 | + |
---|
| 926 | + double distancenext = 0; |
---|
| 927 | + |
---|
| 928 | + if (i > 0) |
---|
| 929 | + { |
---|
| 930 | + cVector w = pointFlow.points.get(i-1); |
---|
| 931 | + |
---|
| 932 | + double dist = w.distance(v); |
---|
| 933 | + |
---|
| 934 | + distancenext = dist; |
---|
| 935 | + |
---|
| 936 | + if (mindist > dist) |
---|
| 937 | + { |
---|
| 938 | + mindist = dist; |
---|
| 939 | + size = mindist*pointFlow.resizefactor; |
---|
| 940 | + } |
---|
| 941 | + } |
---|
| 942 | + |
---|
| 943 | + if (i < s-1) |
---|
| 944 | + { |
---|
| 945 | + cVector w = pointFlow.points.get(i+1); |
---|
| 946 | + |
---|
| 947 | + double dist = w.distance(v); |
---|
| 948 | + |
---|
| 949 | + if (mindist > dist) |
---|
| 950 | + { |
---|
| 951 | + mindist = dist; |
---|
| 952 | + size = mindist*pointFlow.resizefactor; |
---|
| 953 | + } |
---|
| 954 | + } |
---|
| 955 | + |
---|
| 956 | + if (size < pointFlow.minimumSize) |
---|
| 957 | + size = pointFlow.minimumSize; |
---|
| 958 | + if (size > pointFlow.maximumSize) |
---|
| 959 | + size = pointFlow.maximumSize; |
---|
| 960 | + |
---|
| 961 | + double tx = v.x; |
---|
| 962 | + double ty = v.y; |
---|
| 963 | + double tz = v.z; |
---|
| 964 | + |
---|
| 965 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 966 | + // continue; |
---|
| 967 | + |
---|
| 968 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 969 | + gl.glPushMatrix(); |
---|
| 970 | + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; |
---|
| 971 | + |
---|
| 972 | + gl.glMultMatrixf(pointFlow.texmat, 0); |
---|
| 973 | + |
---|
| 974 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 975 | + gl.glPushMatrix(); |
---|
| 976 | + |
---|
| 977 | + gl.glTranslated(tx,ty,tz); |
---|
| 978 | + |
---|
| 979 | + gl.glScaled(size,size,size); |
---|
| 980 | + |
---|
| 981 | +// float cr = colorBuf.get(index4); |
---|
| 982 | +// float cg = colorBuf.get(index4+1); |
---|
| 983 | +// float cb = colorBuf.get(index4+2); |
---|
| 984 | +// float ca = colorBuf.get(index4+3); |
---|
| 985 | +// |
---|
| 986 | +// display.modelParams0[0] = r * cr; |
---|
| 987 | +// display.modelParams0[1] = g * cg; |
---|
| 988 | +// display.modelParams0[2] = b * cb; |
---|
| 989 | +// |
---|
| 990 | +// display.modelParams5[1] = opacity * ca; |
---|
| 991 | +// |
---|
| 992 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 993 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 994 | +// |
---|
| 995 | +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
| 996 | +// RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 997 | +// |
---|
| 998 | +//// gl.glColor4f(cr,cg,cb,ca); |
---|
| 999 | +// // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 1000 | + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); |
---|
| 1001 | + |
---|
| 1002 | + gl.glPopMatrix(); |
---|
| 1003 | + |
---|
| 1004 | + double step = size/4; // |
---|
| 1005 | + |
---|
| 1006 | + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) |
---|
| 1007 | + continue; |
---|
| 1008 | + |
---|
| 1009 | + int nbsteps = (int)(distancenext/step); |
---|
| 1010 | + |
---|
| 1011 | + step = distancenext/nbsteps; |
---|
| 1012 | + |
---|
| 1013 | + cVector next = pointFlow.points.get(i-1); |
---|
| 1014 | + |
---|
| 1015 | + tmp.set(next); |
---|
| 1016 | + tmp.sub(v); |
---|
| 1017 | + tmp.normalize(); |
---|
| 1018 | + tmp.mul(step); |
---|
| 1019 | + |
---|
| 1020 | + // calculate next size |
---|
| 1021 | + mindist = Double.MAX_VALUE; |
---|
| 1022 | + |
---|
| 1023 | + double nextsize = pointFlow.minimumSize; |
---|
| 1024 | + |
---|
| 1025 | + if (i > 1) |
---|
| 1026 | + { |
---|
| 1027 | + cVector w = pointFlow.points.get(i-2); |
---|
| 1028 | + |
---|
| 1029 | + double dist = w.distance(next); |
---|
| 1030 | + |
---|
| 1031 | + if (mindist > dist) |
---|
| 1032 | + { |
---|
| 1033 | + mindist = dist; |
---|
| 1034 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1035 | + } |
---|
| 1036 | + } |
---|
| 1037 | + |
---|
| 1038 | + double dist = v.distance(next); |
---|
| 1039 | + |
---|
| 1040 | + if (mindist > dist) |
---|
| 1041 | + { |
---|
| 1042 | + mindist = dist; |
---|
| 1043 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1044 | + } |
---|
| 1045 | + |
---|
| 1046 | + if (nextsize < pointFlow.minimumSize) |
---|
| 1047 | + nextsize = pointFlow.minimumSize; |
---|
| 1048 | + if (nextsize > pointFlow.maximumSize) |
---|
| 1049 | + nextsize = pointFlow.maximumSize; |
---|
| 1050 | + // |
---|
| 1051 | + |
---|
| 1052 | + double count = 0; |
---|
| 1053 | + |
---|
| 1054 | + while (distancenext > 0.000000001) // step |
---|
| 1055 | + { |
---|
| 1056 | + gl.glPushMatrix(); |
---|
| 1057 | + |
---|
| 1058 | + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); |
---|
| 1059 | + |
---|
| 1060 | + double K = count/nbsteps; |
---|
| 1061 | + |
---|
| 1062 | + double intersize = K*nextsize + (1-K)*size; |
---|
| 1063 | + |
---|
| 1064 | + gl.glScaled(intersize,intersize,intersize); |
---|
| 1065 | + |
---|
| 1066 | + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); |
---|
| 1067 | + |
---|
| 1068 | + count++; |
---|
| 1069 | + |
---|
| 1070 | + distancenext -= step; |
---|
| 1071 | + |
---|
| 1072 | + gl.glPopMatrix(); |
---|
| 1073 | + } |
---|
| 1074 | + |
---|
| 1075 | + if (count != nbsteps) |
---|
| 1076 | + assert(count == nbsteps); |
---|
| 1077 | + |
---|
| 1078 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 1079 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 1080 | + |
---|
| 1081 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1082 | + gl.glPopMatrix(); |
---|
| 1083 | + } |
---|
| 1084 | + |
---|
| 1085 | + if (!cf) |
---|
| 1086 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 1087 | + |
---|
| 1088 | +// display.modelParams0[0] = r; |
---|
| 1089 | +// display.modelParams0[1] = g; |
---|
| 1090 | +// display.modelParams0[2] = b; |
---|
| 1091 | +// |
---|
| 1092 | +// display.modelParams5[1] = opacity; |
---|
| 1093 | +// |
---|
| 1094 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1095 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1096 | + |
---|
| 1097 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1098 | + } |
---|
| 1099 | + |
---|
| 1100 | + public void DrawBox(cVector min, cVector max) |
---|
| 1101 | + { |
---|
| 1102 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1103 | + gl.glBegin(gl.GL_LINES); |
---|
| 1104 | + |
---|
| 1105 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1106 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1107 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1108 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1109 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1110 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1111 | + |
---|
| 1112 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1113 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1114 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1115 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1116 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1117 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1118 | + |
---|
| 1119 | + gl.glEnd(); |
---|
| 1120 | + } |
---|
| 1121 | + |
---|
| 1122 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1123 | + { |
---|
| 1124 | + int[] strips = bRep.getRawIndices(); |
---|
| 1125 | + |
---|
| 1126 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1127 | + |
---|
| 1128 | + // TRIANGLE STRIP ARRAY |
---|
| 1129 | + if (bRep.trimmed) |
---|
| 1130 | + { |
---|
| 1131 | + float[] v = bRep.getRawVertices(); |
---|
| 1132 | + float[] n = bRep.getRawNormals(); |
---|
| 1133 | + float[] c = bRep.getRawColors(); |
---|
| 1134 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1135 | + |
---|
| 1136 | + int count2 = 0; |
---|
| 1137 | + int count3 = 0; |
---|
| 1138 | + |
---|
| 1139 | + if (n.length > 0) |
---|
| 1140 | + { |
---|
| 1141 | + for (int i = 0; i < strips.length; i++) |
---|
| 1142 | + { |
---|
| 1143 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1144 | + |
---|
| 1145 | + /* |
---|
| 1146 | + boolean locked = false; |
---|
| 1147 | + float eps = 0.1f; |
---|
| 1148 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1149 | + |
---|
| 1150 | + int dot = 0; |
---|
| 1151 | + |
---|
| 1152 | + if ((dot&1) == 0) |
---|
| 1153 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1154 | + |
---|
| 1155 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1156 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1157 | + else |
---|
| 1158 | + { |
---|
| 1159 | + locked = true; |
---|
| 1160 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1161 | + } |
---|
| 1162 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1163 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1164 | + if (hasnorm) |
---|
| 1165 | + { |
---|
| 1166 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1167 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1168 | + } |
---|
| 1169 | + |
---|
| 1170 | + if ((dot&4) == 0) |
---|
| 1171 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1172 | + |
---|
| 1173 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1174 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1175 | + else |
---|
| 1176 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1177 | + |
---|
| 1178 | + f.dot = dot; |
---|
| 1179 | + */ |
---|
| 1180 | + |
---|
| 1181 | + if (!selectmode) |
---|
| 1182 | + { |
---|
| 1183 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1184 | + { |
---|
| 1185 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1186 | + } else |
---|
| 1187 | + { |
---|
| 1188 | + gl.glNormal3f(0, 0, 1); |
---|
| 1189 | + } |
---|
| 1190 | + |
---|
| 1191 | + if (c != null) |
---|
| 1192 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1193 | + { |
---|
| 1194 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1195 | + } |
---|
| 1196 | + } |
---|
| 1197 | + |
---|
| 1198 | + if (flipV) |
---|
| 1199 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1200 | + else |
---|
| 1201 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1202 | + |
---|
| 1203 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1204 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1205 | + |
---|
| 1206 | + count2 += 2; |
---|
| 1207 | + count3 += 3; |
---|
| 1208 | + if (!selectmode) |
---|
| 1209 | + { |
---|
| 1210 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1211 | + { |
---|
| 1212 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1213 | + } else |
---|
| 1214 | + { |
---|
| 1215 | + gl.glNormal3f(0, 0, 1); |
---|
| 1216 | + } |
---|
| 1217 | + if (c != null) |
---|
| 1218 | + { |
---|
| 1219 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1220 | + } |
---|
| 1221 | + } |
---|
| 1222 | + |
---|
| 1223 | + if (flipV) |
---|
| 1224 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1225 | + else |
---|
| 1226 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1227 | + |
---|
| 1228 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1229 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1230 | + |
---|
| 1231 | + count2 += 2; |
---|
| 1232 | + count3 += 3; |
---|
| 1233 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1234 | + { |
---|
| 1235 | + //gl.glTexCoord2d(...); |
---|
| 1236 | + if (!selectmode) |
---|
| 1237 | + { |
---|
| 1238 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1239 | + { |
---|
| 1240 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1241 | + } else |
---|
| 1242 | + { |
---|
| 1243 | + gl.glNormal3f(0, 0, 1); |
---|
| 1244 | + } |
---|
| 1245 | + if (c != null) |
---|
| 1246 | + { |
---|
| 1247 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1248 | + } |
---|
| 1249 | + } |
---|
| 1250 | + |
---|
| 1251 | + if (flipV) |
---|
| 1252 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1253 | + else |
---|
| 1254 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1255 | + |
---|
| 1256 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1257 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1258 | + |
---|
| 1259 | + count2 += 2; |
---|
| 1260 | + count3 += 3; |
---|
| 1261 | + } |
---|
| 1262 | + |
---|
| 1263 | + gl.glEnd(); |
---|
| 1264 | + } |
---|
| 1265 | + } |
---|
| 1266 | + |
---|
| 1267 | + assert count3 == v.length; |
---|
| 1268 | + } |
---|
| 1269 | + else // !trimmed |
---|
| 1270 | + { |
---|
| 1271 | + int count = 0; |
---|
| 1272 | + for (int i = 0; i < strips.length; i++) |
---|
| 1273 | + { |
---|
| 1274 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1275 | + |
---|
| 1276 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1277 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1278 | + |
---|
| 1279 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1280 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1281 | + |
---|
| 1282 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1283 | + { |
---|
| 1284 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1285 | + |
---|
| 1286 | + // if (j%2 == 0) |
---|
| 1287 | + // drawFace(p, q, r, display, null); |
---|
| 1288 | + // else |
---|
| 1289 | + // drawFace(p, r, q, display, null); |
---|
| 1290 | + |
---|
| 1291 | + // p = q; |
---|
| 1292 | + // q = r; |
---|
| 1293 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1294 | + } |
---|
| 1295 | + |
---|
| 1296 | + gl.glEnd(); |
---|
| 1297 | + } |
---|
| 1298 | + } |
---|
| 1299 | + } |
---|
| 1300 | + |
---|
| 1301 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1302 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1303 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1304 | + |
---|
| 1305 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1306 | + { |
---|
| 1307 | + GL gl = GetGL(); // getGL(); |
---|
| 1308 | + |
---|
| 1309 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1310 | + |
---|
| 1311 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1312 | + |
---|
| 1313 | + gl.glLineWidth(1); |
---|
| 1314 | + gl.glColor3f(1,1,1); |
---|
| 1315 | + gl.glBegin(gl.GL_LINES); |
---|
| 1316 | + double scale = 0; |
---|
| 1317 | + int count = 0; |
---|
| 1318 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1319 | + { |
---|
| 1320 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1321 | + if(s == 0) |
---|
| 1322 | + { |
---|
| 1323 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1324 | + } |
---|
| 1325 | + if (mesh.showsprings) |
---|
| 1326 | + { |
---|
| 1327 | + temp.set(spring.a.position); |
---|
| 1328 | + temp.add(spring.b.position); |
---|
| 1329 | + temp.mul(0.5); |
---|
| 1330 | + temp2.set(spring.a.position); |
---|
| 1331 | + temp2.sub(spring.b.position); |
---|
| 1332 | + temp2.mul(spring.restLength/2); |
---|
| 1333 | + temp.sub(temp2); |
---|
| 1334 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1335 | + temp.add(temp2); |
---|
| 1336 | + temp.add(temp2); |
---|
| 1337 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1338 | + } |
---|
| 1339 | + |
---|
| 1340 | + if (spring.isHandle) |
---|
| 1341 | + continue; |
---|
| 1342 | + |
---|
| 1343 | + //if (scale < spring.restLength) |
---|
| 1344 | + scale += spring.restLength; |
---|
| 1345 | + count++; |
---|
| 1346 | + } |
---|
| 1347 | + gl.glEnd(); |
---|
| 1348 | + |
---|
| 1349 | + if (count == 0) |
---|
| 1350 | + scale = 0.01; |
---|
| 1351 | + else |
---|
| 1352 | + scale /= count * 3; |
---|
| 1353 | + |
---|
| 1354 | + //scale = 0.25; |
---|
| 1355 | + |
---|
| 1356 | + if (mesh.ShowInfo()) |
---|
| 1357 | + { |
---|
| 1358 | + gl.glLineWidth(4); |
---|
| 1359 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1360 | + { |
---|
| 1361 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1362 | + if (node.mass == 0) |
---|
| 1363 | + continue; |
---|
| 1364 | + |
---|
| 1365 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1366 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1367 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1368 | + //temp.normalize(); |
---|
| 1369 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1370 | + gl.glBegin(gl.GL_LINES); |
---|
| 1371 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1372 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1373 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1374 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1375 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1376 | + gl.glEnd(); |
---|
| 1377 | + } |
---|
| 1378 | + |
---|
| 1379 | + gl.glLineWidth(8); |
---|
| 1380 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1381 | + { |
---|
| 1382 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1383 | + |
---|
| 1384 | + if (node.springs != null) |
---|
| 1385 | + { |
---|
| 1386 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1387 | + { |
---|
| 1388 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1389 | + |
---|
| 1390 | + int c = i+1; |
---|
| 1391 | + // c = node.springs.get(i).nbcopies; |
---|
| 1392 | + |
---|
| 1393 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1394 | + gl.glBegin(gl.GL_LINES); |
---|
| 1395 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1396 | + 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); |
---|
| 1397 | + gl.glEnd(); |
---|
| 1398 | + } |
---|
| 1399 | + } |
---|
| 1400 | + } |
---|
| 1401 | + |
---|
| 1402 | + gl.glLineWidth(1); |
---|
| 1403 | + } |
---|
| 1404 | + |
---|
| 1405 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1406 | + } |
---|
| 1407 | + |
---|
| 1408 | + /// INTERFACE |
---|
| 1409 | + |
---|
| 1410 | + public void StartTriangles() |
---|
| 1411 | + { |
---|
| 1412 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1413 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1414 | + } |
---|
| 1415 | + |
---|
| 1416 | + public void EndTriangles() |
---|
| 1417 | + { |
---|
| 1418 | + GetGL().glEnd(); |
---|
| 1419 | + } |
---|
| 1420 | + |
---|
| 1421 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1422 | + { |
---|
| 1423 | + if (!selectmode) |
---|
| 1424 | + { |
---|
| 1425 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1426 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1427 | + |
---|
| 1428 | + if (flipV) |
---|
| 1429 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1430 | + else |
---|
| 1431 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1432 | + } |
---|
| 1433 | + |
---|
| 1434 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1435 | + } |
---|
| 1436 | + |
---|
| 1437 | + void SetColor(Object3D obj, Vertex p0) |
---|
| 1438 | + { |
---|
| 1439 | + CameraPane display = this; |
---|
| 1440 | + BoundaryRep bRep = obj.bRep; |
---|
| 1441 | + |
---|
| 1442 | + if (RENDERPROGRAM == 0) |
---|
| 1443 | + { |
---|
| 1444 | + float r = 0; |
---|
| 1445 | + if (bRep != null) |
---|
| 1446 | + { |
---|
| 1447 | + if (bRep.stripified) |
---|
| 1448 | + { |
---|
| 1449 | + r = 1; |
---|
| 1450 | + } |
---|
| 1451 | + } |
---|
| 1452 | + float g = 0; |
---|
| 1453 | + if (bRep != null) |
---|
| 1454 | + { |
---|
| 1455 | + if (bRep.trimmed) |
---|
| 1456 | + { |
---|
| 1457 | + g = 1; |
---|
| 1458 | + } |
---|
| 1459 | + } |
---|
| 1460 | + float b = 0; |
---|
| 1461 | + if (obj.support != null && obj.link2master) |
---|
| 1462 | + { |
---|
| 1463 | + b = 1; |
---|
| 1464 | + } |
---|
| 1465 | + display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO); |
---|
| 1466 | + return; |
---|
| 1467 | + } |
---|
| 1468 | + |
---|
| 1469 | + if (display.DrawMode() != CameraPane.SHADOW) |
---|
| 1470 | + return; |
---|
| 1471 | + |
---|
| 1472 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1473 | +// if (true) return; |
---|
| 1474 | +// float ao = p.AO; |
---|
| 1475 | +// |
---|
| 1476 | +// // if (ao == 0 && !bRep.AOdone) // transient problem! |
---|
| 1477 | +// // ao = 1; |
---|
| 1478 | +// |
---|
| 1479 | +// gl.glColor4f(ao, ao, ao, 1); |
---|
| 1480 | + |
---|
| 1481 | +// CameraPane.selectedpoint. |
---|
| 1482 | +// getAverage(cStatic.point1, true); |
---|
| 1483 | + if (CameraPane.pointflow == null) // !random) // live) |
---|
| 1484 | + { |
---|
| 1485 | + return; |
---|
| 1486 | + } |
---|
| 1487 | + |
---|
| 1488 | + cStatic.point1.set(0,0,0); |
---|
| 1489 | + LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1); |
---|
| 1490 | + |
---|
| 1491 | + cStatic.point1.sub(p0); |
---|
| 1492 | + |
---|
| 1493 | + |
---|
| 1494 | +// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta? |
---|
| 1495 | +// { |
---|
| 1496 | +// return; |
---|
| 1497 | +// } |
---|
| 1498 | + |
---|
| 1499 | + //if (true) |
---|
| 1500 | + if (cStatic.point1.dot(cStatic.point1) > 0.000001) |
---|
| 1501 | + { |
---|
| 1502 | + return; |
---|
| 1503 | + } |
---|
| 1504 | + |
---|
| 1505 | + float[] colorV = new float[3]; |
---|
| 1506 | + |
---|
| 1507 | + if (false) // marked) |
---|
| 1508 | + { |
---|
| 1509 | + // debug rigging weights |
---|
| 1510 | + for (int object = 0; object < p0.vertexlinks.length; object++) |
---|
| 1511 | + { |
---|
| 1512 | + float weight = p0.weights[object] / p0.totalweight; |
---|
| 1513 | + |
---|
| 1514 | + // if (weight < 0.1) |
---|
| 1515 | + // { |
---|
| 1516 | + // assert(weight == 0); |
---|
| 1517 | + // continue; |
---|
| 1518 | + // } |
---|
| 1519 | + |
---|
| 1520 | + if (p0.vertexlinks[object] == -1) |
---|
| 1521 | + continue; |
---|
| 1522 | + |
---|
| 1523 | + Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]); |
---|
| 1524 | + |
---|
| 1525 | + int color = //1 << object; // |
---|
| 1526 | + //p.vertexlinks.length; |
---|
| 1527 | + obj.support.bRep.supports[p0.closestsupport].links[object]; |
---|
| 1528 | + colorV[2] += (color & 1) * weight; |
---|
| 1529 | + colorV[1] += ((color & 2) >> 1) * weight; |
---|
| 1530 | + colorV[0] += ((color & 4) >> 2) * weight; |
---|
| 1531 | + } |
---|
| 1532 | + } |
---|
| 1533 | + else |
---|
| 1534 | + { |
---|
| 1535 | + if (obj.drawingstarted) |
---|
| 1536 | + { |
---|
| 1537 | + // find next point |
---|
| 1538 | + if (bRep.GetVertex(0).faceindices == null) |
---|
| 1539 | + { |
---|
| 1540 | + bRep.InitFaceIndices(); |
---|
| 1541 | + } |
---|
| 1542 | + |
---|
| 1543 | + double ymin = p0.y; |
---|
| 1544 | + |
---|
| 1545 | + Vertex newp = p0; |
---|
| 1546 | + |
---|
| 1547 | + for (int fii = 0; fii < p0.faceindices.length; fii++) |
---|
| 1548 | + { |
---|
| 1549 | + int fi = p0.faceindices[fii]; |
---|
| 1550 | + |
---|
| 1551 | + if (fi == -1) |
---|
| 1552 | + break; |
---|
| 1553 | + |
---|
| 1554 | + Face f = bRep.GetFace(fi); |
---|
| 1555 | + |
---|
| 1556 | + Vertex p = bRep.GetVertex(f.p); |
---|
| 1557 | + Vertex q = bRep.GetVertex(f.q); |
---|
| 1558 | + Vertex r = bRep.GetVertex(f.r); |
---|
| 1559 | + |
---|
| 1560 | + int swap = (int)(Math.random()*3); |
---|
| 1561 | + |
---|
| 1562 | +// for (int s=swap; --s>=0;) |
---|
| 1563 | +// { |
---|
| 1564 | +// Vertex t = p; |
---|
| 1565 | +// p = q; |
---|
| 1566 | +// q = r; |
---|
| 1567 | +// r = t; |
---|
| 1568 | +// } |
---|
| 1569 | + if (ymin > p.y) |
---|
| 1570 | + { |
---|
| 1571 | + ymin = p.y; |
---|
| 1572 | + newp = p; |
---|
| 1573 | +// break; |
---|
| 1574 | + } |
---|
| 1575 | + if (ymin > q.y) |
---|
| 1576 | + { |
---|
| 1577 | + ymin = q.y; |
---|
| 1578 | + newp = q; |
---|
| 1579 | +// break; |
---|
| 1580 | + } |
---|
| 1581 | + if (ymin > r.y) |
---|
| 1582 | + { |
---|
| 1583 | + ymin = r.y; |
---|
| 1584 | + newp = r; |
---|
| 1585 | +// break; |
---|
| 1586 | + } |
---|
| 1587 | + } |
---|
| 1588 | + |
---|
| 1589 | + CameraPane.selectedpoint.toParent[3][0] = newp.x; |
---|
| 1590 | + CameraPane.selectedpoint.toParent[3][1] = newp.y; |
---|
| 1591 | + CameraPane.selectedpoint.toParent[3][2] = newp.z; |
---|
| 1592 | + |
---|
| 1593 | + obj.drawingstarted = false; |
---|
| 1594 | + |
---|
| 1595 | + // return; |
---|
| 1596 | + } |
---|
| 1597 | + |
---|
| 1598 | + if (false) // CameraPane.DRAW |
---|
| 1599 | + { |
---|
| 1600 | + p0.AO = colorV[0] = 2; |
---|
| 1601 | + colorV[1] = 2; |
---|
| 1602 | + colorV[2] = 2; |
---|
| 1603 | + } |
---|
| 1604 | + |
---|
| 1605 | + CameraPane.pointflow.add(p0); |
---|
| 1606 | + CameraPane.pointflow.Touch(); |
---|
| 1607 | + } |
---|
| 1608 | + |
---|
| 1609 | +// gl.glColor3f(colorV[0], colorV[1], colorV[2]); |
---|
| 1610 | +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1611 | +// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1612 | + } |
---|
| 1613 | + |
---|
| 1614 | + void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1615 | + { |
---|
| 1616 | + CameraPane display = this; |
---|
| 1617 | + //new Exception().printStackTrace(); |
---|
| 1618 | + |
---|
| 1619 | + if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW) |
---|
| 1620 | + { |
---|
| 1621 | + return; |
---|
| 1622 | + } |
---|
| 1623 | + |
---|
| 1624 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1625 | + |
---|
| 1626 | + //Color col = Color.getHSBColor(color,modulation,1); |
---|
| 1627 | + //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
| 1628 | + if (!material.multiply) |
---|
| 1629 | + { |
---|
| 1630 | + display.color = material.color; |
---|
| 1631 | + display.saturation = material.modulation; |
---|
| 1632 | + } |
---|
| 1633 | + else |
---|
| 1634 | + { |
---|
| 1635 | + display.color *= material.color*2; |
---|
| 1636 | + display.saturation *= material.modulation*2; |
---|
| 1637 | + } |
---|
| 1638 | + |
---|
| 1639 | + cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
| 1640 | + |
---|
| 1641 | + float[] colorV = Grafreed.colorV; |
---|
| 1642 | + |
---|
| 1643 | + /**/ |
---|
| 1644 | + if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
| 1645 | + { |
---|
| 1646 | + colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
| 1647 | + colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
| 1648 | + colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
| 1649 | + colorV[3] = material.opacity; |
---|
| 1650 | + |
---|
| 1651 | + gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
| 1652 | + //System.out.println("Opacity = " + opacity); |
---|
| 1653 | + |
---|
| 1654 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1655 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1656 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1657 | + |
---|
| 1658 | + float amb = material.ambient; |
---|
| 1659 | + if (amb < material.cameralight) |
---|
| 1660 | + { |
---|
| 1661 | + amb = material.cameralight; |
---|
| 1662 | + } |
---|
| 1663 | + colorV[0] = display.modelParams0[0] * material.diffuse * amb; |
---|
| 1664 | + colorV[1] = display.modelParams0[1] * material.diffuse * amb; |
---|
| 1665 | + colorV[2] = display.modelParams0[2] * material.diffuse * amb; |
---|
| 1666 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0); |
---|
| 1667 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1668 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 1669 | + |
---|
| 1670 | + /**/ |
---|
| 1671 | + colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular; |
---|
| 1672 | + colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular; |
---|
| 1673 | + colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular; |
---|
| 1674 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0); |
---|
| 1675 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1676 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0); |
---|
| 1677 | + colorV[0] = 10 / material.shininess; // 1/0.005f; |
---|
| 1678 | + //System.out.println("shininess = " + colorV[0]); |
---|
| 1679 | + if (colorV[0] > 128) |
---|
| 1680 | + { |
---|
| 1681 | + colorV[0] = 128; |
---|
| 1682 | + } |
---|
| 1683 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0); |
---|
| 1684 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0); |
---|
| 1685 | + /**/ |
---|
| 1686 | + } |
---|
| 1687 | + /**/ |
---|
| 1688 | + |
---|
| 1689 | + //selected = false; |
---|
| 1690 | + selected = selected && display.flash; |
---|
| 1691 | + |
---|
| 1692 | + //display.modelParams0[0] = 0; // pigment.r; |
---|
| 1693 | + //display.modelParams0[1] = 0; // pigment.g; |
---|
| 1694 | + //display.modelParams0[2] = 0; // pigment.b; |
---|
| 1695 | + if (!material.multiply) |
---|
| 1696 | + { |
---|
| 1697 | + display.modelParams0[3] = material.metalness; |
---|
| 1698 | + display.modelParams1[0] = material.diffuse; |
---|
| 1699 | + display.modelParams1[1] = material.specular; |
---|
| 1700 | + display.modelParams1[2] = 1 / material.shininess; |
---|
| 1701 | + display.modelParams1[3] = material.shift; |
---|
| 1702 | + display.modelParams2[0] = material.ambient; |
---|
| 1703 | + display.modelParams2[1] = material.lightarea; |
---|
| 1704 | + //System.out.println("light area = " + lightarea); |
---|
| 1705 | + display.modelParams2[2] = 1 / material.factor; // diffuseness |
---|
| 1706 | + display.modelParams2[3] = material.velvet; |
---|
| 1707 | + display.modelParams3[0] = material.sheen; |
---|
| 1708 | + display.modelParams3[1] = material.subsurface; |
---|
| 1709 | + display.modelParams3[2] = material.bump; // backlit |
---|
| 1710 | + display.modelParams3[3] = material.aniso; |
---|
| 1711 | + display.modelParams4[0] = material.anisoV; |
---|
| 1712 | + display.modelParams4[1] = selected ? 100 : material.cameralight; |
---|
| 1713 | + //System.out.println("selected = " + selected); |
---|
| 1714 | + display.modelParams4[2] = material.diffuseness; |
---|
| 1715 | + display.modelParams4[3] = material.shadow; |
---|
| 1716 | + display.modelParams5[0] = material.texture; |
---|
| 1717 | + display.modelParams5[1] = material.opacity; |
---|
| 1718 | + display.modelParams5[2] = material.fakedepth; |
---|
| 1719 | + display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10; |
---|
| 1720 | + } |
---|
| 1721 | + else |
---|
| 1722 | + { |
---|
| 1723 | + display.modelParams0[3] *= material.metalness*2; |
---|
| 1724 | + display.modelParams1[0] *= material.diffuse*2; |
---|
| 1725 | + display.modelParams1[1] *= material.specular*2; |
---|
| 1726 | + display.modelParams1[2] *= material.shininess*2; |
---|
| 1727 | + display.modelParams1[3] *= material.shift*2; |
---|
| 1728 | + display.modelParams2[0] *= material.ambient*2; |
---|
| 1729 | + display.modelParams2[1] *= material.lightarea*2; |
---|
| 1730 | + display.modelParams2[2] *= material.factor*2; |
---|
| 1731 | + display.modelParams2[3] *= material.velvet*2; |
---|
| 1732 | + display.modelParams3[0] *= material.sheen*2; |
---|
| 1733 | + display.modelParams3[1] *= material.subsurface*2; |
---|
| 1734 | + display.modelParams3[2] *= material.bump*2; |
---|
| 1735 | + display.modelParams3[3] *= material.aniso*2; |
---|
| 1736 | + display.modelParams4[0] *= material.anisoV*2; |
---|
| 1737 | + display.modelParams4[1] *= material.cameralight*2; |
---|
| 1738 | + //System.out.println("selected = " + selected); |
---|
| 1739 | + display.modelParams4[2] *= material.diffuseness*2; |
---|
| 1740 | + display.modelParams4[3] *= material.shadow*2; |
---|
| 1741 | + display.modelParams5[0] *= material.texture*2; |
---|
| 1742 | + display.modelParams5[1] *= material.opacity*2; |
---|
| 1743 | + display.modelParams5[2] *= material.fakedepth*2; |
---|
| 1744 | + display.modelParams5[3] *= material.shadowbias*2; |
---|
| 1745 | + } |
---|
| 1746 | + |
---|
| 1747 | + display.modelParams6[0] = 0; |
---|
| 1748 | + display.modelParams6[1] = 0; |
---|
| 1749 | + display.modelParams6[2] = 0; |
---|
| 1750 | + display.modelParams6[3] = 0; |
---|
| 1751 | + |
---|
| 1752 | + display.modelParams7[0] = 0; |
---|
| 1753 | + display.modelParams7[1] = 1000; |
---|
| 1754 | + display.modelParams7[2] = 0; |
---|
| 1755 | + display.modelParams7[3] = 0; |
---|
| 1756 | + |
---|
| 1757 | + display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1758 | + |
---|
| 1759 | + Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1760 | + if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
| 1761 | + { |
---|
| 1762 | + display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
| 1763 | + display.modelParams6[1] = extparams[0].y / 1000.0f; // noise |
---|
| 1764 | + if (extparams.length > 1) |
---|
| 1765 | + { |
---|
| 1766 | + display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade |
---|
| 1767 | + display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough |
---|
| 1768 | + if (extparams.length > 2) |
---|
| 1769 | + { |
---|
| 1770 | + display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power |
---|
| 1771 | + float x = extparams[2].y / 1000.0f; |
---|
| 1772 | + //if (x == 0) |
---|
| 1773 | + // x = 1f; |
---|
| 1774 | + 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 |
---|
| 1775 | + if (extparams[2].y > 0) |
---|
| 1776 | + { |
---|
| 1777 | + //System.out.println("extparams[1].y = " + extparams[1].y); |
---|
| 1778 | + //System.out.println("extparams[2].y = " + extparams[2].y); |
---|
| 1779 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1780 | + } |
---|
| 1781 | + } |
---|
| 1782 | + } |
---|
| 1783 | + } |
---|
| 1784 | + |
---|
| 1785 | + //if (display.modelParams6[2] != 0) |
---|
| 1786 | + /* |
---|
| 1787 | + System.out.println("modelParams0[0] = " + display.modelParams0[0]); |
---|
| 1788 | + System.out.println("modelParams0[1] = " + display.modelParams0[1]); |
---|
| 1789 | + System.out.println("modelParams0[2] = " + display.modelParams0[2]); |
---|
| 1790 | + System.out.println("modelParams0[3] = " + display.modelParams0[3]); |
---|
| 1791 | + System.out.println("modelParams1[0] = " + display.modelParams1[0]); |
---|
| 1792 | + System.out.println("modelParams1[1] = " + display.modelParams1[1]); |
---|
| 1793 | + System.out.println("modelParams1[2] = " + display.modelParams1[2]); |
---|
| 1794 | + System.out.println("modelParams1[3] = " + display.modelParams1[3]); |
---|
| 1795 | + System.out.println("modelParams2[0] = " + display.modelParams2[0]); |
---|
| 1796 | + System.out.println("modelParams2[1] = " + display.modelParams2[1]); |
---|
| 1797 | + System.out.println("modelParams2[2] = " + display.modelParams2[2]); |
---|
| 1798 | + System.out.println("modelParams2[3] = " + display.modelParams2[3]); |
---|
| 1799 | + System.out.println("modelParams3[0] = " + display.modelParams3[0]); |
---|
| 1800 | + System.out.println("modelParams3[1] = " + display.modelParams3[1]); |
---|
| 1801 | + System.out.println("modelParams3[2] = " + display.modelParams3[2]); |
---|
| 1802 | + System.out.println("modelParams3[3] = " + display.modelParams3[3]); |
---|
| 1803 | + System.out.println("modelParams4[0] = " + display.modelParams4[0]); |
---|
| 1804 | + System.out.println("modelParams4[1] = " + display.modelParams4[1]); |
---|
| 1805 | + System.out.println("modelParams4[2] = " + display.modelParams4[2]); |
---|
| 1806 | + System.out.println("modelParams4[3] = " + display.modelParams4[3]); |
---|
| 1807 | + System.out.println("modelParams5[0] = " + display.modelParams5[0]); |
---|
| 1808 | + System.out.println("modelParams5[1] = " + display.modelParams5[1]); |
---|
| 1809 | + System.out.println("modelParams5[2] = " + display.modelParams5[2]); |
---|
| 1810 | + System.out.println("modelParams5[3] = " + display.modelParams5[3]); |
---|
| 1811 | + System.out.println("modelParams6[0] = " + display.modelParams6[0]); |
---|
| 1812 | + System.out.println("modelParams6[1] = " + display.modelParams6[1]); |
---|
| 1813 | + System.out.println("modelParams6[2] = " + display.modelParams6[2]); |
---|
| 1814 | + System.out.println("modelParams6[3] = " + display.modelParams6[3]); |
---|
| 1815 | + System.out.println("modelParams7[0] = " + display.modelParams7[0]); |
---|
| 1816 | + System.out.println("modelParams7[1] = " + display.modelParams7[1]); |
---|
| 1817 | + System.out.println("modelParams7[2] = " + display.modelParams7[2]); |
---|
| 1818 | + System.out.println("modelParams7[3] = " + display.modelParams7[3]); |
---|
| 1819 | + /**/ |
---|
| 1820 | + //assert (display.modelParams6[2] == 0); |
---|
| 1821 | + |
---|
| 1822 | + //System.out.println("noise power = " + display.modelParams7[0]); |
---|
| 1823 | + //System.out.println("shadowbias = " + shadowbias); |
---|
| 1824 | + |
---|
| 1825 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1826 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0); |
---|
| 1827 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0); |
---|
| 1828 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0); |
---|
| 1829 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 1830 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1831 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0); |
---|
| 1832 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0); |
---|
| 1833 | + |
---|
| 1834 | + int mode = display.FP_SHADER; |
---|
| 1835 | + |
---|
| 1836 | + if (material.aniso != material.anisoV || material.aniso > 0.002) |
---|
| 1837 | + { |
---|
| 1838 | + mode |= display.FP_ANISO; |
---|
| 1839 | + } |
---|
| 1840 | + |
---|
| 1841 | + display.EnableProgram(mode); |
---|
| 1842 | + |
---|
| 1843 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1844 | + |
---|
| 1845 | + if (!material.multiply) |
---|
| 1846 | + { |
---|
| 1847 | + if (Globals.drawMode == CameraPane.SHADOW) |
---|
| 1848 | + gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1); |
---|
| 1849 | + else |
---|
| 1850 | + gl.glDepthMask(material.opacity >= 0.99); |
---|
| 1851 | + } |
---|
208 | 1852 | } |
---|
209 | 1853 | |
---|
210 | 1854 | int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0; |
---|
.. | .. |
---|
225 | 1869 | currentGL.glMultMatrixd(model, 0); |
---|
226 | 1870 | } |
---|
227 | 1871 | |
---|
228 | | - void PushMatrix(double[][] matrix, int count) |
---|
| 1872 | + public void PushMatrix(double[][] matrix, int count) // INTERFACE |
---|
229 | 1873 | { |
---|
230 | 1874 | matrixdepth++; |
---|
231 | 1875 | // GrafreeD.tracein(matrix); |
---|
.. | .. |
---|
254 | 1898 | void PushMatrix(double[][] matrix) |
---|
255 | 1899 | { |
---|
256 | 1900 | // GrafreeD.tracein(matrix); |
---|
257 | | - PushMatrix(matrix,1); |
---|
| 1901 | + PushMatrix(matrix, 1); |
---|
258 | 1902 | } |
---|
259 | 1903 | |
---|
260 | 1904 | void PushMatrix() |
---|
.. | .. |
---|
270 | 1914 | |
---|
271 | 1915 | double[][] tmpmat = new double[4][4]; |
---|
272 | 1916 | |
---|
273 | | - void PopMatrix(double[][] inverse) |
---|
| 1917 | + public void PopMatrix(double[][] inverse) // INTERFACE |
---|
274 | 1918 | { |
---|
275 | 1919 | --matrixdepth; |
---|
276 | 1920 | |
---|
.. | .. |
---|
310 | 1954 | PushTextureMatrix(matrix, 1); |
---|
311 | 1955 | } |
---|
312 | 1956 | |
---|
313 | | - void PushTextureMatrix(double[][] matrix, int count) |
---|
| 1957 | + public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE |
---|
314 | 1958 | { |
---|
315 | 1959 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
316 | 1960 | |
---|
.. | .. |
---|
324 | 1968 | currentGL.glMatrixMode(GetGL().GL_MODELVIEW); |
---|
325 | 1969 | } |
---|
326 | 1970 | |
---|
327 | | - void PopTextureMatrix(double[][] inverse) |
---|
| 1971 | + public void PopTextureMatrix(double[][] inverse) // INTERFACE |
---|
328 | 1972 | { |
---|
329 | 1973 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
330 | 1974 | currentGL.glMatrixMode(GetGL().GL_TEXTURE); |
---|
.. | .. |
---|
351 | 1995 | |
---|
352 | 1996 | static int camerachangeframe; |
---|
353 | 1997 | |
---|
354 | | - boolean SetCamera(Camera cam) |
---|
| 1998 | + public boolean SetCamera(Camera cam) |
---|
355 | 1999 | { |
---|
356 | 2000 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
357 | 2001 | // return false; |
---|
358 | 2002 | |
---|
359 | | - if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount) |
---|
| 2003 | + if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount) |
---|
360 | 2004 | { |
---|
361 | 2005 | // check for last change |
---|
362 | | - if (framecount < camerachangeframe + 400) // 120 == 1 second |
---|
| 2006 | + if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second |
---|
363 | 2007 | { |
---|
364 | 2008 | // refuse the camera change |
---|
365 | 2009 | System.err.println("Camera " + cam + " REFUSED"); |
---|
.. | .. |
---|
367 | 2011 | } |
---|
368 | 2012 | } |
---|
369 | 2013 | |
---|
370 | | - camerachangeframe = framecount; |
---|
| 2014 | + camerachangeframe = Globals.framecount; |
---|
371 | 2015 | |
---|
372 | 2016 | cam.hAspect = -1; // Read only |
---|
373 | 2017 | |
---|
.. | .. |
---|
398 | 2042 | { |
---|
399 | 2043 | //System.err.println("Oeil on"); |
---|
400 | 2044 | TRACK = true; |
---|
401 | | -// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 2045 | +// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
402 | 2046 | // object.editWindow.ScreenFit(trackedobject); |
---|
403 | 2047 | //pingthread.StepToTarget(true); |
---|
404 | 2048 | } |
---|
.. | .. |
---|
407 | 2051 | { |
---|
408 | 2052 | //System.err.println("Oeil on"); |
---|
409 | 2053 | OEIL = true; |
---|
410 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 2054 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
411 | 2055 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
412 | 2056 | //pingthread.StepToTarget(true); |
---|
413 | 2057 | } |
---|
.. | .. |
---|
471 | 2115 | { |
---|
472 | 2116 | frozen ^= true; |
---|
473 | 2117 | // Weird... |
---|
474 | | - lighttouched = true; |
---|
| 2118 | + Globals.lighttouched = true; |
---|
475 | 2119 | } |
---|
476 | 2120 | |
---|
477 | 2121 | void ToggleDL() |
---|
478 | 2122 | { |
---|
479 | 2123 | 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 | 2124 | } |
---|
508 | 2125 | |
---|
509 | 2126 | void ToggleFullScreen() |
---|
.. | .. |
---|
513 | 2130 | |
---|
514 | 2131 | void ToggleCrowd() |
---|
515 | 2132 | { |
---|
516 | | - CROWD ^= true; |
---|
517 | | - } |
---|
518 | | - |
---|
519 | | - void ToggleInertia() |
---|
520 | | - { |
---|
521 | | - INERTIA ^= true; |
---|
| 2133 | + Globals.CROWD ^= true; |
---|
522 | 2134 | } |
---|
523 | 2135 | |
---|
524 | 2136 | void ToggleLocal() |
---|
.. | .. |
---|
526 | 2138 | LOCALTRANSFORM ^= true; |
---|
527 | 2139 | } |
---|
528 | 2140 | |
---|
529 | | - void ToggleFast() |
---|
| 2141 | + public void ToggleTexture() |
---|
| 2142 | + { |
---|
| 2143 | + textureon ^= true; |
---|
| 2144 | + } |
---|
| 2145 | + |
---|
| 2146 | + public void ToggleLive() |
---|
| 2147 | + { |
---|
| 2148 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
| 2149 | + |
---|
| 2150 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
| 2151 | + |
---|
| 2152 | + if (!Globals.isLIVE()) // save sound |
---|
| 2153 | + Grafreed.savesound = true; // wav.save(); |
---|
| 2154 | + // else |
---|
| 2155 | + repaint(); // start loop // may 2013 |
---|
| 2156 | + } |
---|
| 2157 | + |
---|
| 2158 | + public void ToggleSupport() |
---|
| 2159 | + { |
---|
| 2160 | + SUPPORT ^= true; |
---|
| 2161 | + } |
---|
| 2162 | + |
---|
| 2163 | + public void ToggleAbort() |
---|
| 2164 | + { |
---|
| 2165 | + ABORTMODE ^= true; |
---|
| 2166 | + } |
---|
| 2167 | + |
---|
| 2168 | + public void ToggleInertia() |
---|
| 2169 | + { |
---|
| 2170 | + INERTIA ^= true; |
---|
| 2171 | + } |
---|
| 2172 | + |
---|
| 2173 | + public void ToggleFast() |
---|
530 | 2174 | { |
---|
531 | 2175 | FAST ^= true; |
---|
532 | 2176 | } |
---|
533 | 2177 | |
---|
534 | | - void ToggleSlowPose() |
---|
| 2178 | + public void ToggleSlowPose() |
---|
535 | 2179 | { |
---|
536 | 2180 | SLOWPOSE ^= true; |
---|
537 | 2181 | } |
---|
538 | 2182 | |
---|
539 | | - void ToggleFootContact() |
---|
540 | | - { |
---|
541 | | - FOOTCONTACT ^= true; |
---|
542 | | - } |
---|
543 | | - |
---|
544 | | - void ToggleBoxMode() |
---|
| 2183 | + public void ToggleBoxMode() |
---|
545 | 2184 | { |
---|
546 | 2185 | BOXMODE ^= true; |
---|
547 | 2186 | } |
---|
548 | 2187 | |
---|
549 | | - void ToggleSmoothFocus() |
---|
| 2188 | + public void ToggleZoomBoxMode() |
---|
| 2189 | + { |
---|
| 2190 | + ZOOMBOXMODE ^= true; |
---|
| 2191 | + } |
---|
| 2192 | + |
---|
| 2193 | + public void ToggleSmoothFocus() |
---|
550 | 2194 | { |
---|
551 | 2195 | SMOOTHFOCUS ^= true; |
---|
552 | 2196 | } |
---|
553 | 2197 | |
---|
554 | | - void ToggleImageFlip() |
---|
| 2198 | + public void ToggleImageFlip() |
---|
555 | 2199 | { |
---|
556 | 2200 | IMAGEFLIP ^= true; |
---|
557 | 2201 | } |
---|
558 | 2202 | |
---|
559 | | - void ToggleSpeakerMocap() |
---|
| 2203 | + public void ToggleSpeakerMocap() |
---|
560 | 2204 | { |
---|
561 | 2205 | SPEAKERMOCAP ^= true; |
---|
562 | 2206 | } |
---|
563 | 2207 | |
---|
564 | | - void ToggleSpeakerCamera() |
---|
| 2208 | + public void ToggleSpeakerCamera() |
---|
565 | 2209 | { |
---|
566 | 2210 | SPEAKERCAMERA ^= true; |
---|
567 | 2211 | } |
---|
568 | 2212 | |
---|
569 | | - void ToggleSpeakerFocus() |
---|
| 2213 | + public void ToggleSpeakerFocus() |
---|
570 | 2214 | { |
---|
571 | 2215 | SPEAKERFOCUS ^= true; |
---|
572 | 2216 | } |
---|
573 | 2217 | |
---|
574 | | - void ToggleDebug() |
---|
575 | | - { |
---|
576 | | - DEBUG ^= true; |
---|
577 | | - } |
---|
578 | | - |
---|
579 | | - void ToggleFrustum() |
---|
| 2218 | + public void ToggleFrustum() |
---|
580 | 2219 | { |
---|
581 | 2220 | FRUSTUM ^= true; |
---|
582 | 2221 | } |
---|
583 | 2222 | |
---|
584 | | - void ToggleTrack() |
---|
| 2223 | + public void ToggleTrack() |
---|
585 | 2224 | { |
---|
586 | 2225 | TRACK ^= true; |
---|
587 | 2226 | if (TRACK) |
---|
.. | .. |
---|
600 | 2239 | repaint(); |
---|
601 | 2240 | } |
---|
602 | 2241 | |
---|
603 | | - void ToggleTrackOnce() |
---|
| 2242 | + public void ToggleTrackOnce() |
---|
604 | 2243 | { |
---|
605 | 2244 | TRACKONCE ^= true; |
---|
606 | 2245 | } |
---|
607 | 2246 | |
---|
608 | | - void ToggleShadowTrack() |
---|
| 2247 | + public void ToggleShadowTrack() |
---|
609 | 2248 | { |
---|
610 | 2249 | SHADOWTRACK ^= true; |
---|
611 | 2250 | repaint(); |
---|
612 | 2251 | } |
---|
613 | 2252 | |
---|
614 | | - void ToggleOeil() |
---|
| 2253 | + public void ToggleOeil() |
---|
615 | 2254 | { |
---|
616 | 2255 | OEIL ^= true; |
---|
617 | 2256 | } |
---|
618 | 2257 | |
---|
619 | | - void ToggleOeilOnce() |
---|
| 2258 | + public void ToggleOeilOnce() |
---|
620 | 2259 | { |
---|
621 | 2260 | OEILONCE ^= true; |
---|
| 2261 | + } |
---|
| 2262 | + |
---|
| 2263 | + void ToggleFootContact() |
---|
| 2264 | + { |
---|
| 2265 | + FOOTCONTACT ^= true; |
---|
| 2266 | + } |
---|
| 2267 | + |
---|
| 2268 | + void ToggleDebug() |
---|
| 2269 | + { |
---|
| 2270 | + DEBUG ^= true; |
---|
622 | 2271 | } |
---|
623 | 2272 | |
---|
624 | 2273 | void ToggleLookAt() |
---|
.. | .. |
---|
626 | 2275 | LOOKAT ^= true; |
---|
627 | 2276 | } |
---|
628 | 2277 | |
---|
629 | | - void ToggleRandom() |
---|
| 2278 | + void ToggleSwitch() |
---|
630 | 2279 | { |
---|
631 | | - RANDOM ^= true; |
---|
| 2280 | + SWITCH ^= true; |
---|
632 | 2281 | } |
---|
633 | 2282 | |
---|
634 | 2283 | void ToggleHandles() |
---|
.. | .. |
---|
672 | 2321 | //assert (cam.hAspect == 0); |
---|
673 | 2322 | cam.hAspect = 0; |
---|
674 | 2323 | 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 | 2324 | } |
---|
704 | 2325 | |
---|
705 | 2326 | private static void ApplyTransform(GL gl, Mat4f xform) |
---|
.. | .. |
---|
759 | 2380 | |
---|
760 | 2381 | GL currentGL; |
---|
761 | 2382 | |
---|
762 | | - GL GetGL() |
---|
| 2383 | + public GL GetGL() // INTERFACE |
---|
763 | 2384 | { |
---|
764 | 2385 | return currentGL; |
---|
765 | 2386 | } |
---|
766 | | - |
---|
| 2387 | + |
---|
767 | 2388 | /**/ |
---|
768 | 2389 | class CacheTexture |
---|
769 | 2390 | { |
---|
.. | .. |
---|
2595 | 4216 | |
---|
2596 | 4217 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
2597 | 4218 | { |
---|
| 4219 | + new Exception().printStackTrace(); |
---|
2598 | 4220 | System.exit(0); |
---|
2599 | 4221 | com.sun.opengl.util.texture.Texture texture = null; |
---|
2600 | 4222 | |
---|
.. | .. |
---|
6271 | 7893 | return null; |
---|
6272 | 7894 | } |
---|
6273 | 7895 | |
---|
6274 | | - void ReleaseTextures(cTexture tex) |
---|
| 7896 | + public void ReleaseTextures(cTexture tex) // INTERFACE |
---|
6275 | 7897 | { |
---|
6276 | 7898 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6277 | 7899 | { |
---|
.. | .. |
---|
6307 | 7929 | ReleaseTexture(pigment, false); |
---|
6308 | 7930 | } |
---|
6309 | 7931 | |
---|
| 7932 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 7933 | + { |
---|
| 7934 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 7935 | + { |
---|
| 7936 | + return; |
---|
| 7937 | + } |
---|
| 7938 | + |
---|
| 7939 | + if (tex == null) |
---|
| 7940 | + { |
---|
| 7941 | + ReleaseTexture(null, false); |
---|
| 7942 | + return; |
---|
| 7943 | + } |
---|
| 7944 | + |
---|
| 7945 | + String pigment = Object3D.GetPigment(tex); |
---|
| 7946 | + |
---|
| 7947 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 7948 | + { |
---|
| 7949 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 7950 | + // System.out.println("; bump = " + bump); |
---|
| 7951 | + } |
---|
| 7952 | + |
---|
| 7953 | + if (pigment.equals("")) |
---|
| 7954 | + { |
---|
| 7955 | + pigment = null; |
---|
| 7956 | + } |
---|
| 7957 | + |
---|
| 7958 | + ReleaseTexture(pigment, false); |
---|
| 7959 | + } |
---|
| 7960 | + |
---|
| 7961 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 7962 | + { |
---|
| 7963 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 7964 | + { |
---|
| 7965 | + return; |
---|
| 7966 | + } |
---|
| 7967 | + |
---|
| 7968 | + if (tex == null) |
---|
| 7969 | + { |
---|
| 7970 | + ReleaseTexture(null, true); |
---|
| 7971 | + return; |
---|
| 7972 | + } |
---|
| 7973 | + |
---|
| 7974 | + String bump = Object3D.GetBump(tex); |
---|
| 7975 | + |
---|
| 7976 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 7977 | + { |
---|
| 7978 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 7979 | + // System.out.println("; bump = " + bump); |
---|
| 7980 | + } |
---|
| 7981 | + |
---|
| 7982 | + if (bump.equals("")) |
---|
| 7983 | + { |
---|
| 7984 | + bump = null; |
---|
| 7985 | + } |
---|
| 7986 | + |
---|
| 7987 | + ReleaseTexture(bump, true); |
---|
| 7988 | + } |
---|
| 7989 | + |
---|
6310 | 7990 | void ReleaseTexture(String tex, boolean bump) |
---|
6311 | 7991 | { |
---|
6312 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 7992 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6313 | 7993 | ambientOcclusion ) // || !textureon) |
---|
6314 | 7994 | { |
---|
6315 | 7995 | return; |
---|
.. | .. |
---|
6410 | 8090 | } |
---|
6411 | 8091 | } |
---|
6412 | 8092 | |
---|
6413 | | - /*boolean*/ void BindTextures(cTexture tex, int resolution) |
---|
| 8093 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
6414 | 8094 | { |
---|
6415 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 8095 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6416 | 8096 | ambientOcclusion ) // || !textureon) |
---|
6417 | 8097 | { |
---|
6418 | 8098 | return; // false; |
---|
.. | .. |
---|
6455 | 8135 | return; // true; |
---|
6456 | 8136 | } |
---|
6457 | 8137 | |
---|
6458 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8138 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8139 | + { |
---|
| 8140 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8141 | + ambientOcclusion ) // || !textureon) |
---|
| 8142 | + { |
---|
| 8143 | + return; // false; |
---|
| 8144 | + } |
---|
| 8145 | + |
---|
| 8146 | + if (tex == null) |
---|
| 8147 | + { |
---|
| 8148 | + BindTexture(null,false,resolution); |
---|
| 8149 | + return; |
---|
| 8150 | + } |
---|
| 8151 | + |
---|
| 8152 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8153 | + |
---|
| 8154 | + usedtextures.put(pigment, pigment); |
---|
| 8155 | + |
---|
| 8156 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8157 | + { |
---|
| 8158 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8159 | + // System.out.println("; bump = " + bump); |
---|
| 8160 | + } |
---|
| 8161 | + |
---|
| 8162 | + if (pigment.equals("")) |
---|
| 8163 | + { |
---|
| 8164 | + pigment = null; |
---|
| 8165 | + } |
---|
| 8166 | + |
---|
| 8167 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8168 | + BindTexture(pigment, false, resolution); |
---|
| 8169 | + } |
---|
| 8170 | + |
---|
| 8171 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8172 | + { |
---|
| 8173 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8174 | + ambientOcclusion ) // || !textureon) |
---|
| 8175 | + { |
---|
| 8176 | + return; // false; |
---|
| 8177 | + } |
---|
| 8178 | + |
---|
| 8179 | + if (tex == null) |
---|
| 8180 | + { |
---|
| 8181 | + BindTexture(null,true,resolution); |
---|
| 8182 | + return; |
---|
| 8183 | + } |
---|
| 8184 | + |
---|
| 8185 | + String bump = Object3D.GetBump(tex); |
---|
| 8186 | + |
---|
| 8187 | + usedtextures.put(bump, bump); |
---|
| 8188 | + |
---|
| 8189 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8190 | + { |
---|
| 8191 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8192 | + // System.out.println("; bump = " + bump); |
---|
| 8193 | + } |
---|
| 8194 | + |
---|
| 8195 | + if (bump.equals("")) |
---|
| 8196 | + { |
---|
| 8197 | + bump = null; |
---|
| 8198 | + } |
---|
| 8199 | + |
---|
| 8200 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8201 | + BindTexture(bump, true, resolution); |
---|
| 8202 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8203 | + } |
---|
| 8204 | + |
---|
| 8205 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8206 | + |
---|
| 8207 | + private boolean FileExists(String tex) |
---|
| 8208 | + { |
---|
| 8209 | + if (missingTextures.contains(tex)) |
---|
| 8210 | + { |
---|
| 8211 | + return false; |
---|
| 8212 | + } |
---|
| 8213 | + |
---|
| 8214 | + boolean fileExists = new File(tex).exists(); |
---|
| 8215 | + |
---|
| 8216 | + if (!fileExists) |
---|
| 8217 | + { |
---|
| 8218 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8219 | + missingTextures.add(tex); |
---|
| 8220 | + } |
---|
| 8221 | + |
---|
| 8222 | + return fileExists; |
---|
| 8223 | + } |
---|
| 8224 | + |
---|
| 8225 | + CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
6459 | 8226 | { |
---|
6460 | 8227 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
6461 | 8228 | |
---|
.. | .. |
---|
6463 | 8230 | { |
---|
6464 | 8231 | String texname = tex; |
---|
6465 | 8232 | |
---|
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; |
---|
| 8233 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8234 | + |
---|
| 8235 | +// String[] split = tex.split("Textures"); |
---|
| 8236 | +// if (split.length > 1) |
---|
| 8237 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8238 | +// else |
---|
| 8239 | +// if (!texname.startsWith("/")) |
---|
| 8240 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8241 | + if (!FileExists(tex)) |
---|
| 8242 | + { |
---|
| 8243 | + texname = fallbackTextureName; |
---|
| 8244 | + } |
---|
6472 | 8245 | |
---|
6473 | 8246 | if (CACHETEXTURE) |
---|
6474 | 8247 | texture = textures.get(texname); // TEXTURE CACHE |
---|
.. | .. |
---|
6537 | 8310 | } |
---|
6538 | 8311 | |
---|
6539 | 8312 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
6540 | | - if (!new File(cachename).exists()) |
---|
| 8313 | + if (!FileExists(cachename)) |
---|
6541 | 8314 | cachename = texname; |
---|
6542 | 8315 | else |
---|
6543 | 8316 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
6559 | 8332 | } |
---|
6560 | 8333 | |
---|
6561 | 8334 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
6562 | | - if (!new File(cachename).exists()) |
---|
| 8335 | + if (!FileExists(cachename)) |
---|
6563 | 8336 | cachename = texname; |
---|
6564 | 8337 | else |
---|
6565 | 8338 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
6568 | 8341 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
6569 | 8342 | |
---|
6570 | 8343 | |
---|
6571 | | - if (texturedata != null) |
---|
| 8344 | + if (texturedata == null) |
---|
| 8345 | + throw new Exception(); |
---|
| 8346 | + |
---|
6572 | 8347 | texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
6573 | 8348 | //texture = GetTexture(tex, bump); |
---|
6574 | 8349 | } |
---|
.. | .. |
---|
6690 | 8465 | return texture; |
---|
6691 | 8466 | } |
---|
6692 | 8467 | |
---|
6693 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8468 | + com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
6694 | 8469 | { |
---|
6695 | 8470 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
6696 | 8471 | |
---|
.. | .. |
---|
6708 | 8483 | return texture!=null?texture.texture:null; |
---|
6709 | 8484 | } |
---|
6710 | 8485 | |
---|
6711 | | - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8486 | + public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
6712 | 8487 | { |
---|
6713 | 8488 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
6714 | 8489 | |
---|
6715 | 8490 | return texture!=null?texture.texturedata:null; |
---|
6716 | 8491 | } |
---|
6717 | 8492 | |
---|
6718 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8493 | + boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
6719 | 8494 | { |
---|
6720 | 8495 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6721 | 8496 | { |
---|
.. | .. |
---|
7312 | 9087 | static boolean occlusionInitialized = false; |
---|
7313 | 9088 | boolean selection = false; |
---|
7314 | 9089 | boolean pointselection = false; |
---|
7315 | | - /*static*/ boolean lighttouched = true; |
---|
| 9090 | + ///*static*/ boolean lighttouched = true; |
---|
7316 | 9091 | boolean deselect; |
---|
7317 | | - boolean ambientOcclusion = false; |
---|
| 9092 | + private boolean ambientOcclusion = false; |
---|
7318 | 9093 | static boolean flash = false; |
---|
7319 | 9094 | /*static*/ boolean wait = false; |
---|
7320 | 9095 | boolean displaydone = false; // after repaint() calls |
---|
.. | .. |
---|
7444 | 9219 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
7445 | 9220 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
7446 | 9221 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 9222 | +// PATCH FILLE AUX JEANS |
---|
| 9223 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
7447 | 9224 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
7448 | 9225 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
7449 | 9226 | |
---|
.. | .. |
---|
7601 | 9378 | |
---|
7602 | 9379 | boolean restartframe = false; |
---|
7603 | 9380 | |
---|
7604 | | - static int framecount = 0; // general-purpose global count |
---|
7605 | | - |
---|
7606 | 9381 | void displayAntiAliased(javax.media.opengl.GL gl) |
---|
7607 | 9382 | { |
---|
7608 | 9383 | //gl.glGetIntegerv(gl.GL_ACCUM_RED_BITS, viewport, 0); |
---|
.. | .. |
---|
7633 | 9408 | gl.glClear(gl.GL_ACCUM_BUFFER_BIT); |
---|
7634 | 9409 | for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0) |
---|
7635 | 9410 | { |
---|
7636 | | - framecount++; |
---|
| 9411 | + Globals.framecount++; |
---|
7637 | 9412 | |
---|
7638 | 9413 | if (CameraPane.tickcount > 0) |
---|
7639 | 9414 | CameraPane.tickcount--; |
---|
.. | .. |
---|
7671 | 9446 | |
---|
7672 | 9447 | gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0); |
---|
7673 | 9448 | */ |
---|
7674 | | - lighttouched = true; |
---|
| 9449 | + Globals.lighttouched = true; |
---|
7675 | 9450 | //System.err.println(" shadowbuffer: " + jitter); |
---|
7676 | 9451 | shadowbuffer.display(); |
---|
7677 | 9452 | |
---|
.. | .. |
---|
7692 | 9467 | assert (parentcam != renderCamera); |
---|
7693 | 9468 | |
---|
7694 | 9469 | if (renderCamera != lightCamera) |
---|
7695 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7696 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9470 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9471 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
7697 | 9472 | |
---|
7698 | 9473 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
7699 | 9474 | |
---|
.. | .. |
---|
7708 | 9483 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
7709 | 9484 | |
---|
7710 | 9485 | if (renderCamera != lightCamera) |
---|
7711 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7712 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9486 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9487 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
7713 | 9488 | |
---|
7714 | 9489 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
7715 | 9490 | |
---|
.. | .. |
---|
7781 | 9556 | //gl.glFlush(); |
---|
7782 | 9557 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
7783 | 9558 | |
---|
7784 | | - if (ANIMATION && ABORTED) |
---|
| 9559 | + if (Globals.ANIMATION && ABORTED) |
---|
7785 | 9560 | { |
---|
7786 | 9561 | System.err.println(" ABORTED FRAME"); |
---|
7787 | 9562 | break; |
---|
.. | .. |
---|
7811 | 9586 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
7812 | 9587 | |
---|
7813 | 9588 | // save image |
---|
7814 | | - if (ANIMATION && !ABORTED) |
---|
| 9589 | + if (Globals.ANIMATION && !ABORTED) |
---|
7815 | 9590 | { |
---|
7816 | 9591 | VPwidth = viewport[2]; |
---|
7817 | 9592 | VPheight = viewport[3]; |
---|
.. | .. |
---|
7922 | 9697 | |
---|
7923 | 9698 | // imagecount++; |
---|
7924 | 9699 | |
---|
7925 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9700 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
7926 | 9701 | |
---|
7927 | 9702 | if (!BOXMODE) |
---|
7928 | 9703 | { |
---|
7929 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9704 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
7930 | 9705 | } |
---|
7931 | 9706 | |
---|
7932 | 9707 | if (!BOXMODE) |
---|
.. | .. |
---|
7964 | 9739 | ABORTED = false; |
---|
7965 | 9740 | } |
---|
7966 | 9741 | else |
---|
7967 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 9742 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
7968 | 9743 | |
---|
7969 | 9744 | if (false) |
---|
7970 | 9745 | { |
---|
.. | .. |
---|
8618 | 10393 | } |
---|
8619 | 10394 | } |
---|
8620 | 10395 | |
---|
8621 | | - boolean IsFrozen() |
---|
8622 | | - { |
---|
8623 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
8624 | | - |
---|
8625 | | - return !selectmode && cameracount == 0; // != 0; |
---|
8626 | | - } |
---|
8627 | | - |
---|
8628 | 10396 | boolean niceon = false; |
---|
8629 | 10397 | javax.swing.Timer AAtimer = new javax.swing.Timer(750, this); |
---|
8630 | 10398 | boolean currentlydrawing = false; |
---|
.. | .. |
---|
8634 | 10402 | |
---|
8635 | 10403 | public void display(GLAutoDrawable drawable) |
---|
8636 | 10404 | { |
---|
8637 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10405 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
8638 | 10406 | { |
---|
8639 | | - GrafreeD.wav.save(); |
---|
8640 | | - GrafreeD.savesound = false; |
---|
8641 | | - GrafreeD.hassound = false; |
---|
| 10407 | + Grafreed.wav.save(); |
---|
| 10408 | + Grafreed.savesound = false; |
---|
| 10409 | + Grafreed.hassound = false; |
---|
8642 | 10410 | } |
---|
8643 | 10411 | // if (DEBUG_SELECTION) |
---|
8644 | 10412 | // { |
---|
8645 | | -// if (drawMode != SELECTION) |
---|
8646 | | -// drawMode = SELECTION; |
---|
| 10413 | +// if (DrawMode() != SELECTION) |
---|
| 10414 | +// DrawMode() = SELECTION; |
---|
8647 | 10415 | // } |
---|
8648 | 10416 | |
---|
8649 | 10417 | if (!isRenderer) |
---|
.. | .. |
---|
8699 | 10467 | |
---|
8700 | 10468 | //ANTIALIAS = 0; |
---|
8701 | 10469 | |
---|
8702 | | - if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
| 10470 | + if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
8703 | 10471 | { |
---|
8704 | | - if (niceon || isLIVE()) |
---|
| 10472 | + if (niceon || Globals.isLIVE()) |
---|
8705 | 10473 | { |
---|
8706 | 10474 | //if(active == 0) |
---|
8707 | 10475 | // antialiaser = null; |
---|
.. | .. |
---|
8726 | 10494 | assert eyeCamera.shaper_zFar == 1E5f; // 500.0f; |
---|
8727 | 10495 | */ |
---|
8728 | 10496 | |
---|
8729 | | - if (drawMode == DEFAULT) |
---|
| 10497 | + if (DrawMode() == DEFAULT) |
---|
8730 | 10498 | { |
---|
8731 | 10499 | currentlydrawing = true; |
---|
8732 | 10500 | } |
---|
.. | .. |
---|
8757 | 10525 | |
---|
8758 | 10526 | // if(Applet3D.clipboard != null) |
---|
8759 | 10527 | // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent); |
---|
8760 | | -//drawMode = SELECTION; |
---|
| 10528 | +//DrawMode() = SELECTION; |
---|
8761 | 10529 | indexcount = 0; |
---|
8762 | 10530 | |
---|
8763 | | - if (drawMode == OCCLUSION) |
---|
| 10531 | + if (DrawMode() == OCCLUSION) |
---|
8764 | 10532 | { |
---|
8765 | | - drawMode = DEFAULT; |
---|
| 10533 | + Globals.drawMode = DEFAULT; // WARNING |
---|
8766 | 10534 | ambientOcclusion = true; |
---|
8767 | 10535 | setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
---|
8768 | 10536 | Object3D theobject = object; |
---|
8769 | 10537 | Object3D theparent = object.parent; |
---|
8770 | 10538 | object.parent = null; |
---|
8771 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10539 | + object = (Object3D)Grafreed.clone(object); |
---|
8772 | 10540 | object.Stripify(); |
---|
8773 | 10541 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
8774 | 10542 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
8781 | 10549 | ambientOcclusion = false; |
---|
8782 | 10550 | } |
---|
8783 | 10551 | |
---|
8784 | | - if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10552 | + if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
8785 | 10553 | { |
---|
8786 | 10554 | //if (RENDERSHADOW) // ? |
---|
8787 | 10555 | if (!IsFrozen()) |
---|
8788 | 10556 | { |
---|
8789 | 10557 | // dec 2012 |
---|
8790 | | - if (!ambientOcclusion && !(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)) |
---|
| 10558 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
8791 | 10559 | { |
---|
8792 | | - framecount++; |
---|
| 10560 | + Globals.framecount++; |
---|
8793 | 10561 | shadowbuffer.display(); |
---|
8794 | 10562 | } |
---|
8795 | 10563 | } |
---|
8796 | | - lighttouched = false; // ?? |
---|
| 10564 | + Globals.lighttouched = false; // ?? |
---|
8797 | 10565 | //drawing = true; |
---|
8798 | 10566 | //lighttouched = true; |
---|
8799 | 10567 | } |
---|
.. | .. |
---|
8814 | 10582 | //eyeCamera.shaper_fovy = 1; |
---|
8815 | 10583 | } |
---|
8816 | 10584 | |
---|
8817 | | - if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION) |
---|
| 10585 | + if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION) |
---|
8818 | 10586 | { |
---|
8819 | | - //System.out.println("drawMode = " + drawMode); |
---|
| 10587 | + //System.out.println("DrawMode() = " + DrawMode()); |
---|
8820 | 10588 | vertexMode |= VP_PASS; |
---|
8821 | 10589 | //vertexMode |= VP_PROJECTION; |
---|
8822 | 10590 | if (!ambientOcclusion) |
---|
.. | .. |
---|
8876 | 10644 | Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera; |
---|
8877 | 10645 | //Camera lightcam = new Camera(light0); |
---|
8878 | 10646 | |
---|
8879 | | - if (drawMode == SHADOW) |
---|
| 10647 | + if (DrawMode() == SHADOW) |
---|
8880 | 10648 | { |
---|
8881 | 10649 | /* |
---|
8882 | 10650 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
.. | .. |
---|
8914 | 10682 | |
---|
8915 | 10683 | // if (parentcam != renderCamera) // not a light |
---|
8916 | 10684 | if (cam != lightCamera) |
---|
8917 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8918 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10685 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10686 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
8919 | 10687 | |
---|
8920 | 10688 | for (int j = 0; j < 4; j++) |
---|
8921 | 10689 | { |
---|
.. | .. |
---|
8929 | 10697 | |
---|
8930 | 10698 | // if (parentcam != renderCamera) // not a light |
---|
8931 | 10699 | if (cam != lightCamera) |
---|
8932 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8933 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10700 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10701 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
8934 | 10702 | |
---|
8935 | 10703 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
8936 | 10704 | |
---|
.. | .. |
---|
8966 | 10734 | gl.glClear(gl.GL_DEPTH_BUFFER_BIT); |
---|
8967 | 10735 | } else |
---|
8968 | 10736 | { |
---|
8969 | | - if (drawMode != DEFAULT) |
---|
| 10737 | + if (DrawMode() != DEFAULT) |
---|
8970 | 10738 | { |
---|
8971 | 10739 | gl.glClearColor(1, 1, 1, 0); |
---|
8972 | 10740 | } // 1); |
---|
.. | .. |
---|
9031 | 10799 | |
---|
9032 | 10800 | fast &= !ambientOcclusion; |
---|
9033 | 10801 | |
---|
9034 | | - if (drawMode == DEFAULT) |
---|
| 10802 | + if (DrawMode() == DEFAULT) |
---|
9035 | 10803 | { |
---|
9036 | 10804 | //gl.glEnable(gl.GL_ALPHA_TEST); |
---|
9037 | 10805 | //gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
.. | .. |
---|
9092 | 10860 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
9093 | 10861 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9094 | 10862 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 10863 | +// PATCH FILLE AUX JEANS |
---|
| 10864 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9095 | 10865 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9096 | 10866 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9097 | 10867 | |
---|
.. | .. |
---|
9187 | 10957 | // Bump noise |
---|
9188 | 10958 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
9189 | 10959 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
9190 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 10960 | + |
---|
| 10961 | + try |
---|
| 10962 | + { |
---|
| 10963 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 10964 | + } |
---|
| 10965 | + catch (Exception e) |
---|
| 10966 | + { |
---|
| 10967 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 10968 | + } |
---|
| 10969 | + |
---|
9191 | 10970 | |
---|
9192 | 10971 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
9193 | 10972 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9227 | 11006 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
9228 | 11007 | gl.glLoadIdentity(); |
---|
9229 | 11008 | |
---|
9230 | | - if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
| 11009 | + if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
9231 | 11010 | { |
---|
9232 | 11011 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9233 | 11012 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 11013 | +// PATCH FILLE AUX JEANS |
---|
| 11014 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9234 | 11015 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9235 | 11016 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9236 | 11017 | //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE); |
---|
.. | .. |
---|
9283 | 11064 | //gl.glPushMatrix(); |
---|
9284 | 11065 | gl.glLoadIdentity(); |
---|
9285 | 11066 | |
---|
9286 | | - if (!ambientOcclusion) // drawMode != OCCLUSION) |
---|
| 11067 | + if (!ambientOcclusion) // DrawMode() != OCCLUSION) |
---|
9287 | 11068 | { |
---|
9288 | 11069 | //LA.xformPos(light0, lightCamera.fromScreen, light); |
---|
9289 | 11070 | LA.xformDir(dirlight, lightCamera.fromScreen, lightposition); |
---|
.. | .. |
---|
9310 | 11091 | System.err.println("parentcam != renderCamera"); |
---|
9311 | 11092 | |
---|
9312 | 11093 | // if (cam != lightCamera) |
---|
9313 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9314 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11094 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11095 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
9315 | 11096 | } |
---|
9316 | 11097 | |
---|
9317 | 11098 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
9332 | 11113 | if (true) // TODO |
---|
9333 | 11114 | { |
---|
9334 | 11115 | if (cam != lightCamera) |
---|
9335 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9336 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11116 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11117 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
9337 | 11118 | } |
---|
9338 | 11119 | |
---|
9339 | 11120 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
9370 | 11151 | } |
---|
9371 | 11152 | |
---|
9372 | 11153 | /**/ |
---|
9373 | | - if (true) // drawMode == SELECTION) // != DEFAULT) |
---|
| 11154 | + if (true) // DrawMode() == SELECTION) // != DEFAULT) |
---|
9374 | 11155 | gl.glDisable(gl.GL_LIGHTING); |
---|
9375 | 11156 | else |
---|
9376 | 11157 | gl.glEnable(gl.GL_LIGHTING); |
---|
.. | .. |
---|
9388 | 11169 | |
---|
9389 | 11170 | lightslot = 64; |
---|
9390 | 11171 | |
---|
9391 | | - if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT) |
---|
| 11172 | + if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT) |
---|
9392 | 11173 | { |
---|
9393 | 11174 | DrawLights(object); |
---|
9394 | 11175 | } |
---|
.. | .. |
---|
9399 | 11180 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
9400 | 11181 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
9401 | 11182 | |
---|
9402 | | - if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION) |
---|
| 11183 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
9403 | 11184 | { |
---|
9404 | 11185 | /* |
---|
9405 | 11186 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
9432 | 11213 | } |
---|
9433 | 11214 | } |
---|
9434 | 11215 | |
---|
9435 | | - if (drawMode == DEFAULT) |
---|
| 11216 | + if (DrawMode() == DEFAULT) |
---|
9436 | 11217 | { |
---|
9437 | 11218 | if (WIREFRAME && !ambientOcclusion) |
---|
9438 | 11219 | { |
---|
.. | .. |
---|
9450 | 11231 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9451 | 11232 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9452 | 11233 | |
---|
9453 | | - if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) // |
---|
| 11234 | + if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) // |
---|
9454 | 11235 | { |
---|
9455 | 11236 | if (vertexMode != 0) // && !fast) |
---|
9456 | 11237 | { |
---|
.. | .. |
---|
9470 | 11251 | } |
---|
9471 | 11252 | } |
---|
9472 | 11253 | |
---|
9473 | | - if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion) |
---|
| 11254 | + if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
9474 | 11255 | { |
---|
9475 | 11256 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
9476 | 11257 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
9498 | 11279 | //gl.glDepthMask(false); |
---|
9499 | 11280 | } |
---|
9500 | 11281 | |
---|
9501 | | - if (false) // drawMode == SHADOW) |
---|
| 11282 | + if (false) // DrawMode() == SHADOW) |
---|
9502 | 11283 | { |
---|
9503 | 11284 | //SetColumnMajorData(cameraInverseTransform, view_1); |
---|
9504 | 11285 | //System.out.println("light = " + cameraInverseTransform); |
---|
.. | .. |
---|
9512 | 11293 | //System.out.println("object = " + object); |
---|
9513 | 11294 | if (!frozen && !imageLocked) |
---|
9514 | 11295 | { |
---|
9515 | | - if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0) |
---|
| 11296 | + if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0) |
---|
9516 | 11297 | { |
---|
9517 | 11298 | displayAntiAliased(gl); |
---|
9518 | 11299 | } else |
---|
9519 | 11300 | { |
---|
9520 | 11301 | programcount = 0; |
---|
9521 | | - int keepmode = drawMode; |
---|
| 11302 | + int keepmode = DrawMode(); |
---|
9522 | 11303 | // if (DEBUG_SELECTION) |
---|
9523 | 11304 | // { |
---|
9524 | | -// drawMode = SELECTION; |
---|
| 11305 | +// DrawMode() = SELECTION; |
---|
9525 | 11306 | // } |
---|
9526 | 11307 | // for point selection |
---|
9527 | 11308 | // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0); |
---|
.. | .. |
---|
9531 | 11312 | DrawObject(gl); |
---|
9532 | 11313 | |
---|
9533 | 11314 | // jan 2013 System.err.println("RESET ABORT (display)"); |
---|
9534 | | - // if (drawMode == DEFAULT) |
---|
| 11315 | + // if (DrawMode() == DEFAULT) |
---|
9535 | 11316 | // ABORTED = false; |
---|
9536 | 11317 | fullreset = false; |
---|
9537 | | - drawMode = keepmode; |
---|
| 11318 | + Globals.drawMode = keepmode; // WARNING |
---|
9538 | 11319 | //System.out.println("PROGRAM SWITCH " + programcount); |
---|
9539 | 11320 | } |
---|
9540 | 11321 | } |
---|
.. | .. |
---|
9542 | 11323 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9543 | 11324 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9544 | 11325 | |
---|
9545 | | - if (drawMode == DEFAULT) |
---|
| 11326 | + if (DrawMode() == DEFAULT) |
---|
9546 | 11327 | { |
---|
9547 | 11328 | ReleaseTexture(NOISE_TEXTURE, false); |
---|
9548 | 11329 | } |
---|
9549 | | - //if (drawMode == DEFAULT) |
---|
| 11330 | + //if (DrawMode() == DEFAULT) |
---|
9550 | 11331 | { |
---|
9551 | 11332 | |
---|
9552 | 11333 | gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
.. | .. |
---|
9558 | 11339 | //else |
---|
9559 | 11340 | //gl.glDisable(gl.GL_TEXTURE_2D); |
---|
9560 | 11341 | //gl.glPopMatrix(); |
---|
9561 | | - if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
| 11342 | + if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
9562 | 11343 | { |
---|
9563 | 11344 | //new Exception().printStackTrace(); |
---|
9564 | 11345 | //System.out.println("Draw image " + width + ", " + height); |
---|
.. | .. |
---|
9600 | 11381 | //gl.glFlush(); |
---|
9601 | 11382 | } |
---|
9602 | 11383 | |
---|
9603 | | - if (flash && drawMode == DEFAULT) |
---|
| 11384 | + if (flash && DrawMode() == DEFAULT) |
---|
9604 | 11385 | { |
---|
9605 | 11386 | flash = false; |
---|
9606 | 11387 | wait = true; |
---|
.. | .. |
---|
9608 | 11389 | } |
---|
9609 | 11390 | |
---|
9610 | 11391 | //drawing = false; |
---|
9611 | | - //if(drawMode == DEFAULT) |
---|
| 11392 | + //if(DrawMode() == DEFAULT) |
---|
9612 | 11393 | // niceon = false; |
---|
9613 | | - if (drawMode == DEFAULT) |
---|
| 11394 | + if (DrawMode() == DEFAULT) |
---|
9614 | 11395 | { |
---|
9615 | 11396 | currentlydrawing = false; |
---|
9616 | 11397 | } |
---|
.. | .. |
---|
9630 | 11411 | repaint(); |
---|
9631 | 11412 | } |
---|
9632 | 11413 | |
---|
9633 | | - if (isLIVE() && drawMode == DEFAULT) // may 2013 |
---|
| 11414 | + if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 |
---|
9634 | 11415 | repaint(); |
---|
9635 | 11416 | |
---|
9636 | 11417 | displaydone = true; |
---|
.. | .. |
---|
9649 | 11430 | { |
---|
9650 | 11431 | renderpass++; |
---|
9651 | 11432 | // System.out.println("Draw object... "); |
---|
| 11433 | + STEP = 1; |
---|
9652 | 11434 | if (FAST) // in case there is no script |
---|
9653 | | - STEP = 16; |
---|
| 11435 | + STEP = 8; |
---|
| 11436 | + |
---|
| 11437 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11438 | + { |
---|
| 11439 | + STEP *= 4; |
---|
| 11440 | + } |
---|
9654 | 11441 | |
---|
9655 | 11442 | //object.FullInvariants(); |
---|
9656 | 11443 | |
---|
.. | .. |
---|
9664 | 11451 | e.printStackTrace(); |
---|
9665 | 11452 | } |
---|
9666 | 11453 | |
---|
9667 | | - if (GrafreeD.RENDERME > 0) |
---|
9668 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11454 | + if (Grafreed.RENDERME > 0) |
---|
| 11455 | + Grafreed.RENDERME--; // mechante magouille |
---|
9669 | 11456 | |
---|
9670 | | - ONESTEP = false; |
---|
| 11457 | + Globals.ONESTEP = false; |
---|
9671 | 11458 | } |
---|
9672 | 11459 | |
---|
9673 | 11460 | static boolean zoomonce = false; |
---|
.. | .. |
---|
9675 | 11462 | void DrawObject(GL gl, boolean draw) |
---|
9676 | 11463 | { |
---|
9677 | 11464 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
9678 | | -// drawMode = SELECTION; |
---|
| 11465 | +// DrawMode() = SELECTION; |
---|
9679 | 11466 | //GL gl = getGL(); |
---|
9680 | 11467 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
9681 | 11468 | { |
---|
9682 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 11469 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
9683 | 11470 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
9684 | 11471 | pingthread.StepToTarget(true); // true); |
---|
9685 | 11472 | // zoomonce = false; |
---|
.. | .. |
---|
9700 | 11487 | callist = gl.glGenLists(1); |
---|
9701 | 11488 | } |
---|
9702 | 11489 | |
---|
9703 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11490 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
9704 | 11491 | |
---|
9705 | | - boolean active = !selectmode; // drawMode != SELECTION; // mouseDown; |
---|
| 11492 | + boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
9706 | 11493 | |
---|
9707 | 11494 | if (!mainDL || !active || touched) |
---|
9708 | 11495 | { |
---|
.. | .. |
---|
9729 | 11516 | PushMatrix(ClickInfo.matbuffer); |
---|
9730 | 11517 | } |
---|
9731 | 11518 | |
---|
9732 | | - if (drawMode == 0) |
---|
| 11519 | + if (DrawMode() == 0) |
---|
9733 | 11520 | { |
---|
9734 | 11521 | // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++"); |
---|
9735 | 11522 | |
---|
9736 | 11523 | usedtextures.clear(); |
---|
9737 | 11524 | |
---|
9738 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11525 | + try |
---|
| 11526 | + { |
---|
| 11527 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11528 | + } |
---|
| 11529 | + catch (Exception e) |
---|
| 11530 | + { |
---|
| 11531 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11532 | + } |
---|
9739 | 11533 | } |
---|
9740 | 11534 | //System.out.println("--> " + stackdepth); |
---|
9741 | 11535 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
9743 | 11537 | // DRAW |
---|
9744 | 11538 | object.draw(this, /*(Composite)*/ object, false, false); |
---|
9745 | 11539 | |
---|
9746 | | - if (drawMode == DEFAULT) |
---|
| 11540 | + if (DrawMode() == DEFAULT) |
---|
9747 | 11541 | { |
---|
9748 | 11542 | if (DEBUG) |
---|
9749 | 11543 | { |
---|
.. | .. |
---|
9754 | 11548 | selectedpoint.radius = radius; |
---|
9755 | 11549 | selectedpoint.recalculate(); |
---|
9756 | 11550 | selectedpoint.material = new cMaterial(); |
---|
9757 | | - selectedpoint.material.color = 0.15f; |
---|
| 11551 | + selectedpoint.material.color = 0.15f; // Yellow |
---|
9758 | 11552 | selectedpoint.material.modulation = 0.75f; |
---|
9759 | 11553 | |
---|
9760 | | - debugpoint.radius = radius; |
---|
9761 | | - debugpoint.recalculate(); |
---|
9762 | | - debugpoint.material = new cMaterial(); |
---|
9763 | | - debugpoint.material.color = 0.25f; |
---|
9764 | | - debugpoint.material.modulation = 0.75f; |
---|
| 11554 | + debugpointG.radius = radius; |
---|
| 11555 | + debugpointG.recalculate(); |
---|
| 11556 | + debugpointG.material = new cMaterial(); |
---|
| 11557 | + debugpointG.material.color = 0.25f; // Green |
---|
| 11558 | + debugpointG.material.modulation = 0.75f; |
---|
9765 | 11559 | |
---|
9766 | | - debugpoint2.radius = radius; |
---|
9767 | | - debugpoint2.recalculate(); |
---|
9768 | | - debugpoint2.material = new cMaterial(); |
---|
9769 | | - debugpoint2.material.color = 0.75f; |
---|
9770 | | - debugpoint2.material.modulation = 0.75f; |
---|
| 11560 | + debugpointP.radius = radius; |
---|
| 11561 | + debugpointP.recalculate(); |
---|
| 11562 | + debugpointP.material = new cMaterial(); |
---|
| 11563 | + debugpointP.material.color = 0.75f; // Purple |
---|
| 11564 | + debugpointP.material.modulation = 0.75f; |
---|
9771 | 11565 | |
---|
9772 | | - debugpoint3.radius = radius; |
---|
9773 | | - debugpoint3.recalculate(); |
---|
9774 | | - debugpoint3.material = new cMaterial(); |
---|
9775 | | - debugpoint3.material.color = 0.5f; |
---|
9776 | | - debugpoint3.material.modulation = 0.75f; |
---|
| 11566 | + debugpointC.radius = radius; |
---|
| 11567 | + debugpointC.recalculate(); |
---|
| 11568 | + debugpointC.material = new cMaterial(); |
---|
| 11569 | + debugpointC.material.color = 0.5f; // Cyan |
---|
| 11570 | + debugpointC.material.modulation = 0.75f; |
---|
9777 | 11571 | |
---|
9778 | | - debugpoint4.radius = radius; |
---|
9779 | | - debugpoint4.recalculate(); |
---|
9780 | | - debugpoint4.material = new cMaterial(); |
---|
9781 | | - debugpoint4.material.color = 0f; |
---|
9782 | | - debugpoint4.material.modulation = 0.75f; |
---|
| 11572 | + debugpointR.radius = radius; |
---|
| 11573 | + debugpointR.recalculate(); |
---|
| 11574 | + debugpointR.material = new cMaterial(); |
---|
| 11575 | + debugpointR.material.color = 0f; // Red |
---|
| 11576 | + debugpointR.material.modulation = 0.75f; |
---|
9783 | 11577 | |
---|
9784 | 11578 | InitPoints(radius); |
---|
9785 | 11579 | } |
---|
9786 | 11580 | 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); |
---|
| 11581 | + debugpointG.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11582 | + debugpointP.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11583 | + debugpointC.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11584 | + debugpointR.draw(this, /*(Composite)*/ null, false,false); |
---|
9791 | 11585 | // DrawPoints(this); |
---|
9792 | 11586 | } |
---|
9793 | 11587 | |
---|
.. | .. |
---|
9795 | 11589 | } |
---|
9796 | 11590 | // GrafreeD.traceoff(); |
---|
9797 | 11591 | //System.out.println(stackdepth); |
---|
9798 | | - if (drawMode == 0) |
---|
| 11592 | + if (DrawMode() == 0) |
---|
9799 | 11593 | { |
---|
9800 | 11594 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
9801 | 11595 | |
---|
.. | .. |
---|
9820 | 11614 | |
---|
9821 | 11615 | checker = null; |
---|
9822 | 11616 | |
---|
9823 | | - if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT) |
---|
| 11617 | + if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT) |
---|
9824 | 11618 | FindChecker(object); |
---|
9825 | 11619 | |
---|
9826 | | - if (checker != null && drawMode == DEFAULT) |
---|
| 11620 | + if (checker != null && DrawMode() == DEFAULT) |
---|
9827 | 11621 | { |
---|
9828 | | - // BindTexture(IMMORTAL_TEXTURE); |
---|
| 11622 | + //BindTexture(IMMORTAL_TEXTURE); |
---|
| 11623 | + try |
---|
| 11624 | + { |
---|
| 11625 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11626 | + } |
---|
| 11627 | + catch (Exception e) |
---|
| 11628 | + { |
---|
| 11629 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11630 | + } |
---|
9829 | 11631 | // NEAREST |
---|
9830 | 11632 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
9831 | 11633 | DrawChecker(gl); |
---|
9832 | 11634 | //checker.Draw(this, null, false); |
---|
9833 | 11635 | // ReleaseTexture(IMMORTAL_TEXTURE); |
---|
| 11636 | + ReleaseTextures(checker.GetTextures()); |
---|
9834 | 11637 | } |
---|
9835 | 11638 | |
---|
9836 | 11639 | if (object.parent != null) |
---|
.. | .. |
---|
9843 | 11646 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9844 | 11647 | //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9845 | 11648 | |
---|
9846 | | - if (DISPLAYTEXT && drawMode == DEFAULT) |
---|
| 11649 | + if (DISPLAYTEXT && DrawMode() == DEFAULT) |
---|
9847 | 11650 | { |
---|
9848 | 11651 | // Draw it once, then use the raster |
---|
9849 | 11652 | Balloon(gl, balloon.createGraphics()); |
---|
.. | .. |
---|
9899 | 11702 | int[] xs = new int[3]; |
---|
9900 | 11703 | int[] ys = new int[3]; |
---|
9901 | 11704 | |
---|
9902 | | - void DrawString(Object3D obj) // String string) |
---|
| 11705 | + public void DrawString(Object3D obj) // String string) // INTERFACE |
---|
9903 | 11706 | { |
---|
9904 | | - if (!DISPLAYTEXT || drawMode != DEFAULT) |
---|
| 11707 | + if (!DISPLAYTEXT || DrawMode() != DEFAULT) |
---|
9905 | 11708 | { |
---|
9906 | 11709 | return; |
---|
9907 | 11710 | } |
---|
9908 | 11711 | |
---|
9909 | | - String string = obj.GetToolTip(); |
---|
| 11712 | + String string = obj.toString(); //.GetToolTip(); |
---|
9910 | 11713 | |
---|
9911 | 11714 | GL gl = GetGL(); |
---|
9912 | 11715 | |
---|
.. | .. |
---|
10223 | 12026 | //obj.TransformToWorld(light, light); |
---|
10224 | 12027 | for (int i = tp.size(); --i >= 0;) |
---|
10225 | 12028 | { |
---|
10226 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
10227 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12029 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12030 | + LA.xformPos(light, tp.get(i).GlobalTransform(), light); |
---|
10228 | 12031 | } |
---|
10229 | 12032 | |
---|
10230 | 12033 | |
---|
.. | .. |
---|
10241 | 12044 | parentcam = cameras[0]; |
---|
10242 | 12045 | } |
---|
10243 | 12046 | |
---|
10244 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10245 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12047 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12048 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
10246 | 12049 | |
---|
10247 | 12050 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
10248 | 12051 | |
---|
.. | .. |
---|
10388 | 12191 | "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" + |
---|
10389 | 12192 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
10390 | 12193 | "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" + |
---|
| 12194 | + "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" + |
---|
10391 | 12195 | "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" + |
---|
10392 | 12196 | "PARAM c256 = { 256, 256, 256, 1.0 };" + |
---|
10393 | 12197 | "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" + |
---|
.. | .. |
---|
10855 | 12659 | |
---|
10856 | 12660 | // display shadow only (bump == 0) |
---|
10857 | 12661 | "SUB temp.x, half.x, shadow.x;" + |
---|
10858 | | - "MOV temp.y, -params6.x;" + |
---|
10859 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12662 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12663 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
10860 | 12664 | "SUB temp.y, one.x, temp.z;" + |
---|
10861 | 12665 | "MUL temp.x, temp.x, temp.y;" + |
---|
10862 | 12666 | "KIL temp.x;" + |
---|
.. | .. |
---|
10985 | 12789 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
10986 | 12790 | |
---|
10987 | 12791 | "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 |
---|
| 12792 | + // Tuning for default skin |
---|
| 12793 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 12794 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 12795 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
10990 | 12796 | "MUL temp.x, temp.x, temp.y;" + |
---|
10991 | 12797 | |
---|
10992 | 12798 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
11185 | 12991 | //once = true; |
---|
11186 | 12992 | } |
---|
11187 | 12993 | |
---|
11188 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 12994 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
11189 | 12995 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
11190 | 12996 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
11191 | 12997 | |
---|
.. | .. |
---|
11302 | 13108 | String Shadow(String depth, String shadow) |
---|
11303 | 13109 | { |
---|
11304 | 13110 | return "MAX temp.x, ndotl.x, one64th.x;" + |
---|
| 13111 | + "MIN temp.x, temp.x, ninetenth.x;" + |
---|
11305 | 13112 | /**/ |
---|
11306 | 13113 | // Sine |
---|
11307 | 13114 | "MUL temp.y, temp.x, temp.x;" + |
---|
.. | .. |
---|
11317 | 13124 | |
---|
11318 | 13125 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
11319 | 13126 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13127 | + |
---|
| 13128 | + // Compare fragment depth in light space with shadowmap. |
---|
11320 | 13129 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
11321 | 13130 | "SGE temp.y, temp.x, zero.x;" + |
---|
11322 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13131 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13132 | + |
---|
| 13133 | + // Reverse comparison |
---|
11323 | 13134 | "SUB temp.x, one.x, temp.x;" + |
---|
11324 | 13135 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
11325 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13136 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
11326 | 13137 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
11327 | 13138 | |
---|
11328 | 13139 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
11336 | 13147 | // No shadow for backface |
---|
11337 | 13148 | "DP3 temp.x, normal, lightd;" + |
---|
11338 | 13149 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13150 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13151 | + |
---|
| 13152 | + // No shadow when out of frustrum |
---|
| 13153 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
11339 | 13154 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
11340 | 13155 | ""; |
---|
11341 | 13156 | } |
---|
.. | .. |
---|
11894 | 13709 | public void mousePressed(MouseEvent e) |
---|
11895 | 13710 | { |
---|
11896 | 13711 | //System.out.println("mousePressed: " + e); |
---|
11897 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 13712 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
11898 | 13713 | } |
---|
11899 | 13714 | |
---|
11900 | 13715 | static long prevtime = 0; |
---|
.. | .. |
---|
11921 | 13736 | |
---|
11922 | 13737 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
11923 | 13738 | |
---|
| 13739 | + if (BUTTONLESSWHEEL) |
---|
11924 | 13740 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
11925 | 13741 | { |
---|
11926 | 13742 | return; |
---|
11927 | 13743 | } |
---|
11928 | 13744 | |
---|
| 13745 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
11929 | 13746 | |
---|
11930 | 13747 | // TIMER |
---|
11931 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR |
---|
| 13748 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
11932 | 13749 | { |
---|
11933 | 13750 | keepboxmode = BOXMODE; |
---|
11934 | 13751 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
11968 | 13785 | // mode |= META; |
---|
11969 | 13786 | //} |
---|
11970 | 13787 | |
---|
11971 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
11972 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 13788 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 13789 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
11973 | 13790 | anchorX = ax; |
---|
11974 | 13791 | anchorY = ay; |
---|
11975 | 13792 | prevX = px; |
---|
.. | .. |
---|
12029 | 13846 | // wasliveok = true; |
---|
12030 | 13847 | // waslive = false; |
---|
12031 | 13848 | |
---|
| 13849 | + // May 2019 Forget it: |
---|
| 13850 | + if (true) |
---|
| 13851 | + return; |
---|
| 13852 | + |
---|
12032 | 13853 | // source == timer |
---|
12033 | 13854 | if (mouseDown) |
---|
12034 | 13855 | { |
---|
.. | .. |
---|
12057 | 13878 | // ObjEditor.tweenManager.update(1f / 60f); |
---|
12058 | 13879 | |
---|
12059 | 13880 | // fev 2014??? |
---|
12060 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode) |
---|
| 13881 | + if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
12061 | 13882 | object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
12062 | 13883 | pingthread.StepToTarget(true); // true); |
---|
12063 | 13884 | } |
---|
.. | .. |
---|
12067 | 13888 | |
---|
12068 | 13889 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
12069 | 13890 | |
---|
12070 | | - void clickStart(int x, int y, int modifiers) |
---|
| 13891 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
12071 | 13892 | { |
---|
12072 | 13893 | if (!wasliveok) |
---|
12073 | 13894 | return; |
---|
.. | .. |
---|
12084 | 13905 | // touched = true; // main DL |
---|
12085 | 13906 | if (isRenderer) |
---|
12086 | 13907 | { |
---|
12087 | | - SetMouseMode(modifiers); |
---|
| 13908 | + SetMouseMode(modifiers, modifiersex); |
---|
12088 | 13909 | } |
---|
12089 | 13910 | |
---|
12090 | 13911 | selectX = anchorX = x; |
---|
.. | .. |
---|
12097 | 13918 | clicked = true; |
---|
12098 | 13919 | hold = false; |
---|
12099 | 13920 | |
---|
12100 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 13921 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
12101 | 13922 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
12102 | 13923 | { |
---|
12103 | 13924 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
12128 | 13949 | info.camera = renderCamera; |
---|
12129 | 13950 | info.x = x; |
---|
12130 | 13951 | info.y = y; |
---|
12131 | | - info.modifiers = modifiers; |
---|
| 13952 | + info.modifiers = modifiersex; |
---|
12132 | 13953 | editObj = object.doEditClick(info, 0); |
---|
12133 | 13954 | if (!editObj) |
---|
12134 | 13955 | { |
---|
.. | .. |
---|
12145 | 13966 | |
---|
12146 | 13967 | public void mouseDragged(MouseEvent e) |
---|
12147 | 13968 | { |
---|
| 13969 | + Globals.MOUSEDRAGGED = true; |
---|
| 13970 | + |
---|
| 13971 | + //System.out.println("mouseDragged: " + e); |
---|
12148 | 13972 | if (isRenderer) |
---|
12149 | 13973 | movingcamera = true; |
---|
| 13974 | + |
---|
12150 | 13975 | //if (drawing) |
---|
12151 | 13976 | //return; |
---|
12152 | | - //System.out.println("mouseDragged: " + e); |
---|
12153 | 13977 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
12154 | 13978 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
12155 | 13979 | { |
---|
.. | .. |
---|
12157 | 13981 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12158 | 13982 | } |
---|
12159 | 13983 | else |
---|
12160 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 13984 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12161 | 13985 | |
---|
12162 | 13986 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
12163 | 13987 | } |
---|
.. | .. |
---|
12169 | 13993 | cVector tmp = new cVector(); |
---|
12170 | 13994 | cVector tmp2 = new cVector(); |
---|
12171 | 13995 | boolean isMoving; |
---|
| 13996 | + |
---|
| 13997 | + public cVector TargetLookAt() |
---|
| 13998 | + { |
---|
| 13999 | + return targetLookAt; |
---|
| 14000 | + } |
---|
12172 | 14001 | |
---|
12173 | 14002 | class PingThread extends Thread |
---|
12174 | 14003 | { |
---|
.. | .. |
---|
12308 | 14137 | //System.out.println("---------------- ---------- Paint " + tmp.length2()); |
---|
12309 | 14138 | if (lightMode) |
---|
12310 | 14139 | { |
---|
12311 | | - lighttouched = true; |
---|
| 14140 | + Globals.lighttouched = true; |
---|
12312 | 14141 | } |
---|
12313 | 14142 | |
---|
12314 | 14143 | if (OEILONCE && OEIL) |
---|
.. | .. |
---|
12325 | 14154 | |
---|
12326 | 14155 | public void run() |
---|
12327 | 14156 | { |
---|
| 14157 | + new Exception().printStackTrace(); |
---|
12328 | 14158 | System.exit(0); |
---|
12329 | 14159 | for (;;) |
---|
12330 | 14160 | { |
---|
.. | .. |
---|
12366 | 14196 | mouseDown = false; |
---|
12367 | 14197 | if (lightMode) |
---|
12368 | 14198 | { |
---|
12369 | | - lighttouched = true; |
---|
| 14199 | + Globals.lighttouched = true; |
---|
12370 | 14200 | } |
---|
12371 | 14201 | repaint(); |
---|
12372 | 14202 | alreadypainted = true; |
---|
.. | .. |
---|
12374 | 14204 | isMoving = false; |
---|
12375 | 14205 | } //?? |
---|
12376 | 14206 | |
---|
12377 | | - if (isLIVE() && !alreadypainted) |
---|
| 14207 | + if (Globals.isLIVE() && !alreadypainted) |
---|
12378 | 14208 | { |
---|
12379 | 14209 | // FOR DEBUG BREAKPOINT USING PAUSE: while (true) |
---|
12380 | 14210 | repaint(); |
---|
.. | .. |
---|
12386 | 14216 | { |
---|
12387 | 14217 | if (lightMode) |
---|
12388 | 14218 | { |
---|
12389 | | - lighttouched = true; |
---|
| 14219 | + Globals.lighttouched = true; |
---|
12390 | 14220 | } |
---|
12391 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14221 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
12392 | 14222 | } |
---|
12393 | 14223 | //else |
---|
12394 | 14224 | } |
---|
.. | .. |
---|
12488 | 14318 | int X, Y; |
---|
12489 | 14319 | boolean SX, SY; |
---|
12490 | 14320 | |
---|
12491 | | - void drag(int x, int y, int modifiers) |
---|
| 14321 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
12492 | 14322 | { |
---|
12493 | 14323 | if (IsFrozen()) |
---|
12494 | 14324 | { |
---|
.. | .. |
---|
12497 | 14327 | |
---|
12498 | 14328 | drag = true; // NEW |
---|
12499 | 14329 | |
---|
12500 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14330 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
12501 | 14331 | |
---|
12502 | 14332 | X = x; |
---|
12503 | 14333 | Y = y; |
---|
12504 | 14334 | // floating state for animation |
---|
12505 | | - MODIFIERS = modifiers; |
---|
12506 | | - modifiers &= ~1024; |
---|
| 14335 | + MODIFIERS = modifiersex; |
---|
| 14336 | + modifiersex &= ~1024; |
---|
12507 | 14337 | if (false) // modifiers != 0) |
---|
12508 | 14338 | { |
---|
12509 | 14339 | //new Exception().printStackTrace(); |
---|
12510 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14340 | + System.out.println("mouseDragged: " + modifiersex); |
---|
12511 | 14341 | System.out.println("SHIFT = " + SHIFT); |
---|
12512 | 14342 | System.out.println("CONTROL = " + COMMAND); |
---|
12513 | 14343 | System.out.println("META = " + META); |
---|
.. | .. |
---|
12527 | 14357 | info.camera = renderCamera; |
---|
12528 | 14358 | info.x = x; |
---|
12529 | 14359 | info.y = y; |
---|
12530 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14360 | + object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
12531 | 14361 | } else |
---|
12532 | 14362 | { |
---|
12533 | 14363 | if (x < startX) |
---|
.. | .. |
---|
12629 | 14459 | { |
---|
12630 | 14460 | manipCamera.Translate(dx, dy, getWidth()); |
---|
12631 | 14461 | } |
---|
| 14462 | + else |
---|
12632 | 14463 | if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0) |
---|
12633 | 14464 | { |
---|
12634 | 14465 | manipCamera.RotateInterest(dx, dy); |
---|
.. | .. |
---|
12639 | 14470 | |
---|
12640 | 14471 | if (manipCamera == lightCamera) |
---|
12641 | 14472 | { |
---|
12642 | | - lighttouched = true; |
---|
| 14473 | + Globals.lighttouched = true; |
---|
12643 | 14474 | } |
---|
12644 | 14475 | /* |
---|
12645 | 14476 | switch (mode) |
---|
.. | .. |
---|
12678 | 14509 | public void mouseMoved(MouseEvent e) |
---|
12679 | 14510 | { |
---|
12680 | 14511 | //System.out.println("mouseMoved: " + e); |
---|
12681 | | - |
---|
12682 | 14512 | if (isRenderer) |
---|
12683 | 14513 | return; |
---|
12684 | 14514 | |
---|
.. | .. |
---|
12703 | 14533 | |
---|
12704 | 14534 | public void mouseReleased(MouseEvent e) |
---|
12705 | 14535 | { |
---|
| 14536 | + Globals.MOUSEDRAGGED = false; |
---|
| 14537 | + |
---|
12706 | 14538 | movingcamera = false; |
---|
| 14539 | + X = Y = 0; |
---|
12707 | 14540 | //System.out.println("mouseReleased: " + e); |
---|
12708 | 14541 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12709 | 14542 | } |
---|
.. | .. |
---|
12726 | 14559 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
12727 | 14560 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
12728 | 14561 | |
---|
12729 | | - if (control || command || IsFrozen()) |
---|
| 14562 | +// No delay if (control || command || IsFrozen()) |
---|
12730 | 14563 | timeout = true; |
---|
12731 | | - else |
---|
| 14564 | +// ?? May 2019 else |
---|
12732 | 14565 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
12733 | 14566 | mouseDown = false; |
---|
12734 | 14567 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
12838 | 14671 | System.out.println("keyReleased: " + e); |
---|
12839 | 14672 | } |
---|
12840 | 14673 | |
---|
12841 | | - void SetMouseMode(int modifiers) |
---|
| 14674 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
12842 | 14675 | { |
---|
12843 | 14676 | //System.out.println("SetMouseMode = " + modifiers); |
---|
12844 | 14677 | //modifiers &= ~1024; |
---|
.. | .. |
---|
12850 | 14683 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
12851 | 14684 | // return; |
---|
12852 | 14685 | //System.out.println("SetMode = " + modifiers); |
---|
12853 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 14686 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
12854 | 14687 | { |
---|
12855 | 14688 | mouseMode |= ZOOM; |
---|
12856 | 14689 | } |
---|
12857 | 14690 | |
---|
12858 | 14691 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
12859 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 14692 | + if (capsLocked) // || (modifiers & META) == META) |
---|
12860 | 14693 | { |
---|
12861 | 14694 | mouseMode |= VR; // BACKFORTH; |
---|
12862 | 14695 | } |
---|
12863 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
12864 | | - { |
---|
12865 | | - mouseMode |= SELECT; // BACKFORTH; |
---|
12866 | | - } |
---|
12867 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 14696 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
12868 | 14697 | { |
---|
12869 | 14698 | mouseMode |= SELECT; |
---|
12870 | 14699 | } |
---|
12871 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 14700 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
| 14701 | + { |
---|
| 14702 | + mouseMode |= SELECT; |
---|
| 14703 | + } |
---|
| 14704 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
12872 | 14705 | { |
---|
12873 | 14706 | mouseMode &= ~VR; |
---|
12874 | 14707 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
12897 | 14730 | |
---|
12898 | 14731 | if (isRenderer) // |
---|
12899 | 14732 | { |
---|
12900 | | - SetMouseMode(modifiers); |
---|
| 14733 | + SetMouseMode(0, modifiers); |
---|
12901 | 14734 | } |
---|
12902 | 14735 | |
---|
12903 | | - theRenderer.keyPressed(key); |
---|
| 14736 | + Globals.theRenderer.keyPressed(key); |
---|
12904 | 14737 | } |
---|
12905 | 14738 | |
---|
12906 | 14739 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
12912 | 14745 | float SATPOW = 1; // 2; // 0.5f; |
---|
12913 | 14746 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
12914 | 14747 | |
---|
12915 | | - void keyPressed(int key) |
---|
| 14748 | + public void keyPressed(int key) |
---|
12916 | 14749 | { |
---|
12917 | 14750 | if (key >= '0' && key <= '5') |
---|
12918 | 14751 | clampbit = (key-'0'); |
---|
.. | .. |
---|
13027 | 14860 | case 'B': |
---|
13028 | 14861 | BRISMOOTH ^= true; |
---|
13029 | 14862 | SHADOWCULLFACE ^= true; |
---|
13030 | | - lighttouched = true; |
---|
| 14863 | + Globals.lighttouched = true; |
---|
13031 | 14864 | repaint(); |
---|
13032 | 14865 | break; |
---|
13033 | 14866 | case 'b': |
---|
.. | .. |
---|
13127 | 14960 | repaint(); |
---|
13128 | 14961 | break; |
---|
13129 | 14962 | case 'O': |
---|
13130 | | - drawMode = OCCLUSION; |
---|
| 14963 | + Globals.drawMode = OCCLUSION; // WARNING |
---|
13131 | 14964 | repaint(); |
---|
13132 | 14965 | break; |
---|
13133 | 14966 | case 'o': |
---|
.. | .. |
---|
13218 | 15051 | break; |
---|
13219 | 15052 | case ' ': |
---|
13220 | 15053 | lightMode ^= true; |
---|
13221 | | - lighttouched = true; |
---|
| 15054 | + Globals.lighttouched = true; |
---|
13222 | 15055 | manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
13223 | 15056 | targetLookAt.set(manipCamera.lookAt); |
---|
13224 | 15057 | repaint(); |
---|
.. | .. |
---|
13230 | 15063 | repaint(); |
---|
13231 | 15064 | break; |
---|
13232 | 15065 | case 'Z': |
---|
13233 | | - RESIZETEXTURE ^= true; |
---|
13234 | | - break; |
---|
| 15066 | + //RESIZETEXTURE ^= true; |
---|
| 15067 | + //break; |
---|
13235 | 15068 | case 'z': |
---|
13236 | | - RENDERSHADOW ^= true; |
---|
13237 | | - lighttouched = true; |
---|
| 15069 | + Globals.RENDERSHADOW ^= true; |
---|
| 15070 | + Globals.lighttouched = true; |
---|
13238 | 15071 | repaint(); |
---|
13239 | 15072 | break; |
---|
13240 | 15073 | //case UP: |
---|
.. | .. |
---|
13349 | 15182 | } |
---|
13350 | 15183 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
13351 | 15184 | } |
---|
| 15185 | + |
---|
13352 | 15186 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
13353 | 15187 | |
---|
13354 | 15188 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
13356 | 15190 | //mode = ROTATE; |
---|
13357 | 15191 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
13358 | 15192 | { |
---|
13359 | | - SetMouseMode(modifiers); |
---|
| 15193 | + SetMouseMode(0, modifiers); |
---|
13360 | 15194 | } |
---|
13361 | 15195 | } |
---|
13362 | 15196 | |
---|
13363 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 15197 | + public void processKeyEvent(KeyEvent e) |
---|
13364 | 15198 | { |
---|
13365 | 15199 | switch (e.getID()) |
---|
13366 | 15200 | { |
---|
.. | .. |
---|
13490 | 15324 | |
---|
13491 | 15325 | protected void processMouseMotionEvent(MouseEvent e) |
---|
13492 | 15326 | { |
---|
13493 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
13494 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15327 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15328 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15329 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
13495 | 15330 | { |
---|
13496 | 15331 | mouseMoved(e); |
---|
13497 | 15332 | } else |
---|
.. | .. |
---|
13521 | 15356 | |
---|
13522 | 15357 | void SelectParent() |
---|
13523 | 15358 | { |
---|
| 15359 | + new Exception().printStackTrace(); |
---|
13524 | 15360 | System.exit(0); |
---|
13525 | 15361 | Composite group = (Composite) object; |
---|
13526 | 15362 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
13544 | 15380 | |
---|
13545 | 15381 | void SelectChildren() |
---|
13546 | 15382 | { |
---|
| 15383 | + new Exception().printStackTrace(); |
---|
13547 | 15384 | System.exit(0); |
---|
13548 | 15385 | /* |
---|
13549 | 15386 | Composite group = (Composite) object; |
---|
.. | .. |
---|
13708 | 15545 | info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
13709 | 15546 | //Image img = CreateImage(width, height); |
---|
13710 | 15547 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15548 | + |
---|
13711 | 15549 | Graphics gr = g; // img.getGraphics(); |
---|
| 15550 | + |
---|
13712 | 15551 | if (!hasMarquee) |
---|
13713 | 15552 | { |
---|
13714 | 15553 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
13806 | 15645 | if (!isRenderer) |
---|
13807 | 15646 | { |
---|
13808 | 15647 | object.drawEditHandles(info, 0); |
---|
| 15648 | + |
---|
| 15649 | + if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 15650 | + { |
---|
| 15651 | + switch (object.selection.get(0).hitSomething) |
---|
| 15652 | + { |
---|
| 15653 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15654 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15655 | + break; |
---|
| 15656 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15657 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15658 | + break; |
---|
| 15659 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 15660 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15661 | + break; |
---|
| 15662 | + } |
---|
| 15663 | + |
---|
| 15664 | + } |
---|
13809 | 15665 | } |
---|
13810 | 15666 | } |
---|
| 15667 | + |
---|
13811 | 15668 | if (isRenderer) |
---|
13812 | 15669 | { |
---|
13813 | 15670 | //gr.setColor(Color.black); |
---|
13814 | 15671 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
13815 | 15672 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
13816 | 15673 | } |
---|
| 15674 | + |
---|
13817 | 15675 | if (hasMarquee) |
---|
13818 | 15676 | { |
---|
13819 | 15677 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
13836 | 15694 | //if (g != gr) g.drawImage(img, 0, 0, width, height, null); |
---|
13837 | 15695 | } |
---|
13838 | 15696 | |
---|
| 15697 | + // To avoid clear. |
---|
13839 | 15698 | public void update(Graphics g) |
---|
13840 | 15699 | { |
---|
13841 | 15700 | paint(g); |
---|
.. | .. |
---|
13925 | 15784 | public boolean mouseDown(Event evt, int x, int y) |
---|
13926 | 15785 | { |
---|
13927 | 15786 | System.out.println("mouseDown: " + evt); |
---|
| 15787 | + System.exit(0); |
---|
13928 | 15788 | /* |
---|
13929 | 15789 | locked = true; |
---|
13930 | 15790 | drag = false; |
---|
.. | .. |
---|
13968 | 15828 | { |
---|
13969 | 15829 | keyPressed(0, modifiers); |
---|
13970 | 15830 | } |
---|
13971 | | - clickStart(x, y, modifiers); |
---|
| 15831 | + // clickStart(x, y, modifiers); |
---|
13972 | 15832 | return true; |
---|
13973 | 15833 | } |
---|
13974 | 15834 | |
---|
.. | .. |
---|
14086 | 15946 | { |
---|
14087 | 15947 | keyReleased(0, 0); |
---|
14088 | 15948 | } |
---|
14089 | | - drag(x, y, modifiers); |
---|
| 15949 | + drag(x, y, 0, modifiers); |
---|
14090 | 15950 | return true; |
---|
14091 | 15951 | } |
---|
14092 | 15952 | |
---|
.. | .. |
---|
14218 | 16078 | Object3D object; |
---|
14219 | 16079 | static Object3D trackedobject; |
---|
14220 | 16080 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
14221 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16081 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
14222 | 16082 | /*static*/ Camera eyeCamera; |
---|
14223 | 16083 | /*static*/ Camera lightCamera; |
---|
14224 | 16084 | int cameracount; |
---|
.. | .. |
---|
14438 | 16298 | gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS); |
---|
14439 | 16299 | gl.glPushMatrix(); |
---|
14440 | 16300 | gl.glLoadIdentity(); |
---|
14441 | | - PushMatrix(checker.toParent); |
---|
| 16301 | + //PushMatrix(checker.toParent); |
---|
14442 | 16302 | |
---|
14443 | 16303 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
14444 | 16304 | gl.glPushMatrix(); |
---|
.. | .. |
---|
14461 | 16321 | |
---|
14462 | 16322 | gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
14463 | 16323 | |
---|
14464 | | - float step = 0.1666f; //0.25f; |
---|
14465 | | - float stepv = step * 1652 / 998; |
---|
| 16324 | + float step = 2; // 0.1666f; //0.25f; |
---|
| 16325 | + float stepv = 2; // step * 1652 / 998; |
---|
14466 | 16326 | |
---|
14467 | 16327 | int i0 = 0; |
---|
14468 | 16328 | /* |
---|
.. | .. |
---|
14498 | 16358 | /**/ |
---|
14499 | 16359 | //checker.GetMaterial().opacity = 1.1f; |
---|
14500 | 16360 | ////checker.GetMaterial().ambient = 0.99f; |
---|
14501 | | - Object3D.materialstack[Object3D.materialdepth] = checker.material; |
---|
14502 | | - Object3D.selectedstack[Object3D.materialdepth] = false; |
---|
14503 | | - cStatic.objectstack[Object3D.materialdepth++] = checker; |
---|
| 16361 | + materialstack[materialdepth] = checker.material; |
---|
| 16362 | + selectedstack[materialdepth] = false; |
---|
| 16363 | + cStatic.objectstack[materialdepth++] = checker; |
---|
14504 | 16364 | //System.out.println("material " + material); |
---|
14505 | 16365 | //Applet3D.tracein(this, selected); |
---|
14506 | 16366 | vector2buffer = checker.projectedVertices; |
---|
14507 | 16367 | |
---|
14508 | | - checker.GetMaterial().Draw(this, false); // true); |
---|
| 16368 | + //checker.GetMaterial().Draw(this, false); // true); |
---|
| 16369 | + DrawMaterial(checker.GetMaterial(), false); // true); |
---|
14509 | 16370 | |
---|
14510 | | - Object3D.materialdepth -= 1; |
---|
14511 | | - if (Object3D.materialdepth > 0) |
---|
| 16371 | + materialdepth -= 1; |
---|
| 16372 | + if (materialdepth > 0) |
---|
14512 | 16373 | { |
---|
14513 | | - vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices; |
---|
14514 | | - Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]); |
---|
| 16374 | + vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16375 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
14515 | 16376 | } |
---|
14516 | 16377 | //checker.GetMaterial().opacity = 1f; |
---|
14517 | 16378 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
14532 | 16393 | |
---|
14533 | 16394 | //float u = (i+1)/2; |
---|
14534 | 16395 | //float v = (j+1)/2; |
---|
14535 | | - gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
| 16396 | + if (checker.flipV) |
---|
| 16397 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2); |
---|
| 16398 | + else |
---|
| 16399 | + gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
14536 | 16400 | gl.glVertex3f(i, j, -0.5f); |
---|
14537 | 16401 | |
---|
| 16402 | + if (checker.flipV) |
---|
| 16403 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
| 16404 | + else |
---|
14538 | 16405 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
14539 | 16406 | gl.glVertex3f(i + step, j, -0.5f); |
---|
14540 | 16407 | |
---|
| 16408 | + if (checker.flipV) |
---|
| 16409 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
| 16410 | + else |
---|
14541 | 16411 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
14542 | 16412 | gl.glVertex3f(i + step, j + stepv, -0.5f); |
---|
14543 | 16413 | |
---|
| 16414 | + if (checker.flipV) |
---|
| 16415 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
| 16416 | + else |
---|
14544 | 16417 | gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
14545 | 16418 | gl.glVertex3f(i, j + stepv, -0.5f); |
---|
14546 | 16419 | } |
---|
.. | .. |
---|
14552 | 16425 | gl.glMatrixMode(GL.GL_PROJECTION); |
---|
14553 | 16426 | gl.glPopMatrix(); |
---|
14554 | 16427 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
14555 | | - PopMatrix(null); // checker.toParent); // null); |
---|
| 16428 | + //PopMatrix(null); // checker.toParent); // null); |
---|
14556 | 16429 | gl.glPopMatrix(); |
---|
14557 | 16430 | PopTextureMatrix(checker.toParent); |
---|
14558 | 16431 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
.. | .. |
---|
14643 | 16516 | { |
---|
14644 | 16517 | if (!selection) |
---|
14645 | 16518 | { |
---|
| 16519 | + new Exception().printStackTrace(); |
---|
14646 | 16520 | System.exit(0); |
---|
14647 | 16521 | return; |
---|
14648 | 16522 | } |
---|
.. | .. |
---|
14665 | 16539 | |
---|
14666 | 16540 | //int tmp = selection_view; |
---|
14667 | 16541 | //selection_view = -1; |
---|
14668 | | - int temp = drawMode; |
---|
14669 | | - drawMode = SELECTION; |
---|
| 16542 | + int temp = DrawMode(); |
---|
| 16543 | + Globals.drawMode = SELECTION; // WARNING |
---|
14670 | 16544 | indexcount = 0; |
---|
14671 | 16545 | parent.display(drawable); |
---|
14672 | 16546 | //selection_view = tmp; |
---|
14673 | 16547 | //if (temp == SELECTION) |
---|
14674 | 16548 | // temp = DEFAULT; // patch for selection debug |
---|
14675 | | - drawMode = temp; |
---|
| 16549 | + Globals.drawMode = temp; // WARNING |
---|
14676 | 16550 | |
---|
14677 | 16551 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
14678 | 16552 | |
---|
.. | .. |
---|
14770 | 16644 | System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2])); |
---|
14771 | 16645 | } |
---|
14772 | 16646 | |
---|
14773 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 16647 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
14774 | 16648 | } |
---|
14775 | 16649 | } |
---|
14776 | 16650 | |
---|
14777 | 16651 | if (!movingcamera && !PAINTMODE) |
---|
14778 | 16652 | object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
14779 | 16653 | |
---|
14780 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 16654 | + if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
14781 | 16655 | { |
---|
14782 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 16656 | + Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
14783 | 16657 | |
---|
14784 | 16658 | Object3D group = new Object3D("inst" + paintcount++); |
---|
14785 | 16659 | |
---|
.. | .. |
---|
14935 | 16809 | gl.glDisable(gl.GL_CULL_FACE); |
---|
14936 | 16810 | } |
---|
14937 | 16811 | |
---|
14938 | | - if (!RENDERSHADOW) |
---|
| 16812 | + if (!Globals.RENDERSHADOW) |
---|
14939 | 16813 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14940 | 16814 | |
---|
14941 | 16815 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
14945 | 16819 | //gl.glColorMask(false, false, false, false); |
---|
14946 | 16820 | |
---|
14947 | 16821 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
14948 | | - if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 16822 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
14949 | 16823 | { |
---|
14950 | 16824 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14951 | 16825 | |
---|
14952 | | - int temp = drawMode; |
---|
14953 | | - drawMode = SHADOW; |
---|
| 16826 | + int temp = DrawMode(); |
---|
| 16827 | + Globals.drawMode = SHADOW; // WARNING |
---|
14954 | 16828 | parent.display(drawable); |
---|
14955 | | - drawMode = temp; |
---|
| 16829 | + Globals.drawMode = temp; // WARNING |
---|
14956 | 16830 | } |
---|
14957 | 16831 | |
---|
14958 | 16832 | gl.glCullFace(gl.GL_BACK); |
---|
.. | .. |
---|
15005 | 16879 | |
---|
15006 | 16880 | class AntialiasBuffer implements GLEventListener |
---|
15007 | 16881 | { |
---|
15008 | | - |
---|
15009 | 16882 | CameraPane parent = null; |
---|
15010 | 16883 | |
---|
15011 | 16884 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
15350 | 17223 | GLUT glut = new GLUT(); |
---|
15351 | 17224 | |
---|
15352 | 17225 | |
---|
15353 | | - static final public int DEFAULT = 0; |
---|
15354 | | - static final public int SELECTION = 1; |
---|
15355 | | - static final public int SHADOW = 2; |
---|
15356 | | - static final public int OCCLUSION = 3; |
---|
15357 | | - static |
---|
15358 | | - public int drawMode = DEFAULT; |
---|
15359 | 17226 | public boolean spherical = false; |
---|
15360 | 17227 | static boolean DEBUG_OCCLUSION = false; |
---|
15361 | 17228 | static boolean DEBUG_SELECTION = false; |
---|
.. | .. |
---|
15370 | 17237 | //double[] selectedpoint = new double[3]; |
---|
15371 | 17238 | static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
15372 | 17239 | static Sphere previousselectedpoint = null; |
---|
15373 | | - static Sphere debugpoint = new Sphere(); |
---|
15374 | | - static Sphere debugpoint2 = new Sphere(); |
---|
15375 | | - static Sphere debugpoint3 = new Sphere(); |
---|
15376 | | - static Sphere debugpoint4 = new Sphere(); |
---|
| 17240 | + static Sphere debugpointG = new Sphere(); |
---|
| 17241 | + static Sphere debugpointP = new Sphere(); |
---|
| 17242 | + static Sphere debugpointC = new Sphere(); |
---|
| 17243 | + static Sphere debugpointR = new Sphere(); |
---|
15377 | 17244 | |
---|
15378 | 17245 | static Sphere debugpoints[] = new Sphere[8]; |
---|
15379 | 17246 | |
---|
.. | .. |
---|
15404 | 17271 | } |
---|
15405 | 17272 | } |
---|
15406 | 17273 | |
---|
15407 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17274 | + static void DrawPoints(iCameraPane cpane) |
---|
15408 | 17275 | { |
---|
15409 | 17276 | for (int i=0; i<8; i++) // first and last are red |
---|
15410 | 17277 | { |
---|
.. | .. |
---|
15436 | 17303 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
15437 | 17304 | // Depth buffer format |
---|
15438 | 17305 | //private int depth_format; |
---|
15439 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17306 | + |
---|
| 17307 | + public void NextIndex() |
---|
15440 | 17308 | { |
---|
15441 | 17309 | indexcount+=16; |
---|
15442 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17310 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
15443 | 17311 | //objects[indexcount] = o; |
---|
15444 | 17312 | //System.out.println("indexcount = " + indexcount); |
---|
15445 | 17313 | } |
---|