Normand Briere
2019-07-20 0a52bd4800459cd9935f360d7ca9555b6bea2146
CameraPane.java
....@@ -37,7 +37,6 @@
3737 static boolean[] selectedstack = new boolean[65536];
3838 static int materialdepth = 0;
3939
40
- static boolean DEBUG = false;
4140 static boolean FRUSTUM = false; // still bogus true; // frustum culling
4241
4342 // camera change fix
....@@ -149,6 +148,8 @@
149148 defaultcaps.setAccumBlueBits(16);
150149 defaultcaps.setAccumAlphaBits(16);
151150 }
151
+
152
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
152153
153154 void SetAsGLRenderer(boolean b)
154155 {
....@@ -325,7 +326,7 @@
325326 cStatic.objectstack[materialdepth++] = obj;
326327 //System.out.println("material " + material);
327328 //Applet3D.tracein(this, selected);
328
- display.vector2buffer = obj.projectedVertices;
329
+ //display.vector2buffer = obj.projectedVertices;
329330 if (obj instanceof Camera)
330331 {
331332 display.options1[0] = material.shift;
....@@ -334,14 +335,28 @@
334335 display.options1[2] = material.shadowbias;
335336 display.options1[3] = material.aniso;
336337 display.options1[4] = material.anisoV;
338
+// System.out.println("display.options1[0] " + display.options1[0]);
339
+// System.out.println("display.options1[1] " + display.options1[1]);
340
+// System.out.println("display.options1[2] " + display.options1[2]);
341
+// System.out.println("display.options1[3] " + display.options1[3]);
342
+// System.out.println("display.options1[4] " + display.options1[4]);
337343 display.options2[0] = material.opacity;
338344 display.options2[1] = material.diffuse;
339345 display.options2[2] = material.factor;
346
+// System.out.println("display.options2[0] " + display.options2[0]);
347
+// System.out.println("display.options2[1] " + display.options2[1]);
348
+// System.out.println("display.options2[2] " + display.options2[2]);
340349
341350 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
351
+// System.out.println("display.options3[0] " + display.options3[0]);
352
+// System.out.println("display.options3[1] " + display.options3[1]);
353
+// System.out.println("display.options3[2] " + display.options3[2]);
342354 display.options4[0] = material.cameralight/0.2f;
343355 display.options4[1] = material.subsurface;
344356 display.options4[2] = material.sheen;
357
+// System.out.println("display.options4[0] " + display.options4[0]);
358
+// System.out.println("display.options4[1] " + display.options4[1]);
359
+// System.out.println("display.options4[2] " + display.options4[2]);
345360
346361 // if (display.CURRENTANTIALIAS > 0)
347362 // display.options3[3] /= 4;
....@@ -357,7 +372,7 @@
357372 /**/
358373 } else
359374 {
360
- DrawMaterial(material, selected);
375
+ DrawMaterial(material, selected, obj.projectedVertices);
361376 }
362377 } else
363378 {
....@@ -381,8 +396,8 @@
381396 cStatic.objectstack[materialdepth++] = obj;
382397 //System.out.println("material " + material);
383398 //Applet3D.tracein("selected ", selected);
384
- display.vector2buffer = obj.projectedVertices;
385
- display.DrawMaterial(material, selected);
399
+ //display.vector2buffer = obj.projectedVertices;
400
+ display.DrawMaterial(material, selected, obj.projectedVertices);
386401 }
387402 }
388403
....@@ -399,8 +414,8 @@
399414 materialdepth -= 1;
400415 if (materialdepth > 0)
401416 {
402
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
403
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
417
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
418
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
404419 }
405420 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
406421 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -420,8 +435,8 @@
420435 materialdepth -= 1;
421436 if (materialdepth > 0)
422437 {
423
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
424
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
438
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
439
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
425440 }
426441 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
427442 //else
....@@ -462,10 +477,12 @@
462477 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
463478 {
464479 //gl.glBegin(gl.GL_TRIANGLES);
465
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
480
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
481
+ // TEST LIVE NORMALS && !obj.dontselect
482
+ ;
466483 if (!hasnorm)
467484 {
468
- // System.out.println("FUCK!!");
485
+ // System.out.println("Mesh normal");
469486 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
470487 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
471488 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1190,10 +1207,12 @@
11901207 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11911208 }
11921209 }
1210
+
11931211 if (flipV)
11941212 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11951213 else
11961214 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1215
+
11971216 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
11981217 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
11991218
....@@ -1213,10 +1232,12 @@
12131232 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12141233 }
12151234 }
1235
+
12161236 if (flipV)
12171237 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12181238 else
12191239 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1240
+
12201241 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12211242 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12221243
....@@ -1244,8 +1265,10 @@
12441265 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12451266 else
12461267 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1268
+
12471269 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12481270 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1271
+
12491272 count2 += 2;
12501273 count3 += 3;
12511274 }
....@@ -1601,7 +1624,7 @@
16011624 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16021625 }
16031626
1604
- void DrawMaterial(cMaterial material, boolean selected)
1627
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16051628 {
16061629 CameraPane display = this;
16071630 //new Exception().printStackTrace();
....@@ -1628,7 +1651,7 @@
16281651
16291652 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16301653
1631
- float[] colorV = GrafreeD.colorV;
1654
+ float[] colorV = Grafreed.colorV;
16321655
16331656 /**/
16341657 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1636,7 +1659,7 @@
16361659 colorV[0] = display.modelParams0[0] * material.diffuse;
16371660 colorV[1] = display.modelParams0[1] * material.diffuse;
16381661 colorV[2] = display.modelParams0[2] * material.diffuse;
1639
- colorV[3] = material.opacity;
1662
+ colorV[3] = 1; // material.opacity;
16401663
16411664 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16421665 //System.out.println("Opacity = " + opacity);
....@@ -1744,9 +1767,9 @@
17441767 display.modelParams7[2] = 0;
17451768 display.modelParams7[3] = 0;
17461769
1747
- display.modelParams6[0] = 100; // criss de bug de bump
1770
+ //display.modelParams6[0] = 100; // criss de bug de bump
17481771
1749
- Object3D.cVector2[] extparams = display.vector2buffer;
1772
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17501773 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17511774 {
17521775 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1888,7 +1911,7 @@
18881911 void PushMatrix(double[][] matrix)
18891912 {
18901913 // GrafreeD.tracein(matrix);
1891
- PushMatrix(matrix,1);
1914
+ PushMatrix(matrix, 1);
18921915 }
18931916
18941917 void PushMatrix()
....@@ -2042,7 +2065,7 @@
20422065 //System.err.println("Oeil on");
20432066 OEIL = true;
20442067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2045
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20462069 //pingthread.StepToTarget(true);
20472070 }
20482071
....@@ -2140,7 +2163,7 @@
21402163 System.err.println("LIVE = " + Globals.isLIVE());
21412164
21422165 if (!Globals.isLIVE()) // save sound
2143
- GrafreeD.savesound = true; // wav.save();
2166
+ Grafreed.savesound = true; // wav.save();
21442167 // else
21452168 repaint(); // start loop // may 2013
21462169 }
....@@ -2257,7 +2280,7 @@
22572280
22582281 void ToggleDebug()
22592282 {
2260
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22612284 }
22622285
22632286 void ToggleLookAt()
....@@ -2265,7 +2288,7 @@
22652288 LOOKAT ^= true;
22662289 }
22672290
2268
- void ToggleRandom()
2291
+ void ToggleSwitch()
22692292 {
22702293 SWITCH ^= true;
22712294 }
....@@ -2275,10 +2298,17 @@
22752298 HANDLES ^= true;
22762299 }
22772300
2301
+ Object3D paintFolder;
2302
+
22782303 void TogglePaint()
22792304 {
22802305 PAINTMODE ^= true;
22812306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
22822312 }
22832313
22842314 void SwapCamera(int a, int b)
....@@ -2374,7 +2404,7 @@
23742404 {
23752405 return currentGL;
23762406 }
2377
-
2407
+
23782408 /**/
23792409 class CacheTexture
23802410 {
....@@ -7919,6 +7949,64 @@
79197949 ReleaseTexture(pigment, false);
79207950 }
79217951
7952
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7953
+ {
7954
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7955
+ {
7956
+ return;
7957
+ }
7958
+
7959
+ if (tex == null)
7960
+ {
7961
+ ReleaseTexture(null, false);
7962
+ return;
7963
+ }
7964
+
7965
+ String pigment = Object3D.GetPigment(tex);
7966
+
7967
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7968
+ {
7969
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7970
+ // System.out.println("; bump = " + bump);
7971
+ }
7972
+
7973
+ if (pigment.equals(""))
7974
+ {
7975
+ pigment = null;
7976
+ }
7977
+
7978
+ ReleaseTexture(pigment, false);
7979
+ }
7980
+
7981
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
7982
+ {
7983
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7984
+ {
7985
+ return;
7986
+ }
7987
+
7988
+ if (tex == null)
7989
+ {
7990
+ ReleaseTexture(null, true);
7991
+ return;
7992
+ }
7993
+
7994
+ String bump = Object3D.GetBump(tex);
7995
+
7996
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7997
+ {
7998
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7999
+ // System.out.println("; bump = " + bump);
8000
+ }
8001
+
8002
+ if (bump.equals(""))
8003
+ {
8004
+ bump = null;
8005
+ }
8006
+
8007
+ ReleaseTexture(bump, true);
8008
+ }
8009
+
79228010 void ReleaseTexture(String tex, boolean bump)
79238011 {
79248012 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8022,7 +8110,7 @@
80228110 }
80238111 }
80248112
8025
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8113
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80268114 {
80278115 if (// DrawMode() != 0 || /*tex == null ||*/
80288116 ambientOcclusion ) // || !textureon)
....@@ -8067,7 +8155,94 @@
80678155 return; // true;
80688156 }
80698157
8070
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8158
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8159
+ {
8160
+ if (// DrawMode() != 0 || /*tex == null ||*/
8161
+ ambientOcclusion ) // || !textureon)
8162
+ {
8163
+ return; // false;
8164
+ }
8165
+
8166
+ if (tex == null)
8167
+ {
8168
+ BindTexture(null,false,resolution);
8169
+ return;
8170
+ }
8171
+
8172
+ String pigment = Object3D.GetPigment(tex);
8173
+
8174
+ usedtextures.put(pigment, pigment);
8175
+
8176
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8177
+ {
8178
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8179
+ // System.out.println("; bump = " + bump);
8180
+ }
8181
+
8182
+ if (pigment.equals(""))
8183
+ {
8184
+ pigment = null;
8185
+ }
8186
+
8187
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8188
+ BindTexture(pigment, false, resolution);
8189
+ }
8190
+
8191
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8192
+ {
8193
+ if (// DrawMode() != 0 || /*tex == null ||*/
8194
+ ambientOcclusion ) // || !textureon)
8195
+ {
8196
+ return; // false;
8197
+ }
8198
+
8199
+ if (tex == null)
8200
+ {
8201
+ BindTexture(null,true,resolution);
8202
+ return;
8203
+ }
8204
+
8205
+ String bump = Object3D.GetBump(tex);
8206
+
8207
+ usedtextures.put(bump, bump);
8208
+
8209
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8210
+ {
8211
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8212
+ // System.out.println("; bump = " + bump);
8213
+ }
8214
+
8215
+ if (bump.equals(""))
8216
+ {
8217
+ bump = null;
8218
+ }
8219
+
8220
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8221
+ BindTexture(bump, true, resolution);
8222
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8223
+ }
8224
+
8225
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8226
+
8227
+ private boolean FileExists(String tex)
8228
+ {
8229
+ if (missingTextures.contains(tex))
8230
+ {
8231
+ return false;
8232
+ }
8233
+
8234
+ boolean fileExists = new File(tex).exists();
8235
+
8236
+ if (!fileExists)
8237
+ {
8238
+ // If file exists, the "new File()" is not executed sgain
8239
+ missingTextures.add(tex);
8240
+ }
8241
+
8242
+ return fileExists;
8243
+ }
8244
+
8245
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
80718246 {
80728247 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80738248
....@@ -8075,15 +8250,17 @@
80758250 {
80768251 String texname = tex;
80778252
8253
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8254
+
80788255 // String[] split = tex.split("Textures");
80798256 // if (split.length > 1)
80808257 // texname = "/Users/nbriere/Textures" + split[split.length-1];
80818258 // else
80828259 // if (!texname.startsWith("/"))
80838260 // texname = "/Users/nbriere/Textures/" + texname;
8084
- if (!new File(tex).exists())
8261
+ if (!FileExists(tex))
80858262 {
8086
- texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname;
8263
+ texname = fallbackTextureName;
80878264 }
80888265
80898266 if (CACHETEXTURE)
....@@ -8153,7 +8330,7 @@
81538330 }
81548331
81558332 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8156
- if (!new File(cachename).exists())
8333
+ if (!FileExists(cachename))
81578334 cachename = texname;
81588335 else
81598336 processbump = false; // don't process bump map again
....@@ -8175,7 +8352,7 @@
81758352 }
81768353
81778354 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8178
- if (!new File(cachename).exists())
8355
+ if (!FileExists(cachename))
81798356 cachename = texname;
81808357 else
81818358 processbump = false; // don't process bump map again
....@@ -8184,7 +8361,9 @@
81848361 texturedata = GetFileTexture(cachename, processbump, resolution);
81858362
81868363
8187
- if (texturedata != null)
8364
+ if (texturedata == null)
8365
+ throw new Exception();
8366
+
81888367 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81898368 //texture = GetTexture(tex, bump);
81908369 }
....@@ -8306,7 +8485,7 @@
83068485 return texture;
83078486 }
83088487
8309
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8488
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
83108489 {
83118490 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83128491
....@@ -8324,14 +8503,14 @@
83248503 return texture!=null?texture.texture:null;
83258504 }
83268505
8327
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8506
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
83288507 {
83298508 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83308509
83318510 return texture!=null?texture.texturedata:null;
83328511 }
83338512
8334
- boolean BindTexture(String tex, boolean bump, int resolution)
8513
+ com.sun.opengl.util.texture.Texture BindTexture(String tex, boolean bump, int resolution) throws Exception
83358514 {
83368515 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83378516 {
....@@ -8343,7 +8522,7 @@
83438522 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
83448523
83458524 if (texture == null)
8346
- return false;
8525
+ return texture;
83478526 /**/
83488527
83498528 if (textureon || tex.equals("DEFAULT_TEXTURE") || tex.equals("DEFAULT_TEXTURE_BUMP") || tex.equals("WHITE_NOISE")) // || tex.equals("IMMORTAL"))
....@@ -9208,11 +9387,35 @@
92089387 jy8[3] = 0.5f;
92099388 }
92109389
9211
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9390
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
92129391 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92139392 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92149393 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92159394
9395
+ void ResetOptions()
9396
+ {
9397
+ options1[0] = 100;
9398
+ options1[1] = 0.025f;
9399
+ options1[2] = 0.01f;
9400
+ options1[3] = 0;
9401
+ options1[4] = 0;
9402
+
9403
+ options2[0] = 0;
9404
+ options2[1] = 0.75f;
9405
+ options2[2] = 0;
9406
+ options2[3] = 0;
9407
+
9408
+ options3[0] = 1;
9409
+ options3[1] = 1;
9410
+ options3[2] = 1;
9411
+ options3[3] = 0;
9412
+
9413
+ options4[0] = 1;
9414
+ options4[1] = 0;
9415
+ options4[2] = 1;
9416
+ options4[3] = 0;
9417
+ }
9418
+
92169419 static int imagecount = 0; // movie generation
92179420
92189421 static int jitter = 0;
....@@ -9308,8 +9511,8 @@
93089511 assert (parentcam != renderCamera);
93099512
93109513 if (renderCamera != lightCamera)
9311
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9312
- LA.matConcat(matrix, parentcam.toParent, matrix);
9514
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9515
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93139516
93149517 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93159518
....@@ -9324,8 +9527,8 @@
93249527 LA.matCopy(renderCamera.fromScreen, matrix);
93259528
93269529 if (renderCamera != lightCamera)
9327
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9328
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9530
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9531
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93299532
93309533 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93319534
....@@ -9542,7 +9745,7 @@
95429745
95439746 if (!BOXMODE)
95449747 {
9545
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9748
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95469749 }
95479750
95489751 if (!BOXMODE)
....@@ -9580,7 +9783,7 @@
95809783 ABORTED = false;
95819784 }
95829785 else
9583
- GrafreeD.wav.cursor += 735 * ACSIZE;
9786
+ Grafreed.wav.cursor += 735 * ACSIZE;
95849787
95859788 if (false)
95869789 {
....@@ -10243,11 +10446,11 @@
1024310446
1024410447 public void display(GLAutoDrawable drawable)
1024510448 {
10246
- if (GrafreeD.savesound && GrafreeD.hassound)
10449
+ if (Grafreed.savesound && Grafreed.hassound)
1024710450 {
10248
- GrafreeD.wav.save();
10249
- GrafreeD.savesound = false;
10250
- GrafreeD.hassound = false;
10451
+ Grafreed.wav.save();
10452
+ Grafreed.savesound = false;
10453
+ Grafreed.hassound = false;
1025110454 }
1025210455 // if (DEBUG_SELECTION)
1025310456 // {
....@@ -10323,6 +10526,7 @@
1032310526 ANTIALIAS = 0;
1032410527 //System.out.println("RESTART");
1032510528 AAtimer.restart();
10529
+ Globals.TIMERRUNNING = true;
1032610530 }
1032710531 }
1032810532 }
....@@ -10377,7 +10581,7 @@
1037710581 Object3D theobject = object;
1037810582 Object3D theparent = object.parent;
1037910583 object.parent = null;
10380
- object = (Object3D)GrafreeD.clone(object);
10584
+ object = (Object3D)Grafreed.clone(object);
1038110585 object.Stripify();
1038210586 if (theobject.selection == null || theobject.selection.Size() == 0)
1038310587 theobject.PreprocessOcclusion(this);
....@@ -10390,13 +10594,14 @@
1039010594 ambientOcclusion = false;
1039110595 }
1039210596
10393
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10597
+ if (//Globals.lighttouched &&
10598
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039410599 {
1039510600 //if (RENDERSHADOW) // ?
1039610601 if (!IsFrozen())
1039710602 {
1039810603 // dec 2012
10399
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10604
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1040010605 {
1040110606 Globals.framecount++;
1040210607 shadowbuffer.display();
....@@ -10523,8 +10728,8 @@
1052310728
1052410729 // if (parentcam != renderCamera) // not a light
1052510730 if (cam != lightCamera)
10526
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10527
- LA.matConcat(matrix, parentcam.toParent, matrix);
10731
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10732
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052810733
1052910734 for (int j = 0; j < 4; j++)
1053010735 {
....@@ -10538,8 +10743,8 @@
1053810743
1053910744 // if (parentcam != renderCamera) // not a light
1054010745 if (cam != lightCamera)
10541
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10542
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10746
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10747
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054310748
1054410749 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054510750
....@@ -10798,7 +11003,16 @@
1079811003 // Bump noise
1079911004 gl.glActiveTexture(GL.GL_TEXTURE6);
1080011005 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10801
- BindTexture(NOISE_TEXTURE, false, 2);
11006
+
11007
+ try
11008
+ {
11009
+ BindTexture(NOISE_TEXTURE, false, 2);
11010
+ }
11011
+ catch (Exception e)
11012
+ {
11013
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11014
+ }
11015
+
1080211016
1080311017 gl.glActiveTexture(GL.GL_TEXTURE0);
1080411018 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10821,9 +11035,9 @@
1082111035
1082211036 gl.glMatrixMode(GL.GL_MODELVIEW);
1082311037
10824
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10825
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10826
-//gl.glEnable(gl.GL_MULTISAMPLE);
11038
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11039
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11040
+gl.glEnable(gl.GL_MULTISAMPLE);
1082711041 } else
1082811042 {
1082911043 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10834,7 +11048,7 @@
1083411048 //System.out.println("BLENDING ON");
1083511049 gl.glEnable(GL.GL_BLEND);
1083611050 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10837
-
11051
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1083811052 gl.glMatrixMode(gl.GL_PROJECTION);
1083911053 gl.glLoadIdentity();
1084011054
....@@ -10923,8 +11137,8 @@
1092311137 System.err.println("parentcam != renderCamera");
1092411138
1092511139 // if (cam != lightCamera)
10926
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10927
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11140
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11141
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1092811142 }
1092911143
1093011144 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10945,8 +11159,8 @@
1094511159 if (true) // TODO
1094611160 {
1094711161 if (cam != lightCamera)
10948
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10949
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11162
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11163
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1095011164 }
1095111165
1095211166 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11283,23 +11497,44 @@
1128311497 e.printStackTrace();
1128411498 }
1128511499
11286
- if (GrafreeD.RENDERME > 0)
11287
- GrafreeD.RENDERME--; // mechante magouille
11500
+ if (Grafreed.RENDERME > 0)
11501
+ Grafreed.RENDERME--; // mechante magouille
1128811502
1128911503 Globals.ONESTEP = false;
1129011504 }
1129111505
1129211506 static boolean zoomonce = false;
1129311507
11508
+ static void CreateSelectedPoint()
11509
+ {
11510
+ if (selectedpoint == null)
11511
+ {
11512
+ debugpointG = new Sphere();
11513
+ debugpointP = new Sphere();
11514
+ debugpointC = new Sphere();
11515
+ debugpointR = new Sphere();
11516
+
11517
+ selectedpoint = new Superellipsoid();
11518
+
11519
+ for (int i=0; i<8; i++)
11520
+ {
11521
+ debugpoints[i] = new Sphere();
11522
+ }
11523
+ }
11524
+ }
11525
+
1129411526 void DrawObject(GL gl, boolean draw)
1129511527 {
11528
+ // To clear camera values
11529
+ ResetOptions();
11530
+
1129611531 //System.out.println("DRAW OBJECT " + mouseDown);
1129711532 // DrawMode() = SELECTION;
1129811533 //GL gl = getGL();
1129911534 if ((TRACK || SHADOWTRACK) || zoomonce)
1130011535 {
1130111536 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11302
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11537
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1130311538 pingthread.StepToTarget(true); // true);
1130411539 // zoomonce = false;
1130511540 }
....@@ -11354,7 +11589,14 @@
1135411589
1135511590 usedtextures.clear();
1135611591
11357
- BindTextures(DEFAULT_TEXTURES, 2);
11592
+ try
11593
+ {
11594
+ BindTextures(DEFAULT_TEXTURES, 2);
11595
+ }
11596
+ catch (Exception e)
11597
+ {
11598
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11599
+ }
1135811600 }
1135911601 //System.out.println("--> " + stackdepth);
1136011602 // GrafreeD.traceon();
....@@ -11364,8 +11606,9 @@
1136411606
1136511607 if (DrawMode() == DEFAULT)
1136611608 {
11367
- if (DEBUG)
11609
+ if (Globals.DEBUG)
1136811610 {
11611
+ CreateSelectedPoint();
1136911612 float radius = 0.05f;
1137011613 if (selectedpoint.radius != radius)
1137111614 {
....@@ -11445,7 +11688,14 @@
1144511688 if (checker != null && DrawMode() == DEFAULT)
1144611689 {
1144711690 //BindTexture(IMMORTAL_TEXTURE);
11448
- BindTextures(checker.GetTextures(), checker.texres);
11691
+ try
11692
+ {
11693
+ BindTextures(checker.GetTextures(), checker.texres);
11694
+ }
11695
+ catch (Exception e)
11696
+ {
11697
+ System.err.println("FAILED: " + checker.GetTextures());
11698
+ }
1144911699 // NEAREST
1145011700 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1145111701 DrawChecker(gl);
....@@ -11527,7 +11777,7 @@
1152711777 return;
1152811778 }
1152911779
11530
- String string = obj.GetToolTip();
11780
+ String string = obj.toString(); //.GetToolTip();
1153111781
1153211782 GL gl = GetGL();
1153311783
....@@ -11844,8 +12094,8 @@
1184412094 //obj.TransformToWorld(light, light);
1184512095 for (int i = tp.size(); --i >= 0;)
1184612096 {
11847
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11848
- LA.xformPos(light, tp.get(i).toParent, light);
12097
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12098
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1184912099 }
1185012100
1185112101
....@@ -11862,8 +12112,8 @@
1186212112 parentcam = cameras[0];
1186312113 }
1186412114
11865
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11866
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12115
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12116
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1186712117
1186812118 LA.xformPos(light, renderCamera.toScreen, light);
1186912119
....@@ -12477,8 +12727,8 @@
1247712727
1247812728 // display shadow only (bump == 0)
1247912729 "SUB temp.x, half.x, shadow.x;" +
12480
- "MOV temp.y, -params6.x;" +
12481
- "SLT temp.z, temp.y, zero.x;" +
12730
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12731
+ "SLT temp.z, temp.y, -one2048th.x;" +
1248212732 "SUB temp.y, one.x, temp.z;" +
1248312733 "MUL temp.x, temp.x, temp.y;" +
1248412734 "KIL temp.x;" +
....@@ -12809,7 +13059,7 @@
1280913059 //once = true;
1281013060 }
1281113061
12812
- System.out.print("Program #" + mode + "; length = " + program.length());
13062
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1281313063 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1281413064 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1281513065
....@@ -12942,12 +13192,16 @@
1294213192
1294313193 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1294413194 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13195
+
13196
+ // Compare fragment depth in light space with shadowmap.
1294513197 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1294613198 "SGE temp.y, temp.x, zero.x;" +
12947
- "SUB " + shadow + ".y, one.x, temp.y;" +
13199
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13200
+
13201
+ // Reverse comparison
1294813202 "SUB temp.x, one.x, temp.x;" +
1294913203 "MUL " + shadow + ".x, temp.x, temp.y;" +
12950
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13204
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1295113205 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1295213206
1295313207 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12961,6 +13215,10 @@
1296113215 // No shadow for backface
1296213216 "DP3 temp.x, normal, lightd;" +
1296313217 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13218
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13219
+
13220
+ // No shadow when out of frustrum
13221
+ "SGE temp.x, " + depth + ".z, one.z;" +
1296413222 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1296513223 "";
1296613224 }
....@@ -13107,7 +13365,8 @@
1310713365 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1310813366 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1310913367 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13110
- Object3D.cVector2[] vector2buffer;
13368
+
13369
+ //Object3D.cVector2[] vector2buffer;
1311113370
1311213371 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1311313372 // OUT : diff, spec
....@@ -13123,9 +13382,10 @@
1312313382 "DP3 " + dest + ".z," + "normals," + "eye;" +
1312413383 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1312513384 //"MOV " + dest + ".w," + "normal.z;" +
13126
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13127
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13128
- //"MOV " + dest + ".z," + "params2.w;" +
13385
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13386
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13387
+
13388
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1312913389 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1313013390 "RCP " + dest + ".w," + dest + ".w;" +
1313113391 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13630,6 +13890,7 @@
1363013890 else
1363113891 if (evt.getSource() == AAtimer)
1363213892 {
13893
+ Globals.TIMERRUNNING = false;
1363313894 if (mouseDown)
1363413895 {
1363513896 //new Exception().printStackTrace();
....@@ -13655,6 +13916,10 @@
1365513916 // LIVE = waslive;
1365613917 // wasliveok = true;
1365713918 // waslive = false;
13919
+
13920
+ // May 2019 Forget it:
13921
+ if (true)
13922
+ return;
1365813923
1365913924 // source == timer
1366013925 if (mouseDown)
....@@ -13685,7 +13950,7 @@
1368513950
1368613951 // fev 2014???
1368713952 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13688
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13953
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1368913954 pingthread.StepToTarget(true); // true);
1369013955 }
1369113956 // if (!LIVE)
....@@ -13700,6 +13965,7 @@
1370013965 return;
1370113966
1370213967 AAtimer.restart(); //
13968
+ Globals.TIMERRUNNING = true;
1370313969
1370413970 // waslive = LIVE;
1370513971 // LIVE = false;
....@@ -13772,9 +14038,12 @@
1377214038
1377314039 public void mouseDragged(MouseEvent e)
1377414040 {
14041
+ Globals.MOUSEDRAGGED = true;
14042
+
1377514043 //System.out.println("mouseDragged: " + e);
1377614044 if (isRenderer)
1377714045 movingcamera = true;
14046
+
1377814047 //if (drawing)
1377914048 //return;
1378014049 if ((e.getModifiersEx() & CTRL) != 0
....@@ -14035,12 +14304,12 @@
1403514304 void GoDown(int mod)
1403614305 {
1403714306 MODIFIERS |= COMMAND;
14038
- /*
14307
+ /**/
1403914308 if((mod&SHIFT) == SHIFT)
1404014309 manipCamera.RotatePosition(0, -speed);
1404114310 else
14042
- manipCamera.BackForth(0, -speed*delta, getWidth());
14043
- */
14311
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14312
+ /**/
1404414313 if ((mod & SHIFT) == SHIFT)
1404514314 {
1404614315 mouseMode = mouseMode; // VR??
....@@ -14056,12 +14325,12 @@
1405614325 void GoUp(int mod)
1405714326 {
1405814327 MODIFIERS |= COMMAND;
14059
- /*
14328
+ /**/
1406014329 if((mod&SHIFT) == SHIFT)
1406114330 manipCamera.RotatePosition(0, speed);
1406214331 else
14063
- manipCamera.BackForth(0, speed*delta, getWidth());
14064
- */
14332
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14333
+ /**/
1406514334 if ((mod & SHIFT) == SHIFT)
1406614335 {
1406714336 mouseMode = mouseMode;
....@@ -14077,12 +14346,12 @@
1407714346 void GoLeft(int mod)
1407814347 {
1407914348 MODIFIERS |= COMMAND;
14080
- /*
14349
+ /**/
1408114350 if((mod&SHIFT) == SHIFT)
14082
- manipCamera.RotatePosition(speed, 0);
14083
- else
1408414351 manipCamera.Translate(speed*delta, 0, getWidth());
14085
- */
14352
+ else
14353
+ manipCamera.RotatePosition(speed, 0);
14354
+ /**/
1408614355 if ((mod & SHIFT) == SHIFT)
1408714356 {
1408814357 mouseMode = mouseMode;
....@@ -14098,12 +14367,12 @@
1409814367 void GoRight(int mod)
1409914368 {
1410014369 MODIFIERS |= COMMAND;
14101
- /*
14370
+ /**/
1410214371 if((mod&SHIFT) == SHIFT)
14103
- manipCamera.RotatePosition(-speed, 0);
14104
- else
1410514372 manipCamera.Translate(-speed*delta, 0, getWidth());
14106
- */
14373
+ else
14374
+ manipCamera.RotatePosition(-speed, 0);
14375
+ /**/
1410714376 if ((mod & SHIFT) == SHIFT)
1410814377 {
1410914378 mouseMode = mouseMode;
....@@ -14160,7 +14429,8 @@
1416014429 info.camera = renderCamera;
1416114430 info.x = x;
1416214431 info.y = y;
14163
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14432
+ object.GetWindow().copy
14433
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1416414434 } else
1416514435 {
1416614436 if (x < startX)
....@@ -14324,7 +14594,9 @@
1432414594 ci.camera = renderCamera;
1432514595 if (!isRenderer)
1432614596 {
14327
- if (object.editWindow.copy.doEditClick(ci, 0))
14597
+ //ObjEditor editWindow = object.editWindow;
14598
+ //Object3D copy = editWindow.copy;
14599
+ if (object.doEditClick(ci, 0))
1432814600 {
1432914601 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1433014602 } else
....@@ -14336,7 +14608,11 @@
1433614608
1433714609 public void mouseReleased(MouseEvent e)
1433814610 {
14611
+ Globals.MOUSEDRAGGED = false;
14612
+
1433914613 movingcamera = false;
14614
+ X = 0; // getBounds().width/2;
14615
+ Y = 0; // getBounds().height/2;
1434014616 //System.out.println("mouseReleased: " + e);
1434114617 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1434214618 }
....@@ -14359,7 +14635,7 @@
1435914635 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1436014636 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1436114637
14362
- if (control || command || IsFrozen())
14638
+// No delay if (control || command || IsFrozen())
1436314639 timeout = true;
1436414640 // ?? May 2019 else
1436514641 // timer.setDelay((modifiers & 128) != 0?0:350);
....@@ -14677,7 +14953,9 @@
1467714953 case 'E' : COMPACT ^= true;
1467814954 repaint();
1467914955 break;
14680
- case 'W' : DEBUGHSB ^= true;
14956
+ case 'W' : // Wide Window (fullscreen)
14957
+ //DEBUGHSB ^= true;
14958
+ ObjEditor.theFrame.ToggleFullScreen();
1468114959 repaint();
1468214960 break;
1468314961 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14702,8 +14980,8 @@
1470214980 RevertCamera();
1470314981 repaint();
1470414982 break;
14705
- case 'L':
1470614983 case 'l':
14984
+ //case 'L':
1470714985 if (lightMode)
1470814986 {
1470914987 lightMode = false;
....@@ -14846,9 +15124,9 @@
1484615124 case '_':
1484715125 kompactbit = 5;
1484815126 break;
14849
- case '+':
14850
- kompactbit = 6;
14851
- break;
15127
+// case '+':
15128
+// kompactbit = 6;
15129
+// break;
1485215130 case ' ':
1485315131 lightMode ^= true;
1485415132 Globals.lighttouched = true;
....@@ -14860,13 +15138,14 @@
1486015138 case ESC:
1486115139 RENDERPROGRAM += 1;
1486215140 RENDERPROGRAM %= 3;
15141
+
1486315142 repaint();
1486415143 break;
1486515144 case 'Z':
1486615145 //RESIZETEXTURE ^= true;
1486715146 //break;
1486815147 case 'z':
14869
- RENDERSHADOW ^= true;
15148
+ Globals.RENDERSHADOW ^= true;
1487015149 Globals.lighttouched = true;
1487115150 repaint();
1487215151 break;
....@@ -14899,8 +15178,9 @@
1489915178 case DELETE:
1490015179 ClearSelection();
1490115180 break;
14902
- /*
1490315181 case '+':
15182
+
15183
+ /*
1490415184 //fontsize += 1;
1490515185 bbzoom *= 2;
1490615186 repaint();
....@@ -14917,17 +15197,17 @@
1491715197 case '=':
1491815198 IncDepth();
1491915199 //fontsize += 1;
14920
- object.editWindow.refreshContents(true);
15200
+ object.GetWindow().refreshContents(true);
1492115201 maskbit = 6;
1492215202 break;
1492315203 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1492415204 DecDepth();
1492515205 maskbit = 5;
1492615206 //if(fontsize > 1) fontsize -= 1;
14927
- if (object.editWindow == null)
14928
- new Exception().printStackTrace();
14929
- else
14930
- object.editWindow.refreshContents(true);
15207
+// if (object.editWindow == null)
15208
+// new Exception().printStackTrace();
15209
+// else
15210
+ object.GetWindow().refreshContents(true);
1493115211 break;
1493215212 case '{':
1493315213 manipCamera.shaper_fovy /= 1.1;
....@@ -15151,7 +15431,7 @@
1515115431 }
1515215432 */
1515315433
15154
- object.editWindow.EditSelection();
15434
+ object.GetWindow().EditSelection(false);
1515515435 }
1515615436
1515715437 void SelectParent()
....@@ -15168,10 +15448,10 @@
1516815448 {
1516915449 //selectees.remove(i);
1517015450 System.out.println("select parent of " + elem);
15171
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15451
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1517215452 } else
1517315453 {
15174
- group.editWindow.Select(elem.GetTreePath(), first, true);
15454
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1517515455 }
1517615456
1517715457 first = false;
....@@ -15213,12 +15493,12 @@
1521315493 for (int j = 0; j < group.children.size(); j++)
1521415494 {
1521515495 elem = (Object3D) group.children.elementAt(j);
15216
- object.editWindow.Select(elem.GetTreePath(), first, true);
15496
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1521715497 first = false;
1521815498 }
1521915499 } else
1522015500 {
15221
- object.editWindow.Select(elem.GetTreePath(), first, true);
15501
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1522215502 }
1522315503
1522415504 first = false;
....@@ -15229,21 +15509,21 @@
1522915509 {
1523015510 //Composite group = (Composite) object;
1523115511 Object3D group = object;
15232
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15512
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1523315513 }
1523415514
1523515515 void ResetTransform(int mask)
1523615516 {
1523715517 //Composite group = (Composite) object;
1523815518 Object3D group = object;
15239
- group.editWindow.ResetTransform(mask);
15519
+ group.GetWindow().ResetTransform(mask);
1524015520 }
1524115521
1524215522 void FlipTransform()
1524315523 {
1524415524 //Composite group = (Composite) object;
1524515525 Object3D group = object;
15246
- group.editWindow.FlipTransform();
15526
+ group.GetWindow().FlipTransform();
1524715527 // group.editWindow.ReduceMesh(true);
1524815528 }
1524915529
....@@ -15251,7 +15531,7 @@
1525115531 {
1525215532 //Composite group = (Composite) object;
1525315533 Object3D group = object;
15254
- group.editWindow.PrintMemory();
15534
+ group.GetWindow().PrintMemory();
1525515535 // group.editWindow.ReduceMesh(true);
1525615536 }
1525715537
....@@ -15259,7 +15539,7 @@
1525915539 {
1526015540 //Composite group = (Composite) object;
1526115541 Object3D group = object;
15262
- group.editWindow.ResetCentroid();
15542
+ group.GetWindow().ResetCentroid();
1526315543 }
1526415544
1526515545 void IncDepth()
....@@ -15345,7 +15625,9 @@
1534515625 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1534615626 //Image img = CreateImage(width, height);
1534715627 //System.out.println("width = " + width + "; height = " + height + "\n");
15628
+
1534815629 Graphics gr = g; // img.getGraphics();
15630
+
1534915631 if (!hasMarquee)
1535015632 {
1535115633 if (Xmin < Xmax) // !locked)
....@@ -15433,6 +15715,7 @@
1543315715 info.bounds.y += (height - desired) / 2;
1543415716 }
1543515717 }
15718
+
1543615719 info.g = gr;
1543715720 info.camera = renderCamera;
1543815721 /*
....@@ -15442,15 +15725,55 @@
1544215725 */
1544315726 if (!isRenderer)
1544415727 {
15445
- object.drawEditHandles(info, 0);
15728
+ Grafreed.Assert(object != null);
15729
+ Grafreed.Assert(object.selection != null);
15730
+ if (object.selection.Size() > 0)
15731
+ {
15732
+ int hitSomething = object.selection.get(0).hitSomething;
15733
+
15734
+ info.DX = 0;
15735
+ info.DY = 0;
15736
+ info.W = 1;
15737
+ if (hitSomething == Object3D.hitCenter)
15738
+ {
15739
+ info.DX = X;
15740
+ if (X != 0)
15741
+ info.DX -= info.bounds.width/2;
15742
+
15743
+ info.DY = Y;
15744
+ if (Y != 0)
15745
+ info.DY -= info.bounds.height/2;
15746
+ }
15747
+
15748
+ object.drawEditHandles(info, 0);
15749
+
15750
+ if (drag && (X != 0 || Y != 0))
15751
+ {
15752
+ switch (hitSomething)
15753
+ {
15754
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15755
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15756
+ break;
15757
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15758
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15759
+ break;
15760
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15761
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15762
+ break;
15763
+ }
15764
+
15765
+ }
15766
+ }
1544615767 }
1544715768 }
15769
+
1544815770 if (isRenderer)
1544915771 {
1545015772 //gr.setColor(Color.black);
1545115773 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1545215774 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1545315775 }
15776
+
1545415777 if (hasMarquee)
1545515778 {
1545615779 gr.setXORMode(Color.white);
....@@ -15857,7 +16180,7 @@
1585716180 Object3D object;
1585816181 static Object3D trackedobject;
1585916182 Camera renderCamera; // Light or Eye (or Occlusion)
15860
- /*static*/ Camera manipCamera; // Light or Eye
16183
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1586116184 /*static*/ Camera eyeCamera;
1586216185 /*static*/ Camera lightCamera;
1586316186 int cameracount;
....@@ -16142,16 +16465,16 @@
1614216465 cStatic.objectstack[materialdepth++] = checker;
1614316466 //System.out.println("material " + material);
1614416467 //Applet3D.tracein(this, selected);
16145
- vector2buffer = checker.projectedVertices;
16468
+ //vector2buffer = checker.projectedVertices;
1614616469
1614716470 //checker.GetMaterial().Draw(this, false); // true);
16148
- DrawMaterial(checker.GetMaterial(), false); // true);
16471
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1614916472
1615016473 materialdepth -= 1;
1615116474 if (materialdepth > 0)
1615216475 {
16153
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16154
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16476
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16477
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1615516478 }
1615616479 //checker.GetMaterial().opacity = 1f;
1615716480 ////checker.GetMaterial().ambient = 1f;
....@@ -16237,6 +16560,14 @@
1623716560 }
1623816561 }
1623916562
16563
+ private Object3D GetFolder()
16564
+ {
16565
+ Object3D folder = object.GetWindow().copy;
16566
+ if (object.GetWindow().copy.selection.Size() > 0)
16567
+ folder = object.GetWindow().copy.selection.elementAt(0);
16568
+ return folder;
16569
+ }
16570
+
1624016571 class SelectBuffer implements GLEventListener
1624116572 {
1624216573
....@@ -16316,6 +16647,17 @@
1631616647
1631716648 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1631816649
16650
+ if (PAINTMODE)
16651
+ {
16652
+ if (object.GetWindow().copy.selection.Size() > 0)
16653
+ {
16654
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16655
+
16656
+ // Make what you paint not selectable.
16657
+ paintobj.ResetSelectable();
16658
+ }
16659
+ }
16660
+
1631916661 //int tmp = selection_view;
1632016662 //selection_view = -1;
1632116663 int temp = DrawMode();
....@@ -16327,6 +16669,17 @@
1632716669 // temp = DEFAULT; // patch for selection debug
1632816670 Globals.drawMode = temp; // WARNING
1632916671
16672
+ if (PAINTMODE)
16673
+ {
16674
+ if (object.GetWindow().copy.selection.Size() > 0)
16675
+ {
16676
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16677
+
16678
+ // Revert.
16679
+ paintobj.RestoreSelectable();
16680
+ }
16681
+ }
16682
+
1633016683 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1633116684
1633216685 // trying different ways of getting the depth info over
....@@ -16374,6 +16727,8 @@
1637416727 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1637516728 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1637616729 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16730
+
16731
+ CreateSelectedPoint();
1637716732
1637816733 // Will fit the mesh !!!
1637916734 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16423,34 +16778,36 @@
1642316778 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]));
1642416779 }
1642516780
16426
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16781
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1642716782 }
1642816783 }
1642916784
1643016785 if (!movingcamera && !PAINTMODE)
16431
- object.editWindow.ScreenFitPoint(); // fev 2014
16786
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1643216787
16433
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16788
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1643416789 {
16435
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16790
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1643616791
16437
- Object3D group = new Object3D("inst" + paintcount++);
16792
+ if (object.GetWindow().copy.selection.Size() > 0)
16793
+ {
16794
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1643816795
16439
- group.CreateMaterial(); // use a void leaf to select instances
16440
-
16441
- group.add(paintobj); // link
16442
-
16443
- object.editWindow.SnapObject(group);
16444
-
16445
- Object3D folder = object.editWindow.copy;
16446
-
16447
- if (object.editWindow.copy.selection.Size() > 0)
16448
- folder = object.editWindow.copy.selection.elementAt(0);
16449
-
16450
- folder.add(group);
16451
-
16452
- object.editWindow.ResetModel();
16453
- object.editWindow.refreshContents();
16796
+ Object3D inst = new Object3D("inst" + paintcount++);
16797
+
16798
+ inst.CreateMaterial(); // use a void leaf to select instances
16799
+
16800
+ inst.add(paintobj); // link
16801
+
16802
+ object.GetWindow().SnapObject(inst);
16803
+
16804
+ Object3D folder = paintFolder; // GetFolder();
16805
+
16806
+ folder.add(inst);
16807
+
16808
+ object.GetWindow().ResetModel();
16809
+ object.GetWindow().refreshContents();
16810
+ }
1645416811 }
1645516812 else
1645616813 paintcount = 0;
....@@ -16489,6 +16846,11 @@
1648916846 //System.out.println("objects[color] = " + objects[color]);
1649016847 //objects[color].Select();
1649116848 indexcount = 0;
16849
+ ObjEditor window = object.GetWindow();
16850
+ if (window != null && deselect)
16851
+ {
16852
+ window.Select(null, deselect, true);
16853
+ }
1649216854 object.Select(color, deselect);
1649316855 }
1649416856
....@@ -16588,7 +16950,7 @@
1658816950 gl.glDisable(gl.GL_CULL_FACE);
1658916951 }
1659016952
16591
- if (!RENDERSHADOW)
16953
+ if (!Globals.RENDERSHADOW)
1659216954 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659316955
1659416956 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16598,7 +16960,7 @@
1659816960 //gl.glColorMask(false, false, false, false);
1659916961
1660016962 //render_scene_from_light_view(gl, drawable, 0, 0);
16601
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16963
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1660216964 {
1660316965 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1660416966
....@@ -17014,23 +17376,15 @@
1701417376 int AAbuffersize = 0;
1701517377
1701617378 //double[] selectedpoint = new double[3];
17017
- static Superellipsoid selectedpoint = new Superellipsoid();
17379
+ static Superellipsoid selectedpoint;
1701817380 static Sphere previousselectedpoint = null;
17019
- static Sphere debugpointG = new Sphere();
17020
- static Sphere debugpointP = new Sphere();
17021
- static Sphere debugpointC = new Sphere();
17022
- static Sphere debugpointR = new Sphere();
17381
+ static Sphere debugpointG;
17382
+ static Sphere debugpointP;
17383
+ static Sphere debugpointC;
17384
+ static Sphere debugpointR;
1702317385
1702417386 static Sphere debugpoints[] = new Sphere[8];
1702517387
17026
- static
17027
- {
17028
- for (int i=0; i<8; i++)
17029
- {
17030
- debugpoints[i] = new Sphere();
17031
- }
17032
- }
17033
-
1703417388 static void InitPoints(float radius)
1703517389 {
1703617390 for (int i=0; i<8; i++)