def main(argv):

    
    arguments = osg.ArgumentParser(argv)
    viewer = osgViewer.Viewer(arguments)
    
    tbm = osgGA.TrackballManipulator()

    viewer.setCameraManipulator(tbm)

    viewer.addEventHandler(osgViewer.StatsHandler())
    viewer.addEventHandler(osgViewer.WindowSizeHandler())

    root = osg.Group()
    geode = osg.Geode()

    geode.setStateSet(setupStateSet())

    root.setInitialBound(osg.BoundingSphere(osg.Vec3(10,0,20), 50))
    root.addChild(setupAnimtkNode(geode))
    root.addChild(geode)

    viewer.setSceneData(root)

    # tbm.setDistance(150)

    return viewer.run()
示例#2
0
def createRoom(loadedModel):


    
    # default scale for this model.
    bs = osg.BoundingSphere(osg.Vec3(0.0,0.0,0.0),1.0)

    root = osg.Group()

    if loadedModel :
        loaded_bs = loadedModel.getBound()

        pat = osg.PositionAttitudeTransform()
        pat.setPivotPoint(loaded_bs.center())

        pat.setUpdateCallback(ModelTransformCallback(loaded_bs))
        pat.addChild(loadedModel)

        bs = pat.getBound()

        root.addChild(pat)


    bs.radius()*=1.5

    # create a bounding box, which we'll use to size the room.
    bb = osg.BoundingBox()
    bb.expandBy(bs)


    # create statesets.
    rootStateSet = osg.StateSet()
    root.setStateSet(rootStateSet)

    wall = osg.StateSet()
    wall.setMode(GL_CULL_FACE,osg.StateAttribute.ON)

    floor = osg.StateSet()
    floor.setMode(GL_CULL_FACE,osg.StateAttribute.ON)

    roof = osg.StateSet()
    roof.setMode(GL_CULL_FACE,osg.StateAttribute.ON)

    geode = osg.Geode()

    # create front side.
    geode.addDrawable(createWall(bb.corner(0),
                                  bb.corner(4),
                                  bb.corner(1),
                                  wall))

    # right side
    geode.addDrawable(createWall(bb.corner(1),
                                  bb.corner(5),
                                  bb.corner(3),
                                  wall))

    # left side
    geode.addDrawable(createWall(bb.corner(2),
                                  bb.corner(6),
                                  bb.corner(0),
                                  wall))
    # back side
    geode.addDrawable(createWall(bb.corner(3),
                                  bb.corner(7),
                                  bb.corner(2),
                                  wall))

    # floor
    geode.addDrawable(createWall(bb.corner(0),
                                  bb.corner(1),
                                  bb.corner(2),
                                  floor))

    # roof
    geode.addDrawable(createWall(bb.corner(6),
                                  bb.corner(7),
                                  bb.corner(4),
                                  roof))

    root.addChild(geode)

    root.addChild(createLights(bb,rootStateSet))

    return root
示例#3
0
# * Overloaded Geometry class to return predefined bounds
# 
class MyGeometry (osg.Geometry) :
    MyGeometry(osg.BoundingBox bounds)
        m_bounds = bounds
        m_bsphere = osg.BoundingSphere(bounds)

    # an attempt to return a reasonable bounding box. Still does not prevent clipping of the heat map.
    def getBoundingBox():
        return m_bounds
    def computeBound():
        return m_bounds
    def getBound():
        return m_bsphere
    m_bounds = osg.BoundingBox()
    m_bsphere = osg.BoundingSphere()


Heatmap.Heatmap(float width, float depth, float maxheight, unsigned int K, unsigned int N, float maximum, float transparency)
    m_K = K
    m_N = N
    O = 4

    # create Geometry object to store all the vertices primitives.
    meshGeom = MyGeometry(osg.BoundingBox(osg.Vec3(-width/2, -depth/2, 0), osg.Vec3(width/2, depth/2, maxheight)))

    # we use a float attribute array storing texcoords
    xypositions = osg.Vec2Array()
    xypositions.setName("xypos")

    # create vertex coordinates
示例#4
0
class MyGeometry (osg.Geometry) :
    MyGeometry(osg.BoundingBox bounds)
        m_bounds = bounds
        m_bsphere = osg.BoundingSphere(bounds)
示例#5
0
                                                        )))

    callback.start()
    node.setUpdateCallback(callback)
    node.addChild(setupCube())
    return node

int main (int argc, char* argv[])
    arguments = osg.ArgumentParser(argv)
    viewer = osgViewer.Viewer(arguments)

    manipulator = osgGA.TrackballManipulator()
    viewer.setCameraManipulator(manipulator)

    root = osg.Group()
    root.setInitialBound(osg.BoundingSphere(osg.Vec3(10,0,10), 30))
    root.addChild(createAxis())

    node = setupAnimtkNode()
    node.addChild(createAxis())
    root.addChild(node)

    viewer.setSceneData( root )
    viewer.realize()

    while  not viewer.done() :
        viewer.frame()



if __name__ == "__main__":