davgothic
02-10-2010, 04:11 PM
Hi!
I'm having trouble writing a script that can make a target camera orbit it's target at a set distance and add keyframes at every 10degree increment.
Here is the process the script should create:
Place camera above target at around 600mm away
rotate camera through 360 degrees and add a keyframe at every 10 degree increment
drop camera by 10 degrees and repeat step 2 till camera is at very bottom of target
Here is the code I have so far, it just doesn't seem to work as expected.
When the camera is at the top it sits there stationary for 36 frames.
cam = TargetCamera target:(targetObject pos:[0,0,0]) pos:[0,0,600];
fn rotateCamera hAngle vAngle = (
hAngle = (90 - hAngle);
x = cam.Target.pos[1] + (cos(hAngle) * sin(vAngle) * cam.targetDistance);
y = cam.Target.pos[2] + (sin(hAngle) * sin(vAngle) * cam.targetDistance);
z = cam.Target.pos[3] + (cos(vAngle) * cam.targetDistance);
return [x,y,z];
)
count = 0;
for v = 0 to 180 by 10 do (
for h = 0 to 350 by 10 do (
at time count animate on cam.pos = rotateCamera (350 - h) v;
count = count + 1;
)
)
Could anybody tell me where I am going wrong? Or point me in the direction of an easier way of doing this?
Thanks in advance!
I'm having trouble writing a script that can make a target camera orbit it's target at a set distance and add keyframes at every 10degree increment.
Here is the process the script should create:
Place camera above target at around 600mm away
rotate camera through 360 degrees and add a keyframe at every 10 degree increment
drop camera by 10 degrees and repeat step 2 till camera is at very bottom of target
Here is the code I have so far, it just doesn't seem to work as expected.
When the camera is at the top it sits there stationary for 36 frames.
cam = TargetCamera target:(targetObject pos:[0,0,0]) pos:[0,0,600];
fn rotateCamera hAngle vAngle = (
hAngle = (90 - hAngle);
x = cam.Target.pos[1] + (cos(hAngle) * sin(vAngle) * cam.targetDistance);
y = cam.Target.pos[2] + (sin(hAngle) * sin(vAngle) * cam.targetDistance);
z = cam.Target.pos[3] + (cos(vAngle) * cam.targetDistance);
return [x,y,z];
)
count = 0;
for v = 0 to 180 by 10 do (
for h = 0 to 350 by 10 do (
at time count animate on cam.pos = rotateCamera (350 - h) v;
count = count + 1;
)
)
Could anybody tell me where I am going wrong? Or point me in the direction of an easier way of doing this?
Thanks in advance!
