Normand Briere
2019-05-13 f924d3e00db476c06f55f3d5aaef307e17575340
Object3D.java
....@@ -5,6 +5,7 @@
55 import java.util.Vector;
66
77 import javax.media.j3d.Transform3D;
8
+import javax.media.opengl.GL;
89 import javax.vecmath.Vector3d;
910
1011 import javax.imageio.ImageIO;
....@@ -20,6 +21,19 @@
2021 static final long serialVersionUID = 5022536242724664900L;
2122
2223 ScriptNode scriptnode;
24
+
25
+ void InitOthers()
26
+ {
27
+ if (projectedVertices == null || projectedVertices.length <= 2)
28
+ {
29
+ projectedVertices = new Object3D.cVector2[3];
30
+ }
31
+ for (int i = 0; i < 3; i++)
32
+ {
33
+ projectedVertices[i] = new cVector2(); // Others
34
+ }
35
+ projectedVertices[0].x = 100; // bump
36
+ }
2337
2438 void MinMax(cVector minima, cVector maxima)
2539 {
....@@ -296,6 +310,8 @@
296310 boolean speedup = false;
297311 boolean rewind = false;
298312
313
+ float NORMALPUSH = 0;
314
+
299315 Object3D support;
300316
301317 Object3D GetObject()
....@@ -415,16 +431,16 @@
415431 {
416432 Object3D copy = this;
417433
418
- Camera parentcam = CameraPane.theRenderer.manipCamera;
434
+ Camera parentcam = Globals.theRenderer.ManipCamera();
419435
420
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
436
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
421437 {
422
- parentcam = CameraPane.theRenderer.cameras[1];
438
+ parentcam = Globals.theRenderer.Cameras()[1];
423439 }
424440
425
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
441
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
426442 {
427
- parentcam = CameraPane.theRenderer.cameras[0];
443
+ parentcam = Globals.theRenderer.Cameras()[0];
428444 }
429445
430446 if (this == parentcam)
....@@ -432,7 +448,7 @@
432448 //assert(this instanceof Camera);
433449
434450 for (int count = parentcam.GetTransformCount(); --count>=0;)
435
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
451
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
436452 }
437453
438454 copy.marked ^= true;
....@@ -452,7 +468,7 @@
452468 //assert(this instanceof Camera);
453469
454470 for (int count = parentcam.GetTransformCount(); --count>=0;)
455
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
471
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
456472 }
457473
458474 copy.Touch(); // display list issue
....@@ -587,7 +603,7 @@
587603 return;
588604 }
589605
590
- if (CameraPane.fromscript)
606
+ if (Globals.fromscript)
591607 {
592608 transformcount = 0;
593609 return;
....@@ -745,7 +761,7 @@
745761
746762 int GetTransformCount()
747763 {
748
- // marde pour serialization de Texture
764
+ // patch pour serialization de Texture
749765 resetmaxcount();
750766 resettransformcount();
751767 resetstep();
....@@ -779,9 +795,12 @@
779795 // factor = CameraPane.STEP;
780796 // }
781797
782
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
798
+ if (marked && Globals.isLIVE() && live &&
799
+ //TEMP21aug2018
800
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
801
+ currentframe != Globals.framecount)
783802 {
784
- currentframe = CameraPane.framecount;
803
+ currentframe = Globals.framecount;
785804
786805 // System.err.println("transformcount = " + transformcount);
787806 // System.err.println("factor = " + factor);
....@@ -893,6 +912,11 @@
893912 fromParent = null; // LA.newMatrix();
894913 bRep = null; // new BoundaryRep();
895914
915
+ if (oname != null && oname.equals("LeftHand"))
916
+ {
917
+ name = oname;
918
+ }
919
+
896920 /*
897921 float hue = (float)Math.random();
898922 Color col;
....@@ -935,7 +959,7 @@
935959
936960 public Object clone()
937961 {
938
- return GrafreeD.clone(this);
962
+ return Grafreed.clone(this);
939963 }
940964
941965 Object3D copyExpand()
....@@ -1451,7 +1475,7 @@
14511475 BoundaryRep.SEUIL = other.material.cameralight;
14521476
14531477 // Set default to 0.1
1454
- BoundaryRep.SEUIL /= 2;
1478
+ BoundaryRep.SEUIL /= 4; // 2;
14551479 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14561480 }
14571481
....@@ -1710,7 +1734,7 @@
17101734 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17111735 o.bRep = transientrep;
17121736 if (clone)
1713
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1737
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17141738 o.CreateMaterial();
17151739 o.SetAttributes(this, -1);
17161740 //parent
....@@ -1723,7 +1747,7 @@
17231747 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17241748 o.bRep = bRep;
17251749 if (clone)
1726
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1750
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17271751 o.CreateMaterial();
17281752 //o.overwriteThis(this, -1);
17291753 o.SetAttributes(this, -1);
....@@ -2130,15 +2154,8 @@
21302154 if (/*parent != null &&*/ material == null)
21312155 {
21322156 material = new cMaterial(GetMaterial());
2133
- if (projectedVertices == null || projectedVertices.length <= 2)
2134
- {
2135
- projectedVertices = new Object3D.cVector2[3];
2136
- }
2137
- for (int i = 0; i < 3; i++)
2138
- {
2139
- projectedVertices[i] = new cVector2(); // Others
2140
- }
2141
- projectedVertices[0].x = 100; // bump
2157
+
2158
+ InitOthers();
21422159
21432160 if (this instanceof Camera)
21442161 {
....@@ -2288,6 +2305,7 @@
22882305 {
22892306 if (newWindow)
22902307 {
2308
+ new Exception().printStackTrace();
22912309 System.exit(0);
22922310 if (parent != null)
22932311 {
....@@ -2464,13 +2482,13 @@
24642482 return retval;
24652483 }
24662484
2467
- void doEditDrag(ClickInfo info)
2485
+ void doEditDrag(ClickInfo info, boolean opposite)
24682486 {
24692487 switch (doSomething)
24702488 {
24712489 case 1: // '\001'
24722490 //super.
2473
- doEditDrag0(info);
2491
+ doEditDrag0(info, opposite);
24742492 break;
24752493
24762494 case 2: // '\002'
....@@ -2483,11 +2501,11 @@
24832501 {
24842502 //sel.hitSomething = childToDrag.hitSomething;
24852503 //childToDrag.doEditDrag(info);
2486
- sel.doEditDrag(info);
2504
+ sel.doEditDrag(info, opposite);
24872505 } else
24882506 {
24892507 //super.
2490
- doEditDrag0(info);
2508
+ doEditDrag0(info, opposite);
24912509 }
24922510 }
24932511 break;
....@@ -2894,7 +2912,8 @@
28942912 {
28952913 if (bRep != null)
28962914 {
2897
- bRep.GenUV();
2915
+ bRep.GenUV(); //1);
2916
+ //bRep.UnfoldUV();
28982917 Touch();
28992918 }
29002919 }
....@@ -2969,6 +2988,31 @@
29692988 blockloop = false;
29702989 }
29712990
2991
+ void TransformChildren()
2992
+ {
2993
+ if (toParent != null)
2994
+ {
2995
+ for (int i=Size(); --i>=0;)
2996
+ {
2997
+ Object3D v = get(i);
2998
+
2999
+ if (v.toParent == null)
3000
+ {
3001
+ v.toParent = LA.newMatrix();
3002
+ v.fromParent = LA.newMatrix();
3003
+ }
3004
+
3005
+ LA.matConcat(v.toParent, toParent, v.toParent);
3006
+ LA.matConcat(fromParent, v.fromParent, v.fromParent);
3007
+ }
3008
+
3009
+ toParent = null; // LA.matIdentity(toParent);
3010
+ fromParent = null; // LA.matIdentity(fromParent);
3011
+
3012
+ Touch();
3013
+ }
3014
+ }
3015
+
29723016 void TransformGeometry()
29733017 {
29743018 Object3D obj = this;
....@@ -3190,7 +3234,7 @@
31903234
31913235 BoundaryRep sup = bRep.support;
31923236 bRep.support = null;
3193
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3237
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31943238 // bRep.SplitInTwo(onlyone); // thread...
31953239 temprep.SplitInTwo(reduction34, onlyone);
31963240 bRep = temprep;
....@@ -3714,7 +3758,7 @@
37143758 if (child == null)
37153759 continue;
37163760
3717
- if (GrafreeD.RENDERME > 0)
3761
+ if (Grafreed.RENDERME > 0)
37183762 {
37193763 if (child instanceof Merge)
37203764 ((Merge)child).renderme();
....@@ -3865,7 +3909,7 @@
38653909 if (child == null)
38663910 continue;
38673911
3868
- if (GrafreeD.RENDERME > 0)
3912
+ if (Grafreed.RENDERME > 0)
38693913 {
38703914 if (child instanceof Merge)
38713915 ((Merge)child).renderme();
....@@ -4060,7 +4104,7 @@
40604104 if (child == null)
40614105 continue;
40624106
4063
- if (GrafreeD.RENDERME > 0)
4107
+ if (Grafreed.RENDERME > 0)
40644108 {
40654109 if (child instanceof Merge)
40664110 ((Merge)child).renderme();
....@@ -4157,6 +4201,22 @@
41574201 }
41584202 blockloop = true;
41594203 get(i).RepairParent();
4204
+ blockloop = false;
4205
+ }
4206
+ }
4207
+
4208
+ void RepairShadow()
4209
+ {
4210
+ if (blockloop)
4211
+ return;
4212
+
4213
+ if (this.material != null)
4214
+ this.InitOthers();
4215
+
4216
+ for (int i=0; i<Size(); i++)
4217
+ {
4218
+ blockloop = true;
4219
+ get(i).RepairShadow();
41604220 blockloop = false;
41614221 }
41624222 }
....@@ -4827,7 +4887,7 @@
48274887 return globalTransform;
48284888 }
48294889
4830
- void PreprocessOcclusion(CameraPane cp)
4890
+ void PreprocessOcclusion(iCameraPane cp)
48314891 {
48324892 /*
48334893 if (AOdone)
....@@ -4974,7 +5034,8 @@
49745034 } else //
49755035 if (editWindow != null)
49765036 {
4977
- editWindow.cameraView.lighttouched = true;
5037
+ //editWindow.cameraView.lighttouched = true;
5038
+ Globals.lighttouched = true;
49785039 }
49795040 }
49805041
....@@ -5128,10 +5189,34 @@
51285189
51295190 // System.out.println("Fullname = " + fullname);
51305191
5131
- if (fullname.name.indexOf(":") == -1)
5132
- return fullname.name;
5192
+ // Does not work on Windows due to C:
5193
+// if (fullname.name.indexOf(":") == -1)
5194
+// return fullname.name;
5195
+//
5196
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51335197
5134
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5198
+ String[] split = fullname.name.split(":");
5199
+
5200
+ if (split.length == 0)
5201
+ {
5202
+ return "";
5203
+ }
5204
+
5205
+ if (split.length <= 2)
5206
+ {
5207
+ if (fullname.name.endsWith(":"))
5208
+ {
5209
+ // Windows
5210
+ return fullname.name.substring(0, fullname.name.length()-1);
5211
+ }
5212
+
5213
+ return split[0];
5214
+ }
5215
+
5216
+ // Windows
5217
+ assert(split.length == 4);
5218
+
5219
+ return split[0] + ":" + split[1];
51355220 }
51365221
51375222 static String GetBump(cTexture fullname)
....@@ -5140,10 +5225,38 @@
51405225 return "";
51415226
51425227 // System.out.println("Fullname = " + fullname);
5143
- if (fullname.name.indexOf(":") == -1)
5144
- return "";
5145
-
5146
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5228
+ // Does not work on Windows due to C:
5229
+// if (fullname.name.indexOf(":") == -1)
5230
+// return "";
5231
+//
5232
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5233
+ String[] split = fullname.name.split(":");
5234
+
5235
+ if (split.length == 0)
5236
+ {
5237
+ return "";
5238
+ }
5239
+
5240
+ if (split.length == 1)
5241
+ {
5242
+ return "";
5243
+ }
5244
+
5245
+ if (split.length == 2)
5246
+ {
5247
+ if (fullname.name.endsWith(":"))
5248
+ {
5249
+ // Windows
5250
+ return "";
5251
+ }
5252
+
5253
+ return split[1];
5254
+ }
5255
+
5256
+ // Windows
5257
+ assert(split.length == 4);
5258
+
5259
+ return split[2] + ":" + split[3];
51475260 }
51485261
51495262 String GetPigmentTexture()
....@@ -5217,7 +5330,7 @@
52175330 System.out.print("; textures = " + textures);
52185331 System.out.println("; usedtextures = " + usedtextures);
52195332
5220
- if (GetTextures() == null)
5333
+ if (GetTextures() == null) // What is that??
52215334 GetTextures().name = ":";
52225335
52235336 String texname = tex;
....@@ -5286,25 +5399,22 @@
52865399 }
52875400 }
52885401
5289
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5402
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52905403 {
52915404 Draw(display, root, selected, blocked);
52925405 }
52935406
5294
- static cMaterial[] materialstack = new cMaterial[65536];
5295
- static boolean[] selectedstack = new boolean[65536];
5296
- static int materialdepth = 0;
5297
-
52985407 boolean NeedSupport()
52995408 {
53005409 return
53015410 CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
53025411 // PROBLEM with CROWD!!
5303
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5412
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53045413 }
53055414
5415
+ static boolean DEBUG_SELECTION = false;
53065416
5307
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5417
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53085418 {
53095419 Invariants(); // june 2013
53105420
....@@ -5313,7 +5423,7 @@
53135423 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
53145424 }
53155425
5316
- if (display.drawMode == CameraPane.SELECTION &&
5426
+ if (display.DrawMode() == iCameraPane.SELECTION &&
53175427 hide)
53185428 return;
53195429
....@@ -5332,7 +5442,7 @@
53325442 if (this instanceof Checker)
53335443 return;
53345444
5335
- if (display.drawMode == display.SHADOW && PASSTEST)
5445
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
53365446 return;
53375447
53385448 if (count <= 0)
....@@ -5340,13 +5450,13 @@
53405450 return;
53415451 }
53425452
5343
- if ((//display.drawMode == CameraPane.SHADOW ||
5344
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5453
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5454
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53455455 {
53465456 return;
53475457 }
53485458
5349
- javax.media.opengl.GL gl = display.GetGL();
5459
+ //javax.media.opengl.GL gl = display.GetGL();
53505460
53515461 /*
53525462 if (touched)
....@@ -5382,15 +5492,15 @@
53825492
53835493 boolean compiled = false;
53845494
5385
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5495
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53865496
5387
- if (!selectmode && //display.drawMode != display.SELECTION &&
5497
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
53885498 (touched || (bRep != null && bRep.displaylist <= 0)))
53895499 {
5390
- display.lighttouched = true;
5500
+ Globals.lighttouched = true;
53915501 } // all panes...
5392
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5393
- if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW &&
5502
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5503
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53945504 (touched || (bRep != null && bRep.displaylist <= 0)))
53955505 {
53965506 if (!(this instanceof Composite))
....@@ -5398,7 +5508,7 @@
53985508 //if (displaylist == -1 && usecalllists)
53995509 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54005510 {
5401
- bRep.displaylist = gl.glGenLists(1);
5511
+ bRep.displaylist = display.GenList();
54025512 assert(bRep.displaylist != 0);
54035513 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54045514 //System.out.println("\tgen list " + list);
....@@ -5410,18 +5520,20 @@
54105520 if (usecalllists)
54115521 {
54125522 // System.err.println("new list " + bRep.displaylist + " for " + this);
5413
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5523
+ display.NewList(bRep.displaylist);
54145524 }
5525
+
54155526 CallList(display, root, selected, blocked);
5527
+
54165528 // compiled = true;
54175529 if (usecalllists)
54185530 {
54195531 // System.err.println("end list " + bRep.displaylist + " for " + this);
5420
- gl.glEndList();
5532
+ display.EndList();
54215533 }
54225534 //gl.glDrawBuffer(gl.GL_BACK);
54235535 // XXX touched = false;
5424
- display.lighttouched = true; // all panes...
5536
+ Globals.lighttouched = true; // all panes...
54255537 }
54265538
54275539 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5460,12 +5572,12 @@
54605572
54615573 // frustum culling
54625574 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5463
- && display.drawMode != CameraPane.SELECTION)
5575
+ && display.DrawMode() != iCameraPane.SELECTION)
54645576 {
5465
- if (display.drawMode == CameraPane.SHADOW)
5577
+ if (display.DrawMode() == iCameraPane.SHADOW)
54665578 {
54675579 if (!link2master // tricky to cull in shadow mode.
5468
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5580
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54695581 {
54705582 //System.out.print("CULLED");
54715583 culled = true;
....@@ -5473,7 +5585,7 @@
54735585 }
54745586 else
54755587 //GetBRep().getBounds(v0, v1, this);
5476
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5588
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54775589 culled = true;
54785590
54795591 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5509,11 +5621,11 @@
55095621
55105622
55115623 if (!culled)
5512
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5624
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55135625 {
55145626 if (GetBRep() != null)
55155627 {
5516
- CameraPane.NextIndex(this, gl);
5628
+ display.NextIndex();
55175629 // vertex color conflict : gl.glCallList(list);
55185630 DrawNode(display, root, selected);
55195631 if (this instanceof BezierPatch)
....@@ -5535,55 +5647,7 @@
55355647 color[2] /= 2;
55365648 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55375649 */
5538
- if (material != null)
5539
- {
5540
- materialstack[materialdepth] = material;
5541
- selectedstack[materialdepth] = selected;
5542
- cStatic.objectstack[materialdepth++] = this;
5543
- //System.out.println("material " + material);
5544
- //Applet3D.tracein(this, selected);
5545
- display.vector2buffer = projectedVertices;
5546
- if (this instanceof Camera)
5547
- {
5548
- display.options1[0] = material.shift;
5549
- //System.out.println("shift " + material.shift);
5550
- display.options1[1] = material.lightarea;
5551
- display.options1[2] = material.shadowbias;
5552
- display.options1[3] = material.aniso;
5553
- display.options1[4] = material.anisoV;
5554
- display.options2[0] = material.opacity;
5555
- display.options2[1] = material.diffuse;
5556
- display.options2[2] = material.factor;
5557
-
5558
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5559
- display.options4[0] = material.cameralight/0.2f;
5560
- display.options4[1] = material.subsurface;
5561
- display.options4[2] = material.sheen;
5562
-
5563
- // if (display.CURRENTANTIALIAS > 0)
5564
- // display.options3[3] /= 4;
5565
-
5566
- /*
5567
- System.out.println("Focus = " + display.options1[0]);
5568
- System.out.println("Aperture = " + display.options1[1]);
5569
- System.out.println("ShadowBlur = " + display.options1[2]);
5570
- System.out.println("Antialiasing = " + display.options1[3]);
5571
- System.out.println("Fog = " + display.options2[0]);
5572
- System.out.println("Intensity = " + display.options2[1]);
5573
- System.out.println("Elevation = " + display.options2[2]);
5574
- /**/
5575
- } else
5576
- {
5577
- material.Draw(display, selected);
5578
- }
5579
- } else
5580
- {
5581
- if (selected && CameraPane.flash)
5582
- {
5583
- display.modelParams4[1] = 100;
5584
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5585
- }
5586
- }
5650
+ display.PushMaterial(this, selected);
55875651
55885652 //System.out.println("call list " + list);
55895653 //System.out.println();
....@@ -5618,30 +5682,15 @@
56185682
56195683 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
56205684 assert(bRep.displaylist != 0);
5621
- gl.glCallList(bRep.displaylist);
5685
+ display.CallList(bRep.displaylist);
56225686 // june 2013 drawSelf(display, root, selected);
56235687 }
56245688 }
56255689 }
56265690
56275691 display.ReleaseTextures(tex);
5628
-
5629
- //if (parent != null && parent.GetMaterial() != null)
5630
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5631
- if (material != null)
5632
- {
5633
- materialdepth -= 1;
5634
- if (materialdepth > 0)
5635
- {
5636
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5637
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5638
- }
5639
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5640
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5641
- {
5642
- display.modelParams4[1] = GetMaterial().cameralight;
5643
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5644
- }
5692
+
5693
+ display.PopMaterial(this, selected);
56455694 }
56465695
56475696 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5683,7 +5732,7 @@
56835732 // resetMasterNode();
56845733 }
56855734
5686
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5735
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56875736 {
56885737 if (GetBRep() == null)
56895738 {
....@@ -5766,7 +5815,7 @@
57665815 boolean flipV = false; // true;
57675816 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57685817
5769
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5818
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57705819 {
57715820 if (hide)
57725821 return;
....@@ -5825,16 +5874,7 @@
58255874 // // ??????????????????????????? Touch();
58265875 // }
58275876
5828
- if (material != null)
5829
- {
5830
- materialstack[materialdepth] = material;
5831
- selectedstack[materialdepth] = selected;
5832
- cStatic.objectstack[materialdepth++] = this;
5833
- //System.out.println("material " + material);
5834
- //Applet3D.tracein("selected ", selected);
5835
- display.vector2buffer = projectedVertices;
5836
- material.Draw(display, selected);
5837
- }
5877
+display.PushMaterial2(this, selected);
58385878
58395879 Object3D child;
58405880 boolean sel;
....@@ -5886,19 +5926,7 @@
58865926 */
58875927 //depth += 1;
58885928
5889
- if (material != null)
5890
- {
5891
- materialdepth -= 1;
5892
- if (materialdepth > 0)
5893
- {
5894
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5895
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5896
- }
5897
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5898
- //else
5899
- //material.Draw(display, false);
5900
- }
5901
-
5929
+display.PopMaterial2(this);
59025930 /*
59035931 display.ReleaseTextures(tex);
59045932 */
....@@ -5909,9 +5937,9 @@
59095937
59105938 //static cVector min,max;
59115939
5912
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
5940
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
59135941 {
5914
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
5942
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59155943 return; // no shadow for transparent objects
59165944
59175945 if (hide)
....@@ -5954,11 +5982,12 @@
59545982 return;
59555983 }
59565984
5985
+ //bRep.GenUV(1/material.diffuseness);
59575986 // bRep.lock = true;
59585987
5959
- javax.media.opengl.GL gl = display.GetGL();
5988
+ //javax.media.opengl.GL gl = display.GetGL();
59605989
5961
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
5990
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59625991 {
59635992 int fc = bRep.FaceCount();
59645993 int vc = bRep.VertexCount();
....@@ -5973,23 +6002,7 @@
59736002
59746003 bRep.getMinMax(min, max, 100);
59756004
5976
- gl.glBegin(gl.GL_LINES);
5977
-
5978
- gl.glVertex3d(min.x, min.y, min.z);
5979
- gl.glVertex3d(min.x, min.y, max.z);
5980
- gl.glVertex3d(min.x, min.y, min.z);
5981
- gl.glVertex3d(min.x, max.y, min.z);
5982
- gl.glVertex3d(min.x, min.y, min.z);
5983
- gl.glVertex3d(max.x, min.y, min.z);
5984
-
5985
- gl.glVertex3d(max.x, max.y, max.z);
5986
- gl.glVertex3d(min.x, max.y, max.z);
5987
- gl.glVertex3d(max.x, max.y, max.z);
5988
- gl.glVertex3d(max.x, min.y, max.z);
5989
- gl.glVertex3d(max.x, max.y, max.z);
5990
- gl.glVertex3d(max.x, max.y, min.z);
5991
-
5992
- gl.glEnd();
6005
+ display.DrawBox(min, max);
59936006
59946007 return;
59956008 }
....@@ -6033,7 +6046,7 @@
60336046 {
60346047 //throw new Error();
60356048
6036
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6049
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60376050
60386051 int[] strips = bRep.getRawIndices();
60396052
....@@ -6043,178 +6056,14 @@
60436056 new Exception().printStackTrace();
60446057 return;
60456058 }
6046
-
6047
- // TRIANGLE STRIP ARRAY
6048
- if (bRep.trimmed)
6049
- {
6050
- float[] v = bRep.getRawVertices();
6051
- float[] n = bRep.getRawNormals();
6052
- float[] c = bRep.getRawColors();
6053
- float[] uv = bRep.getRawUVMap();
6054
-
6055
- int count2 = 0;
6056
- int count3 = 0;
6057
-
6058
- if (n.length > 0)
6059
- {
6060
- for (int i = 0; i < strips.length; i++)
6061
- {
6062
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6063
-
6064
- /*
6065
- boolean locked = false;
6066
- float eps = 0.1f;
6067
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6068
-
6069
- int dot = 0;
6070
-
6071
- if ((dot&1) == 0)
6072
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6073
-
6074
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6075
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6076
- else
6077
- {
6078
- locked = true;
6079
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6080
- }
6081
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6082
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6083
- if (hasnorm)
6084
- {
6085
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6086
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6087
- }
6088
-
6089
- if ((dot&4) == 0)
6090
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6091
-
6092
- if (wrap || !locked && (dot&8) != 0)
6093
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6094
- else
6095
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6096
-
6097
- f.dot = dot;
6098
- */
6099
-
6100
- if (!selectmode)
6101
- {
6102
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6103
- {
6104
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6105
- } else
6106
- {
6107
- gl.glNormal3f(0, 0, 1);
6108
- }
6109
-
6110
- if (c != null)
6111
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6112
- {
6113
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6114
- }
6115
- }
6116
- if (flipV)
6117
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6118
- else
6119
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6120
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6121
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6122
-
6123
- count2 += 2;
6124
- count3 += 3;
6125
- if (!selectmode)
6126
- {
6127
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6128
- {
6129
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6130
- } else
6131
- {
6132
- gl.glNormal3f(0, 0, 1);
6133
- }
6134
- if (c != null)
6135
- {
6136
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6137
- }
6138
- }
6139
- if (flipV)
6140
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6141
- else
6142
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6143
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6144
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6145
-
6146
- count2 += 2;
6147
- count3 += 3;
6148
- for (int j = 0; j < strips[i] - 2; j++)
6149
- {
6150
- //gl.glTexCoord2d(...);
6151
- if (!selectmode)
6152
- {
6153
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6154
- {
6155
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6156
- } else
6157
- {
6158
- gl.glNormal3f(0, 0, 1);
6159
- }
6160
- if (c != null)
6161
- {
6162
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6163
- }
6164
- }
6165
-
6166
- if (flipV)
6167
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6168
- else
6169
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6170
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6171
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6172
- count2 += 2;
6173
- count3 += 3;
6174
- }
6175
-
6176
- gl.glEnd();
6177
- }
6178
- }
6179
-
6180
- assert count3 == v.length;
6181
- }
6182
- else // !trimmed
6183
- {
6184
- int count = 0;
6185
- for (int i = 0; i < strips.length; i++)
6186
- {
6187
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6188
-
6189
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6190
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6191
-
6192
- drawVertex(gl, p, selectmode);
6193
- drawVertex(gl, q, selectmode);
6194
-
6195
- for (int j = 0; j < strips[i] - 2; j++)
6196
- {
6197
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6198
-
6199
-// if (j%2 == 0)
6200
-// drawFace(p, q, r, display, null);
6201
-// else
6202
-// drawFace(p, r, q, display, null);
6203
-
6204
-// p = q;
6205
-// q = r;
6206
- drawVertex(gl, r, selectmode);
6207
- }
6208
-
6209
- gl.glEnd();
6210
- }
6211
- }
6059
+
6060
+ display.DrawGeometry(bRep, flipV, selectmode);
62126061 } else // catch (Error e)
62136062 {
62146063 // TRIANGLE ARRAY
62156064 if (IsOpaque()) // Static())
62166065 {
6217
- gl.glBegin(gl.GL_TRIANGLES);
6066
+ display.StartTriangles();
62186067 int facecount = bRep.FaceCount();
62196068 for (int i = 0; i < facecount; i++)
62206069 {
....@@ -6277,9 +6126,9 @@
62776126 // // r.norm.dot(v3) > -0.5)
62786127 // // continue;
62796128
6280
- drawFace(p, q, r, display, face);
6129
+ display.DrawFace(this, p, q, r, face);
62816130 }
6282
- gl.glEnd();
6131
+ display.EndTriangles();
62836132 }
62846133 else
62856134 {
....@@ -6308,8 +6157,8 @@
63086157 //System.out.println("SORT");
63096158
63106159 java.util.Arrays.sort(facescompare);
6311
-
6312
- gl.glBegin(gl.GL_TRIANGLES);
6160
+
6161
+ display.StartTriangles();
63136162 for (int i = 0; i < facecount; i++)
63146163 {
63156164 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6321,13 +6170,14 @@
63216170 Vertex q = bRep.GetVertex(face.q);
63226171 Vertex r = bRep.GetVertex(face.r);
63236172
6324
- drawFace(p, q, r, display, face);
6173
+ display.DrawFace(this, p, q, r, face);
63256174 }
6326
- gl.glEnd();
6175
+ display.EndTriangles();
63276176 }
63286177
63296178 if (false) // live && support != null && support.bRep != null) // debug weights
63306179 {
6180
+ /*
63316181 gl.glDisable(gl.GL_LIGHTING);
63326182 float[] colorV = new float[3];
63336183
....@@ -6406,6 +6256,7 @@
64066256 // gl.glEnd();
64076257 }
64086258 }
6259
+ */
64096260 }
64106261 }
64116262
....@@ -6450,7 +6301,7 @@
64506301 center.add(r);
64516302 center.mul(1.0/3);
64526303
6453
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6304
+ center.sub(Globals.theRenderer.EyeCamera().location);
64546305
64556306 distance = center.dot(center);
64566307 }
....@@ -6461,347 +6312,11 @@
64616312
64626313 transient FaceCompare[] facescompare = null;
64636314
6464
- void SetColor(CameraPane display, Vertex p0)
6465
- {
6466
- if (display.RENDERPROGRAM == 0)
6467
- {
6468
- float r = 0;
6469
- if (bRep != null)
6470
- {
6471
- if (bRep.stripified)
6472
- {
6473
- r = 1;
6474
- }
6475
- }
6476
- float g = 0;
6477
- if (bRep != null)
6478
- {
6479
- if (bRep.trimmed)
6480
- {
6481
- g = 1;
6482
- }
6483
- }
6484
- float b = 0;
6485
- if (support != null && link2master)
6486
- {
6487
- b = 1;
6488
- }
6489
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6490
- return;
6491
- }
6492
-
6493
- if (display.drawMode != CameraPane.SHADOW)
6494
- return;
6495
-
6496
- javax.media.opengl.GL gl = display.GetGL();
6497
-// if (true) return;
6498
-// float ao = p.AO;
6499
-//
6500
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6501
-// // ao = 1;
6502
-//
6503
-// gl.glColor4f(ao, ao, ao, 1);
6504
-
6505
-// CameraPane.selectedpoint.
6506
-// getAverage(cStatic.point1, true);
6507
- if (CameraPane.pointflow == null) // !random) // live)
6508
- {
6509
- return;
6510
- }
6511
-
6512
- cStatic.point1.set(0,0,0);
6513
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6514
-
6515
- cStatic.point1.sub(p0);
6516
-
6517
-
6518
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6519
-// {
6520
-// return;
6521
-// }
6522
-
6523
- //if (true)
6524
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6525
- {
6526
- return;
6527
- }
6528
-
6529
- float[] colorV = new float[3];
6530
-
6531
- if (false) // marked)
6532
- {
6533
- // debug rigging weights
6534
- for (int object = 0; object < p0.vertexlinks.length; object++)
6535
- {
6536
- float weight = p0.weights[object] / p0.totalweight;
6537
-
6538
- // if (weight < 0.1)
6539
- // {
6540
- // assert(weight == 0);
6541
- // continue;
6542
- // }
6543
-
6544
- if (p0.vertexlinks[object] == -1)
6545
- continue;
6546
-
6547
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6548
-
6549
- int color = //1 << object; //
6550
- //p.vertexlinks.length;
6551
- support.bRep.supports[p0.closestsupport].links[object];
6552
- colorV[2] += (color & 1) * weight;
6553
- colorV[1] += ((color & 2) >> 1) * weight;
6554
- colorV[0] += ((color & 4) >> 2) * weight;
6555
- }
6556
- }
6557
- else
6558
- {
6559
- if (drawingstarted)
6560
- {
6561
- // find next point
6562
- if (bRep.GetVertex(0).faceindices == null)
6563
- {
6564
- bRep.InitFaceIndices();
6565
- }
6566
-
6567
- double ymin = p0.y;
6568
-
6569
- Vertex newp = p0;
6570
-
6571
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6572
- {
6573
- int fi = p0.faceindices[fii];
6574
-
6575
- if (fi == -1)
6576
- break;
6577
-
6578
- Face f = bRep.GetFace(fi);
6579
-
6580
- Vertex p = bRep.GetVertex(f.p);
6581
- Vertex q = bRep.GetVertex(f.q);
6582
- Vertex r = bRep.GetVertex(f.r);
6583
-
6584
- int swap = (int)(Math.random()*3);
6585
-
6586
-// for (int s=swap; --s>=0;)
6587
-// {
6588
-// Vertex t = p;
6589
-// p = q;
6590
-// q = r;
6591
-// r = t;
6592
-// }
6593
- if (ymin > p.y)
6594
- {
6595
- ymin = p.y;
6596
- newp = p;
6597
-// break;
6598
- }
6599
- if (ymin > q.y)
6600
- {
6601
- ymin = q.y;
6602
- newp = q;
6603
-// break;
6604
- }
6605
- if (ymin > r.y)
6606
- {
6607
- ymin = r.y;
6608
- newp = r;
6609
-// break;
6610
- }
6611
- }
6612
-
6613
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6614
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6615
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6616
-
6617
- drawingstarted = false;
6618
-
6619
- // return;
6620
- }
6621
-
6622
- if (false) // CameraPane.DRAW
6623
- {
6624
- p0.AO = colorV[0] = 2;
6625
- colorV[1] = 2;
6626
- colorV[2] = 2;
6627
- }
6628
-
6629
- CameraPane.pointflow.add(p0);
6630
- CameraPane.pointflow.Touch();
6631
- }
6632
-
6633
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6634
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6635
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6636
- }
6637
-
66386315 void Print(Vertex v)
66396316 {
66406317 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66416318 }
66426319
6643
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6644
- {
6645
- if (!selectmode)
6646
- {
6647
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6648
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6649
-
6650
- if (flipV)
6651
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6652
- else
6653
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6654
- }
6655
-
6656
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6657
- }
6658
-
6659
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6660
- CameraPane display, Face face)
6661
- {
6662
- if (pv.y == -10000 ||
6663
- qv.y == -10000 ||
6664
- rv.y == -10000)
6665
- return;
6666
-
6667
-// float b = f.nbiterations & 1;
6668
-// float g = (f.nbiterations>>1) & 1;
6669
-// float r = (f.nbiterations>>2) & 1;
6670
-//
6671
-// //if (f.weight == 10000)
6672
-// //{
6673
-// // r = 1; g = b = 0;
6674
-// //}
6675
-// //else
6676
-// //{
6677
-// // assert(f.weight < 10000);
6678
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6679
-// if (r<0)
6680
-// assert(r>=0);
6681
-// //}
6682
-
6683
- javax.media.opengl.GL gl = display.GetGL();
6684
-
6685
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6686
-
6687
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6688
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6689
- {
6690
- //gl.glBegin(gl.GL_TRIANGLES);
6691
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6692
- if (!hasnorm)
6693
- {
6694
- // System.out.println("FUCK!!");
6695
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6696
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6697
- LA.vecCross(v0, v1, v2);
6698
- LA.vecNormalize(v2);
6699
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6700
- }
6701
-
6702
- if (hasnorm)
6703
- {
6704
-// if (!pv.norm.normalized())
6705
-// assert(pv.norm.normalized());
6706
-
6707
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6708
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6709
- }
6710
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6711
- SetColor(display, pv);
6712
- //gl.glColor4f(r, g, b, 1);
6713
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6714
- if (flipV)
6715
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6716
- else
6717
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6718
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6719
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6720
-// Print(pv);
6721
- if (hasnorm)
6722
- {
6723
-// assert(qv.norm.normalized());
6724
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6725
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6726
- }
6727
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6728
- // boolean locked = false;
6729
- // float eps = 0.1f;
6730
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6731
-
6732
- // int dot = 0; //*/ (int)f.dot;
6733
-
6734
- // if ((dot&1) == 0)
6735
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6736
-
6737
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6738
- if (flipV)
6739
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6740
- else
6741
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6742
- // else
6743
- // {
6744
- // locked = true;
6745
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6746
- // }
6747
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6748
- SetColor(display, qv);
6749
- //gl.glColor4f(r, g, b, 1);
6750
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6751
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6752
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6753
-// Print(qv);
6754
- if (hasnorm)
6755
- {
6756
-// assert(rv.norm.normalized());
6757
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6758
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6759
- }
6760
-
6761
- // if ((dot&4) == 0)
6762
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6763
-
6764
- // if (wrap || !locked && (dot&8) != 0)
6765
- if (flipV)
6766
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6767
- else
6768
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6769
- // else
6770
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6771
-
6772
- // f.dot = dot;
6773
-
6774
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6775
- SetColor(display, rv);
6776
- //gl.glColor4f(r, g, b, 1);
6777
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6778
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6779
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6780
-// Print(rv);
6781
- //gl.glEnd();
6782
- }
6783
- else
6784
- {
6785
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6786
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6787
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6788
-
6789
- }
6790
-
6791
- if (false) // (attributes & WIREFRAME) != 0)
6792
- {
6793
- gl.glDisable(gl.GL_LIGHTING);
6794
-
6795
- gl.glBegin(gl.GL_LINE_LOOP);
6796
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6797
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6798
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6799
- gl.glEnd();
6800
-
6801
- gl.glEnable(gl.GL_LIGHTING);
6802
- }
6803
- }
6804
-
68056320 void drawSelf(ClickInfo info, int level, boolean select)
68066321 {
68076322 if (bRep == null)
....@@ -7373,83 +6888,83 @@
73736888 int spotw = spot.x + spot.width;
73746889 int spoth = spot.y + spot.height;
73756890 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7376
- if (CameraPane.Xmin > spot.x)
7377
- {
7378
- CameraPane.Xmin = spot.x;
7379
- }
7380
- if (CameraPane.Xmax < spotw)
7381
- {
7382
- CameraPane.Xmax = spotw;
7383
- }
7384
- if (CameraPane.Ymin > spot.y)
7385
- {
7386
- CameraPane.Ymin = spot.y;
7387
- }
7388
- if (CameraPane.Ymax < spoth)
7389
- {
7390
- CameraPane.Ymax = spoth;
7391
- }
6891
+// if (CameraPane.Xmin > spot.x)
6892
+// {
6893
+// CameraPane.Xmin = spot.x;
6894
+// }
6895
+// if (CameraPane.Xmax < spotw)
6896
+// {
6897
+// CameraPane.Xmax = spotw;
6898
+// }
6899
+// if (CameraPane.Ymin > spot.y)
6900
+// {
6901
+// CameraPane.Ymin = spot.y;
6902
+// }
6903
+// if (CameraPane.Ymax < spoth)
6904
+// {
6905
+// CameraPane.Ymax = spoth;
6906
+// }
73926907 spot.translate(32, 32);
73936908 spotw = spot.x + spot.width;
73946909 spoth = spot.y + spot.height;
73956910 info.g.setColor(Color.blue);
73966911 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7397
- if (CameraPane.Xmin > spot.x)
7398
- {
7399
- CameraPane.Xmin = spot.x;
7400
- }
7401
- if (CameraPane.Xmax < spotw)
7402
- {
7403
- CameraPane.Xmax = spotw;
7404
- }
7405
- if (CameraPane.Ymin > spot.y)
7406
- {
7407
- CameraPane.Ymin = spot.y;
7408
- }
7409
- if (CameraPane.Ymax < spoth)
7410
- {
7411
- CameraPane.Ymax = spoth;
7412
- }
6912
+// if (CameraPane.Xmin > spot.x)
6913
+// {
6914
+// CameraPane.Xmin = spot.x;
6915
+// }
6916
+// if (CameraPane.Xmax < spotw)
6917
+// {
6918
+// CameraPane.Xmax = spotw;
6919
+// }
6920
+// if (CameraPane.Ymin > spot.y)
6921
+// {
6922
+// CameraPane.Ymin = spot.y;
6923
+// }
6924
+// if (CameraPane.Ymax < spoth)
6925
+// {
6926
+// CameraPane.Ymax = spoth;
6927
+// }
74136928 info.g.drawLine(spotw, spoth, spotw, spoth - 15);
74146929 info.g.drawLine(spotw, spoth, spotw - 15, spoth);
74156930 spot.translate(0, -32);
74166931 info.g.setColor(Color.green);
74176932 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7418
- if (CameraPane.Xmin > spot.x)
7419
- {
7420
- CameraPane.Xmin = spot.x;
7421
- }
7422
- if (CameraPane.Xmax < spotw)
7423
- {
7424
- CameraPane.Xmax = spotw;
7425
- }
7426
- if (CameraPane.Ymin > spot.y)
7427
- {
7428
- CameraPane.Ymin = spot.y;
7429
- }
7430
- if (CameraPane.Ymax < spoth)
7431
- {
7432
- CameraPane.Ymax = spoth;
7433
- }
6933
+// if (CameraPane.Xmin > spot.x)
6934
+// {
6935
+// CameraPane.Xmin = spot.x;
6936
+// }
6937
+// if (CameraPane.Xmax < spotw)
6938
+// {
6939
+// CameraPane.Xmax = spotw;
6940
+// }
6941
+// if (CameraPane.Ymin > spot.y)
6942
+// {
6943
+// CameraPane.Ymin = spot.y;
6944
+// }
6945
+// if (CameraPane.Ymax < spoth)
6946
+// {
6947
+// CameraPane.Ymax = spoth;
6948
+// }
74346949 info.g.drawArc(boundary.x, boundary.y,
74356950 boundary.width, boundary.height, 0, 360);
74366951 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7437
- if (CameraPane.Xmin > boundary.x)
7438
- {
7439
- CameraPane.Xmin = boundary.x;
7440
- }
7441
- if (CameraPane.Xmax < boundary.x + boundary.width)
7442
- {
7443
- CameraPane.Xmax = boundary.x + boundary.width;
7444
- }
7445
- if (CameraPane.Ymin > boundary.y)
7446
- {
7447
- CameraPane.Ymin = boundary.y;
7448
- }
7449
- if (CameraPane.Ymax < boundary.y + boundary.height)
7450
- {
7451
- CameraPane.Ymax = boundary.y + boundary.height;
7452
- }
6952
+// if (CameraPane.Xmin > boundary.x)
6953
+// {
6954
+// CameraPane.Xmin = boundary.x;
6955
+// }
6956
+// if (CameraPane.Xmax < boundary.x + boundary.width)
6957
+// {
6958
+// CameraPane.Xmax = boundary.x + boundary.width;
6959
+// }
6960
+// if (CameraPane.Ymin > boundary.y)
6961
+// {
6962
+// CameraPane.Ymin = boundary.y;
6963
+// }
6964
+// if (CameraPane.Ymax < boundary.y + boundary.height)
6965
+// {
6966
+// CameraPane.Ymax = boundary.y + boundary.height;
6967
+// }
74536968 return;
74546969 }
74556970 }
....@@ -7499,7 +7014,7 @@
74997014 }
75007015
75017016 //System.out.println("info.modifiers = " + info.modifiers);
7502
- modified = (info.modifiers & CameraPane.META) != 0;
7017
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
75037018 //System.out.println("modified = " + modified);
75047019 //new Exception().printStackTrace();
75057020 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7527,7 +7042,7 @@
75277042 return true;
75287043 }
75297044
7530
- void doEditDrag0(ClickInfo info)
7045
+ void doEditDrag0(ClickInfo info, boolean opposite)
75317046 {
75327047 if (hitSomething == 0)
75337048 {
....@@ -7552,9 +7067,9 @@
75527067
75537068 case hitCenter: // Translate
75547069
7555
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7070
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75567071
7557
- if (modified)
7072
+ if (modified || opposite)
75587073 {
75597074 //assert(false);
75607075 /*
....@@ -7600,10 +7115,10 @@
76007115 }
76017116 LA.xformDir(up, ClickInfo.matbuffer, up);
76027117 // if (!CameraPane.LOCALTRANSFORM)
7603
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7118
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
76047119 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
76057120 // if (!CameraPane.LOCALTRANSFORM)
7606
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7121
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
76077122 //LA.vecCross(up, cVector.Z, right2);
76087123
76097124 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7648,6 +7163,7 @@
76487163
76497164 if (modified)
76507165 {
7166
+ // Rotate 90 degrees
76517167 angle /= (Math.PI / 4);
76527168 angle = Math.floor(angle + 0.5);
76537169 angle *= (Math.PI / 4);
....@@ -7661,7 +7177,7 @@
76617177 }
76627178 /**/
76637179
7664
- switch (info.pane.renderCamera.viewCode)
7180
+ switch (info.pane.RenderCamera().viewCode)
76657181 {
76667182 case 1: // '\001'
76677183 LA.matZRotate(toParent, angle);
....@@ -7717,7 +7233,7 @@
77177233 }
77187234 /**/
77197235
7720
- switch (info.pane.renderCamera.viewCode)
7236
+ switch (info.pane.RenderCamera().viewCode)
77217237 {
77227238 case 3: // '\001'
77237239 if (modified)
....@@ -7882,14 +7398,22 @@
78827398 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78837399 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78847400 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7401
+
7402
+ String objname;
7403
+
78857404 if (false) //parent != null)
78867405 {
7887
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7406
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78887407 } else
78897408 {
7890
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7409
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
78917410 } // + super.toString();
78927411 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7412
+
7413
+ if (!Globals.ADVANCED)
7414
+ return objname;
7415
+
7416
+ return objname + " " + System.identityHashCode(this);
78937417 }
78947418
78957419 public int hashCode()
....@@ -7945,6 +7469,7 @@
79457469 objectUI.closeUI();
79467470 if (editWindow != null)
79477471 {
7472
+ editWindow.ctrlPanel.FlushUI();
79487473 editWindow.refreshContents();
79497474 } // ? new
79507475 objectUI = null;
....@@ -8080,7 +7605,7 @@
80807605 {
80817606 assert(bRep != null);
80827607 if (!(support instanceof GenericJoint)) // support.bRep != null)
8083
- GrafreeD.Assert(support.bRep == bRep.support);
7608
+ Grafreed.Assert(support.bRep == bRep.support);
80847609 }
80857610 else
80867611 {
....@@ -8163,6 +7688,8 @@
81637688 {
81647689 Object3D targ = this;
81657690
7691
+ targ.NORMALPUSH = obj.NORMALPUSH;
7692
+
81667693 if (obj.material != null)
81677694 {
81687695 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))