SDK Question moveing cockpit camera

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,708
Reaction score
2,683
Points
203
Location
Dallas, TX
I think I have done this before.

But in the cockpit view I want to have the camera follow an animation. I have an tip that does follow the animation. But when I switch to that view it does not move. One thing I did notice is if I switch from F1 to external and back the direction has changed but the position has not.


For testing I have the direction set straight up.
void FLEXARM::SelectCockpitView(int CAMVIEW) { switch (CAMVIEW) { case 0: //LEFT SetCameraOffset(_V(0, 1.0, -1.4)); // Set camera position (x,y,z) SetCameraDefaultDirection(_V(0, 0, 1)); oapiCameraSetCockpitDir(0, 0); break; case 1: //CAMMAST SetCameraOffset(CAM_tip[0]); // Set camera position (x,y,z) SetCameraDefaultDirection(_V(0, 0, 1)); oapiCameraSetCockpitDir(0, 0); break; case 2: //BACK SetCameraOffset(_V(-.901, -.082, 1.5)); SetCameraDefaultDirection(_V(0, 0, 1)); oapiCameraSetCockpitDir(0, 0); break; case 3: //BACK SetCameraOffset(_V(.901, -.082, 1.5)); SetCameraDefaultDirection(_V(0, 0, 1)); oapiCameraSetCockpitDir(0, 0); break; case 4: //BACK SetCameraOffset(_V(-.901, -.082, -1.5)); SetCameraDefaultDirection(_V(0, 0, -1)); oapiCameraSetCockpitDir(0, 0); break; case 5: //BACK SetCameraOffset(_V(.901, -.082, -1.5)); SetCameraDefaultDirection(_V(0, 0, -1)); oapiCameraSetCockpitDir(0, 0); break; } } here:CAM_tip[0] is the where the camera view should be. It does move with the animation. But when I switch to that view it does not change

and then the key function to switch the view:
if (key == OAPI_KEY_W) { SelectCockpitView(CAMVIEW); CAMVIEW = CAMVIEW + 1; if (CAMVIEW > 5) CAMVIEW = -1; return 1; }
and then in the poststep
void FLEXARM::clbkPostStep(double simt, double simdt, double mjd) { SelectCockpitView(CAMVIEW);
 

BrianJ

Addon Developer
Addon Developer
Joined
Apr 19, 2008
Messages
1,678
Reaction score
902
Points
128
Location
Code 347
From the SAL EVA guy code......

C-like:
SetCameraDefaultDirection(new_dir, 0);
oapiCameraSetCockpitDir(0,0);
SetCameraOffset(new_pos);

if(oapiGetFocusObject () == GetHandle())
    {
    if(oapiCameraMode() == CAM_COCKPIT)oapiCameraAttach(GetHandle(), 2);
    }
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,708
Reaction score
2,683
Points
203
Location
Dallas, TX
Thanks. I will try it. I wonder how the direction is determined. I will look at the code.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,708
Reaction score
2,683
Points
203
Location
Dallas, TX
void FLEXARM::SelectCockpitView(int CAMVIEW) { switch (CAMVIEW) { case 0: //LEFT SetCameraOffset(_V(0, 1.0, -1.4)); // Set camera position (x,y,z) SetCameraDefaultDirection(_V(0, 0, 1)); oapiCameraSetCockpitDir(0, 0); break; case 1: //CAMMAST 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;

so have this. and it works
 
Top