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

Rotating a sphere


The first task of our current mission is to create the mesh of a sphere and make it rotate on the screen. We will create a mesh resembling the latitude and longitude rings found on a globe. To simplify the mathematics required to create these rings, we will use polar coordinates and convert them to Cartesian XYZ coordinates when creating our sphere. Processing can make use of your graphics card's memory for storing the model data, which improves the speed of drawing the object on the screen a lot if the object itself is static. Since our sphere doesn't change while our sketch is running, we will use a PShape object to store the model data.

Engage Thrusters

Let's start with the creation of our sphere's mesh:

  1. Open a new sketch and add the setup() and draw() methods.

    void setup() {
    }
    
    void draw() {
    }
  2. In the setup() method, we define our sketch window size and set the rendering mode to P3D. We also create a PShape object named sphere to store the mesh data.PShape sphere;

    void setup...