SDK Question clbkLoadVC how to set camera after a change of the center of gravity ?

Woodylepic

New member
Joined
Dec 29, 2009
Messages
71
Reaction score
0
Points
0
I have add 4 VC Camera in my 2 stage rocket but when a stage separation occur and the center of gravity change (whit ShiftCG) the Vc Camera do not fallow the mesh position ?
I have read that the camera was supposed to fallow the mesh position when I use ShiftCG is this true ? what I have to do to get the camera to fallow the mesh ?


bool A_001::clbkLoadVC (int id)
{
switch (id) {


case 0: // CM camera
SetCameraOffset (_V(0, 0, 7.361));

oapiCameraSetCockpitDir(0,0);
oapiVCSetNeighbours (-1,-1, -1, 1);
campos = CAM_VCPSNGR1;
break;

case 1: // cockpit
SetCameraOffset (_V(0,1.982,4.824));
oapiCameraSetCockpitDir(0,0);
oapiVCSetNeighbours (-1, -1, 0, 2);
campos = CAM_VCPSNGR2;
break;

case 2: // SM camera
SetCameraOffset (_V(0, 0, 1.202));
oapiCameraSetCockpitDir(0,0);
oapiVCSetNeighbours (-1, -1, 1, 3);
campos = CAM_VCPSNGR3;
break;


case 3: // LES camera
SetCameraOffset (_V(0,0,8.652));
oapiCameraSetCockpitDir(0*RAD,180*RAD);
oapiVCSetNeighbours (-1, -1, 2, -1);
campos = CAM_VCPSNGR4;
returntrue;

default:
returnfalse;
}
 
Last edited:
Since you set the camera offset every time the VC is loaded, it overrides any change that ShiftCG makes. You need to put some conditionals in clbkLoadVC for when the vehicle is staged or not.
 
Thank you I finaly got the camera update whit the shift cog,
But there an other problem ?, when the stagin is done my VC view change to a wrong position, I have to switch the camera view to get the camera updated to the correct position, Is there a way to refresch automaticaly the vc camera whene a stagin is done ? Thank you.

bool A_001::clbkLoadVC (int id)//virtual cockpit
{
switch (id) {

case 0: // CM camera
SetCameraOffset (_V(orbiter_ofs.x+0,orbiter_ofs.y+0,orbiter_ofs.z+7.361));
oapiCameraSetCockpitDir(0,0);
oapiVCSetNeighbours (-1,-1, -1, 1);
campos = CAM_VCPSNGR1;
break;//terminate the switch

case 1: // cockpit
SetCameraOffset (_V(orbiter_ofs.x+0,orbiter_ofs.y+1.982,orbiter_ofs.z+4.824));
oapiCameraSetCockpitDir(0,0);
//SetCameraDefaultDirection (_V(0,0,1)); // forward
oapiVCSetNeighbours (-1, -1, 0, 2);
campos = CAM_VCPSNGR2;
break;//terminate the switch

case 2: // SM camera
SetCameraOffset (_V(orbiter_ofs.x+0, orbiter_ofs.y+0, orbiter_ofs.z+1.202));
oapiCameraSetCockpitDir(0,0);
//SetCameraDefaultDirection (_V(0,0,1)); // forward
oapiVCSetNeighbours (-1, -1, 1, 3);
campos = CAM_VCPSNGR3;
break;//terminate the switch


case 3: // LES camera
SetCameraOffset (_V(orbiter_ofs.x+0,orbiter_ofs.y+0,orbiter_ofs.z+8.652));
oapiCameraSetCockpitDir(0*RAD,180*RAD);
//SetCameraDefaultDirection (_V(0,0,-1)); // forward
oapiVCSetNeighbours (-1, -1, 2, -1);
campos = CAM_VCPSNGR4;
break;//terminate the switch
//return true;


default:
return false;
}
return true;
}
void A_001::AddOrbiterVisual (const VECTOR3 &ofs)
{
orbiter_ofs = ofs;
}
 
Last edited:
But there an other problem ?, when the stagin is done my VC view change to a wrong position, I have to switch the camera view to get the camera updated to the correct position, Is there a way to refresch automaticaly the vc camera whene a stagin is done ?
I think you are saying that if the staging occurs whilst you are using the VC camera, ShiftCG does not automatically move the camera for you? :hmm: The only way I can think to resolve that is to maintain a flag that indicates whether or not you are in VC mode and if you are change the camera position (SetCameraOffset) at the same place in your code where you are doing the staging.

As a matter of interest, is the camera position automatically moved by ShiftCG when you are in generic cockpit or panel cockpit modes?
 
I have finaly find the trouble I have forget some element in my visual, I have to set all mesch in separate visual fonction now all the vc camera is static and not changing whit stage sep call :thumbup:

void A_001::AddLESVisual (const VECTOR3 &ofs)
{
if (LJ_A001_LES == MESH_UNDEFINED)
{
LJ_A001_LES = AddMesh (hLJ_A001_LES, &ofs);
SetMeshVisibilityMode (LJ_A001_LES, MESHVIS_ALWAYS);
}
}
void A_001::AddFirst_StageVisual (const VECTOR3 &ofs)
{
if (LJ_A001_First_Stage == MESH_UNDEFINED)
{
LJ_A001_First_Stage = AddMesh (hLJ_A001_First_Stage, &ofs);//ofs first= view
SetMeshVisibilityMode (LJ_A001_First_Stage, MESHVIS_ALWAYS);//Sets the camera position for internal and external view.
}
}
void A_001::Addbp12Visual (const VECTOR3 &ofs)
{
bp12_ofs = ofs;

if (BP12 == MESH_UNDEFINED)
{
BP12 = AddMesh (hBP12, &ofs);
SetMeshVisibilityMode (BP12, MESHVIS_ALWAYS);
SetCameraOffset (_V(ofs.x+0,ofs.y+1.982,ofs.z+4.364));//SetCameraOffset(_V(0,1.982,4.364));
}
}
 
Back
Top