Hi there
Another question about Virtual Reality!
I'm wanting to program in some Collision to activate, say, a colour switch when you touch a cube with your controller.
So far I've parented a sphere to my motion controller and tried using the python code to reference that and the VSets I have set up to activate the switch.
So, my sphere is the 'PickerL'
The 'Blue_Box' etc are my geometry
and the 'Blue' etc are the VSets.
## Collision Activation Picker = findNode("PickerL") Blue_Box = findNode("Blue_Box") Green_Box = findNode("Green_Box") Red_Box = findNode("Red_Box") def Boxes(): global CollisionBlue_Box global CollisionGreen_Box global CollisionRed_Box CollisionBlue_Box = vrCollision([Picker], [Blue_Box]) CollisionBlue_Box.connect(Blue_Switch) CollisionGreen_Box = vrCollision([Picker], [Green_Box]) CollisionGreen_Box.connect(Green_Switch) CollisionRed_Box = vrCollision([Picker], [Red_Box]) CollisionRed_Box.connect(Red_Switch) def Blue_Switch(): selectVariantSet("Blue") def Green_Switch(): selectVariantSet("Green") def Red_Switch(): selectVariantSet("Red") Boxes()
Attached is a screen grab of my project!
Any help on this would be great!
Thanks
Solved! Go to Solution.
I solved it in the end! So much simpler than I thought!
## Collision Activation PickerR = findNode ("PickerR") PickerL =findNode ("PickerL") Red_Box = findNode ("Red_Box") coll = vrCollision([PickerR, PickerL], [Red_Box]) coll.connect(Red_Switch) controller1.triggerHapticPulse(0,1000) def Red_Switch(): selectVariantSet("Red")
Hello
Looking at your code, you should remove the hashtag '#' at the start of your controller0 and controller1 signals, as well as your PickerR Variable.
Python doesn't read anything after a hashtag '#' as useable code, anything after that are deemed comments for reference purposes only.
Try removing those, and see if that works! (See example below)
#controller main function controller0 = vrOpenVRController("Controller0") controller0.connectSignal("controllerMoved", controller0Moved) controller0.connectSignal("triggerPressed", trigger0Pressed) controller0.connectSignal("triggerReleased", trigger0Released) controller0.connectSignal("touchpadPressed", touchpad0Pressed) controller0.connectSignal("touchpadReleased", touchpad0Released controller0.connectSignal("gripPressed", grip0Pressed) controller1 = vrOpenVRController("Controller1") controller1.connectSignal("controllerMoved", controller1Moved) controller1.connectSignal("triggerPressed", trigger1Pressed) controller1.connectSignal("triggerReleased", trigger1Released) controller1.connectSignal("touchpadPressed", touchpad1Pressed) controller1.connectSignal("touchpadReleased", touchpad1Released controller1.connectSignal("gripPressed", grip1Pressed)
Thanks
Harry
I couldnt understand the meaning of these lines .
moveScaleSideways = -2.0 * touchPos.x() *touchPos.x() *touchPos.x()
moveScaleForward = -0.05 * touchPos.y() * touchPos.y() * touchPos.y() *touchPos.y()*touchPos.y()
clipPos = Pnt3f( cMatrix[3], cMatrix[7], cMatrix[11])
clipNor = Vec3f( cMatrix[2], cMatrix[6], cMatrix[10])
I have attached file , where I took these lines from those script .
Hi
the script is always executed from top to bottom
so you first have to define Red_Switch
def Red_Switch():
selectVariantSet("Red")
and use the name afterwards in the script
coll.connect(Red_Switch)
controller1.triggerHapticPulse(0,1000)
right now it executes the variant set as long it detects a collision. So if you have a Color Switch material which is Looping it is changing the colors very fast and you cant really see it. It's just flickering . Is there a way of Scripting a time Frame for the collision duration until it switches to the next Color
regards
Markus
Hello,
Is possible to deactivate the Collision with the controllers????
I only want to change the object when I press the trigger, but when I am close, the object change.
Can't find what you're looking for? Ask the community or share your knowledge.