0

I'm trying to get the horizontal rotation of the camera, but the scene.camera.axis.x seems to be completely random and makes no sense at all. I need the rotation in degrees because that's what I need to rotate my object to the camera.

Here is what ive tried:

I tried inputting the X in the sin for rotation, and Z in the cos for rotation, which didn't work. I just tried doing only X in both sin and cos for rotation, it seemed random.

This is my code. (model is just an obj files text, but I excluded it and the function source code because those are not the problem, and would make it ridiculously long.)

loadobject(model,size=3)

scene.camera.autoscale = False

sine = 0
rotx = 0
roty = 0
print(offset)

scene.camera.axis = vec(0,0,0)
while True:
  rate(60)
  vertindex = 0
  rotx = scene.camera.axis.x
  
  roty += 1
  for v in verts:
    v.pos.x = (sin(radians(rotx)) * (objectposes[vertindex].z - offset.z)) + (sin(radians(rotx - 90)) * (objectposes[vertindex].x - offset.x))
    v.pos.z = (cos(radians(rotx)) * (objectposes[vertindex].z - offset.z)) + (cos(radians(rotx - 90)) * (objectposes[vertindex].x - offset.x))
    sine += 0.001
    vertindex += 1
3
  • Unable to debug, because verts and other variables and functions are undefined. Minor point: say scene.autoscale = False, not scene.camera.autoscale = False. Commented Jan 10, 2024 at 19:11
  • Sorry i forgot i made this, but from experimenting, it appears the scene.camera.axis values are sin and cos values Commented Jan 11, 2024 at 21:26
  • I just track the camera rotation when the player moves it with the arrow keys Commented Jan 11, 2024 at 21:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.