예제 #1
0
def buildJoint3(previousJoint):

    
    height = 7.5
    radius = 4.45633
    joint = osg.Geode()
    xTransform = osg.MatrixTransform()
    previousJoint.addChild(xTransform)
    xRot = osg.Matrix.rotate(-osg.PI_2, 1.0, 0.0, 0.0)
    xTransform.setMatrix(xRot)


    zCheat = osg.MatrixTransform()
    zTransCheat = osg.Matrix.translate(0.0,0.0,-height)
    zCheat.setMatrix(zTransCheat)
    xTransform.addChild(zCheat)
    
    shape = osg.ShapeDrawable(osg.Capsule(osg.Vec3(0.0,0.0,height/2),radius,height),hints)
    joint.addDrawable(shape)
    zCheat.addChild(joint)

    zTransform = osg.MatrixTransform()
    zCheat.addChild(zTransform)
    zRot = osg.Matrix.rotate((float)jointAngle3, 0.0, 0.0, 1.0)
    zTrans = osg.Matrix.translate(0,0,0)
    zTransform.setMatrix(zTrans*zRot)
    if showAxis :
        createAxis(zTransform)
    return zTransform
예제 #2
0
def createShapes():

    
    geode = osg.Geode()

    
    # ---------------------------------------
    # Set up a StateSet to texture the objects
    # ---------------------------------------
    stateset = osg.StateSet()

    image = osgDB.readImageFile( "Images/lz.rgb" )
    if image :
        texture = osg.Texture2D()
        texture.setImage(image)
        texture.setFilter(osg.Texture.MIN_FILTER, osg.Texture.LINEAR)
        stateset.setTextureAttributeAndModes(0,texture, osg.StateAttribute.ON)
    
    stateset.setMode(GL_LIGHTING, osg.StateAttribute.ON)
    
    geode.setStateSet( stateset )

    
    radius = 0.8
    height = 1.0
    
    hints = osg.TessellationHints()
    hints.setDetailRatio(0.5)
    
    geode.addDrawable(osg.ShapeDrawable(osg.Sphere(osg.Vec3(0.0,0.0,0.0),radius),hints))
    geode.addDrawable(osg.ShapeDrawable(osg.Box(osg.Vec3(2.0,0.0,0.0),2*radius),hints))
    geode.addDrawable(osg.ShapeDrawable(osg.Cone(osg.Vec3(4.0,0.0,0.0),radius,height),hints))
    geode.addDrawable(osg.ShapeDrawable(osg.Cylinder(osg.Vec3(6.0,0.0,0.0),radius,height),hints))
    geode.addDrawable(osg.ShapeDrawable(osg.Capsule(osg.Vec3(8.0,0.0,0.0),radius,height),hints))

    grid = osg.HeightField()
    grid.allocate(38,39)
    grid.setXInterval(0.28)
    grid.setYInterval(0.28)
    
    for(unsigned int r=0r<39++r)
        for(unsigned int c=0c<38++c)
            grid.setHeight(c,r,vertex[r+c*39][2])
예제 #3
0
def buildTube2(previousJoint):

    
    if showAxis :
        createAxis(previousJoint)
    height = 17.6
    radius = 4.45633
    xTransform = osg.MatrixTransform()
    previousJoint.addChild(xTransform)
    xRot = osg.Matrix.rotate(osg.PI_2, 1.0,0.0,0.0)
    xTransform.setMatrix(xRot)
    tube3 = osg.Geode()
    xTransform.addChild(tube3)
    tube3.addDrawable(osg.ShapeDrawable(osg.Capsule(osg.Vec3(0.0,0.0,height/2),radius,height),hints))

    zTransform = osg.MatrixTransform()
    xTransform.addChild(zTransform)
    zTrans = osg.Matrix.translate(0,0,height)
    zTransform.setMatrix(zTrans)
    return zTransform
예제 #4
0
def buildJoint2(previousJoint):

    
    if showAxis :
        createAxis(previousJoint)
    height = 17.6
    radius = 4.45633
    xTransform = osg.MatrixTransform()
    previousJoint.addChild(xTransform)
    xRot = osg.Matrix.rotate(osg.PI_2, 1.0, 0.0, 0.0)
    xTransform.setMatrix(xRot)
    joint = osg.Geode()
    joint.addDrawable(osg.ShapeDrawable(osg.Capsule(osg.Vec3(0.0,0.0,height/2),radius,height),hints))
    xTransform.addChild(joint)

    zTransform = osg.MatrixTransform()
    zTrans = osg.Matrix.translate( 0.0, 0.0, height)
    zRot = osg.Matrix.rotate(osg.PI_2+jointAngle2, 0.0,0.0,1.0)
    zTransform.setMatrix(zTrans*zRot)
    xTransform.addChild(zTransform)
    return zTransform
예제 #5
0
def buildJoint4(previousJoint):
    
    height = 17.5
    radius = 2.86479
    tube4 = osg.Geode()
    tube4.addDrawable(osg.ShapeDrawable(osg.Capsule(osg.Vec3(0.0,0.0,height/2),radius,height),hints))
    xTransform = osg.MatrixTransform()
    #if showAxis :
    #
        #createAxis(xTransform)
    #
    previousJoint.addChild(xTransform)
    xTransform.addChild(tube4)
    xRot = osg.Matrix.rotate(osg.PI_2, 1,0,0)
    xTransform.setMatrix(xRot)
    height = 7.5
    zTrans = osg.Matrix.translate(0,0,17.5)
    zRot = osg.Matrix.rotate(jointAngle4-osg.PI_2, 0,0,1)

    zTransform = osg.MatrixTransform()
    zTransform.setMatrix(zTrans*zRot)
    xTransform.addChild(zTransform)
    return zTransform