fc - sg - 9.1.2014
In AMAPstudio, plants can be stored in opf files (Open plant format, contain topology + geometry). These opf files can be exchanged by Xplo and Simeo. In some cases, vegetal scenes are created by adding such plants at different locations. The resulting plants can also be rotated (inclination, twist around the stem).
The rule is that the opf file always contains a plant located in a local frame (position 0, 0, 0), with no inclination nor twist: the opf contains a centered plant.
Plants are loaded in ArchiTrees by the OPFLoader.
// Load an opf file into an ArchiTree boolean computeCache = true; ArchiTree t = new OPFLoader(fileName, computeCache).load();
The ArchiTree can be moved / rotated by using the following method.
// Change position and rotation of an ArchiTree t.setPositionAndRotation (x, y, z, inclinationAzimut, inclinationAngle, stemTwist, false); // copy: false // Get a copy of an ArchiTree at a different position and rotation ArchiTree copy = t.setPositionAndRotation (x, y, z, inclinationAzimut, inclinationAngle, stemTwist, true); // copy: true
An ArchiTree can be reset at its centered state with the following method.
// Reset the ArchiTree position and rotation t.resetPositionAndRotation ();
When saving an ArchiTree to an opf file, the ArchiTree is automatically recentered by the OPFWriterV2: resetPositionAnRotation () is called if the ArchiTree was moved / rotated.
This ensures the OPF files are always centered.
Important note
// Saving an ArchiTree into an opf file // OPFWriterV2 centers the ArchiTree if a move / rotation is detected new OPFWriterV2 (fileName).save (t);
Vegetal scenes can be exchanged by Simeo and Xplo: all opf files are centered and the locations / rotations are explicitly noted in the ops file for each opf (unchanged).