.. | .. |
---|
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 | + |
---|
| 546 | + SetGLNormal(gl, (float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 547 | + } |
---|
| 548 | + |
---|
| 549 | + // P |
---|
| 550 | + float x = (float)pv.x; |
---|
| 551 | + float y = (float)pv.y; |
---|
| 552 | + float z = (float)pv.z; |
---|
| 553 | + |
---|
| 554 | + if (hasnorm) |
---|
| 555 | + { |
---|
| 556 | +// if (!pv.norm.normalized()) |
---|
| 557 | +// assert(pv.norm.normalized()); |
---|
| 558 | + |
---|
| 559 | + //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z); |
---|
| 560 | + float nx = (float)pv.norm.x; |
---|
| 561 | + float ny = (float)pv.norm.y; |
---|
| 562 | + float nz = (float)pv.norm.z; |
---|
| 563 | + |
---|
| 564 | + x += nx * obj.NORMALPUSH; |
---|
| 565 | + y += ny * obj.NORMALPUSH; |
---|
| 566 | + z += nz * obj.NORMALPUSH; |
---|
| 567 | + |
---|
| 568 | + SetGLNormal(gl, nx, ny, nz); |
---|
| 569 | + } |
---|
| 570 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 571 | + SetColor(obj, pv); |
---|
| 572 | + //gl.glColor4f(r, g, b, 1); |
---|
| 573 | + //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1); |
---|
| 574 | + if (obj.flipV) |
---|
| 575 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 576 | + else |
---|
| 577 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 578 | + //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z); |
---|
| 579 | + |
---|
| 580 | + gl.glVertex3f(x, y, z); |
---|
| 581 | + |
---|
| 582 | + // Q |
---|
| 583 | + x = (float)qv.x; |
---|
| 584 | + y = (float)qv.y; |
---|
| 585 | + z = (float)qv.z; |
---|
| 586 | + |
---|
| 587 | +// Print(pv); |
---|
| 588 | + if (hasnorm) |
---|
| 589 | + { |
---|
| 590 | +// assert(qv.norm.normalized()); |
---|
| 591 | + //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z); |
---|
| 592 | + float nx = (float)qv.norm.x; |
---|
| 593 | + float ny = (float)qv.norm.y; |
---|
| 594 | + float nz = (float)qv.norm.z; |
---|
| 595 | + |
---|
| 596 | + x += nx * obj.NORMALPUSH; |
---|
| 597 | + y += ny * obj.NORMALPUSH; |
---|
| 598 | + z += nz * obj.NORMALPUSH; |
---|
| 599 | + |
---|
| 600 | + SetGLNormal(gl, nx, ny, nz); |
---|
| 601 | + } |
---|
| 602 | + //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
| 603 | + // boolean locked = false; |
---|
| 604 | + // float eps = 0.1f; |
---|
| 605 | + // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 606 | + |
---|
| 607 | + // int dot = 0; //*/ (int)f.dot; |
---|
| 608 | + |
---|
| 609 | + // if ((dot&1) == 0) |
---|
| 610 | + // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 611 | + |
---|
| 612 | + // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 613 | + if (obj.flipV) |
---|
| 614 | + gl.glTexCoord2f((float) qv.s, 1-(float) qv.t); |
---|
| 615 | + else |
---|
| 616 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 617 | + // else |
---|
| 618 | + // { |
---|
| 619 | + // locked = true; |
---|
| 620 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 621 | + // } |
---|
| 622 | + gl.glColor4f(qv.AO, qv.AO, qv.AO, 1); |
---|
| 623 | + SetColor(obj, qv); |
---|
| 624 | + |
---|
| 625 | + gl.glVertex3f(x, y, z); |
---|
| 626 | + //gl.glColor4f(r, g, b, 1); |
---|
| 627 | + //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1); |
---|
| 628 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 629 | +// Print(qv); |
---|
| 630 | + |
---|
| 631 | + // R |
---|
| 632 | + x = (float)rv.x; |
---|
| 633 | + y = (float)rv.y; |
---|
| 634 | + z = (float)rv.z; |
---|
| 635 | + |
---|
| 636 | + if (hasnorm) |
---|
| 637 | + { |
---|
| 638 | +// assert(rv.norm.normalized()); |
---|
| 639 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 640 | + float nx = (float)rv.norm.x; |
---|
| 641 | + float ny = (float)rv.norm.y; |
---|
| 642 | + float nz = (float)rv.norm.z; |
---|
| 643 | + |
---|
| 644 | + x += nx * obj.NORMALPUSH; |
---|
| 645 | + y += ny * obj.NORMALPUSH; |
---|
| 646 | + z += nz * obj.NORMALPUSH; |
---|
| 647 | + |
---|
| 648 | + SetGLNormal(gl, nx, ny, nz); |
---|
| 649 | + } |
---|
| 650 | + |
---|
| 651 | + // if ((dot&4) == 0) |
---|
| 652 | + // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 653 | + |
---|
| 654 | + // if (wrap || !locked && (dot&8) != 0) |
---|
| 655 | + if (obj.flipV) |
---|
| 656 | + gl.glTexCoord2f((float) rv.s, 1-(float) rv.t); |
---|
| 657 | + else |
---|
| 658 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 659 | + // else |
---|
| 660 | + // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 661 | + |
---|
| 662 | + // f.dot = dot; |
---|
| 663 | + |
---|
| 664 | + gl.glColor4f(rv.AO, rv.AO, rv.AO, 1); |
---|
| 665 | + SetColor(obj, rv); |
---|
| 666 | + //gl.glColor4f(r, g, b, 1); |
---|
| 667 | + //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1); |
---|
| 668 | + //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z); |
---|
| 669 | + gl.glVertex3f(x, y, z); |
---|
| 670 | +// Print(rv); |
---|
| 671 | + //gl.glEnd(); |
---|
| 672 | + } |
---|
| 673 | + else |
---|
| 674 | + { |
---|
| 675 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 676 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 677 | + gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z); |
---|
| 678 | + |
---|
| 679 | + } |
---|
| 680 | + |
---|
| 681 | + if (false) // (attributes & WIREFRAME) != 0) |
---|
| 682 | + { |
---|
| 683 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 684 | + |
---|
| 685 | + gl.glBegin(gl.GL_LINE_LOOP); |
---|
| 686 | + gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z); |
---|
| 687 | + gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z); |
---|
| 688 | + gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z); |
---|
| 689 | + gl.glEnd(); |
---|
| 690 | + |
---|
| 691 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 692 | + } |
---|
| 693 | + } |
---|
| 694 | + |
---|
| 695 | + /** |
---|
| 696 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 697 | + * it's normals, colors, textures and vertices. |
---|
| 698 | + * |
---|
| 699 | + * @see Renderer#draw(TriMesh) |
---|
| 700 | + * @param tris |
---|
| 701 | + * the mesh to render. |
---|
| 702 | + */ |
---|
| 703 | + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 704 | + { |
---|
| 705 | + CameraPane display = this; |
---|
| 706 | + |
---|
| 707 | + float r = display.modelParams0[0]; |
---|
| 708 | + float g = display.modelParams0[1]; |
---|
| 709 | + float b = display.modelParams0[2]; |
---|
| 710 | + float opacity = display.modelParams5[1]; |
---|
| 711 | + |
---|
| 712 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 713 | + GL gl = display.GetGL(); // getGL(); |
---|
| 714 | + |
---|
| 715 | + FloatBuffer vertBuf = geo.vertBuf; |
---|
| 716 | + |
---|
| 717 | + int v = vertBuf.capacity(); |
---|
| 718 | + |
---|
| 719 | + int count = 0; |
---|
| 720 | + |
---|
| 721 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 722 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 723 | + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
| 724 | + for (int i=0; i<v/3; i++) |
---|
| 725 | + { |
---|
| 726 | + int index3 = i*3; |
---|
| 727 | + |
---|
| 728 | + if (geo.sizeBuf.get(index3+1) == 0) |
---|
| 729 | + continue; |
---|
| 730 | + |
---|
| 731 | + count++; |
---|
| 732 | + |
---|
| 733 | + int index4 = i*4; |
---|
| 734 | + |
---|
| 735 | + float tx = vertBuf.get(index3); |
---|
| 736 | + float ty = vertBuf.get(index3+1); |
---|
| 737 | + float tz = vertBuf.get(index3+2); |
---|
| 738 | + |
---|
| 739 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 740 | + // continue; |
---|
| 741 | + |
---|
| 742 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 743 | + gl.glPushMatrix(); |
---|
| 744 | + |
---|
| 745 | + float[] texmat = geo.texmat; |
---|
| 746 | + texmat[12] = texmat[13] = texmat[14] = i; |
---|
| 747 | + |
---|
| 748 | + gl.glMultMatrixf(texmat, 0); |
---|
| 749 | + |
---|
| 750 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 751 | + gl.glPushMatrix(); |
---|
| 752 | + |
---|
| 753 | + gl.glTranslatef(tx,ty,tz); |
---|
| 754 | + |
---|
| 755 | + if (rotate) |
---|
| 756 | + gl.glRotatef(i, 0, 1, 0); |
---|
| 757 | + |
---|
| 758 | + float size = geo.sizeBuf.get(index3) / 100; |
---|
| 759 | + gl.glScalef(size,size,size); |
---|
| 760 | + |
---|
| 761 | + float cr = geo.colorBuf.get(index4); |
---|
| 762 | + float cg = geo.colorBuf.get(index4+1); |
---|
| 763 | + float cb = geo.colorBuf.get(index4+2); |
---|
| 764 | + float ca = geo.colorBuf.get(index4+3); |
---|
| 765 | + |
---|
| 766 | + display.modelParams0[0] = r * cr; |
---|
| 767 | + display.modelParams0[1] = g * cg; |
---|
| 768 | + display.modelParams0[2] = b * cb; |
---|
| 769 | + |
---|
| 770 | + display.modelParams5[1] = opacity * ca; |
---|
| 771 | + |
---|
| 772 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 773 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 774 | + |
---|
| 775 | + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; |
---|
| 776 | + RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 777 | + |
---|
| 778 | +// gl.glColor4f(cr,cg,cb,ca); |
---|
| 779 | + // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 780 | + shape.Draw/*Node*/(display,null,selected,false); // blocked |
---|
| 781 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 782 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 783 | + gl.glPopMatrix(); |
---|
| 784 | + |
---|
| 785 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 786 | + gl.glPopMatrix(); |
---|
| 787 | + } |
---|
| 788 | + // gl.glScalef(1024,1024,1024); |
---|
| 789 | + if (!cf) |
---|
| 790 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 791 | + |
---|
| 792 | + display.modelParams0[0] = r; |
---|
| 793 | + display.modelParams0[1] = g; |
---|
| 794 | + display.modelParams0[2] = b; |
---|
| 795 | + |
---|
| 796 | + display.modelParams5[1] = opacity; |
---|
| 797 | + |
---|
| 798 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 799 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 800 | + |
---|
| 801 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 802 | + |
---|
| 803 | +// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
| 804 | + if (true) |
---|
| 805 | + return; |
---|
| 806 | + |
---|
| 807 | +//// if (!tris.predraw(this)) |
---|
| 808 | +//// { |
---|
| 809 | +//// return; |
---|
| 810 | +//// } |
---|
| 811 | +//// if (Debug.stats) |
---|
| 812 | +//// { |
---|
| 813 | +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
| 814 | +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
| 815 | +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
| 816 | +//// } |
---|
| 817 | +//// |
---|
| 818 | +//// if (tris.getDisplayListID() != -1) |
---|
| 819 | +//// { |
---|
| 820 | +//// renderDisplayList(tris); |
---|
| 821 | +//// return; |
---|
| 822 | +//// } |
---|
| 823 | +//// |
---|
| 824 | +//// if (!generatingDisplayList) |
---|
| 825 | +//// { |
---|
| 826 | +//// applyStates(tris.states, tris); |
---|
| 827 | +//// } |
---|
| 828 | +//// if (Debug.stats) |
---|
| 829 | +//// { |
---|
| 830 | +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
| 831 | +//// } |
---|
| 832 | +//// boolean transformed = doTransforms(tris); |
---|
| 833 | +// |
---|
| 834 | +// int glMode = GL.GL_TRIANGLES; |
---|
| 835 | +// switch (getMode()) |
---|
| 836 | +// { |
---|
| 837 | +// case Triangles: |
---|
| 838 | +// glMode = GL.GL_TRIANGLES; |
---|
| 839 | +// break; |
---|
| 840 | +// case Strip: |
---|
| 841 | +// glMode = GL.GL_TRIANGLE_STRIP; |
---|
| 842 | +// break; |
---|
| 843 | +// case Fan: |
---|
| 844 | +// glMode = GL.GL_TRIANGLE_FAN; |
---|
| 845 | +// break; |
---|
| 846 | +// } |
---|
| 847 | +// |
---|
| 848 | +// if (!predrawGeometry(gl)) |
---|
| 849 | +// { |
---|
| 850 | +// // make sure only the necessary indices are sent through on old |
---|
| 851 | +// // cards. |
---|
| 852 | +// IntBuffer indices = this.getIndexBuffer(); |
---|
| 853 | +// if (indices == null) |
---|
| 854 | +// { |
---|
| 855 | +// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
| 856 | +// } else |
---|
| 857 | +// { |
---|
| 858 | +// indices.rewind(); |
---|
| 859 | +// indices.limit(this.getMaxIndex()); |
---|
| 860 | +// |
---|
| 861 | +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
| 862 | +// |
---|
| 863 | +// indices.clear(); |
---|
| 864 | +// } |
---|
| 865 | +// } else |
---|
| 866 | +// { |
---|
| 867 | +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
| 868 | +// GL.GL_UNSIGNED_INT, 0); |
---|
| 869 | +// } |
---|
| 870 | +// |
---|
| 871 | +//// postdrawGeometry(tris); |
---|
| 872 | +//// if (transformed) |
---|
| 873 | +//// { |
---|
| 874 | +//// undoTransforms(tris); |
---|
| 875 | +//// } |
---|
| 876 | +//// |
---|
| 877 | +//// if (Debug.stats) |
---|
| 878 | +//// { |
---|
| 879 | +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
| 880 | +//// } |
---|
| 881 | +//// tris.postdraw(this); |
---|
| 882 | + } |
---|
| 883 | + |
---|
| 884 | + static Camera localcamera = new Camera(); |
---|
| 885 | + static cVector from = new cVector(); |
---|
| 886 | + static cVector to = new cVector(); |
---|
| 887 | + |
---|
| 888 | + public void PrepOcclusion(BoundaryRep br, double[][] transform) |
---|
| 889 | + { |
---|
| 890 | + CameraPane cp = this; |
---|
| 891 | + |
---|
| 892 | + Camera keep = cp.RenderCamera(); |
---|
| 893 | + cp.renderCamera = localcamera; |
---|
| 894 | + |
---|
| 895 | + if (br.trimmed) |
---|
| 896 | + { |
---|
| 897 | + float[] colors = new float[br.positions.length / 3]; |
---|
| 898 | + |
---|
| 899 | + int i3 = 0; |
---|
| 900 | + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) |
---|
| 901 | + { |
---|
| 902 | + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) |
---|
| 903 | + continue; |
---|
| 904 | + |
---|
| 905 | + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); |
---|
| 906 | + to.set(br.positions[i3] + br.normals[i3], |
---|
| 907 | + br.positions[i3 + 1] + br.normals[i3 + 1], |
---|
| 908 | + br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
| 909 | + LA.xformPos(from, transform, from); |
---|
| 910 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 911 | + localcamera.setAim(from, to); |
---|
| 912 | + |
---|
| 913 | + CameraPane.occlusionbuffer.display(); |
---|
| 914 | + |
---|
| 915 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 916 | + cp.display(); // debug |
---|
| 917 | + |
---|
| 918 | + colors[i] = cp.vertexOcclusion.r; |
---|
| 919 | + //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
| 920 | + //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
| 921 | + |
---|
| 922 | + if ((i % 100) == 0 && i != 0) |
---|
| 923 | + { |
---|
| 924 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 925 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 926 | + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); |
---|
| 927 | + } |
---|
| 928 | + } |
---|
| 929 | + |
---|
| 930 | + br.colors = colors; |
---|
| 931 | + } |
---|
| 932 | + else |
---|
| 933 | + { |
---|
| 934 | + for (int i = 0; i < br.VertexCount(); i++) |
---|
| 935 | + { |
---|
| 936 | + Vertex v = br.GetVertex(i); |
---|
| 937 | + |
---|
| 938 | + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
| 939 | + continue; |
---|
| 940 | + |
---|
| 941 | + from.set(v.x, v.y, v.z); |
---|
| 942 | + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
| 943 | + LA.xformPos(from, transform, from); |
---|
| 944 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 945 | + localcamera.setAim(from, to); |
---|
| 946 | + |
---|
| 947 | + CameraPane.occlusionbuffer.display(); |
---|
| 948 | + |
---|
| 949 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 950 | + cp.display(); // debug |
---|
| 951 | + |
---|
| 952 | + v.AO = cp.vertexOcclusion.r; |
---|
| 953 | + |
---|
| 954 | + if ((i % 100) == 0 && i != 0) |
---|
| 955 | + { |
---|
| 956 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 957 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 958 | + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); |
---|
| 959 | + } |
---|
| 960 | + } |
---|
| 961 | + } |
---|
| 962 | + |
---|
| 963 | + //System.out.println("done."); |
---|
| 964 | + |
---|
| 965 | + cp.renderCamera = keep; |
---|
| 966 | + } |
---|
| 967 | + |
---|
| 968 | + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 969 | + { |
---|
| 970 | + CameraPane display = this; |
---|
| 971 | + pointFlow.CreateHT(); |
---|
| 972 | + |
---|
| 973 | + float r = display.modelParams0[0]; |
---|
| 974 | + float g = display.modelParams0[1]; |
---|
| 975 | + float b = display.modelParams0[2]; |
---|
| 976 | + float opacity = display.modelParams5[1]; |
---|
| 977 | + |
---|
| 978 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 979 | + GL gl = display.GetGL(); // getGL(); |
---|
| 980 | + |
---|
| 981 | + int s = pointFlow.points.size(); |
---|
| 982 | + |
---|
| 983 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 984 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 985 | + |
---|
| 986 | + for (int i=s; --i>=0;) |
---|
| 987 | + //for (int i=0; i<s; i++) |
---|
| 988 | + { |
---|
| 989 | + cVector v = pointFlow.points.get(i); |
---|
| 990 | + |
---|
| 991 | + double mindist = Double.MAX_VALUE; |
---|
| 992 | + |
---|
| 993 | + double size = pointFlow.minimumSize; |
---|
| 994 | + |
---|
| 995 | + double distancenext = 0; |
---|
| 996 | + |
---|
| 997 | + if (i > 0) |
---|
| 998 | + { |
---|
| 999 | + cVector w = pointFlow.points.get(i-1); |
---|
| 1000 | + |
---|
| 1001 | + double dist = w.distance(v); |
---|
| 1002 | + |
---|
| 1003 | + distancenext = dist; |
---|
| 1004 | + |
---|
| 1005 | + if (mindist > dist) |
---|
| 1006 | + { |
---|
| 1007 | + mindist = dist; |
---|
| 1008 | + size = mindist*pointFlow.resizefactor; |
---|
| 1009 | + } |
---|
| 1010 | + } |
---|
| 1011 | + |
---|
| 1012 | + if (i < s-1) |
---|
| 1013 | + { |
---|
| 1014 | + cVector w = pointFlow.points.get(i+1); |
---|
| 1015 | + |
---|
| 1016 | + double dist = w.distance(v); |
---|
| 1017 | + |
---|
| 1018 | + if (mindist > dist) |
---|
| 1019 | + { |
---|
| 1020 | + mindist = dist; |
---|
| 1021 | + size = mindist*pointFlow.resizefactor; |
---|
| 1022 | + } |
---|
| 1023 | + } |
---|
| 1024 | + |
---|
| 1025 | + if (size < pointFlow.minimumSize) |
---|
| 1026 | + size = pointFlow.minimumSize; |
---|
| 1027 | + if (size > pointFlow.maximumSize) |
---|
| 1028 | + size = pointFlow.maximumSize; |
---|
| 1029 | + |
---|
| 1030 | + double tx = v.x; |
---|
| 1031 | + double ty = v.y; |
---|
| 1032 | + double tz = v.z; |
---|
| 1033 | + |
---|
| 1034 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 1035 | + // continue; |
---|
| 1036 | + |
---|
| 1037 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1038 | + gl.glPushMatrix(); |
---|
| 1039 | + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; |
---|
| 1040 | + |
---|
| 1041 | + gl.glMultMatrixf(pointFlow.texmat, 0); |
---|
| 1042 | + |
---|
| 1043 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1044 | + gl.glPushMatrix(); |
---|
| 1045 | + |
---|
| 1046 | + gl.glTranslated(tx,ty,tz); |
---|
| 1047 | + |
---|
| 1048 | + gl.glScaled(size,size,size); |
---|
| 1049 | + |
---|
| 1050 | +// float cr = colorBuf.get(index4); |
---|
| 1051 | +// float cg = colorBuf.get(index4+1); |
---|
| 1052 | +// float cb = colorBuf.get(index4+2); |
---|
| 1053 | +// float ca = colorBuf.get(index4+3); |
---|
| 1054 | +// |
---|
| 1055 | +// display.modelParams0[0] = r * cr; |
---|
| 1056 | +// display.modelParams0[1] = g * cg; |
---|
| 1057 | +// display.modelParams0[2] = b * cb; |
---|
| 1058 | +// |
---|
| 1059 | +// display.modelParams5[1] = opacity * ca; |
---|
| 1060 | +// |
---|
| 1061 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1062 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1063 | +// |
---|
| 1064 | +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
| 1065 | +// RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 1066 | +// |
---|
| 1067 | +//// gl.glColor4f(cr,cg,cb,ca); |
---|
| 1068 | +// // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 1069 | + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); |
---|
| 1070 | + |
---|
| 1071 | + gl.glPopMatrix(); |
---|
| 1072 | + |
---|
| 1073 | + double step = size/4; // |
---|
| 1074 | + |
---|
| 1075 | + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) |
---|
| 1076 | + continue; |
---|
| 1077 | + |
---|
| 1078 | + int nbsteps = (int)(distancenext/step); |
---|
| 1079 | + |
---|
| 1080 | + step = distancenext/nbsteps; |
---|
| 1081 | + |
---|
| 1082 | + cVector next = pointFlow.points.get(i-1); |
---|
| 1083 | + |
---|
| 1084 | + tmp.set(next); |
---|
| 1085 | + tmp.sub(v); |
---|
| 1086 | + tmp.normalize(); |
---|
| 1087 | + tmp.mul(step); |
---|
| 1088 | + |
---|
| 1089 | + // calculate next size |
---|
| 1090 | + mindist = Double.MAX_VALUE; |
---|
| 1091 | + |
---|
| 1092 | + double nextsize = pointFlow.minimumSize; |
---|
| 1093 | + |
---|
| 1094 | + if (i > 1) |
---|
| 1095 | + { |
---|
| 1096 | + cVector w = pointFlow.points.get(i-2); |
---|
| 1097 | + |
---|
| 1098 | + double dist = w.distance(next); |
---|
| 1099 | + |
---|
| 1100 | + if (mindist > dist) |
---|
| 1101 | + { |
---|
| 1102 | + mindist = dist; |
---|
| 1103 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1104 | + } |
---|
| 1105 | + } |
---|
| 1106 | + |
---|
| 1107 | + double dist = v.distance(next); |
---|
| 1108 | + |
---|
| 1109 | + if (mindist > dist) |
---|
| 1110 | + { |
---|
| 1111 | + mindist = dist; |
---|
| 1112 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1113 | + } |
---|
| 1114 | + |
---|
| 1115 | + if (nextsize < pointFlow.minimumSize) |
---|
| 1116 | + nextsize = pointFlow.minimumSize; |
---|
| 1117 | + if (nextsize > pointFlow.maximumSize) |
---|
| 1118 | + nextsize = pointFlow.maximumSize; |
---|
| 1119 | + // |
---|
| 1120 | + |
---|
| 1121 | + double count = 0; |
---|
| 1122 | + |
---|
| 1123 | + while (distancenext > 0.000000001) // step |
---|
| 1124 | + { |
---|
| 1125 | + gl.glPushMatrix(); |
---|
| 1126 | + |
---|
| 1127 | + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); |
---|
| 1128 | + |
---|
| 1129 | + double K = count/nbsteps; |
---|
| 1130 | + |
---|
| 1131 | + double intersize = K*nextsize + (1-K)*size; |
---|
| 1132 | + |
---|
| 1133 | + gl.glScaled(intersize,intersize,intersize); |
---|
| 1134 | + |
---|
| 1135 | + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); |
---|
| 1136 | + |
---|
| 1137 | + count++; |
---|
| 1138 | + |
---|
| 1139 | + distancenext -= step; |
---|
| 1140 | + |
---|
| 1141 | + gl.glPopMatrix(); |
---|
| 1142 | + } |
---|
| 1143 | + |
---|
| 1144 | + if (count != nbsteps) |
---|
| 1145 | + assert(count == nbsteps); |
---|
| 1146 | + |
---|
| 1147 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 1148 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 1149 | + |
---|
| 1150 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1151 | + gl.glPopMatrix(); |
---|
| 1152 | + } |
---|
| 1153 | + |
---|
| 1154 | + if (!cf) |
---|
| 1155 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 1156 | + |
---|
| 1157 | +// display.modelParams0[0] = r; |
---|
| 1158 | +// display.modelParams0[1] = g; |
---|
| 1159 | +// display.modelParams0[2] = b; |
---|
| 1160 | +// |
---|
| 1161 | +// display.modelParams5[1] = opacity; |
---|
| 1162 | +// |
---|
| 1163 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1164 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1165 | + |
---|
| 1166 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1167 | + } |
---|
| 1168 | + |
---|
| 1169 | + public void DrawBox(cVector min, cVector max) |
---|
| 1170 | + { |
---|
| 1171 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1172 | + gl.glBegin(gl.GL_LINES); |
---|
| 1173 | + |
---|
| 1174 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1175 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1176 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1177 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1178 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1179 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1180 | + |
---|
| 1181 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1182 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1183 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1184 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1185 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1186 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1187 | + |
---|
| 1188 | + gl.glEnd(); |
---|
| 1189 | + } |
---|
| 1190 | + |
---|
| 1191 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1192 | + { |
---|
| 1193 | + int[] strips = bRep.getRawIndices(); |
---|
| 1194 | + |
---|
| 1195 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1196 | + |
---|
| 1197 | + // TRIANGLE STRIP ARRAY |
---|
| 1198 | + if (bRep.trimmed) |
---|
| 1199 | + { |
---|
| 1200 | + float[] v = bRep.getRawVertices(); |
---|
| 1201 | + float[] n = bRep.getRawNormals(); |
---|
| 1202 | + float[] c = bRep.getRawColors(); |
---|
| 1203 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1204 | + |
---|
| 1205 | + int count2 = 0; |
---|
| 1206 | + int count3 = 0; |
---|
| 1207 | + |
---|
| 1208 | + if (n.length > 0) |
---|
| 1209 | + { |
---|
| 1210 | + for (int i = 0; i < strips.length; i++) |
---|
| 1211 | + { |
---|
| 1212 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1213 | + |
---|
| 1214 | + /* |
---|
| 1215 | + boolean locked = false; |
---|
| 1216 | + float eps = 0.1f; |
---|
| 1217 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1218 | + |
---|
| 1219 | + int dot = 0; |
---|
| 1220 | + |
---|
| 1221 | + if ((dot&1) == 0) |
---|
| 1222 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1223 | + |
---|
| 1224 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1225 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1226 | + else |
---|
| 1227 | + { |
---|
| 1228 | + locked = true; |
---|
| 1229 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1230 | + } |
---|
| 1231 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1232 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1233 | + if (hasnorm) |
---|
| 1234 | + { |
---|
| 1235 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1236 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1237 | + } |
---|
| 1238 | + |
---|
| 1239 | + if ((dot&4) == 0) |
---|
| 1240 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1241 | + |
---|
| 1242 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1243 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1244 | + else |
---|
| 1245 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1246 | + |
---|
| 1247 | + f.dot = dot; |
---|
| 1248 | + */ |
---|
| 1249 | + |
---|
| 1250 | + if (!selectmode) |
---|
| 1251 | + { |
---|
| 1252 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1253 | + { |
---|
| 1254 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1255 | + } else |
---|
| 1256 | + { |
---|
| 1257 | + SetGLNormal(gl, 0, 0, 1); |
---|
| 1258 | + } |
---|
| 1259 | + |
---|
| 1260 | + if (c != null) |
---|
| 1261 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1262 | + { |
---|
| 1263 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1264 | + } |
---|
| 1265 | + } |
---|
| 1266 | + |
---|
| 1267 | + if (flipV) |
---|
| 1268 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1269 | + else |
---|
| 1270 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1271 | + |
---|
| 1272 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1273 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1274 | + |
---|
| 1275 | + count2 += 2; |
---|
| 1276 | + count3 += 3; |
---|
| 1277 | + if (!selectmode) |
---|
| 1278 | + { |
---|
| 1279 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1280 | + { |
---|
| 1281 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1282 | + } else |
---|
| 1283 | + { |
---|
| 1284 | + SetGLNormal(gl, 0, 0, 1); |
---|
| 1285 | + } |
---|
| 1286 | + if (c != null) |
---|
| 1287 | + { |
---|
| 1288 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1289 | + } |
---|
| 1290 | + } |
---|
| 1291 | + |
---|
| 1292 | + if (flipV) |
---|
| 1293 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1294 | + else |
---|
| 1295 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1296 | + |
---|
| 1297 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1298 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1299 | + |
---|
| 1300 | + count2 += 2; |
---|
| 1301 | + count3 += 3; |
---|
| 1302 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1303 | + { |
---|
| 1304 | + //gl.glTexCoord2d(...); |
---|
| 1305 | + if (!selectmode) |
---|
| 1306 | + { |
---|
| 1307 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1308 | + { |
---|
| 1309 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1310 | + } else |
---|
| 1311 | + { |
---|
| 1312 | + SetGLNormal(gl, 0, 0, 1); |
---|
| 1313 | + } |
---|
| 1314 | + if (c != null) |
---|
| 1315 | + { |
---|
| 1316 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1317 | + } |
---|
| 1318 | + } |
---|
| 1319 | + |
---|
| 1320 | + if (flipV) |
---|
| 1321 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1322 | + else |
---|
| 1323 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1324 | + |
---|
| 1325 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1326 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1327 | + |
---|
| 1328 | + count2 += 2; |
---|
| 1329 | + count3 += 3; |
---|
| 1330 | + } |
---|
| 1331 | + |
---|
| 1332 | + gl.glEnd(); |
---|
| 1333 | + } |
---|
| 1334 | + } |
---|
| 1335 | + |
---|
| 1336 | + assert count3 == v.length; |
---|
| 1337 | + } |
---|
| 1338 | + else // !trimmed |
---|
| 1339 | + { |
---|
| 1340 | + int count = 0; |
---|
| 1341 | + for (int i = 0; i < strips.length; i++) |
---|
| 1342 | + { |
---|
| 1343 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1344 | + |
---|
| 1345 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1346 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1347 | + |
---|
| 1348 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1349 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1350 | + |
---|
| 1351 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1352 | + { |
---|
| 1353 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1354 | + |
---|
| 1355 | + // if (j%2 == 0) |
---|
| 1356 | + // drawFace(p, q, r, display, null); |
---|
| 1357 | + // else |
---|
| 1358 | + // drawFace(p, r, q, display, null); |
---|
| 1359 | + |
---|
| 1360 | + // p = q; |
---|
| 1361 | + // q = r; |
---|
| 1362 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1363 | + } |
---|
| 1364 | + |
---|
| 1365 | + gl.glEnd(); |
---|
| 1366 | + } |
---|
| 1367 | + } |
---|
| 1368 | + } |
---|
| 1369 | + |
---|
| 1370 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1371 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1372 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1373 | + |
---|
| 1374 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1375 | + { |
---|
| 1376 | + GL gl = GetGL(); // getGL(); |
---|
| 1377 | + |
---|
| 1378 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1379 | + |
---|
| 1380 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1381 | + |
---|
| 1382 | + gl.glLineWidth(1); |
---|
| 1383 | + gl.glColor3f(1,1,1); |
---|
| 1384 | + gl.glBegin(gl.GL_LINES); |
---|
| 1385 | + double scale = 0; |
---|
| 1386 | + int count = 0; |
---|
| 1387 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1388 | + { |
---|
| 1389 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1390 | + if(s == 0) |
---|
| 1391 | + { |
---|
| 1392 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1393 | + } |
---|
| 1394 | + if (mesh.showsprings) |
---|
| 1395 | + { |
---|
| 1396 | + temp.set(spring.a.position); |
---|
| 1397 | + temp.add(spring.b.position); |
---|
| 1398 | + temp.mul(0.5); |
---|
| 1399 | + temp2.set(spring.a.position); |
---|
| 1400 | + temp2.sub(spring.b.position); |
---|
| 1401 | + temp2.mul(spring.restLength/2); |
---|
| 1402 | + temp.sub(temp2); |
---|
| 1403 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1404 | + temp.add(temp2); |
---|
| 1405 | + temp.add(temp2); |
---|
| 1406 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1407 | + } |
---|
| 1408 | + |
---|
| 1409 | + if (spring.isHandle) |
---|
| 1410 | + continue; |
---|
| 1411 | + |
---|
| 1412 | + //if (scale < spring.restLength) |
---|
| 1413 | + scale += spring.restLength; |
---|
| 1414 | + count++; |
---|
| 1415 | + } |
---|
| 1416 | + gl.glEnd(); |
---|
| 1417 | + |
---|
| 1418 | + if (count == 0) |
---|
| 1419 | + scale = 0.01; |
---|
| 1420 | + else |
---|
| 1421 | + scale /= count * 3; |
---|
| 1422 | + |
---|
| 1423 | + //scale = 0.25; |
---|
| 1424 | + |
---|
| 1425 | + if (mesh.ShowInfo()) |
---|
| 1426 | + { |
---|
| 1427 | + gl.glLineWidth(4); |
---|
| 1428 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1429 | + { |
---|
| 1430 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1431 | + if (node.mass == 0) |
---|
| 1432 | + continue; |
---|
| 1433 | + |
---|
| 1434 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1435 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1436 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1437 | + //temp.normalize(); |
---|
| 1438 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1439 | + gl.glBegin(gl.GL_LINES); |
---|
| 1440 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1441 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1442 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1443 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1444 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1445 | + gl.glEnd(); |
---|
| 1446 | + } |
---|
| 1447 | + |
---|
| 1448 | + gl.glLineWidth(8); |
---|
| 1449 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1450 | + { |
---|
| 1451 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1452 | + |
---|
| 1453 | + if (node.springs != null) |
---|
| 1454 | + { |
---|
| 1455 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1456 | + { |
---|
| 1457 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1458 | + |
---|
| 1459 | + int c = i+1; |
---|
| 1460 | + // c = node.springs.get(i).nbcopies; |
---|
| 1461 | + |
---|
| 1462 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1463 | + gl.glBegin(gl.GL_LINES); |
---|
| 1464 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1465 | + 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); |
---|
| 1466 | + gl.glEnd(); |
---|
| 1467 | + } |
---|
| 1468 | + } |
---|
| 1469 | + } |
---|
| 1470 | + |
---|
| 1471 | + gl.glLineWidth(1); |
---|
| 1472 | + } |
---|
| 1473 | + |
---|
| 1474 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1475 | + } |
---|
| 1476 | + |
---|
| 1477 | + /// INTERFACE |
---|
| 1478 | + |
---|
| 1479 | + public void StartTriangles() |
---|
| 1480 | + { |
---|
| 1481 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1482 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1483 | + } |
---|
| 1484 | + |
---|
| 1485 | + public void EndTriangles() |
---|
| 1486 | + { |
---|
| 1487 | + GetGL().glEnd(); |
---|
| 1488 | + } |
---|
| 1489 | + |
---|
| 1490 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1491 | + { |
---|
| 1492 | + if (!selectmode) |
---|
| 1493 | + { |
---|
| 1494 | + SetGLNormal(gl, (float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1495 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1496 | + |
---|
| 1497 | + if (flipV) |
---|
| 1498 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1499 | + else |
---|
| 1500 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1501 | + } |
---|
| 1502 | + |
---|
| 1503 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1504 | + } |
---|
| 1505 | + |
---|
| 1506 | + float[] colorV = new float[4]; |
---|
| 1507 | + |
---|
| 1508 | + void SetColor(Object3D obj, Vertex p0) |
---|
| 1509 | + { |
---|
| 1510 | + CameraPane display = this; |
---|
| 1511 | + BoundaryRep bRep = obj.bRep; |
---|
| 1512 | + |
---|
| 1513 | + if (RENDERPROGRAM == 0) |
---|
| 1514 | + { |
---|
| 1515 | + float r = 0; |
---|
| 1516 | + if (bRep != null) |
---|
| 1517 | + { |
---|
| 1518 | + if (bRep.stripified) |
---|
| 1519 | + { |
---|
| 1520 | + r = 1; |
---|
| 1521 | + } |
---|
| 1522 | + } |
---|
| 1523 | + float g = 0; |
---|
| 1524 | + if (bRep != null) |
---|
| 1525 | + { |
---|
| 1526 | + if (bRep.trimmed) |
---|
| 1527 | + { |
---|
| 1528 | + g = 1; |
---|
| 1529 | + } |
---|
| 1530 | + } |
---|
| 1531 | + float b = 0; |
---|
| 1532 | + if (obj.support != null && obj.link2master) |
---|
| 1533 | + { |
---|
| 1534 | + b = 1; |
---|
| 1535 | + } |
---|
| 1536 | + display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO); |
---|
| 1537 | + return; |
---|
| 1538 | + } |
---|
| 1539 | + |
---|
| 1540 | + if (display.DrawMode() != CameraPane.SHADOW) |
---|
| 1541 | + return; |
---|
| 1542 | + |
---|
| 1543 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1544 | +// if (true) return; |
---|
| 1545 | +// float ao = p.AO; |
---|
| 1546 | +// |
---|
| 1547 | +// // if (ao == 0 && !bRep.AOdone) // transient problem! |
---|
| 1548 | +// // ao = 1; |
---|
| 1549 | +// |
---|
| 1550 | +// gl.glColor4f(ao, ao, ao, 1); |
---|
| 1551 | + |
---|
| 1552 | +// CameraPane.selectedpoint. |
---|
| 1553 | +// getAverage(cStatic.point1, true); |
---|
| 1554 | + if (CameraPane.pointflow == null) // !random) // live) |
---|
| 1555 | + { |
---|
| 1556 | + return; |
---|
| 1557 | + } |
---|
| 1558 | + |
---|
| 1559 | + cStatic.point1.set(0,0,0); |
---|
| 1560 | + LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1); |
---|
| 1561 | + |
---|
| 1562 | + cStatic.point1.sub(p0); |
---|
| 1563 | + |
---|
| 1564 | + |
---|
| 1565 | +// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta? |
---|
| 1566 | +// { |
---|
| 1567 | +// return; |
---|
| 1568 | +// } |
---|
| 1569 | + |
---|
| 1570 | + //if (true) |
---|
| 1571 | + if (cStatic.point1.dot(cStatic.point1) > 0.000001) |
---|
| 1572 | + { |
---|
| 1573 | + return; |
---|
| 1574 | + } |
---|
| 1575 | + |
---|
| 1576 | + if (false) // marked) |
---|
| 1577 | + { |
---|
| 1578 | + // debug rigging weights |
---|
| 1579 | + for (int object = 0; object < p0.vertexlinks.length; object++) |
---|
| 1580 | + { |
---|
| 1581 | + float weight = p0.weights[object] / p0.totalweight; |
---|
| 1582 | + |
---|
| 1583 | + // if (weight < 0.1) |
---|
| 1584 | + // { |
---|
| 1585 | + // assert(weight == 0); |
---|
| 1586 | + // continue; |
---|
| 1587 | + // } |
---|
| 1588 | + |
---|
| 1589 | + if (p0.vertexlinks[object] == -1) |
---|
| 1590 | + continue; |
---|
| 1591 | + |
---|
| 1592 | + Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]); |
---|
| 1593 | + |
---|
| 1594 | + int color = //1 << object; // |
---|
| 1595 | + //p.vertexlinks.length; |
---|
| 1596 | + obj.support.bRep.supports[p0.closestsupport].links[object]; |
---|
| 1597 | + colorV[2] += (color & 1) * weight; |
---|
| 1598 | + colorV[1] += ((color & 2) >> 1) * weight; |
---|
| 1599 | + colorV[0] += ((color & 4) >> 2) * weight; |
---|
| 1600 | + } |
---|
| 1601 | + } |
---|
| 1602 | + else |
---|
| 1603 | + { |
---|
| 1604 | + if (obj.drawingstarted) |
---|
| 1605 | + { |
---|
| 1606 | + // find next point |
---|
| 1607 | + if (bRep.GetVertex(0).faceindices == null) |
---|
| 1608 | + { |
---|
| 1609 | + bRep.InitFaceIndices(); |
---|
| 1610 | + } |
---|
| 1611 | + |
---|
| 1612 | + double ymin = p0.y; |
---|
| 1613 | + |
---|
| 1614 | + Vertex newp = p0; |
---|
| 1615 | + |
---|
| 1616 | + for (int fii = 0; fii < p0.faceindices.length; fii++) |
---|
| 1617 | + { |
---|
| 1618 | + int fi = p0.faceindices[fii]; |
---|
| 1619 | + |
---|
| 1620 | + if (fi == -1) |
---|
| 1621 | + break; |
---|
| 1622 | + |
---|
| 1623 | + Face f = bRep.GetFace(fi); |
---|
| 1624 | + |
---|
| 1625 | + Vertex p = bRep.GetVertex(f.p); |
---|
| 1626 | + Vertex q = bRep.GetVertex(f.q); |
---|
| 1627 | + Vertex r = bRep.GetVertex(f.r); |
---|
| 1628 | + |
---|
| 1629 | + int swap = (int)(Math.random()*3); |
---|
| 1630 | + |
---|
| 1631 | +// for (int s=swap; --s>=0;) |
---|
| 1632 | +// { |
---|
| 1633 | +// Vertex t = p; |
---|
| 1634 | +// p = q; |
---|
| 1635 | +// q = r; |
---|
| 1636 | +// r = t; |
---|
| 1637 | +// } |
---|
| 1638 | + if (ymin > p.y) |
---|
| 1639 | + { |
---|
| 1640 | + ymin = p.y; |
---|
| 1641 | + newp = p; |
---|
| 1642 | +// break; |
---|
| 1643 | + } |
---|
| 1644 | + if (ymin > q.y) |
---|
| 1645 | + { |
---|
| 1646 | + ymin = q.y; |
---|
| 1647 | + newp = q; |
---|
| 1648 | +// break; |
---|
| 1649 | + } |
---|
| 1650 | + if (ymin > r.y) |
---|
| 1651 | + { |
---|
| 1652 | + ymin = r.y; |
---|
| 1653 | + newp = r; |
---|
| 1654 | +// break; |
---|
| 1655 | + } |
---|
| 1656 | + } |
---|
| 1657 | + |
---|
| 1658 | + CameraPane.selectedpoint.toParent[3][0] = newp.x; |
---|
| 1659 | + CameraPane.selectedpoint.toParent[3][1] = newp.y; |
---|
| 1660 | + CameraPane.selectedpoint.toParent[3][2] = newp.z; |
---|
| 1661 | + |
---|
| 1662 | + obj.drawingstarted = false; |
---|
| 1663 | + |
---|
| 1664 | + // return; |
---|
| 1665 | + } |
---|
| 1666 | + |
---|
| 1667 | + if (false) // CameraPane.DRAW |
---|
| 1668 | + { |
---|
| 1669 | + p0.AO = colorV[0] = 2; |
---|
| 1670 | + colorV[1] = 2; |
---|
| 1671 | + colorV[2] = 2; |
---|
| 1672 | + } |
---|
| 1673 | + |
---|
| 1674 | + CameraPane.pointflow.add(p0); |
---|
| 1675 | + CameraPane.pointflow.Touch(); |
---|
| 1676 | + } |
---|
| 1677 | + |
---|
| 1678 | +// gl.glColor3f(colorV[0], colorV[1], colorV[2]); |
---|
| 1679 | +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1680 | +// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1681 | + } |
---|
| 1682 | + |
---|
| 1683 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
| 1684 | + { |
---|
| 1685 | + CameraPane display = this; |
---|
| 1686 | + //new Exception().printStackTrace(); |
---|
| 1687 | + |
---|
| 1688 | + if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW) |
---|
| 1689 | + { |
---|
| 1690 | + return; |
---|
| 1691 | + } |
---|
| 1692 | + |
---|
| 1693 | + javax.media.opengl.GL gl = display.GetGL(); |
---|
| 1694 | + |
---|
| 1695 | + //Color col = Color.getHSBColor(color,modulation,1); |
---|
| 1696 | + //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
| 1697 | + if (!material.multiply) |
---|
| 1698 | + { |
---|
| 1699 | + display.color = material.color; |
---|
| 1700 | + display.saturation = material.modulation; |
---|
| 1701 | + } |
---|
| 1702 | + else |
---|
| 1703 | + { |
---|
| 1704 | + display.color *= material.color*2; |
---|
| 1705 | + display.saturation *= material.modulation*2; |
---|
| 1706 | + } |
---|
| 1707 | + |
---|
| 1708 | + cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
| 1709 | + |
---|
| 1710 | + float[] colorV = Grafreed.colorV; |
---|
| 1711 | + |
---|
| 1712 | + /**/ |
---|
| 1713 | + if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
| 1714 | + { |
---|
| 1715 | + colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
| 1716 | + colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
| 1717 | + colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
| 1718 | + colorV[3] = 1; // material.opacity; |
---|
| 1719 | + |
---|
| 1720 | + gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
| 1721 | + //System.out.println("Opacity = " + opacity); |
---|
| 1722 | + |
---|
| 1723 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1724 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1725 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
| 1726 | + |
---|
| 1727 | + float amb = material.ambient; |
---|
| 1728 | + if (amb < material.cameralight) |
---|
| 1729 | + { |
---|
| 1730 | + amb = material.cameralight; |
---|
| 1731 | + } |
---|
| 1732 | + colorV[0] = display.modelParams0[0] * material.diffuse * amb; |
---|
| 1733 | + colorV[1] = display.modelParams0[1] * material.diffuse * amb; |
---|
| 1734 | + colorV[2] = display.modelParams0[2] * material.diffuse * amb; |
---|
| 1735 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0); |
---|
| 1736 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1737 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 1738 | + |
---|
| 1739 | + /**/ |
---|
| 1740 | + colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular; |
---|
| 1741 | + colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular; |
---|
| 1742 | + colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular; |
---|
| 1743 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0); |
---|
| 1744 | + //color[0] /= 2; color[1] /= 2; color[2] /= 2; |
---|
| 1745 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0); |
---|
| 1746 | + colorV[0] = 10 / material.shininess; // 1/0.005f; |
---|
| 1747 | + //System.out.println("shininess = " + colorV[0]); |
---|
| 1748 | + if (colorV[0] > 128) |
---|
| 1749 | + { |
---|
| 1750 | + colorV[0] = 128; |
---|
| 1751 | + } |
---|
| 1752 | + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0); |
---|
| 1753 | + gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0); |
---|
| 1754 | + /**/ |
---|
| 1755 | + } |
---|
| 1756 | + /**/ |
---|
| 1757 | + |
---|
| 1758 | + //selected = false; |
---|
| 1759 | + selected = selected && display.flash; |
---|
| 1760 | + |
---|
| 1761 | + //display.modelParams0[0] = 0; // pigment.r; |
---|
| 1762 | + //display.modelParams0[1] = 0; // pigment.g; |
---|
| 1763 | + //display.modelParams0[2] = 0; // pigment.b; |
---|
| 1764 | + if (!material.multiply) |
---|
| 1765 | + { |
---|
| 1766 | + display.modelParams0[3] = material.metalness; |
---|
| 1767 | + display.modelParams1[0] = material.diffuse; |
---|
| 1768 | + display.modelParams1[1] = material.specular; |
---|
| 1769 | + display.modelParams1[2] = 1 / material.shininess; |
---|
| 1770 | + display.modelParams1[3] = material.shift; |
---|
| 1771 | + display.modelParams2[0] = material.ambient; |
---|
| 1772 | + display.modelParams2[1] = material.lightarea; |
---|
| 1773 | + //System.out.println("light area = " + lightarea); |
---|
| 1774 | + display.modelParams2[2] = 1 / material.factor; // diffuseness |
---|
| 1775 | + display.modelParams2[3] = material.velvet; |
---|
| 1776 | + display.modelParams3[0] = material.sheen; |
---|
| 1777 | + display.modelParams3[1] = material.subsurface; |
---|
| 1778 | + display.modelParams3[2] = material.bump; // backlit |
---|
| 1779 | + display.modelParams3[3] = material.aniso; |
---|
| 1780 | + display.modelParams4[0] = material.anisoV; |
---|
| 1781 | + display.modelParams4[1] = selected ? 100 : material.cameralight; |
---|
| 1782 | + //System.out.println("selected = " + selected); |
---|
| 1783 | + display.modelParams4[2] = material.diffuseness; |
---|
| 1784 | + display.modelParams4[3] = material.shadow; |
---|
| 1785 | + display.modelParams5[0] = material.texture; |
---|
| 1786 | + display.modelParams5[1] = material.opacity; |
---|
| 1787 | + display.modelParams5[2] = material.fakedepth; |
---|
| 1788 | + display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10; |
---|
| 1789 | + } |
---|
| 1790 | + else |
---|
| 1791 | + { |
---|
| 1792 | + display.modelParams0[3] *= material.metalness*2; |
---|
| 1793 | + display.modelParams1[0] *= material.diffuse*2; |
---|
| 1794 | + display.modelParams1[1] *= material.specular*2; |
---|
| 1795 | + display.modelParams1[2] *= material.shininess*2; |
---|
| 1796 | + display.modelParams1[3] *= material.shift*2; |
---|
| 1797 | + display.modelParams2[0] *= material.ambient*2; |
---|
| 1798 | + display.modelParams2[1] *= material.lightarea*2; |
---|
| 1799 | + display.modelParams2[2] *= material.factor*2; |
---|
| 1800 | + display.modelParams2[3] *= material.velvet*2; |
---|
| 1801 | + display.modelParams3[0] *= material.sheen*2; |
---|
| 1802 | + display.modelParams3[1] *= material.subsurface*2; |
---|
| 1803 | + display.modelParams3[2] *= material.bump*2; |
---|
| 1804 | + display.modelParams3[3] *= material.aniso*2; |
---|
| 1805 | + display.modelParams4[0] *= material.anisoV*2; |
---|
| 1806 | + display.modelParams4[1] *= material.cameralight*2; |
---|
| 1807 | + //System.out.println("selected = " + selected); |
---|
| 1808 | + display.modelParams4[2] *= material.diffuseness*2; |
---|
| 1809 | + display.modelParams4[3] *= material.shadow*2; |
---|
| 1810 | + display.modelParams5[0] *= material.texture*2; |
---|
| 1811 | + display.modelParams5[1] *= material.opacity*2; |
---|
| 1812 | + display.modelParams5[2] *= material.fakedepth*2; |
---|
| 1813 | + display.modelParams5[3] *= material.shadowbias*2; |
---|
| 1814 | + } |
---|
| 1815 | + |
---|
| 1816 | + display.modelParams6[0] = 0; |
---|
| 1817 | + display.modelParams6[1] = 0; |
---|
| 1818 | + display.modelParams6[2] = 0; |
---|
| 1819 | + display.modelParams6[3] = 0; |
---|
| 1820 | + |
---|
| 1821 | + display.modelParams7[0] = 0; |
---|
| 1822 | + display.modelParams7[1] = 1000; |
---|
| 1823 | + display.modelParams7[2] = material.parallax; |
---|
| 1824 | + display.modelParams7[3] = 0; |
---|
| 1825 | + |
---|
| 1826 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1827 | + |
---|
| 1828 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
| 1829 | + if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
| 1830 | + { |
---|
| 1831 | + display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
| 1832 | + display.modelParams6[1] = extparams[0].y / 1000.0f; // noise |
---|
| 1833 | + if (extparams.length > 1) |
---|
| 1834 | + { |
---|
| 1835 | + display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade |
---|
| 1836 | + display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough |
---|
| 1837 | + if (extparams.length > 2) |
---|
| 1838 | + { |
---|
| 1839 | + display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power |
---|
| 1840 | + float x = extparams[2].y / 1000.0f; |
---|
| 1841 | + //if (x == 0) |
---|
| 1842 | + // x = 1f; |
---|
| 1843 | + 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 |
---|
| 1844 | + if (extparams[2].y > 0) |
---|
| 1845 | + { |
---|
| 1846 | + //System.out.println("extparams[1].y = " + extparams[1].y); |
---|
| 1847 | + //System.out.println("extparams[2].y = " + extparams[2].y); |
---|
| 1848 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1849 | + } |
---|
| 1850 | + } |
---|
| 1851 | + } |
---|
| 1852 | + } |
---|
| 1853 | + |
---|
| 1854 | + //if (display.modelParams6[2] != 0) |
---|
| 1855 | + /* |
---|
| 1856 | + System.out.println("modelParams0[0] = " + display.modelParams0[0]); |
---|
| 1857 | + System.out.println("modelParams0[1] = " + display.modelParams0[1]); |
---|
| 1858 | + System.out.println("modelParams0[2] = " + display.modelParams0[2]); |
---|
| 1859 | + System.out.println("modelParams0[3] = " + display.modelParams0[3]); |
---|
| 1860 | + System.out.println("modelParams1[0] = " + display.modelParams1[0]); |
---|
| 1861 | + System.out.println("modelParams1[1] = " + display.modelParams1[1]); |
---|
| 1862 | + System.out.println("modelParams1[2] = " + display.modelParams1[2]); |
---|
| 1863 | + System.out.println("modelParams1[3] = " + display.modelParams1[3]); |
---|
| 1864 | + System.out.println("modelParams2[0] = " + display.modelParams2[0]); |
---|
| 1865 | + System.out.println("modelParams2[1] = " + display.modelParams2[1]); |
---|
| 1866 | + System.out.println("modelParams2[2] = " + display.modelParams2[2]); |
---|
| 1867 | + System.out.println("modelParams2[3] = " + display.modelParams2[3]); |
---|
| 1868 | + System.out.println("modelParams3[0] = " + display.modelParams3[0]); |
---|
| 1869 | + System.out.println("modelParams3[1] = " + display.modelParams3[1]); |
---|
| 1870 | + System.out.println("modelParams3[2] = " + display.modelParams3[2]); |
---|
| 1871 | + System.out.println("modelParams3[3] = " + display.modelParams3[3]); |
---|
| 1872 | + System.out.println("modelParams4[0] = " + display.modelParams4[0]); |
---|
| 1873 | + System.out.println("modelParams4[1] = " + display.modelParams4[1]); |
---|
| 1874 | + System.out.println("modelParams4[2] = " + display.modelParams4[2]); |
---|
| 1875 | + System.out.println("modelParams4[3] = " + display.modelParams4[3]); |
---|
| 1876 | + System.out.println("modelParams5[0] = " + display.modelParams5[0]); |
---|
| 1877 | + System.out.println("modelParams5[1] = " + display.modelParams5[1]); |
---|
| 1878 | + System.out.println("modelParams5[2] = " + display.modelParams5[2]); |
---|
| 1879 | + System.out.println("modelParams5[3] = " + display.modelParams5[3]); |
---|
| 1880 | + System.out.println("modelParams6[0] = " + display.modelParams6[0]); |
---|
| 1881 | + System.out.println("modelParams6[1] = " + display.modelParams6[1]); |
---|
| 1882 | + System.out.println("modelParams6[2] = " + display.modelParams6[2]); |
---|
| 1883 | + System.out.println("modelParams6[3] = " + display.modelParams6[3]); |
---|
| 1884 | + System.out.println("modelParams7[0] = " + display.modelParams7[0]); |
---|
| 1885 | + System.out.println("modelParams7[1] = " + display.modelParams7[1]); |
---|
| 1886 | + System.out.println("modelParams7[2] = " + display.modelParams7[2]); |
---|
| 1887 | + System.out.println("modelParams7[3] = " + display.modelParams7[3]); |
---|
| 1888 | + /**/ |
---|
| 1889 | + //assert (display.modelParams6[2] == 0); |
---|
| 1890 | + |
---|
| 1891 | + //System.out.println("noise power = " + display.modelParams7[0]); |
---|
| 1892 | + //System.out.println("shadowbias = " + shadowbias); |
---|
| 1893 | + |
---|
| 1894 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1895 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0); |
---|
| 1896 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0); |
---|
| 1897 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0); |
---|
| 1898 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
| 1899 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1900 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0); |
---|
| 1901 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0); |
---|
| 1902 | + |
---|
| 1903 | + int mode = display.FP_SHADER; |
---|
| 1904 | + |
---|
| 1905 | + if (material.aniso != material.anisoV || material.aniso > 0.002) |
---|
| 1906 | + { |
---|
| 1907 | + mode |= display.FP_ANISO; |
---|
| 1908 | + } |
---|
| 1909 | + |
---|
| 1910 | + display.EnableProgram(mode); |
---|
| 1911 | + |
---|
| 1912 | + //System.out.println("opacity power = " + display.modelParams7[1]); |
---|
| 1913 | + |
---|
| 1914 | + if (!material.multiply) |
---|
| 1915 | + { |
---|
| 1916 | + if (Globals.drawMode == CameraPane.SHADOW) |
---|
| 1917 | + gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1); |
---|
| 1918 | + else |
---|
| 1919 | + gl.glDepthMask(material.opacity >= 0.99); |
---|
| 1920 | + } |
---|
208 | 1921 | } |
---|
209 | 1922 | |
---|
210 | 1923 | int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0; |
---|
.. | .. |
---|
225 | 1938 | currentGL.glMultMatrixd(model, 0); |
---|
226 | 1939 | } |
---|
227 | 1940 | |
---|
228 | | - void PushMatrix(double[][] matrix, int count) |
---|
| 1941 | + public void PushMatrix(double[][] matrix, int count) // INTERFACE |
---|
229 | 1942 | { |
---|
230 | 1943 | matrixdepth++; |
---|
231 | 1944 | // GrafreeD.tracein(matrix); |
---|
.. | .. |
---|
254 | 1967 | void PushMatrix(double[][] matrix) |
---|
255 | 1968 | { |
---|
256 | 1969 | // GrafreeD.tracein(matrix); |
---|
257 | | - PushMatrix(matrix,1); |
---|
| 1970 | + PushMatrix(matrix, 1); |
---|
258 | 1971 | } |
---|
259 | 1972 | |
---|
260 | 1973 | void PushMatrix() |
---|
.. | .. |
---|
270 | 1983 | |
---|
271 | 1984 | double[][] tmpmat = new double[4][4]; |
---|
272 | 1985 | |
---|
273 | | - void PopMatrix(double[][] inverse) |
---|
| 1986 | + public void PopMatrix(double[][] inverse) // INTERFACE |
---|
274 | 1987 | { |
---|
275 | 1988 | --matrixdepth; |
---|
276 | 1989 | |
---|
.. | .. |
---|
310 | 2023 | PushTextureMatrix(matrix, 1); |
---|
311 | 2024 | } |
---|
312 | 2025 | |
---|
313 | | - void PushTextureMatrix(double[][] matrix, int count) |
---|
| 2026 | + public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE |
---|
314 | 2027 | { |
---|
315 | 2028 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
316 | 2029 | |
---|
.. | .. |
---|
324 | 2037 | currentGL.glMatrixMode(GetGL().GL_MODELVIEW); |
---|
325 | 2038 | } |
---|
326 | 2039 | |
---|
327 | | - void PopTextureMatrix(double[][] inverse) |
---|
| 2040 | + public void PopTextureMatrix(double[][] inverse) // INTERFACE |
---|
328 | 2041 | { |
---|
329 | 2042 | currentGL.glActiveTexture(GetGL().GL_TEXTURE0); |
---|
330 | 2043 | currentGL.glMatrixMode(GetGL().GL_TEXTURE); |
---|
.. | .. |
---|
340 | 2053 | switch(viewcode) |
---|
341 | 2054 | { |
---|
342 | 2055 | case 0: return "main"; |
---|
343 | | - case 1: return "one"; |
---|
344 | | - case 2: return "two"; |
---|
345 | | - case 3: return "three"; |
---|
| 2056 | + case 1: return "Red"; |
---|
| 2057 | + case 2: return "Green"; |
---|
| 2058 | + case 3: return "Blue"; |
---|
346 | 2059 | case 4: return "light"; |
---|
347 | 2060 | } |
---|
348 | 2061 | |
---|
.. | .. |
---|
351 | 2064 | |
---|
352 | 2065 | static int camerachangeframe; |
---|
353 | 2066 | |
---|
354 | | - boolean SetCamera(Camera cam) |
---|
| 2067 | + public boolean SetCamera(Camera cam) |
---|
355 | 2068 | { |
---|
356 | 2069 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
357 | 2070 | // return false; |
---|
358 | 2071 | |
---|
359 | | - if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount) |
---|
| 2072 | + if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount) |
---|
360 | 2073 | { |
---|
361 | 2074 | // check for last change |
---|
362 | | - if (framecount < camerachangeframe + 400) // 120 == 1 second |
---|
| 2075 | + if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second |
---|
363 | 2076 | { |
---|
364 | 2077 | // refuse the camera change |
---|
365 | 2078 | System.err.println("Camera " + cam + " REFUSED"); |
---|
.. | .. |
---|
367 | 2080 | } |
---|
368 | 2081 | } |
---|
369 | 2082 | |
---|
370 | | - camerachangeframe = framecount; |
---|
| 2083 | + camerachangeframe = Globals.framecount; |
---|
371 | 2084 | |
---|
372 | 2085 | cam.hAspect = -1; // Read only |
---|
373 | 2086 | |
---|
.. | .. |
---|
398 | 2111 | { |
---|
399 | 2112 | //System.err.println("Oeil on"); |
---|
400 | 2113 | TRACK = true; |
---|
401 | | -// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
| 2114 | +// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
402 | 2115 | // object.editWindow.ScreenFit(trackedobject); |
---|
403 | 2116 | //pingthread.StepToTarget(true); |
---|
404 | 2117 | } |
---|
.. | .. |
---|
407 | 2120 | { |
---|
408 | 2121 | //System.err.println("Oeil on"); |
---|
409 | 2122 | OEIL = true; |
---|
410 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
411 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2123 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
| 2124 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
412 | 2125 | //pingthread.StepToTarget(true); |
---|
413 | 2126 | } |
---|
414 | 2127 | |
---|
.. | .. |
---|
471 | 2184 | { |
---|
472 | 2185 | frozen ^= true; |
---|
473 | 2186 | // Weird... |
---|
474 | | - lighttouched = true; |
---|
| 2187 | + Globals.lighttouched = true; |
---|
475 | 2188 | } |
---|
476 | 2189 | |
---|
477 | 2190 | void ToggleDL() |
---|
478 | 2191 | { |
---|
479 | 2192 | 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 | 2193 | } |
---|
508 | 2194 | |
---|
509 | 2195 | void ToggleFullScreen() |
---|
.. | .. |
---|
513 | 2199 | |
---|
514 | 2200 | void ToggleCrowd() |
---|
515 | 2201 | { |
---|
516 | | - CROWD ^= true; |
---|
517 | | - } |
---|
518 | | - |
---|
519 | | - void ToggleInertia() |
---|
520 | | - { |
---|
521 | | - INERTIA ^= true; |
---|
| 2202 | + Globals.CROWD ^= true; |
---|
522 | 2203 | } |
---|
523 | 2204 | |
---|
524 | 2205 | void ToggleLocal() |
---|
.. | .. |
---|
526 | 2207 | LOCALTRANSFORM ^= true; |
---|
527 | 2208 | } |
---|
528 | 2209 | |
---|
529 | | - void ToggleFast() |
---|
| 2210 | + public void ToggleTexture() |
---|
| 2211 | + { |
---|
| 2212 | + textureon ^= true; |
---|
| 2213 | + } |
---|
| 2214 | + |
---|
| 2215 | + public void ToggleLive() |
---|
| 2216 | + { |
---|
| 2217 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
| 2218 | + |
---|
| 2219 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
| 2220 | + |
---|
| 2221 | + if (!Globals.isLIVE()) // save sound |
---|
| 2222 | + Grafreed.savesound = true; // wav.save(); |
---|
| 2223 | + // else |
---|
| 2224 | + repaint(); // start loop // may 2013 |
---|
| 2225 | + } |
---|
| 2226 | + |
---|
| 2227 | + public void ToggleSupport() |
---|
| 2228 | + { |
---|
| 2229 | + SUPPORT ^= true; |
---|
| 2230 | + } |
---|
| 2231 | + |
---|
| 2232 | + public void ToggleAbort() |
---|
| 2233 | + { |
---|
| 2234 | + ABORTMODE ^= true; |
---|
| 2235 | + } |
---|
| 2236 | + |
---|
| 2237 | + public void ToggleInertia() |
---|
| 2238 | + { |
---|
| 2239 | + INERTIA ^= true; |
---|
| 2240 | + } |
---|
| 2241 | + |
---|
| 2242 | + public void ToggleFast() |
---|
530 | 2243 | { |
---|
531 | 2244 | FAST ^= true; |
---|
532 | 2245 | } |
---|
533 | 2246 | |
---|
534 | | - void ToggleSlowPose() |
---|
| 2247 | + public void ToggleSlowPose() |
---|
535 | 2248 | { |
---|
536 | 2249 | SLOWPOSE ^= true; |
---|
537 | 2250 | } |
---|
538 | 2251 | |
---|
539 | | - void ToggleFootContact() |
---|
540 | | - { |
---|
541 | | - FOOTCONTACT ^= true; |
---|
542 | | - } |
---|
543 | | - |
---|
544 | | - void ToggleBoxMode() |
---|
| 2252 | + public void ToggleBoxMode() |
---|
545 | 2253 | { |
---|
546 | 2254 | BOXMODE ^= true; |
---|
547 | 2255 | } |
---|
548 | 2256 | |
---|
549 | | - void ToggleSmoothFocus() |
---|
| 2257 | + public void ToggleZoomBoxMode() |
---|
| 2258 | + { |
---|
| 2259 | + ZOOMBOXMODE ^= true; |
---|
| 2260 | + } |
---|
| 2261 | + |
---|
| 2262 | + public void ToggleSmoothFocus() |
---|
550 | 2263 | { |
---|
551 | 2264 | SMOOTHFOCUS ^= true; |
---|
552 | 2265 | } |
---|
553 | 2266 | |
---|
554 | | - void ToggleImageFlip() |
---|
| 2267 | + public void ToggleImageFlip() |
---|
555 | 2268 | { |
---|
556 | 2269 | IMAGEFLIP ^= true; |
---|
557 | 2270 | } |
---|
558 | 2271 | |
---|
559 | | - void ToggleSpeakerMocap() |
---|
| 2272 | + public void ToggleSpeakerMocap() |
---|
560 | 2273 | { |
---|
561 | 2274 | SPEAKERMOCAP ^= true; |
---|
562 | 2275 | } |
---|
563 | 2276 | |
---|
564 | | - void ToggleSpeakerCamera() |
---|
| 2277 | + public void ToggleSpeakerCamera() |
---|
565 | 2278 | { |
---|
566 | 2279 | SPEAKERCAMERA ^= true; |
---|
567 | 2280 | } |
---|
568 | 2281 | |
---|
569 | | - void ToggleSpeakerFocus() |
---|
| 2282 | + public void ToggleSpeakerFocus() |
---|
570 | 2283 | { |
---|
571 | 2284 | SPEAKERFOCUS ^= true; |
---|
572 | 2285 | } |
---|
573 | 2286 | |
---|
574 | | - void ToggleDebug() |
---|
575 | | - { |
---|
576 | | - DEBUG ^= true; |
---|
577 | | - } |
---|
578 | | - |
---|
579 | | - void ToggleFrustum() |
---|
| 2287 | + public void ToggleFrustum() |
---|
580 | 2288 | { |
---|
581 | 2289 | FRUSTUM ^= true; |
---|
582 | 2290 | } |
---|
583 | 2291 | |
---|
584 | | - void ToggleTrack() |
---|
| 2292 | + public void ToggleTrack() |
---|
585 | 2293 | { |
---|
586 | 2294 | TRACK ^= true; |
---|
587 | 2295 | if (TRACK) |
---|
.. | .. |
---|
600 | 2308 | repaint(); |
---|
601 | 2309 | } |
---|
602 | 2310 | |
---|
603 | | - void ToggleTrackOnce() |
---|
| 2311 | + public void ToggleTrackOnce() |
---|
604 | 2312 | { |
---|
605 | 2313 | TRACKONCE ^= true; |
---|
606 | 2314 | } |
---|
607 | 2315 | |
---|
608 | | - void ToggleShadowTrack() |
---|
| 2316 | + public void ToggleShadowTrack() |
---|
609 | 2317 | { |
---|
610 | 2318 | SHADOWTRACK ^= true; |
---|
611 | 2319 | repaint(); |
---|
612 | 2320 | } |
---|
613 | 2321 | |
---|
614 | | - void ToggleOeil() |
---|
| 2322 | + public void ToggleOeil() |
---|
615 | 2323 | { |
---|
616 | 2324 | OEIL ^= true; |
---|
617 | 2325 | } |
---|
618 | 2326 | |
---|
619 | | - void ToggleOeilOnce() |
---|
| 2327 | + public void ToggleOeilOnce() |
---|
620 | 2328 | { |
---|
621 | 2329 | OEILONCE ^= true; |
---|
| 2330 | + } |
---|
| 2331 | + |
---|
| 2332 | + void ToggleFootContact() |
---|
| 2333 | + { |
---|
| 2334 | + FOOTCONTACT ^= true; |
---|
| 2335 | + } |
---|
| 2336 | + |
---|
| 2337 | + void ToggleDebug() |
---|
| 2338 | + { |
---|
| 2339 | + Globals.DEBUG ^= true; |
---|
622 | 2340 | } |
---|
623 | 2341 | |
---|
624 | 2342 | void ToggleLookAt() |
---|
.. | .. |
---|
626 | 2344 | LOOKAT ^= true; |
---|
627 | 2345 | } |
---|
628 | 2346 | |
---|
629 | | - void ToggleRandom() |
---|
| 2347 | + void ToggleSwitch() |
---|
630 | 2348 | { |
---|
631 | | - RANDOM ^= true; |
---|
| 2349 | + SWITCH ^= true; |
---|
632 | 2350 | } |
---|
633 | 2351 | |
---|
634 | 2352 | void ToggleHandles() |
---|
.. | .. |
---|
636 | 2354 | HANDLES ^= true; |
---|
637 | 2355 | } |
---|
638 | 2356 | |
---|
| 2357 | + Object3D paintFolder; |
---|
| 2358 | + |
---|
639 | 2359 | void TogglePaint() |
---|
640 | 2360 | { |
---|
641 | 2361 | PAINTMODE ^= true; |
---|
642 | 2362 | paintcount = 0; |
---|
| 2363 | + |
---|
| 2364 | + if (PAINTMODE) |
---|
| 2365 | + { |
---|
| 2366 | + paintFolder = GetFolder(); |
---|
| 2367 | + } |
---|
643 | 2368 | } |
---|
644 | 2369 | |
---|
645 | 2370 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
672 | 2397 | //assert (cam.hAspect == 0); |
---|
673 | 2398 | cam.hAspect = 0; |
---|
674 | 2399 | 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 | 2400 | } |
---|
704 | 2401 | |
---|
705 | 2402 | private static void ApplyTransform(GL gl, Mat4f xform) |
---|
.. | .. |
---|
759 | 2456 | |
---|
760 | 2457 | GL currentGL; |
---|
761 | 2458 | |
---|
762 | | - GL GetGL() |
---|
| 2459 | + public GL GetGL() // INTERFACE |
---|
763 | 2460 | { |
---|
764 | 2461 | return currentGL; |
---|
765 | 2462 | } |
---|
766 | | - |
---|
| 2463 | + |
---|
| 2464 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2465 | + { |
---|
| 2466 | + Grafreed.Assert(texturedata != null); |
---|
| 2467 | + |
---|
| 2468 | + int width = texturedata.getWidth(); |
---|
| 2469 | + int height = texturedata.getHeight(); |
---|
| 2470 | + |
---|
| 2471 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2472 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2473 | + |
---|
| 2474 | + byte[] bytes = bytebuf.array(); |
---|
| 2475 | + |
---|
| 2476 | + return CreateBim(bytes, width, height); |
---|
| 2477 | + } |
---|
| 2478 | + |
---|
| 2479 | + private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz) |
---|
| 2480 | + { |
---|
| 2481 | + gl.glNormal3f(nx, ny, nz); |
---|
| 2482 | + |
---|
| 2483 | + if (ny > 0.9 || ny < -0.9) |
---|
| 2484 | + // Ground or ceiling |
---|
| 2485 | + gl.glVertexAttrib3f(4, 1, 0, 0); |
---|
| 2486 | + else |
---|
| 2487 | + // Walls |
---|
| 2488 | + gl.glVertexAttrib3f(4, 0, 1, 0); |
---|
| 2489 | + } |
---|
| 2490 | + |
---|
767 | 2491 | /**/ |
---|
768 | 2492 | class CacheTexture |
---|
769 | 2493 | { |
---|
.. | .. |
---|
772 | 2496 | |
---|
773 | 2497 | int resolution; |
---|
774 | 2498 | |
---|
775 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2499 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
776 | 2500 | { |
---|
777 | | - texture = tex; |
---|
| 2501 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2502 | + texturedata = texdata; |
---|
778 | 2503 | resolution = res; |
---|
779 | 2504 | } |
---|
780 | 2505 | } |
---|
781 | 2506 | /**/ |
---|
782 | 2507 | |
---|
783 | 2508 | // 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>(); |
---|
| 2509 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2510 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2511 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2512 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2513 | + |
---|
787 | 2514 | int pigmentdepth = 0; |
---|
788 | 2515 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
789 | 2516 | int bumpdepth = 0; |
---|
790 | 2517 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
791 | 2518 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
792 | 2519 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
793 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2520 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
794 | 2521 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
795 | 2522 | |
---|
796 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2523 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
797 | 2524 | { |
---|
798 | 2525 | TextureData texturedata = null; |
---|
799 | 2526 | |
---|
.. | .. |
---|
803 | 2530 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
804 | 2531 | getClass().getClassLoader().getResourceAsStream(name), |
---|
805 | 2532 | true, |
---|
806 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2533 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
807 | 2534 | } catch (java.io.IOException e) |
---|
808 | 2535 | { |
---|
809 | 2536 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
812 | 2539 | if (bump) |
---|
813 | 2540 | texturedata = ConvertBump(texturedata, false); |
---|
814 | 2541 | |
---|
815 | | - com.sun.opengl.util.texture.Texture texture = |
---|
816 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2542 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2543 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
817 | 2544 | |
---|
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); |
---|
| 2545 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2546 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
820 | 2547 | |
---|
821 | | - return texture; |
---|
| 2548 | + return texturedata; |
---|
| 2549 | + } |
---|
| 2550 | + |
---|
| 2551 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2552 | + { |
---|
| 2553 | + TextureData texturedata = null; |
---|
| 2554 | + |
---|
| 2555 | + try |
---|
| 2556 | + { |
---|
| 2557 | + texturedata = |
---|
| 2558 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2559 | + bim, |
---|
| 2560 | + true); |
---|
| 2561 | + } catch (Exception e) |
---|
| 2562 | + { |
---|
| 2563 | + throw new javax.media.opengl.GLException(e); |
---|
| 2564 | + } |
---|
| 2565 | + |
---|
| 2566 | + if (bump) |
---|
| 2567 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2568 | + |
---|
| 2569 | + return texturedata; |
---|
822 | 2570 | } |
---|
823 | 2571 | |
---|
824 | 2572 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
1891 | 3639 | |
---|
1892 | 3640 | System.out.println("LOADING TEXTURE : " + name); |
---|
1893 | 3641 | |
---|
| 3642 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3643 | + |
---|
1894 | 3644 | // |
---|
1895 | 3645 | if (false) // compressbit > 0) |
---|
1896 | 3646 | { |
---|
.. | .. |
---|
2000 | 3750 | */ |
---|
2001 | 3751 | TextureData ReduceTexture(TextureData texturedata, int resolution) // String name) |
---|
2002 | 3752 | { |
---|
| 3753 | + int pixelformat = texturedata.getPixelFormat(); |
---|
| 3754 | + |
---|
2003 | 3755 | int stride = 1; |
---|
2004 | | - if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE) |
---|
| 3756 | + if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE) |
---|
2005 | 3757 | stride = 3; |
---|
2006 | | - if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA) |
---|
| 3758 | + if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA) |
---|
2007 | 3759 | stride = 4; |
---|
2008 | 3760 | |
---|
2009 | 3761 | int width = texturedata.getWidth(); |
---|
.. | .. |
---|
2593 | 4345 | |
---|
2594 | 4346 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
2595 | 4347 | { |
---|
| 4348 | + new Exception().printStackTrace(); |
---|
2596 | 4349 | System.exit(0); |
---|
2597 | 4350 | com.sun.opengl.util.texture.Texture texture = null; |
---|
2598 | 4351 | |
---|
.. | .. |
---|
6269 | 8022 | return null; |
---|
6270 | 8023 | } |
---|
6271 | 8024 | |
---|
6272 | | - void ReleaseTextures(cTexture tex) |
---|
| 8025 | + public void ReleaseTextures(cTexture tex) // INTERFACE |
---|
6273 | 8026 | { |
---|
6274 | 8027 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6275 | 8028 | { |
---|
.. | .. |
---|
6286 | 8039 | String pigment = Object3D.GetPigment(tex); |
---|
6287 | 8040 | String bump = Object3D.GetBump(tex); |
---|
6288 | 8041 | |
---|
6289 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8042 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
6290 | 8043 | { |
---|
6291 | 8044 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
6292 | 8045 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
6301 | 8054 | pigment = null; |
---|
6302 | 8055 | } |
---|
6303 | 8056 | |
---|
6304 | | - ReleaseTexture(bump, true); |
---|
6305 | | - ReleaseTexture(pigment, false); |
---|
| 8057 | + ReleaseTexture(tex, true); |
---|
| 8058 | + ReleaseTexture(tex, false); |
---|
6306 | 8059 | } |
---|
6307 | 8060 | |
---|
6308 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8061 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
6309 | 8062 | { |
---|
6310 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 8063 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8064 | + { |
---|
| 8065 | + return; |
---|
| 8066 | + } |
---|
| 8067 | + |
---|
| 8068 | + if (tex == null) |
---|
| 8069 | + { |
---|
| 8070 | + ReleaseTexture(null, false); |
---|
| 8071 | + return; |
---|
| 8072 | + } |
---|
| 8073 | + |
---|
| 8074 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8075 | + |
---|
| 8076 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8077 | + { |
---|
| 8078 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8079 | + // System.out.println("; bump = " + bump); |
---|
| 8080 | + } |
---|
| 8081 | + |
---|
| 8082 | + if (pigment.equals("")) |
---|
| 8083 | + { |
---|
| 8084 | + pigment = null; |
---|
| 8085 | + } |
---|
| 8086 | + |
---|
| 8087 | + ReleaseTexture(tex, false); |
---|
| 8088 | + } |
---|
| 8089 | + |
---|
| 8090 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8091 | + { |
---|
| 8092 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8093 | + { |
---|
| 8094 | + return; |
---|
| 8095 | + } |
---|
| 8096 | + |
---|
| 8097 | + if (tex == null) |
---|
| 8098 | + { |
---|
| 8099 | + ReleaseTexture(null, true); |
---|
| 8100 | + return; |
---|
| 8101 | + } |
---|
| 8102 | + |
---|
| 8103 | + String bump = Object3D.GetBump(tex); |
---|
| 8104 | + |
---|
| 8105 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8106 | + { |
---|
| 8107 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8108 | + // System.out.println("; bump = " + bump); |
---|
| 8109 | + } |
---|
| 8110 | + |
---|
| 8111 | + if (bump.equals("")) |
---|
| 8112 | + { |
---|
| 8113 | + bump = null; |
---|
| 8114 | + } |
---|
| 8115 | + |
---|
| 8116 | + ReleaseTexture(tex, true); |
---|
| 8117 | + } |
---|
| 8118 | + |
---|
| 8119 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
| 8120 | + { |
---|
| 8121 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6311 | 8122 | ambientOcclusion ) // || !textureon) |
---|
6312 | 8123 | { |
---|
6313 | 8124 | return; |
---|
.. | .. |
---|
6316 | 8127 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
6317 | 8128 | |
---|
6318 | 8129 | if (tex != null) |
---|
6319 | | - texture = textures.get(tex); |
---|
| 8130 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
6320 | 8131 | |
---|
6321 | 8132 | // //assert( texture != null ); |
---|
6322 | 8133 | // if (texture == null) |
---|
.. | .. |
---|
6408 | 8219 | } |
---|
6409 | 8220 | } |
---|
6410 | 8221 | |
---|
6411 | | - /*boolean*/ void BindTextures(cTexture tex, int resolution) |
---|
| 8222 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
6412 | 8223 | { |
---|
6413 | | - if (// drawMode != 0 || /*tex == null ||*/ |
---|
| 8224 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8225 | +// ambientOcclusion ) // || !textureon) |
---|
| 8226 | +// { |
---|
| 8227 | +// return; // false; |
---|
| 8228 | +// } |
---|
| 8229 | +// |
---|
| 8230 | +// if (tex == null) |
---|
| 8231 | +// { |
---|
| 8232 | +// BindTexture(null,false,resolution); |
---|
| 8233 | +// BindTexture(null,true,resolution); |
---|
| 8234 | +// return; |
---|
| 8235 | +// } |
---|
| 8236 | +// |
---|
| 8237 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8238 | +// String bump = Object3D.GetBump(tex); |
---|
| 8239 | +// |
---|
| 8240 | +// usedtextures.add(pigment); |
---|
| 8241 | +// usedtextures.add(bump); |
---|
| 8242 | +// |
---|
| 8243 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8244 | +// { |
---|
| 8245 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8246 | +// // System.out.println("; bump = " + bump); |
---|
| 8247 | +// } |
---|
| 8248 | +// |
---|
| 8249 | +// if (bump.equals("")) |
---|
| 8250 | +// { |
---|
| 8251 | +// bump = null; |
---|
| 8252 | +// } |
---|
| 8253 | +// if (pigment.equals("")) |
---|
| 8254 | +// { |
---|
| 8255 | +// pigment = null; |
---|
| 8256 | +// } |
---|
| 8257 | +// |
---|
| 8258 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8259 | +// BindTexture(pigment, false, resolution); |
---|
| 8260 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8261 | +// BindTexture(bump, true, resolution); |
---|
| 8262 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8263 | +// |
---|
| 8264 | +// return; // true; |
---|
| 8265 | + |
---|
| 8266 | + BindPigmentTexture(tex, resolution); |
---|
| 8267 | + BindBumpTexture(tex, resolution); |
---|
| 8268 | + } |
---|
| 8269 | + |
---|
| 8270 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8271 | + { |
---|
| 8272 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
6414 | 8273 | ambientOcclusion ) // || !textureon) |
---|
6415 | 8274 | { |
---|
6416 | 8275 | return; // false; |
---|
.. | .. |
---|
6419 | 8278 | if (tex == null) |
---|
6420 | 8279 | { |
---|
6421 | 8280 | BindTexture(null,false,resolution); |
---|
6422 | | - BindTexture(null,true,resolution); |
---|
6423 | 8281 | return; |
---|
6424 | 8282 | } |
---|
6425 | 8283 | |
---|
6426 | 8284 | String pigment = Object3D.GetPigment(tex); |
---|
| 8285 | + |
---|
| 8286 | + usedtextures.add(tex); |
---|
| 8287 | + |
---|
| 8288 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8289 | + { |
---|
| 8290 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8291 | + // System.out.println("; bump = " + bump); |
---|
| 8292 | + } |
---|
| 8293 | + |
---|
| 8294 | + if (pigment.equals("")) |
---|
| 8295 | + { |
---|
| 8296 | + pigment = null; |
---|
| 8297 | + } |
---|
| 8298 | + |
---|
| 8299 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8300 | + BindTexture(tex, false, resolution); |
---|
| 8301 | + } |
---|
| 8302 | + |
---|
| 8303 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8304 | + { |
---|
| 8305 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8306 | + ambientOcclusion ) // || !textureon) |
---|
| 8307 | + { |
---|
| 8308 | + return; // false; |
---|
| 8309 | + } |
---|
| 8310 | + |
---|
| 8311 | + if (tex == null) |
---|
| 8312 | + { |
---|
| 8313 | + BindTexture(null,true,resolution); |
---|
| 8314 | + return; |
---|
| 8315 | + } |
---|
| 8316 | + |
---|
6427 | 8317 | String bump = Object3D.GetBump(tex); |
---|
6428 | 8318 | |
---|
6429 | | - usedtextures.put(pigment, pigment); |
---|
6430 | | - usedtextures.put(bump, bump); |
---|
| 8319 | + usedtextures.add(tex); |
---|
6431 | 8320 | |
---|
6432 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8321 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
6433 | 8322 | { |
---|
6434 | 8323 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
6435 | 8324 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
6439 | 8328 | { |
---|
6440 | 8329 | bump = null; |
---|
6441 | 8330 | } |
---|
6442 | | - if (pigment.equals("")) |
---|
6443 | | - { |
---|
6444 | | - pigment = null; |
---|
6445 | | - } |
---|
6446 | 8331 | |
---|
6447 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
6448 | | - BindTexture(pigment, false, resolution); |
---|
6449 | 8332 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
6450 | | - BindTexture(bump, true, resolution); |
---|
| 8333 | + BindTexture(tex, true, resolution); |
---|
6451 | 8334 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
6452 | | - |
---|
6453 | | - return; // true; |
---|
6454 | 8335 | } |
---|
6455 | 8336 | |
---|
6456 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8337 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8338 | + |
---|
| 8339 | + private boolean FileExists(String tex) |
---|
6457 | 8340 | { |
---|
6458 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8341 | + if (missingTextures.contains(tex)) |
---|
| 8342 | + { |
---|
| 8343 | + return false; |
---|
| 8344 | + } |
---|
| 8345 | + |
---|
| 8346 | + boolean fileExists = new File(tex).exists(); |
---|
| 8347 | + |
---|
| 8348 | + if (!fileExists) |
---|
| 8349 | + { |
---|
| 8350 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8351 | + missingTextures.add(tex); |
---|
| 8352 | + } |
---|
| 8353 | + |
---|
| 8354 | + return fileExists; |
---|
| 8355 | + } |
---|
| 8356 | + |
---|
| 8357 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
| 8358 | + { |
---|
| 8359 | + CacheTexture texturecache = null; |
---|
6459 | 8360 | |
---|
6460 | 8361 | if (tex != null) |
---|
6461 | 8362 | { |
---|
6462 | | - String texname = tex; |
---|
| 8363 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8364 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
6463 | 8365 | |
---|
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; |
---|
| 8366 | + if (texname.equals("") && texdata == null) |
---|
| 8367 | + { |
---|
| 8368 | + return null; |
---|
| 8369 | + } |
---|
| 8370 | + |
---|
| 8371 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8372 | + |
---|
| 8373 | +// String[] split = tex.split("Textures"); |
---|
| 8374 | +// if (split.length > 1) |
---|
| 8375 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8376 | +// else |
---|
| 8377 | +// if (!texname.startsWith("/")) |
---|
| 8378 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8379 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
| 8380 | + { |
---|
| 8381 | + texname = fallbackTextureName; |
---|
| 8382 | + } |
---|
6470 | 8383 | |
---|
6471 | 8384 | if (CACHETEXTURE) |
---|
6472 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
6473 | | - |
---|
6474 | | - TextureData texturedata = null; |
---|
6475 | | - |
---|
6476 | | - if (texture == null || texture.resolution < resolution) |
---|
6477 | 8385 | { |
---|
6478 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8386 | + if (texdata == null) |
---|
| 8387 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8388 | + else |
---|
| 8389 | + texturecache = bimtextures.get(texdata); |
---|
| 8390 | + } |
---|
| 8391 | + |
---|
| 8392 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8393 | + { |
---|
| 8394 | + TextureData texturedata = null; |
---|
| 8395 | + |
---|
| 8396 | + if (texdata != null && textureon) |
---|
| 8397 | + { |
---|
| 8398 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8399 | + |
---|
| 8400 | + try |
---|
| 8401 | + { |
---|
| 8402 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8403 | + } |
---|
| 8404 | + catch (Exception e) |
---|
| 8405 | + { |
---|
| 8406 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8407 | + } |
---|
| 8408 | + |
---|
| 8409 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8410 | + bimtextures.put(texdata, texturecache); |
---|
| 8411 | + |
---|
| 8412 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8413 | + |
---|
| 8414 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8415 | + //bim2 = bim; |
---|
| 8416 | + } |
---|
| 8417 | + else |
---|
| 8418 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
6479 | 8419 | { |
---|
6480 | 8420 | assert(!bump); |
---|
6481 | 8421 | // if (bump) |
---|
.. | .. |
---|
6486 | 8426 | // } |
---|
6487 | 8427 | // else |
---|
6488 | 8428 | // { |
---|
6489 | | - texture = textures.get(tex); |
---|
6490 | | - if (texture == null) |
---|
| 8429 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8430 | + if (texturecache == null) |
---|
6491 | 8431 | { |
---|
6492 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8432 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
6493 | 8433 | } |
---|
| 8434 | + else |
---|
| 8435 | + new Exception().printStackTrace(); |
---|
6494 | 8436 | // } |
---|
6495 | 8437 | } else |
---|
6496 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8438 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
6497 | 8439 | { |
---|
6498 | 8440 | assert(bump); |
---|
6499 | | - texture = textures.get(tex); |
---|
6500 | | - if (texture == null) |
---|
6501 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8441 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8442 | + if (texturecache == null) |
---|
| 8443 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8444 | + else |
---|
| 8445 | + new Exception().printStackTrace(); |
---|
6502 | 8446 | } else |
---|
6503 | 8447 | { |
---|
6504 | 8448 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
6506 | 8450 | // texture = GetResourceTexture("default.png"); |
---|
6507 | 8451 | //} else |
---|
6508 | 8452 | //{ |
---|
6509 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8453 | + if (texname.endsWith("WHITE_NOISE")) |
---|
6510 | 8454 | { |
---|
6511 | | - texture = textures.get(tex); |
---|
6512 | | - if (texture == null) |
---|
6513 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8455 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8456 | + if (texturecache == null) |
---|
| 8457 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8458 | + else |
---|
| 8459 | + new Exception().printStackTrace(); |
---|
| 8460 | + } else |
---|
| 8461 | + { |
---|
| 8462 | + if (texname.startsWith("@")) |
---|
| 8463 | + { |
---|
| 8464 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8465 | + if (texturecache == null) |
---|
| 8466 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
| 8467 | + else |
---|
| 8468 | + new Exception().printStackTrace(); |
---|
6514 | 8469 | } else |
---|
6515 | 8470 | { |
---|
6516 | 8471 | if (textureon) |
---|
.. | .. |
---|
6535 | 8490 | } |
---|
6536 | 8491 | |
---|
6537 | 8492 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
6538 | | - if (!new File(cachename).exists()) |
---|
| 8493 | + if (!FileExists(cachename)) |
---|
6539 | 8494 | cachename = texname; |
---|
6540 | 8495 | else |
---|
6541 | 8496 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
6557 | 8512 | } |
---|
6558 | 8513 | |
---|
6559 | 8514 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
6560 | | - if (!new File(cachename).exists()) |
---|
| 8515 | + if (!FileExists(cachename)) |
---|
6561 | 8516 | cachename = texname; |
---|
6562 | 8517 | else |
---|
6563 | 8518 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
6566 | 8521 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
6567 | 8522 | |
---|
6568 | 8523 | |
---|
6569 | | - if (texturedata != null) |
---|
6570 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8524 | + if (texturedata == null) |
---|
| 8525 | + throw new Exception(); |
---|
| 8526 | + |
---|
| 8527 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
6571 | 8528 | //texture = GetTexture(tex, bump); |
---|
6572 | 8529 | } |
---|
| 8530 | + } |
---|
6573 | 8531 | } |
---|
6574 | 8532 | //} |
---|
6575 | 8533 | } |
---|
6576 | 8534 | |
---|
6577 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8535 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
6578 | 8536 | { |
---|
6579 | 8537 | //return false; |
---|
6580 | 8538 | |
---|
6581 | 8539 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
6582 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8540 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
6583 | 8541 | { |
---|
6584 | 8542 | // String ext = "_highres"; |
---|
6585 | 8543 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
6596 | 8554 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
6597 | 8555 | if (!cachefile.exists()) |
---|
6598 | 8556 | { |
---|
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)) |
---|
| 8557 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
6608 | 8558 | { |
---|
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); |
---|
| 8559 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8560 | + |
---|
6639 | 8561 | ImageWriter writer = null; |
---|
6640 | 8562 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
6641 | 8563 | if (iter.hasNext()) { |
---|
6642 | 8564 | writer = (ImageWriter)iter.next(); |
---|
6643 | 8565 | } |
---|
6644 | | - float compressionQuality = 0.9f; |
---|
| 8566 | + |
---|
| 8567 | + float compressionQuality = 0.85f; |
---|
6645 | 8568 | try |
---|
6646 | 8569 | { |
---|
6647 | 8570 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
6658 | 8581 | } |
---|
6659 | 8582 | } |
---|
6660 | 8583 | } |
---|
6661 | | - |
---|
| 8584 | + |
---|
| 8585 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8586 | + |
---|
6662 | 8587 | //System.out.println("Texture = " + tex); |
---|
6663 | | - if (textures.containsKey(texname)) |
---|
| 8588 | + if (textures.containsKey(tex)) |
---|
6664 | 8589 | { |
---|
6665 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8590 | + CacheTexture thetex = textures.get(tex); |
---|
6666 | 8591 | thetex.texture.disable(); |
---|
6667 | 8592 | thetex.texture.dispose(); |
---|
6668 | | - textures.remove(texname); |
---|
| 8593 | + textures.remove(tex); |
---|
6669 | 8594 | } |
---|
6670 | 8595 | |
---|
6671 | | - texture.texturedata = texturedata; |
---|
6672 | | - textures.put(texname, texture); |
---|
| 8596 | + //texture.texturedata = texturedata; |
---|
| 8597 | + textures.put(tex, texturecache); |
---|
6673 | 8598 | |
---|
6674 | 8599 | // newtex = true; |
---|
6675 | 8600 | } |
---|
.. | .. |
---|
6685 | 8610 | } |
---|
6686 | 8611 | } |
---|
6687 | 8612 | |
---|
6688 | | - return texture; |
---|
| 8613 | + return texturecache; |
---|
6689 | 8614 | } |
---|
6690 | 8615 | |
---|
6691 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8616 | + static void EmbedTextures(cTexture tex) |
---|
| 8617 | + { |
---|
| 8618 | + if (tex.pigmentdata == null) |
---|
| 8619 | + { |
---|
| 8620 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8621 | + |
---|
| 8622 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8623 | + |
---|
| 8624 | + if (texturecache != null) |
---|
| 8625 | + { |
---|
| 8626 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8627 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8628 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8629 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8630 | + ; |
---|
| 8631 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8632 | + } |
---|
| 8633 | + } |
---|
| 8634 | + |
---|
| 8635 | + if (tex.bumpdata == null) |
---|
| 8636 | + { |
---|
| 8637 | + //String texname = Object3D.GetBump(tex); |
---|
| 8638 | + |
---|
| 8639 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8640 | + |
---|
| 8641 | + if (texturecache != null) |
---|
| 8642 | + { |
---|
| 8643 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8644 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8645 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8646 | + } |
---|
| 8647 | + } |
---|
| 8648 | + } |
---|
| 8649 | + |
---|
| 8650 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
6692 | 8651 | { |
---|
6693 | 8652 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
6694 | 8653 | |
---|
.. | .. |
---|
6706 | 8665 | return texture!=null?texture.texture:null; |
---|
6707 | 8666 | } |
---|
6708 | 8667 | |
---|
6709 | | - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8668 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
6710 | 8669 | { |
---|
6711 | 8670 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
6712 | 8671 | |
---|
6713 | 8672 | return texture!=null?texture.texturedata:null; |
---|
6714 | 8673 | } |
---|
6715 | 8674 | |
---|
6716 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8675 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
6717 | 8676 | { |
---|
6718 | 8677 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
6719 | 8678 | { |
---|
6720 | 8679 | return false; |
---|
6721 | 8680 | } |
---|
6722 | 8681 | |
---|
6723 | | - boolean newtex = false; |
---|
| 8682 | + //boolean newtex = false; |
---|
6724 | 8683 | |
---|
6725 | 8684 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
6726 | 8685 | |
---|
.. | .. |
---|
6752 | 8711 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
6753 | 8712 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
6754 | 8713 | |
---|
6755 | | - return newtex; |
---|
| 8714 | + return true; // Warning: not used. |
---|
6756 | 8715 | } |
---|
6757 | 8716 | |
---|
| 8717 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8718 | + { |
---|
| 8719 | + try |
---|
| 8720 | + { |
---|
| 8721 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8722 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8723 | + ImageWriter writer = writers.next(); |
---|
| 8724 | + |
---|
| 8725 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8726 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8727 | + param.setCompressionQuality(quality); |
---|
| 8728 | + |
---|
| 8729 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8730 | + writer.setOutput(ios); |
---|
| 8731 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8732 | + |
---|
| 8733 | + byte[] data = baos.toByteArray(); |
---|
| 8734 | + writer.dispose(); |
---|
| 8735 | + return data; |
---|
| 8736 | + } |
---|
| 8737 | + catch (Exception e) |
---|
| 8738 | + { |
---|
| 8739 | + e.printStackTrace(); |
---|
| 8740 | + return null; |
---|
| 8741 | + } |
---|
| 8742 | + } |
---|
| 8743 | + |
---|
| 8744 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8745 | + { |
---|
| 8746 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8747 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8748 | + ImageReader reader = writers.next(); |
---|
| 8749 | + |
---|
| 8750 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8751 | + |
---|
| 8752 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8753 | + param.setDestination(bim); |
---|
| 8754 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8755 | + |
---|
| 8756 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8757 | + reader.setInput(ios); |
---|
| 8758 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8759 | + reader.dispose(); |
---|
| 8760 | + |
---|
| 8761 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8762 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8763 | +// byte[] bytes = data.getData(); |
---|
| 8764 | +// |
---|
| 8765 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8766 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8767 | +// { |
---|
| 8768 | +// int i3 = i*3; |
---|
| 8769 | +// pixels[i] = 0xFF; |
---|
| 8770 | +// pixels[i] <<= 8; |
---|
| 8771 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8772 | +// pixels[i] <<= 8; |
---|
| 8773 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8774 | +// pixels[i] <<= 8; |
---|
| 8775 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8776 | +// } |
---|
| 8777 | +// |
---|
| 8778 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8779 | + |
---|
| 8780 | + return bim; |
---|
| 8781 | + } |
---|
| 8782 | + |
---|
6758 | 8783 | ShadowBuffer shadowPBuf; |
---|
6759 | 8784 | AntialiasBuffer antialiasPBuf; |
---|
6760 | 8785 | int MAXSTACK; |
---|
.. | .. |
---|
6771 | 8796 | |
---|
6772 | 8797 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
6773 | 8798 | MAXSTACK = temp[0]; |
---|
6774 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
6775 | 8801 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
6776 | 8802 | MAXSTACK = temp[0]; |
---|
6777 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8803 | + if (Globals.DEBUG) |
---|
| 8804 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
6778 | 8805 | |
---|
6779 | 8806 | // Use debug pipeline |
---|
6780 | 8807 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
6782 | 8809 | gl = drawable.getGL(); // |
---|
6783 | 8810 | |
---|
6784 | 8811 | GL gl3 = getGL(); |
---|
6785 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8812 | + if (Globals.DEBUG) |
---|
| 8813 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
6786 | 8814 | |
---|
6787 | 8815 | |
---|
6788 | 8816 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
6947 | 8975 | |
---|
6948 | 8976 | if (cubemap == null) |
---|
6949 | 8977 | { |
---|
6950 | | - LoadEnvy(5); |
---|
| 8978 | + //LoadEnvy(1); |
---|
6951 | 8979 | } |
---|
6952 | 8980 | |
---|
6953 | 8981 | //cubemap.enable(); |
---|
.. | .. |
---|
7223 | 9251 | |
---|
7224 | 9252 | void LoadEnvy(int which) |
---|
7225 | 9253 | { |
---|
| 9254 | + assert(false); |
---|
| 9255 | + |
---|
7226 | 9256 | String name; |
---|
7227 | 9257 | String ext; |
---|
7228 | 9258 | |
---|
.. | .. |
---|
7234 | 9264 | cubemap = null; |
---|
7235 | 9265 | return; |
---|
7236 | 9266 | case 1: |
---|
7237 | | - name = "cubemaps/box_"; |
---|
7238 | | - ext = "png"; |
---|
| 9267 | + name = "cubemaps/rgb/"; |
---|
| 9268 | + ext = "jpg"; |
---|
7239 | 9269 | reverseUP = false; |
---|
7240 | 9270 | break; |
---|
7241 | 9271 | case 2: |
---|
7242 | | - name = "cubemaps/uffizi_"; |
---|
7243 | | - ext = "png"; |
---|
7244 | | - break; // reverseUP = true; break; |
---|
| 9272 | + name = "cubemaps/uffizi/"; |
---|
| 9273 | + ext = "jpg"; |
---|
| 9274 | + reverseUP = false; |
---|
| 9275 | + break; |
---|
7245 | 9276 | case 3: |
---|
7246 | | - name = "cubemaps/CloudyHills_"; |
---|
7247 | | - ext = "tga"; |
---|
| 9277 | + name = "cubemaps/CloudyHills/"; |
---|
| 9278 | + ext = "jpg"; |
---|
7248 | 9279 | reverseUP = false; |
---|
7249 | 9280 | break; |
---|
7250 | 9281 | case 4: |
---|
7251 | | - name = "cubemaps/cornell_"; |
---|
| 9282 | + name = "cubemaps/cornell/"; |
---|
7252 | 9283 | ext = "png"; |
---|
7253 | 9284 | reverseUP = false; |
---|
7254 | 9285 | break; |
---|
| 9286 | + case 5: |
---|
| 9287 | + name = "cubemaps/skycube/"; |
---|
| 9288 | + ext = "jpg"; |
---|
| 9289 | + reverseUP = false; |
---|
| 9290 | + break; |
---|
| 9291 | + case 6: |
---|
| 9292 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9293 | + ext = "jpg"; |
---|
| 9294 | + reverseUP = false; |
---|
| 9295 | + break; |
---|
| 9296 | + case 7: |
---|
| 9297 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9298 | + ext = "jpg"; |
---|
| 9299 | + reverseUP = false; |
---|
| 9300 | + break; |
---|
| 9301 | + case 8: |
---|
| 9302 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9303 | + ext = "jpg"; |
---|
| 9304 | + reverseUP = false; |
---|
| 9305 | + break; |
---|
| 9306 | + case 9: |
---|
| 9307 | + name = "cubemaps/UnionSquare/"; |
---|
| 9308 | + ext = "jpg"; |
---|
| 9309 | + reverseUP = false; |
---|
| 9310 | + break; |
---|
7255 | 9311 | default: |
---|
7256 | | - name = "cubemaps/rgb_"; |
---|
7257 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9312 | + name = "cubemaps/box/"; |
---|
| 9313 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9314 | + reverseUP = false; |
---|
7258 | 9315 | break; |
---|
7259 | 9316 | } |
---|
7260 | | - |
---|
7261 | | - try |
---|
7262 | | - { |
---|
7263 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
7264 | | - } catch (IOException e) |
---|
7265 | | - { |
---|
7266 | | - throw new RuntimeException(e); |
---|
7267 | | - } |
---|
| 9317 | + |
---|
| 9318 | + LoadSkybox(name, ext, mipmap); |
---|
7268 | 9319 | } |
---|
7269 | 9320 | |
---|
7270 | 9321 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
7296 | 9347 | static double[] model = new double[16]; |
---|
7297 | 9348 | double[] camera2light = new double[16]; |
---|
7298 | 9349 | double[] light2camera = new double[16]; |
---|
7299 | | - int newenvy = -1; |
---|
7300 | | - boolean envyoff = true; // false; |
---|
| 9350 | + |
---|
| 9351 | + //int newenvy = -1; |
---|
| 9352 | + //boolean envyoff = false; |
---|
| 9353 | + |
---|
| 9354 | + String loadedskyboxname; |
---|
| 9355 | + |
---|
7301 | 9356 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
7302 | 9357 | //float[] light0 = { 0,0,0 }; |
---|
7303 | 9358 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
7310 | 9365 | static boolean occlusionInitialized = false; |
---|
7311 | 9366 | boolean selection = false; |
---|
7312 | 9367 | boolean pointselection = false; |
---|
7313 | | - /*static*/ boolean lighttouched = true; |
---|
| 9368 | + ///*static*/ boolean lighttouched = true; |
---|
7314 | 9369 | boolean deselect; |
---|
7315 | | - boolean ambientOcclusion = false; |
---|
| 9370 | + private boolean ambientOcclusion = false; |
---|
7316 | 9371 | static boolean flash = false; |
---|
7317 | 9372 | /*static*/ boolean wait = false; |
---|
7318 | 9373 | boolean displaydone = false; // after repaint() calls |
---|
.. | .. |
---|
7442 | 9497 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
7443 | 9498 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
7444 | 9499 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 9500 | +// PATCH FILLE AUX JEANS |
---|
| 9501 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
7445 | 9502 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
7446 | 9503 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
7447 | 9504 | |
---|
.. | .. |
---|
7588 | 9645 | jy8[3] = 0.5f; |
---|
7589 | 9646 | } |
---|
7590 | 9647 | |
---|
7591 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9648 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
7592 | 9649 | 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 |
---|
| 9650 | + float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
| 9651 | + float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
7594 | 9652 | |
---|
| 9653 | + void ResetOptions() |
---|
| 9654 | + { |
---|
| 9655 | + options1[0] = 100; |
---|
| 9656 | + options1[1] = 0.025f; |
---|
| 9657 | + options1[2] = 0.01f; |
---|
| 9658 | + options1[3] = 0; |
---|
| 9659 | + options1[4] = 0; |
---|
| 9660 | + |
---|
| 9661 | + options2[0] = 0; |
---|
| 9662 | + options2[1] = 0.75f; |
---|
| 9663 | + options2[2] = 0; |
---|
| 9664 | + options2[3] = 0; |
---|
| 9665 | + |
---|
| 9666 | + options3[0] = 1; |
---|
| 9667 | + options3[1] = 1; |
---|
| 9668 | + options3[2] = 1; |
---|
| 9669 | + options3[3] = 0; |
---|
| 9670 | + |
---|
| 9671 | + options4[0] = 1; |
---|
| 9672 | + options4[1] = 0; |
---|
| 9673 | + options4[2] = 1; |
---|
| 9674 | + options4[3] = 0; |
---|
| 9675 | + } |
---|
| 9676 | + |
---|
7595 | 9677 | static int imagecount = 0; // movie generation |
---|
7596 | 9678 | |
---|
7597 | 9679 | static int jitter = 0; |
---|
7598 | 9680 | |
---|
7599 | 9681 | boolean restartframe = false; |
---|
7600 | | - |
---|
7601 | | - static int framecount = 0; // general-purpose global count |
---|
7602 | 9682 | |
---|
7603 | 9683 | void displayAntiAliased(javax.media.opengl.GL gl) |
---|
7604 | 9684 | { |
---|
.. | .. |
---|
7630 | 9710 | gl.glClear(gl.GL_ACCUM_BUFFER_BIT); |
---|
7631 | 9711 | for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0) |
---|
7632 | 9712 | { |
---|
7633 | | - framecount++; |
---|
| 9713 | + Globals.framecount++; |
---|
7634 | 9714 | |
---|
7635 | 9715 | if (CameraPane.tickcount > 0) |
---|
7636 | 9716 | CameraPane.tickcount--; |
---|
.. | .. |
---|
7668 | 9748 | |
---|
7669 | 9749 | gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0); |
---|
7670 | 9750 | */ |
---|
7671 | | - lighttouched = true; |
---|
| 9751 | + Globals.lighttouched = true; |
---|
7672 | 9752 | //System.err.println(" shadowbuffer: " + jitter); |
---|
7673 | 9753 | shadowbuffer.display(); |
---|
7674 | 9754 | |
---|
.. | .. |
---|
7689 | 9769 | assert (parentcam != renderCamera); |
---|
7690 | 9770 | |
---|
7691 | 9771 | if (renderCamera != lightCamera) |
---|
7692 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7693 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 9772 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9773 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
7694 | 9774 | |
---|
7695 | 9775 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
7696 | 9776 | |
---|
.. | .. |
---|
7705 | 9785 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
7706 | 9786 | |
---|
7707 | 9787 | if (renderCamera != lightCamera) |
---|
7708 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7709 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 9788 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9789 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
7710 | 9790 | |
---|
7711 | 9791 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
7712 | 9792 | |
---|
.. | .. |
---|
7752 | 9832 | rati = 1 / rati; |
---|
7753 | 9833 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
7754 | 9834 | } |
---|
7755 | | - assert (newenvy == -1); |
---|
| 9835 | + |
---|
| 9836 | + //assert (newenvy == -1); |
---|
| 9837 | + |
---|
7756 | 9838 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
7757 | 9839 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
7758 | | - DrawSkyBox(gl); |
---|
| 9840 | + DrawSkyBox(gl, (float)rati); |
---|
7759 | 9841 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
7760 | 9842 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
7761 | 9843 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
7778 | 9860 | //gl.glFlush(); |
---|
7779 | 9861 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
7780 | 9862 | |
---|
7781 | | - if (ANIMATION && ABORTED) |
---|
| 9863 | + if (Globals.ANIMATION && ABORTED) |
---|
7782 | 9864 | { |
---|
7783 | 9865 | System.err.println(" ABORTED FRAME"); |
---|
7784 | 9866 | break; |
---|
.. | .. |
---|
7808 | 9890 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
7809 | 9891 | |
---|
7810 | 9892 | // save image |
---|
7811 | | - if (ANIMATION && !ABORTED) |
---|
| 9893 | + if (Globals.ANIMATION && !ABORTED) |
---|
7812 | 9894 | { |
---|
7813 | 9895 | VPwidth = viewport[2]; |
---|
7814 | 9896 | VPheight = viewport[3]; |
---|
.. | .. |
---|
7919 | 10001 | |
---|
7920 | 10002 | // imagecount++; |
---|
7921 | 10003 | |
---|
7922 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 10004 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
7923 | 10005 | |
---|
7924 | 10006 | if (!BOXMODE) |
---|
7925 | 10007 | { |
---|
7926 | | - System.out.println("image: " + fullname + " (" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 10008 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
7927 | 10009 | } |
---|
7928 | 10010 | |
---|
7929 | 10011 | if (!BOXMODE) |
---|
.. | .. |
---|
7961 | 10043 | ABORTED = false; |
---|
7962 | 10044 | } |
---|
7963 | 10045 | else |
---|
7964 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 10046 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
7965 | 10047 | |
---|
7966 | 10048 | if (false) |
---|
7967 | 10049 | { |
---|
.. | .. |
---|
8615 | 10697 | } |
---|
8616 | 10698 | } |
---|
8617 | 10699 | |
---|
8618 | | - boolean IsFrozen() |
---|
8619 | | - { |
---|
8620 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
8621 | | - |
---|
8622 | | - return !selectmode && cameracount == 0; // != 0; |
---|
8623 | | - } |
---|
8624 | | - |
---|
8625 | 10700 | boolean niceon = false; |
---|
8626 | 10701 | javax.swing.Timer AAtimer = new javax.swing.Timer(750, this); |
---|
8627 | 10702 | boolean currentlydrawing = false; |
---|
8628 | 10703 | static boolean init = false; |
---|
8629 | 10704 | |
---|
8630 | 10705 | double[][] matrix = LA.newMatrix(); |
---|
| 10706 | + |
---|
| 10707 | + // This is to refresh the UI of the material panel. |
---|
| 10708 | + ObjEditor patchMaterial; |
---|
8631 | 10709 | |
---|
8632 | 10710 | public void display(GLAutoDrawable drawable) |
---|
8633 | 10711 | { |
---|
8634 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10712 | + if (patchMaterial.patchMaterial) |
---|
8635 | 10713 | { |
---|
8636 | | - GrafreeD.wav.save(); |
---|
8637 | | - GrafreeD.savesound = false; |
---|
8638 | | - GrafreeD.hassound = false; |
---|
| 10714 | + patchMaterial.patchMaterial = false; |
---|
| 10715 | + patchMaterial.objectPanel.setSelectedIndex(1); |
---|
| 10716 | + } |
---|
| 10717 | + |
---|
| 10718 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
| 10719 | + { |
---|
| 10720 | + Grafreed.wav.save(); |
---|
| 10721 | + Grafreed.savesound = false; |
---|
| 10722 | + Grafreed.hassound = false; |
---|
8639 | 10723 | } |
---|
8640 | 10724 | // if (DEBUG_SELECTION) |
---|
8641 | 10725 | // { |
---|
8642 | | -// if (drawMode != SELECTION) |
---|
8643 | | -// drawMode = SELECTION; |
---|
| 10726 | +// if (DrawMode() != SELECTION) |
---|
| 10727 | +// DrawMode() = SELECTION; |
---|
8644 | 10728 | // } |
---|
8645 | 10729 | |
---|
8646 | 10730 | if (!isRenderer) |
---|
.. | .. |
---|
8696 | 10780 | |
---|
8697 | 10781 | //ANTIALIAS = 0; |
---|
8698 | 10782 | |
---|
8699 | | - if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
| 10783 | + if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0) |
---|
8700 | 10784 | { |
---|
8701 | | - if (niceon || isLIVE()) |
---|
| 10785 | + if (niceon || Globals.isLIVE()) |
---|
8702 | 10786 | { |
---|
8703 | 10787 | //if(active == 0) |
---|
8704 | 10788 | // antialiaser = null; |
---|
.. | .. |
---|
8711 | 10795 | ANTIALIAS = 0; |
---|
8712 | 10796 | //System.out.println("RESTART"); |
---|
8713 | 10797 | AAtimer.restart(); |
---|
| 10798 | + Globals.TIMERRUNNING = true; |
---|
8714 | 10799 | } |
---|
8715 | 10800 | } |
---|
8716 | 10801 | } |
---|
.. | .. |
---|
8723 | 10808 | assert eyeCamera.shaper_zFar == 1E5f; // 500.0f; |
---|
8724 | 10809 | */ |
---|
8725 | 10810 | |
---|
8726 | | - if (drawMode == DEFAULT) |
---|
| 10811 | + if (DrawMode() == DEFAULT) |
---|
8727 | 10812 | { |
---|
8728 | 10813 | currentlydrawing = true; |
---|
8729 | 10814 | } |
---|
.. | .. |
---|
8754 | 10839 | |
---|
8755 | 10840 | // if(Applet3D.clipboard != null) |
---|
8756 | 10841 | // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent); |
---|
8757 | | -//drawMode = SELECTION; |
---|
| 10842 | +//DrawMode() = SELECTION; |
---|
8758 | 10843 | indexcount = 0; |
---|
8759 | 10844 | |
---|
8760 | | - if (drawMode == OCCLUSION) |
---|
| 10845 | + if (DrawMode() == OCCLUSION) |
---|
8761 | 10846 | { |
---|
8762 | | - drawMode = DEFAULT; |
---|
| 10847 | + Globals.drawMode = DEFAULT; // WARNING |
---|
8763 | 10848 | ambientOcclusion = true; |
---|
8764 | 10849 | setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
---|
8765 | 10850 | Object3D theobject = object; |
---|
8766 | 10851 | Object3D theparent = object.parent; |
---|
8767 | 10852 | object.parent = null; |
---|
8768 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10853 | + object = (Object3D)Grafreed.clone(object); |
---|
8769 | 10854 | object.Stripify(); |
---|
8770 | 10855 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
8771 | 10856 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
8778 | 10863 | ambientOcclusion = false; |
---|
8779 | 10864 | } |
---|
8780 | 10865 | |
---|
8781 | | - if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10866 | + if (//Globals.lighttouched && |
---|
| 10867 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
8782 | 10868 | { |
---|
8783 | 10869 | //if (RENDERSHADOW) // ? |
---|
8784 | 10870 | if (!IsFrozen()) |
---|
8785 | 10871 | { |
---|
8786 | 10872 | // dec 2012 |
---|
8787 | | - if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)) |
---|
| 10873 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
8788 | 10874 | { |
---|
8789 | | - framecount++; |
---|
| 10875 | + Globals.framecount++; |
---|
8790 | 10876 | shadowbuffer.display(); |
---|
8791 | 10877 | } |
---|
8792 | 10878 | } |
---|
8793 | | - lighttouched = false; // ?? |
---|
| 10879 | + Globals.lighttouched = false; // ?? |
---|
8794 | 10880 | //drawing = true; |
---|
8795 | 10881 | //lighttouched = true; |
---|
8796 | 10882 | } |
---|
8797 | 10883 | |
---|
8798 | 10884 | if (wait) |
---|
8799 | 10885 | { |
---|
8800 | | - Sleep(500); |
---|
| 10886 | + Sleep(200); // blocks everything |
---|
8801 | 10887 | |
---|
8802 | 10888 | wait = false; |
---|
8803 | 10889 | } |
---|
.. | .. |
---|
8811 | 10897 | //eyeCamera.shaper_fovy = 1; |
---|
8812 | 10898 | } |
---|
8813 | 10899 | |
---|
8814 | | - if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION) |
---|
| 10900 | + if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION) |
---|
8815 | 10901 | { |
---|
8816 | | - //System.out.println("drawMode = " + drawMode); |
---|
| 10902 | + //System.out.println("DrawMode() = " + DrawMode()); |
---|
8817 | 10903 | vertexMode |= VP_PASS; |
---|
8818 | 10904 | //vertexMode |= VP_PROJECTION; |
---|
8819 | 10905 | if (!ambientOcclusion) |
---|
.. | .. |
---|
8873 | 10959 | Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera; |
---|
8874 | 10960 | //Camera lightcam = new Camera(light0); |
---|
8875 | 10961 | |
---|
8876 | | - if (drawMode == SHADOW) |
---|
| 10962 | + if (DrawMode() == SHADOW) |
---|
8877 | 10963 | { |
---|
8878 | 10964 | /* |
---|
8879 | 10965 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
.. | .. |
---|
8911 | 10997 | |
---|
8912 | 10998 | // if (parentcam != renderCamera) // not a light |
---|
8913 | 10999 | if (cam != lightCamera) |
---|
8914 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8915 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 11000 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11001 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
8916 | 11002 | |
---|
8917 | 11003 | for (int j = 0; j < 4; j++) |
---|
8918 | 11004 | { |
---|
.. | .. |
---|
8926 | 11012 | |
---|
8927 | 11013 | // if (parentcam != renderCamera) // not a light |
---|
8928 | 11014 | if (cam != lightCamera) |
---|
8929 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8930 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 11015 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11016 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
8931 | 11017 | |
---|
8932 | 11018 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
8933 | 11019 | |
---|
.. | .. |
---|
8963 | 11049 | gl.glClear(gl.GL_DEPTH_BUFFER_BIT); |
---|
8964 | 11050 | } else |
---|
8965 | 11051 | { |
---|
8966 | | - if (drawMode != DEFAULT) |
---|
| 11052 | + if (DrawMode() != DEFAULT) |
---|
8967 | 11053 | { |
---|
8968 | 11054 | gl.glClearColor(1, 1, 1, 0); |
---|
8969 | 11055 | } // 1); |
---|
.. | .. |
---|
9013 | 11099 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
9014 | 11100 | } |
---|
9015 | 11101 | |
---|
9016 | | - if (newenvy > -1) |
---|
| 11102 | +// if (newenvy > -1) |
---|
| 11103 | +// { |
---|
| 11104 | +// LoadEnvy(newenvy); |
---|
| 11105 | +// } |
---|
| 11106 | +// |
---|
| 11107 | +// newenvy = -1; |
---|
| 11108 | + |
---|
| 11109 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
9017 | 11110 | { |
---|
9018 | | - LoadEnvy(newenvy); |
---|
| 11111 | + if (cubemaprgb == null) |
---|
| 11112 | + { |
---|
| 11113 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11114 | + } |
---|
| 11115 | + |
---|
| 11116 | + cubemap = cubemaprgb; |
---|
9019 | 11117 | } |
---|
9020 | | - |
---|
9021 | | - newenvy = -1; |
---|
9022 | | - |
---|
| 11118 | + else |
---|
| 11119 | + { |
---|
| 11120 | + if (object.skyboxname != null) |
---|
| 11121 | + { |
---|
| 11122 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11123 | + { |
---|
| 11124 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11125 | + cubemap.dispose(); |
---|
| 11126 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11127 | + loadedskyboxname = object.skyboxname; |
---|
| 11128 | + } |
---|
| 11129 | + } |
---|
| 11130 | + else |
---|
| 11131 | + { |
---|
| 11132 | + cubemapcustom = null; |
---|
| 11133 | + loadedskyboxname = null; |
---|
| 11134 | + } |
---|
| 11135 | + |
---|
| 11136 | + cubemap = cubemapcustom; |
---|
| 11137 | + } |
---|
| 11138 | + |
---|
9023 | 11139 | ratio = ((double) getWidth()) / getHeight(); |
---|
9024 | 11140 | //System.out.println("ratio = " + ratio); |
---|
9025 | 11141 | |
---|
.. | .. |
---|
9028 | 11144 | |
---|
9029 | 11145 | fast &= !ambientOcclusion; |
---|
9030 | 11146 | |
---|
9031 | | - if (drawMode == DEFAULT) |
---|
| 11147 | + if (DrawMode() == DEFAULT) |
---|
9032 | 11148 | { |
---|
9033 | 11149 | //gl.glEnable(gl.GL_ALPHA_TEST); |
---|
9034 | 11150 | //gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
9035 | 11151 | |
---|
9036 | 11152 | if (!IsFrozen() && !ambientOcclusion) |
---|
9037 | 11153 | { |
---|
9038 | | - DrawSkyBox(gl); |
---|
| 11154 | + DrawSkyBox(gl, (float)ratio); |
---|
9039 | 11155 | } |
---|
9040 | 11156 | |
---|
9041 | 11157 | //if (selection_view == -1) |
---|
.. | .. |
---|
9089 | 11205 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
9090 | 11206 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9091 | 11207 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 11208 | +// PATCH FILLE AUX JEANS |
---|
| 11209 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9092 | 11210 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9093 | 11211 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9094 | 11212 | |
---|
.. | .. |
---|
9184 | 11302 | // Bump noise |
---|
9185 | 11303 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
9186 | 11304 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
9187 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11305 | + |
---|
| 11306 | + try |
---|
| 11307 | + { |
---|
| 11308 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11309 | + } |
---|
| 11310 | + catch (Exception e) |
---|
| 11311 | + { |
---|
| 11312 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11313 | + } |
---|
| 11314 | + |
---|
9188 | 11315 | |
---|
9189 | 11316 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
9190 | 11317 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9207 | 11334 | |
---|
9208 | 11335 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
9209 | 11336 | |
---|
9210 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
9211 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
9212 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11337 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11338 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11339 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
9213 | 11340 | } else |
---|
9214 | 11341 | { |
---|
9215 | 11342 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9220 | 11347 | //System.out.println("BLENDING ON"); |
---|
9221 | 11348 | gl.glEnable(GL.GL_BLEND); |
---|
9222 | 11349 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
9223 | | - |
---|
| 11350 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
9224 | 11351 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
9225 | 11352 | gl.glLoadIdentity(); |
---|
9226 | 11353 | |
---|
9227 | | - if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
| 11354 | + if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) |
---|
9228 | 11355 | { |
---|
9229 | 11356 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9230 | 11357 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 11358 | +// PATCH FILLE AUX JEANS |
---|
| 11359 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9231 | 11360 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9232 | 11361 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9233 | 11362 | //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE); |
---|
.. | .. |
---|
9280 | 11409 | //gl.glPushMatrix(); |
---|
9281 | 11410 | gl.glLoadIdentity(); |
---|
9282 | 11411 | |
---|
9283 | | - if (!ambientOcclusion) // drawMode != OCCLUSION) |
---|
| 11412 | + if (!ambientOcclusion) // DrawMode() != OCCLUSION) |
---|
9284 | 11413 | { |
---|
9285 | 11414 | //LA.xformPos(light0, lightCamera.fromScreen, light); |
---|
9286 | 11415 | LA.xformDir(dirlight, lightCamera.fromScreen, lightposition); |
---|
.. | .. |
---|
9307 | 11436 | System.err.println("parentcam != renderCamera"); |
---|
9308 | 11437 | |
---|
9309 | 11438 | // if (cam != lightCamera) |
---|
9310 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9311 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11439 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11440 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
9312 | 11441 | } |
---|
9313 | 11442 | |
---|
9314 | 11443 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
9329 | 11458 | if (true) // TODO |
---|
9330 | 11459 | { |
---|
9331 | 11460 | if (cam != lightCamera) |
---|
9332 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9333 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11461 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11462 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
9334 | 11463 | } |
---|
9335 | 11464 | |
---|
9336 | 11465 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
9367 | 11496 | } |
---|
9368 | 11497 | |
---|
9369 | 11498 | /**/ |
---|
9370 | | - if (true) // drawMode == SELECTION) // != DEFAULT) |
---|
| 11499 | + if (true) // DrawMode() == SELECTION) // != DEFAULT) |
---|
9371 | 11500 | gl.glDisable(gl.GL_LIGHTING); |
---|
9372 | 11501 | else |
---|
9373 | 11502 | gl.glEnable(gl.GL_LIGHTING); |
---|
.. | .. |
---|
9379 | 11508 | |
---|
9380 | 11509 | gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0); |
---|
9381 | 11510 | gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0); |
---|
| 11511 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0); |
---|
9382 | 11512 | |
---|
9383 | 11513 | options2[0] *= renderCamera.Distance(); |
---|
9384 | 11514 | |
---|
9385 | 11515 | lightslot = 64; |
---|
9386 | 11516 | |
---|
9387 | | - if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT) |
---|
| 11517 | + if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT) |
---|
9388 | 11518 | { |
---|
9389 | 11519 | DrawLights(object); |
---|
9390 | 11520 | } |
---|
.. | .. |
---|
9395 | 11525 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
9396 | 11526 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
9397 | 11527 | |
---|
9398 | | - if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION) |
---|
| 11528 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
9399 | 11529 | { |
---|
9400 | 11530 | /* |
---|
9401 | 11531 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
9428 | 11558 | } |
---|
9429 | 11559 | } |
---|
9430 | 11560 | |
---|
9431 | | - if (drawMode == DEFAULT) |
---|
| 11561 | + if (DrawMode() == DEFAULT) |
---|
9432 | 11562 | { |
---|
9433 | 11563 | if (WIREFRAME && !ambientOcclusion) |
---|
9434 | 11564 | { |
---|
.. | .. |
---|
9446 | 11576 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9447 | 11577 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9448 | 11578 | |
---|
9449 | | - if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) // |
---|
| 11579 | + if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) // |
---|
9450 | 11580 | { |
---|
9451 | 11581 | if (vertexMode != 0) // && !fast) |
---|
9452 | 11582 | { |
---|
.. | .. |
---|
9466 | 11596 | } |
---|
9467 | 11597 | } |
---|
9468 | 11598 | |
---|
9469 | | - if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion) |
---|
| 11599 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
9470 | 11600 | { |
---|
9471 | 11601 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
9472 | 11602 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
9474 | 11604 | |
---|
9475 | 11605 | boolean texon = textureon; |
---|
9476 | 11606 | |
---|
9477 | | - if (RENDERPROGRAM > 0) |
---|
9478 | | - { |
---|
9479 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9480 | | - textureon = false; |
---|
9481 | | - } |
---|
| 11607 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11608 | + textureon = false; |
---|
| 11609 | + |
---|
9482 | 11610 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9483 | 11611 | //System.out.println("ALLO"); |
---|
9484 | 11612 | gl.glColorMask(false, false, false, false); |
---|
9485 | 11613 | DrawObject(gl); |
---|
9486 | | - if (RENDERPROGRAM > 0) |
---|
9487 | | - { |
---|
9488 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9489 | | - textureon = texon; |
---|
9490 | | - } |
---|
| 11614 | + |
---|
| 11615 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11616 | + textureon = texon; |
---|
| 11617 | + |
---|
9491 | 11618 | gl.glColorMask(true, true, true, true); |
---|
9492 | 11619 | |
---|
9493 | 11620 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
9494 | | - //gl.glDepthMask(false); |
---|
| 11621 | + gl.glDepthMask(false); |
---|
9495 | 11622 | } |
---|
9496 | 11623 | |
---|
9497 | | - if (false) // drawMode == SHADOW) |
---|
| 11624 | + if (false) // DrawMode() == SHADOW) |
---|
9498 | 11625 | { |
---|
9499 | 11626 | //SetColumnMajorData(cameraInverseTransform, view_1); |
---|
9500 | 11627 | //System.out.println("light = " + cameraInverseTransform); |
---|
.. | .. |
---|
9508 | 11635 | //System.out.println("object = " + object); |
---|
9509 | 11636 | if (!frozen && !imageLocked) |
---|
9510 | 11637 | { |
---|
9511 | | - if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0) |
---|
| 11638 | + if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0) |
---|
9512 | 11639 | { |
---|
9513 | 11640 | displayAntiAliased(gl); |
---|
9514 | 11641 | } else |
---|
9515 | 11642 | { |
---|
9516 | 11643 | programcount = 0; |
---|
9517 | | - int keepmode = drawMode; |
---|
| 11644 | + int keepmode = DrawMode(); |
---|
9518 | 11645 | // if (DEBUG_SELECTION) |
---|
9519 | 11646 | // { |
---|
9520 | | -// drawMode = SELECTION; |
---|
| 11647 | +// DrawMode() = SELECTION; |
---|
9521 | 11648 | // } |
---|
9522 | 11649 | // for point selection |
---|
9523 | 11650 | // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0); |
---|
.. | .. |
---|
9527 | 11654 | DrawObject(gl); |
---|
9528 | 11655 | |
---|
9529 | 11656 | // jan 2013 System.err.println("RESET ABORT (display)"); |
---|
9530 | | - // if (drawMode == DEFAULT) |
---|
| 11657 | + // if (DrawMode() == DEFAULT) |
---|
9531 | 11658 | // ABORTED = false; |
---|
9532 | 11659 | fullreset = false; |
---|
9533 | | - drawMode = keepmode; |
---|
| 11660 | + Globals.drawMode = keepmode; // WARNING |
---|
9534 | 11661 | //System.out.println("PROGRAM SWITCH " + programcount); |
---|
9535 | 11662 | } |
---|
9536 | 11663 | } |
---|
.. | .. |
---|
9538 | 11665 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9539 | 11666 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9540 | 11667 | |
---|
9541 | | - if (drawMode == DEFAULT) |
---|
| 11668 | + if (DrawMode() == DEFAULT) |
---|
9542 | 11669 | { |
---|
9543 | 11670 | ReleaseTexture(NOISE_TEXTURE, false); |
---|
9544 | 11671 | } |
---|
9545 | | - //if (drawMode == DEFAULT) |
---|
| 11672 | + //if (DrawMode() == DEFAULT) |
---|
9546 | 11673 | { |
---|
9547 | 11674 | |
---|
9548 | 11675 | gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
.. | .. |
---|
9554 | 11681 | //else |
---|
9555 | 11682 | //gl.glDisable(gl.GL_TEXTURE_2D); |
---|
9556 | 11683 | //gl.glPopMatrix(); |
---|
9557 | | - if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
| 11684 | + if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion) |
---|
9558 | 11685 | { |
---|
9559 | 11686 | //new Exception().printStackTrace(); |
---|
9560 | 11687 | //System.out.println("Draw image " + width + ", " + height); |
---|
.. | .. |
---|
9596 | 11723 | //gl.glFlush(); |
---|
9597 | 11724 | } |
---|
9598 | 11725 | |
---|
9599 | | - if (flash && drawMode == DEFAULT) |
---|
| 11726 | + if (flash && DrawMode() == DEFAULT) |
---|
9600 | 11727 | { |
---|
9601 | 11728 | flash = false; |
---|
9602 | 11729 | wait = true; |
---|
.. | .. |
---|
9604 | 11731 | } |
---|
9605 | 11732 | |
---|
9606 | 11733 | //drawing = false; |
---|
9607 | | - //if(drawMode == DEFAULT) |
---|
| 11734 | + //if(DrawMode() == DEFAULT) |
---|
9608 | 11735 | // niceon = false; |
---|
9609 | | - if (drawMode == DEFAULT) |
---|
| 11736 | + if (DrawMode() == DEFAULT) |
---|
9610 | 11737 | { |
---|
9611 | 11738 | currentlydrawing = false; |
---|
9612 | 11739 | } |
---|
.. | .. |
---|
9626 | 11753 | repaint(); |
---|
9627 | 11754 | } |
---|
9628 | 11755 | |
---|
9629 | | - if (isLIVE() && drawMode == DEFAULT) // may 2013 |
---|
| 11756 | + if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 |
---|
9630 | 11757 | repaint(); |
---|
9631 | 11758 | |
---|
9632 | 11759 | displaydone = true; |
---|
.. | .. |
---|
9645 | 11772 | { |
---|
9646 | 11773 | renderpass++; |
---|
9647 | 11774 | // System.out.println("Draw object... "); |
---|
| 11775 | + STEP = 1; |
---|
9648 | 11776 | if (FAST) // in case there is no script |
---|
9649 | | - STEP = 16; |
---|
| 11777 | + STEP = 8; |
---|
| 11778 | + |
---|
| 11779 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11780 | + { |
---|
| 11781 | + STEP *= 4; |
---|
| 11782 | + } |
---|
9650 | 11783 | |
---|
9651 | 11784 | //object.FullInvariants(); |
---|
9652 | 11785 | |
---|
.. | .. |
---|
9660 | 11793 | e.printStackTrace(); |
---|
9661 | 11794 | } |
---|
9662 | 11795 | |
---|
9663 | | - if (GrafreeD.RENDERME > 0) |
---|
9664 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11796 | + if (Grafreed.RENDERME > 0) |
---|
| 11797 | + Grafreed.RENDERME--; // mechante magouille |
---|
9665 | 11798 | |
---|
9666 | | - ONESTEP = false; |
---|
| 11799 | + Globals.ONESTEP = false; |
---|
9667 | 11800 | } |
---|
9668 | 11801 | |
---|
9669 | 11802 | static boolean zoomonce = false; |
---|
9670 | 11803 | |
---|
| 11804 | + static void CreateSelectedPoint() |
---|
| 11805 | + { |
---|
| 11806 | + if (selectedpoint == null) |
---|
| 11807 | + { |
---|
| 11808 | + debugpointG = new Sphere(); |
---|
| 11809 | + debugpointP = new Sphere(); |
---|
| 11810 | + debugpointC = new Sphere(); |
---|
| 11811 | + debugpointR = new Sphere(); |
---|
| 11812 | + |
---|
| 11813 | + selectedpoint = new Superellipsoid(); |
---|
| 11814 | + |
---|
| 11815 | + for (int i=0; i<8; i++) |
---|
| 11816 | + { |
---|
| 11817 | + debugpoints[i] = new Sphere(); |
---|
| 11818 | + } |
---|
| 11819 | + } |
---|
| 11820 | + } |
---|
| 11821 | + |
---|
9671 | 11822 | void DrawObject(GL gl, boolean draw) |
---|
9672 | 11823 | { |
---|
| 11824 | + // To clear camera values |
---|
| 11825 | + ResetOptions(); |
---|
| 11826 | + |
---|
9673 | 11827 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
9674 | | -// drawMode = SELECTION; |
---|
| 11828 | +// DrawMode() = SELECTION; |
---|
9675 | 11829 | //GL gl = getGL(); |
---|
9676 | 11830 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
9677 | 11831 | { |
---|
9678 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) |
---|
9679 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11832 | + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
| 11833 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
9680 | 11834 | pingthread.StepToTarget(true); // true); |
---|
9681 | 11835 | // zoomonce = false; |
---|
9682 | 11836 | } |
---|
.. | .. |
---|
9696 | 11850 | callist = gl.glGenLists(1); |
---|
9697 | 11851 | } |
---|
9698 | 11852 | |
---|
9699 | | - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11853 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
9700 | 11854 | |
---|
9701 | | - boolean active = !selectmode; // drawMode != SELECTION; // mouseDown; |
---|
| 11855 | + boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
9702 | 11856 | |
---|
9703 | 11857 | if (!mainDL || !active || touched) |
---|
9704 | 11858 | { |
---|
.. | .. |
---|
9725 | 11879 | PushMatrix(ClickInfo.matbuffer); |
---|
9726 | 11880 | } |
---|
9727 | 11881 | |
---|
9728 | | - if (drawMode == 0) |
---|
| 11882 | + if (DrawMode() == 0) |
---|
9729 | 11883 | { |
---|
9730 | 11884 | // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++"); |
---|
9731 | 11885 | |
---|
9732 | 11886 | usedtextures.clear(); |
---|
9733 | 11887 | |
---|
9734 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11888 | + try |
---|
| 11889 | + { |
---|
| 11890 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11891 | + } |
---|
| 11892 | + catch (Exception e) |
---|
| 11893 | + { |
---|
| 11894 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11895 | + } |
---|
9735 | 11896 | } |
---|
9736 | 11897 | //System.out.println("--> " + stackdepth); |
---|
9737 | 11898 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
9739 | 11900 | // DRAW |
---|
9740 | 11901 | object.draw(this, /*(Composite)*/ object, false, false); |
---|
9741 | 11902 | |
---|
9742 | | - if (drawMode == DEFAULT) |
---|
| 11903 | + if (DrawMode() == DEFAULT) |
---|
9743 | 11904 | { |
---|
9744 | | - if (DEBUG) |
---|
| 11905 | + if (Globals.DEBUG) |
---|
9745 | 11906 | { |
---|
| 11907 | + CreateSelectedPoint(); |
---|
9746 | 11908 | float radius = 0.05f; |
---|
9747 | 11909 | if (selectedpoint.radius != radius) |
---|
9748 | 11910 | { |
---|
.. | .. |
---|
9750 | 11912 | selectedpoint.radius = radius; |
---|
9751 | 11913 | selectedpoint.recalculate(); |
---|
9752 | 11914 | selectedpoint.material = new cMaterial(); |
---|
9753 | | - selectedpoint.material.color = 0.25f; |
---|
| 11915 | + selectedpoint.material.color = 0.15f; // Yellow |
---|
9754 | 11916 | selectedpoint.material.modulation = 0.75f; |
---|
9755 | 11917 | |
---|
9756 | | - debugpoint.radius = radius; |
---|
9757 | | - debugpoint.recalculate(); |
---|
9758 | | - debugpoint.material = new cMaterial(); |
---|
9759 | | - debugpoint.material.color = 0.25f; |
---|
9760 | | - debugpoint.material.modulation = 0.75f; |
---|
| 11918 | + debugpointG.radius = radius; |
---|
| 11919 | + debugpointG.recalculate(); |
---|
| 11920 | + debugpointG.material = new cMaterial(); |
---|
| 11921 | + debugpointG.material.color = 0.25f; // Green |
---|
| 11922 | + debugpointG.material.modulation = 0.75f; |
---|
9761 | 11923 | |
---|
9762 | | - debugpoint2.radius = radius; |
---|
9763 | | - debugpoint2.recalculate(); |
---|
9764 | | - debugpoint2.material = new cMaterial(); |
---|
9765 | | - debugpoint2.material.color = 0.75f; |
---|
9766 | | - debugpoint2.material.modulation = 0.75f; |
---|
| 11924 | + debugpointP.radius = radius; |
---|
| 11925 | + debugpointP.recalculate(); |
---|
| 11926 | + debugpointP.material = new cMaterial(); |
---|
| 11927 | + debugpointP.material.color = 0.75f; // Purple |
---|
| 11928 | + debugpointP.material.modulation = 0.75f; |
---|
9767 | 11929 | |
---|
9768 | | - debugpoint3.radius = radius; |
---|
9769 | | - debugpoint3.recalculate(); |
---|
9770 | | - debugpoint3.material = new cMaterial(); |
---|
9771 | | - debugpoint3.material.color = 0.5f; |
---|
9772 | | - debugpoint3.material.modulation = 0.75f; |
---|
| 11930 | + debugpointC.radius = radius; |
---|
| 11931 | + debugpointC.recalculate(); |
---|
| 11932 | + debugpointC.material = new cMaterial(); |
---|
| 11933 | + debugpointC.material.color = 0.5f; // Cyan |
---|
| 11934 | + debugpointC.material.modulation = 0.75f; |
---|
9773 | 11935 | |
---|
9774 | | - debugpoint4.radius = radius; |
---|
9775 | | - debugpoint4.recalculate(); |
---|
9776 | | - debugpoint4.material = new cMaterial(); |
---|
9777 | | - debugpoint4.material.color = 0f; |
---|
9778 | | - debugpoint4.material.modulation = 0.75f; |
---|
| 11936 | + debugpointR.radius = radius; |
---|
| 11937 | + debugpointR.recalculate(); |
---|
| 11938 | + debugpointR.material = new cMaterial(); |
---|
| 11939 | + debugpointR.material.color = 0f; // Red |
---|
| 11940 | + debugpointR.material.modulation = 0.75f; |
---|
9779 | 11941 | |
---|
9780 | 11942 | InitPoints(radius); |
---|
9781 | 11943 | } |
---|
9782 | 11944 | 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); |
---|
| 11945 | + debugpointG.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11946 | + debugpointP.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11947 | + debugpointC.draw(this, /*(Composite)*/ null, false,false); |
---|
| 11948 | + debugpointR.draw(this, /*(Composite)*/ null, false,false); |
---|
9787 | 11949 | // DrawPoints(this); |
---|
9788 | 11950 | } |
---|
9789 | 11951 | |
---|
.. | .. |
---|
9791 | 11953 | } |
---|
9792 | 11954 | // GrafreeD.traceoff(); |
---|
9793 | 11955 | //System.out.println(stackdepth); |
---|
9794 | | - if (drawMode == 0) |
---|
| 11956 | + if (DrawMode() == 0) |
---|
9795 | 11957 | { |
---|
9796 | 11958 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
9797 | 11959 | |
---|
9798 | 11960 | if (CLEANCACHE) |
---|
9799 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11961 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
9800 | 11962 | { |
---|
9801 | | - String tex = e.nextElement(); |
---|
| 11963 | + cTexture tex = e.nextElement(); |
---|
9802 | 11964 | |
---|
9803 | 11965 | // System.out.println("Texture --------- " + tex); |
---|
9804 | 11966 | |
---|
9805 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11967 | + if (tex.equals("WHITE_NOISE:")) |
---|
9806 | 11968 | continue; |
---|
9807 | 11969 | |
---|
9808 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11970 | + if (!usedtextures.contains(tex)) |
---|
9809 | 11971 | { |
---|
| 11972 | + CacheTexture gettex = texturepigment.get(tex); |
---|
9810 | 11973 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
9811 | | - textures.get(tex).texture.dispose(); |
---|
9812 | | - textures.remove(tex); |
---|
| 11974 | + if (gettex != null) |
---|
| 11975 | + { |
---|
| 11976 | + gettex.texture.dispose(); |
---|
| 11977 | + texturepigment.remove(tex); |
---|
| 11978 | + } |
---|
| 11979 | + |
---|
| 11980 | + gettex = texturebump.get(tex); |
---|
| 11981 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11982 | + if (gettex != null) |
---|
| 11983 | + { |
---|
| 11984 | + gettex.texture.dispose(); |
---|
| 11985 | + texturebump.remove(tex); |
---|
| 11986 | + } |
---|
9813 | 11987 | } |
---|
9814 | 11988 | } |
---|
9815 | 11989 | } |
---|
9816 | 11990 | |
---|
9817 | 11991 | checker = null; |
---|
9818 | 11992 | |
---|
9819 | | - if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT) |
---|
| 11993 | + if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT) |
---|
9820 | 11994 | FindChecker(object); |
---|
9821 | 11995 | |
---|
9822 | | - if (checker != null && drawMode == DEFAULT) |
---|
| 11996 | + if (checker != null && DrawMode() == DEFAULT) |
---|
9823 | 11997 | { |
---|
9824 | | - // BindTexture(IMMORTAL_TEXTURE); |
---|
| 11998 | + //BindTexture(IMMORTAL_TEXTURE); |
---|
| 11999 | + try |
---|
| 12000 | + { |
---|
| 12001 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 12002 | + } |
---|
| 12003 | + catch (Exception e) |
---|
| 12004 | + { |
---|
| 12005 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 12006 | + } |
---|
9825 | 12007 | // NEAREST |
---|
9826 | 12008 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
9827 | 12009 | DrawChecker(gl); |
---|
9828 | 12010 | //checker.Draw(this, null, false); |
---|
9829 | 12011 | // ReleaseTexture(IMMORTAL_TEXTURE); |
---|
| 12012 | + ReleaseTextures(checker.GetTextures()); |
---|
9830 | 12013 | } |
---|
9831 | 12014 | |
---|
9832 | 12015 | if (object.parent != null) |
---|
.. | .. |
---|
9839 | 12022 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9840 | 12023 | //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9841 | 12024 | |
---|
9842 | | - if (DISPLAYTEXT && drawMode == DEFAULT) |
---|
| 12025 | + if (DISPLAYTEXT && DrawMode() == DEFAULT) |
---|
9843 | 12026 | { |
---|
9844 | 12027 | // Draw it once, then use the raster |
---|
9845 | 12028 | Balloon(gl, balloon.createGraphics()); |
---|
.. | .. |
---|
9895 | 12078 | int[] xs = new int[3]; |
---|
9896 | 12079 | int[] ys = new int[3]; |
---|
9897 | 12080 | |
---|
9898 | | - void DrawString(Object3D obj) // String string) |
---|
| 12081 | + public void DrawString(Object3D obj) // String string) // INTERFACE |
---|
9899 | 12082 | { |
---|
9900 | | - if (!DISPLAYTEXT || drawMode != DEFAULT) |
---|
| 12083 | + if (!DISPLAYTEXT || DrawMode() != DEFAULT) |
---|
9901 | 12084 | { |
---|
9902 | 12085 | return; |
---|
9903 | 12086 | } |
---|
9904 | 12087 | |
---|
9905 | | - String string = obj.GetToolTip(); |
---|
| 12088 | + String string = obj.toString(); //.GetToolTip(); |
---|
9906 | 12089 | |
---|
9907 | 12090 | GL gl = GetGL(); |
---|
9908 | 12091 | |
---|
.. | .. |
---|
10219 | 12402 | //obj.TransformToWorld(light, light); |
---|
10220 | 12403 | for (int i = tp.size(); --i >= 0;) |
---|
10221 | 12404 | { |
---|
10222 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
10223 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12405 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12406 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
10224 | 12407 | } |
---|
10225 | 12408 | |
---|
10226 | 12409 | |
---|
.. | .. |
---|
10237 | 12420 | parentcam = cameras[0]; |
---|
10238 | 12421 | } |
---|
10239 | 12422 | |
---|
10240 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10241 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12423 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12424 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
10242 | 12425 | |
---|
10243 | 12426 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
10244 | 12427 | |
---|
.. | .. |
---|
10328 | 12511 | |
---|
10329 | 12512 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
10330 | 12513 | |
---|
10331 | | - String program = |
---|
| 12514 | + String programmin = |
---|
| 12515 | + // Min shader |
---|
10332 | 12516 | "!!ARBfp1.0\n" + |
---|
| 12517 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12518 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12519 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12520 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12521 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12522 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12523 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12524 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12525 | + "TEMP temp;" + |
---|
| 12526 | + "TEMP light;" + |
---|
| 12527 | + "TEMP ndotl;" + |
---|
| 12528 | + "TEMP normal;" + |
---|
| 12529 | + "TEMP depth;" + |
---|
| 12530 | + "TEMP eye;" + |
---|
| 12531 | + "TEMP pos;" + |
---|
| 12532 | + |
---|
| 12533 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12534 | + Normalize("normal") + |
---|
| 12535 | + "MOV light, state.light[0].position;" + |
---|
| 12536 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12537 | + |
---|
| 12538 | + // shadow |
---|
| 12539 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12540 | + "MOV temp, pos;" + |
---|
| 12541 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12542 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12543 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12544 | + |
---|
| 12545 | + // No shadow when out of frustum |
---|
| 12546 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12547 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12548 | + |
---|
| 12549 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12550 | + |
---|
| 12551 | + // Backlit |
---|
| 12552 | + "MOV pos.w, zero123.y;" + |
---|
| 12553 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12554 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12555 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12556 | + Normalize("eye") + |
---|
| 12557 | + |
---|
| 12558 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12559 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12560 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12561 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12562 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12563 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12564 | + |
---|
| 12565 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12566 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12567 | + |
---|
| 12568 | + // Pigment |
---|
| 12569 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12570 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12571 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12572 | + |
---|
| 12573 | + "MUL temp, temp, zero123.z;" + |
---|
| 12574 | + |
---|
| 12575 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12576 | + |
---|
| 12577 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12578 | + "MOV result.color, temp;" + |
---|
| 12579 | + "END"; |
---|
| 12580 | + |
---|
| 12581 | + String programmax = |
---|
| 12582 | + "!!ARBfp1.0\n" + |
---|
| 12583 | + |
---|
10333 | 12584 | //"OPTION ARB_fragment_program_shadow;" + |
---|
10334 | 12585 | "PARAM light2cam0 = program.env[10];" + |
---|
10335 | 12586 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
10355 | 12606 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
10356 | 12607 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
10357 | 12608 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
10358 | | - "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
| 12609 | + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax |
---|
10359 | 12610 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
10360 | | - "PARAM options1 = program.env[62];" + // fog rgb color, image intensity |
---|
| 12611 | + "PARAM options1 = program.env[62];" + // fog rgb color |
---|
| 12612 | + "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
10361 | 12613 | "PARAM pointlight = program.env[127];" + // ... |
---|
10362 | 12614 | "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" + |
---|
10363 | 12615 | "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" + |
---|
10364 | 12616 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
| 12617 | + "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" + |
---|
10365 | 12618 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
10366 | 12619 | "PARAM ten = { 10, 10, 10, 1.0 };" + |
---|
10367 | 12620 | "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" + |
---|
.. | .. |
---|
10382 | 12635 | "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" + |
---|
10383 | 12636 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
10384 | 12637 | "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" + |
---|
| 12638 | + "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" + |
---|
10385 | 12639 | "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" + |
---|
10386 | 12640 | "PARAM c256 = { 256, 256, 256, 1.0 };" + |
---|
10387 | 12641 | "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" + |
---|
.. | .. |
---|
10422 | 12676 | "TEMP R1;" + |
---|
10423 | 12677 | "TEMP R2;" + |
---|
10424 | 12678 | "TEMP R3;" + |
---|
| 12679 | + "TEMP min;" + |
---|
| 12680 | + "TEMP max;" + |
---|
| 12681 | + "TEMP average;" + |
---|
| 12682 | + "TEMP saturation;" + |
---|
10425 | 12683 | "TEMP keep1;" + |
---|
10426 | 12684 | "TEMP keep2;" + |
---|
10427 | 12685 | "TEMP keep3;" + |
---|
.. | .. |
---|
10437 | 12695 | "TEMP shininess;" + |
---|
10438 | 12696 | "\n" + |
---|
10439 | 12697 | "MOV texSamp, one;" + |
---|
10440 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
10441 | | - |
---|
| 12698 | + |
---|
10442 | 12699 | "MOV mapgrid.x, one2048th.x;" + |
---|
10443 | 12700 | "MOV temp, fragment.texcoord[1];" + |
---|
10444 | 12701 | /* |
---|
.. | .. |
---|
10459 | 12716 | "MUL temp, floor, mapgrid.x;" + |
---|
10460 | 12717 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
10461 | 12718 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
10462 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12719 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
10463 | 12720 | "") + |
---|
10464 | 12721 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
10465 | 12722 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
10466 | 12723 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
10467 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12724 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
10468 | 12725 | "") + |
---|
10469 | 12726 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
10470 | 12727 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
10471 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12728 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
10472 | 12729 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
10473 | 12730 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
10474 | 12731 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
10475 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12732 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
10476 | 12733 | "") + |
---|
10477 | 12734 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
10478 | 12735 | //"MOV params, material;" + |
---|
.. | .. |
---|
10594 | 12851 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
10595 | 12852 | // mar 2013 ??? "KIL alpha.a;" + |
---|
10596 | 12853 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
10597 | | - "KIL alpha.a;" + |
---|
| 12854 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
10598 | 12855 | /* |
---|
10599 | 12856 | "MUL temp.xy, temp, two;" + |
---|
10600 | 12857 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
10680 | 12937 | "SUB bump0, bump0, half;" + |
---|
10681 | 12938 | "ADD bump, bump, bump0;" + |
---|
10682 | 12939 | |
---|
10683 | | - "MOV temp.x, texSamp.a;" + |
---|
10684 | | - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
10685 | | - //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
10686 | | - "MOV texSamp.a, temp.x;" + |
---|
10687 | | - |
---|
10688 | 12940 | // double-sided |
---|
10689 | 12941 | /**/ |
---|
10690 | 12942 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
10701 | 12953 | "MOV normald, normal;" + |
---|
10702 | 12954 | "MOV normals, normal;" + |
---|
10703 | 12955 | |
---|
| 12956 | + "MOV temp, fragment.texcoord[4];" + |
---|
| 12957 | + |
---|
10704 | 12958 | // UV base |
---|
10705 | 12959 | //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + |
---|
10706 | 12960 | //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + |
---|
10707 | 12961 | //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + |
---|
10708 | | - "DP3 UP.x,state.matrix.texture[7].row[0],Y;" + |
---|
10709 | | - "DP3 UP.y,state.matrix.texture[7].row[1],Y;" + |
---|
10710 | | - "DP3 UP.z,state.matrix.texture[7].row[2],Y;" + |
---|
| 12962 | + "DP3 UP.x,state.matrix.texture[7].row[0],temp;" + |
---|
| 12963 | + "DP3 UP.y,state.matrix.texture[7].row[1],temp;" + |
---|
| 12964 | + "DP3 UP.z,state.matrix.texture[7].row[2],temp;" + |
---|
| 12965 | + Normalize("UP") + |
---|
| 12966 | + |
---|
10711 | 12967 | "XPD V, normal, UP;" + |
---|
10712 | 12968 | Normalize("V") + |
---|
10713 | 12969 | "XPD U, V, normal;" + |
---|
10714 | 12970 | Normalize("U") + |
---|
10715 | 12971 | |
---|
10716 | 12972 | // parallax mapping |
---|
| 12973 | + |
---|
| 12974 | + "DP3 temp2.x, V, eye;" + |
---|
| 12975 | + "DP3 temp2.y, U, eye;" + |
---|
| 12976 | + "DP3 temp2.z, normal, eye;" + |
---|
| 12977 | + "RCP temp2.z, temp2.z;" + |
---|
| 12978 | + |
---|
| 12979 | + "DP3 temp2.w, texSamp, texSamp;" + // Height |
---|
| 12980 | + "RSQ temp2.w, temp2.w;" + |
---|
| 12981 | + "RCP temp2.w, temp2.w;" + |
---|
| 12982 | + |
---|
| 12983 | + "SUB temp2.w, temp2.w, half;" + |
---|
| 12984 | +// "SGE temp.x, temp2.w, eps.x;" + |
---|
| 12985 | +// "MUL temp2.w, temp2.w, temp.x;" + |
---|
| 12986 | + |
---|
| 12987 | + //"MOV texSamp, U;" + |
---|
| 12988 | + |
---|
| 12989 | + "MUL temp2.z, temp2.z, temp2.w;" + |
---|
| 12990 | + "MUL temp2.z, temp2.z, params7.z;" + // parallax |
---|
| 12991 | + |
---|
| 12992 | + "MUL temp2, temp2, temp2.z;" + |
---|
| 12993 | + |
---|
| 12994 | + "MOV temp, fragment.texcoord[0];" + |
---|
| 12995 | + |
---|
| 12996 | + "SUB temp, temp, temp2;" + |
---|
| 12997 | + |
---|
| 12998 | + "TEX temp, temp, texture[0], 2D;" + |
---|
| 12999 | + "POW temp.a, temp.a, params6.w;" + // punch through |
---|
| 13000 | + |
---|
| 13001 | + "ADD texSamp, temp, texSamp;" + |
---|
| 13002 | + "MUL texSamp.xyz, half, texSamp;" + |
---|
| 13003 | + |
---|
| 13004 | + "MOV alpha, texSamp.aaaa;" + |
---|
| 13005 | + |
---|
| 13006 | +// parallax mapping |
---|
| 13007 | + |
---|
| 13008 | + "MOV temp.x, texSamp.a;" + |
---|
| 13009 | + "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
| 13010 | + //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
| 13011 | + "MOV texSamp.a, temp.x;" + |
---|
10717 | 13012 | |
---|
10718 | 13013 | //"MOV temp, fragment.texcoord[0];" + |
---|
10719 | 13014 | // |
---|
.. | .. |
---|
10843 | 13138 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
10844 | 13139 | "") + |
---|
10845 | 13140 | |
---|
10846 | | - // display shadow only (bump == 0) |
---|
| 13141 | + // display shadow only (fakedepth == 0) |
---|
10847 | 13142 | "SUB temp.x, half.x, shadow.x;" + |
---|
10848 | | - "MOV temp.y, -params6.x;" + |
---|
10849 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 13143 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 13144 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
10850 | 13145 | "SUB temp.y, one.x, temp.z;" + |
---|
10851 | 13146 | "MUL temp.x, temp.x, temp.y;" + |
---|
10852 | 13147 | "KIL temp.x;" + |
---|
.. | .. |
---|
10952 | 13247 | |
---|
10953 | 13248 | // skin? |
---|
10954 | 13249 | // Saturation for skin |
---|
10955 | | - /**/ // c'est ici |
---|
10956 | | - (Skinshader? "DP3 temp.x, final,one;" + |
---|
| 13250 | + /**/ |
---|
| 13251 | + (Skinshader? |
---|
| 13252 | + "DP3 average.x, final,one;" + |
---|
| 13253 | + "MUL average, one3rd.xxxx,average.xxxx;" + |
---|
| 13254 | + |
---|
| 13255 | + "MIN min.x, final.x,final.y;" + |
---|
| 13256 | + "MIN min.x, min.x,final.z;" + |
---|
| 13257 | + |
---|
| 13258 | + "MAX max.x, final.x,final.y;" + |
---|
| 13259 | + "MAX max.x, max.x,final.z;" + |
---|
| 13260 | + "MOV max, max.xxxx;" + |
---|
| 13261 | + |
---|
| 13262 | + "SUB saturation, max, final;" + |
---|
| 13263 | + |
---|
| 13264 | + "ADD temp.x, max.x, one10th.x;" + |
---|
| 13265 | + "RCP temp.x, temp.x;" + |
---|
| 13266 | + "MUL temp.x, temp.x, half.x;" + |
---|
| 13267 | + "MUL saturation, saturation, temp.xxxx;" + |
---|
| 13268 | + |
---|
| 13269 | + "DP3 ndotl.x, normald, light;" + |
---|
| 13270 | + "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
| 13271 | + |
---|
| 13272 | + "SUB temp.x, one.x, ndotl.x;" + |
---|
| 13273 | + // Tuning for default skin |
---|
| 13274 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 13275 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 13276 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
| 13277 | + "MUL temp.x, temp.x, temp.y;" + |
---|
| 13278 | + |
---|
| 13279 | + "MUL saturation, saturation, temp.xxxx;" + |
---|
| 13280 | + "SUB_SAT temp, max, saturation;" + |
---|
| 13281 | +/** |
---|
| 13282 | + "DP3 temp.x, final,one;" + |
---|
10957 | 13283 | "MUL R2, one3rd.xxxx,temp.xxxx;" + |
---|
10958 | | - "SUB temp, final,R2;" + |
---|
| 13284 | + "SUB temp, final, R2;" + |
---|
| 13285 | + |
---|
10959 | 13286 | // using light angle |
---|
10960 | 13287 | "DP3 ndotl.x, normald,light;" + |
---|
10961 | 13288 | //"SLT ndotl.y, ndotl.x, zero.x;" + |
---|
.. | .. |
---|
10968 | 13295 | // using light intensity |
---|
10969 | 13296 | "MOV ndotl.z, R2.x;" + |
---|
10970 | 13297 | "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning... |
---|
10971 | | - |
---|
10972 | 13298 | // june 2014 |
---|
10973 | 13299 | "MAD R1.x, ndotl.z,slope.y,one.x;" + |
---|
10974 | 13300 | // "SUB ndotl.x, one.x, ndotl.x;" + |
---|
.. | .. |
---|
10980 | 13306 | //"MUL R2.y, shadow.x,R2.y;" + // avril 2014 |
---|
10981 | 13307 | |
---|
10982 | 13308 | "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin) |
---|
| 13309 | +/**/ |
---|
10983 | 13310 | |
---|
10984 | 13311 | // "ADD final, R2,temp;" + |
---|
10985 | 13312 | "MOV final, temp;" |
---|
.. | .. |
---|
11069 | 13396 | /**/ |
---|
11070 | 13397 | // HDR |
---|
11071 | 13398 | "MOV temp.z, final.a;" + |
---|
11072 | | - "MUL final, final,options1.w;" + |
---|
| 13399 | + "MUL final, final,options2.x;" + |
---|
11073 | 13400 | "MOV final.a, temp.z;" + |
---|
11074 | 13401 | /**/ |
---|
11075 | 13402 | |
---|
.. | .. |
---|
11145 | 13472 | //once = true; |
---|
11146 | 13473 | } |
---|
11147 | 13474 | |
---|
11148 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
11149 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13475 | + String program = programmax; |
---|
| 13476 | + |
---|
| 13477 | + if (Globals.MINSHADER) |
---|
| 13478 | + { |
---|
| 13479 | + program = programmin; |
---|
| 13480 | + } |
---|
| 13481 | + |
---|
| 13482 | + if (Globals.DEBUG) |
---|
| 13483 | + { |
---|
| 13484 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13485 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13486 | + } |
---|
| 13487 | + |
---|
11150 | 13488 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
11151 | 13489 | |
---|
11152 | 13490 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
11193 | 13531 | "\n" + |
---|
11194 | 13532 | "END\n"; |
---|
11195 | 13533 | |
---|
11196 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13534 | + if (Globals.DEBUG) |
---|
| 13535 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
11197 | 13536 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
11198 | 13537 | |
---|
11199 | 13538 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
11238 | 13577 | return out; |
---|
11239 | 13578 | } |
---|
11240 | 13579 | |
---|
11241 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13580 | + // Also does frustum culling |
---|
| 13581 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
11242 | 13582 | { |
---|
11243 | 13583 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
11244 | 13584 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
11245 | 13585 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13586 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13587 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
11246 | 13588 | "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;" + |
---|
| 13589 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13590 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
11251 | 13591 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
11252 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13592 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
11253 | 13593 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
11254 | 13594 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
11255 | 13595 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
11256 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13596 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
11257 | 13597 | |
---|
11258 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
11259 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13598 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13599 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
11260 | 13600 | } |
---|
11261 | 13601 | |
---|
11262 | 13602 | String Shadow(String depth, String shadow) |
---|
11263 | 13603 | { |
---|
11264 | 13604 | return "MAX temp.x, ndotl.x, one64th.x;" + |
---|
| 13605 | + "MIN temp.x, temp.x, ninetenth.x;" + |
---|
11265 | 13606 | /**/ |
---|
11266 | 13607 | // Sine |
---|
11267 | 13608 | "MUL temp.y, temp.x, temp.x;" + |
---|
.. | .. |
---|
11277 | 13618 | |
---|
11278 | 13619 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
11279 | 13620 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13621 | + |
---|
| 13622 | + // Compare fragment depth in light space with shadowmap. |
---|
11280 | 13623 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
11281 | 13624 | "SGE temp.y, temp.x, zero.x;" + |
---|
11282 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13625 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13626 | + |
---|
| 13627 | + // Reverse comparison |
---|
11283 | 13628 | "SUB temp.x, one.x, temp.x;" + |
---|
11284 | 13629 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
11285 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13630 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
11286 | 13631 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
11287 | 13632 | |
---|
11288 | 13633 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
11296 | 13641 | // No shadow for backface |
---|
11297 | 13642 | "DP3 temp.x, normal, lightd;" + |
---|
11298 | 13643 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13644 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13645 | + |
---|
| 13646 | + // No shadow when out of frustum |
---|
| 13647 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
11299 | 13648 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
11300 | 13649 | ""; |
---|
11301 | 13650 | } |
---|
.. | .. |
---|
11441 | 13790 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
11442 | 13791 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
11443 | 13792 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
11444 | | - /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
11445 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13793 | + /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax |
---|
| 13794 | + |
---|
| 13795 | + //Object3D.cVector2[] vector2buffer; |
---|
11446 | 13796 | |
---|
11447 | 13797 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
11448 | 13798 | // OUT : diff, spec |
---|
.. | .. |
---|
11458 | 13808 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
11459 | 13809 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
11460 | 13810 | //"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;" + |
---|
| 13811 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13812 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13813 | + |
---|
| 13814 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
11464 | 13815 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
11465 | 13816 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
11466 | 13817 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
11606 | 13957 | "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" + |
---|
11607 | 13958 | "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" + |
---|
11608 | 13959 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
11609 | | - "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" + |
---|
| 13960 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
11610 | 13961 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
11611 | 13962 | "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + |
---|
11612 | 13963 | //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" + |
---|
.. | .. |
---|
11667 | 14018 | "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + |
---|
11668 | 14019 | "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + |
---|
11669 | 14020 | "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + |
---|
11670 | | - //"MOV result.texcoord, vertex.texcoord;" + |
---|
| 14021 | + //"MOV result.texcoord, vertex.fogcoord;" + |
---|
11671 | 14022 | "MOV result.texcoord, temp;" + |
---|
11672 | 14023 | // border fade |
---|
11673 | 14024 | "MOV result.texcoord[3], vertex.texcoord;" + |
---|
.. | .. |
---|
11714 | 14065 | |
---|
11715 | 14066 | //"ADD temp.z, temp.z, one;" + |
---|
11716 | 14067 | |
---|
11717 | | - "MOV result.color, temp;" |
---|
| 14068 | + "MOV result.texcoord[4], vertex.attrib[4];" + // U dir |
---|
| 14069 | + |
---|
| 14070 | + "MOV result.color, temp;" // Normal |
---|
11718 | 14071 | : "MOV result.color, vertex.color;") + |
---|
11719 | 14072 | ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" |
---|
11720 | 14073 | : "") + |
---|
.. | .. |
---|
11854 | 14207 | public void mousePressed(MouseEvent e) |
---|
11855 | 14208 | { |
---|
11856 | 14209 | //System.out.println("mousePressed: " + e); |
---|
11857 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14210 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
11858 | 14211 | } |
---|
11859 | 14212 | |
---|
11860 | 14213 | static long prevtime = 0; |
---|
.. | .. |
---|
11881 | 14234 | |
---|
11882 | 14235 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
11883 | 14236 | |
---|
| 14237 | + if (BUTTONLESSWHEEL) |
---|
11884 | 14238 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
11885 | 14239 | { |
---|
11886 | 14240 | return; |
---|
11887 | 14241 | } |
---|
11888 | 14242 | |
---|
| 14243 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
11889 | 14244 | |
---|
11890 | 14245 | // TIMER |
---|
11891 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR |
---|
| 14246 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
11892 | 14247 | { |
---|
11893 | 14248 | keepboxmode = BOXMODE; |
---|
11894 | 14249 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
11928 | 14283 | // mode |= META; |
---|
11929 | 14284 | //} |
---|
11930 | 14285 | |
---|
11931 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
11932 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 14286 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 14287 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
11933 | 14288 | anchorX = ax; |
---|
11934 | 14289 | anchorY = ay; |
---|
11935 | 14290 | prevX = px; |
---|
.. | .. |
---|
11963 | 14318 | else |
---|
11964 | 14319 | if (evt.getSource() == AAtimer) |
---|
11965 | 14320 | { |
---|
| 14321 | + Globals.TIMERRUNNING = false; |
---|
11966 | 14322 | if (mouseDown) |
---|
11967 | 14323 | { |
---|
11968 | 14324 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
11988 | 14344 | // LIVE = waslive; |
---|
11989 | 14345 | // wasliveok = true; |
---|
11990 | 14346 | // waslive = false; |
---|
| 14347 | + |
---|
| 14348 | + // May 2019 Forget it: |
---|
| 14349 | + if (true) |
---|
| 14350 | + return; |
---|
11991 | 14351 | |
---|
11992 | 14352 | // source == timer |
---|
11993 | 14353 | if (mouseDown) |
---|
.. | .. |
---|
12017 | 14377 | // ObjEditor.tweenManager.update(1f / 60f); |
---|
12018 | 14378 | |
---|
12019 | 14379 | // fev 2014??? |
---|
12020 | | - if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode) |
---|
12021 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14380 | + if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
| 14381 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
12022 | 14382 | pingthread.StepToTarget(true); // true); |
---|
12023 | 14383 | } |
---|
12024 | 14384 | // if (!LIVE) |
---|
.. | .. |
---|
12027 | 14387 | |
---|
12028 | 14388 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
12029 | 14389 | |
---|
12030 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14390 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
12031 | 14391 | { |
---|
12032 | 14392 | if (!wasliveok) |
---|
12033 | 14393 | return; |
---|
12034 | 14394 | |
---|
12035 | 14395 | AAtimer.restart(); // |
---|
| 14396 | + Globals.TIMERRUNNING = true; |
---|
12036 | 14397 | |
---|
12037 | 14398 | // waslive = LIVE; |
---|
12038 | 14399 | // LIVE = false; |
---|
.. | .. |
---|
12044 | 14405 | // touched = true; // main DL |
---|
12045 | 14406 | if (isRenderer) |
---|
12046 | 14407 | { |
---|
12047 | | - SetMouseMode(modifiers); |
---|
| 14408 | + SetMouseMode(modifiers, modifiersex); |
---|
12048 | 14409 | } |
---|
12049 | 14410 | |
---|
12050 | 14411 | selectX = anchorX = x; |
---|
.. | .. |
---|
12057 | 14418 | clicked = true; |
---|
12058 | 14419 | hold = false; |
---|
12059 | 14420 | |
---|
12060 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14421 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
12061 | 14422 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
12062 | 14423 | { |
---|
12063 | 14424 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
12082 | 14443 | drag = false; |
---|
12083 | 14444 | //System.out.println("Mouse DOWN"); |
---|
12084 | 14445 | 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); |
---|
| 14446 | + //ClickInfo info = new ClickInfo(); |
---|
| 14447 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14448 | + object.clickInfo.pane = this; |
---|
| 14449 | + object.clickInfo.camera = renderCamera; |
---|
| 14450 | + object.clickInfo.x = x; |
---|
| 14451 | + object.clickInfo.y = y; |
---|
| 14452 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14453 | + editObj = object.doEditClick(//info, |
---|
| 14454 | + 0); |
---|
12093 | 14455 | if (!editObj) |
---|
12094 | 14456 | { |
---|
12095 | 14457 | hasMarquee = true; |
---|
.. | .. |
---|
12105 | 14467 | |
---|
12106 | 14468 | public void mouseDragged(MouseEvent e) |
---|
12107 | 14469 | { |
---|
| 14470 | + Globals.MOUSEDRAGGED = true; |
---|
| 14471 | + |
---|
| 14472 | + //System.out.println("mouseDragged: " + e); |
---|
12108 | 14473 | if (isRenderer) |
---|
12109 | 14474 | movingcamera = true; |
---|
| 14475 | + |
---|
12110 | 14476 | //if (drawing) |
---|
12111 | 14477 | //return; |
---|
12112 | | - //System.out.println("mouseDragged: " + e); |
---|
12113 | 14478 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
12114 | 14479 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
12115 | 14480 | { |
---|
.. | .. |
---|
12117 | 14482 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12118 | 14483 | } |
---|
12119 | 14484 | else |
---|
12120 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14485 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12121 | 14486 | |
---|
12122 | 14487 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
12123 | 14488 | } |
---|
.. | .. |
---|
12129 | 14494 | cVector tmp = new cVector(); |
---|
12130 | 14495 | cVector tmp2 = new cVector(); |
---|
12131 | 14496 | boolean isMoving; |
---|
| 14497 | + |
---|
| 14498 | + public cVector TargetLookAt() |
---|
| 14499 | + { |
---|
| 14500 | + return targetLookAt; |
---|
| 14501 | + } |
---|
12132 | 14502 | |
---|
12133 | 14503 | class PingThread extends Thread |
---|
12134 | 14504 | { |
---|
.. | .. |
---|
12268 | 14638 | //System.out.println("---------------- ---------- Paint " + tmp.length2()); |
---|
12269 | 14639 | if (lightMode) |
---|
12270 | 14640 | { |
---|
12271 | | - lighttouched = true; |
---|
| 14641 | + Globals.lighttouched = true; |
---|
12272 | 14642 | } |
---|
12273 | 14643 | |
---|
12274 | 14644 | if (OEILONCE && OEIL) |
---|
.. | .. |
---|
12285 | 14655 | |
---|
12286 | 14656 | public void run() |
---|
12287 | 14657 | { |
---|
| 14658 | + new Exception().printStackTrace(); |
---|
12288 | 14659 | System.exit(0); |
---|
12289 | 14660 | for (;;) |
---|
12290 | 14661 | { |
---|
.. | .. |
---|
12326 | 14697 | mouseDown = false; |
---|
12327 | 14698 | if (lightMode) |
---|
12328 | 14699 | { |
---|
12329 | | - lighttouched = true; |
---|
| 14700 | + Globals.lighttouched = true; |
---|
12330 | 14701 | } |
---|
12331 | 14702 | repaint(); |
---|
12332 | 14703 | alreadypainted = true; |
---|
.. | .. |
---|
12334 | 14705 | isMoving = false; |
---|
12335 | 14706 | } //?? |
---|
12336 | 14707 | |
---|
12337 | | - if (isLIVE() && !alreadypainted) |
---|
| 14708 | + if (Globals.isLIVE() && !alreadypainted) |
---|
12338 | 14709 | { |
---|
12339 | 14710 | // FOR DEBUG BREAKPOINT USING PAUSE: while (true) |
---|
12340 | 14711 | repaint(); |
---|
.. | .. |
---|
12346 | 14717 | { |
---|
12347 | 14718 | if (lightMode) |
---|
12348 | 14719 | { |
---|
12349 | | - lighttouched = true; |
---|
| 14720 | + Globals.lighttouched = true; |
---|
12350 | 14721 | } |
---|
12351 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14722 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
12352 | 14723 | } |
---|
12353 | 14724 | //else |
---|
12354 | 14725 | } |
---|
.. | .. |
---|
12362 | 14733 | void GoDown(int mod) |
---|
12363 | 14734 | { |
---|
12364 | 14735 | MODIFIERS |= COMMAND; |
---|
12365 | | - /* |
---|
| 14736 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14737 | + /**/ |
---|
12366 | 14738 | if((mod&SHIFT) == SHIFT) |
---|
12367 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14739 | + { |
---|
| 14740 | + if (isVR) |
---|
| 14741 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14742 | + else |
---|
| 14743 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14744 | + } |
---|
12368 | 14745 | else |
---|
12369 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
12370 | | - */ |
---|
| 14746 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14747 | + /**/ |
---|
12371 | 14748 | if ((mod & SHIFT) == SHIFT) |
---|
12372 | 14749 | { |
---|
12373 | 14750 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
12376 | 14753 | mouseMode |= BACKFORTH; |
---|
12377 | 14754 | } |
---|
12378 | 14755 | |
---|
| 14756 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14757 | + |
---|
12379 | 14758 | //prevX = X = anchorX; |
---|
12380 | 14759 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
12381 | 14760 | } |
---|
.. | .. |
---|
12383 | 14762 | void GoUp(int mod) |
---|
12384 | 14763 | { |
---|
12385 | 14764 | MODIFIERS |= COMMAND; |
---|
12386 | | - /* |
---|
| 14765 | + /**/ |
---|
| 14766 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14767 | + |
---|
12387 | 14768 | if((mod&SHIFT) == SHIFT) |
---|
12388 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14769 | + { |
---|
| 14770 | + if (isVR) |
---|
| 14771 | + manipCamera.RotateInterest(0, speed); |
---|
| 14772 | + else |
---|
| 14773 | + manipCamera.RotatePosition(0, speed); |
---|
| 14774 | + } |
---|
12389 | 14775 | else |
---|
12390 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
12391 | | - */ |
---|
| 14776 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14777 | + /**/ |
---|
12392 | 14778 | if ((mod & SHIFT) == SHIFT) |
---|
12393 | 14779 | { |
---|
12394 | 14780 | mouseMode = mouseMode; |
---|
.. | .. |
---|
12397 | 14783 | mouseMode |= BACKFORTH; |
---|
12398 | 14784 | } |
---|
12399 | 14785 | |
---|
| 14786 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14787 | + |
---|
12400 | 14788 | //prevX = X = anchorX; |
---|
12401 | 14789 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
12402 | 14790 | } |
---|
.. | .. |
---|
12404 | 14792 | void GoLeft(int mod) |
---|
12405 | 14793 | { |
---|
12406 | 14794 | MODIFIERS |= COMMAND; |
---|
12407 | | - /* |
---|
| 14795 | + /**/ |
---|
12408 | 14796 | if((mod&SHIFT) == SHIFT) |
---|
12409 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14797 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
12410 | 14798 | else |
---|
12411 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
12412 | | - */ |
---|
| 14799 | + { |
---|
| 14800 | + if ((mouseMode&VR)!=0) |
---|
| 14801 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14802 | + else |
---|
| 14803 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14804 | + } |
---|
| 14805 | + /**/ |
---|
12413 | 14806 | if ((mod & SHIFT) == SHIFT) |
---|
12414 | 14807 | { |
---|
12415 | 14808 | mouseMode = mouseMode; |
---|
.. | .. |
---|
12418 | 14811 | mouseMode |= ROTATE; |
---|
12419 | 14812 | } // TRANSLATE; |
---|
12420 | 14813 | |
---|
| 14814 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14815 | + |
---|
12421 | 14816 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
12422 | 14817 | prevY = Y = anchorY; |
---|
12423 | 14818 | } |
---|
.. | .. |
---|
12425 | 14820 | void GoRight(int mod) |
---|
12426 | 14821 | { |
---|
12427 | 14822 | MODIFIERS |= COMMAND; |
---|
12428 | | - /* |
---|
| 14823 | + /**/ |
---|
12429 | 14824 | if((mod&SHIFT) == SHIFT) |
---|
12430 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14825 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
12431 | 14826 | else |
---|
12432 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
12433 | | - */ |
---|
| 14827 | + { |
---|
| 14828 | + if ((mouseMode&VR)!=0) |
---|
| 14829 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14830 | + else |
---|
| 14831 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14832 | + } |
---|
| 14833 | + |
---|
| 14834 | + /**/ |
---|
12434 | 14835 | if ((mod & SHIFT) == SHIFT) |
---|
12435 | 14836 | { |
---|
12436 | 14837 | mouseMode = mouseMode; |
---|
.. | .. |
---|
12439 | 14840 | mouseMode |= ROTATE; |
---|
12440 | 14841 | } // TRANSLATE; |
---|
12441 | 14842 | |
---|
| 14843 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14844 | + |
---|
12442 | 14845 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
12443 | 14846 | prevY = Y = anchorY; |
---|
12444 | 14847 | } |
---|
.. | .. |
---|
12448 | 14851 | int X, Y; |
---|
12449 | 14852 | boolean SX, SY; |
---|
12450 | 14853 | |
---|
12451 | | - void drag(int x, int y, int modifiers) |
---|
| 14854 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
12452 | 14855 | { |
---|
12453 | 14856 | if (IsFrozen()) |
---|
12454 | 14857 | { |
---|
.. | .. |
---|
12457 | 14860 | |
---|
12458 | 14861 | drag = true; // NEW |
---|
12459 | 14862 | |
---|
12460 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14863 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
12461 | 14864 | |
---|
12462 | 14865 | X = x; |
---|
12463 | 14866 | Y = y; |
---|
12464 | 14867 | // floating state for animation |
---|
12465 | | - MODIFIERS = modifiers; |
---|
12466 | | - modifiers &= ~1024; |
---|
| 14868 | + MODIFIERS = modifiersex; |
---|
| 14869 | + modifiersex &= ~1024; |
---|
12467 | 14870 | if (false) // modifiers != 0) |
---|
12468 | 14871 | { |
---|
12469 | 14872 | //new Exception().printStackTrace(); |
---|
12470 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14873 | + System.out.println("mouseDragged: " + modifiersex); |
---|
12471 | 14874 | System.out.println("SHIFT = " + SHIFT); |
---|
12472 | 14875 | System.out.println("CONTROL = " + COMMAND); |
---|
12473 | 14876 | System.out.println("META = " + META); |
---|
.. | .. |
---|
12480 | 14883 | if (editObj) |
---|
12481 | 14884 | { |
---|
12482 | 14885 | drag = true; |
---|
12483 | | - ClickInfo info = new ClickInfo(); |
---|
12484 | | - info.bounds.setBounds(0, 0, |
---|
| 14886 | + //ClickInfo info = new ClickInfo(); |
---|
| 14887 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
12485 | 14888 | (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); |
---|
| 14889 | + object.clickInfo.pane = this; |
---|
| 14890 | + object.clickInfo.camera = renderCamera; |
---|
| 14891 | + object.clickInfo.x = x; |
---|
| 14892 | + object.clickInfo.y = y; |
---|
| 14893 | + object //.GetWindow().copy |
---|
| 14894 | + .doEditDrag(//info, |
---|
| 14895 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
12491 | 14896 | } else |
---|
12492 | 14897 | { |
---|
12493 | 14898 | if (x < startX) |
---|
.. | .. |
---|
12589 | 14994 | { |
---|
12590 | 14995 | manipCamera.Translate(dx, dy, getWidth()); |
---|
12591 | 14996 | } |
---|
| 14997 | + else |
---|
12592 | 14998 | if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0) |
---|
12593 | 14999 | { |
---|
12594 | 15000 | manipCamera.RotateInterest(dx, dy); |
---|
.. | .. |
---|
12599 | 15005 | |
---|
12600 | 15006 | if (manipCamera == lightCamera) |
---|
12601 | 15007 | { |
---|
12602 | | - lighttouched = true; |
---|
| 15008 | + Globals.lighttouched = true; |
---|
12603 | 15009 | } |
---|
12604 | 15010 | /* |
---|
12605 | 15011 | switch (mode) |
---|
.. | .. |
---|
12635 | 15041 | } |
---|
12636 | 15042 | } |
---|
12637 | 15043 | |
---|
| 15044 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 15045 | + |
---|
12638 | 15046 | public void mouseMoved(MouseEvent e) |
---|
12639 | 15047 | { |
---|
12640 | 15048 | //System.out.println("mouseMoved: " + e); |
---|
12641 | | - |
---|
12642 | 15049 | if (isRenderer) |
---|
12643 | 15050 | return; |
---|
12644 | 15051 | |
---|
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; |
---|
| 15052 | + // Mouse cursor feedback |
---|
| 15053 | + object.clickInfo.x = e.getX(); |
---|
| 15054 | + object.clickInfo.y = e.getY(); |
---|
| 15055 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 15056 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 15057 | + object.clickInfo.pane = this; |
---|
| 15058 | + object.clickInfo.camera = renderCamera; |
---|
12652 | 15059 | if (!isRenderer) |
---|
12653 | 15060 | { |
---|
12654 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 15061 | + //ObjEditor editWindow = object.editWindow; |
---|
| 15062 | + //Object3D copy = editWindow.copy; |
---|
| 15063 | + if (object.doEditClick(//clickInfo, |
---|
| 15064 | + 0)) |
---|
12655 | 15065 | { |
---|
12656 | 15066 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
12657 | 15067 | } else |
---|
.. | .. |
---|
12663 | 15073 | |
---|
12664 | 15074 | public void mouseReleased(MouseEvent e) |
---|
12665 | 15075 | { |
---|
| 15076 | + Globals.MOUSEDRAGGED = false; |
---|
| 15077 | + |
---|
12666 | 15078 | movingcamera = false; |
---|
| 15079 | + X = 0; // getBounds().width/2; |
---|
| 15080 | + Y = 0; // getBounds().height/2; |
---|
12667 | 15081 | //System.out.println("mouseReleased: " + e); |
---|
12668 | 15082 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12669 | 15083 | } |
---|
.. | .. |
---|
12686 | 15100 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
12687 | 15101 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
12688 | 15102 | |
---|
12689 | | - if (control || command || IsFrozen()) |
---|
| 15103 | +// No delay if (control || command || IsFrozen()) |
---|
12690 | 15104 | timeout = true; |
---|
12691 | | - else |
---|
| 15105 | +// ?? May 2019 else |
---|
12692 | 15106 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
12693 | 15107 | mouseDown = false; |
---|
12694 | 15108 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
12798 | 15212 | System.out.println("keyReleased: " + e); |
---|
12799 | 15213 | } |
---|
12800 | 15214 | |
---|
12801 | | - void SetMouseMode(int modifiers) |
---|
| 15215 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
12802 | 15216 | { |
---|
12803 | 15217 | //System.out.println("SetMouseMode = " + modifiers); |
---|
12804 | 15218 | //modifiers &= ~1024; |
---|
.. | .. |
---|
12810 | 15224 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
12811 | 15225 | // return; |
---|
12812 | 15226 | //System.out.println("SetMode = " + modifiers); |
---|
12813 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 15227 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
12814 | 15228 | { |
---|
12815 | 15229 | mouseMode |= ZOOM; |
---|
12816 | 15230 | } |
---|
12817 | | - if ((modifiers & META) == META) |
---|
| 15231 | + |
---|
| 15232 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
| 15233 | + if (capsLocked) // || (modifiers & META) == META) |
---|
12818 | 15234 | { |
---|
12819 | 15235 | mouseMode |= VR; // BACKFORTH; |
---|
12820 | 15236 | } |
---|
12821 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
12822 | | - { |
---|
12823 | | - mouseMode |= SELECT; // BACKFORTH; |
---|
12824 | | - } |
---|
12825 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 15237 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
12826 | 15238 | { |
---|
12827 | 15239 | mouseMode |= SELECT; |
---|
12828 | 15240 | } |
---|
12829 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 15241 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
12830 | 15242 | { |
---|
| 15243 | + mouseMode |= SELECT; |
---|
| 15244 | + } |
---|
| 15245 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
| 15246 | + { |
---|
| 15247 | + mouseMode &= ~VR; |
---|
12831 | 15248 | mouseMode |= TRANSLATE; |
---|
12832 | 15249 | } |
---|
12833 | 15250 | // if ((modifiers & SHIFT_META) == SHIFT_META) |
---|
.. | .. |
---|
12854 | 15271 | |
---|
12855 | 15272 | if (isRenderer) // |
---|
12856 | 15273 | { |
---|
12857 | | - SetMouseMode(modifiers); |
---|
| 15274 | + SetMouseMode(0, modifiers); |
---|
12858 | 15275 | } |
---|
12859 | 15276 | |
---|
12860 | | - theRenderer.keyPressed(key); |
---|
| 15277 | + Globals.theRenderer.keyPressed(key); |
---|
12861 | 15278 | } |
---|
12862 | 15279 | |
---|
12863 | 15280 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
12869 | 15286 | float SATPOW = 1; // 2; // 0.5f; |
---|
12870 | 15287 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
12871 | 15288 | |
---|
12872 | | - void keyPressed(int key) |
---|
| 15289 | + public void keyPressed(int key) |
---|
12873 | 15290 | { |
---|
12874 | 15291 | if (key >= '0' && key <= '5') |
---|
12875 | 15292 | clampbit = (key-'0'); |
---|
.. | .. |
---|
12916 | 15333 | // break; |
---|
12917 | 15334 | case 'T': |
---|
12918 | 15335 | CACHETEXTURE ^= true; |
---|
12919 | | - textures.clear(); |
---|
| 15336 | + texturepigment.clear(); |
---|
| 15337 | + texturebump.clear(); |
---|
12920 | 15338 | // repaint(); |
---|
12921 | 15339 | break; |
---|
12922 | 15340 | case 'Y': |
---|
.. | .. |
---|
12926 | 15344 | case 'K': |
---|
12927 | 15345 | KOMPACTTEXTURE ^= true; |
---|
12928 | 15346 | //textures.clear(); |
---|
12929 | | - break; |
---|
12930 | | - case 'P': // Texture Projection macros |
---|
| 15347 | + // break; |
---|
| 15348 | + //case 'P': // Texture Projection macros |
---|
12931 | 15349 | // SAVETEXTURE ^= true; |
---|
12932 | 15350 | macromode = true; |
---|
12933 | 15351 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
12984 | 15402 | case 'B': |
---|
12985 | 15403 | BRISMOOTH ^= true; |
---|
12986 | 15404 | SHADOWCULLFACE ^= true; |
---|
12987 | | - lighttouched = true; |
---|
| 15405 | + Globals.lighttouched = true; |
---|
12988 | 15406 | repaint(); |
---|
12989 | 15407 | break; |
---|
12990 | 15408 | case 'b': |
---|
.. | .. |
---|
13001 | 15419 | case 'E' : COMPACT ^= true; |
---|
13002 | 15420 | repaint(); |
---|
13003 | 15421 | break; |
---|
13004 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15422 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15423 | + //DEBUGHSB ^= true; |
---|
| 15424 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
13005 | 15425 | repaint(); |
---|
13006 | 15426 | break; |
---|
13007 | 15427 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
13026 | 15446 | RevertCamera(); |
---|
13027 | 15447 | repaint(); |
---|
13028 | 15448 | break; |
---|
13029 | | - case 'L': |
---|
13030 | 15449 | case 'l': |
---|
| 15450 | + //case 'L': |
---|
13031 | 15451 | if (lightMode) |
---|
13032 | 15452 | { |
---|
13033 | 15453 | lightMode = false; |
---|
.. | .. |
---|
13046 | 15466 | targetLookAt.set(manipCamera.lookAt); |
---|
13047 | 15467 | repaint(); |
---|
13048 | 15468 | break; |
---|
13049 | | - case 'p': |
---|
| 15469 | + case 'P': // p': |
---|
13050 | 15470 | // c'est quoi ca au juste? spherical ^= true; |
---|
13051 | 15471 | Skinshader ^= true; programInitialized = false; |
---|
13052 | 15472 | repaint(); |
---|
.. | .. |
---|
13084 | 15504 | repaint(); |
---|
13085 | 15505 | break; |
---|
13086 | 15506 | case 'O': |
---|
13087 | | - drawMode = OCCLUSION; |
---|
| 15507 | + Globals.drawMode = OCCLUSION; // WARNING |
---|
13088 | 15508 | repaint(); |
---|
13089 | 15509 | break; |
---|
13090 | 15510 | case 'o': |
---|
13091 | 15511 | OCCLUSION_CULLING ^= true; |
---|
13092 | 15512 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
13093 | 15513 | break; |
---|
13094 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15514 | + //case '0': envyoff ^= true; repaint(); break; |
---|
13095 | 15515 | case '1': |
---|
13096 | 15516 | case '2': |
---|
13097 | 15517 | case '3': |
---|
13098 | 15518 | case '4': |
---|
13099 | 15519 | case '5': |
---|
13100 | | - newenvy = Character.getNumericValue(key); |
---|
13101 | | - repaint(); |
---|
13102 | | - break; |
---|
13103 | 15520 | case '6': |
---|
13104 | 15521 | case '7': |
---|
13105 | 15522 | case '8': |
---|
13106 | 15523 | case '9': |
---|
13107 | | - BGcolor = (key - '6')/3.f; |
---|
| 15524 | + if (true) // envyoff) |
---|
| 15525 | + { |
---|
| 15526 | + BGcolor = (key - '1')/8.f; |
---|
| 15527 | + } |
---|
| 15528 | + else |
---|
| 15529 | + { |
---|
| 15530 | + //newenvy = Character.getNumericValue(key); |
---|
| 15531 | + } |
---|
13108 | 15532 | repaint(); |
---|
13109 | 15533 | break; |
---|
13110 | 15534 | case '!': |
---|
.. | .. |
---|
13170 | 15594 | case '_': |
---|
13171 | 15595 | kompactbit = 5; |
---|
13172 | 15596 | break; |
---|
13173 | | - case '+': |
---|
13174 | | - kompactbit = 6; |
---|
13175 | | - break; |
---|
| 15597 | +// case '+': |
---|
| 15598 | +// kompactbit = 6; |
---|
| 15599 | +// break; |
---|
13176 | 15600 | case ' ': |
---|
13177 | 15601 | lightMode ^= true; |
---|
13178 | | - lighttouched = true; |
---|
| 15602 | + Globals.lighttouched = true; |
---|
13179 | 15603 | manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
13180 | 15604 | targetLookAt.set(manipCamera.lookAt); |
---|
13181 | 15605 | repaint(); |
---|
.. | .. |
---|
13184 | 15608 | case ESC: |
---|
13185 | 15609 | RENDERPROGRAM += 1; |
---|
13186 | 15610 | RENDERPROGRAM %= 3; |
---|
| 15611 | + |
---|
13187 | 15612 | repaint(); |
---|
13188 | 15613 | break; |
---|
13189 | 15614 | case 'Z': |
---|
13190 | | - RESIZETEXTURE ^= true; |
---|
13191 | | - break; |
---|
| 15615 | + //RESIZETEXTURE ^= true; |
---|
| 15616 | + //break; |
---|
13192 | 15617 | case 'z': |
---|
13193 | | - RENDERSHADOW ^= true; |
---|
13194 | | - lighttouched = true; |
---|
| 15618 | + Globals.RENDERSHADOW ^= true; |
---|
| 15619 | + Globals.lighttouched = true; |
---|
13195 | 15620 | repaint(); |
---|
13196 | 15621 | break; |
---|
13197 | 15622 | //case UP: |
---|
.. | .. |
---|
13217 | 15642 | FlipTransform(); |
---|
13218 | 15643 | break; |
---|
13219 | 15644 | case ENTER: |
---|
13220 | | - object.editWindow.ScreenFit(); // Edit(); |
---|
| 15645 | + // object.editWindow.ScreenFit(); // Edit(); |
---|
| 15646 | + ToggleLive(); |
---|
13221 | 15647 | break; |
---|
13222 | 15648 | case DELETE: |
---|
13223 | 15649 | ClearSelection(); |
---|
13224 | 15650 | break; |
---|
13225 | | - /* |
---|
13226 | 15651 | case '+': |
---|
| 15652 | + |
---|
| 15653 | + /* |
---|
13227 | 15654 | //fontsize += 1; |
---|
13228 | 15655 | bbzoom *= 2; |
---|
13229 | 15656 | repaint(); |
---|
.. | .. |
---|
13240 | 15667 | case '=': |
---|
13241 | 15668 | IncDepth(); |
---|
13242 | 15669 | //fontsize += 1; |
---|
13243 | | - object.editWindow.refreshContents(true); |
---|
| 15670 | + object.GetWindow().refreshContents(true); |
---|
13244 | 15671 | maskbit = 6; |
---|
13245 | 15672 | break; |
---|
13246 | 15673 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
13247 | 15674 | DecDepth(); |
---|
13248 | 15675 | maskbit = 5; |
---|
13249 | 15676 | //if(fontsize > 1) fontsize -= 1; |
---|
13250 | | - if (object.editWindow == null) |
---|
13251 | | - new Exception().printStackTrace(); |
---|
13252 | | - else |
---|
13253 | | - object.editWindow.refreshContents(true); |
---|
| 15677 | +// if (object.editWindow == null) |
---|
| 15678 | +// new Exception().printStackTrace(); |
---|
| 15679 | +// else |
---|
| 15680 | + object.GetWindow().refreshContents(true); |
---|
13254 | 15681 | break; |
---|
13255 | 15682 | case '{': |
---|
13256 | 15683 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
13305 | 15732 | } |
---|
13306 | 15733 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
13307 | 15734 | } |
---|
| 15735 | + |
---|
13308 | 15736 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
13309 | 15737 | |
---|
13310 | 15738 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
13312 | 15740 | //mode = ROTATE; |
---|
13313 | 15741 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
13314 | 15742 | { |
---|
13315 | | - SetMouseMode(modifiers); |
---|
| 15743 | + SetMouseMode(0, modifiers); |
---|
13316 | 15744 | } |
---|
13317 | 15745 | } |
---|
13318 | 15746 | |
---|
13319 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 15747 | + public void processKeyEvent(KeyEvent e) |
---|
13320 | 15748 | { |
---|
13321 | 15749 | switch (e.getID()) |
---|
13322 | 15750 | { |
---|
.. | .. |
---|
13446 | 15874 | |
---|
13447 | 15875 | protected void processMouseMotionEvent(MouseEvent e) |
---|
13448 | 15876 | { |
---|
13449 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
13450 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15877 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15878 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15879 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
13451 | 15880 | { |
---|
13452 | 15881 | mouseMoved(e); |
---|
13453 | 15882 | } else |
---|
.. | .. |
---|
13472 | 15901 | } |
---|
13473 | 15902 | */ |
---|
13474 | 15903 | |
---|
13475 | | - object.editWindow.EditSelection(); |
---|
| 15904 | + object.GetWindow().EditSelection(false); |
---|
13476 | 15905 | } |
---|
13477 | 15906 | |
---|
13478 | 15907 | void SelectParent() |
---|
13479 | 15908 | { |
---|
| 15909 | + new Exception().printStackTrace(); |
---|
13480 | 15910 | System.exit(0); |
---|
13481 | 15911 | Composite group = (Composite) object; |
---|
13482 | 15912 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
13488 | 15918 | { |
---|
13489 | 15919 | //selectees.remove(i); |
---|
13490 | 15920 | System.out.println("select parent of " + elem); |
---|
13491 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15921 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
13492 | 15922 | } else |
---|
13493 | 15923 | { |
---|
13494 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15924 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
13495 | 15925 | } |
---|
13496 | 15926 | |
---|
13497 | 15927 | first = false; |
---|
.. | .. |
---|
13500 | 15930 | |
---|
13501 | 15931 | void SelectChildren() |
---|
13502 | 15932 | { |
---|
| 15933 | + new Exception().printStackTrace(); |
---|
13503 | 15934 | System.exit(0); |
---|
13504 | 15935 | /* |
---|
13505 | 15936 | Composite group = (Composite) object; |
---|
.. | .. |
---|
13532 | 15963 | for (int j = 0; j < group.children.size(); j++) |
---|
13533 | 15964 | { |
---|
13534 | 15965 | elem = (Object3D) group.children.elementAt(j); |
---|
13535 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15966 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
13536 | 15967 | first = false; |
---|
13537 | 15968 | } |
---|
13538 | 15969 | } else |
---|
13539 | 15970 | { |
---|
13540 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15971 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
13541 | 15972 | } |
---|
13542 | 15973 | |
---|
13543 | 15974 | first = false; |
---|
.. | .. |
---|
13548 | 15979 | { |
---|
13549 | 15980 | //Composite group = (Composite) object; |
---|
13550 | 15981 | Object3D group = object; |
---|
13551 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15982 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
13552 | 15983 | } |
---|
13553 | 15984 | |
---|
13554 | 15985 | void ResetTransform(int mask) |
---|
13555 | 15986 | { |
---|
13556 | 15987 | //Composite group = (Composite) object; |
---|
13557 | 15988 | Object3D group = object; |
---|
13558 | | - group.editWindow.ResetTransform(mask); |
---|
| 15989 | + group.GetWindow().ResetTransform(mask); |
---|
13559 | 15990 | } |
---|
13560 | 15991 | |
---|
13561 | 15992 | void FlipTransform() |
---|
13562 | 15993 | { |
---|
13563 | 15994 | //Composite group = (Composite) object; |
---|
13564 | 15995 | Object3D group = object; |
---|
13565 | | - group.editWindow.FlipTransform(); |
---|
| 15996 | + group.GetWindow().FlipTransform(); |
---|
13566 | 15997 | // group.editWindow.ReduceMesh(true); |
---|
13567 | 15998 | } |
---|
13568 | 15999 | |
---|
.. | .. |
---|
13570 | 16001 | { |
---|
13571 | 16002 | //Composite group = (Composite) object; |
---|
13572 | 16003 | Object3D group = object; |
---|
13573 | | - group.editWindow.PrintMemory(); |
---|
| 16004 | + group.GetWindow().PrintMemory(); |
---|
13574 | 16005 | // group.editWindow.ReduceMesh(true); |
---|
13575 | 16006 | } |
---|
13576 | 16007 | |
---|
.. | .. |
---|
13578 | 16009 | { |
---|
13579 | 16010 | //Composite group = (Composite) object; |
---|
13580 | 16011 | Object3D group = object; |
---|
13581 | | - group.editWindow.ResetCentroid(); |
---|
| 16012 | + group.GetWindow().ResetCentroid(); |
---|
13582 | 16013 | } |
---|
13583 | 16014 | |
---|
13584 | 16015 | void IncDepth() |
---|
.. | .. |
---|
13660 | 16091 | |
---|
13661 | 16092 | int width = getBounds().width; |
---|
13662 | 16093 | int height = getBounds().height; |
---|
13663 | | - ClickInfo info = new ClickInfo(); |
---|
13664 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
13665 | 16094 | //Image img = CreateImage(width, height); |
---|
13666 | 16095 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 16096 | + |
---|
13667 | 16097 | Graphics gr = g; // img.getGraphics(); |
---|
| 16098 | + |
---|
13668 | 16099 | if (!hasMarquee) |
---|
13669 | 16100 | { |
---|
13670 | 16101 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
13736 | 16167 | } |
---|
13737 | 16168 | if (object != null && !hasMarquee) |
---|
13738 | 16169 | { |
---|
| 16170 | + if (object.clickInfo == null) |
---|
| 16171 | + object.clickInfo = new ClickInfo(); |
---|
| 16172 | + ClickInfo info = object.clickInfo; |
---|
| 16173 | + //ClickInfo info = new ClickInfo(); |
---|
| 16174 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16175 | + |
---|
13739 | 16176 | if (isRenderer) |
---|
13740 | 16177 | { |
---|
13741 | | - info.flags++; |
---|
| 16178 | + object.clickInfo.flags++; |
---|
13742 | 16179 | double frameAspect = (double) width / (double) height; |
---|
13743 | 16180 | if (frameAspect > renderCamera.aspect) |
---|
13744 | 16181 | { |
---|
13745 | 16182 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
13746 | | - info.bounds.width -= width - desired; |
---|
13747 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16183 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16184 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
13748 | 16185 | } else |
---|
13749 | 16186 | { |
---|
13750 | 16187 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
13751 | | - info.bounds.height -= height - desired; |
---|
13752 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16188 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16189 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
13753 | 16190 | } |
---|
13754 | 16191 | } |
---|
13755 | | - info.g = gr; |
---|
13756 | | - info.camera = renderCamera; |
---|
| 16192 | + |
---|
| 16193 | + object.clickInfo.g = gr; |
---|
| 16194 | + object.clickInfo.camera = renderCamera; |
---|
13757 | 16195 | /* |
---|
13758 | 16196 | // Memory intensive (brep.verticescopy) |
---|
13759 | 16197 | if (!(object instanceof Composite)) |
---|
13760 | 16198 | object.draw(info, 0, false); // SLOW : |
---|
13761 | 16199 | */ |
---|
13762 | | - if (!isRenderer) |
---|
| 16200 | + if (!isRenderer) // && drag) |
---|
13763 | 16201 | { |
---|
13764 | | - object.drawEditHandles(info, 0); |
---|
| 16202 | + Grafreed.Assert(object != null); |
---|
| 16203 | + Grafreed.Assert(object.selection != null); |
---|
| 16204 | + if (object.selection.Size() > 0) |
---|
| 16205 | + { |
---|
| 16206 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16207 | + |
---|
| 16208 | + object.clickInfo.DX = 0; |
---|
| 16209 | + object.clickInfo.DY = 0; |
---|
| 16210 | + object.clickInfo.W = 1; |
---|
| 16211 | + if (hitSomething == Object3D.hitCenter) |
---|
| 16212 | + { |
---|
| 16213 | + info.DX = X; |
---|
| 16214 | + if (X != 0) |
---|
| 16215 | + info.DX -= info.bounds.width/2; |
---|
| 16216 | + |
---|
| 16217 | + info.DY = Y; |
---|
| 16218 | + if (Y != 0) |
---|
| 16219 | + info.DY -= info.bounds.height/2; |
---|
| 16220 | + } |
---|
| 16221 | + |
---|
| 16222 | + object.drawEditHandles(//info, |
---|
| 16223 | + 0); |
---|
| 16224 | + |
---|
| 16225 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16226 | + { |
---|
| 16227 | + switch (hitSomething) |
---|
| 16228 | + { |
---|
| 16229 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
| 16230 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16231 | + break; |
---|
| 16232 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16233 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16234 | + break; |
---|
| 16235 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16236 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16237 | + break; |
---|
| 16238 | + } |
---|
| 16239 | + |
---|
| 16240 | + } |
---|
| 16241 | + } |
---|
13765 | 16242 | } |
---|
13766 | 16243 | } |
---|
| 16244 | + |
---|
13767 | 16245 | if (isRenderer) |
---|
13768 | 16246 | { |
---|
13769 | 16247 | //gr.setColor(Color.black); |
---|
13770 | 16248 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
13771 | 16249 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
13772 | 16250 | } |
---|
| 16251 | + |
---|
13773 | 16252 | if (hasMarquee) |
---|
13774 | 16253 | { |
---|
13775 | 16254 | gr.setXORMode(Color.white); |
---|
13776 | | - gr.setColor(Color.red); |
---|
| 16255 | + gr.setColor(Color.white); |
---|
13777 | 16256 | if (!firstime) |
---|
13778 | 16257 | { |
---|
13779 | 16258 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
13792 | 16271 | //if (g != gr) g.drawImage(img, 0, 0, width, height, null); |
---|
13793 | 16272 | } |
---|
13794 | 16273 | |
---|
| 16274 | + // To avoid clear. |
---|
13795 | 16275 | public void update(Graphics g) |
---|
13796 | 16276 | { |
---|
13797 | 16277 | paint(g); |
---|
.. | .. |
---|
13881 | 16361 | public boolean mouseDown(Event evt, int x, int y) |
---|
13882 | 16362 | { |
---|
13883 | 16363 | System.out.println("mouseDown: " + evt); |
---|
| 16364 | + System.exit(0); |
---|
13884 | 16365 | /* |
---|
13885 | 16366 | locked = true; |
---|
13886 | 16367 | drag = false; |
---|
.. | .. |
---|
13924 | 16405 | { |
---|
13925 | 16406 | keyPressed(0, modifiers); |
---|
13926 | 16407 | } |
---|
13927 | | - clickStart(x, y, modifiers); |
---|
| 16408 | + // clickStart(x, y, modifiers); |
---|
13928 | 16409 | return true; |
---|
13929 | 16410 | } |
---|
13930 | 16411 | |
---|
.. | .. |
---|
14042 | 16523 | { |
---|
14043 | 16524 | keyReleased(0, 0); |
---|
14044 | 16525 | } |
---|
14045 | | - drag(x, y, modifiers); |
---|
| 16526 | + drag(x, y, 0, modifiers); |
---|
14046 | 16527 | return true; |
---|
14047 | 16528 | } |
---|
14048 | 16529 | |
---|
.. | .. |
---|
14174 | 16655 | Object3D object; |
---|
14175 | 16656 | static Object3D trackedobject; |
---|
14176 | 16657 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
14177 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16658 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
14178 | 16659 | /*static*/ Camera eyeCamera; |
---|
14179 | 16660 | /*static*/ Camera lightCamera; |
---|
14180 | 16661 | int cameracount; |
---|
.. | .. |
---|
14238 | 16719 | private /*static*/ boolean firstime; |
---|
14239 | 16720 | private /*static*/ cVector newView = new cVector(); |
---|
14240 | 16721 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16722 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16723 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
14241 | 16724 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
14242 | 16725 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
14243 | 16726 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
14250 | 16733 | { |
---|
14251 | 16734 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
14252 | 16735 | |
---|
| 16736 | + int usedsuf = 0; |
---|
| 16737 | + |
---|
14253 | 16738 | for (int i = 0; i < suffixes.length; i++) |
---|
14254 | 16739 | { |
---|
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) |
---|
| 16740 | + String[] suffixe = suffixes; |
---|
| 16741 | + String[] fallback = suffixes2; |
---|
| 16742 | + String[] fallfallback = suffixes3; |
---|
| 16743 | + |
---|
| 16744 | + for (int c=usedsuf; --c>=0;) |
---|
14260 | 16745 | { |
---|
14261 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16746 | +// String[] temp = suffixe; |
---|
| 16747 | +// suffixe = fallback; |
---|
| 16748 | +// fallback = fallfallback; |
---|
| 16749 | +// fallfallback = temp; |
---|
14262 | 16750 | } |
---|
| 16751 | + |
---|
| 16752 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16753 | + TextureData data; |
---|
| 16754 | + |
---|
| 16755 | + try |
---|
| 16756 | + { |
---|
| 16757 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16758 | + mipmapped, |
---|
| 16759 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16760 | + } |
---|
| 16761 | + catch (Exception e) |
---|
| 16762 | + { |
---|
| 16763 | + try |
---|
| 16764 | + { |
---|
| 16765 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16766 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16767 | + mipmapped, |
---|
| 16768 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16769 | + } |
---|
| 16770 | + catch (Exception e2) |
---|
| 16771 | + { |
---|
| 16772 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16773 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16774 | + mipmapped, |
---|
| 16775 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16776 | + } |
---|
| 16777 | + } |
---|
| 16778 | + |
---|
14263 | 16779 | //System.out.println("Target = " + targets[i]); |
---|
14264 | 16780 | cubemap.updateImage(data, targets[i]); |
---|
14265 | 16781 | } |
---|
14266 | 16782 | |
---|
14267 | 16783 | return cubemap; |
---|
14268 | 16784 | } |
---|
| 16785 | + |
---|
14269 | 16786 | int bigsphere = -1; |
---|
14270 | 16787 | |
---|
14271 | 16788 | float BGcolor = 0.5f; |
---|
14272 | 16789 | |
---|
14273 | | - private void DrawSkyBox(GL gl) |
---|
| 16790 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16791 | + |
---|
| 16792 | + private void DrawSkyBox(GL gl, float ratio) |
---|
14274 | 16793 | { |
---|
14275 | | - if (envyoff || cubemap == null) |
---|
| 16794 | + if (//envyoff || |
---|
| 16795 | + WIREFRAME || |
---|
| 16796 | + cubemap == null) |
---|
14276 | 16797 | { |
---|
14277 | 16798 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
14278 | 16799 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
14287 | 16808 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
14288 | 16809 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
14289 | 16810 | gl.glLoadIdentity(); |
---|
| 16811 | + gl.glScalef(1,ratio,1); |
---|
14290 | 16812 | |
---|
| 16813 | +// colorV[0] = 2; |
---|
| 16814 | +// colorV[1] = 2; |
---|
| 16815 | +// colorV[2] = 2; |
---|
| 16816 | +// colorV[3] = 1; |
---|
| 16817 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16818 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16819 | +// |
---|
| 16820 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16821 | + |
---|
14291 | 16822 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
14292 | 16823 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
14293 | 16824 | |
---|
.. | .. |
---|
14319 | 16850 | { |
---|
14320 | 16851 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
14321 | 16852 | } |
---|
| 16853 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
14322 | 16854 | gl.glMultMatrixd(viewrot_1, 0); |
---|
14323 | 16855 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
14324 | 16856 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
14359 | 16891 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
14360 | 16892 | |
---|
14361 | 16893 | cubemap.disable(); |
---|
14362 | | - ////cubemap.unbind(); |
---|
| 16894 | + //cubemap.dispose(); |
---|
| 16895 | + |
---|
14363 | 16896 | if (CULLFACE) |
---|
14364 | 16897 | { |
---|
14365 | 16898 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
14394 | 16927 | gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS); |
---|
14395 | 16928 | gl.glPushMatrix(); |
---|
14396 | 16929 | gl.glLoadIdentity(); |
---|
14397 | | - PushMatrix(checker.toParent); |
---|
| 16930 | + //PushMatrix(checker.toParent); |
---|
14398 | 16931 | |
---|
14399 | 16932 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
14400 | 16933 | gl.glPushMatrix(); |
---|
.. | .. |
---|
14415 | 16948 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
14416 | 16949 | } |
---|
14417 | 16950 | |
---|
14418 | | - gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
| 16951 | + SetGLNormal(gl, 0.0f, 0.0f, 1.0f); |
---|
14419 | 16952 | |
---|
14420 | | - float step = 0.1666f; //0.25f; |
---|
14421 | | - float stepv = step * 1652 / 998; |
---|
| 16953 | + float step = 2; // 0.1666f; //0.25f; |
---|
| 16954 | + float stepv = 2; // step * 1652 / 998; |
---|
14422 | 16955 | |
---|
14423 | 16956 | int i0 = 0; |
---|
14424 | 16957 | /* |
---|
.. | .. |
---|
14454 | 16987 | /**/ |
---|
14455 | 16988 | //checker.GetMaterial().opacity = 1.1f; |
---|
14456 | 16989 | ////checker.GetMaterial().ambient = 0.99f; |
---|
14457 | | - Object3D.materialstack[Object3D.materialdepth] = checker.material; |
---|
14458 | | - Object3D.selectedstack[Object3D.materialdepth] = false; |
---|
14459 | | - cStatic.objectstack[Object3D.materialdepth++] = checker; |
---|
| 16990 | + materialstack[materialdepth] = checker.material; |
---|
| 16991 | + selectedstack[materialdepth] = false; |
---|
| 16992 | + cStatic.objectstack[materialdepth++] = checker; |
---|
14460 | 16993 | //System.out.println("material " + material); |
---|
14461 | 16994 | //Applet3D.tracein(this, selected); |
---|
14462 | | - vector2buffer = checker.projectedVertices; |
---|
| 16995 | + //vector2buffer = checker.projectedVertices; |
---|
14463 | 16996 | |
---|
14464 | | - checker.GetMaterial().Draw(this, false); // true); |
---|
| 16997 | + //checker.GetMaterial().Draw(this, false); // true); |
---|
| 16998 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
14465 | 16999 | |
---|
14466 | | - Object3D.materialdepth -= 1; |
---|
14467 | | - if (Object3D.materialdepth > 0) |
---|
| 17000 | + materialdepth -= 1; |
---|
| 17001 | + if (materialdepth > 0) |
---|
14468 | 17002 | { |
---|
14469 | | - vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices; |
---|
14470 | | - Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]); |
---|
| 17003 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 17004 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
14471 | 17005 | } |
---|
14472 | 17006 | //checker.GetMaterial().opacity = 1f; |
---|
14473 | 17007 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
14488 | 17022 | |
---|
14489 | 17023 | //float u = (i+1)/2; |
---|
14490 | 17024 | //float v = (j+1)/2; |
---|
14491 | | - gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
| 17025 | + if (checker.flipV) |
---|
| 17026 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2); |
---|
| 17027 | + else |
---|
| 17028 | + gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); |
---|
14492 | 17029 | gl.glVertex3f(i, j, -0.5f); |
---|
14493 | 17030 | |
---|
| 17031 | + if (checker.flipV) |
---|
| 17032 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
| 17033 | + else |
---|
14494 | 17034 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
14495 | 17035 | gl.glVertex3f(i + step, j, -0.5f); |
---|
14496 | 17036 | |
---|
| 17037 | + if (checker.flipV) |
---|
| 17038 | + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
| 17039 | + else |
---|
14497 | 17040 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
14498 | 17041 | gl.glVertex3f(i + step, j + stepv, -0.5f); |
---|
14499 | 17042 | |
---|
| 17043 | + if (checker.flipV) |
---|
| 17044 | + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
| 17045 | + else |
---|
14500 | 17046 | gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
14501 | 17047 | gl.glVertex3f(i, j + stepv, -0.5f); |
---|
14502 | 17048 | } |
---|
.. | .. |
---|
14508 | 17054 | gl.glMatrixMode(GL.GL_PROJECTION); |
---|
14509 | 17055 | gl.glPopMatrix(); |
---|
14510 | 17056 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
14511 | | - PopMatrix(null); // checker.toParent); // null); |
---|
| 17057 | + //PopMatrix(null); // checker.toParent); // null); |
---|
14512 | 17058 | gl.glPopMatrix(); |
---|
14513 | 17059 | PopTextureMatrix(checker.toParent); |
---|
14514 | 17060 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
.. | .. |
---|
14541 | 17087 | } |
---|
14542 | 17088 | } |
---|
14543 | 17089 | |
---|
| 17090 | + private Object3D GetFolder() |
---|
| 17091 | + { |
---|
| 17092 | + Object3D folder = object.GetWindow().copy; |
---|
| 17093 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17094 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17095 | + return folder; |
---|
| 17096 | + } |
---|
| 17097 | + |
---|
14544 | 17098 | class SelectBuffer implements GLEventListener |
---|
14545 | 17099 | { |
---|
14546 | 17100 | |
---|
.. | .. |
---|
14556 | 17110 | //new Exception().printStackTrace(); |
---|
14557 | 17111 | System.out.println("select buffer init"); |
---|
14558 | 17112 | // Use debug pipeline |
---|
14559 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17113 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
14560 | 17114 | |
---|
14561 | 17115 | GL gl = drawable.getGL(); |
---|
14562 | 17116 | |
---|
.. | .. |
---|
14599 | 17153 | { |
---|
14600 | 17154 | if (!selection) |
---|
14601 | 17155 | { |
---|
| 17156 | + new Exception().printStackTrace(); |
---|
14602 | 17157 | System.exit(0); |
---|
14603 | 17158 | return; |
---|
14604 | 17159 | } |
---|
.. | .. |
---|
14619 | 17174 | |
---|
14620 | 17175 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
14621 | 17176 | |
---|
| 17177 | + if (PAINTMODE) |
---|
| 17178 | + { |
---|
| 17179 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17180 | + { |
---|
| 17181 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17182 | + |
---|
| 17183 | + // Make what you paint not selectable. |
---|
| 17184 | + paintobj.ResetSelectable(); |
---|
| 17185 | + } |
---|
| 17186 | + } |
---|
| 17187 | + |
---|
14622 | 17188 | //int tmp = selection_view; |
---|
14623 | 17189 | //selection_view = -1; |
---|
14624 | | - int temp = drawMode; |
---|
14625 | | - drawMode = SELECTION; |
---|
| 17190 | + int temp = DrawMode(); |
---|
| 17191 | + Globals.drawMode = SELECTION; // WARNING |
---|
14626 | 17192 | indexcount = 0; |
---|
14627 | 17193 | parent.display(drawable); |
---|
14628 | 17194 | //selection_view = tmp; |
---|
14629 | 17195 | //if (temp == SELECTION) |
---|
14630 | 17196 | // temp = DEFAULT; // patch for selection debug |
---|
14631 | | - drawMode = temp; |
---|
| 17197 | + Globals.drawMode = temp; // WARNING |
---|
14632 | 17198 | |
---|
| 17199 | + if (PAINTMODE) |
---|
| 17200 | + { |
---|
| 17201 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17202 | + { |
---|
| 17203 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17204 | + |
---|
| 17205 | + // Revert. |
---|
| 17206 | + paintobj.RestoreSelectable(); |
---|
| 17207 | + } |
---|
| 17208 | + } |
---|
| 17209 | + |
---|
14633 | 17210 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
14634 | 17211 | |
---|
14635 | 17212 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
14678 | 17255 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
14679 | 17256 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
14680 | 17257 | |
---|
| 17258 | + CreateSelectedPoint(); |
---|
| 17259 | + |
---|
| 17260 | + // Will fit the mesh !!! |
---|
| 17261 | + selectedpoint.toParent[0][0] = 0.0001; |
---|
| 17262 | + selectedpoint.toParent[1][1] = 0.0001; |
---|
| 17263 | + selectedpoint.toParent[2][2] = 0.0001; |
---|
| 17264 | + |
---|
14681 | 17265 | glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0); |
---|
14682 | 17266 | |
---|
14683 | 17267 | // if (object.selection != null && object.selection.Size() > 0) |
---|
.. | .. |
---|
14721 | 17305 | 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 | 17306 | } |
---|
14723 | 17307 | |
---|
14724 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 17308 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
14725 | 17309 | } |
---|
14726 | 17310 | } |
---|
14727 | 17311 | |
---|
14728 | 17312 | if (!movingcamera && !PAINTMODE) |
---|
14729 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17313 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
14730 | 17314 | |
---|
14731 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17315 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
14732 | 17316 | { |
---|
14733 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17317 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
14734 | 17318 | |
---|
14735 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17319 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17320 | + { |
---|
| 17321 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
14736 | 17322 | |
---|
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(); |
---|
| 17323 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17324 | + |
---|
| 17325 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17326 | + |
---|
| 17327 | + inst.add(paintobj); // link |
---|
| 17328 | + |
---|
| 17329 | + object.GetWindow().SnapObject(inst); |
---|
| 17330 | + |
---|
| 17331 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17332 | + |
---|
| 17333 | + folder.add(inst); |
---|
| 17334 | + |
---|
| 17335 | + object.GetWindow().ResetModel(); |
---|
| 17336 | + object.GetWindow().refreshContents(); |
---|
| 17337 | + } |
---|
14752 | 17338 | } |
---|
14753 | 17339 | else |
---|
14754 | 17340 | paintcount = 0; |
---|
.. | .. |
---|
14787 | 17373 | //System.out.println("objects[color] = " + objects[color]); |
---|
14788 | 17374 | //objects[color].Select(); |
---|
14789 | 17375 | indexcount = 0; |
---|
| 17376 | + ObjEditor window = object.GetWindow(); |
---|
| 17377 | + if (window != null && deselect) |
---|
| 17378 | + { |
---|
| 17379 | + window.Select(null, deselect, true); |
---|
| 17380 | + } |
---|
14790 | 17381 | object.Select(color, deselect); |
---|
14791 | 17382 | } |
---|
14792 | 17383 | |
---|
.. | .. |
---|
14837 | 17428 | |
---|
14838 | 17429 | public void init(GLAutoDrawable drawable) |
---|
14839 | 17430 | { |
---|
| 17431 | + if (Globals.DEBUG) |
---|
14840 | 17432 | System.out.println("shadow buffer init"); |
---|
14841 | 17433 | |
---|
14842 | 17434 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
14886 | 17478 | gl.glDisable(gl.GL_CULL_FACE); |
---|
14887 | 17479 | } |
---|
14888 | 17480 | |
---|
14889 | | - if (!RENDERSHADOW) |
---|
| 17481 | + if (!Globals.RENDERSHADOW) |
---|
14890 | 17482 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14891 | 17483 | |
---|
14892 | 17484 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
14896 | 17488 | //gl.glColorMask(false, false, false, false); |
---|
14897 | 17489 | |
---|
14898 | 17490 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
14899 | | - if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17491 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
14900 | 17492 | { |
---|
14901 | 17493 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
14902 | 17494 | |
---|
14903 | | - int temp = drawMode; |
---|
14904 | | - drawMode = SHADOW; |
---|
| 17495 | + int temp = DrawMode(); |
---|
| 17496 | + Globals.drawMode = SHADOW; // WARNING |
---|
14905 | 17497 | parent.display(drawable); |
---|
14906 | | - drawMode = temp; |
---|
| 17498 | + Globals.drawMode = temp; // WARNING |
---|
14907 | 17499 | } |
---|
14908 | 17500 | |
---|
14909 | 17501 | gl.glCullFace(gl.GL_BACK); |
---|
.. | .. |
---|
14956 | 17548 | |
---|
14957 | 17549 | class AntialiasBuffer implements GLEventListener |
---|
14958 | 17550 | { |
---|
14959 | | - |
---|
14960 | 17551 | CameraPane parent = null; |
---|
14961 | 17552 | |
---|
14962 | 17553 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
15066 | 17657 | gl.glFlush(); |
---|
15067 | 17658 | |
---|
15068 | 17659 | /**/ |
---|
15069 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer); |
---|
| 17660 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
15070 | 17661 | |
---|
15071 | | - int[] pixels = occlusionsizebuffer.array(); |
---|
| 17662 | + float[] depths = occlusiondepthbuffer.array(); |
---|
15072 | 17663 | |
---|
| 17664 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17665 | + |
---|
| 17666 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17667 | + |
---|
15073 | 17668 | double r = 0, g = 0, b = 0; |
---|
15074 | 17669 | |
---|
15075 | 17670 | double count = 0; |
---|
| 17671 | + |
---|
| 17672 | + gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0); |
---|
| 17673 | + |
---|
| 17674 | + float mindepth = 1; |
---|
| 17675 | + |
---|
| 17676 | + double FACTOR = 1; |
---|
15076 | 17677 | |
---|
15077 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17678 | + for (int i = 0; i < depths.length; i++) |
---|
15078 | 17679 | { |
---|
15079 | 17680 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
15080 | 17681 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
15157 | 17758 | |
---|
15158 | 17759 | double scale = ray.z; // 1; // cos |
---|
15159 | 17760 | |
---|
15160 | | - int p = pixels[newindex]; |
---|
| 17761 | + float depth = depths[newindex]; |
---|
15161 | 17762 | |
---|
15162 | 17763 | /* |
---|
15163 | 17764 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
15181 | 17782 | scale = (1 - modu) * modv; |
---|
15182 | 17783 | */ |
---|
15183 | 17784 | |
---|
15184 | | - r += ((p >> 16) & 0xFF) * scale / 255; |
---|
15185 | | - g += ((p >> 8) & 0xFF) * scale / 255; |
---|
15186 | | - b += (p & 0xFF) * scale / 255; |
---|
| 17785 | + //r += ((p >> 16) & 0xFF) * scale / 255; |
---|
| 17786 | + //g += ((p >> 8) & 0xFF) * scale / 255; |
---|
| 17787 | + //b += (p & 0xFF) * scale / 255; |
---|
| 17788 | + |
---|
| 17789 | + if (mindepth > depth) |
---|
| 17790 | + { |
---|
| 17791 | + mindepth = depth; |
---|
| 17792 | + } |
---|
15187 | 17793 | |
---|
| 17794 | + double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]); |
---|
| 17795 | + |
---|
| 17796 | + double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR); |
---|
| 17797 | + |
---|
| 17798 | + r += factor * scale; |
---|
| 17799 | + g += factor * scale; |
---|
| 17800 | + b += factor * scale; |
---|
| 17801 | + |
---|
15188 | 17802 | count += scale; |
---|
15189 | 17803 | } |
---|
15190 | 17804 | |
---|
.. | .. |
---|
15282 | 17896 | GLUT glut = new GLUT(); |
---|
15283 | 17897 | |
---|
15284 | 17898 | |
---|
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 | 17899 | public boolean spherical = false; |
---|
15292 | 17900 | static boolean DEBUG_OCCLUSION = false; |
---|
15293 | 17901 | static boolean DEBUG_SELECTION = false; |
---|
.. | .. |
---|
15300 | 17908 | int AAbuffersize = 0; |
---|
15301 | 17909 | |
---|
15302 | 17910 | //double[] selectedpoint = new double[3]; |
---|
15303 | | - static Sphere selectedpoint = new Sphere(); |
---|
| 17911 | + static Superellipsoid selectedpoint; |
---|
15304 | 17912 | 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(); |
---|
| 17913 | + static Sphere debugpointG; |
---|
| 17914 | + static Sphere debugpointP; |
---|
| 17915 | + static Sphere debugpointC; |
---|
| 17916 | + static Sphere debugpointR; |
---|
15309 | 17917 | |
---|
15310 | 17918 | static Sphere debugpoints[] = new Sphere[8]; |
---|
15311 | 17919 | |
---|
15312 | | - static |
---|
15313 | | - { |
---|
15314 | | - for (int i=0; i<8; i++) |
---|
15315 | | - { |
---|
15316 | | - debugpoints[i] = new Sphere(); |
---|
15317 | | - } |
---|
15318 | | - } |
---|
15319 | | - |
---|
15320 | 17920 | static void InitPoints(float radius) |
---|
15321 | 17921 | { |
---|
15322 | 17922 | for (int i=0; i<8; i++) |
---|
.. | .. |
---|
15336 | 17936 | } |
---|
15337 | 17937 | } |
---|
15338 | 17938 | |
---|
15339 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17939 | + static void DrawPoints(iCameraPane cpane) |
---|
15340 | 17940 | { |
---|
15341 | 17941 | for (int i=0; i<8; i++) // first and last are red |
---|
15342 | 17942 | { |
---|
.. | .. |
---|
15355 | 17955 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
15356 | 17956 | static IntBuffer bigAAbuffer; |
---|
15357 | 17957 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
15358 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17958 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
15359 | 17959 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15360 | 17960 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15361 | | - static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17961 | + //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17962 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17963 | + |
---|
| 17964 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17965 | + |
---|
15362 | 17966 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
15363 | 17967 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
15364 | 17968 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|
.. | .. |
---|
15367 | 17971 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
15368 | 17972 | // Depth buffer format |
---|
15369 | 17973 | //private int depth_format; |
---|
15370 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17974 | + |
---|
| 17975 | + public void NextIndex() |
---|
15371 | 17976 | { |
---|
15372 | 17977 | indexcount+=16; |
---|
15373 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17978 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
15374 | 17979 | //objects[indexcount] = o; |
---|
15375 | 17980 | //System.out.println("indexcount = " + indexcount); |
---|
15376 | 17981 | } |
---|