Java Code Examples for processing.core.PGraphics#popMatrix()

The following examples show how to use processing.core.PGraphics#popMatrix() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Shapes.java    From haxademic with MIT License 6 votes vote down vote up
public static void drawDisc( PGraphics p, float radius, float innerRadius, int numSegments ) {
	p.pushMatrix();
	
	float segmentRads = P.TWO_PI / numSegments;
	for( int i = 0; i < numSegments; i++ ) {
		p.beginShape(P.TRIANGLES);
		
		p.vertex( P.cos( i * segmentRads ) * innerRadius, P.sin( i * segmentRads ) * innerRadius, 0 );
		p.vertex( P.cos( i * segmentRads ) * radius, P.sin( i * segmentRads ) * radius, 0 );
		p.vertex( P.cos( (i + 1) * segmentRads ) * radius, P.sin( (i + 1) * segmentRads ) * radius, 0 );
		
		p.vertex( P.cos( i * segmentRads ) * innerRadius, P.sin( i * segmentRads ) * innerRadius, 0 );
		p.vertex( P.cos( (i + 1) * segmentRads ) * innerRadius, P.sin( (i + 1) * segmentRads ) * innerRadius, 0 );
		p.vertex( P.cos( (i + 1) * segmentRads ) * radius, P.sin( (i + 1) * segmentRads ) * radius, 0 );
		p.endShape();
	}
	
	p.popMatrix();
}
 
Example 2
Source File: Gradients.java    From haxademic with MIT License 6 votes vote down vote up
public static void radial( PGraphics p, float width, float height, int colorInner, int colorOuter, int numSegments )
{
	p.pushMatrix();

	float halfW = width/2;
	float halfH = height/2;
	
	float segmentRadians = P.TWO_PI / numSegments;
	p.noStroke();
	for(float r=0; r < P.TWO_PI; r += segmentRadians) {
		float r2 = r + segmentRadians;
		p.beginShape();
		p.fill(colorInner);
		p.vertex(0,0);
		p.fill(colorOuter);
		p.vertex(P.sin(r) * halfW, P.cos(r) * halfH);
		p.vertex(P.sin(r2) * halfW, P.cos(r2) * halfH);
		p.endShape(P.CLOSE);
	}
	
	p.popMatrix();
}
 
Example 3
Source File: ShaderSSAO.java    From haxademic with MIT License 6 votes vote down vote up
protected void drawFewCubes(PGraphics pg) {
		// spin it
		pg.rotateX(P.PI/3 + P.sin(progressRads) * 0.1f);

		// draw plane
		pg.fill(255);
		pg.rect(0, 0, p.width * 3, p.height * 3);

		float radius = pg.width * 0.2f;
		for (int i = 0; i < 24; i++) {
			pg.fill(60f + 55f * P.sin(i), 170f + 35f * P.cos(i * 2f), 150f + 75f * P.sin(i));
			pg.pushMatrix();
//			pg.translate(radius * P.sin(i/3f + progressRads), radius * P.cos(i/3f + progressRads), 0);
			pg.rotateX(P.TWO_PI * p.noise(i + 0.1f * P.cos(progressRads + i)));
			pg.rotateY(P.TWO_PI * p.noise(i + 0.1f * P.sin(progressRads + i)));
			pg.rotateZ(P.TWO_PI * p.noise(i + 0.1f * P.sin(progressRads + i * 20f)));
			pg.box(
					pg.height * P.sin(i + progressRads),
					pg.height * P.sin(i + progressRads) * 0.1f,
					pg.height * P.sin(i + progressRads) * 0.1f
					);
			pg.popMatrix();
		}
	}
 
