|
From: Gordon K. <kin...@us...> - 2004-05-10 19:27:40
|
Update of /cvsroot/teem/teem/src/limn In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13197 Modified Files: cam.c hestLimn.c limn.h methodsLimn.c Log Message: added two new fields to the limnCamera, "fov" and "aspect", augmented the semantics of limnCameraUpdate, and made an effort to fix/debug the limnCameraPathMake() function. "fov" is like the "fovy" argument to gluPerspective()- the angle in degrees vertically subtended by the view window, and "aspect" is the ratio of horizontal to vertical size of the view window. Now, when limCameraUpdate() is called, it will see if both fov and aspect are set (non-NaN), and if so will update uRange[] and vRange[] accordingly. Otherwise, uRange[] and vRange[] will not be touched. limnCameraPathMake is not a new function, but it never worked usefully. Index: methodsLimn.c =================================================================== RCS file: /cvsroot/teem/teem/src/limn/methodsLimn.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** methodsLimn.c 13 Feb 2004 22:57:30 -0000 1.12 --- methodsLimn.c 10 May 2004 19:27:25 -0000 1.13 *************** *** 44,47 **** --- 44,51 ---- cam->orthographic = limnDefCameraOrthographic; cam->rightHanded = limnDefCameraRightHanded; + cam->uRange[0] = cam->uRange[1] = AIR_NAN; + cam->vRange[0] = cam->vRange[1] = AIR_NAN; + cam->fov = AIR_NAN; + cam->aspect = AIR_NAN; } return; Index: hestLimn.c =================================================================== RCS file: /cvsroot/teem/teem/src/limn/hestLimn.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** hestLimn.c 7 Jan 2004 15:34:30 -0000 1.8 --- hestLimn.c 10 May 2004 19:27:24 -0000 1.9 *************** *** 36,39 **** --- 36,40 ---- ** ur: cam->uRange ** vr: cam->vRange + ** fv: cam->fov */ void *************** *** 41,45 **** char *frDef, char *atDef, char *upDef, char *dnDef, char *diDef, char *dfDef, ! char *urDef, char *vrDef) { hestOpt *hopt; --- 42,46 ---- char *frDef, char *atDef, char *upDef, char *dnDef, char *diDef, char *dfDef, ! char *urDef, char *vrDef, char *fvDef) { hestOpt *hopt; *************** *** 68,71 **** --- 69,74 ---- hestOptAdd(&hopt, "vr", "vMin vMax", airTypeDouble, 2, 2, cam->vRange, vrDef, "range in V direction of image plane"); + hestOptAdd(&hopt, "fv", "field of view", airTypeDouble, 1, 1, &(cam->fov), + fvDef, "angle (in degrees) vertically subtended by view window"); *hoptP = hopt; return; Index: limn.h =================================================================== RCS file: /cvsroot/teem/teem/src/limn/limn.h,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** limn.h 29 Mar 2004 21:27:39 -0000 1.52 --- limn.h 10 May 2004 19:27:24 -0000 1.53 *************** *** 63,68 **** uRange[2], /* range of U values to put on horiz. image axis */ vRange[2], /* range of V values to put on vert. image axis */ ! neer, faar, /* neer and far clipping plane distances ! (misspelled for the sake of McRosopht) */ dist; /* distance to image plane */ int atRelative, /* if non-zero: given neer, faar, and dist --- 63,74 ---- uRange[2], /* range of U values to put on horiz. image axis */ vRange[2], /* range of V values to put on vert. image axis */ ! fov, /* if non-NaN, and aspect is non-NaN, then {u,v}Range ! will be set accordingly by limnCameraUpdate(). ! "fov" is the angle, in degrees, vertically subtended ! by the view window */ ! aspect, /* the ratio of horizontal to vertical size of the ! view window */ ! neer, faar, /* near and far clipping plane distances ! (misspelled for the sake of a McRosopht compiler) */ dist; /* distance to image plane */ int atRelative, /* if non-zero: given neer, faar, and dist *************** *** 321,325 **** limnCameraPathTrackAt, /* 2: 3-D spline for *at* points, quaternion spline for directions back to camera */ ! limnCameraPathTrackBoth, /* 3: 2 3-D splines: one for from, one for at */ limnCameraPathTrackLast }; --- 327,332 ---- limnCameraPathTrackAt, /* 2: 3-D spline for *at* points, quaternion spline for directions back to camera */ ! limnCameraPathTrackBoth, /* 3: three 3-D splines: for from point, at ! point, and the up vector */ limnCameraPathTrackLast }; *************** *** 362,365 **** --- 369,375 ---- TEEM_API int limnDefCameraRightHanded; + /* enumsLimn.c */ + TEEM_API airEnum *limnCameraPathTrack; + /* qn.c */ TEEM_API int limnQNBins[LIMN_QN_MAX+1]; *************** *** 369,373 **** TEEM_API int (*limnVtoQN_d[LIMN_QN_MAX+1])(double *vec); - /* light.c */ TEEM_API void limnLightSet(limnLight *lit, int which, int vsp, --- 379,382 ---- *************** *** 399,405 **** char *frDef, char *atDef, char *upDef, char *dnDef, char *diDef, char *dfDef, ! char *urDef, char *vrDef); /* cam.c */ TEEM_API int limnCameraUpdate(limnCamera *cam); TEEM_API int limnCameraPathMake(limnCamera *cam, int numFrames, --- 408,416 ---- char *frDef, char *atDef, char *upDef, char *dnDef, char *diDef, char *dfDef, ! char *urDef, char *vrDef, char *fvDef); /* cam.c */ + TEEM_API int limnCameraAspectSet(limnCamera *cam, + int horz, int vert, int centering); TEEM_API int limnCameraUpdate(limnCamera *cam); TEEM_API int limnCameraPathMake(limnCamera *cam, int numFrames, *************** *** 409,413 **** limnSplineTypeSpec *posType, limnSplineTypeSpec *distType, ! limnSplineTypeSpec *uvType); /* obj.c */ --- 420,424 ---- limnSplineTypeSpec *posType, limnSplineTypeSpec *distType, ! limnSplineTypeSpec *viewType); /* obj.c */ Index: cam.c =================================================================== RCS file: /cvsroot/teem/teem/src/limn/cam.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** cam.c 7 Jan 2004 15:34:30 -0000 1.19 --- cam.c 10 May 2004 19:27:24 -0000 1.20 *************** *** 24,28 **** ******** limnCameraUpdate() ** ! ** sets in cam: W2V matrix, vspNeer, vspFaar, vspDist ** ** This does use biff to describe problems with camera settings --- 24,29 ---- ******** limnCameraUpdate() ** ! ** sets in cam: W2V, V2W, U, V, N, vspNeer, vspFaar, vspDist ! ** and, if fov and aspect are set, this also sets uRange and vRange ** ** This does use biff to describe problems with camera settings *************** *** 30,47 **** int limnCameraUpdate(limnCamera *cam) { ! char me[] = "limnCameraUpdate", err[129]; ! double len, l[4], u[4], v[4], n[4], T[16], R[16]; ! ELL_4V_SET(u, 0, 0, 0, 0); ! ELL_4V_SET(v, 0, 0, 0, 0); ! ELL_4V_SET(n, 0, 0, 0, 0); ! ELL_4V_SET(l, 0, 0, 0, 1); ! ELL_3V_SUB(n, cam->at, cam->from); ! len = ELL_3V_LEN(n); if (!len) { ! sprintf(err, "%s: cam->at (%g,%g,%g) == cam->from (%g,%g,%g)\n", me, ! cam->at[0], cam->at[1], cam->at[2], ! cam->from[0], cam->from[1], cam->from[2]); biffAdd(LIMN, err); return 1; } --- 31,51 ---- int limnCameraUpdate(limnCamera *cam) { ! char me[] = "limnCameraUpdate", err[AIR_STRLEN_MED]; ! double len, bb[4], uu[4], vv[4], nn[4], TT[16], RR[16]; ! if (!cam) { ! sprintf(err, "%s: got NULL pointer", me); ! biffAdd(LIMN, err); return 1; ! } ! ELL_4V_SET(uu, 0, 0, 0, 0); ! ELL_4V_SET(vv, 0, 0, 0, 0); ! ELL_4V_SET(nn, 0, 0, 0, 0); ! ELL_4V_SET(bb, 0, 0, 0, 1); ! ELL_3V_SUB(nn, cam->at, cam->from); ! len = ELL_3V_LEN(nn); if (!len) { ! sprintf(err, "%s: cam->at (%g,%g,%g) == cam->from", me, ! cam->at[0], cam->at[1], cam->at[2]); biffAdd(LIMN, err); return 1; } *************** *** 59,95 **** } if (!(cam->vspNeer > 0 && cam->vspDist > 0 && cam->vspFaar > 0)) { ! sprintf(err, "%s: eye-relative near (%g), dist (%g), or far (%g) <= 0\n", me, cam->vspNeer, cam->vspDist, cam->vspFaar); biffAdd(LIMN, err); return 1; } if (!(cam->vspNeer <= cam->vspFaar)) { ! sprintf(err, "%s: eye-relative near (%g) further than far (%g)\n", me, cam->vspNeer, cam->vspFaar); biffAdd(LIMN, err); return 1 ; } ! ELL_3V_SCALE(n, 1.0/len, n); ! ELL_3V_CROSS(u, n, cam->up); ! len = ELL_3V_LEN(u); if (!len) { ! sprintf(err, "%s: cam->up is co-linear with view direction\n", me); biffAdd(LIMN, err); return 1 ; } ! ELL_3V_SCALE(u, 1.0/len, u); if (cam->rightHanded) { ! ELL_3V_CROSS(v, n, u); } else { ! ELL_3V_CROSS(v, u, n); } ! ELL_4V_COPY(cam->U, u); ! ELL_4V_COPY(cam->V, v); ! ELL_4V_COPY(cam->N, n); ! ELL_4M_TRANSLATE_SET(T, -cam->from[0], -cam->from[1], -cam->from[2]); ! ELL_4M_ROWS_SET(R, u, v, n, l); ! ELL_4M_MUL(cam->W2V, R, T); ! ELL_4M_COPY(T, cam->W2V); ! ell_4m_inv_d(cam->V2W, T); return 0; --- 63,117 ---- } if (!(cam->vspNeer > 0 && cam->vspDist > 0 && cam->vspFaar > 0)) { ! sprintf(err, "%s: eye-relative near (%g), dist (%g), or far (%g) <= 0", me, cam->vspNeer, cam->vspDist, cam->vspFaar); biffAdd(LIMN, err); return 1; } if (!(cam->vspNeer <= cam->vspFaar)) { ! sprintf(err, "%s: eye-relative near (%g) further than far (%g)", me, cam->vspNeer, cam->vspFaar); biffAdd(LIMN, err); return 1 ; } ! if (AIR_EXISTS(cam->fov)) { ! if (!( AIR_IN_OP(0.0, cam->fov, 180.0) )) { ! sprintf(err, "%s: cam->fov (%g) not in valid range between 0 and 180", ! me, cam->fov); ! biffAdd(LIMN, err); return 1 ; ! } ! if (!AIR_EXISTS(cam->aspect)) { ! sprintf(err, "%s: cam->fov set, but cam->aspect isn't", me); ! biffAdd(LIMN, err); return 1; ! } ! /* "fov" is half vertical angle */ ! cam->vRange[0] = -tan(cam->fov*AIR_PI/360)*(cam->vspDist); ! cam->vRange[1] = -cam->vRange[0]; ! cam->uRange[0] = cam->vRange[0]*(cam->aspect); ! cam->uRange[1] = -cam->uRange[0]; ! } ! /* else cam->fov isn't set, but we're not going to complain if ! uRange and vRange aren't both set ... */ ! ! ELL_3V_SCALE(nn, 1.0/len, nn); ! ELL_3V_CROSS(uu, nn, cam->up); ! len = ELL_3V_LEN(uu); if (!len) { ! sprintf(err, "%s: cam->up is co-linear with view direction", me); biffAdd(LIMN, err); return 1 ; } ! ELL_3V_SCALE(uu, 1.0/len, uu); if (cam->rightHanded) { ! ELL_3V_CROSS(vv, nn, uu); } else { ! ELL_3V_CROSS(vv, uu, nn); } ! ELL_4V_COPY(cam->U, uu); ! ELL_4V_COPY(cam->V, vv); ! ELL_4V_COPY(cam->N, nn); ! ELL_4M_TRANSLATE_SET(TT, -cam->from[0], -cam->from[1], -cam->from[2]); ! ELL_4M_ROWS_SET(RR, uu, vv, nn, bb); ! ELL_4M_MUL(cam->W2V, RR, TT); ! ell_4m_inv_d(cam->V2W, cam->W2V); return 0; *************** *** 97,134 **** /* ******** limnCameraPathMake ** ! ** the atRelative, orthographic, and rightHanded fields are used from ! ** keycam[0], and those fields are ignored for all other keycam[i] */ int limnCameraPathMake(limnCamera *cam, int numFrames, ! limnCamera *keycam, double *time, ! int numKeys, int trackFrom, limnSplineTypeSpec *quatType, limnSplineTypeSpec *posType, limnSplineTypeSpec *distType, ! limnSplineTypeSpec *uvType) { char me[]="limnCameraPathMake", err[AIR_STRLEN_MED]; char which[AIR_STRLEN_MED]; airArray *mop; ! Nrrd *nquat, *npos, *ndist, *nuv, *ntime, *nsample; ! double fratVec[3], *quat, *pos, *dist, *uv, W2V[9], N[3], fratDist; ! limnSpline *timeSpline, *quatSpline, *posSpline, *distSpline, *uvSpline; limnSplineTypeSpec *timeType; ! int ii; ! if (!( cam && keycam && time ! && quatType && posType && distType && uvType )) { sprintf(err, "%s: got NULL pointer", me); biffAdd(LIMN, err); return 1; } ! /* create and allocate nrrds */ mop = airMopNew(); airMopAdd(mop, nquat = nrrdNew(), (airMopper)nrrdNuke, airMopAlways); ! airMopAdd(mop, npos = nrrdNew(), (airMopper)nrrdNuke, airMopAlways); airMopAdd(mop, ndist = nrrdNew(), (airMopper)nrrdNuke, airMopAlways); ! airMopAdd(mop, nuv = nrrdNew(), (airMopper)nrrdNuke, airMopAlways); airMopAdd(mop, ntime = nrrdNew(), (airMopper)nrrdNix, airMopAlways); if (nrrdWrap(ntime, time, nrrdTypeDouble, 1, numKeys)) { --- 119,233 ---- /* + ******** limnCameraAspectSet + ** + ** simply sets the "aspect" field of the cam. Note that calling this + ** does *not* automatically mean that the uRange and vRange in the camera + ** will be set according to the "fov"- the "fov" has to actually be set + ** (be non-NaN) for that to happen. This allows dumber functions to + ** call this whenever they have the information required to do so, even + ** if the "aspect" is not going to be needed for a given camera use + */ + int + limnCameraAspectSet(limnCamera *cam, int horz, int vert, int centering) { + char me[] = "limnCameraAspectSet", err[AIR_STRLEN_MED]; + + if (!cam) { + sprintf(err, "%s: got NULL pointer", me); + biffAdd(LIMN, err); return 1; + } + if (!( horz > 0 && vert > 0 )) { + sprintf(err, "%s: bad image dimensions %dx%d", me, horz, vert); + biffAdd(LIMN, err); return 1; + } + if (airEnumValCheck(nrrdCenter, centering)) { + sprintf(err, "%s: centering %d not valid", me, centering); + biffAdd(LIMN, err); return 1; + } + + if (nrrdCenterCell == centering) { + cam->aspect = ((double)horz)/vert; + } else { + cam->aspect = ((double)(horz-1))/(vert-1); + } + + return 0; + } + + /* ******** limnCameraPathMake ** ! ** uses limnSplines to do camera paths based on key-frames ! ** ! ** output: cameras at all "numFrames" frames are set in the ! ** PRE-ALLOCATED array of output cameras, "cam". ! ** ! ** input: an array of keyframe cameras "keycam", and times associated ! ** with the key frames "time", both arrays length "numKeys" ! ** trackWhat: takes values from the limnCameraPathTrack* enum ! ** quatType: spline to control camera orientations. This is needed for ! ** tracking at or from, but not needed for limnCameraPathTrackBoth ! ** This is the only limnSplineTypeSpec* argument that can be NULL ! ** posType: spline to control whichever of from, at, and up are needed for ! ** the given style of tracking ! ** distType: spline to control neer, faar, dist: positions of near clipping, ! ** far clipping, and image plane, as well as the ! ** distance between from and at (which is used if not doing ! ** limnCameraPathTrackBoth) ! ** viewType: spline to control fov (and aspect, if you're crazy) ! ** ! ** NOTE: The "atRelative", "orthographic", and "rightHanded" fields ! ** are used from keycam[0], and those fields are ignored for all other ! ** keycam[i]. Also, for the sake of simplicity, this only works with ! ** fov and aspect, instead of {u,v}Range, and hence both "fov" and "aspect" ! ** need to set in *all* the keycams, even if neither of them ever changes! */ int limnCameraPathMake(limnCamera *cam, int numFrames, ! limnCamera *keycam, double *time, int numKeys, ! int trackWhat, limnSplineTypeSpec *quatType, limnSplineTypeSpec *posType, limnSplineTypeSpec *distType, ! limnSplineTypeSpec *viewType) { char me[]="limnCameraPathMake", err[AIR_STRLEN_MED]; char which[AIR_STRLEN_MED]; airArray *mop; ! Nrrd *nquat, *nfrom, *natpt, *nupvc, *ndist, *nfova, *ntime, *nsample; ! double fratVec[3], *quat, *from, *atpt, *upvc, *dist, *fova, ! W2V[9], N[3], fratDist; ! limnSpline *timeSpline, *quatSpline, *fromSpline, *atptSpline, *upvcSpline, ! *distSpline, *fovaSpline; limnSplineTypeSpec *timeType; ! int ii, E; ! if (!( cam && keycam && time && posType && distType && viewType )) { sprintf(err, "%s: got NULL pointer", me); biffAdd(LIMN, err); return 1; } + if (!( AIR_IN_OP(limnCameraPathTrackUnknown, trackWhat, + limnCameraPathTrackLast) )) { + sprintf(err, "%s: trackWhat %d not in valid range [%d,%d]", me, + trackWhat, limnCameraPathTrackUnknown+1, + limnCameraPathTrackLast-1); + biffAdd(LIMN, err); return 1; + } + if (limnCameraPathTrackBoth != trackWhat && !quatType) { + sprintf(err, "%s: need the quaternion limnSplineTypeSpec if not " + "doing trackBoth", me); + biffAdd(LIMN, err); return 1; + } ! /* create and allocate nrrds. For the time being, we're allocating ! more different nrrds, and filling their contents, than we need ! to-- nquat is not needed if we're doing limnCameraPathTrackBoth, ! for example. However, we do make an effort to only do the spline ! evaluation on the things we actually need to know. */ mop = airMopNew(); airMopAdd(mop, nquat = nrrdNew(), (airMopper)nrrdNuke, airMopAlways); ! airMopAdd(mop, nfrom = nrrdNew(), (airMopper)nrrdNuke, airMopAlways); ! airMopAdd(mop, natpt = nrrdNew(), (airMopper)nrrdNuke, airMopAlways); ! airMopAdd(mop, nupvc = nrrdNew(), (airMopper)nrrdNuke, airMopAlways); airMopAdd(mop, ndist = nrrdNew(), (airMopper)nrrdNuke, airMopAlways); ! airMopAdd(mop, nfova = nrrdNew(), (airMopper)nrrdNuke, airMopAlways); airMopAdd(mop, ntime = nrrdNew(), (airMopper)nrrdNix, airMopAlways); if (nrrdWrap(ntime, time, nrrdTypeDouble, 1, numKeys)) { *************** *** 140,153 **** airMopAdd(mop, timeType, (airMopper)limnSplineTypeSpecNix, airMopAlways); if (nrrdMaybeAlloc(nquat, nrrdTypeDouble, 2, 4, numKeys) ! || nrrdMaybeAlloc(npos, nrrdTypeDouble, 2, 3, numKeys) || nrrdMaybeAlloc(ndist, nrrdTypeDouble, 2, 4, numKeys) ! || nrrdMaybeAlloc(nuv, nrrdTypeDouble, 2, 4, numKeys)) { sprintf(err, "%s: couldn't allocate buffer nrrds", me); biffMove(LIMN, err, NRRD); airMopError(mop); return 1; } quat = (double*)(nquat->data); ! pos = (double*)(npos->data); dist = (double*)(ndist->data); ! uv = (double*)(nuv->data); /* check cameras, and put camera information into nrrds */ --- 239,256 ---- airMopAdd(mop, timeType, (airMopper)limnSplineTypeSpecNix, airMopAlways); if (nrrdMaybeAlloc(nquat, nrrdTypeDouble, 2, 4, numKeys) ! || nrrdMaybeAlloc(nfrom, nrrdTypeDouble, 2, 3, numKeys) ! || nrrdMaybeAlloc(natpt, nrrdTypeDouble, 2, 3, numKeys) ! || nrrdMaybeAlloc(nupvc, nrrdTypeDouble, 2, 3, numKeys) || nrrdMaybeAlloc(ndist, nrrdTypeDouble, 2, 4, numKeys) ! || nrrdMaybeAlloc(nfova, nrrdTypeDouble, 2, 2, numKeys)) { sprintf(err, "%s: couldn't allocate buffer nrrds", me); biffMove(LIMN, err, NRRD); airMopError(mop); return 1; } quat = (double*)(nquat->data); ! from = (double*)(nfrom->data); ! atpt = (double*)(natpt->data); ! upvc = (double*)(nupvc->data); dist = (double*)(ndist->data); ! fova = (double*)(nfova->data); /* check cameras, and put camera information into nrrds */ *************** *** 157,160 **** --- 260,267 ---- biffAdd(LIMN, err); airMopError(mop); return 1; } + if (!( AIR_EXISTS(keycam[ii].fov) && AIR_EXISTS(keycam[ii].aspect) )) { + sprintf(err, "%s: fov, aspect not both defined on keyframe %d", me, ii); + biffAdd(LIMN, err); airMopError(mop); return 1; + } ell_4m_to_q_d(quat + 4*ii, keycam[ii].W2V); if (ii) { *************** *** 163,178 **** } } ! if (trackFrom) { ! ELL_3V_COPY(pos + 3*ii, keycam[ii].from); ! } else { ! ELL_3V_COPY(pos + 3*ii, keycam[ii].at); ! } ELL_3V_SUB(fratVec, keycam[ii].from, keycam[ii].at); ELL_4V_SET(dist + 4*ii, ELL_3V_LEN(fratVec), keycam[ii].neer, keycam[ii].dist, keycam[ii].faar); ! ELL_4V_SET(uv + 4*ii, ! keycam[ii].uRange[0], keycam[ii].uRange[1], ! keycam[ii].vRange[0], keycam[ii].vRange[1]); } --- 270,281 ---- } } ! ELL_3V_COPY(from + 3*ii, keycam[ii].from); ! ELL_3V_COPY(atpt + 3*ii, keycam[ii].at); ! ELL_3V_COPY(upvc + 3*ii, keycam[ii].up); ELL_3V_SUB(fratVec, keycam[ii].from, keycam[ii].at); ELL_4V_SET(dist + 4*ii, ELL_3V_LEN(fratVec), keycam[ii].neer, keycam[ii].dist, keycam[ii].faar); ! ELL_2V_SET(fova + 2*ii, keycam[ii].fov, keycam[ii].aspect); } *************** *** 180,189 **** if (!( (strcpy(which, "quaternion"), quatSpline = limnSplineCleverNew(nquat, limnSplineInfoQuaternion, quatType)) ! && (strcpy(which, "position"), posSpline = ! limnSplineCleverNew(npos, limnSplineInfo3Vector, posType)) ! && (strcpy(which, "distance"), distSpline = limnSplineCleverNew(ndist, limnSplineInfo4Vector, distType)) ! && (strcpy(which, "uvRange"), uvSpline = ! limnSplineCleverNew(nuv, limnSplineInfo4Vector, uvType)) && (strcpy(which, "time warp"), timeSpline = limnSplineCleverNew(ntime, limnSplineInfoScalar, timeType)) )) { --- 283,296 ---- if (!( (strcpy(which, "quaternion"), quatSpline = limnSplineCleverNew(nquat, limnSplineInfoQuaternion, quatType)) ! && (strcpy(which, "from point"), fromSpline = ! limnSplineCleverNew(nfrom, limnSplineInfo3Vector, posType)) ! && (strcpy(which, "at point"), atptSpline = ! limnSplineCleverNew(natpt, limnSplineInfo3Vector, posType)) ! && (strcpy(which, "up vector"), upvcSpline = ! limnSplineCleverNew(nupvc, limnSplineInfo3Vector, posType)) ! && (strcpy(which, "plane distances"), distSpline = limnSplineCleverNew(ndist, limnSplineInfo4Vector, distType)) ! && (strcpy(which, "field-of-view"), fovaSpline = ! limnSplineCleverNew(nfova, limnSplineInfo2Vector, viewType)) && (strcpy(which, "time warp"), timeSpline = limnSplineCleverNew(ntime, limnSplineInfoScalar, timeType)) )) { *************** *** 192,214 **** } airMopAdd(mop, quatSpline, (airMopper)limnSplineNix, airMopAlways); ! airMopAdd(mop, posSpline, (airMopper)limnSplineNix, airMopAlways); airMopAdd(mop, distSpline, (airMopper)limnSplineNix, airMopAlways); ! airMopAdd(mop, quatSpline, (airMopper)limnSplineNix, airMopAlways); airMopAdd(mop, timeSpline, (airMopper)limnSplineNix, airMopAlways); /* evaluate splines */ ! if (limnSplineSample(nsample, timeSpline, limnSplineMinT(timeSpline), ! numFrames, limnSplineMaxT(timeSpline)) ! || limnSplineNrrdEvaluate(nquat, quatSpline, nsample) ! || limnSplineNrrdEvaluate(npos, posSpline, nsample) ! || limnSplineNrrdEvaluate(ndist, distSpline, nsample) ! || limnSplineNrrdEvaluate(nuv, uvSpline, nsample)) { sprintf(err, "%s: trouble evaluating splines", me); biffAdd(LIMN, err); airMopError(mop); return 1; } - quat = (double*)(nquat->data); - pos = (double*)(npos->data); - dist = (double*)(ndist->data); - uv = (double*)(nuv->data); /* copy information from nrrds back into cameras */ --- 299,350 ---- } airMopAdd(mop, quatSpline, (airMopper)limnSplineNix, airMopAlways); ! airMopAdd(mop, fromSpline, (airMopper)limnSplineNix, airMopAlways); ! airMopAdd(mop, atptSpline, (airMopper)limnSplineNix, airMopAlways); ! airMopAdd(mop, upvcSpline, (airMopper)limnSplineNix, airMopAlways); airMopAdd(mop, distSpline, (airMopper)limnSplineNix, airMopAlways); ! airMopAdd(mop, fovaSpline, (airMopper)limnSplineNix, airMopAlways); airMopAdd(mop, timeSpline, (airMopper)limnSplineNix, airMopAlways); /* evaluate splines */ ! E = AIR_FALSE; ! if (!E) E |= limnSplineSample(nsample, timeSpline, ! limnSplineMinT(timeSpline), numFrames, ! limnSplineMaxT(timeSpline)); ! quat = NULL; ! from = NULL; ! atpt = NULL; ! upvc = NULL; ! switch(trackWhat) { ! case limnCameraPathTrackAt: ! if (!E) E |= limnSplineNrrdEvaluate(natpt, atptSpline, nsample); ! if (!E) atpt = (double*)(natpt->data); ! if (!E) E |= limnSplineNrrdEvaluate(nquat, quatSpline, nsample); ! if (!E) quat = (double*)(nquat->data); ! break; ! case limnCameraPathTrackFrom: ! if (!E) E |= limnSplineNrrdEvaluate(nfrom, fromSpline, nsample); ! if (!E) from = (double*)(nfrom->data); ! if (!E) E |= limnSplineNrrdEvaluate(nquat, quatSpline, nsample); ! if (!E) quat = (double*)(nquat->data); ! break; ! case limnCameraPathTrackBoth: ! if (!E) E |= limnSplineNrrdEvaluate(nfrom, fromSpline, nsample); ! if (!E) from = (double*)(nfrom->data); ! if (!E) E |= limnSplineNrrdEvaluate(natpt, atptSpline, nsample); ! if (!E) atpt = (double*)(natpt->data); ! if (!E) E |= limnSplineNrrdEvaluate(nupvc, atptSpline, nsample); ! if (!E) upvc = (double*)(nupvc->data); ! break; ! } ! dist = NULL; ! if (!E) E |= limnSplineNrrdEvaluate(ndist, distSpline, nsample); ! if (!E) dist = (double*)(ndist->data); ! fova = NULL; ! if (!E) E |= limnSplineNrrdEvaluate(nfova, fovaSpline, nsample); ! if (!E) fova = (double*)(nfova->data); ! if (E) { sprintf(err, "%s: trouble evaluating splines", me); biffAdd(LIMN, err); airMopError(mop); return 1; } /* copy information from nrrds back into cameras */ *************** *** 217,237 **** cam[ii].orthographic = keycam[0].orthographic; cam[ii].rightHanded = keycam[0].rightHanded; ! ell_q_to_3m_d(W2V, quat + 4*ii); ! ELL_3MV_ROW1_GET(cam[ii].up, W2V); ! if (cam[ii].rightHanded) { ! ELL_3V_SCALE(cam[ii].up, -1, cam[ii].up); ! } ! ELL_3MV_ROW2_GET(N, W2V); ! ELL_4V_GET(fratDist, cam[ii].neer, cam[ii].dist, cam[ii].faar, ! dist + 4*ii); ! if (trackFrom) { ! ELL_3V_COPY(cam[ii].from, pos + 3*ii); ! ELL_3V_SCALE_ADD2(cam[ii].at, 1.0, cam[ii].from, fratDist, N); } else { ! ELL_3V_COPY(cam[ii].at, pos + 3*ii); ! ELL_3V_SCALE_ADD2(cam[ii].from, 1.0, cam[ii].at, -fratDist, N); } ! ELL_4V_GET(cam[ii].uRange[0], cam[ii].uRange[1], ! cam[ii].vRange[0], cam[ii].vRange[1], uv + 4*ii); if (limnCameraUpdate(cam + ii)) { sprintf(err, "%s: trouble with output camera %d\n", me, ii); --- 353,381 ---- cam[ii].orthographic = keycam[0].orthographic; cam[ii].rightHanded = keycam[0].rightHanded; ! if (limnCameraPathTrackBoth == trackWhat) { ! ELL_3V_COPY(cam[ii].from, from + 3*ii); ! ELL_3V_COPY(cam[ii].at, atpt + 3*ii); ! ELL_3V_COPY(cam[ii].up, upvc + 3*ii); } else { ! fratDist = (dist + 4*ii)[0]; ! ell_q_to_3m_d(W2V, quat + 4*ii); ! ELL_3MV_ROW1_GET(cam[ii].up, W2V); ! if (cam[ii].rightHanded) { ! ELL_3V_SCALE(cam[ii].up, -1, cam[ii].up); ! } ! ELL_3MV_ROW2_GET(N, W2V); ! if (limnCameraPathTrackFrom == trackWhat) { ! ELL_3V_COPY(cam[ii].from, from + 3*ii); ! ELL_3V_SCALE_ADD2(cam[ii].at, 1.0, cam[ii].from, fratDist, N); ! } else { ! ELL_3V_COPY(cam[ii].at, atpt + 3*ii); ! ELL_3V_SCALE_ADD2(cam[ii].from, 1.0, cam[ii].at, -fratDist, N); ! } } ! cam[ii].neer = (dist + 4*ii)[1]; ! cam[ii].dist = (dist + 4*ii)[2]; ! cam[ii].faar = (dist + 4*ii)[3]; ! cam[ii].fov = (fova + 2*ii)[0]; ! cam[ii].aspect = (fova + 2*ii)[1]; if (limnCameraUpdate(cam + ii)) { sprintf(err, "%s: trouble with output camera %d\n", me, ii); |