User Tools

Site Tools


private:centeredopfmanagement

New management of position and rotations in OPF files

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).

Centered opf

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.

Opf files loading

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();

Change the position and rotation of an ArchiTree

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 ();

Saving an ArchiTree into a centered opf

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

If the ArchiTree to be saved was translated or rotated, the OPFWriterV2 detects it and resets the translations and rotations in a copy before writing on disk. The original ArchiTree in memory is not reset, it is the responsability of the user to reset it if needed with resetPositionAndRotation ().
// 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).

private/centeredopfmanagement.txt ยท Last modified: 2021/12/17 09:22 by 127.0.0.1