Node OSG plugin extension

From COLLADA Public Wiki
Jump to: navigation, search
Extension information
This article is part of the COLLADA extensions directory
Adding to the extensions directory

Overview

The OpenSceneGraph plugin uses extensions to store specific node information used by OpenSceneGraph graphics library. It supports both reading and writing of the extension information. Currently no tools other than OpenSceneGraph based tools exist that are able to generate or reuse the information stored in the OpenSceneGraph node extension.

First of all it is important to note that the OpenSceneGraph profile uses the type attribute in the <extra> element to specify which node information will be available in the <extra>.
A <node> with an extra of profile="OpenSceneGraph" may be extended by a

  • <extra type="Node">

and/or one of

  • <extra type="LOD">
  • <extra type="Switch">
  • <extra type="MultiSwitch">
  • <extra type="Sequence">
  • <extra type="DOFTransform">

Detailed description

Because OpenSceneGraph is Open Source software the source code can be inspected to see the intended behaviour.

Node

Each node in OSG can have a list of strings attached.

Element Subelement Type Comments
<Descriptions> contains a list of <Description> elements
<Description> string Line of free text

Example

A node with a single description string containing "Some info".

<extra type="Node">
	<technique profile="OpenSceneGraph">
		<Descriptions>
			<Description>Some info</Description>
		</Descriptions>
	</technique>
</extra>

LOD

An OSG level of detail (LOD) node specifies when to switch child nodes either based on distance or on pixels on screen.

Element Subelement Type Comments
<Center> 3 floats Optional, when specified this center value is used, otherwise the boundingsphere center is used
<Radius> float Radius of user specified bounding sphere, this one is required if the <Center> is specified
<RangeMode> integer How to interpret range values in the rangelist
0 = DISTANCE_FROM_EYE_POINT
1 = PIXEL_SIZE_ON_SCREEN
<RangeList> list of <MinMax> elements
<MinMax> two floats Minimum and maximum range for enabling the child node.
Either used as distance from eyepoint or as pixelsize on screen (of the boundingsphere).

Example

A node with two children that will be switched based on distance from the viewpoint. A boundingsphere center of 1,2,3 is used. First child (typically highest detail) will be active when viewer is within 300 meters from the center. Second child (typically lower detail) will be active when viewer is between 300 and 600 meters from center. Beyond 600 meter no child will be visible.

<extra type="LOD">
	<technique profile="OpenSceneGraph">
		<Center>1 2 3</Center>
		<Radius>100</Radius>
		<RangeMode>0</RangeMode>
		<RangeList>
			<MinMax>0 300</MinMax>
			<MinMax>300 600</MinMax>
		</RangeList>
	</technique>
</extra>

Switch

The OSG switch node allows for switching individual children on or off and is typically controlled from within the application.

Element Type Comments
<ValueList> list of booleans 0 for disabled child, 1 for enabled child
Number of values must equal number of children

Example

Switch node with two children. First is active, second is not visible.

<extra type="Switch">
	<technique profile="OpenSceneGraph">
		<ValueList>1 0</ValueList>
	</technique>
</extra>

MultiSwitch

The OSG MultSwitch node stores predefined sets of children to enable and disable. The application can activate one of these predefined sets.

Element Type Subelement Comments
<ActiveSwitchSet> integer Zero based number for switchset to use. Range: 0 to (number of <ValueLists> - 1)
<ValueLists> list of <ValueList> elements
<ValueList> list of booleans 0 for disabled child, 1 for enabled child
Number of values must equal number of children

Example

MultiSwitch node with three children and two predefined switch sets. The first switchset will show only the first child. The second switchset will show the second and third child. The first switchset (0) is currently active so only the first child will be visible.

<extra type="MultiSwitch">
	<technique profile="OpenSceneGraph">
		<ActiveSwitchSet>0</ActiveSwitchSet>
		<ValueLists>
			<ValueList>1 0 0</ValueList>
			<ValueList>0 1 1</ValueList>
		</ValueLists>
	</technique>
</extra>

