Groups are all the NodeCores who can be used as interior nodes in the graph. These nodes can have and actually use their children.
The center field specifies a translation offset from the origin of the local coordinate system (0,0,0). The rotation field specifies a rotation of the coordinate system. The scale field specifies a non-uniform scale of the coordinate system. scale values shall be greater than zero. The scaleOrientation specifies a rotation of the coordinate system before the scale (to specify scales in arbitrary orientations). The scaleOrientation applies only to the scale operation. The translation field specifies a translation to the coordinate system.
Given a 3-dimensional point P and Transform node, P is transformed into point P' in its parent's coordinate system by a series of intermediate transformations. In matrix transformation notation, where C (center), SR (scaleOrientation), T (translation), R (rotation), and S (scale) are the equivalent transformation matrices,
P' = T × C × R × SR × S × -SR × -C × P
A DistanceLOD is the simplest version, which switches versions based on distance to the viewer. The children is selected based on the center and range settings.
The center field is a translation offset in the local coordinate system that specifies the centre of the LOD node for distance calculations.
The number of children shall exceed the number of values in the range field by one (i.e., N+1 children for N range values). The range field contains monotonic increasing values that shall be greater than 0. In order to calculate which level to display, the distance is calculated from the viewer's location, transformed into the local coordinate system of the LOD node (including any scaling transformations), to the center point of the LOD node.
DistanceLOD example
Using the position of the light in the graph for geometry allows moving the Light just like any other node, by putting it below a osg::Transform Node and changing the transformation. This consistency also simplifies attaching Lights to moving parts in the scene: just put them below the same Transform and they will move with the object.
The semantic interpretation also makes sense, it lets you restrict the influence area of the light to a subgraph of the scene. This can be used for efficiency, as every active light increases the amount of calculations necessary per vertex, even if the light doesn't influence the vertex, because it is too far away. It can also be used to overcome the restrictions on the number of lights. OpenSG currently only allows 8 concurrently active lights.
It is also not difficult to imagine situations where both interpretations are necessary at the same time. Take for example a car driving through a night scene. You'd want to headlights to be fixed to the car and move together with it. But at the same time they should light the houses you're driving by, and not the mountains in the distance.
Thus there should be a way to do both at the same time. OpenSG solves this by splitting the two tasks to two Nodes. The Light's Node is for the sematntic part, it defines which object are lit by the Light. FOr the geometrc part the Light keeps a SFNodePtr to a different Node, the so called beacon. The local coordinate system of the beacon provides the reference coordinate system for the light's position.
Thus the typical setup of an OpenSG scenegraph starts with a set of lights, which light the whole scene, followed by the actual geometry.
Tip: Using the beacon of the camera (see Camera) as the beacon of a light source creates a headlight.
NOTE: Currently OpenSG does not implement the restricted influence area. All Light sources are global and light the whole scene. Expect that to change soon!
Every light is closely related to OpenGL's light specification. It has a diffuse, specular and ambient color. Additionally it can be switched on and off using the on field.
To use it as a headlight use (0,0,-1) as a direction. it is the computationally cheapest light source. Thus for the fastest lit rendering, just a single directional light source. The osg::SimpleSceneManager's headlight is a directional light source.
Point lights are more expesinve to compute than directional lights, but not quite as expesive as spot lights. If you need to see the localized effects of the light, a point light is a good compromise between speed and quality.
Spot lights are very expensive to compute, use them sparingly.
1.4.3