vrTouchSensor

vrTouchSensor

Anonymous
Not applicable
1,122 Views
2 Replies
Message 1 of 3

vrTouchSensor

Anonymous
Not applicable

Good Evening,
I'm new on VRed and i'm trying to work with the python APIs. I have problems to create a touch sensor on a node of my scene, probably I didn't understand how the api work.

 
I have a node in my scene, for example a Sphere, I compute the pointer to the object in this way:

 

ptr_sphere = findNode("Sphere")

Now I would create a touch sensor for this node, and I followed the API instruction:

 

touch_1 = vrTouchSensor(ptr_sphere)

but in inspector of Touch Sensor I did not found the new element touch_1. Where's my mistake? Can anyone please help me?


I need another suggestion: if this step will work, how can I attach at this touchsensor a variant set loaded previously by xml?

 

Thank you for your reply

0 Likes
Accepted solutions (1)
1,123 Views
2 Replies
Replies (2)
Message 2 of 3

sinje_thiedemann
Autodesk
Autodesk
Accepted solution

Hello,

 

unfortunately, it seems like there is a bug in vrTouchSensor. Normally, you should be able to call connect(...) on a vrTouchSensor object to connect it to a python function that will be executed when you trigger the touch sensor (see vrAEBase class that vrTouchSensor is derived from).
But this functionality seems to be broken since version 2015 SR1.

 

Good news: There is a workaround for what you want to do:

A node that is defined as a touch sensor has a special touch sensor attachment that you can create with Python. That attachment has a field that defines which variant sets will be triggered.
(You can view the attachments of a node in the Node Editor, after selecting the node in the scenegraph.)

 

 

node = findNode("some name")

# check if node has a touch sensor attachment, and if not, create it if not node.hasAttachment("TouchSensorAttachment"): t = createAttachment("TouchSensorAttachment") node.addAttachment(t) print "created touch sensor attachment for ", node.getName() # set the variant set that should be triggered
touchSensorAtt = node.getAttachment("TouchSensorAttachment") vrFieldAccess(touchSensorAtt).setMString("variantSets", ["My Variant Set"]

 

 

 

Best regards

Sinje

 

Message 3 of 3

Anonymous
Not applicable

Thanks Sinje the workaround seems works fine.

0 Likes