wiki:QuickStart

5 minutes quick-start guide

Note that this page stills needs a bit of cleaning up and adding of additional material. If you have questions in the meantime feel free to contact us.

Example: Displaying a Sphere

import avango
import avango.osg
import avango.osg.simpleviewer

object = avango.osg.nodes.Sphere()
object.Radius.value = 1.0
object.Color.value = avango.osg.Vec4(1., 0. , 0., 1.)

avango.osg.simpleviewer.run(object)

Fields and FieldContainers

  • The base class of many Avango-NG classes is FieldContainer
  • A FieldContainer contains instances of Field
  • These are the fields of the Sphere class:
    • Radius (SFFloat)
    • DetailRatio (SFFloat)
    • Color (SFVec3)

Accessing Field values

Values of a Field are accessed via a property called value:

object = avango.osg.nodes.Sphere()
object.Radius.value = 1.0

When setting a lot of values a short-hand notation can be used:

object = avango.osg.nodes.Sphere()
values = object.get_values()
values.Radius = 1.0
values.DetailRatio = 0.5
values.Color = avango.osg.Vec4(1., 0., 0., 1.)

All FieldContainers can also be initialized in the constructor:

object = avango.osg.nodes.Sphere(Radius = 1.0)

Example: Building a Scene Graph

import avango
import avango.osg
import avango.osg.simpleviewer

object = avango.osg.nodes.LoadFile(Filename = "monkey.obj")
translation = avango.osg.nodes.MatrixTransform()
translation.Matrix.value = avango.osg.make_trans_mat(1, 0, 0)
translation.Children.value = [ object ]

avango.osg.simpleviewer.run(translation)

List of available FieldContainers

Here are some frequently used FieldContainers:

LoadFile
A node that loads a wide range of supported file formats.
MatrixTransform
Transformation node for scene graph
Group
A simple grouping node. Use e.g. for state setting.
TimeSensor
Give current time
<ScriptNode>
Build your own FieldContainer using Python.

Example: Animating a Model

import avango
import avango.osg
import avango.osg.simpleviewer
import avango.script

class RotateTransform(avango.script.Script):
    "Build a time-variant matrix performing a rotation"

    TimeIn = avango.SFDouble()
    Matrix = avango.osg.SFMatrix()

    def evaluate(self):
        time = self.TimeIn.value
        matrix = avango.osg.make_rot_mat(time, 0., 0., 1.)
        self.Matrix.value = matrix

object = avango.osg.nodes.LoadFile(Filename = "monkey.obj")
translation = avango.osg.nodes.MatrixTransform()
translation.Children.value = [ object ]
time = avango.nodes.TimeSensor()

rotation = RotateTransform()
rotation.TimeIn.connect_from(time.Time)
translation.Matrix.connect_from(rotation.Matrix)

avango.osg.simpleviewer.run(translation)

Field-Connection Graph

TODO link to picture

  • Field connections form a directed graph
  • Evaluate is called in correct topological order
  • The graph should be acyclic
  • Do not set values in fields of other FieldContainers in callbacks.