Structs.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  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 void Merge (Vector3 point)
  144. {
  145. if (point.X < Min.X)
  146. Min.X = point.X;
  147. if (point.Y < Min.Y)
  148. Min.Y = point.Y;
  149. if (point.Z < Min.Z)
  150. Min.Z = point.Z;
  151. if (point.X > Max.X)
  152. Max.X = point.X;
  153. if (point.Y > Max.Y)
  154. Max.Y = point.Y;
  155. if (point.Z > Max.Z)
  156. Max.Z = point.Z;
  157. }
  158. public void Merge (BoundingBox box)
  159. {
  160. if (box.Min.X < Min.X)
  161. Min.X = box.Min.X;
  162. if (box.Min.Y < Min.Y)
  163. Min.Y = box.Min.Y;
  164. if (box.Min.Z < Min.Z)
  165. Min.Z = box.Min.Z;
  166. if (box.Max.X > Max.X)
  167. Max.X = box.Max.X;
  168. if (box.Max.Y > Max.Y)
  169. Max.Y = box.Max.Y;
  170. if (box.Max.Z > Max.Z)
  171. Max.Z = box.Max.Z;
  172. }
  173. public bool Defined ()
  174. {
  175. return Min.X != float.PositiveInfinity;
  176. }
  177. public Vector3 Center {
  178. get {
  179. return (Max + Min) * 0.5f;
  180. }
  181. }
  182. public Vector3 Size {
  183. get {
  184. return Max - Min;
  185. }
  186. }
  187. public Vector3 HalfSize {
  188. get {
  189. return (Max - Min)*0.5f;
  190. }
  191. }
  192. public Intersection IsInside (Vector3 point)
  193. {
  194. if (point.X < Min.X || point.X > Max.X ||
  195. point.Y < Min.Y || point.Y > Max.Y ||
  196. point.Z < Min.Z || point.Z > Max.Z)
  197. return Intersection.Outside;
  198. return Intersection.Inside;
  199. }
  200. public Intersection IsInside (BoundingBox box)
  201. {
  202. if (box.Max.X < Min.X || box.Min.X > Max.X ||
  203. box.Max.Y < Min.Y || box.Min.Y > Max.Y ||
  204. box.Max.Z < Min.Z || box.Min.Z > Max.Z)
  205. return Intersection.Outside;
  206. else if (box.Min.X < Min.X || box.Max.X > Max.X ||
  207. box.Min.Y < Min.Y || box.Max.Y > Max.Y ||
  208. box.Min.Z < Min.Z || box.Max.Z > Max.Z)
  209. return Intersection.Intersects;
  210. else
  211. return Intersection.Inside;
  212. }
  213. public Intersection IsInsideFast (BoundingBox box)
  214. {
  215. if (box.Max.X < Min.X || box.Min.X > Max.X ||
  216. box.Max.Y < Min.Y || box.Min.Y > Max.Y ||
  217. box.Max.Z < Min.Z || box.Min.Z > Max.Z)
  218. return Intersection.Outside;
  219. else
  220. return Intersection.Inside;
  221. }
  222. }
  223. [StructLayout(LayoutKind.Sequential)]
  224. public struct AnimationTriggerPoint {
  225. public float Time;
  226. public Variant Variant;
  227. }
  228. [StructLayout(LayoutKind.Sequential)]
  229. public struct VariantValue
  230. {
  231. public VariantValueLine VariantValueLine1;
  232. public VariantValueLine VariantValueLine2;
  233. public VariantValueLine VariantValueLine3;
  234. public VariantValueLine VariantValueLine4;
  235. }
  236. [StructLayout(LayoutKind.Explicit)]
  237. public struct VariantValueLine
  238. {
  239. [FieldOffset(0)] public int Int;
  240. [FieldOffset(0)] public byte Bool;
  241. [FieldOffset(0)] public float Float;
  242. [FieldOffset(0)] public IntPtr Ptr;
  243. }
  244. [StructLayout(LayoutKind.Sequential)]
  245. public struct Variant {
  246. public VariantType Type;
  247. public VariantValue Value;
  248. }
  249. [StructLayout (LayoutKind.Sequential)]
  250. public struct Matrix3x4 {
  251. public float m00;
  252. public float m01;
  253. public float m02;
  254. public float m03;
  255. public float m10;
  256. public float m11;
  257. public float m12;
  258. public float m13;
  259. public float m20;
  260. public float m21;
  261. public float m22;
  262. public float m23;
  263. public Matrix3x4 Inverse()
  264. {
  265. float det = m00 * m11 * m22 +
  266. m10 * m21 * m02 +
  267. m20 * m01 * m12 -
  268. m20 * m11 * m02 -
  269. m10 * m01 * m22 -
  270. m00 * m21 * m12;
  271. float invDet = 1.0f / det;
  272. Matrix3x4 ret;
  273. ret.m00 = (m11 * m22 - m21 * m12) * invDet;
  274. ret.m01 = -(m01 * m22 - m21 * m02) * invDet;
  275. ret.m02 = (m01 * m12 - m11 * m02) * invDet;
  276. ret.m03 = -(m03 * ret.m00 + m13 * ret.m01 + m23 * ret.m02);
  277. ret.m10 = -(m10 * m22 - m20 * m12) * invDet;
  278. ret.m11 = (m00 * m22 - m20 * m02) * invDet;
  279. ret.m12 = -(m00 * m12 - m10 * m02) * invDet;
  280. ret.m13 = -(m03 * ret.m10 + m13 * ret.m11 + m23 * ret.m12);
  281. ret.m20 = (m10 * m21 - m20 * m11) * invDet;
  282. ret.m21 = -(m00 * m21 - m20 * m01) * invDet;
  283. ret.m22 = (m00 * m11 - m10 * m01) * invDet;
  284. ret.m23 = -(m03 * ret.m20 + m13 * ret.m21 + m23 * ret.m22);
  285. return ret;
  286. }
  287. public static Matrix4 operator *(Matrix4 left, Matrix3x4 rhs)
  288. {
  289. return new Matrix4(
  290. left.M11 * rhs.m00 + left.M12 * rhs.m10 + left.M13 * rhs.m20,
  291. left.M11 * rhs.m01 + left.M12 * rhs.m11 + left.M13 * rhs.m21,
  292. left.M11 * rhs.m02 + left.M12 * rhs.m12 + left.M13 * rhs.m22,
  293. left.M11 * rhs.m03 + left.M12 * rhs.m13 + left.M13 * rhs.m23 + left.M14,
  294. left.M21 * rhs.m00 + left.M22 * rhs.m10 + left.M23 * rhs.m20,
  295. left.M21 * rhs.m01 + left.M22 * rhs.m11 + left.M23 * rhs.m21,
  296. left.M21 * rhs.m02 + left.M22 * rhs.m12 + left.M23 * rhs.m22,
  297. left.M21 * rhs.m03 + left.M22 * rhs.m13 + left.M23 * rhs.m23 + left.M24,
  298. left.M31 * rhs.m00 + left.M32 * rhs.m10 + left.M33 * rhs.m20,
  299. left.M31 * rhs.m01 + left.M32 * rhs.m11 + left.M33 * rhs.m21,
  300. left.M31 * rhs.m02 + left.M32 * rhs.m12 + left.M33 * rhs.m22,
  301. left.M31 * rhs.m03 + left.M32 * rhs.m13 + left.M33 * rhs.m23 + left.M34,
  302. left.M41 * rhs.m00 + left.M42 * rhs.m10 + left.M43 * rhs.m20,
  303. left.M41 * rhs.m01 + left.M42 * rhs.m11 + left.M43 * rhs.m21,
  304. left.M41 * rhs.m02 + left.M42 * rhs.m12 + left.M43 * rhs.m22,
  305. left.M41 * rhs.m03 + left.M42 * rhs.m13 + left.M43 * rhs.m23 + left.M44
  306. );
  307. }
  308. }
  309. [StructLayout (LayoutKind.Sequential)]
  310. public struct Color {
  311. public float R, G, B, A;
  312. public Color (float r = 1f, float g = 1f, float b = 1f, float a = 1f)
  313. {
  314. R = r;
  315. G = g;
  316. B = b;
  317. A = a;
  318. }
  319. public Color (Color source)
  320. {
  321. R = source.R;
  322. G = source.G;
  323. B = source.B;
  324. A = source.A;
  325. }
  326. public Color (Color source, float alpha)
  327. {
  328. R = source.R;
  329. G = source.G;
  330. B = source.B;
  331. A = alpha;
  332. }
  333. public static Color White = new Color (1, 1, 1);
  334. public static Color Gray = new Color (0.5f, 0.5f, 0.5f);
  335. public static Color Black = new Color (0.0f, 0.0f, 0.0f);
  336. public static Color Red = new Color (1.0f, 0.0f, 0.0f);
  337. public static Color Green = new Color (0.0f, 1.0f, 0.0f);
  338. public static Color Blue = new Color (0.0f, 0.0f, 1.0f);
  339. public static Color Cyan = new Color (0.0f, 1.0f, 1.0f);
  340. public static Color Magenta = new Color (1.0f, 0.0f, 1.0f);
  341. public static Color Yellow = new Color (1.0f, 1.0f, 0.0f);
  342. public static Color Transparent = new Color (0.0f, 0.0f, 0.0f, 0.0f);
  343. public uint ToUInt()
  344. {
  345. uint r = (uint)MathHelper.Clamp(((int)(R * 255.0f)), 0, 255);
  346. uint g = (uint)MathHelper.Clamp(((int)(G * 255.0f)), 0, 255);
  347. uint b = (uint)MathHelper.Clamp(((int)(B * 255.0f)), 0, 255);
  348. uint a = (uint)MathHelper.Clamp(((int)(A * 255.0f)), 0, 255);
  349. return (a << 24) | (b << 16) | (g << 8) | r;
  350. }
  351. public static Color operator +(Color left, Color right)
  352. {
  353. left.A = MathHelper.Clamp(left.A + right.A, 0, 1);
  354. left.R = MathHelper.Clamp(left.R + right.R, 0, 1);
  355. left.G = MathHelper.Clamp(left.G + right.G, 0, 1);
  356. left.B = MathHelper.Clamp(left.B + right.B, 0, 1);
  357. return left;
  358. }
  359. public static Color operator -(Color left, Color right)
  360. {
  361. left.A = MathHelper.Clamp(left.A - right.A, 0, 1);
  362. left.R = MathHelper.Clamp(left.R - right.R, 0, 1);
  363. left.G = MathHelper.Clamp(left.G - right.G, 0, 1);
  364. left.B = MathHelper.Clamp(left.B - right.B, 0, 1);
  365. return left;
  366. }
  367. public static Color operator *(Color left, float value)
  368. {
  369. left.A = MathHelper.Clamp(left.A * value, 0, 1);
  370. left.R = MathHelper.Clamp(left.R * value, 0, 1);
  371. left.G = MathHelper.Clamp(left.G * value, 0, 1);
  372. left.B = MathHelper.Clamp(left.B * value, 0, 1);
  373. return left;
  374. }
  375. }
  376. [StructLayout (LayoutKind.Sequential)]
  377. public struct Frustum {
  378. }
  379. [StructLayout (LayoutKind.Sequential)]
  380. public struct WeakPtr {
  381. IntPtr ptr;
  382. IntPtr refCountPtr;
  383. public T GetUrhoObject<T>() where T : UrhoObject => Runtime.LookupObject<T>(ptr);
  384. public T GetRefCounted<T>() where T : RefCounted => Runtime.LookupRefCounted<T>(ptr);
  385. }
  386. [StructLayout (LayoutKind.Sequential)]
  387. public struct TouchState {
  388. public int TouchID;
  389. public IntVector2 Position, LastPosition, Delta;
  390. public float Pressure;
  391. WeakPtr touchedElementPtr;
  392. public UIElement TouchedElement => touchedElementPtr.GetUrhoObject<UIElement>();
  393. }
  394. [StructLayout (LayoutKind.Sequential)]
  395. public struct ColorFrame {
  396. public Color Color;
  397. public float Time;
  398. }
  399. [StructLayout (LayoutKind.Sequential)]
  400. public struct JoystickState {
  401. public IntPtr JoystickPtr;
  402. public IntPtr JoystickIdPtr;
  403. public IntPtr ControllerPtr;
  404. IntPtr screenJoystickPtr;
  405. public UIElement ScreenJoystick => Runtime.LookupObject<UIElement>(screenJoystickPtr);
  406. public UrhoString Name;
  407. public VectorBase Buttons;
  408. public VectorBase ButtonPress;
  409. public VectorBase Axes;
  410. public VectorBase Hats;
  411. public float GetAxisPosition(int position)
  412. {
  413. if (position >= Axes.Size)
  414. return 0;
  415. return Axes.Buffer.ReadSingle(position * sizeof(float));
  416. }
  417. public byte GetButtonDown(int position)
  418. {
  419. if (position >= Buttons.Size)
  420. return 0;
  421. return Marshal.ReadByte(Buttons.Buffer, position * sizeof(byte));
  422. }
  423. public byte GetButtonPress(int position)
  424. {
  425. if (position >= ButtonPress.Size)
  426. return 0;
  427. return Marshal.ReadByte(ButtonPress.Buffer, position * sizeof(byte));
  428. }
  429. public int GetHatPosition(int position)
  430. {
  431. if (position >= Hats.Size)
  432. return 0;
  433. return Marshal.ReadInt32(Hats.Buffer, position * sizeof(int));
  434. }
  435. }
  436. [StructLayout(LayoutKind.Sequential)]
  437. public struct VectorBase {
  438. public uint Size;
  439. public uint Capacity;
  440. public IntPtr Buffer;
  441. }
  442. [StructLayout(LayoutKind.Sequential)]
  443. public struct SDL_Event {
  444. }
  445. [StructLayout (LayoutKind.Sequential)]
  446. public struct TextureFrame {
  447. }
  448. [StructLayout (LayoutKind.Sequential)]
  449. public struct LightBatchQueue {
  450. }
  451. [StructLayout (LayoutKind.Sequential)]
  452. public struct Bone {
  453. public UrhoString Name;
  454. public int NameHash;
  455. public uint ParentIndex;
  456. public Vector3 InitialPosition;
  457. public Quaternion InitialRotation;
  458. public Vector3 InitialScale;
  459. public Matrix3x4 OffsetMatrix;
  460. byte animated; //bool is not blittable.
  461. public bool Animated { get { return animated != 0; } set { animated = (byte)(value ? 1 : 0); } }
  462. public byte CollisionMask;
  463. public float Radius;
  464. public BoundingBox BoundingBox;
  465. WeakPtr Node;
  466. }
  467. public unsafe class BoneWrapper
  468. {
  469. readonly object objHolder;
  470. readonly Bone* b;
  471. public BoneWrapper(object objHolder, Bone* bone)
  472. {
  473. this.objHolder = objHolder;
  474. this.b = bone;
  475. }
  476. public UrhoString Name { get { return b->Name; } set { b->Name = value; } }
  477. public int NameHash { get { return b->NameHash; } set { b->NameHash = value; } }
  478. public uint ParentIndex { get { return b->ParentIndex; } set { b->ParentIndex = value; } }
  479. public Vector3 InitialPosition { get { return b->InitialPosition; } set { b->InitialPosition = value; } }
  480. public Quaternion InitialRotation { get { return b->InitialRotation; } set { b->InitialRotation = value; } }
  481. public Vector3 InitialScale { get { return b->InitialScale; } set { b->InitialScale = value; } }
  482. public Matrix3x4 OffsetMatrix { get { return b->OffsetMatrix; } set { b->OffsetMatrix = value; } }
  483. public bool Animated { get { return b->Animated; } set { b->Animated = value; } }
  484. public byte CollisionMask { get { return b->CollisionMask; } set { b->CollisionMask = value; } }
  485. public float Radius { get { return b->Radius; } set { b->Radius = value; } }
  486. public BoundingBox BoundingBox { get { return b->BoundingBox; } set { b->BoundingBox = value; } }
  487. }
  488. // DEBATABLE: maybe we should let the binder handle it?
  489. [StructLayout(LayoutKind.Sequential)]
  490. public struct RayQueryResult {
  491. public Vector3 Position;
  492. public Vector3 Normal;
  493. public Vector2 TextureUV;
  494. public float Distance;
  495. IntPtr drawablePtr;
  496. public Drawable Drawable => Runtime.LookupObject<Drawable>(drawablePtr);
  497. IntPtr nodePtr;
  498. public Node Node => Runtime.LookupObject<Node>(nodePtr);
  499. public uint SubObject;
  500. }
  501. [StructLayout (LayoutKind.Sequential)]
  502. public struct RenderPathCommand {
  503. public UrhoString Tag;
  504. public RenderCommandType Type;
  505. public RenderCommandSortMode SortMode;
  506. public UrhoString Pass;
  507. public uint PassIndex;
  508. public UrhoString Metadata;
  509. public UrhoString VertexShaderName;
  510. public UrhoString PixelShaderName;
  511. public UrhoString VertexShaderDefines;
  512. public UrhoString PixelShaderDefines;
  513. //Marshalling String textureNames_[16]
  514. public UrhoString TextureName0;
  515. public UrhoString TextureName1;
  516. public UrhoString TextureName2;
  517. public UrhoString TextureName3;
  518. public UrhoString TextureName4;
  519. public UrhoString TextureName5;
  520. public UrhoString TextureName6;
  521. public UrhoString TextureName7;
  522. #if !IOS && !ANDROID
  523. public UrhoString TextureName8;
  524. public UrhoString TextureName9;
  525. public UrhoString TextureName10;
  526. public UrhoString TextureName11;
  527. public UrhoString TextureName12;
  528. public UrhoString TextureName13;
  529. public UrhoString TextureName14;
  530. public UrhoString TextureName15;
  531. #endif
  532. public HashBase ShaderParameters;
  533. public VectorBase Outputs;
  534. public UrhoString DepthStencilName;
  535. public uint ClearFlags;
  536. public Color ClearColor;
  537. public float ClearDepth;
  538. public uint ClearStencil;
  539. public BlendMode BlendMode;
  540. public byte Enabled;
  541. public byte UseFogColor;
  542. public byte MarkToStencil;
  543. public byte UseLitBase;
  544. public byte VertexLights;
  545. public UrhoString EventName;
  546. }
  547. [StructLayout(LayoutKind.Sequential)]
  548. public struct VertexElement
  549. {
  550. public VertexElementType Type;
  551. /// <summary>
  552. /// Semantic of element.
  553. /// </summary>
  554. VertexElementSemantic Semantic;
  555. /// <summary>
  556. /// Semantic index of element, for example multi-texcoords.
  557. /// </summary>
  558. public byte Index;
  559. /// <summary>
  560. /// Per-instance flag.
  561. /// </summary>
  562. public byte PerInstance;
  563. /// <summary>
  564. /// Offset of element from vertex start. Filled by VertexBuffer once the vertex declaration is built.
  565. /// </summary>
  566. public uint Offset;
  567. }
  568. [StructLayout(LayoutKind.Sequential)]
  569. public struct HashBase {
  570. public IntPtr Head;
  571. public IntPtr Tail;
  572. public IntPtr Ptrs;
  573. public IntPtr Allocator;
  574. }
  575. // DEBATABLE: maybe we should let the binder handle it?
  576. [StructLayout (LayoutKind.Sequential)]
  577. public struct GPUObject {
  578. }
  579. // DEBATABLE: maybe we should let the binder handle it?
  580. [StructLayout (LayoutKind.Sequential)]
  581. public struct GraphicsImpl {
  582. }
  583. [StructLayout (LayoutKind.Sequential)]
  584. public struct FontGlyph {
  585. public short X, Y, Width, Height, OffsetX, OffsetY, AdvanceX;
  586. public int Page;
  587. byte used;
  588. public bool Used { get { return used != 0; } set { used = (byte) (value ? 1 : 0); }}
  589. }
  590. // DEBATABLE: maybe we should let the binder handle it?
  591. [StructLayout (LayoutKind.Sequential)]
  592. public struct RandomAccessIterator {
  593. }
  594. // DEBATABLE: maybe we should let the binder handle it?
  595. [StructLayout (LayoutKind.Sequential)]
  596. public struct ModelMorph {
  597. }
  598. // DEBATABLE: maybe we should let the binder handle it?
  599. [StructLayout (LayoutKind.Sequential)]
  600. public struct Octant {
  601. }
  602. // DEBATABLE: maybe we should let the binder handle it?
  603. [StructLayout (LayoutKind.Sequential)]
  604. public struct CompressedLevel {
  605. public IntPtr ImageData;
  606. public CompressedFormat Format;
  607. public int Width, Height, Depth;
  608. public uint BlockSize, DataSize, RowSize, RowCount;
  609. }
  610. // DEBATABLE: maybe we should let the binder handle it?
  611. [StructLayout (LayoutKind.Sequential)]
  612. public struct Billboard {
  613. public Vector3 Position;
  614. public Vector2 Size;
  615. public Rect Uv;
  616. public Color Color;
  617. public float Rotation;
  618. public Vector3 Direction;
  619. byte enabled; //bool is not blittable.
  620. public bool Enabled { get { return enabled != 0; } set { enabled = (byte)(value ? 1 : 0); } }
  621. public float SortDistance;
  622. public float ScreenScaleFactor;
  623. }
  624. public unsafe class BillboardWrapper
  625. {
  626. readonly object bbHolder;
  627. readonly Billboard* bb;
  628. public BillboardWrapper(object bbHolder, Billboard* bb)
  629. {
  630. this.bbHolder = bbHolder;
  631. this.bb = bb;
  632. }
  633. public Vector3 Position { get { return bb->Position; } set { bb->Position = value; } }
  634. public Vector2 Size { get { return bb->Size; } set { bb->Size = value; } }
  635. public Rect Uv { get { return bb->Uv; } set { bb->Uv = value; } }
  636. public Color Color { get { return bb->Color; } set { bb->Color = value; } }
  637. public float Rotation { get { return bb->Rotation; } set { bb->Rotation = value; } }
  638. public bool Enabled { get { return bb->Enabled; } set { bb->Enabled = value; } }
  639. public float SortDistance { get { return bb->SortDistance; } set { bb->SortDistance = value; } }
  640. }
  641. // DEBATABLE: maybe we should let the binder handle it?
  642. [StructLayout (LayoutKind.Sequential)]
  643. public struct AnimationTrack {
  644. }
  645. // DEBATABLE: maybe we should let the binder handle it?
  646. [StructLayout (LayoutKind.Sequential)]
  647. public struct CustomGeometryVertex
  648. {
  649. public Vector3 Position;
  650. public Vector3 Normal;
  651. public uint Color;
  652. public Vector2 TexCoord;
  653. public Vector4 Tangent;
  654. }
  655. // DEBATABLE: maybe we should let the binder handle it?
  656. [StructLayout (LayoutKind.Sequential)]
  657. public struct NetworkState {
  658. }
  659. // DEBATABLE: maybe we should let the binder handle it?
  660. [StructLayout (LayoutKind.Sequential)]
  661. public struct ComponentReplicationState {
  662. }
  663. // DEBATABLE: maybe we should let the binder handle it?
  664. [StructLayout (LayoutKind.Sequential)]
  665. public struct ShaderParameter {
  666. }
  667. // DEBATABLE: maybe we should let the binder handle it?
  668. [StructLayout (LayoutKind.Sequential)]
  669. public struct UrhoString
  670. {
  671. public uint Length;
  672. public uint Capacity;
  673. public IntPtr Buffer;
  674. }
  675. [StructLayout (LayoutKind.Sequential)]
  676. public struct BiasParameters {
  677. public float ConstantBias;
  678. public float SlopeScaleBias;
  679. public float NormalOffset;
  680. public BiasParameters (float constantBias, float slopeScaleBias, float normalOffset = 0.0f)
  681. {
  682. ConstantBias = constantBias;
  683. SlopeScaleBias = slopeScaleBias;
  684. NormalOffset = normalOffset;
  685. }
  686. }
  687. [StructLayout (LayoutKind.Sequential)]
  688. public struct CascadeParameters {
  689. public float Split1, Split2, Split3, Split4;
  690. public float FadeStart;
  691. public float BiasAutoAdjust;
  692. public CascadeParameters (float split1, float split2, float split3, float split4, float fadeStart, float biasAutoAdjust = 1f)
  693. {
  694. Split1 = split1;
  695. Split2 = split2;
  696. Split3 = split3;
  697. Split4 = split4;
  698. FadeStart = fadeStart;
  699. BiasAutoAdjust = biasAutoAdjust;
  700. }
  701. }
  702. [StructLayout (LayoutKind.Sequential)]
  703. public struct FocusParameters {
  704. public byte Focus;
  705. public byte NonUniform;
  706. public byte AutoSize;
  707. public float Quantize;
  708. public float MinView;
  709. }
  710. }
  711. namespace Urho.IO {
  712. [StructLayout (LayoutKind.Sequential)]
  713. public struct PackageEntry {
  714. public int Offset, Size, Checksum;
  715. }
  716. }
  717. namespace Urho.Urho2D {
  718. // DEBATABLE: maybe we should let the binder handle it?
  719. [StructLayout(LayoutKind.Sequential)]
  720. public struct TileMapInfo2D {
  721. public Orientation2D Orientation;
  722. public int Width;
  723. public int Height;
  724. public float TileWidth;
  725. public float TileHeight;
  726. //calculated properties:
  727. public float MapWidth => Width * TileWidth;
  728. public float MapHeight
  729. {
  730. get
  731. {
  732. if (Orientation == Orientation2D.Staggered)
  733. return (Height + 1) * 0.5f * TileHeight;
  734. return Height * TileHeight;
  735. }
  736. }
  737. }
  738. }
  739. namespace Urho.Navigation {
  740. [StructLayout(LayoutKind.Sequential)]
  741. public struct dtQueryFilter {
  742. //public float[] AreaCost; // Cost per area type. (Used by default implementation.)
  743. //public ushort IncludeFlags; // Flags for polygons that can be visited. (Used by default implementation.)
  744. //public ushort ExcludeFlags; // Flags for polygons that should not be visted. (Used by default implementation.)
  745. }
  746. [StructLayout(LayoutKind.Sequential)]
  747. public struct CrowdObstacleAvoidanceParams {
  748. public float VelBias;
  749. public float WeightDesVel;
  750. public float WeightCurVel;
  751. public float WeightSide;
  752. public float WeightToi;
  753. public float HorizTime;
  754. public byte GridSize;
  755. public byte AdaptiveDivs;
  756. public byte AdaptiveRings;
  757. public byte AdaptiveDepth;
  758. };
  759. }
  760. namespace Urho.Physics {
  761. [StructLayout(LayoutKind.Sequential)]
  762. public struct PhysicsRaycastResult {
  763. public Vector3 Position;
  764. public Vector3 Normal;
  765. public float Distance;
  766. public float HitFraction;
  767. IntPtr bodyPtr;
  768. public RigidBody Body => Runtime.LookupObject<RigidBody>(bodyPtr);
  769. }
  770. }
  771. namespace Urho.Resources {
  772. [StructLayout (LayoutKind.Sequential)]
  773. public struct XPathResultSet {
  774. }
  775. }
  776. namespace Urho.Network {
  777. [StructLayout (LayoutKind.Sequential)]
  778. public struct ReplicationState {
  779. IntPtr connection;
  780. public Connection Connection => Runtime.LookupObject<Connection> (connection);
  781. }
  782. [StructLayout (LayoutKind.Sequential)]
  783. public unsafe struct DirtyBits {
  784. public fixed byte Data [8];
  785. public byte Count;
  786. }
  787. [StructLayout (LayoutKind.Sequential)]
  788. public struct NodeReplicationState {
  789. }
  790. }