w800i
08-29-2006, 10:59 PM
hello.
i am trying to create a script for 3ds max to convert a txt file with informations about a camera path in order to create a camera in max. initially i thought that this shouldn't be too hard for somebody who has no experience in maxscript i stumbled upon a problem: the script doesnt read the camera rotation properly.
each line in the text file contains a frame of the camera in the following format:
pos.x pos.y pos.z pitch yaw roll fov
so for example:
2681.052 303.825 292.543 -358.743 167.726 359.968 120.000
the rotation values go from -360 to +360. this could be the first problem as they might switch from -360 to +360 the next frame.
however it isnt the thing that bothers me the most. the camera seems to be totally off. while the position might be ok (not sure) the rotation certainly isnt. i also have to adapt the y and z position to match the 3ds coordinate system and now im unsure whether this affects the pitch and yaw aswell. i've also tried to code a command line application to convert the txt file into a ms file similiar to what boujou outputs. in that app i've used quaternions for the rotation, but still no luck.
hopefully somebody could point me in the right direction. thanks in advance.
this is the script:
function doCamera =
(
fileName = getOpenFileName types:"camera(*.cam)|*.cam|All|*.*|"
if ( fileName == undefined ) do return 0
fileStream = openFile(fileName)
if ( fileStream == undefined) do return 0
theCam = freeCamera()
theCam.fov.controller = bezier_float()
theCam.pos.controller = bezier_position()
theCam.rotation.controller = bezier_rotation()
theTime = 0;
while ( not eof(fileStream)) do (
theLine = readLine( fileStream ) as stringstream;
print theLine
posKey = addNewKey theCam.pos.controller theTime
posKey.value = [ readToken(theLine) as float, readToken(theLine) as float, readToken(theLine) as float ]
anglesKey = addNewKey theCam.rotation.controller theTime
anglesKey.value = eulerAngles (readToken(theLine) as float ) (readToken(theLine) as float) (readToken(theLine) as float)
fovKey = addNewKey theCam.fov.controller theTime
fovKey.value = readToken(theLine) as float
theTime = theTime + 1
)
)
doCamera()
i am trying to create a script for 3ds max to convert a txt file with informations about a camera path in order to create a camera in max. initially i thought that this shouldn't be too hard for somebody who has no experience in maxscript i stumbled upon a problem: the script doesnt read the camera rotation properly.
each line in the text file contains a frame of the camera in the following format:
pos.x pos.y pos.z pitch yaw roll fov
so for example:
2681.052 303.825 292.543 -358.743 167.726 359.968 120.000
the rotation values go from -360 to +360. this could be the first problem as they might switch from -360 to +360 the next frame.
however it isnt the thing that bothers me the most. the camera seems to be totally off. while the position might be ok (not sure) the rotation certainly isnt. i also have to adapt the y and z position to match the 3ds coordinate system and now im unsure whether this affects the pitch and yaw aswell. i've also tried to code a command line application to convert the txt file into a ms file similiar to what boujou outputs. in that app i've used quaternions for the rotation, but still no luck.
hopefully somebody could point me in the right direction. thanks in advance.
this is the script:
function doCamera =
(
fileName = getOpenFileName types:"camera(*.cam)|*.cam|All|*.*|"
if ( fileName == undefined ) do return 0
fileStream = openFile(fileName)
if ( fileStream == undefined) do return 0
theCam = freeCamera()
theCam.fov.controller = bezier_float()
theCam.pos.controller = bezier_position()
theCam.rotation.controller = bezier_rotation()
theTime = 0;
while ( not eof(fileStream)) do (
theLine = readLine( fileStream ) as stringstream;
print theLine
posKey = addNewKey theCam.pos.controller theTime
posKey.value = [ readToken(theLine) as float, readToken(theLine) as float, readToken(theLine) as float ]
anglesKey = addNewKey theCam.rotation.controller theTime
anglesKey.value = eulerAngles (readToken(theLine) as float ) (readToken(theLine) as float) (readToken(theLine) as float)
fovKey = addNewKey theCam.fov.controller theTime
fovKey.value = readToken(theLine) as float
theTime = theTime + 1
)
)
doCamera()
