Normand Briere
2019-09-04 b6efb029509980fd08ca4ebe28c89cf8d79fa46c
deepCopyNode
27 files modified
1 files added
367 ■■■■■ changed files
Attribute.java 4 ●●●● patch | view | raw | blame | history
BezierPatch.java 4 ●●●● patch | view | raw | blame | history
Biparam.java 4 ●●●● patch | view | raw | blame | history
Blob.java 4 ●●●● patch | view | raw | blame | history
BlobComponent.java 4 ●●●● patch | view | raw | blame | history
Box.java 4 ●●●● patch | view | raw | blame | history
CSG.java 4 ●●●● patch | view | raw | blame | history
Composite.java 4 ●●●● patch | view | raw | blame | history
Cone.java 4 ●●●● patch | view | raw | blame | history
FileObject.java 4 ●●●● patch | view | raw | blame | history
FrameSelector.java 4 ●●●● patch | view | raw | blame | history
Grid.java 4 ●●●● patch | view | raw | blame | history
JpegLoader.java 16 ●●●●● patch | view | raw | blame | history
Klein.java 4 ●●●● patch | view | raw | blame | history
Lathe.java 4 ●●●● patch | view | raw | blame | history
MorphNode.java 4 ●●●● patch | view | raw | blame | history
ObjEditor.java 21 ●●●●● patch | view | raw | blame | history
Object3D.java 208 ●●●●● patch | view | raw | blame | history
RandomEditor.java 9 ●●●● patch | view | raw | blame | history
RandomNode.java 21 ●●●●● patch | view | raw | blame | history
ScriptNode.java 4 ●●●● patch | view | raw | blame | history
Skybox.java 4 ●●●● patch | view | raw | blame | history
Sphere.java 4 ●●●● patch | view | raw | blame | history
Spline.java 4 ●●●● patch | view | raw | blame | history
Superellipsoid.java 4 ●●●● patch | view | raw | blame | history
SwitchNode.java 4 ●●●● patch | view | raw | blame | history
TextureNode.java 4 ●●●● patch | view | raw | blame | history
Torus.java 4 ●●●● patch | view | raw | blame | history
Attribute.java
....@@ -22,9 +22,9 @@
2222 return csg;
2323 }
2424
25
- protected void deepCopySelf(Object3D other)
25
+ protected void deepCopyNode(Object3D other)
2626 {
27
- super.deepCopySelf(other);
27
+ super.deepCopyNode(other);
2828 Attribute c = (Attribute) other;
2929
3030 c.cleardepth = cleardepth;
BezierPatch.java
....@@ -43,9 +43,9 @@
4343 return l;
4444 }
4545
46
- protected void deepCopySelf(Object3D other)
46
+ protected void deepCopyNode(Object3D other)
4747 {
48
- super.deepCopySelf(other);
48
+ super.deepCopyNode(other);
4949 BezierPatch bp = (BezierPatch)other;
5050 bp.depth = depth;
5151 int count = ctrlPnts.size();
Biparam.java
....@@ -40,9 +40,9 @@
4040 super.DrawNode(display, root, selected);
4141 }
4242
43
- protected void deepCopySelf(Object3D other)
43
+ protected void deepCopyNode(Object3D other)
4444 {
45
- super.deepCopySelf(other);
45
+ super.deepCopyNode(other);
4646 Biparam bp = (Biparam)other;
4747 bp.uDivs = uDivs;
4848 bp.vDivs = vDivs;
Blob.java
....@@ -21,9 +21,9 @@
2121 return blob;
2222 }
2323
24
- protected void deepCopySelf(Object3D other)
24
+ protected void deepCopyNode(Object3D other)
2525 {
26
- super.deepCopySelf(other);
26
+ super.deepCopyNode(other);
2727 Blob b = (Blob)other;
2828 b.threshold = threshold;
2929 b.cellSize = cellSize;
BlobComponent.java
....@@ -20,9 +20,9 @@
2020 return comp;
2121 }
2222
23
- protected void deepCopySelf(Object3D other)
23
+ protected void deepCopyNode(Object3D other)
2424 {
25
- super.deepCopySelf(other);
25
+ super.deepCopyNode(other);
2626 BlobComponent b = (BlobComponent)other;
2727 //b.center = new cVector();
2828 //LA.vecCopy(center, b.center);
Box.java
....@@ -23,9 +23,9 @@
2323 return rec;
2424 }
2525
26
- protected void deepCopySelf(Object3D other)
26
+ protected void deepCopyNode(Object3D other)
2727 {
28
- super.deepCopySelf(other);
28
+ super.deepCopyNode(other);
2929 // Box rec = (Box)other;
3030 // rec.minima = new cVector();
3131 // LA.vecCopy(minima, rec.minima);
CSG.java
....@@ -31,9 +31,9 @@
3131 return csg;
3232 }
3333
34
- protected void deepCopySelf(Object3D other)
34
+ protected void deepCopyNode(Object3D other)
3535 {
36
- super.deepCopySelf(other);
36
+ super.deepCopyNode(other);
3737 CSG c = (CSG) other;
3838 c.csgType = csgType;
3939 c.genType = genType;
Composite.java
....@@ -293,9 +293,9 @@
293293 return compo;
294294 }
295295
296
- protected void deepCopySelf(Object3D other)
296
+ protected void deepCopyNode(Object3D other)
297297 {
298
- super.deepCopySelf(other);
298
+ super.deepCopyNode(other);
299299
300300 if (false)
301301 {
Cone.java
....@@ -86,9 +86,9 @@
8686 return cone;
8787 }
8888
89
- protected void deepCopySelf(Object3D other)
89
+ protected void deepCopyNode(Object3D other)
9090 {
91
- super.deepCopySelf(other);
91
+ super.deepCopyNode(other);
9292 Cone c = (Cone)other;
9393 LA.vecCopy(base, c.base);
9494 c.baseRadius = baseRadius;
FileObject.java
....@@ -101,9 +101,9 @@
101101 return e;
102102 }
103103
104
- protected void deepCopySelf(Object3D other)
104
+ protected void deepCopyNode(Object3D other)
105105 {
106
- super.deepCopySelf(other);
106
+ super.deepCopyNode(other);
107107 }
108108
109109 // void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected)
FrameSelector.java
....@@ -47,9 +47,9 @@
4747 return e;
4848 }
4949
50
- protected void deepCopySelf(Object3D other)
50
+ protected void deepCopyNode(Object3D other)
5151 {
52
- super.deepCopySelf(other);
52
+ super.deepCopyNode(other);
5353 FrameSelector bp = (FrameSelector)other;
5454 // bp.frame = (int)(Math.random()*(getNumFrames() - mocap.offset));
5555 }
Grid.java
....@@ -37,9 +37,9 @@
3737 return e;
3838 }
3939
40
- protected void deepCopySelf(Object3D other)
40
+ protected void deepCopyNode(Object3D other)
4141 {
42
- super.deepCopySelf(other);
42
+ super.deepCopyNode(other);
4343 Grid e = (Grid)other;
4444 e.center = new cVector();
4545 LA.vecCopy(center, e.center);
JpegLoader.java
....@@ -0,0 +1,16 @@
1
+/*
2
+ * To change this template, choose Tools | Templates
3
+ * and open the template in the editor.
4
+ */
5
+
6
+/**
7
+ *
8
+ * @author nbriere
9
+ */
10
+public class JpegLoader
11
+{
12
+ static java.awt.image.BufferedImage load(String name)
13
+ {
14
+ return new sun.awt.image.codec.JPEGImageDecoderImpl(ObjEditor.class.getClassLoader().getResourceAsStream(name)).decodeAsBufferedImage();
15
+ }
16
+}
Klein.java
....@@ -74,9 +74,9 @@
7474 return e;
7575 }
7676
77
- protected void deepCopySelf(Object3D other)
77
+ protected void deepCopyNode(Object3D other)
7878 {
79
- super.deepCopySelf(other);
79
+ super.deepCopyNode(other);
8080 Klein e = (Klein) other;
8181 if (center != null)
8282 {
Lathe.java
....@@ -22,9 +22,9 @@
2222 return l;
2323 }
2424
25
- protected void deepCopySelf(Object3D other)
25
+ protected void deepCopyNode(Object3D other)
2626 {
27
- super.deepCopySelf(other);
27
+ super.deepCopyNode(other);
2828 Lathe l = (Lathe)other;
2929 l.spline = (Spline)spline.deepCopy();
3030 }
MorphNode.java
....@@ -107,9 +107,9 @@
107107 return e;
108108 }
109109
110
- protected void deepCopySelf(Object3D other)
110
+ protected void deepCopyNode(Object3D other)
111111 {
112
- super.deepCopySelf(other);
112
+ super.deepCopyNode(other);
113113 MorphNode bp = (MorphNode)other;
114114
115115 bp.morphweights = (double[]) Grafreed.clone(morphweights);
ObjEditor.java
....@@ -24,6 +24,7 @@
2424 matrix.Matrix;
2525
2626 import grafeme.ui.*;
27
+import org.xj3d.ui.swt.widgets.ImageLoader;
2728
2829 class ObjEditor /*extends JFrame*/ implements iCallBack, ObjectUI,
2930 ActionListener, ChangeListener,
....@@ -141,7 +142,7 @@
141142 try
142143 {
143144 // Much faster!
144
- image = new sun.awt.image.codec.JPEGImageDecoderImpl(ObjEditor.class.getClassLoader().getResourceAsStream(name)).decodeAsBufferedImage();
145
+ image = JpegLoader.load(name);
145146 }
146147 catch (Exception e)
147148 {
....@@ -4662,9 +4663,8 @@
46624663 changed.ExtractBigData(Grafreed.grafreed.universe.versiontable);
46634664
46644665 changed.clear();
4665
-
4666
- changed.skyboxname = obj.skyboxname;
4667
- changed.skyboxext = obj.skyboxext;
4666
+
4667
+ obj.deepCopyNode(changed);
46684668
46694669 for (int i=0; i<obj.Size(); i++)
46704670 {
....@@ -4860,11 +4860,14 @@
48604860
48614861 void SetCameras()
48624862 {
4863
- Camera neweye = (Camera)copy.GetObject(cameraView.cameras[0].GetUUID());
4864
- Camera newlight = (Camera)copy.GetObject(cameraView.LightCamera().GetUUID());
4865
-
4866
- cameraView.SetCamera(neweye);
4867
- cameraView.SetLight(newlight);
4863
+ if (copy == Grafreed.grafreed.universe)
4864
+ {
4865
+ Camera neweye = (Camera)copy.GetObject(cameraView.cameras[0].GetUUID());
4866
+ Camera newlight = (Camera)copy.GetObject(cameraView.LightCamera().GetUUID());
4867
+
4868
+ cameraView.SetCamera(neweye);
4869
+ cameraView.SetLight(newlight);
4870
+ }
48684871 }
48694872
48704873 void ImportGFD()
Object3D.java
....@@ -40,6 +40,78 @@
4040
4141 ScriptNode scriptnode;
4242
43
+ void deepCopyNode(Object3D other)
44
+ {
45
+ other.skyboxname = skyboxname;
46
+ other.skyboxext = skyboxext;
47
+
48
+ if (toParent != null)
49
+ {
50
+ other.toParent = LA.newMatrix();
51
+ other.fromParent = LA.newMatrix();
52
+ LA.matCopy(toParent, other.toParent);
53
+ LA.matCopy(fromParent, other.fromParent);
54
+ if (toParentMarked != null)
55
+ {
56
+ other.toParentMarked = LA.newMatrix();
57
+ other.fromParentMarked = LA.newMatrix();
58
+ LA.matCopy(toParentMarked, other.toParentMarked);
59
+ LA.matCopy(fromParentMarked, other.fromParentMarked);
60
+ }
61
+ }
62
+ else
63
+ {
64
+ if (other.toParent == null)
65
+// assert(other.toParent == null);
66
+// new Exception().printStackTrace();
67
+ System.err.println("null parent: " + other);
68
+ }
69
+
70
+ /*
71
+ double ident[][] = LA.newMatrix();
72
+ if (bRep == null)
73
+ other.bRep = null;
74
+ else
75
+ other.bRep = new BoundaryRep(bRep, ident);
76
+ */
77
+ // Really new...
78
+ //other.editWindow = null;
79
+ if (name == null)
80
+ other.name = null;
81
+ else
82
+ other.name = new String(name);
83
+
84
+ if (material != null)
85
+ {
86
+ other.material = new cMaterial(material);
87
+ } else
88
+ {
89
+ other.material = null;
90
+ }
91
+
92
+ other.GetTextures().name = GetTextures().name;
93
+
94
+ CopyExtraMaterial(other);
95
+
96
+ other.touched = touched;
97
+ other.softtouched = softtouched;
98
+
99
+ other.random = random;
100
+ other.link2master = link2master;
101
+ other.transformcount = transformcount;
102
+ other.marked = marked;
103
+ other.skip = skip;
104
+ other.count = count;
105
+ other.flipV = flipV;
106
+ other.live = live;
107
+ other.rewind = rewind;
108
+ other.hide = hide;
109
+ other.texres = texres;
110
+ other.speedup = speedup;
111
+ other.height = height;
112
+ other.depth = depth;
113
+ }
114
+
43115 int VersionCount()
44116 {
45117 int count = 0;
....@@ -1310,78 +1382,16 @@
13101382 return;
13111383
13121384 blockloop = true;
1385
+
1386
+ other.parent = parent;
1387
+
13131388 //System.out.println("COPY " + this + " to " + other);
13141389 //new Exception().printStackTrace();
1390
+ deepCopyNode(other);
13151391
1316
- other.parent = parent;
1317
- if (toParent != null)
1318
- {
1319
- other.toParent = LA.newMatrix();
1320
- other.fromParent = LA.newMatrix();
1321
- LA.matCopy(toParent, other.toParent);
1322
- LA.matCopy(fromParent, other.fromParent);
1323
- if (toParentMarked != null)
1324
- {
1325
- other.toParentMarked = LA.newMatrix();
1326
- other.fromParentMarked = LA.newMatrix();
1327
- LA.matCopy(toParentMarked, other.toParentMarked);
1328
- LA.matCopy(fromParentMarked, other.fromParentMarked);
1329
- }
1330
- }
1331
- else
1332
- {
1333
- if (other.toParent == null)
1334
-// assert(other.toParent == null);
1335
-// new Exception().printStackTrace();
1336
- System.err.println("null parent: " + other);
1337
- }
1338
- /*
1339
- double ident[][] = LA.newMatrix();
1340
- if (bRep == null)
1341
- other.bRep = null;
1342
- else
1343
- other.bRep = new BoundaryRep(bRep, ident);
1344
- */
1345
- // Really new...
13461392 other.bRep = bRep; // Share the geometry
13471393
13481394 other.support = support; // Share the support
1349
-
1350
- //other.editWindow = null;
1351
- if (name == null)
1352
- other.name = null;
1353
- else
1354
- other.name = new String(name);
1355
-
1356
- if (material != null)
1357
- {
1358
- other.material = new cMaterial(material);
1359
- } else
1360
- {
1361
- other.material = null;
1362
- }
1363
-
1364
- other.GetTextures().name = GetTextures().name;
1365
-
1366
- CopyExtraMaterial(other);
1367
-
1368
- other.touched = touched;
1369
- other.softtouched = softtouched;
1370
-
1371
- other.random = random;
1372
- other.link2master = link2master;
1373
- other.transformcount = transformcount;
1374
- other.marked = marked;
1375
- other.skip = skip;
1376
- other.count = count;
1377
- other.flipV = flipV;
1378
- other.live = live;
1379
- other.rewind = rewind;
1380
- other.hide = hide;
1381
- other.texres = texres;
1382
- other.speedup = speedup;
1383
- other.height = height;
1384
- other.depth = depth;
13851395
13861396 // aout 2013 if (/*displaylist != -1 &&*/other.displaylist != displaylist)
13871397 // {
....@@ -1437,17 +1447,24 @@
14371447 if ((mask & GEOMETRY) != 0)
14381448 {
14391449 if (bRep != null)
1440
- bRep.overwriteThis(other.bRep==null?other.transientrep:other.bRep);
1441
- else
1442
- assert(other.bRep == null);
1443
-
1444
- if (bRep != null)
14451450 {
1451
+ bRep.overwriteThis(other.bRep==null?other.transientrep:other.bRep);
14461452 CameraPane.RemoveList(bRep.displaylist);
14471453 bRep.displaylist = 0; // june 2013 -1;
14481454 }
14491455 else
1450
- bRep = bRep;
1456
+ {
1457
+ //assert(other.bRep == null);
1458
+ bRep = other.bRep;
1459
+ }
1460
+
1461
+// if (bRep != null)
1462
+// {
1463
+// CameraPane.RemoveList(bRep.displaylist);
1464
+// bRep.displaylist = 0; // june 2013 -1;
1465
+// }
1466
+// else
1467
+// bRep = bRep;
14511468 }
14521469
14531470 /* Use a MASK = GEO/MAT
....@@ -4260,9 +4277,9 @@
42604277 max = new cVector();
42614278 }
42624279
4263
- for (int i = 0; i<size(); i++)
4280
+ for (int i = 0; i<Size(); i++)
42644281 {
4265
- Object3D child = (Object3D) reserve(i);
4282
+ Object3D child = (Object3D) get(i); //reserve(i);
42664283 if (child == null)
42674284 continue;
42684285
....@@ -4281,14 +4298,14 @@
42814298 if (child.hide && !(child instanceof Merge) || child.skip)
42824299 //if (child.hide)
42834300 {
4284
- release(i);
4301
+ //release(i);
42854302 continue;
42864303 }
42874304
42884305 blockloop = true;
42894306 child.getBounds(min, max, true); // xform);
42904307 blockloop = false;
4291
- release(i);
4308
+ //release(i);
42924309
42934310 MinMax(minima, maxima);
42944311 }
....@@ -6357,6 +6374,20 @@
63576374 {
63586375 drawSelf(display, root, selected, blocked);
63596376 }
6377
+
6378
+// if (!(this instanceof Composite))
6379
+// {
6380
+// for (int i = 0; i < size(); i++)
6381
+// {
6382
+// Object3D child = (Object3D) reserve(i);
6383
+// if (child == null)
6384
+// continue;
6385
+//
6386
+// child.draw(display, root, selected, blocked);
6387
+//
6388
+// release(i);
6389
+// }
6390
+// }
63606391 } else
63616392 {
63626393 /*
....@@ -6427,6 +6458,20 @@
64276458 // june 2013 drawSelf(display, root, selected);
64286459 }
64296460 }
6461
+
6462
+ assert (!(this instanceof Composite));
6463
+ {
6464
+ for (int i = 0; i < size(); i++)
6465
+ {
6466
+ Object3D child = (Object3D) reserve(i);
6467
+ if (child == null)
6468
+ continue;
6469
+
6470
+ child.draw(display, root, selected, blocked);
6471
+
6472
+ release(i);
6473
+ }
6474
+ }
64306475 }
64316476
64326477 if (!failedBump)
....@@ -6479,16 +6524,17 @@
64796524
64806525 void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
64816526 {
6482
- if (GetBRep() == null)
6483
- {
6484
- drawSelf(display, root, selected, blocked);
6485
- } else
6527
+ if (GetBRep() != null)
64866528 {
64876529 DrawNode(display, root, selected);
64886530 if (this instanceof BezierPatch)
64896531 {
64906532 //drawSelf(display, root, selected);
64916533 }
6534
+ }
6535
+ else
6536
+ {
6537
+ drawSelf(display, root, selected, blocked);
64926538 }
64936539 }
64946540
....@@ -8237,7 +8283,7 @@
82378283 // if (!Globals.ADVANCED)
82388284 // return objname;
82398285
8240
- return objname + " " + System.identityHashCode(this); // + GetUUID()
8286
+ return objname; // + " " + System.identityHashCode(this); // + GetUUID()
82418287 }
82428288
82438289 public int hashCode()
RandomEditor.java
....@@ -136,9 +136,14 @@
136136 return objEditor;
137137 }
138138
139
- void refreshContents2()
139
+ void refreshContents()
140140 {
141
- objEditor.refreshContents();
141
+ itemField.setMinimum(0);
142
+ itemField.setMaximum(randomnode.Size() - 1);
143
+ itemField.setInteger(randomnode.rndIndex);
144
+
145
+ itemField.validate();
146
+ // objEditor.refreshContents();
142147 }
143148
144149 RandomNode randomnode;
RandomNode.java
....@@ -20,6 +20,15 @@
2020 return comp;
2121 }
2222
23
+ protected void deepCopyNode(Object3D other)
24
+ {
25
+ super.deepCopyNode(other);
26
+ RandomNode bp = (RandomNode)other;
27
+ bp.rndIndex = rndIndex;
28
+ bp.damp = damp;
29
+ bp.firstchoice = firstchoice;
30
+ }
31
+
2332 // public int Size()
2433 // {
2534 // return 1;
....@@ -43,6 +52,18 @@
4352 return super.size();
4453 }
4554
55
+ void addChild(Object3D child)
56
+ {
57
+ super.addChild(child);
58
+
59
+ this.rndIndex = Size() - 1;
60
+
61
+ if (this.editWindow != null)
62
+ {
63
+ ((RandomEditor)this.objectUI).refreshContents();
64
+ }
65
+ }
66
+
4667 int rndIndex = -1;
4768
4869 static int globalseed = 0;
ScriptNode.java
....@@ -1821,9 +1821,9 @@
18211821 return e;
18221822 }
18231823
1824
- protected void deepCopySelf(Object3D other)
1824
+ protected void deepCopyNode(Object3D other)
18251825 {
1826
- super.deepCopySelf(other);
1826
+ super.deepCopyNode(other);
18271827 // FrameSelector bp = (FrameSelector)other;
18281828 // bp.frame = (int)(Math.random()*(getNumFrames() - mocap.offset));
18291829 }
Skybox.java
....@@ -24,9 +24,9 @@
2424 return rec;
2525 }
2626
27
- protected void deepCopySelf(Object3D other)
27
+ protected void deepCopyNode(Object3D other)
2828 {
29
- super.deepCopySelf(other);
29
+ super.deepCopyNode(other);
3030 Skybox rec = (Skybox)other;
3131 rec.minima = new cVector();
3232 LA.vecCopy(minima, rec.minima);
Sphere.java
....@@ -95,9 +95,9 @@
9595 return e;
9696 }
9797
98
- protected void deepCopySelf(Object3D other)
98
+ protected void deepCopyNode(Object3D other)
9999 {
100
- super.deepCopySelf(other);
100
+ super.deepCopyNode(other);
101101 Sphere e = (Sphere) other;
102102 if (center != null)
103103 {
Spline.java
....@@ -19,9 +19,9 @@
1919 return spline;
2020 }
2121
22
- protected void deepCopySelf(Object3D other)
22
+ protected void deepCopyNode(Object3D other)
2323 {
24
- super.deepCopySelf(other);
24
+ super.deepCopyNode(other);
2525 Spline spline = (Spline)other;
2626 spline.type = type;
2727 int count = ctrlPnts.size();
Superellipsoid.java
....@@ -30,9 +30,9 @@
3030 return s;
3131 }
3232
33
- protected void deepCopySelf(Object3D other)
33
+ protected void deepCopyNode(Object3D other)
3434 {
35
- super.deepCopySelf(other);
35
+ super.deepCopyNode(other);
3636 Superellipsoid s = (Superellipsoid)other;
3737 s.east = east;
3838 s.north = north;
SwitchNode.java
....@@ -138,9 +138,9 @@
138138 return e;
139139 }
140140
141
- protected void deepCopySelf(Object3D other)
141
+ protected void deepCopyNode(Object3D other)
142142 {
143
- super.deepCopySelf(other);
143
+ super.deepCopyNode(other);
144144 SwitchNode bp = (SwitchNode)other;
145145 bp.child = child;
146146 }
TextureNode.java
....@@ -124,9 +124,9 @@
124124 // else
125125 // return 1;
126126 // }
127
- protected void deepCopySelf(Object3D other)
127
+ protected void deepCopyNode(Object3D other)
128128 {
129
- super.deepCopySelf(other);
129
+ super.deepCopyNode(other);
130130
131131 other.maxcount = maxcount;
132132 other.transformcount = transformcount;
Torus.java
....@@ -25,9 +25,9 @@
2525 return t;
2626 }
2727
28
- protected void deepCopySelf(Object3D other)
28
+ protected void deepCopyNode(Object3D other)
2929 {
30
- super.deepCopySelf(other);
30
+ super.deepCopyNode(other);
3131 Torus t = (Torus)other;
3232 t.major = major;
3333 t.minor = minor;