Last active
December 25, 2015 10:38
-
-
Save darkwave/6962613 to your computer and use it in GitHub Desktop.
Asylum Jam 2013 in Rome "Protocol 23 Module 64" game entry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import processing.video.*; | |
import remixlab.proscene.*; | |
Scene scene; | |
FPACameraProfile wProfile; | |
PShape rocket; | |
PShader toon; | |
ArrayList<VideoLog> logs = new ArrayList<VideoLog>(); | |
boolean applyShader = false; | |
PFont ubuntuRulez; | |
float distanceMade = 0; | |
PShader nebula; | |
boolean intro = true; | |
void setup() { | |
size(displayWidth, displayHeight, P3D); | |
ubuntuRulez = createFont("Ubuntu Bold", 48); | |
textFont(ubuntuRulez, 18); | |
nebula = loadShader("nebula.glsl"); | |
nebula.set("resolution", float(width), float(height)); | |
toon = loadShader("ToonFrag.glsl", "ToonVert.glsl"); | |
rocket = loadShape("starship.obj");//loadLevel("https://raw.github.com/openlabroma/modulex/gh-pages/level.json"); | |
logs.add(new VideoLog(this, 10, 5, 15, "test.mpg")); | |
scene = new Scene(this); | |
scene.registerCameraProfile( new FPACameraProfile(scene, "MY_PROFILE") ); | |
scene.setCurrentCameraProfile("MY_PROFILE"); | |
noCursor(); | |
rectMode(CENTER); | |
textMode(SHAPE); | |
} | |
void displayNebula() { | |
nebula.set("time", millis() / 500.0); | |
shader(nebula); | |
// This kind of raymarching effects are entirely implemented in the | |
// fragment shader, they only need a quad covering the entire view | |
// area so every pixel is pushed through the shader. | |
translate(0, 0, 140); | |
scale(1, -1, 1); | |
scale(0.5); | |
textAlign(CENTER, CENTER); | |
text("Protocol 23th\nModule 63", 0, 0); | |
} | |
void movieEvent(Movie m) { | |
m.read(); | |
} | |
void lights() { | |
float intensity = sin(radians(millis() * .3)) * 128 + 128; | |
ambientLight(intensity, intensity, intensity); | |
ambientLight(128, 0, 0); | |
//spotLight(128, 0, 0, 0, 0, 0, -1, 0, 0, PI / 2, 2); | |
} | |
void draw() { | |
background(0, 0, 0); | |
if (intro) { | |
if (millis() > 20000) | |
intro = false; | |
pushMatrix(); | |
// scene.disableMouseHandling(); | |
rotateX(radians(90)); | |
displayNebula(); | |
popMatrix(); | |
return; | |
} | |
if (mousePressed && mouseButton != CENTER) | |
distanceMade += 10; | |
PVector currentPosition = scene.camera().position(); | |
scene.camera().setPosition(new PVector(currentPosition.x, currentPosition.y, 8 + (1 * abs(sin(radians(distanceMade)))))); | |
//background(255); | |
lights(); | |
// Save the current model view matrix | |
// Multiply matrix to get in the frame coordinate system. | |
// applyMatrix(scene.interactiveFrame().matrix()) is handy but | |
// inefficient | |
//scene.interactiveFrame().applyTransformation(); // optimum | |
// Draw an axis using the Scene static function | |
//scene.drawAxis(20); | |
for (VideoLog v: logs) | |
v.display(); | |
pushMatrix(); | |
scale(.13); | |
shape(rocket); | |
popMatrix(); | |
} | |
void keyPressed() { | |
intro = false; | |
//if (q | |
/* | |
applyShader = !applyShader; | |
if (applyShader) | |
shader(toon); | |
else | |
resetShader(); | |
*/ | |
} | |
public class FPACameraProfile extends CameraProfile { | |
public FPACameraProfile(Scene scn, String name) { | |
super(scn, name, CameraProfile.Mode.FIRST_PERSON); | |
//removeAllShortcuts(); | |
// scn.setShortcut('w', Scene.KeyboardAction.MOVE_CAMERA_UP); | |
scn.setInteractiveFrame(new InteractiveFrame(scene)); | |
scn.camera().setFlySpeed(0.4); | |
scn.setAxisIsDrawn(false); | |
scn.setGridIsDrawn(false); | |
scn.camera().setPosition(new PVector(0, 0, 6)); | |
scn.camera().frame().setOrientation(new Quaternion(new PVector(1, 0, 0), radians(-90))); | |
scn.camera().frame().setRotationSensitivity(2.3); | |
CameraConstraint cons = new CameraConstraint(scn.camera()); | |
PVector dir = new PVector(0, 1.0f, 0); | |
cons.setRotationConstraintType(AxisPlaneConstraint.Type.AXIS); | |
cons.setRotationConstraintDirection(dir); | |
// scn.disableKeyboardHandling(); | |
scn.camera().frame().setConstraint(cons); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VideoLog { | |
PVector position; | |
Movie movie; | |
VideoLog(PApplet parent, float x, float y, float z, String filename) { | |
position = new PVector(x, y, z); | |
movie = new Movie(parent, filename); | |
movie.loop(); | |
} | |
void display() { | |
pushMatrix(); | |
translate(position.x, position.y, position.z); | |
rotateX(radians(-90)); | |
rotateY(radians(-90)); | |
beginShape(); | |
scale(10); | |
noStroke(); | |
texture(movie); | |
vertex(0, 0, 0, 0); | |
vertex(1, 0, movie.width, 0); | |
vertex(1, 1, movie.width, movie.height); | |
vertex(0, 1, 0, movie.height); | |
endShape(); | |
popMatrix(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment