We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I made a simple 3D project to see what it could do. I wanted to make a first-person sort of perspective. You can walk around but you are always looking in one direction. What do I have to do to get the person to turn? Thanks.
import vsync.*;
import processing.sound.*;
float x;
float y;
float z;
int w,a,s,d = 0;
void setup(){
size(displayWidth,displayHeight,P3D);
background(0);
fill(0);
stroke(255);
strokeWeight(5);
x = width/2;
y = height/2;
z = height/1.5;
}
void draw(){
background(0);
render();
println(z);
control();
}
void keyPressed(){
if(key == 'w'){
w = 1;
}
if(key == 'a'){
a = 1;
}
if(key == 's'){
s = 1;
}
if(key == 'd'){
d = 1;
}
}
void keyReleased(){
if(key == 'w'){
w = 0;
}
if(key == 'a'){
a = 0;
}
if(key == 's'){
s = 0;
}
if(key == 'd'){
d = 0;
}
}
void control(){
if(w == 1){
z += 5;
}
if(a == 1){
x += 5;
}
if(s == 1){
z -= 5;
}
if(d == 1){
x -= 5;
}
}
void render(){
translate(x,y,z);
box(40);
translate(40,0,0);
box(40);
}
Answers
Have you looked at the qeasycam library?
Failing that, the camera() method has 9 variables which define where you are and where you are looking.
So I tried the PeasyCam and it didn't work how I wanted it to but, with the camera() method what would I do to get the camera to basically be placed in the x,y,z variables positions while looking forward as it was without the camera()?
QueasyCam, not Peasycam. Two different things.
I can't parse your question. With the camera without the camera?
The first three parameters are position, the next three are where you are looking. So if you are at x, y, z looking along the +ve x axis then the next three would be x + 100, y, z (the 100 is just a guess, depends on your scene). They last three are typically 0, 1, 0... y is up.
ah, QueasyCam worked thanks!