SDK Question Camerasetup for Idiots :D

Inspired

New member
Joined
Jun 10, 2014
Messages
8
Reaction score
0
Points
0
Hey guys,

can someone tell me how to set up 2 Cameras?
I don't understand how it works the right way.
I have no Cockpit grafics like 2D Panels or a 3D Cockpit.
(Still a looong way to understand how 2D/3D Panels are working)
So, for the moment I just want a 2nd camera position inside my vessel.
Like one cam outside my vessel (0,10,10) and a 2nd one inside it (0,0,0).
Which functions do i need to define to use my Stuff coded in ConsumeBufferedKey?

For simple testing, i defined 2 cameras in ConsumeBufferedKey
Code:
if (key == OAPI_KEY_V)
		{
			CAM = CAM + 1;
			if (CAM > 2)
			{
				CAM = 1;
			}

			if (CAM == 1)
			{
				SetCameraOffset (_V(0,10,10));
				SetCameraDefaultDirection(_V(0,0,1));
				oapiCameraSetCockpitDir (0,0);
			}
			if (CAM == 2)
			{
				SetCameraOffset (_V(0,0,0));
				SetCameraDefaultDirection(_V(0,0,1));
				oapiCameraSetCockpitDir (0,0);
			}
		}

And i definded a standard camera (i think it is?) like this:

Code:
bool MyVessel::clbkLoadGenericCockpit ()
{
SetCameraOffset (_V(0,0,10));
SetCameraDefaultDirection(_V(0,0,1));
return true;
}

BUT nothing works and i canot figure out why. I already read many,many posts here, but none gave me the answer i need.
So maby someone could give me a short tutorial or some instructions on how to set up a very basic camera? I'm now trying on it since 4 or 5 days, getting a bit frustrated by it....
 
So what happens? I pm you and can help out with some code
 
My problem is, that nothing happens.
If i press "v" for the first time, i can set the standard direction of the standard cam once, eg. from z direction to x direction.
But just, if i reduce my code to just 1 cam setup in the clbkConsumeBufferedKey
Now, if i use my mouse to rotate the view anywhere else, or zoom, or whatever,
"v" doesn't work anymore. Nothing happens if i press it a 2nd,3rd,4th... time.
The change in camera offset isn't recognized in any of those cases.
 
Has "CAM" been initialized elsewhere in your code? What happens if CAM <= 0?

If you are only having two cameras in your vessel I'd recomend a boolean or bool equivelent to gaurd against such issues. For instance

if (dockingview)
{
set docking camera specs
}
else
{
set default camera specs
}

or

Code:
if (CAM != 1)
{
CAM = 0;
set camera specs
}
else
{
set other camera specs
}

Finally I would point out that if you are using more than two camera angles that this is a really good place to use a switch in conjunction with a custom void.

For instance...

Code:
void InspiredSpacecraft9000::SetCameraView ()
{
   switch (CAM)
   {
      case 1:
      set camera one specs
      break;

      case 2:
      set camera two specs
      break;

      default: // AKA all other cases
      set default camera specs
      CAM = 0;
      break;
   }
}
then all you need in clbkConsumeBufferedKey is

Code:
if (key == OAPI_KEY_V  &&!KEYMOD_SHIFT(kstate) && !KEYMOD_CONTROL (kstate) && !KEYMOD_ALT(kstate))
{
CAM++;
SetCameraView ();
return 1;
}
}
 
I managed it to get different cameras in my szenario with help of gattispilot.
Many thanks for this!!! :cheers:
I set my mesh visability to "always".
Now, i press F1 and i'm inside my vessel. Here i can see the mesh in the cams positioned in (0,0,0) (Look forward, left, right -> Cam 1,2,3).
If i switch to cam4 located in (0,0,-25), i can't see my mesh anymore.
The cam moves outside of the vessel, but the mesh is gone somehow...
How can i get my mesh "back" in cam4 view mode?

This is all my cam code at the moment.
SelectCockpitView is proper defined in my header.

Code:
void TIEFighter::clbkSetClassCaps(FILEHANDLE cfg)
{
	CAM=1;
	SetMeshVisibilityMode(idx, MESHVIS_ALWAYS);
        ......
}


Code:
void TIEFighter::SelectCockpitView (int CAM)
{
	if (CAM==1) 
	{
		SetCameraDefaultDirection (_V(0,0,1));
		SetCameraOffset (_V(0,0,0));
		oapiCameraSetCockpitDir (0,0);
	}

	if (CAM==2)
	{
		SetCameraDefaultDirection (_V(0.7,0,0.7));
		SetCameraOffset (_V(0,0,1));
		oapiCameraSetCockpitDir (0,0);
	}
	if (CAM==3)
	{
		SetCameraDefaultDirection (_V(-0.7,0,0.7));
		SetCameraOffset (_V(0,0,0));
		oapiCameraSetCockpitDir (0,0);
	}
		if (CAM==4)
	{
		SetCameraDefaultDirection (_V(0,0,1));
		SetCameraOffset (_V(0,0,-25));
		oapiCameraSetCockpitDir (0,0);
	}
}

Code:
int TIEFighter::clbkConsumeBufferedKey(DWORD key , bool down, char *kstate)
{
	if(key==OAPI_KEY_V && down == true )
	{
		CAM = CAM + 1;
		if(CAM > 4) 
			CAM = 1;
		SelectCockpitView(CAM);
		return 1;
	} 
        .......


---------- Post added at 08:35 AM ---------- Previous post was at 12:14 AM ----------

Problem solved with:
Code:
SetMeshVisibilityMode(idx, MESHVIS_ALWAYS | MESHVIS_EXTPASS);

Huge thanks to Gattispilot :hail: :cheers:
 
Back
Top