129
edits
| No edit summary | |||
| Line 61: | Line 61: | ||
| 本地接收信息框截图 | 本地接收信息框截图 | ||
| *To make sure that all the bones in use are available and refresh them every second or so. And   | *To make sure that all the bones in use are available and refresh them every second or so. And send the message back to the Captury. | ||
| <source lang="Java" line start= "58"> | <source lang="Java" line start= "58"> | ||
| void refreshSubscriptions() { | void refreshSubscriptions() { | ||
| Line 86: | Line 86: | ||
| '''PART 03 – Pass data to the object''' | '''PART 03 – Pass data to the object''' | ||
| *plug a specific bone | *Define a function to plug a specific bone to a object. | ||
| <source lang="Java" line start= "88"> | <source lang="Java" line start= "88"> | ||
| void plugBone(Object target, String skeleton, String bone) { | void plugBone(Object target, String skeleton, String bone) { | ||
| Line 94: | Line 94: | ||
| </source> | </source> | ||
| * | *Declare and construct a object (sphere) from the class Sphere, which is the receiver of the data. | ||
| <source lang="Java" line start= "22"> | <source lang="Java" line start= "22"> | ||
| Sphere sphere1; | Sphere sphere1; | ||
| Line 100: | Line 100: | ||
| <source lang="Java" line start= "40"> | <source lang="Java" line start= "40"> | ||
| sphere1 = new Sphere(1); | sphere1 = new Sphere(1); | ||
| </source> | |||
| <source lang="Java" line start= "68"> | |||
| sphere1.draw(); | |||
| </source> | </source> | ||
| *pass position of  | *Use plugBone function to pass position data of LiQianqian's Root bone to the sphere object | ||
| <source lang="Java" line start= "50"> | <source lang="Java" line start= "50"> | ||
| plugBone(sphere1, skeleton1, bone1); | plugBone(sphere1, skeleton1, bone1); | ||
| Line 108: | Line 111: | ||
| '''PART 04 – Use the data as a variable''' | '''PART 04 – Use the data as a variable''' | ||
| *position of the sphere | *In the class Sphere, define the float variable for the position of the sphere. | ||
| <source lang="Java" line start= "3"> | <source lang="Java" line start= "3"> | ||
| float x, y, z; | float x, y, z; | ||
| </source> | </source> | ||
| * | *Update the position of the root node. This function will be plugged to OSC. | ||
| <source lang="Java" line start= "48"> | <source lang="Java" line start= "48"> | ||
| public void updateRoot(float x, float y, float z) { | public void updateRoot(float x, float y, float z) { | ||
| Line 122: | Line 125: | ||
| </source> | </source> | ||
| ==  | Then you can have a sphere moving follow the data from the Captury! For further application, you can use x, y, z to control whatever you want in Processing! | ||
| == Control The Video By Processing == | |||
| Since we can successfully use the data from the capture, it can be creatively to use the position of the object to control whatever you want in Processing!  <br> | |||
| The following is an example of using a single value (position x) to play or reverse the video and change the play speed of the video.<br> | |||
| <br> | |||
| '''PART 01 – Play a video in Processing''' <br> | |||
| *Basic code to play a video in Processing.  | |||
| <source lang="Java" line start= "12"> | |||
| import processing.video.*;  //Import libraries | |||
| </source> | |||
| <source lang="Java" line start= "16"> | |||
| Movie myMovie;  //Declare a object as Movie | |||
| </source> | |||
| <source lang="Java" line start= "31"> | |||
| void setup() { | |||
|   size(1920, 1080);  //or use 'fullScreen(P3D);' | |||
|   frameRate(60); | |||
|   background(0); | |||
|   myMovie = new Movie(this, "Chinese Knot_Final.mov");  //Load a movie, normally followed with 'play()' or 'loop()' | |||
| } | |||
| </source> | |||
| *Draw the movie by the class object (Sphere) | |||
| <source lang="Java" line start= "22"> | |||
| void draw() { | |||
|     image(myMovie, 0, 0, width, height);  //Position to put the movie | |||
| } | |||
| </source> | |||
| *Called every time a new frame is available to read. | |||
| <source lang="Java" line start= "62"> | |||
| void movieEvent(Movie m) { | |||
|   m.read(); | |||
| } | |||
| </source> | |||
| '''PART  | '''PART 02 – Play or reverse the video and change the play speed''' <br> | ||
| *Using position x as the condition. If user stand at the left edge, the speed will be slowest. The righter user stand, the faster the movie play. | |||
| *Using position y as the condition. If user stand close to the platform, the movie will play as usual, if else the movie will reverse.  | |||
| <source lang="Java" line start= "4"> | |||
| int play;  //Declare a value to judge play or reverse the video | |||
| </source> | |||
| <source lang="Java"> | *Get the total number of the movie frames. | ||
| <source lang="Java" line start= "7"> | |||
|   int getLength() { | |||
|       return int(myMovie.duration() * myMovie.frameRate); | |||
|   } | |||
| </source> | |||
| *Get current frame. | |||
| <source lang="Java" line start= "11"> | |||
|   int getFrame() {     | |||
|       return ceil(myMovie.time() * 60) - 1; | |||
|   } | |||
| </source> | </source> | ||
| *Pay attention that if the movie play to the end, it must be reversed. And if the movie reverse to the beginning, it must play as usual. | |||
| <source lang="Java" line start= "26"> | |||
|     if(y > 200 && getFrame() < (getLength() - 1)){ | |||
|       play = 1; | |||
|       myMovie.play(); | |||
|     } | |||
|     else { | |||
|       play = -1; | |||
|       myMovie.play(); | |||
|     } | |||
|     if(getFrame() < 1) myMovie.play(); | |||
| < |     float newSpeed = map(x, 0, 150, 0*play, 2*play); | ||
|     myMovie.speed(newSpeed); | |||
| </source> | |||
| == Let's Enjoy The Example File== | == Let's Enjoy The Example File== | ||
edits