Little Signs of Life
Things are coming along nicely with the PFD so far.
Currently, I am pulling the bank and pitch angle.
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
struct Struct1
{
public float bankangle;
public float pitchangle;
};
simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Bank Degrees", "radians", SIMCONNECT_DATATYPE.FLOAT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Pitch Degrees", "radians", SIMCONNECT_DATATYPE.FLOAT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
After that, it's all pretty simple.
I've got three layers of texture, although, technically, it could be two. The first the large brown horizon, on top of that is a "glass ball" texture (using alpha to make it partially transparent) that includes the center marks, and the top black mask layer that frames it all.
Then it's just a matter of moving and rotating the horizon based on the angles that simconnect is sending me. The program runs at 60fps, and I've got FSX at 20fps, so I send really only get an update once every 3 frames on the client side, but it still looks smooth enough.
The core of the Update function is this:
RotationAngle = 0;
KeyboardState keyboardState = Keyboard.GetState();
if (keyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape))
{
Exit();
}
else
{
rotpasstrans = (float)hWindow.rotpass;
RotationAngle = rotpasstrans;
float switchPitch = (float)hWindow.pitchpass * -600.0f;
horizonPos.Y = (Window.ClientBounds.Width / 2.0f)+ switchPitch;
}
It's a bit messy, but it does the work.
Here's a screenshot of the PFD in action, chirping along (2048x800)

As you can see, it can use some polish and tuning, but for the most part, it's working perfectly. The next step is going to be sizing everything down a bit to make room for more stuff, and then adding the angle of attack registration lines, bank indicator at the top of the artificial horizon, and then the fun stuff: Heading indicator, and the speed and altitude tape.
I have an idea on how to do that, but it most certainly will not be as easy as I think it will.
I want to throw out a huge show of support for ZiggyWare for their wonderfully easy to use XNAFont tutorial. Although you don't see it there, I have been using it for debug purposes.
They have some great stuff going on over there, so I suggest checking out the tutorials if you want to get started from the ground floor on XNA programming.
More to come tomorrow, when I attempt to break everything.
Currently, I am pulling the bank and pitch angle.
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
struct Struct1
{
public float bankangle;
public float pitchangle;
};
simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Bank Degrees", "radians", SIMCONNECT_DATATYPE.FLOAT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Pitch Degrees", "radians", SIMCONNECT_DATATYPE.FLOAT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
After that, it's all pretty simple.
I've got three layers of texture, although, technically, it could be two. The first the large brown horizon, on top of that is a "glass ball" texture (using alpha to make it partially transparent) that includes the center marks, and the top black mask layer that frames it all.
Then it's just a matter of moving and rotating the horizon based on the angles that simconnect is sending me. The program runs at 60fps, and I've got FSX at 20fps, so I send really only get an update once every 3 frames on the client side, but it still looks smooth enough.
The core of the Update function is this:
RotationAngle = 0;
KeyboardState keyboardState = Keyboard.GetState();
if (keyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape))
{
Exit();
}
else
{
rotpasstrans = (float)hWindow.rotpass;
RotationAngle = rotpasstrans;
float switchPitch = (float)hWindow.pitchpass * -600.0f;
horizonPos.Y = (Window.ClientBounds.Width / 2.0f)+ switchPitch;
}
It's a bit messy, but it does the work.
Here's a screenshot of the PFD in action, chirping along (2048x800)

As you can see, it can use some polish and tuning, but for the most part, it's working perfectly. The next step is going to be sizing everything down a bit to make room for more stuff, and then adding the angle of attack registration lines, bank indicator at the top of the artificial horizon, and then the fun stuff: Heading indicator, and the speed and altitude tape.
I have an idea on how to do that, but it most certainly will not be as easy as I think it will.
I want to throw out a huge show of support for ZiggyWare for their wonderfully easy to use XNAFont tutorial. Although you don't see it there, I have been using it for debug purposes.
They have some great stuff going on over there, so I suggest checking out the tutorials if you want to get started from the ground floor on XNA programming.
More to come tomorrow, when I attempt to break everything.
Labels: FSX, SimConnect, XNA
4 Comments:
Just out of curiosity, how do you get that "SimConnect Diagnostics" window? Is it part of the SDK?
Just out of curiosity, how do you get that "SimConnect Diagnostics" window? Is it part of the SDK?
Anonymous,
If you have the simconnect.ini file in your My Documents\Flight Simulator X Files folder, (you can find the file in the SDK directory, under Core Utilities Kit/SimConnect SDK/config) there's a line called "console" which by default is set to yes. This turns on the console when you launch FSX.
This is what mine looks like:
[SimConnect]
level=verbose
console=1
;RedirectStdOutToConsole=1
;OutputDebugString=1
;file=c:\simconnect%03u.log
;file_next_index=0
;file_max_index=9
Hi,
great work, I learned a lot from your tutorials! Is it possible to have a look at the code of the PFD? I'm trying to get something similar up and running - but I'm a beginner with C#.
Thanks in advance, cheers
tcs
Post a Comment
<< Home