• 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

Messages
120
Country
unitedstates
I'd like to write my own app to create and edit my own cockpit VC views. I've read some of the docs on the aircraft.cfg file structure so I know they contain the camera views I will need to create and use.

I don't know if I need to be using SimConnect for this kind of project? It seems to me that what my app needs to do is edit the .cfg file and reload it. I don't think I need SimConnect to do this but I don't know what else I might need to be doing with FSX to make this work.

I'd like to create a new camera view and use my app to set the axis values in real time to see the effects of the changes. I'm not sure what the sequence is to do that. Meaning, do I load the .cfg file into memory and make changes in memory and somehow update FSX in real time? Or so I have to actually save each small edit change to disk and reload the .cfg file before I am able to see the change in real time? Not having done this before, I don't know what the steps are to make this work that way.

I'm not even sure I need to use SimConnect.

Thanks for any help and pointers...
 
I don't think you can get away with not using simconnect unless your program can:

1. determine what aircraft you are flying.
2. able to the open the aircraft.cfg file for that aircraft
3. Then you have to determine what camera you are currently using (i'm not sure how).

The only thing you can change with simconnect as far as the camera is concerned is the 6DOF. x,y,z pitch bank and heading.

What will you do with changing all the other stuff

So you are stuck with what you said - save the config and reload (not sure if there would be an issue of caching or not being able to write the cfg file - due to windows security etc. if you have FSX in the C:\program files folder)

Then there is the camera in sim.cfg, cameras.cfg and the flt file.
 
Hi Ron,

Thanks for the reply.

Here is what I've found out so far:

1. I will need (that is my app will need) to edit the specific aircraft.cfg file and make changes to the x y z p b h values, as you correctly stated. I don't need SimConnect to do that...however, I'm assuming I will be able to find some kind of C# Class to edit that file much like an .ini Class file that exists for windows development. I don't know (yet) if SimConnect has any API calls that allow me to edit specific sections of an aircraft.cfg file. If it does then I'll use that. If it doesn't then I'll have to write my own C# Class to do that.

2. Pete Dowson (the creatr of FSUIPC) told me I can use SimConnect_CameraSetRelative6DOF to make those 6 value edits in real time from my app, which is exactly what is needed, so Ron, you too are again correct.

3. My app will have a list of the aircraft I fly, so I will simply select the target aircraft from the list and will then know which aircraft.cfg file to work with.

4. My app will maintain a list of camera views that can be created, edited and deleted and these will be inserted into the aircraft-specific .cfg file.

5. I will also set a hot key for each view and save those values in an .ini file, related to their respective views.

6. Then I'll have to figure out how to use those hot keys inside FSX to change the views to the key pressed (I don't know how to do that yet but I suspect SimConnect will be involved!).

Thanks again Ron for your reply...
 
I've had a detailed look at the aircraft.cfg file structure and it's the same structure as a windows .ini file...so my app will use an Ini Class that I have used in another app to read and write data to ini files.

So, this issue is now resolved: reading writing to an aircraft.cfg file is now done just like an regular windows .ini file. Progress.

Update: So, what I'm looking for now are some examples of how to install and connect to SimConnect using C#.

Update: I found some instructions on the Microsoft site about how to use SimConnect using C#:

https://msdn.microsoft.com/en-us/library/cc526983.aspx#ProgrammingSimConnectClientsusingCsharp

Ensure that .NET Framework Version 2.0 is installed.
Create a new project using Visual Studio 2005, typically this would be a C# Windows Application, or a VB.NET Windows application.
Add a new reference to Microsoft.ESP.SimConnect in your project. This file can be found in the SDK\Core Utilities Kit\SimConnect SDK\lib\managed folder.
Add the following two lines to the projects' using statements (in C#, note the VB.NET equivalent to using is imports):
using Microsoft.ESP.SimConnect;
using System.Runtime.InteropServices;

I did the above but I get this compile error:
The type or namespace name 'ESP' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

