Cameras in trees

New Message Reply Date view Thread view Subject view Author view

Renee Strong (renee++at++pat.mdc.com)
Wed, 17 Nov 93 12:27:41 CST


In our application we have cameras in trees attached to different pieces of
hardware. When a user switches cameras we're going back up through the tree
trying to create the proper matrix for the channel. Are we supposed to be
pre-multiplying, post-multiplying or what? Any help would really be wonderful!

Here's the code:

extern OBJ *cur_camera;
extern pfChannel *cur_channel;
extern pfPipe *cur_pipe;
extern pfScene *scene;

void
change_cams()
{
pfMatrix pos_rot, matrix;
pfMatrix mat;
pfCoord view;
pfDCS *dcs;
CAMERA *camera;

        camera = cur_camera->type_data.camera;
        cur_channel = camera->perf_cam_data;
        dcs = cur_camera->perf_node;

        pfChanNearFar(cur_channel, camera->near, camera->far);
        pfChanFOV(cur_channel, camera->FOV, -1.0f);
    pfGetDCSMatrix(dcs, pos_rot);
/*
 * put in pan and tilt
 */
    pfSetVec3(view.hpr, -camera->pan, 0.0, -camera->tilt);
    pfSetVec3(view.xyz, 0.0, 0.0, 0.0);
    pfMakeCoordMat(matrix, &view);
    pfPreMultMat(pos_rot, matrix);

/*
 * rotate -90 in x because performer is off by 90 degrees in x from gl
 */
    pfSetVec3(view.hpr, 0.0, -90.0, 0.0);
    pfSetVec3(view.xyz, 0.0, 0.0, 0.0);
    pfMakeCoordMat(matrix, &view);
    pfPreMultMat(pos_rot, matrix);

/*
 * put on all the preceding trans and rots
 */
    do
    {
        dcs = (pfDCS *)pfGetParent(dcs, 0);
        pfGetDCSMatrix(dcs, mat);
        pfPreMultMat(pos_rot, mat);
    } while (dcs != root_node->perf_node);

    pfChanViewMat(cur_channel, pos_rot);
    pfChanScene(cur_channel, scene);

}

Thanks,
Renee Strong
renee++at++pat.mdc.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:06 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.