Example 4
Source File: WashHands.java    From haxademic with MIT License 6 votes vote down vote up
public void update(PGraphics pg) {
			if(available()) return;
			
			pg.sphereDetail(6);
			
			// update position
			speed.add(gravity);
			pos.add(speed);
			
			// update size
			sizeProgress.update();
			float curSize = size * Penner.easeOutExpo(sizeProgress.value());
			if(sizeProgress.value() == 1) sizeProgress.setTarget(0);
			
			// draw image
			pg.pushMatrix();
			pg.translate(pos.x, pos.y, pos.z);
			pg.rotateY(rotationMin);
			pg.fill(color);
			pg.box(curSize, curSize, curSize);
//			pg.sphere(curSize);
			pg.fill(255);
			pg.popMatrix();
		}
 
Example 5
Source File: Shapes.java    From haxademic with MIT License 5 votes vote down vote up
public static void drawPyramid( PGraphics p, float shapeHeight, float baseWidth, boolean drawBase ){
	baseWidth *= P.HALF_PI;
	
	p.pushMatrix();
	p.rotateZ(P.radians(-45.0f));
	p.beginShape(P.TRIANGLES);
	
	int numSides = 4;
	float segmentCircumference = (2f*P.PI) / numSides;
	float halfBaseW = baseWidth / 2f;

	for( int i = 0; i < numSides; i++ )
	{
		p.vertex( 0, 0, shapeHeight );
		p.vertex( P.sin( i * segmentCircumference ) * halfBaseW, P.cos( i * segmentCircumference ) * halfBaseW, 0 );
		p.vertex( P.sin( (i + 1) * segmentCircumference ) * halfBaseW, P.cos( (i + 1) * segmentCircumference ) * halfBaseW, 0 );
	}
	
	if( drawBase ) {
		// base
		p.vertex( P.sin( 0 * segmentCircumference ) * halfBaseW, P.cos( 0 * segmentCircumference ) * halfBaseW, 0 );
		p.vertex( P.sin( 1 * segmentCircumference ) * halfBaseW, P.cos( 1 * segmentCircumference ) * halfBaseW, 0 );
		p.vertex( P.sin( 2 * segmentCircumference ) * halfBaseW, P.cos( 2 * segmentCircumference ) * halfBaseW, 0 );

		p.vertex( P.sin( 2 * segmentCircumference ) * halfBaseW, P.cos( 2 * segmentCircumference ) * halfBaseW, 0 );
		p.vertex( P.sin( 3 * segmentCircumference ) * halfBaseW, P.cos( 3 * segmentCircumference ) * halfBaseW, 0 );
		p.vertex( P.sin( 0 * segmentCircumference ) * halfBaseW, P.cos( 0 * segmentCircumference ) * halfBaseW, 0 );
	}
	
	p.endShape();
	p.popMatrix();
}
 
Example 6
Source File: Shapes.java    From haxademic with MIT License 5 votes vote down vote up
public static void cylinderBetween( PGraphics pg, PVector point1, PVector point2, int resolution, float radius, float radiusBot ) {
	pg.pushMatrix();
		
	// set orientation 
	OrientationUtil.setMidPoint(pg, point1, point2);
	OrientationUtil.setRotationTowards(pg, point1, point2);

	// draw box
	Shapes.drawCylinder(pg, resolution, radius, radiusBot, point1.dist(point2), false);

	pg.popMatrix(); 
}
 
Example 7
Source File: LeapRegion.java    From haxademic with MIT License 5 votes vote down vote up
public void drawDebug(PGraphics debugGraphics) {
	if( _blockColor == -1 ) return;
	
	// set box color for (in)active states
	debugGraphics.strokeWeight(5f);
	if(_isActive == true) {
		debugGraphics.stroke(_blockColor, 255);
		debugGraphics.noFill();
	} else {
		debugGraphics.stroke(255, 127);
		debugGraphics.noFill();
	}
	debugGraphics.pushMatrix();
	
	// move to center of box location & draw box
	debugGraphics.translate(P.lerp(_right, _left, 0.5f), P.lerp(_top, _bottom, 0.5f), -1f * P.lerp(_far, _near, 0.5f));
	debugGraphics.box(_right - _left, _top - _bottom, _far - _near);
	
	// draw text control values
	if(_isActive == true) {
		debugGraphics.noStroke();
		debugGraphics.fill(255);
		debugGraphics.textSize(24);
		debugGraphics.text(MathUtil.roundToPrecision(_controlX, 2)+", "+MathUtil.roundToPrecision(_controlY, 2)+", "+MathUtil.roundToPrecision(_controlZ, 2), -50, 0);
	}
	
	debugGraphics.popMatrix();
}
 
Example 8
Source File: ImageSequencePlayer.java    From haxademic with MIT License 5 votes vote down vote up
public int display(PGraphics pg, int x, int y, int frame) {
	boolean flipped = (frameIndexPlaybackSequence[frame] < 0);
	frame = P.abs(frameIndexPlaybackSequence[frame]);
	if(loaded == false) return -1;
	if(imageSequence.size() > frame) {
		pg.pushMatrix();
		pg.translate(x + imgW/2, y + imgH/2);
		if(flipped == true) pg.scale(-1, 1);
		pg.image(imageSequence.get(frame), 0, 0, imgW, imgH);
		pg.popMatrix();
	}
	return frame;
}
 
Example 9
Source File: Shapes.java    From haxademic with MIT License 5 votes vote down vote up
public static void drawStar( PGraphics p, float spikes, float outerrad, float innerradpercent, float h, float rot)
{
	p.pushMatrix();

	int pi;
	float futil;
	p.beginShape(P.TRIANGLE_STRIP);
	for(pi=0;pi<spikes+1;pi++)
	{
		p.vertex(0,0,h/2);
	    futil=(pi/spikes)  * P.TWO_PI;    //current angle 
	    p.vertex(  P.cos(futil+rot)*outerrad, P.sin(futil+rot)*outerrad, 0);
	    futil=futil+ (  (1/spikes)/2 *P.TWO_PI  );
	    p.vertex(  P.cos(futil+rot)*outerrad*innerradpercent, P.sin(futil+rot)*outerrad*innerradpercent, 0);
	}
	p.endShape();
	p.beginShape(P.TRIANGLE_STRIP);
	for(pi=0;pi<spikes+1;pi++)
	{
		p.vertex(0,0,-h/2);
		futil=(pi/spikes)  * P.TWO_PI;    //current angle 
		p.vertex(  P.cos(futil+rot)*outerrad, P.sin(futil+rot)*outerrad, 0);
		futil=futil+ (  (1/spikes)/2 *P.TWO_PI  );
		p.vertex(  P.cos(futil+rot)*outerrad*innerradpercent, P.sin(futil+rot)*outerrad*innerradpercent, 0);
	}
	p.endShape();
	
	p.popMatrix();
}
 
Example 10
Source File: SvgImageRedraw.java    From haxademic with MIT License 5 votes vote down vote up
public void draw(PGraphics canvas, float x, float y, float drawSize) {
	if(scale < 1.0f) {
		if(isWhite) {
			canvas.shape(_whiteDot.shape, x, y, drawSize, drawSize);
		} else {
			canvas.shape(_blackDot.shape, x, y, drawSize, drawSize);
		}
	}
	canvas.pushMatrix();
	canvas.translate(x, y);
	canvas.shape(shape, 0, 0, drawSize * scale, drawSize * scale);
	canvas.popMatrix();
}
 
Example 11
Source File: SvgImageRedrawCollections.java    From haxademic with MIT License 5 votes vote down vote up
public void draw(PGraphics canvas, float x, float y, float drawSize) {
	if(scale < 1.0f) {
		if(isWhite) {
			canvas.shape(_whiteDot.shape, x, y, drawSize, drawSize);
		} else {
			canvas.shape(_blackDot.shape, x, y, drawSize, drawSize);
		}
	}
	canvas.pushMatrix();
	canvas.translate(x, y);
	canvas.shape(shape, 0, 0, drawSize * scale, drawSize * scale);
	canvas.popMatrix();
}
 
