Normand Briere
2018-05-22 42107f9a01652cb2f47228d20c1148a2a22f6a63
ObjEditor.java
....@@ -692,7 +692,7 @@
692692 protected static ImageIcon createImageIcon(String path,
693693 String description)
694694 {
695
- java.net.URL imgURL = GraphreeD.class.getResource(path);
695
+ java.net.URL imgURL = GrafreeD.class.getResource(path);
696696 if (imgURL != null)
697697 {
698698 return new ImageIcon(imgURL, description);
....@@ -1107,7 +1107,7 @@
11071107 //frontScroll.setLabel("------------------------------ XZ (front) ---------------------------------------------------");
11081108 //sideScroll.setLabel("------------------------------- YZ (side) ---------------------------------------------------");
11091109
1110
-// GridBagConstraints gbc = (GridBagConstraints) GraphreeD.clone(aConstraints);
1110
+// GridBagConstraints gbc = (GridBagConstraints) GrafreeD.clone(aConstraints);
11111111 Camera cam = GetCamera(copy, 0);
11121112
11131113 Composite cams = null;
....@@ -1334,7 +1334,7 @@
13341334 frame.getContentPane().add(/*"Center",*/framePanel);
13351335 //frame.getContentPane().add(/*"Center",*/ worldPane);
13361336
1337
-// aConstraints = gbc; // (GridBagConstraints) GraphreeD.clone(gbc);
1337
+// aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13381338
13391339 frame.setSize(1024, 768);
13401340 frame.show();
....@@ -1859,19 +1859,21 @@
18591859 }
18601860
18611861 // Images/textures
1862
- if (textures
1863
- && (filename.toLowerCase().endsWith(".jpg")
1864
- || filename.toLowerCase().endsWith(".jpeg")
1865
- || filename.toLowerCase().endsWith(".gif")
1866
- || filename.toLowerCase().endsWith(".png")
1867
- || filename.toLowerCase().endsWith(".tre")
1868
- || filename.toLowerCase().endsWith(".bmp")
1869
- || filename.toLowerCase().endsWith(".tga")
1870
- || filename.toLowerCase().endsWith(".sgi")
1871
- || filename.toLowerCase().endsWith(".tif")
1872
- || filename.toLowerCase().endsWith(".tiff")))
1862
+ if (filename.toLowerCase().endsWith(".jpg")
1863
+ || filename.toLowerCase().endsWith(".jpeg")
1864
+ || filename.toLowerCase().endsWith(".gif")
1865
+ || filename.toLowerCase().endsWith(".png")
1866
+ || filename.toLowerCase().endsWith(".tre")
1867
+ || filename.toLowerCase().endsWith(".bmp")
1868
+ || filename.toLowerCase().endsWith(".tga")
1869
+ || filename.toLowerCase().endsWith(".sgi")
1870
+ || filename.toLowerCase().endsWith(".tif")
1871
+ || filename.toLowerCase().endsWith(".tiff"))
18731872 {
1874
- DropTexture(filename);
1873
+ if (textures)
1874
+ DropTexture(filename);
1875
+ else
1876
+ CreateBillboard(filename);
18751877 continue;
18761878 }
18771879
....@@ -1880,6 +1882,60 @@
18801882 }
18811883
18821884 ResetModel();
1885
+ }
1886
+
1887
+ void CreateBillboard(String filename)
1888
+ {
1889
+ Object3D source = null;
1890
+ Object3D group = copy;
1891
+
1892
+ if (group.selection.size() > 0)
1893
+ {
1894
+ source = group.selection.get(0);
1895
+ }
1896
+
1897
+ Grid grid = new Grid(1,1);
1898
+ grid.material = null;
1899
+
1900
+ grid.toParent = LA.newMatrix();
1901
+ grid.fromParent = LA.newMatrix();
1902
+ LA.matYRotate(grid.toParent, Math.PI/2);
1903
+ LA.matXRotate(grid.toParent, -Math.PI/2);
1904
+ LA.matXRotate(grid.fromParent, Math.PI/2);
1905
+ LA.matYRotate(grid.fromParent, -Math.PI/2);
1906
+
1907
+ BillboardNode bb = new BillboardNode();
1908
+ bb.addChild(grid);
1909
+
1910
+ Object3D newgroup = new Object3D();
1911
+ newgroup.CreateMaterial();
1912
+
1913
+ File file = new File(filename);
1914
+ newgroup.name = file.getName();
1915
+ newgroup.addChild(bb);
1916
+
1917
+ Object3D main = newgroup;
1918
+
1919
+ main.SetPigmentTexture(filename);
1920
+
1921
+ if (source != null)
1922
+ {
1923
+ main.material = new cMaterial(source.material);
1924
+ if (main.projectedVertices.length < source.projectedVertices.length)
1925
+ {
1926
+ main.projectedVertices = new Object3D.cVector2[source.projectedVertices.length];
1927
+ }
1928
+
1929
+ for (int i=0; i<source.projectedVertices.length; i++)
1930
+ {
1931
+ main.projectedVertices[i].x = source.projectedVertices[i].x;
1932
+ main.projectedVertices[i].y = source.projectedVertices[i].y;
1933
+ }
1934
+
1935
+ main.texres = source.texres;
1936
+ }
1937
+
1938
+ makeSomething(newgroup, false);
18831939 }
18841940
18851941 Point location;
....@@ -2345,7 +2401,7 @@
23452401
23462402 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23472403 {
2348
- if (GraphreeD.standAlone)
2404
+ if (GrafreeD.standAlone)
23492405 {
23502406 /**/
23512407 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
....@@ -3183,8 +3239,8 @@
31833239
31843240 CameraPane.ANIMATION ^= true;
31853241
3186
- GraphreeD.wav.cursor = 0;
3187
- GraphreeD.wav.loop = 0;
3242
+ GrafreeD.wav.cursor = 0;
3243
+ GrafreeD.wav.loop = 0;
31883244 }
31893245 } else
31903246 {
....@@ -4085,7 +4141,7 @@
40854141
40864142 void load() // throws ClassNotFoundException
40874143 {
4088
- if (GraphreeD.standAlone)
4144
+ if (GrafreeD.standAlone)
40894145 {
40904146 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
40914147 browser.show();
....@@ -4190,7 +4246,7 @@
41904246
41914247 void saveAs()
41924248 {
4193
- if (GraphreeD.standAlone)
4249
+ if (GrafreeD.standAlone)
41944250 {
41954251 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
41964252 browser.setVisible(true);
....@@ -4213,10 +4269,20 @@
42134269
42144270 Object3D object = copy.selection.get(0);
42154271
4272
+ FileObject fileobj = null;
4273
+
4274
+ if (object instanceof FileObject)
4275
+ fileobj = (FileObject)object;
4276
+
42164277 if (object.fileparent != null)
42174278 {
4218
- FileObject fileobj = (FileObject) object.fileparent;
4279
+ assert(fileobj == null);
42194280
4281
+ fileobj = (FileObject) object.fileparent;
4282
+ }
4283
+
4284
+ if (fileobj != null)
4285
+ {
42204286 System.out.println("WriteObject " + object + " : " + fileobj.name);
42214287 WriteObject(object, fileobj.name);
42224288 }
....@@ -4259,7 +4325,7 @@
42594325 }
42604326 }
42614327 else
4262
- //if (GraphreeD.standAlone)
4328
+ //if (GrafreeD.standAlone)
42634329 {
42644330 FileDialog browser = new FileDialog(frame, "Export", FileDialog.SAVE);
42654331 browser.setVisible(true);
....@@ -4291,7 +4357,7 @@
42914357 Object3D objectparent = obj.parent;
42924358 obj.parent = null;
42934359
4294
- Object3D object = (Object3D) GraphreeD.clone(obj);
4360
+ Object3D object = (Object3D) GrafreeD.clone(obj);
42954361
42964362 obj.parent = objectparent;
42974363
....@@ -4325,7 +4391,7 @@
43254391 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43264392 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43274393 copy.generatePOV(buffer);
4328
- if (GraphreeD.standAlone)
4394
+ if (GrafreeD.standAlone)
43294395 {
43304396 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43314397 browser.show();