Created
June 28, 2013 16:31
-
-
Save febret/5886038 to your computer and use it in GitHub Desktop.
Getting a wand position
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example 1: Get wand position using the event function | |
onEvent(): | |
e = getEvent() | |
if(e.getServiceType() == ServiceType.Wand()) | |
wandPosition = e.getPosition() | |
# use wandPosition to do stuff here or save it in | |
# a global var and do stuf later | |
setEventFunction(onEvent) | |
#---------------------------------------------------- | |
# Example 2: attach an object to the wand trackable. | |
# Make it visible when it's above 1.5 meters. | |
sphere = SphereShape.create(1,2) | |
sphere.followTrackable(1) # CAVE2 main wand it trackable #1 | |
onUpdate(frame, time, dt): | |
# if sphere is 1.5 meters above ground, make it visible | |
if(sphere.getPosition().y - getDefaultCamera().getPosition().y): | |
sphere.setVisible(True) | |
else: | |
sphere.setVisible(False) | |
setUpdateFunction(onUpdate) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment