Book Image

Processing 2: Creative Coding Hotshot

By : Nikolaus Gradwohl
Book Image

Processing 2: Creative Coding Hotshot

By: Nikolaus Gradwohl

Overview of this book

Processing makes it convenient for developers, artists, and designers to create their own projects easily and efficiently. Processing offers you a platform for expressing your ideas and engaging audiences in new ways. This book teaches you everything you need to know to explore new frontiers in animation and interactivity with the help of Processing."Processing 2: Creative Coding Hotshot' will present you with nine exciting projects that will take you beyond the basics and show you how you can make your programs see, hear, and even feel! With these projects, you will also learn how to build your own hardware controllers and integrate devices such as a Kinect senor board in your Processing sketches.Processing is an exciting programming environment for programmers and visual artists alike that makes it easier to create interactive programs.Through nine complete projects, "Processing 2: Creative Coding Hotshot' will help you explore the exciting possibilities that this open source language provides. The topics we will cover range from creating robot - actors performing Shakespeare's "Romeo and Juliet", to generating objects for 3D printing, and you will learn how to run your processing sketches nearly anywhere from a desktop computer to a browser or a mobile device.
Table of Contents (16 chapters)
Processing 2: Creative Coding Hotshot
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Generating an object


The second task of our current mission is to generate a 3D object that can be used as a small pen holder or vase. We will use the 2D shape we created in task 1 as a cross section of our object by extruding it along the z axis. We will extend our getR() method and add a bunch of additional control variables that will allow us to change the circular shape depending on the object's height.

To make it easier for our users to look at the object, we will add the mousePressed() and mouseDragged() functions, which rotate the object in any direction. We will use a mathematical construct named quaternion to implement these rotations.

Engage Thrusters

Let's bring our shape to the third dimension:

  1. To turn our shape into a 3D object, we need to extend our vertx and verty arrays.

    import controlP5.*;
    
    ControlGroup box;
    ControlP5 cp5;
    Button toggleButton;
    float[][] vertx;
    float[][] verty;
    
  2. In our setup() method, we change the display mode to P3D and define our array initialization. Our shape...