Sequence

The OSG sequence node can be used for animation by switching children on or off dynamically.

Element Type Comments
<FrameTime> list of floats Specifies the display duration of each child
<LastFrameTime> float Special time to display last frame of last loop
<LoopMode> integer 0 = LOOP start over at the beginning
1 = SWING pingpong animation back and forth
<IntervalBegin> integer First child to take part in animation
<IntervalEnd> integer Last child to take part in animation
<DurationSpeed> float Multiplier of real-time clock, set to N to go N times faster
<DurationNReps> integer How many times to repeat, -1 means repeat forever
<SequenceMode> integer 0 = START
1 = STOP
2 = PAUSE
3 = RESUME

Example

<extra type="Sequence">
	<technique profile="OpenSceneGraph">
		<FrameTime>0 0</FrameTime>
		<LastFrameTime>0</LastFrameTime>
		<LoopMode>0</LoopMode>
		<IntervalBegin>0</IntervalBegin>
		<IntervalEnd>-1</IntervalEnd>
		<DurationSpeed>1</DurationSpeed>
		<DurationNReps>-1</DurationNReps>
		<SequenceMode>0</SequenceMode>
	</technique>
</extra>

DOFTransform

An OSG DOFTransform specifies a transformation that can be animated with limited degrees of freedom.

Element Type Comments
<MinHPR> 3 floats Minimum orientation limit specified as Euler angles
<MaxHPR> 3 floats Maximum orientation limit specified as Euler angles
<IncrementHPR> 3 floats Rotation speed as Euler angles
<CurrentHPR> 3 floats Current orientation as Euler angles
<MinTranslate> 3 floats Minimum translation limit
<MaxTranslate> 3 floats Maximum translation limit
<IncrementTranslate> 3 floats Translation speed
<CurrentTranslate> 3 floats Current translation
<MinScale> 3 floats Minimum scale limit
<MaxScale> 3 floats Maximum scale limit
<IncrementScale> 3 floats Scaling speed
<CurrentScale> 3 floats Current scale factor
<MultOrder> integer Multiplication order of the Euler angles
0 = PRH
1 = PHR
2 = HPR
3 = HRP
4 = RPH
5 = RHP
<LimitationFlags> long Degrees of freedom limitions in bits
0 = x translation limited (2^31)
1 = y translation limited (2^30)
2 = z translation limited (2^29)
3 = pitch limited (2^28)
4 = roll limited (2^27)
5 = yaw limited (2^26)
6 = x scale limited (2^25)
7 = y scale limited (2^24)
8 = z scale limited (2^23)
<AnimationOn> bool When true the DOF Transform will animate all degrees of freedom that are not limited by the <LimitationFlags>. A degree of freedom will pingpong between the specified minimum and maximum limits.
0 = FALSE, 1 = TRUE,
<PutMatrix> 16 float values Matrix that can be used for specifying a pivot point

Example

<extra type="DOFTransform">
	<technique profile="OpenSceneGraph">
		<MinHPR>0 -0.174533 0</MinHPR>
		<MaxHPR>0 0.872665 0</MaxHPR>
		<IncrementHPR>0 0.0174533 0</IncrementHPR>
		<CurrentHPR>0 0 0</CurrentHPR>
		<MinTranslate>0 0 0</MinTranslate>
		<MaxTranslate>0 0 0</MaxTranslate>
		<IncrementTranslate>0 0 0</IncrementTranslate>
		<CurrentTranslate>0 0 0</CurrentTranslate>
		<MinScale>0 0 0</MinScale>
		<MaxScale>1 1 1</MaxScale>
		<IncrementScale>0 0 0</IncrementScale>
		<CurrentScale>1 1 1</CurrentScale>
		<MultOrder>0</MultOrder>
		<LimitationFlags>269964960</LimitationFlags>
		<AnimationOn>0</AnimationOn>
		<PutMatrix>
			1 0 0 0
			0 1 0 0
			0 0 1 0
			0 0 0 1
		</PutMatrix>
	</technique>
</extra>