==== The OPF format (Open Plant Format) ====
This is a standard format to describe plant architecture.
10.1.2011 - JF. Barczi , S. Griffon
=== 1. Context ===
**Xplo** handles plant architecture data with **ArchiTree** data structure. **ArchiTree** is an improved Java implementation of the **MTG** formalism. It is a **Multiscale Tree Graph** ready to represents plant topology **AND** geometry attached to it.
Each graph node is a topology element and may carry any attribute(length, diameter, weight, notes ...) and geometry (mesh, transform matrix, material).
**ArchiTree** can be stored in standardized XML file with an extension **_.opf_**.
=== 2. Topology encoding ===
== 2.1. File example ==
A simple .opf file example (only topology) :
This file loaded in Xplo:
//3D View (with default geometry rules reconstruction) + browser view//
!https://amap-dev.cirad.fr/attachments/624/opfTopology.jpg! !https://amap-dev.cirad.fr/attachments/623/opfTopologyBrowser.jpg!
== 2.3. OPF ==
An **OPF** contains one main node : **TOPOLOGY**. The **TOPOLOGY** node contains all the tree graph topology relations.
Attributes for the **OPF** tag are :
> * **version** : version number (actually 2.0).
> * **editable** (optional): If true, this opf will be editable in Xplo.
== 2.4. TOPOLOGY ==
The **TOPOLOGY** node contains all the tree graph topology relations. It contains three main nodes : **DECOMP**, **FOLLOW** and **BRANCH**.
**DECOMP** tag defines decomposition link to the previous node.
**FOLLOW** tag defines succession link to the previous node.
**BRANCH** tag defines ramification link to the previous node.
Inside the **TOPOLOGY**, **DECOMP**, **FOLLOW** and **BRANCH** you can insert attribute nodes. (see 2.5. _ATTRIBUTE_ TAGS)
Attributes for the **TOPOLOGY**, **DECOMP**, **FOLLOW** and **BRANCH** tags are :
> * **class** : a class or type name for the current node.
> * **scale** (optional) : a specific decomposition level (scale) for the current node.
== 2.5. _ATTRIBUTE_ TAGS ==
**TOPOLOGY**, **DECOMP**, **FOLLOW** and **BRANCH** can have unlimited attribute tags.
Xplo known attributes (such as **LENGTH** tag in above example) are listed in **ArchiTree** documentation.
However, custom attribute can have any name and their values can be integer, float or string.
=== 3. Geometry encoding ===
== 3.1. File example ==
An OPF file example with geometry looks like :
This file loaded in Xplo:
**3D View**
https://amap-dev.cirad.fr/attachments/625/opfGeometry.jpg
== 3.2. MESHBDD ==
The **MESHBDD** node contains all the mesh collection used in the plant geometry.
A mesh is reprensted by a *MESH* node.
== 3.3. MESH ==
It contains four main nodes : **POINTS**, **NORMALS**, **TEXTURECOORDS** and **FACES**
Attributes for the **MESH** tag :
> * **name** : a string to identify mesh.
> * **id** : an integer to identify mesh.
== 3.4. POINTS ==
The **POINTS** node contains all the xyz mesh point coordinates.
Coordinates are written in raw :
xp1 yp1 zp1 xp2 yp2 zp2 xp3 yp3 zp3 ....== 3.5. NORMALS == The **NORMALS** node contains all the xyz mesh normal coordinates (linked to each point mesh => must be described in the same order than points). Coordinates are written in raw :
xn1 yn1 zn1 xn2 yn2 zn2 xn3 yn3 zn3 ....== 3.6. TEXTURECOORDS == The **TEXTURECOORDS** node contains all the uv mesh texture coordinates (linked to each point mesh => must be described in the same order than points). Coordinates are written in raw :
u1 v1 u2 v2 u3 v3 ....== 3.7. FACES == The **FACES** node contains all the mesh faces. A **FACE** node references all the points to build a face. The point reference is an index into the point list (described by **POINTS**). Point index are written in raw : (here a face composed by 4 points)
i1 i2 i3 i4== 3.8. MATERIALBDD == The **MATERIALBDD** node contains all the material collection used by the meshes. A material is reprensted by a **MATERIAL** node. == 3.9. MATERIAL == The **MATERIAL** node contains four main nodes : **EMISSION**, **AMBIENT**, **DIFFUSE**, **SPECULAR** and **SHININESS**. **EMISSION**, **AMBIENT**, **DIFFUSE** and **SPECULAR** color are written in raw (float value between 0.0 and 1.0):
r g b a**SHININESS** is a single float value. Attributes for the **MATERIAL** tag : > * **id** : an integer to identify material == 3.10. SHAPEBDD == The **SHAPEBDD** node contains a list of shape. A shape is referencing a mesh and a material. A **SHAPE** node has one attribute (id : an integer to identify the shape) and is componed by 3 nodes : **NAME**, **MESHINDEX** and **MATERIALINDEX**. **MESHINDEX** and **MATERIALINDEX** node refers respectively to the **MESH** id and the **MATERIAL** id. == 3.11. GEOMETRY == The **GEOMETRY** node is **always** linked to a topology element (like an **attribute tag**). A geometry contains at least a **MAT** node. This is a 4x4 transformation matrix written in raw :
x1 y1 z1 t1 x2 y2 z2 t2 x3 y3 z3 t3 x4 y4 z4 t4Attributes for the **GEOMETRY** tag : > * **class** : a string to define the type of geometry (mesh, bezier, spline...). If geometry class is _Mesh_, then **Mesh** can be componed by : **shapeIndex** : the shape index (defined in **shapeBDD**). **dDwn** : the bottom diameter of the mesh **dUp** : the top diameter of the mesh