I'm using the reference but I wonder if this error is because I'm using VS 2013 and not VS 2005?
And I'm also using .NET 4.5 and not 2.0?
 
Last edited:
Add the following two lines to the projects' using statements (in C#, note the VB.NET equivalent to using is imports):
using Microsoft.ESP.SimConnect;
using System.Runtime.InteropServices;

I did the above but I get this compile error:
The type or namespace name 'ESP' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

I'm using the reference but I wonder if this error is because I'm using VS 2013 and not VS 2005?
And I'm also using .NET 4.5 and not 2.0?

Do you actually have ESP? - it should be more like FSX.

using Microsoft.FlightSimulator.SimConnect;
using System.Runtime.InteropServices;

another thread here
 
Hmmm...yeah...

using Microsoft.FlightSimulator.SimConnect;

removed the error....guess I didn't have the .ESP. file.

I added this test code snippet from the MS SimConnect site:

// Open
// Declare a SimConnect object
SimConnect simconnect = null;
// User-defined win32 event
const int WM_USER_SIMCONNECT = 0x0402;
try
{
simconnect = new SimConnect("Managed Data Request", this.Handle, WM_USER_SIMCONNECT, null, 0);
}
catch (COMException ex)
{
// A connection to the SimConnect server could not be established
}
// Close
if (simconnect != null)
{
simconnect.Dispose();
simconnect = null;
}

A pretty simple test, but when I enter this code with a button click event, I get this error:

An unhandled exception of type 'System.IO.FileLoadException' occurred in System.Windows.Forms.dll
Additional information: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

I'm not sure what that means?
 
You may be compiling to .NET v 4 or higher.

Try .NET 3.5 or .NET 2

See the program properties - Compile tab and Advanced Compile Options -> target framework. Also make sure target CPU is x86.

You may also need msvcrt80 (VS 2008) on your machine since you are using VS2013. download the redist from microsoft.

edit:

Review any messages in the ouput window - you should see what it is really compiling to.
 
Last edited:
My PC hard disk crashed so I'm going to have to rebuild it. This will take some time.

In the mean time, I have a question regarding which version of Visual Studio should I use for SimConnect development?

I'm going to stick with C# and have read the Microsoft SimConnect SDK notes regarding using C# with SimConnect, so I think I'll be ok with using C#.

The MS SDK notes say I can use any version of VS with C# from 2005 on, but I was wondering if there was a 'preferred' version of Visual Studio to use for this kind of project? Are you recommending when I re-install VS that I use VS 2008?

Thanks...
 
My PC hard disk crashed so I'm going to have to rebuild it. This will take some time.

Oh Ralph ..... Bummer man - sorry to hear of the drive crash.

I am using VS 2010 for both FSX and P3D. I just learned that P3D will be adding/changing so that simconnect will work better with VS2013. There are a few gothchas with 2010 and 2013 when using FSX, but once you find those VS2013 should not be a problem. Your just forced to use older technology .Net 2/3.5 and msvrct 9 or 10 rather than the latest.
 
Hmmm...ok...I'll install VS 2010 and .NET Framework 3.5 then when I get ready to install my new software.

I'm not sure you know the answer to this question re SimConnect, but I'm assuming that when I use the SimConnect_CameraSetRelative6DOF() function that my app will be able to make changes to the target camera view in real time and I'll be able to see those changes as I make them? I plan to be able to click on a Zoom button for example to zoom in bit by bit.

I'm assuming SimConnect_CameraSetRelative6DOF() will allow me to do that and then when I'm happy with the camera view, I can save the changes to the aircraft.cfg file. This is the only way I know of (so far) to be able to see camera view changes in real time...and is the primary reason I am going to use SimConnect.

Thanks...
 
When you get your machine going. I created a 6DOF C# program from the C++ console example. It should point you in the right direction. At first, it confused me - thought the EVENT IDs are CAMERA_LEFT and CAMERA_RIGHT, when it looks like it should be EYEPOINT_LEFT and EYEPOINT_RIGHT. I used the managed code
Managed Client Event sample s a start for the C# program.

