Community
VRED Forum
Welcome to Autodesk’s VRED Forums. Share your knowledge, ask questions, and explore popular VRED topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VRED Material Switch VR (HTC VIVE)

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
1394 Views, 5 Replies

VRED Material Switch VR (HTC VIVE)

Hello

 

I'm wanting to trigger a material switch using the HTC Vive motion controllers.

 

Currently, I have a basic sphere set up which shares a touch sensor and switch material cycle with the vehicle I'm working on. I can manually change them upon a mouse click in real time, which is good - but how would I implement say, a button press, or collision event so when the motion controller is in the sphere, it can cycle through the materials?

I have no knowledge of Python, and am willing to learn - if there's anywhere anyone can point me to get to grips with it, that'd be awesome!

 

Thanks

5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

Hello, 

 

You just need to create a Touch Sensor on your node ( Interaction > Touch Sensor), with a variant set wich will change your material, then when you'll click with your controller on the node, your material will change. (for example)

Message 3 of 6
Anonymous
in reply to: Anonymous

Hello

 

Thanks for your reply!

 

I have that set up with the relevant code, and I can change material with a trigger press, for example:

def trigger1Pressed():
     controller1.setPickingAxis(1)
     controller1.showPickingAxis(true)
     print "Trigger 1 Pressed"

 

def trigger1Released():
     pickedNode = controller1.pickNode()
     selectNode(pickedNode)
     triggerTouchSensor("r8_gt_mb:r8_gt_obj:r8_gt_body_TouchSensor")
     controller1.showPickingAxis(false)
     print "Trigger 1 Released"



However, the material changes no matter where I'm aiming, is there a way to stop this happening? And Only have it change when you're aiming at the object?

Sorry if this is all very simple, I am very new to both Python and VRED!

 

Thanks again

Message 4 of 6
Anonymous
in reply to: Anonymous

You should try this :

 

- Put this function in your script 

 

def triggerSensor( node):
    if node.hasAttachment("TouchSensorAttachment"):
        touchAttachment = node.getAttachment("TouchSensorAttachment")
        acc = vrFieldAccess(touchAttachment)
        if acc.isValid():
            variantSetName = acc.getMString("variantSets")
            for vset in variantSetName:
                selectVariantSet(vset)
                controller1.triggerHapticPulse(0,1000)
        return
    parentNode = node.getParent()
    if parentNode.isValid():
        triggerSensor( parentNode)

- Then, just keep that in your Triggers functions : 

 

def trigger1Pressed():
    controller1.setPickingAxis(0)
    controller1.showPickingAxis(true)

def trigger1Released():
    pickedNode = controller1.pickNode()
    controller1.showPickingAxis(false)
    triggerSensor(pickedNode)

With that, if you have a touchsensor attached to a node, when you'll aim it and click it, it should work...

Message 5 of 6
Anonymous
in reply to: Anonymous

Hello!

 

Thanks for your reply!!

 

That has solved my issue, really appreciate the help!!

 

All the best

 

Harry

Message 6 of 6
Anonymous
in reply to: Anonymous

Glad that has helped you !

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report