SimConnect Datatypes
I overcame my last issue, with not being able to have an event handler, by nesting a call to open a hidden window in the initialization section, using the handle to that form for the SimConnect constructor. All of the event handlers and setup code for SimConnect stayed within that form's extended class. I kind of like it that way, like it was it's own little transport.
If I were to draw a diagram, the form would be represented by a Mini Cooper S.
With that solved, I moved on to the question of actually displaying my instruments. First up, just the artificial horizon. Two sprites, the blue background and the brown/orange "ground" section, that will move and rotate.
The data I'll be requesting from SimConnect is rather basic so far:
Except, this is wrong.
By following this up with a call to pull in my data, I discovered all sorts of crazy numbers coming through as my bank angle. It didn't make any sense to me, until I looked back and found out the issue. The data type should be SIMCONNECT_DATATYPE.FLOAT32, not FLOAT64. As soon as that happened and my nice 32-bit doubles came flowing in, the horizon was banking beautifully, smooth as silk.
Later today, I'll be adding in the pitch on the horizon and pitch guide lines.
So, that's something to keep in mind if the data you are getting back doesn't make any sense.
If I were to draw a diagram, the form would be represented by a Mini Cooper S.
With that solved, I moved on to the question of actually displaying my instruments. First up, just the artificial horizon. Two sprites, the blue background and the brown/orange "ground" section, that will move and rotate.
The data I'll be requesting from SimConnect is rather basic so far:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]And then I set up my data definition:
struct Struct1
{
public float bankangle;
};
simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Bank Degrees", "radians", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
Except, this is wrong.
By following this up with a call to pull in my data, I discovered all sorts of crazy numbers coming through as my bank angle. It didn't make any sense to me, until I looked back and found out the issue. The data type should be SIMCONNECT_DATATYPE.FLOAT32, not FLOAT64. As soon as that happened and my nice 32-bit doubles came flowing in, the horizon was banking beautifully, smooth as silk.
Later today, I'll be adding in the pitch on the horizon and pitch guide lines.
So, that's something to keep in mind if the data you are getting back doesn't make any sense.
Labels: Artificial Horizon, SimConnect
1 Comments:
Hmm, I don't understand but that probably means you are doing something right.
Post a Comment
<< Home