Cool Steve, looks like we're on the same page
Nah, it just means I'll have to adjust my "ears" to fit yours exactly once you release it!
I know there's a better way and I'm stuck on a problem, perhaps some of you math/3d coordinate geniuses could help me out!
The problem is this: Apparently how the renderman spec works is that instead of moving and rotating the camera around the coordinate system, the entire coordinate system moves and rotates around the camera.
So I need help reverse calculating the camera's position and orientation and instead applying it to the 3D coordinate system. I've been looking up math formulas online but the stuff is just flying right over my head and I have yet to find something with all factors tied in...any pointers would be a great help.
If you guys are interested, here's some sample code to play with if you have ideas on how to turn it into the right equations and such:
shape $shape, $Cameras;
point3 $location, $CamRot;
int $width, $height;
float $FOV, $nearClip, $farClip;
/* Objects were sorted out beforehand and */
/* this chunk of code deals with the camera */
if ($Cameras.size == 1)
$shape = $Cameras.pop();
/* Since I couldn't read parameters from parametric shapes, */
/* I made the shape embed the data into the uv coords, and */
/* it gets read by the export script */
/* Get meshdata and read the UV coords as parameters*/
$mdata = $shape.GetMeshData();
$uv = $mdata.GetTexCoord(0);
$width = $uv.x;
$height = $uv.y;
$uv = $mdata.GetTexCoord(1);
$FOV = $uv.x;
$nearClip = $uv.y;
$uv = $mdata.GetTexCoord(2);
$farClip = $uv.x;
/* Our camera's location and orientation */
$location = $shape.loc;
$orientation = $shape.orientation;
/* Code to convert the rotation quaternion into euler */
/* Special thanks to Leslie's post at */
/* http://www.anim8or.com/ubb/Forum1/HTML/014922.html */
$CamRot = (-atan2(2*$orientation.x*$orientation.w-2*$orientation.y*$orientation.z , 1 - 2*$orientation.x*$orientation.x - 2*$orientation.z*$orientation.z),
-atan2(2*$orientation.y*$orientation.w-2*$orientation.x*$orientation.z , 1 - 2*$orientation.y*$orientation.y - 2*$orientation.z*$orientation.z),
-asin(2*($orientation.x*$orientation.y + $orientation.z*$orientation.w)));
/* Convert from radians to degrees */
$CamRot = ($CamRot.x*(180/PI), $CamRot.y*(180/PI), $CamRot.z*(180/PI));
So pretty much the main things you have to work with is the point3 $location which is the x,y,z coordinates of the camera's origin, and the point3 $CamRot which is the x,y,z rotation for the camera. So now we have to pretend that the camera is the one staying still and instead the entire world around the camera is moving and rotating around it. Of course if it's easier then the quaternions can be worked on before being converted to eulers.
Note that all other shapes already have their relative offsets and rotations applied to them (via float4x4 transform matrix).
The way the camera/coordinate system in .rib files is written out is:
Translate X Y ZThe coordinate system moves to that position away from the camera
Rotate [Angle] X Y ZI can't really tell if this is equal to an axis angle system or just eulers. Put in the angle it rotated on an axis, and set 1 for the axis it represents and 0 for the others. So if rotating the entire world 45 degrees on the X-axis, you do "Rotate 45 1 0 0"
Any hints, links or just plain solving would be greatly appreciated, and of course I'll give you credit in the script like I'm doing for Leslie