Defining Custom Tools


How to Define a tool 

Even though this is a simple basic lesson, I know that this might seem very confusing to some of you. It was very confusing to me in the beginning. I highly suggest taking a couple python lessons at Code Academy. It will break down all these concepts much slower and easier to understand. 

When you are coding you can define a tool whatever name you want and whatever actions you want. So for this exercise we are going to make a tool that changes the color of our sphere. Type this into your terminal and press enter

def ChangeColor():
    print "Color Changed"

Now I wrote this in proper python syntax or what we would call structure. To break down the code what I did was first define a new function called ChangeColor. Then inside this function I added some of the tool I wanted. One is to select the variant set and the next is to print in the terminal Color Change. So now type the following into the terminal and press enter. 


As you can see now when we type ChangeColor() it calls that function and that function has all the tools we added to it. This is a simple example but once it gets complex, we can define complex tools and make them easy to get to. 


Finding Objects in our scene

To do anything with an object in our scene we need to first tell VRED what node we want to use.  That function is called findNode() so for example. We will want to attach our light to the contrellor so we need to first tell VRED where the node is at. Write the following 

Main_Hand = findNode('Main_Hand')

Here we are telling VRED, when I type Main_Hand into my code. I am talking about the Node that is named Main_Hand. 


Putting it all Together

Now that we learned some very basic codes in python. We can start attaching geometry and functions to our controller. This is the only current way to work with the VIVE controllers. This is the reason I learned to code. So I can have a full control of every aspect of my VR experience.