Hey guys, soo.... I have this code, I'm able to get my Video and two images to project, however if you look at the code I have a PG IMAGE i made in processing. I'm unable to connect it to a surface mapper (SM). The PG imagine in the code, can you please help me figure out how to put it in the surface mapper alongside with my video and images. Thank you soo much.
That's the dropbox link for my code, in the Data folder it wouldn't let me attach my movie clip, so just replace the "climb.mov" i use with any random footage on your computer. You'll notice a lot of things at the bottom of the code.. it's mostly just key commands so just ignore it last section. All you need to know it "z" to add a new surface mapper and "c" to render. Thank you soo much for any help you can offer me. You can just copy paste the code in this forum and i'll take a look at it. Ty.
Ok so, I've been playing around with this code for a couple of days now... I figured out how to add a different image to each surface mapper(SM), and I'm able to create a sketch within processing and attach it to a surface-mapper as well. However, I'm unable to figure out how to add a movie clip to a SM, I've tried all sorts of different techniques... I've made movie Events, m.read, tried looping a movie, added movie libraries.. I've incorporated movies in processing before so I understand how to do it.. however, I cant figure out to attach it to a mapper, let's say the fourth time I press "Z" I want a movie to appear.. how would I do that?
I'm going to paste my code below... I took out everything I had that was related to my movie clip because it clearly wasn't working. The Two images that I have inputted won't work on your computer because the Data file is missing so you can just ignore them or replace them with an image you want. As far the everything else goes... you press "Z" to input a new (SM) and "C" to render it, so you can view it outside of GLgraphicsOfScreen (Glos). Any help would be appreciated. It's for a school project and I'm really struggling. Just copy paste the code into processing and it should work.
void setup() {
size(1600, 1050, GLConstants.GLGRAPHICS);
glos = new GLGraphicsOffScreen(this, width, height, false); // Of screen. passing it the width and height of the window
tex = new GLTexture(this);
pg = createGraphics(400, 400, P2D);
img1 = new GLTexture(this, "ShadowProjection.jpg");
img2 = new GLTexture(this, "Piller.jpg");
img3 = new GLTexture(this, "Piller.jpg");
// img = new GLTexture(this, "moonbottomleft.png");
//Create new instance of SurfaceMapper
sm = new SurfaceMapper(this, width, height);
//Creates one surface with subdivision 3, at center of screen
sm.createQuadSurface(3, width/2, height/2);
}
void draw() {
glos.beginDraw();
glos.clear(0); // black background so any space without projected background is not li
glos.hint(ENABLE_DEPTH_TEST);
glos.endDraw();
pgDraw();
// This process is like a loop
//get movie frame;
if (tex.putPixelsIntoTexture())
//Updates the shaking of the surfaces in render mode
sm.shake();
// Surface Mapper is rendered with GLOS (Graphics Off Screen)
//render all surfaces in calibration mode
if (sm.getMode() == sm.MODE_CALIBRATE)sm.render(glos); // the loop is using an iterator, it's a way to cycle through higher level data objects
//render all surfaces in render mode
// GRAPHICS OFF SCREEN ----
tex.putImage(pg);
if (sm.getMode() == sm.MODE_RENDER) {
for (SuperSurface ss : sm.getSurfaces()) {
tex.putImage(pg);
ss.render(glos, tex);
//render this surface to GLOS, use TEX as texture
if (ss.getId() == 1) ss.render(glos, img2);
else if (ss.getId() == 2) ss.render(glos, img1);
else if (ss.getId() == 3) ss.render(glos, img3);
}
}
image(glos.getTexture(), 0, 0, width, height);
}
void movieEvent(GSMovie movie) {
movie.read();
}
/// KEY PRESSED COMMANDS --- "Z" & "C" are the main ones you need to know, the rest are just extra tweeks.
void keyPressed() {
//create a new QUAD surface at mouse pos
if (key == 'a')sm.createQuadSurface(3, mouseX, mouseY);
//create new BEZIER surface at mouse pos
if (key == 'z')sm.createBezierSurface(3, mouseX, mouseY);
//switch between calibration and render mode
if (key == 'c')sm.toggleCalibration();
//increase subdivision of surface
if (key == 'p') {
for (SuperSurface ss : sm.getSelectedSurfaces()) {
ss.increaseResolution();
}
}
//decrease subdivision of surface
if (key == 'o') {
for (SuperSurface ss : sm.getSelectedSurfaces()) {
ss.decreaseResolution();
}
}
//save layout to xml
if (key == 's')sm.save("bla.xml");
//load layout from xml
if (key == 'l')sm.load("bla.xml");
//rotate how the texture is mapped in to the QUAD (clockwise)
if (key == 'j') {
for (SuperSurface ss : sm.getSelectedSurfaces()) {
ss.rotateCornerPoints(0);
}
}
//rotate how the texture is mapped in to the QUAD (counter clockwise)
if (key == 'k') {
for (SuperSurface ss : sm.getSelectedSurfaces()) {
ss.rotateCornerPoints(1);
}
}
//increase the horizontal force on a BEZIER surface
if (key == 't') {
for (SuperSurface ss : sm.getSelectedSurfaces()) {
ss.increaseHorizontalForce();
}
}
//decrease the horizontal force on a BEZIER surface
if (key == 'y') {
for (SuperSurface ss : sm.getSelectedSurfaces()) {
ss.decreaseHorizontalForce();
}
}
//increase the vertical force on a BEZIER surface
if (key == 'g') {
for (SuperSurface ss : sm.getSelectedSurfaces()) {
ss.increaseVerticalForce();
}
}
//decrease the vertical force on a BEZIER surface
if (key == 'h') {
for (SuperSurface ss : sm.getSelectedSurfaces()) {
ss.decreaseVerticalForce();
}
}
}
Hey, ok so I have this code and I have to create an array of Ball objects. I need 25 objects instead of a single ball. the Ball has to be a class which is exactly what i've done. However, I cant create an array of 25 balls, the balls should vary a bit in sizes and larger balls have to fall down a little bit faster than smaller ones, I keep encountering errors and its not working, we have to use a loop im pretty sure. Here's the example I'm working off of --
http://www.openprocessing.org/sketch/22180 -- I've tried so many different ways but I cant seem to get it to work. So the way the code works is when you click the rectangle in the upper right corner it pauses the balls form falling, SO i pretty much need 25 balls to drop instead of 1 using an array. Please help me out, I'm going to paste my code below so you can take a look at it, Aprreciate any help :)
Ball oneBall;
boolean animate = true;
int btnX = 260;
int btnY = 50;
int btnW = 80;
int btnH = 80;
void setup() {
size(400, 500);
smooth();
oneBall = new Ball();
void mousePressed() {
if ( mouseX > btnX && mouseX < (btnX+btnW) && mouseY > btnY && mouseY < (btnY+btnH)) {
// toggle the value of on
// in other words, if on == true, then on becomes not true (false) and
// vice versa
animate = !animate; // on = (not)on
}
}
}
void move() {
if (animate == true) {
ypos = ypos + speed;
speed = speed + gravity;
if (ypos >= height-120) {
// reduce the speed on every bounce to make it more
// realistic.. try -1 and see what happens
speed *= -0.9;
}
}
}
}
Ok, so i'm supposed to "Write a function that determines if two rectangles overlap and returns a boolean value to indicate the answer. Write a simple sketch that demonstrates your function in action."
Alright so I figured out how to do this with with circles, but I have no idea how to do it with rectangles. I dont think I understand the math behind it and even when I try to do it I get all sorts of errors, please help me out. I'll paste my code that I have for circles below, please help me transform the circles into rectangles. I just want the rectangles to change colors when they intersect each other. Thank you.
// Integrates the circle intersection code to our class
// so that we can detect when two circle objects intersect
Circle oneCircle;
Circle anotherCircle;
//=======================================================================
void setup() {
size(300, 300);
smooth();
fill(255);
noStroke();
// create a new Circle object and put it in a variable
oneCircle = new Circle(random(width), random(height), 50);
// create another one with a different size and color
anotherCircle = new Circle(random(width), random(height), 60);
}
// we now have two Instances of the Circle class. They are separate
// objects and each represent a Circle with the variables and methods
// that come with the package
// draw and move the first one
if (oneCircle.intersects(anotherCircle)) {
fill(33, 64);
stroke(255);
strokeWeight(2);
line(oneCircle.x, oneCircle.y, anotherCircle.x, anotherCircle.y);
}
else {
noStroke();
fill(255, 128);
}
oneCircle.display();
oneCircle.move();
// draw and move the other
anotherCircle.display();
anotherCircle.move();
}
class Circle {
// this is what defines a Circle -- some variables
// each Circle we create will have one of each:
float x;
float y;
float speedX;
float speedY;
float radius;
//---------------------------------------------------
// This is a special function called the Constructor.
// It is invoked when we use the "new" keyword
Circle( float x, float y, float radius ) {
// store the values of the parameters into the matching object
// variables
this.x = x;
this.y = y;
this.radius = radius;
// lets say speed is always random:
this.speedX = random(-2, 2);
this.speedY = random(-2, 2);
}
//---------------------------------------------------
void display() {
// draw the circle
ellipse(this.x, this.y, this.radius*2, this.radius*2);
}
//---------------------------------------------------
void move() {
// move the circle
this.x = this.x + this.speedX;
this.y = this.y + this.speedY;
// make sure x and y stay within a certain area
// this will prevent the "sticking" effect which happens when
// the speed is too small
this.x = constrain(this.x, this.radius, width-this.radius);
this.y = constrain(this.y, this.radius, height-this.radius);
}
//---------------------------------------------------
// Checks if this circle intersects with another
boolean intersects(Circle other) {
float d = dist(this.x, this.y, other.x, other.y);
if ( d < (this.radius + other.radius) ) {
return true;
}
else {
return false;
}
}
} // end of Circle class
Hello, I need some help, ok so the code below is of a spiral circle that's filled in with colors.
void setup () {
size (300, 700);
smooth();
}
void draw() {
background (120);
float s = 450;
while (s > 10) {
float c = map (s, 450, 10, 255, 10);
colorMode(HSB);
fill(c, 255,255);
ellipse (width/2, height/2, s, s);
s -= 20;
}
}
So i created a loop of a bunch of circles and i'm trying to fill each circle in to look like the spirals (code I posted above) I've tried a bunch of stuff but I cant seem to figure it out, everything I try ends up looking different or not running at all. Please help. Below is the Code i'm working with, can someone tell me how to create each individual circle into a spiral.
void setup () {
size(600, 600);
smooth();
}
void draw () {
int d = 60;
background (128);
int counter = 0;
if (counter <= width ) {
ellipse (width/2, counter, d,d);
I have to create an assignment using loops and conditionals... Ok so I created a 8x8 grid checkerboard, But, i want to make it white and black, how do I do that please help? The code Below is what i'm working with on processing. I've tried soo many things but i cant figure it out. I tried if statements and all that but I cant seem to get it.
int NumBars = 35;
int cols, rows;
void setup() {
size(280,280); // 280/8 = 8x8 grid full screen. The size has to be divided by 8.
cols = width/NumBars; // height/35 - this makes the height go up the screen
rows = height/NumBars; // width/35 - this makes it go across the screen
}
void draw() {
// Begin loop for columns
for (int i = 0; i < cols; i++) { // Height
// Begin loop for rows
for (int j = 0; j < rows; j++) { //Width
// Scaling up to draw a rectangle at (x,y)
int x = i*NumBars; // height
int y = j*NumBars; // width
stroke(0);
// For every column and row, a rectangle is drawn at an (x,y) location scaled and sized by videoScale.
rect(x,y,NumBars,NumBars);
Hey I have to create an 8x8 checkerboard for a class assignment using processing. I have to use loops and conditionals as part of the assignment. I've figured out how to create vertical lines but I cant seem to create horizontal lines i've tried so hard but i cant seem to figure it out. Here's the code i have so far for my horizontal lines plz help.
void setup () {
size(200,200);
}
void draw () {
int numBars = 20;
float w = width / numBars;
// run 'numBars' times
for (int i=0; i < numBars; i++) {
rect(i*w, 0, w, height);
}
}
Hello, I created a few simple apps using the software 'processing', I'm going to shortly be getting an android(Iphone) and i wanted some help as to how I upload apps onto the Iphone. I found this information on the processing website
however, I read that it has a couple bugs. I just want to know if i follow the instructions on there would I be able to upload an app I created through processing onto my iphone.
I've also been following the instructions posted above but when it gets to android mode i get this message:
" To build for Android, select “Android” from the drop-down box in the toolbar (by default it reads “Standard”). This places the current editor window into Android mode. To show you that you've now entered a new world, the window will also get a lot more green.
The Run and Export features change a bit in Android mode:
Run in Emulator - preprocess the current sketch, create an Android project, and run (debug) it in the Android emulator.
Run on Device - the same as Run, but run on a device (phone) that's attached by USB.
Export Android Project - creates an 'android' folder that contains the files necessary to build an APK using Ant.
Export Signed Package - same as export, but creates a signed version of the 'release' build for the market. (not yet implemented, coming soon)
(As of 0193, these are thankfully no longer called Run, Present, Export, and Export Application.) "
which one would i have to chose. These instructions are kind of difficult would anyone be able to help a brother out and guide me through these instructions and or give me easier instuctions to follow because I don't have enough background knowledge to execute my idea. I'm fairly new at this.