RFC: Vector Types in the Property System
Proposal: Allow vector types as properties in property list XML files
and as properties in the runtime property system. The syntax in an XML
file would look like:
<parameters>
<material>
<diffuse type="vec4d">
.2 .4 .6 1.0
</diffuse>
<specular type="vec4d">
.4 .5 .7 1.0
</specular>
<uniform>
<name>sky-direction</name>
<value type="vec3d">0 0 1</value>
</uniform>
</material>
</parameters>
Existing 3D XML file formats, like Collada, support this syntax for
vector values such colors.
Rationale: Without these types, the XML syntax is much more verbose:
<parameters>
<material>
<diffuse>
<r>.2</r>
<g>.4</g>
<b>.6</b>
<a>1.0</a>
</diffuse>
<specular>
<r>.4</r>
<g>.5</g>
<b>.7</b>
<a>1.0</a>
</specular>
<uniform>
<name>sky-direction</name>
<value>
<x>0</x>
<y>0</y>
<z>1</z>
</value>
</uniform>
</material>
</parameters>
Furthermore, C++ code that reads and writes the color values has to
process the child properties, looking them up by name and traversing
children. Whether or not this costly, it is much more straightforward
to fetch all values at once from a property node. It is irritating to
code around the "mini-tree" of values at each aggregate property,
especially when the value is immediately written into an Open Scene
Graph object.
API:
The vector properties are represented in C++ as Open Scene Graph Vec3d and
Vec4d objects.
SGPropertyNode has two new template member functions:
template<typename T> T SGPropertyNode::getValue() const;
template<typename T> bool SGPropertyNode::setValue(const T& val);
These work like the existing property node getter and setter
functions, e.g. getFloatValue() and setFloatValue(), for either the
basic atomic types or Vec3d or Vec4d. If the actual type of the
property node is STRING or UNSPECIFIED, the value is read from the
string. If the type T in the template and the property type are not
the same but are basic types, the existing conversion rules are
used. Otherwise, a default value , typically 0, is returned.
In Nasal code, getValue() returns a vector of length 3 or 4 for vector
valued properties. setValue() can be passed a vector argument which
will be passed as a Vec3d or Vec4d to SGPropertyNode::setValue.
Implementation:
The SGRawValue classes are changed to return type information. A new
class, SGRawExtended, is added that can store the value of a property
node in allocated storage outside of the node. The type is also stored
in the SGRawExtended object.
The changes are available in git://repo.or.cz/simgear/timoore.git
and git://repo.or.cz/flightgear/timoore.git in the topic/property
branch.
Discussion:
The property system is very useful and I want to use it for
implementing effects. However, I find the syntax way too verbose for
simple aggregate properties like colors. With the proposed changes
effect files can be property lists, and effects values can easily be
represented as property trees, while still preserving a concise
syntax.
I'm not proposing to change any existing property to an extended
property.
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel