• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Creating Custom Camera Views

Yes I have that also - exception 1 is ERROR - thanks Microsoft.

You can find a list in the simconnect.h file in the SDK folder.

C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Core Utilities Kit\SimConnect SDK\inc

I made this from an example - I'm not sure if the order I am doing things is correct. Use debug to figure out where its sending the exception.
 
Ok - change the Mapinputeventtoclientevent to:

Code:
                simconnect.MapInputEventToClientEvent(INPUT_GROUPS.INPUT0, "VK_PERIOD", EVENTS.CAMERA_RIGHT, (uint)0, EVENTS.CAMERA_RIGHT, (uint)0, false);
                simconnect.MapInputEventToClientEvent(INPUT_GROUPS.INPUT0, "VK_COMMA", EVENTS.CAMERA_LEFT, (uint)0, EVENTS.CAMERA_LEFT, (uint)0, false);

Seems the code I gave you did not really work right - now it rotates rather than pans.
 
Hey...your changes fixed the two errors I was getting...now when I click connect it just shows 'Connected to FSX'.

Update:

(1) I see those two updates you gave me (the VK_PERIOD and VK_COMMA) let me pan the camera right and left and I can see the changes in real time inside the cockpit. Very cool. So then, now I will be able to add my other axis buttons to move the camera up and down, etc.

(2) I wonder why the code calls moving the camera left and right 'bank'? There is a bank property as part of those 6 arguments of the 6DOF() function but I don't think of bank when moving something left or right. Seems a bit odd to me.

(3) Do you know why when you press the . key the actual value displays twice?

This is my modified code - changing only 1.0 at a time vs 5.0 but see the screen shot showing 2 units changed for each key press? I was expecting to see only 1.0 unit change per key press.

case (uint)EVENTS.CAMERA_RIGHT:
//cameraBank = normalize180(cameraBank + 5.0f);
cameraBank = normalize180(cameraBank + 1.0f);
// needs to be fully qualified - because library has it as static
simconnect.CameraSetRelative6DOF(0.0f, 0.0f, 0.0f, Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD, Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD, cameraBank);
displayText("\nCamera Bank = " + cameraBank);
break;

case (uint)EVENTS.CAMERA_LEFT:
//cameraBank = normalize180(cameraBank - 5.0f);
cameraBank = normalize180(cameraBank - 1.0f);
simconnect.CameraSetRelative6DOF(0.0f, 0.0f, 0.0f, Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD, Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD, cameraBank);
displayText("\nCamera Bank = " + cameraBank);
break;
 

Attachments

  • 25.png
    25.png
    1.3 KB · Views: 469
Last edited:
Ok, glad to hear it.

I mostly work in C++, and a little in C#. I've been reviewing the

MapInputEventToClientEvent and here are a few things I have found.

1. The types in C# don't always reflect the same size for C++.

We are getting errors because I was trying to use null for SimConnect.SIMCONNECT_UNUSED. Which is what you are suppose to use - hence the exception. So I told you to add in a second Events.CAMERA_LEFT. This satisfied the type, but now you get two camera_lefts for every key - one for key down and one for key up.

SimConnect.SIMCONNECT_UNUSED was also giving me an error.

Have to make SimConnect.SIMCONNECT_UNUSED a uint type.

So at the beginning of the code near the add:

Code:
        uint unused = SimConnect.SIMCONNECT_UNUSED;

2. enum in C# are also not the same as C++ you have to make the enum a specific size - so change enum to enum : uint.

eg:
Code:
        enum EVENTS : uint
        {
            PITOT_TOGGLE,
            FLAPS_INC,
            FLAPS_DEC,
            FLAPS_UP,
            FLAPS_DOWN,
            CAMERA_RIGHT,
            CAMERA_LEFT,
            CAMERA_FORWARD,
            CAMERA_BACK,
        };


Now we can get rid of the extra key up event and replace with unused. Cast the unused event to the EVENTS enum. here is the code with extra keys to move forward and back.