Example 12
Source File: VectorFlyer.java    From haxademic with MIT License 5 votes vote down vote up
public void update( PGraphics pg, boolean draws, boolean debugTarget ) {
	// color - if closer than threshold, ease towards saturated color
	pg.noStroke();
	if( distToDest < 200 ) {
		pg.fill(color.colorIntMixedWith(color2, 1f - distToDest/200f));
		// if( target != null ) BoxBetween.draw( p, new PVector(position.x, position.y, position.z), new PVector(target.x, target.y, target.z), 10 );
	} else {
		pg.fill(color.colorInt());
	}
	
	// store last position for rotation towards heading
	positionLast.set(position);
	
	//		accel = baseAccel * ( 0.5f + 0.6f * (float)Math.sin(p.frameCount * 0.01f) ); // was an effect to get particles to slow on following attractors 

	// always accelerate towards destination using basic xyz comparison & cap speed
	vector.x += ( position.x < target.x ) ? accel : -accel;
	vector.x = P.constrain(vector.x, -maxSpeed, maxSpeed);
	vector.y += ( position.y < target.y ) ? accel : -accel;
	vector.y = P.constrain(vector.y, -maxSpeed, maxSpeed);
	vector.z += ( position.z < target.z ) ? accel : -accel;
	vector.z = P.constrain(vector.z, -maxSpeed, maxSpeed);
	position.add(vector);
	
				
	if( draws == true ) { 
		// point and position
		pg.pushMatrix();
		pg.translate(position.x, position.y, position.z);
		OrientationUtil.setRotationTowards( pg, new PVector(position.x, position.y, position.z), new PVector(positionLast.x, positionLast.y, positionLast.z) );
		pg.box(10, 30, 10);
		pg.popMatrix();
		
		// line to target
		if(debugTarget) {
			pg.stroke(255);
			pg.line(position.x, position.y, position.z, target.x, target.y, target.z);
		}
	}
}
 
Example 13
Source File: ShaderSSAO.java    From haxademic with MIT License 5 votes vote down vote up
protected void drawCubesInGrid(PGraphics pg) {
	// spin it
	pg.rotateX(-P.PI/3f - 0.1f + P.sin(progressRads) * 0.1f);  
	pg.translate(0, 0, -pg.height * 0.5f);
	// draw plane
	pg.fill(100);
	pg.box(p.width * 3);

	// grid setup
	float boxSize = p.width / 10f;
	float numBoxes = 120f;

	for (int x = 0; x < numBoxes; x++) {
		for (int z = 0; z < numBoxes; z++) {
			pg.fill(255f);
			pg.pushMatrix();
			float xx = (-numBoxes/2f * boxSize) + x * boxSize;
			float yy = pg.height * 1.1f;
			float zz = (-numBoxes/2f * boxSize) + z * boxSize;
			pg.translate(xx, yy, zz);
			float dist = MathUtil.getDistance(0, 0, xx, zz);
			pg.box(
					boxSize,
					pg.height * (0.4f + 0.4f * P.sin(dist/250f + progressRads)),
					boxSize
				);
			pg.popMatrix();
		}
	}	
}
 
Example 14
Source File: PG.java    From haxademic with MIT License 5 votes vote down vote up
public static void rotateRedraw(PGraphics pg, float radians) {
	pg.beginDraw();
	PG.setDrawCenter(pg);
	pg.pushMatrix();
	PG.setCenterScreen(pg);
	pg.rotate(radians);
	pg.image(pg, 0, 0);
	pg.popMatrix();
	PG.setDrawCorner(pg);
	pg.endDraw();
}
 
