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()
....@@ -355,7 +371,7 @@
355371
356372 int MemorySize()
357373 {
358
- if (memorysize == 0)
374
+ if (true) // memorysize == 0)
359375 {
360376 try
361377 {
....@@ -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()
....@@ -1446,7 +1470,16 @@
14461470 // if (other == null)
14471471 // return;
14481472
1449
- System.out.println("Link support this = " + this + "; other = " + other);
1473
+ if (other != null)
1474
+ {
1475
+ BoundaryRep.SEUIL = other.material.cameralight;
1476
+
1477
+ // Set default to 0.1
1478
+ BoundaryRep.SEUIL /= 4; // 2;
1479
+ System.out.println("SEUIL = " + BoundaryRep.SEUIL);
1480
+ }
1481
+
1482
+ System.out.println("Link this = " + this + "; support = " + other);
14501483
14511484 //if (bRep != null)
14521485 // bRep.linkVerticesThis(other.bRep);
....@@ -1701,7 +1734,7 @@
17011734 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17021735 o.bRep = transientrep;
17031736 if (clone)
1704
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1737
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17051738 o.CreateMaterial();
17061739 o.SetAttributes(this, -1);
17071740 //parent
....@@ -1714,7 +1747,7 @@
17141747 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17151748 o.bRep = bRep;
17161749 if (clone)
1717
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1750
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17181751 o.CreateMaterial();
17191752 //o.overwriteThis(this, -1);
17201753 o.SetAttributes(this, -1);
....@@ -1816,8 +1849,9 @@
18161849 if (obj.name == null)
18171850 continue; // can't be a null one
18181851
1819
- //if (n.contains(obj.name)) // dec 2013 name.split(":")[0])) // Poser generates a count
1820
- if (n.startsWith(obj.name))
1852
+ String name = obj.name.split(":")[0]; // Poser generates a count
1853
+ //if (n.startsWith(obj.name))
1854
+ if (n.contains(name))
18211855 {
18221856 theobj = obj;
18231857 count++;
....@@ -2120,15 +2154,8 @@
21202154 if (/*parent != null &&*/ material == null)
21212155 {
21222156 material = new cMaterial(GetMaterial());
2123
- if (projectedVertices == null || projectedVertices.length <= 2)
2124
- {
2125
- projectedVertices = new Object3D.cVector2[3];
2126
- }
2127
- for (int i = 0; i < 3; i++)
2128
- {
2129
- projectedVertices[i] = new cVector2(); // Others
2130
- }
2131
- projectedVertices[0].x = 100; // bump
2157
+
2158
+ InitOthers();
21322159
21332160 if (this instanceof Camera)
21342161 {
....@@ -2278,6 +2305,7 @@
22782305 {
22792306 if (newWindow)
22802307 {
2308
+ new Exception().printStackTrace();
22812309 System.exit(0);
22822310 if (parent != null)
22832311 {
....@@ -2454,13 +2482,13 @@
24542482 return retval;
24552483 }
24562484
2457
- void doEditDrag(ClickInfo info)
2485
+ void doEditDrag(ClickInfo info, boolean opposite)
24582486 {
24592487 switch (doSomething)
24602488 {
24612489 case 1: // '\001'
24622490 //super.
2463
- doEditDrag0(info);
2491
+ doEditDrag0(info, opposite);
24642492 break;
24652493
24662494 case 2: // '\002'
....@@ -2473,11 +2501,11 @@
24732501 {
24742502 //sel.hitSomething = childToDrag.hitSomething;
24752503 //childToDrag.doEditDrag(info);
2476
- sel.doEditDrag(info);
2504
+ sel.doEditDrag(info, opposite);
24772505 } else
24782506 {
24792507 //super.
2480
- doEditDrag0(info);
2508
+ doEditDrag0(info, opposite);
24812509 }
24822510 }
24832511 break;
....@@ -2732,6 +2760,24 @@
27322760 blockloop = false;
27332761 }
27342762
2763
+ void GenNormalsMINE()
2764
+ {
2765
+ if (blockloop)
2766
+ return;
2767
+
2768
+ blockloop = true;
2769
+ GenNormalsMINE0();
2770
+ for (int i = 0; i < Children().Size(); i++)
2771
+ {
2772
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2773
+ if (child == null)
2774
+ continue;
2775
+ child.GenNormalsMINE();
2776
+// Children().release(i);
2777
+ }
2778
+ blockloop = false;
2779
+ }
2780
+
27352781 void ClearColors()
27362782 {
27372783 if (blockloop)
....@@ -2866,7 +2912,8 @@
28662912 {
28672913 if (bRep != null)
28682914 {
2869
- bRep.GenUV();
2915
+ bRep.GenUV(); //1);
2916
+ //bRep.UnfoldUV();
28702917 Touch();
28712918 }
28722919 }
....@@ -2876,6 +2923,15 @@
28762923 if (bRep != null)
28772924 {
28782925 bRep.GenerateNormals(crease);
2926
+ Touch();
2927
+ }
2928
+ }
2929
+
2930
+ void GenNormalsMINE0()
2931
+ {
2932
+ if (bRep != null)
2933
+ {
2934
+ bRep.GenerateNormalsMINE();
28792935 Touch();
28802936 }
28812937 }
....@@ -2932,6 +2988,31 @@
29322988 blockloop = false;
29332989 }
29342990
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
+
29353016 void TransformGeometry()
29363017 {
29373018 Object3D obj = this;
....@@ -3153,7 +3234,7 @@
31533234
31543235 BoundaryRep sup = bRep.support;
31553236 bRep.support = null;
3156
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3237
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31573238 // bRep.SplitInTwo(onlyone); // thread...
31583239 temprep.SplitInTwo(reduction34, onlyone);
31593240 bRep = temprep;
....@@ -3677,7 +3758,7 @@
36773758 if (child == null)
36783759 continue;
36793760
3680
- if (GrafreeD.RENDERME > 0)
3761
+ if (Grafreed.RENDERME > 0)
36813762 {
36823763 if (child instanceof Merge)
36833764 ((Merge)child).renderme();
....@@ -3828,7 +3909,7 @@
38283909 if (child == null)
38293910 continue;
38303911
3831
- if (GrafreeD.RENDERME > 0)
3912
+ if (Grafreed.RENDERME > 0)
38323913 {
38333914 if (child instanceof Merge)
38343915 ((Merge)child).renderme();
....@@ -4023,7 +4104,7 @@
40234104 if (child == null)
40244105 continue;
40254106
4026
- if (GrafreeD.RENDERME > 0)
4107
+ if (Grafreed.RENDERME > 0)
40274108 {
40284109 if (child instanceof Merge)
40294110 ((Merge)child).renderme();
....@@ -4111,7 +4192,7 @@
41114192 if (blockloop)
41124193 return;
41134194
4114
- for (int i=0; i<size(); i++)
4195
+ for (int i=0; i<Size(); i++)
41154196 {
41164197 if (get(i).parent != this)
41174198 {
....@@ -4120,6 +4201,22 @@
41204201 }
41214202 blockloop = true;
41224203 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();
41234220 blockloop = false;
41244221 }
41254222 }
....@@ -4790,7 +4887,7 @@
47904887 return globalTransform;
47914888 }
47924889
4793
- void PreprocessOcclusion(CameraPane cp)
4890
+ void PreprocessOcclusion(iCameraPane cp)
47944891 {
47954892 /*
47964893 if (AOdone)
....@@ -4937,7 +5034,8 @@
49375034 } else //
49385035 if (editWindow != null)
49395036 {
4940
- editWindow.cameraView.lighttouched = true;
5037
+ //editWindow.cameraView.lighttouched = true;
5038
+ Globals.lighttouched = true;
49415039 }
49425040 }
49435041
....@@ -5091,10 +5189,34 @@
50915189
50925190 // System.out.println("Fullname = " + fullname);
50935191
5094
- if (fullname.name.indexOf(":") == -1)
5095
- 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(":"));
50965197
5097
- 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];
50985220 }
50995221
51005222 static String GetBump(cTexture fullname)
....@@ -5103,10 +5225,38 @@
51035225 return "";
51045226
51055227 // System.out.println("Fullname = " + fullname);
5106
- if (fullname.name.indexOf(":") == -1)
5107
- return "";
5108
-
5109
- 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];
51105260 }
51115261
51125262 String GetPigmentTexture()
....@@ -5180,7 +5330,7 @@
51805330 System.out.print("; textures = " + textures);
51815331 System.out.println("; usedtextures = " + usedtextures);
51825332
5183
- if (GetTextures() == null)
5333
+ if (GetTextures() == null) // What is that??
51845334 GetTextures().name = ":";
51855335
51865336 String texname = tex;
....@@ -5249,25 +5399,22 @@
52495399 }
52505400 }
52515401
5252
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5402
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52535403 {
52545404 Draw(display, root, selected, blocked);
52555405 }
52565406
5257
- static cMaterial[] materialstack = new cMaterial[65536];
5258
- static boolean[] selectedstack = new boolean[65536];
5259
- static int materialdepth = 0;
5260
-
52615407 boolean NeedSupport()
52625408 {
52635409 return
52645410 CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
52655411 // PROBLEM with CROWD!!
5266
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5412
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
52675413 }
52685414
5415
+ static boolean DEBUG_SELECTION = false;
52695416
5270
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5417
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52715418 {
52725419 Invariants(); // june 2013
52735420
....@@ -5276,7 +5423,7 @@
52765423 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
52775424 }
52785425
5279
- if (display.drawMode == CameraPane.SELECTION &&
5426
+ if (display.DrawMode() == iCameraPane.SELECTION &&
52805427 hide)
52815428 return;
52825429
....@@ -5295,7 +5442,7 @@
52955442 if (this instanceof Checker)
52965443 return;
52975444
5298
- if (display.drawMode == display.SHADOW && PASSTEST)
5445
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
52995446 return;
53005447
53015448 if (count <= 0)
....@@ -5303,13 +5450,13 @@
53035450 return;
53045451 }
53055452
5306
- if ((//display.drawMode == CameraPane.SHADOW ||
5307
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5453
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5454
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53085455 {
53095456 return;
53105457 }
53115458
5312
- javax.media.opengl.GL gl = display.GetGL();
5459
+ //javax.media.opengl.GL gl = display.GetGL();
53135460
53145461 /*
53155462 if (touched)
....@@ -5345,15 +5492,15 @@
53455492
53465493 boolean compiled = false;
53475494
5348
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5495
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53495496
5350
- if (!selectmode && //display.drawMode != display.SELECTION &&
5497
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
53515498 (touched || (bRep != null && bRep.displaylist <= 0)))
53525499 {
5353
- display.lighttouched = true;
5500
+ Globals.lighttouched = true;
53545501 } // all panes...
5355
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5356
- 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 &&
53575504 (touched || (bRep != null && bRep.displaylist <= 0)))
53585505 {
53595506 if (!(this instanceof Composite))
....@@ -5361,7 +5508,7 @@
53615508 //if (displaylist == -1 && usecalllists)
53625509 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
53635510 {
5364
- bRep.displaylist = gl.glGenLists(1);
5511
+ bRep.displaylist = display.GenList();
53655512 assert(bRep.displaylist != 0);
53665513 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
53675514 //System.out.println("\tgen list " + list);
....@@ -5373,18 +5520,20 @@
53735520 if (usecalllists)
53745521 {
53755522 // System.err.println("new list " + bRep.displaylist + " for " + this);
5376
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5523
+ display.NewList(bRep.displaylist);
53775524 }
5525
+
53785526 CallList(display, root, selected, blocked);
5527
+
53795528 // compiled = true;
53805529 if (usecalllists)
53815530 {
53825531 // System.err.println("end list " + bRep.displaylist + " for " + this);
5383
- gl.glEndList();
5532
+ display.EndList();
53845533 }
53855534 //gl.glDrawBuffer(gl.GL_BACK);
53865535 // XXX touched = false;
5387
- display.lighttouched = true; // all panes...
5536
+ Globals.lighttouched = true; // all panes...
53885537 }
53895538
53905539 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5423,12 +5572,12 @@
54235572
54245573 // frustum culling
54255574 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5426
- && display.drawMode != CameraPane.SELECTION)
5575
+ && display.DrawMode() != iCameraPane.SELECTION)
54275576 {
5428
- if (display.drawMode == CameraPane.SHADOW)
5577
+ if (display.DrawMode() == iCameraPane.SHADOW)
54295578 {
54305579 if (!link2master // tricky to cull in shadow mode.
5431
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5580
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54325581 {
54335582 //System.out.print("CULLED");
54345583 culled = true;
....@@ -5436,7 +5585,7 @@
54365585 }
54375586 else
54385587 //GetBRep().getBounds(v0, v1, this);
5439
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5588
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54405589 culled = true;
54415590
54425591 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5472,11 +5621,11 @@
54725621
54735622
54745623 if (!culled)
5475
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5624
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
54765625 {
54775626 if (GetBRep() != null)
54785627 {
5479
- CameraPane.NextIndex(this, gl);
5628
+ display.NextIndex();
54805629 // vertex color conflict : gl.glCallList(list);
54815630 DrawNode(display, root, selected);
54825631 if (this instanceof BezierPatch)
....@@ -5498,55 +5647,7 @@
54985647 color[2] /= 2;
54995648 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55005649 */
5501
- if (material != null)
5502
- {
5503
- materialstack[materialdepth] = material;
5504
- selectedstack[materialdepth] = selected;
5505
- cStatic.objectstack[materialdepth++] = this;
5506
- //System.out.println("material " + material);
5507
- //Applet3D.tracein(this, selected);
5508
- display.vector2buffer = projectedVertices;
5509
- if (this instanceof Camera)
5510
- {
5511
- display.options1[0] = material.shift;
5512
- //System.out.println("shift " + material.shift);
5513
- display.options1[1] = material.lightarea;
5514
- display.options1[2] = material.shadowbias;
5515
- display.options1[3] = material.aniso;
5516
- display.options1[4] = material.anisoV;
5517
- display.options2[0] = material.opacity;
5518
- display.options2[1] = material.diffuse;
5519
- display.options2[2] = material.factor;
5520
-
5521
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5522
- display.options4[0] = material.cameralight/0.2f;
5523
- display.options4[1] = material.subsurface;
5524
- display.options4[2] = material.sheen;
5525
-
5526
- // if (display.CURRENTANTIALIAS > 0)
5527
- // display.options3[3] /= 4;
5528
-
5529
- /*
5530
- System.out.println("Focus = " + display.options1[0]);
5531
- System.out.println("Aperture = " + display.options1[1]);
5532
- System.out.println("ShadowBlur = " + display.options1[2]);
5533
- System.out.println("Antialiasing = " + display.options1[3]);
5534
- System.out.println("Fog = " + display.options2[0]);
5535
- System.out.println("Intensity = " + display.options2[1]);
5536
- System.out.println("Elevation = " + display.options2[2]);
5537
- /**/
5538
- } else
5539
- {
5540
- material.Draw(display, selected);
5541
- }
5542
- } else
5543
- {
5544
- if (selected && CameraPane.flash)
5545
- {
5546
- display.modelParams4[1] = 100;
5547
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5548
- }
5549
- }
5650
+ display.PushMaterial(this, selected);
55505651
55515652 //System.out.println("call list " + list);
55525653 //System.out.println();
....@@ -5581,30 +5682,15 @@
55815682
55825683 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55835684 assert(bRep.displaylist != 0);
5584
- gl.glCallList(bRep.displaylist);
5685
+ display.CallList(bRep.displaylist);
55855686 // june 2013 drawSelf(display, root, selected);
55865687 }
55875688 }
55885689 }
55895690
55905691 display.ReleaseTextures(tex);
5591
-
5592
- //if (parent != null && parent.GetMaterial() != null)
5593
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5594
- if (material != null)
5595
- {
5596
- materialdepth -= 1;
5597
- if (materialdepth > 0)
5598
- {
5599
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5600
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5601
- }
5602
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5603
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5604
- {
5605
- display.modelParams4[1] = GetMaterial().cameralight;
5606
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5607
- }
5692
+
5693
+ display.PopMaterial(this, selected);
56085694 }
56095695
56105696 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5646,7 +5732,7 @@
56465732 // resetMasterNode();
56475733 }
56485734
5649
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5735
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56505736 {
56515737 if (GetBRep() == null)
56525738 {
....@@ -5729,7 +5815,7 @@
57295815 boolean flipV = false; // true;
57305816 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57315817
5732
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5818
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57335819 {
57345820 if (hide)
57355821 return;
....@@ -5788,16 +5874,7 @@
57885874 // // ??????????????????????????? Touch();
57895875 // }
57905876
5791
- if (material != null)
5792
- {
5793
- materialstack[materialdepth] = material;
5794
- selectedstack[materialdepth] = selected;
5795
- cStatic.objectstack[materialdepth++] = this;
5796
- //System.out.println("material " + material);
5797
- //Applet3D.tracein("selected ", selected);
5798
- display.vector2buffer = projectedVertices;
5799
- material.Draw(display, selected);
5800
- }
5877
+display.PushMaterial2(this, selected);
58015878
58025879 Object3D child;
58035880 boolean sel;
....@@ -5849,19 +5926,7 @@
58495926 */
58505927 //depth += 1;
58515928
5852
- if (material != null)
5853
- {
5854
- materialdepth -= 1;
5855
- if (materialdepth > 0)
5856
- {
5857
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5858
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5859
- }
5860
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5861
- //else
5862
- //material.Draw(display, false);
5863
- }
5864
-
5929
+display.PopMaterial2(this);
58655930 /*
58665931 display.ReleaseTextures(tex);
58675932 */
....@@ -5872,9 +5937,9 @@
58725937
58735938 //static cVector min,max;
58745939
5875
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
5940
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
58765941 {
5877
- 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)
58785943 return; // no shadow for transparent objects
58795944
58805945 if (hide)
....@@ -5917,11 +5982,12 @@
59175982 return;
59185983 }
59195984
5985
+ //bRep.GenUV(1/material.diffuseness);
59205986 // bRep.lock = true;
59215987
5922
- javax.media.opengl.GL gl = display.GetGL();
5988
+ //javax.media.opengl.GL gl = display.GetGL();
59235989
5924
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
5990
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59255991 {
59265992 int fc = bRep.FaceCount();
59275993 int vc = bRep.VertexCount();
....@@ -5936,23 +6002,7 @@
59366002
59376003 bRep.getMinMax(min, max, 100);
59386004
5939
- gl.glBegin(gl.GL_LINES);
5940
-
5941
- gl.glVertex3d(min.x, min.y, min.z);
5942
- gl.glVertex3d(min.x, min.y, max.z);
5943
- gl.glVertex3d(min.x, min.y, min.z);
5944
- gl.glVertex3d(min.x, max.y, min.z);
5945
- gl.glVertex3d(min.x, min.y, min.z);
5946
- gl.glVertex3d(max.x, min.y, min.z);
5947
-
5948
- gl.glVertex3d(max.x, max.y, max.z);
5949
- gl.glVertex3d(min.x, max.y, max.z);
5950
- gl.glVertex3d(max.x, max.y, max.z);
5951
- gl.glVertex3d(max.x, min.y, max.z);
5952
- gl.glVertex3d(max.x, max.y, max.z);
5953
- gl.glVertex3d(max.x, max.y, min.z);
5954
-
5955
- gl.glEnd();
6005
+ display.DrawBox(min, max);
59566006
59576007 return;
59586008 }
....@@ -5996,7 +6046,7 @@
59966046 {
59976047 //throw new Error();
59986048
5999
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6049
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60006050
60016051 int[] strips = bRep.getRawIndices();
60026052
....@@ -6006,178 +6056,14 @@
60066056 new Exception().printStackTrace();
60076057 return;
60086058 }
6009
-
6010
- // TRIANGLE STRIP ARRAY
6011
- if (bRep.trimmed)
6012
- {
6013
- float[] v = bRep.getRawVertices();
6014
- float[] n = bRep.getRawNormals();
6015
- float[] c = bRep.getRawColors();
6016
- float[] uv = bRep.getRawUVMap();
6017
-
6018
- int count2 = 0;
6019
- int count3 = 0;
6020
-
6021
- if (n.length > 0)
6022
- {
6023
- for (int i = 0; i < strips.length; i++)
6024
- {
6025
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6026
-
6027
- /*
6028
- boolean locked = false;
6029
- float eps = 0.1f;
6030
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6031
-
6032
- int dot = 0;
6033
-
6034
- if ((dot&1) == 0)
6035
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6036
-
6037
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6038
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6039
- else
6040
- {
6041
- locked = true;
6042
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6043
- }
6044
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6045
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6046
- if (hasnorm)
6047
- {
6048
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6049
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6050
- }
6051
-
6052
- if ((dot&4) == 0)
6053
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6054
-
6055
- if (wrap || !locked && (dot&8) != 0)
6056
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6057
- else
6058
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6059
-
6060
- f.dot = dot;
6061
- */
6062
-
6063
- if (!selectmode)
6064
- {
6065
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6066
- {
6067
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6068
- } else
6069
- {
6070
- gl.glNormal3f(0, 0, 1);
6071
- }
6072
-
6073
- if (c != null)
6074
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6075
- {
6076
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6077
- }
6078
- }
6079
- if (flipV)
6080
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6081
- else
6082
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6083
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6084
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6085
-
6086
- count2 += 2;
6087
- count3 += 3;
6088
- if (!selectmode)
6089
- {
6090
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6091
- {
6092
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6093
- } else
6094
- {
6095
- gl.glNormal3f(0, 0, 1);
6096
- }
6097
- if (c != null)
6098
- {
6099
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6100
- }
6101
- }
6102
- if (flipV)
6103
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6104
- else
6105
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6106
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6107
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6108
-
6109
- count2 += 2;
6110
- count3 += 3;
6111
- for (int j = 0; j < strips[i] - 2; j++)
6112
- {
6113
- //gl.glTexCoord2d(...);
6114
- if (!selectmode)
6115
- {
6116
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6117
- {
6118
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6119
- } else
6120
- {
6121
- gl.glNormal3f(0, 0, 1);
6122
- }
6123
- if (c != null)
6124
- {
6125
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6126
- }
6127
- }
6128
-
6129
- if (flipV)
6130
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6131
- else
6132
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6133
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6134
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6135
- count2 += 2;
6136
- count3 += 3;
6137
- }
6138
-
6139
- gl.glEnd();
6140
- }
6141
- }
6142
-
6143
- assert count3 == v.length;
6144
- }
6145
- else // !trimmed
6146
- {
6147
- int count = 0;
6148
- for (int i = 0; i < strips.length; i++)
6149
- {
6150
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6151
-
6152
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6153
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6154
-
6155
- drawVertex(gl, p, selectmode);
6156
- drawVertex(gl, q, selectmode);
6157
-
6158
- for (int j = 0; j < strips[i] - 2; j++)
6159
- {
6160
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6161
-
6162
-// if (j%2 == 0)
6163
-// drawFace(p, q, r, display, null);
6164
-// else
6165
-// drawFace(p, r, q, display, null);
6166
-
6167
-// p = q;
6168
-// q = r;
6169
- drawVertex(gl, r, selectmode);
6170
- }
6171
-
6172
- gl.glEnd();
6173
- }
6174
- }
6059
+
6060
+ display.DrawGeometry(bRep, flipV, selectmode);
61756061 } else // catch (Error e)
61766062 {
61776063 // TRIANGLE ARRAY
61786064 if (IsOpaque()) // Static())
61796065 {
6180
- gl.glBegin(gl.GL_TRIANGLES);
6066
+ display.StartTriangles();
61816067 int facecount = bRep.FaceCount();
61826068 for (int i = 0; i < facecount; i++)
61836069 {
....@@ -6240,9 +6126,9 @@
62406126 // // r.norm.dot(v3) > -0.5)
62416127 // // continue;
62426128
6243
- drawFace(p, q, r, display, face);
6129
+ display.DrawFace(this, p, q, r, face);
62446130 }
6245
- gl.glEnd();
6131
+ display.EndTriangles();
62466132 }
62476133 else
62486134 {
....@@ -6271,8 +6157,8 @@
62716157 //System.out.println("SORT");
62726158
62736159 java.util.Arrays.sort(facescompare);
6274
-
6275
- gl.glBegin(gl.GL_TRIANGLES);
6160
+
6161
+ display.StartTriangles();
62766162 for (int i = 0; i < facecount; i++)
62776163 {
62786164 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6284,13 +6170,14 @@
62846170 Vertex q = bRep.GetVertex(face.q);
62856171 Vertex r = bRep.GetVertex(face.r);
62866172
6287
- drawFace(p, q, r, display, face);
6173
+ display.DrawFace(this, p, q, r, face);
62886174 }
6289
- gl.glEnd();
6175
+ display.EndTriangles();
62906176 }
62916177
62926178 if (false) // live && support != null && support.bRep != null) // debug weights
62936179 {
6180
+ /*
62946181 gl.glDisable(gl.GL_LIGHTING);
62956182 float[] colorV = new float[3];
62966183
....@@ -6369,6 +6256,7 @@
63696256 // gl.glEnd();
63706257 }
63716258 }
6259
+ */
63726260 }
63736261 }
63746262
....@@ -6413,7 +6301,7 @@
64136301 center.add(r);
64146302 center.mul(1.0/3);
64156303
6416
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6304
+ center.sub(Globals.theRenderer.EyeCamera().location);
64176305
64186306 distance = center.dot(center);
64196307 }
....@@ -6424,347 +6312,11 @@
64246312
64256313 transient FaceCompare[] facescompare = null;
64266314
6427
- void SetColor(CameraPane display, Vertex p0)
6428
- {
6429
- if (display.RENDERPROGRAM == 0)
6430
- {
6431
- float r = 0;
6432
- if (bRep != null)
6433
- {
6434
- if (bRep.stripified)
6435
- {
6436
- r = 1;
6437
- }
6438
- }
6439
- float g = 0;
6440
- if (bRep != null)
6441
- {
6442
- if (bRep.trimmed)
6443
- {
6444
- g = 1;
6445
- }
6446
- }
6447
- float b = 0;
6448
- if (support != null && link2master)
6449
- {
6450
- b = 1;
6451
- }
6452
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6453
- return;
6454
- }
6455
-
6456
- if (display.drawMode != CameraPane.SHADOW)
6457
- return;
6458
-
6459
- javax.media.opengl.GL gl = display.GetGL();
6460
-// if (true) return;
6461
-// float ao = p.AO;
6462
-//
6463
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6464
-// // ao = 1;
6465
-//
6466
-// gl.glColor4f(ao, ao, ao, 1);
6467
-
6468
-// CameraPane.selectedpoint.
6469
-// getAverage(cStatic.point1, true);
6470
- if (CameraPane.pointflow == null) // !random) // live)
6471
- {
6472
- return;
6473
- }
6474
-
6475
- cStatic.point1.set(0,0,0);
6476
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6477
-
6478
- cStatic.point1.sub(p0);
6479
-
6480
-
6481
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6482
-// {
6483
-// return;
6484
-// }
6485
-
6486
- //if (true)
6487
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6488
- {
6489
- return;
6490
- }
6491
-
6492
- float[] colorV = new float[3];
6493
-
6494
- if (false) // marked)
6495
- {
6496
- // debug rigging weights
6497
- for (int object = 0; object < p0.vertexlinks.length; object++)
6498
- {
6499
- float weight = p0.weights[object] / p0.totalweight;
6500
-
6501
- // if (weight < 0.1)
6502
- // {
6503
- // assert(weight == 0);
6504
- // continue;
6505
- // }
6506
-
6507
- if (p0.vertexlinks[object] == -1)
6508
- continue;
6509
-
6510
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6511
-
6512
- int color = //1 << object; //
6513
- //p.vertexlinks.length;
6514
- support.bRep.supports[p0.closestsupport].links[object];
6515
- colorV[2] += (color & 1) * weight;
6516
- colorV[1] += ((color & 2) >> 1) * weight;
6517
- colorV[0] += ((color & 4) >> 2) * weight;
6518
- }
6519
- }
6520
- else
6521
- {
6522
- if (drawingstarted)
6523
- {
6524
- // find next point
6525
- if (bRep.GetVertex(0).faceindices == null)
6526
- {
6527
- bRep.InitFaceIndices();
6528
- }
6529
-
6530
- double ymin = p0.y;
6531
-
6532
- Vertex newp = p0;
6533
-
6534
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6535
- {
6536
- int fi = p0.faceindices[fii];
6537
-
6538
- if (fi == -1)
6539
- break;
6540
-
6541
- Face f = bRep.GetFace(fi);
6542
-
6543
- Vertex p = bRep.GetVertex(f.p);
6544
- Vertex q = bRep.GetVertex(f.q);
6545
- Vertex r = bRep.GetVertex(f.r);
6546
-
6547
- int swap = (int)(Math.random()*3);
6548
-
6549
-// for (int s=swap; --s>=0;)
6550
-// {
6551
-// Vertex t = p;
6552
-// p = q;
6553
-// q = r;
6554
-// r = t;
6555
-// }
6556
- if (ymin > p.y)
6557
- {
6558
- ymin = p.y;
6559
- newp = p;
6560
-// break;
6561
- }
6562
- if (ymin > q.y)
6563
- {
6564
- ymin = q.y;
6565
- newp = q;
6566
-// break;
6567
- }
6568
- if (ymin > r.y)
6569
- {
6570
- ymin = r.y;
6571
- newp = r;
6572
-// break;
6573
- }
6574
- }
6575
-
6576
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6577
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6578
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6579
-
6580
- drawingstarted = false;
6581
-
6582
- // return;
6583
- }
6584
-
6585
- if (false) // CameraPane.DRAW
6586
- {
6587
- p0.AO = colorV[0] = 2;
6588
- colorV[1] = 2;
6589
- colorV[2] = 2;
6590
- }
6591
-
6592
- CameraPane.pointflow.add(p0);
6593
- CameraPane.pointflow.Touch();
6594
- }
6595
-
6596
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6597
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6598
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6599
- }
6600
-
66016315 void Print(Vertex v)
66026316 {
66036317 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66046318 }
66056319
6606
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6607
- {
6608
- if (!selectmode)
6609
- {
6610
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6611
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6612
-
6613
- if (flipV)
6614
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6615
- else
6616
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6617
- }
6618
-
6619
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6620
- }
6621
-
6622
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6623
- CameraPane display, Face face)
6624
- {
6625
- if (pv.y == -10000 ||
6626
- qv.y == -10000 ||
6627
- rv.y == -10000)
6628
- return;
6629
-
6630
-// float b = f.nbiterations & 1;
6631
-// float g = (f.nbiterations>>1) & 1;
6632
-// float r = (f.nbiterations>>2) & 1;
6633
-//
6634
-// //if (f.weight == 10000)
6635
-// //{
6636
-// // r = 1; g = b = 0;
6637
-// //}
6638
-// //else
6639
-// //{
6640
-// // assert(f.weight < 10000);
6641
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6642
-// if (r<0)
6643
-// assert(r>=0);
6644
-// //}
6645
-
6646
- javax.media.opengl.GL gl = display.GetGL();
6647
-
6648
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6649
-
6650
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6651
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6652
- {
6653
- //gl.glBegin(gl.GL_TRIANGLES);
6654
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6655
- if (!hasnorm)
6656
- {
6657
- // System.out.println("FUCK!!");
6658
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6659
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6660
- LA.vecCross(v0, v1, v2);
6661
- LA.vecNormalize(v2);
6662
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6663
- }
6664
-
6665
- if (hasnorm)
6666
- {
6667
-// if (!pv.norm.normalized())
6668
-// assert(pv.norm.normalized());
6669
-
6670
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6671
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6672
- }
6673
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6674
- SetColor(display, pv);
6675
- //gl.glColor4f(r, g, b, 1);
6676
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6677
- if (flipV)
6678
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6679
- else
6680
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6681
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6682
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6683
-// Print(pv);
6684
- if (hasnorm)
6685
- {
6686
-// assert(qv.norm.normalized());
6687
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6688
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6689
- }
6690
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6691
- // boolean locked = false;
6692
- // float eps = 0.1f;
6693
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6694
-
6695
- // int dot = 0; //*/ (int)f.dot;
6696
-
6697
- // if ((dot&1) == 0)
6698
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6699
-
6700
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6701
- if (flipV)
6702
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6703
- else
6704
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6705
- // else
6706
- // {
6707
- // locked = true;
6708
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6709
- // }
6710
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6711
- SetColor(display, qv);
6712
- //gl.glColor4f(r, g, b, 1);
6713
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6714
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6715
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6716
-// Print(qv);
6717
- if (hasnorm)
6718
- {
6719
-// assert(rv.norm.normalized());
6720
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6721
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6722
- }
6723
-
6724
- // if ((dot&4) == 0)
6725
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6726
-
6727
- // if (wrap || !locked && (dot&8) != 0)
6728
- if (flipV)
6729
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6730
- else
6731
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6732
- // else
6733
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6734
-
6735
- // f.dot = dot;
6736
-
6737
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6738
- SetColor(display, rv);
6739
- //gl.glColor4f(r, g, b, 1);
6740
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6741
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6742
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6743
-// Print(rv);
6744
- //gl.glEnd();
6745
- }
6746
- else
6747
- {
6748
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6749
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6750
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6751
-
6752
- }
6753
-
6754
- if (false) // (attributes & WIREFRAME) != 0)
6755
- {
6756
- gl.glDisable(gl.GL_LIGHTING);
6757
-
6758
- gl.glBegin(gl.GL_LINE_LOOP);
6759
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6760
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6761
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6762
- gl.glEnd();
6763
-
6764
- gl.glEnable(gl.GL_LIGHTING);
6765
- }
6766
- }
6767
-
67686320 void drawSelf(ClickInfo info, int level, boolean select)
67696321 {
67706322 if (bRep == null)
....@@ -7336,83 +6888,83 @@
73366888 int spotw = spot.x + spot.width;
73376889 int spoth = spot.y + spot.height;
73386890 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7339
- if (CameraPane.Xmin > spot.x)
7340
- {
7341
- CameraPane.Xmin = spot.x;
7342
- }
7343
- if (CameraPane.Xmax < spotw)
7344
- {
7345
- CameraPane.Xmax = spotw;
7346
- }
7347
- if (CameraPane.Ymin > spot.y)
7348
- {
7349
- CameraPane.Ymin = spot.y;
7350
- }
7351
- if (CameraPane.Ymax < spoth)
7352
- {
7353
- CameraPane.Ymax = spoth;
7354
- }
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
+// }
73556907 spot.translate(32, 32);
73566908 spotw = spot.x + spot.width;
73576909 spoth = spot.y + spot.height;
73586910 info.g.setColor(Color.blue);
73596911 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7360
- if (CameraPane.Xmin > spot.x)
7361
- {
7362
- CameraPane.Xmin = spot.x;
7363
- }
7364
- if (CameraPane.Xmax < spotw)
7365
- {
7366
- CameraPane.Xmax = spotw;
7367
- }
7368
- if (CameraPane.Ymin > spot.y)
7369
- {
7370
- CameraPane.Ymin = spot.y;
7371
- }
7372
- if (CameraPane.Ymax < spoth)
7373
- {
7374
- CameraPane.Ymax = spoth;
7375
- }
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
+// }
73766928 info.g.drawLine(spotw, spoth, spotw, spoth - 15);
73776929 info.g.drawLine(spotw, spoth, spotw - 15, spoth);
73786930 spot.translate(0, -32);
73796931 info.g.setColor(Color.green);
73806932 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7381
- if (CameraPane.Xmin > spot.x)
7382
- {
7383
- CameraPane.Xmin = spot.x;
7384
- }
7385
- if (CameraPane.Xmax < spotw)
7386
- {
7387
- CameraPane.Xmax = spotw;
7388
- }
7389
- if (CameraPane.Ymin > spot.y)
7390
- {
7391
- CameraPane.Ymin = spot.y;
7392
- }
7393
- if (CameraPane.Ymax < spoth)
7394
- {
7395
- CameraPane.Ymax = spoth;
7396
- }
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
+// }
73976949 info.g.drawArc(boundary.x, boundary.y,
73986950 boundary.width, boundary.height, 0, 360);
73996951 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7400
- if (CameraPane.Xmin > boundary.x)
7401
- {
7402
- CameraPane.Xmin = boundary.x;
7403
- }
7404
- if (CameraPane.Xmax < boundary.x + boundary.width)
7405
- {
7406
- CameraPane.Xmax = boundary.x + boundary.width;
7407
- }
7408
- if (CameraPane.Ymin > boundary.y)
7409
- {
7410
- CameraPane.Ymin = boundary.y;
7411
- }
7412
- if (CameraPane.Ymax < boundary.y + boundary.height)
7413
- {
7414
- CameraPane.Ymax = boundary.y + boundary.height;
7415
- }
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
+// }
74166968 return;
74176969 }
74186970 }
....@@ -7462,7 +7014,7 @@
74627014 }
74637015
74647016 //System.out.println("info.modifiers = " + info.modifiers);
7465
- modified = (info.modifiers & CameraPane.META) != 0;
7017
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
74667018 //System.out.println("modified = " + modified);
74677019 //new Exception().printStackTrace();
74687020 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7490,7 +7042,7 @@
74907042 return true;
74917043 }
74927044
7493
- void doEditDrag0(ClickInfo info)
7045
+ void doEditDrag0(ClickInfo info, boolean opposite)
74947046 {
74957047 if (hitSomething == 0)
74967048 {
....@@ -7515,9 +7067,9 @@
75157067
75167068 case hitCenter: // Translate
75177069
7518
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7070
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75197071
7520
- if (modified)
7072
+ if (modified || opposite)
75217073 {
75227074 //assert(false);
75237075 /*
....@@ -7563,10 +7115,10 @@
75637115 }
75647116 LA.xformDir(up, ClickInfo.matbuffer, up);
75657117 // if (!CameraPane.LOCALTRANSFORM)
7566
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7118
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
75677119 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
75687120 // if (!CameraPane.LOCALTRANSFORM)
7569
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7121
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75707122 //LA.vecCross(up, cVector.Z, right2);
75717123
75727124 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7611,6 +7163,7 @@
76117163
76127164 if (modified)
76137165 {
7166
+ // Rotate 90 degrees
76147167 angle /= (Math.PI / 4);
76157168 angle = Math.floor(angle + 0.5);
76167169 angle *= (Math.PI / 4);
....@@ -7624,7 +7177,7 @@
76247177 }
76257178 /**/
76267179
7627
- switch (info.pane.renderCamera.viewCode)
7180
+ switch (info.pane.RenderCamera().viewCode)
76287181 {
76297182 case 1: // '\001'
76307183 LA.matZRotate(toParent, angle);
....@@ -7680,7 +7233,7 @@
76807233 }
76817234 /**/
76827235
7683
- switch (info.pane.renderCamera.viewCode)
7236
+ switch (info.pane.RenderCamera().viewCode)
76847237 {
76857238 case 3: // '\001'
76867239 if (modified)
....@@ -7733,7 +7286,7 @@
77337286 if (parent == null)
77347287 {
77357288 System.out.println("NULL PARENT");
7736
- new Exception().printStackTrace();
7289
+ //new Exception().printStackTrace();
77377290 } else
77387291 {
77397292 if (parent instanceof BezierPatch)
....@@ -7845,14 +7398,22 @@
78457398 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78467399 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78477400 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7401
+
7402
+ String objname;
7403
+
78487404 if (false) //parent != null)
78497405 {
7850
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7406
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78517407 } else
78527408 {
7853
- 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) ":"") */ "";
78547410 } // + super.toString();
78557411 //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);
78567417 }
78577418
78587419 public int hashCode()
....@@ -7908,6 +7469,7 @@
79087469 objectUI.closeUI();
79097470 if (editWindow != null)
79107471 {
7472
+ editWindow.ctrlPanel.FlushUI();
79117473 editWindow.refreshContents();
79127474 } // ? new
79137475 objectUI = null;
....@@ -8043,7 +7605,7 @@
80437605 {
80447606 assert(bRep != null);
80457607 if (!(support instanceof GenericJoint)) // support.bRep != null)
8046
- GrafreeD.Assert(support.bRep == bRep.support);
7608
+ Grafreed.Assert(support.bRep == bRep.support);
80477609 }
80487610 else
80497611 {
....@@ -8126,6 +7688,8 @@
81267688 {
81277689 Object3D targ = this;
81287690
7691
+ targ.NORMALPUSH = obj.NORMALPUSH;
7692
+
81297693 if (obj.material != null)
81307694 {
81317695 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))