Code:
                // Define private events
                simconnect.MapClientEventToSimEvent(EVENTS.CAMERA_BACK, "EYEPOINT_BACK");
                simconnect.MapClientEventToSimEvent(EVENTS.CAMERA_FORWARD, "EYEPOINT_FORWARD");
                simconnect.MapClientEventToSimEvent(EVENTS.CAMERA_LEFT, "EYEPOINT_LEFT");
                simconnect.MapClientEventToSimEvent(EVENTS.CAMERA_RIGHT, "EYEPOINT_RIGHT");

                simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.CAMERA_BACK, false);
                simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.CAMERA_FORWARD, false);
                simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.CAMERA_LEFT, false);
                simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.CAMERA_RIGHT, false);

                // Map the keys , and . keys to the private events
                simconnect.MapInputEventToClientEvent(INPUT_GROUPS.INPUT0, "VK_PERIOD", EVENTS.CAMERA_RIGHT, (uint)0, (EVENTS)unused, (uint)0, (bool)false);
                simconnect.MapInputEventToClientEvent(INPUT_GROUPS.INPUT0, "VK_COMMA", EVENTS.CAMERA_LEFT, (uint)0, (EVENTS)unused, (uint)0, (bool)false);
                simconnect.MapInputEventToClientEvent(INPUT_GROUPS.INPUT0, "VK_SLASH", EVENTS.CAMERA_FORWARD, (uint)0, (EVENTS)unused, (uint)0, (bool)false);
                simconnect.MapInputEventToClientEvent(INPUT_GROUPS.INPUT0, "M", EVENTS.CAMERA_BACK, (uint)0, (EVENTS)unused, (uint)0, (bool)false);

3. camerabank is just a variable name - they did an example for left right but may have started as bank left right
 
Good progress Ron. I've got camera left/right and forward/back working pretty well.

I've coded for pitch up/down and it does work but it's very 'jumpy'. I press the U key and cockpit image flickers twice before it stops (and correctly increments the f value). Same for the D down key: cockpit image flickers twice and then moves down correctly.

The other camera movements move without this flicker or jumpy image so I can't see yet what is causing this pitch flicker.

simconnect.MapClientEventToSimEvent(EVENTS.CAMERA_BACK, "EYEPOINT_BACK");
simconnect.MapClientEventToSimEvent(EVENTS.CAMERA_FORWARD, "EYEPOINT_FORWARD");
simconnect.MapClientEventToSimEvent(EVENTS.CAMERA_LEFT, "EYEPOINT_LEFT");
simconnect.MapClientEventToSimEvent(EVENTS.CAMERA_RIGHT, "EYEPOINT_RIGHT");
simconnect.MapClientEventToSimEvent(EVENTS.CAMERA_PITCH_UP, "EYEPOINT_UP");
simconnect.MapClientEventToSimEvent(EVENTS.CAMERA_PITCH_DOWN, "EYEPOINT_DOWN");

simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.CAMERA_BACK, false);
simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.CAMERA_FORWARD, false);
simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.CAMERA_LEFT, false);
simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.CAMERA_RIGHT, false);
simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.CAMERA_PITCH_UP, false);
simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.CAMERA_PITCH_DOWN, false);

// Map the keys , and . keys to the private events
simconnect.MapInputEventToClientEvent(INPUT_GROUPS.INPUT0, "VK_PERIOD", EVENTS.CAMERA_RIGHT, (uint)0, (EVENTS)unused, (uint)0, (bool)false);
simconnect.MapInputEventToClientEvent(INPUT_GROUPS.INPUT0, "VK_COMMA", EVENTS.CAMERA_LEFT, (uint)0, (EVENTS)unused, (uint)0, (bool)false);
simconnect.MapInputEventToClientEvent(INPUT_GROUPS.INPUT0, "VK_SLASH", EVENTS.CAMERA_FORWARD, (uint)0, (EVENTS)unused, (uint)0, (bool)false);
simconnect.MapInputEventToClientEvent(INPUT_GROUPS.INPUT0, "M", EVENTS.CAMERA_BACK, (uint)0, (EVENTS)unused, (uint)0, (bool)false);
simconnect.MapInputEventToClientEvent(INPUT_GROUPS.INPUT0, "U", EVENTS.CAMERA_PITCH_UP, (uint)0, (EVENTS)unused, (uint)0, (bool)false);
simconnect.MapInputEventToClientEvent(INPUT_GROUPS.INPUT0, "D", EVENTS.CAMERA_PITCH_DOWN, (uint)0, (EVENTS)unused, (uint)0, (bool)false);


case (uint)EVENTS.CAMERA_LEFT:
cameraPanLeft = normalize180(cameraPanLeft - 1.0f);
simconnect.CameraSetRelative6DOF(0.0f, 0.0f, cameraForward, cameraPitchUp, cameraBankLeft, cameraPanLeft);
displayText("\nCamera Left = " + cameraPanLeft);
cameraPanRight = cameraPanLeft;
break;

