Normand Briere
2017-05-07 314b34423070cf127464da79a53cddf6b1c38587
GroupEditor.java
....@@ -14,7 +14,7 @@
1414
1515 //import buoy.widget.BFileChooser;
1616
17
-class GroupEditor extends ObjEditor implements iParse, //iCallBack,
17
+class GroupEditor extends ObjEditor implements //iParse, //iCallBack,
1818 ObjectUI,
1919 Runnable,
2020 ActionListener,
....@@ -83,7 +83,7 @@
8383
8484 void CloneSelection(boolean supports)
8585 {
86
- // Object3D keep = GraphreeD.clipboard;
86
+ // Object3D keep = GrafreeD.clipboard;
8787 //Object3D obj;
8888 for (int i=0; i<group.selection.size(); i++)// Enumeration e = group.selection.elements(); e.hasMoreElements();)
8989 {
....@@ -97,14 +97,14 @@
9797
9898 void CloneClipboard(boolean supports)
9999 {
100
- assert(GraphreeD.clipboard.parent == null);
101
- Object3D /*Composite*/ keepparent = GraphreeD.clipboard.get(0).parent;
102
- GraphreeD.clipboard.get(0).parent = null; // Avoid copy?
103
- if (LA.isIdentity(GraphreeD.clipboard.toParent))
104
- makeSomething(CloneObject(GraphreeD.clipboard.get(0), false));
100
+ assert(GrafreeD.clipboard.parent == null);
101
+ Object3D /*Composite*/ keepparent = GrafreeD.clipboard.get(0).parent;
102
+ GrafreeD.clipboard.get(0).parent = null; // Avoid copy?
103
+ if (LA.isIdentity(GrafreeD.clipboard.toParent))
104
+ makeSomething(CloneObject(GrafreeD.clipboard.get(0), false));
105105 else
106
- makeSomething(CloneObject(GraphreeD.clipboard, false));
107
- GraphreeD.clipboard.get(0).parent = keepparent;
106
+ makeSomething(CloneObject(GrafreeD.clipboard, false));
107
+ GrafreeD.clipboard.get(0).parent = keepparent;
108108 }
109109
110110 static Object3D CloneObject(Object3D obj, boolean supports)
....@@ -118,7 +118,7 @@
118118 // obj.support = null;
119119 if (!supports)
120120 obj.SaveSupports();
121
- Object3D clone = (Object3D)GraphreeD.clone(obj);
121
+ Object3D clone = (Object3D)GrafreeD.clone(obj);
122122 obj.parent = parent;
123123 // obj.support = support;
124124 // clone.support = support; // aout 2013
....@@ -188,8 +188,9 @@
188188 clearItem.addActionListener(this);
189189 clearAllItem = menu.add(new MenuItem("Clear All"));
190190 clearAllItem.addActionListener(this);
191
- menu.add("-");
192
- resetMeshItem = menu.add(new MenuItem("Reset All"));
191
+
192
+ oe.menuBar.add(menu = new Menu("Setting"));
193
+ resetMeshItem = menu.add(new MenuItem("Reset All"));
193194 resetMeshItem.addActionListener(this);
194195 stepAllItem = menu.add(new MenuItem("Step All"));
195196 stepAllItem.addActionListener(this);
....@@ -221,13 +222,13 @@
221222 setMasterItem = menu.add(new MenuItem("Set Master Mesh"));
222223 setMasterItem.addActionListener(this);
223224
224
- oe.menuBar.add(menu = new Menu("Object"));
225
+ oe.menuBar.add(menu = new Menu("Group"));
225226 grabItem = menu.add(new MenuItem("Grab"));
226227 grabItem.addActionListener(this);
227
- frontItem = menu.add(new MenuItem("Front"));
228
- frontItem.addActionListener(this);
229228 backItem = menu.add(new MenuItem("Back"));
230229 backItem.addActionListener(this);
230
+ frontItem = menu.add(new MenuItem("Front"));
231
+ frontItem.addActionListener(this);
231232 compositeItem = menu.add(new MenuItem("Composite"));
232233 compositeItem.addActionListener(this);
233234 menu.add("-");
....@@ -247,7 +248,8 @@
247248 scriptNodeItem.addActionListener(this);
248249 cameraItem = menu.add(new MenuItem("Camera"));
249250 cameraItem.addActionListener(this);
250
- menu.add("-");
251
+
252
+ oe.menuBar.add(menu = new Menu("Object"));
251253 textureItem = menu.add(new MenuItem("Texture"));
252254 textureItem.addActionListener(this);
253255 csgItem = menu.add(new MenuItem("CSG"));
....@@ -283,6 +285,8 @@
283285 genNormalsORGANItem.addActionListener(this);
284286 genNormalsCADItem = menu.add(new MenuItem("CAD Normals"));
285287 genNormalsCADItem.addActionListener(this);
288
+ genNormalsMESHItem = menu.add(new MenuItem("Mesh Normals"));
289
+ genNormalsMESHItem.addActionListener(this);
286290 stripifyItem = menu.add(new MenuItem("Stripify"));
287291 stripifyItem.addActionListener(this);
288292 unstripifyItem = menu.add(new MenuItem("Unstripify"));
....@@ -292,8 +296,6 @@
292296 untrimItem = menu.add(new MenuItem("Untrim"));
293297 untrimItem.addActionListener(this);
294298 menu.add("-");
295
- clearMaterialsItem = menu.add(new MenuItem("Clear Materials"));
296
- clearMaterialsItem.addActionListener(this);
297299 clearColorsItem = menu.add(new MenuItem("Clear AO"));
298300 clearColorsItem.addActionListener(this);
299301 reverseNormalsItem = menu.add(new MenuItem("Reverse Normals"));
....@@ -310,6 +312,10 @@
310312 smoothMeshItem.addActionListener(this);
311313 clipMeshItem = menu.add(new MenuItem("Clip mesh"));
312314 clipMeshItem.addActionListener(this);
315
+
316
+ oe.menuBar.add(menu = new Menu("Attributes"));
317
+ clearMaterialsItem = menu.add(new MenuItem("Clear Materials"));
318
+ clearMaterialsItem.addActionListener(this);
313319 menu.add("-");
314320 liveleavesItem = menu.add(new MenuItem("Live Leaves"));
315321 liveleavesItem.addActionListener(this);
....@@ -332,27 +338,18 @@
332338 flipVItem.addActionListener(this);
333339 unflipVItem = menu.add(new MenuItem("Unflip V"));
334340 unflipVItem.addActionListener(this);
335
- lowTexturesItem = menu.add(new MenuItem("Low Texture"));
341
+ lowTexturesItem = menu.add(new MenuItem("Low Texture (256)"));
336342 lowTexturesItem.addActionListener(this);
337
- normalTexturesItem = menu.add(new MenuItem("Normal Texture"));
343
+ normalTexturesItem = menu.add(new MenuItem("Normal Texture (512)"));
338344 normalTexturesItem.addActionListener(this);
339
- highTexturesItem = menu.add(new MenuItem("High Texture"));
345
+ highTexturesItem = menu.add(new MenuItem("High Texture (1024)"));
340346 highTexturesItem.addActionListener(this);
341
- veryhighTexturesItem = menu.add(new MenuItem("Very high Texture"));
347
+ veryhighTexturesItem = menu.add(new MenuItem("Very high Texture (2048)"));
342348 veryhighTexturesItem.addActionListener(this);
343
- maxTexturesItem = menu.add(new MenuItem("Max Texture"));
349
+ maxTexturesItem = menu.add(new MenuItem("Max Texture (4096)"));
344350 maxTexturesItem.addActionListener(this);
345
- panoTexturesItem = menu.add(new MenuItem("Panoramic Texture"));
351
+ panoTexturesItem = menu.add(new MenuItem("Panoramic Texture (8192)"));
346352 panoTexturesItem.addActionListener(this);
347
- menu.add("-");
348
- extractGeometriesItem = menu.add(new MenuItem("Link Geometry"));
349
- extractGeometriesItem.addActionListener(this);
350
- cloneGeometriesItem = menu.add(new MenuItem("Clone Geometry"));
351
- cloneGeometriesItem.addActionListener(this);
352
- shareGeometriesItem = menu.add(new MenuItem("Share Geometry"));
353
- shareGeometriesItem.addActionListener(this);
354
- mergeGeometriesItem = menu.add(new MenuItem("Merge Geometry"));
355
- mergeGeometriesItem.addActionListener(this);
356353
357354 oe.menuBar.add(menu = new Menu("Selection"));
358355 attachPigmentItem = menu.add(new MenuItem("Attach Pigment..."));
....@@ -370,9 +367,31 @@
370367 sortbysizeItem.addActionListener(this);
371368 sortbynameItem = menu.add(new MenuItem("Sort by name"));
372369 sortbynameItem.addActionListener(this);
370
+ menu.add("-");
371
+ extractGeometriesItem = menu.add(new MenuItem("Link Geometry"));
372
+ extractGeometriesItem.addActionListener(this);
373
+ cloneGeometriesItem = menu.add(new MenuItem("Clone Geometry"));
374
+ cloneGeometriesItem.addActionListener(this);
375
+ shareGeometriesItem = menu.add(new MenuItem("Share Geometry"));
376
+ shareGeometriesItem.addActionListener(this);
377
+ mergeGeometriesItem = menu.add(new MenuItem("Merge Geometry"));
378
+ mergeGeometriesItem.addActionListener(this);
379
+
373380 oe.menuBar.add(menu = new Menu("Insert"));
374381 buildCreateMenu(menu);
375
- oe.menuBar.add(menu = new Menu("Tools"));
382
+
383
+
384
+ oe.menuBar.add(menu = new Menu("Include"));
385
+ importGFDItem = menu.add(new MenuItem("GrafreeD Object..."));
386
+ importGFDItem.addActionListener(this);
387
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D Object..."));
388
+ importVRMLX3DItem.addActionListener(this);
389
+ importOBJItem = menu.add(new MenuItem("OBJ Object..."));
390
+ importOBJItem.addActionListener(this);
391
+ import3DSItem = menu.add(new MenuItem("3DS Object..."));
392
+ import3DSItem.addActionListener(this);
393
+
394
+ oe.menuBar.add(menu = new Menu("Tools"));
376395 buildToolsMenu(menu);
377396 }
378397
....@@ -1002,6 +1021,8 @@
10021021
10031022 void buildCreateMenu(Menu menu)
10041023 {
1024
+ //heightFieldItem = menu.add(new MenuItem("Height Field"));
1025
+ //heightFieldItem.addActionListener(this);
10051026 gridItem = menu.add(new MenuItem("Grid"));
10061027 gridItem.addActionListener(this);
10071028 rectoidItem = menu.add(new MenuItem("Box"));
....@@ -1048,15 +1069,6 @@
10481069 doubleItem.addActionListener(this);
10491070 tripleItem = menu.add(new MenuItem("Trident"));
10501071 tripleItem.addActionListener(this);
1051
- menu.add("-");
1052
- importGFDItem = menu.add(new MenuItem("GraphreeD Object..."));
1053
- importGFDItem.addActionListener(this);
1054
- importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D Object..."));
1055
- importVRMLX3DItem.addActionListener(this);
1056
- importOBJItem = menu.add(new MenuItem("OBJ Object..."));
1057
- importOBJItem.addActionListener(this);
1058
- import3DSItem = menu.add(new MenuItem("3DS Object..."));
1059
- import3DSItem.addActionListener(this);
10601072 }
10611073
10621074 void buildToolsMenu(Menu menu)
....@@ -1068,6 +1080,8 @@
10681080 menu.add("-");
10691081 parseverticesItem = menu.add(new MenuItem("Multiplicity"));
10701082 parseverticesItem.addActionListener(this);
1083
+ textureFieldItem = menu.add(new MenuItem("Texture Field"));
1084
+ textureFieldItem.addActionListener(this);
10711085 alignItem = menu.add(new MenuItem("Align"));
10721086 alignItem.addActionListener(this);
10731087 mirrorItem = menu.add(new MenuItem("Mirror Poses"));
....@@ -1429,9 +1443,9 @@
14291443
14301444 void Overwrite(int mask)
14311445 {
1432
- if (/*group.selection.size() == 1 &&*/ GraphreeD.clipboard.size() == 1)
1446
+ if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1)
14331447 {
1434
- Object3D content = GraphreeD.clipboard.get(0);
1448
+ Object3D content = GrafreeD.clipboard.get(0);
14351449
14361450 if (content instanceof cGroup && ((cGroup)content).transientlink )
14371451 content = ((cGroup)content).get(0);
....@@ -1521,6 +1535,46 @@
15211535 makeSomething(ragdoll);
15221536 //makeSomething(new VehicleDemo());
15231537 } else
1538
+ /*
1539
+ */
1540
+ if (event.getSource() == heightFieldItem)
1541
+ {
1542
+ Object3D obj = new Object3D();
1543
+
1544
+ obj.CreateMaterial();
1545
+ obj.bRep = new BoundaryRep();
1546
+
1547
+ obj.bRep.CreateMesh(new iHeightField()
1548
+ {
1549
+ public double f(double x, double y)
1550
+ {
1551
+ // The Mandelbrot set is represented by coloring
1552
+ // each point (x,y) according to the number of
1553
+ // iterations it takes before the while loop in
1554
+ // this method ends. For points that are actually
1555
+ // in the Mandelbrot set, or very close to it, the
1556
+ // count will reach the maximum value, 80. These
1557
+ // points will be colored purple. All other colors
1558
+ // represent points that are definitely NOT in the set.
1559
+ x -= 600;
1560
+ y -= 500;
1561
+ x /= 200;
1562
+ y /= 200;
1563
+ int count = 0;
1564
+ double zx = x;
1565
+ double zy = y;
1566
+ while (count < 80 && Math.abs(x) < 100 && Math.abs(zy) < 100) {
1567
+ double new_zx = zx*zx - zy*zy + x;
1568
+ zy = 2*zx*zy + y;
1569
+ zx = new_zx;
1570
+ count++;
1571
+ }
1572
+ return count; // Math.sqrt(count);
1573
+ }
1574
+ }, 1000,1000);
1575
+
1576
+ makeSomething(obj);
1577
+ } else
15241578 if (event.getSource() == gridItem)
15251579 {
15261580 makeSomething(new Grid());
....@@ -1570,7 +1624,7 @@
15701624 LA.matConcat(obj.toParent, cameraView.renderCamera.fromParent, obj.toParent);
15711625 LA.matInvert(obj.toParent, obj.fromParent);
15721626 */
1573
- makeSomething(new CheckerIG());
1627
+ makeSomething(new Checker());
15741628 } else
15751629 if (event.getSource() == meshItem)
15761630 {
....@@ -1726,7 +1780,7 @@
17261780 if (event.getSource() == invariantsItem)
17271781 {
17281782 System.out.println("Invariants:");
1729
- GraphreeD.theApplet3D.universe.invariants();
1783
+ GrafreeD.theApplet3D.universe.invariants();
17301784 } else
17311785 if (event.getSource() == memoryItem)
17321786 {
....@@ -1796,10 +1850,10 @@
17961850 } else
17971851 if (event.getSource() == duplicateItem)
17981852 {
1799
- Object3D keep = GraphreeD.clipboard;
1853
+ Object3D keep = GrafreeD.clipboard;
18001854 loadClipboard(false);
18011855 paste(false);
1802
- GraphreeD.clipboard = keep;
1856
+ GrafreeD.clipboard = keep;
18031857 } else
18041858 if (event.getSource() == cloneItem)
18051859 {
....@@ -1843,8 +1897,9 @@
18431897 } else
18441898 if (event.getSource() == overwriteMatItem)
18451899 {
1900
+ /* july 2015
18461901 if ((dropAttributes & Object3D.TEXTURE) == 0)
1847
- Overwrite(Object3D.MATERIAL);
1902
+ Overwrite(Object3D.MATERIAL | Object3D.COLOR);
18481903 else
18491904 {
18501905 if ((dropAttributes & Object3D.COLOR) == 0 && (dropAttributes & Object3D.MATERIAL) == 0)
....@@ -1856,13 +1911,16 @@
18561911 Overwrite(Object3D.MATERIAL | Object3D.TEXTURE);
18571912 }
18581913 }
1914
+ */
1915
+
1916
+ Overwrite(dropAttributes);
18591917 }
18601918 if (event.getSource() == overwriteGeoItem)
18611919 {
18621920 Overwrite(Object3D.GEOMETRY);
1863
-// if (/*group.selection.size() == 1 &&*/ GraphreeD.clipboard.size() == 1)
1921
+// if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1)
18641922 // {
1865
-// Object3D content = GraphreeD.clipboard.get(0);
1923
+// Object3D content = GrafreeD.clipboard.get(0);
18661924 //
18671925 // if (content instanceof cGroup && ((cGroup)content).transientlink )
18681926 // content = ((cGroup)content).get(0);
....@@ -1995,9 +2053,9 @@
19952053 } else
19962054 if (event.getSource() == linkverticesItem)
19972055 {
1998
-// if (group.selection.size() == 1 && GraphreeD.clipboard.size() == 1)
2056
+// if (group.selection.size() == 1 && GrafreeD.clipboard.size() == 1)
19992057 // {
2000
-// Object3D content = GraphreeD.clipboard.get(0);
2058
+// Object3D content = GrafreeD.clipboard.get(0);
20012059 //
20022060 // if (content instanceof cGroup && ((cGroup)content).transientlink )
20032061 // content = ((cGroup)content).get(0);
....@@ -2006,9 +2064,9 @@
20062064 // group.selection.get(0).setMasterThis(content); // should be identity
20072065 // refreshContents();
20082066 // }
2009
- if (/*group.selection.size() == 1 &&*/ GraphreeD.clipboard.size() == 1)
2067
+ if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1)
20102068 {
2011
- Object3D content = GraphreeD.clipboard.get(0);
2069
+ Object3D content = GrafreeD.clipboard.get(0);
20122070
20132071 if (content instanceof cGroup && ((cGroup)content).transientlink )
20142072 content = ((cGroup)content).get(0);
....@@ -2049,9 +2107,9 @@
20492107 } else
20502108 if (event.getSource() == setMasterItem)
20512109 {
2052
- if (group.selection.size() == 1 && GraphreeD.clipboard.size() == 1)
2110
+ if (group.selection.size() == 1 && GrafreeD.clipboard.size() == 1)
20532111 {
2054
- Object3D content = GraphreeD.clipboard.get(0);
2112
+ Object3D content = GrafreeD.clipboard.get(0);
20552113
20562114 if (content instanceof cGroup && ((cGroup)content).transientlink )
20572115 content = ((cGroup)content).get(0);
....@@ -2064,9 +2122,9 @@
20642122 {
20652123 if (group.selection.size() == 1)
20662124 {
2067
- if (GraphreeD.clipboard.size() == 1)
2125
+ if (GrafreeD.clipboard.size() == 1)
20682126 {
2069
- Object3D content = GraphreeD.clipboard.get(0);
2127
+ Object3D content = GrafreeD.clipboard.get(0);
20702128
20712129 if (content instanceof cGroup && ((cGroup)content).transientlink )
20722130 content = ((cGroup)content).get(0);
....@@ -2253,6 +2311,10 @@
22532311 {
22542312 GenNormals(true);
22552313 } else
2314
+ if (event.getSource() == genNormalsMESHItem)
2315
+ {
2316
+ GenNormals(true); // TODO
2317
+ } else
22562318 if (event.getSource() == genNormalsORGANItem)
22572319 {
22582320 GenNormals(false);
....@@ -2352,6 +2414,10 @@
23522414 if (event.getSource() == parseverticesItem)
23532415 {
23542416 ParseVertices();
2417
+ } else
2418
+ if (event.getSource() == textureFieldItem)
2419
+ {
2420
+ TextureVertices();
23552421 } else
23562422 if (event.getSource() == alignItem)
23572423 {
....@@ -2750,7 +2816,7 @@
27502816 if (event.getSource() == unselectButton)
27512817 {
27522818 objEditor.jTree.clearSelection();
2753
- // ?? oct 2012 GraphreeD.clipboard.clear();
2819
+ // ?? oct 2012 GrafreeD.clipboard.clear();
27542820 objEditor.ResetSliders();
27552821 refreshContents(true);
27562822 } else
....@@ -3065,9 +3131,9 @@
30653131 obj = (Object3D)e.nextElement();
30663132
30673133 System.out.println("Object is: " + obj);
3068
- GraphreeD.AnalyzeObject(obj);
3134
+ GrafreeD.AnalyzeObject(obj);
30693135 System.out.println("Boundary rep: " + obj.bRep);
3070
- GraphreeD.AnalyzeObject(obj.bRep);
3136
+ GrafreeD.AnalyzeObject(obj.bRep);
30713137
30723138 // System.err.println((size/1024) + " KB is the size of " + obj);
30733139 }
....@@ -3157,96 +3223,228 @@
31573223
31583224 //Object3D buffer;
31593225 cVector temp = new cVector();
3160
- BoundaryRep temprep;
3161
- Object3D nodes;
3162
- Vector<Vertex> vertices;
3163
-
3164
- public void Vertex(Object3D node, Vertex v)
3165
- {
3166
- vertices.add(v);
3167
- nodes.addElement(node);
3168
-
3169
- if (temprep.GetCache(v) != null)
3170
- {
3171
- temprep.Remove(v);
3172
- }
3173
- else
3174
- {
3175
- temprep.Remember(v);
3176
- }
3177
- }
3178
-
3179
- public void Face(Object3D node, Face f)
3180
- {
3181
-
3182
- }
3183
-
3226
+// BoundaryRep temprep;
3227
+// Object3D nodes;
3228
+// Vector<Vertex> vertices;
3229
+//
3230
+// cGroup buffer;
3231
+//
3232
+// public void Vertex(Object3D node, Vertex v)
3233
+// {
3234
+//// vertices.add(v);
3235
+//// nodes.addElement(node);
3236
+////
3237
+//// if (temprep.GetCache(v) != null)
3238
+//// {
3239
+//// temprep.Remove(v);
3240
+//// } else
3241
+//// {
3242
+//// temprep.Remember(v);
3243
+//// }
3244
+//
3245
+// //Object3D node = nodes.get(index);
3246
+// temp.set(v); // vertices.get(index)); // temprep.GetVertex(k));
3247
+// // System.out.println("temp = " + temp.x + ", " + temp.y + ", " + temp.z);
3248
+//
3249
+// LA.xformPos(temp, node.GlobalTransformInv(), temp);
3250
+//
3251
+// // System.out.println("tem+ = " + temp.x + ", " + temp.y + ", " + temp.z);
3252
+//
3253
+// cGroup g = new cGroup();
3254
+//
3255
+// if (g.toParent == null)
3256
+// {
3257
+// g.toParent = LA.newMatrix();
3258
+// g.fromParent = LA.newMatrix();
3259
+// }
3260
+// LA.matTranslate(g.toParent, temp.x, temp.y, temp.z);
3261
+// LA.matTranslate(g.fromParent, -temp.x, -temp.y, -temp.z);
3262
+//
3263
+// g.add(GrafreeD.clipboard);
3264
+//
3265
+// buffer.add(g);
3266
+// }
3267
+//
3268
+// public void Face(Object3D node, Face f)
3269
+// {
3270
+//
3271
+// }
3272
+//
3273
+// void ParseVerticesOld() // ??
3274
+// {
3275
+// //if (group.selection.size() != 1)
3276
+// // return;
3277
+//
3278
+// temprep = new BoundaryRep();
3279
+// nodes = new Object3D();
3280
+// vertices = new Vector<Vertex>();
3281
+//
3282
+// boolean epsequal = GrafreeD.epsequal;
3283
+// GrafreeD.epsequal = true;
3284
+//
3285
+// for (int i=0; i<group.selection.size(); i++)
3286
+// {
3287
+// Object3D buffer = new cGroup(group.selection.get(i).name + "+");
3288
+//
3289
+// group.selection.get(i).Parse(
3290
+//this );
3291
+//
3292
+// int repsize = temprep.VertexCount();
3293
+// int tablesize = temprep.vertextable.size();
3294
+// int nodesize = nodes.size();
3295
+//
3296
+// assert(vertices.size() == nodes.size());
3297
+//
3298
+// temprep.vertextable.elements();
3299
+//
3300
+// java.util.Set<java.util.Map.Entry<Vertex,Vertex>> set = temprep.vertextable.entrySet();
3301
+//
3302
+// for (java.util.Map.Entry<Vertex,Vertex> entry : set)
3303
+// {
3304
+// cGroup g = new cGroup();
3305
+//
3306
+// int index = vertices.indexOf(entry.getValue()); // temprep.vertextable.(k));
3307
+//
3308
+// Object3D node = nodes.get(index);
3309
+// temp.set(vertices.get(index)); // temprep.GetVertex(k));
3310
+// // System.out.println("temp = " + temp.x + ", " + temp.y + ", " + temp.z);
3311
+//
3312
+// LA.xformPos(temp, node.GlobalTransformInv(), temp);
3313
+//
3314
+// // System.out.println("tem+ = " + temp.x + ", " + temp.y + ", " + temp.z);
3315
+//
3316
+// if (g.toParent == null)
3317
+// {
3318
+// g.toParent = LA.newMatrix();
3319
+// g.fromParent = LA.newMatrix();
3320
+// }
3321
+// LA.matTranslate(g.toParent, temp.x, temp.y, temp.z);
3322
+// LA.matTranslate(g.fromParent, -temp.x, -temp.y, -temp.z);
3323
+//
3324
+// g.add(GrafreeD.clipboard);
3325
+//
3326
+// buffer.add(g);
3327
+// }
3328
+//
3329
+// makeSomething(buffer, i==group.selection.size()-1);
3330
+// }
3331
+//
3332
+// GrafreeD.epsequal = epsequal;
3333
+//
3334
+// //buffer = null;
3335
+// temprep = null;
3336
+// nodes = null;
3337
+//
3338
+// refreshContents();
3339
+// }
3340
+
31843341 void ParseVertices()
31853342 {
3186
- //if (group.selection.size() != 1)
3187
- // return;
3188
-
3189
- temprep = new BoundaryRep();
3190
- nodes = new Object3D();
3191
- vertices = new Vector<Vertex>();
3192
-
3193
- boolean epsequal = GraphreeD.epsequal;
3194
- GraphreeD.epsequal = true;
3343
+ boolean epsequal = GrafreeD.epsequal;
3344
+ GrafreeD.epsequal = true;
31953345
31963346 for (int i=0; i<group.selection.size(); i++)
31973347 {
3198
- Object3D buffer = new cGroup(group.selection.get(i).name + "+");
3348
+ final cGroup buffer = new cGroup(group.selection.get(i).name + "+");
31993349
3200
- group.selection.get(i).Parse(this);
3201
-
3202
- int repsize = temprep.VertexCount();
3203
- int tablesize = temprep.vertextable.size();
3204
- int nodesize = nodes.size();
3350
+ group.selection.get(i).Parse(
3351
+
3352
+ new iParse()
3353
+ {
3354
+ public void Vertex(Object3D node, Vertex v)
3355
+ {
3356
+ temp.set(v);
3357
+ LA.xformPos(temp, node.GlobalTransformInv(), temp);
32053358
3206
- assert(vertices.size() == nodes.size());
3207
-
3208
- temprep.vertextable.elements();
3209
-
3210
- java.util.Set<java.util.Map.Entry<Vertex,Vertex>> set = temprep.vertextable.entrySet();
3359
+ cGroup g = new cGroup();
32113360
3212
- for (java.util.Map.Entry<Vertex,Vertex> entry : set)
3213
- {
3214
- cGroup g = new cGroup();
3361
+ if (g.toParent == null)
3362
+ {
3363
+ g.toParent = LA.newMatrix();
3364
+ g.fromParent = LA.newMatrix();
3365
+ }
3366
+ LA.matTranslate(g.toParent, temp.x, temp.y, temp.z);
3367
+ LA.matTranslate(g.fromParent, -temp.x, -temp.y, -temp.z);
32153368
3216
- int index = vertices.indexOf(entry.getValue()); // temprep.vertextable.(k));
3217
- Object3D node = nodes.get(index);
3218
- temp.set(vertices.get(index)); // temprep.GetVertex(k));
3219
- // System.out.println("temp = " + temp.x + ", " + temp.y + ", " + temp.z);
3369
+ g.add(GrafreeD.clipboard);
32203370
3221
- LA.xformPos(temp, node.GlobalTransformInv(), temp);
3222
-
3223
- // System.out.println("tem+ = " + temp.x + ", " + temp.y + ", " + temp.z);
3224
-
3225
- if (g.toParent == null)
3226
- {
3227
- g.toParent = LA.newMatrix();
3228
- g.fromParent = LA.newMatrix();
3229
- }
3230
- LA.matTranslate(g.toParent, temp.x, temp.y, temp.z);
3231
- LA.matTranslate(g.fromParent, -temp.x, -temp.y, -temp.z);
3371
+ buffer.add(g);
3372
+ }
32323373
3233
- g.add(GraphreeD.clipboard);
3374
+ public void Face(Object3D node, Face f)
3375
+ {
32343376
3235
- buffer.add(g);
3236
- }
3377
+ }
3378
+ }
3379
+ );
32373380
32383381 makeSomething(buffer, i==group.selection.size()-1);
32393382 }
32403383
3241
- GraphreeD.epsequal = epsequal;
3242
-
3243
- //buffer = null;
3244
- temprep = null;
3245
- nodes = null;
3384
+ GrafreeD.epsequal = epsequal;
32463385
32473386 refreshContents();
32483387 }
3249
-
3388
+
3389
+ void TextureVertices()
3390
+ {
3391
+ for (int i=0; i<group.selection.size(); i++)
3392
+ {
3393
+ group.selection.get(i).Parse(
3394
+ new iParse()
3395
+ {
3396
+ public void Vertex(Object3D node, Vertex v)
3397
+ {
3398
+ cTexture tex = node.GetTextures();
3399
+ String pigment = Object3D.GetPigment(tex);
3400
+ //String bump = Object3D.GetBump(tex);
3401
+
3402
+ com.sun.opengl.util.texture.TextureData texturedata = CameraPane.theRenderer.GetTextureData(pigment, false, node.texres);
3403
+
3404
+ double s = v.s;
3405
+
3406
+ if (s == 1)
3407
+ s = 0;
3408
+
3409
+ double t = v.t;
3410
+
3411
+ if (t == 1)
3412
+ t = 0;
3413
+
3414
+ int indexs = (int) (texturedata.getWidth() * s);
3415
+ int indext = (int) (texturedata.getHeight() * t);
3416
+
3417
+ int index = indext * texturedata.getWidth() + indexs;
3418
+
3419
+ java.nio.ByteBuffer bytebuf = (java.nio.ByteBuffer)texturedata.getBuffer();
3420
+
3421
+ int slide = bytebuf.capacity() / texturedata.getWidth() / texturedata.getHeight();
3422
+
3423
+ float scale = bytebuf.get(index*slide) & 0xFF;
3424
+ scale += bytebuf.get(index*slide+1) & 0xFF;
3425
+ scale += bytebuf.get(index*slide+2) & 0xFF;
3426
+ scale /= 3;
3427
+
3428
+ scale /= 0xFF;
3429
+ // c'est quoi ca? scale /= 4;
3430
+
3431
+ //v.AO = scale;
3432
+
3433
+ v.x += v.norm.x * scale;
3434
+ v.y += v.norm.y * scale;
3435
+ v.z += v.norm.z * scale;
3436
+ }
3437
+
3438
+ public void Face(Object3D node, Face f)
3439
+ {
3440
+ }
3441
+ }
3442
+ );
3443
+ }
3444
+
3445
+ refreshContents();
3446
+ }
3447
+
32503448 void Align()
32513449 {
32523450 for (int i=0; i<group.selection.size(); i++)
....@@ -3267,7 +3465,7 @@
32673465 // ref.SaveSupports();
32683466 // Object3D par = ref.parent;
32693467 // ref.parent = null;
3270
-// Object3D lowres = (Object3D) GraphreeD.clone(ref);
3468
+// Object3D lowres = (Object3D) GrafreeD.clone(ref);
32713469 // ref.parent = par;
32723470 // ref.RestoreSupports();
32733471
....@@ -3297,7 +3495,7 @@
32973495 // lowres.SaveSupports();
32983496 // par = lowres.parent;
32993497 // lowres.parent = null;
3300
-// Object3D newlow = (Object3D) GraphreeD.clone(lowres);
3498
+// Object3D newlow = (Object3D) GrafreeD.clone(lowres);
33013499 Object3D newlow = CloneObject(lowres, false);
33023500 newlow.name = sn.switchobject.get(i).name;
33033501 System.out.println(" pose#" + i + " = " + newlow);
....@@ -3319,7 +3517,7 @@
33193517 return;
33203518
33213519 Object3D poses = group.selection.get(0);
3322
- Object3D ref = GraphreeD.clipboard.get(0);
3520
+ Object3D ref = GrafreeD.clipboard.get(0);
33233521
33243522 Object3D newgroup = new Object3D("Po:" + poses.name);
33253523
....@@ -3513,20 +3711,20 @@
35133711
35143712 void ClipMesh()
35153713 {
3516
- if (/*group.selection.size() == 1 &&*/ GraphreeD.clipboard.size() == 1)
3714
+ if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1)
35173715 {
3518
- Object3D content = GraphreeD.clipboard.get(0);
3716
+ Object3D content = GrafreeD.clipboard.get(0);
35193717
35203718 if (content instanceof cGroup && ((cGroup)content).transientlink )
35213719 content = ((cGroup)content).get(0);
35223720
35233721 // for (int i=0; i<group.selection.size(); i++)
35243722 // {
3525
-// group.selection.get(i).ClipMesh(GraphreeD.clipboard);
3723
+// group.selection.get(i).ClipMesh(GrafreeD.clipboard);
35263724 // }
3527
- group.selection.ClipMesh(GraphreeD.clipboard);
3725
+ group.selection.ClipMesh(GrafreeD.clipboard);
35283726 }
3529
-// group.selection.ClipMesh(GraphreeD.clipboard);
3727
+// group.selection.ClipMesh(GrafreeD.clipboard);
35303728 System.out.println("DONE.");
35313729 refreshContents();
35323730 }
....@@ -3864,12 +4062,12 @@
38644062 {
38654063 if (group.selection.isEmpty())
38664064 return;
3867
- GraphreeD.clipboardIsTempGroup = false;
4065
+ GrafreeD.clipboardIsTempGroup = false;
38684066 Composite tGroup = null;
38694067 if (group.selection.size() > 0) // 1)
38704068 {
38714069 tGroup = new cGroup();
3872
- GraphreeD.clipboardIsTempGroup = true;
4070
+ GrafreeD.clipboardIsTempGroup = true;
38734071 }
38744072
38754073 if (cut)
....@@ -3909,16 +4107,16 @@
39094107 //System.out.println("cut " + child);
39104108 //System.out.println("parent = " + child.parent);
39114109 // tmp.addChild(child);
3912
- if (GraphreeD.clipboardIsTempGroup)
4110
+ if (GrafreeD.clipboardIsTempGroup)
39134111 tGroup.add/*Child*/(tmp);
39144112 else
3915
- GraphreeD.clipboard = tmp;
4113
+ GrafreeD.clipboard = tmp;
39164114 }
39174115 else
3918
- if (GraphreeD.clipboardIsTempGroup)
4116
+ if (GrafreeD.clipboardIsTempGroup)
39194117 tGroup.add/*Child*/(child);
39204118 else
3921
- GraphreeD.clipboard = child;
4119
+ GrafreeD.clipboard = child;
39224120 }
39234121
39244122 //ResetModel();
....@@ -3950,21 +4148,21 @@
39504148 //System.out.println("cut " + elem);
39514149 //System.out.println("parent = " + elem.parent);
39524150 // tmp.addChild(elem);
3953
- if (GraphreeD.clipboardIsTempGroup)
4151
+ if (GrafreeD.clipboardIsTempGroup)
39544152 tGroup.add/*Child*/(tmp);
39554153 else
3956
- GraphreeD.clipboard = tmp;
4154
+ GrafreeD.clipboard = tmp;
39574155 }
39584156 else
3959
- if (GraphreeD.clipboardIsTempGroup)
4157
+ if (GrafreeD.clipboardIsTempGroup)
39604158 tGroup.add/*Child*/(child);
39614159 else
3962
- GraphreeD.clipboard = child;
4160
+ GrafreeD.clipboard = child;
39634161 }
39644162
39654163 }
3966
- if (GraphreeD.clipboardIsTempGroup)
3967
- GraphreeD.clipboard = tGroup;
4164
+ if (GrafreeD.clipboardIsTempGroup)
4165
+ GrafreeD.clipboard = tGroup;
39684166 if (cut)
39694167 {
39704168 ResetModel();
....@@ -3974,11 +4172,11 @@
39744172
39754173 void paste(boolean expand)
39764174 {
3977
- // if (GraphreeD.clipboard == null)
4175
+ // if (GrafreeD.clipboard == null)
39784176 // return;
39794177 boolean first = true;
39804178
3981
- if (GraphreeD.clipboardIsTempGroup)
4179
+ if (GrafreeD.clipboardIsTempGroup)
39824180 {
39834181 Composite temp;
39844182
....@@ -3989,7 +4187,7 @@
39894187 temp = (Composite)Applet3D.clipboard.deepCopy();
39904188 */
39914189 Object3D elem;
3992
- for (Enumeration e = /*temp.children*/GraphreeD.clipboard.elements(); e.hasMoreElements();) // objList.add(copy.name))
4190
+ for (Enumeration e = /*temp.children*/GrafreeD.clipboard.elements(); e.hasMoreElements();) // objList.add(copy.name))
39934191 {
39944192 Object3D child = (Object3D)e.nextElement();
39954193
....@@ -4003,7 +4201,7 @@
40034201 else
40044202 elem = child.deepCopy(); // ?
40054203 child.parent = keepparent;
4006
- //if (GraphreeD.clipboardIsTempGroup && LA.isIdentity(elem.fromParent))
4204
+ //if (GrafreeD.clipboardIsTempGroup && LA.isIdentity(elem.fromParent))
40074205 // elem = elem.get(0);
40084206 makeSomething(elem, true); // ?? first);
40094207 //group.addChild(elem);
....@@ -4023,14 +4221,14 @@
40234221 //Object3D cb = Applet3D.clipboard;
40244222 //temp.addChild(cb);
40254223 //makeSomething((expand?temp.copyExpand():temp.deepCopy()).get(0));
4026
- assert(GraphreeD.clipboard.parent == null);
4027
- Object3D /*Composite*/ keepparent = GraphreeD.clipboard.get(0).parent;
4028
- GraphreeD.clipboard.get(0).parent = null; // Avoid copy?
4029
- if (LA.isIdentity(GraphreeD.clipboard.toParent))
4030
- makeSomething(expand?GraphreeD.clipboard.get(0).copyExpand():GraphreeD.clipboard.get(0).deepCopy());
4224
+ assert(GrafreeD.clipboard.parent == null);
4225
+ Object3D /*Composite*/ keepparent = GrafreeD.clipboard.get(0).parent;
4226
+ GrafreeD.clipboard.get(0).parent = null; // Avoid copy?
4227
+ if (LA.isIdentity(GrafreeD.clipboard.toParent))
4228
+ makeSomething(expand?GrafreeD.clipboard.get(0).copyExpand():GrafreeD.clipboard.get(0).deepCopy());
40314229 else
4032
- makeSomething(expand?GraphreeD.clipboard.copyExpand():GraphreeD.clipboard.deepCopy());
4033
- GraphreeD.clipboard.get(0).parent = keepparent;
4230
+ makeSomething(expand?GrafreeD.clipboard.copyExpand():GrafreeD.clipboard.deepCopy());
4231
+ GrafreeD.clipboard.get(0).parent = keepparent;
40344232 }
40354233
40364234 ResetModel();
....@@ -4039,7 +4237,7 @@
40394237
40404238 void pasteInto(boolean copyit)
40414239 {
4042
-// if (GraphreeD.clipboard == null)
4240
+// if (GrafreeD.clipboard == null)
40434241 // return;
40444242
40454243 if (group.selection.size() != 1)
....@@ -4072,9 +4270,9 @@
40724270 {
40734271 boolean first = true;
40744272
4075
- if (GraphreeD.clipboardIsTempGroup)
4273
+ if (GrafreeD.clipboardIsTempGroup)
40764274 {
4077
- Composite temp = (Composite)GraphreeD.clipboard;
4275
+ Composite temp = (Composite)GrafreeD.clipboard;
40784276 Object3D copy;
40794277 for (Enumeration e = temp.children.elements(); e.hasMoreElements();)
40804278 {
....@@ -4084,7 +4282,7 @@
40844282 }
40854283 } else
40864284 {
4087
- linkSomething(GraphreeD.clipboard); //.get(0));
4285
+ linkSomething(GrafreeD.clipboard); //.get(0));
40884286 }
40894287 }
40904288 }
....@@ -4471,7 +4669,7 @@
44714669
44724670 void ImportGFD()
44734671 {
4474
- FileDialog browser = new FileDialog(objEditor.frame, "Import GraphreeD", FileDialog.LOAD);
4672
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
44754673 browser.show();
44764674 String filename = browser.getFile();
44774675 if (filename != null && filename.length() > 0)
....@@ -4509,7 +4707,7 @@
45094707
45104708 void ImportVRMLX3D()
45114709 {
4512
- if (GraphreeD.standAlone)
4710
+ if (GrafreeD.standAlone)
45134711 {
45144712 /**/
45154713 FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
....@@ -4526,7 +4724,7 @@
45264724
45274725 String GetFile(String dialogName)
45284726 {
4529
- if (GraphreeD.standAlone)
4727
+ if (GrafreeD.standAlone)
45304728 {
45314729 FileDialog browser = new FileDialog(objEditor.frame, dialogName, FileDialog.LOAD);
45324730 browser.show();
....@@ -4653,6 +4851,7 @@
46534851 private MenuItem clearItem;
46544852 private MenuItem clearAllItem;
46554853 private MenuItem genUVItem;
4854
+ private MenuItem genNormalsMESHItem;
46564855 private MenuItem genNormalsCADItem;
46574856 private MenuItem genNormalsORGANItem;
46584857 private MenuItem stripifyItem;
....@@ -4728,6 +4927,8 @@
47284927 private MenuItem particleItem;
47294928 private MenuItem ragdollItem;
47304929 private MenuItem ragdoll2Item;
4930
+ private MenuItem heightFieldItem;
4931
+ private MenuItem textureFieldItem;
47314932 private MenuItem gridItem;
47324933 private MenuItem rectoidItem;
47334934 private MenuItem ellipsoidItem;