Just replace the form1.cs code with the attached (you will have to add two buttons and a rich text box in the form yourself).

Enjoy

edit 2015-05-11
Attachment deleted - new one later in post
 
Last edited:
Be awesome if you get this working. There is a program called Visualizer V1.01 which has the ability to connect to to FSX using sim connect and has force reload aircraft button. So i see no reason you should not be able to make it work. Just make sure when you add your camera views it does not make the cfg all in 1 paragraph and keeps the spaces and format intact.

i always wondered if the visualizer can add red lines live in game it would be cool if you could have a program that loaded more mdl files for aircraft equipment so you could have more than 1 model and use the program to show those items when your in a parked state. It sure would be popular with developers. For example air stairs or GPU units...
 
it would be cool if you could have a program that loaded more mdl files for aircraft equipment so you could have more than 1 model and use the program to show those items when your in a parked state. It sure would be popular with developers. For example air stairs or GPU units...

Hmmm ... this is functionality I can add to my Livingworld program. I could spawn static mdls around the aircraft when parked or when the user hits a key after parking, the mdls get spawned and even follow a path (relative to the aircraft position) to the parked aircraft - this way you can park at any airport and have this happen.

edit:

OR

you could buy GSX
 
Last edited:
GSX looks good. But i am sure it needs info to align to your aircraft like other products that were like this one. With a build in system for each product this new program comes with the aircraft and makes it so the developer can make a lot of extra models without having it all in 1 model file. Build it and i will pay money to use for commercial use!
 
@ronh

I finally got my Win7 machine back together.

I'm trying to run your example you were kind enough to zip up for me. I'm using VS 2010 C# Express.

Update: I got my one error fixed: needed to add using FSX_csCamera6DOF;

I assume I have to have FSX running with a cockpit view showing?

What will this app show me? I see I can connect and disconnect from SimConnect and I see there will be some data displayed in the richTextBox, correct?
 
Last edited:
It's an example of using keys < and > to move the camera view of the current view. You can then get the values of x,y,z etc and store them for your aircraft.cfg. I leave that to you. Add code to display the x,y z values in the rich text box. Then you can copy paste to the aircraft.cfg as a new camera. I'm not really an expert in this camera stuff.
 
Ahhh got it yes...thanks.

I'm getting a .NET 4.0 framework exception when I try to run the sample app you zipped up for me. I got it to compile cleanly but with SFX running when I try to execute the app I get this msg:

An unhandled exception of type 'System.IO.FileLoadException' occurred in CameraTest.exe
Additional information: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

In my Turn Features On and Off all I see is the .NET 3.5 framework. If I try to install .NET 4.0 or .NET 4.5 I get a msg saying this version of .NET is already installed.

I installed VS 2010 C# Express and I also installed VS 2013 C# Express but I only see .NET 3.5.

Perhaps the key here is in that message "...without additional configuration information..."?

Update: Inside VS2013 in the App Settings window I can set various .NET Frameworks from 2.0 all the way up to 4.5.1. So I set 4.0 but still get the exception when I try and run the app. I've set x86 as the target platform, x64 and AnyPlatform but always get the same exception.

I get the same exception in VS 2010 C# as well.

I feel I'm close but this one last barrier is puzzling to me.
 
Last edited:
That fixed it Ron...thanks.

OK, so I ran the small test app with FSX running, clicked the connect button and it connected OK (and pretty fast I must say)...but then the Exceptions 1 and 2 immediately displayed.

1: Connected to FSX
2: Exception received: 1
3: Exception received: 1

I'm looking at the simconnect_OnRecvException() method and see the data.dwException property but I guess it is just saying it's a "1" exception...do you know if there is a list of what these exceptions are?

Thanks again for hanging in there with me!
 
Back
Top