User Tools

Site Tools


soft:xplo:private:the_gwa_format_-_geometry_with_attributes

The GWA format - geometry with attributes

sg+fc-15.4.2013, sg+fc-5.1.2014

This file format is for geometrical objects (i.e. not plants), but which components (one or several) may carry attributes like the plants managed by AMAPstudio.

A GWA object contains a main node typed 'GWA', itself decomposed in one or several nodes with free types. The GWA node is the complex of the other nodes. The other nodes have no relations between them. All nodes have a geometry and an attribute map.

All sizes in a GWA are in centimeters.

See GeometryWithAttribute, GWALoader, GWAWriter, SimpleMeshFactory.

// Example code
GeometryWithAttribute gwa = new GeometryWithAttribute();
 
// Create a green pin .gwa file: a cylinder and a sphere
SimpleMesh cylinder = SimpleMeshFactory.createCylinder(0, 0, 0, 1, 100, 3, 1);
gwa.addNode(1, "Cylinder", cylinder, COMPUTE_AND_REVERSE_NORMALS);
 
SimpleMesh sphere = SimpleMeshFactory.createEllipsoid(0, 0, 0, 30, 30, 30, 4, 4);
gwa.addNode(2, "Sphere", sphere, COMPUTE_AND_REVERSE_NORMALS);
gwa.translateNode(2, 0, 0, 70);
 
Color color = new Color(0, 255, 0);
gwa.setAttribute(2, "Color", color);
 
ArchiTree gwatree = gwa.getArchiTree();
 
GWAWriter gwawriter = new GWAWriter("./pins.gwa");
gwawriter.save(gwatree);

This is an example showing how to convert an .obj file into an AMAPstudio .gwa.

// Load an .obj
ObjMeshLoader loader = new ObjMeshLoader(objFileName);
Mesh m = loader.load();
 
// Create a.gwa
GeometryWithAttribute gwa = new GeometryWithAttribute();
gwa.addNode(1, objFileName, m, GeometryWithAttribute.KEEP_NORMALS);
 
// Write the .gwa
ArchiTree gwatree = gwa.getArchiTree();
GWAWriter gwawriter = new GWAWriter("./objFile.gwa");
gwawriter.save(gwatree);

An example of GWA object added in a Simeo-Edito scene. The second table was rotated around its local origin, showing the importance of thinking where the GWA origin is set at build time. The origin of this table is on the ground, directly below the center of the rectangle.

// The code to build the table
GeometryWithAttribute gwa = new GeometryWithAttribute();
 
SimpleMesh c1 = SimpleMeshFactory.createCylinder(-250, -500, 0, 5, 300, 4, 5);
SimpleMesh c2 = SimpleMeshFactory.createCylinder(250, -500, 0, 5, 300, 4, 5);
SimpleMesh c3 = SimpleMeshFactory.createCylinder(250, 500, 0, 5, 300, 4, 5);
SimpleMesh c4 = SimpleMeshFactory.createCylinder(-250, 500, 0, 5, 300, 4, 5);
 
SimpleMesh p1 = SimpleMeshFactory.makeRichParallelepiped (500, 1000, 1);
p1.translate(new Point3f (0, 0, 300));
 
gwa.addNode(1, "Cylinder", c1, GeometryWithAttribute.COMPUTE_NORMALS);
gwa.addNode(2, "Cylinder", c2, GeometryWithAttribute.COMPUTE_NORMALS);
gwa.addNode(3, "Cylinder", c3, GeometryWithAttribute.COMPUTE_NORMALS);
gwa.addNode(4, "Cylinder", c4, GeometryWithAttribute.COMPUTE_NORMALS);
gwa.addNode(5, "Parallelepiped", p1, GeometryWithAttribute.KEEP_NORMALS);
 
Color col1 = new Color(0, 0, 255);
Color col2 = new Color(0, 0, 255);
 
gwa.setAttribute(1, "Color", col1);
gwa.setAttribute(2, "Color", col1);
gwa.setAttribute(3, "Color", col1);
gwa.setAttribute(4, "Color", col1);
gwa.setAttribute(5, "Color", col2);
 
ArchiTree gwatree = gwa.getArchiTree();
 
GWAWriter gwawriter = new GWAWriter("./data/gwa/table.gwa");
gwawriter.save(gwatree);
soft/xplo/private/the_gwa_format_-_geometry_with_attributes.txt ยท Last modified: 2021/12/17 09:22 by 127.0.0.1