Example 15
Source File: UISlider.java    From haxademic with MIT License 5 votes vote down vote up
public void draw(PGraphics pg) {
		pg.pushMatrix();
		PG.setDrawCorner(pg);
		
		// outline
		pg.noStroke();
		pg.fill(ColorsHax.BUTTON_OUTLINE);
		pg.rect(x, y, w, h);
		
		// background
		if(mouseHovered) pg.fill(ColorsHax.BUTTON_BG_HOVER);
		else pg.fill(ColorsHax.BUTTON_BG);
		pg.rect(x+1, y+1, w-2, h-2);
		
		// draw current value
		pg.noStroke();
		if(mousePressed) pg.fill(ColorsHax.WHITE, 180);
		else pg.fill(0, 127, 0);
//		else pg.fill(ColorsHax.WHITE, 120);
		float handleW = 4;
		float mappedX = P.map(value, valueMin, valueMax, x+1, x + w - handleW);
		pg.rect(mappedX - 0.5f, y+1, handleW, h-2);
		
		// text label
		IUIControl.setFont(pg);
		pg.fill(ColorsHax.BUTTON_TEXT);
		pg.text(id + ": " + MathUtil.roundToPrecision(value, 5), P.round(x + TEXT_INDENT), y, w, h*2);
		uiRect.setBounds(x, y, w, h);
		
		// set active if drawing
		activeTime = P.p.millis();
		pg.popMatrix();
	}
 
Example 16
Source File: Interphase.java    From haxademic with MIT License 4 votes vote down vote up
protected void drawSequencer(PGraphics pg) {
		float spacing = 40;
		float boxSize = 25;
		float startx = (spacing * sequencers.length) / -2f + boxSize/2;
		float startY = (spacing * NUM_STEPS) / -2f + boxSize/2;
		pg.beginDraw();
		PG.setCenterScreen(pg);
		PG.basicCameraFromMouse(pg, 0.1f);
		PG.setBetterLights(pg);
		PG.setDrawCenter(pg);
		
		// draw cubes
		for (int x = 0; x < sequencers.length; x++) {
			for (int y = 0; y < NUM_STEPS; y++) {
//				float value = (sequencers[x].stepActive(y)) ? 1 : 0; 
				boolean isOn = (sequencers[x].stepActive(y)); 
				pg.fill(isOn ? P.p.color(255) : 30);
				pg.pushMatrix();
				pg.translate(startx + x * spacing, startY + y * spacing);
				pg.box(20);
				pg.popMatrix();
			}
		}
		
		// show beat/4
		for (int y = 0; y < NUM_STEPS; y+=4) {
//			float value = (sequencers[x].stepActive(y)) ? 1 : 0; 
			pg.stroke(255);
			pg.noFill();
			pg.pushMatrix();
			pg.translate(-boxSize/2, startY + y * spacing);
			Shapes.drawDashedBox(pg, spacing * (sequencers.length + 1), boxSize, boxSize, 10, true);
			pg.popMatrix();
		}
		
		// track current beat
		int curBeat = P.store.getInt(BEAT) % NUM_STEPS;
		pg.stroke(255);
		pg.noFill();
		pg.pushMatrix();
		pg.translate(-boxSize/2, startY + curBeat * spacing);
		pg.box(spacing * (sequencers.length + 1), boxSize, boxSize);
		pg.popMatrix();	
		
		pg.endDraw();
	}
 
