I am trying to get the Perseverance Rover camera to follow the animation.
I am moving an attachment point which is where the camera should be.
I can attach something to it to see if it is correct. And it is. The animation is good. But the camera point of view is off.
I am moving an attachment point which is where the camera should be.
I can attach something to it to see if it is correct. And it is. The animation is good. But the camera point of view is off.
Code:
CAM_tip[0] = _V(.512, 2.1383, .542);//-0.5, -2.1,-.15 x=y y=z z=x.555, .724, .723
CAM_tip[1] = (_V(.512, 2.1383, .542) + _V(0, 1,0));;
CAM_tip[2] = (_V(.512, 2.1383, .542) + _V(.866, 0, 0.5));//1.5, -2.1, -.15
CAMERAVIEW1 = _V(.512, 2.1383, .542);
[\code]
[code]
static UINT CAMMASTGrp[13] = { GRP_HEADBASE1, GRP_HEADBASE2,GRP_HEADBASE3,GRP_HEADBASE4,GRP_HEADBASE5,GRP_HEADBASE6,GRP_HEADBASE7,GRP_HEADBASE8,GRP_HEADBASE9,GRP_HEADBASE10,GRP_HEADBASE11,GRP_HEADBASE12,GRP_HEADBASE13 };//MAST DOWN
CAM_anim[0] = new MGROUP_ROTATE(0, CAMMASTGrp, 13, _V(.5560269, 1.243, .7159711), _V(-.5, 0, .866), (float)(-90 * RAD)); // -2 .. +145
CAMBASEPARENT = AddAnimationComponent(anim_CAMERA, 0, 1, CAM_anim[0]);
//ROTATE CAMERA HEAD
static UINT CAMGrp1[6] = { GRP_HDPIVOT6,GRP_HDPIVOT5,GRP_HDPIVOT4,GRP_HDPIVOT3,GRP_HDPIVOT2,GRP_HDPIVOT1 };//CAMERA ROTATE Z AXIS MAST TOP AND REEL
CAM_anim[1] = new MGROUP_ROTATE(0, CAMGrp1, 6, _V(.556, 1.83665, .714), _V(0, 1, 0), (float)(-360 * RAD)); // -2 .. +145
//anim_CAM_Z = CreateAnimation(0.5);
CAMPARENT = AddAnimationComponent(anim_CAM_Z, 0, 1, CAM_anim[1], CAMBASEPARENT);
//TILT CAMERA HEAD
static UINT CAMGrp2[16] = { GRP_HEADTILT9,GRP_HEADTILT8,GRP_HEADTILT7,GRP_HEADTILT6,GRP_HEADTILT5,GRP_HEADTILT4,GRP_HEADTILT3,GRP_HEADTILT2,GRP_HEADTILT1,GRP_HEADTILT10, GRP_HEADTILT12, GRP_HEADTILT13, GRP_HEADTILT15,GRP_HEADTILT16,GRP_HEADTILT17,GRP_HEADTILT14 };//CAMERA ROTATE Y AXIS
CAM_anim[2] = new MGROUP_ROTATE(0, CAMGrp2, 16, _V(.576, 1.923, .6842173), _V(-.5, 0, .866), (float)(-170 * RAD)); // -2 .. +145
CAMPARENTAZ = AddAnimationComponent(anim_CAM_Y, 0, 1, CAM_anim[2], CAMPARENT);
//anim_CAM_Y = CreateAnimation(0.5);
//MOVE CAMERA WITH ANIMATION
CAM_anim[3] = new MGROUP_ROTATE(LOCALVERTEXLIST, MAKEGROUPARRAY(CAM_tip), 3, CAMERAVIEW1, _V(0, 1, 0), (float)(894 * RAD)); // -447 .. +447
hAC_CAM = AddAnimationComponent(anim_CAMERAVIEW1, 0, 1, CAM_anim[3], CAMPARENTAZ);
[\code]
camera view code
[code]
case 1: //CAMMAST
if (oapiCameraMode() == CAM_COCKPIT) {
oapiDelAnnotation(hNote);
char imstr[256];
strcpy(imstr, "Cam");
VECTOR3 col = _V(0.8, 0.7, 0.1);
hNote = oapiCreateAnnotation(true, 1, col);
oapiAnnotationSetPos(hNote, 0.468, 0.05, 0.66, 0.1);
oapiAnnotationSetText(hNote, imstr);
}
SetCameraOffset(CAM_tip[0]); // Set camera position (x,y,z)
sprintf(oapiDebugString(), "camx %lf camy %lf camz %lf", CAM_tip[0].x, CAM_tip[0].y, CAM_tip[0].z);
SetCameraDefaultDirection(xp1, 0);
// oapiCameraSetCockpitDir(0, 0);
break;
[\code]
here the attachment is moved
[code]
void Perseverance::clbkPostStep(double simt, double simdt, double mjd)
{
SelectCockpitView(CAMVIEW);
xp1 = CAM_tip[1] - CAM_tip[0]; normalise(xp1);
xr1 = CAM_tip[2] - CAM_tip[0]; normalise(xr1);
SetAttachmentParams(CAMERAVIEW, CAM_tip[0], xp1, xr1);
[\code]