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 {
....@@ -285,7 +299,6 @@
285299 return parent.GetName() + "#";
286300 }
287301
288
- boolean timeline = false;
289302 boolean live = false;
290303 boolean hide = false;
291304 boolean link2master = false; // performs reset support/master at each frame
....@@ -296,6 +309,8 @@
296309 boolean random = false;
297310 boolean speedup = false;
298311 boolean rewind = false;
312
+
313
+ float NORMALPUSH = 0;
299314
300315 Object3D support;
301316
....@@ -416,16 +431,16 @@
416431 {
417432 Object3D copy = this;
418433
419
- Camera parentcam = CameraPane.theRenderer.manipCamera;
434
+ Camera parentcam = Globals.theRenderer.ManipCamera();
420435
421
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
436
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
422437 {
423
- parentcam = CameraPane.theRenderer.cameras[1];
438
+ parentcam = Globals.theRenderer.Cameras()[1];
424439 }
425440
426
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
441
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
427442 {
428
- parentcam = CameraPane.theRenderer.cameras[0];
443
+ parentcam = Globals.theRenderer.Cameras()[0];
429444 }
430445
431446 if (this == parentcam)
....@@ -433,7 +448,7 @@
433448 //assert(this instanceof Camera);
434449
435450 for (int count = parentcam.GetTransformCount(); --count>=0;)
436
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
451
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
437452 }
438453
439454 copy.marked ^= true;
....@@ -453,7 +468,7 @@
453468 //assert(this instanceof Camera);
454469
455470 for (int count = parentcam.GetTransformCount(); --count>=0;)
456
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
471
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
457472 }
458473
459474 copy.Touch(); // display list issue
....@@ -588,7 +603,7 @@
588603 return;
589604 }
590605
591
- if (CameraPane.fromscript)
606
+ if (Globals.fromscript)
592607 {
593608 transformcount = 0;
594609 return;
....@@ -746,7 +761,7 @@
746761
747762 int GetTransformCount()
748763 {
749
- // marde pour serialization de Texture
764
+ // patch pour serialization de Texture
750765 resetmaxcount();
751766 resettransformcount();
752767 resetstep();
....@@ -780,9 +795,12 @@
780795 // factor = CameraPane.STEP;
781796 // }
782797
783
- 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)
784802 {
785
- currentframe = CameraPane.framecount;
803
+ currentframe = Globals.framecount;
786804
787805 // System.err.println("transformcount = " + transformcount);
788806 // System.err.println("factor = " + factor);
....@@ -894,6 +912,11 @@
894912 fromParent = null; // LA.newMatrix();
895913 bRep = null; // new BoundaryRep();
896914
915
+ if (oname != null && oname.equals("LeftHand"))
916
+ {
917
+ name = oname;
918
+ }
919
+
897920 /*
898921 float hue = (float)Math.random();
899922 Color col;
....@@ -936,7 +959,7 @@
936959
937960 public Object clone()
938961 {
939
- return GrafreeD.clone(this);
962
+ return Grafreed.clone(this);
940963 }
941964
942965 Object3D copyExpand()
....@@ -1452,7 +1475,7 @@
14521475 BoundaryRep.SEUIL = other.material.cameralight;
14531476
14541477 // Set default to 0.1
1455
- BoundaryRep.SEUIL /= 2;
1478
+ BoundaryRep.SEUIL /= 4; // 2;
14561479 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14571480 }
14581481
....@@ -1711,7 +1734,7 @@
17111734 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17121735 o.bRep = transientrep;
17131736 if (clone)
1714
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1737
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17151738 o.CreateMaterial();
17161739 o.SetAttributes(this, -1);
17171740 //parent
....@@ -1724,7 +1747,7 @@
17241747 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17251748 o.bRep = bRep;
17261749 if (clone)
1727
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1750
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17281751 o.CreateMaterial();
17291752 //o.overwriteThis(this, -1);
17301753 o.SetAttributes(this, -1);
....@@ -2131,15 +2154,8 @@
21312154 if (/*parent != null &&*/ material == null)
21322155 {
21332156 material = new cMaterial(GetMaterial());
2134
- if (projectedVertices == null || projectedVertices.length <= 2)
2135
- {
2136
- projectedVertices = new Object3D.cVector2[3];
2137
- }
2138
- for (int i = 0; i < 3; i++)
2139
- {
2140
- projectedVertices[i] = new cVector2(); // Others
2141
- }
2142
- projectedVertices[0].x = 100; // bump
2157
+
2158
+ InitOthers();
21432159
21442160 if (this instanceof Camera)
21452161 {
....@@ -2289,6 +2305,7 @@
22892305 {
22902306 if (newWindow)
22912307 {
2308
+ new Exception().printStackTrace();
22922309 System.exit(0);
22932310 if (parent != null)
22942311 {
....@@ -2465,13 +2482,13 @@
24652482 return retval;
24662483 }
24672484
2468
- void doEditDrag(ClickInfo info)
2485
+ void doEditDrag(ClickInfo info, boolean opposite)
24692486 {
24702487 switch (doSomething)
24712488 {
24722489 case 1: // '\001'
24732490 //super.
2474
- doEditDrag0(info);
2491
+ doEditDrag0(info, opposite);
24752492 break;
24762493
24772494 case 2: // '\002'
....@@ -2484,11 +2501,11 @@
24842501 {
24852502 //sel.hitSomething = childToDrag.hitSomething;
24862503 //childToDrag.doEditDrag(info);
2487
- sel.doEditDrag(info);
2504
+ sel.doEditDrag(info, opposite);
24882505 } else
24892506 {
24902507 //super.
2491
- doEditDrag0(info);
2508
+ doEditDrag0(info, opposite);
24922509 }
24932510 }
24942511 break;
....@@ -2895,7 +2912,8 @@
28952912 {
28962913 if (bRep != null)
28972914 {
2898
- bRep.GenUV();
2915
+ bRep.GenUV(); //1);
2916
+ //bRep.UnfoldUV();
28992917 Touch();
29002918 }
29012919 }
....@@ -2970,6 +2988,31 @@
29702988 blockloop = false;
29712989 }
29722990
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
+
29733016 void TransformGeometry()
29743017 {
29753018 Object3D obj = this;
....@@ -3191,7 +3234,7 @@
31913234
31923235 BoundaryRep sup = bRep.support;
31933236 bRep.support = null;
3194
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3237
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31953238 // bRep.SplitInTwo(onlyone); // thread...
31963239 temprep.SplitInTwo(reduction34, onlyone);
31973240 bRep = temprep;
....@@ -3715,7 +3758,7 @@
37153758 if (child == null)
37163759 continue;
37173760
3718
- if (GrafreeD.RENDERME > 0)
3761
+ if (Grafreed.RENDERME > 0)
37193762 {
37203763 if (child instanceof Merge)
37213764 ((Merge)child).renderme();
....@@ -3866,7 +3909,7 @@
38663909 if (child == null)
38673910 continue;
38683911
3869
- if (GrafreeD.RENDERME > 0)
3912
+ if (Grafreed.RENDERME > 0)
38703913 {
38713914 if (child instanceof Merge)
38723915 ((Merge)child).renderme();
....@@ -4061,7 +4104,7 @@
40614104 if (child == null)
40624105 continue;
40634106
4064
- if (GrafreeD.RENDERME > 0)
4107
+ if (Grafreed.RENDERME > 0)
40654108 {
40664109 if (child instanceof Merge)
40674110 ((Merge)child).renderme();
....@@ -4158,6 +4201,22 @@
41584201 }
41594202 blockloop = true;
41604203 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();
41614220 blockloop = false;
41624221 }
41634222 }
....@@ -4828,7 +4887,7 @@
48284887 return globalTransform;
48294888 }
48304889
4831
- void PreprocessOcclusion(CameraPane cp)
4890
+ void PreprocessOcclusion(iCameraPane cp)
48324891 {
48334892 /*
48344893 if (AOdone)
....@@ -4975,7 +5034,8 @@
49755034 } else //
49765035 if (editWindow != null)
49775036 {
4978
- editWindow.cameraView.lighttouched = true;
5037
+ //editWindow.cameraView.lighttouched = true;
5038
+ Globals.lighttouched = true;
49795039 }
49805040 }
49815041
....@@ -5129,10 +5189,34 @@
51295189
51305190 // System.out.println("Fullname = " + fullname);
51315191
5132
- if (fullname.name.indexOf(":") == -1)
5133
- 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(":"));
51345197
5135
- 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];
51365220 }
51375221
51385222 static String GetBump(cTexture fullname)
....@@ -5141,10 +5225,38 @@
51415225 return "";
51425226
51435227 // System.out.println("Fullname = " + fullname);
5144
- if (fullname.name.indexOf(":") == -1)
5145
- return "";
5146
-
5147
- 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];
51485260 }
51495261
51505262 String GetPigmentTexture()
....@@ -5218,7 +5330,7 @@
52185330 System.out.print("; textures = " + textures);
52195331 System.out.println("; usedtextures = " + usedtextures);
52205332
5221
- if (GetTextures() == null)
5333
+ if (GetTextures() == null) // What is that??
52225334 GetTextures().name = ":";
52235335
52245336 String texname = tex;
....@@ -5287,25 +5399,22 @@
52875399 }
52885400 }
52895401
5290
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5402
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52915403 {
52925404 Draw(display, root, selected, blocked);
52935405 }
52945406
5295
- static cMaterial[] materialstack = new cMaterial[65536];
5296
- static boolean[] selectedstack = new boolean[65536];
5297
- static int materialdepth = 0;
5298
-
52995407 boolean NeedSupport()
53005408 {
53015409 return
53025410 CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
53035411 // PROBLEM with CROWD!!
5304
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5412
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53055413 }
53065414
5415
+ static boolean DEBUG_SELECTION = false;
53075416
5308
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5417
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53095418 {
53105419 Invariants(); // june 2013
53115420
....@@ -5314,7 +5423,7 @@
53145423 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
53155424 }
53165425
5317
- if (display.drawMode == CameraPane.SELECTION &&
5426
+ if (display.DrawMode() == iCameraPane.SELECTION &&
53185427 hide)
53195428 return;
53205429
....@@ -5333,7 +5442,7 @@
53335442 if (this instanceof Checker)
53345443 return;
53355444
5336
- if (display.drawMode == display.SHADOW && PASSTEST)
5445
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
53375446 return;
53385447
53395448 if (count <= 0)
....@@ -5341,13 +5450,13 @@
53415450 return;
53425451 }
53435452
5344
- if ((//display.drawMode == CameraPane.SHADOW ||
5345
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5453
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5454
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53465455 {
53475456 return;
53485457 }
53495458
5350
- javax.media.opengl.GL gl = display.GetGL();
5459
+ //javax.media.opengl.GL gl = display.GetGL();
53515460
53525461 /*
53535462 if (touched)
....@@ -5383,15 +5492,15 @@
53835492
53845493 boolean compiled = false;
53855494
5386
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5495
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53875496
5388
- if (!selectmode && //display.drawMode != display.SELECTION &&
5497
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
53895498 (touched || (bRep != null && bRep.displaylist <= 0)))
53905499 {
5391
- display.lighttouched = true;
5500
+ Globals.lighttouched = true;
53925501 } // all panes...
5393
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5394
- 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 &&
53955504 (touched || (bRep != null && bRep.displaylist <= 0)))
53965505 {
53975506 if (!(this instanceof Composite))
....@@ -5399,7 +5508,7 @@
53995508 //if (displaylist == -1 && usecalllists)
54005509 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54015510 {
5402
- bRep.displaylist = gl.glGenLists(1);
5511
+ bRep.displaylist = display.GenList();
54035512 assert(bRep.displaylist != 0);
54045513 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54055514 //System.out.println("\tgen list " + list);
....@@ -5411,18 +5520,20 @@
54115520 if (usecalllists)
54125521 {
54135522 // System.err.println("new list " + bRep.displaylist + " for " + this);
5414
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5523
+ display.NewList(bRep.displaylist);
54155524 }
5525
+
54165526 CallList(display, root, selected, blocked);
5527
+
54175528 // compiled = true;
54185529 if (usecalllists)
54195530 {
54205531 // System.err.println("end list " + bRep.displaylist + " for " + this);
5421
- gl.glEndList();
5532
+ display.EndList();
54225533 }
54235534 //gl.glDrawBuffer(gl.GL_BACK);
54245535 // XXX touched = false;
5425
- display.lighttouched = true; // all panes...
5536
+ Globals.lighttouched = true; // all panes...
54265537 }
54275538
54285539 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5461,12 +5572,12 @@
54615572
54625573 // frustum culling
54635574 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5464
- && display.drawMode != CameraPane.SELECTION)
5575
+ && display.DrawMode() != iCameraPane.SELECTION)
54655576 {
5466
- if (display.drawMode == CameraPane.SHADOW)
5577
+ if (display.DrawMode() == iCameraPane.SHADOW)
54675578 {
54685579 if (!link2master // tricky to cull in shadow mode.
5469
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5580
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54705581 {
54715582 //System.out.print("CULLED");
54725583 culled = true;
....@@ -5474,7 +5585,7 @@
54745585 }
54755586 else
54765587 //GetBRep().getBounds(v0, v1, this);
5477
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5588
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54785589 culled = true;
54795590
54805591 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5510,11 +5621,11 @@
55105621
55115622
55125623 if (!culled)
5513
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5624
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55145625 {
55155626 if (GetBRep() != null)
55165627 {
5517
- CameraPane.NextIndex(this, gl);
5628
+ display.NextIndex();
55185629 // vertex color conflict : gl.glCallList(list);
55195630 DrawNode(display, root, selected);
55205631 if (this instanceof BezierPatch)
....@@ -5536,55 +5647,7 @@
55365647 color[2] /= 2;
55375648 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55385649 */
5539
- if (material != null)
5540
- {
5541
- materialstack[materialdepth] = material;
5542
- selectedstack[materialdepth] = selected;
5543
- cStatic.objectstack[materialdepth++] = this;
5544
- //System.out.println("material " + material);
5545
- //Applet3D.tracein(this, selected);
5546
- display.vector2buffer = projectedVertices;
5547
- if (this instanceof Camera)
5548
- {
5549
- display.options1[0] = material.shift;
5550
- //System.out.println("shift " + material.shift);
5551
- display.options1[1] = material.lightarea;
5552
- display.options1[2] = material.shadowbias;
5553
- display.options1[3] = material.aniso;
5554
- display.options1[4] = material.anisoV;
5555
- display.options2[0] = material.opacity;
5556
- display.options2[1] = material.diffuse;
5557
- display.options2[2] = material.factor;
5558
-
5559
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5560
- display.options4[0] = material.cameralight/0.2f;
5561
- display.options4[1] = material.subsurface;
5562
- display.options4[2] = material.sheen;
5563
-
5564
- // if (display.CURRENTANTIALIAS > 0)
5565
- // display.options3[3] /= 4;
5566
-
5567
- /*
5568
- System.out.println("Focus = " + display.options1[0]);
5569
- System.out.println("Aperture = " + display.options1[1]);
5570
- System.out.println("ShadowBlur = " + display.options1[2]);
5571
- System.out.println("Antialiasing = " + display.options1[3]);
5572
- System.out.println("Fog = " + display.options2[0]);
5573
- System.out.println("Intensity = " + display.options2[1]);
5574
- System.out.println("Elevation = " + display.options2[2]);
5575
- /**/
5576
- } else
5577
- {
5578
- material.Draw(display, selected);
5579
- }
5580
- } else
5581
- {
5582
- if (selected && CameraPane.flash)
5583
- {
5584
- display.modelParams4[1] = 100;
5585
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5586
- }
5587
- }
5650
+ display.PushMaterial(this, selected);
55885651
55895652 //System.out.println("call list " + list);
55905653 //System.out.println();
....@@ -5619,30 +5682,15 @@
56195682
56205683 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
56215684 assert(bRep.displaylist != 0);
5622
- gl.glCallList(bRep.displaylist);
5685
+ display.CallList(bRep.displaylist);
56235686 // june 2013 drawSelf(display, root, selected);
56245687 }
56255688 }
56265689 }
56275690
56285691 display.ReleaseTextures(tex);
5629
-
5630
- //if (parent != null && parent.GetMaterial() != null)
5631
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5632
- if (material != null)
5633
- {
5634
- materialdepth -= 1;
5635
- if (materialdepth > 0)
5636
- {
5637
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5638
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5639
- }
5640
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5641
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5642
- {
5643
- display.modelParams4[1] = GetMaterial().cameralight;
5644
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5645
- }
5692
+
5693
+ display.PopMaterial(this, selected);
56465694 }
56475695
56485696 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5684,7 +5732,7 @@
56845732 // resetMasterNode();
56855733 }
56865734
5687
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5735
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56885736 {
56895737 if (GetBRep() == null)
56905738 {
....@@ -5767,7 +5815,7 @@
57675815 boolean flipV = false; // true;
57685816 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57695817
5770
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5818
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57715819 {
57725820 if (hide)
57735821 return;
....@@ -5826,16 +5874,7 @@
58265874 // // ??????????????????????????? Touch();
58275875 // }
58285876
5829
- if (material != null)
5830
- {
5831
- materialstack[materialdepth] = material;
5832
- selectedstack[materialdepth] = selected;
5833
- cStatic.objectstack[materialdepth++] = this;
5834
- //System.out.println("material " + material);
5835
- //Applet3D.tracein("selected ", selected);
5836
- display.vector2buffer = projectedVertices;
5837
- material.Draw(display, selected);
5838
- }
5877
+display.PushMaterial2(this, selected);
58395878
58405879 Object3D child;
58415880 boolean sel;
....@@ -5887,19 +5926,7 @@
58875926 */
58885927 //depth += 1;
58895928
5890
- if (material != null)
5891
- {
5892
- materialdepth -= 1;
5893
- if (materialdepth > 0)
5894
- {
5895
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5896
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5897
- }
5898
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5899
- //else
5900
- //material.Draw(display, false);
5901
- }
5902
-
5929
+display.PopMaterial2(this);
59035930 /*
59045931 display.ReleaseTextures(tex);
59055932 */
....@@ -5910,9 +5937,9 @@
59105937
59115938 //static cVector min,max;
59125939
5913
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
5940
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
59145941 {
5915
- 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)
59165943 return; // no shadow for transparent objects
59175944
59185945 if (hide)
....@@ -5955,11 +5982,12 @@
59555982 return;
59565983 }
59575984
5985
+ //bRep.GenUV(1/material.diffuseness);
59585986 // bRep.lock = true;
59595987
5960
- javax.media.opengl.GL gl = display.GetGL();
5988
+ //javax.media.opengl.GL gl = display.GetGL();
59615989
5962
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
5990
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59635991 {
59645992 int fc = bRep.FaceCount();
59655993 int vc = bRep.VertexCount();
....@@ -5974,23 +6002,7 @@
59746002
59756003 bRep.getMinMax(min, max, 100);
59766004
5977
- gl.glBegin(gl.GL_LINES);
5978
-
5979
- gl.glVertex3d(min.x, min.y, min.z);
5980
- gl.glVertex3d(min.x, min.y, max.z);
5981
- gl.glVertex3d(min.x, min.y, min.z);
5982
- gl.glVertex3d(min.x, max.y, min.z);
5983
- gl.glVertex3d(min.x, min.y, min.z);
5984
- gl.glVertex3d(max.x, min.y, min.z);
5985
-
5986
- gl.glVertex3d(max.x, max.y, max.z);
5987
- gl.glVertex3d(min.x, max.y, max.z);
5988
- gl.glVertex3d(max.x, max.y, max.z);
5989
- gl.glVertex3d(max.x, min.y, max.z);
5990
- gl.glVertex3d(max.x, max.y, max.z);
5991
- gl.glVertex3d(max.x, max.y, min.z);
5992
-
5993
- gl.glEnd();
6005
+ display.DrawBox(min, max);
59946006
59956007 return;
59966008 }
....@@ -6034,7 +6046,7 @@
60346046 {
60356047 //throw new Error();
60366048
6037
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6049
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60386050
60396051 int[] strips = bRep.getRawIndices();
60406052
....@@ -6044,178 +6056,14 @@
60446056 new Exception().printStackTrace();
60456057 return;
60466058 }
6047
-
6048
- // TRIANGLE STRIP ARRAY
6049
- if (bRep.trimmed)
6050
- {
6051
- float[] v = bRep.getRawVertices();
6052
- float[] n = bRep.getRawNormals();
6053
- float[] c = bRep.getRawColors();
6054
- float[] uv = bRep.getRawUVMap();
6055
-
6056
- int count2 = 0;
6057
- int count3 = 0;
6058
-
6059
- if (n.length > 0)
6060
- {
6061
- for (int i = 0; i < strips.length; i++)
6062
- {
6063
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6064
-
6065
- /*
6066
- boolean locked = false;
6067
- float eps = 0.1f;
6068
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6069
-
6070
- int dot = 0;
6071
-
6072
- if ((dot&1) == 0)
6073
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6074
-
6075
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6076
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6077
- else
6078
- {
6079
- locked = true;
6080
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6081
- }
6082
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6083
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6084
- if (hasnorm)
6085
- {
6086
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6087
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6088
- }
6089
-
6090
- if ((dot&4) == 0)
6091
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6092
-
6093
- if (wrap || !locked && (dot&8) != 0)
6094
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6095
- else
6096
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6097
-
6098
- f.dot = dot;
6099
- */
6100
-
6101
- if (!selectmode)
6102
- {
6103
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6104
- {
6105
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6106
- } else
6107
- {
6108
- gl.glNormal3f(0, 0, 1);
6109
- }
6110
-
6111
- if (c != null)
6112
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6113
- {
6114
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6115
- }
6116
- }
6117
- if (flipV)
6118
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6119
- else
6120
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6121
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6122
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6123
-
6124
- count2 += 2;
6125
- count3 += 3;
6126
- if (!selectmode)
6127
- {
6128
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6129
- {
6130
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6131
- } else
6132
- {
6133
- gl.glNormal3f(0, 0, 1);
6134
- }
6135
- if (c != null)
6136
- {
6137
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6138
- }
6139
- }
6140
- if (flipV)
6141
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6142
- else
6143
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6144
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6145
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6146
-
6147
- count2 += 2;
6148
- count3 += 3;
6149
- for (int j = 0; j < strips[i] - 2; j++)
6150
- {
6151
- //gl.glTexCoord2d(...);
6152
- if (!selectmode)
6153
- {
6154
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6155
- {
6156
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6157
- } else
6158
- {
6159
- gl.glNormal3f(0, 0, 1);
6160
- }
6161
- if (c != null)
6162
- {
6163
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6164
- }
6165
- }
6166
-
6167
- if (flipV)
6168
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6169
- else
6170
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6171
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6172
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6173
- count2 += 2;
6174
- count3 += 3;
6175
- }
6176
-
6177
- gl.glEnd();
6178
- }
6179
- }
6180
-
6181
- assert count3 == v.length;
6182
- }
6183
- else // !trimmed
6184
- {
6185
- int count = 0;
6186
- for (int i = 0; i < strips.length; i++)
6187
- {
6188
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6189
-
6190
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6191
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6192
-
6193
- drawVertex(gl, p, selectmode);
6194
- drawVertex(gl, q, selectmode);
6195
-
6196
- for (int j = 0; j < strips[i] - 2; j++)
6197
- {
6198
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6199
-
6200
-// if (j%2 == 0)
6201
-// drawFace(p, q, r, display, null);
6202
-// else
6203
-// drawFace(p, r, q, display, null);
6204
-
6205
-// p = q;
6206
-// q = r;
6207
- drawVertex(gl, r, selectmode);
6208
- }
6209
-
6210
- gl.glEnd();
6211
- }
6212
- }
6059
+
6060
+ display.DrawGeometry(bRep, flipV, selectmode);
62136061 } else // catch (Error e)
62146062 {
62156063 // TRIANGLE ARRAY
62166064 if (IsOpaque()) // Static())
62176065 {
6218
- gl.glBegin(gl.GL_TRIANGLES);
6066
+ display.StartTriangles();
62196067 int facecount = bRep.FaceCount();
62206068 for (int i = 0; i < facecount; i++)
62216069 {
....@@ -6278,9 +6126,9 @@
62786126 // // r.norm.dot(v3) > -0.5)
62796127 // // continue;
62806128
6281
- drawFace(p, q, r, display, face);
6129
+ display.DrawFace(this, p, q, r, face);
62826130 }
6283
- gl.glEnd();
6131
+ display.EndTriangles();
62846132 }
62856133 else
62866134 {
....@@ -6309,8 +6157,8 @@
63096157 //System.out.println("SORT");
63106158
63116159 java.util.Arrays.sort(facescompare);
6312
-
6313
- gl.glBegin(gl.GL_TRIANGLES);
6160
+
6161
+ display.StartTriangles();
63146162 for (int i = 0; i < facecount; i++)
63156163 {
63166164 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6322,13 +6170,14 @@
63226170 Vertex q = bRep.GetVertex(face.q);
63236171 Vertex r = bRep.GetVertex(face.r);
63246172
6325
- drawFace(p, q, r, display, face);
6173
+ display.DrawFace(this, p, q, r, face);
63266174 }
6327
- gl.glEnd();
6175
+ display.EndTriangles();
63286176 }
63296177
63306178 if (false) // live && support != null && support.bRep != null) // debug weights
63316179 {
6180
+ /*
63326181 gl.glDisable(gl.GL_LIGHTING);
63336182 float[] colorV = new float[3];
63346183
....@@ -6407,6 +6256,7 @@
64076256 // gl.glEnd();
64086257 }
64096258 }
6259
+ */
64106260 }
64116261 }
64126262
....@@ -6451,7 +6301,7 @@
64516301 center.add(r);
64526302 center.mul(1.0/3);
64536303
6454
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6304
+ center.sub(Globals.theRenderer.EyeCamera().location);
64556305
64566306 distance = center.dot(center);
64576307 }
....@@ -6462,347 +6312,11 @@
64626312
64636313 transient FaceCompare[] facescompare = null;
64646314
6465
- void SetColor(CameraPane display, Vertex p0)
6466
- {
6467
- if (display.RENDERPROGRAM == 0)
6468
- {
6469
- float r = 0;
6470
- if (bRep != null)
6471
- {
6472
- if (bRep.stripified)
6473
- {
6474
- r = 1;
6475
- }
6476
- }
6477
- float g = 0;
6478
- if (bRep != null)
6479
- {
6480
- if (bRep.trimmed)
6481
- {
6482
- g = 1;
6483
- }
6484
- }
6485
- float b = 0;
6486
- if (support != null && link2master)
6487
- {
6488
- b = 1;
6489
- }
6490
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6491
- return;
6492
- }
6493
-
6494
- if (display.drawMode != CameraPane.SHADOW)
6495
- return;
6496
-
6497
- javax.media.opengl.GL gl = display.GetGL();
6498
-// if (true) return;
6499
-// float ao = p.AO;
6500
-//
6501
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6502
-// // ao = 1;
6503
-//
6504
-// gl.glColor4f(ao, ao, ao, 1);
6505
-
6506
-// CameraPane.selectedpoint.
6507
-// getAverage(cStatic.point1, true);
6508
- if (CameraPane.pointflow == null) // !random) // live)
6509
- {
6510
- return;
6511
- }
6512
-
6513
- cStatic.point1.set(0,0,0);
6514
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6515
-
6516
- cStatic.point1.sub(p0);
6517
-
6518
-
6519
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6520
-// {
6521
-// return;
6522
-// }
6523
-
6524
- //if (true)
6525
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6526
- {
6527
- return;
6528
- }
6529
-
6530
- float[] colorV = new float[3];
6531
-
6532
- if (false) // marked)
6533
- {
6534
- // debug rigging weights
6535
- for (int object = 0; object < p0.vertexlinks.length; object++)
6536
- {
6537
- float weight = p0.weights[object] / p0.totalweight;
6538
-
6539
- // if (weight < 0.1)
6540
- // {
6541
- // assert(weight == 0);
6542
- // continue;
6543
- // }
6544
-
6545
- if (p0.vertexlinks[object] == -1)
6546
- continue;
6547
-
6548
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6549
-
6550
- int color = //1 << object; //
6551
- //p.vertexlinks.length;
6552
- support.bRep.supports[p0.closestsupport].links[object];
6553
- colorV[2] += (color & 1) * weight;
6554
- colorV[1] += ((color & 2) >> 1) * weight;
6555
- colorV[0] += ((color & 4) >> 2) * weight;
6556
- }
6557
- }
6558
- else
6559
- {
6560
- if (drawingstarted)
6561
- {
6562
- // find next point
6563
- if (bRep.GetVertex(0).faceindices == null)
6564
- {
6565
- bRep.InitFaceIndices();
6566
- }
6567
-
6568
- double ymin = p0.y;
6569
-
6570
- Vertex newp = p0;
6571
-
6572
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6573
- {
6574
- int fi = p0.faceindices[fii];
6575
-
6576
- if (fi == -1)
6577
- break;
6578
-
6579
- Face f = bRep.GetFace(fi);
6580
-
6581
- Vertex p = bRep.GetVertex(f.p);
6582
- Vertex q = bRep.GetVertex(f.q);
6583
- Vertex r = bRep.GetVertex(f.r);
6584
-
6585
- int swap = (int)(Math.random()*3);
6586
-
6587
-// for (int s=swap; --s>=0;)
6588
-// {
6589
-// Vertex t = p;
6590
-// p = q;
6591
-// q = r;
6592
-// r = t;
6593
-// }
6594
- if (ymin > p.y)
6595
- {
6596
- ymin = p.y;
6597
- newp = p;
6598
-// break;
6599
- }
6600
- if (ymin > q.y)
6601
- {
6602
- ymin = q.y;
6603
- newp = q;
6604
-// break;
6605
- }
6606
- if (ymin > r.y)
6607
- {
6608
- ymin = r.y;
6609
- newp = r;
6610
-// break;
6611
- }
6612
- }
6613
-
6614
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6615
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6616
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6617
-
6618
- drawingstarted = false;
6619
-
6620
- // return;
6621
- }
6622
-
6623
- if (false) // CameraPane.DRAW
6624
- {
6625
- p0.AO = colorV[0] = 2;
6626
- colorV[1] = 2;
6627
- colorV[2] = 2;
6628
- }
6629
-
6630
- CameraPane.pointflow.add(p0);
6631
- CameraPane.pointflow.Touch();
6632
- }
6633
-
6634
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6635
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6636
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6637
- }
6638
-
66396315 void Print(Vertex v)
66406316 {
66416317 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66426318 }
66436319
6644
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6645
- {
6646
- if (!selectmode)
6647
- {
6648
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6649
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6650
-
6651
- if (flipV)
6652
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6653
- else
6654
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6655
- }
6656
-
6657
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6658
- }
6659
-
6660
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6661
- CameraPane display, Face face)
6662
- {
6663
- if (pv.y == -10000 ||
6664
- qv.y == -10000 ||
6665
- rv.y == -10000)
6666
- return;
6667
-
6668
-// float b = f.nbiterations & 1;
6669
-// float g = (f.nbiterations>>1) & 1;
6670
-// float r = (f.nbiterations>>2) & 1;
6671
-//
6672
-// //if (f.weight == 10000)
6673
-// //{
6674
-// // r = 1; g = b = 0;
6675
-// //}
6676
-// //else
6677
-// //{
6678
-// // assert(f.weight < 10000);
6679
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6680
-// if (r<0)
6681
-// assert(r>=0);
6682
-// //}
6683
-
6684
- javax.media.opengl.GL gl = display.GetGL();
6685
-
6686
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6687
-
6688
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6689
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6690
- {
6691
- //gl.glBegin(gl.GL_TRIANGLES);
6692
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6693
- if (!hasnorm)
6694
- {
6695
- // System.out.println("FUCK!!");
6696
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6697
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6698
- LA.vecCross(v0, v1, v2);
6699
- LA.vecNormalize(v2);
6700
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6701
- }
6702
-
6703
- if (hasnorm)
6704
- {
6705
-// if (!pv.norm.normalized())
6706
-// assert(pv.norm.normalized());
6707
-
6708
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6709
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6710
- }
6711
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6712
- SetColor(display, pv);
6713
- //gl.glColor4f(r, g, b, 1);
6714
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6715
- if (flipV)
6716
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6717
- else
6718
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6719
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6720
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6721
-// Print(pv);
6722
- if (hasnorm)
6723
- {
6724
-// assert(qv.norm.normalized());
6725
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6726
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6727
- }
6728
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6729
- // boolean locked = false;
6730
- // float eps = 0.1f;
6731
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6732
-
6733
- // int dot = 0; //*/ (int)f.dot;
6734
-
6735
- // if ((dot&1) == 0)
6736
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6737
-
6738
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6739
- if (flipV)
6740
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6741
- else
6742
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6743
- // else
6744
- // {
6745
- // locked = true;
6746
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6747
- // }
6748
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6749
- SetColor(display, qv);
6750
- //gl.glColor4f(r, g, b, 1);
6751
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6752
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6753
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6754
-// Print(qv);
6755
- if (hasnorm)
6756
- {
6757
-// assert(rv.norm.normalized());
6758
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6759
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6760
- }
6761
-
6762
- // if ((dot&4) == 0)
6763
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6764
-
6765
- // if (wrap || !locked && (dot&8) != 0)
6766
- if (flipV)
6767
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6768
- else
6769
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6770
- // else
6771
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6772
-
6773
- // f.dot = dot;
6774
-
6775
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6776
- SetColor(display, rv);
6777
- //gl.glColor4f(r, g, b, 1);
6778
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6779
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6780
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6781
-// Print(rv);
6782
- //gl.glEnd();
6783
- }
6784
- else
6785
- {
6786
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6787
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6788
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6789
-
6790
- }
6791
-
6792
- if (false) // (attributes & WIREFRAME) != 0)
6793
- {
6794
- gl.glDisable(gl.GL_LIGHTING);
6795
-
6796
- gl.glBegin(gl.GL_LINE_LOOP);
6797
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6798
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6799
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6800
- gl.glEnd();
6801
-
6802
- gl.glEnable(gl.GL_LIGHTING);
6803
- }
6804
- }
6805
-
68066320 void drawSelf(ClickInfo info, int level, boolean select)
68076321 {
68086322 if (bRep == null)
....@@ -7374,83 +6888,83 @@
73746888 int spotw = spot.x + spot.width;
73756889 int spoth = spot.y + spot.height;
73766890 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7377
- if (CameraPane.Xmin > spot.x)
7378
- {
7379
- CameraPane.Xmin = spot.x;
7380
- }
7381
- if (CameraPane.Xmax < spotw)
7382
- {
7383
- CameraPane.Xmax = spotw;
7384
- }
7385
- if (CameraPane.Ymin > spot.y)
7386
- {
7387
- CameraPane.Ymin = spot.y;
7388
- }
7389
- if (CameraPane.Ymax < spoth)
7390
- {
7391
- CameraPane.Ymax = spoth;
7392
- }
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
+// }
73936907 spot.translate(32, 32);
73946908 spotw = spot.x + spot.width;
73956909 spoth = spot.y + spot.height;
73966910 info.g.setColor(Color.blue);
73976911 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7398
- if (CameraPane.Xmin > spot.x)
7399
- {
7400
- CameraPane.Xmin = spot.x;
7401
- }
7402
- if (CameraPane.Xmax < spotw)
7403
- {
7404
- CameraPane.Xmax = spotw;
7405
- }
7406
- if (CameraPane.Ymin > spot.y)
7407
- {
7408
- CameraPane.Ymin = spot.y;
7409
- }
7410
- if (CameraPane.Ymax < spoth)
7411
- {
7412
- CameraPane.Ymax = spoth;
7413
- }
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
+// }
74146928 info.g.drawLine(spotw, spoth, spotw, spoth - 15);
74156929 info.g.drawLine(spotw, spoth, spotw - 15, spoth);
74166930 spot.translate(0, -32);
74176931 info.g.setColor(Color.green);
74186932 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7419
- if (CameraPane.Xmin > spot.x)
7420
- {
7421
- CameraPane.Xmin = spot.x;
7422
- }
7423
- if (CameraPane.Xmax < spotw)
7424
- {
7425
- CameraPane.Xmax = spotw;
7426
- }
7427
- if (CameraPane.Ymin > spot.y)
7428
- {
7429
- CameraPane.Ymin = spot.y;
7430
- }
7431
- if (CameraPane.Ymax < spoth)
7432
- {
7433
- CameraPane.Ymax = spoth;
7434
- }
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
+// }
74356949 info.g.drawArc(boundary.x, boundary.y,
74366950 boundary.width, boundary.height, 0, 360);
74376951 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7438
- if (CameraPane.Xmin > boundary.x)
7439
- {
7440
- CameraPane.Xmin = boundary.x;
7441
- }
7442
- if (CameraPane.Xmax < boundary.x + boundary.width)
7443
- {
7444
- CameraPane.Xmax = boundary.x + boundary.width;
7445
- }
7446
- if (CameraPane.Ymin > boundary.y)
7447
- {
7448
- CameraPane.Ymin = boundary.y;
7449
- }
7450
- if (CameraPane.Ymax < boundary.y + boundary.height)
7451
- {
7452
- CameraPane.Ymax = boundary.y + boundary.height;
7453
- }
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
+// }
74546968 return;
74556969 }
74566970 }
....@@ -7500,7 +7014,7 @@
75007014 }
75017015
75027016 //System.out.println("info.modifiers = " + info.modifiers);
7503
- modified = (info.modifiers & CameraPane.META) != 0;
7017
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
75047018 //System.out.println("modified = " + modified);
75057019 //new Exception().printStackTrace();
75067020 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7528,7 +7042,7 @@
75287042 return true;
75297043 }
75307044
7531
- void doEditDrag0(ClickInfo info)
7045
+ void doEditDrag0(ClickInfo info, boolean opposite)
75327046 {
75337047 if (hitSomething == 0)
75347048 {
....@@ -7553,9 +7067,9 @@
75537067
75547068 case hitCenter: // Translate
75557069
7556
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7070
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75577071
7558
- if (modified)
7072
+ if (modified || opposite)
75597073 {
75607074 //assert(false);
75617075 /*
....@@ -7601,10 +7115,10 @@
76017115 }
76027116 LA.xformDir(up, ClickInfo.matbuffer, up);
76037117 // if (!CameraPane.LOCALTRANSFORM)
7604
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7118
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
76057119 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
76067120 // if (!CameraPane.LOCALTRANSFORM)
7607
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7121
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
76087122 //LA.vecCross(up, cVector.Z, right2);
76097123
76107124 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7649,6 +7163,7 @@
76497163
76507164 if (modified)
76517165 {
7166
+ // Rotate 90 degrees
76527167 angle /= (Math.PI / 4);
76537168 angle = Math.floor(angle + 0.5);
76547169 angle *= (Math.PI / 4);
....@@ -7662,7 +7177,7 @@
76627177 }
76637178 /**/
76647179
7665
- switch (info.pane.renderCamera.viewCode)
7180
+ switch (info.pane.RenderCamera().viewCode)
76667181 {
76677182 case 1: // '\001'
76687183 LA.matZRotate(toParent, angle);
....@@ -7718,7 +7233,7 @@
77187233 }
77197234 /**/
77207235
7721
- switch (info.pane.renderCamera.viewCode)
7236
+ switch (info.pane.RenderCamera().viewCode)
77227237 {
77237238 case 3: // '\001'
77247239 if (modified)
....@@ -7883,14 +7398,22 @@
78837398 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78847399 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78857400 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7401
+
7402
+ String objname;
7403
+
78867404 if (false) //parent != null)
78877405 {
7888
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7406
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78897407 } else
78907408 {
7891
- 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) ":"") */ "";
78927410 } // + super.toString();
78937411 //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);
78947417 }
78957418
78967419 public int hashCode()
....@@ -7946,6 +7469,7 @@
79467469 objectUI.closeUI();
79477470 if (editWindow != null)
79487471 {
7472
+ editWindow.ctrlPanel.FlushUI();
79497473 editWindow.refreshContents();
79507474 } // ? new
79517475 objectUI = null;
....@@ -8081,7 +7605,7 @@
80817605 {
80827606 assert(bRep != null);
80837607 if (!(support instanceof GenericJoint)) // support.bRep != null)
8084
- GrafreeD.Assert(support.bRep == bRep.support);
7608
+ Grafreed.Assert(support.bRep == bRep.support);
80857609 }
80867610 else
80877611 {
....@@ -8164,6 +7688,8 @@
81647688 {
81657689 Object3D targ = this;
81667690
7691
+ targ.NORMALPUSH = obj.NORMALPUSH;
7692
+
81677693 if (obj.material != null)
81687694 {
81697695 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))