Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
jtullen
jtullen's Profile
1
Posts
3
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Camera rotation and zooming around an object
[10 Replies]
16-Mar-2013 02:06 PM
Forum:
Programming Questions
Hi
I've been trying to get this working for a while. For some reason it keeps giving problems. It compiles, but it doesn't do the trick. Any help?
I'm trying to make it zoom and rotating around the object when pressed ENTER.
public class Huisje{
void draw(){
translate(300, 0, 100);
noStroke();
fill(100);
box(50,20,10);
}
}
Huisje huis = new Huisje();
// Camera variables
float xPos = 100;
float yPos = -50;
float zPos = 100;
float rotation = 0;
float radius = 50;
// Zoom variables
float zoom = 0;
int s1;
int s2;
void setup(){
size(400, 400, P3D);
background(50);
lights();
}
void draw(){
cameraTurn();
camera( 300 + xPos + zoom,
yPos + zoom,
100 + zPos + zoom,
300.0, 0, 100.0, 0.0, 1.0, 0.0);
huis.draw();
tekst();
}
void tekst(){
if(mousePressed && (mouseX<140) && (130<mouseX) && (10<mouseY) && (mouseY<30)){
zoom--;
s1 = 155;
redraw();
}
else if(mousePressed && (mouseX< 120) && (110< mouseX) && (10<mouseY) && (mouseY<30)){
zoom++;
s2 = 155;
redraw();
}
else{
s1 = 0;
s2 = 0;
}
camera();
fill(100 + s1);
textSize(20);
text("-", 130, 20);
fill(100 + s2);
textSize(20);
text("+", 110, 20);
}
void cameraTurn(){
xPos = cos(radians(rotation)) * radius;
zPos = sin(radians(rotation)) * radius;
yPos = 0;
while(keyPressed){
if(key == ENTER){
rotation++;
redraw();
}
}
}
«Prev
Next »
Moderate user : jtullen
Forum