• 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.

dynamic camera using SimConnect

Messages
29
Country
iran
Hi dear all


can I create a camera in my desire location (lat, long, alt) using simConnect and change its location dynamically?
can I set the bank and pitch of camera?

thanks
 
I believe you can control a camera's pitch bank heading, and set at a relative xyz point in space from the SimConnect object's eye-point. This is in the SimConnect SDK.

The Cockpit Camera sample in the SDK shows how to use the comma and period as left and right camera controls for the cockpit view.

Dick
 
thanks rhumbaflappy

I was run it! yes it is great.

simconnect.CameraSetRelative6DOF fucntion has 6 parameters. three of them is Deltax, Deltay, Deltaz and other three parameters is roll, pitch, heading.
I want to set the camera by lat, long and no deltax, delatay.

any Idea to move camera using lat , long?

thank you for your help
 
Why don't you just fix the position of the aircraft in Lat Long Alt Pitch bank and roll then fix the camera relatively to this position ?
 
As marcob writes, you may need to create/control a sim object, and position the camera from that. The camera is attached to an object. The object can be moved to ant lat/long you like.

Dick
 
Why don't you just fix the position of the aircraft in Lat Long Alt Pitch bank and roll then fix the camera relatively to this position ?



I'm so eager to do it BUT it can't be done.

how can I move the aircraft programmingly?


thank you for your help
 
You should do it programmaticaly creating an instance of simconnect
Create a data definition object that contains the parameters you want to fix.
Add that object to the data definitions of SimConnect Object.
Call SimConnect.SetDataOnSimObject method to fix the data for this definition object.
You can have samples on this site
http://msdn.microsoft.com/en-us/library/cc526948.aspx#CoreUtilitiesKit
I use C# on .NET to do that and it works correctly
 
thanks dear marcob


I try to do it! but I face to fail!

would you please tell me more or even show some code. the above link which you present in previous section is helpful but it is insufficient. I can't find an appropriate example.

I'm so thanksfull, if you give me some code to solve my problem.

best wishes
 
Some Code to help you

Hi tazaree,
I cannot for industrial reason give you a copy of my program
But I wrote for you and the persons that could be interrested some code explaining how to position the plane by program.
This code is in C#
diplaytext is a simple displaying module like Console.WriteLine()
I hope this will help you

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Media;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Threading;


// This example is given without guarante. Normally calling connecteretpositionner_avion should connect
// to FSX and position the plane

using Microsoft.FlightSimulator.SimConnect;
using System.Runtime.InteropServices;
namespace ConnectionSimple
{

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
struct PositionData
{
public double latitude;
public double longitude;
public double altitude;
public double pitch;
public double bank;
public double heading;
};
enum DEFINITIONS
{

PositionData,
AltSol,
AltSol0
}

SimConnect simconnect = null;


void connecter()
{
// Creer l'objet simconnect

simconnect = new SimConnect("C# Creation Objet", this.Handle, WM_USER_SIMCONNECT, null, 0);

}
void connecteretpositionner_avion ()
{
if (simconnect == null)
{
try
{
// the constructor is similar to SimConnect_Open in the native API
// simconnect = new SimConnect("C# Creating AI Objects", this.Handle, WM_USER_SIMCONNECT, null, 0);
connecter();

}
catch
{
displayText("Impossible de se connecter");
}
}
else
{
displayText("Erreur reessayer");
closeConnection();
return;
}

// Definir l'element PositionData dans l'Enumeration DEFINITIONS

simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "Plane Latitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "Plane Longitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "PLANE ALTITUDE", "meters", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "Plane Pitch Degrees", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "Plane Bank Degrees", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "Plane Heading Degrees True", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);

// Definir la structure initPositionData et l'alimenter
// Definir les variables de positionner et les alimenter
PositionData initPositionData;
Double latc, lngc, capc, altc, rouc, assc;


//
// Put here the value you want for latc Lattitude ,lngc Longitute , altc Altitude assc is the pitch, rouc the bank and capc the heading
// this will put the plane where you want it to be
//
// ex:
// latc=43.5;
lngc=2.3;, etc...

initPositionData.latitude = latc;
initPositionData.longitude = lngc;
initPositionData.altitude = altc;
initPositionData.heading = capc;
initPositionData.pitch = assc;
initPositionData.bank = rouc;

simconnect.SetDataOnSimObject(DEFINITIONS.PositionData, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_DATA_SET_FLAG.DEFAULT, initPositionData);



}
}
 
Some Code to help you

Hi tazaree,
I cannot for industrial reason give you a copy of my program
But I wrote for you and the persons that could be interrested some code explaining how to position the plane by program.
This code is in C#
diplaytext is a simple displaying module like Console.WriteLine()
I hope this will help you

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Media;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Threading;


// This example is given without guarante. Normally calling connecteretpositionner_avion should connect
// to FSX and position the plane

using Microsoft.FlightSimulator.SimConnect;
using System.Runtime.InteropServices;
namespace ConnectionSimple
{

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
struct PositionData
{
public double latitude;
public double longitude;
public double altitude;
public double pitch;
public double bank;
public double heading;
};
enum DEFINITIONS
{

PositionData,
AltSol,
AltSol0
}

SimConnect simconnect = null;


void connecter()
{
// Creer l'objet simconnect

simconnect = new SimConnect("C# Creation Objet", this.Handle, WM_USER_SIMCONNECT, null, 0);

}
void connecteretpositionner_avion ()
{
if (simconnect == null)
{
try
{
connecter();

}
catch
{
displayText("Impossible de se connecter");
return;
}
}


// Definir l'element PositionData dans l'Enumeration DEFINITIONS

simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "Plane Latitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "Plane Longitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "PLANE ALTITUDE", "meters", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "Plane Pitch Degrees", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "Plane Bank Degrees", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "Plane Heading Degrees True", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);

// Definir la structure initPositionData et l'alimenter
// Definir les variables de positionner et les alimenter
PositionData initPositionData;
Double latc, lngc, capc, altc, rouc, assc;


//
// Put here the value you want for latc Lattitude ,lngc Longitute , altc Altitude assc is the pitch, rouc the bank and capc the heading
// this will put the plane where you want it to be
//
// ex:
// latc=43.5;
lngc=2.3;, etc...

initPositionData.latitude = latc;
initPositionData.longitude = lngc;
initPositionData.altitude = altc;
initPositionData.heading = capc;
initPositionData.pitch = assc;
initPositionData.bank = rouc;

simconnect.SetDataOnSimObject(DEFINITIONS.PositionData, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_DATA_SET_FLAG.DEFAULT, initPositionData);



}
}
 
Last edited:
Back
Top