case (uint)EVENTS.CAMERA_RIGHT:
cameraPanRight = normalize180(cameraPanRight + 1.0f);
simconnect.CameraSetRelative6DOF(0.0f, 0.0f, cameraForward, cameraPitchUp, cameraBankLeft, cameraPanRight);
displayText("\nCamera Right = " + cameraPanRight);
cameraPanLeft = cameraPanRight;
break;

case (uint)EVENTS.CAMERA_PITCH_UP:
cameraPitchUp = normalize180(cameraPitchUp - 0.5f);
simconnect.CameraSetRelative6DOF(0.0f, 0.0f, cameraForward, cameraPitchUp, cameraBankLeft, cameraPanLeft);
displayText("\nCamera Pitch Up = " + cameraPitchUp);
cameraPitchDown = cameraPitchUp;
break;

case (uint)EVENTS.CAMERA_PITCH_DOWN:
cameraPitchDown = normalize180(cameraPitchDown + 0.5f);
simconnect.CameraSetRelative6DOF(0.0f, 0.0f, cameraForward, cameraPitchDown, cameraBankLeft, cameraPanLeft);
displayText("\nCamera Pitch Down = " + cameraPitchDown);
cameraPitchUp = cameraPitchDown;
break;
 
The EYEPOINT_UP and EYEPOINT_DOWN are x,y,z not pitch bank heading. So you have to use something different. If you don't set any values you will see rgw eye points more left, right up down and forward and back. The example may be mixed up. Will need to figure things out.

edit

pitch is only between +-90

also make sure values you don't change are set to:

Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD

this keeps the same existing value. See the SDK
 
Last edited:
Hmmm...OK....where does it tell me which EYEPOINTS are for xyz vs pbh? The SimConnect SDK manual?

