Commit MetaInfo

Revisiona7e971f0b352d309a4b973f6b9608a1d8cb15a40 (tree)
Time2007-06-07 04:02:55
Authorface__
Commiterface__

Log Message

[svn r32] Started Airfoil delegate implementation.

Change Summary

Incremental Difference

diff -r 4506b2fc4952 -r a7e971f0b352 Orbitersdk/samples/Orbiter.NET/Orbiter.Interfaces/Commons.cs
--- a/Orbitersdk/samples/Orbiter.NET/Orbiter.Interfaces/Commons.cs Tue Jun 05 20:17:48 2007 +0200
+++ b/Orbitersdk/samples/Orbiter.NET/Orbiter.Interfaces/Commons.cs Wed Jun 06 21:02:55 2007 +0200
@@ -335,11 +335,11 @@
335335 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
336336 public delegate double LiftCoefficientDelegate(double angleOfAttack);
337337
338- //TODO: Since this is not equal to the native delegate, the vessel wrapper needs to wrap this, too!
339- public delegate void AirFoilCoefficientDelegate(double angleOfAttack, double mach, double reynolds, out double cl, out double cm, out double cd);
340- public delegate void AirFoilCoefficientExDelegate(double angleOfAttack, double mach, double reynolds, object context, out double cl, out double cm, out double cd);
341-
342-
338+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
339+ public delegate void AirFoilCoefficientDelegate(double angleOfAttack, double mach, double reynolds, IntPtr LiftCoefficientDoublePointer, IntPtr MomentCoefficientDoublePointer, IntPtr DragCoefficientDoublePointer);
340+
341+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
342+ public delegate void AirFoilCoefficientExDelegate(double angleOfAttack, double mach, double reynolds, IntPtr contextVoidPointer, IntPtr LiftCoefficientDoublePointer, IntPtr MomentCoefficientDoublePointer, IntPtr DragCoefficientDoublePointer);
343343
344344 public enum ThrusterGroup
345345 {
@@ -360,4 +360,10 @@
360360 Back,
361361 User = 0x40,
362362 }
363+
364+ public enum AirFoilOrientation
365+ {
366+ Vertical,
367+ Horizontal,
368+ }
363369 }
diff -r 4506b2fc4952 -r a7e971f0b352 Orbitersdk/samples/Orbiter.NET/Orbiter.Interfaces/Vessel.cs
--- a/Orbitersdk/samples/Orbiter.NET/Orbiter.Interfaces/Vessel.cs Tue Jun 05 20:17:48 2007 +0200
+++ b/Orbitersdk/samples/Orbiter.NET/Orbiter.Interfaces/Vessel.cs Wed Jun 06 21:02:55 2007 +0200
@@ -170,6 +170,17 @@
170170 void SetWheelbrakeLevel (double level);
171171 double GetWheelbrakeLevel (int which);
172172 void InitNavRadios (uint navRadios);
173- bool IsTransponderEnabled { set; }
173+ bool IsTransponderEnabled { set; }
174+ void CreateAirfoil(AirFoilOrientation align, Vector3 reference, AirFoilCoefficientDelegate coefficient, double chordLength, double wingArea, double aspectRatio);
175+ IntPtr CreateAirfoil2(AirFoilOrientation align, Vector3 reference, AirFoilCoefficientDelegate coefficient, double chordLength, double wingArea, double aspectRatio);
176+ IntPtr CreateAirfoil3(AirFoilOrientation align, Vector3 reference, AirFoilCoefficientExDelegate coefficient, object context, double chordLength, double wingArea, double aspectRatio);
177+ /// <summary>
178+ /// This function returns the managed object stored for the unmanaged key.
179+ /// </summary>
180+ /// <param name="key">The unmanaged key pointer.</param>
181+ /// <returns>The managed object associated with the key.</returns>
182+ /// <remarks>This is not a native Orbiter function. It is used for marshalling managed context in
183+ /// airfoil coefficient functions.</remarks>
184+ object GetAirFoilCoefficientFunctionContext (IntPtr key);
174185 }
175186 }
diff -r 4506b2fc4952 -r a7e971f0b352 Orbitersdk/samples/Orbiter.NET/Orbiter.StockVessels/DeltaGlider.cs
--- a/Orbitersdk/samples/Orbiter.NET/Orbiter.StockVessels/DeltaGlider.cs Tue Jun 05 20:17:48 2007 +0200
+++ b/Orbitersdk/samples/Orbiter.NET/Orbiter.StockVessels/DeltaGlider.cs Wed Jun 06 21:02:55 2007 +0200
@@ -1294,10 +1294,10 @@
12941294
12951295 // ********************* aerodynamics ***********************
12961296
1297- //hwing = CreateAirfoil3 (LIFT_VERTICAL, _V(0,0,-0.3), VLiftCoeff, 0, 5, 90, 1.5);
1297+ //hwing = This.CreateAirfoil3 (LIFT_VERTICAL, _V(0,0,-0.3), VLiftCoeff, 0, 5, 90, 1.5);
12981298 //// wing and body lift+drag components
12991299
1300- //CreateAirfoil3 (LIFT_HORIZONTAL, _V(0,0,-4), HLiftCoeff, 0, 5, 15, 1.5);
1300+ //This.CreateAirfoil3 (LIFT_HORIZONTAL, _V(0,0,-4), HLiftCoeff, 0, 5, 15, 1.5);
13011301 //// vertical stabiliser and body lift and drag components
13021302
13031303 //CreateControlSurface (AIRCTRL_ELEVATOR, 1.4, 1.5, _V( 0,0,-7.2), AIRCTRL_AXIS_XPOS, anim_elevator);
diff -r 4506b2fc4952 -r a7e971f0b352 Orbitersdk/samples/Orbiter.NET/Orbiter.Wrapper/Vessel.cpp
--- a/Orbitersdk/samples/Orbiter.NET/Orbiter.Wrapper/Vessel.cpp Tue Jun 05 20:17:48 2007 +0200
+++ b/Orbitersdk/samples/Orbiter.NET/Orbiter.Wrapper/Vessel.cpp Wed Jun 06 21:02:55 2007 +0200
@@ -19,6 +19,8 @@
1919 Vessel::Vessel(VESSEL *vessel)
2020 {
2121 this->vessel=vessel;
22+ this->coefficientDelegatesByAirFoil=gcnew System::Collections::Hashtable();
23+ this->coefficientDelegatesByKey=gcnew System::Collections::Hashtable();
2224 }
2325 Vessel::~Vessel()
2426 {
@@ -269,6 +271,41 @@
269271 double Vessel::GetWheelbrakeLevel(int which){return vessel->GetWheelbrakeLevel(which);}
270272 void Vessel::InitNavRadios(unsigned int navRadios){vessel->InitNavRadios((DWORD)navRadios);}
271273 void Vessel::IsTransponderEnabled::set(bool value){vessel->EnableTransponder(value);}
274+ void Vessel::CreateAirfoil(Orbiter::Interfaces::AirFoilOrientation align, Orbiter::Interfaces::Vector3 ^reference, Orbiter::Interfaces::AirFoilCoefficientDelegate ^coefficient, double chordLength, double wingArea, double aspectRatio)
275+ {
276+ IntPtr p = Marshal::GetFunctionPointerForDelegate(coefficient);
277+ array<Object^>^ payload=gcnew array<Object^>(3);
278+ payload[0]=coefficient;
279+ payload[1]=IntPtr::Zero;
280+ payload[2]=nullptr;
281+ coefficientDelegatesByAirFoil[coefficient]=payload;
282+ vessel->CreateAirfoil((AIRFOIL_ORIENTATION)align, _V(reference->X, reference->Y, reference->Z), static_cast<AirfoilCoeffFunc>(p.ToPointer()), chordLength, wingArea, aspectRatio);
283+ }
284+ IntPtr Vessel::CreateAirfoil2(Orbiter::Interfaces::AirFoilOrientation align, Orbiter::Interfaces::Vector3 ^reference, Orbiter::Interfaces::AirFoilCoefficientDelegate ^coefficient, double chordLength, double wingArea, double aspectRatio)
285+ {
286+ IntPtr p = Marshal::GetFunctionPointerForDelegate(coefficient);
287+ array<Object^>^ payload=gcnew array<Object^>(3);
288+ payload[0]=coefficient;
289+ payload[1]=IntPtr::Zero;
290+ payload[2]=nullptr;
291+ IntPtr result=(IntPtr)vessel->CreateAirfoil2((AIRFOIL_ORIENTATION)align, _V(reference->X, reference->Y, reference->Z), static_cast<AirfoilCoeffFunc>(p.ToPointer()), chordLength, wingArea, aspectRatio);
292+ coefficientDelegatesByAirFoil[result]=payload;
293+ return result;
294+ }
295+ IntPtr Vessel::CreateAirfoil3(Orbiter::Interfaces::AirFoilOrientation align, Orbiter::Interfaces::Vector3 ^reference, Orbiter::Interfaces::AirFoilCoefficientExDelegate ^coefficient, System::Object ^context, double chordLength, double wingArea, double aspectRatio)
296+ {
297+ IntPtr p = Marshal::GetFunctionPointerForDelegate(coefficient);
298+ char *key=new char[1];
299+ array<Object^>^ payload=gcnew array<Object^>(3);
300+ payload[0]=coefficient;
301+ payload[1]=(IntPtr)key;
302+ payload[2]=context;
303+ IntPtr result=(IntPtr)vessel->CreateAirfoil3((AIRFOIL_ORIENTATION)align, _V(reference->X, reference->Y, reference->Z), static_cast<AirfoilCoeffFuncEx>(p.ToPointer()), key, chordLength, wingArea, aspectRatio);
304+ coefficientDelegatesByAirFoil[result]=payload;
305+ coefficientDelegatesByKey[payload[1]]=payload;
306+ return result;
307+ }
308+ System::Object^ Vessel::GetAirFoilCoefficientFunctionContext(System::IntPtr key){return coefficientDelegatesByKey[key];}
272309
273310 IntPtr Vessel::Init(IntPtr vessel, int flightmodel, Interfaces::Vessel2^ vessel2)
274311 {
diff -r 4506b2fc4952 -r a7e971f0b352 Orbitersdk/samples/Orbiter.NET/Orbiter.Wrapper/Vessel.h
--- a/Orbitersdk/samples/Orbiter.NET/Orbiter.Wrapper/Vessel.h Tue Jun 05 20:17:48 2007 +0200
+++ b/Orbitersdk/samples/Orbiter.NET/Orbiter.Wrapper/Vessel.h Wed Jun 06 21:02:55 2007 +0200
@@ -111,8 +111,12 @@
111111 virtual void SetWheelbrakeLevel (double level, int which);
112112 virtual void SetWheelbrakeLevel (double level);
113113 virtual double GetWheelbrakeLevel (int which);
114- virtual void InitNavRadios (unsigned int navRadios);
114+ virtual void InitNavRadios (unsigned int navRadios);
115115 virtual property bool IsTransponderEnabled {void set(bool value);};
116+ virtual void CreateAirfoil (Interfaces::AirFoilOrientation align, Interfaces::Vector3^ reference, Interfaces::AirFoilCoefficientDelegate^ coefficient, double chordLength, double wingArea, double aspectRatio);
117+ virtual IntPtr CreateAirfoil2 (Interfaces::AirFoilOrientation align, Interfaces::Vector3^ reference, Interfaces::AirFoilCoefficientDelegate^ coefficient, double chordLength, double wingArea, double aspectRatio);
118+ virtual IntPtr CreateAirfoil3 (Interfaces::AirFoilOrientation align, Interfaces::Vector3^ reference, Interfaces::AirFoilCoefficientExDelegate^ coefficient, Object^ context, double chordLength, double wingArea, double aspectRatio);
119+ virtual Object^ GetAirFoilCoefficientFunctionContext (IntPtr key);
116120
117121 //double GetMaxThrust (ENGINETYPE eng) const;
118122 //double GetEngineLevel (ENGINETYPE eng) const;
@@ -356,6 +360,8 @@
356360 private:
357361 VESSEL *vessel;
358362 Interfaces::LiftCoefficientDelegate^ liftCoefficientDelegate;
363+ System::Collections::Hashtable^ coefficientDelegatesByAirFoil;
364+ System::Collections::Hashtable^ coefficientDelegatesByKey;
359365 };
360366 }
361367 }
\ No newline at end of file
Show on old repository browser