Normand Briere
2019-07-21 5a546232b84ce65d8779d29e9171e7e2df013614
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();
....@@ -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
....@@ -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 {
....@@ -7900,7 +7930,7 @@
79007930 String pigment = Object3D.GetPigment(tex);
79017931 String bump = Object3D.GetBump(tex);
79027932
7903
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7933
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79047934 {
79057935 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79067936 // System.out.println("; bump = " + bump);
....@@ -7917,6 +7947,64 @@
79177947
79187948 ReleaseTexture(bump, true);
79197949 ReleaseTexture(pigment, false);
7950
+ }
7951
+
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);
79208008 }
79218009
79228010 void ReleaseTexture(String tex, boolean bump)
....@@ -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)
....@@ -8043,7 +8131,7 @@
80438131 usedtextures.put(pigment, pigment);
80448132 usedtextures.put(bump, bump);
80458133
8046
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8134
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80478135 {
80488136 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80498137 // System.out.println("; bump = " + bump);
....@@ -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,21 +8503,21 @@
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
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83358514 {
83368515 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83378516 {
83388517 return false;
83398518 }
83408519
8341
- boolean newtex = false;
8520
+ //boolean newtex = false;
83428521
83438522 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
83448523
....@@ -8370,7 +8549,7 @@
83708549 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83718550 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83728551
8373
- return newtex;
8552
+ return true; // Warning: not used.
83748553 }
83758554
83768555 ShadowBuffer shadowPBuf;
....@@ -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
....@@ -10323,6 +10526,7 @@
1032310526 ANTIALIAS = 0;
1032410527 //System.out.println("RESTART");
1032510528 AAtimer.restart();
10529
+ Globals.TIMERRUNNING = true;
1032610530 }
1032710531 }
1032810532 }
....@@ -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);
....@@ -11291,15 +11505,36 @@
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();
....@@ -13689,7 +13950,7 @@
1368913950
1369013951 // fev 2014???
1369113952 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13692
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13953
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1369313954 pingthread.StepToTarget(true); // true);
1369413955 }
1369513956 // if (!LIVE)
....@@ -13704,6 +13965,7 @@
1370413965 return;
1370513966
1370613967 AAtimer.restart(); //
13968
+ Globals.TIMERRUNNING = true;
1370713969
1370813970 // waslive = LIVE;
1370913971 // LIVE = false;
....@@ -13776,9 +14038,12 @@
1377614038
1377714039 public void mouseDragged(MouseEvent e)
1377814040 {
14041
+ Globals.MOUSEDRAGGED = true;
14042
+
1377914043 //System.out.println("mouseDragged: " + e);
1378014044 if (isRenderer)
1378114045 movingcamera = true;
14046
+
1378214047 //if (drawing)
1378314048 //return;
1378414049 if ((e.getModifiersEx() & CTRL) != 0
....@@ -14039,12 +14304,12 @@
1403914304 void GoDown(int mod)
1404014305 {
1404114306 MODIFIERS |= COMMAND;
14042
- /*
14307
+ /**/
1404314308 if((mod&SHIFT) == SHIFT)
1404414309 manipCamera.RotatePosition(0, -speed);
1404514310 else
14046
- manipCamera.BackForth(0, -speed*delta, getWidth());
14047
- */
14311
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14312
+ /**/
1404814313 if ((mod & SHIFT) == SHIFT)
1404914314 {
1405014315 mouseMode = mouseMode; // VR??
....@@ -14060,12 +14325,12 @@
1406014325 void GoUp(int mod)
1406114326 {
1406214327 MODIFIERS |= COMMAND;
14063
- /*
14328
+ /**/
1406414329 if((mod&SHIFT) == SHIFT)
1406514330 manipCamera.RotatePosition(0, speed);
1406614331 else
14067
- manipCamera.BackForth(0, speed*delta, getWidth());
14068
- */
14332
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14333
+ /**/
1406914334 if ((mod & SHIFT) == SHIFT)
1407014335 {
1407114336 mouseMode = mouseMode;
....@@ -14081,12 +14346,12 @@
1408114346 void GoLeft(int mod)
1408214347 {
1408314348 MODIFIERS |= COMMAND;
14084
- /*
14349
+ /**/
1408514350 if((mod&SHIFT) == SHIFT)
14086
- manipCamera.RotatePosition(speed, 0);
14087
- else
1408814351 manipCamera.Translate(speed*delta, 0, getWidth());
14089
- */
14352
+ else
14353
+ manipCamera.RotatePosition(speed, 0);
14354
+ /**/
1409014355 if ((mod & SHIFT) == SHIFT)
1409114356 {
1409214357 mouseMode = mouseMode;
....@@ -14102,12 +14367,12 @@
1410214367 void GoRight(int mod)
1410314368 {
1410414369 MODIFIERS |= COMMAND;
14105
- /*
14370
+ /**/
1410614371 if((mod&SHIFT) == SHIFT)
14107
- manipCamera.RotatePosition(-speed, 0);
14108
- else
1410914372 manipCamera.Translate(-speed*delta, 0, getWidth());
14110
- */
14373
+ else
14374
+ manipCamera.RotatePosition(-speed, 0);
14375
+ /**/
1411114376 if ((mod & SHIFT) == SHIFT)
1411214377 {
1411314378 mouseMode = mouseMode;
....@@ -14164,7 +14429,8 @@
1416414429 info.camera = renderCamera;
1416514430 info.x = x;
1416614431 info.y = y;
14167
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14432
+ object.GetWindow().copy
14433
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1416814434 } else
1416914435 {
1417014436 if (x < startX)
....@@ -14328,7 +14594,9 @@
1432814594 ci.camera = renderCamera;
1432914595 if (!isRenderer)
1433014596 {
14331
- if (object.editWindow.copy.doEditClick(ci, 0))
14597
+ //ObjEditor editWindow = object.editWindow;
14598
+ //Object3D copy = editWindow.copy;
14599
+ if (object.doEditClick(ci, 0))
1433214600 {
1433314601 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1433414602 } else
....@@ -14340,7 +14608,11 @@
1434014608
1434114609 public void mouseReleased(MouseEvent e)
1434214610 {
14611
+ Globals.MOUSEDRAGGED = false;
14612
+
1434314613 movingcamera = false;
14614
+ X = 0; // getBounds().width/2;
14615
+ Y = 0; // getBounds().height/2;
1434414616 //System.out.println("mouseReleased: " + e);
1434514617 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1434614618 }
....@@ -14681,7 +14953,9 @@
1468114953 case 'E' : COMPACT ^= true;
1468214954 repaint();
1468314955 break;
14684
- case 'W' : DEBUGHSB ^= true;
14956
+ case 'W' : // Wide Window (fullscreen)
14957
+ //DEBUGHSB ^= true;
14958
+ ObjEditor.theFrame.ToggleFullScreen();
1468514959 repaint();
1468614960 break;
1468714961 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14706,8 +14980,8 @@
1470614980 RevertCamera();
1470714981 repaint();
1470814982 break;
14709
- case 'L':
1471014983 case 'l':
14984
+ //case 'L':
1471114985 if (lightMode)
1471214986 {
1471314987 lightMode = false;
....@@ -14850,9 +15124,9 @@
1485015124 case '_':
1485115125 kompactbit = 5;
1485215126 break;
14853
- case '+':
14854
- kompactbit = 6;
14855
- break;
15127
+// case '+':
15128
+// kompactbit = 6;
15129
+// break;
1485615130 case ' ':
1485715131 lightMode ^= true;
1485815132 Globals.lighttouched = true;
....@@ -14864,13 +15138,14 @@
1486415138 case ESC:
1486515139 RENDERPROGRAM += 1;
1486615140 RENDERPROGRAM %= 3;
15141
+
1486715142 repaint();
1486815143 break;
1486915144 case 'Z':
1487015145 //RESIZETEXTURE ^= true;
1487115146 //break;
1487215147 case 'z':
14873
- RENDERSHADOW ^= true;
15148
+ Globals.RENDERSHADOW ^= true;
1487415149 Globals.lighttouched = true;
1487515150 repaint();
1487615151 break;
....@@ -14903,8 +15178,9 @@
1490315178 case DELETE:
1490415179 ClearSelection();
1490515180 break;
14906
- /*
1490715181 case '+':
15182
+
15183
+ /*
1490815184 //fontsize += 1;
1490915185 bbzoom *= 2;
1491015186 repaint();
....@@ -14921,17 +15197,17 @@
1492115197 case '=':
1492215198 IncDepth();
1492315199 //fontsize += 1;
14924
- object.editWindow.refreshContents(true);
15200
+ object.GetWindow().refreshContents(true);
1492515201 maskbit = 6;
1492615202 break;
1492715203 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1492815204 DecDepth();
1492915205 maskbit = 5;
1493015206 //if(fontsize > 1) fontsize -= 1;
14931
- if (object.editWindow == null)
14932
- new Exception().printStackTrace();
14933
- else
14934
- object.editWindow.refreshContents(true);
15207
+// if (object.editWindow == null)
15208
+// new Exception().printStackTrace();
15209
+// else
15210
+ object.GetWindow().refreshContents(true);
1493515211 break;
1493615212 case '{':
1493715213 manipCamera.shaper_fovy /= 1.1;
....@@ -15155,7 +15431,7 @@
1515515431 }
1515615432 */
1515715433
15158
- object.editWindow.EditSelection();
15434
+ object.GetWindow().EditSelection(false);
1515915435 }
1516015436
1516115437 void SelectParent()
....@@ -15172,10 +15448,10 @@
1517215448 {
1517315449 //selectees.remove(i);
1517415450 System.out.println("select parent of " + elem);
15175
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15451
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1517615452 } else
1517715453 {
15178
- group.editWindow.Select(elem.GetTreePath(), first, true);
15454
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1517915455 }
1518015456
1518115457 first = false;
....@@ -15217,12 +15493,12 @@
1521715493 for (int j = 0; j < group.children.size(); j++)
1521815494 {
1521915495 elem = (Object3D) group.children.elementAt(j);
15220
- object.editWindow.Select(elem.GetTreePath(), first, true);
15496
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1522115497 first = false;
1522215498 }
1522315499 } else
1522415500 {
15225
- object.editWindow.Select(elem.GetTreePath(), first, true);
15501
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1522615502 }
1522715503
1522815504 first = false;
....@@ -15233,21 +15509,21 @@
1523315509 {
1523415510 //Composite group = (Composite) object;
1523515511 Object3D group = object;
15236
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15512
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1523715513 }
1523815514
1523915515 void ResetTransform(int mask)
1524015516 {
1524115517 //Composite group = (Composite) object;
1524215518 Object3D group = object;
15243
- group.editWindow.ResetTransform(mask);
15519
+ group.GetWindow().ResetTransform(mask);
1524415520 }
1524515521
1524615522 void FlipTransform()
1524715523 {
1524815524 //Composite group = (Composite) object;
1524915525 Object3D group = object;
15250
- group.editWindow.FlipTransform();
15526
+ group.GetWindow().FlipTransform();
1525115527 // group.editWindow.ReduceMesh(true);
1525215528 }
1525315529
....@@ -15255,7 +15531,7 @@
1525515531 {
1525615532 //Composite group = (Composite) object;
1525715533 Object3D group = object;
15258
- group.editWindow.PrintMemory();
15534
+ group.GetWindow().PrintMemory();
1525915535 // group.editWindow.ReduceMesh(true);
1526015536 }
1526115537
....@@ -15263,7 +15539,7 @@
1526315539 {
1526415540 //Composite group = (Composite) object;
1526515541 Object3D group = object;
15266
- group.editWindow.ResetCentroid();
15542
+ group.GetWindow().ResetCentroid();
1526715543 }
1526815544
1526915545 void IncDepth()
....@@ -15349,7 +15625,9 @@
1534915625 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1535015626 //Image img = CreateImage(width, height);
1535115627 //System.out.println("width = " + width + "; height = " + height + "\n");
15628
+
1535215629 Graphics gr = g; // img.getGraphics();
15630
+
1535315631 if (!hasMarquee)
1535415632 {
1535515633 if (Xmin < Xmax) // !locked)
....@@ -15437,6 +15715,7 @@
1543715715 info.bounds.y += (height - desired) / 2;
1543815716 }
1543915717 }
15718
+
1544015719 info.g = gr;
1544115720 info.camera = renderCamera;
1544215721 /*
....@@ -15446,15 +15725,55 @@
1544615725 */
1544715726 if (!isRenderer)
1544815727 {
15449
- 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
+ }
1545015767 }
1545115768 }
15769
+
1545215770 if (isRenderer)
1545315771 {
1545415772 //gr.setColor(Color.black);
1545515773 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1545615774 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1545715775 }
15776
+
1545815777 if (hasMarquee)
1545915778 {
1546015779 gr.setXORMode(Color.white);
....@@ -15861,7 +16180,7 @@
1586116180 Object3D object;
1586216181 static Object3D trackedobject;
1586316182 Camera renderCamera; // Light or Eye (or Occlusion)
15864
- /*static*/ Camera manipCamera; // Light or Eye
16183
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1586516184 /*static*/ Camera eyeCamera;
1586616185 /*static*/ Camera lightCamera;
1586716186 int cameracount;
....@@ -16146,16 +16465,16 @@
1614616465 cStatic.objectstack[materialdepth++] = checker;
1614716466 //System.out.println("material " + material);
1614816467 //Applet3D.tracein(this, selected);
16149
- vector2buffer = checker.projectedVertices;
16468
+ //vector2buffer = checker.projectedVertices;
1615016469
1615116470 //checker.GetMaterial().Draw(this, false); // true);
16152
- DrawMaterial(checker.GetMaterial(), false); // true);
16471
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1615316472
1615416473 materialdepth -= 1;
1615516474 if (materialdepth > 0)
1615616475 {
16157
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16158
- 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);
1615916478 }
1616016479 //checker.GetMaterial().opacity = 1f;
1616116480 ////checker.GetMaterial().ambient = 1f;
....@@ -16241,6 +16560,14 @@
1624116560 }
1624216561 }
1624316562
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
+
1624416571 class SelectBuffer implements GLEventListener
1624516572 {
1624616573
....@@ -16320,6 +16647,17 @@
1632016647
1632116648 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1632216649
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
+
1632316661 //int tmp = selection_view;
1632416662 //selection_view = -1;
1632516663 int temp = DrawMode();
....@@ -16331,6 +16669,17 @@
1633116669 // temp = DEFAULT; // patch for selection debug
1633216670 Globals.drawMode = temp; // WARNING
1633316671
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
+
1633416683 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1633516684
1633616685 // trying different ways of getting the depth info over
....@@ -16378,6 +16727,8 @@
1637816727 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1637916728 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1638016729 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16730
+
16731
+ CreateSelectedPoint();
1638116732
1638216733 // Will fit the mesh !!!
1638316734 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16432,29 +16783,31 @@
1643216783 }
1643316784
1643416785 if (!movingcamera && !PAINTMODE)
16435
- object.editWindow.ScreenFitPoint(); // fev 2014
16786
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1643616787
16437
- 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)
1643816789 {
16439
- 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);
1644016791
16441
- Object3D group = new Object3D("inst" + paintcount++);
16792
+ if (object.GetWindow().copy.selection.Size() > 0)
16793
+ {
16794
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1644216795
16443
- group.CreateMaterial(); // use a void leaf to select instances
16444
-
16445
- group.add(paintobj); // link
16446
-
16447
- object.editWindow.SnapObject(group);
16448
-
16449
- Object3D folder = object.editWindow.copy;
16450
-
16451
- if (object.editWindow.copy.selection.Size() > 0)
16452
- folder = object.editWindow.copy.selection.elementAt(0);
16453
-
16454
- folder.add(group);
16455
-
16456
- object.editWindow.ResetModel();
16457
- 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
+ }
1645816811 }
1645916812 else
1646016813 paintcount = 0;
....@@ -16493,6 +16846,11 @@
1649316846 //System.out.println("objects[color] = " + objects[color]);
1649416847 //objects[color].Select();
1649516848 indexcount = 0;
16849
+ ObjEditor window = object.GetWindow();
16850
+ if (window != null && deselect)
16851
+ {
16852
+ window.Select(null, deselect, true);
16853
+ }
1649616854 object.Select(color, deselect);
1649716855 }
1649816856
....@@ -16592,7 +16950,7 @@
1659216950 gl.glDisable(gl.GL_CULL_FACE);
1659316951 }
1659416952
16595
- if (!RENDERSHADOW)
16953
+ if (!Globals.RENDERSHADOW)
1659616954 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659716955
1659816956 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16602,7 +16960,7 @@
1660216960 //gl.glColorMask(false, false, false, false);
1660316961
1660416962 //render_scene_from_light_view(gl, drawable, 0, 0);
16605
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16963
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1660616964 {
1660716965 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1660816966
....@@ -17018,23 +17376,15 @@
1701817376 int AAbuffersize = 0;
1701917377
1702017378 //double[] selectedpoint = new double[3];
17021
- static Superellipsoid selectedpoint = new Superellipsoid();
17379
+ static Superellipsoid selectedpoint;
1702217380 static Sphere previousselectedpoint = null;
17023
- static Sphere debugpointG = new Sphere();
17024
- static Sphere debugpointP = new Sphere();
17025
- static Sphere debugpointC = new Sphere();
17026
- static Sphere debugpointR = new Sphere();
17381
+ static Sphere debugpointG;
17382
+ static Sphere debugpointP;
17383
+ static Sphere debugpointC;
17384
+ static Sphere debugpointR;
1702717385
1702817386 static Sphere debugpoints[] = new Sphere[8];
1702917387
17030
- static
17031
- {
17032
- for (int i=0; i<8; i++)
17033
- {
17034
- debugpoints[i] = new Sphere();
17035
- }
17036
- }
17037
-
1703817388 static void InitPoints(float radius)
1703917389 {
1704017390 for (int i=0; i<8; i++)