HANDLEBAR 3D

Free Roam Script

Free Roam Script

def FreeRoam():
    Leftcontroller.showPickingAxis(true)
    Leftcontroller.setPickingAxis(1)
    pickedNode, pickedPos, pickedNormal, pickedUV = Leftcontroller.pickNodeEx()
    xpos = pickedPos.x()
    ypos = pickedPos.y()
    zpos = 0
    if xpos > 10000:
        xpos = 10000
    if xpos < -10000:
        xpos = -10000
    if ypos > 10000:
        ypos = 10000
    if ypos < -10000:
        ypos = -10000
    camfrom = getFrom(-1)
    fromx = camfrom.x()
    fromy = camfrom.y()
    fromz = camfrom.z()
    camat = getAt(-1)
    atx = camat.x()
    aty = camat.y()
    atz = camat.z()
    difx = atx - fromx
    dify = aty - fromy
    difz = atz - fromz
    xat = xpos + difx
    yat = ypos + dify
    zat = zpos + difz
    setFromAtUp(-1,xpos, ypos, zpos, xat, yat, zat, 0, 0 , 1)

def LeftTriggerPressed():
    Leftcontroller.setPickingAxis(1)
    Leftcontroller.showPickingAxis(true)
    print "Left Trigger Pressed"

def LeftTriggerReleased():
    Pick = Leftcontroller.pickNode()
    selectNode(Pick)
    FreeRoam()
    deselectAll()
    Leftcontroller.showPickingAxis(false)

Leftcontroller = vrOpenVRController("Controller0")
Leftcontroller.connectSignal("triggerPressed", LeftTriggerPressed)
Leftcontroller.connectSignal("triggerReleased", LeftTriggerReleased)


print "Free Roam Loaded"