-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Umair Khan <[email protected]>
- Loading branch information
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package=""><uses-sdk android:minSdkVersion="22"/><application android:debuggable="true" android:icon="@drawable/icon" android:label=""><activity android:name=".MainActivity">android:theme="@android:style/Theme.NoTitleBar"><intent-filter><action android:name="android.intent.action.MAIN"/><category android:name="android.intent.category.LAUNCHER"/></intent-filter></activity></application><uses-permission android:name="android.permission.CAMERA"/></manifest> |
85 changes: 85 additions & 0 deletions
85
examples/Capture/CameraTextureOnCube/CameraTextureOnCube.pde
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import in.omerjerk.processing.video.android.*; | ||
|
||
Capture cameraTex; | ||
float rotx = PI/4; | ||
float roty = PI/4; | ||
|
||
void setup() { | ||
fullScreen(P3D); | ||
|
||
String[] cameras = Capture.list(); | ||
cameraTex = new Capture(this, cameras[0]); | ||
cameraTex.start(); | ||
textureMode(NORMAL); | ||
fill(255); | ||
stroke(color(44,48,32)); | ||
} | ||
|
||
void draw() { | ||
cameraTex.read(); | ||
background(255); | ||
noStroke(); | ||
translate(width/2.0, height/2.0, -100); | ||
rotateX(rotx); | ||
rotateY(roty); | ||
scale(230); | ||
TexturedCube(cameraTex); | ||
} | ||
|
||
void TexturedCube(PImage tex) { | ||
beginShape(QUADS); | ||
texture(tex); | ||
|
||
// Given one texture and six faces, we can easily set up the uv coordinates | ||
// such that four of the faces tile "perfectly" along either u or v, but the other | ||
// two faces cannot be so aligned. This code tiles "along" u, "around" the X/Z faces | ||
// and fudges the Y faces - the Y faces are arbitrarily aligned such that a | ||
// rotation along the X axis will put the "top" of either texture at the "top" | ||
// of the screen, but is not otherwised aligned with the X/Z faces. (This | ||
// just affects what type of symmetry is required if you need seamless | ||
// tiling all the way around the cube) | ||
|
||
// +Z "front" face | ||
vertex(-1, -1, 1, 0, 0); | ||
vertex( 1, -1, 1, 1, 0); | ||
vertex( 1, 1, 1, 1, 1); | ||
vertex(-1, 1, 1, 0, 1); | ||
|
||
// -Z "back" face | ||
vertex( 1, -1, -1, 0, 0); | ||
vertex(-1, -1, -1, 1, 0); | ||
vertex(-1, 1, -1, 1, 1); | ||
vertex( 1, 1, -1, 0, 1); | ||
|
||
// +Y "bottom" face | ||
vertex(-1, 1, 1, 0, 0); | ||
vertex( 1, 1, 1, 1, 0); | ||
vertex( 1, 1, -1, 1, 1); | ||
vertex(-1, 1, -1, 0, 1); | ||
|
||
// -Y "top" face | ||
vertex(-1, -1, -1, 0, 0); | ||
vertex( 1, -1, -1, 1, 0); | ||
vertex( 1, -1, 1, 1, 1); | ||
vertex(-1, -1, 1, 0, 1); | ||
|
||
// +X "right" face | ||
vertex( 1, -1, 1, 0, 0); | ||
vertex( 1, -1, -1, 1, 0); | ||
vertex( 1, 1, -1, 1, 1); | ||
vertex( 1, 1, 1, 0, 1); | ||
|
||
// -X "left" face | ||
vertex(-1, -1, -1, 0, 0); | ||
vertex(-1, -1, 1, 1, 0); | ||
vertex(-1, 1, 1, 1, 1); | ||
vertex(-1, 1, -1, 0, 1); | ||
|
||
endShape(); | ||
} | ||
|
||
void mouseDragged() { | ||
float rate = 0.01; | ||
rotx += (pmouseY-mouseY) * rate; | ||
roty += (mouseX-pmouseX) * rate; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mode=Android | ||
mode.id=processing.mode.android.AndroidMode |