Just started learing 3d and having trouble with the camera.
I’m trying to make it first person, so i assume you would rotate the lookat pos around the eye pos.
I have tried a formula i use in 2d, but the distance between the two decreases the more i rotate.
What is the proper way to do this?
Any help would be appreciated
function setup()
lookAt = vec3(0,0,0) --camera direction
parameter.watch("lookAt")
parameter.watch("lookAt:dist(vec3(0,0,500))")
parameter.number("ang",-90,95,85)
parameter.integer("spriteZ",-100,1000,620)
end
function draw()
background()perspective()pushMatrix()
dist = 500
lookAt.x = math.cos(math.rad(ang))*dist
lookAt.z = math.sin(math.rad(ang))*dist
camera(0, 0, 500, lookAt.x, lookAt.y, lookAt.z)
translate(-100,0,0) sprite("Planet Cute:Character Cat Girl",0,0)
translate(500,0,spriteZ) sprite("Planet Cute:Character Horn Girl",0,0)
popMatrix()ortho()viewMatrix(matrix())
strokeWidth(2)fill(127, 127, 127, 145)translate(WIDTH/2,HEIGHT/2)
ellipse(0,0,40)
ellipse(lookAt.x/10,-lookAt.z/10,20)
popMatrix()
end