In testing, I inserted my button clicks for each one of the x y z axis and saw this VC behavior:
x == left/right movement but outside of the cockpit (I wanted left/right inside but I'll try to figure this one out later).
y == Up/Down movement but outside of the cockpit (again I wanted that for inside but I'll try to figure this one out later).
z == Forward/Backward seems to work fine inside the cockpit.

p == pitch up/down (works but 'jumps' so I will look at your reply and try to figure this one out).
b == bank left/right (works ok inside the cockpit)
h == heading in degrees (works ok inside the cockpit)

Update: I'm reading the (1) Aircraft Configuration Files technical document from Microsoft and their (2) Camera Configuration document and the DOF syntax:

SimConnect_CameraSetRelative6DOF(
HANDLE hSimConnect,
float fDeltaX,
float fDeltaY,
float fDeltaZ,
float fPitchDeg,
float fBankDeg,
float fHeadingDeg
);

I guess where I'm still lost is what is the difference between the deltaX,Y,Z values and the P,B,H values? I read about these in the above referenced documents but they don't explain what their differences are?

Are the X,Y,Z values camera references for outside of the cockpit and the P,B,H values for inside the cockpit? I just don't 'see the light' yet with these 6 DOF arguments.

Thank you...
 
Last edited:
This example leaves a bit to be desired.

Camerabank should have been labeled cameraheading. +-180 degrees. x,y,z are for moving the camera from it's current eye position (see aircraft.cfg) which is also relative to the reference datum which is assumed to be relative to another reference.

pitch - is move head up down
bank - tilt head
heading - rotate head

6 degrees of freedom.

Note the arguments for x,y,z are delta - so everytime you put a value in the first three (edit - thats probably wrong)- it increments by that amount. It's not an absolute value (I think). So you need to use Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD for the values that don't change. I'm not sure about the pbh ones.

It's all very confusing. I'll continue playing with the values and see if I can make any sense out of all this.
 
Last edited:
Here is a new example for the camera view move. (I have removed the previous zip file from the other post)

The important thing is to ensure you use

Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD

to ensure it does not use existing values to increment view position.

example code:

Code:
                case (uint)EVENTS.CAMERA_PITCHDOWN:

                    cameraPitch = normalize90(cameraPitch - 5.0f);

                    simconnect.CameraSetRelative6DOF(Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
                        Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
                        Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
                        cameraPitch,
                        Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
                        Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD);

                    //displayText("\nCamera Bank = %f", cameraBank);
                    break;
In the above code the event pitch down only changes the pitch value, the rest don't affect the camera.
 

Attachments

Last edited:
Thank you Ron...I'll try this out tonite.

I see from your photo your flying what looks like a real airplane...are you a real pilot vs a flight simmer enthusiast?
 
Yes I am a private pilot 30 years. C-152, C-172, C-172RG , DA-20, DA-40. Flying is expensive, so a lot of Sim time and less real time.
 
Very nice...yes it is expensive...I don't fly real airplanes anymore...I'm in Los Angeles and flew out of southern California airports for about 30 years too...
 
Oh California..... I would love to be able to fly out west. Ontario, Canada is pretty flat. Do any mountain flying?
 
I'm attaching my Form1.cs as a zip file.

I've got the first 3 DOF() delta values coded in. The c# variables and c# constants follow the DOF() argument sequence and I've given them more meaningful names (to me at least so I can keep them straight in my head lol).

I'm only testing the first 3 delta values and camera dolly up/down and camera dolly left/right seem to be working OK but camera dolly forward/back doesn't work.

I'm using the term Dolly for these first 3 values because I think of the camera as being mounted on a dolly and that's how the camera moves: physically moves up or down in the cockpit or left/right or fwd/back, just as if you were pushing or pulling the camera dolly around to get your desired view. Please correct me if I'm wrong in using this analogy of camera 'Dolly' for these first 3 DOF() values.

I want to work on the last 3 DOF() arguments once I get the dolly views working. The last 3 values, again, to my mind, are the Lens position: pitch up/down, bank left/right and heading in degrees left or right around the cockpit. I think of these 3 values as simply moving the camera itself, on the dolly, while the dolly does not move.

Thank you...
 

Attachments

Got it,

You Hollywood types - Dolly forward ... dolly back:duck:That's a rap - I'm ready for my close-up Mr. DeMille

Since the xyz dolly is not a angle you should not use the normalize (+-180). - Also I think the x,y,z is in feet. - so .02 feet - is 12 * .02 = .24 inches. Make it a bit bigger. I'm not at my development computer right now.
 
OK, I removed the normalized() call in the dolly moves and made some small adjustments in the rates of movement and now the X,Y,Z values are working as I expect and as I want. I may add some variables to choose from to change the rates later on but what is there works for now.

Here is my current 'dolly' code:

case (uint)EVENTS.CAMERA_DOLLY_LEFT:
cameraDollyLeftRight = cameraDollyLeftRight - 0.005f;
simconnect.CameraSetRelative6DOF(cameraDollyLeftRight,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD);
break;

case (uint)EVENTS.CAMERA_DOLLY_RIGHT:
cameraDollyLeftRight = cameraDollyLeftRight + 0.005f;
simconnect.CameraSetRelative6DOF(cameraDollyLeftRight,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD);
break;

case (uint)EVENTS.CAMERA_DOLLY_UP:
cameraDollyUpDown = cameraDollyUpDown + 0.005f;
simconnect.CameraSetRelative6DOF(Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
cameraDollyUpDown,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD);
break;

case (uint)EVENTS.CAMERA_DOLLY_DOWN:
cameraDollyUpDown = cameraDollyUpDown - 0.005f;
simconnect.CameraSetRelative6DOF(Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
cameraDollyUpDown,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD);
break;

case (uint)EVENTS.CAMERA_DOLLY_FORWARD:
cameraDollyForwardBack = cameraDollyForwardBack + 0.02f;
simconnect.CameraSetRelative6DOF(Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
cameraDollyForwardBack,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD);
break;

case (uint)EVENTS.CAMERA_DOLLY_BACK:
cameraDollyForwardBack = cameraDollyForwardBack - 0.02f;
simconnect.CameraSetRelative6DOF(Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
cameraDollyForwardBack,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD,
Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_CAMERA_IGNORE_FIELD);
break;

I do notice that when I hold the key the camera moves repeatedly but after about 2 to 3 secs it stops. I'm not sure why that happens...maybe a buffer is getting filled up? I read some where that I can set a value to make the camera movement stay moving once you press the key so I will look that up and play around with that just to learn about that feature.

So, next up for me is to get into the P,B,H values and try to get those working as well. Then I think I'll have it!

Thanks for all the help and pointers Ron.
 
I fly Lionheart's DA-40, Caranedo 17(8)2RG and the DA-42. One day I will take the DA-42 out for real. Where did I put that Lottery Ticket!!
 
Back
Top