614ControlP5, PeasyCam and HUD in Processing

A slight development of an ControlP5 example. I needed to have the controls over the PeasyCam, wasn't too hard to achieve. Nice one, Processing.

Here's the applet.

/**
 * ControlP5 with PeasyCam support. 
 * Tested with Processing 1.2.1, PeasyCam 0.8.3 and ControlP5 0.5.0
 *
 * original by
 * by jeffg 2009
 * http://processing.org/discourse/yabb2/YaBB.pl?num=1234988194/30#30
 *
 * modified by trembl 2010
 */

import peasy.*;
import controlP5.*;
import processing.opengl.*;

PeasyCam cam;
ControlP5 controlP5;
PMatrix3D currCameraMatrix;
PGraphics3D g3; 

int buttonValue = 1;

int myColor = color(255,0,0);
Slider r,gr,b;
void setup() {
  size(400,400,OPENGL);
  g3 = (PGraphics3D)g;
  cam = new PeasyCam(this, 100);
  cam.setMinimumDistance(-100);
  cam.setMaximumDistance(200);

  controlP5 = new ControlP5(this);
  //controlP5.addButton("button",10,10,10,80,20).setId(1);
  //controlP5.addButton("buttonValue",4,10,40,80,20).setId(2);

  r = controlP5.addSlider("redSlider",0,255,128,10,10,200,20);
  r.setColorActive(color(128,0,0));
  r.setColorBackground( color(127,100) );
  r.setColorForeground(color(255,0,0));
  r.setColorLabel(color(0,255,255,127));
  r.setColorValue(color(0,255,255,127));
  r.setLabel("");
  r.setLabelVisible(true);

  gr = controlP5.addSlider("greenSlider",0,255,128,10,40,200,20);
  gr.setColorActive(color(0,128,0));
  gr.setColorBackground( color(127,100) );
  gr.setColorForeground(color(0,255,0));
  gr.setColorLabel(color(0,255,255,127));
  gr.setColorValue(color(0,255,255,127));
  gr.setLabel("");
  gr.setLabelVisible(true);

  b = controlP5.addSlider("blueSlider",0,255,128,10,70,200,20);
  b.setColorActive(color(0,0,128));
  b.setColorBackground( color(127,100) );
  b.setColorForeground(color(0,0,128));
  b.setColorLabel(color(0,255,255,127));
  b.setColorValue(color(0,255,255,127));
  b.setLabel("");
  b.setLabelVisible(true);

  controlP5.setAutoDraw(false);
}
void draw() {

  background(0);
  fill(myColor);
  box(30);
  pushMatrix();
  translate(0,0,20);
  fill(0,0,255);
  box(5);
  popMatrix();

  cam.beginHUD();
  gui();
  cam.endHUD();

  cam.setMouseControlled(true);
  if(r.isInside() || gr.isInside() || b.isInside() ) {
    cam.setMouseControlled(false);
  } 
}

void gui() {
  currCameraMatrix = new PMatrix3D(g3.camera);
  camera();
  controlP5.draw();
  g3.camera = currCameraMatrix;
}

void redSlider(float v) {
  myColor = color( v, green(myColor), blue(myColor) );
  r.setColorActive(color(v,0,0));
}

void greenSlider(float v) {
  myColor = color(red(myColor), v, blue(myColor) );
  gr.setColorActive(color(0,v,0));
}

void blueSlider(float v) {
  myColor = color(red(myColor), green(myColor), v );
  b.setColorActive(color(0,0,v));
}

65wolf3d

The granddaddy of the FPS at your fingertips.

http://www.idsoftware.com/wolfenstein3dclassic/

buy at app store - or download the source code for free!!!

(just change the code signing settings to your id. you should really know how to do this.)