Here is an example I put together to demo the different values for rotate and camera. The eyeXYZ values set the camera position. The cXYZ values set where the camera is pointed. The upXYZ values set which axis is pointing up and which axis the rotation goes around. One or more of the upXYZ values can be set to rotate about a combination of the axis. I also show the rotate and camera functions with their values. Hope this helps explain how the rotate and camera functions work. After the program starts, pull the output pane all the way down to show all the parameters.
-- 3d example
function setup()
iparameter("rot",-180,180,70)
iparameter("size", 0, 20, 20)
iparameter("eyeX",-200,200,90)
iparameter("eyeY",-200,200,50)
iparameter("eyeZ",-200,200,70)
iparameter("cX",-100,100,0)
iparameter("cY",-100,100,0)
iparameter("cZ",-100,100,0)
iparameter("upX",0,1,0)
iparameter("upY",0,1,1)
iparameter("upZ",0,1,0)
end
function draw()
background(0, 0, 0, 255)
textMode(CORNER)
text("3D Example",200,1000)
str=string.format("rotate(%d,%d,%d,%d)",
rot,upX,upY,upZ)
text(str,50,900)
str=string.format("camera(%d,%d,%d, %d,%d,%d, %d,%d,%d)",
eyeX,eyeY,eyeZ,cX,cY,cZ,upX,upY,upZ)
text(str,50,850)
perspective(90)
camera(eyeX,eyeY,eyeZ,cX,cY,cZ,upX,upY,upZ)
rotate(rot,upX,upY,upZ)
strokeWidth(4)
textMode(CENTER)
stroke(255,0,0)
fill(255, 0, 0)
text("-x",-50,0)
text("+x",50,0)
line(-40,0,40,0)
stroke(0,0,255)
fill(0,0,255)
text("-y",0,-50)
text("+y",0,50)
line(0,-40,0,40)
s=size * .1
scale(s,s,s)
create3d()
end
function create3d()
c3d = mesh()
vp = {vec3(0,0,0),vec3(-20,0,0),vec3(0,0,20),
vec3(0,0,0),vec3(0,20,0),vec3(0,0,20),
vec3(0,0,0),vec3(0,-20,0),vec3(20,0,0)}
sides = {
vp[1],vp[2],vp[3],
vp[4],vp[5],vp[6],
vp[7],vp[8],vp[9]
}
c3d.vertices = sides
c3d:setColors(0,0,0)
c3d:color(1,255,0,0) -- red
c3d:color(2,255,0,0)
c3d:color(3,255,0,0)
c3d:color(4,0,0,255) -- blue
c3d:color(5,0,0,255)
c3d:color(6,0,0,255)
c3d:color(7,0,255,0) -- green
c3d:color(8,0,255,0)
c3d:color(9,0,255,0)
c3d:draw()
end