Structs.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading;
  5. using System.Runtime.InteropServices;
  6. using Urho.Physics;
  7. using Urho.Gui;
  8. using Urho.Urho2D;
  9. using Urho.Resources;
  10. namespace Urho {
  11. [StructLayout (LayoutKind.Sequential)]
  12. public struct Ray {
  13. public Vector3 Origin;
  14. public Vector3 Direction;
  15. public Ray(Vector3 origin, Vector3 direction)
  16. {
  17. Origin = origin;
  18. Direction = Vector3.Normalize(direction);
  19. }
  20. public override bool Equals (object obj)
  21. {
  22. if (!(obj is Ray))
  23. return false;
  24. return (this == (Ray) obj);
  25. }
  26. public static bool operator == (Ray left, Ray right)
  27. {
  28. return ((left.Origin == right.Origin) && (left.Direction == right.Direction));
  29. }
  30. public static bool operator != (Ray left, Ray right)
  31. {
  32. return ((left.Origin != right.Origin) || (left.Direction != right.Direction));
  33. }
  34. public Vector3 Project (Vector3 point)
  35. {
  36. var offset = point - Origin;
  37. return Origin + Vector3.Dot (offset, Direction) * Direction;
  38. }
  39. public override int GetHashCode ()
  40. {
  41. return Origin.GetHashCode () + Direction.GetHashCode ();
  42. }
  43. public float Distance (Vector3 point)
  44. {
  45. var projected = Project (point);
  46. return (point - projected).Length;
  47. }
  48. public Vector3 ClosestPoint (Ray otherRay)
  49. {
  50. var p13 = Origin - otherRay.Origin;
  51. var p43 = otherRay.Direction;
  52. Vector3 p21 = Direction;
  53. float d1343 = Vector3.Dot (p13, p43);
  54. float d4321 = Vector3.Dot (p43, p21);
  55. float d1321 = Vector3.Dot (p13, p21);
  56. float d4343 = Vector3.Dot (p43, p43);
  57. float d2121 = Vector3.Dot (p21, p21);
  58. float d = d2121 * d4343 - d4321 * d4321;
  59. if (Math.Abs(d) < float.Epsilon)
  60. return Origin;
  61. float n = d1343 * d4321 - d1321 * d4343;
  62. float a = n / d;
  63. return Origin + a * Direction;
  64. }
  65. public float HitDistance (Plane plane)
  66. {
  67. float d = Vector3.Dot (plane.Normal, Direction);
  68. if (Math.Abs (d) >= float.Epsilon) {
  69. float t = -(Vector3.Dot (plane.Normal, Origin) + plane.D) / d;
  70. if (t >= 0.0f)
  71. return t;
  72. else
  73. return float.PositiveInfinity;
  74. } else
  75. return float.PositiveInfinity;
  76. }
  77. }
  78. [StructLayout (LayoutKind.Sequential)]
  79. public struct IntRect {
  80. public int Left, Top, Right, Bottom;
  81. public IntRect (int left, int top, int right, int bottom)
  82. {
  83. Left = left;
  84. Top = top;
  85. Right = right;
  86. Bottom = bottom;
  87. }
  88. }
  89. [StructLayout (LayoutKind.Sequential)]
  90. public unsafe struct TypeInfo {
  91. public StringHash Type;
  92. public UrhoString TypeName;
  93. public TypeInfo* BaseTypeInfo;
  94. }
  95. [StructLayout (LayoutKind.Sequential)]
  96. public struct Rect {
  97. public Vector2 Min, Max;
  98. public Rect (int left, int top, int right, int bottom)
  99. {
  100. Min = new Vector2 (left, top);
  101. Max = new Vector2 (right, bottom);
  102. }
  103. public Rect (Vector2 min, Vector2 max)
  104. {
  105. Min = min;
  106. Max = max;
  107. }
  108. }
  109. [StructLayout (LayoutKind.Sequential)]
  110. public struct ResourceRef {
  111. public StringHash Type;
  112. public UrhoString Name;
  113. }
  114. [StructLayout (LayoutKind.Sequential)]
  115. public struct HashIteratorBase {
  116. }
  117. [StructLayout (LayoutKind.Sequential)]
  118. public struct Iterator {
  119. }
  120. [StructLayout (LayoutKind.Sequential)]
  121. public struct ResourceRefList {
  122. }
  123. [StructLayout (LayoutKind.Sequential)]
  124. public struct BoundingBox {
  125. public Vector3 Min;
  126. public float DummyMin;
  127. public Vector3 Max;
  128. public float DummyMax;
  129. public BoundingBox (float min, float max)
  130. {
  131. DummyMax = 0;
  132. DummyMin = 0;
  133. Min = new Vector3 (min, min, min);
  134. Max = new Vector3 (max, max, max);
  135. }
  136. public BoundingBox (Vector3 min, Vector3 max)
  137. {
  138. DummyMax = 0;
  139. DummyMin = 0;
  140. Min = min;
  141. Max = max;
  142. }
  143. public bool Defined ()
  144. {
  145. return Min.X != float.PositiveInfinity;
  146. }
  147. public Vector3 Center {
  148. get {
  149. return (Max + Min) * 0.5f;
  150. }
  151. }
  152. public Vector3 Size {
  153. get {
  154. return Max - Min;
  155. }
  156. }
  157. public Vector3 HalfSize {
  158. get {
  159. return (Max - Min)*0.5f;
  160. }
  161. }
  162. public Intersection IsInside (Vector3 point)
  163. {
  164. if (point.X < Min.X || point.X > Max.X ||
  165. point.Y < Min.Y || point.Y > Max.Y ||
  166. point.Z < Min.Z || point.Z > Max.Z)
  167. return Intersection.Outside;
  168. return Intersection.Inside;
  169. }
  170. public Intersection IsInside (BoundingBox box)
  171. {
  172. if (box.Max.X < Min.X || box.Min.X > Max.X ||
  173. box.Max.Y < Min.Y || box.Min.Y > Max.Y ||
  174. box.Max.Z < Min.Z || box.Min.Z > Max.Z)
  175. return Intersection.Outside;
  176. else if (box.Min.X < Min.X || box.Max.X > Max.X ||
  177. box.Min.Y < Min.Y || box.Max.Y > Max.Y ||
  178. box.Min.Z < Min.Z || box.Max.Z > Max.Z)
  179. return Intersection.Intersects;
  180. else
  181. return Intersection.Inside;
  182. }
  183. public Intersection IsInsideFast (BoundingBox box)
  184. {
  185. if (box.Max.X < Min.X || box.Min.X > Max.X ||
  186. box.Max.Y < Min.Y || box.Min.Y > Max.Y ||
  187. box.Max.Z < Min.Z || box.Min.Z > Max.Z)
  188. return Intersection.Outside;
  189. else
  190. return Intersection.Inside;
  191. }
  192. }
  193. [StructLayout(LayoutKind.Sequential)]
  194. public struct AnimationTriggerPoint {
  195. public float Time;
  196. public Variant Variant;
  197. }
  198. [StructLayout(LayoutKind.Sequential)]
  199. public struct VariantValue
  200. {
  201. public VariantValueLine VariantValueLine1;
  202. public VariantValueLine VariantValueLine2;
  203. public VariantValueLine VariantValueLine3;
  204. public VariantValueLine VariantValueLine4;
  205. }
  206. [StructLayout(LayoutKind.Explicit)]
  207. public struct VariantValueLine
  208. {
  209. [FieldOffset(0)] public int Int;
  210. [FieldOffset(0)] public byte Bool;
  211. [FieldOffset(0)] public float Float;
  212. [FieldOffset(0)] public IntPtr Ptr;
  213. }
  214. [StructLayout(LayoutKind.Sequential)]
  215. public struct Variant {
  216. public VariantType Type;
  217. public VariantValue Value;
  218. }
  219. [StructLayout (LayoutKind.Sequential)]
  220. public struct Matrix3x4 {
  221. public float m00;
  222. public float m01;
  223. public float m02;
  224. public float m03;
  225. public float m10;
  226. public float m11;
  227. public float m12;
  228. public float m13;
  229. public float m20;
  230. public float m21;
  231. public float m22;
  232. public float m23;
  233. public Matrix3x4 Inverse()
  234. {
  235. float det = m00 * m11 * m22 +
  236. m10 * m21 * m02 +
  237. m20 * m01 * m12 -
  238. m20 * m11 * m02 -
  239. m10 * m01 * m22 -
  240. m00 * m21 * m12;
  241. float invDet = 1.0f / det;
  242. Matrix3x4 ret;
  243. ret.m00 = (m11 * m22 - m21 * m12) * invDet;
  244. ret.m01 = -(m01 * m22 - m21 * m02) * invDet;
  245. ret.m02 = (m01 * m12 - m11 * m02) * invDet;
  246. ret.m03 = -(m03 * ret.m00 + m13 * ret.m01 + m23 * ret.m02);
  247. ret.m10 = -(m10 * m22 - m20 * m12) * invDet;
  248. ret.m11 = (m00 * m22 - m20 * m02) * invDet;
  249. ret.m12 = -(m00 * m12 - m10 * m02) * invDet;
  250. ret.m13 = -(m03 * ret.m10 + m13 * ret.m11 + m23 * ret.m12);
  251. ret.m20 = (m10 * m21 - m20 * m11) * invDet;
  252. ret.m21 = -(m00 * m21 - m20 * m01) * invDet;
  253. ret.m22 = (m00 * m11 - m10 * m01) * invDet;
  254. ret.m23 = -(m03 * ret.m20 + m13 * ret.m21 + m23 * ret.m22);
  255. return ret;
  256. }
  257. public static Matrix4 operator *(Matrix4 left, Matrix3x4 rhs)
  258. {
  259. return new Matrix4(
  260. left.M11 * rhs.m00 + left.M12 * rhs.m10 + left.M13 * rhs.m20,
  261. left.M11 * rhs.m01 + left.M12 * rhs.m11 + left.M13 * rhs.m21,
  262. left.M11 * rhs.m02 + left.M12 * rhs.m12 + left.M13 * rhs.m22,
  263. left.M11 * rhs.m03 + left.M12 * rhs.m13 + left.M13 * rhs.m23 + left.M14,
  264. left.M21 * rhs.m00 + left.M22 * rhs.m10 + left.M23 * rhs.m20,
  265. left.M21 * rhs.m01 + left.M22 * rhs.m11 + left.M23 * rhs.m21,
  266. left.M21 * rhs.m02 + left.M22 * rhs.m12 + left.M23 * rhs.m22,
  267. left.M21 * rhs.m03 + left.M22 * rhs.m13 + left.M23 * rhs.m23 + left.M24,
  268. left.M31 * rhs.m00 + left.M32 * rhs.m10 + left.M33 * rhs.m20,
  269. left.M31 * rhs.m01 + left.M32 * rhs.m11 + left.M33 * rhs.m21,
  270. left.M31 * rhs.m02 + left.M32 * rhs.m12 + left.M33 * rhs.m22,
  271. left.M31 * rhs.m03 + left.M32 * rhs.m13 + left.M33 * rhs.m23 + left.M34,
  272. left.M41 * rhs.m00 + left.M42 * rhs.m10 + left.M43 * rhs.m20,
  273. left.M41 * rhs.m01 + left.M42 * rhs.m11 + left.M43 * rhs.m21,
  274. left.M41 * rhs.m02 + left.M42 * rhs.m12 + left.M43 * rhs.m22,
  275. left.M41 * rhs.m03 + left.M42 * rhs.m13 + left.M43 * rhs.m23 + left.M44
  276. );
  277. }
  278. }
  279. [StructLayout (LayoutKind.Sequential)]
  280. public struct Color {
  281. public float R, G, B, A;
  282. public Color (float r = 1f, float g = 1f, float b = 1f, float a = 1f)
  283. {
  284. R = r;
  285. G = g;
  286. B = b;
  287. A = a;
  288. }
  289. public Color (Color source)
  290. {
  291. R = source.R;
  292. G = source.G;
  293. B = source.B;
  294. A = source.A;
  295. }
  296. public Color (Color source, float alpha)
  297. {
  298. R = source.R;
  299. G = source.G;
  300. B = source.B;
  301. A = alpha;
  302. }
  303. public static Color White = new Color (1, 1, 1);
  304. public static Color Gray = new Color (0.5f, 0.5f, 0.5f);
  305. public static Color Black = new Color (0.0f, 0.0f, 0.0f);
  306. public static Color Red = new Color (1.0f, 0.0f, 0.0f);
  307. public static Color Green = new Color (0.0f, 1.0f, 0.0f);
  308. public static Color Blue = new Color (0.0f, 0.0f, 1.0f);
  309. public static Color Cyan = new Color (0.0f, 1.0f, 1.0f);
  310. public static Color Magenta = new Color (1.0f, 0.0f, 1.0f);
  311. public static Color Yellow = new Color (1.0f, 1.0f, 0.0f);
  312. public static Color Transparent = new Color (0.0f, 0.0f, 0.0f, 0.0f);
  313. }
  314. [StructLayout (LayoutKind.Sequential)]
  315. public struct Frustum {
  316. }
  317. [StructLayout (LayoutKind.Sequential)]
  318. public struct WeakPtr {
  319. IntPtr ptr;
  320. IntPtr refCountPtr;
  321. public T GetUrhoObject<T>() where T : UrhoObject => Runtime.LookupObject<T>(ptr);
  322. public T GetRefCounted<T>() where T : RefCounted => Runtime.LookupRefCounted<T>(ptr);
  323. }
  324. [StructLayout (LayoutKind.Sequential)]
  325. public struct TouchState {
  326. public int TouchID;
  327. public IntVector2 Position, LastPosition, Delta;
  328. public float Pressure;
  329. WeakPtr touchedElementPtr;
  330. public UIElement TouchedElement => touchedElementPtr.GetUrhoObject<UIElement>();
  331. }
  332. [StructLayout (LayoutKind.Sequential)]
  333. public struct ColorFrame {
  334. public Color Color;
  335. public float Time;
  336. }
  337. [StructLayout (LayoutKind.Sequential)]
  338. public struct JoystickState {
  339. public IntPtr JoystickPtr;
  340. public IntPtr JoystickIdPtr;
  341. public IntPtr ControllerPtr;
  342. IntPtr screenJoystickPtr;
  343. public UIElement ScreenJoystick => Runtime.LookupObject<UIElement>(screenJoystickPtr);
  344. public UrhoString Name;
  345. public VectorBase Buttons;
  346. public VectorBase ButtonPress;
  347. public VectorBase Axes;
  348. public VectorBase Hats;
  349. public float GetAxisPosition(int position)
  350. {
  351. if (position >= Axes.Size)
  352. return 0;
  353. return Axes.Buffer.ReadSingle(position * sizeof(float));
  354. }
  355. public byte GetButtonDown(int position)
  356. {
  357. if (position >= Buttons.Size)
  358. return 0;
  359. return Marshal.ReadByte(Buttons.Buffer, position * sizeof(byte));
  360. }
  361. public byte GetButtonPress(int position)
  362. {
  363. if (position >= ButtonPress.Size)
  364. return 0;
  365. return Marshal.ReadByte(ButtonPress.Buffer, position * sizeof(byte));
  366. }
  367. public int GetHatPosition(int position)
  368. {
  369. if (position >= Hats.Size)
  370. return 0;
  371. return Marshal.ReadInt32(Hats.Buffer, position * sizeof(int));
  372. }
  373. }
  374. [StructLayout(LayoutKind.Sequential)]
  375. public struct VectorBase {
  376. public uint Size;
  377. public uint Capacity;
  378. public IntPtr Buffer;
  379. }
  380. [StructLayout (LayoutKind.Sequential)]
  381. public struct TextureFrame {
  382. }
  383. [StructLayout (LayoutKind.Sequential)]
  384. public struct LightBatchQueue {
  385. }
  386. [StructLayout (LayoutKind.Sequential)]
  387. public struct Bone {
  388. public UrhoString Name;
  389. public int NameHash;
  390. public uint ParentIndex;
  391. public Vector3 InitialPosition;
  392. public Quaternion InitialRotation;
  393. public Vector3 InitialScale;
  394. public Matrix3x4 OffsetMatrix;
  395. byte animated; //bool is not blittable.
  396. public bool Animated { get { return animated != 0; } set { animated = (byte)(value ? 1 : 0); } }
  397. public byte CollisionMask;
  398. public float Radius;
  399. public BoundingBox BoundingBox;
  400. WeakPtr Node;
  401. }
  402. public unsafe class BoneWrapper
  403. {
  404. readonly object objHolder;
  405. readonly Bone* b;
  406. public BoneWrapper(object objHolder, Bone* bone)
  407. {
  408. this.objHolder = objHolder;
  409. this.b = bone;
  410. }
  411. public UrhoString Name { get { return b->Name; } set { b->Name = value; } }
  412. public int NameHash { get { return b->NameHash; } set { b->NameHash = value; } }
  413. public uint ParentIndex { get { return b->ParentIndex; } set { b->ParentIndex = value; } }
  414. public Vector3 InitialPosition { get { return b->InitialPosition; } set { b->InitialPosition = value; } }
  415. public Quaternion InitialRotation { get { return b->InitialRotation; } set { b->InitialRotation = value; } }
  416. public Vector3 InitialScale { get { return b->InitialScale; } set { b->InitialScale = value; } }
  417. public Matrix3x4 OffsetMatrix { get { return b->OffsetMatrix; } set { b->OffsetMatrix = value; } }
  418. public bool Animated { get { return b->Animated; } set { b->Animated = value; } }
  419. public byte CollisionMask { get { return b->CollisionMask; } set { b->CollisionMask = value; } }
  420. public float Radius { get { return b->Radius; } set { b->Radius = value; } }
  421. public BoundingBox BoundingBox { get { return b->BoundingBox; } set { b->BoundingBox = value; } }
  422. }
  423. // DEBATABLE: maybe we should let the binder handle it?
  424. [StructLayout(LayoutKind.Sequential)]
  425. public struct RayQueryResult {
  426. public Vector3 Position;
  427. public Vector3 Normal;
  428. public Vector2 TextureUV;
  429. public float Distance;
  430. IntPtr drawablePtr;
  431. public Drawable Drawable => Runtime.LookupObject<Drawable>(drawablePtr);
  432. IntPtr nodePtr;
  433. public Node Node => Runtime.LookupObject<Node>(nodePtr);
  434. public uint SubObject;
  435. }
  436. [StructLayout (LayoutKind.Sequential)]
  437. public struct RenderPathCommand {
  438. public UrhoString Tag;
  439. public RenderCommandType Type;
  440. public RenderCommandSortMode SortMode;
  441. public UrhoString Pass;
  442. public uint PassIndex;
  443. public UrhoString Metadata;
  444. public UrhoString VertexShaderName;
  445. public UrhoString PixelShaderName;
  446. public UrhoString VertexShaderDefines;
  447. public UrhoString PixelShaderDefines;
  448. //Marshalling String textureNames_[16]
  449. public UrhoString TextureName0;
  450. public UrhoString TextureName1;
  451. public UrhoString TextureName2;
  452. public UrhoString TextureName3;
  453. public UrhoString TextureName4;
  454. public UrhoString TextureName5;
  455. public UrhoString TextureName6;
  456. public UrhoString TextureName7;
  457. #if !IOS && !ANDROID
  458. public UrhoString TextureName8;
  459. public UrhoString TextureName9;
  460. public UrhoString TextureName10;
  461. public UrhoString TextureName11;
  462. public UrhoString TextureName12;
  463. public UrhoString TextureName13;
  464. public UrhoString TextureName14;
  465. public UrhoString TextureName15;
  466. #endif
  467. public HashBase ShaderParameters;
  468. public VectorBase Outputs;
  469. public UrhoString DepthStencilName;
  470. public uint ClearFlags;
  471. public Color ClearColor;
  472. public float ClearDepth;
  473. public uint ClearStencil;
  474. public BlendMode BlendMode;
  475. public byte Enabled;
  476. public byte UseFogColor;
  477. public byte MarkToStencil;
  478. public byte UseLitBase;
  479. public byte VertexLights;
  480. }
  481. [StructLayout(LayoutKind.Sequential)]
  482. public struct VertexElement
  483. {
  484. public VertexElementType Type;
  485. /// <summary>
  486. /// Semantic of element.
  487. /// </summary>
  488. VertexElementSemantic Semantic;
  489. /// <summary>
  490. /// Semantic index of element, for example multi-texcoords.
  491. /// </summary>
  492. public byte Index;
  493. /// <summary>
  494. /// Per-instance flag.
  495. /// </summary>
  496. public byte PerInstance;
  497. /// <summary>
  498. /// Offset of element from vertex start. Filled by VertexBuffer once the vertex declaration is built.
  499. /// </summary>
  500. public uint Offset;
  501. }
  502. [StructLayout(LayoutKind.Sequential)]
  503. public struct HashBase {
  504. public IntPtr Head;
  505. public IntPtr Tail;
  506. public IntPtr Ptrs;
  507. public IntPtr Allocator;
  508. }
  509. // DEBATABLE: maybe we should let the binder handle it?
  510. [StructLayout (LayoutKind.Sequential)]
  511. public struct GPUObject {
  512. }
  513. // DEBATABLE: maybe we should let the binder handle it?
  514. [StructLayout (LayoutKind.Sequential)]
  515. public struct GraphicsImpl {
  516. }
  517. [StructLayout (LayoutKind.Sequential)]
  518. public struct FontGlyph {
  519. public short X, Y, Width, Height, OffsetX, OffsetY, AdvanceX;
  520. public int Page;
  521. byte used;
  522. public bool Used { get { return used != 0; } set { used = (byte) (value ? 1 : 0); }}
  523. }
  524. // DEBATABLE: maybe we should let the binder handle it?
  525. [StructLayout (LayoutKind.Sequential)]
  526. public struct RandomAccessIterator {
  527. }
  528. // DEBATABLE: maybe we should let the binder handle it?
  529. [StructLayout (LayoutKind.Sequential)]
  530. public struct ModelMorph {
  531. }
  532. // DEBATABLE: maybe we should let the binder handle it?
  533. [StructLayout (LayoutKind.Sequential)]
  534. public struct Octant {
  535. }
  536. // DEBATABLE: maybe we should let the binder handle it?
  537. [StructLayout (LayoutKind.Sequential)]
  538. public struct CompressedLevel {
  539. public IntPtr ImageData;
  540. public CompressedFormat Format;
  541. public int Width, Height, Depth;
  542. public uint BlockSize, DataSize, RowSize, RowCount;
  543. }
  544. // DEBATABLE: maybe we should let the binder handle it?
  545. [StructLayout (LayoutKind.Sequential)]
  546. public struct Billboard {
  547. public Vector3 Position;
  548. public Vector2 Size;
  549. public Rect Uv;
  550. public Color Color;
  551. public float Rotation;
  552. public Vector3 Direction;
  553. byte enabled; //bool is not blittable.
  554. public bool Enabled { get { return enabled != 0; } set { enabled = (byte)(value ? 1 : 0); } }
  555. public float SortDistance;
  556. }
  557. public unsafe class BillboardWrapper
  558. {
  559. readonly object bbHolder;
  560. readonly Billboard* bb;
  561. public BillboardWrapper(object bbHolder, Billboard* bb)
  562. {
  563. this.bbHolder = bbHolder;
  564. this.bb = bb;
  565. }
  566. public Vector3 Position { get { return bb->Position; } set { bb->Position = value; } }
  567. public Vector2 Size { get { return bb->Size; } set { bb->Size = value; } }
  568. public Rect Uv { get { return bb->Uv; } set { bb->Uv = value; } }
  569. public Color Color { get { return bb->Color; } set { bb->Color = value; } }
  570. public float Rotation { get { return bb->Rotation; } set { bb->Rotation = value; } }
  571. public bool Enabled { get { return bb->Enabled; } set { bb->Enabled = value; } }
  572. public float SortDistance { get { return bb->SortDistance; } set { bb->SortDistance = value; } }
  573. }
  574. // DEBATABLE: maybe we should let the binder handle it?
  575. [StructLayout (LayoutKind.Sequential)]
  576. public struct AnimationTrack {
  577. }
  578. // DEBATABLE: maybe we should let the binder handle it?
  579. [StructLayout (LayoutKind.Sequential)]
  580. public struct CustomGeometryVertex {
  581. }
  582. // DEBATABLE: maybe we should let the binder handle it?
  583. [StructLayout (LayoutKind.Sequential)]
  584. public struct NetworkState {
  585. }
  586. // DEBATABLE: maybe we should let the binder handle it?
  587. [StructLayout (LayoutKind.Sequential)]
  588. public struct ComponentReplicationState {
  589. }
  590. // DEBATABLE: maybe we should let the binder handle it?
  591. [StructLayout (LayoutKind.Sequential)]
  592. public struct ShaderParameter {
  593. }
  594. // DEBATABLE: maybe we should let the binder handle it?
  595. [StructLayout (LayoutKind.Sequential)]
  596. public struct UrhoString
  597. {
  598. public uint Length;
  599. public uint Capacity;
  600. public IntPtr Buffer;
  601. }
  602. [StructLayout (LayoutKind.Sequential)]
  603. public struct BiasParameters {
  604. public float ConstantBias;
  605. public float SlopeScaleBias;
  606. public float NormalOffset;
  607. public BiasParameters (float constantBias, float slopeScaleBias, float normalOffset = 0.0f)
  608. {
  609. ConstantBias = constantBias;
  610. SlopeScaleBias = slopeScaleBias;
  611. NormalOffset = normalOffset;
  612. }
  613. }
  614. [StructLayout (LayoutKind.Sequential)]
  615. public struct CascadeParameters {
  616. public float Split1, Split2, Split3, Split4;
  617. public float FadeStart;
  618. public float BiasAutoAdjust;
  619. public CascadeParameters (float split1, float split2, float split3, float split4, float fadeStart, float biasAutoAdjust = 1f)
  620. {
  621. Split1 = split1;
  622. Split2 = split2;
  623. Split3 = split3;
  624. Split4 = split4;
  625. FadeStart = fadeStart;
  626. BiasAutoAdjust = biasAutoAdjust;
  627. }
  628. }
  629. [StructLayout (LayoutKind.Sequential)]
  630. public struct FocusParameters {
  631. public byte Focus;
  632. public byte NonUniform;
  633. public byte AutoSize;
  634. public float Quantize;
  635. public float MinView;
  636. }
  637. }
  638. namespace Urho.IO {
  639. [StructLayout (LayoutKind.Sequential)]
  640. public struct PackageEntry {
  641. public int Offset, Size, Checksum;
  642. }
  643. }
  644. namespace Urho.Urho2D {
  645. // DEBATABLE: maybe we should let the binder handle it?
  646. [StructLayout(LayoutKind.Sequential)]
  647. public struct TileMapInfo2D {
  648. public Orientation2D Orientation;
  649. public int Width;
  650. public int Height;
  651. public float TileWidth;
  652. public float TileHeight;
  653. //calculated properties:
  654. public float MapWidth => Width * TileWidth;
  655. public float MapHeight
  656. {
  657. get
  658. {
  659. if (Orientation == Orientation2D.Staggered)
  660. return (Height + 1) * 0.5f * TileHeight;
  661. return Height * TileHeight;
  662. }
  663. }
  664. }
  665. }
  666. namespace Urho.Navigation {
  667. [StructLayout(LayoutKind.Sequential)]
  668. public struct dtQueryFilter {
  669. //public float[] AreaCost; // Cost per area type. (Used by default implementation.)
  670. //public ushort IncludeFlags; // Flags for polygons that can be visited. (Used by default implementation.)
  671. //public ushort ExcludeFlags; // Flags for polygons that should not be visted. (Used by default implementation.)
  672. }
  673. [StructLayout(LayoutKind.Sequential)]
  674. public struct CrowdObstacleAvoidanceParams {
  675. public float VelBias;
  676. public float WeightDesVel;
  677. public float WeightCurVel;
  678. public float WeightSide;
  679. public float WeightToi;
  680. public float HorizTime;
  681. public byte GridSize;
  682. public byte AdaptiveDivs;
  683. public byte AdaptiveRings;
  684. public byte AdaptiveDepth;
  685. };
  686. }
  687. namespace Urho.Physics {
  688. [StructLayout(LayoutKind.Sequential)]
  689. public struct PhysicsRaycastResult {
  690. public Vector3 Position;
  691. public Vector3 Normal;
  692. public float Distance;
  693. public float HitFraction;
  694. IntPtr bodyPtr;
  695. public RigidBody Body => Runtime.LookupObject<RigidBody>(bodyPtr);
  696. }
  697. }
  698. namespace Urho.Resources {
  699. [StructLayout (LayoutKind.Sequential)]
  700. public struct XPathResultSet {
  701. }
  702. }
  703. namespace Urho.Network {
  704. [StructLayout (LayoutKind.Sequential)]
  705. public struct ReplicationState {
  706. IntPtr connection;
  707. public Connection Connection => Runtime.LookupObject<Connection> (connection);
  708. }
  709. [StructLayout (LayoutKind.Sequential)]
  710. public unsafe struct DirtyBits {
  711. public fixed byte Data [8];
  712. public byte Count;
  713. }
  714. [StructLayout (LayoutKind.Sequential)]
  715. public struct NodeReplicationState {
  716. }
  717. }