.. | .. |
---|
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; |
---|
.. | .. |
---|
90 | 110 | //private Mat4f spotlightTransform = new Mat4f(); |
---|
91 | 111 | //private Mat4f spotlightInverseTransform = new Mat4f(); |
---|
92 | 112 | static GLContext glcontext = null; |
---|
93 | | - /*static*/ com.sun.opengl.util.texture.Texture cubemap; |
---|
| 113 | + /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb |
---|
| 114 | + /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom; |
---|
| 115 | + /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb; |
---|
| 116 | + boolean transformMode; |
---|
| 117 | + |
---|
94 | 118 | boolean reverseUP = false; |
---|
95 | 119 | static boolean frozen = false; |
---|
96 | 120 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
97 | 121 | |
---|
98 | 122 | static boolean textureon = true; |
---|
99 | 123 | static boolean LOCALTRANSFORM = false; |
---|
100 | | -private static boolean LIVE = false; |
---|
101 | 124 | static boolean FULLSCREEN = false; |
---|
102 | 125 | static boolean SUPPORT = true; |
---|
103 | | -static boolean CROWD = false; |
---|
104 | 126 | static boolean INERTIA = true; |
---|
105 | 127 | static boolean FAST = false; |
---|
106 | 128 | static boolean SLOWPOSE = false; |
---|
.. | .. |
---|
108 | 130 | |
---|
109 | 131 | static int tickcount = 0; // slow pose issue |
---|
110 | 132 | |
---|
| 133 | +static boolean BUTTONLESSWHEEL = false; |
---|
| 134 | +static boolean ZOOMBOXMODE = false; |
---|
111 | 135 | static boolean BOXMODE = false; |
---|
112 | 136 | static boolean IMAGEFLIP = false; |
---|
113 | 137 | static boolean SMOOTHFOCUS = false; |
---|
.. | .. |
---|
122 | 146 | static boolean OEIL = true; |
---|
123 | 147 | static boolean OEILONCE = false; // do oeilon then oeiloff |
---|
124 | 148 | static boolean LOOKAT = true; |
---|
125 | | -static boolean RANDOM = true; // false; |
---|
| 149 | +static boolean SWITCH = true; // false; |
---|
126 | 150 | static boolean HANDLES = false; // selection doesn't work!! |
---|
127 | 151 | static boolean PAINTMODE = false; |
---|
128 | 152 | |
---|
.. | .. |
---|
144 | 168 | |
---|
145 | 169 | |
---|
146 | 170 | // OPTIONS |
---|
147 | | - boolean Skinshader = true; |
---|
| 171 | + boolean Skinshader = false; // true; |
---|
148 | 172 | boolean cameraLight = false; |
---|
149 | 173 | boolean UVdebug = false; |
---|
150 | 174 | boolean Udebug = false; |
---|
.. | .. |
---|
153 | 177 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
154 | 178 | boolean anisotropy = true; |
---|
155 | 179 | boolean softshadow = true; // slower but better false; |
---|
156 | | - boolean opacityhalo = false; |
---|
| 180 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
157 | 181 | |
---|
158 | 182 | boolean macromode = false; |
---|
159 | 183 | |
---|
.. | .. |
---|
165 | 189 | defaultcaps.setAccumBlueBits(16); |
---|
166 | 190 | defaultcaps.setAccumAlphaBits(16); |
---|
167 | 191 | } |
---|
168 | | - static CameraPane theRenderer; |
---|
| 192 | + |
---|
| 193 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
169 | 194 | |
---|
| 195 | + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 196 | + { |
---|
| 197 | + try |
---|
| 198 | + { |
---|
| 199 | + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 200 | + } catch (IOException e) |
---|
| 201 | + { |
---|
| 202 | + System.out.println("NAME = " + name); |
---|
| 203 | + e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 204 | + return null; |
---|
| 205 | + } |
---|
| 206 | + } |
---|
| 207 | + |
---|
170 | 208 | void SetAsGLRenderer(boolean b) |
---|
171 | 209 | { |
---|
172 | 210 | isRenderer = b; |
---|
173 | | - theRenderer = this; |
---|
| 211 | + Globals.theRenderer = this; |
---|
| 212 | + } |
---|
| 213 | + |
---|
| 214 | + CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
| 215 | + { |
---|
| 216 | + super(defaultcaps, null, withcontext?glcontext:null, null); |
---|
| 217 | + |
---|
| 218 | + //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523)); |
---|
| 219 | + glcontext = getContext(); |
---|
| 220 | + |
---|
| 221 | + cameras = new Camera[2]; |
---|
| 222 | + targetLookAts = new cVector[2]; |
---|
| 223 | + |
---|
| 224 | + SetCamera(cam); |
---|
| 225 | + |
---|
| 226 | + // Warning: not used. |
---|
| 227 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
| 228 | + |
---|
| 229 | + object = o; |
---|
| 230 | + |
---|
| 231 | + setBackground(Color.white); |
---|
| 232 | + |
---|
| 233 | + addKeyListener(this); |
---|
| 234 | + addMouseListener(this); |
---|
| 235 | + addMouseMotionListener(this); |
---|
| 236 | + addMouseWheelListener(this); |
---|
| 237 | + //System.out.println("addGLEventListener: " + this); |
---|
| 238 | + addGLEventListener(this); |
---|
| 239 | + |
---|
| 240 | +// pingthread.start(); // may 2013 |
---|
174 | 241 | } |
---|
175 | 242 | |
---|
176 | 243 | static boolean AntialiasingEnabled() |
---|
.. | .. |
---|
178 | 245 | return CURRENTANTIALIAS > 0; |
---|
179 | 246 | } |
---|
180 | 247 | |
---|
181 | | - void ClearDepth() |
---|
| 248 | + /// INTERFACE |
---|
| 249 | + |
---|
| 250 | + public javax.media.opengl.GL GetGL0() |
---|
| 251 | + { |
---|
| 252 | + return null; |
---|
| 253 | + } |
---|
| 254 | + |
---|
| 255 | + public int GenList() |
---|
| 256 | + { |
---|
| 257 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 258 | + return gl.glGenLists(1); |
---|
| 259 | + } |
---|
| 260 | + |
---|
| 261 | + public void NewList(int id) |
---|
| 262 | + { |
---|
| 263 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 264 | + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 265 | + } |
---|
| 266 | + |
---|
| 267 | + public void CallList(int id) |
---|
| 268 | + { |
---|
| 269 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 270 | + gl.glCallList(id); |
---|
| 271 | + } |
---|
| 272 | + |
---|
| 273 | + public void EndList() |
---|
| 274 | + { |
---|
| 275 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 276 | + gl.glEndList(); |
---|
| 277 | + } |
---|
| 278 | + |
---|
| 279 | + public boolean IsBoxMode() |
---|
| 280 | + { |
---|
| 281 | + return BOXMODE; |
---|
| 282 | + } |
---|
| 283 | + |
---|
| 284 | + public boolean IsZoomBoxMode() |
---|
| 285 | + { |
---|
| 286 | + return ZOOMBOXMODE; |
---|
| 287 | + } |
---|
| 288 | + |
---|
| 289 | + public void ClearDepth() |
---|
182 | 290 | { |
---|
183 | 291 | GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT); |
---|
184 | 292 | } |
---|
185 | 293 | |
---|
186 | | - void DepthTest(boolean depthtest) |
---|
| 294 | + public void DepthTest(boolean depthtest) |
---|
187 | 295 | { |
---|
188 | 296 | if (depthtest) |
---|
189 | 297 | GetGL().glDepthFunc(GL.GL_LEQUAL); |
---|
.. | .. |
---|
191 | 299 | GetGL().glDepthFunc(GL.GL_ALWAYS); |
---|
192 | 300 | } |
---|
193 | 301 | |
---|
194 | | - void DepthWrite(boolean depthwrite) |
---|
| 302 | + public void DepthWrite(boolean depthwrite) |
---|
195 | 303 | { |
---|
196 | 304 | if (depthwrite) |
---|
197 | 305 | GetGL().glDepthMask(true); |
---|
.. | .. |
---|
199 | 307 | GetGL().glDepthMask(false); |
---|
200 | 308 | } |
---|
201 | 309 | |
---|
202 | | - void BackFaceCull(boolean bfc) |
---|
| 310 | + public void BackFaceCull(boolean bfc) |
---|
203 | 311 | { |
---|
204 | 312 | if (bfc) |
---|
205 | 313 | GetGL().glEnable(GetGL().GL_CULL_FACE); |
---|
206 | 314 | else |
---|
207 | 315 | GetGL().glDisable(GetGL().GL_CULL_FACE); |
---|
| 316 | + } |
---|
| 317 | + |
---|
| 318 | + public boolean BackFaceCullMode() |
---|
| 319 | + { |
---|
| 320 | + return this.CULLFACE; |
---|
| 321 | + } |
---|
| 322 | + |
---|
| 323 | + public boolean IsAmbientOcclusionOn() |
---|
| 324 | + { |
---|
| 325 | + return this.ambientOcclusion; |
---|
| 326 | + } |
---|
| 327 | + |
---|
| 328 | + public boolean IsDebugSelection() |
---|
| 329 | + { |
---|
| 330 | + return DEBUG_SELECTION; |
---|
| 331 | + } |
---|
| 332 | + |
---|
| 333 | + public boolean IsFrozen() |
---|
| 334 | + { |
---|
| 335 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
| 336 | + |
---|
| 337 | + return !selectmode && cameracount == 0; // != 0; |
---|
| 338 | + } |
---|
| 339 | + |
---|
| 340 | + // Currently in Globals |
---|
| 341 | + public int DrawMode() |
---|
| 342 | + { |
---|
| 343 | + return Globals.DrawMode(); |
---|
| 344 | + } |
---|
| 345 | + |
---|
| 346 | + public Camera EyeCamera() |
---|
| 347 | + { |
---|
| 348 | + return eyeCamera; |
---|
| 349 | + } |
---|
| 350 | + |
---|
| 351 | + public Camera LightCamera() |
---|
| 352 | + { |
---|
| 353 | + return lightCamera; |
---|
| 354 | + } |
---|
| 355 | + |
---|
| 356 | + public Camera ManipCamera() |
---|
| 357 | + { |
---|
| 358 | + return manipCamera; |
---|
| 359 | + } |
---|
| 360 | + |
---|
| 361 | + public Camera RenderCamera() |
---|
| 362 | + { |
---|
| 363 | + return renderCamera; |
---|
| 364 | + } |
---|
| 365 | + |
---|
| 366 | + public Camera[] Cameras() |
---|
| 367 | + { |
---|
| 368 | + return cameras; |
---|
| 369 | + } |
---|
| 370 | + |
---|
| 371 | + public void PushMaterial(Object3D obj, boolean selected) |
---|
| 372 | + { |
---|
| 373 | + CameraPane display = this; |
---|
| 374 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 375 | + cMaterial material = obj.material; |
---|
| 376 | + |
---|
| 377 | + if (material != null) |
---|
| 378 | + { |
---|
| 379 | + materialstack[materialdepth] = material; |
---|
| 380 | + selectedstack[materialdepth] = selected; |
---|
| 381 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 382 | + //System.out.println("material " + material); |
---|
| 383 | + //Applet3D.tracein(this, selected); |
---|
| 384 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 385 | + if (obj instanceof Camera) |
---|
| 386 | + { |
---|
| 387 | + display.options1[0] = material.shift; |
---|
| 388 | + //System.out.println("shift " + material.shift); |
---|
| 389 | + display.options1[1] = material.lightarea; |
---|
| 390 | + display.options1[2] = material.shadowbias; |
---|
| 391 | + display.options1[3] = material.aniso; |
---|
| 392 | + display.options1[4] = material.anisoV; |
---|
| 393 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 394 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 395 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 396 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 397 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
| 398 | + display.options2[0] = material.opacity; |
---|
| 399 | + display.options2[1] = material.diffuse; |
---|
| 400 | + display.options2[2] = material.factor; |
---|
| 401 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 402 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 403 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
| 404 | + |
---|
| 405 | + cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 406 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 407 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 408 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
| 409 | + display.options4[0] = material.cameralight/0.2f; |
---|
| 410 | + display.options4[1] = material.subsurface; |
---|
| 411 | + display.options4[2] = material.sheen; |
---|
| 412 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 413 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 414 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
| 415 | + |
---|
| 416 | + // if (display.CURRENTANTIALIAS > 0) |
---|
| 417 | + // display.options3[3] /= 4; |
---|
| 418 | + |
---|
| 419 | + /* |
---|
| 420 | + System.out.println("Focus = " + display.options1[0]); |
---|
| 421 | + System.out.println("Aperture = " + display.options1[1]); |
---|
| 422 | + System.out.println("ShadowBlur = " + display.options1[2]); |
---|
| 423 | + System.out.println("Antialiasing = " + display.options1[3]); |
---|
| 424 | + System.out.println("Fog = " + display.options2[0]); |
---|
| 425 | + System.out.println("Intensity = " + display.options2[1]); |
---|
| 426 | + System.out.println("Elevation = " + display.options2[2]); |
---|
| 427 | + /**/ |
---|
| 428 | + } else |
---|
| 429 | + { |
---|
| 430 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
| 431 | + } |
---|
| 432 | + } else |
---|
| 433 | + { |
---|
| 434 | + if (selected && CameraPane.flash) |
---|
| 435 | + { |
---|
| 436 | + display.modelParams4[1] = 100; |
---|
| 437 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 438 | + } |
---|
| 439 | + } |
---|
| 440 | + } |
---|
| 441 | + |
---|
| 442 | + public void PushMaterial2(Object3D obj, boolean selected) |
---|
| 443 | + { |
---|
| 444 | + CameraPane display = this; |
---|
| 445 | + cMaterial material = obj.material; |
---|
| 446 | + |
---|
| 447 | + if (material != null) |
---|
| 448 | + { |
---|
| 449 | + materialstack[materialdepth] = material; |
---|
| 450 | + selectedstack[materialdepth] = selected; |
---|
| 451 | + cStatic.objectstack[materialdepth++] = obj; |
---|
| 452 | + //System.out.println("material " + material); |
---|
| 453 | + //Applet3D.tracein("selected ", selected); |
---|
| 454 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 455 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
| 456 | + } |
---|
| 457 | + } |
---|
| 458 | + |
---|
| 459 | + public void PopMaterial(Object3D obj, boolean selected) |
---|
| 460 | + { |
---|
| 461 | + CameraPane display = this; |
---|
| 462 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 463 | + cMaterial material = obj.material; |
---|
| 464 | + |
---|
| 465 | + //if (parent != null && parent.GetMaterial() != null) |
---|
| 466 | + // parent.GetMaterial().Draw(display, parent.IsSelected(this)); |
---|
| 467 | + if (material != null) |
---|
| 468 | + { |
---|
| 469 | + materialdepth -= 1; |
---|
| 470 | + if (materialdepth > 0) |
---|
| 471 | + { |
---|
| 472 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 473 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
| 474 | + } |
---|
| 475 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 476 | + } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
| 477 | + { |
---|
| 478 | + display.modelParams4[1] = obj.GetMaterial().cameralight; |
---|
| 479 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 480 | + } |
---|
| 481 | + } |
---|
| 482 | + |
---|
| 483 | + public void PopMaterial2(Object3D obj) |
---|
| 484 | + { |
---|
| 485 | + CameraPane display = this; |
---|
| 486 | + cMaterial material = obj.material; |
---|
| 487 | + |
---|
| 488 | + if (material != null) |
---|
| 489 | + { |
---|
| 490 | + materialdepth -= 1; |
---|
| 491 | + if (materialdepth > 0) |
---|
| 492 | + { |
---|
| 493 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 494 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
| 495 | + } |
---|
| 496 | + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
| 497 | + //else |
---|
| 498 | + //material.Draw(display, false); |
---|
| 499 | + } |
---|
| 500 | + } |
---|
| 501 | + |
---|
| 502 | + public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face) |
---|
| 503 | + { |
---|
| 504 | + CameraPane display = this; |
---|
| 505 | + |
---|
| 506 | + if (pv.y == -10000 || |
---|
| 507 | + qv.y == -10000 || |
---|
| 508 | + rv.y == -10000) |
---|
| 509 | + return; |
---|
| 510 | + |
---|
| 511 | +// float b = f.nbiterations & 1; |
---|
| 512 | +// float g = (f.nbiterations>>1) & 1; |
---|
| 513 | +// float r = (f.nbiterations>>2) & 1; |
---|
| 514 | +// |
---|
| 515 | +// //if (f.weight == 10000) |
---|
| 516 | +// //{ |
---|
| 517 | +// // r = 1; g = b = 0; |
---|
| 518 | +// //} |
---|
| 519 | +// //else |
---|
| 520 | +// //{ |
---|
| 521 | +// // assert(f.weight < 10000); |
---|
| 522 | +// r = g = b = (float)bRep.FaceWeight(f)*100; |
---|
| 523 | +// if (r<0) |
---|
| 524 | +// assert(r>=0); |
---|
| 525 | +// //} |
---|
| 526 | + |
---|
| 527 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 528 | + |
---|
| 529 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
| 530 | + |
---|
| 531 | + //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
| 532 | + if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
| 533 | + { |
---|
| 534 | + //gl.glBegin(gl.GL_TRIANGLES); |
---|
| 535 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 536 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 537 | + ; |
---|
| 538 | + if (!hasnorm) |
---|
| 539 | + { |
---|
| 540 | + // System.out.println("Mesh normal"); |
---|
| 541 | + LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
| 542 | + LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
| 543 | + LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
| 544 | + LA.vecNormalize(obj.v2); |
---|
| 545 | + gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 546 | + } |
---|
| 547 | + |
---|
| 548 | + // P |
---|
| 549 | + float x = (float)pv.x; |
---|
| 550 | + float y = (float)pv.y; |
---|
| 551 | + float z = (float)pv.z; |
---|
| 552 | + |
---|
| 553 | + if (hasnorm) |
---|
| 554 | + { |
---|
| 555 | +// if (!pv.norm.normalized()) |
---|
| 556 | +// assert(pv.norm.normalized()); |
---|
| 557 | + |
---|
| 558 | + //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z); |
---|
| 559 | + float nx = (float)pv.norm.x; |
---|
| 560 | + float ny = (float)pv.norm.y; |
---|
| 561 | + float nz = (float)pv.norm.z; |
---|
| 562 | + |
---|
| 563 | + x += nx * obj.NORMALPUSH; |
---|
| 564 | + y += ny * obj.NORMALPUSH; |
---|
| 565 | + z += nz * obj.NORMALPUSH; |
---|
| 566 | + |
---|
| 567 | + gl.glNormal3f(nx, ny, nz); |
---|
| 568 | + } |
---|
| 569 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 570 | + SetColor(obj, pv); |
---|
| 571 | + //gl.glColor4f(r, g, b, 1); |
---|
| 572 | + //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1); |
---|
| 573 | + if (obj.flipV) |
---|
| 574 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 575 | + else |
---|
| 576 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 577 | + //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z); |
---|
| 578 | + |
---|
| 579 | + gl.glVertex3f(x, y, z); |
---|
| 580 | + |
---|
| 581 | + // Q |
---|
| 582 | + x = (float)qv.x; |
---|
| 583 | + y = (float)qv.y; |
---|
| 584 | + z = (float)qv.z; |
---|
| 585 | + |
---|
| 586 | +// Print(pv); |
---|
| 587 | + if (hasnorm) |
---|
| 588 | + { |
---|
| 589 | +// assert(qv.norm.normalized()); |
---|
| 590 | + //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z); |
---|
| 591 | + float nx = (float)qv.norm.x; |
---|
| 592 | + float ny = (float)qv.norm.y; |
---|
| 593 | + float nz = (float)qv.norm.z; |
---|
| 594 | + |
---|
| 595 | + x += nx * obj.NORMALPUSH; |
---|
| 596 | + y += ny * obj.NORMALPUSH; |
---|
| 597 | + z += nz * obj.NORMALPUSH; |
---|
| 598 | + |
---|
| 599 | + gl.glNormal3f(nx, ny, nz); |
---|
| 600 | + } |
---|
| 601 | + //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
| 602 | + // boolean locked = false; |
---|
| 603 | + // float eps = 0.1f; |
---|
| 604 | + // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 605 | + |
---|
| 606 | + // int dot = 0; //*/ (int)f.dot; |
---|
| 607 | + |
---|
| 608 | + // if ((dot&1) == 0) |
---|
| 609 | + // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 610 | + |
---|
| 611 | + // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 612 | + if (obj.flipV) |
---|
| 613 | + gl.glTexCoord2f((float) qv.s, 1-(float) qv.t); |
---|
| 614 | + else |
---|
| 615 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 616 | + // else |
---|
| 617 | + // { |
---|
| 618 | + // locked = true; |
---|
| 619 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 620 | + // } |
---|
| 621 | + gl.glColor4f(qv.AO, qv.AO, qv.AO, 1); |
---|
| 622 | + SetColor(obj, qv); |
---|
| 623 | + |
---|
| 624 | + gl.glVertex3f(x, y, z); |
---|
| 625 | + //gl.glColor4f(r, g, b, 1); |
---|
| 626 | + //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1); |
---|
| 627 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 628 | +// Print(qv); |
---|
| 629 | + |
---|
| 630 | + // R |
---|
| 631 | + x = (float)rv.x; |
---|
| 632 | + y = (float)rv.y; |
---|
| 633 | + z = (float)rv.z; |
---|
| 634 | + |
---|
| 635 | + if (hasnorm) |
---|
| 636 | + { |
---|
| 637 | +// assert(rv.norm.normalized()); |
---|
| 638 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 639 | + float nx = (float)rv.norm.x; |
---|
| 640 | + float ny = (float)rv.norm.y; |
---|
| 641 | + float nz = (float)rv.norm.z; |
---|
| 642 | + |
---|
| 643 | + x += nx * obj.NORMALPUSH; |
---|
| 644 | + y += ny * obj.NORMALPUSH; |
---|
| 645 | + z += nz * obj.NORMALPUSH; |
---|
| 646 | + |
---|
| 647 | + gl.glNormal3f(nx, ny, nz); |
---|
| 648 | + } |
---|
| 649 | + |
---|
| 650 | + // if ((dot&4) == 0) |
---|
| 651 | + // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 652 | + |
---|
| 653 | + // if (wrap || !locked && (dot&8) != 0) |
---|
| 654 | + if (obj.flipV) |
---|
| 655 | + gl.glTexCoord2f((float) rv.s, 1-(float) rv.t); |
---|
| 656 | + else |
---|
| 657 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 658 | + // else |
---|
| 659 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 660 | + |
---|
| 661 | + // f.dot = dot; |
---|
| 662 | + |
---|
| 663 | + gl.glColor4f(rv.AO, rv.AO, rv.AO, 1); |
---|
| 664 | + SetColor(obj, rv); |
---|
| 665 | + //gl.glColor4f(r, g, b, 1); |
---|
| 666 | + //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1); |
---|
| 667 | + //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z); |
---|
| 668 | + gl.glVertex3f(x, y, z); |
---|
| 669 | +// Print(rv); |
---|
| 670 | + //gl.glEnd(); |
---|
| 671 | + } |
---|
| 672 | + else |
---|
| 673 | + { |
---|
| 674 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 675 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 676 | + gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z); |
---|
| 677 | + |
---|
| 678 | + } |
---|
| 679 | + |
---|
| 680 | + if (false) // (attributes & WIREFRAME) != 0) |
---|
| 681 | + { |
---|
| 682 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 683 | + |
---|
| 684 | + gl.glBegin(gl.GL_LINE_LOOP); |
---|
| 685 | + gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z); |
---|
| 686 | + gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z); |
---|
| 687 | + gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z); |
---|
| 688 | + gl.glEnd(); |
---|
| 689 | + |
---|
| 690 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 691 | + } |
---|
| 692 | + } |
---|
| 693 | + |
---|
| 694 | + /** |
---|
| 695 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 696 | + * it's normals, colors, textures and vertices. |
---|
| 697 | + * |
---|
| 698 | + * @see Renderer#draw(TriMesh) |
---|
| 699 | + * @param tris |
---|
| 700 | + * the mesh to render. |
---|
| 701 | + */ |
---|
| 702 | + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 703 | + { |
---|
| 704 | + CameraPane display = this; |
---|
| 705 | + |
---|
| 706 | + float r = display.modelParams0[0]; |
---|
| 707 | + float g = display.modelParams0[1]; |
---|
| 708 | + float b = display.modelParams0[2]; |
---|
| 709 | + float opacity = display.modelParams5[1]; |
---|
| 710 | + |
---|
| 711 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 712 | + GL gl = display.GetGL(); // getGL(); |
---|
| 713 | + |
---|
| 714 | + FloatBuffer vertBuf = geo.vertBuf; |
---|
| 715 | + |
---|
| 716 | + int v = vertBuf.capacity(); |
---|
| 717 | + |
---|
| 718 | + int count = 0; |
---|
| 719 | + |
---|
| 720 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 721 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 722 | + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
| 723 | + for (int i=0; i<v/3; i++) |
---|
| 724 | + { |
---|
| 725 | + int index3 = i*3; |
---|
| 726 | + |
---|
| 727 | + if (geo.sizeBuf.get(index3+1) == 0) |
---|
| 728 | + continue; |
---|
| 729 | + |
---|
| 730 | + count++; |
---|
| 731 | + |
---|
| 732 | + int index4 = i*4; |
---|
| 733 | + |
---|
| 734 | + float tx = vertBuf.get(index3); |
---|
| 735 | + float ty = vertBuf.get(index3+1); |
---|
| 736 | + float tz = vertBuf.get(index3+2); |
---|
| 737 | + |
---|
| 738 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 739 | + // continue; |
---|
| 740 | + |
---|
| 741 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 742 | + gl.glPushMatrix(); |
---|
| 743 | + |
---|
| 744 | + float[] texmat = geo.texmat; |
---|
| 745 | + texmat[12] = texmat[13] = texmat[14] = i; |
---|
| 746 | + |
---|
| 747 | + gl.glMultMatrixf(texmat, 0); |
---|
| 748 | + |
---|
| 749 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 750 | + gl.glPushMatrix(); |
---|
| 751 | + |
---|
| 752 | + gl.glTranslatef(tx,ty,tz); |
---|
| 753 | + |
---|
| 754 | + if (rotate) |
---|
| 755 | + gl.glRotatef(i, 0, 1, 0); |
---|
| 756 | + |
---|
| 757 | + float size = geo.sizeBuf.get(index3) / 100; |
---|
| 758 | + gl.glScalef(size,size,size); |
---|
| 759 | + |
---|
| 760 | + float cr = geo.colorBuf.get(index4); |
---|
| 761 | + float cg = geo.colorBuf.get(index4+1); |
---|
| 762 | + float cb = geo.colorBuf.get(index4+2); |
---|
| 763 | + float ca = geo.colorBuf.get(index4+3); |
---|
| 764 | + |
---|
| 765 | + display.modelParams0[0] = r * cr; |
---|
| 766 | + display.modelParams0[1] = g * cg; |
---|
| 767 | + display.modelParams0[2] = b * cb; |
---|
| 768 | + |
---|
| 769 | + display.modelParams5[1] = opacity * ca; |
---|
| 770 | + |
---|
| 771 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 772 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 773 | + |
---|
| 774 | + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; |
---|
| 775 | + RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 776 | + |
---|
| 777 | +// gl.glColor4f(cr,cg,cb,ca); |
---|
| 778 | + // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 779 | + shape.Draw/*Node*/(display,null,selected,false); // blocked |
---|
| 780 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 781 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 782 | + gl.glPopMatrix(); |
---|
| 783 | + |
---|
| 784 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 785 | + gl.glPopMatrix(); |
---|
| 786 | + } |
---|
| 787 | + // gl.glScalef(1024,1024,1024); |
---|
| 788 | + if (!cf) |
---|
| 789 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 790 | + |
---|
| 791 | + display.modelParams0[0] = r; |
---|
| 792 | + display.modelParams0[1] = g; |
---|
| 793 | + display.modelParams0[2] = b; |
---|
| 794 | + |
---|
| 795 | + display.modelParams5[1] = opacity; |
---|
| 796 | + |
---|
| 797 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 798 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 799 | + |
---|
| 800 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 801 | + |
---|
| 802 | +// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
| 803 | + if (true) |
---|
| 804 | + return; |
---|
| 805 | + |
---|
| 806 | +//// if (!tris.predraw(this)) |
---|
| 807 | +//// { |
---|
| 808 | +//// return; |
---|
| 809 | +//// } |
---|
| 810 | +//// if (Debug.stats) |
---|
| 811 | +//// { |
---|
| 812 | +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
| 813 | +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
| 814 | +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
| 815 | +//// } |
---|
| 816 | +//// |
---|
| 817 | +//// if (tris.getDisplayListID() != -1) |
---|
| 818 | +//// { |
---|
| 819 | +//// renderDisplayList(tris); |
---|
| 820 | +//// return; |
---|
| 821 | +//// } |
---|
| 822 | +//// |
---|
| 823 | +//// if (!generatingDisplayList) |
---|
| 824 | +//// { |
---|
| 825 | +//// applyStates(tris.states, tris); |
---|
| 826 | +//// } |
---|
| 827 | +//// if (Debug.stats) |
---|
| 828 | +//// { |
---|
| 829 | +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
| 830 | +//// } |
---|
| 831 | +//// boolean transformed = doTransforms(tris); |
---|
| 832 | +// |
---|
| 833 | +// int glMode = GL.GL_TRIANGLES; |
---|
| 834 | +// switch (getMode()) |
---|
| 835 | +// { |
---|
| 836 | +// case Triangles: |
---|
| 837 | +// glMode = GL.GL_TRIANGLES; |
---|
| 838 | +// break; |
---|
| 839 | +// case Strip: |
---|
| 840 | +// glMode = GL.GL_TRIANGLE_STRIP; |
---|
| 841 | +// break; |
---|
| 842 | +// case Fan: |
---|
| 843 | +// glMode = GL.GL_TRIANGLE_FAN; |
---|
| 844 | +// break; |
---|
| 845 | +// } |
---|
| 846 | +// |
---|
| 847 | +// if (!predrawGeometry(gl)) |
---|
| 848 | +// { |
---|
| 849 | +// // make sure only the necessary indices are sent through on old |
---|
| 850 | +// // cards. |
---|
| 851 | +// IntBuffer indices = this.getIndexBuffer(); |
---|
| 852 | +// if (indices == null) |
---|
| 853 | +// { |
---|
| 854 | +// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
| 855 | +// } else |
---|
| 856 | +// { |
---|
| 857 | +// indices.rewind(); |
---|
| 858 | +// indices.limit(this.getMaxIndex()); |
---|
| 859 | +// |
---|
| 860 | +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
| 861 | +// |
---|
| 862 | +// indices.clear(); |
---|
| 863 | +// } |
---|
| 864 | +// } else |
---|
| 865 | +// { |
---|
| 866 | +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
| 867 | +// GL.GL_UNSIGNED_INT, 0); |
---|
| 868 | +// } |
---|
| 869 | +// |
---|
| 870 | +//// postdrawGeometry(tris); |
---|
| 871 | +//// if (transformed) |
---|
| 872 | +//// { |
---|
| 873 | +//// undoTransforms(tris); |
---|
| 874 | +//// } |
---|
| 875 | +//// |
---|
| 876 | +//// if (Debug.stats) |
---|
| 877 | +//// { |
---|
| 878 | +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
| 879 | +//// } |
---|
| 880 | +//// tris.postdraw(this); |
---|
| 881 | + } |
---|
| 882 | + |
---|
| 883 | + static Camera localcamera = new Camera(); |
---|
| 884 | + static cVector from = new cVector(); |
---|
| 885 | + static cVector to = new cVector(); |
---|
| 886 | + |
---|
| 887 | + public void PrepOcclusion(BoundaryRep br, double[][] transform) |
---|
| 888 | + { |
---|
| 889 | + CameraPane cp = this; |
---|
| 890 | + |
---|
| 891 | + Camera keep = cp.RenderCamera(); |
---|
| 892 | + cp.renderCamera = localcamera; |
---|
| 893 | + |
---|
| 894 | + if (br.trimmed) |
---|
| 895 | + { |
---|
| 896 | + float[] colors = new float[br.positions.length / 3]; |
---|
| 897 | + |
---|
| 898 | + int i3 = 0; |
---|
| 899 | + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) |
---|
| 900 | + { |
---|
| 901 | + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) |
---|
| 902 | + continue; |
---|
| 903 | + |
---|
| 904 | + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); |
---|
| 905 | + to.set(br.positions[i3] + br.normals[i3], |
---|
| 906 | + br.positions[i3 + 1] + br.normals[i3 + 1], |
---|
| 907 | + br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
| 908 | + LA.xformPos(from, transform, from); |
---|
| 909 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 910 | + localcamera.setAim(from, to); |
---|
| 911 | + |
---|
| 912 | + CameraPane.occlusionbuffer.display(); |
---|
| 913 | + |
---|
| 914 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 915 | + cp.display(); // debug |
---|
| 916 | + |
---|
| 917 | + colors[i] = cp.vertexOcclusion.r; |
---|
| 918 | + //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
| 919 | + //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
| 920 | + |
---|
| 921 | + if ((i % 100) == 0 && i != 0) |
---|
| 922 | + { |
---|
| 923 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 924 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 925 | + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); |
---|
| 926 | + } |
---|
| 927 | + } |
---|
| 928 | + |
---|
| 929 | + br.colors = colors; |
---|
| 930 | + } |
---|
| 931 | + else |
---|
| 932 | + { |
---|
| 933 | + for (int i = 0; i < br.VertexCount(); i++) |
---|
| 934 | + { |
---|
| 935 | + Vertex v = br.GetVertex(i); |
---|
| 936 | + |
---|
| 937 | + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
| 938 | + continue; |
---|
| 939 | + |
---|
| 940 | + from.set(v.x, v.y, v.z); |
---|
| 941 | + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
| 942 | + LA.xformPos(from, transform, from); |
---|
| 943 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 944 | + localcamera.setAim(from, to); |
---|
| 945 | + |
---|
| 946 | + CameraPane.occlusionbuffer.display(); |
---|
| 947 | + |
---|
| 948 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 949 | + cp.display(); // debug |
---|
| 950 | + |
---|
| 951 | + v.AO = cp.vertexOcclusion.r; |
---|
| 952 | + |
---|
| 953 | + if ((i % 100) == 0 && i != 0) |
---|
| 954 | + { |
---|
| 955 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 956 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 957 | + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); |
---|
| 958 | + } |
---|
| 959 | + } |
---|
| 960 | + } |
---|
| 961 | + |
---|
| 962 | + //System.out.println("done."); |
---|
| 963 | + |
---|
| 964 | + cp.renderCamera = keep; |
---|
| 965 | + } |
---|
| 966 | + |
---|
| 967 | + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 968 | + { |
---|
| 969 | + CameraPane display = this; |
---|
| 970 | + pointFlow.CreateHT(); |
---|
| 971 | + |
---|
| 972 | + float r = display.modelParams0[0]; |
---|
| 973 | + float g = display.modelParams0[1]; |
---|
| 974 | + float b = display.modelParams0[2]; |
---|
| 975 | + float opacity = display.modelParams5[1]; |
---|
| 976 | + |
---|
| 977 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 978 | + GL gl = display.GetGL(); // getGL(); |
---|
| 979 | + |
---|
| 980 | + int s = pointFlow.points.size(); |
---|
| 981 | + |
---|
| 982 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 983 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 984 | + |
---|
| 985 | + for (int i=s; --i>=0;) |
---|
| 986 | + //for (int i=0; i<s; i++) |
---|
| 987 | + { |
---|
| 988 | + cVector v = pointFlow.points.get(i); |
---|
| 989 | + |
---|
| 990 | + double mindist = Double.MAX_VALUE; |
---|
| 991 | + |
---|
| 992 | + double size = pointFlow.minimumSize; |
---|
| 993 | + |
---|
| 994 | + double distancenext = 0; |
---|
| 995 | + |
---|
| 996 | + if (i > 0) |
---|
| 997 | + { |
---|
| 998 | + cVector w = pointFlow.points.get(i-1); |
---|
| 999 | + |
---|
| 1000 | + double dist = w.distance(v); |
---|
| 1001 | + |
---|
| 1002 | + distancenext = dist; |
---|
| 1003 | + |
---|
| 1004 | + if (mindist > dist) |
---|
| 1005 | + { |
---|
| 1006 | + mindist = dist; |
---|
| 1007 | + size = mindist*pointFlow.resizefactor; |
---|
| 1008 | + } |
---|
| 1009 | + } |
---|
| 1010 | + |
---|
| 1011 | + if (i < s-1) |
---|
| 1012 | + { |
---|
| 1013 | + cVector w = pointFlow.points.get(i+1); |
---|
| 1014 | + |
---|
| 1015 | + double dist = w.distance(v); |
---|
| 1016 | + |
---|
| 1017 | + if (mindist > dist) |
---|
| 1018 | + { |
---|
| 1019 | + mindist = dist; |
---|
| 1020 | + size = mindist*pointFlow.resizefactor; |
---|
| 1021 | + } |
---|
| 1022 | + } |
---|
| 1023 | + |
---|
| 1024 | + if (size < pointFlow.minimumSize) |
---|
| 1025 | + size = pointFlow.minimumSize; |
---|
| 1026 | + if (size > pointFlow.maximumSize) |
---|
| 1027 | + size = pointFlow.maximumSize; |
---|
| 1028 | + |
---|
| 1029 | + double tx = v.x; |
---|
| 1030 | + double ty = v.y; |
---|
| 1031 | + double tz = v.z; |
---|
| 1032 | + |
---|
| 1033 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 1034 | + // continue; |
---|
| 1035 | + |
---|
| 1036 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1037 | + gl.glPushMatrix(); |
---|
| 1038 | + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; |
---|
| 1039 | + |
---|
| 1040 | + gl.glMultMatrixf(pointFlow.texmat, 0); |
---|
| 1041 | + |
---|
| 1042 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1043 | + gl.glPushMatrix(); |
---|
| 1044 | + |
---|
| 1045 | + gl.glTranslated(tx,ty,tz); |
---|
| 1046 | + |
---|
| 1047 | + gl.glScaled(size,size,size); |
---|
| 1048 | + |
---|
| 1049 | +// float cr = colorBuf.get(index4); |
---|
| 1050 | +// float cg = colorBuf.get(index4+1); |
---|
| 1051 | +// float cb = colorBuf.get(index4+2); |
---|
| 1052 | +// float ca = colorBuf.get(index4+3); |
---|
| 1053 | +// |
---|
| 1054 | +// display.modelParams0[0] = r * cr; |
---|
| 1055 | +// display.modelParams0[1] = g * cg; |
---|
| 1056 | +// display.modelParams0[2] = b * cb; |
---|
| 1057 | +// |
---|
| 1058 | +// display.modelParams5[1] = opacity * ca; |
---|
| 1059 | +// |
---|
| 1060 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1061 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1062 | +// |
---|
| 1063 | +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
| 1064 | +// RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 1065 | +// |
---|
| 1066 | +//// gl.glColor4f(cr,cg,cb,ca); |
---|
| 1067 | +// // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 1068 | + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); |
---|
| 1069 | + |
---|
| 1070 | + gl.glPopMatrix(); |
---|
| 1071 | + |
---|
| 1072 | + double step = size/4; // |
---|
| 1073 | + |
---|
| 1074 | + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) |
---|
| 1075 | + continue; |
---|
| 1076 | + |
---|
| 1077 | + int nbsteps = (int)(distancenext/step); |
---|
| 1078 | + |
---|
| 1079 | + step = distancenext/nbsteps; |
---|
| 1080 | + |
---|
| 1081 | + cVector next = pointFlow.points.get(i-1); |
---|
| 1082 | + |
---|
| 1083 | + tmp.set(next); |
---|
| 1084 | + tmp.sub(v); |
---|
| 1085 | + tmp.normalize(); |
---|
| 1086 | + tmp.mul(step); |
---|
| 1087 | + |
---|
| 1088 | + // calculate next size |
---|
| 1089 | + mindist = Double.MAX_VALUE; |
---|
| 1090 | + |
---|
| 1091 | + double nextsize = pointFlow.minimumSize; |
---|
| 1092 | + |
---|
| 1093 | + if (i > 1) |
---|
| 1094 | + { |
---|
| 1095 | + cVector w = pointFlow.points.get(i-2); |
---|
| 1096 | + |
---|
| 1097 | + double dist = w.distance(next); |
---|
| 1098 | + |
---|
| 1099 | + if (mindist > dist) |
---|
| 1100 | + { |
---|
| 1101 | + mindist = dist; |
---|
| 1102 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1103 | + } |
---|
| 1104 | + } |
---|
| 1105 | + |
---|
| 1106 | + double dist = v.distance(next); |
---|
| 1107 | + |
---|
| 1108 | + if (mindist > dist) |
---|
| 1109 | + { |
---|
| 1110 | + mindist = dist; |
---|
| 1111 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1112 | + } |
---|
| 1113 | + |
---|
| 1114 | + if (nextsize < pointFlow.minimumSize) |
---|
| 1115 | + nextsize = pointFlow.minimumSize; |
---|
| 1116 | + if (nextsize > pointFlow.maximumSize) |
---|
| 1117 | + nextsize = pointFlow.maximumSize; |
---|
| 1118 | + // |
---|
| 1119 | + |
---|
| 1120 | + double count = 0; |
---|
| 1121 | + |
---|
| 1122 | + while (distancenext > 0.000000001) // step |
---|
| 1123 | + { |
---|
| 1124 | + gl.glPushMatrix(); |
---|
| 1125 | + |
---|
| 1126 | + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); |
---|
| 1127 | + |
---|
| 1128 | + double K = count/nbsteps; |
---|
| 1129 | + |
---|
| 1130 | + double intersize = K*nextsize + (1-K)*size; |
---|
| 1131 | + |
---|
| 1132 | + gl.glScaled(intersize,intersize,intersize); |
---|
| 1133 | + |
---|
| 1134 | + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); |
---|
| 1135 | + |
---|
| 1136 | + count++; |
---|
| 1137 | + |
---|
| 1138 | + distancenext -= step; |
---|
| 1139 | + |
---|
| 1140 | + gl.glPopMatrix(); |
---|
| 1141 | + } |
---|
| 1142 | + |
---|
| 1143 | + if (count != nbsteps) |
---|
| 1144 | + assert(count == nbsteps); |
---|
| 1145 | + |
---|
| 1146 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 1147 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 1148 | + |
---|
| 1149 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1150 | + gl.glPopMatrix(); |
---|
| 1151 | + } |
---|
| 1152 | + |
---|
| 1153 | + if (!cf) |
---|
| 1154 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 1155 | + |
---|
| 1156 | +// display.modelParams0[0] = r; |
---|
| 1157 | +// display.modelParams0[1] = g; |
---|
| 1158 | +// display.modelParams0[2] = b; |
---|
| 1159 | +// |
---|
| 1160 | +// display.modelParams5[1] = opacity; |
---|
| 1161 | +// |
---|
| 1162 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1163 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1164 | + |
---|
| 1165 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1166 | + } |
---|
| 1167 | + |
---|
| 1168 | + public void DrawBox(cVector min, cVector max) |
---|
| 1169 | + { |
---|
| 1170 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1171 | + gl.glBegin(gl.GL_LINES); |
---|
| 1172 | + |
---|
| 1173 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1174 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1175 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1176 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1177 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1178 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1179 | + |
---|
| 1180 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1181 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1182 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1183 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1184 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1185 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1186 | + |
---|
| 1187 | + gl.glEnd(); |
---|
| 1188 | + } |
---|
| 1189 | + |
---|
| 1190 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1191 | + { |
---|
| 1192 | + int[] strips = bRep.getRawIndices(); |
---|
| 1193 | + |
---|
| 1194 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1195 | + |
---|
| 1196 | + // TRIANGLE STRIP ARRAY |
---|
| 1197 | + if (bRep.trimmed) |
---|
| 1198 | + { |
---|
| 1199 | + float[] v = bRep.getRawVertices(); |
---|
| 1200 | + float[] n = bRep.getRawNormals(); |
---|
| 1201 | + float[] c = bRep.getRawColors(); |
---|
| 1202 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1203 | + |
---|
| 1204 | + int count2 = 0; |
---|
| 1205 | + int count3 = 0; |
---|
| 1206 | + |
---|
| 1207 | + if (n.length > 0) |
---|
| 1208 | + { |
---|
| 1209 | + for (int i = 0; i < strips.length; i++) |
---|
| 1210 | + { |
---|
| 1211 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1212 | + |
---|
| 1213 | + /* |
---|
| 1214 | + boolean locked = false; |
---|
| 1215 | + float eps = 0.1f; |
---|
| 1216 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1217 | + |
---|
| 1218 | + int dot = 0; |
---|
| 1219 | + |
---|
| 1220 | + if ((dot&1) == 0) |
---|
| 1221 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1222 | + |
---|
| 1223 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1224 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1225 | + else |
---|
| 1226 | + { |
---|
| 1227 | + locked = true; |
---|
| 1228 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1229 | + } |
---|
| 1230 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1231 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1232 | + if (hasnorm) |
---|
| 1233 | + { |
---|
| 1234 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1235 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1236 | + } |
---|
| 1237 | + |
---|
| 1238 | + if ((dot&4) == 0) |
---|
| 1239 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1240 | + |
---|
| 1241 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1242 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1243 | + else |
---|
| 1244 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1245 | + |
---|
| 1246 | + f.dot = dot; |
---|
| 1247 | + */ |
---|
| 1248 | + |
---|
| 1249 | + if (!selectmode) |
---|
| 1250 | + { |
---|
| 1251 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1252 | + { |
---|
| 1253 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1254 | + } else |
---|
| 1255 | + { |
---|
| 1256 | + gl.glNormal3f(0, 0, 1); |
---|
| 1257 | + } |
---|
| 1258 | + |
---|
| 1259 | + if (c != null) |
---|
| 1260 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1261 | + { |
---|
| 1262 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1263 | + } |
---|
| 1264 | + } |
---|
| 1265 | + |
---|
| 1266 | + if (flipV) |
---|
| 1267 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1268 | + else |
---|
| 1269 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1270 | + |
---|
| 1271 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1272 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1273 | + |
---|
| 1274 | + count2 += 2; |
---|
| 1275 | + count3 += 3; |
---|
| 1276 | + if (!selectmode) |
---|
| 1277 | + { |
---|
| 1278 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1279 | + { |
---|
| 1280 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1281 | + } else |
---|
| 1282 | + { |
---|
| 1283 | + gl.glNormal3f(0, 0, 1); |
---|
| 1284 | + } |
---|
| 1285 | + if (c != null) |
---|
| 1286 | + { |
---|
| 1287 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1288 | + } |
---|
| 1289 | + } |
---|
| 1290 | + |
---|
| 1291 | + if (flipV) |
---|
| 1292 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1293 | + else |
---|
| 1294 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1295 | + |
---|
| 1296 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1297 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1298 | + |
---|
| 1299 | + count2 += 2; |
---|
| 1300 | + count3 += 3; |
---|
| 1301 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1302 | + { |
---|
| 1303 | + //gl.glTexCoord2d(...); |
---|
| 1304 | + if (!selectmode) |
---|
| 1305 | + { |
---|
| 1306 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1307 | + { |
---|
| 1308 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1309 | + } else |
---|
| 1310 | + { |
---|
| 1311 | + gl.glNormal3f(0, 0, 1); |
---|
| 1312 | + } |
---|
| 1313 | + if (c != null) |
---|
| 1314 | + { |
---|
| 1315 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1316 | + } |
---|
| 1317 | + } |
---|
| 1318 | + |
---|
| 1319 | + if (flipV) |
---|
| 1320 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1321 | + else |
---|
| 1322 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1323 | + |
---|
| 1324 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1325 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1326 | + |
---|
| 1327 | + count2 += 2; |
---|
| 1328 | + count3 += 3; |
---|
| 1329 | + } |
---|
| 1330 | + |
---|
| 1331 | + gl.glEnd(); |
---|
| 1332 | + } |
---|
| 1333 | + } |
---|
| 1334 | + |
---|
| 1335 | + assert count3 == v.length; |
---|
| 1336 | + } |
---|
| 1337 | + else // !trimmed |
---|
| 1338 | + { |
---|
| 1339 | + int count = 0; |
---|
| 1340 | + for (int i = 0; i < strips.length; i++) |
---|
| 1341 | + { |
---|
| 1342 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1343 | + |
---|
| 1344 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1345 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1346 | + |
---|
| 1347 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1348 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1349 | + |
---|
| 1350 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1351 | + { |
---|
| 1352 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1353 | + |
---|
| 1354 | + // if (j%2 == 0) |
---|
| 1355 | + // drawFace(p, q, r, display, null); |
---|
| 1356 | + // else |
---|
| 1357 | + // drawFace(p, r, q, display, null); |
---|
| 1358 | + |
---|
| 1359 | + // p = q; |
---|
| 1360 | + // q = r; |
---|
| 1361 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1362 | + } |
---|
| 1363 | + |
---|
| 1364 | + gl.glEnd(); |
---|
| 1365 | + } |
---|
| 1366 | + } |
---|
| 1367 | + } |
---|
| 1368 | + |
---|
| 1369 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1370 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1371 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1372 | + |
---|
| 1373 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1374 | + { |
---|
| 1375 | + GL gl = GetGL(); // getGL(); |
---|
| 1376 | + |
---|
| 1377 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1378 | + |
---|
| 1379 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1380 | + |
---|
| 1381 | + gl.glLineWidth(1); |
---|
| 1382 | + gl.glColor3f(1,1,1); |
---|
| 1383 | + gl.glBegin(gl.GL_LINES); |
---|
| 1384 | + double scale = 0; |
---|
| 1385 | + int count = 0; |
---|
| 1386 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1387 | + { |
---|
| 1388 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1389 | + if(s == 0) |
---|
| 1390 | + { |
---|
| 1391 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1392 | + } |
---|
| 1393 | + if (mesh.showsprings) |
---|
| 1394 | + { |
---|
| 1395 | + temp.set(spring.a.position); |
---|
| 1396 | + temp.add(spring.b.position); |
---|
| 1397 | + temp.mul(0.5); |
---|
| 1398 | + temp2.set(spring.a.position); |
---|
| 1399 | + temp2.sub(spring.b.position); |
---|
| 1400 | + temp2.mul(spring.restLength/2); |
---|
| 1401 | + temp.sub(temp2); |
---|
| 1402 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1403 | + temp.add(temp2); |
---|
| 1404 | + temp.add(temp2); |
---|
| 1405 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1406 | + } |
---|
| 1407 | + |
---|
| 1408 | + if (spring.isHandle) |
---|
| 1409 | + continue; |
---|
| 1410 | + |
---|
| 1411 | + //if (scale < spring.restLength) |
---|
| 1412 | + scale += spring.restLength; |
---|
| 1413 | + count++; |
---|
| 1414 | + } |
---|
| 1415 | + gl.glEnd(); |
---|
| 1416 | + |
---|
| 1417 | + if (count == 0) |
---|
| 1418 | + scale = 0.01; |
---|
| 1419 | + else |
---|
| 1420 | + scale /= count * 3; |
---|
| 1421 | + |
---|
| 1422 | + //scale = 0.25; |
---|
| 1423 | + |
---|
| 1424 | + if (mesh.ShowInfo()) |
---|
| 1425 | + { |
---|
| 1426 | + gl.glLineWidth(4); |
---|
| 1427 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1428 | + { |
---|
| 1429 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1430 | + if (node.mass == 0) |
---|
| 1431 | + continue; |
---|
| 1432 | + |
---|
| 1433 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1434 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1435 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1436 | + //temp.normalize(); |
---|
| 1437 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1438 | + gl.glBegin(gl.GL_LINES); |
---|
| 1439 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1440 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1441 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1442 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1443 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1444 | + gl.glEnd(); |
---|
| 1445 | + } |
---|
| 1446 | + |
---|
| 1447 | + gl.glLineWidth(8); |
---|
| 1448 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1449 | + { |
---|
| 1450 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1451 | + |
---|
| 1452 | + if (node.springs != null) |
---|
| 1453 | + { |
---|
| 1454 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1455 | + { |
---|
| 1456 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1457 | + |
---|
| 1458 | + int c = i+1; |
---|
| 1459 | + // c = node.springs.get(i).nbcopies; |
---|
| 1460 | + |
---|
| 1461 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1462 | + gl.glBegin(gl.GL_LINES); |
---|
| 1463 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1464 | + 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); |
---|
| 1465 | + gl.glEnd(); |
---|
| 1466 | + } |
---|
| 1467 | + } |
---|
| 1468 | + } |
---|
| 1469 | + |
---|
| 1470 | + gl.glLineWidth(1); |
---|
| 1471 | + } |
---|
| 1472 | + |
---|
| 1473 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1474 | + } |
---|
| 1475 | + |
---|
| 1476 | + /// INTERFACE |
---|
| 1477 | + |
---|
| 1478 | + public void StartTriangles() |
---|
| 1479 | + { |
---|
| 1480 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1481 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1482 | + } |
---|
| 1483 | + |
---|
| 1484 | + public void EndTriangles() |
---|
| 1485 | + { |
---|
| 1486 | + GetGL().glEnd(); |
---|
| 1487 | + } |
---|
| 1488 | + |
---|
| 1489 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1490 | + { |
---|
| 1491 | + if (!selectmode) |
---|
| 1492 | + { |
---|
| 1493 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1494 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1495 | + |
---|
| 1496 | + if (flipV) |
---|
| 1497 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1498 | + else |
---|
| 1499 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1500 | + } |
---|
| 1501 | + |
---|
| 1502 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1503 | + } |
---|
| 1504 | + |
---|
| 1505 | + float[] colorV = new float[4]; |
---|
| 1506 | + |
---|
| 1507 | + void SetColor(Object3D obj, Vertex p0) |
---|
| 1508 | + { |
---|
| 1509 | + CameraPane display = this; |
---|
| 1510 | + BoundaryRep bRep = obj.bRep; |
---|
| 1511 | + |
---|
| 1512 | + if (RENDERPROGRAM == 0) |
---|
| 1513 | + { |
---|
| 1514 | + float r = 0; |
---|
| 1515 | + if (bRep != null) |
---|
| 1516 | + { |
---|
| 1517 | + if (bRep.stripified) |
---|
| 1518 | + { |
---|
| 1519 | + r = 1; |
---|
| 1520 | + } |
---|
| 1521 | + } |
---|
| 1522 | + float g = 0; |
---|
| 1523 | + if (bRep != null) |
---|
| 1524 | + { |
---|
| 1525 | + if (bRep.trimmed) |
---|
| 1526 | + { |
---|
| 1527 | + g = 1; |
---|
| 1528 | + } |
---|
| 1529 | + } |
---|
| 1530 | + float b = 0; |
---|
| 1531 | + if (obj.support != null && obj.link2master) |
---|
| 1532 | + { |
---|
| 1533 | + b = 1; |
---|
| 1534 | + } |
---|
| 1535 | + display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO); |
---|
| 1536 | + return; |
---|
| 1537 | + } |
---|
| 1538 | + |
---|
| 1539 | + if (display.DrawMode() != CameraPane.SHADOW) |
---|
| 1540 | + return; |
---|
| 1541 | + |
---|
| 1542 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1543 | +// if (true) return; |
---|
| 1544 | +// float ao = p.AO; |
---|
| 1545 | +// |
---|
| 1546 | +// // if (ao == 0 && !bRep.AOdone) // transient problem! |
---|
| 1547 | +// // ao = 1; |
---|
| 1548 | +// |
---|
| 1549 | +// gl.glColor4f(ao, ao, ao, 1); |
---|
| 1550 | + |
---|
| 1551 | +// CameraPane.selectedpoint. |
---|
| 1552 | +// getAverage(cStatic.point1, true); |
---|
| 1553 | + if (CameraPane.pointflow == null) // !random) // live) |
---|
| 1554 | + { |
---|
| 1555 | + return; |
---|
| 1556 | + } |
---|
| 1557 | + |
---|
| 1558 | + cStatic.point1.set(0,0,0); |
---|
| 1559 | + LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1); |
---|
| 1560 | + |
---|
| 1561 | + cStatic.point1.sub(p0); |
---|
| 1562 | + |
---|
| 1563 | + |
---|
| 1564 | +// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta? |
---|
| 1565 | +// { |
---|
| 1566 | +// return; |
---|
| 1567 | +// } |
---|
| 1568 | + |
---|
| 1569 | + //if (true) |
---|
| 1570 | + if (cStatic.point1.dot(cStatic.point1) > 0.000001) |
---|
| 1571 | + { |
---|
| 1572 | + return; |
---|
| 1573 | + } |
---|
| 1574 | + |
---|
| 1575 | + if (false) // marked) |
---|
| 1576 | + { |
---|
| 1577 | + // debug rigging weights |
---|
| 1578 | + for (int object = 0; object < p0.vertexlinks.length; object++) |
---|
| 1579 | + { |
---|
| 1580 | + float weight = p0.weights[object] / p0.totalweight; |
---|
| 1581 | + |
---|
| 1582 | + // if (weight < 0.1) |
---|
| 1583 | + // { |
---|
| 1584 | + // assert(weight == 0); |
---|
| 1585 | + // continue; |
---|
| 1586 | + // } |
---|
| 1587 | + |
---|
| 1588 | + if (p0.vertexlinks[object] == -1) |
---|
| 1589 | + continue; |
---|
| 1590 | + |
---|
| 1591 | + Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]); |
---|
| 1592 | + |
---|
| 1593 | + int color = //1 << object; // |
---|
| 1594 | + //p.vertexlinks.length; |
---|
| 1595 | + obj.support.bRep.supports[p0.closestsupport].links[object]; |
---|
| 1596 | + colorV[2] += (color & 1) * weight; |
---|
| 1597 | + colorV[1] += ((color & 2) >> 1) * weight; |
---|
| 1598 | + colorV[0] += ((color & 4) >> 2) * weight; |
---|
| 1599 | + } |
---|
| 1600 | + } |
---|
| 1601 | + else |
---|
| 1602 | + { |
---|
| 1603 | + if (obj.drawingstarted) |
---|
| 1604 | + { |
---|
| 1605 | + // find next point |
---|
| 1606 | + if (bRep.GetVertex(0).faceindices == null) |
---|
| 1607 | + { |
---|
| 1608 | + bRep.InitFaceIndices(); |
---|
| 1609 | + } |
---|
| 1610 | + |
---|
| 1611 | + double ymin = p0.y; |
---|
| 1612 | + |
---|
| 1613 | + Vertex newp = p0; |
---|
| 1614 | + |
---|
| 1615 | + for (int fii = 0; fii < p0.faceindices.length; fii++) |
---|
| 1616 | + { |
---|
| 1617 | + int fi = p0.faceindices[fii]; |
---|
| 1618 | + |
---|
| 1619 | + if (fi == -1) |
---|
| 1620 | + break; |
---|
| 1621 | + |
---|
| 1622 | + Face f = bRep.GetFace(fi); |
---|
| 1623 | + |
---|
| 1624 | + Vertex p = bRep.GetVertex(f.p); |
---|
| 1625 | + Vertex q = bRep.GetVertex(f.q); |
---|
| 1626 | + Vertex r = bRep.GetVertex(f.r); |
---|
| 1627 | + |
---|
| 1628 | + int swap = (int)(Math.random()*3); |
---|
| 1629 | + |
---|
| 1630 | +// for (int s=swap; --s>=0;) |
---|
| 1631 | +// { |
---|
| 1632 | +// Vertex t = p; |
---|
| 1633 | +// p = q; |
---|
| 1634 | +// q = r; |
---|
| 1635 | +// r = t; |
---|
| 1636 | +// } |
---|
| 1637 | + if (ymin > p.y) |
---|
| 1638 | + { |
---|
| 1639 | + ymin = p.y; |
---|
| 1640 | + newp = p; |
---|
| 1641 | +// break; |
---|
| 1642 | + } |
---|
| 1643 | + if (ymin > q.y) |
---|
| 1644 | + { |
---|
| 1645 | + ymin = q.y; |
---|
| 1646 | + newp = q; |
---|
| 1647 | +// break; |
---|
| 1648 | + } |
---|
| 1649 | + if (ymin > r.y) |
---|
| 1650 | + { |
---|
| 1651 | + ymin = r.y; |
---|
| 1652 | + newp = r; |
---|
| 1653 | +// break; |
---|
| 1654 | + } |
---|
| 1655 | + } |
---|
| 1656 | + |
---|
| 1657 | + CameraPane.selectedpoint.toParent[3][0] = newp.x; |
---|
| 1658 | + CameraPane.selectedpoint.toParent[3][1] = newp.y; |
---|
| 1659 | + CameraPane.selectedpoint.toParent[3][2] = newp.z; |
---|
| 1660 | + |
---|
| 1661 | + obj.drawingstarted = false; |
---|
| 1662 | + |
---|
| 1663 | + // return; |
---|
| 1664 | + } |
---|
| 1665 | + |
---|
| 1666 | + if (false) // CameraPane.DRAW |
---|
| 1667 | + { |
---|
| 1668 | + p0.AO = colorV[0] = 2; |
---|
| 1669 | + colorV[1] = 2; |
---|
| 1670 | + colorV[2] = 2; |
---|
| 1671 | + } |
---|
| 1672 | + |
---|
| 1673 | + CameraPane.pointflow.add(p0); |
---|
| 1674 | + CameraPane.pointflow.Touch(); |
---|
| 1675 | + } |
---|
| 1676 | + |
---|
| 1677 | +// gl.glColor3f(colorV[0], colorV[1], colorV[2]); |
---|
| 1678 | +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1679 | +// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1680 | + } |
---|
| 1681 | + |
---|
| 1682 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
| 1683 | + { |
---|
| 1684 | + CameraPane display = this; |
---|
| 1685 | + //new Exception().printStackTrace(); |
---|
| 1686 | + |
---|
| 1687 | + if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW) |
---|
| 1688 | + { |
---|
| 1689 | + return; |
---|
| 1690 | + } |
---|
| 1691 | + |
---|
| 1692 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1693 | + |
---|
| 1694 | + //Color col = Color.getHSBColor(color,modulation,1); |
---|
| 1695 | + //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
| 1696 | + if (!material.multiply) |
---|
| 1697 | + { |
---|
| 1698 | + display.color = material.color; |
---|
| 1699 | + display.saturation = material.modulation; |
---|
| 1700 | + } |
---|
| 1701 | + else |
---|
| 1702 | + { |
---|
| 1703 | + display.color *= material.color*2; |
---|
| 1704 | + display.saturation *= material.modulation*2; |
---|
| 1705 | + } |
---|
| 1706 | + |
---|
| 1707 | + cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
| 1708 | + |
---|
| 1709 | + float[] colorV = Grafreed.colorV; |
---|
| 1710 | + |
---|
| 1711 | + /**/ |
---|
| 1712 | + if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
| 1713 | + { |
---|
| 1714 | + colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
| 1715 | + colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
| 1716 | + colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
| 1717 | + colorV[3] = 1; // material.opacity; |
---|
| 1718 | + |
---|
| 1719 | + gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
| 1720 | + //System.out.println("Opacity = " + opacity); |
---|
| 1721 | + |
---|
| 1722 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1723 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1724 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1725 | + |
---|
| 1726 | + float amb = material.ambient; |
---|
| 1727 | + if (amb < material.cameralight) |
---|
| 1728 | + { |
---|
| 1729 | + amb = material.cameralight; |
---|
| 1730 | + } |
---|
| 1731 | + colorV[0] = display.modelParams0[0] * material.diffuse * amb; |
---|
| 1732 | + colorV[1] = display.modelParams0[1] * material.diffuse * amb; |
---|
| 1733 | + colorV[2] = display.modelParams0[2] * material.diffuse * amb; |
---|
| 1734 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0); |
---|
| 1735 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1736 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 1737 | + |
---|
| 1738 | + /**/ |
---|
| 1739 | + colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular; |
---|
| 1740 | + colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular; |
---|
| 1741 | + colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular; |
---|
| 1742 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0); |
---|
| 1743 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1744 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0); |
---|
| 1745 | + colorV[0] = 10 / material.shininess; // 1/0.005f; |
---|
| 1746 | + //System.out.println("shininess = " + colorV[0]); |
---|
| 1747 | + if (colorV[0] > 128) |
---|
| 1748 | + { |
---|
| 1749 | + colorV[0] = 128; |
---|
| 1750 | + } |
---|
| 1751 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0); |
---|
| 1752 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0); |
---|
| 1753 | + /**/ |
---|
| 1754 | + } |
---|
| 1755 | + /**/ |
---|
| 1756 | + |
---|
| 1757 | + //selected = false; |
---|
| 1758 | + selected = selected && display.flash; |
---|
| 1759 | + |
---|
| 1760 | + //display.modelParams0[0] = 0; // pigment.r; |
---|
| 1761 | + //display.modelParams0[1] = 0; // pigment.g; |
---|
| 1762 | + //display.modelParams0[2] = 0; // pigment.b; |
---|
| 1763 | + if (!material.multiply) |
---|
| 1764 | + { |
---|
| 1765 | + display.modelParams0[3] = material.metalness; |
---|
| 1766 | + display.modelParams1[0] = material.diffuse; |
---|
| 1767 | + display.modelParams1[1] = material.specular; |
---|
| 1768 | + display.modelParams1[2] = 1 / material.shininess; |
---|
| 1769 | + display.modelParams1[3] = material.shift; |
---|
| 1770 | + display.modelParams2[0] = material.ambient; |
---|
| 1771 | + display.modelParams2[1] = material.lightarea; |
---|
| 1772 | + //System.out.println("light area = " + lightarea); |
---|
| 1773 | + display.modelParams2[2] = 1 / material.factor; // diffuseness |
---|
| 1774 | + display.modelParams2[3] = material.velvet; |
---|
| 1775 | + display.modelParams3[0] = material.sheen; |
---|
| 1776 | + display.modelParams3[1] = material.subsurface; |
---|
| 1777 | + display.modelParams3[2] = material.bump; // backlit |
---|
| 1778 | + display.modelParams3[3] = material.aniso; |
---|
| 1779 | + display.modelParams4[0] = material.anisoV; |
---|
| 1780 | + display.modelParams4[1] = selected ? 100 : material.cameralight; |
---|
| 1781 | + //System.out.println("selected = " + selected); |
---|
| 1782 | + display.modelParams4[2] = material.diffuseness; |
---|
| 1783 | + display.modelParams4[3] = material.shadow; |
---|
| 1784 | + display.modelParams5[0] = material.texture; |
---|
| 1785 | + display.modelParams5[1] = material.opacity; |
---|
| 1786 | + display.modelParams5[2] = material.fakedepth; |
---|
| 1787 | + display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10; |
---|
| 1788 | + } |
---|
| 1789 | + else |
---|
| 1790 | + { |
---|
| 1791 | + display.modelParams0[3] *= material.metalness*2; |
---|
| 1792 | + display.modelParams1[0] *= material.diffuse*2; |
---|
| 1793 | + display.modelParams1[1] *= material.specular*2; |
---|
| 1794 | + display.modelParams1[2] *= material.shininess*2; |
---|
| 1795 | + display.modelParams1[3] *= material.shift*2; |
---|
| 1796 | + display.modelParams2[0] *= material.ambient*2; |
---|
| 1797 | + display.modelParams2[1] *= material.lightarea*2; |
---|
| 1798 | + display.modelParams2[2] *= material.factor*2; |
---|
| 1799 | + display.modelParams2[3] *= material.velvet*2; |
---|
| 1800 | + display.modelParams3[0] *= material.sheen*2; |
---|
| 1801 | + display.modelParams3[1] *= material.subsurface*2; |
---|
| 1802 | + display.modelParams3[2] *= material.bump*2; |
---|
| 1803 | + display.modelParams3[3] *= material.aniso*2; |
---|
| 1804 | + display.modelParams4[0] *= material.anisoV*2; |
---|
| 1805 | + display.modelParams4[1] *= material.cameralight*2; |
---|
| 1806 | + //System.out.println("selected = " + selected); |
---|
| 1807 | + display.modelParams4[2] *= material.diffuseness*2; |
---|
| 1808 | + display.modelParams4[3] *= material.shadow*2; |
---|
| 1809 | + display.modelParams5[0] *= material.texture*2; |
---|
| 1810 | + display.modelParams5[1] *= material.opacity*2; |
---|
| 1811 | + display.modelParams5[2] *= material.fakedepth*2; |
---|
| 1812 | + display.modelParams5[3] *= material.shadowbias*2; |
---|
| 1813 | + } |
---|
| 1814 | + |
---|
| 1815 | + display.modelParams6[0] = 0; |
---|
| 1816 | + display.modelParams6[1] = 0; |
---|
| 1817 | + display.modelParams6[2] = 0; |
---|
| 1818 | + display.modelParams6[3] = 0; |
---|
| 1819 | + |
---|
| 1820 | + display.modelParams7[0] = 0; |
---|
| 1821 | + display.modelParams7[1] = 1000; |
---|
| 1822 | + display.modelParams7[2] = 0; |
---|
| 1823 | + display.modelParams7[3] = 0; |
---|
| 1824 | + |
---|
| 1825 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1826 | + |
---|
| 1827 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
| 1828 | + if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
| 1829 | + { |
---|
| 1830 | + display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
| 1831 | + display.modelParams6[1] = extparams[0].y / 1000.0f; // noise |
---|
| 1832 | + if (extparams.length > 1) |
---|
| 1833 | + { |
---|
| 1834 | + display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade |
---|
| 1835 | + display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough |
---|
| 1836 | + if (extparams.length > 2) |
---|
| 1837 | + { |
---|
| 1838 | + display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power |
---|
| 1839 | + float x = extparams[2].y / 1000.0f; |
---|
| 1840 | + //if (x == 0) |
---|
| 1841 | + // x = 1f; |
---|
| 1842 | + 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 |
---|
| 1843 | + if (extparams[2].y > 0) |
---|
| 1844 | + { |
---|
| 1845 | + //System.out.println("extparams[1].y = " + extparams[1].y); |
---|
| 1846 | + //System.out.println("extparams[2].y = " + extparams[2].y); |
---|
| 1847 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1848 | + } |
---|
| 1849 | + } |
---|
| 1850 | + } |
---|
| 1851 | + } |
---|
| 1852 | + |
---|
| 1853 | + //if (display.modelParams6[2] != 0) |
---|
| 1854 | + /* |
---|
| 1855 | + System.out.println("modelParams0[0] = " + display.modelParams0[0]); |
---|
| 1856 | + System.out.println("modelParams0[1] = " + display.modelParams0[1]); |
---|
| 1857 | + System.out.println("modelParams0[2] = " + display.modelParams0[2]); |
---|
| 1858 | + System.out.println("modelParams0[3] = " + display.modelParams0[3]); |
---|
| 1859 | + System.out.println("modelParams1[0] = " + display.modelParams1[0]); |
---|
| 1860 | + System.out.println("modelParams1[1] = " + display.modelParams1[1]); |
---|
| 1861 | + System.out.println("modelParams1[2] = " + display.modelParams1[2]); |
---|
| 1862 | + System.out.println("modelParams1[3] = " + display.modelParams1[3]); |
---|
| 1863 | + System.out.println("modelParams2[0] = " + display.modelParams2[0]); |
---|
| 1864 | + System.out.println("modelParams2[1] = " + display.modelParams2[1]); |
---|
| 1865 | + System.out.println("modelParams2[2] = " + display.modelParams2[2]); |
---|
| 1866 | + System.out.println("modelParams2[3] = " + display.modelParams2[3]); |
---|
| 1867 | + System.out.println("modelParams3[0] = " + display.modelParams3[0]); |
---|
| 1868 | + System.out.println("modelParams3[1] = " + display.modelParams3[1]); |
---|
| 1869 | + System.out.println("modelParams3[2] = " + display.modelParams3[2]); |
---|
| 1870 | + System.out.println("modelParams3[3] = " + display.modelParams3[3]); |
---|
| 1871 | + System.out.println("modelParams4[0] = " + display.modelParams4[0]); |
---|
| 1872 | + System.out.println("modelParams4[1] = " + display.modelParams4[1]); |
---|
| 1873 | + System.out.println("modelParams4[2] = " + display.modelParams4[2]); |
---|
| 1874 | + System.out.println("modelParams4[3] = " + display.modelParams4[3]); |
---|
| 1875 | + System.out.println("modelParams5[0] = " + display.modelParams5[0]); |
---|
| 1876 | + System.out.println("modelParams5[1] = " + display.modelParams5[1]); |
---|
| 1877 | + System.out.println("modelParams5[2] = " + display.modelParams5[2]); |
---|
| 1878 | + System.out.println("modelParams5[3] = " + display.modelParams5[3]); |
---|
| 1879 | + System.out.println("modelParams6[0] = " + display.modelParams6[0]); |
---|
| 1880 | + System.out.println("modelParams6[1] = " + display.modelParams6[1]); |
---|
| 1881 | + System.out.println("modelParams6[2] = " + display.modelParams6[2]); |
---|
| 1882 | + System.out.println("modelParams6[3] = " + display.modelParams6[3]); |
---|
| 1883 | + System.out.println("modelParams7[0] = " + display.modelParams7[0]); |
---|
| 1884 | + System.out.println("modelParams7[1] = " + display.modelParams7[1]); |
---|
| 1885 | + System.out.println("modelParams7[2] = " + display.modelParams7[2]); |
---|
| 1886 | + System.out.println("modelParams7[3] = " + display.modelParams7[3]); |
---|
| 1887 | + /**/ |
---|
| 1888 | + //assert (display.modelParams6[2] == 0); |
---|
| 1889 | + |
---|
| 1890 | + //System.out.println("noise power = " + display.modelParams7[0]); |
---|
| 1891 | + //System.out.println("shadowbias = " + shadowbias); |
---|
| 1892 | + |
---|
| 1893 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1894 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0); |
---|
| 1895 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0); |
---|
| 1896 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0); |
---|
| 1897 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 1898 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1899 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0); |
---|
| 1900 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0); |
---|
| 1901 | + |
---|
| 1902 | + int mode = display.FP_SHADER; |
---|
| 1903 | + |
---|
| 1904 | + if (material.aniso != material.anisoV || material.aniso > 0.002) |
---|
| 1905 | + { |
---|
| 1906 | + mode |= display.FP_ANISO; |
---|
| 1907 | + } |
---|
| 1908 | + |
---|
| 1909 | + display.EnableProgram(mode); |
---|
| 1910 | + |
---|
| 1911 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1912 | + |
---|
| 1913 | + if (!material.multiply) |
---|
| 1914 | + { |
---|
| 1915 | + if (Globals.drawMode == CameraPane.SHADOW) |
---|
| 1916 | + gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1); |
---|
| 1917 | + else |
---|
| 1918 | + gl.glDepthMask(material.opacity >= 0.99); |
---|
| 1919 | + } |
---|
208 | 1920 | } |
---|
209 | 1921 | |
---|
210 | 1922 | int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0; |
---|
.. | .. |
---|
225 | 1937 | currentGL.glMultMatrixd(model, 0); |
---|
226 | 1938 | } |
---|
227 | 1939 | |
---|
228 | | - void PushMatrix(double[][] matrix, int count) |
---|
| 1940 | + public void PushMatrix(double[][] matrix, int count) // INTERFACE |
---|
229 | 1941 | { |
---|
230 | 1942 | matrixdepth++; |
---|
231 | 1943 | // GrafreeD.tracein(matrix); |
---|
.. | .. |
---|
254 | 1966 | void PushMatrix(double[][] matrix) |
---|
255 | 1967 | { |
---|
256 | 1968 | // GrafreeD.tracein(matrix); |
---|
257 | | - PushMatrix(matrix,1); |
---|
| 1969 | + PushMatrix(matrix, 1); |
---|
258 | 1970 | } |
---|
259 | 1971 | |
---|
260 | 1972 | void PushMatrix() |
---|
.. | .. |
---|
270 | 1982 | |
---|
271 | 1983 | double[][] tmpmat = new double[4][4]; |
---|
272 | 1984 | |
---|
273 | | - void PopMatrix(double[][] inverse) |
---|
| 1985 | + public void PopMatrix(double[][] inverse) // INTERFACE |
---|
274 | 1986 | { |
---|
275 | 1987 | --matrixdepth; |
---|
276 | 1988 | |
---|
.. | .. |
---|
310 | 2022 | PushTextureMatrix(matrix, 1); |
---|
311 | 2023 | } |
---|
312 | 2024 | |
---|
313 | | - void PushTextureMatrix(double[][] matrix, int count) |
---|
| 2025 | + public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE |
---|
314 | 2026 | { |
---|
315 | 2027 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
316 | 2028 | |
---|
.. | .. |
---|
324 | 2036 | currentGL.glMatrixMode(GetGL().GL_MODELVIEW); |
---|
325 | 2037 | } |
---|
326 | 2038 | |
---|
327 | | - void PopTextureMatrix(double[][] inverse) |
---|
| 2039 | + public void PopTextureMatrix(double[][] inverse) // INTERFACE |
---|
328 | 2040 | { |
---|
329 | 2041 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
330 | 2042 | currentGL.glMatrixMode(GetGL().GL_TEXTURE); |
---|
.. | .. |
---|
340 | 2052 | switch(viewcode) |
---|
341 | 2053 | { |
---|
342 | 2054 | case 0: return "main"; |
---|
343 | | - case 1: return "one"; |
---|
344 | | - case 2: return "two"; |
---|
345 | | - case 3: return "three"; |
---|
| 2055 | + case 1: return "Red"; |
---|
| 2056 | + case 2: return "Green"; |
---|
| 2057 | + case 3: return "Blue"; |
---|
346 | 2058 | case 4: return "light"; |
---|
347 | 2059 | } |
---|
348 | 2060 | |
---|
.. | .. |
---|
351 | 2063 | |
---|
352 | 2064 | static int camerachangeframe; |
---|
353 | 2065 | |
---|
354 | | - boolean SetCamera(Camera cam) |
---|
| 2066 | + public boolean SetCamera(Camera cam) |
---|
355 | 2067 | { |
---|
356 | 2068 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
357 | 2069 | // return false; |
---|
358 | 2070 | |
---|
359 | | - if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount) |
---|
| 2071 | + if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount) |
---|
360 | 2072 | { |
---|
361 | 2073 | // check for last change |
---|
362 | | - if (framecount < camerachangeframe + 400) // 120 == 1 second |
---|
| 2074 | + if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second |
---|
363 | 2075 | { |
---|
364 | 2076 | // refuse the camera change |
---|
365 | 2077 | System.err.println("Camera " + cam + " REFUSED"); |
---|
.. | .. |
---|
367 | 2079 | } |
---|
368 | 2080 | } |
---|
369 | 2081 | |
---|
370 | | - camerachangeframe = framecount; |
---|
| 2082 | + camerachangeframe = Globals.framecount; |
---|
371 | 2083 | |
---|
372 | 2084 | cam.hAspect = -1; // Read only |
---|
373 | 2085 | |
---|
.. | .. |
---|
398 | 2110 | { |
---|
399 | 2111 | //System.err.println("Oeil on"); |
---|
400 | 2112 | TRACK = true; |
---|
401 | | -// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 2113 | +// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
402 | 2114 | // object.editWindow.ScreenFit(trackedobject); |
---|
403 | 2115 | //pingthread.StepToTarget(true); |
---|
404 | 2116 | } |
---|
.. | .. |
---|
407 | 2119 | { |
---|
408 | 2120 | //System.err.println("Oeil on"); |
---|
409 | 2121 | OEIL = true; |
---|
410 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
411 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2122 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
| 2123 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
412 | 2124 | //pingthread.StepToTarget(true); |
---|
413 | 2125 | } |
---|
414 | 2126 | |
---|
.. | .. |
---|
471 | 2183 | { |
---|
472 | 2184 | frozen ^= true; |
---|
473 | 2185 | // Weird... |
---|
474 | | - lighttouched = true; |
---|
| 2186 | + Globals.lighttouched = true; |
---|
475 | 2187 | } |
---|
476 | 2188 | |
---|
477 | 2189 | void ToggleDL() |
---|
478 | 2190 | { |
---|
479 | 2191 | 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 | 2192 | } |
---|
508 | 2193 | |
---|
509 | 2194 | void ToggleFullScreen() |
---|
.. | .. |
---|
513 | 2198 | |
---|
514 | 2199 | void ToggleCrowd() |
---|
515 | 2200 | { |
---|
516 | | - CROWD ^= true; |
---|
517 | | - } |
---|
518 | | - |
---|
519 | | - void ToggleInertia() |
---|
520 | | - { |
---|
521 | | - INERTIA ^= true; |
---|
| 2201 | + Globals.CROWD ^= true; |
---|
522 | 2202 | } |
---|
523 | 2203 | |
---|
524 | 2204 | void ToggleLocal() |
---|
.. | .. |
---|
526 | 2206 | LOCALTRANSFORM ^= true; |
---|
527 | 2207 | } |
---|
528 | 2208 | |
---|
529 | | - void ToggleFast() |
---|
| 2209 | + public void ToggleTexture() |
---|
| 2210 | + { |
---|
| 2211 | + textureon ^= true; |
---|
| 2212 | + } |
---|
| 2213 | + |
---|
| 2214 | + public void ToggleLive() |
---|
| 2215 | + { |
---|
| 2216 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
| 2217 | + |
---|
| 2218 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
| 2219 | + |
---|
| 2220 | + if (!Globals.isLIVE()) // save sound |
---|
| 2221 | + Grafreed.savesound = true; // wav.save(); |
---|
| 2222 | + // else |
---|
| 2223 | + repaint(); // start loop // may 2013 |
---|
| 2224 | + } |
---|
| 2225 | + |
---|
| 2226 | + public void ToggleSupport() |
---|
| 2227 | + { |
---|
| 2228 | + SUPPORT ^= true; |
---|
| 2229 | + } |
---|
| 2230 | + |
---|
| 2231 | + public void ToggleAbort() |
---|
| 2232 | + { |
---|
| 2233 | + ABORTMODE ^= true; |
---|
| 2234 | + } |
---|
| 2235 | + |
---|
| 2236 | + public void ToggleInertia() |
---|
| 2237 | + { |
---|
| 2238 | + INERTIA ^= true; |
---|
| 2239 | + } |
---|
| 2240 | + |
---|
| 2241 | + public void ToggleFast() |
---|
530 | 2242 | { |
---|
531 | 2243 | FAST ^= true; |
---|
532 | 2244 | } |
---|
533 | 2245 | |
---|
534 | | - void ToggleSlowPose() |
---|
| 2246 | + public void ToggleSlowPose() |
---|
535 | 2247 | { |
---|
536 | 2248 | SLOWPOSE ^= true; |
---|
537 | 2249 | } |
---|
538 | 2250 | |
---|
539 | | - void ToggleFootContact() |
---|
540 | | - { |
---|
541 | | - FOOTCONTACT ^= true; |
---|
542 | | - } |
---|
543 | | - |
---|
544 | | - void ToggleBoxMode() |
---|
| 2251 | + public void ToggleBoxMode() |
---|
545 | 2252 | { |
---|
546 | 2253 | BOXMODE ^= true; |
---|
547 | 2254 | } |
---|
548 | 2255 | |
---|
549 | | - void ToggleSmoothFocus() |
---|
| 2256 | + public void ToggleZoomBoxMode() |
---|
| 2257 | + { |
---|
| 2258 | + ZOOMBOXMODE ^= true; |
---|
| 2259 | + } |
---|
| 2260 | + |
---|
| 2261 | + public void ToggleSmoothFocus() |
---|
550 | 2262 | { |
---|
551 | 2263 | SMOOTHFOCUS ^= true; |
---|
552 | 2264 | } |
---|
553 | 2265 | |
---|
554 | | - void ToggleImageFlip() |
---|
| 2266 | + public void ToggleImageFlip() |
---|
555 | 2267 | { |
---|
556 | 2268 | IMAGEFLIP ^= true; |
---|
557 | 2269 | } |
---|
558 | 2270 | |
---|
559 | | - void ToggleSpeakerMocap() |
---|
| 2271 | + public void ToggleSpeakerMocap() |
---|
560 | 2272 | { |
---|
561 | 2273 | SPEAKERMOCAP ^= true; |
---|
562 | 2274 | } |
---|
563 | 2275 | |
---|
564 | | - void ToggleSpeakerCamera() |
---|
| 2276 | + public void ToggleSpeakerCamera() |
---|
565 | 2277 | { |
---|
566 | 2278 | SPEAKERCAMERA ^= true; |
---|
567 | 2279 | } |
---|
568 | 2280 | |
---|
569 | | - void ToggleSpeakerFocus() |
---|
| 2281 | + public void ToggleSpeakerFocus() |
---|
570 | 2282 | { |
---|
571 | 2283 | SPEAKERFOCUS ^= true; |
---|
572 | 2284 | } |
---|
573 | 2285 | |
---|
574 | | - void ToggleDebug() |
---|
575 | | - { |
---|
576 | | - DEBUG ^= true; |
---|
577 | | - } |
---|
578 | | - |
---|
579 | | - void ToggleFrustum() |
---|
| 2286 | + public void ToggleFrustum() |
---|
580 | 2287 | { |
---|
581 | 2288 | FRUSTUM ^= true; |
---|
582 | 2289 | } |
---|
583 | 2290 | |
---|
584 | | - void ToggleTrack() |
---|
| 2291 | + public void ToggleTrack() |
---|
585 | 2292 | { |
---|
586 | 2293 | TRACK ^= true; |
---|
587 | 2294 | if (TRACK) |
---|
.. | .. |
---|
600 | 2307 | repaint(); |
---|
601 | 2308 | } |
---|
602 | 2309 | |
---|
603 | | - void ToggleTrackOnce() |
---|
| 2310 | + public void ToggleTrackOnce() |
---|
604 | 2311 | { |
---|
605 | 2312 | TRACKONCE ^= true; |
---|
606 | 2313 | } |
---|
607 | 2314 | |
---|
608 | | - void ToggleShadowTrack() |
---|
| 2315 | + public void ToggleShadowTrack() |
---|
609 | 2316 | { |
---|
610 | 2317 | SHADOWTRACK ^= true; |
---|
611 | 2318 | repaint(); |
---|
612 | 2319 | } |
---|
613 | 2320 | |
---|
614 | | - void ToggleOeil() |
---|
| 2321 | + public void ToggleOeil() |
---|
615 | 2322 | { |
---|
616 | 2323 | OEIL ^= true; |
---|
617 | 2324 | } |
---|
618 | 2325 | |
---|
619 | | - void ToggleOeilOnce() |
---|
| 2326 | + public void ToggleOeilOnce() |
---|
620 | 2327 | { |
---|
621 | 2328 | OEILONCE ^= true; |
---|
| 2329 | + } |
---|
| 2330 | + |
---|
| 2331 | + void ToggleFootContact() |
---|
| 2332 | + { |
---|
| 2333 | + FOOTCONTACT ^= true; |
---|
| 2334 | + } |
---|
| 2335 | + |
---|
| 2336 | + void ToggleDebug() |
---|
| 2337 | + { |
---|
| 2338 | + Globals.DEBUG ^= true; |
---|
622 | 2339 | } |
---|
623 | 2340 | |
---|
624 | 2341 | void ToggleLookAt() |
---|
.. | .. |
---|
626 | 2343 | LOOKAT ^= true; |
---|
627 | 2344 | } |
---|
628 | 2345 | |
---|
629 | | - void ToggleRandom() |
---|
| 2346 | + void ToggleSwitch() |
---|
630 | 2347 | { |
---|
631 | | - RANDOM ^= true; |
---|
| 2348 | + SWITCH ^= true; |
---|
632 | 2349 | } |
---|
633 | 2350 | |
---|
634 | 2351 | void ToggleHandles() |
---|
.. | .. |
---|
636 | 2353 | HANDLES ^= true; |
---|
637 | 2354 | } |
---|
638 | 2355 | |
---|
| 2356 | + Object3D paintFolder; |
---|
| 2357 | + |
---|
639 | 2358 | void TogglePaint() |
---|
640 | 2359 | { |
---|
641 | 2360 | PAINTMODE ^= true; |
---|
642 | 2361 | paintcount = 0; |
---|
| 2362 | + |
---|
| 2363 | + if (PAINTMODE) |
---|
| 2364 | + { |
---|
| 2365 | + paintFolder = GetFolder(); |
---|
| 2366 | + } |
---|
643 | 2367 | } |
---|
644 | 2368 | |
---|
645 | 2369 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
672 | 2396 | //assert (cam.hAspect == 0); |
---|
673 | 2397 | cam.hAspect = 0; |
---|
674 | 2398 | 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 | 2399 | } |
---|
704 | 2400 | |
---|
705 | 2401 | private static void ApplyTransform(GL gl, Mat4f xform) |
---|
.. | .. |
---|
759 | 2455 | |
---|
760 | 2456 | GL currentGL; |
---|
761 | 2457 | |
---|
762 | | - GL GetGL() |
---|
| 2458 | + public GL GetGL() // INTERFACE |
---|
763 | 2459 | { |
---|
764 | 2460 | return currentGL; |
---|
765 | 2461 | } |
---|
766 | | - |
---|
| 2462 | + |
---|
| 2463 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2464 | + { |
---|
| 2465 | + Grafreed.Assert(texturedata != null); |
---|
| 2466 | + |
---|
| 2467 | + int width = texturedata.getWidth(); |
---|
| 2468 | + int height = texturedata.getHeight(); |
---|
| 2469 | + |
---|
| 2470 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2471 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2472 | + |
---|
| 2473 | + byte[] bytes = bytebuf.array(); |
---|
| 2474 | + |
---|
| 2475 | + return CreateBim(bytes, width, height); |
---|
| 2476 | + } |
---|
| 2477 | + |
---|
767 | 2478 | /**/ |
---|
768 | 2479 | class CacheTexture |
---|
769 | 2480 | { |
---|
.. | .. |
---|
772 | 2483 | |
---|
773 | 2484 | int resolution; |
---|
774 | 2485 | |
---|
775 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2486 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
776 | 2487 | { |
---|
777 | | - texture = tex; |
---|
| 2488 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2489 | + texturedata = texdata; |
---|
778 | 2490 | resolution = res; |
---|
779 | 2491 | } |
---|
780 | 2492 | } |
---|
781 | 2493 | /**/ |
---|
782 | 2494 | |
---|
783 | 2495 | // 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>(); |
---|
| 2496 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2497 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2498 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2499 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2500 | + |
---|
787 | 2501 | int pigmentdepth = 0; |
---|
788 | 2502 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
789 | 2503 | int bumpdepth = 0; |
---|
790 | 2504 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
791 | 2505 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
792 | 2506 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
793 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2507 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
794 | 2508 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
795 | 2509 | |
---|
796 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2510 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
797 | 2511 | { |
---|
798 | 2512 | TextureData texturedata = null; |
---|
799 | 2513 | |
---|
.. | .. |
---|
803 | 2517 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
804 | 2518 | getClass().getClassLoader().getResourceAsStream(name), |
---|
805 | 2519 | true, |
---|
806 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2520 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
807 | 2521 | } catch (java.io.IOException e) |
---|
808 | 2522 | { |
---|
809 | 2523 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
812 | 2526 | if (bump) |
---|
813 | 2527 | texturedata = ConvertBump(texturedata, false); |
---|
814 | 2528 | |
---|
815 | | - com.sun.opengl.util.texture.Texture texture = |
---|
816 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2529 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2530 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
817 | 2531 | |
---|
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); |
---|
| 2532 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2533 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
820 | 2534 | |
---|
821 | | - return texture; |
---|
| 2535 | + return texturedata; |
---|
| 2536 | + } |
---|
| 2537 | + |
---|
| 2538 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2539 | + { |
---|
| 2540 | + TextureData texturedata = null; |
---|
| 2541 | + |
---|
| 2542 | + try |
---|
| 2543 | + { |
---|
| 2544 | + texturedata = |
---|
| 2545 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2546 | + bim, |
---|
| 2547 | + true); |
---|
| 2548 | + } catch (Exception e) |
---|
| 2549 | + { |
---|
| 2550 | + throw new javax.media.opengl.GLException(e); |
---|
| 2551 | + } |
---|
| 2552 | + |
---|
| 2553 | + if (bump) |
---|
| 2554 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2555 | + |
---|
| 2556 | + return texturedata; |
---|
822 | 2557 | } |
---|
823 | 2558 | |
---|
824 | 2559 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
1891 | 3626 | |
---|
1892 | 3627 | System.out.println("LOADING TEXTURE : " + name); |
---|
1893 | 3628 | |
---|
| 3629 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3630 | + |
---|
1894 | 3631 | // |
---|
1895 | 3632 | if (false) // compressbit > 0) |
---|
1896 | 3633 | { |
---|
.. | .. |
---|
2000 | 3737 | */ |
---|
2001 | 3738 | TextureData ReduceTexture(TextureData texturedata, int resolution) // String name) |
---|
2002 | 3739 | { |
---|
| 3740 | + int pixelformat = texturedata.getPixelFormat(); |
---|
| 3741 | + |
---|
2003 | 3742 | int stride = 1; |
---|
2004 | | - if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE) |
---|
| 3743 | + if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE) |
---|
2005 | 3744 | stride = 3; |
---|
2006 | | - if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA) |
---|
| 3745 | + if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA) |
---|
2007 | 3746 | stride = 4; |
---|
2008 | 3747 | |
---|
2009 | 3748 | int width = texturedata.getWidth(); |
---|
.. | .. |
---|
2593 | 4332 | |
---|
2594 | 4333 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
2595 | 4334 | { |
---|
| 4335 | + new Exception().printStackTrace(); |
---|
2596 | 4336 | System.exit(0); |
---|
2597 | 4337 | com.sun.opengl.util.texture.Texture texture = null; |
---|
2598 | 4338 | |
---|
.. | .. |
---|
6269 | 8009 | return null; |
---|
6270 | 8010 | } |
---|
6271 | 8011 | |
---|
6272 | | - void ReleaseTextures(cTexture tex) |
---|
| 8012 | + public void ReleaseTextures(cTexture tex) // INTERFACE |
---|
6273 | 8013 | { |
---|
6274 | 8014 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6275 | 8015 | { |
---|
.. | .. |
---|
6286 | 8026 | String pigment = Object3D.GetPigment(tex); |
---|
6287 | 8027 | String bump = Object3D.GetBump(tex); |
---|
6288 | 8028 | |
---|
6289 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8029 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
6290 | 8030 | { |
---|
6291 | 8031 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
6292 | 8032 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
6301 | 8041 | pigment = null; |
---|
6302 | 8042 | } |
---|
6303 | 8043 | |
---|
6304 | | - ReleaseTexture(bump, true); |
---|
6305 | | - ReleaseTexture(pigment, false); |
---|
| 8044 | + ReleaseTexture(tex, true); |
---|
| 8045 | + ReleaseTexture(tex, false); |
---|
6306 | 8046 | } |
---|
6307 | 8047 | |
---|
6308 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8048 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
6309 | 8049 | { |
---|
6310 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 8050 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8051 | + { |
---|
| 8052 | + return; |
---|
| 8053 | + } |
---|
| 8054 | + |
---|
| 8055 | + if (tex == null) |
---|
| 8056 | + { |
---|
| 8057 | + ReleaseTexture(null, false); |
---|
| 8058 | + return; |
---|
| 8059 | + } |
---|
| 8060 | + |
---|
| 8061 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8062 | + |
---|
| 8063 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8064 | + { |
---|
| 8065 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8066 | + // System.out.println("; bump = " + bump); |
---|
| 8067 | + } |
---|
| 8068 | + |
---|
| 8069 | + if (pigment.equals("")) |
---|
| 8070 | + { |
---|
| 8071 | + pigment = null; |
---|
| 8072 | + } |
---|
| 8073 | + |
---|
| 8074 | + ReleaseTexture(tex, false); |
---|
| 8075 | + } |
---|
| 8076 | + |
---|
| 8077 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8078 | + { |
---|
| 8079 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8080 | + { |
---|
| 8081 | + return; |
---|
| 8082 | + } |
---|
| 8083 | + |
---|
| 8084 | + if (tex == null) |
---|
| 8085 | + { |
---|
| 8086 | + ReleaseTexture(null, true); |
---|
| 8087 | + return; |
---|
| 8088 | + } |
---|
| 8089 | + |
---|
| 8090 | + String bump = Object3D.GetBump(tex); |
---|
| 8091 | + |
---|
| 8092 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8093 | + { |
---|
| 8094 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8095 | + // System.out.println("; bump = " + bump); |
---|
| 8096 | + } |
---|
| 8097 | + |
---|
| 8098 | + if (bump.equals("")) |
---|
| 8099 | + { |
---|
| 8100 | + bump = null; |
---|
| 8101 | + } |
---|
| 8102 | + |
---|
| 8103 | + ReleaseTexture(tex, true); |
---|
| 8104 | + } |
---|
| 8105 | + |
---|
| 8106 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
| 8107 | + { |
---|
| 8108 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6311 | 8109 | ambientOcclusion ) // || !textureon) |
---|
6312 | 8110 | { |
---|
6313 | 8111 | return; |
---|
.. | .. |
---|
6316 | 8114 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
6317 | 8115 | |
---|
6318 | 8116 | if (tex != null) |
---|
6319 | | - texture = textures.get(tex); |
---|
| 8117 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
6320 | 8118 | |
---|
6321 | 8119 | // //assert( texture != null ); |
---|
6322 | 8120 | // if (texture == null) |
---|
.. | .. |
---|
6408 | 8206 | } |
---|
6409 | 8207 | } |
---|
6410 | 8208 | |
---|
6411 | | - /*boolean*/ void BindTextures(cTexture tex, int resolution) |
---|
| 8209 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
6412 | 8210 | { |
---|
6413 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 8211 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8212 | +// ambientOcclusion ) // || !textureon) |
---|
| 8213 | +// { |
---|
| 8214 | +// return; // false; |
---|
| 8215 | +// } |
---|
| 8216 | +// |
---|
| 8217 | +// if (tex == null) |
---|
| 8218 | +// { |
---|
| 8219 | +// BindTexture(null,false,resolution); |
---|
| 8220 | +// BindTexture(null,true,resolution); |
---|
| 8221 | +// return; |
---|
| 8222 | +// } |
---|
| 8223 | +// |
---|
| 8224 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8225 | +// String bump = Object3D.GetBump(tex); |
---|
| 8226 | +// |
---|
| 8227 | +// usedtextures.add(pigment); |
---|
| 8228 | +// usedtextures.add(bump); |
---|
| 8229 | +// |
---|
| 8230 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8231 | +// { |
---|
| 8232 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8233 | +// // System.out.println("; bump = " + bump); |
---|
| 8234 | +// } |
---|
| 8235 | +// |
---|
| 8236 | +// if (bump.equals("")) |
---|
| 8237 | +// { |
---|
| 8238 | +// bump = null; |
---|
| 8239 | +// } |
---|
| 8240 | +// if (pigment.equals("")) |
---|
| 8241 | +// { |
---|
| 8242 | +// pigment = null; |
---|
| 8243 | +// } |
---|
| 8244 | +// |
---|
| 8245 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8246 | +// BindTexture(pigment, false, resolution); |
---|
| 8247 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8248 | +// BindTexture(bump, true, resolution); |
---|
| 8249 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8250 | +// |
---|
| 8251 | +// return; // true; |
---|
| 8252 | + |
---|
| 8253 | + BindPigmentTexture(tex, resolution); |
---|
| 8254 | + BindBumpTexture(tex, resolution); |
---|
| 8255 | + } |
---|
| 8256 | + |
---|
| 8257 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8258 | + { |
---|
| 8259 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6414 | 8260 | ambientOcclusion ) // || !textureon) |
---|
6415 | 8261 | { |
---|
6416 | 8262 | return; // false; |
---|
.. | .. |
---|
6419 | 8265 | if (tex == null) |
---|
6420 | 8266 | { |
---|
6421 | 8267 | BindTexture(null,false,resolution); |
---|
6422 | | - BindTexture(null,true,resolution); |
---|
6423 | 8268 | return; |
---|
6424 | 8269 | } |
---|
6425 | 8270 | |
---|
6426 | 8271 | String pigment = Object3D.GetPigment(tex); |
---|
| 8272 | + |
---|
| 8273 | + usedtextures.add(tex); |
---|
| 8274 | + |
---|
| 8275 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8276 | + { |
---|
| 8277 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8278 | + // System.out.println("; bump = " + bump); |
---|
| 8279 | + } |
---|
| 8280 | + |
---|
| 8281 | + if (pigment.equals("")) |
---|
| 8282 | + { |
---|
| 8283 | + pigment = null; |
---|
| 8284 | + } |
---|
| 8285 | + |
---|
| 8286 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8287 | + BindTexture(tex, false, resolution); |
---|
| 8288 | + } |
---|
| 8289 | + |
---|
| 8290 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8291 | + { |
---|
| 8292 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8293 | + ambientOcclusion ) // || !textureon) |
---|
| 8294 | + { |
---|
| 8295 | + return; // false; |
---|
| 8296 | + } |
---|
| 8297 | + |
---|
| 8298 | + if (tex == null) |
---|
| 8299 | + { |
---|
| 8300 | + BindTexture(null,true,resolution); |
---|
| 8301 | + return; |
---|
| 8302 | + } |
---|
| 8303 | + |
---|
6427 | 8304 | String bump = Object3D.GetBump(tex); |
---|
6428 | 8305 | |
---|
6429 | | - usedtextures.put(pigment, pigment); |
---|
6430 | | - usedtextures.put(bump, bump); |
---|
| 8306 | + usedtextures.add(tex); |
---|
6431 | 8307 | |
---|
6432 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8308 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
6433 | 8309 | { |
---|
6434 | 8310 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
6435 | 8311 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
6439 | 8315 | { |
---|
6440 | 8316 | bump = null; |
---|
6441 | 8317 | } |
---|
6442 | | - if (pigment.equals("")) |
---|
6443 | | - { |
---|
6444 | | - pigment = null; |
---|
6445 | | - } |
---|
6446 | 8318 | |
---|
6447 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
6448 | | - BindTexture(pigment, false, resolution); |
---|
6449 | 8319 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
6450 | | - BindTexture(bump, true, resolution); |
---|
| 8320 | + BindTexture(tex, true, resolution); |
---|
6451 | 8321 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
6452 | | - |
---|
6453 | | - return; // true; |
---|
6454 | 8322 | } |
---|
6455 | 8323 | |
---|
6456 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8324 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8325 | + |
---|
| 8326 | + private boolean FileExists(String tex) |
---|
6457 | 8327 | { |
---|
6458 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8328 | + if (missingTextures.contains(tex)) |
---|
| 8329 | + { |
---|
| 8330 | + return false; |
---|
| 8331 | + } |
---|
| 8332 | + |
---|
| 8333 | + boolean fileExists = new File(tex).exists(); |
---|
| 8334 | + |
---|
| 8335 | + if (!fileExists) |
---|
| 8336 | + { |
---|
| 8337 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8338 | + missingTextures.add(tex); |
---|
| 8339 | + } |
---|
| 8340 | + |
---|
| 8341 | + return fileExists; |
---|
| 8342 | + } |
---|
| 8343 | + |
---|
| 8344 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
| 8345 | + { |
---|
| 8346 | + CacheTexture texturecache = null; |
---|
6459 | 8347 | |
---|
6460 | 8348 | if (tex != null) |
---|
6461 | 8349 | { |
---|
6462 | | - String texname = tex; |
---|
| 8350 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8351 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
6463 | 8352 | |
---|
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; |
---|
| 8353 | + if (texname.equals("") && texdata == null) |
---|
| 8354 | + { |
---|
| 8355 | + return null; |
---|
| 8356 | + } |
---|
| 8357 | + |
---|
| 8358 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8359 | + |
---|
| 8360 | +// String[] split = tex.split("Textures"); |
---|
| 8361 | +// if (split.length > 1) |
---|
| 8362 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8363 | +// else |
---|
| 8364 | +// if (!texname.startsWith("/")) |
---|
| 8365 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8366 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
| 8367 | + { |
---|
| 8368 | + texname = fallbackTextureName; |
---|
| 8369 | + } |
---|
6470 | 8370 | |
---|
6471 | 8371 | if (CACHETEXTURE) |
---|
6472 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
6473 | | - |
---|
6474 | | - TextureData texturedata = null; |
---|
6475 | | - |
---|
6476 | | - if (texture == null || texture.resolution < resolution) |
---|
6477 | 8372 | { |
---|
6478 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8373 | + if (texdata == null) |
---|
| 8374 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8375 | + else |
---|
| 8376 | + texturecache = bimtextures.get(texdata); |
---|
| 8377 | + } |
---|
| 8378 | + |
---|
| 8379 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8380 | + { |
---|
| 8381 | + TextureData texturedata = null; |
---|
| 8382 | + |
---|
| 8383 | + if (texdata != null && textureon) |
---|
| 8384 | + { |
---|
| 8385 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8386 | + |
---|
| 8387 | + try |
---|
| 8388 | + { |
---|
| 8389 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8390 | + } |
---|
| 8391 | + catch (Exception e) |
---|
| 8392 | + { |
---|
| 8393 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8394 | + } |
---|
| 8395 | + |
---|
| 8396 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8397 | + bimtextures.put(texdata, texturecache); |
---|
| 8398 | + |
---|
| 8399 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8400 | + |
---|
| 8401 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8402 | + //bim2 = bim; |
---|
| 8403 | + } |
---|
| 8404 | + else |
---|
| 8405 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
6479 | 8406 | { |
---|
6480 | 8407 | assert(!bump); |
---|
6481 | 8408 | // if (bump) |
---|
.. | .. |
---|
6486 | 8413 | // } |
---|
6487 | 8414 | // else |
---|
6488 | 8415 | // { |
---|
6489 | | - texture = textures.get(tex); |
---|
6490 | | - if (texture == null) |
---|
| 8416 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8417 | + if (texturecache == null) |
---|
6491 | 8418 | { |
---|
6492 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8419 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
6493 | 8420 | } |
---|
| 8421 | + else |
---|
| 8422 | + new Exception().printStackTrace(); |
---|
6494 | 8423 | // } |
---|
6495 | 8424 | } else |
---|
6496 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8425 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
6497 | 8426 | { |
---|
6498 | 8427 | assert(bump); |
---|
6499 | | - texture = textures.get(tex); |
---|
6500 | | - if (texture == null) |
---|
6501 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8428 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8429 | + if (texturecache == null) |
---|
| 8430 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8431 | + else |
---|
| 8432 | + new Exception().printStackTrace(); |
---|
6502 | 8433 | } else |
---|
6503 | 8434 | { |
---|
6504 | 8435 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
6506 | 8437 | // texture = GetResourceTexture("default.png"); |
---|
6507 | 8438 | //} else |
---|
6508 | 8439 | //{ |
---|
6509 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8440 | + if (texname.endsWith("WHITE_NOISE")) |
---|
6510 | 8441 | { |
---|
6511 | | - texture = textures.get(tex); |
---|
6512 | | - if (texture == null) |
---|
6513 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8442 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8443 | + if (texturecache == null) |
---|
| 8444 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8445 | + else |
---|
| 8446 | + new Exception().printStackTrace(); |
---|
| 8447 | + } else |
---|
| 8448 | + { |
---|
| 8449 | + if (texname.startsWith("@")) |
---|
| 8450 | + { |
---|
| 8451 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8452 | + if (texturecache == null) |
---|
| 8453 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
| 8454 | + else |
---|
| 8455 | + new Exception().printStackTrace(); |
---|
6514 | 8456 | } else |
---|
6515 | 8457 | { |
---|
6516 | 8458 | if (textureon) |
---|
.. | .. |
---|
6535 | 8477 | } |
---|
6536 | 8478 | |
---|
6537 | 8479 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
6538 | | - if (!new File(cachename).exists()) |
---|
| 8480 | + if (!FileExists(cachename)) |
---|
6539 | 8481 | cachename = texname; |
---|
6540 | 8482 | else |
---|
6541 | 8483 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
6557 | 8499 | } |
---|
6558 | 8500 | |
---|
6559 | 8501 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
6560 | | - if (!new File(cachename).exists()) |
---|
| 8502 | + if (!FileExists(cachename)) |
---|
6561 | 8503 | cachename = texname; |
---|
6562 | 8504 | else |
---|
6563 | 8505 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
6566 | 8508 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
6567 | 8509 | |
---|
6568 | 8510 | |
---|
6569 | | - if (texturedata != null) |
---|
6570 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8511 | + if (texturedata == null) |
---|
| 8512 | + throw new Exception(); |
---|
| 8513 | + |
---|
| 8514 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
6571 | 8515 | //texture = GetTexture(tex, bump); |
---|
6572 | 8516 | } |
---|
| 8517 | + } |
---|
6573 | 8518 | } |
---|
6574 | 8519 | //} |
---|
6575 | 8520 | } |
---|
6576 | 8521 | |
---|
6577 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8522 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
6578 | 8523 | { |
---|
6579 | 8524 | //return false; |
---|
6580 | 8525 | |
---|
6581 | 8526 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
6582 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8527 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
6583 | 8528 | { |
---|
6584 | 8529 | // String ext = "_highres"; |
---|
6585 | 8530 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
6596 | 8541 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
6597 | 8542 | if (!cachefile.exists()) |
---|
6598 | 8543 | { |
---|
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)) |
---|
| 8544 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
6608 | 8545 | { |
---|
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); |
---|
| 8546 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8547 | + |
---|
6639 | 8548 | ImageWriter writer = null; |
---|
6640 | 8549 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
6641 | 8550 | if (iter.hasNext()) { |
---|
6642 | 8551 | writer = (ImageWriter)iter.next(); |
---|
6643 | 8552 | } |
---|
6644 | | - float compressionQuality = 0.9f; |
---|
| 8553 | + |
---|
| 8554 | + float compressionQuality = 0.85f; |
---|
6645 | 8555 | try |
---|
6646 | 8556 | { |
---|
6647 | 8557 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
6658 | 8568 | } |
---|
6659 | 8569 | } |
---|
6660 | 8570 | } |
---|
6661 | | - |
---|
| 8571 | + |
---|
| 8572 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8573 | + |
---|
6662 | 8574 | //System.out.println("Texture = " + tex); |
---|
6663 | | - if (textures.containsKey(texname)) |
---|
| 8575 | + if (textures.containsKey(tex)) |
---|
6664 | 8576 | { |
---|
6665 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8577 | + CacheTexture thetex = textures.get(tex); |
---|
6666 | 8578 | thetex.texture.disable(); |
---|
6667 | 8579 | thetex.texture.dispose(); |
---|
6668 | | - textures.remove(texname); |
---|
| 8580 | + textures.remove(tex); |
---|
6669 | 8581 | } |
---|
6670 | 8582 | |
---|
6671 | | - texture.texturedata = texturedata; |
---|
6672 | | - textures.put(texname, texture); |
---|
| 8583 | + //texture.texturedata = texturedata; |
---|
| 8584 | + textures.put(tex, texturecache); |
---|
6673 | 8585 | |
---|
6674 | 8586 | // newtex = true; |
---|
6675 | 8587 | } |
---|
.. | .. |
---|
6685 | 8597 | } |
---|
6686 | 8598 | } |
---|
6687 | 8599 | |
---|
6688 | | - return texture; |
---|
| 8600 | + return texturecache; |
---|
6689 | 8601 | } |
---|
6690 | 8602 | |
---|
6691 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8603 | + static void EmbedTextures(cTexture tex) |
---|
| 8604 | + { |
---|
| 8605 | + if (tex.pigmentdata == null) |
---|
| 8606 | + { |
---|
| 8607 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8608 | + |
---|
| 8609 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8610 | + |
---|
| 8611 | + if (texturecache != null) |
---|
| 8612 | + { |
---|
| 8613 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8614 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8615 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8616 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8617 | + ; |
---|
| 8618 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8619 | + } |
---|
| 8620 | + } |
---|
| 8621 | + |
---|
| 8622 | + if (tex.bumpdata == null) |
---|
| 8623 | + { |
---|
| 8624 | + //String texname = Object3D.GetBump(tex); |
---|
| 8625 | + |
---|
| 8626 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8627 | + |
---|
| 8628 | + if (texturecache != null) |
---|
| 8629 | + { |
---|
| 8630 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8631 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8632 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8633 | + } |
---|
| 8634 | + } |
---|
| 8635 | + } |
---|
| 8636 | + |
---|
| 8637 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
6692 | 8638 | { |
---|
6693 | 8639 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
6694 | 8640 | |
---|
.. | .. |
---|
6706 | 8652 | return texture!=null?texture.texture:null; |
---|
6707 | 8653 | } |
---|
6708 | 8654 | |
---|
6709 | | - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8655 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
6710 | 8656 | { |
---|
6711 | 8657 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
6712 | 8658 | |
---|
6713 | 8659 | return texture!=null?texture.texturedata:null; |
---|
6714 | 8660 | } |
---|
6715 | 8661 | |
---|
6716 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8662 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
6717 | 8663 | { |
---|
6718 | 8664 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6719 | 8665 | { |
---|
6720 | 8666 | return false; |
---|
6721 | 8667 | } |
---|
6722 | 8668 | |
---|
6723 | | - boolean newtex = false; |
---|
| 8669 | + //boolean newtex = false; |
---|
6724 | 8670 | |
---|
6725 | 8671 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
6726 | 8672 | |
---|
.. | .. |
---|
6752 | 8698 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
6753 | 8699 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
6754 | 8700 | |
---|
6755 | | - return newtex; |
---|
| 8701 | + return true; // Warning: not used. |
---|
6756 | 8702 | } |
---|
6757 | 8703 | |
---|
| 8704 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8705 | + { |
---|
| 8706 | + try |
---|
| 8707 | + { |
---|
| 8708 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8709 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8710 | + ImageWriter writer = writers.next(); |
---|
| 8711 | + |
---|
| 8712 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8713 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8714 | + param.setCompressionQuality(quality); |
---|
| 8715 | + |
---|
| 8716 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8717 | + writer.setOutput(ios); |
---|
| 8718 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8719 | + |
---|
| 8720 | + byte[] data = baos.toByteArray(); |
---|
| 8721 | + writer.dispose(); |
---|
| 8722 | + return data; |
---|
| 8723 | + } |
---|
| 8724 | + catch (Exception e) |
---|
| 8725 | + { |
---|
| 8726 | + e.printStackTrace(); |
---|
| 8727 | + return null; |
---|
| 8728 | + } |
---|
| 8729 | + } |
---|
| 8730 | + |
---|
| 8731 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8732 | + { |
---|
| 8733 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8734 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8735 | + ImageReader reader = writers.next(); |
---|
| 8736 | + |
---|
| 8737 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8738 | + |
---|
| 8739 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8740 | + param.setDestination(bim); |
---|
| 8741 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8742 | + |
---|
| 8743 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8744 | + reader.setInput(ios); |
---|
| 8745 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8746 | + reader.dispose(); |
---|
| 8747 | + |
---|
| 8748 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8749 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8750 | +// byte[] bytes = data.getData(); |
---|
| 8751 | +// |
---|
| 8752 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8753 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8754 | +// { |
---|
| 8755 | +// int i3 = i*3; |
---|
| 8756 | +// pixels[i] = 0xFF; |
---|
| 8757 | +// pixels[i] <<= 8; |
---|
| 8758 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8759 | +// pixels[i] <<= 8; |
---|
| 8760 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8761 | +// pixels[i] <<= 8; |
---|
| 8762 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8763 | +// } |
---|
| 8764 | +// |
---|
| 8765 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8766 | + |
---|
| 8767 | + return bim; |
---|
| 8768 | + } |
---|
| 8769 | + |
---|
6758 | 8770 | ShadowBuffer shadowPBuf; |
---|
6759 | 8771 | AntialiasBuffer antialiasPBuf; |
---|
6760 | 8772 | int MAXSTACK; |
---|
.. | .. |
---|
6771 | 8783 | |
---|
6772 | 8784 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
6773 | 8785 | MAXSTACK = temp[0]; |
---|
6774 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8786 | + if (Globals.DEBUG) |
---|
| 8787 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
6775 | 8788 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
6776 | 8789 | MAXSTACK = temp[0]; |
---|
6777 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8790 | + if (Globals.DEBUG) |
---|
| 8791 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
6778 | 8792 | |
---|
6779 | 8793 | // Use debug pipeline |
---|
6780 | 8794 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
6782 | 8796 | gl = drawable.getGL(); // |
---|
6783 | 8797 | |
---|
6784 | 8798 | GL gl3 = getGL(); |
---|
6785 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
6786 | 8801 | |
---|
6787 | 8802 | |
---|
6788 | 8803 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
6947 | 8962 | |
---|
6948 | 8963 | if (cubemap == null) |
---|
6949 | 8964 | { |
---|
6950 | | - LoadEnvy(5); |
---|
| 8965 | + //LoadEnvy(1); |
---|
6951 | 8966 | } |
---|
6952 | 8967 | |
---|
6953 | 8968 | //cubemap.enable(); |
---|
.. | .. |
---|
7223 | 9238 | |
---|
7224 | 9239 | void LoadEnvy(int which) |
---|
7225 | 9240 | { |
---|
| 9241 | + assert(false); |
---|
| 9242 | + |
---|
7226 | 9243 | String name; |
---|
7227 | 9244 | String ext; |
---|
7228 | 9245 | |
---|
.. | .. |
---|
7234 | 9251 | cubemap = null; |
---|
7235 | 9252 | return; |
---|
7236 | 9253 | case 1: |
---|
7237 | | - name = "cubemaps/box_"; |
---|
7238 | | - ext = "png"; |
---|
| 9254 | + name = "cubemaps/rgb/"; |
---|
| 9255 | + ext = "jpg"; |
---|
7239 | 9256 | reverseUP = false; |
---|
7240 | 9257 | break; |
---|
7241 | 9258 | case 2: |
---|
7242 | | - name = "cubemaps/uffizi_"; |
---|
7243 | | - ext = "png"; |
---|
7244 | | - break; // reverseUP = true; break; |
---|
| 9259 | + name = "cubemaps/uffizi/"; |
---|
| 9260 | + ext = "jpg"; |
---|
| 9261 | + reverseUP = false; |
---|
| 9262 | + break; |
---|
7245 | 9263 | case 3: |
---|
7246 | | - name = "cubemaps/CloudyHills_"; |
---|
7247 | | - ext = "tga"; |
---|
| 9264 | + name = "cubemaps/CloudyHills/"; |
---|
| 9265 | + ext = "jpg"; |
---|
7248 | 9266 | reverseUP = false; |
---|
7249 | 9267 | break; |
---|
7250 | 9268 | case 4: |
---|
7251 | | - name = "cubemaps/cornell_"; |
---|
| 9269 | + name = "cubemaps/cornell/"; |
---|
7252 | 9270 | ext = "png"; |
---|
7253 | 9271 | reverseUP = false; |
---|
7254 | 9272 | break; |
---|
| 9273 | + case 5: |
---|
| 9274 | + name = "cubemaps/skycube/"; |
---|
| 9275 | + ext = "jpg"; |
---|
| 9276 | + reverseUP = false; |
---|
| 9277 | + break; |
---|
| 9278 | + case 6: |
---|
| 9279 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9280 | + ext = "jpg"; |
---|
| 9281 | + reverseUP = false; |
---|
| 9282 | + break; |
---|
| 9283 | + case 7: |
---|
| 9284 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9285 | + ext = "jpg"; |
---|
| 9286 | + reverseUP = false; |
---|
| 9287 | + break; |
---|
| 9288 | + case 8: |
---|
| 9289 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9290 | + ext = "jpg"; |
---|
| 9291 | + reverseUP = false; |
---|
| 9292 | + break; |
---|
| 9293 | + case 9: |
---|
| 9294 | + name = "cubemaps/UnionSquare/"; |
---|
| 9295 | + ext = "jpg"; |
---|
| 9296 | + reverseUP = false; |
---|
| 9297 | + break; |
---|
7255 | 9298 | default: |
---|
7256 | | - name = "cubemaps/rgb_"; |
---|
7257 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9299 | + name = "cubemaps/box/"; |
---|
| 9300 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9301 | + reverseUP = false; |
---|
7258 | 9302 | break; |
---|
7259 | 9303 | } |
---|
7260 | | - |
---|
7261 | | - try |
---|
7262 | | - { |
---|
7263 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
7264 | | - } catch (IOException e) |
---|
7265 | | - { |
---|
7266 | | - throw new RuntimeException(e); |
---|
7267 | | - } |
---|
| 9304 | + |
---|
| 9305 | + LoadSkybox(name, ext, mipmap); |
---|
7268 | 9306 | } |
---|
7269 | 9307 | |
---|
7270 | 9308 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
7296 | 9334 | static double[] model = new double[16]; |
---|
7297 | 9335 | double[] camera2light = new double[16]; |
---|
7298 | 9336 | double[] light2camera = new double[16]; |
---|
7299 | | - int newenvy = -1; |
---|
7300 | | - boolean envyoff = true; // false; |
---|
| 9337 | + |
---|
| 9338 | + //int newenvy = -1; |
---|
| 9339 | + //boolean envyoff = false; |
---|
| 9340 | + |
---|
| 9341 | + String loadedskyboxname; |
---|
| 9342 | + |
---|
7301 | 9343 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
7302 | 9344 | //float[] light0 = { 0,0,0 }; |
---|
7303 | 9345 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
7310 | 9352 | static boolean occlusionInitialized = false; |
---|
7311 | 9353 | boolean selection = false; |
---|
7312 | 9354 | boolean pointselection = false; |
---|
7313 | | - /*static*/ boolean lighttouched = true; |
---|
| 9355 | + ///*static*/ boolean lighttouched = true; |
---|
7314 | 9356 | boolean deselect; |
---|
7315 | | - boolean ambientOcclusion = false; |
---|
| 9357 | + private boolean ambientOcclusion = false; |
---|
7316 | 9358 | static boolean flash = false; |
---|
7317 | 9359 | /*static*/ boolean wait = false; |
---|
7318 | 9360 | boolean displaydone = false; // after repaint() calls |
---|
.. | .. |
---|
7442 | 9484 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
7443 | 9485 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
7444 | 9486 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 9487 | +// PATCH FILLE AUX JEANS |
---|
| 9488 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
7445 | 9489 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
7446 | 9490 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
7447 | 9491 | |
---|
.. | .. |
---|
7588 | 9632 | jy8[3] = 0.5f; |
---|
7589 | 9633 | } |
---|
7590 | 9634 | |
---|
7591 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9635 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
7592 | 9636 | 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 |
---|
| 9637 | + float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
| 9638 | + float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
7594 | 9639 | |
---|
| 9640 | + void ResetOptions() |
---|
| 9641 | + { |
---|
| 9642 | + options1[0] = 100; |
---|
| 9643 | + options1[1] = 0.025f; |
---|
| 9644 | + options1[2] = 0.01f; |
---|
| 9645 | + options1[3] = 0; |
---|
| 9646 | + options1[4] = 0; |
---|
| 9647 | + |
---|
| 9648 | + options2[0] = 0; |
---|
| 9649 | + options2[1] = 0.75f; |
---|
| 9650 | + options2[2] = 0; |
---|
| 9651 | + options2[3] = 0; |
---|
| 9652 | + |
---|
| 9653 | + options3[0] = 1; |
---|
| 9654 | + options3[1] = 1; |
---|
| 9655 | + options3[2] = 1; |
---|
| 9656 | + options3[3] = 0; |
---|
| 9657 | + |
---|
| 9658 | + options4[0] = 1; |
---|
| 9659 | + options4[1] = 0; |
---|
| 9660 | + options4[2] = 1; |
---|
| 9661 | + options4[3] = 0; |
---|
| 9662 | + } |
---|
| 9663 | + |
---|
7595 | 9664 | static int imagecount = 0; // movie generation |
---|
7596 | 9665 | |
---|
7597 | 9666 | static int jitter = 0; |
---|
7598 | 9667 | |
---|
7599 | 9668 | boolean restartframe = false; |
---|
7600 | | - |
---|
7601 | | - static int framecount = 0; // general-purpose global count |
---|
7602 | 9669 | |
---|
7603 | 9670 | void displayAntiAliased(javax.media.opengl.GL gl) |
---|
7604 | 9671 | { |
---|
.. | .. |
---|
7630 | 9697 | gl.glClear(gl.GL_ACCUM_BUFFER_BIT); |
---|
7631 | 9698 | for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0) |
---|
7632 | 9699 | { |
---|
7633 | | - framecount++; |
---|
| 9700 | + Globals.framecount++; |
---|
7634 | 9701 | |
---|
7635 | 9702 | if (CameraPane.tickcount > 0) |
---|
7636 | 9703 | CameraPane.tickcount--; |
---|
.. | .. |
---|
7668 | 9735 | |
---|
7669 | 9736 | gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0); |
---|
7670 | 9737 | */ |
---|
7671 | | - lighttouched = true; |
---|
| 9738 | + Globals.lighttouched = true; |
---|
7672 | 9739 | //System.err.println(" shadowbuffer: " + jitter); |
---|
7673 | 9740 | shadowbuffer.display(); |
---|
7674 | 9741 | |
---|
.. | .. |
---|
7689 | 9756 | assert (parentcam != renderCamera); |
---|
7690 | 9757 | |
---|
7691 | 9758 | if (renderCamera != lightCamera) |
---|
7692 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7693 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 9759 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9760 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
7694 | 9761 | |
---|
7695 | 9762 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
7696 | 9763 | |
---|
.. | .. |
---|
7705 | 9772 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
7706 | 9773 | |
---|
7707 | 9774 | if (renderCamera != lightCamera) |
---|
7708 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7709 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 9775 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9776 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
7710 | 9777 | |
---|
7711 | 9778 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
7712 | 9779 | |
---|
.. | .. |
---|
7752 | 9819 | rati = 1 / rati; |
---|
7753 | 9820 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
7754 | 9821 | } |
---|
7755 | | - assert (newenvy == -1); |
---|
| 9822 | + |
---|
| 9823 | + //assert (newenvy == -1); |
---|
| 9824 | + |
---|
7756 | 9825 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
7757 | 9826 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
7758 | | - DrawSkyBox(gl); |
---|
| 9827 | + DrawSkyBox(gl, (float)rati); |
---|
7759 | 9828 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
7760 | 9829 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
7761 | 9830 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
7778 | 9847 | //gl.glFlush(); |
---|
7779 | 9848 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
7780 | 9849 | |
---|
7781 | | - if (ANIMATION && ABORTED) |
---|
| 9850 | + if (Globals.ANIMATION && ABORTED) |
---|
7782 | 9851 | { |
---|
7783 | 9852 | System.err.println(" ABORTED FRAME"); |
---|
7784 | 9853 | break; |
---|
.. | .. |
---|
7808 | 9877 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
7809 | 9878 | |
---|
7810 | 9879 | // save image |
---|
7811 | | - if (ANIMATION && !ABORTED) |
---|
| 9880 | + if (Globals.ANIMATION && !ABORTED) |
---|
7812 | 9881 | { |
---|
7813 | 9882 | VPwidth = viewport[2]; |
---|
7814 | 9883 | VPheight = viewport[3]; |
---|
.. | .. |
---|
7919 | 9988 | |
---|
7920 | 9989 | // imagecount++; |
---|
7921 | 9990 | |
---|
7922 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9991 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
7923 | 9992 | |
---|
7924 | 9993 | if (!BOXMODE) |
---|
7925 | 9994 | { |
---|
7926 | | - System.out.println("image: " + fullname + " (" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9995 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
7927 | 9996 | } |
---|
7928 | 9997 | |
---|
7929 | 9998 | if (!BOXMODE) |
---|
.. | .. |
---|
7961 | 10030 | ABORTED = false; |
---|
7962 | 10031 | } |
---|
7963 | 10032 | else |
---|
7964 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 10033 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
7965 | 10034 | |
---|
7966 | 10035 | if (false) |
---|
7967 | 10036 | { |
---|
.. | .. |
---|
8615 | 10684 | } |
---|
8616 | 10685 | } |
---|
8617 | 10686 | |
---|
8618 | | - boolean IsFrozen() |
---|
8619 | | - { |
---|
8620 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
8621 | | - |
---|
8622 | | - return !selectmode && cameracount == 0; // != 0; |
---|
8623 | | - } |
---|
8624 | | - |
---|
8625 | 10687 | boolean niceon = false; |
---|
8626 | 10688 | javax.swing.Timer AAtimer = new javax.swing.Timer(750, this); |
---|
8627 | 10689 | boolean currentlydrawing = false; |
---|
8628 | 10690 | static boolean init = false; |
---|
8629 | 10691 | |
---|
8630 | 10692 | double[][] matrix = LA.newMatrix(); |
---|
| 10693 | + |
---|
| 10694 | + // This is to refresh the UI of the material panel. |
---|
| 10695 | + ObjEditor patchMaterial; |
---|
8631 | 10696 | |
---|
8632 | 10697 | public void display(GLAutoDrawable drawable) |
---|
8633 | 10698 | { |
---|
8634 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10699 | + if (patchMaterial.patchMaterial) |
---|
8635 | 10700 | { |
---|
8636 | | - GrafreeD.wav.save(); |
---|
8637 | | - GrafreeD.savesound = false; |
---|
8638 | | - GrafreeD.hassound = false; |
---|
| 10701 | + patchMaterial.patchMaterial = false; |
---|
| 10702 | + patchMaterial.objectPanel.setSelectedIndex(0); |
---|
| 10703 | + } |
---|
| 10704 | + |
---|
| 10705 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
| 10706 | + { |
---|
| 10707 | + Grafreed.wav.save(); |
---|
| 10708 | + Grafreed.savesound = false; |
---|
| 10709 | + Grafreed.hassound = false; |
---|
8639 | 10710 | } |
---|
8640 | 10711 | // if (DEBUG_SELECTION) |
---|
8641 | 10712 | // { |
---|
8642 | | -// if (drawMode != SELECTION) |
---|
8643 | | -// drawMode = SELECTION; |
---|
| 10713 | +// if (DrawMode() != SELECTION) |
---|
| 10714 | +// DrawMode() = SELECTION; |
---|
8644 | 10715 | // } |
---|
8645 | 10716 | |
---|
8646 | 10717 | if (!isRenderer) |
---|
.. | .. |
---|
8696 | 10767 | |
---|
8697 | 10768 | //ANTIALIAS = 0; |
---|
8698 | 10769 | |
---|
8699 | | - if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
| 10770 | + if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
8700 | 10771 | { |
---|
8701 | | - if (niceon || isLIVE()) |
---|
| 10772 | + if (niceon || Globals.isLIVE()) |
---|
8702 | 10773 | { |
---|
8703 | 10774 | //if(active == 0) |
---|
8704 | 10775 | // antialiaser = null; |
---|
.. | .. |
---|
8711 | 10782 | ANTIALIAS = 0; |
---|
8712 | 10783 | //System.out.println("RESTART"); |
---|
8713 | 10784 | AAtimer.restart(); |
---|
| 10785 | + Globals.TIMERRUNNING = true; |
---|
8714 | 10786 | } |
---|
8715 | 10787 | } |
---|
8716 | 10788 | } |
---|
.. | .. |
---|
8723 | 10795 | assert eyeCamera.shaper_zFar == 1E5f; // 500.0f; |
---|
8724 | 10796 | */ |
---|
8725 | 10797 | |
---|
8726 | | - if (drawMode == DEFAULT) |
---|
| 10798 | + if (DrawMode() == DEFAULT) |
---|
8727 | 10799 | { |
---|
8728 | 10800 | currentlydrawing = true; |
---|
8729 | 10801 | } |
---|
.. | .. |
---|
8754 | 10826 | |
---|
8755 | 10827 | // if(Applet3D.clipboard != null) |
---|
8756 | 10828 | // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent); |
---|
8757 | | -//drawMode = SELECTION; |
---|
| 10829 | +//DrawMode() = SELECTION; |
---|
8758 | 10830 | indexcount = 0; |
---|
8759 | 10831 | |
---|
8760 | | - if (drawMode == OCCLUSION) |
---|
| 10832 | + if (DrawMode() == OCCLUSION) |
---|
8761 | 10833 | { |
---|
8762 | | - drawMode = DEFAULT; |
---|
| 10834 | + Globals.drawMode = DEFAULT; // WARNING |
---|
8763 | 10835 | ambientOcclusion = true; |
---|
8764 | 10836 | setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
---|
8765 | 10837 | Object3D theobject = object; |
---|
8766 | 10838 | Object3D theparent = object.parent; |
---|
8767 | 10839 | object.parent = null; |
---|
8768 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10840 | + object = (Object3D)Grafreed.clone(object); |
---|
8769 | 10841 | object.Stripify(); |
---|
8770 | 10842 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
8771 | 10843 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
8778 | 10850 | ambientOcclusion = false; |
---|
8779 | 10851 | } |
---|
8780 | 10852 | |
---|
8781 | | - if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10853 | + if (//Globals.lighttouched && |
---|
| 10854 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
8782 | 10855 | { |
---|
8783 | 10856 | //if (RENDERSHADOW) // ? |
---|
8784 | 10857 | if (!IsFrozen()) |
---|
8785 | 10858 | { |
---|
8786 | 10859 | // dec 2012 |
---|
8787 | | - if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)) |
---|
| 10860 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
8788 | 10861 | { |
---|
8789 | | - framecount++; |
---|
| 10862 | + Globals.framecount++; |
---|
8790 | 10863 | shadowbuffer.display(); |
---|
8791 | 10864 | } |
---|
8792 | 10865 | } |
---|
8793 | | - lighttouched = false; // ?? |
---|
| 10866 | + Globals.lighttouched = false; // ?? |
---|
8794 | 10867 | //drawing = true; |
---|
8795 | 10868 | //lighttouched = true; |
---|
8796 | 10869 | } |
---|
8797 | 10870 | |
---|
8798 | 10871 | if (wait) |
---|
8799 | 10872 | { |
---|
8800 | | - Sleep(500); |
---|
| 10873 | + Sleep(200); // blocks everything |
---|
8801 | 10874 | |
---|
8802 | 10875 | wait = false; |
---|
8803 | 10876 | } |
---|
.. | .. |
---|
8811 | 10884 | //eyeCamera.shaper_fovy = 1; |
---|
8812 | 10885 | } |
---|
8813 | 10886 | |
---|
8814 | | - if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION) |
---|
| 10887 | + if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION) |
---|
8815 | 10888 | { |
---|
8816 | | - //System.out.println("drawMode = " + drawMode); |
---|
| 10889 | + //System.out.println("DrawMode() = " + DrawMode()); |
---|
8817 | 10890 | vertexMode |= VP_PASS; |
---|
8818 | 10891 | //vertexMode |= VP_PROJECTION; |
---|
8819 | 10892 | if (!ambientOcclusion) |
---|
.. | .. |
---|
8873 | 10946 | Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera; |
---|
8874 | 10947 | //Camera lightcam = new Camera(light0); |
---|
8875 | 10948 | |
---|
8876 | | - if (drawMode == SHADOW) |
---|
| 10949 | + if (DrawMode() == SHADOW) |
---|
8877 | 10950 | { |
---|
8878 | 10951 | /* |
---|
8879 | 10952 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
.. | .. |
---|
8911 | 10984 | |
---|
8912 | 10985 | // if (parentcam != renderCamera) // not a light |
---|
8913 | 10986 | if (cam != lightCamera) |
---|
8914 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8915 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 10987 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10988 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
8916 | 10989 | |
---|
8917 | 10990 | for (int j = 0; j < 4; j++) |
---|
8918 | 10991 | { |
---|
.. | .. |
---|
8926 | 10999 | |
---|
8927 | 11000 | // if (parentcam != renderCamera) // not a light |
---|
8928 | 11001 | if (cam != lightCamera) |
---|
8929 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8930 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 11002 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11003 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
8931 | 11004 | |
---|
8932 | 11005 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
8933 | 11006 | |
---|
.. | .. |
---|
8963 | 11036 | gl.glClear(gl.GL_DEPTH_BUFFER_BIT); |
---|
8964 | 11037 | } else |
---|
8965 | 11038 | { |
---|
8966 | | - if (drawMode != DEFAULT) |
---|
| 11039 | + if (DrawMode() != DEFAULT) |
---|
8967 | 11040 | { |
---|
8968 | 11041 | gl.glClearColor(1, 1, 1, 0); |
---|
8969 | 11042 | } // 1); |
---|
.. | .. |
---|
9013 | 11086 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
9014 | 11087 | } |
---|
9015 | 11088 | |
---|
9016 | | - if (newenvy > -1) |
---|
| 11089 | +// if (newenvy > -1) |
---|
| 11090 | +// { |
---|
| 11091 | +// LoadEnvy(newenvy); |
---|
| 11092 | +// } |
---|
| 11093 | +// |
---|
| 11094 | +// newenvy = -1; |
---|
| 11095 | + |
---|
| 11096 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
9017 | 11097 | { |
---|
9018 | | - LoadEnvy(newenvy); |
---|
| 11098 | + if (cubemaprgb == null) |
---|
| 11099 | + { |
---|
| 11100 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11101 | + } |
---|
| 11102 | + |
---|
| 11103 | + cubemap = cubemaprgb; |
---|
9019 | 11104 | } |
---|
9020 | | - |
---|
9021 | | - newenvy = -1; |
---|
9022 | | - |
---|
| 11105 | + else |
---|
| 11106 | + { |
---|
| 11107 | + if (object.skyboxname != null) |
---|
| 11108 | + { |
---|
| 11109 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11110 | + { |
---|
| 11111 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11112 | + cubemap.dispose(); |
---|
| 11113 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11114 | + loadedskyboxname = object.skyboxname; |
---|
| 11115 | + } |
---|
| 11116 | + } |
---|
| 11117 | + else |
---|
| 11118 | + { |
---|
| 11119 | + cubemapcustom = null; |
---|
| 11120 | + loadedskyboxname = null; |
---|
| 11121 | + } |
---|
| 11122 | + |
---|
| 11123 | + cubemap = cubemapcustom; |
---|
| 11124 | + } |
---|
| 11125 | + |
---|
9023 | 11126 | ratio = ((double) getWidth()) / getHeight(); |
---|
9024 | 11127 | //System.out.println("ratio = " + ratio); |
---|
9025 | 11128 | |
---|
.. | .. |
---|
9028 | 11131 | |
---|
9029 | 11132 | fast &= !ambientOcclusion; |
---|
9030 | 11133 | |
---|
9031 | | - if (drawMode == DEFAULT) |
---|
| 11134 | + if (DrawMode() == DEFAULT) |
---|
9032 | 11135 | { |
---|
9033 | 11136 | //gl.glEnable(gl.GL_ALPHA_TEST); |
---|
9034 | 11137 | //gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
9035 | 11138 | |
---|
9036 | 11139 | if (!IsFrozen() && !ambientOcclusion) |
---|
9037 | 11140 | { |
---|
9038 | | - DrawSkyBox(gl); |
---|
| 11141 | + DrawSkyBox(gl, (float)ratio); |
---|
9039 | 11142 | } |
---|
9040 | 11143 | |
---|
9041 | 11144 | //if (selection_view == -1) |
---|
.. | .. |
---|
9089 | 11192 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
9090 | 11193 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9091 | 11194 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 11195 | +// PATCH FILLE AUX JEANS |
---|
| 11196 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9092 | 11197 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9093 | 11198 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9094 | 11199 | |
---|
.. | .. |
---|
9184 | 11289 | // Bump noise |
---|
9185 | 11290 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
9186 | 11291 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
9187 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11292 | + |
---|
| 11293 | + try |
---|
| 11294 | + { |
---|
| 11295 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11296 | + } |
---|
| 11297 | + catch (Exception e) |
---|
| 11298 | + { |
---|
| 11299 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11300 | + } |
---|
| 11301 | + |
---|
9188 | 11302 | |
---|
9189 | 11303 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
9190 | 11304 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9207 | 11321 | |
---|
9208 | 11322 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
9209 | 11323 | |
---|
9210 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
9211 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
9212 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11324 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11325 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11326 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
9213 | 11327 | } else |
---|
9214 | 11328 | { |
---|
9215 | 11329 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9220 | 11334 | //System.out.println("BLENDING ON"); |
---|
9221 | 11335 | gl.glEnable(GL.GL_BLEND); |
---|
9222 | 11336 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
9223 | | - |
---|
| 11337 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
9224 | 11338 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
9225 | 11339 | gl.glLoadIdentity(); |
---|
9226 | 11340 | |
---|
9227 | | - if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
| 11341 | + if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
9228 | 11342 | { |
---|
9229 | 11343 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9230 | 11344 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 11345 | +// PATCH FILLE AUX JEANS |
---|
| 11346 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9231 | 11347 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9232 | 11348 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9233 | 11349 | //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE); |
---|
.. | .. |
---|
9280 | 11396 | //gl.glPushMatrix(); |
---|
9281 | 11397 | gl.glLoadIdentity(); |
---|
9282 | 11398 | |
---|
9283 | | - if (!ambientOcclusion) // drawMode != OCCLUSION) |
---|
| 11399 | + if (!ambientOcclusion) // DrawMode() != OCCLUSION) |
---|
9284 | 11400 | { |
---|
9285 | 11401 | //LA.xformPos(light0, lightCamera.fromScreen, light); |
---|
9286 | 11402 | LA.xformDir(dirlight, lightCamera.fromScreen, lightposition); |
---|
.. | .. |
---|
9307 | 11423 | System.err.println("parentcam != renderCamera"); |
---|
9308 | 11424 | |
---|
9309 | 11425 | // if (cam != lightCamera) |
---|
9310 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9311 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11426 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11427 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
9312 | 11428 | } |
---|
9313 | 11429 | |
---|
9314 | 11430 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
9329 | 11445 | if (true) // TODO |
---|
9330 | 11446 | { |
---|
9331 | 11447 | if (cam != lightCamera) |
---|
9332 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9333 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11448 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11449 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
9334 | 11450 | } |
---|
9335 | 11451 | |
---|
9336 | 11452 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
9367 | 11483 | } |
---|
9368 | 11484 | |
---|
9369 | 11485 | /**/ |
---|
9370 | | - if (true) // drawMode == SELECTION) // != DEFAULT) |
---|
| 11486 | + if (true) // DrawMode() == SELECTION) // != DEFAULT) |
---|
9371 | 11487 | gl.glDisable(gl.GL_LIGHTING); |
---|
9372 | 11488 | else |
---|
9373 | 11489 | gl.glEnable(gl.GL_LIGHTING); |
---|
.. | .. |
---|
9379 | 11495 | |
---|
9380 | 11496 | gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0); |
---|
9381 | 11497 | gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0); |
---|
| 11498 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0); |
---|
9382 | 11499 | |
---|
9383 | 11500 | options2[0] *= renderCamera.Distance(); |
---|
9384 | 11501 | |
---|
9385 | 11502 | lightslot = 64; |
---|
9386 | 11503 | |
---|
9387 | | - if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT) |
---|
| 11504 | + if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT) |
---|
9388 | 11505 | { |
---|
9389 | 11506 | DrawLights(object); |
---|
9390 | 11507 | } |
---|
.. | .. |
---|
9395 | 11512 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
9396 | 11513 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
9397 | 11514 | |
---|
9398 | | - if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION) |
---|
| 11515 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
9399 | 11516 | { |
---|
9400 | 11517 | /* |
---|
9401 | 11518 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
9428 | 11545 | } |
---|
9429 | 11546 | } |
---|
9430 | 11547 | |
---|
9431 | | - if (drawMode == DEFAULT) |
---|
| 11548 | + if (DrawMode() == DEFAULT) |
---|
9432 | 11549 | { |
---|
9433 | 11550 | if (WIREFRAME && !ambientOcclusion) |
---|
9434 | 11551 | { |
---|
.. | .. |
---|
9446 | 11563 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9447 | 11564 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9448 | 11565 | |
---|
9449 | | - if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) // |
---|
| 11566 | + if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) // |
---|
9450 | 11567 | { |
---|
9451 | 11568 | if (vertexMode != 0) // && !fast) |
---|
9452 | 11569 | { |
---|
.. | .. |
---|
9466 | 11583 | } |
---|
9467 | 11584 | } |
---|
9468 | 11585 | |
---|
9469 | | - if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion) |
---|
| 11586 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
9470 | 11587 | { |
---|
9471 | 11588 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
9472 | 11589 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
9474 | 11591 | |
---|
9475 | 11592 | boolean texon = textureon; |
---|
9476 | 11593 | |
---|
9477 | | - if (RENDERPROGRAM > 0) |
---|
9478 | | - { |
---|
9479 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9480 | | - textureon = false; |
---|
9481 | | - } |
---|
| 11594 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11595 | + textureon = false; |
---|
| 11596 | + |
---|
9482 | 11597 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9483 | 11598 | //System.out.println("ALLO"); |
---|
9484 | 11599 | gl.glColorMask(false, false, false, false); |
---|
9485 | 11600 | DrawObject(gl); |
---|
9486 | | - if (RENDERPROGRAM > 0) |
---|
9487 | | - { |
---|
9488 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9489 | | - textureon = texon; |
---|
9490 | | - } |
---|
| 11601 | + |
---|
| 11602 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11603 | + textureon = texon; |
---|
| 11604 | + |
---|
9491 | 11605 | gl.glColorMask(true, true, true, true); |
---|
9492 | 11606 | |
---|
9493 | 11607 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
9494 | | - //gl.glDepthMask(false); |
---|
| 11608 | + gl.glDepthMask(false); |
---|
9495 | 11609 | } |
---|
9496 | 11610 | |
---|
9497 | | - if (false) // drawMode == SHADOW) |
---|
| 11611 | + if (false) // DrawMode() == SHADOW) |
---|
9498 | 11612 | { |
---|
9499 | 11613 | //SetColumnMajorData(cameraInverseTransform, view_1); |
---|
9500 | 11614 | //System.out.println("light = " + cameraInverseTransform); |
---|
.. | .. |
---|
9508 | 11622 | //System.out.println("object = " + object); |
---|
9509 | 11623 | if (!frozen && !imageLocked) |
---|
9510 | 11624 | { |
---|
9511 | | - if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0) |
---|
| 11625 | + if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0) |
---|
9512 | 11626 | { |
---|
9513 | 11627 | displayAntiAliased(gl); |
---|
9514 | 11628 | } else |
---|
9515 | 11629 | { |
---|
9516 | 11630 | programcount = 0; |
---|
9517 | | - int keepmode = drawMode; |
---|
| 11631 | + int keepmode = DrawMode(); |
---|
9518 | 11632 | // if (DEBUG_SELECTION) |
---|
9519 | 11633 | // { |
---|
9520 | | -// drawMode = SELECTION; |
---|
| 11634 | +// DrawMode() = SELECTION; |
---|
9521 | 11635 | // } |
---|
9522 | 11636 | // for point selection |
---|
9523 | 11637 | // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0); |
---|
.. | .. |
---|
9527 | 11641 | DrawObject(gl); |
---|
9528 | 11642 | |
---|
9529 | 11643 | // jan 2013 System.err.println("RESET ABORT (display)"); |
---|
9530 | | - // if (drawMode == DEFAULT) |
---|
| 11644 | + // if (DrawMode() == DEFAULT) |
---|
9531 | 11645 | // ABORTED = false; |
---|
9532 | 11646 | fullreset = false; |
---|
9533 | | - drawMode = keepmode; |
---|
| 11647 | + Globals.drawMode = keepmode; // WARNING |
---|
9534 | 11648 | //System.out.println("PROGRAM SWITCH " + programcount); |
---|
9535 | 11649 | } |
---|
9536 | 11650 | } |
---|
.. | .. |
---|
9538 | 11652 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9539 | 11653 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9540 | 11654 | |
---|
9541 | | - if (drawMode == DEFAULT) |
---|
| 11655 | + if (DrawMode() == DEFAULT) |
---|
9542 | 11656 | { |
---|
9543 | 11657 | ReleaseTexture(NOISE_TEXTURE, false); |
---|
9544 | 11658 | } |
---|
9545 | | - //if (drawMode == DEFAULT) |
---|
| 11659 | + //if (DrawMode() == DEFAULT) |
---|
9546 | 11660 | { |
---|
9547 | 11661 | |
---|
9548 | 11662 | gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
.. | .. |
---|
9554 | 11668 | //else |
---|
9555 | 11669 | //gl.glDisable(gl.GL_TEXTURE_2D); |
---|
9556 | 11670 | //gl.glPopMatrix(); |
---|
9557 | | - if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
| 11671 | + if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
9558 | 11672 | { |
---|
9559 | 11673 | //new Exception().printStackTrace(); |
---|
9560 | 11674 | //System.out.println("Draw image " + width + ", " + height); |
---|
.. | .. |
---|
9596 | 11710 | //gl.glFlush(); |
---|
9597 | 11711 | } |
---|
9598 | 11712 | |
---|
9599 | | - if (flash && drawMode == DEFAULT) |
---|
| 11713 | + if (flash && DrawMode() == DEFAULT) |
---|
9600 | 11714 | { |
---|
9601 | 11715 | flash = false; |
---|
9602 | 11716 | wait = true; |
---|
.. | .. |
---|
9604 | 11718 | } |
---|
9605 | 11719 | |
---|
9606 | 11720 | //drawing = false; |
---|
9607 | | - //if(drawMode == DEFAULT) |
---|
| 11721 | + //if(DrawMode() == DEFAULT) |
---|
9608 | 11722 | // niceon = false; |
---|
9609 | | - if (drawMode == DEFAULT) |
---|
| 11723 | + if (DrawMode() == DEFAULT) |
---|
9610 | 11724 | { |
---|
9611 | 11725 | currentlydrawing = false; |
---|
9612 | 11726 | } |
---|
.. | .. |
---|
9626 | 11740 | repaint(); |
---|
9627 | 11741 | } |
---|
9628 | 11742 | |
---|
9629 | | - if (isLIVE() && drawMode == DEFAULT) // may 2013 |
---|
| 11743 | + if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 |
---|
9630 | 11744 | repaint(); |
---|
9631 | 11745 | |
---|
9632 | 11746 | displaydone = true; |
---|
.. | .. |
---|
9645 | 11759 | { |
---|
9646 | 11760 | renderpass++; |
---|
9647 | 11761 | // System.out.println("Draw object... "); |
---|
| 11762 | + STEP = 1; |
---|
9648 | 11763 | if (FAST) // in case there is no script |
---|
9649 | | - STEP = 16; |
---|
| 11764 | + STEP = 8; |
---|
| 11765 | + |
---|
| 11766 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11767 | + { |
---|
| 11768 | + STEP *= 4; |
---|
| 11769 | + } |
---|
9650 | 11770 | |
---|
9651 | 11771 | //object.FullInvariants(); |
---|
9652 | 11772 | |
---|
.. | .. |
---|
9660 | 11780 | e.printStackTrace(); |
---|
9661 | 11781 | } |
---|
9662 | 11782 | |
---|
9663 | | - if (GrafreeD.RENDERME > 0) |
---|
9664 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11783 | + if (Grafreed.RENDERME > 0) |
---|
| 11784 | + Grafreed.RENDERME--; // mechante magouille |
---|
9665 | 11785 | |
---|
9666 | | - ONESTEP = false; |
---|
| 11786 | + Globals.ONESTEP = false; |
---|
9667 | 11787 | } |
---|
9668 | 11788 | |
---|
9669 | 11789 | static boolean zoomonce = false; |
---|
9670 | 11790 | |
---|
| 11791 | + static void CreateSelectedPoint() |
---|
| 11792 | + { |
---|
| 11793 | + if (selectedpoint == null) |
---|
| 11794 | + { |
---|
| 11795 | + debugpointG = new Sphere(); |
---|
| 11796 | + debugpointP = new Sphere(); |
---|
| 11797 | + debugpointC = new Sphere(); |
---|
| 11798 | + debugpointR = new Sphere(); |
---|
| 11799 | + |
---|
| 11800 | + selectedpoint = new Superellipsoid(); |
---|
| 11801 | + |
---|
| 11802 | + for (int i=0; i<8; i++) |
---|
| 11803 | + { |
---|
| 11804 | + debugpoints[i] = new Sphere(); |
---|
| 11805 | + } |
---|
| 11806 | + } |
---|
| 11807 | + } |
---|
| 11808 | + |
---|
9671 | 11809 | void DrawObject(GL gl, boolean draw) |
---|
9672 | 11810 | { |
---|
| 11811 | + // To clear camera values |
---|
| 11812 | + ResetOptions(); |
---|
| 11813 | + |
---|
9673 | 11814 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
9674 | | -// drawMode = SELECTION; |
---|
| 11815 | +// DrawMode() = SELECTION; |
---|
9675 | 11816 | //GL gl = getGL(); |
---|
9676 | 11817 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
9677 | 11818 | { |
---|
9678 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
9679 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11819 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
| 11820 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
9680 | 11821 | pingthread.StepToTarget(true); // true); |
---|
9681 | 11822 | // zoomonce = false; |
---|
9682 | 11823 | } |
---|
.. | .. |
---|
9696 | 11837 | callist = gl.glGenLists(1); |
---|
9697 | 11838 | } |
---|
9698 | 11839 | |
---|
9699 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11840 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
9700 | 11841 | |
---|
9701 | | - boolean active = !selectmode; // drawMode != SELECTION; // mouseDown; |
---|
| 11842 | + boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
9702 | 11843 | |
---|
9703 | 11844 | if (!mainDL || !active || touched) |
---|
9704 | 11845 | { |
---|
.. | .. |
---|
9725 | 11866 | PushMatrix(ClickInfo.matbuffer); |
---|
9726 | 11867 | } |
---|
9727 | 11868 | |
---|
9728 | | - if (drawMode == 0) |
---|
| 11869 | + if (DrawMode() == 0) |
---|
9729 | 11870 | { |
---|
9730 | 11871 | // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++"); |
---|
9731 | 11872 | |
---|
9732 | 11873 | usedtextures.clear(); |
---|
9733 | 11874 | |
---|
9734 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11875 | + try |
---|
| 11876 | + { |
---|
| 11877 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11878 | + } |
---|
| 11879 | + catch (Exception e) |
---|
| 11880 | + { |
---|
| 11881 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11882 | + } |
---|
9735 | 11883 | } |
---|
9736 | 11884 | //System.out.println("--> " + stackdepth); |
---|
9737 | 11885 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
9739 | 11887 | // DRAW |
---|
9740 | 11888 | object.draw(this, /*(Composite)*/ object, false, false); |
---|
9741 | 11889 | |
---|
9742 | | - if (drawMode == DEFAULT) |
---|
| 11890 | + if (DrawMode() == DEFAULT) |
---|
9743 | 11891 | { |
---|
9744 | | - if (DEBUG) |
---|
| 11892 | + if (Globals.DEBUG) |
---|
9745 | 11893 | { |
---|
| 11894 | + CreateSelectedPoint(); |
---|
9746 | 11895 | float radius = 0.05f; |
---|
9747 | 11896 | if (selectedpoint.radius != radius) |
---|
9748 | 11897 | { |
---|
.. | .. |
---|
9750 | 11899 | selectedpoint.radius = radius; |
---|
9751 | 11900 | selectedpoint.recalculate(); |
---|
9752 | 11901 | selectedpoint.material = new cMaterial(); |
---|
9753 | | - selectedpoint.material.color = 0.25f; |
---|
| 11902 | + selectedpoint.material.color = 0.15f; // Yellow |
---|
9754 | 11903 | selectedpoint.material.modulation = 0.75f; |
---|
9755 | 11904 | |
---|
9756 | | - debugpoint.radius = radius; |
---|
9757 | | - debugpoint.recalculate(); |
---|
9758 | | - debugpoint.material = new cMaterial(); |
---|
9759 | | - debugpoint.material.color = 0.25f; |
---|
9760 | | - debugpoint.material.modulation = 0.75f; |
---|
| 11905 | + debugpointG.radius = radius; |
---|
| 11906 | + debugpointG.recalculate(); |
---|
| 11907 | + debugpointG.material = new cMaterial(); |
---|
| 11908 | + debugpointG.material.color = 0.25f; // Green |
---|
| 11909 | + debugpointG.material.modulation = 0.75f; |
---|
9761 | 11910 | |
---|
9762 | | - debugpoint2.radius = radius; |
---|
9763 | | - debugpoint2.recalculate(); |
---|
9764 | | - debugpoint2.material = new cMaterial(); |
---|
9765 | | - debugpoint2.material.color = 0.75f; |
---|
9766 | | - debugpoint2.material.modulation = 0.75f; |
---|
| 11911 | + debugpointP.radius = radius; |
---|
| 11912 | + debugpointP.recalculate(); |
---|
| 11913 | + debugpointP.material = new cMaterial(); |
---|
| 11914 | + debugpointP.material.color = 0.75f; // Purple |
---|
| 11915 | + debugpointP.material.modulation = 0.75f; |
---|
9767 | 11916 | |
---|
9768 | | - debugpoint3.radius = radius; |
---|
9769 | | - debugpoint3.recalculate(); |
---|
9770 | | - debugpoint3.material = new cMaterial(); |
---|
9771 | | - debugpoint3.material.color = 0.5f; |
---|
9772 | | - debugpoint3.material.modulation = 0.75f; |
---|
| 11917 | + debugpointC.radius = radius; |
---|
| 11918 | + debugpointC.recalculate(); |
---|
| 11919 | + debugpointC.material = new cMaterial(); |
---|
| 11920 | + debugpointC.material.color = 0.5f; // Cyan |
---|
| 11921 | + debugpointC.material.modulation = 0.75f; |
---|
9773 | 11922 | |
---|
9774 | | - debugpoint4.radius = radius; |
---|
9775 | | - debugpoint4.recalculate(); |
---|
9776 | | - debugpoint4.material = new cMaterial(); |
---|
9777 | | - debugpoint4.material.color = 0f; |
---|
9778 | | - debugpoint4.material.modulation = 0.75f; |
---|
| 11923 | + debugpointR.radius = radius; |
---|
| 11924 | + debugpointR.recalculate(); |
---|
| 11925 | + debugpointR.material = new cMaterial(); |
---|
| 11926 | + debugpointR.material.color = 0f; // Red |
---|
| 11927 | + debugpointR.material.modulation = 0.75f; |
---|
9779 | 11928 | |
---|
9780 | 11929 | InitPoints(radius); |
---|
9781 | 11930 | } |
---|
9782 | 11931 | 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); |
---|
| 11932 | + debugpointG.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11933 | + debugpointP.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11934 | + debugpointC.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11935 | + debugpointR.draw(this, /*(Composite)*/ null, false,false); |
---|
9787 | 11936 | // DrawPoints(this); |
---|
9788 | 11937 | } |
---|
9789 | 11938 | |
---|
.. | .. |
---|
9791 | 11940 | } |
---|
9792 | 11941 | // GrafreeD.traceoff(); |
---|
9793 | 11942 | //System.out.println(stackdepth); |
---|
9794 | | - if (drawMode == 0) |
---|
| 11943 | + if (DrawMode() == 0) |
---|
9795 | 11944 | { |
---|
9796 | 11945 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
9797 | 11946 | |
---|
9798 | 11947 | if (CLEANCACHE) |
---|
9799 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11948 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
9800 | 11949 | { |
---|
9801 | | - String tex = e.nextElement(); |
---|
| 11950 | + cTexture tex = e.nextElement(); |
---|
9802 | 11951 | |
---|
9803 | 11952 | // System.out.println("Texture --------- " + tex); |
---|
9804 | 11953 | |
---|
9805 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11954 | + if (tex.equals("WHITE_NOISE:")) |
---|
9806 | 11955 | continue; |
---|
9807 | 11956 | |
---|
9808 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11957 | + if (!usedtextures.contains(tex)) |
---|
9809 | 11958 | { |
---|
| 11959 | + CacheTexture gettex = texturepigment.get(tex); |
---|
9810 | 11960 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
9811 | | - textures.get(tex).texture.dispose(); |
---|
9812 | | - textures.remove(tex); |
---|
| 11961 | + if (gettex != null) |
---|
| 11962 | + { |
---|
| 11963 | + gettex.texture.dispose(); |
---|
| 11964 | + texturepigment.remove(tex); |
---|
| 11965 | + } |
---|
| 11966 | + |
---|
| 11967 | + gettex = texturebump.get(tex); |
---|
| 11968 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11969 | + if (gettex != null) |
---|
| 11970 | + { |
---|
| 11971 | + gettex.texture.dispose(); |
---|
| 11972 | + texturebump.remove(tex); |
---|
| 11973 | + } |
---|
9813 | 11974 | } |
---|
9814 | 11975 | } |
---|
9815 | 11976 | } |
---|
9816 | 11977 | |
---|
9817 | 11978 | checker = null; |
---|
9818 | 11979 | |
---|
9819 | | - if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT) |
---|
| 11980 | + if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT) |
---|
9820 | 11981 | FindChecker(object); |
---|
9821 | 11982 | |
---|
9822 | | - if (checker != null && drawMode == DEFAULT) |
---|
| 11983 | + if (checker != null && DrawMode() == DEFAULT) |
---|
9823 | 11984 | { |
---|
9824 | | - // BindTexture(IMMORTAL_TEXTURE); |
---|
| 11985 | + //BindTexture(IMMORTAL_TEXTURE); |
---|
| 11986 | + try |
---|
| 11987 | + { |
---|
| 11988 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11989 | + } |
---|
| 11990 | + catch (Exception e) |
---|
| 11991 | + { |
---|
| 11992 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11993 | + } |
---|
9825 | 11994 | // NEAREST |
---|
9826 | 11995 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
9827 | 11996 | DrawChecker(gl); |
---|
9828 | 11997 | //checker.Draw(this, null, false); |
---|
9829 | 11998 | // ReleaseTexture(IMMORTAL_TEXTURE); |
---|
| 11999 | + ReleaseTextures(checker.GetTextures()); |
---|
9830 | 12000 | } |
---|
9831 | 12001 | |
---|
9832 | 12002 | if (object.parent != null) |
---|
.. | .. |
---|
9839 | 12009 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9840 | 12010 | //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9841 | 12011 | |
---|
9842 | | - if (DISPLAYTEXT && drawMode == DEFAULT) |
---|
| 12012 | + if (DISPLAYTEXT && DrawMode() == DEFAULT) |
---|
9843 | 12013 | { |
---|
9844 | 12014 | // Draw it once, then use the raster |
---|
9845 | 12015 | Balloon(gl, balloon.createGraphics()); |
---|
.. | .. |
---|
9895 | 12065 | int[] xs = new int[3]; |
---|
9896 | 12066 | int[] ys = new int[3]; |
---|
9897 | 12067 | |
---|
9898 | | - void DrawString(Object3D obj) // String string) |
---|
| 12068 | + public void DrawString(Object3D obj) // String string) // INTERFACE |
---|
9899 | 12069 | { |
---|
9900 | | - if (!DISPLAYTEXT || drawMode != DEFAULT) |
---|
| 12070 | + if (!DISPLAYTEXT || DrawMode() != DEFAULT) |
---|
9901 | 12071 | { |
---|
9902 | 12072 | return; |
---|
9903 | 12073 | } |
---|
9904 | 12074 | |
---|
9905 | | - String string = obj.GetToolTip(); |
---|
| 12075 | + String string = obj.toString(); //.GetToolTip(); |
---|
9906 | 12076 | |
---|
9907 | 12077 | GL gl = GetGL(); |
---|
9908 | 12078 | |
---|
.. | .. |
---|
10219 | 12389 | //obj.TransformToWorld(light, light); |
---|
10220 | 12390 | for (int i = tp.size(); --i >= 0;) |
---|
10221 | 12391 | { |
---|
10222 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
10223 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12392 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12393 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
10224 | 12394 | } |
---|
10225 | 12395 | |
---|
10226 | 12396 | |
---|
.. | .. |
---|
10237 | 12407 | parentcam = cameras[0]; |
---|
10238 | 12408 | } |
---|
10239 | 12409 | |
---|
10240 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10241 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12410 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12411 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
10242 | 12412 | |
---|
10243 | 12413 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
10244 | 12414 | |
---|
.. | .. |
---|
10328 | 12498 | |
---|
10329 | 12499 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
10330 | 12500 | |
---|
10331 | | - String program = |
---|
| 12501 | + String programmin = |
---|
| 12502 | + // Min shader |
---|
10332 | 12503 | "!!ARBfp1.0\n" + |
---|
| 12504 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12505 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12506 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12507 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12508 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12509 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12510 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12511 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12512 | + "TEMP temp;" + |
---|
| 12513 | + "TEMP light;" + |
---|
| 12514 | + "TEMP ndotl;" + |
---|
| 12515 | + "TEMP normal;" + |
---|
| 12516 | + "TEMP depth;" + |
---|
| 12517 | + "TEMP eye;" + |
---|
| 12518 | + "TEMP pos;" + |
---|
| 12519 | + |
---|
| 12520 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12521 | + Normalize("normal") + |
---|
| 12522 | + "MOV light, state.light[0].position;" + |
---|
| 12523 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12524 | + |
---|
| 12525 | + // shadow |
---|
| 12526 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12527 | + "MOV temp, pos;" + |
---|
| 12528 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12529 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12530 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12531 | + |
---|
| 12532 | + // No shadow when out of frustum |
---|
| 12533 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12534 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12535 | + |
---|
| 12536 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12537 | + |
---|
| 12538 | + // Backlit |
---|
| 12539 | + "MOV pos.w, zero123.y;" + |
---|
| 12540 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12541 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12542 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12543 | + Normalize("eye") + |
---|
| 12544 | + |
---|
| 12545 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12546 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12547 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12548 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12549 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12550 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12551 | + |
---|
| 12552 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12553 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12554 | + |
---|
| 12555 | + // Pigment |
---|
| 12556 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12557 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12558 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12559 | + |
---|
| 12560 | + "MUL temp, temp, zero123.z;" + |
---|
| 12561 | + |
---|
| 12562 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12563 | + |
---|
| 12564 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12565 | + "MOV result.color, temp;" + |
---|
| 12566 | + "END"; |
---|
| 12567 | + |
---|
| 12568 | + String programmax = |
---|
| 12569 | + "!!ARBfp1.0\n" + |
---|
| 12570 | + |
---|
10333 | 12571 | //"OPTION ARB_fragment_program_shadow;" + |
---|
10334 | 12572 | "PARAM light2cam0 = program.env[10];" + |
---|
10335 | 12573 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
10357 | 12595 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
10358 | 12596 | "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
10359 | 12597 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
10360 | | - "PARAM options1 = program.env[62];" + // fog rgb color, image intensity |
---|
| 12598 | + "PARAM options1 = program.env[62];" + // fog rgb color |
---|
| 12599 | + "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
10361 | 12600 | "PARAM pointlight = program.env[127];" + // ... |
---|
10362 | 12601 | "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" + |
---|
10363 | 12602 | "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" + |
---|
10364 | 12603 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
| 12604 | + "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" + |
---|
10365 | 12605 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
10366 | 12606 | "PARAM ten = { 10, 10, 10, 1.0 };" + |
---|
10367 | 12607 | "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" + |
---|
.. | .. |
---|
10382 | 12622 | "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" + |
---|
10383 | 12623 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
10384 | 12624 | "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" + |
---|
| 12625 | + "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" + |
---|
10385 | 12626 | "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" + |
---|
10386 | 12627 | "PARAM c256 = { 256, 256, 256, 1.0 };" + |
---|
10387 | 12628 | "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" + |
---|
.. | .. |
---|
10422 | 12663 | "TEMP R1;" + |
---|
10423 | 12664 | "TEMP R2;" + |
---|
10424 | 12665 | "TEMP R3;" + |
---|
| 12666 | + "TEMP min;" + |
---|
| 12667 | + "TEMP max;" + |
---|
| 12668 | + "TEMP average;" + |
---|
| 12669 | + "TEMP saturation;" + |
---|
10425 | 12670 | "TEMP keep1;" + |
---|
10426 | 12671 | "TEMP keep2;" + |
---|
10427 | 12672 | "TEMP keep3;" + |
---|
.. | .. |
---|
10437 | 12682 | "TEMP shininess;" + |
---|
10438 | 12683 | "\n" + |
---|
10439 | 12684 | "MOV texSamp, one;" + |
---|
10440 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
10441 | | - |
---|
| 12685 | + |
---|
10442 | 12686 | "MOV mapgrid.x, one2048th.x;" + |
---|
10443 | 12687 | "MOV temp, fragment.texcoord[1];" + |
---|
10444 | 12688 | /* |
---|
.. | .. |
---|
10459 | 12703 | "MUL temp, floor, mapgrid.x;" + |
---|
10460 | 12704 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
10461 | 12705 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
10462 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12706 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
10463 | 12707 | "") + |
---|
10464 | 12708 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
10465 | 12709 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
10466 | 12710 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
10467 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12711 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
10468 | 12712 | "") + |
---|
10469 | 12713 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
10470 | 12714 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
10471 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12715 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
10472 | 12716 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
10473 | 12717 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
10474 | 12718 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
10475 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12719 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
10476 | 12720 | "") + |
---|
10477 | 12721 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
10478 | 12722 | //"MOV params, material;" + |
---|
.. | .. |
---|
10843 | 13087 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
10844 | 13088 | "") + |
---|
10845 | 13089 | |
---|
10846 | | - // display shadow only (bump == 0) |
---|
| 13090 | + // display shadow only (fakedepth == 0) |
---|
10847 | 13091 | "SUB temp.x, half.x, shadow.x;" + |
---|
10848 | | - "MOV temp.y, -params6.x;" + |
---|
10849 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 13092 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 13093 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
10850 | 13094 | "SUB temp.y, one.x, temp.z;" + |
---|
10851 | 13095 | "MUL temp.x, temp.x, temp.y;" + |
---|
10852 | 13096 | "KIL temp.x;" + |
---|
.. | .. |
---|
10952 | 13196 | |
---|
10953 | 13197 | // skin? |
---|
10954 | 13198 | // Saturation for skin |
---|
10955 | | - /**/ // c'est ici |
---|
10956 | | - (Skinshader? "DP3 temp.x, final,one;" + |
---|
| 13199 | + /**/ |
---|
| 13200 | + (Skinshader? |
---|
| 13201 | + "DP3 average.x, final,one;" + |
---|
| 13202 | + "MUL average, one3rd.xxxx,average.xxxx;" + |
---|
| 13203 | + |
---|
| 13204 | + "MIN min.x, final.x,final.y;" + |
---|
| 13205 | + "MIN min.x, min.x,final.z;" + |
---|
| 13206 | + |
---|
| 13207 | + "MAX max.x, final.x,final.y;" + |
---|
| 13208 | + "MAX max.x, max.x,final.z;" + |
---|
| 13209 | + "MOV max, max.xxxx;" + |
---|
| 13210 | + |
---|
| 13211 | + "SUB saturation, max, final;" + |
---|
| 13212 | + |
---|
| 13213 | + "ADD temp.x, max.x, one10th.x;" + |
---|
| 13214 | + "RCP temp.x, temp.x;" + |
---|
| 13215 | + "MUL temp.x, temp.x, half.x;" + |
---|
| 13216 | + "MUL saturation, saturation, temp.xxxx;" + |
---|
| 13217 | + |
---|
| 13218 | + "DP3 ndotl.x, normald, light;" + |
---|
| 13219 | + "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
| 13220 | + |
---|
| 13221 | + "SUB temp.x, one.x, ndotl.x;" + |
---|
| 13222 | + // Tuning for default skin |
---|
| 13223 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 13224 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 13225 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
| 13226 | + "MUL temp.x, temp.x, temp.y;" + |
---|
| 13227 | + |
---|
| 13228 | + "MUL saturation, saturation, temp.xxxx;" + |
---|
| 13229 | + "SUB_SAT temp, max, saturation;" + |
---|
| 13230 | +/** |
---|
| 13231 | + "DP3 temp.x, final,one;" + |
---|
10957 | 13232 | "MUL R2, one3rd.xxxx,temp.xxxx;" + |
---|
10958 | | - "SUB temp, final,R2;" + |
---|
| 13233 | + "SUB temp, final, R2;" + |
---|
| 13234 | + |
---|
10959 | 13235 | // using light angle |
---|
10960 | 13236 | "DP3 ndotl.x, normald,light;" + |
---|
10961 | 13237 | //"SLT ndotl.y, ndotl.x, zero.x;" + |
---|
.. | .. |
---|
10968 | 13244 | // using light intensity |
---|
10969 | 13245 | "MOV ndotl.z, R2.x;" + |
---|
10970 | 13246 | "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning... |
---|
10971 | | - |
---|
10972 | 13247 | // june 2014 |
---|
10973 | 13248 | "MAD R1.x, ndotl.z,slope.y,one.x;" + |
---|
10974 | 13249 | // "SUB ndotl.x, one.x, ndotl.x;" + |
---|
.. | .. |
---|
10980 | 13255 | //"MUL R2.y, shadow.x,R2.y;" + // avril 2014 |
---|
10981 | 13256 | |
---|
10982 | 13257 | "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin) |
---|
| 13258 | +/**/ |
---|
10983 | 13259 | |
---|
10984 | 13260 | // "ADD final, R2,temp;" + |
---|
10985 | 13261 | "MOV final, temp;" |
---|
.. | .. |
---|
11069 | 13345 | /**/ |
---|
11070 | 13346 | // HDR |
---|
11071 | 13347 | "MOV temp.z, final.a;" + |
---|
11072 | | - "MUL final, final,options1.w;" + |
---|
| 13348 | + "MUL final, final,options2.x;" + |
---|
11073 | 13349 | "MOV final.a, temp.z;" + |
---|
11074 | 13350 | /**/ |
---|
11075 | 13351 | |
---|
.. | .. |
---|
11145 | 13421 | //once = true; |
---|
11146 | 13422 | } |
---|
11147 | 13423 | |
---|
11148 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
11149 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13424 | + String program = programmax; |
---|
| 13425 | + |
---|
| 13426 | + if (Globals.MINSHADER) |
---|
| 13427 | + { |
---|
| 13428 | + program = programmin; |
---|
| 13429 | + } |
---|
| 13430 | + |
---|
| 13431 | + if (Globals.DEBUG) |
---|
| 13432 | + { |
---|
| 13433 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13434 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13435 | + } |
---|
| 13436 | + |
---|
11150 | 13437 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
11151 | 13438 | |
---|
11152 | 13439 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
11193 | 13480 | "\n" + |
---|
11194 | 13481 | "END\n"; |
---|
11195 | 13482 | |
---|
11196 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13483 | + if (Globals.DEBUG) |
---|
| 13484 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
11197 | 13485 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
11198 | 13486 | |
---|
11199 | 13487 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
11238 | 13526 | return out; |
---|
11239 | 13527 | } |
---|
11240 | 13528 | |
---|
11241 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13529 | + // Also does frustum culling |
---|
| 13530 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
11242 | 13531 | { |
---|
11243 | 13532 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
11244 | 13533 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
11245 | 13534 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13535 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13536 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
11246 | 13537 | "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;" + |
---|
| 13538 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13539 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
11251 | 13540 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
11252 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13541 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
11253 | 13542 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
11254 | 13543 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
11255 | 13544 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
11256 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13545 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
11257 | 13546 | |
---|
11258 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
11259 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13547 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13548 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
11260 | 13549 | } |
---|
11261 | 13550 | |
---|
11262 | 13551 | String Shadow(String depth, String shadow) |
---|
11263 | 13552 | { |
---|
11264 | 13553 | return "MAX temp.x, ndotl.x, one64th.x;" + |
---|
| 13554 | + "MIN temp.x, temp.x, ninetenth.x;" + |
---|
11265 | 13555 | /**/ |
---|
11266 | 13556 | // Sine |
---|
11267 | 13557 | "MUL temp.y, temp.x, temp.x;" + |
---|
.. | .. |
---|
11277 | 13567 | |
---|
11278 | 13568 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
11279 | 13569 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13570 | + |
---|
| 13571 | + // Compare fragment depth in light space with shadowmap. |
---|
11280 | 13572 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
11281 | 13573 | "SGE temp.y, temp.x, zero.x;" + |
---|
11282 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13574 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13575 | + |
---|
| 13576 | + // Reverse comparison |
---|
11283 | 13577 | "SUB temp.x, one.x, temp.x;" + |
---|
11284 | 13578 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
11285 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13579 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
11286 | 13580 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
11287 | 13581 | |
---|
11288 | 13582 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
11296 | 13590 | // No shadow for backface |
---|
11297 | 13591 | "DP3 temp.x, normal, lightd;" + |
---|
11298 | 13592 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13593 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13594 | + |
---|
| 13595 | + // No shadow when out of frustum |
---|
| 13596 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
11299 | 13597 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
11300 | 13598 | ""; |
---|
11301 | 13599 | } |
---|
.. | .. |
---|
11442 | 13740 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
11443 | 13741 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
11444 | 13742 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
11445 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13743 | + |
---|
| 13744 | + //Object3D.cVector2[] vector2buffer; |
---|
11446 | 13745 | |
---|
11447 | 13746 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
11448 | 13747 | // OUT : diff, spec |
---|
.. | .. |
---|
11458 | 13757 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
11459 | 13758 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
11460 | 13759 | //"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;" + |
---|
| 13760 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13761 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13762 | + |
---|
| 13763 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
11464 | 13764 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
11465 | 13765 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
11466 | 13766 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
11854 | 14154 | public void mousePressed(MouseEvent e) |
---|
11855 | 14155 | { |
---|
11856 | 14156 | //System.out.println("mousePressed: " + e); |
---|
11857 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14157 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
11858 | 14158 | } |
---|
11859 | 14159 | |
---|
11860 | 14160 | static long prevtime = 0; |
---|
.. | .. |
---|
11881 | 14181 | |
---|
11882 | 14182 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
11883 | 14183 | |
---|
| 14184 | + if (BUTTONLESSWHEEL) |
---|
11884 | 14185 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
11885 | 14186 | { |
---|
11886 | 14187 | return; |
---|
11887 | 14188 | } |
---|
11888 | 14189 | |
---|
| 14190 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
11889 | 14191 | |
---|
11890 | 14192 | // TIMER |
---|
11891 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR |
---|
| 14193 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
11892 | 14194 | { |
---|
11893 | 14195 | keepboxmode = BOXMODE; |
---|
11894 | 14196 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
11928 | 14230 | // mode |= META; |
---|
11929 | 14231 | //} |
---|
11930 | 14232 | |
---|
11931 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
11932 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 14233 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 14234 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
11933 | 14235 | anchorX = ax; |
---|
11934 | 14236 | anchorY = ay; |
---|
11935 | 14237 | prevX = px; |
---|
.. | .. |
---|
11963 | 14265 | else |
---|
11964 | 14266 | if (evt.getSource() == AAtimer) |
---|
11965 | 14267 | { |
---|
| 14268 | + Globals.TIMERRUNNING = false; |
---|
11966 | 14269 | if (mouseDown) |
---|
11967 | 14270 | { |
---|
11968 | 14271 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
11988 | 14291 | // LIVE = waslive; |
---|
11989 | 14292 | // wasliveok = true; |
---|
11990 | 14293 | // waslive = false; |
---|
| 14294 | + |
---|
| 14295 | + // May 2019 Forget it: |
---|
| 14296 | + if (true) |
---|
| 14297 | + return; |
---|
11991 | 14298 | |
---|
11992 | 14299 | // source == timer |
---|
11993 | 14300 | if (mouseDown) |
---|
.. | .. |
---|
12017 | 14324 | // ObjEditor.tweenManager.update(1f / 60f); |
---|
12018 | 14325 | |
---|
12019 | 14326 | // fev 2014??? |
---|
12020 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode) |
---|
12021 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14327 | + if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
| 14328 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
12022 | 14329 | pingthread.StepToTarget(true); // true); |
---|
12023 | 14330 | } |
---|
12024 | 14331 | // if (!LIVE) |
---|
.. | .. |
---|
12027 | 14334 | |
---|
12028 | 14335 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
12029 | 14336 | |
---|
12030 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14337 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
12031 | 14338 | { |
---|
12032 | 14339 | if (!wasliveok) |
---|
12033 | 14340 | return; |
---|
12034 | 14341 | |
---|
12035 | 14342 | AAtimer.restart(); // |
---|
| 14343 | + Globals.TIMERRUNNING = true; |
---|
12036 | 14344 | |
---|
12037 | 14345 | // waslive = LIVE; |
---|
12038 | 14346 | // LIVE = false; |
---|
.. | .. |
---|
12044 | 14352 | // touched = true; // main DL |
---|
12045 | 14353 | if (isRenderer) |
---|
12046 | 14354 | { |
---|
12047 | | - SetMouseMode(modifiers); |
---|
| 14355 | + SetMouseMode(modifiers, modifiersex); |
---|
12048 | 14356 | } |
---|
12049 | 14357 | |
---|
12050 | 14358 | selectX = anchorX = x; |
---|
.. | .. |
---|
12057 | 14365 | clicked = true; |
---|
12058 | 14366 | hold = false; |
---|
12059 | 14367 | |
---|
12060 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14368 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
12061 | 14369 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
12062 | 14370 | { |
---|
12063 | 14371 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
12082 | 14390 | drag = false; |
---|
12083 | 14391 | //System.out.println("Mouse DOWN"); |
---|
12084 | 14392 | 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); |
---|
| 14393 | + //ClickInfo info = new ClickInfo(); |
---|
| 14394 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14395 | + object.clickInfo.pane = this; |
---|
| 14396 | + object.clickInfo.camera = renderCamera; |
---|
| 14397 | + object.clickInfo.x = x; |
---|
| 14398 | + object.clickInfo.y = y; |
---|
| 14399 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14400 | + editObj = object.doEditClick(//info, |
---|
| 14401 | + 0); |
---|
12093 | 14402 | if (!editObj) |
---|
12094 | 14403 | { |
---|
12095 | 14404 | hasMarquee = true; |
---|
.. | .. |
---|
12105 | 14414 | |
---|
12106 | 14415 | public void mouseDragged(MouseEvent e) |
---|
12107 | 14416 | { |
---|
| 14417 | + Globals.MOUSEDRAGGED = true; |
---|
| 14418 | + |
---|
| 14419 | + //System.out.println("mouseDragged: " + e); |
---|
12108 | 14420 | if (isRenderer) |
---|
12109 | 14421 | movingcamera = true; |
---|
| 14422 | + |
---|
12110 | 14423 | //if (drawing) |
---|
12111 | 14424 | //return; |
---|
12112 | | - //System.out.println("mouseDragged: " + e); |
---|
12113 | 14425 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
12114 | 14426 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
12115 | 14427 | { |
---|
.. | .. |
---|
12117 | 14429 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12118 | 14430 | } |
---|
12119 | 14431 | else |
---|
12120 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14432 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12121 | 14433 | |
---|
12122 | 14434 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
12123 | 14435 | } |
---|
.. | .. |
---|
12129 | 14441 | cVector tmp = new cVector(); |
---|
12130 | 14442 | cVector tmp2 = new cVector(); |
---|
12131 | 14443 | boolean isMoving; |
---|
| 14444 | + |
---|
| 14445 | + public cVector TargetLookAt() |
---|
| 14446 | + { |
---|
| 14447 | + return targetLookAt; |
---|
| 14448 | + } |
---|
12132 | 14449 | |
---|
12133 | 14450 | class PingThread extends Thread |
---|
12134 | 14451 | { |
---|
.. | .. |
---|
12268 | 14585 | //System.out.println("---------------- ---------- Paint " + tmp.length2()); |
---|
12269 | 14586 | if (lightMode) |
---|
12270 | 14587 | { |
---|
12271 | | - lighttouched = true; |
---|
| 14588 | + Globals.lighttouched = true; |
---|
12272 | 14589 | } |
---|
12273 | 14590 | |
---|
12274 | 14591 | if (OEILONCE && OEIL) |
---|
.. | .. |
---|
12285 | 14602 | |
---|
12286 | 14603 | public void run() |
---|
12287 | 14604 | { |
---|
| 14605 | + new Exception().printStackTrace(); |
---|
12288 | 14606 | System.exit(0); |
---|
12289 | 14607 | for (;;) |
---|
12290 | 14608 | { |
---|
.. | .. |
---|
12326 | 14644 | mouseDown = false; |
---|
12327 | 14645 | if (lightMode) |
---|
12328 | 14646 | { |
---|
12329 | | - lighttouched = true; |
---|
| 14647 | + Globals.lighttouched = true; |
---|
12330 | 14648 | } |
---|
12331 | 14649 | repaint(); |
---|
12332 | 14650 | alreadypainted = true; |
---|
.. | .. |
---|
12334 | 14652 | isMoving = false; |
---|
12335 | 14653 | } //?? |
---|
12336 | 14654 | |
---|
12337 | | - if (isLIVE() && !alreadypainted) |
---|
| 14655 | + if (Globals.isLIVE() && !alreadypainted) |
---|
12338 | 14656 | { |
---|
12339 | 14657 | // FOR DEBUG BREAKPOINT USING PAUSE: while (true) |
---|
12340 | 14658 | repaint(); |
---|
.. | .. |
---|
12346 | 14664 | { |
---|
12347 | 14665 | if (lightMode) |
---|
12348 | 14666 | { |
---|
12349 | | - lighttouched = true; |
---|
| 14667 | + Globals.lighttouched = true; |
---|
12350 | 14668 | } |
---|
12351 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14669 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
12352 | 14670 | } |
---|
12353 | 14671 | //else |
---|
12354 | 14672 | } |
---|
.. | .. |
---|
12362 | 14680 | void GoDown(int mod) |
---|
12363 | 14681 | { |
---|
12364 | 14682 | MODIFIERS |= COMMAND; |
---|
12365 | | - /* |
---|
| 14683 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14684 | + /**/ |
---|
12366 | 14685 | if((mod&SHIFT) == SHIFT) |
---|
12367 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14686 | + { |
---|
| 14687 | + if (isVR) |
---|
| 14688 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14689 | + else |
---|
| 14690 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14691 | + } |
---|
12368 | 14692 | else |
---|
12369 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
12370 | | - */ |
---|
| 14693 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14694 | + /**/ |
---|
12371 | 14695 | if ((mod & SHIFT) == SHIFT) |
---|
12372 | 14696 | { |
---|
12373 | 14697 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
12376 | 14700 | mouseMode |= BACKFORTH; |
---|
12377 | 14701 | } |
---|
12378 | 14702 | |
---|
| 14703 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14704 | + |
---|
12379 | 14705 | //prevX = X = anchorX; |
---|
12380 | 14706 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
12381 | 14707 | } |
---|
.. | .. |
---|
12383 | 14709 | void GoUp(int mod) |
---|
12384 | 14710 | { |
---|
12385 | 14711 | MODIFIERS |= COMMAND; |
---|
12386 | | - /* |
---|
| 14712 | + /**/ |
---|
| 14713 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14714 | + |
---|
12387 | 14715 | if((mod&SHIFT) == SHIFT) |
---|
12388 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14716 | + { |
---|
| 14717 | + if (isVR) |
---|
| 14718 | + manipCamera.RotateInterest(0, speed); |
---|
| 14719 | + else |
---|
| 14720 | + manipCamera.RotatePosition(0, speed); |
---|
| 14721 | + } |
---|
12389 | 14722 | else |
---|
12390 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
12391 | | - */ |
---|
| 14723 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14724 | + /**/ |
---|
12392 | 14725 | if ((mod & SHIFT) == SHIFT) |
---|
12393 | 14726 | { |
---|
12394 | 14727 | mouseMode = mouseMode; |
---|
.. | .. |
---|
12397 | 14730 | mouseMode |= BACKFORTH; |
---|
12398 | 14731 | } |
---|
12399 | 14732 | |
---|
| 14733 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14734 | + |
---|
12400 | 14735 | //prevX = X = anchorX; |
---|
12401 | 14736 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
12402 | 14737 | } |
---|
.. | .. |
---|
12404 | 14739 | void GoLeft(int mod) |
---|
12405 | 14740 | { |
---|
12406 | 14741 | MODIFIERS |= COMMAND; |
---|
12407 | | - /* |
---|
| 14742 | + /**/ |
---|
12408 | 14743 | if((mod&SHIFT) == SHIFT) |
---|
12409 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14744 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
12410 | 14745 | else |
---|
12411 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
12412 | | - */ |
---|
| 14746 | + { |
---|
| 14747 | + if ((mouseMode&VR)!=0) |
---|
| 14748 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14749 | + else |
---|
| 14750 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14751 | + } |
---|
| 14752 | + /**/ |
---|
12413 | 14753 | if ((mod & SHIFT) == SHIFT) |
---|
12414 | 14754 | { |
---|
12415 | 14755 | mouseMode = mouseMode; |
---|
.. | .. |
---|
12418 | 14758 | mouseMode |= ROTATE; |
---|
12419 | 14759 | } // TRANSLATE; |
---|
12420 | 14760 | |
---|
| 14761 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14762 | + |
---|
12421 | 14763 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
12422 | 14764 | prevY = Y = anchorY; |
---|
12423 | 14765 | } |
---|
.. | .. |
---|
12425 | 14767 | void GoRight(int mod) |
---|
12426 | 14768 | { |
---|
12427 | 14769 | MODIFIERS |= COMMAND; |
---|
12428 | | - /* |
---|
| 14770 | + /**/ |
---|
12429 | 14771 | if((mod&SHIFT) == SHIFT) |
---|
12430 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14772 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
12431 | 14773 | else |
---|
12432 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
12433 | | - */ |
---|
| 14774 | + { |
---|
| 14775 | + if ((mouseMode&VR)!=0) |
---|
| 14776 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14777 | + else |
---|
| 14778 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14779 | + } |
---|
| 14780 | + |
---|
| 14781 | + /**/ |
---|
12434 | 14782 | if ((mod & SHIFT) == SHIFT) |
---|
12435 | 14783 | { |
---|
12436 | 14784 | mouseMode = mouseMode; |
---|
.. | .. |
---|
12439 | 14787 | mouseMode |= ROTATE; |
---|
12440 | 14788 | } // TRANSLATE; |
---|
12441 | 14789 | |
---|
| 14790 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14791 | + |
---|
12442 | 14792 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
12443 | 14793 | prevY = Y = anchorY; |
---|
12444 | 14794 | } |
---|
.. | .. |
---|
12448 | 14798 | int X, Y; |
---|
12449 | 14799 | boolean SX, SY; |
---|
12450 | 14800 | |
---|
12451 | | - void drag(int x, int y, int modifiers) |
---|
| 14801 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
12452 | 14802 | { |
---|
12453 | 14803 | if (IsFrozen()) |
---|
12454 | 14804 | { |
---|
.. | .. |
---|
12457 | 14807 | |
---|
12458 | 14808 | drag = true; // NEW |
---|
12459 | 14809 | |
---|
12460 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14810 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
12461 | 14811 | |
---|
12462 | 14812 | X = x; |
---|
12463 | 14813 | Y = y; |
---|
12464 | 14814 | // floating state for animation |
---|
12465 | | - MODIFIERS = modifiers; |
---|
12466 | | - modifiers &= ~1024; |
---|
| 14815 | + MODIFIERS = modifiersex; |
---|
| 14816 | + modifiersex &= ~1024; |
---|
12467 | 14817 | if (false) // modifiers != 0) |
---|
12468 | 14818 | { |
---|
12469 | 14819 | //new Exception().printStackTrace(); |
---|
12470 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14820 | + System.out.println("mouseDragged: " + modifiersex); |
---|
12471 | 14821 | System.out.println("SHIFT = " + SHIFT); |
---|
12472 | 14822 | System.out.println("CONTROL = " + COMMAND); |
---|
12473 | 14823 | System.out.println("META = " + META); |
---|
.. | .. |
---|
12480 | 14830 | if (editObj) |
---|
12481 | 14831 | { |
---|
12482 | 14832 | drag = true; |
---|
12483 | | - ClickInfo info = new ClickInfo(); |
---|
12484 | | - info.bounds.setBounds(0, 0, |
---|
| 14833 | + //ClickInfo info = new ClickInfo(); |
---|
| 14834 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
12485 | 14835 | (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); |
---|
| 14836 | + object.clickInfo.pane = this; |
---|
| 14837 | + object.clickInfo.camera = renderCamera; |
---|
| 14838 | + object.clickInfo.x = x; |
---|
| 14839 | + object.clickInfo.y = y; |
---|
| 14840 | + object //.GetWindow().copy |
---|
| 14841 | + .doEditDrag(//info, |
---|
| 14842 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
12491 | 14843 | } else |
---|
12492 | 14844 | { |
---|
12493 | 14845 | if (x < startX) |
---|
.. | .. |
---|
12589 | 14941 | { |
---|
12590 | 14942 | manipCamera.Translate(dx, dy, getWidth()); |
---|
12591 | 14943 | } |
---|
| 14944 | + else |
---|
12592 | 14945 | if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0) |
---|
12593 | 14946 | { |
---|
12594 | 14947 | manipCamera.RotateInterest(dx, dy); |
---|
.. | .. |
---|
12599 | 14952 | |
---|
12600 | 14953 | if (manipCamera == lightCamera) |
---|
12601 | 14954 | { |
---|
12602 | | - lighttouched = true; |
---|
| 14955 | + Globals.lighttouched = true; |
---|
12603 | 14956 | } |
---|
12604 | 14957 | /* |
---|
12605 | 14958 | switch (mode) |
---|
.. | .. |
---|
12635 | 14988 | } |
---|
12636 | 14989 | } |
---|
12637 | 14990 | |
---|
| 14991 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14992 | + |
---|
12638 | 14993 | public void mouseMoved(MouseEvent e) |
---|
12639 | 14994 | { |
---|
12640 | 14995 | //System.out.println("mouseMoved: " + e); |
---|
12641 | | - |
---|
12642 | 14996 | if (isRenderer) |
---|
12643 | 14997 | return; |
---|
12644 | 14998 | |
---|
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; |
---|
| 14999 | + // Mouse cursor feedback |
---|
| 15000 | + object.clickInfo.x = e.getX(); |
---|
| 15001 | + object.clickInfo.y = e.getY(); |
---|
| 15002 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 15003 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 15004 | + object.clickInfo.pane = this; |
---|
| 15005 | + object.clickInfo.camera = renderCamera; |
---|
12652 | 15006 | if (!isRenderer) |
---|
12653 | 15007 | { |
---|
12654 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 15008 | + //ObjEditor editWindow = object.editWindow; |
---|
| 15009 | + //Object3D copy = editWindow.copy; |
---|
| 15010 | + if (object.doEditClick(//clickInfo, |
---|
| 15011 | + 0)) |
---|
12655 | 15012 | { |
---|
12656 | 15013 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
12657 | 15014 | } else |
---|
.. | .. |
---|
12663 | 15020 | |
---|
12664 | 15021 | public void mouseReleased(MouseEvent e) |
---|
12665 | 15022 | { |
---|
| 15023 | + Globals.MOUSEDRAGGED = false; |
---|
| 15024 | + |
---|
12666 | 15025 | movingcamera = false; |
---|
| 15026 | + X = 0; // getBounds().width/2; |
---|
| 15027 | + Y = 0; // getBounds().height/2; |
---|
12667 | 15028 | //System.out.println("mouseReleased: " + e); |
---|
12668 | 15029 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12669 | 15030 | } |
---|
.. | .. |
---|
12686 | 15047 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
12687 | 15048 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
12688 | 15049 | |
---|
12689 | | - if (control || command || IsFrozen()) |
---|
| 15050 | +// No delay if (control || command || IsFrozen()) |
---|
12690 | 15051 | timeout = true; |
---|
12691 | | - else |
---|
| 15052 | +// ?? May 2019 else |
---|
12692 | 15053 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
12693 | 15054 | mouseDown = false; |
---|
12694 | 15055 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
12798 | 15159 | System.out.println("keyReleased: " + e); |
---|
12799 | 15160 | } |
---|
12800 | 15161 | |
---|
12801 | | - void SetMouseMode(int modifiers) |
---|
| 15162 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
12802 | 15163 | { |
---|
12803 | 15164 | //System.out.println("SetMouseMode = " + modifiers); |
---|
12804 | 15165 | //modifiers &= ~1024; |
---|
.. | .. |
---|
12810 | 15171 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
12811 | 15172 | // return; |
---|
12812 | 15173 | //System.out.println("SetMode = " + modifiers); |
---|
12813 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 15174 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
12814 | 15175 | { |
---|
12815 | 15176 | mouseMode |= ZOOM; |
---|
12816 | 15177 | } |
---|
12817 | | - if ((modifiers & META) == META) |
---|
| 15178 | + |
---|
| 15179 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
| 15180 | + if (capsLocked) // || (modifiers & META) == META) |
---|
12818 | 15181 | { |
---|
12819 | 15182 | mouseMode |= VR; // BACKFORTH; |
---|
12820 | 15183 | } |
---|
12821 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
12822 | | - { |
---|
12823 | | - mouseMode |= SELECT; // BACKFORTH; |
---|
12824 | | - } |
---|
12825 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 15184 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
12826 | 15185 | { |
---|
12827 | 15186 | mouseMode |= SELECT; |
---|
12828 | 15187 | } |
---|
12829 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 15188 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
12830 | 15189 | { |
---|
| 15190 | + mouseMode |= SELECT; |
---|
| 15191 | + } |
---|
| 15192 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
| 15193 | + { |
---|
| 15194 | + mouseMode &= ~VR; |
---|
12831 | 15195 | mouseMode |= TRANSLATE; |
---|
12832 | 15196 | } |
---|
12833 | 15197 | // if ((modifiers & SHIFT_META) == SHIFT_META) |
---|
.. | .. |
---|
12854 | 15218 | |
---|
12855 | 15219 | if (isRenderer) // |
---|
12856 | 15220 | { |
---|
12857 | | - SetMouseMode(modifiers); |
---|
| 15221 | + SetMouseMode(0, modifiers); |
---|
12858 | 15222 | } |
---|
12859 | 15223 | |
---|
12860 | | - theRenderer.keyPressed(key); |
---|
| 15224 | + Globals.theRenderer.keyPressed(key); |
---|
12861 | 15225 | } |
---|
12862 | 15226 | |
---|
12863 | 15227 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
12869 | 15233 | float SATPOW = 1; // 2; // 0.5f; |
---|
12870 | 15234 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
12871 | 15235 | |
---|
12872 | | - void keyPressed(int key) |
---|
| 15236 | + public void keyPressed(int key) |
---|
12873 | 15237 | { |
---|
12874 | 15238 | if (key >= '0' && key <= '5') |
---|
12875 | 15239 | clampbit = (key-'0'); |
---|
.. | .. |
---|
12916 | 15280 | // break; |
---|
12917 | 15281 | case 'T': |
---|
12918 | 15282 | CACHETEXTURE ^= true; |
---|
12919 | | - textures.clear(); |
---|
| 15283 | + texturepigment.clear(); |
---|
| 15284 | + texturebump.clear(); |
---|
12920 | 15285 | // repaint(); |
---|
12921 | 15286 | break; |
---|
12922 | 15287 | case 'Y': |
---|
.. | .. |
---|
12926 | 15291 | case 'K': |
---|
12927 | 15292 | KOMPACTTEXTURE ^= true; |
---|
12928 | 15293 | //textures.clear(); |
---|
12929 | | - break; |
---|
12930 | | - case 'P': // Texture Projection macros |
---|
| 15294 | + // break; |
---|
| 15295 | + //case 'P': // Texture Projection macros |
---|
12931 | 15296 | // SAVETEXTURE ^= true; |
---|
12932 | 15297 | macromode = true; |
---|
12933 | 15298 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
12984 | 15349 | case 'B': |
---|
12985 | 15350 | BRISMOOTH ^= true; |
---|
12986 | 15351 | SHADOWCULLFACE ^= true; |
---|
12987 | | - lighttouched = true; |
---|
| 15352 | + Globals.lighttouched = true; |
---|
12988 | 15353 | repaint(); |
---|
12989 | 15354 | break; |
---|
12990 | 15355 | case 'b': |
---|
.. | .. |
---|
13001 | 15366 | case 'E' : COMPACT ^= true; |
---|
13002 | 15367 | repaint(); |
---|
13003 | 15368 | break; |
---|
13004 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15369 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15370 | + //DEBUGHSB ^= true; |
---|
| 15371 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
13005 | 15372 | repaint(); |
---|
13006 | 15373 | break; |
---|
13007 | 15374 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
13026 | 15393 | RevertCamera(); |
---|
13027 | 15394 | repaint(); |
---|
13028 | 15395 | break; |
---|
13029 | | - case 'L': |
---|
13030 | 15396 | case 'l': |
---|
| 15397 | + //case 'L': |
---|
13031 | 15398 | if (lightMode) |
---|
13032 | 15399 | { |
---|
13033 | 15400 | lightMode = false; |
---|
.. | .. |
---|
13046 | 15413 | targetLookAt.set(manipCamera.lookAt); |
---|
13047 | 15414 | repaint(); |
---|
13048 | 15415 | break; |
---|
13049 | | - case 'p': |
---|
| 15416 | + case 'P': // p': |
---|
13050 | 15417 | // c'est quoi ca au juste? spherical ^= true; |
---|
13051 | 15418 | Skinshader ^= true; programInitialized = false; |
---|
13052 | 15419 | repaint(); |
---|
.. | .. |
---|
13084 | 15451 | repaint(); |
---|
13085 | 15452 | break; |
---|
13086 | 15453 | case 'O': |
---|
13087 | | - drawMode = OCCLUSION; |
---|
| 15454 | + Globals.drawMode = OCCLUSION; // WARNING |
---|
13088 | 15455 | repaint(); |
---|
13089 | 15456 | break; |
---|
13090 | 15457 | case 'o': |
---|
13091 | 15458 | OCCLUSION_CULLING ^= true; |
---|
13092 | 15459 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
13093 | 15460 | break; |
---|
13094 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15461 | + //case '0': envyoff ^= true; repaint(); break; |
---|
13095 | 15462 | case '1': |
---|
13096 | 15463 | case '2': |
---|
13097 | 15464 | case '3': |
---|
13098 | 15465 | case '4': |
---|
13099 | 15466 | case '5': |
---|
13100 | | - newenvy = Character.getNumericValue(key); |
---|
13101 | | - repaint(); |
---|
13102 | | - break; |
---|
13103 | 15467 | case '6': |
---|
13104 | 15468 | case '7': |
---|
13105 | 15469 | case '8': |
---|
13106 | 15470 | case '9': |
---|
13107 | | - BGcolor = (key - '6')/3.f; |
---|
| 15471 | + if (true) // envyoff) |
---|
| 15472 | + { |
---|
| 15473 | + BGcolor = (key - '1')/8.f; |
---|
| 15474 | + } |
---|
| 15475 | + else |
---|
| 15476 | + { |
---|
| 15477 | + //newenvy = Character.getNumericValue(key); |
---|
| 15478 | + } |
---|
13108 | 15479 | repaint(); |
---|
13109 | 15480 | break; |
---|
13110 | 15481 | case '!': |
---|
.. | .. |
---|
13170 | 15541 | case '_': |
---|
13171 | 15542 | kompactbit = 5; |
---|
13172 | 15543 | break; |
---|
13173 | | - case '+': |
---|
13174 | | - kompactbit = 6; |
---|
13175 | | - break; |
---|
| 15544 | +// case '+': |
---|
| 15545 | +// kompactbit = 6; |
---|
| 15546 | +// break; |
---|
13176 | 15547 | case ' ': |
---|
13177 | 15548 | lightMode ^= true; |
---|
13178 | | - lighttouched = true; |
---|
| 15549 | + Globals.lighttouched = true; |
---|
13179 | 15550 | manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
13180 | 15551 | targetLookAt.set(manipCamera.lookAt); |
---|
13181 | 15552 | repaint(); |
---|
.. | .. |
---|
13184 | 15555 | case ESC: |
---|
13185 | 15556 | RENDERPROGRAM += 1; |
---|
13186 | 15557 | RENDERPROGRAM %= 3; |
---|
| 15558 | + |
---|
13187 | 15559 | repaint(); |
---|
13188 | 15560 | break; |
---|
13189 | 15561 | case 'Z': |
---|
13190 | | - RESIZETEXTURE ^= true; |
---|
13191 | | - break; |
---|
| 15562 | + //RESIZETEXTURE ^= true; |
---|
| 15563 | + //break; |
---|
13192 | 15564 | case 'z': |
---|
13193 | | - RENDERSHADOW ^= true; |
---|
13194 | | - lighttouched = true; |
---|
| 15565 | + Globals.RENDERSHADOW ^= true; |
---|
| 15566 | + Globals.lighttouched = true; |
---|
13195 | 15567 | repaint(); |
---|
13196 | 15568 | break; |
---|
13197 | 15569 | //case UP: |
---|
.. | .. |
---|
13217 | 15589 | FlipTransform(); |
---|
13218 | 15590 | break; |
---|
13219 | 15591 | case ENTER: |
---|
13220 | | - object.editWindow.ScreenFit(); // Edit(); |
---|
| 15592 | + // object.editWindow.ScreenFit(); // Edit(); |
---|
| 15593 | + ToggleLive(); |
---|
13221 | 15594 | break; |
---|
13222 | 15595 | case DELETE: |
---|
13223 | 15596 | ClearSelection(); |
---|
13224 | 15597 | break; |
---|
13225 | | - /* |
---|
13226 | 15598 | case '+': |
---|
| 15599 | + |
---|
| 15600 | + /* |
---|
13227 | 15601 | //fontsize += 1; |
---|
13228 | 15602 | bbzoom *= 2; |
---|
13229 | 15603 | repaint(); |
---|
.. | .. |
---|
13240 | 15614 | case '=': |
---|
13241 | 15615 | IncDepth(); |
---|
13242 | 15616 | //fontsize += 1; |
---|
13243 | | - object.editWindow.refreshContents(true); |
---|
| 15617 | + object.GetWindow().refreshContents(true); |
---|
13244 | 15618 | maskbit = 6; |
---|
13245 | 15619 | break; |
---|
13246 | 15620 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
13247 | 15621 | DecDepth(); |
---|
13248 | 15622 | maskbit = 5; |
---|
13249 | 15623 | //if(fontsize > 1) fontsize -= 1; |
---|
13250 | | - if (object.editWindow == null) |
---|
13251 | | - new Exception().printStackTrace(); |
---|
13252 | | - else |
---|
13253 | | - object.editWindow.refreshContents(true); |
---|
| 15624 | +// if (object.editWindow == null) |
---|
| 15625 | +// new Exception().printStackTrace(); |
---|
| 15626 | +// else |
---|
| 15627 | + object.GetWindow().refreshContents(true); |
---|
13254 | 15628 | break; |
---|
13255 | 15629 | case '{': |
---|
13256 | 15630 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
13305 | 15679 | } |
---|
13306 | 15680 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
13307 | 15681 | } |
---|
| 15682 | + |
---|
13308 | 15683 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
13309 | 15684 | |
---|
13310 | 15685 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
13312 | 15687 | //mode = ROTATE; |
---|
13313 | 15688 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
13314 | 15689 | { |
---|
13315 | | - SetMouseMode(modifiers); |
---|
| 15690 | + SetMouseMode(0, modifiers); |
---|
13316 | 15691 | } |
---|
13317 | 15692 | } |
---|
13318 | 15693 | |
---|
13319 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 15694 | + public void processKeyEvent(KeyEvent e) |
---|
13320 | 15695 | { |
---|
13321 | 15696 | switch (e.getID()) |
---|
13322 | 15697 | { |
---|
.. | .. |
---|
13446 | 15821 | |
---|
13447 | 15822 | protected void processMouseMotionEvent(MouseEvent e) |
---|
13448 | 15823 | { |
---|
13449 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
13450 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15824 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15825 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15826 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
13451 | 15827 | { |
---|
13452 | 15828 | mouseMoved(e); |
---|
13453 | 15829 | } else |
---|
.. | .. |
---|
13472 | 15848 | } |
---|
13473 | 15849 | */ |
---|
13474 | 15850 | |
---|
13475 | | - object.editWindow.EditSelection(); |
---|
| 15851 | + object.GetWindow().EditSelection(false); |
---|
13476 | 15852 | } |
---|
13477 | 15853 | |
---|
13478 | 15854 | void SelectParent() |
---|
13479 | 15855 | { |
---|
| 15856 | + new Exception().printStackTrace(); |
---|
13480 | 15857 | System.exit(0); |
---|
13481 | 15858 | Composite group = (Composite) object; |
---|
13482 | 15859 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
13488 | 15865 | { |
---|
13489 | 15866 | //selectees.remove(i); |
---|
13490 | 15867 | System.out.println("select parent of " + elem); |
---|
13491 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15868 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
13492 | 15869 | } else |
---|
13493 | 15870 | { |
---|
13494 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15871 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
13495 | 15872 | } |
---|
13496 | 15873 | |
---|
13497 | 15874 | first = false; |
---|
.. | .. |
---|
13500 | 15877 | |
---|
13501 | 15878 | void SelectChildren() |
---|
13502 | 15879 | { |
---|
| 15880 | + new Exception().printStackTrace(); |
---|
13503 | 15881 | System.exit(0); |
---|
13504 | 15882 | /* |
---|
13505 | 15883 | Composite group = (Composite) object; |
---|
.. | .. |
---|
13532 | 15910 | for (int j = 0; j < group.children.size(); j++) |
---|
13533 | 15911 | { |
---|
13534 | 15912 | elem = (Object3D) group.children.elementAt(j); |
---|
13535 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15913 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
13536 | 15914 | first = false; |
---|
13537 | 15915 | } |
---|
13538 | 15916 | } else |
---|
13539 | 15917 | { |
---|
13540 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15918 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
13541 | 15919 | } |
---|
13542 | 15920 | |
---|
13543 | 15921 | first = false; |
---|
.. | .. |
---|
13548 | 15926 | { |
---|
13549 | 15927 | //Composite group = (Composite) object; |
---|
13550 | 15928 | Object3D group = object; |
---|
13551 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15929 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
13552 | 15930 | } |
---|
13553 | 15931 | |
---|
13554 | 15932 | void ResetTransform(int mask) |
---|
13555 | 15933 | { |
---|
13556 | 15934 | //Composite group = (Composite) object; |
---|
13557 | 15935 | Object3D group = object; |
---|
13558 | | - group.editWindow.ResetTransform(mask); |
---|
| 15936 | + group.GetWindow().ResetTransform(mask); |
---|
13559 | 15937 | } |
---|
13560 | 15938 | |
---|
13561 | 15939 | void FlipTransform() |
---|
13562 | 15940 | { |
---|
13563 | 15941 | //Composite group = (Composite) object; |
---|
13564 | 15942 | Object3D group = object; |
---|
13565 | | - group.editWindow.FlipTransform(); |
---|
| 15943 | + group.GetWindow().FlipTransform(); |
---|
13566 | 15944 | // group.editWindow.ReduceMesh(true); |
---|
13567 | 15945 | } |
---|
13568 | 15946 | |
---|
.. | .. |
---|
13570 | 15948 | { |
---|
13571 | 15949 | //Composite group = (Composite) object; |
---|
13572 | 15950 | Object3D group = object; |
---|
13573 | | - group.editWindow.PrintMemory(); |
---|
| 15951 | + group.GetWindow().PrintMemory(); |
---|
13574 | 15952 | // group.editWindow.ReduceMesh(true); |
---|
13575 | 15953 | } |
---|
13576 | 15954 | |
---|
.. | .. |
---|
13578 | 15956 | { |
---|
13579 | 15957 | //Composite group = (Composite) object; |
---|
13580 | 15958 | Object3D group = object; |
---|
13581 | | - group.editWindow.ResetCentroid(); |
---|
| 15959 | + group.GetWindow().ResetCentroid(); |
---|
13582 | 15960 | } |
---|
13583 | 15961 | |
---|
13584 | 15962 | void IncDepth() |
---|
.. | .. |
---|
13660 | 16038 | |
---|
13661 | 16039 | int width = getBounds().width; |
---|
13662 | 16040 | int height = getBounds().height; |
---|
13663 | | - ClickInfo info = new ClickInfo(); |
---|
13664 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
13665 | 16041 | //Image img = CreateImage(width, height); |
---|
13666 | 16042 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 16043 | + |
---|
13667 | 16044 | Graphics gr = g; // img.getGraphics(); |
---|
| 16045 | + |
---|
13668 | 16046 | if (!hasMarquee) |
---|
13669 | 16047 | { |
---|
13670 | 16048 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
13736 | 16114 | } |
---|
13737 | 16115 | if (object != null && !hasMarquee) |
---|
13738 | 16116 | { |
---|
| 16117 | + if (object.clickInfo == null) |
---|
| 16118 | + object.clickInfo = new ClickInfo(); |
---|
| 16119 | + ClickInfo info = object.clickInfo; |
---|
| 16120 | + //ClickInfo info = new ClickInfo(); |
---|
| 16121 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16122 | + |
---|
13739 | 16123 | if (isRenderer) |
---|
13740 | 16124 | { |
---|
13741 | | - info.flags++; |
---|
| 16125 | + object.clickInfo.flags++; |
---|
13742 | 16126 | double frameAspect = (double) width / (double) height; |
---|
13743 | 16127 | if (frameAspect > renderCamera.aspect) |
---|
13744 | 16128 | { |
---|
13745 | 16129 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
13746 | | - info.bounds.width -= width - desired; |
---|
13747 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16130 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16131 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
13748 | 16132 | } else |
---|
13749 | 16133 | { |
---|
13750 | 16134 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
13751 | | - info.bounds.height -= height - desired; |
---|
13752 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16135 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16136 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
13753 | 16137 | } |
---|
13754 | 16138 | } |
---|
13755 | | - info.g = gr; |
---|
13756 | | - info.camera = renderCamera; |
---|
| 16139 | + |
---|
| 16140 | + object.clickInfo.g = gr; |
---|
| 16141 | + object.clickInfo.camera = renderCamera; |
---|
13757 | 16142 | /* |
---|
13758 | 16143 | // Memory intensive (brep.verticescopy) |
---|
13759 | 16144 | if (!(object instanceof Composite)) |
---|
13760 | 16145 | object.draw(info, 0, false); // SLOW : |
---|
13761 | 16146 | */ |
---|
13762 | | - if (!isRenderer) |
---|
| 16147 | + if (!isRenderer) // && drag) |
---|
13763 | 16148 | { |
---|
13764 | | - object.drawEditHandles(info, 0); |
---|
| 16149 | + Grafreed.Assert(object != null); |
---|
| 16150 | + Grafreed.Assert(object.selection != null); |
---|
| 16151 | + if (object.selection.Size() > 0) |
---|
| 16152 | + { |
---|
| 16153 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16154 | + |
---|
| 16155 | + object.clickInfo.DX = 0; |
---|
| 16156 | + object.clickInfo.DY = 0; |
---|
| 16157 | + object.clickInfo.W = 1; |
---|
| 16158 | + if (hitSomething == Object3D.hitCenter) |
---|
| 16159 | + { |
---|
| 16160 | + info.DX = X; |
---|
| 16161 | + if (X != 0) |
---|
| 16162 | + info.DX -= info.bounds.width/2; |
---|
| 16163 | + |
---|
| 16164 | + info.DY = Y; |
---|
| 16165 | + if (Y != 0) |
---|
| 16166 | + info.DY -= info.bounds.height/2; |
---|
| 16167 | + } |
---|
| 16168 | + |
---|
| 16169 | + object.drawEditHandles(//info, |
---|
| 16170 | + 0); |
---|
| 16171 | + |
---|
| 16172 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16173 | + { |
---|
| 16174 | + switch (hitSomething) |
---|
| 16175 | + { |
---|
| 16176 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
| 16177 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16178 | + break; |
---|
| 16179 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16180 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16181 | + break; |
---|
| 16182 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16183 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16184 | + break; |
---|
| 16185 | + } |
---|
| 16186 | + |
---|
| 16187 | + } |
---|
| 16188 | + } |
---|
13765 | 16189 | } |
---|
13766 | 16190 | } |
---|
| 16191 | + |
---|
13767 | 16192 | if (isRenderer) |
---|
13768 | 16193 | { |
---|
13769 | 16194 | //gr.setColor(Color.black); |
---|
13770 | 16195 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
13771 | 16196 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
13772 | 16197 | } |
---|
| 16198 | + |
---|
13773 | 16199 | if (hasMarquee) |
---|
13774 | 16200 | { |
---|
13775 | 16201 | gr.setXORMode(Color.white); |
---|
13776 | | - gr.setColor(Color.red); |
---|
| 16202 | + gr.setColor(Color.white); |
---|
13777 | 16203 | if (!firstime) |
---|
13778 | 16204 | { |
---|
13779 | 16205 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
13792 | 16218 | //if (g != gr) g.drawImage(img, 0, 0, width, height, null); |
---|
13793 | 16219 | } |
---|
13794 | 16220 | |
---|
| 16221 | + // To avoid clear. |
---|
13795 | 16222 | public void update(Graphics g) |
---|
13796 | 16223 | { |
---|
13797 | 16224 | paint(g); |
---|
.. | .. |
---|
13881 | 16308 | public boolean mouseDown(Event evt, int x, int y) |
---|
13882 | 16309 | { |
---|
13883 | 16310 | System.out.println("mouseDown: " + evt); |
---|
| 16311 | + System.exit(0); |
---|
13884 | 16312 | /* |
---|
13885 | 16313 | locked = true; |
---|
13886 | 16314 | drag = false; |
---|
.. | .. |
---|
13924 | 16352 | { |
---|
13925 | 16353 | keyPressed(0, modifiers); |
---|
13926 | 16354 | } |
---|
13927 | | - clickStart(x, y, modifiers); |
---|
| 16355 | + // clickStart(x, y, modifiers); |
---|
13928 | 16356 | return true; |
---|
13929 | 16357 | } |
---|
13930 | 16358 | |
---|
.. | .. |
---|
14042 | 16470 | { |
---|
14043 | 16471 | keyReleased(0, 0); |
---|
14044 | 16472 | } |
---|
14045 | | - drag(x, y, modifiers); |
---|
| 16473 | + drag(x, y, 0, modifiers); |
---|
14046 | 16474 | return true; |
---|
14047 | 16475 | } |
---|
14048 | 16476 | |
---|
.. | .. |
---|
14174 | 16602 | Object3D object; |
---|
14175 | 16603 | static Object3D trackedobject; |
---|
14176 | 16604 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
14177 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16605 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
14178 | 16606 | /*static*/ Camera eyeCamera; |
---|
14179 | 16607 | /*static*/ Camera lightCamera; |
---|
14180 | 16608 | int cameracount; |
---|
.. | .. |
---|
14238 | 16666 | private /*static*/ boolean firstime; |
---|
14239 | 16667 | private /*static*/ cVector newView = new cVector(); |
---|
14240 | 16668 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16669 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16670 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
14241 | 16671 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
14242 | 16672 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
14243 | 16673 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
14250 | 16680 | { |
---|
14251 | 16681 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
14252 | 16682 | |
---|
| 16683 | + int usedsuf = 0; |
---|
| 16684 | + |
---|
14253 | 16685 | for (int i = 0; i < suffixes.length; i++) |
---|
14254 | 16686 | { |
---|
14255 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
14256 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
14257 | | - mipmapped, |
---|
14258 | | - FileUtil.getFileSuffix(resourceName)); |
---|
14259 | | - if (data == null) |
---|
| 16687 | + String[] suffixe = suffixes; |
---|
| 16688 | + String[] fallback = suffixes2; |
---|
| 16689 | + String[] fallfallback = suffixes3; |
---|
| 16690 | + |
---|
| 16691 | + for (int c=usedsuf; --c>=0;) |
---|
14260 | 16692 | { |
---|
14261 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16693 | +// String[] temp = suffixe; |
---|
| 16694 | +// suffixe = fallback; |
---|
| 16695 | +// fallback = fallfallback; |
---|
| 16696 | +// fallfallback = temp; |
---|
14262 | 16697 | } |
---|
| 16698 | + |
---|
| 16699 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16700 | + TextureData data; |
---|
| 16701 | + |
---|
| 16702 | + try |
---|
| 16703 | + { |
---|
| 16704 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16705 | + mipmapped, |
---|
| 16706 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16707 | + } |
---|
| 16708 | + catch (Exception e) |
---|
| 16709 | + { |
---|
| 16710 | + try |
---|
| 16711 | + { |
---|
| 16712 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16713 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16714 | + mipmapped, |
---|
| 16715 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16716 | + } |
---|
| 16717 | + catch (Exception e2) |
---|
| 16718 | + { |
---|
| 16719 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16720 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16721 | + mipmapped, |
---|
| 16722 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16723 | + } |
---|
| 16724 | + } |
---|
| 16725 | + |
---|
14263 | 16726 | //System.out.println("Target = " + targets[i]); |
---|
14264 | 16727 | cubemap.updateImage(data, targets[i]); |
---|
14265 | 16728 | } |
---|
14266 | 16729 | |
---|
14267 | 16730 | return cubemap; |
---|
14268 | 16731 | } |
---|
| 16732 | + |
---|
14269 | 16733 | int bigsphere = -1; |
---|
14270 | 16734 | |
---|
14271 | 16735 | float BGcolor = 0.5f; |
---|
14272 | 16736 | |
---|
14273 | | - private void DrawSkyBox(GL gl) |
---|
| 16737 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16738 | + |
---|
| 16739 | + private void DrawSkyBox(GL gl, float ratio) |
---|
14274 | 16740 | { |
---|
14275 | | - if (envyoff || cubemap == null) |
---|
| 16741 | + if (//envyoff || |
---|
| 16742 | + WIREFRAME || |
---|
| 16743 | + cubemap == null) |
---|
14276 | 16744 | { |
---|
14277 | 16745 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
14278 | 16746 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
14287 | 16755 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
14288 | 16756 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
14289 | 16757 | gl.glLoadIdentity(); |
---|
| 16758 | + gl.glScalef(1,ratio,1); |
---|
14290 | 16759 | |
---|
| 16760 | +// colorV[0] = 2; |
---|
| 16761 | +// colorV[1] = 2; |
---|
| 16762 | +// colorV[2] = 2; |
---|
| 16763 | +// colorV[3] = 1; |
---|
| 16764 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16765 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16766 | +// |
---|
| 16767 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16768 | + |
---|
14291 | 16769 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
14292 | 16770 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
14293 | 16771 | |
---|
.. | .. |
---|
14319 | 16797 | { |
---|
14320 | 16798 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
14321 | 16799 | } |
---|
| 16800 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
14322 | 16801 | gl.glMultMatrixd(viewrot_1, 0); |
---|
14323 | 16802 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
14324 | 16803 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
14359 | 16838 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
14360 | 16839 | |
---|
14361 | 16840 | cubemap.disable(); |
---|
14362 | | - ////cubemap.unbind(); |
---|
| 16841 | + //cubemap.dispose(); |
---|
| 16842 | + |
---|
14363 | 16843 | if (CULLFACE) |
---|
14364 | 16844 | { |
---|
14365 | 16845 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
14394 | 16874 | gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS); |
---|
14395 | 16875 | gl.glPushMatrix(); |
---|
14396 | 16876 | gl.glLoadIdentity(); |
---|
14397 | | - PushMatrix(checker.toParent); |
---|
| 16877 | + //PushMatrix(checker.toParent); |
---|
14398 | 16878 | |
---|
14399 | 16879 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
14400 | 16880 | gl.glPushMatrix(); |
---|
.. | .. |
---|
14417 | 16897 | |
---|
14418 | 16898 | gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
14419 | 16899 | |
---|
14420 | | - float step = 0.1666f; //0.25f; |
---|
14421 | | - float stepv = step * 1652 / 998; |
---|
| 16900 | + float step = 2; // 0.1666f; //0.25f; |
---|
| 16901 | + float stepv = 2; // step * 1652 / 998; |
---|
14422 | 16902 | |
---|
14423 | 16903 | int i0 = 0; |
---|
14424 | 16904 | /* |
---|
.. | .. |
---|
14454 | 16934 | /**/ |
---|
14455 | 16935 | //checker.GetMaterial().opacity = 1.1f; |
---|
14456 | 16936 | ////checker.GetMaterial().ambient = 0.99f; |
---|
14457 | | - Object3D.materialstack[Object3D.materialdepth] = checker.material; |
---|
14458 | | - Object3D.selectedstack[Object3D.materialdepth] = false; |
---|
14459 | | - cStatic.objectstack[Object3D.materialdepth++] = checker; |
---|
| 16937 | + materialstack[materialdepth] = checker.material; |
---|
| 16938 | + selectedstack[materialdepth] = false; |
---|
| 16939 | + cStatic.objectstack[materialdepth++] = checker; |
---|
14460 | 16940 | //System.out.println("material " + material); |
---|
14461 | 16941 | //Applet3D.tracein(this, selected); |
---|
14462 | | - vector2buffer = checker.projectedVertices; |
---|
| 16942 | + //vector2buffer = checker.projectedVertices; |
---|
14463 | 16943 | |
---|
14464 | | - checker.GetMaterial().Draw(this, false); // true); |
---|
| 16944 | + //checker.GetMaterial().Draw(this, false); // true); |
---|
| 16945 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
14465 | 16946 | |
---|
14466 | | - Object3D.materialdepth -= 1; |
---|
14467 | | - if (Object3D.materialdepth > 0) |
---|
| 16947 | + materialdepth -= 1; |
---|
| 16948 | + if (materialdepth > 0) |
---|
14468 | 16949 | { |
---|
14469 | | - vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices; |
---|
14470 | | - Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]); |
---|
| 16950 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16951 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
14471 | 16952 | } |
---|
14472 | 16953 | //checker.GetMaterial().opacity = 1f; |
---|
14473 | 16954 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
14488 | 16969 | |
---|
14489 | 16970 | //float u = (i+1)/2; |
---|
14490 | 16971 | //float v = (j+1)/2; |
---|
14491 | | - gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
| 16972 | + if (checker.flipV) |
---|
| 16973 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2); |
---|
| 16974 | + else |
---|
| 16975 | + gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
14492 | 16976 | gl.glVertex3f(i, j, -0.5f); |
---|
14493 | 16977 | |
---|
| 16978 | + if (checker.flipV) |
---|
| 16979 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
| 16980 | + else |
---|
14494 | 16981 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
14495 | 16982 | gl.glVertex3f(i + step, j, -0.5f); |
---|
14496 | 16983 | |
---|
| 16984 | + if (checker.flipV) |
---|
| 16985 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
| 16986 | + else |
---|
14497 | 16987 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
14498 | 16988 | gl.glVertex3f(i + step, j + stepv, -0.5f); |
---|
14499 | 16989 | |
---|
| 16990 | + if (checker.flipV) |
---|
| 16991 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
| 16992 | + else |
---|
14500 | 16993 | gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
14501 | 16994 | gl.glVertex3f(i, j + stepv, -0.5f); |
---|
14502 | 16995 | } |
---|
.. | .. |
---|
14508 | 17001 | gl.glMatrixMode(GL.GL_PROJECTION); |
---|
14509 | 17002 | gl.glPopMatrix(); |
---|
14510 | 17003 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
14511 | | - PopMatrix(null); // checker.toParent); // null); |
---|
| 17004 | + //PopMatrix(null); // checker.toParent); // null); |
---|
14512 | 17005 | gl.glPopMatrix(); |
---|
14513 | 17006 | PopTextureMatrix(checker.toParent); |
---|
14514 | 17007 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
.. | .. |
---|
14541 | 17034 | } |
---|
14542 | 17035 | } |
---|
14543 | 17036 | |
---|
| 17037 | + private Object3D GetFolder() |
---|
| 17038 | + { |
---|
| 17039 | + Object3D folder = object.GetWindow().copy; |
---|
| 17040 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17041 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17042 | + return folder; |
---|
| 17043 | + } |
---|
| 17044 | + |
---|
14544 | 17045 | class SelectBuffer implements GLEventListener |
---|
14545 | 17046 | { |
---|
14546 | 17047 | |
---|
.. | .. |
---|
14556 | 17057 | //new Exception().printStackTrace(); |
---|
14557 | 17058 | System.out.println("select buffer init"); |
---|
14558 | 17059 | // Use debug pipeline |
---|
14559 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17060 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
14560 | 17061 | |
---|
14561 | 17062 | GL gl = drawable.getGL(); |
---|
14562 | 17063 | |
---|
.. | .. |
---|
14599 | 17100 | { |
---|
14600 | 17101 | if (!selection) |
---|
14601 | 17102 | { |
---|
| 17103 | + new Exception().printStackTrace(); |
---|
14602 | 17104 | System.exit(0); |
---|
14603 | 17105 | return; |
---|
14604 | 17106 | } |
---|
.. | .. |
---|
14619 | 17121 | |
---|
14620 | 17122 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
14621 | 17123 | |
---|
| 17124 | + if (PAINTMODE) |
---|
| 17125 | + { |
---|
| 17126 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17127 | + { |
---|
| 17128 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17129 | + |
---|
| 17130 | + // Make what you paint not selectable. |
---|
| 17131 | + paintobj.ResetSelectable(); |
---|
| 17132 | + } |
---|
| 17133 | + } |
---|
| 17134 | + |
---|
14622 | 17135 | //int tmp = selection_view; |
---|
14623 | 17136 | //selection_view = -1; |
---|
14624 | | - int temp = drawMode; |
---|
14625 | | - drawMode = SELECTION; |
---|
| 17137 | + int temp = DrawMode(); |
---|
| 17138 | + Globals.drawMode = SELECTION; // WARNING |
---|
14626 | 17139 | indexcount = 0; |
---|
14627 | 17140 | parent.display(drawable); |
---|
14628 | 17141 | //selection_view = tmp; |
---|
14629 | 17142 | //if (temp == SELECTION) |
---|
14630 | 17143 | // temp = DEFAULT; // patch for selection debug |
---|
14631 | | - drawMode = temp; |
---|
| 17144 | + Globals.drawMode = temp; // WARNING |
---|
14632 | 17145 | |
---|
| 17146 | + if (PAINTMODE) |
---|
| 17147 | + { |
---|
| 17148 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17149 | + { |
---|
| 17150 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17151 | + |
---|
| 17152 | + // Revert. |
---|
| 17153 | + paintobj.RestoreSelectable(); |
---|
| 17154 | + } |
---|
| 17155 | + } |
---|
| 17156 | + |
---|
14633 | 17157 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
14634 | 17158 | |
---|
14635 | 17159 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
14678 | 17202 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
14679 | 17203 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
14680 | 17204 | |
---|
| 17205 | + CreateSelectedPoint(); |
---|
| 17206 | + |
---|
| 17207 | + // Will fit the mesh !!! |
---|
| 17208 | + selectedpoint.toParent[0][0] = 0.0001; |
---|
| 17209 | + selectedpoint.toParent[1][1] = 0.0001; |
---|
| 17210 | + selectedpoint.toParent[2][2] = 0.0001; |
---|
| 17211 | + |
---|
14681 | 17212 | glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0); |
---|
14682 | 17213 | |
---|
14683 | 17214 | // if (object.selection != null && object.selection.Size() > 0) |
---|
.. | .. |
---|
14721 | 17252 | 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 | 17253 | } |
---|
14723 | 17254 | |
---|
14724 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 17255 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
14725 | 17256 | } |
---|
14726 | 17257 | } |
---|
14727 | 17258 | |
---|
14728 | 17259 | if (!movingcamera && !PAINTMODE) |
---|
14729 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17260 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
14730 | 17261 | |
---|
14731 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17262 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
14732 | 17263 | { |
---|
14733 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17264 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
14734 | 17265 | |
---|
14735 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17266 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17267 | + { |
---|
| 17268 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
14736 | 17269 | |
---|
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(); |
---|
| 17270 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17271 | + |
---|
| 17272 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17273 | + |
---|
| 17274 | + inst.add(paintobj); // link |
---|
| 17275 | + |
---|
| 17276 | + object.GetWindow().SnapObject(inst); |
---|
| 17277 | + |
---|
| 17278 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17279 | + |
---|
| 17280 | + folder.add(inst); |
---|
| 17281 | + |
---|
| 17282 | + object.GetWindow().ResetModel(); |
---|
| 17283 | + object.GetWindow().refreshContents(); |
---|
| 17284 | + } |
---|
14752 | 17285 | } |
---|
14753 | 17286 | else |
---|
14754 | 17287 | paintcount = 0; |
---|
.. | .. |
---|
14787 | 17320 | //System.out.println("objects[color] = " + objects[color]); |
---|
14788 | 17321 | //objects[color].Select(); |
---|
14789 | 17322 | indexcount = 0; |
---|
| 17323 | + ObjEditor window = object.GetWindow(); |
---|
| 17324 | + if (window != null && deselect) |
---|
| 17325 | + { |
---|
| 17326 | + window.Select(null, deselect, true); |
---|
| 17327 | + } |
---|
14790 | 17328 | object.Select(color, deselect); |
---|
14791 | 17329 | } |
---|
14792 | 17330 | |
---|
.. | .. |
---|
14837 | 17375 | |
---|
14838 | 17376 | public void init(GLAutoDrawable drawable) |
---|
14839 | 17377 | { |
---|
| 17378 | + if (Globals.DEBUG) |
---|
14840 | 17379 | System.out.println("shadow buffer init"); |
---|
14841 | 17380 | |
---|
14842 | 17381 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
14886 | 17425 | gl.glDisable(gl.GL_CULL_FACE); |
---|
14887 | 17426 | } |
---|
14888 | 17427 | |
---|
14889 | | - if (!RENDERSHADOW) |
---|
| 17428 | + if (!Globals.RENDERSHADOW) |
---|
14890 | 17429 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14891 | 17430 | |
---|
14892 | 17431 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
14896 | 17435 | //gl.glColorMask(false, false, false, false); |
---|
14897 | 17436 | |
---|
14898 | 17437 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
14899 | | - if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17438 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
14900 | 17439 | { |
---|
14901 | 17440 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14902 | 17441 | |
---|
14903 | | - int temp = drawMode; |
---|
14904 | | - drawMode = SHADOW; |
---|
| 17442 | + int temp = DrawMode(); |
---|
| 17443 | + Globals.drawMode = SHADOW; // WARNING |
---|
14905 | 17444 | parent.display(drawable); |
---|
14906 | | - drawMode = temp; |
---|
| 17445 | + Globals.drawMode = temp; // WARNING |
---|
14907 | 17446 | } |
---|
14908 | 17447 | |
---|
14909 | 17448 | gl.glCullFace(gl.GL_BACK); |
---|
.. | .. |
---|
14956 | 17495 | |
---|
14957 | 17496 | class AntialiasBuffer implements GLEventListener |
---|
14958 | 17497 | { |
---|
14959 | | - |
---|
14960 | 17498 | CameraPane parent = null; |
---|
14961 | 17499 | |
---|
14962 | 17500 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
15066 | 17604 | gl.glFlush(); |
---|
15067 | 17605 | |
---|
15068 | 17606 | /**/ |
---|
15069 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer); |
---|
| 17607 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
15070 | 17608 | |
---|
15071 | | - int[] pixels = occlusionsizebuffer.array(); |
---|
| 17609 | + float[] depths = occlusiondepthbuffer.array(); |
---|
15072 | 17610 | |
---|
| 17611 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17612 | + |
---|
| 17613 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17614 | + |
---|
15073 | 17615 | double r = 0, g = 0, b = 0; |
---|
15074 | 17616 | |
---|
15075 | 17617 | double count = 0; |
---|
| 17618 | + |
---|
| 17619 | + gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0); |
---|
| 17620 | + |
---|
| 17621 | + float mindepth = 1; |
---|
| 17622 | + |
---|
| 17623 | + double FACTOR = 1; |
---|
15076 | 17624 | |
---|
15077 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17625 | + for (int i = 0; i < depths.length; i++) |
---|
15078 | 17626 | { |
---|
15079 | 17627 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
15080 | 17628 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
15157 | 17705 | |
---|
15158 | 17706 | double scale = ray.z; // 1; // cos |
---|
15159 | 17707 | |
---|
15160 | | - int p = pixels[newindex]; |
---|
| 17708 | + float depth = depths[newindex]; |
---|
15161 | 17709 | |
---|
15162 | 17710 | /* |
---|
15163 | 17711 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
15181 | 17729 | scale = (1 - modu) * modv; |
---|
15182 | 17730 | */ |
---|
15183 | 17731 | |
---|
15184 | | - r += ((p >> 16) & 0xFF) * scale / 255; |
---|
15185 | | - g += ((p >> 8) & 0xFF) * scale / 255; |
---|
15186 | | - b += (p & 0xFF) * scale / 255; |
---|
| 17732 | + //r += ((p >> 16) & 0xFF) * scale / 255; |
---|
| 17733 | + //g += ((p >> 8) & 0xFF) * scale / 255; |
---|
| 17734 | + //b += (p & 0xFF) * scale / 255; |
---|
| 17735 | + |
---|
| 17736 | + if (mindepth > depth) |
---|
| 17737 | + { |
---|
| 17738 | + mindepth = depth; |
---|
| 17739 | + } |
---|
15187 | 17740 | |
---|
| 17741 | + double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]); |
---|
| 17742 | + |
---|
| 17743 | + double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR); |
---|
| 17744 | + |
---|
| 17745 | + r += factor * scale; |
---|
| 17746 | + g += factor * scale; |
---|
| 17747 | + b += factor * scale; |
---|
| 17748 | + |
---|
15188 | 17749 | count += scale; |
---|
15189 | 17750 | } |
---|
15190 | 17751 | |
---|
.. | .. |
---|
15282 | 17843 | GLUT glut = new GLUT(); |
---|
15283 | 17844 | |
---|
15284 | 17845 | |
---|
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 | 17846 | public boolean spherical = false; |
---|
15292 | 17847 | static boolean DEBUG_OCCLUSION = false; |
---|
15293 | 17848 | static boolean DEBUG_SELECTION = false; |
---|
.. | .. |
---|
15300 | 17855 | int AAbuffersize = 0; |
---|
15301 | 17856 | |
---|
15302 | 17857 | //double[] selectedpoint = new double[3]; |
---|
15303 | | - static Sphere selectedpoint = new Sphere(); |
---|
| 17858 | + static Superellipsoid selectedpoint; |
---|
15304 | 17859 | 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(); |
---|
| 17860 | + static Sphere debugpointG; |
---|
| 17861 | + static Sphere debugpointP; |
---|
| 17862 | + static Sphere debugpointC; |
---|
| 17863 | + static Sphere debugpointR; |
---|
15309 | 17864 | |
---|
15310 | 17865 | static Sphere debugpoints[] = new Sphere[8]; |
---|
15311 | 17866 | |
---|
15312 | | - static |
---|
15313 | | - { |
---|
15314 | | - for (int i=0; i<8; i++) |
---|
15315 | | - { |
---|
15316 | | - debugpoints[i] = new Sphere(); |
---|
15317 | | - } |
---|
15318 | | - } |
---|
15319 | | - |
---|
15320 | 17867 | static void InitPoints(float radius) |
---|
15321 | 17868 | { |
---|
15322 | 17869 | for (int i=0; i<8; i++) |
---|
.. | .. |
---|
15336 | 17883 | } |
---|
15337 | 17884 | } |
---|
15338 | 17885 | |
---|
15339 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17886 | + static void DrawPoints(iCameraPane cpane) |
---|
15340 | 17887 | { |
---|
15341 | 17888 | for (int i=0; i<8; i++) // first and last are red |
---|
15342 | 17889 | { |
---|
.. | .. |
---|
15355 | 17902 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
15356 | 17903 | static IntBuffer bigAAbuffer; |
---|
15357 | 17904 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
15358 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17905 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
15359 | 17906 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15360 | 17907 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15361 | | - static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17908 | + //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17909 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17910 | + |
---|
| 17911 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17912 | + |
---|
15362 | 17913 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
15363 | 17914 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
15364 | 17915 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|
.. | .. |
---|
15367 | 17918 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
15368 | 17919 | // Depth buffer format |
---|
15369 | 17920 | //private int depth_format; |
---|
15370 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17921 | + |
---|
| 17922 | + public void NextIndex() |
---|
15371 | 17923 | { |
---|
15372 | 17924 | indexcount+=16; |
---|
15373 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17925 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
15374 | 17926 | //objects[indexcount] = o; |
---|
15375 | 17927 | //System.out.println("indexcount = " + indexcount); |
---|
15376 | 17928 | } |
---|