Example 17
Source File: SlideImage.java    From haxademic with MIT License 4 votes vote down vote up
protected void draw(PGraphics buffer) {
	activeFrames++;

	buffer.pushMatrix();

	// update position
	if(state == SlideState.FADE_IN) {
		curX = startOffset.x * (float) buffer.width * easeInProgress(1f - fadeInProgress.value());	// ease in since progress is reversed
		curY = startOffset.y * (float) buffer.height * easeInProgress(1f - fadeInProgress.value());
	} else if(state == SlideState.FADE_OUT) {
		if(fadesAway == true) {
			fadeOutSpeedMult.update();
			curZ -= speedZ * fadeOutSpeedMult.value();
		}
		curX = endOffset.x * (float) buffer.width * easeInProgress(fadeOutProgress.value());
		curY = endOffset.y * (float) buffer.height * easeInProgress(fadeOutProgress.value());
	} else {
		curX = 0;
		curY = 0;
	}
	buffer.translate(curX, curY, curZ);

	// fade to black
	float curFade = 1f;
	if((state == SlideState.FADE_OUT && fadesOut == true) || state == SlideState.REMOVE) curFade = 1f - fadeOutProgress.value();
	if(state == SlideState.FADE_IN && fadesIn == true) curFade = fadeInProgress.value();
	buffer.tint( 255, curFade * 255 );

	// draw image
	if(cropOffset != null) {
		// image size
		float imageW = cropOffset[2];
		float imageH = cropOffset[3];
		if(state == SlideState.FADE_IN && scalesUp == true) {
			imageW *= easeOutProgress(fadeInProgress.value());
			imageH *= easeOutProgress(fadeInProgress.value());
		}
		if(state == SlideState.FADE_OUT && scalesDown == true) {
			imageW *= easeInProgress(1f - fadeOutProgress.value());
			imageH *= easeInProgress(1f - fadeOutProgress.value());
		}

		if(image != null) buffer.image(image, 0, 0, imageW, imageH);
		if(movie != null) buffer.image(movie, 0, 0, imageW, imageH);
		if(gif != null) buffer.image(gif, 0, 0, imageW, imageH);
		if(imageSequence != null) {
			PImage frameImg = (imageSequence.isPlaying() == true) ? imageSequence.image() : imageSequence.getFrame(imageSequence.numImages() - 1);
			buffer.image(frameImg, 0, 0, imageW, imageH);
		}
	}
	PG.resetPImageAlpha(buffer);

	buffer.popMatrix();
}
 
Example 18
Source File: Partycles.java    From haxademic with MIT License 4 votes vote down vote up
public void update(PGraphics pg) {
			if(available()) return;
			
			// update position
			gravity.x *= 0.97f;
			speed.add(gravity);
			pos.add(speed);
			rotation += gravity.z;
			
			// update size
			sizeProgress.update();
			float audioAmp = (1f + 1f * AudioIn.audioFreq(audioIndex));
			if(sizeProgress.value() == 1) shrink -= 0.01f;
			float curSize = (sizeProgress.value() == 1) ?
					size * shrink * audioAmp:
					size * Penner.easeOutQuad(sizeProgress.value()) * audioAmp;
//			if(sizeProgress.value() == 1) sizeProgress.setTarget(0);
			
			// draw image or polygon
			if(image != null) {
				// draw image
				pg.pushMatrix();
				pg.translate(pos.x, pos.y);
				pg.rotate(rotation);
				pg.tint(color);
				pg.image(image, 0, 0, curSize * 2f, curSize * 2f);
				pg.tint(255);
				pg.popMatrix();
			} else {
				// draw shape
				float segmentRads = P.TWO_PI / vertices;
				pg.fill(color); // , 150);
//				pg.stroke(255);
				pg.noStroke();
				pg.pushMatrix();
				pg.translate(pos.x, pos.y);
				pg.rotate(rotation);
				pg.beginShape(P.POLYGON);
				for(float i = 0; i <= vertices; i++) {
					pg.vertex(P.cos(segmentRads * i) * curSize, P.sin(segmentRads * i) * curSize);
				}
				pg.endShape();
				pg.popMatrix();
				// pg.rect(pos.x, pos.y, 2, 2);
			}
			pg.tint(255);
		}
 
