.. | .. |
---|
18 | 18 | import javax.imageio.ImageIO; |
---|
19 | 19 | import javax.imageio.ImageWriteParam; |
---|
20 | 20 | import javax.imageio.ImageWriter; |
---|
| 21 | +import javax.imageio.ImageReadParam; |
---|
| 22 | +import javax.imageio.ImageReader; |
---|
21 | 23 | import javax.imageio.plugins.jpeg.JPEGImageWriteParam; |
---|
| 24 | +import javax.imageio.stream.ImageInputStream; |
---|
22 | 25 | import javax.imageio.stream.ImageOutputStream; |
---|
23 | 26 | import javax.imageio.ImageWriteParam; |
---|
24 | 27 | |
---|
.. | .. |
---|
30 | 33 | import java.nio.*; |
---|
31 | 34 | |
---|
32 | 35 | import gleem.linalg.Mat4f; |
---|
| 36 | +import javax.imageio.ImageTypeSpecifier; |
---|
33 | 37 | |
---|
34 | | -class CameraPane extends GLCanvas implements Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
| 38 | +class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 39 | { |
---|
36 | | - static boolean DEBUG = false; |
---|
| 40 | + static cMaterial[] materialstack = new cMaterial[65536]; |
---|
| 41 | + static boolean[] selectedstack = new boolean[65536]; |
---|
| 42 | + static int materialdepth = 0; |
---|
| 43 | + |
---|
37 | 44 | static boolean FRUSTUM = false; // still bogus true; // frustum culling |
---|
38 | 45 | |
---|
39 | 46 | // camera change fix |
---|
.. | .. |
---|
42 | 49 | |
---|
43 | 50 | static int STEP = 1; |
---|
44 | 51 | |
---|
45 | | - static boolean ONESTEP = false; // do LIVE once |
---|
46 | | - |
---|
47 | | - /** |
---|
48 | | - * @return the LIVE |
---|
49 | | - */ |
---|
50 | | - public static boolean isLIVE() |
---|
| 52 | + private static BufferedImage CreateBim(byte[] bytes, int width, int height) |
---|
51 | 53 | { |
---|
52 | | - return LIVE || ONESTEP; |
---|
| 54 | + int[] pixels = new int[bytes.length/3]; |
---|
| 55 | + for (int i=pixels.length; --i>=0;) |
---|
| 56 | + { |
---|
| 57 | + int i3 = i*3; |
---|
| 58 | + pixels[i] = 0xFF; |
---|
| 59 | + pixels[i] <<= 8; |
---|
| 60 | + pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 61 | + pixels[i] <<= 8; |
---|
| 62 | + pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 63 | + pixels[i] <<= 8; |
---|
| 64 | + pixels[i] |= bytes[i3] & 0xFF; |
---|
| 65 | + } |
---|
| 66 | + /* |
---|
| 67 | + int r=0,g=0,b=0,a=0; |
---|
| 68 | + for (int i=0; i<width; i++) |
---|
| 69 | + for (int j=0; j<height; j++) |
---|
| 70 | + { |
---|
| 71 | + int index = j*width+i; |
---|
| 72 | + int p = pixels[index]; |
---|
| 73 | + a = ((p>>24) & 0xFF); |
---|
| 74 | + r = ((p>>16) & 0xFF); |
---|
| 75 | + g = ((p>>8) & 0xFF); |
---|
| 76 | + b = (p & 0xFF); |
---|
| 77 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
| 78 | + } |
---|
| 79 | + /**/ |
---|
| 80 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 81 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 82 | + return rendImage; |
---|
53 | 83 | } |
---|
54 | 84 | |
---|
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; |
---|
| 85 | + /*static*/ private boolean CULLFACE = false; // true; |
---|
64 | 86 | /*static*/ boolean NEAREST = false; // true; |
---|
65 | 87 | /*static*/ boolean WIREFRAME = false; // true; |
---|
66 | 88 | |
---|
.. | .. |
---|
70 | 92 | static int CURRENTANTIALIAS = 0; // 1; |
---|
71 | 93 | /*static*/ boolean RENDERSHADOW = true; |
---|
72 | 94 | /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal |
---|
73 | | - static boolean ANIMATION = false; |
---|
74 | | - static String filename; |
---|
75 | 95 | |
---|
76 | 96 | boolean DISPLAYTEXT = false; |
---|
77 | 97 | //boolean REDUCETEXTURE = true; |
---|
78 | 98 | boolean CACHETEXTURE = true; |
---|
79 | 99 | boolean CLEANCACHE = false; // true; |
---|
80 | | - boolean MIPMAP = false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
81 | 101 | boolean COMPRESSTEXTURE = false; |
---|
82 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
83 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
97 | 117 | |
---|
98 | 118 | static boolean textureon = true; |
---|
99 | 119 | static boolean LOCALTRANSFORM = false; |
---|
100 | | -private static boolean LIVE = false; |
---|
101 | 120 | static boolean FULLSCREEN = false; |
---|
102 | 121 | static boolean SUPPORT = true; |
---|
103 | | -static boolean CROWD = false; |
---|
104 | 122 | static boolean INERTIA = true; |
---|
105 | 123 | static boolean FAST = false; |
---|
106 | 124 | static boolean SLOWPOSE = false; |
---|
.. | .. |
---|
108 | 126 | |
---|
109 | 127 | static int tickcount = 0; // slow pose issue |
---|
110 | 128 | |
---|
| 129 | +static boolean BUTTONLESSWHEEL = false; |
---|
| 130 | +static boolean ZOOMBOXMODE = false; |
---|
111 | 131 | static boolean BOXMODE = false; |
---|
112 | 132 | static boolean IMAGEFLIP = false; |
---|
113 | 133 | static boolean SMOOTHFOCUS = false; |
---|
.. | .. |
---|
122 | 142 | static boolean OEIL = true; |
---|
123 | 143 | static boolean OEILONCE = false; // do oeilon then oeiloff |
---|
124 | 144 | static boolean LOOKAT = true; |
---|
125 | | -static boolean RANDOM = true; // false; |
---|
| 145 | +static boolean SWITCH = true; // false; |
---|
126 | 146 | static boolean HANDLES = false; // selection doesn't work!! |
---|
127 | 147 | static boolean PAINTMODE = false; |
---|
128 | 148 | |
---|
.. | .. |
---|
165 | 185 | defaultcaps.setAccumBlueBits(16); |
---|
166 | 186 | defaultcaps.setAccumAlphaBits(16); |
---|
167 | 187 | } |
---|
168 | | - static CameraPane theRenderer; |
---|
169 | | - |
---|
| 188 | + |
---|
| 189 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 190 | + |
---|
170 | 191 | void SetAsGLRenderer(boolean b) |
---|
171 | 192 | { |
---|
172 | 193 | isRenderer = b; |
---|
173 | | - theRenderer = this; |
---|
| 194 | + Globals.theRenderer = this; |
---|
| 195 | + } |
---|
| 196 | + |
---|
| 197 | + CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
| 198 | + { |
---|
| 199 | + super(defaultcaps, null, withcontext?glcontext:null, null); |
---|
| 200 | + |
---|
| 201 | + //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523)); |
---|
| 202 | + glcontext = getContext(); |
---|
| 203 | + |
---|
| 204 | + cameras = new Camera[2]; |
---|
| 205 | + targetLookAts = new cVector[2]; |
---|
| 206 | + |
---|
| 207 | + SetCamera(cam); |
---|
| 208 | + |
---|
| 209 | + SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 210 | + |
---|
| 211 | + object = o; |
---|
| 212 | + |
---|
| 213 | + setBackground(Color.white); |
---|
| 214 | + |
---|
| 215 | + addKeyListener(this); |
---|
| 216 | + addMouseListener(this); |
---|
| 217 | + addMouseMotionListener(this); |
---|
| 218 | + addMouseWheelListener(this); |
---|
| 219 | + //System.out.println("addGLEventListener: " + this); |
---|
| 220 | + addGLEventListener(this); |
---|
| 221 | + |
---|
| 222 | +// pingthread.start(); // may 2013 |
---|
174 | 223 | } |
---|
175 | 224 | |
---|
176 | 225 | static boolean AntialiasingEnabled() |
---|
.. | .. |
---|
178 | 227 | return CURRENTANTIALIAS > 0; |
---|
179 | 228 | } |
---|
180 | 229 | |
---|
181 | | - void ClearDepth() |
---|
| 230 | + /// INTERFACE |
---|
| 231 | + |
---|
| 232 | + public javax.media.opengl.GL GetGL0() |
---|
| 233 | + { |
---|
| 234 | + return null; |
---|
| 235 | + } |
---|
| 236 | + |
---|
| 237 | + public int GenList() |
---|
| 238 | + { |
---|
| 239 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 240 | + return gl.glGenLists(1); |
---|
| 241 | + } |
---|
| 242 | + |
---|
| 243 | + public void NewList(int id) |
---|
| 244 | + { |
---|
| 245 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 246 | + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 247 | + } |
---|
| 248 | + |
---|
| 249 | + public void CallList(int id) |
---|
| 250 | + { |
---|
| 251 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 252 | + gl.glCallList(id); |
---|
| 253 | + } |
---|
| 254 | + |
---|
| 255 | + public void EndList() |
---|
| 256 | + { |
---|
| 257 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 258 | + gl.glEndList(); |
---|
| 259 | + } |
---|
| 260 | + |
---|
| 261 | + public boolean IsBoxMode() |
---|
| 262 | + { |
---|
| 263 | + return BOXMODE; |
---|
| 264 | + } |
---|
| 265 | + |
---|
| 266 | + public boolean IsZoomBoxMode() |
---|
| 267 | + { |
---|
| 268 | + return ZOOMBOXMODE; |
---|
| 269 | + } |
---|
| 270 | + |
---|
| 271 | + public void ClearDepth() |
---|
182 | 272 | { |
---|
183 | 273 | GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT); |
---|
184 | 274 | } |
---|
185 | 275 | |
---|
186 | | - void DepthTest(boolean depthtest) |
---|
| 276 | + public void DepthTest(boolean depthtest) |
---|
187 | 277 | { |
---|
188 | 278 | if (depthtest) |
---|
189 | 279 | GetGL().glDepthFunc(GL.GL_LEQUAL); |
---|
.. | .. |
---|
191 | 281 | GetGL().glDepthFunc(GL.GL_ALWAYS); |
---|
192 | 282 | } |
---|
193 | 283 | |
---|
194 | | - void DepthWrite(boolean depthwrite) |
---|
| 284 | + public void DepthWrite(boolean depthwrite) |
---|
195 | 285 | { |
---|
196 | 286 | if (depthwrite) |
---|
197 | 287 | GetGL().glDepthMask(true); |
---|
.. | .. |
---|
199 | 289 | GetGL().glDepthMask(false); |
---|
200 | 290 | } |
---|
201 | 291 | |
---|
202 | | - void BackFaceCull(boolean bfc) |
---|
| 292 | + public void BackFaceCull(boolean bfc) |
---|
203 | 293 | { |
---|
204 | 294 | if (bfc) |
---|
205 | 295 | GetGL().glEnable(GetGL().GL_CULL_FACE); |
---|
206 | 296 | else |
---|
207 | 297 | GetGL().glDisable(GetGL().GL_CULL_FACE); |
---|
| 298 | + } |
---|
| 299 | + |
---|
| 300 | + public boolean BackFaceCullMode() |
---|
| 301 | + { |
---|
| 302 | + return this.CULLFACE; |
---|
| 303 | + } |
---|
| 304 | + |
---|
| 305 | + public boolean IsAmbientOcclusionOn() |
---|
| 306 | + { |
---|
| 307 | + return this.ambientOcclusion; |
---|
| 308 | + } |
---|
| 309 | + |
---|
| 310 | + public boolean IsDebugSelection() |
---|
| 311 | + { |
---|
| 312 | + return DEBUG_SELECTION; |
---|
| 313 | + } |
---|
| 314 | + |
---|
| 315 | + public boolean IsFrozen() |
---|
| 316 | + { |
---|
| 317 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
| 318 | + |
---|
| 319 | + return !selectmode && cameracount == 0; // != 0; |
---|
| 320 | + } |
---|
| 321 | + |
---|
| 322 | + // Currently in Globals |
---|
| 323 | + public int DrawMode() |
---|
| 324 | + { |
---|
| 325 | + return Globals.DrawMode(); |
---|
| 326 | + } |
---|
| 327 | + |
---|
| 328 | + public Camera EyeCamera() |
---|
| 329 | + { |
---|
| 330 | + return eyeCamera; |
---|
| 331 | + } |
---|
| 332 | + |
---|
| 333 | + public Camera LightCamera() |
---|
| 334 | + { |
---|
| 335 | + return lightCamera; |
---|
| 336 | + } |
---|
| 337 | + |
---|
| 338 | + public Camera ManipCamera() |
---|
| 339 | + { |
---|
| 340 | + return manipCamera; |
---|
| 341 | + } |
---|
| 342 | + |
---|
| 343 | + public Camera RenderCamera() |
---|
| 344 | + { |
---|
| 345 | + return renderCamera; |
---|
| 346 | + } |
---|
| 347 | + |
---|
| 348 | + public Camera[] Cameras() |
---|
| 349 | + { |
---|
| 350 | + return cameras; |
---|
| 351 | + } |
---|
| 352 | + |
---|
| 353 | + public void PushMaterial(Object3D obj, boolean selected) |
---|
| 354 | + { |
---|
| 355 | + CameraPane display = this; |
---|
| 356 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 357 | + cMaterial material = obj.material; |
---|
| 358 | + |
---|
| 359 | + if (material != null) |
---|
| 360 | + { |
---|
| 361 | + materialstack[materialdepth] = material; |
---|
| 362 | + selectedstack[materialdepth] = selected; |
---|
| 363 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 364 | + //System.out.println("material " + material); |
---|
| 365 | + //Applet3D.tracein(this, selected); |
---|
| 366 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 367 | + if (obj instanceof Camera) |
---|
| 368 | + { |
---|
| 369 | + display.options1[0] = material.shift; |
---|
| 370 | + //System.out.println("shift " + material.shift); |
---|
| 371 | + display.options1[1] = material.lightarea; |
---|
| 372 | + display.options1[2] = material.shadowbias; |
---|
| 373 | + display.options1[3] = material.aniso; |
---|
| 374 | + display.options1[4] = material.anisoV; |
---|
| 375 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 376 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 377 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 378 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 379 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
| 380 | + display.options2[0] = material.opacity; |
---|
| 381 | + display.options2[1] = material.diffuse; |
---|
| 382 | + display.options2[2] = material.factor; |
---|
| 383 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 384 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 385 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
| 386 | + |
---|
| 387 | + cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 388 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 389 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 390 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
| 391 | + display.options4[0] = material.cameralight/0.2f; |
---|
| 392 | + display.options4[1] = material.subsurface; |
---|
| 393 | + display.options4[2] = material.sheen; |
---|
| 394 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 395 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 396 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
| 397 | + |
---|
| 398 | + // if (display.CURRENTANTIALIAS > 0) |
---|
| 399 | + // display.options3[3] /= 4; |
---|
| 400 | + |
---|
| 401 | + /* |
---|
| 402 | + System.out.println("Focus = " + display.options1[0]); |
---|
| 403 | + System.out.println("Aperture = " + display.options1[1]); |
---|
| 404 | + System.out.println("ShadowBlur = " + display.options1[2]); |
---|
| 405 | + System.out.println("Antialiasing = " + display.options1[3]); |
---|
| 406 | + System.out.println("Fog = " + display.options2[0]); |
---|
| 407 | + System.out.println("Intensity = " + display.options2[1]); |
---|
| 408 | + System.out.println("Elevation = " + display.options2[2]); |
---|
| 409 | + /**/ |
---|
| 410 | + } else |
---|
| 411 | + { |
---|
| 412 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
| 413 | + } |
---|
| 414 | + } else |
---|
| 415 | + { |
---|
| 416 | + if (selected && CameraPane.flash) |
---|
| 417 | + { |
---|
| 418 | + display.modelParams4[1] = 100; |
---|
| 419 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 420 | + } |
---|
| 421 | + } |
---|
| 422 | + } |
---|
| 423 | + |
---|
| 424 | + public void PushMaterial2(Object3D obj, boolean selected) |
---|
| 425 | + { |
---|
| 426 | + CameraPane display = this; |
---|
| 427 | + cMaterial material = obj.material; |
---|
| 428 | + |
---|
| 429 | + if (material != null) |
---|
| 430 | + { |
---|
| 431 | + materialstack[materialdepth] = material; |
---|
| 432 | + selectedstack[materialdepth] = selected; |
---|
| 433 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 434 | + //System.out.println("material " + material); |
---|
| 435 | + //Applet3D.tracein("selected ", selected); |
---|
| 436 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 437 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
| 438 | + } |
---|
| 439 | + } |
---|
| 440 | + |
---|
| 441 | + public void PopMaterial(Object3D obj, boolean selected) |
---|
| 442 | + { |
---|
| 443 | + CameraPane display = this; |
---|
| 444 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 445 | + cMaterial material = obj.material; |
---|
| 446 | + |
---|
| 447 | + //if (parent != null && parent.GetMaterial() != null) |
---|
| 448 | + // parent.GetMaterial().Draw(display, parent.IsSelected(this)); |
---|
| 449 | + if (material != null) |
---|
| 450 | + { |
---|
| 451 | + materialdepth -= 1; |
---|
| 452 | + if (materialdepth > 0) |
---|
| 453 | + { |
---|
| 454 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 455 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
| 456 | + } |
---|
| 457 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 458 | + } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
| 459 | + { |
---|
| 460 | + display.modelParams4[1] = obj.GetMaterial().cameralight; |
---|
| 461 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 462 | + } |
---|
| 463 | + } |
---|
| 464 | + |
---|
| 465 | + public void PopMaterial2(Object3D obj) |
---|
| 466 | + { |
---|
| 467 | + CameraPane display = this; |
---|
| 468 | + cMaterial material = obj.material; |
---|
| 469 | + |
---|
| 470 | + if (material != null) |
---|
| 471 | + { |
---|
| 472 | + materialdepth -= 1; |
---|
| 473 | + if (materialdepth > 0) |
---|
| 474 | + { |
---|
| 475 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 476 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
| 477 | + } |
---|
| 478 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 479 | + //else |
---|
| 480 | + //material.Draw(display, false); |
---|
| 481 | + } |
---|
| 482 | + } |
---|
| 483 | + |
---|
| 484 | + public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face) |
---|
| 485 | + { |
---|
| 486 | + CameraPane display = this; |
---|
| 487 | + |
---|
| 488 | + if (pv.y == -10000 || |
---|
| 489 | + qv.y == -10000 || |
---|
| 490 | + rv.y == -10000) |
---|
| 491 | + return; |
---|
| 492 | + |
---|
| 493 | +// float b = f.nbiterations & 1; |
---|
| 494 | +// float g = (f.nbiterations>>1) & 1; |
---|
| 495 | +// float r = (f.nbiterations>>2) & 1; |
---|
| 496 | +// |
---|
| 497 | +// //if (f.weight == 10000) |
---|
| 498 | +// //{ |
---|
| 499 | +// // r = 1; g = b = 0; |
---|
| 500 | +// //} |
---|
| 501 | +// //else |
---|
| 502 | +// //{ |
---|
| 503 | +// // assert(f.weight < 10000); |
---|
| 504 | +// r = g = b = (float)bRep.FaceWeight(f)*100; |
---|
| 505 | +// if (r<0) |
---|
| 506 | +// assert(r>=0); |
---|
| 507 | +// //} |
---|
| 508 | + |
---|
| 509 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 510 | + |
---|
| 511 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
| 512 | + |
---|
| 513 | + //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
| 514 | + if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
| 515 | + { |
---|
| 516 | + //gl.glBegin(gl.GL_TRIANGLES); |
---|
| 517 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 518 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 519 | + ; |
---|
| 520 | + if (!hasnorm) |
---|
| 521 | + { |
---|
| 522 | + // System.out.println("Mesh normal"); |
---|
| 523 | + LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
| 524 | + LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
| 525 | + LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
| 526 | + LA.vecNormalize(obj.v2); |
---|
| 527 | + gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 528 | + } |
---|
| 529 | + |
---|
| 530 | + // P |
---|
| 531 | + float x = (float)pv.x; |
---|
| 532 | + float y = (float)pv.y; |
---|
| 533 | + float z = (float)pv.z; |
---|
| 534 | + |
---|
| 535 | + if (hasnorm) |
---|
| 536 | + { |
---|
| 537 | +// if (!pv.norm.normalized()) |
---|
| 538 | +// assert(pv.norm.normalized()); |
---|
| 539 | + |
---|
| 540 | + //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z); |
---|
| 541 | + float nx = (float)pv.norm.x; |
---|
| 542 | + float ny = (float)pv.norm.y; |
---|
| 543 | + float nz = (float)pv.norm.z; |
---|
| 544 | + |
---|
| 545 | + x += nx * obj.NORMALPUSH; |
---|
| 546 | + y += ny * obj.NORMALPUSH; |
---|
| 547 | + z += nz * obj.NORMALPUSH; |
---|
| 548 | + |
---|
| 549 | + gl.glNormal3f(nx, ny, nz); |
---|
| 550 | + } |
---|
| 551 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 552 | + SetColor(obj, pv); |
---|
| 553 | + //gl.glColor4f(r, g, b, 1); |
---|
| 554 | + //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1); |
---|
| 555 | + if (obj.flipV) |
---|
| 556 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 557 | + else |
---|
| 558 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 559 | + //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z); |
---|
| 560 | + |
---|
| 561 | + gl.glVertex3f(x, y, z); |
---|
| 562 | + |
---|
| 563 | + // Q |
---|
| 564 | + x = (float)qv.x; |
---|
| 565 | + y = (float)qv.y; |
---|
| 566 | + z = (float)qv.z; |
---|
| 567 | + |
---|
| 568 | +// Print(pv); |
---|
| 569 | + if (hasnorm) |
---|
| 570 | + { |
---|
| 571 | +// assert(qv.norm.normalized()); |
---|
| 572 | + //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z); |
---|
| 573 | + float nx = (float)qv.norm.x; |
---|
| 574 | + float ny = (float)qv.norm.y; |
---|
| 575 | + float nz = (float)qv.norm.z; |
---|
| 576 | + |
---|
| 577 | + x += nx * obj.NORMALPUSH; |
---|
| 578 | + y += ny * obj.NORMALPUSH; |
---|
| 579 | + z += nz * obj.NORMALPUSH; |
---|
| 580 | + |
---|
| 581 | + gl.glNormal3f(nx, ny, nz); |
---|
| 582 | + } |
---|
| 583 | + //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
| 584 | + // boolean locked = false; |
---|
| 585 | + // float eps = 0.1f; |
---|
| 586 | + // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 587 | + |
---|
| 588 | + // int dot = 0; //*/ (int)f.dot; |
---|
| 589 | + |
---|
| 590 | + // if ((dot&1) == 0) |
---|
| 591 | + // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 592 | + |
---|
| 593 | + // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 594 | + if (obj.flipV) |
---|
| 595 | + gl.glTexCoord2f((float) qv.s, 1-(float) qv.t); |
---|
| 596 | + else |
---|
| 597 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 598 | + // else |
---|
| 599 | + // { |
---|
| 600 | + // locked = true; |
---|
| 601 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 602 | + // } |
---|
| 603 | + gl.glColor4f(qv.AO, qv.AO, qv.AO, 1); |
---|
| 604 | + SetColor(obj, qv); |
---|
| 605 | + |
---|
| 606 | + gl.glVertex3f(x, y, z); |
---|
| 607 | + //gl.glColor4f(r, g, b, 1); |
---|
| 608 | + //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1); |
---|
| 609 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 610 | +// Print(qv); |
---|
| 611 | + |
---|
| 612 | + // R |
---|
| 613 | + x = (float)rv.x; |
---|
| 614 | + y = (float)rv.y; |
---|
| 615 | + z = (float)rv.z; |
---|
| 616 | + |
---|
| 617 | + if (hasnorm) |
---|
| 618 | + { |
---|
| 619 | +// assert(rv.norm.normalized()); |
---|
| 620 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 621 | + float nx = (float)rv.norm.x; |
---|
| 622 | + float ny = (float)rv.norm.y; |
---|
| 623 | + float nz = (float)rv.norm.z; |
---|
| 624 | + |
---|
| 625 | + x += nx * obj.NORMALPUSH; |
---|
| 626 | + y += ny * obj.NORMALPUSH; |
---|
| 627 | + z += nz * obj.NORMALPUSH; |
---|
| 628 | + |
---|
| 629 | + gl.glNormal3f(nx, ny, nz); |
---|
| 630 | + } |
---|
| 631 | + |
---|
| 632 | + // if ((dot&4) == 0) |
---|
| 633 | + // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 634 | + |
---|
| 635 | + // if (wrap || !locked && (dot&8) != 0) |
---|
| 636 | + if (obj.flipV) |
---|
| 637 | + gl.glTexCoord2f((float) rv.s, 1-(float) rv.t); |
---|
| 638 | + else |
---|
| 639 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 640 | + // else |
---|
| 641 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 642 | + |
---|
| 643 | + // f.dot = dot; |
---|
| 644 | + |
---|
| 645 | + gl.glColor4f(rv.AO, rv.AO, rv.AO, 1); |
---|
| 646 | + SetColor(obj, rv); |
---|
| 647 | + //gl.glColor4f(r, g, b, 1); |
---|
| 648 | + //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1); |
---|
| 649 | + //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z); |
---|
| 650 | + gl.glVertex3f(x, y, z); |
---|
| 651 | +// Print(rv); |
---|
| 652 | + //gl.glEnd(); |
---|
| 653 | + } |
---|
| 654 | + else |
---|
| 655 | + { |
---|
| 656 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 657 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 658 | + gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z); |
---|
| 659 | + |
---|
| 660 | + } |
---|
| 661 | + |
---|
| 662 | + if (false) // (attributes & WIREFRAME) != 0) |
---|
| 663 | + { |
---|
| 664 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 665 | + |
---|
| 666 | + gl.glBegin(gl.GL_LINE_LOOP); |
---|
| 667 | + gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z); |
---|
| 668 | + gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z); |
---|
| 669 | + gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z); |
---|
| 670 | + gl.glEnd(); |
---|
| 671 | + |
---|
| 672 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 673 | + } |
---|
| 674 | + } |
---|
| 675 | + |
---|
| 676 | + /** |
---|
| 677 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 678 | + * it's normals, colors, textures and vertices. |
---|
| 679 | + * |
---|
| 680 | + * @see Renderer#draw(TriMesh) |
---|
| 681 | + * @param tris |
---|
| 682 | + * the mesh to render. |
---|
| 683 | + */ |
---|
| 684 | + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 685 | + { |
---|
| 686 | + CameraPane display = this; |
---|
| 687 | + |
---|
| 688 | + float r = display.modelParams0[0]; |
---|
| 689 | + float g = display.modelParams0[1]; |
---|
| 690 | + float b = display.modelParams0[2]; |
---|
| 691 | + float opacity = display.modelParams5[1]; |
---|
| 692 | + |
---|
| 693 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 694 | + GL gl = display.GetGL(); // getGL(); |
---|
| 695 | + |
---|
| 696 | + FloatBuffer vertBuf = geo.vertBuf; |
---|
| 697 | + |
---|
| 698 | + int v = vertBuf.capacity(); |
---|
| 699 | + |
---|
| 700 | + int count = 0; |
---|
| 701 | + |
---|
| 702 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 703 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 704 | + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
| 705 | + for (int i=0; i<v/3; i++) |
---|
| 706 | + { |
---|
| 707 | + int index3 = i*3; |
---|
| 708 | + |
---|
| 709 | + if (geo.sizeBuf.get(index3+1) == 0) |
---|
| 710 | + continue; |
---|
| 711 | + |
---|
| 712 | + count++; |
---|
| 713 | + |
---|
| 714 | + int index4 = i*4; |
---|
| 715 | + |
---|
| 716 | + float tx = vertBuf.get(index3); |
---|
| 717 | + float ty = vertBuf.get(index3+1); |
---|
| 718 | + float tz = vertBuf.get(index3+2); |
---|
| 719 | + |
---|
| 720 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 721 | + // continue; |
---|
| 722 | + |
---|
| 723 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 724 | + gl.glPushMatrix(); |
---|
| 725 | + |
---|
| 726 | + float[] texmat = geo.texmat; |
---|
| 727 | + texmat[12] = texmat[13] = texmat[14] = i; |
---|
| 728 | + |
---|
| 729 | + gl.glMultMatrixf(texmat, 0); |
---|
| 730 | + |
---|
| 731 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 732 | + gl.glPushMatrix(); |
---|
| 733 | + |
---|
| 734 | + gl.glTranslatef(tx,ty,tz); |
---|
| 735 | + |
---|
| 736 | + if (rotate) |
---|
| 737 | + gl.glRotatef(i, 0, 1, 0); |
---|
| 738 | + |
---|
| 739 | + float size = geo.sizeBuf.get(index3) / 100; |
---|
| 740 | + gl.glScalef(size,size,size); |
---|
| 741 | + |
---|
| 742 | + float cr = geo.colorBuf.get(index4); |
---|
| 743 | + float cg = geo.colorBuf.get(index4+1); |
---|
| 744 | + float cb = geo.colorBuf.get(index4+2); |
---|
| 745 | + float ca = geo.colorBuf.get(index4+3); |
---|
| 746 | + |
---|
| 747 | + display.modelParams0[0] = r * cr; |
---|
| 748 | + display.modelParams0[1] = g * cg; |
---|
| 749 | + display.modelParams0[2] = b * cb; |
---|
| 750 | + |
---|
| 751 | + display.modelParams5[1] = opacity * ca; |
---|
| 752 | + |
---|
| 753 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 754 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 755 | + |
---|
| 756 | + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; |
---|
| 757 | + RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 758 | + |
---|
| 759 | +// gl.glColor4f(cr,cg,cb,ca); |
---|
| 760 | + // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 761 | + shape.Draw/*Node*/(display,null,selected,false); // blocked |
---|
| 762 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 763 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 764 | + gl.glPopMatrix(); |
---|
| 765 | + |
---|
| 766 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 767 | + gl.glPopMatrix(); |
---|
| 768 | + } |
---|
| 769 | + // gl.glScalef(1024,1024,1024); |
---|
| 770 | + if (!cf) |
---|
| 771 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 772 | + |
---|
| 773 | + display.modelParams0[0] = r; |
---|
| 774 | + display.modelParams0[1] = g; |
---|
| 775 | + display.modelParams0[2] = b; |
---|
| 776 | + |
---|
| 777 | + display.modelParams5[1] = opacity; |
---|
| 778 | + |
---|
| 779 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 780 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 781 | + |
---|
| 782 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 783 | + |
---|
| 784 | +// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
| 785 | + if (true) |
---|
| 786 | + return; |
---|
| 787 | + |
---|
| 788 | +//// if (!tris.predraw(this)) |
---|
| 789 | +//// { |
---|
| 790 | +//// return; |
---|
| 791 | +//// } |
---|
| 792 | +//// if (Debug.stats) |
---|
| 793 | +//// { |
---|
| 794 | +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
| 795 | +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
| 796 | +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
| 797 | +//// } |
---|
| 798 | +//// |
---|
| 799 | +//// if (tris.getDisplayListID() != -1) |
---|
| 800 | +//// { |
---|
| 801 | +//// renderDisplayList(tris); |
---|
| 802 | +//// return; |
---|
| 803 | +//// } |
---|
| 804 | +//// |
---|
| 805 | +//// if (!generatingDisplayList) |
---|
| 806 | +//// { |
---|
| 807 | +//// applyStates(tris.states, tris); |
---|
| 808 | +//// } |
---|
| 809 | +//// if (Debug.stats) |
---|
| 810 | +//// { |
---|
| 811 | +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
| 812 | +//// } |
---|
| 813 | +//// boolean transformed = doTransforms(tris); |
---|
| 814 | +// |
---|
| 815 | +// int glMode = GL.GL_TRIANGLES; |
---|
| 816 | +// switch (getMode()) |
---|
| 817 | +// { |
---|
| 818 | +// case Triangles: |
---|
| 819 | +// glMode = GL.GL_TRIANGLES; |
---|
| 820 | +// break; |
---|
| 821 | +// case Strip: |
---|
| 822 | +// glMode = GL.GL_TRIANGLE_STRIP; |
---|
| 823 | +// break; |
---|
| 824 | +// case Fan: |
---|
| 825 | +// glMode = GL.GL_TRIANGLE_FAN; |
---|
| 826 | +// break; |
---|
| 827 | +// } |
---|
| 828 | +// |
---|
| 829 | +// if (!predrawGeometry(gl)) |
---|
| 830 | +// { |
---|
| 831 | +// // make sure only the necessary indices are sent through on old |
---|
| 832 | +// // cards. |
---|
| 833 | +// IntBuffer indices = this.getIndexBuffer(); |
---|
| 834 | +// if (indices == null) |
---|
| 835 | +// { |
---|
| 836 | +// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
| 837 | +// } else |
---|
| 838 | +// { |
---|
| 839 | +// indices.rewind(); |
---|
| 840 | +// indices.limit(this.getMaxIndex()); |
---|
| 841 | +// |
---|
| 842 | +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
| 843 | +// |
---|
| 844 | +// indices.clear(); |
---|
| 845 | +// } |
---|
| 846 | +// } else |
---|
| 847 | +// { |
---|
| 848 | +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
| 849 | +// GL.GL_UNSIGNED_INT, 0); |
---|
| 850 | +// } |
---|
| 851 | +// |
---|
| 852 | +//// postdrawGeometry(tris); |
---|
| 853 | +//// if (transformed) |
---|
| 854 | +//// { |
---|
| 855 | +//// undoTransforms(tris); |
---|
| 856 | +//// } |
---|
| 857 | +//// |
---|
| 858 | +//// if (Debug.stats) |
---|
| 859 | +//// { |
---|
| 860 | +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
| 861 | +//// } |
---|
| 862 | +//// tris.postdraw(this); |
---|
| 863 | + } |
---|
| 864 | + |
---|
| 865 | + static Camera localcamera = new Camera(); |
---|
| 866 | + static cVector from = new cVector(); |
---|
| 867 | + static cVector to = new cVector(); |
---|
| 868 | + |
---|
| 869 | + public void PrepOcclusion(BoundaryRep br, double[][] transform) |
---|
| 870 | + { |
---|
| 871 | + CameraPane cp = this; |
---|
| 872 | + |
---|
| 873 | + Camera keep = cp.RenderCamera(); |
---|
| 874 | + cp.renderCamera = localcamera; |
---|
| 875 | + |
---|
| 876 | + if (br.trimmed) |
---|
| 877 | + { |
---|
| 878 | + float[] colors = new float[br.positions.length / 3]; |
---|
| 879 | + |
---|
| 880 | + int i3 = 0; |
---|
| 881 | + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) |
---|
| 882 | + { |
---|
| 883 | + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) |
---|
| 884 | + continue; |
---|
| 885 | + |
---|
| 886 | + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); |
---|
| 887 | + to.set(br.positions[i3] + br.normals[i3], |
---|
| 888 | + br.positions[i3 + 1] + br.normals[i3 + 1], |
---|
| 889 | + br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
| 890 | + LA.xformPos(from, transform, from); |
---|
| 891 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 892 | + localcamera.setAim(from, to); |
---|
| 893 | + |
---|
| 894 | + CameraPane.occlusionbuffer.display(); |
---|
| 895 | + |
---|
| 896 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 897 | + cp.display(); // debug |
---|
| 898 | + |
---|
| 899 | + colors[i] = cp.vertexOcclusion.r; |
---|
| 900 | + //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
| 901 | + //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
| 902 | + |
---|
| 903 | + if ((i % 100) == 0 && i != 0) |
---|
| 904 | + { |
---|
| 905 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 906 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 907 | + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); |
---|
| 908 | + } |
---|
| 909 | + } |
---|
| 910 | + |
---|
| 911 | + br.colors = colors; |
---|
| 912 | + } |
---|
| 913 | + else |
---|
| 914 | + { |
---|
| 915 | + for (int i = 0; i < br.VertexCount(); i++) |
---|
| 916 | + { |
---|
| 917 | + Vertex v = br.GetVertex(i); |
---|
| 918 | + |
---|
| 919 | + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
| 920 | + continue; |
---|
| 921 | + |
---|
| 922 | + from.set(v.x, v.y, v.z); |
---|
| 923 | + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
| 924 | + LA.xformPos(from, transform, from); |
---|
| 925 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 926 | + localcamera.setAim(from, to); |
---|
| 927 | + |
---|
| 928 | + CameraPane.occlusionbuffer.display(); |
---|
| 929 | + |
---|
| 930 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 931 | + cp.display(); // debug |
---|
| 932 | + |
---|
| 933 | + v.AO = cp.vertexOcclusion.r; |
---|
| 934 | + |
---|
| 935 | + if ((i % 100) == 0 && i != 0) |
---|
| 936 | + { |
---|
| 937 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 938 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 939 | + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); |
---|
| 940 | + } |
---|
| 941 | + } |
---|
| 942 | + } |
---|
| 943 | + |
---|
| 944 | + //System.out.println("done."); |
---|
| 945 | + |
---|
| 946 | + cp.renderCamera = keep; |
---|
| 947 | + } |
---|
| 948 | + |
---|
| 949 | + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 950 | + { |
---|
| 951 | + CameraPane display = this; |
---|
| 952 | + pointFlow.CreateHT(); |
---|
| 953 | + |
---|
| 954 | + float r = display.modelParams0[0]; |
---|
| 955 | + float g = display.modelParams0[1]; |
---|
| 956 | + float b = display.modelParams0[2]; |
---|
| 957 | + float opacity = display.modelParams5[1]; |
---|
| 958 | + |
---|
| 959 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 960 | + GL gl = display.GetGL(); // getGL(); |
---|
| 961 | + |
---|
| 962 | + int s = pointFlow.points.size(); |
---|
| 963 | + |
---|
| 964 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 965 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 966 | + |
---|
| 967 | + for (int i=s; --i>=0;) |
---|
| 968 | + //for (int i=0; i<s; i++) |
---|
| 969 | + { |
---|
| 970 | + cVector v = pointFlow.points.get(i); |
---|
| 971 | + |
---|
| 972 | + double mindist = Double.MAX_VALUE; |
---|
| 973 | + |
---|
| 974 | + double size = pointFlow.minimumSize; |
---|
| 975 | + |
---|
| 976 | + double distancenext = 0; |
---|
| 977 | + |
---|
| 978 | + if (i > 0) |
---|
| 979 | + { |
---|
| 980 | + cVector w = pointFlow.points.get(i-1); |
---|
| 981 | + |
---|
| 982 | + double dist = w.distance(v); |
---|
| 983 | + |
---|
| 984 | + distancenext = dist; |
---|
| 985 | + |
---|
| 986 | + if (mindist > dist) |
---|
| 987 | + { |
---|
| 988 | + mindist = dist; |
---|
| 989 | + size = mindist*pointFlow.resizefactor; |
---|
| 990 | + } |
---|
| 991 | + } |
---|
| 992 | + |
---|
| 993 | + if (i < s-1) |
---|
| 994 | + { |
---|
| 995 | + cVector w = pointFlow.points.get(i+1); |
---|
| 996 | + |
---|
| 997 | + double dist = w.distance(v); |
---|
| 998 | + |
---|
| 999 | + if (mindist > dist) |
---|
| 1000 | + { |
---|
| 1001 | + mindist = dist; |
---|
| 1002 | + size = mindist*pointFlow.resizefactor; |
---|
| 1003 | + } |
---|
| 1004 | + } |
---|
| 1005 | + |
---|
| 1006 | + if (size < pointFlow.minimumSize) |
---|
| 1007 | + size = pointFlow.minimumSize; |
---|
| 1008 | + if (size > pointFlow.maximumSize) |
---|
| 1009 | + size = pointFlow.maximumSize; |
---|
| 1010 | + |
---|
| 1011 | + double tx = v.x; |
---|
| 1012 | + double ty = v.y; |
---|
| 1013 | + double tz = v.z; |
---|
| 1014 | + |
---|
| 1015 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 1016 | + // continue; |
---|
| 1017 | + |
---|
| 1018 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1019 | + gl.glPushMatrix(); |
---|
| 1020 | + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; |
---|
| 1021 | + |
---|
| 1022 | + gl.glMultMatrixf(pointFlow.texmat, 0); |
---|
| 1023 | + |
---|
| 1024 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1025 | + gl.glPushMatrix(); |
---|
| 1026 | + |
---|
| 1027 | + gl.glTranslated(tx,ty,tz); |
---|
| 1028 | + |
---|
| 1029 | + gl.glScaled(size,size,size); |
---|
| 1030 | + |
---|
| 1031 | +// float cr = colorBuf.get(index4); |
---|
| 1032 | +// float cg = colorBuf.get(index4+1); |
---|
| 1033 | +// float cb = colorBuf.get(index4+2); |
---|
| 1034 | +// float ca = colorBuf.get(index4+3); |
---|
| 1035 | +// |
---|
| 1036 | +// display.modelParams0[0] = r * cr; |
---|
| 1037 | +// display.modelParams0[1] = g * cg; |
---|
| 1038 | +// display.modelParams0[2] = b * cb; |
---|
| 1039 | +// |
---|
| 1040 | +// display.modelParams5[1] = opacity * ca; |
---|
| 1041 | +// |
---|
| 1042 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1043 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1044 | +// |
---|
| 1045 | +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
| 1046 | +// RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 1047 | +// |
---|
| 1048 | +//// gl.glColor4f(cr,cg,cb,ca); |
---|
| 1049 | +// // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 1050 | + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); |
---|
| 1051 | + |
---|
| 1052 | + gl.glPopMatrix(); |
---|
| 1053 | + |
---|
| 1054 | + double step = size/4; // |
---|
| 1055 | + |
---|
| 1056 | + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) |
---|
| 1057 | + continue; |
---|
| 1058 | + |
---|
| 1059 | + int nbsteps = (int)(distancenext/step); |
---|
| 1060 | + |
---|
| 1061 | + step = distancenext/nbsteps; |
---|
| 1062 | + |
---|
| 1063 | + cVector next = pointFlow.points.get(i-1); |
---|
| 1064 | + |
---|
| 1065 | + tmp.set(next); |
---|
| 1066 | + tmp.sub(v); |
---|
| 1067 | + tmp.normalize(); |
---|
| 1068 | + tmp.mul(step); |
---|
| 1069 | + |
---|
| 1070 | + // calculate next size |
---|
| 1071 | + mindist = Double.MAX_VALUE; |
---|
| 1072 | + |
---|
| 1073 | + double nextsize = pointFlow.minimumSize; |
---|
| 1074 | + |
---|
| 1075 | + if (i > 1) |
---|
| 1076 | + { |
---|
| 1077 | + cVector w = pointFlow.points.get(i-2); |
---|
| 1078 | + |
---|
| 1079 | + double dist = w.distance(next); |
---|
| 1080 | + |
---|
| 1081 | + if (mindist > dist) |
---|
| 1082 | + { |
---|
| 1083 | + mindist = dist; |
---|
| 1084 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1085 | + } |
---|
| 1086 | + } |
---|
| 1087 | + |
---|
| 1088 | + double dist = v.distance(next); |
---|
| 1089 | + |
---|
| 1090 | + if (mindist > dist) |
---|
| 1091 | + { |
---|
| 1092 | + mindist = dist; |
---|
| 1093 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1094 | + } |
---|
| 1095 | + |
---|
| 1096 | + if (nextsize < pointFlow.minimumSize) |
---|
| 1097 | + nextsize = pointFlow.minimumSize; |
---|
| 1098 | + if (nextsize > pointFlow.maximumSize) |
---|
| 1099 | + nextsize = pointFlow.maximumSize; |
---|
| 1100 | + // |
---|
| 1101 | + |
---|
| 1102 | + double count = 0; |
---|
| 1103 | + |
---|
| 1104 | + while (distancenext > 0.000000001) // step |
---|
| 1105 | + { |
---|
| 1106 | + gl.glPushMatrix(); |
---|
| 1107 | + |
---|
| 1108 | + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); |
---|
| 1109 | + |
---|
| 1110 | + double K = count/nbsteps; |
---|
| 1111 | + |
---|
| 1112 | + double intersize = K*nextsize + (1-K)*size; |
---|
| 1113 | + |
---|
| 1114 | + gl.glScaled(intersize,intersize,intersize); |
---|
| 1115 | + |
---|
| 1116 | + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); |
---|
| 1117 | + |
---|
| 1118 | + count++; |
---|
| 1119 | + |
---|
| 1120 | + distancenext -= step; |
---|
| 1121 | + |
---|
| 1122 | + gl.glPopMatrix(); |
---|
| 1123 | + } |
---|
| 1124 | + |
---|
| 1125 | + if (count != nbsteps) |
---|
| 1126 | + assert(count == nbsteps); |
---|
| 1127 | + |
---|
| 1128 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 1129 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 1130 | + |
---|
| 1131 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1132 | + gl.glPopMatrix(); |
---|
| 1133 | + } |
---|
| 1134 | + |
---|
| 1135 | + if (!cf) |
---|
| 1136 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 1137 | + |
---|
| 1138 | +// display.modelParams0[0] = r; |
---|
| 1139 | +// display.modelParams0[1] = g; |
---|
| 1140 | +// display.modelParams0[2] = b; |
---|
| 1141 | +// |
---|
| 1142 | +// display.modelParams5[1] = opacity; |
---|
| 1143 | +// |
---|
| 1144 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1145 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1146 | + |
---|
| 1147 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1148 | + } |
---|
| 1149 | + |
---|
| 1150 | + public void DrawBox(cVector min, cVector max) |
---|
| 1151 | + { |
---|
| 1152 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1153 | + gl.glBegin(gl.GL_LINES); |
---|
| 1154 | + |
---|
| 1155 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1156 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1157 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1158 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1159 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1160 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1161 | + |
---|
| 1162 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1163 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1164 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1165 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1166 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1167 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1168 | + |
---|
| 1169 | + gl.glEnd(); |
---|
| 1170 | + } |
---|
| 1171 | + |
---|
| 1172 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1173 | + { |
---|
| 1174 | + int[] strips = bRep.getRawIndices(); |
---|
| 1175 | + |
---|
| 1176 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1177 | + |
---|
| 1178 | + // TRIANGLE STRIP ARRAY |
---|
| 1179 | + if (bRep.trimmed) |
---|
| 1180 | + { |
---|
| 1181 | + float[] v = bRep.getRawVertices(); |
---|
| 1182 | + float[] n = bRep.getRawNormals(); |
---|
| 1183 | + float[] c = bRep.getRawColors(); |
---|
| 1184 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1185 | + |
---|
| 1186 | + int count2 = 0; |
---|
| 1187 | + int count3 = 0; |
---|
| 1188 | + |
---|
| 1189 | + if (n.length > 0) |
---|
| 1190 | + { |
---|
| 1191 | + for (int i = 0; i < strips.length; i++) |
---|
| 1192 | + { |
---|
| 1193 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1194 | + |
---|
| 1195 | + /* |
---|
| 1196 | + boolean locked = false; |
---|
| 1197 | + float eps = 0.1f; |
---|
| 1198 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1199 | + |
---|
| 1200 | + int dot = 0; |
---|
| 1201 | + |
---|
| 1202 | + if ((dot&1) == 0) |
---|
| 1203 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1204 | + |
---|
| 1205 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1206 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1207 | + else |
---|
| 1208 | + { |
---|
| 1209 | + locked = true; |
---|
| 1210 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1211 | + } |
---|
| 1212 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1213 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1214 | + if (hasnorm) |
---|
| 1215 | + { |
---|
| 1216 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1217 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1218 | + } |
---|
| 1219 | + |
---|
| 1220 | + if ((dot&4) == 0) |
---|
| 1221 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1222 | + |
---|
| 1223 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1224 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1225 | + else |
---|
| 1226 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1227 | + |
---|
| 1228 | + f.dot = dot; |
---|
| 1229 | + */ |
---|
| 1230 | + |
---|
| 1231 | + if (!selectmode) |
---|
| 1232 | + { |
---|
| 1233 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1234 | + { |
---|
| 1235 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1236 | + } else |
---|
| 1237 | + { |
---|
| 1238 | + gl.glNormal3f(0, 0, 1); |
---|
| 1239 | + } |
---|
| 1240 | + |
---|
| 1241 | + if (c != null) |
---|
| 1242 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1243 | + { |
---|
| 1244 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1245 | + } |
---|
| 1246 | + } |
---|
| 1247 | + |
---|
| 1248 | + if (flipV) |
---|
| 1249 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1250 | + else |
---|
| 1251 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1252 | + |
---|
| 1253 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1254 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1255 | + |
---|
| 1256 | + count2 += 2; |
---|
| 1257 | + count3 += 3; |
---|
| 1258 | + if (!selectmode) |
---|
| 1259 | + { |
---|
| 1260 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1261 | + { |
---|
| 1262 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1263 | + } else |
---|
| 1264 | + { |
---|
| 1265 | + gl.glNormal3f(0, 0, 1); |
---|
| 1266 | + } |
---|
| 1267 | + if (c != null) |
---|
| 1268 | + { |
---|
| 1269 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1270 | + } |
---|
| 1271 | + } |
---|
| 1272 | + |
---|
| 1273 | + if (flipV) |
---|
| 1274 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1275 | + else |
---|
| 1276 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1277 | + |
---|
| 1278 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1279 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1280 | + |
---|
| 1281 | + count2 += 2; |
---|
| 1282 | + count3 += 3; |
---|
| 1283 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1284 | + { |
---|
| 1285 | + //gl.glTexCoord2d(...); |
---|
| 1286 | + if (!selectmode) |
---|
| 1287 | + { |
---|
| 1288 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1289 | + { |
---|
| 1290 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1291 | + } else |
---|
| 1292 | + { |
---|
| 1293 | + gl.glNormal3f(0, 0, 1); |
---|
| 1294 | + } |
---|
| 1295 | + if (c != null) |
---|
| 1296 | + { |
---|
| 1297 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1298 | + } |
---|
| 1299 | + } |
---|
| 1300 | + |
---|
| 1301 | + if (flipV) |
---|
| 1302 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1303 | + else |
---|
| 1304 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1305 | + |
---|
| 1306 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1307 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1308 | + |
---|
| 1309 | + count2 += 2; |
---|
| 1310 | + count3 += 3; |
---|
| 1311 | + } |
---|
| 1312 | + |
---|
| 1313 | + gl.glEnd(); |
---|
| 1314 | + } |
---|
| 1315 | + } |
---|
| 1316 | + |
---|
| 1317 | + assert count3 == v.length; |
---|
| 1318 | + } |
---|
| 1319 | + else // !trimmed |
---|
| 1320 | + { |
---|
| 1321 | + int count = 0; |
---|
| 1322 | + for (int i = 0; i < strips.length; i++) |
---|
| 1323 | + { |
---|
| 1324 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1325 | + |
---|
| 1326 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1327 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1328 | + |
---|
| 1329 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1330 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1331 | + |
---|
| 1332 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1333 | + { |
---|
| 1334 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1335 | + |
---|
| 1336 | + // if (j%2 == 0) |
---|
| 1337 | + // drawFace(p, q, r, display, null); |
---|
| 1338 | + // else |
---|
| 1339 | + // drawFace(p, r, q, display, null); |
---|
| 1340 | + |
---|
| 1341 | + // p = q; |
---|
| 1342 | + // q = r; |
---|
| 1343 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1344 | + } |
---|
| 1345 | + |
---|
| 1346 | + gl.glEnd(); |
---|
| 1347 | + } |
---|
| 1348 | + } |
---|
| 1349 | + } |
---|
| 1350 | + |
---|
| 1351 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1352 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1353 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1354 | + |
---|
| 1355 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1356 | + { |
---|
| 1357 | + GL gl = GetGL(); // getGL(); |
---|
| 1358 | + |
---|
| 1359 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1360 | + |
---|
| 1361 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1362 | + |
---|
| 1363 | + gl.glLineWidth(1); |
---|
| 1364 | + gl.glColor3f(1,1,1); |
---|
| 1365 | + gl.glBegin(gl.GL_LINES); |
---|
| 1366 | + double scale = 0; |
---|
| 1367 | + int count = 0; |
---|
| 1368 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1369 | + { |
---|
| 1370 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1371 | + if(s == 0) |
---|
| 1372 | + { |
---|
| 1373 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1374 | + } |
---|
| 1375 | + if (mesh.showsprings) |
---|
| 1376 | + { |
---|
| 1377 | + temp.set(spring.a.position); |
---|
| 1378 | + temp.add(spring.b.position); |
---|
| 1379 | + temp.mul(0.5); |
---|
| 1380 | + temp2.set(spring.a.position); |
---|
| 1381 | + temp2.sub(spring.b.position); |
---|
| 1382 | + temp2.mul(spring.restLength/2); |
---|
| 1383 | + temp.sub(temp2); |
---|
| 1384 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1385 | + temp.add(temp2); |
---|
| 1386 | + temp.add(temp2); |
---|
| 1387 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1388 | + } |
---|
| 1389 | + |
---|
| 1390 | + if (spring.isHandle) |
---|
| 1391 | + continue; |
---|
| 1392 | + |
---|
| 1393 | + //if (scale < spring.restLength) |
---|
| 1394 | + scale += spring.restLength; |
---|
| 1395 | + count++; |
---|
| 1396 | + } |
---|
| 1397 | + gl.glEnd(); |
---|
| 1398 | + |
---|
| 1399 | + if (count == 0) |
---|
| 1400 | + scale = 0.01; |
---|
| 1401 | + else |
---|
| 1402 | + scale /= count * 3; |
---|
| 1403 | + |
---|
| 1404 | + //scale = 0.25; |
---|
| 1405 | + |
---|
| 1406 | + if (mesh.ShowInfo()) |
---|
| 1407 | + { |
---|
| 1408 | + gl.glLineWidth(4); |
---|
| 1409 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1410 | + { |
---|
| 1411 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1412 | + if (node.mass == 0) |
---|
| 1413 | + continue; |
---|
| 1414 | + |
---|
| 1415 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1416 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1417 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1418 | + //temp.normalize(); |
---|
| 1419 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1420 | + gl.glBegin(gl.GL_LINES); |
---|
| 1421 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1422 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1423 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1424 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1425 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1426 | + gl.glEnd(); |
---|
| 1427 | + } |
---|
| 1428 | + |
---|
| 1429 | + gl.glLineWidth(8); |
---|
| 1430 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1431 | + { |
---|
| 1432 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1433 | + |
---|
| 1434 | + if (node.springs != null) |
---|
| 1435 | + { |
---|
| 1436 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1437 | + { |
---|
| 1438 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1439 | + |
---|
| 1440 | + int c = i+1; |
---|
| 1441 | + // c = node.springs.get(i).nbcopies; |
---|
| 1442 | + |
---|
| 1443 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1444 | + gl.glBegin(gl.GL_LINES); |
---|
| 1445 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1446 | + 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); |
---|
| 1447 | + gl.glEnd(); |
---|
| 1448 | + } |
---|
| 1449 | + } |
---|
| 1450 | + } |
---|
| 1451 | + |
---|
| 1452 | + gl.glLineWidth(1); |
---|
| 1453 | + } |
---|
| 1454 | + |
---|
| 1455 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1456 | + } |
---|
| 1457 | + |
---|
| 1458 | + /// INTERFACE |
---|
| 1459 | + |
---|
| 1460 | + public void StartTriangles() |
---|
| 1461 | + { |
---|
| 1462 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1463 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1464 | + } |
---|
| 1465 | + |
---|
| 1466 | + public void EndTriangles() |
---|
| 1467 | + { |
---|
| 1468 | + GetGL().glEnd(); |
---|
| 1469 | + } |
---|
| 1470 | + |
---|
| 1471 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1472 | + { |
---|
| 1473 | + if (!selectmode) |
---|
| 1474 | + { |
---|
| 1475 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1476 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1477 | + |
---|
| 1478 | + if (flipV) |
---|
| 1479 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1480 | + else |
---|
| 1481 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1482 | + } |
---|
| 1483 | + |
---|
| 1484 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1485 | + } |
---|
| 1486 | + |
---|
| 1487 | + void SetColor(Object3D obj, Vertex p0) |
---|
| 1488 | + { |
---|
| 1489 | + CameraPane display = this; |
---|
| 1490 | + BoundaryRep bRep = obj.bRep; |
---|
| 1491 | + |
---|
| 1492 | + if (RENDERPROGRAM == 0) |
---|
| 1493 | + { |
---|
| 1494 | + float r = 0; |
---|
| 1495 | + if (bRep != null) |
---|
| 1496 | + { |
---|
| 1497 | + if (bRep.stripified) |
---|
| 1498 | + { |
---|
| 1499 | + r = 1; |
---|
| 1500 | + } |
---|
| 1501 | + } |
---|
| 1502 | + float g = 0; |
---|
| 1503 | + if (bRep != null) |
---|
| 1504 | + { |
---|
| 1505 | + if (bRep.trimmed) |
---|
| 1506 | + { |
---|
| 1507 | + g = 1; |
---|
| 1508 | + } |
---|
| 1509 | + } |
---|
| 1510 | + float b = 0; |
---|
| 1511 | + if (obj.support != null && obj.link2master) |
---|
| 1512 | + { |
---|
| 1513 | + b = 1; |
---|
| 1514 | + } |
---|
| 1515 | + display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO); |
---|
| 1516 | + return; |
---|
| 1517 | + } |
---|
| 1518 | + |
---|
| 1519 | + if (display.DrawMode() != CameraPane.SHADOW) |
---|
| 1520 | + return; |
---|
| 1521 | + |
---|
| 1522 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1523 | +// if (true) return; |
---|
| 1524 | +// float ao = p.AO; |
---|
| 1525 | +// |
---|
| 1526 | +// // if (ao == 0 && !bRep.AOdone) // transient problem! |
---|
| 1527 | +// // ao = 1; |
---|
| 1528 | +// |
---|
| 1529 | +// gl.glColor4f(ao, ao, ao, 1); |
---|
| 1530 | + |
---|
| 1531 | +// CameraPane.selectedpoint. |
---|
| 1532 | +// getAverage(cStatic.point1, true); |
---|
| 1533 | + if (CameraPane.pointflow == null) // !random) // live) |
---|
| 1534 | + { |
---|
| 1535 | + return; |
---|
| 1536 | + } |
---|
| 1537 | + |
---|
| 1538 | + cStatic.point1.set(0,0,0); |
---|
| 1539 | + LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1); |
---|
| 1540 | + |
---|
| 1541 | + cStatic.point1.sub(p0); |
---|
| 1542 | + |
---|
| 1543 | + |
---|
| 1544 | +// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta? |
---|
| 1545 | +// { |
---|
| 1546 | +// return; |
---|
| 1547 | +// } |
---|
| 1548 | + |
---|
| 1549 | + //if (true) |
---|
| 1550 | + if (cStatic.point1.dot(cStatic.point1) > 0.000001) |
---|
| 1551 | + { |
---|
| 1552 | + return; |
---|
| 1553 | + } |
---|
| 1554 | + |
---|
| 1555 | + float[] colorV = new float[3]; |
---|
| 1556 | + |
---|
| 1557 | + if (false) // marked) |
---|
| 1558 | + { |
---|
| 1559 | + // debug rigging weights |
---|
| 1560 | + for (int object = 0; object < p0.vertexlinks.length; object++) |
---|
| 1561 | + { |
---|
| 1562 | + float weight = p0.weights[object] / p0.totalweight; |
---|
| 1563 | + |
---|
| 1564 | + // if (weight < 0.1) |
---|
| 1565 | + // { |
---|
| 1566 | + // assert(weight == 0); |
---|
| 1567 | + // continue; |
---|
| 1568 | + // } |
---|
| 1569 | + |
---|
| 1570 | + if (p0.vertexlinks[object] == -1) |
---|
| 1571 | + continue; |
---|
| 1572 | + |
---|
| 1573 | + Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]); |
---|
| 1574 | + |
---|
| 1575 | + int color = //1 << object; // |
---|
| 1576 | + //p.vertexlinks.length; |
---|
| 1577 | + obj.support.bRep.supports[p0.closestsupport].links[object]; |
---|
| 1578 | + colorV[2] += (color & 1) * weight; |
---|
| 1579 | + colorV[1] += ((color & 2) >> 1) * weight; |
---|
| 1580 | + colorV[0] += ((color & 4) >> 2) * weight; |
---|
| 1581 | + } |
---|
| 1582 | + } |
---|
| 1583 | + else |
---|
| 1584 | + { |
---|
| 1585 | + if (obj.drawingstarted) |
---|
| 1586 | + { |
---|
| 1587 | + // find next point |
---|
| 1588 | + if (bRep.GetVertex(0).faceindices == null) |
---|
| 1589 | + { |
---|
| 1590 | + bRep.InitFaceIndices(); |
---|
| 1591 | + } |
---|
| 1592 | + |
---|
| 1593 | + double ymin = p0.y; |
---|
| 1594 | + |
---|
| 1595 | + Vertex newp = p0; |
---|
| 1596 | + |
---|
| 1597 | + for (int fii = 0; fii < p0.faceindices.length; fii++) |
---|
| 1598 | + { |
---|
| 1599 | + int fi = p0.faceindices[fii]; |
---|
| 1600 | + |
---|
| 1601 | + if (fi == -1) |
---|
| 1602 | + break; |
---|
| 1603 | + |
---|
| 1604 | + Face f = bRep.GetFace(fi); |
---|
| 1605 | + |
---|
| 1606 | + Vertex p = bRep.GetVertex(f.p); |
---|
| 1607 | + Vertex q = bRep.GetVertex(f.q); |
---|
| 1608 | + Vertex r = bRep.GetVertex(f.r); |
---|
| 1609 | + |
---|
| 1610 | + int swap = (int)(Math.random()*3); |
---|
| 1611 | + |
---|
| 1612 | +// for (int s=swap; --s>=0;) |
---|
| 1613 | +// { |
---|
| 1614 | +// Vertex t = p; |
---|
| 1615 | +// p = q; |
---|
| 1616 | +// q = r; |
---|
| 1617 | +// r = t; |
---|
| 1618 | +// } |
---|
| 1619 | + if (ymin > p.y) |
---|
| 1620 | + { |
---|
| 1621 | + ymin = p.y; |
---|
| 1622 | + newp = p; |
---|
| 1623 | +// break; |
---|
| 1624 | + } |
---|
| 1625 | + if (ymin > q.y) |
---|
| 1626 | + { |
---|
| 1627 | + ymin = q.y; |
---|
| 1628 | + newp = q; |
---|
| 1629 | +// break; |
---|
| 1630 | + } |
---|
| 1631 | + if (ymin > r.y) |
---|
| 1632 | + { |
---|
| 1633 | + ymin = r.y; |
---|
| 1634 | + newp = r; |
---|
| 1635 | +// break; |
---|
| 1636 | + } |
---|
| 1637 | + } |
---|
| 1638 | + |
---|
| 1639 | + CameraPane.selectedpoint.toParent[3][0] = newp.x; |
---|
| 1640 | + CameraPane.selectedpoint.toParent[3][1] = newp.y; |
---|
| 1641 | + CameraPane.selectedpoint.toParent[3][2] = newp.z; |
---|
| 1642 | + |
---|
| 1643 | + obj.drawingstarted = false; |
---|
| 1644 | + |
---|
| 1645 | + // return; |
---|
| 1646 | + } |
---|
| 1647 | + |
---|
| 1648 | + if (false) // CameraPane.DRAW |
---|
| 1649 | + { |
---|
| 1650 | + p0.AO = colorV[0] = 2; |
---|
| 1651 | + colorV[1] = 2; |
---|
| 1652 | + colorV[2] = 2; |
---|
| 1653 | + } |
---|
| 1654 | + |
---|
| 1655 | + CameraPane.pointflow.add(p0); |
---|
| 1656 | + CameraPane.pointflow.Touch(); |
---|
| 1657 | + } |
---|
| 1658 | + |
---|
| 1659 | +// gl.glColor3f(colorV[0], colorV[1], colorV[2]); |
---|
| 1660 | +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1661 | +// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1662 | + } |
---|
| 1663 | + |
---|
| 1664 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
| 1665 | + { |
---|
| 1666 | + CameraPane display = this; |
---|
| 1667 | + //new Exception().printStackTrace(); |
---|
| 1668 | + |
---|
| 1669 | + if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW) |
---|
| 1670 | + { |
---|
| 1671 | + return; |
---|
| 1672 | + } |
---|
| 1673 | + |
---|
| 1674 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1675 | + |
---|
| 1676 | + //Color col = Color.getHSBColor(color,modulation,1); |
---|
| 1677 | + //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
| 1678 | + if (!material.multiply) |
---|
| 1679 | + { |
---|
| 1680 | + display.color = material.color; |
---|
| 1681 | + display.saturation = material.modulation; |
---|
| 1682 | + } |
---|
| 1683 | + else |
---|
| 1684 | + { |
---|
| 1685 | + display.color *= material.color*2; |
---|
| 1686 | + display.saturation *= material.modulation*2; |
---|
| 1687 | + } |
---|
| 1688 | + |
---|
| 1689 | + cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
| 1690 | + |
---|
| 1691 | + float[] colorV = Grafreed.colorV; |
---|
| 1692 | + |
---|
| 1693 | + /**/ |
---|
| 1694 | + if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
| 1695 | + { |
---|
| 1696 | + colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
| 1697 | + colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
| 1698 | + colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
| 1699 | + colorV[3] = 1; // material.opacity; |
---|
| 1700 | + |
---|
| 1701 | + gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
| 1702 | + //System.out.println("Opacity = " + opacity); |
---|
| 1703 | + |
---|
| 1704 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1705 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1706 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1707 | + |
---|
| 1708 | + float amb = material.ambient; |
---|
| 1709 | + if (amb < material.cameralight) |
---|
| 1710 | + { |
---|
| 1711 | + amb = material.cameralight; |
---|
| 1712 | + } |
---|
| 1713 | + colorV[0] = display.modelParams0[0] * material.diffuse * amb; |
---|
| 1714 | + colorV[1] = display.modelParams0[1] * material.diffuse * amb; |
---|
| 1715 | + colorV[2] = display.modelParams0[2] * material.diffuse * amb; |
---|
| 1716 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0); |
---|
| 1717 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1718 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 1719 | + |
---|
| 1720 | + /**/ |
---|
| 1721 | + colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular; |
---|
| 1722 | + colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular; |
---|
| 1723 | + colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular; |
---|
| 1724 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0); |
---|
| 1725 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1726 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0); |
---|
| 1727 | + colorV[0] = 10 / material.shininess; // 1/0.005f; |
---|
| 1728 | + //System.out.println("shininess = " + colorV[0]); |
---|
| 1729 | + if (colorV[0] > 128) |
---|
| 1730 | + { |
---|
| 1731 | + colorV[0] = 128; |
---|
| 1732 | + } |
---|
| 1733 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0); |
---|
| 1734 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0); |
---|
| 1735 | + /**/ |
---|
| 1736 | + } |
---|
| 1737 | + /**/ |
---|
| 1738 | + |
---|
| 1739 | + //selected = false; |
---|
| 1740 | + selected = selected && display.flash; |
---|
| 1741 | + |
---|
| 1742 | + //display.modelParams0[0] = 0; // pigment.r; |
---|
| 1743 | + //display.modelParams0[1] = 0; // pigment.g; |
---|
| 1744 | + //display.modelParams0[2] = 0; // pigment.b; |
---|
| 1745 | + if (!material.multiply) |
---|
| 1746 | + { |
---|
| 1747 | + display.modelParams0[3] = material.metalness; |
---|
| 1748 | + display.modelParams1[0] = material.diffuse; |
---|
| 1749 | + display.modelParams1[1] = material.specular; |
---|
| 1750 | + display.modelParams1[2] = 1 / material.shininess; |
---|
| 1751 | + display.modelParams1[3] = material.shift; |
---|
| 1752 | + display.modelParams2[0] = material.ambient; |
---|
| 1753 | + display.modelParams2[1] = material.lightarea; |
---|
| 1754 | + //System.out.println("light area = " + lightarea); |
---|
| 1755 | + display.modelParams2[2] = 1 / material.factor; // diffuseness |
---|
| 1756 | + display.modelParams2[3] = material.velvet; |
---|
| 1757 | + display.modelParams3[0] = material.sheen; |
---|
| 1758 | + display.modelParams3[1] = material.subsurface; |
---|
| 1759 | + display.modelParams3[2] = material.bump; // backlit |
---|
| 1760 | + display.modelParams3[3] = material.aniso; |
---|
| 1761 | + display.modelParams4[0] = material.anisoV; |
---|
| 1762 | + display.modelParams4[1] = selected ? 100 : material.cameralight; |
---|
| 1763 | + //System.out.println("selected = " + selected); |
---|
| 1764 | + display.modelParams4[2] = material.diffuseness; |
---|
| 1765 | + display.modelParams4[3] = material.shadow; |
---|
| 1766 | + display.modelParams5[0] = material.texture; |
---|
| 1767 | + display.modelParams5[1] = material.opacity; |
---|
| 1768 | + display.modelParams5[2] = material.fakedepth; |
---|
| 1769 | + display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10; |
---|
| 1770 | + } |
---|
| 1771 | + else |
---|
| 1772 | + { |
---|
| 1773 | + display.modelParams0[3] *= material.metalness*2; |
---|
| 1774 | + display.modelParams1[0] *= material.diffuse*2; |
---|
| 1775 | + display.modelParams1[1] *= material.specular*2; |
---|
| 1776 | + display.modelParams1[2] *= material.shininess*2; |
---|
| 1777 | + display.modelParams1[3] *= material.shift*2; |
---|
| 1778 | + display.modelParams2[0] *= material.ambient*2; |
---|
| 1779 | + display.modelParams2[1] *= material.lightarea*2; |
---|
| 1780 | + display.modelParams2[2] *= material.factor*2; |
---|
| 1781 | + display.modelParams2[3] *= material.velvet*2; |
---|
| 1782 | + display.modelParams3[0] *= material.sheen*2; |
---|
| 1783 | + display.modelParams3[1] *= material.subsurface*2; |
---|
| 1784 | + display.modelParams3[2] *= material.bump*2; |
---|
| 1785 | + display.modelParams3[3] *= material.aniso*2; |
---|
| 1786 | + display.modelParams4[0] *= material.anisoV*2; |
---|
| 1787 | + display.modelParams4[1] *= material.cameralight*2; |
---|
| 1788 | + //System.out.println("selected = " + selected); |
---|
| 1789 | + display.modelParams4[2] *= material.diffuseness*2; |
---|
| 1790 | + display.modelParams4[3] *= material.shadow*2; |
---|
| 1791 | + display.modelParams5[0] *= material.texture*2; |
---|
| 1792 | + display.modelParams5[1] *= material.opacity*2; |
---|
| 1793 | + display.modelParams5[2] *= material.fakedepth*2; |
---|
| 1794 | + display.modelParams5[3] *= material.shadowbias*2; |
---|
| 1795 | + } |
---|
| 1796 | + |
---|
| 1797 | + display.modelParams6[0] = 0; |
---|
| 1798 | + display.modelParams6[1] = 0; |
---|
| 1799 | + display.modelParams6[2] = 0; |
---|
| 1800 | + display.modelParams6[3] = 0; |
---|
| 1801 | + |
---|
| 1802 | + display.modelParams7[0] = 0; |
---|
| 1803 | + display.modelParams7[1] = 1000; |
---|
| 1804 | + display.modelParams7[2] = 0; |
---|
| 1805 | + display.modelParams7[3] = 0; |
---|
| 1806 | + |
---|
| 1807 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1808 | + |
---|
| 1809 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
| 1810 | + if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
| 1811 | + { |
---|
| 1812 | + display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
| 1813 | + display.modelParams6[1] = extparams[0].y / 1000.0f; // noise |
---|
| 1814 | + if (extparams.length > 1) |
---|
| 1815 | + { |
---|
| 1816 | + display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade |
---|
| 1817 | + display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough |
---|
| 1818 | + if (extparams.length > 2) |
---|
| 1819 | + { |
---|
| 1820 | + display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power |
---|
| 1821 | + float x = extparams[2].y / 1000.0f; |
---|
| 1822 | + //if (x == 0) |
---|
| 1823 | + // x = 1f; |
---|
| 1824 | + 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 |
---|
| 1825 | + if (extparams[2].y > 0) |
---|
| 1826 | + { |
---|
| 1827 | + //System.out.println("extparams[1].y = " + extparams[1].y); |
---|
| 1828 | + //System.out.println("extparams[2].y = " + extparams[2].y); |
---|
| 1829 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1830 | + } |
---|
| 1831 | + } |
---|
| 1832 | + } |
---|
| 1833 | + } |
---|
| 1834 | + |
---|
| 1835 | + //if (display.modelParams6[2] != 0) |
---|
| 1836 | + /* |
---|
| 1837 | + System.out.println("modelParams0[0] = " + display.modelParams0[0]); |
---|
| 1838 | + System.out.println("modelParams0[1] = " + display.modelParams0[1]); |
---|
| 1839 | + System.out.println("modelParams0[2] = " + display.modelParams0[2]); |
---|
| 1840 | + System.out.println("modelParams0[3] = " + display.modelParams0[3]); |
---|
| 1841 | + System.out.println("modelParams1[0] = " + display.modelParams1[0]); |
---|
| 1842 | + System.out.println("modelParams1[1] = " + display.modelParams1[1]); |
---|
| 1843 | + System.out.println("modelParams1[2] = " + display.modelParams1[2]); |
---|
| 1844 | + System.out.println("modelParams1[3] = " + display.modelParams1[3]); |
---|
| 1845 | + System.out.println("modelParams2[0] = " + display.modelParams2[0]); |
---|
| 1846 | + System.out.println("modelParams2[1] = " + display.modelParams2[1]); |
---|
| 1847 | + System.out.println("modelParams2[2] = " + display.modelParams2[2]); |
---|
| 1848 | + System.out.println("modelParams2[3] = " + display.modelParams2[3]); |
---|
| 1849 | + System.out.println("modelParams3[0] = " + display.modelParams3[0]); |
---|
| 1850 | + System.out.println("modelParams3[1] = " + display.modelParams3[1]); |
---|
| 1851 | + System.out.println("modelParams3[2] = " + display.modelParams3[2]); |
---|
| 1852 | + System.out.println("modelParams3[3] = " + display.modelParams3[3]); |
---|
| 1853 | + System.out.println("modelParams4[0] = " + display.modelParams4[0]); |
---|
| 1854 | + System.out.println("modelParams4[1] = " + display.modelParams4[1]); |
---|
| 1855 | + System.out.println("modelParams4[2] = " + display.modelParams4[2]); |
---|
| 1856 | + System.out.println("modelParams4[3] = " + display.modelParams4[3]); |
---|
| 1857 | + System.out.println("modelParams5[0] = " + display.modelParams5[0]); |
---|
| 1858 | + System.out.println("modelParams5[1] = " + display.modelParams5[1]); |
---|
| 1859 | + System.out.println("modelParams5[2] = " + display.modelParams5[2]); |
---|
| 1860 | + System.out.println("modelParams5[3] = " + display.modelParams5[3]); |
---|
| 1861 | + System.out.println("modelParams6[0] = " + display.modelParams6[0]); |
---|
| 1862 | + System.out.println("modelParams6[1] = " + display.modelParams6[1]); |
---|
| 1863 | + System.out.println("modelParams6[2] = " + display.modelParams6[2]); |
---|
| 1864 | + System.out.println("modelParams6[3] = " + display.modelParams6[3]); |
---|
| 1865 | + System.out.println("modelParams7[0] = " + display.modelParams7[0]); |
---|
| 1866 | + System.out.println("modelParams7[1] = " + display.modelParams7[1]); |
---|
| 1867 | + System.out.println("modelParams7[2] = " + display.modelParams7[2]); |
---|
| 1868 | + System.out.println("modelParams7[3] = " + display.modelParams7[3]); |
---|
| 1869 | + /**/ |
---|
| 1870 | + //assert (display.modelParams6[2] == 0); |
---|
| 1871 | + |
---|
| 1872 | + //System.out.println("noise power = " + display.modelParams7[0]); |
---|
| 1873 | + //System.out.println("shadowbias = " + shadowbias); |
---|
| 1874 | + |
---|
| 1875 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1876 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0); |
---|
| 1877 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0); |
---|
| 1878 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0); |
---|
| 1879 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 1880 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1881 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0); |
---|
| 1882 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0); |
---|
| 1883 | + |
---|
| 1884 | + int mode = display.FP_SHADER; |
---|
| 1885 | + |
---|
| 1886 | + if (material.aniso != material.anisoV || material.aniso > 0.002) |
---|
| 1887 | + { |
---|
| 1888 | + mode |= display.FP_ANISO; |
---|
| 1889 | + } |
---|
| 1890 | + |
---|
| 1891 | + display.EnableProgram(mode); |
---|
| 1892 | + |
---|
| 1893 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1894 | + |
---|
| 1895 | + if (!material.multiply) |
---|
| 1896 | + { |
---|
| 1897 | + if (Globals.drawMode == CameraPane.SHADOW) |
---|
| 1898 | + gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1); |
---|
| 1899 | + else |
---|
| 1900 | + gl.glDepthMask(material.opacity >= 0.99); |
---|
| 1901 | + } |
---|
208 | 1902 | } |
---|
209 | 1903 | |
---|
210 | 1904 | int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0; |
---|
.. | .. |
---|
225 | 1919 | currentGL.glMultMatrixd(model, 0); |
---|
226 | 1920 | } |
---|
227 | 1921 | |
---|
228 | | - void PushMatrix(double[][] matrix, int count) |
---|
| 1922 | + public void PushMatrix(double[][] matrix, int count) // INTERFACE |
---|
229 | 1923 | { |
---|
230 | 1924 | matrixdepth++; |
---|
231 | 1925 | // GrafreeD.tracein(matrix); |
---|
.. | .. |
---|
254 | 1948 | void PushMatrix(double[][] matrix) |
---|
255 | 1949 | { |
---|
256 | 1950 | // GrafreeD.tracein(matrix); |
---|
257 | | - PushMatrix(matrix,1); |
---|
| 1951 | + PushMatrix(matrix, 1); |
---|
258 | 1952 | } |
---|
259 | 1953 | |
---|
260 | 1954 | void PushMatrix() |
---|
.. | .. |
---|
270 | 1964 | |
---|
271 | 1965 | double[][] tmpmat = new double[4][4]; |
---|
272 | 1966 | |
---|
273 | | - void PopMatrix(double[][] inverse) |
---|
| 1967 | + public void PopMatrix(double[][] inverse) // INTERFACE |
---|
274 | 1968 | { |
---|
275 | 1969 | --matrixdepth; |
---|
276 | 1970 | |
---|
.. | .. |
---|
310 | 2004 | PushTextureMatrix(matrix, 1); |
---|
311 | 2005 | } |
---|
312 | 2006 | |
---|
313 | | - void PushTextureMatrix(double[][] matrix, int count) |
---|
| 2007 | + public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE |
---|
314 | 2008 | { |
---|
315 | 2009 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
316 | 2010 | |
---|
.. | .. |
---|
324 | 2018 | currentGL.glMatrixMode(GetGL().GL_MODELVIEW); |
---|
325 | 2019 | } |
---|
326 | 2020 | |
---|
327 | | - void PopTextureMatrix(double[][] inverse) |
---|
| 2021 | + public void PopTextureMatrix(double[][] inverse) // INTERFACE |
---|
328 | 2022 | { |
---|
329 | 2023 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
330 | 2024 | currentGL.glMatrixMode(GetGL().GL_TEXTURE); |
---|
.. | .. |
---|
351 | 2045 | |
---|
352 | 2046 | static int camerachangeframe; |
---|
353 | 2047 | |
---|
354 | | - boolean SetCamera(Camera cam) |
---|
| 2048 | + public boolean SetCamera(Camera cam) |
---|
355 | 2049 | { |
---|
356 | 2050 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
357 | 2051 | // return false; |
---|
358 | 2052 | |
---|
359 | | - if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount) |
---|
| 2053 | + if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount) |
---|
360 | 2054 | { |
---|
361 | 2055 | // check for last change |
---|
362 | | - if (framecount < camerachangeframe + 400) // 120 == 1 second |
---|
| 2056 | + if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second |
---|
363 | 2057 | { |
---|
364 | 2058 | // refuse the camera change |
---|
365 | 2059 | System.err.println("Camera " + cam + " REFUSED"); |
---|
.. | .. |
---|
367 | 2061 | } |
---|
368 | 2062 | } |
---|
369 | 2063 | |
---|
370 | | - camerachangeframe = framecount; |
---|
| 2064 | + camerachangeframe = Globals.framecount; |
---|
371 | 2065 | |
---|
372 | 2066 | cam.hAspect = -1; // Read only |
---|
373 | 2067 | |
---|
.. | .. |
---|
398 | 2092 | { |
---|
399 | 2093 | //System.err.println("Oeil on"); |
---|
400 | 2094 | TRACK = true; |
---|
401 | | -// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 2095 | +// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
402 | 2096 | // object.editWindow.ScreenFit(trackedobject); |
---|
403 | 2097 | //pingthread.StepToTarget(true); |
---|
404 | 2098 | } |
---|
.. | .. |
---|
407 | 2101 | { |
---|
408 | 2102 | //System.err.println("Oeil on"); |
---|
409 | 2103 | OEIL = true; |
---|
410 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
411 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2104 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
| 2105 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
412 | 2106 | //pingthread.StepToTarget(true); |
---|
413 | 2107 | } |
---|
414 | 2108 | |
---|
.. | .. |
---|
471 | 2165 | { |
---|
472 | 2166 | frozen ^= true; |
---|
473 | 2167 | // Weird... |
---|
474 | | - lighttouched = true; |
---|
| 2168 | + Globals.lighttouched = true; |
---|
475 | 2169 | } |
---|
476 | 2170 | |
---|
477 | 2171 | void ToggleDL() |
---|
478 | 2172 | { |
---|
479 | 2173 | 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 | 2174 | } |
---|
508 | 2175 | |
---|
509 | 2176 | void ToggleFullScreen() |
---|
.. | .. |
---|
513 | 2180 | |
---|
514 | 2181 | void ToggleCrowd() |
---|
515 | 2182 | { |
---|
516 | | - CROWD ^= true; |
---|
517 | | - } |
---|
518 | | - |
---|
519 | | - void ToggleInertia() |
---|
520 | | - { |
---|
521 | | - INERTIA ^= true; |
---|
| 2183 | + Globals.CROWD ^= true; |
---|
522 | 2184 | } |
---|
523 | 2185 | |
---|
524 | 2186 | void ToggleLocal() |
---|
.. | .. |
---|
526 | 2188 | LOCALTRANSFORM ^= true; |
---|
527 | 2189 | } |
---|
528 | 2190 | |
---|
529 | | - void ToggleFast() |
---|
| 2191 | + public void ToggleTexture() |
---|
| 2192 | + { |
---|
| 2193 | + textureon ^= true; |
---|
| 2194 | + } |
---|
| 2195 | + |
---|
| 2196 | + public void ToggleLive() |
---|
| 2197 | + { |
---|
| 2198 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
| 2199 | + |
---|
| 2200 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
| 2201 | + |
---|
| 2202 | + if (!Globals.isLIVE()) // save sound |
---|
| 2203 | + Grafreed.savesound = true; // wav.save(); |
---|
| 2204 | + // else |
---|
| 2205 | + repaint(); // start loop // may 2013 |
---|
| 2206 | + } |
---|
| 2207 | + |
---|
| 2208 | + public void ToggleSupport() |
---|
| 2209 | + { |
---|
| 2210 | + SUPPORT ^= true; |
---|
| 2211 | + } |
---|
| 2212 | + |
---|
| 2213 | + public void ToggleAbort() |
---|
| 2214 | + { |
---|
| 2215 | + ABORTMODE ^= true; |
---|
| 2216 | + } |
---|
| 2217 | + |
---|
| 2218 | + public void ToggleInertia() |
---|
| 2219 | + { |
---|
| 2220 | + INERTIA ^= true; |
---|
| 2221 | + } |
---|
| 2222 | + |
---|
| 2223 | + public void ToggleFast() |
---|
530 | 2224 | { |
---|
531 | 2225 | FAST ^= true; |
---|
532 | 2226 | } |
---|
533 | 2227 | |
---|
534 | | - void ToggleSlowPose() |
---|
| 2228 | + public void ToggleSlowPose() |
---|
535 | 2229 | { |
---|
536 | 2230 | SLOWPOSE ^= true; |
---|
537 | 2231 | } |
---|
538 | 2232 | |
---|
539 | | - void ToggleFootContact() |
---|
540 | | - { |
---|
541 | | - FOOTCONTACT ^= true; |
---|
542 | | - } |
---|
543 | | - |
---|
544 | | - void ToggleBoxMode() |
---|
| 2233 | + public void ToggleBoxMode() |
---|
545 | 2234 | { |
---|
546 | 2235 | BOXMODE ^= true; |
---|
547 | 2236 | } |
---|
548 | 2237 | |
---|
549 | | - void ToggleSmoothFocus() |
---|
| 2238 | + public void ToggleZoomBoxMode() |
---|
| 2239 | + { |
---|
| 2240 | + ZOOMBOXMODE ^= true; |
---|
| 2241 | + } |
---|
| 2242 | + |
---|
| 2243 | + public void ToggleSmoothFocus() |
---|
550 | 2244 | { |
---|
551 | 2245 | SMOOTHFOCUS ^= true; |
---|
552 | 2246 | } |
---|
553 | 2247 | |
---|
554 | | - void ToggleImageFlip() |
---|
| 2248 | + public void ToggleImageFlip() |
---|
555 | 2249 | { |
---|
556 | 2250 | IMAGEFLIP ^= true; |
---|
557 | 2251 | } |
---|
558 | 2252 | |
---|
559 | | - void ToggleSpeakerMocap() |
---|
| 2253 | + public void ToggleSpeakerMocap() |
---|
560 | 2254 | { |
---|
561 | 2255 | SPEAKERMOCAP ^= true; |
---|
562 | 2256 | } |
---|
563 | 2257 | |
---|
564 | | - void ToggleSpeakerCamera() |
---|
| 2258 | + public void ToggleSpeakerCamera() |
---|
565 | 2259 | { |
---|
566 | 2260 | SPEAKERCAMERA ^= true; |
---|
567 | 2261 | } |
---|
568 | 2262 | |
---|
569 | | - void ToggleSpeakerFocus() |
---|
| 2263 | + public void ToggleSpeakerFocus() |
---|
570 | 2264 | { |
---|
571 | 2265 | SPEAKERFOCUS ^= true; |
---|
572 | 2266 | } |
---|
573 | 2267 | |
---|
574 | | - void ToggleDebug() |
---|
575 | | - { |
---|
576 | | - DEBUG ^= true; |
---|
577 | | - } |
---|
578 | | - |
---|
579 | | - void ToggleFrustum() |
---|
| 2268 | + public void ToggleFrustum() |
---|
580 | 2269 | { |
---|
581 | 2270 | FRUSTUM ^= true; |
---|
582 | 2271 | } |
---|
583 | 2272 | |
---|
584 | | - void ToggleTrack() |
---|
| 2273 | + public void ToggleTrack() |
---|
585 | 2274 | { |
---|
586 | 2275 | TRACK ^= true; |
---|
587 | 2276 | if (TRACK) |
---|
.. | .. |
---|
600 | 2289 | repaint(); |
---|
601 | 2290 | } |
---|
602 | 2291 | |
---|
603 | | - void ToggleTrackOnce() |
---|
| 2292 | + public void ToggleTrackOnce() |
---|
604 | 2293 | { |
---|
605 | 2294 | TRACKONCE ^= true; |
---|
606 | 2295 | } |
---|
607 | 2296 | |
---|
608 | | - void ToggleShadowTrack() |
---|
| 2297 | + public void ToggleShadowTrack() |
---|
609 | 2298 | { |
---|
610 | 2299 | SHADOWTRACK ^= true; |
---|
611 | 2300 | repaint(); |
---|
612 | 2301 | } |
---|
613 | 2302 | |
---|
614 | | - void ToggleOeil() |
---|
| 2303 | + public void ToggleOeil() |
---|
615 | 2304 | { |
---|
616 | 2305 | OEIL ^= true; |
---|
617 | 2306 | } |
---|
618 | 2307 | |
---|
619 | | - void ToggleOeilOnce() |
---|
| 2308 | + public void ToggleOeilOnce() |
---|
620 | 2309 | { |
---|
621 | 2310 | OEILONCE ^= true; |
---|
| 2311 | + } |
---|
| 2312 | + |
---|
| 2313 | + void ToggleFootContact() |
---|
| 2314 | + { |
---|
| 2315 | + FOOTCONTACT ^= true; |
---|
| 2316 | + } |
---|
| 2317 | + |
---|
| 2318 | + void ToggleDebug() |
---|
| 2319 | + { |
---|
| 2320 | + Globals.DEBUG ^= true; |
---|
622 | 2321 | } |
---|
623 | 2322 | |
---|
624 | 2323 | void ToggleLookAt() |
---|
.. | .. |
---|
626 | 2325 | LOOKAT ^= true; |
---|
627 | 2326 | } |
---|
628 | 2327 | |
---|
629 | | - void ToggleRandom() |
---|
| 2328 | + void ToggleSwitch() |
---|
630 | 2329 | { |
---|
631 | | - RANDOM ^= true; |
---|
| 2330 | + SWITCH ^= true; |
---|
632 | 2331 | } |
---|
633 | 2332 | |
---|
634 | 2333 | void ToggleHandles() |
---|
.. | .. |
---|
636 | 2335 | HANDLES ^= true; |
---|
637 | 2336 | } |
---|
638 | 2337 | |
---|
| 2338 | + Object3D paintFolder; |
---|
| 2339 | + |
---|
639 | 2340 | void TogglePaint() |
---|
640 | 2341 | { |
---|
641 | 2342 | PAINTMODE ^= true; |
---|
642 | 2343 | paintcount = 0; |
---|
| 2344 | + |
---|
| 2345 | + if (PAINTMODE) |
---|
| 2346 | + { |
---|
| 2347 | + paintFolder = GetFolder(); |
---|
| 2348 | + } |
---|
643 | 2349 | } |
---|
644 | 2350 | |
---|
645 | 2351 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
672 | 2378 | //assert (cam.hAspect == 0); |
---|
673 | 2379 | cam.hAspect = 0; |
---|
674 | 2380 | 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 | 2381 | } |
---|
704 | 2382 | |
---|
705 | 2383 | private static void ApplyTransform(GL gl, Mat4f xform) |
---|
.. | .. |
---|
759 | 2437 | |
---|
760 | 2438 | GL currentGL; |
---|
761 | 2439 | |
---|
762 | | - GL GetGL() |
---|
| 2440 | + public GL GetGL() // INTERFACE |
---|
763 | 2441 | { |
---|
764 | 2442 | return currentGL; |
---|
765 | 2443 | } |
---|
766 | | - |
---|
| 2444 | + |
---|
| 2445 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2446 | + { |
---|
| 2447 | + Grafreed.Assert(texturedata != null); |
---|
| 2448 | + |
---|
| 2449 | + int width = texturedata.getWidth(); |
---|
| 2450 | + int height = texturedata.getHeight(); |
---|
| 2451 | + |
---|
| 2452 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2453 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2454 | + |
---|
| 2455 | + byte[] bytes = bytebuf.array(); |
---|
| 2456 | + |
---|
| 2457 | + return CreateBim(bytes, width, height); |
---|
| 2458 | + } |
---|
| 2459 | + |
---|
767 | 2460 | /**/ |
---|
768 | 2461 | class CacheTexture |
---|
769 | 2462 | { |
---|
.. | .. |
---|
772 | 2465 | |
---|
773 | 2466 | int resolution; |
---|
774 | 2467 | |
---|
775 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2468 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
776 | 2469 | { |
---|
777 | | - texture = tex; |
---|
| 2470 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2471 | + texturedata = texdata; |
---|
778 | 2472 | resolution = res; |
---|
779 | 2473 | } |
---|
780 | 2474 | } |
---|
781 | 2475 | /**/ |
---|
782 | 2476 | |
---|
783 | 2477 | // TEXTURE static Texture texture; |
---|
784 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
785 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
786 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2478 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2479 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2480 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2481 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2482 | + |
---|
787 | 2483 | int pigmentdepth = 0; |
---|
788 | 2484 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
789 | 2485 | int bumpdepth = 0; |
---|
790 | 2486 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
791 | 2487 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
792 | 2488 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
793 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2489 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
794 | 2490 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
795 | 2491 | |
---|
796 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2492 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
797 | 2493 | { |
---|
798 | 2494 | TextureData texturedata = null; |
---|
799 | 2495 | |
---|
.. | .. |
---|
812 | 2508 | if (bump) |
---|
813 | 2509 | texturedata = ConvertBump(texturedata, false); |
---|
814 | 2510 | |
---|
815 | | - com.sun.opengl.util.texture.Texture texture = |
---|
816 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2511 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2512 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
817 | 2513 | |
---|
818 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
819 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2514 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2515 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
820 | 2516 | |
---|
821 | | - return texture; |
---|
| 2517 | + return texturedata; |
---|
| 2518 | + } |
---|
| 2519 | + |
---|
| 2520 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2521 | + { |
---|
| 2522 | + TextureData texturedata = null; |
---|
| 2523 | + |
---|
| 2524 | + try |
---|
| 2525 | + { |
---|
| 2526 | + texturedata = |
---|
| 2527 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2528 | + bim, |
---|
| 2529 | + true); |
---|
| 2530 | + } catch (Exception e) |
---|
| 2531 | + { |
---|
| 2532 | + throw new javax.media.opengl.GLException(e); |
---|
| 2533 | + } |
---|
| 2534 | + |
---|
| 2535 | + if (bump) |
---|
| 2536 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2537 | + |
---|
| 2538 | + return texturedata; |
---|
822 | 2539 | } |
---|
823 | 2540 | |
---|
824 | 2541 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
1891 | 3608 | |
---|
1892 | 3609 | System.out.println("LOADING TEXTURE : " + name); |
---|
1893 | 3610 | |
---|
| 3611 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3612 | + |
---|
1894 | 3613 | // |
---|
1895 | 3614 | if (false) // compressbit > 0) |
---|
1896 | 3615 | { |
---|
.. | .. |
---|
2000 | 3719 | */ |
---|
2001 | 3720 | TextureData ReduceTexture(TextureData texturedata, int resolution) // String name) |
---|
2002 | 3721 | { |
---|
| 3722 | + int pixelformat = texturedata.getPixelFormat(); |
---|
| 3723 | + |
---|
2003 | 3724 | int stride = 1; |
---|
2004 | | - if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE) |
---|
| 3725 | + if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE) |
---|
2005 | 3726 | stride = 3; |
---|
2006 | | - if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA) |
---|
| 3727 | + if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA) |
---|
2007 | 3728 | stride = 4; |
---|
2008 | 3729 | |
---|
2009 | 3730 | int width = texturedata.getWidth(); |
---|
.. | .. |
---|
2593 | 4314 | |
---|
2594 | 4315 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
2595 | 4316 | { |
---|
| 4317 | + new Exception().printStackTrace(); |
---|
2596 | 4318 | System.exit(0); |
---|
2597 | 4319 | com.sun.opengl.util.texture.Texture texture = null; |
---|
2598 | 4320 | |
---|
.. | .. |
---|
6269 | 7991 | return null; |
---|
6270 | 7992 | } |
---|
6271 | 7993 | |
---|
6272 | | - void ReleaseTextures(cTexture tex) |
---|
| 7994 | + public void ReleaseTextures(cTexture tex) // INTERFACE |
---|
6273 | 7995 | { |
---|
6274 | 7996 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6275 | 7997 | { |
---|
.. | .. |
---|
6286 | 8008 | String pigment = Object3D.GetPigment(tex); |
---|
6287 | 8009 | String bump = Object3D.GetBump(tex); |
---|
6288 | 8010 | |
---|
6289 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8011 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
6290 | 8012 | { |
---|
6291 | 8013 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
6292 | 8014 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
6301 | 8023 | pigment = null; |
---|
6302 | 8024 | } |
---|
6303 | 8025 | |
---|
6304 | | - ReleaseTexture(bump, true); |
---|
6305 | | - ReleaseTexture(pigment, false); |
---|
| 8026 | + ReleaseTexture(tex, true); |
---|
| 8027 | + ReleaseTexture(tex, false); |
---|
6306 | 8028 | } |
---|
6307 | 8029 | |
---|
6308 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8030 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
6309 | 8031 | { |
---|
6310 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 8032 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8033 | + { |
---|
| 8034 | + return; |
---|
| 8035 | + } |
---|
| 8036 | + |
---|
| 8037 | + if (tex == null) |
---|
| 8038 | + { |
---|
| 8039 | + ReleaseTexture(null, false); |
---|
| 8040 | + return; |
---|
| 8041 | + } |
---|
| 8042 | + |
---|
| 8043 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8044 | + |
---|
| 8045 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8046 | + { |
---|
| 8047 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8048 | + // System.out.println("; bump = " + bump); |
---|
| 8049 | + } |
---|
| 8050 | + |
---|
| 8051 | + if (pigment.equals("")) |
---|
| 8052 | + { |
---|
| 8053 | + pigment = null; |
---|
| 8054 | + } |
---|
| 8055 | + |
---|
| 8056 | + ReleaseTexture(tex, false); |
---|
| 8057 | + } |
---|
| 8058 | + |
---|
| 8059 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8060 | + { |
---|
| 8061 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8062 | + { |
---|
| 8063 | + return; |
---|
| 8064 | + } |
---|
| 8065 | + |
---|
| 8066 | + if (tex == null) |
---|
| 8067 | + { |
---|
| 8068 | + ReleaseTexture(null, true); |
---|
| 8069 | + return; |
---|
| 8070 | + } |
---|
| 8071 | + |
---|
| 8072 | + String bump = Object3D.GetBump(tex); |
---|
| 8073 | + |
---|
| 8074 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8075 | + { |
---|
| 8076 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8077 | + // System.out.println("; bump = " + bump); |
---|
| 8078 | + } |
---|
| 8079 | + |
---|
| 8080 | + if (bump.equals("")) |
---|
| 8081 | + { |
---|
| 8082 | + bump = null; |
---|
| 8083 | + } |
---|
| 8084 | + |
---|
| 8085 | + ReleaseTexture(tex, true); |
---|
| 8086 | + } |
---|
| 8087 | + |
---|
| 8088 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
| 8089 | + { |
---|
| 8090 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6311 | 8091 | ambientOcclusion ) // || !textureon) |
---|
6312 | 8092 | { |
---|
6313 | 8093 | return; |
---|
.. | .. |
---|
6316 | 8096 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
6317 | 8097 | |
---|
6318 | 8098 | if (tex != null) |
---|
6319 | | - texture = textures.get(tex); |
---|
| 8099 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
6320 | 8100 | |
---|
6321 | 8101 | // //assert( texture != null ); |
---|
6322 | 8102 | // if (texture == null) |
---|
.. | .. |
---|
6408 | 8188 | } |
---|
6409 | 8189 | } |
---|
6410 | 8190 | |
---|
6411 | | - /*boolean*/ void BindTextures(cTexture tex, int resolution) |
---|
| 8191 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
6412 | 8192 | { |
---|
6413 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 8193 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8194 | +// ambientOcclusion ) // || !textureon) |
---|
| 8195 | +// { |
---|
| 8196 | +// return; // false; |
---|
| 8197 | +// } |
---|
| 8198 | +// |
---|
| 8199 | +// if (tex == null) |
---|
| 8200 | +// { |
---|
| 8201 | +// BindTexture(null,false,resolution); |
---|
| 8202 | +// BindTexture(null,true,resolution); |
---|
| 8203 | +// return; |
---|
| 8204 | +// } |
---|
| 8205 | +// |
---|
| 8206 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8207 | +// String bump = Object3D.GetBump(tex); |
---|
| 8208 | +// |
---|
| 8209 | +// usedtextures.add(pigment); |
---|
| 8210 | +// usedtextures.add(bump); |
---|
| 8211 | +// |
---|
| 8212 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8213 | +// { |
---|
| 8214 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8215 | +// // System.out.println("; bump = " + bump); |
---|
| 8216 | +// } |
---|
| 8217 | +// |
---|
| 8218 | +// if (bump.equals("")) |
---|
| 8219 | +// { |
---|
| 8220 | +// bump = null; |
---|
| 8221 | +// } |
---|
| 8222 | +// if (pigment.equals("")) |
---|
| 8223 | +// { |
---|
| 8224 | +// pigment = null; |
---|
| 8225 | +// } |
---|
| 8226 | +// |
---|
| 8227 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8228 | +// BindTexture(pigment, false, resolution); |
---|
| 8229 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8230 | +// BindTexture(bump, true, resolution); |
---|
| 8231 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8232 | +// |
---|
| 8233 | +// return; // true; |
---|
| 8234 | + |
---|
| 8235 | + BindPigmentTexture(tex, resolution); |
---|
| 8236 | + BindBumpTexture(tex, resolution); |
---|
| 8237 | + } |
---|
| 8238 | + |
---|
| 8239 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8240 | + { |
---|
| 8241 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6414 | 8242 | ambientOcclusion ) // || !textureon) |
---|
6415 | 8243 | { |
---|
6416 | 8244 | return; // false; |
---|
.. | .. |
---|
6419 | 8247 | if (tex == null) |
---|
6420 | 8248 | { |
---|
6421 | 8249 | BindTexture(null,false,resolution); |
---|
6422 | | - BindTexture(null,true,resolution); |
---|
6423 | 8250 | return; |
---|
6424 | 8251 | } |
---|
6425 | 8252 | |
---|
6426 | 8253 | String pigment = Object3D.GetPigment(tex); |
---|
| 8254 | + |
---|
| 8255 | + usedtextures.add(tex); |
---|
| 8256 | + |
---|
| 8257 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8258 | + { |
---|
| 8259 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8260 | + // System.out.println("; bump = " + bump); |
---|
| 8261 | + } |
---|
| 8262 | + |
---|
| 8263 | + if (pigment.equals("")) |
---|
| 8264 | + { |
---|
| 8265 | + pigment = null; |
---|
| 8266 | + } |
---|
| 8267 | + |
---|
| 8268 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8269 | + BindTexture(tex, false, resolution); |
---|
| 8270 | + } |
---|
| 8271 | + |
---|
| 8272 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8273 | + { |
---|
| 8274 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8275 | + ambientOcclusion ) // || !textureon) |
---|
| 8276 | + { |
---|
| 8277 | + return; // false; |
---|
| 8278 | + } |
---|
| 8279 | + |
---|
| 8280 | + if (tex == null) |
---|
| 8281 | + { |
---|
| 8282 | + BindTexture(null,true,resolution); |
---|
| 8283 | + return; |
---|
| 8284 | + } |
---|
| 8285 | + |
---|
6427 | 8286 | String bump = Object3D.GetBump(tex); |
---|
6428 | 8287 | |
---|
6429 | | - usedtextures.put(pigment, pigment); |
---|
6430 | | - usedtextures.put(bump, bump); |
---|
| 8288 | + usedtextures.add(tex); |
---|
6431 | 8289 | |
---|
6432 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8290 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
6433 | 8291 | { |
---|
6434 | 8292 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
6435 | 8293 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
6439 | 8297 | { |
---|
6440 | 8298 | bump = null; |
---|
6441 | 8299 | } |
---|
6442 | | - if (pigment.equals("")) |
---|
6443 | | - { |
---|
6444 | | - pigment = null; |
---|
6445 | | - } |
---|
6446 | 8300 | |
---|
6447 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
6448 | | - BindTexture(pigment, false, resolution); |
---|
6449 | 8301 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
6450 | | - BindTexture(bump, true, resolution); |
---|
| 8302 | + BindTexture(tex, true, resolution); |
---|
6451 | 8303 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
6452 | | - |
---|
6453 | | - return; // true; |
---|
6454 | 8304 | } |
---|
6455 | 8305 | |
---|
6456 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8306 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8307 | + |
---|
| 8308 | + private boolean FileExists(String tex) |
---|
6457 | 8309 | { |
---|
6458 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8310 | + if (missingTextures.contains(tex)) |
---|
| 8311 | + { |
---|
| 8312 | + return false; |
---|
| 8313 | + } |
---|
| 8314 | + |
---|
| 8315 | + boolean fileExists = new File(tex).exists(); |
---|
| 8316 | + |
---|
| 8317 | + if (!fileExists) |
---|
| 8318 | + { |
---|
| 8319 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8320 | + missingTextures.add(tex); |
---|
| 8321 | + } |
---|
| 8322 | + |
---|
| 8323 | + return fileExists; |
---|
| 8324 | + } |
---|
| 8325 | + |
---|
| 8326 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
| 8327 | + { |
---|
| 8328 | + CacheTexture texturecache = null; |
---|
6459 | 8329 | |
---|
6460 | 8330 | if (tex != null) |
---|
6461 | 8331 | { |
---|
6462 | | - String texname = tex; |
---|
| 8332 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8333 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
6463 | 8334 | |
---|
6464 | | - String[] split = tex.split("Textures"); |
---|
6465 | | - if (split.length > 1) |
---|
6466 | | - texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
6467 | | - else |
---|
6468 | | - if (!texname.startsWith("/")) |
---|
6469 | | - texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8335 | + if (texname.equals("") && texdata == null) |
---|
| 8336 | + { |
---|
| 8337 | + return null; |
---|
| 8338 | + } |
---|
| 8339 | + |
---|
| 8340 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8341 | + |
---|
| 8342 | +// String[] split = tex.split("Textures"); |
---|
| 8343 | +// if (split.length > 1) |
---|
| 8344 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8345 | +// else |
---|
| 8346 | +// if (!texname.startsWith("/")) |
---|
| 8347 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8348 | + if (!FileExists(texname)) |
---|
| 8349 | + { |
---|
| 8350 | + texname = fallbackTextureName; |
---|
| 8351 | + } |
---|
6470 | 8352 | |
---|
6471 | 8353 | if (CACHETEXTURE) |
---|
6472 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
6473 | | - |
---|
6474 | | - TextureData texturedata = null; |
---|
6475 | | - |
---|
6476 | | - if (texture == null || texture.resolution < resolution) |
---|
6477 | 8354 | { |
---|
6478 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8355 | + if (texdata == null) |
---|
| 8356 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8357 | + else |
---|
| 8358 | + texturecache = bimtextures.get(texdata); |
---|
| 8359 | + } |
---|
| 8360 | + |
---|
| 8361 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8362 | + { |
---|
| 8363 | + TextureData texturedata = null; |
---|
| 8364 | + |
---|
| 8365 | + if (texdata != null && textureon) |
---|
| 8366 | + { |
---|
| 8367 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8368 | + |
---|
| 8369 | + try |
---|
| 8370 | + { |
---|
| 8371 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8372 | + } |
---|
| 8373 | + catch (Exception e) |
---|
| 8374 | + { |
---|
| 8375 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8376 | + } |
---|
| 8377 | + |
---|
| 8378 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8379 | + bimtextures.put(texdata, texturecache); |
---|
| 8380 | + |
---|
| 8381 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8382 | + |
---|
| 8383 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8384 | + //bim2 = bim; |
---|
| 8385 | + } |
---|
| 8386 | + else |
---|
| 8387 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
6479 | 8388 | { |
---|
6480 | 8389 | assert(!bump); |
---|
6481 | 8390 | // if (bump) |
---|
.. | .. |
---|
6486 | 8395 | // } |
---|
6487 | 8396 | // else |
---|
6488 | 8397 | // { |
---|
6489 | | - texture = textures.get(tex); |
---|
6490 | | - if (texture == null) |
---|
| 8398 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8399 | + if (texturecache == null) |
---|
6491 | 8400 | { |
---|
6492 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8401 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
6493 | 8402 | } |
---|
| 8403 | + else |
---|
| 8404 | + new Exception().printStackTrace(); |
---|
6494 | 8405 | // } |
---|
6495 | 8406 | } else |
---|
6496 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8407 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
6497 | 8408 | { |
---|
6498 | 8409 | assert(bump); |
---|
6499 | | - texture = textures.get(tex); |
---|
6500 | | - if (texture == null) |
---|
6501 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8410 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8411 | + if (texturecache == null) |
---|
| 8412 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8413 | + else |
---|
| 8414 | + new Exception().printStackTrace(); |
---|
6502 | 8415 | } else |
---|
6503 | 8416 | { |
---|
6504 | 8417 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
6506 | 8419 | // texture = GetResourceTexture("default.png"); |
---|
6507 | 8420 | //} else |
---|
6508 | 8421 | //{ |
---|
6509 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8422 | + if (texname.endsWith("WHITE_NOISE")) |
---|
6510 | 8423 | { |
---|
6511 | | - texture = textures.get(tex); |
---|
6512 | | - if (texture == null) |
---|
6513 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8424 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8425 | + if (texturecache == null) |
---|
| 8426 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8427 | + else |
---|
| 8428 | + new Exception().printStackTrace(); |
---|
6514 | 8429 | } else |
---|
6515 | 8430 | { |
---|
6516 | 8431 | if (textureon) |
---|
.. | .. |
---|
6535 | 8450 | } |
---|
6536 | 8451 | |
---|
6537 | 8452 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
6538 | | - if (!new File(cachename).exists()) |
---|
| 8453 | + if (!FileExists(cachename)) |
---|
6539 | 8454 | cachename = texname; |
---|
6540 | 8455 | else |
---|
6541 | 8456 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
6557 | 8472 | } |
---|
6558 | 8473 | |
---|
6559 | 8474 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
6560 | | - if (!new File(cachename).exists()) |
---|
| 8475 | + if (!FileExists(cachename)) |
---|
6561 | 8476 | cachename = texname; |
---|
6562 | 8477 | else |
---|
6563 | 8478 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
6566 | 8481 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
6567 | 8482 | |
---|
6568 | 8483 | |
---|
6569 | | - if (texturedata != null) |
---|
6570 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8484 | + if (texturedata == null) |
---|
| 8485 | + throw new Exception(); |
---|
| 8486 | + |
---|
| 8487 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
6571 | 8488 | //texture = GetTexture(tex, bump); |
---|
6572 | 8489 | } |
---|
6573 | 8490 | } |
---|
6574 | 8491 | //} |
---|
6575 | 8492 | } |
---|
6576 | 8493 | |
---|
6577 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8494 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
6578 | 8495 | { |
---|
6579 | 8496 | //return false; |
---|
6580 | 8497 | |
---|
6581 | 8498 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
6582 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8499 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
6583 | 8500 | { |
---|
6584 | 8501 | // String ext = "_highres"; |
---|
6585 | 8502 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
6596 | 8513 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
6597 | 8514 | if (!cachefile.exists()) |
---|
6598 | 8515 | { |
---|
6599 | | - // cache to disk |
---|
6600 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
6601 | | - //buffers[0]. |
---|
6602 | | - |
---|
6603 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
6604 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
6605 | | - |
---|
6606 | | - // squared size heuristic... |
---|
6607 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8516 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
6608 | 8517 | { |
---|
6609 | | - for (int i=pixels.length; --i>=0;) |
---|
6610 | | - { |
---|
6611 | | - int i3 = i*3; |
---|
6612 | | - pixels[i] = 0xFF; |
---|
6613 | | - pixels[i] <<= 8; |
---|
6614 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
6615 | | - pixels[i] <<= 8; |
---|
6616 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
6617 | | - pixels[i] <<= 8; |
---|
6618 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
6619 | | - } |
---|
6620 | | - |
---|
6621 | | - /* |
---|
6622 | | - int r=0,g=0,b=0,a=0; |
---|
6623 | | - for (int i=0; i<width; i++) |
---|
6624 | | - for (int j=0; j<height; j++) |
---|
6625 | | - { |
---|
6626 | | - int index = j*width+i; |
---|
6627 | | - int p = pixels[index]; |
---|
6628 | | - a = ((p>>24) & 0xFF); |
---|
6629 | | - r = ((p>>16) & 0xFF); |
---|
6630 | | - g = ((p>>8) & 0xFF); |
---|
6631 | | - b = (p & 0xFF); |
---|
6632 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
6633 | | - } |
---|
6634 | | - /**/ |
---|
6635 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
6636 | | - int height = width; |
---|
6637 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
6638 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8518 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8519 | + |
---|
6639 | 8520 | ImageWriter writer = null; |
---|
6640 | 8521 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
6641 | 8522 | if (iter.hasNext()) { |
---|
6642 | 8523 | writer = (ImageWriter)iter.next(); |
---|
6643 | 8524 | } |
---|
6644 | | - float compressionQuality = 0.9f; |
---|
| 8525 | + |
---|
| 8526 | + float compressionQuality = 0.85f; |
---|
6645 | 8527 | try |
---|
6646 | 8528 | { |
---|
6647 | 8529 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
6658 | 8540 | } |
---|
6659 | 8541 | } |
---|
6660 | 8542 | } |
---|
6661 | | - |
---|
| 8543 | + |
---|
| 8544 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8545 | + |
---|
6662 | 8546 | //System.out.println("Texture = " + tex); |
---|
6663 | | - if (textures.containsKey(texname)) |
---|
| 8547 | + if (textures.containsKey(tex)) |
---|
6664 | 8548 | { |
---|
6665 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8549 | + CacheTexture thetex = textures.get(tex); |
---|
6666 | 8550 | thetex.texture.disable(); |
---|
6667 | 8551 | thetex.texture.dispose(); |
---|
6668 | | - textures.remove(texname); |
---|
| 8552 | + textures.remove(tex); |
---|
6669 | 8553 | } |
---|
6670 | 8554 | |
---|
6671 | | - texture.texturedata = texturedata; |
---|
6672 | | - textures.put(texname, texture); |
---|
| 8555 | + //texture.texturedata = texturedata; |
---|
| 8556 | + textures.put(tex, texturecache); |
---|
6673 | 8557 | |
---|
6674 | 8558 | // newtex = true; |
---|
6675 | 8559 | } |
---|
.. | .. |
---|
6685 | 8569 | } |
---|
6686 | 8570 | } |
---|
6687 | 8571 | |
---|
6688 | | - return texture; |
---|
| 8572 | + return texturecache; |
---|
6689 | 8573 | } |
---|
6690 | 8574 | |
---|
6691 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8575 | + static void EmbedTextures(cTexture tex) |
---|
| 8576 | + { |
---|
| 8577 | + if (tex.pigmentdata == null) |
---|
| 8578 | + { |
---|
| 8579 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8580 | + |
---|
| 8581 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8582 | + |
---|
| 8583 | + if (texturecache != null) |
---|
| 8584 | + { |
---|
| 8585 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8586 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8587 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8588 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8589 | + ; |
---|
| 8590 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8591 | + } |
---|
| 8592 | + } |
---|
| 8593 | + |
---|
| 8594 | + if (tex.bumpdata == null) |
---|
| 8595 | + { |
---|
| 8596 | + //String texname = Object3D.GetBump(tex); |
---|
| 8597 | + |
---|
| 8598 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8599 | + |
---|
| 8600 | + if (texturecache != null) |
---|
| 8601 | + { |
---|
| 8602 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8603 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8604 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8605 | + } |
---|
| 8606 | + } |
---|
| 8607 | + } |
---|
| 8608 | + |
---|
| 8609 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
6692 | 8610 | { |
---|
6693 | 8611 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
6694 | 8612 | |
---|
.. | .. |
---|
6706 | 8624 | return texture!=null?texture.texture:null; |
---|
6707 | 8625 | } |
---|
6708 | 8626 | |
---|
6709 | | - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8627 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
6710 | 8628 | { |
---|
6711 | 8629 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
6712 | 8630 | |
---|
6713 | 8631 | return texture!=null?texture.texturedata:null; |
---|
6714 | 8632 | } |
---|
6715 | 8633 | |
---|
6716 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8634 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
6717 | 8635 | { |
---|
6718 | 8636 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6719 | 8637 | { |
---|
6720 | 8638 | return false; |
---|
6721 | 8639 | } |
---|
6722 | 8640 | |
---|
6723 | | - boolean newtex = false; |
---|
| 8641 | + //boolean newtex = false; |
---|
6724 | 8642 | |
---|
6725 | 8643 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
6726 | 8644 | |
---|
.. | .. |
---|
6752 | 8670 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
6753 | 8671 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
6754 | 8672 | |
---|
6755 | | - return newtex; |
---|
| 8673 | + return true; // Warning: not used. |
---|
6756 | 8674 | } |
---|
6757 | 8675 | |
---|
| 8676 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8677 | + { |
---|
| 8678 | + try |
---|
| 8679 | + { |
---|
| 8680 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8681 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8682 | + ImageWriter writer = writers.next(); |
---|
| 8683 | + |
---|
| 8684 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8685 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8686 | + param.setCompressionQuality(quality); |
---|
| 8687 | + |
---|
| 8688 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8689 | + writer.setOutput(ios); |
---|
| 8690 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8691 | + |
---|
| 8692 | + byte[] data = baos.toByteArray(); |
---|
| 8693 | + writer.dispose(); |
---|
| 8694 | + return data; |
---|
| 8695 | + } |
---|
| 8696 | + catch (Exception e) |
---|
| 8697 | + { |
---|
| 8698 | + e.printStackTrace(); |
---|
| 8699 | + return null; |
---|
| 8700 | + } |
---|
| 8701 | + } |
---|
| 8702 | + |
---|
| 8703 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8704 | + { |
---|
| 8705 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8706 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8707 | + ImageReader reader = writers.next(); |
---|
| 8708 | + |
---|
| 8709 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8710 | + |
---|
| 8711 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8712 | + param.setDestination(bim); |
---|
| 8713 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8714 | + |
---|
| 8715 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8716 | + reader.setInput(ios); |
---|
| 8717 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8718 | + reader.dispose(); |
---|
| 8719 | + |
---|
| 8720 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8721 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8722 | +// byte[] bytes = data.getData(); |
---|
| 8723 | +// |
---|
| 8724 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8725 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8726 | +// { |
---|
| 8727 | +// int i3 = i*3; |
---|
| 8728 | +// pixels[i] = 0xFF; |
---|
| 8729 | +// pixels[i] <<= 8; |
---|
| 8730 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8731 | +// pixels[i] <<= 8; |
---|
| 8732 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8733 | +// pixels[i] <<= 8; |
---|
| 8734 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8735 | +// } |
---|
| 8736 | +// |
---|
| 8737 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8738 | + |
---|
| 8739 | + return bim; |
---|
| 8740 | + } |
---|
| 8741 | + |
---|
6758 | 8742 | ShadowBuffer shadowPBuf; |
---|
6759 | 8743 | AntialiasBuffer antialiasPBuf; |
---|
6760 | 8744 | int MAXSTACK; |
---|
.. | .. |
---|
7310 | 9294 | static boolean occlusionInitialized = false; |
---|
7311 | 9295 | boolean selection = false; |
---|
7312 | 9296 | boolean pointselection = false; |
---|
7313 | | - /*static*/ boolean lighttouched = true; |
---|
| 9297 | + ///*static*/ boolean lighttouched = true; |
---|
7314 | 9298 | boolean deselect; |
---|
7315 | | - boolean ambientOcclusion = false; |
---|
| 9299 | + private boolean ambientOcclusion = false; |
---|
7316 | 9300 | static boolean flash = false; |
---|
7317 | 9301 | /*static*/ boolean wait = false; |
---|
7318 | 9302 | boolean displaydone = false; // after repaint() calls |
---|
.. | .. |
---|
7442 | 9426 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
7443 | 9427 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
7444 | 9428 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 9429 | +// PATCH FILLE AUX JEANS |
---|
| 9430 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
7445 | 9431 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
7446 | 9432 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
7447 | 9433 | |
---|
.. | .. |
---|
7588 | 9574 | jy8[3] = 0.5f; |
---|
7589 | 9575 | } |
---|
7590 | 9576 | |
---|
7591 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9577 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
7592 | 9578 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
7593 | | - float[] options3 = new float[]{1, 1, 1, 1}; // fog color. image intensity |
---|
| 9579 | + float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
| 9580 | + float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
7594 | 9581 | |
---|
| 9582 | + void ResetOptions() |
---|
| 9583 | + { |
---|
| 9584 | + options1[0] = 100; |
---|
| 9585 | + options1[1] = 0.025f; |
---|
| 9586 | + options1[2] = 0.01f; |
---|
| 9587 | + options1[3] = 0; |
---|
| 9588 | + options1[4] = 0; |
---|
| 9589 | + |
---|
| 9590 | + options2[0] = 0; |
---|
| 9591 | + options2[1] = 0.75f; |
---|
| 9592 | + options2[2] = 0; |
---|
| 9593 | + options2[3] = 0; |
---|
| 9594 | + |
---|
| 9595 | + options3[0] = 1; |
---|
| 9596 | + options3[1] = 1; |
---|
| 9597 | + options3[2] = 1; |
---|
| 9598 | + options3[3] = 0; |
---|
| 9599 | + |
---|
| 9600 | + options4[0] = 1; |
---|
| 9601 | + options4[1] = 0; |
---|
| 9602 | + options4[2] = 1; |
---|
| 9603 | + options4[3] = 0; |
---|
| 9604 | + } |
---|
| 9605 | + |
---|
7595 | 9606 | static int imagecount = 0; // movie generation |
---|
7596 | 9607 | |
---|
7597 | 9608 | static int jitter = 0; |
---|
7598 | 9609 | |
---|
7599 | 9610 | boolean restartframe = false; |
---|
7600 | | - |
---|
7601 | | - static int framecount = 0; // general-purpose global count |
---|
7602 | 9611 | |
---|
7603 | 9612 | void displayAntiAliased(javax.media.opengl.GL gl) |
---|
7604 | 9613 | { |
---|
.. | .. |
---|
7630 | 9639 | gl.glClear(gl.GL_ACCUM_BUFFER_BIT); |
---|
7631 | 9640 | for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0) |
---|
7632 | 9641 | { |
---|
7633 | | - framecount++; |
---|
| 9642 | + Globals.framecount++; |
---|
7634 | 9643 | |
---|
7635 | 9644 | if (CameraPane.tickcount > 0) |
---|
7636 | 9645 | CameraPane.tickcount--; |
---|
.. | .. |
---|
7668 | 9677 | |
---|
7669 | 9678 | gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0); |
---|
7670 | 9679 | */ |
---|
7671 | | - lighttouched = true; |
---|
| 9680 | + Globals.lighttouched = true; |
---|
7672 | 9681 | //System.err.println(" shadowbuffer: " + jitter); |
---|
7673 | 9682 | shadowbuffer.display(); |
---|
7674 | 9683 | |
---|
.. | .. |
---|
7689 | 9698 | assert (parentcam != renderCamera); |
---|
7690 | 9699 | |
---|
7691 | 9700 | if (renderCamera != lightCamera) |
---|
7692 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7693 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 9701 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9702 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
7694 | 9703 | |
---|
7695 | 9704 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
7696 | 9705 | |
---|
.. | .. |
---|
7705 | 9714 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
7706 | 9715 | |
---|
7707 | 9716 | if (renderCamera != lightCamera) |
---|
7708 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7709 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 9717 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9718 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
7710 | 9719 | |
---|
7711 | 9720 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
7712 | 9721 | |
---|
.. | .. |
---|
7778 | 9787 | //gl.glFlush(); |
---|
7779 | 9788 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
7780 | 9789 | |
---|
7781 | | - if (ANIMATION && ABORTED) |
---|
| 9790 | + if (Globals.ANIMATION && ABORTED) |
---|
7782 | 9791 | { |
---|
7783 | 9792 | System.err.println(" ABORTED FRAME"); |
---|
7784 | 9793 | break; |
---|
.. | .. |
---|
7808 | 9817 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
7809 | 9818 | |
---|
7810 | 9819 | // save image |
---|
7811 | | - if (ANIMATION && !ABORTED) |
---|
| 9820 | + if (Globals.ANIMATION && !ABORTED) |
---|
7812 | 9821 | { |
---|
7813 | 9822 | VPwidth = viewport[2]; |
---|
7814 | 9823 | VPheight = viewport[3]; |
---|
.. | .. |
---|
7919 | 9928 | |
---|
7920 | 9929 | // imagecount++; |
---|
7921 | 9930 | |
---|
7922 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9931 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
7923 | 9932 | |
---|
7924 | 9933 | if (!BOXMODE) |
---|
7925 | 9934 | { |
---|
7926 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9935 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
7927 | 9936 | } |
---|
7928 | 9937 | |
---|
7929 | 9938 | if (!BOXMODE) |
---|
.. | .. |
---|
7961 | 9970 | ABORTED = false; |
---|
7962 | 9971 | } |
---|
7963 | 9972 | else |
---|
7964 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 9973 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
7965 | 9974 | |
---|
7966 | 9975 | if (false) |
---|
7967 | 9976 | { |
---|
.. | .. |
---|
8615 | 10624 | } |
---|
8616 | 10625 | } |
---|
8617 | 10626 | |
---|
8618 | | - boolean IsFrozen() |
---|
8619 | | - { |
---|
8620 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
8621 | | - |
---|
8622 | | - return !selectmode && cameracount == 0; // != 0; |
---|
8623 | | - } |
---|
8624 | | - |
---|
8625 | 10627 | boolean niceon = false; |
---|
8626 | 10628 | javax.swing.Timer AAtimer = new javax.swing.Timer(750, this); |
---|
8627 | 10629 | boolean currentlydrawing = false; |
---|
.. | .. |
---|
8631 | 10633 | |
---|
8632 | 10634 | public void display(GLAutoDrawable drawable) |
---|
8633 | 10635 | { |
---|
8634 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10636 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
8635 | 10637 | { |
---|
8636 | | - GrafreeD.wav.save(); |
---|
8637 | | - GrafreeD.savesound = false; |
---|
8638 | | - GrafreeD.hassound = false; |
---|
| 10638 | + Grafreed.wav.save(); |
---|
| 10639 | + Grafreed.savesound = false; |
---|
| 10640 | + Grafreed.hassound = false; |
---|
8639 | 10641 | } |
---|
8640 | 10642 | // if (DEBUG_SELECTION) |
---|
8641 | 10643 | // { |
---|
8642 | | -// if (drawMode != SELECTION) |
---|
8643 | | -// drawMode = SELECTION; |
---|
| 10644 | +// if (DrawMode() != SELECTION) |
---|
| 10645 | +// DrawMode() = SELECTION; |
---|
8644 | 10646 | // } |
---|
8645 | 10647 | |
---|
8646 | 10648 | if (!isRenderer) |
---|
.. | .. |
---|
8696 | 10698 | |
---|
8697 | 10699 | //ANTIALIAS = 0; |
---|
8698 | 10700 | |
---|
8699 | | - if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
| 10701 | + if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
8700 | 10702 | { |
---|
8701 | | - if (niceon || isLIVE()) |
---|
| 10703 | + if (niceon || Globals.isLIVE()) |
---|
8702 | 10704 | { |
---|
8703 | 10705 | //if(active == 0) |
---|
8704 | 10706 | // antialiaser = null; |
---|
.. | .. |
---|
8711 | 10713 | ANTIALIAS = 0; |
---|
8712 | 10714 | //System.out.println("RESTART"); |
---|
8713 | 10715 | AAtimer.restart(); |
---|
| 10716 | + Globals.TIMERRUNNING = true; |
---|
8714 | 10717 | } |
---|
8715 | 10718 | } |
---|
8716 | 10719 | } |
---|
.. | .. |
---|
8723 | 10726 | assert eyeCamera.shaper_zFar == 1E5f; // 500.0f; |
---|
8724 | 10727 | */ |
---|
8725 | 10728 | |
---|
8726 | | - if (drawMode == DEFAULT) |
---|
| 10729 | + if (DrawMode() == DEFAULT) |
---|
8727 | 10730 | { |
---|
8728 | 10731 | currentlydrawing = true; |
---|
8729 | 10732 | } |
---|
.. | .. |
---|
8754 | 10757 | |
---|
8755 | 10758 | // if(Applet3D.clipboard != null) |
---|
8756 | 10759 | // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent); |
---|
8757 | | -//drawMode = SELECTION; |
---|
| 10760 | +//DrawMode() = SELECTION; |
---|
8758 | 10761 | indexcount = 0; |
---|
8759 | 10762 | |
---|
8760 | | - if (drawMode == OCCLUSION) |
---|
| 10763 | + if (DrawMode() == OCCLUSION) |
---|
8761 | 10764 | { |
---|
8762 | | - drawMode = DEFAULT; |
---|
| 10765 | + Globals.drawMode = DEFAULT; // WARNING |
---|
8763 | 10766 | ambientOcclusion = true; |
---|
8764 | 10767 | setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
---|
8765 | 10768 | Object3D theobject = object; |
---|
8766 | 10769 | Object3D theparent = object.parent; |
---|
8767 | 10770 | object.parent = null; |
---|
8768 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10771 | + object = (Object3D)Grafreed.clone(object); |
---|
8769 | 10772 | object.Stripify(); |
---|
8770 | 10773 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
8771 | 10774 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
8778 | 10781 | ambientOcclusion = false; |
---|
8779 | 10782 | } |
---|
8780 | 10783 | |
---|
8781 | | - if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10784 | + if (//Globals.lighttouched && |
---|
| 10785 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
8782 | 10786 | { |
---|
8783 | 10787 | //if (RENDERSHADOW) // ? |
---|
8784 | 10788 | if (!IsFrozen()) |
---|
8785 | 10789 | { |
---|
8786 | 10790 | // dec 2012 |
---|
8787 | | - if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)) |
---|
| 10791 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
8788 | 10792 | { |
---|
8789 | | - framecount++; |
---|
| 10793 | + Globals.framecount++; |
---|
8790 | 10794 | shadowbuffer.display(); |
---|
8791 | 10795 | } |
---|
8792 | 10796 | } |
---|
8793 | | - lighttouched = false; // ?? |
---|
| 10797 | + Globals.lighttouched = false; // ?? |
---|
8794 | 10798 | //drawing = true; |
---|
8795 | 10799 | //lighttouched = true; |
---|
8796 | 10800 | } |
---|
.. | .. |
---|
8811 | 10815 | //eyeCamera.shaper_fovy = 1; |
---|
8812 | 10816 | } |
---|
8813 | 10817 | |
---|
8814 | | - if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION) |
---|
| 10818 | + if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION) |
---|
8815 | 10819 | { |
---|
8816 | | - //System.out.println("drawMode = " + drawMode); |
---|
| 10820 | + //System.out.println("DrawMode() = " + DrawMode()); |
---|
8817 | 10821 | vertexMode |= VP_PASS; |
---|
8818 | 10822 | //vertexMode |= VP_PROJECTION; |
---|
8819 | 10823 | if (!ambientOcclusion) |
---|
.. | .. |
---|
8873 | 10877 | Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera; |
---|
8874 | 10878 | //Camera lightcam = new Camera(light0); |
---|
8875 | 10879 | |
---|
8876 | | - if (drawMode == SHADOW) |
---|
| 10880 | + if (DrawMode() == SHADOW) |
---|
8877 | 10881 | { |
---|
8878 | 10882 | /* |
---|
8879 | 10883 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
.. | .. |
---|
8911 | 10915 | |
---|
8912 | 10916 | // if (parentcam != renderCamera) // not a light |
---|
8913 | 10917 | if (cam != lightCamera) |
---|
8914 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8915 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 10918 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10919 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
8916 | 10920 | |
---|
8917 | 10921 | for (int j = 0; j < 4; j++) |
---|
8918 | 10922 | { |
---|
.. | .. |
---|
8926 | 10930 | |
---|
8927 | 10931 | // if (parentcam != renderCamera) // not a light |
---|
8928 | 10932 | if (cam != lightCamera) |
---|
8929 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8930 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 10933 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10934 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
8931 | 10935 | |
---|
8932 | 10936 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
8933 | 10937 | |
---|
.. | .. |
---|
8963 | 10967 | gl.glClear(gl.GL_DEPTH_BUFFER_BIT); |
---|
8964 | 10968 | } else |
---|
8965 | 10969 | { |
---|
8966 | | - if (drawMode != DEFAULT) |
---|
| 10970 | + if (DrawMode() != DEFAULT) |
---|
8967 | 10971 | { |
---|
8968 | 10972 | gl.glClearColor(1, 1, 1, 0); |
---|
8969 | 10973 | } // 1); |
---|
.. | .. |
---|
9028 | 11032 | |
---|
9029 | 11033 | fast &= !ambientOcclusion; |
---|
9030 | 11034 | |
---|
9031 | | - if (drawMode == DEFAULT) |
---|
| 11035 | + if (DrawMode() == DEFAULT) |
---|
9032 | 11036 | { |
---|
9033 | 11037 | //gl.glEnable(gl.GL_ALPHA_TEST); |
---|
9034 | 11038 | //gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
.. | .. |
---|
9089 | 11093 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
9090 | 11094 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9091 | 11095 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 11096 | +// PATCH FILLE AUX JEANS |
---|
| 11097 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9092 | 11098 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9093 | 11099 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9094 | 11100 | |
---|
.. | .. |
---|
9184 | 11190 | // Bump noise |
---|
9185 | 11191 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
9186 | 11192 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
9187 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11193 | + |
---|
| 11194 | + try |
---|
| 11195 | + { |
---|
| 11196 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11197 | + } |
---|
| 11198 | + catch (Exception e) |
---|
| 11199 | + { |
---|
| 11200 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11201 | + } |
---|
| 11202 | + |
---|
9188 | 11203 | |
---|
9189 | 11204 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
9190 | 11205 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9207 | 11222 | |
---|
9208 | 11223 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
9209 | 11224 | |
---|
9210 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
9211 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
9212 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11225 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11226 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11227 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
9213 | 11228 | } else |
---|
9214 | 11229 | { |
---|
9215 | 11230 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9220 | 11235 | //System.out.println("BLENDING ON"); |
---|
9221 | 11236 | gl.glEnable(GL.GL_BLEND); |
---|
9222 | 11237 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
9223 | | - |
---|
| 11238 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
9224 | 11239 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
9225 | 11240 | gl.glLoadIdentity(); |
---|
9226 | 11241 | |
---|
9227 | | - if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
| 11242 | + if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
9228 | 11243 | { |
---|
9229 | 11244 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9230 | 11245 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 11246 | +// PATCH FILLE AUX JEANS |
---|
| 11247 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9231 | 11248 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9232 | 11249 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9233 | 11250 | //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE); |
---|
.. | .. |
---|
9280 | 11297 | //gl.glPushMatrix(); |
---|
9281 | 11298 | gl.glLoadIdentity(); |
---|
9282 | 11299 | |
---|
9283 | | - if (!ambientOcclusion) // drawMode != OCCLUSION) |
---|
| 11300 | + if (!ambientOcclusion) // DrawMode() != OCCLUSION) |
---|
9284 | 11301 | { |
---|
9285 | 11302 | //LA.xformPos(light0, lightCamera.fromScreen, light); |
---|
9286 | 11303 | LA.xformDir(dirlight, lightCamera.fromScreen, lightposition); |
---|
.. | .. |
---|
9307 | 11324 | System.err.println("parentcam != renderCamera"); |
---|
9308 | 11325 | |
---|
9309 | 11326 | // if (cam != lightCamera) |
---|
9310 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9311 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11327 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11328 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
9312 | 11329 | } |
---|
9313 | 11330 | |
---|
9314 | 11331 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
9329 | 11346 | if (true) // TODO |
---|
9330 | 11347 | { |
---|
9331 | 11348 | if (cam != lightCamera) |
---|
9332 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9333 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11349 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11350 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
9334 | 11351 | } |
---|
9335 | 11352 | |
---|
9336 | 11353 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
9367 | 11384 | } |
---|
9368 | 11385 | |
---|
9369 | 11386 | /**/ |
---|
9370 | | - if (true) // drawMode == SELECTION) // != DEFAULT) |
---|
| 11387 | + if (true) // DrawMode() == SELECTION) // != DEFAULT) |
---|
9371 | 11388 | gl.glDisable(gl.GL_LIGHTING); |
---|
9372 | 11389 | else |
---|
9373 | 11390 | gl.glEnable(gl.GL_LIGHTING); |
---|
.. | .. |
---|
9379 | 11396 | |
---|
9380 | 11397 | gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0); |
---|
9381 | 11398 | gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0); |
---|
| 11399 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0); |
---|
9382 | 11400 | |
---|
9383 | 11401 | options2[0] *= renderCamera.Distance(); |
---|
9384 | 11402 | |
---|
9385 | 11403 | lightslot = 64; |
---|
9386 | 11404 | |
---|
9387 | | - if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT) |
---|
| 11405 | + if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT) |
---|
9388 | 11406 | { |
---|
9389 | 11407 | DrawLights(object); |
---|
9390 | 11408 | } |
---|
.. | .. |
---|
9395 | 11413 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
9396 | 11414 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
9397 | 11415 | |
---|
9398 | | - if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION) |
---|
| 11416 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
9399 | 11417 | { |
---|
9400 | 11418 | /* |
---|
9401 | 11419 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
9428 | 11446 | } |
---|
9429 | 11447 | } |
---|
9430 | 11448 | |
---|
9431 | | - if (drawMode == DEFAULT) |
---|
| 11449 | + if (DrawMode() == DEFAULT) |
---|
9432 | 11450 | { |
---|
9433 | 11451 | if (WIREFRAME && !ambientOcclusion) |
---|
9434 | 11452 | { |
---|
.. | .. |
---|
9446 | 11464 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9447 | 11465 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9448 | 11466 | |
---|
9449 | | - if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) // |
---|
| 11467 | + if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) // |
---|
9450 | 11468 | { |
---|
9451 | 11469 | if (vertexMode != 0) // && !fast) |
---|
9452 | 11470 | { |
---|
.. | .. |
---|
9466 | 11484 | } |
---|
9467 | 11485 | } |
---|
9468 | 11486 | |
---|
9469 | | - if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion) |
---|
| 11487 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
9470 | 11488 | { |
---|
9471 | 11489 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
9472 | 11490 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
9474 | 11492 | |
---|
9475 | 11493 | boolean texon = textureon; |
---|
9476 | 11494 | |
---|
9477 | | - if (RENDERPROGRAM > 0) |
---|
9478 | | - { |
---|
9479 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9480 | | - textureon = false; |
---|
9481 | | - } |
---|
| 11495 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11496 | + textureon = false; |
---|
| 11497 | + |
---|
9482 | 11498 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9483 | 11499 | //System.out.println("ALLO"); |
---|
9484 | 11500 | gl.glColorMask(false, false, false, false); |
---|
9485 | 11501 | DrawObject(gl); |
---|
9486 | | - if (RENDERPROGRAM > 0) |
---|
9487 | | - { |
---|
9488 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9489 | | - textureon = texon; |
---|
9490 | | - } |
---|
| 11502 | + |
---|
| 11503 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11504 | + textureon = texon; |
---|
| 11505 | + |
---|
9491 | 11506 | gl.glColorMask(true, true, true, true); |
---|
9492 | 11507 | |
---|
9493 | 11508 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
9494 | | - //gl.glDepthMask(false); |
---|
| 11509 | + gl.glDepthMask(false); |
---|
9495 | 11510 | } |
---|
9496 | 11511 | |
---|
9497 | | - if (false) // drawMode == SHADOW) |
---|
| 11512 | + if (false) // DrawMode() == SHADOW) |
---|
9498 | 11513 | { |
---|
9499 | 11514 | //SetColumnMajorData(cameraInverseTransform, view_1); |
---|
9500 | 11515 | //System.out.println("light = " + cameraInverseTransform); |
---|
.. | .. |
---|
9508 | 11523 | //System.out.println("object = " + object); |
---|
9509 | 11524 | if (!frozen && !imageLocked) |
---|
9510 | 11525 | { |
---|
9511 | | - if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0) |
---|
| 11526 | + if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0) |
---|
9512 | 11527 | { |
---|
9513 | 11528 | displayAntiAliased(gl); |
---|
9514 | 11529 | } else |
---|
9515 | 11530 | { |
---|
9516 | 11531 | programcount = 0; |
---|
9517 | | - int keepmode = drawMode; |
---|
| 11532 | + int keepmode = DrawMode(); |
---|
9518 | 11533 | // if (DEBUG_SELECTION) |
---|
9519 | 11534 | // { |
---|
9520 | | -// drawMode = SELECTION; |
---|
| 11535 | +// DrawMode() = SELECTION; |
---|
9521 | 11536 | // } |
---|
9522 | 11537 | // for point selection |
---|
9523 | 11538 | // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0); |
---|
.. | .. |
---|
9527 | 11542 | DrawObject(gl); |
---|
9528 | 11543 | |
---|
9529 | 11544 | // jan 2013 System.err.println("RESET ABORT (display)"); |
---|
9530 | | - // if (drawMode == DEFAULT) |
---|
| 11545 | + // if (DrawMode() == DEFAULT) |
---|
9531 | 11546 | // ABORTED = false; |
---|
9532 | 11547 | fullreset = false; |
---|
9533 | | - drawMode = keepmode; |
---|
| 11548 | + Globals.drawMode = keepmode; // WARNING |
---|
9534 | 11549 | //System.out.println("PROGRAM SWITCH " + programcount); |
---|
9535 | 11550 | } |
---|
9536 | 11551 | } |
---|
.. | .. |
---|
9538 | 11553 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9539 | 11554 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9540 | 11555 | |
---|
9541 | | - if (drawMode == DEFAULT) |
---|
| 11556 | + if (DrawMode() == DEFAULT) |
---|
9542 | 11557 | { |
---|
9543 | 11558 | ReleaseTexture(NOISE_TEXTURE, false); |
---|
9544 | 11559 | } |
---|
9545 | | - //if (drawMode == DEFAULT) |
---|
| 11560 | + //if (DrawMode() == DEFAULT) |
---|
9546 | 11561 | { |
---|
9547 | 11562 | |
---|
9548 | 11563 | gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
.. | .. |
---|
9554 | 11569 | //else |
---|
9555 | 11570 | //gl.glDisable(gl.GL_TEXTURE_2D); |
---|
9556 | 11571 | //gl.glPopMatrix(); |
---|
9557 | | - if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
| 11572 | + if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
9558 | 11573 | { |
---|
9559 | 11574 | //new Exception().printStackTrace(); |
---|
9560 | 11575 | //System.out.println("Draw image " + width + ", " + height); |
---|
.. | .. |
---|
9596 | 11611 | //gl.glFlush(); |
---|
9597 | 11612 | } |
---|
9598 | 11613 | |
---|
9599 | | - if (flash && drawMode == DEFAULT) |
---|
| 11614 | + if (flash && DrawMode() == DEFAULT) |
---|
9600 | 11615 | { |
---|
9601 | 11616 | flash = false; |
---|
9602 | 11617 | wait = true; |
---|
.. | .. |
---|
9604 | 11619 | } |
---|
9605 | 11620 | |
---|
9606 | 11621 | //drawing = false; |
---|
9607 | | - //if(drawMode == DEFAULT) |
---|
| 11622 | + //if(DrawMode() == DEFAULT) |
---|
9608 | 11623 | // niceon = false; |
---|
9609 | | - if (drawMode == DEFAULT) |
---|
| 11624 | + if (DrawMode() == DEFAULT) |
---|
9610 | 11625 | { |
---|
9611 | 11626 | currentlydrawing = false; |
---|
9612 | 11627 | } |
---|
.. | .. |
---|
9626 | 11641 | repaint(); |
---|
9627 | 11642 | } |
---|
9628 | 11643 | |
---|
9629 | | - if (isLIVE() && drawMode == DEFAULT) // may 2013 |
---|
| 11644 | + if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 |
---|
9630 | 11645 | repaint(); |
---|
9631 | 11646 | |
---|
9632 | 11647 | displaydone = true; |
---|
.. | .. |
---|
9645 | 11660 | { |
---|
9646 | 11661 | renderpass++; |
---|
9647 | 11662 | // System.out.println("Draw object... "); |
---|
| 11663 | + STEP = 1; |
---|
9648 | 11664 | if (FAST) // in case there is no script |
---|
9649 | | - STEP = 16; |
---|
| 11665 | + STEP = 8; |
---|
| 11666 | + |
---|
| 11667 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11668 | + { |
---|
| 11669 | + STEP *= 4; |
---|
| 11670 | + } |
---|
9650 | 11671 | |
---|
9651 | 11672 | //object.FullInvariants(); |
---|
9652 | 11673 | |
---|
.. | .. |
---|
9660 | 11681 | e.printStackTrace(); |
---|
9661 | 11682 | } |
---|
9662 | 11683 | |
---|
9663 | | - if (GrafreeD.RENDERME > 0) |
---|
9664 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11684 | + if (Grafreed.RENDERME > 0) |
---|
| 11685 | + Grafreed.RENDERME--; // mechante magouille |
---|
9665 | 11686 | |
---|
9666 | | - ONESTEP = false; |
---|
| 11687 | + Globals.ONESTEP = false; |
---|
9667 | 11688 | } |
---|
9668 | 11689 | |
---|
9669 | 11690 | static boolean zoomonce = false; |
---|
9670 | 11691 | |
---|
| 11692 | + static void CreateSelectedPoint() |
---|
| 11693 | + { |
---|
| 11694 | + if (selectedpoint == null) |
---|
| 11695 | + { |
---|
| 11696 | + debugpointG = new Sphere(); |
---|
| 11697 | + debugpointP = new Sphere(); |
---|
| 11698 | + debugpointC = new Sphere(); |
---|
| 11699 | + debugpointR = new Sphere(); |
---|
| 11700 | + |
---|
| 11701 | + selectedpoint = new Superellipsoid(); |
---|
| 11702 | + |
---|
| 11703 | + for (int i=0; i<8; i++) |
---|
| 11704 | + { |
---|
| 11705 | + debugpoints[i] = new Sphere(); |
---|
| 11706 | + } |
---|
| 11707 | + } |
---|
| 11708 | + } |
---|
| 11709 | + |
---|
9671 | 11710 | void DrawObject(GL gl, boolean draw) |
---|
9672 | 11711 | { |
---|
| 11712 | + // To clear camera values |
---|
| 11713 | + ResetOptions(); |
---|
| 11714 | + |
---|
9673 | 11715 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
9674 | | -// drawMode = SELECTION; |
---|
| 11716 | +// DrawMode() = SELECTION; |
---|
9675 | 11717 | //GL gl = getGL(); |
---|
9676 | 11718 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
9677 | 11719 | { |
---|
9678 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
9679 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11720 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
| 11721 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
9680 | 11722 | pingthread.StepToTarget(true); // true); |
---|
9681 | 11723 | // zoomonce = false; |
---|
9682 | 11724 | } |
---|
.. | .. |
---|
9696 | 11738 | callist = gl.glGenLists(1); |
---|
9697 | 11739 | } |
---|
9698 | 11740 | |
---|
9699 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11741 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
9700 | 11742 | |
---|
9701 | | - boolean active = !selectmode; // drawMode != SELECTION; // mouseDown; |
---|
| 11743 | + boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
9702 | 11744 | |
---|
9703 | 11745 | if (!mainDL || !active || touched) |
---|
9704 | 11746 | { |
---|
.. | .. |
---|
9725 | 11767 | PushMatrix(ClickInfo.matbuffer); |
---|
9726 | 11768 | } |
---|
9727 | 11769 | |
---|
9728 | | - if (drawMode == 0) |
---|
| 11770 | + if (DrawMode() == 0) |
---|
9729 | 11771 | { |
---|
9730 | 11772 | // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++"); |
---|
9731 | 11773 | |
---|
9732 | 11774 | usedtextures.clear(); |
---|
9733 | 11775 | |
---|
9734 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11776 | + try |
---|
| 11777 | + { |
---|
| 11778 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11779 | + } |
---|
| 11780 | + catch (Exception e) |
---|
| 11781 | + { |
---|
| 11782 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11783 | + } |
---|
9735 | 11784 | } |
---|
9736 | 11785 | //System.out.println("--> " + stackdepth); |
---|
9737 | 11786 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
9739 | 11788 | // DRAW |
---|
9740 | 11789 | object.draw(this, /*(Composite)*/ object, false, false); |
---|
9741 | 11790 | |
---|
9742 | | - if (drawMode == DEFAULT) |
---|
| 11791 | + if (DrawMode() == DEFAULT) |
---|
9743 | 11792 | { |
---|
9744 | | - if (DEBUG) |
---|
| 11793 | + if (Globals.DEBUG) |
---|
9745 | 11794 | { |
---|
| 11795 | + CreateSelectedPoint(); |
---|
9746 | 11796 | float radius = 0.05f; |
---|
9747 | 11797 | if (selectedpoint.radius != radius) |
---|
9748 | 11798 | { |
---|
.. | .. |
---|
9750 | 11800 | selectedpoint.radius = radius; |
---|
9751 | 11801 | selectedpoint.recalculate(); |
---|
9752 | 11802 | selectedpoint.material = new cMaterial(); |
---|
9753 | | - selectedpoint.material.color = 0.25f; |
---|
| 11803 | + selectedpoint.material.color = 0.15f; // Yellow |
---|
9754 | 11804 | selectedpoint.material.modulation = 0.75f; |
---|
9755 | 11805 | |
---|
9756 | | - debugpoint.radius = radius; |
---|
9757 | | - debugpoint.recalculate(); |
---|
9758 | | - debugpoint.material = new cMaterial(); |
---|
9759 | | - debugpoint.material.color = 0.25f; |
---|
9760 | | - debugpoint.material.modulation = 0.75f; |
---|
| 11806 | + debugpointG.radius = radius; |
---|
| 11807 | + debugpointG.recalculate(); |
---|
| 11808 | + debugpointG.material = new cMaterial(); |
---|
| 11809 | + debugpointG.material.color = 0.25f; // Green |
---|
| 11810 | + debugpointG.material.modulation = 0.75f; |
---|
9761 | 11811 | |
---|
9762 | | - debugpoint2.radius = radius; |
---|
9763 | | - debugpoint2.recalculate(); |
---|
9764 | | - debugpoint2.material = new cMaterial(); |
---|
9765 | | - debugpoint2.material.color = 0.75f; |
---|
9766 | | - debugpoint2.material.modulation = 0.75f; |
---|
| 11812 | + debugpointP.radius = radius; |
---|
| 11813 | + debugpointP.recalculate(); |
---|
| 11814 | + debugpointP.material = new cMaterial(); |
---|
| 11815 | + debugpointP.material.color = 0.75f; // Purple |
---|
| 11816 | + debugpointP.material.modulation = 0.75f; |
---|
9767 | 11817 | |
---|
9768 | | - debugpoint3.radius = radius; |
---|
9769 | | - debugpoint3.recalculate(); |
---|
9770 | | - debugpoint3.material = new cMaterial(); |
---|
9771 | | - debugpoint3.material.color = 0.5f; |
---|
9772 | | - debugpoint3.material.modulation = 0.75f; |
---|
| 11818 | + debugpointC.radius = radius; |
---|
| 11819 | + debugpointC.recalculate(); |
---|
| 11820 | + debugpointC.material = new cMaterial(); |
---|
| 11821 | + debugpointC.material.color = 0.5f; // Cyan |
---|
| 11822 | + debugpointC.material.modulation = 0.75f; |
---|
9773 | 11823 | |
---|
9774 | | - debugpoint4.radius = radius; |
---|
9775 | | - debugpoint4.recalculate(); |
---|
9776 | | - debugpoint4.material = new cMaterial(); |
---|
9777 | | - debugpoint4.material.color = 0f; |
---|
9778 | | - debugpoint4.material.modulation = 0.75f; |
---|
| 11824 | + debugpointR.radius = radius; |
---|
| 11825 | + debugpointR.recalculate(); |
---|
| 11826 | + debugpointR.material = new cMaterial(); |
---|
| 11827 | + debugpointR.material.color = 0f; // Red |
---|
| 11828 | + debugpointR.material.modulation = 0.75f; |
---|
9779 | 11829 | |
---|
9780 | 11830 | InitPoints(radius); |
---|
9781 | 11831 | } |
---|
9782 | 11832 | selectedpoint.draw(this, /*(Composite)*/ null, false, false); |
---|
9783 | | - debugpoint.draw(this, /*(Composite)*/ null, false,false); |
---|
9784 | | - debugpoint2.draw(this, /*(Composite)*/ null, false,false); |
---|
9785 | | - debugpoint3.draw(this, /*(Composite)*/ null, false,false); |
---|
9786 | | - debugpoint4.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11833 | + debugpointG.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11834 | + debugpointP.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11835 | + debugpointC.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11836 | + debugpointR.draw(this, /*(Composite)*/ null, false,false); |
---|
9787 | 11837 | // DrawPoints(this); |
---|
9788 | 11838 | } |
---|
9789 | 11839 | |
---|
.. | .. |
---|
9791 | 11841 | } |
---|
9792 | 11842 | // GrafreeD.traceoff(); |
---|
9793 | 11843 | //System.out.println(stackdepth); |
---|
9794 | | - if (drawMode == 0) |
---|
| 11844 | + if (DrawMode() == 0) |
---|
9795 | 11845 | { |
---|
9796 | 11846 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
9797 | 11847 | |
---|
9798 | 11848 | if (CLEANCACHE) |
---|
9799 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11849 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
9800 | 11850 | { |
---|
9801 | | - String tex = e.nextElement(); |
---|
| 11851 | + cTexture tex = e.nextElement(); |
---|
9802 | 11852 | |
---|
9803 | 11853 | // System.out.println("Texture --------- " + tex); |
---|
9804 | 11854 | |
---|
9805 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11855 | + if (tex.equals("WHITE_NOISE:")) |
---|
9806 | 11856 | continue; |
---|
9807 | 11857 | |
---|
9808 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11858 | + if (!usedtextures.contains(tex)) |
---|
9809 | 11859 | { |
---|
| 11860 | + CacheTexture gettex = texturepigment.get(tex); |
---|
9810 | 11861 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
9811 | | - textures.get(tex).texture.dispose(); |
---|
9812 | | - textures.remove(tex); |
---|
| 11862 | + if (gettex != null) |
---|
| 11863 | + { |
---|
| 11864 | + gettex.texture.dispose(); |
---|
| 11865 | + texturepigment.remove(tex); |
---|
| 11866 | + } |
---|
| 11867 | + |
---|
| 11868 | + gettex = texturebump.get(tex); |
---|
| 11869 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11870 | + if (gettex != null) |
---|
| 11871 | + { |
---|
| 11872 | + gettex.texture.dispose(); |
---|
| 11873 | + texturebump.remove(tex); |
---|
| 11874 | + } |
---|
9813 | 11875 | } |
---|
9814 | 11876 | } |
---|
9815 | 11877 | } |
---|
9816 | 11878 | |
---|
9817 | 11879 | checker = null; |
---|
9818 | 11880 | |
---|
9819 | | - if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT) |
---|
| 11881 | + if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT) |
---|
9820 | 11882 | FindChecker(object); |
---|
9821 | 11883 | |
---|
9822 | | - if (checker != null && drawMode == DEFAULT) |
---|
| 11884 | + if (checker != null && DrawMode() == DEFAULT) |
---|
9823 | 11885 | { |
---|
9824 | | - // BindTexture(IMMORTAL_TEXTURE); |
---|
| 11886 | + //BindTexture(IMMORTAL_TEXTURE); |
---|
| 11887 | + try |
---|
| 11888 | + { |
---|
| 11889 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11890 | + } |
---|
| 11891 | + catch (Exception e) |
---|
| 11892 | + { |
---|
| 11893 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11894 | + } |
---|
9825 | 11895 | // NEAREST |
---|
9826 | 11896 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
9827 | 11897 | DrawChecker(gl); |
---|
9828 | 11898 | //checker.Draw(this, null, false); |
---|
9829 | 11899 | // ReleaseTexture(IMMORTAL_TEXTURE); |
---|
| 11900 | + ReleaseTextures(checker.GetTextures()); |
---|
9830 | 11901 | } |
---|
9831 | 11902 | |
---|
9832 | 11903 | if (object.parent != null) |
---|
.. | .. |
---|
9839 | 11910 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9840 | 11911 | //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9841 | 11912 | |
---|
9842 | | - if (DISPLAYTEXT && drawMode == DEFAULT) |
---|
| 11913 | + if (DISPLAYTEXT && DrawMode() == DEFAULT) |
---|
9843 | 11914 | { |
---|
9844 | 11915 | // Draw it once, then use the raster |
---|
9845 | 11916 | Balloon(gl, balloon.createGraphics()); |
---|
.. | .. |
---|
9895 | 11966 | int[] xs = new int[3]; |
---|
9896 | 11967 | int[] ys = new int[3]; |
---|
9897 | 11968 | |
---|
9898 | | - void DrawString(Object3D obj) // String string) |
---|
| 11969 | + public void DrawString(Object3D obj) // String string) // INTERFACE |
---|
9899 | 11970 | { |
---|
9900 | | - if (!DISPLAYTEXT || drawMode != DEFAULT) |
---|
| 11971 | + if (!DISPLAYTEXT || DrawMode() != DEFAULT) |
---|
9901 | 11972 | { |
---|
9902 | 11973 | return; |
---|
9903 | 11974 | } |
---|
9904 | 11975 | |
---|
9905 | | - String string = obj.GetToolTip(); |
---|
| 11976 | + String string = obj.toString(); //.GetToolTip(); |
---|
9906 | 11977 | |
---|
9907 | 11978 | GL gl = GetGL(); |
---|
9908 | 11979 | |
---|
.. | .. |
---|
10219 | 12290 | //obj.TransformToWorld(light, light); |
---|
10220 | 12291 | for (int i = tp.size(); --i >= 0;) |
---|
10221 | 12292 | { |
---|
10222 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
10223 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12293 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12294 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
10224 | 12295 | } |
---|
10225 | 12296 | |
---|
10226 | 12297 | |
---|
.. | .. |
---|
10237 | 12308 | parentcam = cameras[0]; |
---|
10238 | 12309 | } |
---|
10239 | 12310 | |
---|
10240 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10241 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12311 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12312 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
10242 | 12313 | |
---|
10243 | 12314 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
10244 | 12315 | |
---|
.. | .. |
---|
10329 | 12400 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
10330 | 12401 | |
---|
10331 | 12402 | String program = |
---|
| 12403 | + // Min shader |
---|
10332 | 12404 | "!!ARBfp1.0\n" + |
---|
| 12405 | + "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" + |
---|
| 12406 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12407 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12408 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12409 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12410 | + "TEMP temp;" + |
---|
| 12411 | + "TEMP light;" + |
---|
| 12412 | + "TEMP ndotl;" + |
---|
| 12413 | + "TEMP normal;" + |
---|
| 12414 | + "TEMP depth;" + |
---|
| 12415 | + |
---|
| 12416 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12417 | + |
---|
| 12418 | + "MOV light, state.light[0].position;" + |
---|
| 12419 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12420 | + |
---|
| 12421 | + // shadow |
---|
| 12422 | + "MOV temp, fragment.texcoord[1];" + |
---|
| 12423 | + TextureFetch("depth", "temp", "1") + |
---|
| 12424 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12425 | + "SLT temp.x, fragment.texcoord[1].z, depth.z;" + |
---|
| 12426 | + |
---|
| 12427 | + |
---|
| 12428 | + // No shadow when out of frustum |
---|
| 12429 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12430 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12431 | + |
---|
| 12432 | + "MUL ndotl.x, ndotl.x, temp.x;" + |
---|
| 12433 | + "MAX ndotl.x, ndotl.x, pow2.y;" + |
---|
| 12434 | + |
---|
| 12435 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12436 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12437 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12438 | + |
---|
| 12439 | + "MUL temp, temp, zero123.z;" + |
---|
| 12440 | + |
---|
| 12441 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12442 | + |
---|
| 12443 | + "MOV result.color, temp;" + |
---|
| 12444 | + "END"; |
---|
| 12445 | + |
---|
| 12446 | + String program2 = |
---|
| 12447 | + "!!ARBfp1.0\n" + |
---|
| 12448 | + |
---|
10333 | 12449 | //"OPTION ARB_fragment_program_shadow;" + |
---|
10334 | 12450 | "PARAM light2cam0 = program.env[10];" + |
---|
10335 | 12451 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
10357 | 12473 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
10358 | 12474 | "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
10359 | 12475 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
10360 | | - "PARAM options1 = program.env[62];" + // fog rgb color, image intensity |
---|
| 12476 | + "PARAM options1 = program.env[62];" + // fog rgb color |
---|
| 12477 | + "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
10361 | 12478 | "PARAM pointlight = program.env[127];" + // ... |
---|
10362 | 12479 | "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" + |
---|
10363 | 12480 | "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" + |
---|
10364 | 12481 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
| 12482 | + "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" + |
---|
10365 | 12483 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
10366 | 12484 | "PARAM ten = { 10, 10, 10, 1.0 };" + |
---|
10367 | 12485 | "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" + |
---|
.. | .. |
---|
10382 | 12500 | "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" + |
---|
10383 | 12501 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
10384 | 12502 | "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" + |
---|
| 12503 | + "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" + |
---|
10385 | 12504 | "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" + |
---|
10386 | 12505 | "PARAM c256 = { 256, 256, 256, 1.0 };" + |
---|
10387 | 12506 | "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" + |
---|
.. | .. |
---|
10422 | 12541 | "TEMP R1;" + |
---|
10423 | 12542 | "TEMP R2;" + |
---|
10424 | 12543 | "TEMP R3;" + |
---|
| 12544 | + "TEMP min;" + |
---|
| 12545 | + "TEMP max;" + |
---|
| 12546 | + "TEMP average;" + |
---|
| 12547 | + "TEMP saturation;" + |
---|
10425 | 12548 | "TEMP keep1;" + |
---|
10426 | 12549 | "TEMP keep2;" + |
---|
10427 | 12550 | "TEMP keep3;" + |
---|
.. | .. |
---|
10437 | 12560 | "TEMP shininess;" + |
---|
10438 | 12561 | "\n" + |
---|
10439 | 12562 | "MOV texSamp, one;" + |
---|
10440 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
10441 | | - |
---|
| 12563 | + |
---|
10442 | 12564 | "MOV mapgrid.x, one2048th.x;" + |
---|
10443 | 12565 | "MOV temp, fragment.texcoord[1];" + |
---|
10444 | 12566 | /* |
---|
.. | .. |
---|
10843 | 12965 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
10844 | 12966 | "") + |
---|
10845 | 12967 | |
---|
10846 | | - // display shadow only (bump == 0) |
---|
| 12968 | + // display shadow only (fakedepth == 0) |
---|
10847 | 12969 | "SUB temp.x, half.x, shadow.x;" + |
---|
10848 | | - "MOV temp.y, -params6.x;" + |
---|
10849 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12970 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12971 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
10850 | 12972 | "SUB temp.y, one.x, temp.z;" + |
---|
10851 | 12973 | "MUL temp.x, temp.x, temp.y;" + |
---|
10852 | 12974 | "KIL temp.x;" + |
---|
.. | .. |
---|
10952 | 13074 | |
---|
10953 | 13075 | // skin? |
---|
10954 | 13076 | // Saturation for skin |
---|
10955 | | - /**/ // c'est ici |
---|
10956 | | - (Skinshader? "DP3 temp.x, final,one;" + |
---|
| 13077 | + /**/ |
---|
| 13078 | + (Skinshader? |
---|
| 13079 | + "DP3 average.x, final,one;" + |
---|
| 13080 | + "MUL average, one3rd.xxxx,average.xxxx;" + |
---|
| 13081 | + |
---|
| 13082 | + "MIN min.x, final.x,final.y;" + |
---|
| 13083 | + "MIN min.x, min.x,final.z;" + |
---|
| 13084 | + |
---|
| 13085 | + "MAX max.x, final.x,final.y;" + |
---|
| 13086 | + "MAX max.x, max.x,final.z;" + |
---|
| 13087 | + "MOV max, max.xxxx;" + |
---|
| 13088 | + |
---|
| 13089 | + "SUB saturation, max, final;" + |
---|
| 13090 | + |
---|
| 13091 | + "ADD temp.x, max.x, one10th.x;" + |
---|
| 13092 | + "RCP temp.x, temp.x;" + |
---|
| 13093 | + "MUL temp.x, temp.x, half.x;" + |
---|
| 13094 | + "MUL saturation, saturation, temp.xxxx;" + |
---|
| 13095 | + |
---|
| 13096 | + "DP3 ndotl.x, normald, light;" + |
---|
| 13097 | + "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
| 13098 | + |
---|
| 13099 | + "SUB temp.x, one.x, ndotl.x;" + |
---|
| 13100 | + // Tuning for default skin |
---|
| 13101 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 13102 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 13103 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
| 13104 | + "MUL temp.x, temp.x, temp.y;" + |
---|
| 13105 | + |
---|
| 13106 | + "MUL saturation, saturation, temp.xxxx;" + |
---|
| 13107 | + "SUB_SAT temp, max, saturation;" + |
---|
| 13108 | +/** |
---|
| 13109 | + "DP3 temp.x, final,one;" + |
---|
10957 | 13110 | "MUL R2, one3rd.xxxx,temp.xxxx;" + |
---|
10958 | | - "SUB temp, final,R2;" + |
---|
| 13111 | + "SUB temp, final, R2;" + |
---|
| 13112 | + |
---|
10959 | 13113 | // using light angle |
---|
10960 | 13114 | "DP3 ndotl.x, normald,light;" + |
---|
10961 | 13115 | //"SLT ndotl.y, ndotl.x, zero.x;" + |
---|
.. | .. |
---|
10968 | 13122 | // using light intensity |
---|
10969 | 13123 | "MOV ndotl.z, R2.x;" + |
---|
10970 | 13124 | "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning... |
---|
10971 | | - |
---|
10972 | 13125 | // june 2014 |
---|
10973 | 13126 | "MAD R1.x, ndotl.z,slope.y,one.x;" + |
---|
10974 | 13127 | // "SUB ndotl.x, one.x, ndotl.x;" + |
---|
.. | .. |
---|
10980 | 13133 | //"MUL R2.y, shadow.x,R2.y;" + // avril 2014 |
---|
10981 | 13134 | |
---|
10982 | 13135 | "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin) |
---|
| 13136 | +/**/ |
---|
10983 | 13137 | |
---|
10984 | 13138 | // "ADD final, R2,temp;" + |
---|
10985 | 13139 | "MOV final, temp;" |
---|
.. | .. |
---|
11069 | 13223 | /**/ |
---|
11070 | 13224 | // HDR |
---|
11071 | 13225 | "MOV temp.z, final.a;" + |
---|
11072 | | - "MUL final, final,options1.w;" + |
---|
| 13226 | + "MUL final, final,options2.x;" + |
---|
11073 | 13227 | "MOV final.a, temp.z;" + |
---|
11074 | 13228 | /**/ |
---|
11075 | 13229 | |
---|
.. | .. |
---|
11145 | 13299 | //once = true; |
---|
11146 | 13300 | } |
---|
11147 | 13301 | |
---|
11148 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 13302 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
11149 | 13303 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
11150 | 13304 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
11151 | 13305 | |
---|
.. | .. |
---|
11243 | 13397 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
11244 | 13398 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
11245 | 13399 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13400 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13401 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
11246 | 13402 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
11247 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
11248 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
11249 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
11250 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13403 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13404 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
11251 | 13405 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
11252 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13406 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
11253 | 13407 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
11254 | 13408 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
11255 | 13409 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
11256 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13410 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
11257 | 13411 | |
---|
11258 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
11259 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13412 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13413 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
11260 | 13414 | } |
---|
11261 | 13415 | |
---|
11262 | 13416 | String Shadow(String depth, String shadow) |
---|
11263 | 13417 | { |
---|
11264 | 13418 | return "MAX temp.x, ndotl.x, one64th.x;" + |
---|
| 13419 | + "MIN temp.x, temp.x, ninetenth.x;" + |
---|
11265 | 13420 | /**/ |
---|
11266 | 13421 | // Sine |
---|
11267 | 13422 | "MUL temp.y, temp.x, temp.x;" + |
---|
.. | .. |
---|
11277 | 13432 | |
---|
11278 | 13433 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
11279 | 13434 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13435 | + |
---|
| 13436 | + // Compare fragment depth in light space with shadowmap. |
---|
11280 | 13437 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
11281 | 13438 | "SGE temp.y, temp.x, zero.x;" + |
---|
11282 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13439 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13440 | + |
---|
| 13441 | + // Reverse comparison |
---|
11283 | 13442 | "SUB temp.x, one.x, temp.x;" + |
---|
11284 | 13443 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
11285 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13444 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
11286 | 13445 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
11287 | 13446 | |
---|
11288 | 13447 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
11296 | 13455 | // No shadow for backface |
---|
11297 | 13456 | "DP3 temp.x, normal, lightd;" + |
---|
11298 | 13457 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13458 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13459 | + |
---|
| 13460 | + // No shadow when out of frustum |
---|
| 13461 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
11299 | 13462 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
11300 | 13463 | ""; |
---|
11301 | 13464 | } |
---|
.. | .. |
---|
11442 | 13605 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
11443 | 13606 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
11444 | 13607 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
11445 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13608 | + |
---|
| 13609 | + //Object3D.cVector2[] vector2buffer; |
---|
11446 | 13610 | |
---|
11447 | 13611 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
11448 | 13612 | // OUT : diff, spec |
---|
.. | .. |
---|
11458 | 13622 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
11459 | 13623 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
11460 | 13624 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
11461 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
11462 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
11463 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13625 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13626 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13627 | + |
---|
| 13628 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
11464 | 13629 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
11465 | 13630 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
11466 | 13631 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
11854 | 14019 | public void mousePressed(MouseEvent e) |
---|
11855 | 14020 | { |
---|
11856 | 14021 | //System.out.println("mousePressed: " + e); |
---|
11857 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14022 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
11858 | 14023 | } |
---|
11859 | 14024 | |
---|
11860 | 14025 | static long prevtime = 0; |
---|
.. | .. |
---|
11881 | 14046 | |
---|
11882 | 14047 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
11883 | 14048 | |
---|
| 14049 | + if (BUTTONLESSWHEEL) |
---|
11884 | 14050 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
11885 | 14051 | { |
---|
11886 | 14052 | return; |
---|
11887 | 14053 | } |
---|
11888 | 14054 | |
---|
| 14055 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
11889 | 14056 | |
---|
11890 | 14057 | // TIMER |
---|
11891 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR |
---|
| 14058 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
11892 | 14059 | { |
---|
11893 | 14060 | keepboxmode = BOXMODE; |
---|
11894 | 14061 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
11928 | 14095 | // mode |= META; |
---|
11929 | 14096 | //} |
---|
11930 | 14097 | |
---|
11931 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
11932 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 14098 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 14099 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
11933 | 14100 | anchorX = ax; |
---|
11934 | 14101 | anchorY = ay; |
---|
11935 | 14102 | prevX = px; |
---|
.. | .. |
---|
11963 | 14130 | else |
---|
11964 | 14131 | if (evt.getSource() == AAtimer) |
---|
11965 | 14132 | { |
---|
| 14133 | + Globals.TIMERRUNNING = false; |
---|
11966 | 14134 | if (mouseDown) |
---|
11967 | 14135 | { |
---|
11968 | 14136 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
11988 | 14156 | // LIVE = waslive; |
---|
11989 | 14157 | // wasliveok = true; |
---|
11990 | 14158 | // waslive = false; |
---|
| 14159 | + |
---|
| 14160 | + // May 2019 Forget it: |
---|
| 14161 | + if (true) |
---|
| 14162 | + return; |
---|
11991 | 14163 | |
---|
11992 | 14164 | // source == timer |
---|
11993 | 14165 | if (mouseDown) |
---|
.. | .. |
---|
12017 | 14189 | // ObjEditor.tweenManager.update(1f / 60f); |
---|
12018 | 14190 | |
---|
12019 | 14191 | // fev 2014??? |
---|
12020 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode) |
---|
12021 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14192 | + if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
| 14193 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
12022 | 14194 | pingthread.StepToTarget(true); // true); |
---|
12023 | 14195 | } |
---|
12024 | 14196 | // if (!LIVE) |
---|
.. | .. |
---|
12027 | 14199 | |
---|
12028 | 14200 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
12029 | 14201 | |
---|
12030 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14202 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
12031 | 14203 | { |
---|
12032 | 14204 | if (!wasliveok) |
---|
12033 | 14205 | return; |
---|
12034 | 14206 | |
---|
12035 | 14207 | AAtimer.restart(); // |
---|
| 14208 | + Globals.TIMERRUNNING = true; |
---|
12036 | 14209 | |
---|
12037 | 14210 | // waslive = LIVE; |
---|
12038 | 14211 | // LIVE = false; |
---|
.. | .. |
---|
12044 | 14217 | // touched = true; // main DL |
---|
12045 | 14218 | if (isRenderer) |
---|
12046 | 14219 | { |
---|
12047 | | - SetMouseMode(modifiers); |
---|
| 14220 | + SetMouseMode(modifiers, modifiersex); |
---|
12048 | 14221 | } |
---|
12049 | 14222 | |
---|
12050 | 14223 | selectX = anchorX = x; |
---|
.. | .. |
---|
12057 | 14230 | clicked = true; |
---|
12058 | 14231 | hold = false; |
---|
12059 | 14232 | |
---|
12060 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14233 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
12061 | 14234 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
12062 | 14235 | { |
---|
12063 | 14236 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
12082 | 14255 | drag = false; |
---|
12083 | 14256 | //System.out.println("Mouse DOWN"); |
---|
12084 | 14257 | editObj = false; |
---|
12085 | | - ClickInfo info = new ClickInfo(); |
---|
12086 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
12087 | | - info.pane = this; |
---|
12088 | | - info.camera = renderCamera; |
---|
12089 | | - info.x = x; |
---|
12090 | | - info.y = y; |
---|
12091 | | - info.modifiers = modifiers; |
---|
12092 | | - editObj = object.doEditClick(info, 0); |
---|
| 14258 | + //ClickInfo info = new ClickInfo(); |
---|
| 14259 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14260 | + object.clickInfo.pane = this; |
---|
| 14261 | + object.clickInfo.camera = renderCamera; |
---|
| 14262 | + object.clickInfo.x = x; |
---|
| 14263 | + object.clickInfo.y = y; |
---|
| 14264 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14265 | + editObj = object.doEditClick(//info, |
---|
| 14266 | + 0); |
---|
12093 | 14267 | if (!editObj) |
---|
12094 | 14268 | { |
---|
12095 | 14269 | hasMarquee = true; |
---|
.. | .. |
---|
12105 | 14279 | |
---|
12106 | 14280 | public void mouseDragged(MouseEvent e) |
---|
12107 | 14281 | { |
---|
| 14282 | + Globals.MOUSEDRAGGED = true; |
---|
| 14283 | + |
---|
| 14284 | + //System.out.println("mouseDragged: " + e); |
---|
12108 | 14285 | if (isRenderer) |
---|
12109 | 14286 | movingcamera = true; |
---|
| 14287 | + |
---|
12110 | 14288 | //if (drawing) |
---|
12111 | 14289 | //return; |
---|
12112 | | - //System.out.println("mouseDragged: " + e); |
---|
12113 | 14290 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
12114 | 14291 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
12115 | 14292 | { |
---|
.. | .. |
---|
12117 | 14294 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12118 | 14295 | } |
---|
12119 | 14296 | else |
---|
12120 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14297 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12121 | 14298 | |
---|
12122 | 14299 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
12123 | 14300 | } |
---|
.. | .. |
---|
12129 | 14306 | cVector tmp = new cVector(); |
---|
12130 | 14307 | cVector tmp2 = new cVector(); |
---|
12131 | 14308 | boolean isMoving; |
---|
| 14309 | + |
---|
| 14310 | + public cVector TargetLookAt() |
---|
| 14311 | + { |
---|
| 14312 | + return targetLookAt; |
---|
| 14313 | + } |
---|
12132 | 14314 | |
---|
12133 | 14315 | class PingThread extends Thread |
---|
12134 | 14316 | { |
---|
.. | .. |
---|
12268 | 14450 | //System.out.println("---------------- ---------- Paint " + tmp.length2()); |
---|
12269 | 14451 | if (lightMode) |
---|
12270 | 14452 | { |
---|
12271 | | - lighttouched = true; |
---|
| 14453 | + Globals.lighttouched = true; |
---|
12272 | 14454 | } |
---|
12273 | 14455 | |
---|
12274 | 14456 | if (OEILONCE && OEIL) |
---|
.. | .. |
---|
12285 | 14467 | |
---|
12286 | 14468 | public void run() |
---|
12287 | 14469 | { |
---|
| 14470 | + new Exception().printStackTrace(); |
---|
12288 | 14471 | System.exit(0); |
---|
12289 | 14472 | for (;;) |
---|
12290 | 14473 | { |
---|
.. | .. |
---|
12326 | 14509 | mouseDown = false; |
---|
12327 | 14510 | if (lightMode) |
---|
12328 | 14511 | { |
---|
12329 | | - lighttouched = true; |
---|
| 14512 | + Globals.lighttouched = true; |
---|
12330 | 14513 | } |
---|
12331 | 14514 | repaint(); |
---|
12332 | 14515 | alreadypainted = true; |
---|
.. | .. |
---|
12334 | 14517 | isMoving = false; |
---|
12335 | 14518 | } //?? |
---|
12336 | 14519 | |
---|
12337 | | - if (isLIVE() && !alreadypainted) |
---|
| 14520 | + if (Globals.isLIVE() && !alreadypainted) |
---|
12338 | 14521 | { |
---|
12339 | 14522 | // FOR DEBUG BREAKPOINT USING PAUSE: while (true) |
---|
12340 | 14523 | repaint(); |
---|
.. | .. |
---|
12346 | 14529 | { |
---|
12347 | 14530 | if (lightMode) |
---|
12348 | 14531 | { |
---|
12349 | | - lighttouched = true; |
---|
| 14532 | + Globals.lighttouched = true; |
---|
12350 | 14533 | } |
---|
12351 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14534 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
12352 | 14535 | } |
---|
12353 | 14536 | //else |
---|
12354 | 14537 | } |
---|
.. | .. |
---|
12362 | 14545 | void GoDown(int mod) |
---|
12363 | 14546 | { |
---|
12364 | 14547 | MODIFIERS |= COMMAND; |
---|
12365 | | - /* |
---|
| 14548 | + /**/ |
---|
12366 | 14549 | if((mod&SHIFT) == SHIFT) |
---|
12367 | 14550 | manipCamera.RotatePosition(0, -speed); |
---|
12368 | 14551 | else |
---|
12369 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
12370 | | - */ |
---|
| 14552 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14553 | + /**/ |
---|
12371 | 14554 | if ((mod & SHIFT) == SHIFT) |
---|
12372 | 14555 | { |
---|
12373 | 14556 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
12383 | 14566 | void GoUp(int mod) |
---|
12384 | 14567 | { |
---|
12385 | 14568 | MODIFIERS |= COMMAND; |
---|
12386 | | - /* |
---|
| 14569 | + /**/ |
---|
12387 | 14570 | if((mod&SHIFT) == SHIFT) |
---|
12388 | 14571 | manipCamera.RotatePosition(0, speed); |
---|
12389 | 14572 | else |
---|
12390 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
12391 | | - */ |
---|
| 14573 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14574 | + /**/ |
---|
12392 | 14575 | if ((mod & SHIFT) == SHIFT) |
---|
12393 | 14576 | { |
---|
12394 | 14577 | mouseMode = mouseMode; |
---|
.. | .. |
---|
12404 | 14587 | void GoLeft(int mod) |
---|
12405 | 14588 | { |
---|
12406 | 14589 | MODIFIERS |= COMMAND; |
---|
12407 | | - /* |
---|
| 14590 | + /**/ |
---|
12408 | 14591 | if((mod&SHIFT) == SHIFT) |
---|
12409 | | - manipCamera.RotatePosition(speed, 0); |
---|
12410 | | - else |
---|
12411 | 14592 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
12412 | | - */ |
---|
| 14593 | + else |
---|
| 14594 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14595 | + /**/ |
---|
12413 | 14596 | if ((mod & SHIFT) == SHIFT) |
---|
12414 | 14597 | { |
---|
12415 | 14598 | mouseMode = mouseMode; |
---|
.. | .. |
---|
12425 | 14608 | void GoRight(int mod) |
---|
12426 | 14609 | { |
---|
12427 | 14610 | MODIFIERS |= COMMAND; |
---|
12428 | | - /* |
---|
| 14611 | + /**/ |
---|
12429 | 14612 | if((mod&SHIFT) == SHIFT) |
---|
12430 | | - manipCamera.RotatePosition(-speed, 0); |
---|
12431 | | - else |
---|
12432 | 14613 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
12433 | | - */ |
---|
| 14614 | + else |
---|
| 14615 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14616 | + /**/ |
---|
12434 | 14617 | if ((mod & SHIFT) == SHIFT) |
---|
12435 | 14618 | { |
---|
12436 | 14619 | mouseMode = mouseMode; |
---|
.. | .. |
---|
12448 | 14631 | int X, Y; |
---|
12449 | 14632 | boolean SX, SY; |
---|
12450 | 14633 | |
---|
12451 | | - void drag(int x, int y, int modifiers) |
---|
| 14634 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
12452 | 14635 | { |
---|
12453 | 14636 | if (IsFrozen()) |
---|
12454 | 14637 | { |
---|
.. | .. |
---|
12457 | 14640 | |
---|
12458 | 14641 | drag = true; // NEW |
---|
12459 | 14642 | |
---|
12460 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14643 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
12461 | 14644 | |
---|
12462 | 14645 | X = x; |
---|
12463 | 14646 | Y = y; |
---|
12464 | 14647 | // floating state for animation |
---|
12465 | | - MODIFIERS = modifiers; |
---|
12466 | | - modifiers &= ~1024; |
---|
| 14648 | + MODIFIERS = modifiersex; |
---|
| 14649 | + modifiersex &= ~1024; |
---|
12467 | 14650 | if (false) // modifiers != 0) |
---|
12468 | 14651 | { |
---|
12469 | 14652 | //new Exception().printStackTrace(); |
---|
12470 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14653 | + System.out.println("mouseDragged: " + modifiersex); |
---|
12471 | 14654 | System.out.println("SHIFT = " + SHIFT); |
---|
12472 | 14655 | System.out.println("CONTROL = " + COMMAND); |
---|
12473 | 14656 | System.out.println("META = " + META); |
---|
.. | .. |
---|
12480 | 14663 | if (editObj) |
---|
12481 | 14664 | { |
---|
12482 | 14665 | drag = true; |
---|
12483 | | - ClickInfo info = new ClickInfo(); |
---|
12484 | | - info.bounds.setBounds(0, 0, |
---|
| 14666 | + //ClickInfo info = new ClickInfo(); |
---|
| 14667 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
12485 | 14668 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
12486 | | - info.pane = this; |
---|
12487 | | - info.camera = renderCamera; |
---|
12488 | | - info.x = x; |
---|
12489 | | - info.y = y; |
---|
12490 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14669 | + object.clickInfo.pane = this; |
---|
| 14670 | + object.clickInfo.camera = renderCamera; |
---|
| 14671 | + object.clickInfo.x = x; |
---|
| 14672 | + object.clickInfo.y = y; |
---|
| 14673 | + object //.GetWindow().copy |
---|
| 14674 | + .doEditDrag(//info, |
---|
| 14675 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
12491 | 14676 | } else |
---|
12492 | 14677 | { |
---|
12493 | 14678 | if (x < startX) |
---|
.. | .. |
---|
12589 | 14774 | { |
---|
12590 | 14775 | manipCamera.Translate(dx, dy, getWidth()); |
---|
12591 | 14776 | } |
---|
| 14777 | + else |
---|
12592 | 14778 | if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0) |
---|
12593 | 14779 | { |
---|
12594 | 14780 | manipCamera.RotateInterest(dx, dy); |
---|
.. | .. |
---|
12599 | 14785 | |
---|
12600 | 14786 | if (manipCamera == lightCamera) |
---|
12601 | 14787 | { |
---|
12602 | | - lighttouched = true; |
---|
| 14788 | + Globals.lighttouched = true; |
---|
12603 | 14789 | } |
---|
12604 | 14790 | /* |
---|
12605 | 14791 | switch (mode) |
---|
.. | .. |
---|
12635 | 14821 | } |
---|
12636 | 14822 | } |
---|
12637 | 14823 | |
---|
| 14824 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14825 | + |
---|
12638 | 14826 | public void mouseMoved(MouseEvent e) |
---|
12639 | 14827 | { |
---|
12640 | 14828 | //System.out.println("mouseMoved: " + e); |
---|
12641 | | - |
---|
12642 | 14829 | if (isRenderer) |
---|
12643 | 14830 | return; |
---|
12644 | 14831 | |
---|
12645 | | - ClickInfo ci = new ClickInfo(); |
---|
12646 | | - ci.x = e.getX(); |
---|
12647 | | - ci.y = e.getY(); |
---|
12648 | | - ci.modifiers = e.getModifiersEx(); |
---|
12649 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
12650 | | - ci.pane = this; |
---|
12651 | | - ci.camera = renderCamera; |
---|
| 14832 | + // Mouse cursor feedback |
---|
| 14833 | + object.clickInfo.x = e.getX(); |
---|
| 14834 | + object.clickInfo.y = e.getY(); |
---|
| 14835 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14836 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14837 | + object.clickInfo.pane = this; |
---|
| 14838 | + object.clickInfo.camera = renderCamera; |
---|
12652 | 14839 | if (!isRenderer) |
---|
12653 | 14840 | { |
---|
12654 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14841 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14842 | + //Object3D copy = editWindow.copy; |
---|
| 14843 | + if (object.doEditClick(//clickInfo, |
---|
| 14844 | + 0)) |
---|
12655 | 14845 | { |
---|
12656 | 14846 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
12657 | 14847 | } else |
---|
.. | .. |
---|
12663 | 14853 | |
---|
12664 | 14854 | public void mouseReleased(MouseEvent e) |
---|
12665 | 14855 | { |
---|
| 14856 | + Globals.MOUSEDRAGGED = false; |
---|
| 14857 | + |
---|
12666 | 14858 | movingcamera = false; |
---|
| 14859 | + X = 0; // getBounds().width/2; |
---|
| 14860 | + Y = 0; // getBounds().height/2; |
---|
12667 | 14861 | //System.out.println("mouseReleased: " + e); |
---|
12668 | 14862 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12669 | 14863 | } |
---|
.. | .. |
---|
12686 | 14880 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
12687 | 14881 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
12688 | 14882 | |
---|
12689 | | - if (control || command || IsFrozen()) |
---|
| 14883 | +// No delay if (control || command || IsFrozen()) |
---|
12690 | 14884 | timeout = true; |
---|
12691 | | - else |
---|
| 14885 | +// ?? May 2019 else |
---|
12692 | 14886 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
12693 | 14887 | mouseDown = false; |
---|
12694 | 14888 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
12798 | 14992 | System.out.println("keyReleased: " + e); |
---|
12799 | 14993 | } |
---|
12800 | 14994 | |
---|
12801 | | - void SetMouseMode(int modifiers) |
---|
| 14995 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
12802 | 14996 | { |
---|
12803 | 14997 | //System.out.println("SetMouseMode = " + modifiers); |
---|
12804 | 14998 | //modifiers &= ~1024; |
---|
.. | .. |
---|
12810 | 15004 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
12811 | 15005 | // return; |
---|
12812 | 15006 | //System.out.println("SetMode = " + modifiers); |
---|
12813 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 15007 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
12814 | 15008 | { |
---|
12815 | 15009 | mouseMode |= ZOOM; |
---|
12816 | 15010 | } |
---|
12817 | | - if ((modifiers & META) == META) |
---|
| 15011 | + |
---|
| 15012 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
| 15013 | + if (capsLocked) // || (modifiers & META) == META) |
---|
12818 | 15014 | { |
---|
12819 | 15015 | mouseMode |= VR; // BACKFORTH; |
---|
12820 | 15016 | } |
---|
12821 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
12822 | | - { |
---|
12823 | | - mouseMode |= SELECT; // BACKFORTH; |
---|
12824 | | - } |
---|
12825 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 15017 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
12826 | 15018 | { |
---|
12827 | 15019 | mouseMode |= SELECT; |
---|
12828 | 15020 | } |
---|
12829 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 15021 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
12830 | 15022 | { |
---|
| 15023 | + mouseMode |= SELECT; |
---|
| 15024 | + } |
---|
| 15025 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
| 15026 | + { |
---|
| 15027 | + mouseMode &= ~VR; |
---|
12831 | 15028 | mouseMode |= TRANSLATE; |
---|
12832 | 15029 | } |
---|
12833 | 15030 | // if ((modifiers & SHIFT_META) == SHIFT_META) |
---|
.. | .. |
---|
12854 | 15051 | |
---|
12855 | 15052 | if (isRenderer) // |
---|
12856 | 15053 | { |
---|
12857 | | - SetMouseMode(modifiers); |
---|
| 15054 | + SetMouseMode(0, modifiers); |
---|
12858 | 15055 | } |
---|
12859 | 15056 | |
---|
12860 | | - theRenderer.keyPressed(key); |
---|
| 15057 | + Globals.theRenderer.keyPressed(key); |
---|
12861 | 15058 | } |
---|
12862 | 15059 | |
---|
12863 | 15060 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
12869 | 15066 | float SATPOW = 1; // 2; // 0.5f; |
---|
12870 | 15067 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
12871 | 15068 | |
---|
12872 | | - void keyPressed(int key) |
---|
| 15069 | + public void keyPressed(int key) |
---|
12873 | 15070 | { |
---|
12874 | 15071 | if (key >= '0' && key <= '5') |
---|
12875 | 15072 | clampbit = (key-'0'); |
---|
.. | .. |
---|
12916 | 15113 | // break; |
---|
12917 | 15114 | case 'T': |
---|
12918 | 15115 | CACHETEXTURE ^= true; |
---|
12919 | | - textures.clear(); |
---|
| 15116 | + texturepigment.clear(); |
---|
| 15117 | + texturebump.clear(); |
---|
12920 | 15118 | // repaint(); |
---|
12921 | 15119 | break; |
---|
12922 | 15120 | case 'Y': |
---|
.. | .. |
---|
12984 | 15182 | case 'B': |
---|
12985 | 15183 | BRISMOOTH ^= true; |
---|
12986 | 15184 | SHADOWCULLFACE ^= true; |
---|
12987 | | - lighttouched = true; |
---|
| 15185 | + Globals.lighttouched = true; |
---|
12988 | 15186 | repaint(); |
---|
12989 | 15187 | break; |
---|
12990 | 15188 | case 'b': |
---|
.. | .. |
---|
13001 | 15199 | case 'E' : COMPACT ^= true; |
---|
13002 | 15200 | repaint(); |
---|
13003 | 15201 | break; |
---|
13004 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15202 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15203 | + //DEBUGHSB ^= true; |
---|
| 15204 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
13005 | 15205 | repaint(); |
---|
13006 | 15206 | break; |
---|
13007 | 15207 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
13026 | 15226 | RevertCamera(); |
---|
13027 | 15227 | repaint(); |
---|
13028 | 15228 | break; |
---|
13029 | | - case 'L': |
---|
13030 | 15229 | case 'l': |
---|
| 15230 | + //case 'L': |
---|
13031 | 15231 | if (lightMode) |
---|
13032 | 15232 | { |
---|
13033 | 15233 | lightMode = false; |
---|
.. | .. |
---|
13084 | 15284 | repaint(); |
---|
13085 | 15285 | break; |
---|
13086 | 15286 | case 'O': |
---|
13087 | | - drawMode = OCCLUSION; |
---|
| 15287 | + Globals.drawMode = OCCLUSION; // WARNING |
---|
13088 | 15288 | repaint(); |
---|
13089 | 15289 | break; |
---|
13090 | 15290 | case 'o': |
---|
.. | .. |
---|
13170 | 15370 | case '_': |
---|
13171 | 15371 | kompactbit = 5; |
---|
13172 | 15372 | break; |
---|
13173 | | - case '+': |
---|
13174 | | - kompactbit = 6; |
---|
13175 | | - break; |
---|
| 15373 | +// case '+': |
---|
| 15374 | +// kompactbit = 6; |
---|
| 15375 | +// break; |
---|
13176 | 15376 | case ' ': |
---|
13177 | 15377 | lightMode ^= true; |
---|
13178 | | - lighttouched = true; |
---|
| 15378 | + Globals.lighttouched = true; |
---|
13179 | 15379 | manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
13180 | 15380 | targetLookAt.set(manipCamera.lookAt); |
---|
13181 | 15381 | repaint(); |
---|
.. | .. |
---|
13184 | 15384 | case ESC: |
---|
13185 | 15385 | RENDERPROGRAM += 1; |
---|
13186 | 15386 | RENDERPROGRAM %= 3; |
---|
| 15387 | + |
---|
13187 | 15388 | repaint(); |
---|
13188 | 15389 | break; |
---|
13189 | 15390 | case 'Z': |
---|
13190 | | - RESIZETEXTURE ^= true; |
---|
13191 | | - break; |
---|
| 15391 | + //RESIZETEXTURE ^= true; |
---|
| 15392 | + //break; |
---|
13192 | 15393 | case 'z': |
---|
13193 | | - RENDERSHADOW ^= true; |
---|
13194 | | - lighttouched = true; |
---|
| 15394 | + Globals.RENDERSHADOW ^= true; |
---|
| 15395 | + Globals.lighttouched = true; |
---|
13195 | 15396 | repaint(); |
---|
13196 | 15397 | break; |
---|
13197 | 15398 | //case UP: |
---|
.. | .. |
---|
13217 | 15418 | FlipTransform(); |
---|
13218 | 15419 | break; |
---|
13219 | 15420 | case ENTER: |
---|
13220 | | - object.editWindow.ScreenFit(); // Edit(); |
---|
| 15421 | + // object.editWindow.ScreenFit(); // Edit(); |
---|
| 15422 | + ToggleLive(); |
---|
13221 | 15423 | break; |
---|
13222 | 15424 | case DELETE: |
---|
13223 | 15425 | ClearSelection(); |
---|
13224 | 15426 | break; |
---|
13225 | | - /* |
---|
13226 | 15427 | case '+': |
---|
| 15428 | + |
---|
| 15429 | + /* |
---|
13227 | 15430 | //fontsize += 1; |
---|
13228 | 15431 | bbzoom *= 2; |
---|
13229 | 15432 | repaint(); |
---|
.. | .. |
---|
13240 | 15443 | case '=': |
---|
13241 | 15444 | IncDepth(); |
---|
13242 | 15445 | //fontsize += 1; |
---|
13243 | | - object.editWindow.refreshContents(true); |
---|
| 15446 | + object.GetWindow().refreshContents(true); |
---|
13244 | 15447 | maskbit = 6; |
---|
13245 | 15448 | break; |
---|
13246 | 15449 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
13247 | 15450 | DecDepth(); |
---|
13248 | 15451 | maskbit = 5; |
---|
13249 | 15452 | //if(fontsize > 1) fontsize -= 1; |
---|
13250 | | - if (object.editWindow == null) |
---|
13251 | | - new Exception().printStackTrace(); |
---|
13252 | | - else |
---|
13253 | | - object.editWindow.refreshContents(true); |
---|
| 15453 | +// if (object.editWindow == null) |
---|
| 15454 | +// new Exception().printStackTrace(); |
---|
| 15455 | +// else |
---|
| 15456 | + object.GetWindow().refreshContents(true); |
---|
13254 | 15457 | break; |
---|
13255 | 15458 | case '{': |
---|
13256 | 15459 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
13305 | 15508 | } |
---|
13306 | 15509 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
13307 | 15510 | } |
---|
| 15511 | + |
---|
13308 | 15512 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
13309 | 15513 | |
---|
13310 | 15514 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
13312 | 15516 | //mode = ROTATE; |
---|
13313 | 15517 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
13314 | 15518 | { |
---|
13315 | | - SetMouseMode(modifiers); |
---|
| 15519 | + SetMouseMode(0, modifiers); |
---|
13316 | 15520 | } |
---|
13317 | 15521 | } |
---|
13318 | 15522 | |
---|
13319 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 15523 | + public void processKeyEvent(KeyEvent e) |
---|
13320 | 15524 | { |
---|
13321 | 15525 | switch (e.getID()) |
---|
13322 | 15526 | { |
---|
.. | .. |
---|
13446 | 15650 | |
---|
13447 | 15651 | protected void processMouseMotionEvent(MouseEvent e) |
---|
13448 | 15652 | { |
---|
13449 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
13450 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15653 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15654 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15655 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
13451 | 15656 | { |
---|
13452 | 15657 | mouseMoved(e); |
---|
13453 | 15658 | } else |
---|
.. | .. |
---|
13472 | 15677 | } |
---|
13473 | 15678 | */ |
---|
13474 | 15679 | |
---|
13475 | | - object.editWindow.EditSelection(); |
---|
| 15680 | + object.GetWindow().EditSelection(false); |
---|
13476 | 15681 | } |
---|
13477 | 15682 | |
---|
13478 | 15683 | void SelectParent() |
---|
13479 | 15684 | { |
---|
| 15685 | + new Exception().printStackTrace(); |
---|
13480 | 15686 | System.exit(0); |
---|
13481 | 15687 | Composite group = (Composite) object; |
---|
13482 | 15688 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
13488 | 15694 | { |
---|
13489 | 15695 | //selectees.remove(i); |
---|
13490 | 15696 | System.out.println("select parent of " + elem); |
---|
13491 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15697 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
13492 | 15698 | } else |
---|
13493 | 15699 | { |
---|
13494 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15700 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
13495 | 15701 | } |
---|
13496 | 15702 | |
---|
13497 | 15703 | first = false; |
---|
.. | .. |
---|
13500 | 15706 | |
---|
13501 | 15707 | void SelectChildren() |
---|
13502 | 15708 | { |
---|
| 15709 | + new Exception().printStackTrace(); |
---|
13503 | 15710 | System.exit(0); |
---|
13504 | 15711 | /* |
---|
13505 | 15712 | Composite group = (Composite) object; |
---|
.. | .. |
---|
13532 | 15739 | for (int j = 0; j < group.children.size(); j++) |
---|
13533 | 15740 | { |
---|
13534 | 15741 | elem = (Object3D) group.children.elementAt(j); |
---|
13535 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15742 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
13536 | 15743 | first = false; |
---|
13537 | 15744 | } |
---|
13538 | 15745 | } else |
---|
13539 | 15746 | { |
---|
13540 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15747 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
13541 | 15748 | } |
---|
13542 | 15749 | |
---|
13543 | 15750 | first = false; |
---|
.. | .. |
---|
13548 | 15755 | { |
---|
13549 | 15756 | //Composite group = (Composite) object; |
---|
13550 | 15757 | Object3D group = object; |
---|
13551 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15758 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
13552 | 15759 | } |
---|
13553 | 15760 | |
---|
13554 | 15761 | void ResetTransform(int mask) |
---|
13555 | 15762 | { |
---|
13556 | 15763 | //Composite group = (Composite) object; |
---|
13557 | 15764 | Object3D group = object; |
---|
13558 | | - group.editWindow.ResetTransform(mask); |
---|
| 15765 | + group.GetWindow().ResetTransform(mask); |
---|
13559 | 15766 | } |
---|
13560 | 15767 | |
---|
13561 | 15768 | void FlipTransform() |
---|
13562 | 15769 | { |
---|
13563 | 15770 | //Composite group = (Composite) object; |
---|
13564 | 15771 | Object3D group = object; |
---|
13565 | | - group.editWindow.FlipTransform(); |
---|
| 15772 | + group.GetWindow().FlipTransform(); |
---|
13566 | 15773 | // group.editWindow.ReduceMesh(true); |
---|
13567 | 15774 | } |
---|
13568 | 15775 | |
---|
.. | .. |
---|
13570 | 15777 | { |
---|
13571 | 15778 | //Composite group = (Composite) object; |
---|
13572 | 15779 | Object3D group = object; |
---|
13573 | | - group.editWindow.PrintMemory(); |
---|
| 15780 | + group.GetWindow().PrintMemory(); |
---|
13574 | 15781 | // group.editWindow.ReduceMesh(true); |
---|
13575 | 15782 | } |
---|
13576 | 15783 | |
---|
.. | .. |
---|
13578 | 15785 | { |
---|
13579 | 15786 | //Composite group = (Composite) object; |
---|
13580 | 15787 | Object3D group = object; |
---|
13581 | | - group.editWindow.ResetCentroid(); |
---|
| 15788 | + group.GetWindow().ResetCentroid(); |
---|
13582 | 15789 | } |
---|
13583 | 15790 | |
---|
13584 | 15791 | void IncDepth() |
---|
.. | .. |
---|
13660 | 15867 | |
---|
13661 | 15868 | int width = getBounds().width; |
---|
13662 | 15869 | int height = getBounds().height; |
---|
13663 | | - ClickInfo info = new ClickInfo(); |
---|
13664 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
13665 | 15870 | //Image img = CreateImage(width, height); |
---|
13666 | 15871 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15872 | + |
---|
13667 | 15873 | Graphics gr = g; // img.getGraphics(); |
---|
| 15874 | + |
---|
13668 | 15875 | if (!hasMarquee) |
---|
13669 | 15876 | { |
---|
13670 | 15877 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
13736 | 15943 | } |
---|
13737 | 15944 | if (object != null && !hasMarquee) |
---|
13738 | 15945 | { |
---|
| 15946 | + if (object.clickInfo == null) |
---|
| 15947 | + object.clickInfo = new ClickInfo(); |
---|
| 15948 | + ClickInfo info = object.clickInfo; |
---|
| 15949 | + //ClickInfo info = new ClickInfo(); |
---|
| 15950 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 15951 | + |
---|
13739 | 15952 | if (isRenderer) |
---|
13740 | 15953 | { |
---|
13741 | | - info.flags++; |
---|
| 15954 | + object.clickInfo.flags++; |
---|
13742 | 15955 | double frameAspect = (double) width / (double) height; |
---|
13743 | 15956 | if (frameAspect > renderCamera.aspect) |
---|
13744 | 15957 | { |
---|
13745 | 15958 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
13746 | | - info.bounds.width -= width - desired; |
---|
13747 | | - info.bounds.x += (width - desired) / 2; |
---|
| 15959 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 15960 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
13748 | 15961 | } else |
---|
13749 | 15962 | { |
---|
13750 | 15963 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
13751 | | - info.bounds.height -= height - desired; |
---|
13752 | | - info.bounds.y += (height - desired) / 2; |
---|
| 15964 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 15965 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
13753 | 15966 | } |
---|
13754 | 15967 | } |
---|
13755 | | - info.g = gr; |
---|
13756 | | - info.camera = renderCamera; |
---|
| 15968 | + |
---|
| 15969 | + object.clickInfo.g = gr; |
---|
| 15970 | + object.clickInfo.camera = renderCamera; |
---|
13757 | 15971 | /* |
---|
13758 | 15972 | // Memory intensive (brep.verticescopy) |
---|
13759 | 15973 | if (!(object instanceof Composite)) |
---|
13760 | 15974 | object.draw(info, 0, false); // SLOW : |
---|
13761 | 15975 | */ |
---|
13762 | | - if (!isRenderer) |
---|
| 15976 | + if (!isRenderer) // && drag) |
---|
13763 | 15977 | { |
---|
13764 | | - object.drawEditHandles(info, 0); |
---|
| 15978 | + Grafreed.Assert(object != null); |
---|
| 15979 | + Grafreed.Assert(object.selection != null); |
---|
| 15980 | + if (object.selection.Size() > 0) |
---|
| 15981 | + { |
---|
| 15982 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 15983 | + |
---|
| 15984 | + object.clickInfo.DX = 0; |
---|
| 15985 | + object.clickInfo.DY = 0; |
---|
| 15986 | + object.clickInfo.W = 1; |
---|
| 15987 | + if (hitSomething == Object3D.hitCenter) |
---|
| 15988 | + { |
---|
| 15989 | + info.DX = X; |
---|
| 15990 | + if (X != 0) |
---|
| 15991 | + info.DX -= info.bounds.width/2; |
---|
| 15992 | + |
---|
| 15993 | + info.DY = Y; |
---|
| 15994 | + if (Y != 0) |
---|
| 15995 | + info.DY -= info.bounds.height/2; |
---|
| 15996 | + } |
---|
| 15997 | + |
---|
| 15998 | + object.drawEditHandles(//info, |
---|
| 15999 | + 0); |
---|
| 16000 | + |
---|
| 16001 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16002 | + { |
---|
| 16003 | + switch (hitSomething) |
---|
| 16004 | + { |
---|
| 16005 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16006 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16007 | + break; |
---|
| 16008 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16009 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16010 | + break; |
---|
| 16011 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16012 | + gr.drawLine(X, Y, 0, 0); |
---|
| 16013 | + break; |
---|
| 16014 | + } |
---|
| 16015 | + |
---|
| 16016 | + } |
---|
| 16017 | + } |
---|
13765 | 16018 | } |
---|
13766 | 16019 | } |
---|
| 16020 | + |
---|
13767 | 16021 | if (isRenderer) |
---|
13768 | 16022 | { |
---|
13769 | 16023 | //gr.setColor(Color.black); |
---|
13770 | 16024 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
13771 | 16025 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
13772 | 16026 | } |
---|
| 16027 | + |
---|
13773 | 16028 | if (hasMarquee) |
---|
13774 | 16029 | { |
---|
13775 | 16030 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
13792 | 16047 | //if (g != gr) g.drawImage(img, 0, 0, width, height, null); |
---|
13793 | 16048 | } |
---|
13794 | 16049 | |
---|
| 16050 | + // To avoid clear. |
---|
13795 | 16051 | public void update(Graphics g) |
---|
13796 | 16052 | { |
---|
13797 | 16053 | paint(g); |
---|
.. | .. |
---|
13881 | 16137 | public boolean mouseDown(Event evt, int x, int y) |
---|
13882 | 16138 | { |
---|
13883 | 16139 | System.out.println("mouseDown: " + evt); |
---|
| 16140 | + System.exit(0); |
---|
13884 | 16141 | /* |
---|
13885 | 16142 | locked = true; |
---|
13886 | 16143 | drag = false; |
---|
.. | .. |
---|
13924 | 16181 | { |
---|
13925 | 16182 | keyPressed(0, modifiers); |
---|
13926 | 16183 | } |
---|
13927 | | - clickStart(x, y, modifiers); |
---|
| 16184 | + // clickStart(x, y, modifiers); |
---|
13928 | 16185 | return true; |
---|
13929 | 16186 | } |
---|
13930 | 16187 | |
---|
.. | .. |
---|
14042 | 16299 | { |
---|
14043 | 16300 | keyReleased(0, 0); |
---|
14044 | 16301 | } |
---|
14045 | | - drag(x, y, modifiers); |
---|
| 16302 | + drag(x, y, 0, modifiers); |
---|
14046 | 16303 | return true; |
---|
14047 | 16304 | } |
---|
14048 | 16305 | |
---|
.. | .. |
---|
14174 | 16431 | Object3D object; |
---|
14175 | 16432 | static Object3D trackedobject; |
---|
14176 | 16433 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
14177 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16434 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
14178 | 16435 | /*static*/ Camera eyeCamera; |
---|
14179 | 16436 | /*static*/ Camera lightCamera; |
---|
14180 | 16437 | int cameracount; |
---|
.. | .. |
---|
14394 | 16651 | gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS); |
---|
14395 | 16652 | gl.glPushMatrix(); |
---|
14396 | 16653 | gl.glLoadIdentity(); |
---|
14397 | | - PushMatrix(checker.toParent); |
---|
| 16654 | + //PushMatrix(checker.toParent); |
---|
14398 | 16655 | |
---|
14399 | 16656 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
14400 | 16657 | gl.glPushMatrix(); |
---|
.. | .. |
---|
14417 | 16674 | |
---|
14418 | 16675 | gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
14419 | 16676 | |
---|
14420 | | - float step = 0.1666f; //0.25f; |
---|
14421 | | - float stepv = step * 1652 / 998; |
---|
| 16677 | + float step = 2; // 0.1666f; //0.25f; |
---|
| 16678 | + float stepv = 2; // step * 1652 / 998; |
---|
14422 | 16679 | |
---|
14423 | 16680 | int i0 = 0; |
---|
14424 | 16681 | /* |
---|
.. | .. |
---|
14454 | 16711 | /**/ |
---|
14455 | 16712 | //checker.GetMaterial().opacity = 1.1f; |
---|
14456 | 16713 | ////checker.GetMaterial().ambient = 0.99f; |
---|
14457 | | - Object3D.materialstack[Object3D.materialdepth] = checker.material; |
---|
14458 | | - Object3D.selectedstack[Object3D.materialdepth] = false; |
---|
14459 | | - cStatic.objectstack[Object3D.materialdepth++] = checker; |
---|
| 16714 | + materialstack[materialdepth] = checker.material; |
---|
| 16715 | + selectedstack[materialdepth] = false; |
---|
| 16716 | + cStatic.objectstack[materialdepth++] = checker; |
---|
14460 | 16717 | //System.out.println("material " + material); |
---|
14461 | 16718 | //Applet3D.tracein(this, selected); |
---|
14462 | | - vector2buffer = checker.projectedVertices; |
---|
| 16719 | + //vector2buffer = checker.projectedVertices; |
---|
14463 | 16720 | |
---|
14464 | | - checker.GetMaterial().Draw(this, false); // true); |
---|
| 16721 | + //checker.GetMaterial().Draw(this, false); // true); |
---|
| 16722 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
14465 | 16723 | |
---|
14466 | | - Object3D.materialdepth -= 1; |
---|
14467 | | - if (Object3D.materialdepth > 0) |
---|
| 16724 | + materialdepth -= 1; |
---|
| 16725 | + if (materialdepth > 0) |
---|
14468 | 16726 | { |
---|
14469 | | - vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices; |
---|
14470 | | - Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]); |
---|
| 16727 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16728 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
14471 | 16729 | } |
---|
14472 | 16730 | //checker.GetMaterial().opacity = 1f; |
---|
14473 | 16731 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
14488 | 16746 | |
---|
14489 | 16747 | //float u = (i+1)/2; |
---|
14490 | 16748 | //float v = (j+1)/2; |
---|
14491 | | - gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
| 16749 | + if (checker.flipV) |
---|
| 16750 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2); |
---|
| 16751 | + else |
---|
| 16752 | + gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
14492 | 16753 | gl.glVertex3f(i, j, -0.5f); |
---|
14493 | 16754 | |
---|
| 16755 | + if (checker.flipV) |
---|
| 16756 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
| 16757 | + else |
---|
14494 | 16758 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
14495 | 16759 | gl.glVertex3f(i + step, j, -0.5f); |
---|
14496 | 16760 | |
---|
| 16761 | + if (checker.flipV) |
---|
| 16762 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
| 16763 | + else |
---|
14497 | 16764 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
14498 | 16765 | gl.glVertex3f(i + step, j + stepv, -0.5f); |
---|
14499 | 16766 | |
---|
| 16767 | + if (checker.flipV) |
---|
| 16768 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
| 16769 | + else |
---|
14500 | 16770 | gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
14501 | 16771 | gl.glVertex3f(i, j + stepv, -0.5f); |
---|
14502 | 16772 | } |
---|
.. | .. |
---|
14508 | 16778 | gl.glMatrixMode(GL.GL_PROJECTION); |
---|
14509 | 16779 | gl.glPopMatrix(); |
---|
14510 | 16780 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
14511 | | - PopMatrix(null); // checker.toParent); // null); |
---|
| 16781 | + //PopMatrix(null); // checker.toParent); // null); |
---|
14512 | 16782 | gl.glPopMatrix(); |
---|
14513 | 16783 | PopTextureMatrix(checker.toParent); |
---|
14514 | 16784 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
.. | .. |
---|
14541 | 16811 | } |
---|
14542 | 16812 | } |
---|
14543 | 16813 | |
---|
| 16814 | + private Object3D GetFolder() |
---|
| 16815 | + { |
---|
| 16816 | + Object3D folder = object.GetWindow().copy; |
---|
| 16817 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16818 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16819 | + return folder; |
---|
| 16820 | + } |
---|
| 16821 | + |
---|
14544 | 16822 | class SelectBuffer implements GLEventListener |
---|
14545 | 16823 | { |
---|
14546 | 16824 | |
---|
.. | .. |
---|
14599 | 16877 | { |
---|
14600 | 16878 | if (!selection) |
---|
14601 | 16879 | { |
---|
| 16880 | + new Exception().printStackTrace(); |
---|
14602 | 16881 | System.exit(0); |
---|
14603 | 16882 | return; |
---|
14604 | 16883 | } |
---|
.. | .. |
---|
14619 | 16898 | |
---|
14620 | 16899 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
14621 | 16900 | |
---|
| 16901 | + if (PAINTMODE) |
---|
| 16902 | + { |
---|
| 16903 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16904 | + { |
---|
| 16905 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16906 | + |
---|
| 16907 | + // Make what you paint not selectable. |
---|
| 16908 | + paintobj.ResetSelectable(); |
---|
| 16909 | + } |
---|
| 16910 | + } |
---|
| 16911 | + |
---|
14622 | 16912 | //int tmp = selection_view; |
---|
14623 | 16913 | //selection_view = -1; |
---|
14624 | | - int temp = drawMode; |
---|
14625 | | - drawMode = SELECTION; |
---|
| 16914 | + int temp = DrawMode(); |
---|
| 16915 | + Globals.drawMode = SELECTION; // WARNING |
---|
14626 | 16916 | indexcount = 0; |
---|
14627 | 16917 | parent.display(drawable); |
---|
14628 | 16918 | //selection_view = tmp; |
---|
14629 | 16919 | //if (temp == SELECTION) |
---|
14630 | 16920 | // temp = DEFAULT; // patch for selection debug |
---|
14631 | | - drawMode = temp; |
---|
| 16921 | + Globals.drawMode = temp; // WARNING |
---|
14632 | 16922 | |
---|
| 16923 | + if (PAINTMODE) |
---|
| 16924 | + { |
---|
| 16925 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16926 | + { |
---|
| 16927 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16928 | + |
---|
| 16929 | + // Revert. |
---|
| 16930 | + paintobj.RestoreSelectable(); |
---|
| 16931 | + } |
---|
| 16932 | + } |
---|
| 16933 | + |
---|
14633 | 16934 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
14634 | 16935 | |
---|
14635 | 16936 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
14678 | 16979 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
14679 | 16980 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
14680 | 16981 | |
---|
| 16982 | + CreateSelectedPoint(); |
---|
| 16983 | + |
---|
| 16984 | + // Will fit the mesh !!! |
---|
| 16985 | + selectedpoint.toParent[0][0] = 0.0001; |
---|
| 16986 | + selectedpoint.toParent[1][1] = 0.0001; |
---|
| 16987 | + selectedpoint.toParent[2][2] = 0.0001; |
---|
| 16988 | + |
---|
14681 | 16989 | glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0); |
---|
14682 | 16990 | |
---|
14683 | 16991 | // if (object.selection != null && object.selection.Size() > 0) |
---|
.. | .. |
---|
14721 | 17029 | 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])); |
---|
14722 | 17030 | } |
---|
14723 | 17031 | |
---|
14724 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 17032 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
14725 | 17033 | } |
---|
14726 | 17034 | } |
---|
14727 | 17035 | |
---|
14728 | 17036 | if (!movingcamera && !PAINTMODE) |
---|
14729 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17037 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
14730 | 17038 | |
---|
14731 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17039 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
14732 | 17040 | { |
---|
14733 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17041 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
14734 | 17042 | |
---|
14735 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17043 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17044 | + { |
---|
| 17045 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
14736 | 17046 | |
---|
14737 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
14738 | | - |
---|
14739 | | - group.add(paintobj); // link |
---|
14740 | | - |
---|
14741 | | - object.editWindow.SnapObject(group); |
---|
14742 | | - |
---|
14743 | | - Object3D folder = object.editWindow.copy; |
---|
14744 | | - |
---|
14745 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
14746 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
14747 | | - |
---|
14748 | | - folder.add(group); |
---|
14749 | | - |
---|
14750 | | - object.editWindow.ResetModel(); |
---|
14751 | | - object.editWindow.refreshContents(); |
---|
| 17047 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17048 | + |
---|
| 17049 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17050 | + |
---|
| 17051 | + inst.add(paintobj); // link |
---|
| 17052 | + |
---|
| 17053 | + object.GetWindow().SnapObject(inst); |
---|
| 17054 | + |
---|
| 17055 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17056 | + |
---|
| 17057 | + folder.add(inst); |
---|
| 17058 | + |
---|
| 17059 | + object.GetWindow().ResetModel(); |
---|
| 17060 | + object.GetWindow().refreshContents(); |
---|
| 17061 | + } |
---|
14752 | 17062 | } |
---|
14753 | 17063 | else |
---|
14754 | 17064 | paintcount = 0; |
---|
.. | .. |
---|
14787 | 17097 | //System.out.println("objects[color] = " + objects[color]); |
---|
14788 | 17098 | //objects[color].Select(); |
---|
14789 | 17099 | indexcount = 0; |
---|
| 17100 | + ObjEditor window = object.GetWindow(); |
---|
| 17101 | + if (window != null && deselect) |
---|
| 17102 | + { |
---|
| 17103 | + window.Select(null, deselect, true); |
---|
| 17104 | + } |
---|
14790 | 17105 | object.Select(color, deselect); |
---|
14791 | 17106 | } |
---|
14792 | 17107 | |
---|
.. | .. |
---|
14886 | 17201 | gl.glDisable(gl.GL_CULL_FACE); |
---|
14887 | 17202 | } |
---|
14888 | 17203 | |
---|
14889 | | - if (!RENDERSHADOW) |
---|
| 17204 | + if (!Globals.RENDERSHADOW) |
---|
14890 | 17205 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14891 | 17206 | |
---|
14892 | 17207 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
14896 | 17211 | //gl.glColorMask(false, false, false, false); |
---|
14897 | 17212 | |
---|
14898 | 17213 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
14899 | | - if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17214 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
14900 | 17215 | { |
---|
14901 | 17216 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14902 | 17217 | |
---|
14903 | | - int temp = drawMode; |
---|
14904 | | - drawMode = SHADOW; |
---|
| 17218 | + int temp = DrawMode(); |
---|
| 17219 | + Globals.drawMode = SHADOW; // WARNING |
---|
14905 | 17220 | parent.display(drawable); |
---|
14906 | | - drawMode = temp; |
---|
| 17221 | + Globals.drawMode = temp; // WARNING |
---|
14907 | 17222 | } |
---|
14908 | 17223 | |
---|
14909 | 17224 | gl.glCullFace(gl.GL_BACK); |
---|
.. | .. |
---|
14956 | 17271 | |
---|
14957 | 17272 | class AntialiasBuffer implements GLEventListener |
---|
14958 | 17273 | { |
---|
14959 | | - |
---|
14960 | 17274 | CameraPane parent = null; |
---|
14961 | 17275 | |
---|
14962 | 17276 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
15066 | 17380 | gl.glFlush(); |
---|
15067 | 17381 | |
---|
15068 | 17382 | /**/ |
---|
15069 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer); |
---|
| 17383 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
15070 | 17384 | |
---|
15071 | | - int[] pixels = occlusionsizebuffer.array(); |
---|
| 17385 | + float[] pixels = occlusionsizebuffer.array(); |
---|
15072 | 17386 | |
---|
15073 | 17387 | double r = 0, g = 0, b = 0; |
---|
15074 | 17388 | |
---|
15075 | 17389 | double count = 0; |
---|
| 17390 | + |
---|
| 17391 | + gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0); |
---|
| 17392 | + |
---|
| 17393 | + float mindepth = 1; |
---|
| 17394 | + |
---|
| 17395 | + double FACTOR = 1; |
---|
15076 | 17396 | |
---|
15077 | 17397 | for (int i = 0; i < pixels.length; i++) |
---|
15078 | 17398 | { |
---|
.. | .. |
---|
15157 | 17477 | |
---|
15158 | 17478 | double scale = ray.z; // 1; // cos |
---|
15159 | 17479 | |
---|
15160 | | - int p = pixels[newindex]; |
---|
| 17480 | + float depth = pixels[newindex]; |
---|
15161 | 17481 | |
---|
15162 | 17482 | /* |
---|
15163 | 17483 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
15181 | 17501 | scale = (1 - modu) * modv; |
---|
15182 | 17502 | */ |
---|
15183 | 17503 | |
---|
15184 | | - r += ((p >> 16) & 0xFF) * scale / 255; |
---|
15185 | | - g += ((p >> 8) & 0xFF) * scale / 255; |
---|
15186 | | - b += (p & 0xFF) * scale / 255; |
---|
| 17504 | + //r += ((p >> 16) & 0xFF) * scale / 255; |
---|
| 17505 | + //g += ((p >> 8) & 0xFF) * scale / 255; |
---|
| 17506 | + //b += (p & 0xFF) * scale / 255; |
---|
| 17507 | + |
---|
| 17508 | + if (mindepth > depth) |
---|
| 17509 | + { |
---|
| 17510 | + mindepth = depth; |
---|
| 17511 | + } |
---|
15187 | 17512 | |
---|
| 17513 | + double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]); |
---|
| 17514 | + |
---|
| 17515 | + double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR); |
---|
| 17516 | + |
---|
| 17517 | + r += factor * scale; |
---|
| 17518 | + g += factor * scale; |
---|
| 17519 | + b += factor * scale; |
---|
| 17520 | + |
---|
15188 | 17521 | count += scale; |
---|
15189 | 17522 | } |
---|
15190 | 17523 | |
---|
.. | .. |
---|
15282 | 17615 | GLUT glut = new GLUT(); |
---|
15283 | 17616 | |
---|
15284 | 17617 | |
---|
15285 | | - static final public int DEFAULT = 0; |
---|
15286 | | - static final public int SELECTION = 1; |
---|
15287 | | - static final public int SHADOW = 2; |
---|
15288 | | - static final public int OCCLUSION = 3; |
---|
15289 | | - static |
---|
15290 | | - public int drawMode = DEFAULT; |
---|
15291 | 17618 | public boolean spherical = false; |
---|
15292 | 17619 | static boolean DEBUG_OCCLUSION = false; |
---|
15293 | 17620 | static boolean DEBUG_SELECTION = false; |
---|
.. | .. |
---|
15300 | 17627 | int AAbuffersize = 0; |
---|
15301 | 17628 | |
---|
15302 | 17629 | //double[] selectedpoint = new double[3]; |
---|
15303 | | - static Sphere selectedpoint = new Sphere(); |
---|
| 17630 | + static Superellipsoid selectedpoint; |
---|
15304 | 17631 | static Sphere previousselectedpoint = null; |
---|
15305 | | - static Sphere debugpoint = new Sphere(); |
---|
15306 | | - static Sphere debugpoint2 = new Sphere(); |
---|
15307 | | - static Sphere debugpoint3 = new Sphere(); |
---|
15308 | | - static Sphere debugpoint4 = new Sphere(); |
---|
| 17632 | + static Sphere debugpointG; |
---|
| 17633 | + static Sphere debugpointP; |
---|
| 17634 | + static Sphere debugpointC; |
---|
| 17635 | + static Sphere debugpointR; |
---|
15309 | 17636 | |
---|
15310 | 17637 | static Sphere debugpoints[] = new Sphere[8]; |
---|
15311 | 17638 | |
---|
15312 | | - static |
---|
15313 | | - { |
---|
15314 | | - for (int i=0; i<8; i++) |
---|
15315 | | - { |
---|
15316 | | - debugpoints[i] = new Sphere(); |
---|
15317 | | - } |
---|
15318 | | - } |
---|
15319 | | - |
---|
15320 | 17639 | static void InitPoints(float radius) |
---|
15321 | 17640 | { |
---|
15322 | 17641 | for (int i=0; i<8; i++) |
---|
.. | .. |
---|
15336 | 17655 | } |
---|
15337 | 17656 | } |
---|
15338 | 17657 | |
---|
15339 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17658 | + static void DrawPoints(iCameraPane cpane) |
---|
15340 | 17659 | { |
---|
15341 | 17660 | for (int i=0; i<8; i++) // first and last are red |
---|
15342 | 17661 | { |
---|
.. | .. |
---|
15358 | 17677 | static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
15359 | 17678 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15360 | 17679 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15361 | | - static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17680 | + //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17681 | + static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
15362 | 17682 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
15363 | 17683 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
15364 | 17684 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|
.. | .. |
---|
15367 | 17687 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
15368 | 17688 | // Depth buffer format |
---|
15369 | 17689 | //private int depth_format; |
---|
15370 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17690 | + |
---|
| 17691 | + public void NextIndex() |
---|
15371 | 17692 | { |
---|
15372 | 17693 | indexcount+=16; |
---|
15373 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17694 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
15374 | 17695 | //objects[indexcount] = o; |
---|
15375 | 17696 | //System.out.println("indexcount = " + indexcount); |
---|
15376 | 17697 | } |
---|