2016-11-17 教學軟體設計 week10
1.
簡單複習上周Leap Motion接金幣
2.
陣列、存檔、成績排名SORT計算
3.
如何做
剪刀石頭布 的猜拳判斷
4. 用陣列做”3d畫畫過程重播”示範
PVector pt;
ArrayList<PVector>history;
void setup(){
size(600,400,P3D);
pt=new PVector(width/2, height/2);
history=new ArrayList<PVector>(0);
}
void draw(){
for(PVector nowPt : history){
ellipse(nowPt.x, nowPt.y, 3,3);
}
}
void mouseMoved(){
history.add(new PVector(mouseX, mouseY));
}
import de.voidplus.leapmotion.*;
LeapMotion leap;
PVector pt;
ArrayList<PVector>history;
void setup() {
size(600, 400, P3D);
leap=new LeapMotion(this);
pt=new PVector(width/2, height/2);
history=new ArrayList<PVector>(0);
}
void draw() {
background(255);
for
(PVector nowPt : history) {
fill(255, 0, 0);
noStroke();
ellipse(nowPt.x, nowPt.y, 10, 10);
}
for
( Hand hand : leap.getHands() ) {
hand.draw();
PVector pos = hand.getPosition();
history.add(new PVector(pos.x, pos.y));
}
}
import
de.voidplus.leapmotion.*;
LeapMotion leap;
PVector pt;
ArrayList<PVector>
history;
ArrayList<PVector>
history2;
ArrayList<PVector>
history3;
ArrayList<PVector>
history4;
ArrayList<PVector>
history5;
void setup() {
size(600, 400, P3D);
leap=new LeapMotion(this);
pt=new PVector(width/2, height/2);
history=new ArrayList<PVector>(0);
history2=new ArrayList<PVector>(0);
history3=new ArrayList<PVector>(0);
history4=new ArrayList<PVector>(0);
history5=new ArrayList<PVector>(0);
}
void draw() {
background(255);
fill(255, 0, 0);
noStroke();
for (PVector nowPt : history) {
ellipse(nowPt.x, nowPt.y, 10, 10);
}
for (PVector nowPt : history2) {
ellipse(nowPt.x, nowPt.y, 10, 10);
}
for (PVector nowPt : history3) {
ellipse(nowPt.x, nowPt.y, 10, 10);
}
for (PVector nowPt : history4) {
ellipse(nowPt.x, nowPt.y, 10, 10);
}
for (PVector nowPt : history5) {
ellipse(nowPt.x, nowPt.y, 10, 10);
}
for ( Hand hand : leap.getHands() ) {
hand.draw();
Finger finger = hand.getThumb();
Finger finger2 = hand.getIndexFinger();
Finger finger3 = hand.getMiddleFinger();
Finger finger4 = hand.getRingFinger();
Finger finger5 = hand.getPinkyFinger();
PVector pos;
pos= finger.getPosition();
history.add(new PVector(pos.x, pos.y));
pos = finger2.getPosition();
history2.add(new PVector(pos.x, pos.y));
pos = finger3.getPosition();
history3.add(new PVector(pos.x, pos.y));
pos = finger4.getPosition();
history4.add(new PVector(pos.x, pos.y));
pos = finger5.getPosition();
history5.add(new PVector(pos.x, pos.y));
}
}
//void
mouseMoved(){
// history.add(new
PVector(mouseX, mouseY));
//}
import de.voidplus.leapmotion.*;
LeapMotion leap;
PVector pt;
ArrayList<PVector>
history;
ArrayList<PVector>
history2;
ArrayList<PVector>
history3;
ArrayList<PVector>
history4;
ArrayList<PVector>
history5;
void setup() {
size(640, 480, P3D);//Need P3D 3D function
(ball, translate, rotate, pushMatrix,popMatrix)
leap=new LeapMotion(this);
pt=new PVector(width/2, height/2);
history=new ArrayList<PVector>(0);
history2=new ArrayList<PVector>(0);
history3=new ArrayList<PVector>(0);
history4=new ArrayList<PVector>(0);
history5=new ArrayList<PVector>(0);
}
void myBall(float
x, float y, float z) {
pushMatrix();//backup translate/rotate matrix
translate(x, y, z*10);// z need to be x10
sphere(10);
popMatrix();//restore the translate/rotate
matrix
}
void draw() {
background(255);
lights();// lighs will let 3D ball to look
like 3D
translate(width/2, height/2);//This 3 lines
(Translate, rotate, translate)
rotateY(radians(frameCount));// can let the
balls rotating in the center of screen
translate(-width/2, -height/2);//
noStroke();
for (PVector nowPt : history) {
fill(255, 0, 0);
myBall(nowPt.x, nowPt.y, nowPt.z);
}
for (PVector nowPt : history2) {
fill(255, 255, 0);
myBall(nowPt.x, nowPt.y, nowPt.z);
}
for (PVector nowPt : history3) {
fill(0, 255, 0);
myBall(nowPt.x, nowPt.y, nowPt.z);
}
for (PVector nowPt : history4) {
fill(0, 0, 255);
myBall(nowPt.x, nowPt.y, nowPt.z);
}
for (PVector nowPt : history5) {
fill(255, 0, 255);
myBall(nowPt.x, nowPt.y, nowPt.z);
}
for ( Hand hand : leap.getHands() ) {
hand.draw();
Finger finger = hand.getThumb();
Finger finger2 = hand.getIndexFinger();
Finger finger3 = hand.getMiddleFinger();
Finger finger4 = hand.getRingFinger();
Finger finger5 = hand.getPinkyFinger();
PVector pos;
pos= finger.getPosition();
history.add(new PVector(pos.x, pos.y,
pos.z));
pos = finger2.getPosition();
history2.add(new PVector(pos.x, pos.y,
pos.z));
pos = finger3.getPosition();
history3.add(new PVector(pos.x, pos.y,
pos.z));
pos = finger4.getPosition();
history4.add(new PVector(pos.x, pos.y,
pos.z));
pos = finger5.getPosition();
history5.add(new PVector(pos.x, pos.y,
pos.z));
}
}
//void mouseMoved(){
// history.add(new
PVector(mouseX, mouseY));
//}
沒有留言:
張貼留言