Normand Briere
2019-08-22 6a145f6c81dfcbe0653eda27d042efb48daa7512
CameraPane.java
....@@ -18,7 +18,10 @@
1818 import javax.imageio.ImageIO;
1919 import javax.imageio.ImageWriteParam;
2020 import javax.imageio.ImageWriter;
21
+import javax.imageio.ImageReadParam;
22
+import javax.imageio.ImageReader;
2123 import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
24
+import javax.imageio.stream.ImageInputStream;
2225 import javax.imageio.stream.ImageOutputStream;
2326 import javax.imageio.ImageWriteParam;
2427
....@@ -30,10 +33,14 @@
3033 import java.nio.*;
3134
3235 import gleem.linalg.Mat4f;
36
+import javax.imageio.ImageTypeSpecifier;
3337
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
3539 {
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
+
3744 static boolean FRUSTUM = false; // still bogus true; // frustum culling
3845
3946 // camera change fix
....@@ -42,25 +49,40 @@
4249
4350 static int STEP = 1;
4451
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)
5153 {
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;
5383 }
5484
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;
6486 /*static*/ boolean NEAREST = false; // true;
6587 /*static*/ boolean WIREFRAME = false; // true;
6688
....@@ -70,14 +92,12 @@
7092 static int CURRENTANTIALIAS = 0; // 1;
7193 /*static*/ boolean RENDERSHADOW = true;
7294 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
73
- static boolean ANIMATION = false;
74
- static String filename;
7595
7696 boolean DISPLAYTEXT = false;
7797 //boolean REDUCETEXTURE = true;
7898 boolean CACHETEXTURE = true;
7999 boolean CLEANCACHE = false; // true;
80
- boolean MIPMAP = false; // true;
100
+ boolean MIPMAP = false; // true; // never works...
81101 boolean COMPRESSTEXTURE = false;
82102 boolean KOMPACTTEXTURE = false; // true;
83103 boolean RESIZETEXTURE = false;
....@@ -90,17 +110,19 @@
90110 //private Mat4f spotlightTransform = new Mat4f();
91111 //private Mat4f spotlightInverseTransform = new Mat4f();
92112 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
+
94118 boolean reverseUP = false;
95119 static boolean frozen = false;
96120 boolean enablebackspace = false; // patch for back buffer refresh
97121
98122 static boolean textureon = true;
99123 static boolean LOCALTRANSFORM = false;
100
-private static boolean LIVE = false;
101124 static boolean FULLSCREEN = false;
102125 static boolean SUPPORT = true;
103
-static boolean CROWD = false;
104126 static boolean INERTIA = true;
105127 static boolean FAST = false;
106128 static boolean SLOWPOSE = false;
....@@ -108,6 +130,8 @@
108130
109131 static int tickcount = 0; // slow pose issue
110132
133
+static boolean BUTTONLESSWHEEL = false;
134
+static boolean ZOOMBOXMODE = false;
111135 static boolean BOXMODE = false;
112136 static boolean IMAGEFLIP = false;
113137 static boolean SMOOTHFOCUS = false;
....@@ -122,7 +146,7 @@
122146 static boolean OEIL = true;
123147 static boolean OEILONCE = false; // do oeilon then oeiloff
124148 static boolean LOOKAT = true;
125
-static boolean RANDOM = true; // false;
149
+static boolean SWITCH = true; // false;
126150 static boolean HANDLES = false; // selection doesn't work!!
127151 static boolean PAINTMODE = false;
128152
....@@ -144,7 +168,7 @@
144168
145169
146170 // OPTIONS
147
- boolean Skinshader = true;
171
+ boolean Skinshader = false; // true;
148172 boolean cameraLight = false;
149173 boolean UVdebug = false;
150174 boolean Udebug = false;
....@@ -153,7 +177,7 @@
153177 static boolean doublesided = false; // true; // reversed normals are awful for conformance
154178 boolean anisotropy = true;
155179 boolean softshadow = true; // slower but better false;
156
- boolean opacityhalo = false;
180
+ boolean opacityhalo = false; // reverse the halo effect (e.g. glass)
157181
158182 boolean macromode = false;
159183
....@@ -165,12 +189,55 @@
165189 defaultcaps.setAccumBlueBits(16);
166190 defaultcaps.setAccumAlphaBits(16);
167191 }
168
- static CameraPane theRenderer;
192
+
193
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
169194
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
+
170208 void SetAsGLRenderer(boolean b)
171209 {
172210 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
174241 }
175242
176243 static boolean AntialiasingEnabled()
....@@ -178,12 +245,53 @@
178245 return CURRENTANTIALIAS > 0;
179246 }
180247
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()
182290 {
183291 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
184292 }
185293
186
- void DepthTest(boolean depthtest)
294
+ public void DepthTest(boolean depthtest)
187295 {
188296 if (depthtest)
189297 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -191,7 +299,7 @@
191299 GetGL().glDepthFunc(GL.GL_ALWAYS);
192300 }
193301
194
- void DepthWrite(boolean depthwrite)
302
+ public void DepthWrite(boolean depthwrite)
195303 {
196304 if (depthwrite)
197305 GetGL().glDepthMask(true);
....@@ -199,12 +307,1617 @@
199307 GetGL().glDepthMask(false);
200308 }
201309
202
- void BackFaceCull(boolean bfc)
310
+ public void BackFaceCull(boolean bfc)
203311 {
204312 if (bfc)
205313 GetGL().glEnable(GetGL().GL_CULL_FACE);
206314 else
207315 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
+ }
2081921 }
2091922
2101923 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -225,7 +1938,7 @@
2251938 currentGL.glMultMatrixd(model, 0);
2261939 }
2271940
228
- void PushMatrix(double[][] matrix, int count)
1941
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2291942 {
2301943 matrixdepth++;
2311944 // GrafreeD.tracein(matrix);
....@@ -254,7 +1967,7 @@
2541967 void PushMatrix(double[][] matrix)
2551968 {
2561969 // GrafreeD.tracein(matrix);
257
- PushMatrix(matrix,1);
1970
+ PushMatrix(matrix, 1);
2581971 }
2591972
2601973 void PushMatrix()
....@@ -270,7 +1983,7 @@
2701983
2711984 double[][] tmpmat = new double[4][4];
2721985
273
- void PopMatrix(double[][] inverse)
1986
+ public void PopMatrix(double[][] inverse) // INTERFACE
2741987 {
2751988 --matrixdepth;
2761989
....@@ -310,7 +2023,7 @@
3102023 PushTextureMatrix(matrix, 1);
3112024 }
3122025
313
- void PushTextureMatrix(double[][] matrix, int count)
2026
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3142027 {
3152028 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3162029
....@@ -324,7 +2037,7 @@
3242037 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3252038 }
3262039
327
- void PopTextureMatrix(double[][] inverse)
2040
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3282041 {
3292042 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3302043 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -340,9 +2053,9 @@
3402053 switch(viewcode)
3412054 {
3422055 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";
3462059 case 4: return "light";
3472060 }
3482061
....@@ -351,15 +2064,15 @@
3512064
3522065 static int camerachangeframe;
3532066
354
- boolean SetCamera(Camera cam)
2067
+ public boolean SetCamera(Camera cam)
3552068 {
3562069 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3572070 // return false;
3582071
359
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
2072
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3602073 {
3612074 // check for last change
362
- if (framecount < camerachangeframe + 400) // 120 == 1 second
2075
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3632076 {
3642077 // refuse the camera change
3652078 System.err.println("Camera " + cam + " REFUSED");
....@@ -367,7 +2080,7 @@
3672080 }
3682081 }
3692082
370
- camerachangeframe = framecount;
2083
+ camerachangeframe = Globals.framecount;
3712084
3722085 cam.hAspect = -1; // Read only
3732086
....@@ -398,7 +2111,7 @@
3982111 {
3992112 //System.err.println("Oeil on");
4002113 TRACK = true;
401
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
2114
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4022115 // object.editWindow.ScreenFit(trackedobject);
4032116 //pingthread.StepToTarget(true);
4042117 }
....@@ -407,8 +2120,8 @@
4072120 {
4082121 //System.err.println("Oeil on");
4092122 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);
4122125 //pingthread.StepToTarget(true);
4132126 }
4142127
....@@ -471,39 +2184,12 @@
4712184 {
4722185 frozen ^= true;
4732186 // Weird...
474
- lighttouched = true;
2187
+ Globals.lighttouched = true;
4752188 }
4762189
4772190 void ToggleDL()
4782191 {
4792192 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;
5072193 }
5082194
5092195 void ToggleFullScreen()
....@@ -513,12 +2199,7 @@
5132199
5142200 void ToggleCrowd()
5152201 {
516
- CROWD ^= true;
517
- }
518
-
519
- void ToggleInertia()
520
- {
521
- INERTIA ^= true;
2202
+ Globals.CROWD ^= true;
5222203 }
5232204
5242205 void ToggleLocal()
....@@ -526,62 +2207,89 @@
5262207 LOCALTRANSFORM ^= true;
5272208 }
5282209
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()
5302243 {
5312244 FAST ^= true;
5322245 }
5332246
534
- void ToggleSlowPose()
2247
+ public void ToggleSlowPose()
5352248 {
5362249 SLOWPOSE ^= true;
5372250 }
5382251
539
- void ToggleFootContact()
540
- {
541
- FOOTCONTACT ^= true;
542
- }
543
-
544
- void ToggleBoxMode()
2252
+ public void ToggleBoxMode()
5452253 {
5462254 BOXMODE ^= true;
5472255 }
5482256
549
- void ToggleSmoothFocus()
2257
+ public void ToggleZoomBoxMode()
2258
+ {
2259
+ ZOOMBOXMODE ^= true;
2260
+ }
2261
+
2262
+ public void ToggleSmoothFocus()
5502263 {
5512264 SMOOTHFOCUS ^= true;
5522265 }
5532266
554
- void ToggleImageFlip()
2267
+ public void ToggleImageFlip()
5552268 {
5562269 IMAGEFLIP ^= true;
5572270 }
5582271
559
- void ToggleSpeakerMocap()
2272
+ public void ToggleSpeakerMocap()
5602273 {
5612274 SPEAKERMOCAP ^= true;
5622275 }
5632276
564
- void ToggleSpeakerCamera()
2277
+ public void ToggleSpeakerCamera()
5652278 {
5662279 SPEAKERCAMERA ^= true;
5672280 }
5682281
569
- void ToggleSpeakerFocus()
2282
+ public void ToggleSpeakerFocus()
5702283 {
5712284 SPEAKERFOCUS ^= true;
5722285 }
5732286
574
- void ToggleDebug()
575
- {
576
- DEBUG ^= true;
577
- }
578
-
579
- void ToggleFrustum()
2287
+ public void ToggleFrustum()
5802288 {
5812289 FRUSTUM ^= true;
5822290 }
5832291
584
- void ToggleTrack()
2292
+ public void ToggleTrack()
5852293 {
5862294 TRACK ^= true;
5872295 if (TRACK)
....@@ -600,25 +2308,35 @@
6002308 repaint();
6012309 }
6022310
603
- void ToggleTrackOnce()
2311
+ public void ToggleTrackOnce()
6042312 {
6052313 TRACKONCE ^= true;
6062314 }
6072315
608
- void ToggleShadowTrack()
2316
+ public void ToggleShadowTrack()
6092317 {
6102318 SHADOWTRACK ^= true;
6112319 repaint();
6122320 }
6132321
614
- void ToggleOeil()
2322
+ public void ToggleOeil()
6152323 {
6162324 OEIL ^= true;
6172325 }
6182326
619
- void ToggleOeilOnce()
2327
+ public void ToggleOeilOnce()
6202328 {
6212329 OEILONCE ^= true;
2330
+ }
2331
+
2332
+ void ToggleFootContact()
2333
+ {
2334
+ FOOTCONTACT ^= true;
2335
+ }
2336
+
2337
+ void ToggleDebug()
2338
+ {
2339
+ Globals.DEBUG ^= true;
6222340 }
6232341
6242342 void ToggleLookAt()
....@@ -626,9 +2344,9 @@
6262344 LOOKAT ^= true;
6272345 }
6282346
629
- void ToggleRandom()
2347
+ void ToggleSwitch()
6302348 {
631
- RANDOM ^= true;
2349
+ SWITCH ^= true;
6322350 }
6332351
6342352 void ToggleHandles()
....@@ -636,10 +2354,17 @@
6362354 HANDLES ^= true;
6372355 }
6382356
2357
+ Object3D paintFolder;
2358
+
6392359 void TogglePaint()
6402360 {
6412361 PAINTMODE ^= true;
6422362 paintcount = 0;
2363
+
2364
+ if (PAINTMODE)
2365
+ {
2366
+ paintFolder = GetFolder();
2367
+ }
6432368 }
6442369
6452370 void SwapCamera(int a, int b)
....@@ -672,34 +2397,6 @@
6722397 //assert (cam.hAspect == 0);
6732398 cam.hAspect = 0;
6742399 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
7032400 }
7042401
7052402 private static void ApplyTransform(GL gl, Mat4f xform)
....@@ -759,11 +2456,38 @@
7592456
7602457 GL currentGL;
7612458
762
- GL GetGL()
2459
+ public GL GetGL() // INTERFACE
7632460 {
7642461 return currentGL;
7652462 }
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
+
7672491 /**/
7682492 class CacheTexture
7692493 {
....@@ -772,28 +2496,31 @@
7722496
7732497 int resolution;
7742498
775
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2499
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
7762500 {
777
- texture = tex;
2501
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2502
+ texturedata = texdata;
7782503 resolution = res;
7792504 }
7802505 }
7812506 /**/
7822507
7832508 // 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
+
7872514 int pigmentdepth = 0;
7882515 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
7892516 int bumpdepth = 0;
7902517 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
7912518 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
7922519 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:");
7942521 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
7952522
796
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2523
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
7972524 {
7982525 TextureData texturedata = null;
7992526
....@@ -803,7 +2530,7 @@
8032530 com.sun.opengl.util.texture.TextureIO.newTextureData(
8042531 getClass().getClassLoader().getResourceAsStream(name),
8052532 true,
806
- com.sun.opengl.util.texture.TextureIO.PNG);
2533
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
8072534 } catch (java.io.IOException e)
8082535 {
8092536 throw new javax.media.opengl.GLException(e);
....@@ -812,13 +2539,34 @@
8122539 if (bump)
8132540 texturedata = ConvertBump(texturedata, false);
8142541
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);
8172544
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);
8202547
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;
8222570 }
8232571
8242572 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -1891,6 +3639,8 @@
18913639
18923640 System.out.println("LOADING TEXTURE : " + name);
18933641
3642
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3643
+
18943644 //
18953645 if (false) // compressbit > 0)
18963646 {
....@@ -2000,10 +3750,12 @@
20003750 */
20013751 TextureData ReduceTexture(TextureData texturedata, int resolution) // String name)
20023752 {
3753
+ int pixelformat = texturedata.getPixelFormat();
3754
+
20033755 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)
20053757 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)
20073759 stride = 4;
20083760
20093761 int width = texturedata.getWidth();
....@@ -2593,6 +4345,7 @@
25934345
25944346 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
25954347 {
4348
+ new Exception().printStackTrace();
25964349 System.exit(0);
25974350 com.sun.opengl.util.texture.Texture texture = null;
25984351
....@@ -6269,7 +8022,7 @@
62698022 return null;
62708023 }
62718024
6272
- void ReleaseTextures(cTexture tex)
8025
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62738026 {
62748027 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62758028 {
....@@ -6286,7 +8039,7 @@
62868039 String pigment = Object3D.GetPigment(tex);
62878040 String bump = Object3D.GetBump(tex);
62888041
6289
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8042
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
62908043 {
62918044 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
62928045 // System.out.println("; bump = " + bump);
....@@ -6301,13 +8054,71 @@
63018054 pigment = null;
63028055 }
63038056
6304
- ReleaseTexture(bump, true);
6305
- ReleaseTexture(pigment, false);
8057
+ ReleaseTexture(tex, true);
8058
+ ReleaseTexture(tex, false);
63068059 }
63078060
6308
- void ReleaseTexture(String tex, boolean bump)
8061
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
63098062 {
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 ||*/
63118122 ambientOcclusion ) // || !textureon)
63128123 {
63138124 return;
....@@ -6316,7 +8127,7 @@
63168127 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
63178128
63188129 if (tex != null)
6319
- texture = textures.get(tex);
8130
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
63208131
63218132 // //assert( texture != null );
63228133 // if (texture == null)
....@@ -6408,9 +8219,57 @@
64088219 }
64098220 }
64108221
6411
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
8222
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
64128223 {
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 ||*/
64148273 ambientOcclusion ) // || !textureon)
64158274 {
64168275 return; // false;
....@@ -6419,17 +8278,47 @@
64198278 if (tex == null)
64208279 {
64218280 BindTexture(null,false,resolution);
6422
- BindTexture(null,true,resolution);
64238281 return;
64248282 }
64258283
64268284 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
+
64278317 String bump = Object3D.GetBump(tex);
64288318
6429
- usedtextures.put(pigment, pigment);
6430
- usedtextures.put(bump, bump);
8319
+ usedtextures.add(tex);
64318320
6432
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8321
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
64338322 {
64348323 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
64358324 // System.out.println("; bump = " + bump);
....@@ -6439,43 +8328,94 @@
64398328 {
64408329 bump = null;
64418330 }
6442
- if (pigment.equals(""))
6443
- {
6444
- pigment = null;
6445
- }
64468331
6447
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
6448
- BindTexture(pigment, false, resolution);
64498332 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
6450
- BindTexture(bump, true, resolution);
8333
+ BindTexture(tex, true, resolution);
64518334 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
6452
-
6453
- return; // true;
64548335 }
64558336
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)
64578340 {
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;
64598360
64608361 if (tex != null)
64618362 {
6462
- String texname = tex;
8363
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8364
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
64638365
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
+ }
64708383
64718384 if (CACHETEXTURE)
6472
- texture = textures.get(texname); // TEXTURE CACHE
6473
-
6474
- TextureData texturedata = null;
6475
-
6476
- if (texture == null || texture.resolution < resolution)
64778385 {
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(""))
64798419 {
64808420 assert(!bump);
64818421 // if (bump)
....@@ -6486,19 +8426,23 @@
64868426 // }
64878427 // else
64888428 // {
6489
- texture = textures.get(tex);
6490
- if (texture == null)
8429
+ // texturecache = textures.get(texname); // suspicious
8430
+ if (texturecache == null)
64918431 {
6492
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8432
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
64938433 }
8434
+ else
8435
+ new Exception().printStackTrace();
64948436 // }
64958437 } else
6496
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8438
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
64978439 {
64988440 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();
65028446 } else
65038447 {
65048448 //if (tex.equals("IMMORTAL"))
....@@ -6506,11 +8450,22 @@
65068450 // texture = GetResourceTexture("default.png");
65078451 //} else
65088452 //{
6509
- if (tex.equals("WHITE_NOISE"))
8453
+ if (texname.endsWith("WHITE_NOISE"))
65108454 {
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();
65148469 } else
65158470 {
65168471 if (textureon)
....@@ -6535,7 +8490,7 @@
65358490 }
65368491
65378492 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
6538
- if (!new File(cachename).exists())
8493
+ if (!FileExists(cachename))
65398494 cachename = texname;
65408495 else
65418496 processbump = false; // don't process bump map again
....@@ -6557,7 +8512,7 @@
65578512 }
65588513
65598514 cachename = texname.substring(0, texname.length()-4)+ext+".png";
6560
- if (!new File(cachename).exists())
8515
+ if (!FileExists(cachename))
65618516 cachename = texname;
65628517 else
65638518 processbump = false; // don't process bump map again
....@@ -6566,20 +8521,23 @@
65668521 texturedata = GetFileTexture(cachename, processbump, resolution);
65678522
65688523
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);
65718528 //texture = GetTexture(tex, bump);
65728529 }
8530
+ }
65738531 }
65748532 //}
65758533 }
65768534
6577
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8535
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
65788536 {
65798537 //return false;
65808538
65818539 // 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"))
65838541 {
65848542 // String ext = "_highres";
65858543 // if (REDUCETEXTURE)
....@@ -6596,52 +8554,17 @@
65968554 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
65978555 if (!cachefile.exists())
65988556 {
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())
66088558 {
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
+
66398561 ImageWriter writer = null;
66408562 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
66418563 if (iter.hasNext()) {
66428564 writer = (ImageWriter)iter.next();
66438565 }
6644
- float compressionQuality = 0.9f;
8566
+
8567
+ float compressionQuality = 0.85f;
66458568 try
66468569 {
66478570 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -6658,18 +8581,20 @@
66588581 }
66598582 }
66608583 }
6661
-
8584
+
8585
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8586
+
66628587 //System.out.println("Texture = " + tex);
6663
- if (textures.containsKey(texname))
8588
+ if (textures.containsKey(tex))
66648589 {
6665
- CacheTexture thetex = textures.get(texname);
8590
+ CacheTexture thetex = textures.get(tex);
66668591 thetex.texture.disable();
66678592 thetex.texture.dispose();
6668
- textures.remove(texname);
8593
+ textures.remove(tex);
66698594 }
66708595
6671
- texture.texturedata = texturedata;
6672
- textures.put(texname, texture);
8596
+ //texture.texturedata = texturedata;
8597
+ textures.put(tex, texturecache);
66738598
66748599 // newtex = true;
66758600 }
....@@ -6685,10 +8610,44 @@
66858610 }
66868611 }
66878612
6688
- return texture;
8613
+ return texturecache;
66898614 }
66908615
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
66928651 {
66938652 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
66948653
....@@ -6706,21 +8665,21 @@
67068665 return texture!=null?texture.texture:null;
67078666 }
67088667
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
67108669 {
67118670 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
67128671
67138672 return texture!=null?texture.texturedata:null;
67148673 }
67158674
6716
- boolean BindTexture(String tex, boolean bump, int resolution)
8675
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
67178676 {
67188677 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
67198678 {
67208679 return false;
67218680 }
67228681
6723
- boolean newtex = false;
8682
+ //boolean newtex = false;
67248683
67258684 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
67268685
....@@ -6752,9 +8711,75 @@
67528711 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
67538712 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
67548713
6755
- return newtex;
8714
+ return true; // Warning: not used.
67568715 }
67578716
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
+
67588783 ShadowBuffer shadowPBuf;
67598784 AntialiasBuffer antialiasPBuf;
67608785 int MAXSTACK;
....@@ -6771,10 +8796,12 @@
67718796
67728797 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
67738798 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);
67758801 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
67768802 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);
67788805
67798806 // Use debug pipeline
67808807 //drawable.setGL(new DebugGL(gl)); //
....@@ -6782,7 +8809,8 @@
67828809 gl = drawable.getGL(); //
67838810
67848811 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());
67868814
67878815
67888816 //float pos[] = { 100, 100, 100, 0 };
....@@ -6947,7 +8975,7 @@
69478975
69488976 if (cubemap == null)
69498977 {
6950
- LoadEnvy(5);
8978
+ //LoadEnvy(1);
69518979 }
69528980
69538981 //cubemap.enable();
....@@ -7223,6 +9251,8 @@
72239251
72249252 void LoadEnvy(int which)
72259253 {
9254
+ assert(false);
9255
+
72269256 String name;
72279257 String ext;
72289258
....@@ -7234,37 +9264,58 @@
72349264 cubemap = null;
72359265 return;
72369266 case 1:
7237
- name = "cubemaps/box_";
7238
- ext = "png";
9267
+ name = "cubemaps/rgb/";
9268
+ ext = "jpg";
72399269 reverseUP = false;
72409270 break;
72419271 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;
72459276 case 3:
7246
- name = "cubemaps/CloudyHills_";
7247
- ext = "tga";
9277
+ name = "cubemaps/CloudyHills/";
9278
+ ext = "jpg";
72489279 reverseUP = false;
72499280 break;
72509281 case 4:
7251
- name = "cubemaps/cornell_";
9282
+ name = "cubemaps/cornell/";
72529283 ext = "png";
72539284 reverseUP = false;
72549285 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;
72559311 default:
7256
- name = "cubemaps/rgb_";
7257
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9312
+ name = "cubemaps/box/";
9313
+ ext = "png"; /*mipmap = true;*/
9314
+ reverseUP = false;
72589315 break;
72599316 }
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);
72689319 }
72699320
72709321 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -7296,8 +9347,12 @@
72969347 static double[] model = new double[16];
72979348 double[] camera2light = new double[16];
72989349 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
+
73019356 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
73029357 //float[] light0 = { 0,0,0 };
73039358 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -7310,9 +9365,9 @@
73109365 static boolean occlusionInitialized = false;
73119366 boolean selection = false;
73129367 boolean pointselection = false;
7313
- /*static*/ boolean lighttouched = true;
9368
+ ///*static*/ boolean lighttouched = true;
73149369 boolean deselect;
7315
- boolean ambientOcclusion = false;
9370
+ private boolean ambientOcclusion = false;
73169371 static boolean flash = false;
73179372 /*static*/ boolean wait = false;
73189373 boolean displaydone = false; // after repaint() calls
....@@ -7442,6 +9497,8 @@
74429497 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
74439498 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
74449499 double scale = lightCamera.SCALE / lightCamera.Distance();
9500
+// PATCH FILLE AUX JEANS
9501
+ //scale *= lightCamera.shaper_fovy / 25;
74459502 gl.glScaled(2 * scale, 2 * scale, -scale);
74469503 gl.glTranslated(0, 0, lightCamera.DECAL);
74479504
....@@ -7588,17 +9645,40 @@
75889645 jy8[3] = 0.5f;
75899646 }
75909647
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
75929649 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
75949652
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
+
75959677 static int imagecount = 0; // movie generation
75969678
75979679 static int jitter = 0;
75989680
75999681 boolean restartframe = false;
7600
-
7601
- static int framecount = 0; // general-purpose global count
76029682
76039683 void displayAntiAliased(javax.media.opengl.GL gl)
76049684 {
....@@ -7630,7 +9710,7 @@
76309710 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
76319711 for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76329712 {
7633
- framecount++;
9713
+ Globals.framecount++;
76349714
76359715 if (CameraPane.tickcount > 0)
76369716 CameraPane.tickcount--;
....@@ -7668,7 +9748,7 @@
76689748
76699749 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76709750 */
7671
- lighttouched = true;
9751
+ Globals.lighttouched = true;
76729752 //System.err.println(" shadowbuffer: " + jitter);
76739753 shadowbuffer.display();
76749754
....@@ -7689,8 +9769,8 @@
76899769 assert (parentcam != renderCamera);
76909770
76919771 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);
76949774
76959775 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
76969776
....@@ -7705,8 +9785,8 @@
77059785 LA.matCopy(renderCamera.fromScreen, matrix);
77069786
77079787 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);
77109790
77119791 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
77129792
....@@ -7752,10 +9832,12 @@
77529832 rati = 1 / rati;
77539833 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
77549834 }
7755
- assert (newenvy == -1);
9835
+
9836
+ //assert (newenvy == -1);
9837
+
77569838 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
77579839 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
7758
- DrawSkyBox(gl);
9840
+ DrawSkyBox(gl, (float)rati);
77599841 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
77609842 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
77619843 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -7778,7 +9860,7 @@
77789860 //gl.glFlush();
77799861 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
77809862
7781
- if (ANIMATION && ABORTED)
9863
+ if (Globals.ANIMATION && ABORTED)
77829864 {
77839865 System.err.println(" ABORTED FRAME");
77849866 break;
....@@ -7808,7 +9890,7 @@
78089890 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
78099891
78109892 // save image
7811
- if (ANIMATION && !ABORTED)
9893
+ if (Globals.ANIMATION && !ABORTED)
78129894 {
78139895 VPwidth = viewport[2];
78149896 VPheight = viewport[3];
....@@ -7919,11 +10001,11 @@
791910001
792010002 // imagecount++;
792110003
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;
792310005
792410006 if (!BOXMODE)
792510007 {
7926
- System.out.println("image: " + fullname + " (" + (GrafreeD.wav.cursor / 735 / 4) + ")");
10008
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
792710009 }
792810010
792910011 if (!BOXMODE)
....@@ -7961,7 +10043,7 @@
796110043 ABORTED = false;
796210044 }
796310045 else
7964
- GrafreeD.wav.cursor += 735 * ACSIZE;
10046
+ Grafreed.wav.cursor += 735 * ACSIZE;
796510047
796610048 if (false)
796710049 {
....@@ -8615,32 +10697,34 @@
861510697 }
861610698 }
861710699
8618
- boolean IsFrozen()
8619
- {
8620
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8621
-
8622
- return !selectmode && cameracount == 0; // != 0;
8623
- }
8624
-
862510700 boolean niceon = false;
862610701 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
862710702 boolean currentlydrawing = false;
862810703 static boolean init = false;
862910704
863010705 double[][] matrix = LA.newMatrix();
10706
+
10707
+ // This is to refresh the UI of the material panel.
10708
+ ObjEditor patchMaterial;
863110709
863210710 public void display(GLAutoDrawable drawable)
863310711 {
8634
- if (GrafreeD.savesound && GrafreeD.hassound)
10712
+ if (patchMaterial.patchMaterial)
863510713 {
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;
863910723 }
864010724 // if (DEBUG_SELECTION)
864110725 // {
8642
-// if (drawMode != SELECTION)
8643
-// drawMode = SELECTION;
10726
+// if (DrawMode() != SELECTION)
10727
+// DrawMode() = SELECTION;
864410728 // }
864510729
864610730 if (!isRenderer)
....@@ -8696,9 +10780,9 @@
869610780
869710781 //ANTIALIAS = 0;
869810782
8699
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
10783
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
870010784 {
8701
- if (niceon || isLIVE())
10785
+ if (niceon || Globals.isLIVE())
870210786 {
870310787 //if(active == 0)
870410788 // antialiaser = null;
....@@ -8711,6 +10795,7 @@
871110795 ANTIALIAS = 0;
871210796 //System.out.println("RESTART");
871310797 AAtimer.restart();
10798
+ Globals.TIMERRUNNING = true;
871410799 }
871510800 }
871610801 }
....@@ -8723,7 +10808,7 @@
872310808 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
872410809 */
872510810
8726
- if (drawMode == DEFAULT)
10811
+ if (DrawMode() == DEFAULT)
872710812 {
872810813 currentlydrawing = true;
872910814 }
....@@ -8754,18 +10839,18 @@
875410839
875510840 // if(Applet3D.clipboard != null)
875610841 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8757
-//drawMode = SELECTION;
10842
+//DrawMode() = SELECTION;
875810843 indexcount = 0;
875910844
8760
- if (drawMode == OCCLUSION)
10845
+ if (DrawMode() == OCCLUSION)
876110846 {
8762
- drawMode = DEFAULT;
10847
+ Globals.drawMode = DEFAULT; // WARNING
876310848 ambientOcclusion = true;
876410849 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
876510850 Object3D theobject = object;
876610851 Object3D theparent = object.parent;
876710852 object.parent = null;
8768
- object = (Object3D)GrafreeD.clone(object);
10853
+ object = (Object3D)Grafreed.clone(object);
876910854 object.Stripify();
877010855 if (theobject.selection == null || theobject.selection.Size() == 0)
877110856 theobject.PreprocessOcclusion(this);
....@@ -8778,26 +10863,27 @@
877810863 ambientOcclusion = false;
877910864 }
878010865
8781
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
10866
+ if (//Globals.lighttouched &&
10867
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
878210868 {
878310869 //if (RENDERSHADOW) // ?
878410870 if (!IsFrozen())
878510871 {
878610872 // dec 2012
8787
- if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
10873
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
878810874 {
8789
- framecount++;
10875
+ Globals.framecount++;
879010876 shadowbuffer.display();
879110877 }
879210878 }
8793
- lighttouched = false; // ??
10879
+ Globals.lighttouched = false; // ??
879410880 //drawing = true;
879510881 //lighttouched = true;
879610882 }
879710883
879810884 if (wait)
879910885 {
8800
- Sleep(500);
10886
+ Sleep(200); // blocks everything
880110887
880210888 wait = false;
880310889 }
....@@ -8811,9 +10897,9 @@
881110897 //eyeCamera.shaper_fovy = 1;
881210898 }
881310899
8814
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
10900
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
881510901 {
8816
- //System.out.println("drawMode = " + drawMode);
10902
+ //System.out.println("DrawMode() = " + DrawMode());
881710903 vertexMode |= VP_PASS;
881810904 //vertexMode |= VP_PROJECTION;
881910905 if (!ambientOcclusion)
....@@ -8873,7 +10959,7 @@
887310959 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
887410960 //Camera lightcam = new Camera(light0);
887510961
8876
- if (drawMode == SHADOW)
10962
+ if (DrawMode() == SHADOW)
887710963 {
887810964 /*
887910965 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8911,8 +10997,8 @@
891110997
891210998 // if (parentcam != renderCamera) // not a light
891310999 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);
891611002
891711003 for (int j = 0; j < 4; j++)
891811004 {
....@@ -8926,8 +11012,8 @@
892611012
892711013 // if (parentcam != renderCamera) // not a light
892811014 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);
893111017
893211018 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
893311019
....@@ -8963,7 +11049,7 @@
896311049 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
896411050 } else
896511051 {
8966
- if (drawMode != DEFAULT)
11052
+ if (DrawMode() != DEFAULT)
896711053 {
896811054 gl.glClearColor(1, 1, 1, 0);
896911055 } // 1);
....@@ -9013,13 +11099,43 @@
901311099 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
901411100 }
901511101
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"))
901711110 {
9018
- LoadEnvy(newenvy);
11111
+ if (cubemaprgb == null)
11112
+ {
11113
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
11114
+ }
11115
+
11116
+ cubemap = cubemaprgb;
901911117 }
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
+
902311139 ratio = ((double) getWidth()) / getHeight();
902411140 //System.out.println("ratio = " + ratio);
902511141
....@@ -9028,14 +11144,14 @@
902811144
902911145 fast &= !ambientOcclusion;
903011146
9031
- if (drawMode == DEFAULT)
11147
+ if (DrawMode() == DEFAULT)
903211148 {
903311149 //gl.glEnable(gl.GL_ALPHA_TEST);
903411150 //gl.glActiveTexture(GL.GL_TEXTURE0);
903511151
903611152 if (!IsFrozen() && !ambientOcclusion)
903711153 {
9038
- DrawSkyBox(gl);
11154
+ DrawSkyBox(gl, (float)ratio);
903911155 }
904011156
904111157 //if (selection_view == -1)
....@@ -9089,6 +11205,8 @@
908911205 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
909011206 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
909111207 double scale = lightCamera.SCALE / lightCamera.Distance();
11208
+// PATCH FILLE AUX JEANS
11209
+ //scale *= lightCamera.shaper_fovy / 25;
909211210 gl.glScaled(2 * scale, 2 * scale, -scale);
909311211 gl.glTranslated(0, 0, lightCamera.DECAL);
909411212
....@@ -9184,7 +11302,16 @@
918411302 // Bump noise
918511303 gl.glActiveTexture(GL.GL_TEXTURE6);
918611304 //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
+
918811315
918911316 gl.glActiveTexture(GL.GL_TEXTURE0);
919011317 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -9207,9 +11334,9 @@
920711334
920811335 gl.glMatrixMode(GL.GL_MODELVIEW);
920911336
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);
921311340 } else
921411341 {
921511342 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -9220,14 +11347,16 @@
922011347 //System.out.println("BLENDING ON");
922111348 gl.glEnable(GL.GL_BLEND);
922211349 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
9223
-
11350
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
922411351 gl.glMatrixMode(gl.GL_PROJECTION);
922511352 gl.glLoadIdentity();
922611353
9227
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
11354
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
922811355 {
922911356 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
923011357 double scale = lightCamera.SCALE / lightCamera.Distance();
11358
+// PATCH FILLE AUX JEANS
11359
+ //scale *= lightCamera.shaper_fovy / 25;
923111360 gl.glScaled(2 * scale, 2 * scale, -scale);
923211361 gl.glTranslated(0, 0, lightCamera.DECAL);
923311362 //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE);
....@@ -9280,7 +11409,7 @@
928011409 //gl.glPushMatrix();
928111410 gl.glLoadIdentity();
928211411
9283
- if (!ambientOcclusion) // drawMode != OCCLUSION)
11412
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
928411413 {
928511414 //LA.xformPos(light0, lightCamera.fromScreen, light);
928611415 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9307,8 +11436,8 @@
930711436 System.err.println("parentcam != renderCamera");
930811437
930911438 // 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
931211441 }
931311442
931411443 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -9329,8 +11458,8 @@
932911458 if (true) // TODO
933011459 {
933111460 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
933411463 }
933511464
933611465 LA.xformPos(light0, cam.toScreen, light0);
....@@ -9367,7 +11496,7 @@
936711496 }
936811497
936911498 /**/
9370
- if (true) // drawMode == SELECTION) // != DEFAULT)
11499
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
937111500 gl.glDisable(gl.GL_LIGHTING);
937211501 else
937311502 gl.glEnable(gl.GL_LIGHTING);
....@@ -9379,12 +11508,13 @@
937911508
938011509 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0);
938111510 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0);
11511
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0);
938211512
938311513 options2[0] *= renderCamera.Distance();
938411514
938511515 lightslot = 64;
938611516
9387
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
11517
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
938811518 {
938911519 DrawLights(object);
939011520 }
....@@ -9395,7 +11525,7 @@
939511525 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
939611526 //System.out.println("fragmentMode = " + fragmentMode);
939711527
9398
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
11528
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
939911529 {
940011530 /*
940111531 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9428,7 +11558,7 @@
942811558 }
942911559 }
943011560
9431
- if (drawMode == DEFAULT)
11561
+ if (DrawMode() == DEFAULT)
943211562 {
943311563 if (WIREFRAME && !ambientOcclusion)
943411564 {
....@@ -9446,7 +11576,7 @@
944611576 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
944711577 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
944811578
9449
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
11579
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
945011580 {
945111581 if (vertexMode != 0) // && !fast)
945211582 {
....@@ -9466,7 +11596,7 @@
946611596 }
946711597 }
946811598
9469
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
11599
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
947011600 {
947111601 //gl.glDepthFunc(GL.GL_LEQUAL);
947211602 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9474,27 +11604,24 @@
947411604
947511605 boolean texon = textureon;
947611606
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
+
948211610 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
948311611 //System.out.println("ALLO");
948411612 gl.glColorMask(false, false, false, false);
948511613 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
+
949111618 gl.glColorMask(true, true, true, true);
949211619
949311620 gl.glDepthFunc(GL.GL_EQUAL);
9494
- //gl.glDepthMask(false);
11621
+ gl.glDepthMask(false);
949511622 }
949611623
9497
- if (false) // drawMode == SHADOW)
11624
+ if (false) // DrawMode() == SHADOW)
949811625 {
949911626 //SetColumnMajorData(cameraInverseTransform, view_1);
950011627 //System.out.println("light = " + cameraInverseTransform);
....@@ -9508,16 +11635,16 @@
950811635 //System.out.println("object = " + object);
950911636 if (!frozen && !imageLocked)
951011637 {
9511
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
11638
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
951211639 {
951311640 displayAntiAliased(gl);
951411641 } else
951511642 {
951611643 programcount = 0;
9517
- int keepmode = drawMode;
11644
+ int keepmode = DrawMode();
951811645 // if (DEBUG_SELECTION)
951911646 // {
9520
-// drawMode = SELECTION;
11647
+// DrawMode() = SELECTION;
952111648 // }
952211649 // for point selection
952311650 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9527,10 +11654,10 @@
952711654 DrawObject(gl);
952811655
952911656 // jan 2013 System.err.println("RESET ABORT (display)");
9530
- // if (drawMode == DEFAULT)
11657
+ // if (DrawMode() == DEFAULT)
953111658 // ABORTED = false;
953211659 fullreset = false;
9533
- drawMode = keepmode;
11660
+ Globals.drawMode = keepmode; // WARNING
953411661 //System.out.println("PROGRAM SWITCH " + programcount);
953511662 }
953611663 }
....@@ -9538,11 +11665,11 @@
953811665 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
953911666 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
954011667
9541
- if (drawMode == DEFAULT)
11668
+ if (DrawMode() == DEFAULT)
954211669 {
954311670 ReleaseTexture(NOISE_TEXTURE, false);
954411671 }
9545
- //if (drawMode == DEFAULT)
11672
+ //if (DrawMode() == DEFAULT)
954611673 {
954711674
954811675 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9554,7 +11681,7 @@
955411681 //else
955511682 //gl.glDisable(gl.GL_TEXTURE_2D);
955611683 //gl.glPopMatrix();
9557
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
11684
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
955811685 {
955911686 //new Exception().printStackTrace();
956011687 //System.out.println("Draw image " + width + ", " + height);
....@@ -9596,7 +11723,7 @@
959611723 //gl.glFlush();
959711724 }
959811725
9599
- if (flash && drawMode == DEFAULT)
11726
+ if (flash && DrawMode() == DEFAULT)
960011727 {
960111728 flash = false;
960211729 wait = true;
....@@ -9604,9 +11731,9 @@
960411731 }
960511732
960611733 //drawing = false;
9607
- //if(drawMode == DEFAULT)
11734
+ //if(DrawMode() == DEFAULT)
960811735 // niceon = false;
9609
- if (drawMode == DEFAULT)
11736
+ if (DrawMode() == DEFAULT)
961011737 {
961111738 currentlydrawing = false;
961211739 }
....@@ -9626,7 +11753,7 @@
962611753 repaint();
962711754 }
962811755
9629
- if (isLIVE() && drawMode == DEFAULT) // may 2013
11756
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
963011757 repaint();
963111758
963211759 displaydone = true;
....@@ -9645,8 +11772,14 @@
964511772 {
964611773 renderpass++;
964711774 // System.out.println("Draw object... ");
11775
+ STEP = 1;
964811776 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
+ }
965011783
965111784 //object.FullInvariants();
965211785
....@@ -9660,23 +11793,44 @@
966011793 e.printStackTrace();
966111794 }
966211795
9663
- if (GrafreeD.RENDERME > 0)
9664
- GrafreeD.RENDERME--; // mechante magouille
11796
+ if (Grafreed.RENDERME > 0)
11797
+ Grafreed.RENDERME--; // mechante magouille
966511798
9666
- ONESTEP = false;
11799
+ Globals.ONESTEP = false;
966711800 }
966811801
966911802 static boolean zoomonce = false;
967011803
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
+
967111822 void DrawObject(GL gl, boolean draw)
967211823 {
11824
+ // To clear camera values
11825
+ ResetOptions();
11826
+
967311827 //System.out.println("DRAW OBJECT " + mouseDown);
9674
-// drawMode = SELECTION;
11828
+// DrawMode() = SELECTION;
967511829 //GL gl = getGL();
967611830 if ((TRACK || SHADOWTRACK) || zoomonce)
967711831 {
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);
968011834 pingthread.StepToTarget(true); // true);
968111835 // zoomonce = false;
968211836 }
....@@ -9696,9 +11850,9 @@
969611850 callist = gl.glGenLists(1);
969711851 }
969811852
9699
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
11853
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
970011854
9701
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
11855
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
970211856
970311857 if (!mainDL || !active || touched)
970411858 {
....@@ -9725,13 +11879,20 @@
972511879 PushMatrix(ClickInfo.matbuffer);
972611880 }
972711881
9728
- if (drawMode == 0)
11882
+ if (DrawMode() == 0)
972911883 {
973011884 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
973111885
973211886 usedtextures.clear();
973311887
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
+ }
973511896 }
973611897 //System.out.println("--> " + stackdepth);
973711898 // GrafreeD.traceon();
....@@ -9739,10 +11900,11 @@
973911900 // DRAW
974011901 object.draw(this, /*(Composite)*/ object, false, false);
974111902
9742
- if (drawMode == DEFAULT)
11903
+ if (DrawMode() == DEFAULT)
974311904 {
9744
- if (DEBUG)
11905
+ if (Globals.DEBUG)
974511906 {
11907
+ CreateSelectedPoint();
974611908 float radius = 0.05f;
974711909 if (selectedpoint.radius != radius)
974811910 {
....@@ -9750,40 +11912,40 @@
975011912 selectedpoint.radius = radius;
975111913 selectedpoint.recalculate();
975211914 selectedpoint.material = new cMaterial();
9753
- selectedpoint.material.color = 0.25f;
11915
+ selectedpoint.material.color = 0.15f; // Yellow
975411916 selectedpoint.material.modulation = 0.75f;
975511917
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;
976111923
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;
976711929
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;
977311935
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;
977911941
978011942 InitPoints(radius);
978111943 }
978211944 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);
978711949 // DrawPoints(this);
978811950 }
978911951
....@@ -9791,42 +11953,63 @@
979111953 }
979211954 // GrafreeD.traceoff();
979311955 //System.out.println(stackdepth);
9794
- if (drawMode == 0)
11956
+ if (DrawMode() == 0)
979511957 {
979611958 ReleaseTextures(DEFAULT_TEXTURES);
979711959
979811960 if (CLEANCACHE)
9799
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11961
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
980011962 {
9801
- String tex = e.nextElement();
11963
+ cTexture tex = e.nextElement();
980211964
980311965 // System.out.println("Texture --------- " + tex);
980411966
9805
- if (tex.equals("WHITE_NOISE"))
11967
+ if (tex.equals("WHITE_NOISE:"))
980611968 continue;
980711969
9808
- if (!usedtextures.containsKey(tex))
11970
+ if (!usedtextures.contains(tex))
980911971 {
11972
+ CacheTexture gettex = texturepigment.get(tex);
981011973 // 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
+ }
981311987 }
981411988 }
981511989 }
981611990
981711991 checker = null;
981811992
9819
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
11993
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
982011994 FindChecker(object);
982111995
9822
- if (checker != null && drawMode == DEFAULT)
11996
+ if (checker != null && DrawMode() == DEFAULT)
982311997 {
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
+ }
982512007 // NEAREST
982612008 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
982712009 DrawChecker(gl);
982812010 //checker.Draw(this, null, false);
982912011 // ReleaseTexture(IMMORTAL_TEXTURE);
12012
+ ReleaseTextures(checker.GetTextures());
983012013 }
983112014
983212015 if (object.parent != null)
....@@ -9839,7 +12022,7 @@
983912022 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
984012023 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
984112024
9842
- if (DISPLAYTEXT && drawMode == DEFAULT)
12025
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
984312026 {
984412027 // Draw it once, then use the raster
984512028 Balloon(gl, balloon.createGraphics());
....@@ -9895,14 +12078,14 @@
989512078 int[] xs = new int[3];
989612079 int[] ys = new int[3];
989712080
9898
- void DrawString(Object3D obj) // String string)
12081
+ public void DrawString(Object3D obj) // String string) // INTERFACE
989912082 {
9900
- if (!DISPLAYTEXT || drawMode != DEFAULT)
12083
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
990112084 {
990212085 return;
990312086 }
990412087
9905
- String string = obj.GetToolTip();
12088
+ String string = obj.toString(); //.GetToolTip();
990612089
990712090 GL gl = GetGL();
990812091
....@@ -10219,8 +12402,8 @@
1021912402 //obj.TransformToWorld(light, light);
1022012403 for (int i = tp.size(); --i >= 0;)
1022112404 {
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);
1022412407 }
1022512408
1022612409
....@@ -10237,8 +12420,8 @@
1023712420 parentcam = cameras[0];
1023812421 }
1023912422
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
1024212425
1024312426 LA.xformPos(light, renderCamera.toScreen, light);
1024412427
....@@ -10328,8 +12511,76 @@
1032812511
1032912512 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1033012513
10331
- String program =
12514
+ String programmin =
12515
+ // Min shader
1033212516 "!!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
+
1033312584 //"OPTION ARB_fragment_program_shadow;" +
1033412585 "PARAM light2cam0 = program.env[10];" +
1033512586 "PARAM light2cam1 = program.env[11];" +
....@@ -10355,13 +12606,15 @@
1035512606 "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow
1035612607 "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias
1035712608 "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
1035912610 "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
1036112613 "PARAM pointlight = program.env[127];" + // ...
1036212614 "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" +
1036312615 "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" +
1036412616 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
12617
+ "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" +
1036512618 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1036612619 "PARAM ten = { 10, 10, 10, 1.0 };" +
1036712620 "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" +
....@@ -10382,6 +12635,7 @@
1038212635 "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" +
1038312636 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
1038412637 "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" +
12638
+ "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" +
1038512639 "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" +
1038612640 "PARAM c256 = { 256, 256, 256, 1.0 };" +
1038712641 "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" +
....@@ -10422,6 +12676,10 @@
1042212676 "TEMP R1;" +
1042312677 "TEMP R2;" +
1042412678 "TEMP R3;" +
12679
+ "TEMP min;" +
12680
+ "TEMP max;" +
12681
+ "TEMP average;" +
12682
+ "TEMP saturation;" +
1042512683 "TEMP keep1;" +
1042612684 "TEMP keep2;" +
1042712685 "TEMP keep3;" +
....@@ -10437,8 +12695,7 @@
1043712695 "TEMP shininess;" +
1043812696 "\n" +
1043912697 "MOV texSamp, one;" +
10440
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
10441
-
12698
+
1044212699 "MOV mapgrid.x, one2048th.x;" +
1044312700 "MOV temp, fragment.texcoord[1];" +
1044412701 /*
....@@ -10459,20 +12716,20 @@
1045912716 "MUL temp, floor, mapgrid.x;" +
1046012717 //"TEX depth0, temp, texture[1], 2D;" +
1046112718 (((mode & FP_SOFTSHADOW) == 0) ? "" :
10462
- TextureFetch("depth0", "temp", "1") +
12719
+ ShadowTextureFetch("depth0", "temp", "1") +
1046312720 "") +
1046412721 "ADD temp.x, temp.x, mapgrid.x;" +
1046512722 //"TEX depth1, temp, texture[1], 2D;" +
1046612723 (((mode & FP_SOFTSHADOW) == 0) ? "" :
10467
- TextureFetch("depth1", "temp", "1") +
12724
+ ShadowTextureFetch("depth1", "temp", "1") +
1046812725 "") +
1046912726 "ADD temp.y, temp.y, mapgrid.x;" +
1047012727 //"TEX depth2, temp, texture[1], 2D;" +
10471
- TextureFetch("depth2", "temp", "1") +
12728
+ ShadowTextureFetch("depth2", "temp", "1") +
1047212729 "SUB temp.x, temp.x, mapgrid.x;" +
1047312730 //"TEX depth3, temp, texture[1], 2D;" +
1047412731 (((mode & FP_SOFTSHADOW) == 0) ? "" :
10475
- TextureFetch("depth3", "temp", "1") +
12732
+ ShadowTextureFetch("depth3", "temp", "1") +
1047612733 "") +
1047712734 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1047812735 //"MOV params, material;" +
....@@ -10594,7 +12851,7 @@
1059412851 "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut
1059512852 // mar 2013 ??? "KIL alpha.a;" +
1059612853 "MOV alpha, texSamp.aaaa;" + // y;" +
10597
- "KIL alpha.a;" +
12854
+ "KIL alpha.a;" + // not sure with parallax mapping
1059812855 /*
1059912856 "MUL temp.xy, temp, two;" +
1060012857 "TXB bump, temp, texture[0], 2D;" +
....@@ -10680,11 +12937,6 @@
1068012937 "SUB bump0, bump0, half;" +
1068112938 "ADD bump, bump, bump0;" +
1068212939
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
-
1068812940 // double-sided
1068912941 /**/
1069012942 (doublesided?"DP3 temp.z, normal, eye;" +
....@@ -10701,19 +12953,62 @@
1070112953 "MOV normald, normal;" +
1070212954 "MOV normals, normal;" +
1070312955
12956
+ "MOV temp, fragment.texcoord[4];" +
12957
+
1070412958 // UV base
1070512959 //"DP3 UP.x,state.matrix.modelview.row[0],Y;" +
1070612960 //"DP3 UP.y,state.matrix.modelview.row[1],Y;" +
1070712961 //"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
+
1071112967 "XPD V, normal, UP;" +
1071212968 Normalize("V") +
1071312969 "XPD U, V, normal;" +
1071412970 Normalize("U") +
1071512971
1071612972 // 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;" +
1071713012
1071813013 //"MOV temp, fragment.texcoord[0];" +
1071913014 //
....@@ -10843,10 +13138,10 @@
1084313138 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1084413139 "") +
1084513140
10846
- // display shadow only (bump == 0)
13141
+ // display shadow only (fakedepth == 0)
1084713142 "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;" +
1085013145 "SUB temp.y, one.x, temp.z;" +
1085113146 "MUL temp.x, temp.x, temp.y;" +
1085213147 "KIL temp.x;" +
....@@ -10952,10 +13247,42 @@
1095213247
1095313248 // skin?
1095413249 // 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;" +
1095713283 "MUL R2, one3rd.xxxx,temp.xxxx;" +
10958
- "SUB temp, final,R2;" +
13284
+ "SUB temp, final, R2;" +
13285
+
1095913286 // using light angle
1096013287 "DP3 ndotl.x, normald,light;" +
1096113288 //"SLT ndotl.y, ndotl.x, zero.x;" +
....@@ -10968,7 +13295,6 @@
1096813295 // using light intensity
1096913296 "MOV ndotl.z, R2.x;" +
1097013297 "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning...
10971
-
1097213298 // june 2014
1097313299 "MAD R1.x, ndotl.z,slope.y,one.x;" +
1097413300 // "SUB ndotl.x, one.x, ndotl.x;" +
....@@ -10980,6 +13306,7 @@
1098013306 //"MUL R2.y, shadow.x,R2.y;" + // avril 2014
1098113307
1098213308 "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin)
13309
+/**/
1098313310
1098413311 // "ADD final, R2,temp;" +
1098513312 "MOV final, temp;"
....@@ -11069,7 +13396,7 @@
1106913396 /**/
1107013397 // HDR
1107113398 "MOV temp.z, final.a;" +
11072
- "MUL final, final,options1.w;" +
13399
+ "MUL final, final,options2.x;" +
1107313400 "MOV final.a, temp.z;" +
1107413401 /**/
1107513402
....@@ -11145,8 +13472,19 @@
1114513472 //once = true;
1114613473 }
1114713474
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
+
1115013488 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1115113489
1115213490 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -11193,7 +13531,8 @@
1119313531 "\n" +
1119413532 "END\n";
1119513533
11196
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13534
+ if (Globals.DEBUG)
13535
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1119713536 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1119813537
1119913538 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -11238,30 +13577,32 @@
1123813577 return out;
1123913578 }
1124013579
11241
- String TextureFetch(String dest, String src, String unit)
13580
+ // Also does frustum culling
13581
+ String ShadowTextureFetch(String dest, String src, String unit)
1124213582 {
1124313583 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1124413584 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1124513585 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13586
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13587
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1124613588 "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;" +
1125113591 //"SWZ buffer, temp, w,w,w,w;";
11252
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13592
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1125313593 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1125413594 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1125513595 //"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;";
1125713597
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;";
1126013600 }
1126113601
1126213602 String Shadow(String depth, String shadow)
1126313603 {
1126413604 return "MAX temp.x, ndotl.x, one64th.x;" +
13605
+ "MIN temp.x, temp.x, ninetenth.x;" +
1126513606 /**/
1126613607 // Sine
1126713608 "MUL temp.y, temp.x, temp.x;" +
....@@ -11277,12 +13618,16 @@
1127713618
1127813619 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1127913620 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13621
+
13622
+ // Compare fragment depth in light space with shadowmap.
1128013623 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1128113624 "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
1128313628 "SUB temp.x, one.x, temp.x;" +
1128413629 "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
1128613631 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1128713632
1128813633 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -11296,6 +13641,10 @@
1129613641 // No shadow for backface
1129713642 "DP3 temp.x, normal, lightd;" +
1129813643 "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;" +
1129913648 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1130013649 "";
1130113650 }
....@@ -11441,8 +13790,9 @@
1144113790 /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow
1144213791 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1144313792 /*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;
1144613796
1144713797 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1144813798 // OUT : diff, spec
....@@ -11458,9 +13808,10 @@
1145813808 "DP3 " + dest + ".z," + "normals," + "eye;" +
1145913809 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1146013810 //"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
1146413815 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1146513816 "RCP " + dest + ".w," + dest + ".w;" +
1146613817 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -11606,7 +13957,7 @@
1160613957 "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" +
1160713958 "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" +
1160813959 "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 };" +
1161013961 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1161113962 "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" +
1161213963 //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" +
....@@ -11667,7 +14018,7 @@
1166714018 "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" +
1166814019 "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" +
1166914020 "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" +
11670
- //"MOV result.texcoord, vertex.texcoord;" +
14021
+ //"MOV result.texcoord, vertex.fogcoord;" +
1167114022 "MOV result.texcoord, temp;" +
1167214023 // border fade
1167314024 "MOV result.texcoord[3], vertex.texcoord;" +
....@@ -11714,7 +14065,9 @@
1171414065
1171514066 //"ADD temp.z, temp.z, one;" +
1171614067
11717
- "MOV result.color, temp;"
14068
+ "MOV result.texcoord[4], vertex.attrib[4];" + // U dir
14069
+
14070
+ "MOV result.color, temp;" // Normal
1171814071 : "MOV result.color, vertex.color;") +
1171914072 ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;"
1172014073 : "") +
....@@ -11854,7 +14207,7 @@
1185414207 public void mousePressed(MouseEvent e)
1185514208 {
1185614209 //System.out.println("mousePressed: " + e);
11857
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
14210
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1185814211 }
1185914212
1186014213 static long prevtime = 0;
....@@ -11881,14 +14234,16 @@
1188114234
1188214235 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1188314236
14237
+ if (BUTTONLESSWHEEL)
1188414238 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1188514239 {
1188614240 return;
1188714241 }
1188814242
14243
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1188914244
1189014245 // TIMER
11891
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR
14246
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1189214247 {
1189314248 keepboxmode = BOXMODE;
1189414249 keepsupport = SUPPORT;
....@@ -11928,8 +14283,8 @@
1192814283 // mode |= META;
1192914284 //}
1193014285
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);
1193314288 anchorX = ax;
1193414289 anchorY = ay;
1193514290 prevX = px;
....@@ -11963,6 +14318,7 @@
1196314318 else
1196414319 if (evt.getSource() == AAtimer)
1196514320 {
14321
+ Globals.TIMERRUNNING = false;
1196614322 if (mouseDown)
1196714323 {
1196814324 //new Exception().printStackTrace();
....@@ -11988,6 +14344,10 @@
1198814344 // LIVE = waslive;
1198914345 // wasliveok = true;
1199014346 // waslive = false;
14347
+
14348
+ // May 2019 Forget it:
14349
+ if (true)
14350
+ return;
1199114351
1199214352 // source == timer
1199314353 if (mouseDown)
....@@ -12017,8 +14377,8 @@
1201714377 // ObjEditor.tweenManager.update(1f / 60f);
1201814378
1201914379 // 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);
1202214382 pingthread.StepToTarget(true); // true);
1202314383 }
1202414384 // if (!LIVE)
....@@ -12027,12 +14387,13 @@
1202714387
1202814388 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1202914389
12030
- void clickStart(int x, int y, int modifiers)
14390
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1203114391 {
1203214392 if (!wasliveok)
1203314393 return;
1203414394
1203514395 AAtimer.restart(); //
14396
+ Globals.TIMERRUNNING = true;
1203614397
1203714398 // waslive = LIVE;
1203814399 // LIVE = false;
....@@ -12044,7 +14405,7 @@
1204414405 // touched = true; // main DL
1204514406 if (isRenderer)
1204614407 {
12047
- SetMouseMode(modifiers);
14408
+ SetMouseMode(modifiers, modifiersex);
1204814409 }
1204914410
1205014411 selectX = anchorX = x;
....@@ -12057,7 +14418,7 @@
1205714418 clicked = true;
1205814419 hold = false;
1205914420
12060
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14421
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1206114422 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1206214423 {
1206314424 // System.out.println("RESTART II " + modifiers);
....@@ -12082,14 +14443,15 @@
1208214443 drag = false;
1208314444 //System.out.println("Mouse DOWN");
1208414445 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);
1209314455 if (!editObj)
1209414456 {
1209514457 hasMarquee = true;
....@@ -12105,11 +14467,14 @@
1210514467
1210614468 public void mouseDragged(MouseEvent e)
1210714469 {
14470
+ Globals.MOUSEDRAGGED = true;
14471
+
14472
+ //System.out.println("mouseDragged: " + e);
1210814473 if (isRenderer)
1210914474 movingcamera = true;
14475
+
1211014476 //if (drawing)
1211114477 //return;
12112
- //System.out.println("mouseDragged: " + e);
1211314478 if ((e.getModifiersEx() & CTRL) != 0
1211414479 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1211514480 {
....@@ -12117,7 +14482,7 @@
1211714482 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1211814483 }
1211914484 else
12120
- drag(e.getX(), e.getY(), e.getModifiersEx());
14485
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1212114486
1212214487 //try { Thread.sleep(1); } catch (Exception ex) {}
1212314488 }
....@@ -12129,6 +14494,11 @@
1212914494 cVector tmp = new cVector();
1213014495 cVector tmp2 = new cVector();
1213114496 boolean isMoving;
14497
+
14498
+ public cVector TargetLookAt()
14499
+ {
14500
+ return targetLookAt;
14501
+ }
1213214502
1213314503 class PingThread extends Thread
1213414504 {
....@@ -12268,7 +14638,7 @@
1226814638 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1226914639 if (lightMode)
1227014640 {
12271
- lighttouched = true;
14641
+ Globals.lighttouched = true;
1227214642 }
1227314643
1227414644 if (OEILONCE && OEIL)
....@@ -12285,6 +14655,7 @@
1228514655
1228614656 public void run()
1228714657 {
14658
+ new Exception().printStackTrace();
1228814659 System.exit(0);
1228914660 for (;;)
1229014661 {
....@@ -12326,7 +14697,7 @@
1232614697 mouseDown = false;
1232714698 if (lightMode)
1232814699 {
12329
- lighttouched = true;
14700
+ Globals.lighttouched = true;
1233014701 }
1233114702 repaint();
1233214703 alreadypainted = true;
....@@ -12334,7 +14705,7 @@
1233414705 isMoving = false;
1233514706 } //??
1233614707
12337
- if (isLIVE() && !alreadypainted)
14708
+ if (Globals.isLIVE() && !alreadypainted)
1233814709 {
1233914710 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1234014711 repaint();
....@@ -12346,9 +14717,9 @@
1234614717 {
1234714718 if (lightMode)
1234814719 {
12349
- lighttouched = true;
14720
+ Globals.lighttouched = true;
1235014721 }
12351
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14722
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1235214723 }
1235314724 //else
1235414725 }
....@@ -12362,12 +14733,18 @@
1236214733 void GoDown(int mod)
1236314734 {
1236414735 MODIFIERS |= COMMAND;
12365
- /*
14736
+ boolean isVR = (mouseMode&VR)!=0;
14737
+ /**/
1236614738 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
+ }
1236814745 else
12369
- manipCamera.BackForth(0, -speed*delta, getWidth());
12370
- */
14746
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
14747
+ /**/
1237114748 if ((mod & SHIFT) == SHIFT)
1237214749 {
1237314750 mouseMode = mouseMode; // VR??
....@@ -12376,6 +14753,8 @@
1237614753 mouseMode |= BACKFORTH;
1237714754 }
1237814755
14756
+ targetLookAt.set(manipCamera.lookAt);
14757
+
1237914758 //prevX = X = anchorX;
1238014759 prevY = Y = anchorY - (int) (renderCamera.Distance());
1238114760 }
....@@ -12383,12 +14762,19 @@
1238314762 void GoUp(int mod)
1238414763 {
1238514764 MODIFIERS |= COMMAND;
12386
- /*
14765
+ /**/
14766
+ boolean isVR = (mouseMode&VR)!=0;
14767
+
1238714768 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
+ }
1238914775 else
12390
- manipCamera.BackForth(0, speed*delta, getWidth());
12391
- */
14776
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
14777
+ /**/
1239214778 if ((mod & SHIFT) == SHIFT)
1239314779 {
1239414780 mouseMode = mouseMode;
....@@ -12397,6 +14783,8 @@
1239714783 mouseMode |= BACKFORTH;
1239814784 }
1239914785
14786
+ targetLookAt.set(manipCamera.lookAt);
14787
+
1240014788 //prevX = X = anchorX;
1240114789 prevY = Y = anchorY + (int) (renderCamera.Distance());
1240214790 }
....@@ -12404,12 +14792,17 @@
1240414792 void GoLeft(int mod)
1240514793 {
1240614794 MODIFIERS |= COMMAND;
12407
- /*
14795
+ /**/
1240814796 if((mod&SHIFT) == SHIFT)
12409
- manipCamera.RotatePosition(speed, 0);
14797
+ manipCamera.Translate(speed*delta, 0, getWidth());
1241014798 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
+ /**/
1241314806 if ((mod & SHIFT) == SHIFT)
1241414807 {
1241514808 mouseMode = mouseMode;
....@@ -12418,6 +14811,8 @@
1241814811 mouseMode |= ROTATE;
1241914812 } // TRANSLATE;
1242014813
14814
+ targetLookAt.set(manipCamera.lookAt);
14815
+
1242114816 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1242214817 prevY = Y = anchorY;
1242314818 }
....@@ -12425,12 +14820,18 @@
1242514820 void GoRight(int mod)
1242614821 {
1242714822 MODIFIERS |= COMMAND;
12428
- /*
14823
+ /**/
1242914824 if((mod&SHIFT) == SHIFT)
12430
- manipCamera.RotatePosition(-speed, 0);
14825
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1243114826 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
+ /**/
1243414835 if ((mod & SHIFT) == SHIFT)
1243514836 {
1243614837 mouseMode = mouseMode;
....@@ -12439,6 +14840,8 @@
1243914840 mouseMode |= ROTATE;
1244014841 } // TRANSLATE;
1244114842
14843
+ targetLookAt.set(manipCamera.lookAt);
14844
+
1244214845 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1244314846 prevY = Y = anchorY;
1244414847 }
....@@ -12448,7 +14851,7 @@
1244814851 int X, Y;
1244914852 boolean SX, SY;
1245014853
12451
- void drag(int x, int y, int modifiers)
14854
+ void drag(int x, int y, int modifiers, int modifiersex)
1245214855 {
1245314856 if (IsFrozen())
1245414857 {
....@@ -12457,17 +14860,17 @@
1245714860
1245814861 drag = true; // NEW
1245914862
12460
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14863
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1246114864
1246214865 X = x;
1246314866 Y = y;
1246414867 // floating state for animation
12465
- MODIFIERS = modifiers;
12466
- modifiers &= ~1024;
14868
+ MODIFIERS = modifiersex;
14869
+ modifiersex &= ~1024;
1246714870 if (false) // modifiers != 0)
1246814871 {
1246914872 //new Exception().printStackTrace();
12470
- System.out.println("mouseDragged: " + modifiers);
14873
+ System.out.println("mouseDragged: " + modifiersex);
1247114874 System.out.println("SHIFT = " + SHIFT);
1247214875 System.out.println("CONTROL = " + COMMAND);
1247314876 System.out.println("META = " + META);
....@@ -12480,14 +14883,16 @@
1248014883 if (editObj)
1248114884 {
1248214885 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,
1248514888 (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);
1249114896 } else
1249214897 {
1249314898 if (x < startX)
....@@ -12589,6 +14994,7 @@
1258914994 {
1259014995 manipCamera.Translate(dx, dy, getWidth());
1259114996 }
14997
+ else
1259214998 if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0)
1259314999 {
1259415000 manipCamera.RotateInterest(dx, dy);
....@@ -12599,7 +15005,7 @@
1259915005
1260015006 if (manipCamera == lightCamera)
1260115007 {
12602
- lighttouched = true;
15008
+ Globals.lighttouched = true;
1260315009 }
1260415010 /*
1260515011 switch (mode)
....@@ -12635,23 +15041,27 @@
1263515041 }
1263615042 }
1263715043
15044
+// ClickInfo clickInfo = new ClickInfo();
15045
+
1263815046 public void mouseMoved(MouseEvent e)
1263915047 {
1264015048 //System.out.println("mouseMoved: " + e);
12641
-
1264215049 if (isRenderer)
1264315050 return;
1264415051
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;
1265215059 if (!isRenderer)
1265315060 {
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))
1265515065 {
1265615066 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1265715067 } else
....@@ -12663,7 +15073,11 @@
1266315073
1266415074 public void mouseReleased(MouseEvent e)
1266515075 {
15076
+ Globals.MOUSEDRAGGED = false;
15077
+
1266615078 movingcamera = false;
15079
+ X = 0; // getBounds().width/2;
15080
+ Y = 0; // getBounds().height/2;
1266715081 //System.out.println("mouseReleased: " + e);
1266815082 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1266915083 }
....@@ -12686,9 +15100,9 @@
1268615100 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1268715101 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1268815102
12689
- if (control || command || IsFrozen())
15103
+// No delay if (control || command || IsFrozen())
1269015104 timeout = true;
12691
- else
15105
+// ?? May 2019 else
1269215106 // timer.setDelay((modifiers & 128) != 0?0:350);
1269315107 mouseDown = false;
1269415108 if (!control && !command) // june 2013
....@@ -12798,7 +15212,7 @@
1279815212 System.out.println("keyReleased: " + e);
1279915213 }
1280015214
12801
- void SetMouseMode(int modifiers)
15215
+ void SetMouseMode(int modifiers, int modifiersex)
1280215216 {
1280315217 //System.out.println("SetMouseMode = " + modifiers);
1280415218 //modifiers &= ~1024;
....@@ -12810,24 +15224,27 @@
1281015224 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1281115225 // return;
1281215226 //System.out.println("SetMode = " + modifiers);
12813
- if ((modifiers & WHEEL) == WHEEL)
15227
+ if ((modifiersex & WHEEL) == WHEEL)
1281415228 {
1281515229 mouseMode |= ZOOM;
1281615230 }
12817
- if ((modifiers & META) == META)
15231
+
15232
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
15233
+ if (capsLocked) // || (modifiers & META) == META)
1281815234 {
1281915235 mouseMode |= VR; // BACKFORTH;
1282015236 }
12821
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
12822
- {
12823
- mouseMode |= SELECT; // BACKFORTH;
12824
- }
12825
- if ((modifiers & COMMAND) == COMMAND)
15237
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1282615238 {
1282715239 mouseMode |= SELECT;
1282815240 }
12829
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
15241
+ if ((modifiersex & COMMAND) == COMMAND)
1283015242 {
15243
+ mouseMode |= SELECT;
15244
+ }
15245
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
15246
+ {
15247
+ mouseMode &= ~VR;
1283115248 mouseMode |= TRANSLATE;
1283215249 }
1283315250 // if ((modifiers & SHIFT_META) == SHIFT_META)
....@@ -12854,10 +15271,10 @@
1285415271
1285515272 if (isRenderer) //
1285615273 {
12857
- SetMouseMode(modifiers);
15274
+ SetMouseMode(0, modifiers);
1285815275 }
1285915276
12860
- theRenderer.keyPressed(key);
15277
+ Globals.theRenderer.keyPressed(key);
1286115278 }
1286215279
1286315280 int kompactbit = 4; // power bit
....@@ -12869,7 +15286,7 @@
1286915286 float SATPOW = 1; // 2; // 0.5f;
1287015287 float BRIPOW = 1; // 0.5f; // 0.5f;
1287115288
12872
- void keyPressed(int key)
15289
+ public void keyPressed(int key)
1287315290 {
1287415291 if (key >= '0' && key <= '5')
1287515292 clampbit = (key-'0');
....@@ -12916,7 +15333,8 @@
1291615333 // break;
1291715334 case 'T':
1291815335 CACHETEXTURE ^= true;
12919
- textures.clear();
15336
+ texturepigment.clear();
15337
+ texturebump.clear();
1292015338 // repaint();
1292115339 break;
1292215340 case 'Y':
....@@ -12926,8 +15344,8 @@
1292615344 case 'K':
1292715345 KOMPACTTEXTURE ^= true;
1292815346 //textures.clear();
12929
- break;
12930
- case 'P': // Texture Projection macros
15347
+ // break;
15348
+ //case 'P': // Texture Projection macros
1293115349 // SAVETEXTURE ^= true;
1293215350 macromode = true;
1293315351 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -12984,7 +15402,7 @@
1298415402 case 'B':
1298515403 BRISMOOTH ^= true;
1298615404 SHADOWCULLFACE ^= true;
12987
- lighttouched = true;
15405
+ Globals.lighttouched = true;
1298815406 repaint();
1298915407 break;
1299015408 case 'b':
....@@ -13001,7 +15419,9 @@
1300115419 case 'E' : COMPACT ^= true;
1300215420 repaint();
1300315421 break;
13004
- case 'W' : DEBUGHSB ^= true;
15422
+ case 'W' : // Wide Window (fullscreen)
15423
+ //DEBUGHSB ^= true;
15424
+ ObjEditor.theFrame.ToggleFullScreen();
1300515425 repaint();
1300615426 break;
1300715427 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -13026,8 +15446,8 @@
1302615446 RevertCamera();
1302715447 repaint();
1302815448 break;
13029
- case 'L':
1303015449 case 'l':
15450
+ //case 'L':
1303115451 if (lightMode)
1303215452 {
1303315453 lightMode = false;
....@@ -13046,7 +15466,7 @@
1304615466 targetLookAt.set(manipCamera.lookAt);
1304715467 repaint();
1304815468 break;
13049
- case 'p':
15469
+ case 'P': // p':
1305015470 // c'est quoi ca au juste? spherical ^= true;
1305115471 Skinshader ^= true; programInitialized = false;
1305215472 repaint();
....@@ -13084,27 +15504,31 @@
1308415504 repaint();
1308515505 break;
1308615506 case 'O':
13087
- drawMode = OCCLUSION;
15507
+ Globals.drawMode = OCCLUSION; // WARNING
1308815508 repaint();
1308915509 break;
1309015510 case 'o':
1309115511 OCCLUSION_CULLING ^= true;
1309215512 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1309315513 break;
13094
- case '0': envyoff ^= true; repaint(); break;
15514
+ //case '0': envyoff ^= true; repaint(); break;
1309515515 case '1':
1309615516 case '2':
1309715517 case '3':
1309815518 case '4':
1309915519 case '5':
13100
- newenvy = Character.getNumericValue(key);
13101
- repaint();
13102
- break;
1310315520 case '6':
1310415521 case '7':
1310515522 case '8':
1310615523 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
+ }
1310815532 repaint();
1310915533 break;
1311015534 case '!':
....@@ -13170,12 +15594,12 @@
1317015594 case '_':
1317115595 kompactbit = 5;
1317215596 break;
13173
- case '+':
13174
- kompactbit = 6;
13175
- break;
15597
+// case '+':
15598
+// kompactbit = 6;
15599
+// break;
1317615600 case ' ':
1317715601 lightMode ^= true;
13178
- lighttouched = true;
15602
+ Globals.lighttouched = true;
1317915603 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1318015604 targetLookAt.set(manipCamera.lookAt);
1318115605 repaint();
....@@ -13184,14 +15608,15 @@
1318415608 case ESC:
1318515609 RENDERPROGRAM += 1;
1318615610 RENDERPROGRAM %= 3;
15611
+
1318715612 repaint();
1318815613 break;
1318915614 case 'Z':
13190
- RESIZETEXTURE ^= true;
13191
- break;
15615
+ //RESIZETEXTURE ^= true;
15616
+ //break;
1319215617 case 'z':
13193
- RENDERSHADOW ^= true;
13194
- lighttouched = true;
15618
+ Globals.RENDERSHADOW ^= true;
15619
+ Globals.lighttouched = true;
1319515620 repaint();
1319615621 break;
1319715622 //case UP:
....@@ -13217,13 +15642,15 @@
1321715642 FlipTransform();
1321815643 break;
1321915644 case ENTER:
13220
- object.editWindow.ScreenFit(); // Edit();
15645
+ // object.editWindow.ScreenFit(); // Edit();
15646
+ ToggleLive();
1322115647 break;
1322215648 case DELETE:
1322315649 ClearSelection();
1322415650 break;
13225
- /*
1322615651 case '+':
15652
+
15653
+ /*
1322715654 //fontsize += 1;
1322815655 bbzoom *= 2;
1322915656 repaint();
....@@ -13240,17 +15667,17 @@
1324015667 case '=':
1324115668 IncDepth();
1324215669 //fontsize += 1;
13243
- object.editWindow.refreshContents(true);
15670
+ object.GetWindow().refreshContents(true);
1324415671 maskbit = 6;
1324515672 break;
1324615673 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1324715674 DecDepth();
1324815675 maskbit = 5;
1324915676 //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);
1325415681 break;
1325515682 case '{':
1325615683 manipCamera.shaper_fovy /= 1.1;
....@@ -13305,6 +15732,7 @@
1330515732 }
1330615733 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1330715734 }
15735
+
1330815736 static double OCCLUSIONBOOST = 1; // 0.5;
1330915737
1331015738 void keyReleased(int key, int modifiers)
....@@ -13312,11 +15740,11 @@
1331215740 //mode = ROTATE;
1331315741 if ((MODIFIERS & COMMAND) == 0) // VR??
1331415742 {
13315
- SetMouseMode(modifiers);
15743
+ SetMouseMode(0, modifiers);
1331615744 }
1331715745 }
1331815746
13319
- protected void processKeyEvent(KeyEvent e)
15747
+ public void processKeyEvent(KeyEvent e)
1332015748 {
1332115749 switch (e.getID())
1332215750 {
....@@ -13446,8 +15874,9 @@
1344615874
1344715875 protected void processMouseMotionEvent(MouseEvent e)
1344815876 {
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)
1345115880 {
1345215881 mouseMoved(e);
1345315882 } else
....@@ -13472,11 +15901,12 @@
1347215901 }
1347315902 */
1347415903
13475
- object.editWindow.EditSelection();
15904
+ object.GetWindow().EditSelection(false);
1347615905 }
1347715906
1347815907 void SelectParent()
1347915908 {
15909
+ new Exception().printStackTrace();
1348015910 System.exit(0);
1348115911 Composite group = (Composite) object;
1348215912 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -13488,10 +15918,10 @@
1348815918 {
1348915919 //selectees.remove(i);
1349015920 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);
1349215922 } else
1349315923 {
13494
- group.editWindow.Select(elem.GetTreePath(), first, true);
15924
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1349515925 }
1349615926
1349715927 first = false;
....@@ -13500,6 +15930,7 @@
1350015930
1350115931 void SelectChildren()
1350215932 {
15933
+ new Exception().printStackTrace();
1350315934 System.exit(0);
1350415935 /*
1350515936 Composite group = (Composite) object;
....@@ -13532,12 +15963,12 @@
1353215963 for (int j = 0; j < group.children.size(); j++)
1353315964 {
1353415965 elem = (Object3D) group.children.elementAt(j);
13535
- object.editWindow.Select(elem.GetTreePath(), first, true);
15966
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1353615967 first = false;
1353715968 }
1353815969 } else
1353915970 {
13540
- object.editWindow.Select(elem.GetTreePath(), first, true);
15971
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1354115972 }
1354215973
1354315974 first = false;
....@@ -13548,21 +15979,21 @@
1354815979 {
1354915980 //Composite group = (Composite) object;
1355015981 Object3D group = object;
13551
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15982
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1355215983 }
1355315984
1355415985 void ResetTransform(int mask)
1355515986 {
1355615987 //Composite group = (Composite) object;
1355715988 Object3D group = object;
13558
- group.editWindow.ResetTransform(mask);
15989
+ group.GetWindow().ResetTransform(mask);
1355915990 }
1356015991
1356115992 void FlipTransform()
1356215993 {
1356315994 //Composite group = (Composite) object;
1356415995 Object3D group = object;
13565
- group.editWindow.FlipTransform();
15996
+ group.GetWindow().FlipTransform();
1356615997 // group.editWindow.ReduceMesh(true);
1356715998 }
1356815999
....@@ -13570,7 +16001,7 @@
1357016001 {
1357116002 //Composite group = (Composite) object;
1357216003 Object3D group = object;
13573
- group.editWindow.PrintMemory();
16004
+ group.GetWindow().PrintMemory();
1357416005 // group.editWindow.ReduceMesh(true);
1357516006 }
1357616007
....@@ -13578,7 +16009,7 @@
1357816009 {
1357916010 //Composite group = (Composite) object;
1358016011 Object3D group = object;
13581
- group.editWindow.ResetCentroid();
16012
+ group.GetWindow().ResetCentroid();
1358216013 }
1358316014
1358416015 void IncDepth()
....@@ -13660,11 +16091,11 @@
1366016091
1366116092 int width = getBounds().width;
1366216093 int height = getBounds().height;
13663
- ClickInfo info = new ClickInfo();
13664
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1366516094 //Image img = CreateImage(width, height);
1366616095 //System.out.println("width = " + width + "; height = " + height + "\n");
16096
+
1366716097 Graphics gr = g; // img.getGraphics();
16098
+
1366816099 if (!hasMarquee)
1366916100 {
1367016101 if (Xmin < Xmax) // !locked)
....@@ -13736,44 +16167,92 @@
1373616167 }
1373716168 if (object != null && !hasMarquee)
1373816169 {
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
+
1373916176 if (isRenderer)
1374016177 {
13741
- info.flags++;
16178
+ object.clickInfo.flags++;
1374216179 double frameAspect = (double) width / (double) height;
1374316180 if (frameAspect > renderCamera.aspect)
1374416181 {
1374516182 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;
1374816185 } else
1374916186 {
1375016187 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;
1375316190 }
1375416191 }
13755
- info.g = gr;
13756
- info.camera = renderCamera;
16192
+
16193
+ object.clickInfo.g = gr;
16194
+ object.clickInfo.camera = renderCamera;
1375716195 /*
1375816196 // Memory intensive (brep.verticescopy)
1375916197 if (!(object instanceof Composite))
1376016198 object.draw(info, 0, false); // SLOW :
1376116199 */
13762
- if (!isRenderer)
16200
+ if (!isRenderer) // && drag)
1376316201 {
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
+ }
1376516242 }
1376616243 }
16244
+
1376716245 if (isRenderer)
1376816246 {
1376916247 //gr.setColor(Color.black);
1377016248 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1377116249 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1377216250 }
16251
+
1377316252 if (hasMarquee)
1377416253 {
1377516254 gr.setXORMode(Color.white);
13776
- gr.setColor(Color.red);
16255
+ gr.setColor(Color.white);
1377716256 if (!firstime)
1377816257 {
1377916258 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -13792,6 +16271,7 @@
1379216271 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1379316272 }
1379416273
16274
+ // To avoid clear.
1379516275 public void update(Graphics g)
1379616276 {
1379716277 paint(g);
....@@ -13881,6 +16361,7 @@
1388116361 public boolean mouseDown(Event evt, int x, int y)
1388216362 {
1388316363 System.out.println("mouseDown: " + evt);
16364
+ System.exit(0);
1388416365 /*
1388516366 locked = true;
1388616367 drag = false;
....@@ -13924,7 +16405,7 @@
1392416405 {
1392516406 keyPressed(0, modifiers);
1392616407 }
13927
- clickStart(x, y, modifiers);
16408
+ // clickStart(x, y, modifiers);
1392816409 return true;
1392916410 }
1393016411
....@@ -14042,7 +16523,7 @@
1404216523 {
1404316524 keyReleased(0, 0);
1404416525 }
14045
- drag(x, y, modifiers);
16526
+ drag(x, y, 0, modifiers);
1404616527 return true;
1404716528 }
1404816529
....@@ -14174,7 +16655,7 @@
1417416655 Object3D object;
1417516656 static Object3D trackedobject;
1417616657 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
1417816659 /*static*/ Camera eyeCamera;
1417916660 /*static*/ Camera lightCamera;
1418016661 int cameracount;
....@@ -14238,6 +16719,8 @@
1423816719 private /*static*/ boolean firstime;
1423916720 private /*static*/ cVector newView = new cVector();
1424016721 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"};
1424116724 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1424216725 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1424316726 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -14250,29 +16733,67 @@
1425016733 {
1425116734 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1425216735
16736
+ int usedsuf = 0;
16737
+
1425316738 for (int i = 0; i < suffixes.length; i++)
1425416739 {
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;)
1426016745 {
14261
- throw new IOException("Unable to load texture " + resourceName);
16746
+// String[] temp = suffixe;
16747
+// suffixe = fallback;
16748
+// fallback = fallfallback;
16749
+// fallfallback = temp;
1426216750 }
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
+
1426316779 //System.out.println("Target = " + targets[i]);
1426416780 cubemap.updateImage(data, targets[i]);
1426516781 }
1426616782
1426716783 return cubemap;
1426816784 }
16785
+
1426916786 int bigsphere = -1;
1427016787
1427116788 float BGcolor = 0.5f;
1427216789
14273
- private void DrawSkyBox(GL gl)
16790
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16791
+
16792
+ private void DrawSkyBox(GL gl, float ratio)
1427416793 {
14275
- if (envyoff || cubemap == null)
16794
+ if (//envyoff ||
16795
+ WIREFRAME ||
16796
+ cubemap == null)
1427616797 {
1427716798 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1427816799 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -14287,7 +16808,17 @@
1428716808 // Compensates for ExaminerViewer's modification of modelview matrix
1428816809 gl.glMatrixMode(GL.GL_MODELVIEW);
1428916810 gl.glLoadIdentity();
16811
+ gl.glScalef(1,ratio,1);
1429016812
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
+
1429116822 //gl.glActiveTexture(GL.GL_TEXTURE1);
1429216823 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1429316824
....@@ -14319,6 +16850,7 @@
1431916850 {
1432016851 gl.glScalef(1.0f, -1.0f, 1.0f);
1432116852 }
16853
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1432216854 gl.glMultMatrixd(viewrot_1, 0);
1432316855 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1432416856 //viewer.updateInverseRotation(gl);
....@@ -14359,7 +16891,8 @@
1435916891 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1436016892
1436116893 cubemap.disable();
14362
- ////cubemap.unbind();
16894
+ //cubemap.dispose();
16895
+
1436316896 if (CULLFACE)
1436416897 {
1436516898 gl.glEnable(gl.GL_CULL_FACE);
....@@ -14394,7 +16927,7 @@
1439416927 gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
1439516928 gl.glPushMatrix();
1439616929 gl.glLoadIdentity();
14397
- PushMatrix(checker.toParent);
16930
+ //PushMatrix(checker.toParent);
1439816931
1439916932 gl.glMatrixMode(GL.GL_TEXTURE);
1440016933 gl.glPushMatrix();
....@@ -14415,10 +16948,10 @@
1441516948 gl.glScalef(1.0f, -1.0f, 1.0f);
1441616949 }
1441716950
14418
- gl.glNormal3f(0.0f, 0.0f, 1.0f);
16951
+ SetGLNormal(gl, 0.0f, 0.0f, 1.0f);
1441916952
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;
1442216955
1442316956 int i0 = 0;
1442416957 /*
....@@ -14454,20 +16987,21 @@
1445416987 /**/
1445516988 //checker.GetMaterial().opacity = 1.1f;
1445616989 ////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;
1446016993 //System.out.println("material " + material);
1446116994 //Applet3D.tracein(this, selected);
14462
- vector2buffer = checker.projectedVertices;
16995
+ //vector2buffer = checker.projectedVertices;
1446316996
14464
- checker.GetMaterial().Draw(this, false); // true);
16997
+ //checker.GetMaterial().Draw(this, false); // true);
16998
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1446516999
14466
- Object3D.materialdepth -= 1;
14467
- if (Object3D.materialdepth > 0)
17000
+ materialdepth -= 1;
17001
+ if (materialdepth > 0)
1446817002 {
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);
1447117005 }
1447217006 //checker.GetMaterial().opacity = 1f;
1447317007 ////checker.GetMaterial().ambient = 1f;
....@@ -14488,15 +17022,27 @@
1448817022
1448917023 //float u = (i+1)/2;
1449017024 //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);
1449217029 gl.glVertex3f(i, j, -0.5f);
1449317030
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
1449417034 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
1449517035 gl.glVertex3f(i + step, j, -0.5f);
1449617036
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
1449717040 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
1449817041 gl.glVertex3f(i + step, j + stepv, -0.5f);
1449917042
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
1450017046 gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
1450117047 gl.glVertex3f(i, j + stepv, -0.5f);
1450217048 }
....@@ -14508,7 +17054,7 @@
1450817054 gl.glMatrixMode(GL.GL_PROJECTION);
1450917055 gl.glPopMatrix();
1451017056 gl.glMatrixMode(GL.GL_MODELVIEW);
14511
- PopMatrix(null); // checker.toParent); // null);
17057
+ //PopMatrix(null); // checker.toParent); // null);
1451217058 gl.glPopMatrix();
1451317059 PopTextureMatrix(checker.toParent);
1451417060 gl.glMatrixMode(GL.GL_TEXTURE);
....@@ -14541,6 +17087,14 @@
1454117087 }
1454217088 }
1454317089
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
+
1454417098 class SelectBuffer implements GLEventListener
1454517099 {
1454617100
....@@ -14556,7 +17110,7 @@
1455617110 //new Exception().printStackTrace();
1455717111 System.out.println("select buffer init");
1455817112 // Use debug pipeline
14559
- drawable.setGL(new DebugGL(drawable.getGL()));
17113
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1456017114
1456117115 GL gl = drawable.getGL();
1456217116
....@@ -14599,6 +17153,7 @@
1459917153 {
1460017154 if (!selection)
1460117155 {
17156
+ new Exception().printStackTrace();
1460217157 System.exit(0);
1460317158 return;
1460417159 }
....@@ -14619,17 +17174,39 @@
1461917174
1462017175 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1462117176
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
+
1462217188 //int tmp = selection_view;
1462317189 //selection_view = -1;
14624
- int temp = drawMode;
14625
- drawMode = SELECTION;
17190
+ int temp = DrawMode();
17191
+ Globals.drawMode = SELECTION; // WARNING
1462617192 indexcount = 0;
1462717193 parent.display(drawable);
1462817194 //selection_view = tmp;
1462917195 //if (temp == SELECTION)
1463017196 // temp = DEFAULT; // patch for selection debug
14631
- drawMode = temp;
17197
+ Globals.drawMode = temp; // WARNING
1463217198
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
+
1463317210 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1463417211
1463517212 // trying different ways of getting the depth info over
....@@ -14678,6 +17255,13 @@
1467817255 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1467917256 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1468017257
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
+
1468117265 glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0);
1468217266
1468317267 // if (object.selection != null && object.selection.Size() > 0)
....@@ -14721,34 +17305,36 @@
1472117305 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]));
1472217306 }
1472317307
14724
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
17308
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1472517309 }
1472617310 }
1472717311
1472817312 if (!movingcamera && !PAINTMODE)
14729
- object.editWindow.ScreenFitPoint(); // fev 2014
17313
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1473017314
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)
1473217316 {
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);
1473417318
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);
1473617322
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
+ }
1475217338 }
1475317339 else
1475417340 paintcount = 0;
....@@ -14787,6 +17373,11 @@
1478717373 //System.out.println("objects[color] = " + objects[color]);
1478817374 //objects[color].Select();
1478917375 indexcount = 0;
17376
+ ObjEditor window = object.GetWindow();
17377
+ if (window != null && deselect)
17378
+ {
17379
+ window.Select(null, deselect, true);
17380
+ }
1479017381 object.Select(color, deselect);
1479117382 }
1479217383
....@@ -14837,6 +17428,7 @@
1483717428
1483817429 public void init(GLAutoDrawable drawable)
1483917430 {
17431
+ if (Globals.DEBUG)
1484017432 System.out.println("shadow buffer init");
1484117433
1484217434 GL gl = drawable.getGL();
....@@ -14886,7 +17478,7 @@
1488617478 gl.glDisable(gl.GL_CULL_FACE);
1488717479 }
1488817480
14889
- if (!RENDERSHADOW)
17481
+ if (!Globals.RENDERSHADOW)
1489017482 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1489117483
1489217484 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -14896,14 +17488,14 @@
1489617488 //gl.glColorMask(false, false, false, false);
1489717489
1489817490 //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())
1490017492 {
1490117493 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1490217494
14903
- int temp = drawMode;
14904
- drawMode = SHADOW;
17495
+ int temp = DrawMode();
17496
+ Globals.drawMode = SHADOW; // WARNING
1490517497 parent.display(drawable);
14906
- drawMode = temp;
17498
+ Globals.drawMode = temp; // WARNING
1490717499 }
1490817500
1490917501 gl.glCullFace(gl.GL_BACK);
....@@ -14956,7 +17548,6 @@
1495617548
1495717549 class AntialiasBuffer implements GLEventListener
1495817550 {
14959
-
1496017551 CameraPane parent = null;
1496117552
1496217553 AntialiasBuffer(CameraPane p)
....@@ -15066,15 +17657,25 @@
1506617657 gl.glFlush();
1506717658
1506817659 /**/
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);
1507017661
15071
- int[] pixels = occlusionsizebuffer.array();
17662
+ float[] depths = occlusiondepthbuffer.array();
1507217663
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
+
1507317668 double r = 0, g = 0, b = 0;
1507417669
1507517670 double count = 0;
17671
+
17672
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
17673
+
17674
+ float mindepth = 1;
17675
+
17676
+ double FACTOR = 1;
1507617677
15077
- for (int i = 0; i < pixels.length; i++)
17678
+ for (int i = 0; i < depths.length; i++)
1507817679 {
1507917680 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1508017681 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -15157,7 +17758,7 @@
1515717758
1515817759 double scale = ray.z; // 1; // cos
1515917760
15160
- int p = pixels[newindex];
17761
+ float depth = depths[newindex];
1516117762
1516217763 /*
1516317764 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15181,10 +17782,23 @@
1518117782 scale = (1 - modu) * modv;
1518217783 */
1518317784
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
+ }
1518717793
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
+
1518817802 count += scale;
1518917803 }
1519017804
....@@ -15282,12 +17896,6 @@
1528217896 GLUT glut = new GLUT();
1528317897
1528417898
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;
1529117899 public boolean spherical = false;
1529217900 static boolean DEBUG_OCCLUSION = false;
1529317901 static boolean DEBUG_SELECTION = false;
....@@ -15300,23 +17908,15 @@
1530017908 int AAbuffersize = 0;
1530117909
1530217910 //double[] selectedpoint = new double[3];
15303
- static Sphere selectedpoint = new Sphere();
17911
+ static Superellipsoid selectedpoint;
1530417912 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;
1530917917
1531017918 static Sphere debugpoints[] = new Sphere[8];
1531117919
15312
- static
15313
- {
15314
- for (int i=0; i<8; i++)
15315
- {
15316
- debugpoints[i] = new Sphere();
15317
- }
15318
- }
15319
-
1532017920 static void InitPoints(float radius)
1532117921 {
1532217922 for (int i=0; i<8; i++)
....@@ -15336,7 +17936,7 @@
1533617936 }
1533717937 }
1533817938
15339
- static void DrawPoints(CameraPane cpane)
17939
+ static void DrawPoints(iCameraPane cpane)
1534017940 {
1534117941 for (int i=0; i<8; i++) // first and last are red
1534217942 {
....@@ -15355,10 +17955,14 @@
1535517955 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1535617956 static IntBuffer bigAAbuffer;
1535717957 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);
1535917959 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1536017960 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
+
1536217966 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1536317967 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1536417968 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();
....@@ -15367,10 +17971,11 @@
1536717971 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1536817972 // Depth buffer format
1536917973 //private int depth_format;
15370
- static public void NextIndex(Object3D o, GL gl)
17974
+
17975
+ public void NextIndex()
1537117976 {
1537217977 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);
1537417979 //objects[indexcount] = o;
1537517980 //System.out.println("indexcount = " + indexcount);
1537617981 }