Example 19
Source File: UITextInput.java    From haxademic with MIT License 4 votes vote down vote up
public void draw( PGraphics pg ) {
	pg.pushMatrix();
	PG.setDrawCorner(pg);
	
	// outline
	pg.noStroke();
	pg.fill(ColorsHax.BUTTON_OUTLINE);
	pg.rect(rect.x, rect.y, rect.width, rect.height);

	// draw input background
	if( pressed == true || focused == true ) {
		pg.fill(ColorsHax.BUTTON_BG_PRESS);
	} else if( over == true ) {
		pg.fill(ColorsHax.BUTTON_BG_HOVER);
	} else {
		pg.fill(ColorsHax.BUTTON_BG);
	}
	pg.rect(rect.x+1, rect.y+1, rect.width-2, rect.height-2);

	// set font on context
	boolean isUIComponent = (rect.height == IUIControl.controlH);
	if(isUIComponent) {  	// lock to UI size if we're a UI component
		IUIControl.setFont(pg);
		pg.fill(ColorsHax.BUTTON_TEXT);
	} else {
		PFont font = FontCacher.getFont(fontFile, fontSize);
		FontCacher.setFontOnContext(pg, font, ColorsHax.BUTTON_TEXT, 1f, align, PTextAlign.CENTER);
	}
	
	// get text width for cursor and to "scroll" text
	String displayText = value;
	float textW = pg.textWidth(displayText);
	int maxTextW = rect.width - padX * 2;
	while(textW > maxTextW) {
		displayText = displayText.substring(1);	// shift chars off the front of the text
		textW = pg.textWidth(displayText);
	}
	if(isUIComponent) {
		pg.text(displayText, rect.x + TEXT_INDENT, rect.y, rect.width, rect.height);
	} else {
		pg.text(displayText, rect.x + padX, rect.y - rect.height * 0.05f, rect.width, rect.height);
	}

	// draw blinking cursor
	cursorX = rect.x + padX + textW + cursorPadding;
	if(isUIComponent) cursorX -= 3;
	if(align == PTextAlign.CENTER) cursorX = rect.x + rect.width/2 + textW/2 + cursorPadding * 3f;
	if(focused == true) {
		pg.noStroke();
		pg.fill(ColorsHax.BUTTON_TEXT);
		if( P.p.millis() % 1000f > 500 ) pg.rect( cursorX, rect.y + rect.height * 0.25f, 2f, fontSize );
	}
	pg.popMatrix();
}
 
Example 20
Source File: LeapRegion.java    From haxademic with MIT License 4 votes vote down vote up
public void update(PGraphics debugGraphics) {
	// find kinect readings in the region
	_isActive = false;
	if( leapMotion != null ) {
		DebugView.setValue("leapMotion.getHands()", leapMotion.getHands().size());
	    for(Hand hand : leapMotion.getHands()){
	        PVector hand_position    = hand.getPosition();
	        // PVector hand_stabilized  = hand.getStabilizedPosition();
	        DebugView.setValue("hand "+hand.getId(), hand_position.toString());
	        
	        // draw debug hand position
	        if(debugGraphics != null) {
	        	debugGraphics.noStroke();
		        debugGraphics.fill(255);
		        debugGraphics.pushMatrix();
		        debugGraphics.translate(hand_position.x, hand_position.y, -1f * hand_position.z);
		        debugGraphics.box(40, 40, 40);
		        debugGraphics.popMatrix();
	        }
			
	        // set position if hand is in region
	        if(
	        	hand_position.x > _left && 
	        	hand_position.x < _right && 
	        	hand_position.y > _top && 
	        	hand_position.y < _bottom && 
	        	hand_position.z > _near && 
	        	hand_position.z < _far 
	        	) {
	        	_isActive = true;
	        	_controlX = (MathUtil.getPercentWithinRange(_left, _right, hand_position.x) - 0.5f) * 2f;
	        	_controlY = (MathUtil.getPercentWithinRange(_top, _bottom, hand_position.y) - 0.5f) * 2f;
	        	_controlZ = (MathUtil.getPercentWithinRange(_near, _far, hand_position.z) - 0.5f) * 2f;
	        }
	    }
	}
	
	// if none found, reset values
	if(_isActive == false) {
		_controlX = 0;
		_controlY = 0;
		_controlZ = 0;
	}
}