Light.cs 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // Light.cs
  6. //
  7. // Copyright 2015 Xamarin Inc. All rights reserved.
  8. using System;
  9. using System.Runtime.InteropServices;
  10. using System.Collections.Generic;
  11. using Urho.Urho2D;
  12. using Urho.Gui;
  13. using Urho.Resources;
  14. using Urho.IO;
  15. using Urho.Navigation;
  16. using Urho.Network;
  17. namespace Urho
  18. {
  19. /// <summary>
  20. /// %Light component.
  21. /// </summary>
  22. public unsafe partial class Light : Drawable
  23. {
  24. unsafe partial void OnLightCreated ();
  25. [Preserve]
  26. public Light (IntPtr handle) : base (handle)
  27. {
  28. OnLightCreated ();
  29. }
  30. [Preserve]
  31. protected Light (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  32. {
  33. OnLightCreated ();
  34. }
  35. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  36. internal static extern int Light_GetType (IntPtr handle);
  37. private StringHash UrhoGetType ()
  38. {
  39. Runtime.ValidateRefCounted (this);
  40. return new StringHash (Light_GetType (handle));
  41. }
  42. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  43. internal static extern IntPtr Light_GetTypeName (IntPtr handle);
  44. private string GetTypeName ()
  45. {
  46. Runtime.ValidateRefCounted (this);
  47. return Marshal.PtrToStringAnsi (Light_GetTypeName (handle));
  48. }
  49. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  50. internal static extern int Light_GetTypeStatic ();
  51. private static StringHash GetTypeStatic ()
  52. {
  53. Runtime.Validate (typeof(Light));
  54. return new StringHash (Light_GetTypeStatic ());
  55. }
  56. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  57. internal static extern IntPtr Light_GetTypeNameStatic ();
  58. private static string GetTypeNameStatic ()
  59. {
  60. Runtime.Validate (typeof(Light));
  61. return Marshal.PtrToStringAnsi (Light_GetTypeNameStatic ());
  62. }
  63. [Preserve]
  64. public Light () : this (Application.CurrentContext)
  65. {
  66. }
  67. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  68. internal static extern IntPtr Light_Light (IntPtr context);
  69. [Preserve]
  70. public Light (Context context) : base (UrhoObjectFlag.Empty)
  71. {
  72. Runtime.Validate (typeof(Light));
  73. handle = Light_Light ((object)context == null ? IntPtr.Zero : context.Handle);
  74. Runtime.RegisterObject (this);
  75. OnLightCreated ();
  76. }
  77. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  78. internal static extern void Light_RegisterObject (IntPtr context);
  79. /// <summary>
  80. /// Register object factory. Drawable must be registered first.
  81. /// </summary>
  82. public new static void RegisterObject (Context context)
  83. {
  84. Runtime.Validate (typeof(Light));
  85. Light_RegisterObject ((object)context == null ? IntPtr.Zero : context.Handle);
  86. }
  87. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  88. internal static extern void Light_DrawDebugGeometry (IntPtr handle, IntPtr debug, bool depthTest);
  89. /// <summary>
  90. /// Visualize the component as debug geometry.
  91. /// </summary>
  92. public override void DrawDebugGeometry (DebugRenderer debug, bool depthTest)
  93. {
  94. Runtime.ValidateRefCounted (this);
  95. Light_DrawDebugGeometry (handle, (object)debug == null ? IntPtr.Zero : debug.Handle, depthTest);
  96. }
  97. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  98. internal static extern void Light_SetLightType (IntPtr handle, LightType type);
  99. /// <summary>
  100. /// Set light type.
  101. /// </summary>
  102. private void SetLightType (LightType type)
  103. {
  104. Runtime.ValidateRefCounted (this);
  105. Light_SetLightType (handle, type);
  106. }
  107. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  108. internal static extern void Light_SetPerVertex (IntPtr handle, bool enable);
  109. /// <summary>
  110. /// Set vertex lighting mode.
  111. /// </summary>
  112. private void SetPerVertex (bool enable)
  113. {
  114. Runtime.ValidateRefCounted (this);
  115. Light_SetPerVertex (handle, enable);
  116. }
  117. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  118. internal static extern void Light_SetColor (IntPtr handle, ref Urho.Color color);
  119. /// <summary>
  120. /// Set color.
  121. /// </summary>
  122. private void SetColor (Urho.Color color)
  123. {
  124. Runtime.ValidateRefCounted (this);
  125. Light_SetColor (handle, ref color);
  126. }
  127. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  128. internal static extern void Light_SetTemperature (IntPtr handle, float temperature);
  129. /// <summary>
  130. /// Set temperature of the light in Kelvin. Modulates the light color when "use physical values" is enabled.
  131. /// </summary>
  132. private void SetTemperature (float temperature)
  133. {
  134. Runtime.ValidateRefCounted (this);
  135. Light_SetTemperature (handle, temperature);
  136. }
  137. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  138. internal static extern void Light_SetRadius (IntPtr handle, float radius);
  139. /// <summary>
  140. /// Set area light radius. Greater than zero activates area light mode. Works only with PBR shaders.
  141. /// </summary>
  142. private void SetRadius (float radius)
  143. {
  144. Runtime.ValidateRefCounted (this);
  145. Light_SetRadius (handle, radius);
  146. }
  147. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  148. internal static extern void Light_SetLength (IntPtr handle, float length);
  149. /// <summary>
  150. /// Set tube area light length. Works only with PBR shaders.
  151. /// </summary>
  152. private void SetLength (float length)
  153. {
  154. Runtime.ValidateRefCounted (this);
  155. Light_SetLength (handle, length);
  156. }
  157. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  158. internal static extern void Light_SetUsePhysicalValues (IntPtr handle, bool enable);
  159. /// <summary>
  160. /// Set use physical light values.
  161. /// </summary>
  162. private void SetUsePhysicalValues (bool enable)
  163. {
  164. Runtime.ValidateRefCounted (this);
  165. Light_SetUsePhysicalValues (handle, enable);
  166. }
  167. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  168. internal static extern void Light_SetSpecularIntensity (IntPtr handle, float intensity);
  169. /// <summary>
  170. /// Set specular intensity. Zero disables specular calculations.
  171. /// </summary>
  172. private void SetSpecularIntensity (float intensity)
  173. {
  174. Runtime.ValidateRefCounted (this);
  175. Light_SetSpecularIntensity (handle, intensity);
  176. }
  177. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  178. internal static extern void Light_SetBrightness (IntPtr handle, float brightness);
  179. /// <summary>
  180. /// Set light brightness multiplier. Both the color and specular intensity are multiplied with this. When "use physical values" is enabled, the value is specified in lumens.
  181. /// </summary>
  182. private void SetBrightness (float brightness)
  183. {
  184. Runtime.ValidateRefCounted (this);
  185. Light_SetBrightness (handle, brightness);
  186. }
  187. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  188. internal static extern void Light_SetRange (IntPtr handle, float range);
  189. /// <summary>
  190. /// Set range.
  191. /// </summary>
  192. private void SetRange (float range)
  193. {
  194. Runtime.ValidateRefCounted (this);
  195. Light_SetRange (handle, range);
  196. }
  197. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  198. internal static extern void Light_SetFov (IntPtr handle, float fov);
  199. /// <summary>
  200. /// Set spotlight field of view.
  201. /// </summary>
  202. private void SetFov (float fov)
  203. {
  204. Runtime.ValidateRefCounted (this);
  205. Light_SetFov (handle, fov);
  206. }
  207. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  208. internal static extern void Light_SetAspectRatio (IntPtr handle, float aspectRatio);
  209. /// <summary>
  210. /// Set spotlight aspect ratio.
  211. /// </summary>
  212. private void SetAspectRatio (float aspectRatio)
  213. {
  214. Runtime.ValidateRefCounted (this);
  215. Light_SetAspectRatio (handle, aspectRatio);
  216. }
  217. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  218. internal static extern void Light_SetFadeDistance (IntPtr handle, float distance);
  219. /// <summary>
  220. /// Set fade out start distance.
  221. /// </summary>
  222. private void SetFadeDistance (float distance)
  223. {
  224. Runtime.ValidateRefCounted (this);
  225. Light_SetFadeDistance (handle, distance);
  226. }
  227. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  228. internal static extern void Light_SetShadowFadeDistance (IntPtr handle, float distance);
  229. /// <summary>
  230. /// Set shadow fade out start distance. Only has effect if shadow distance is also non-zero.
  231. /// </summary>
  232. private void SetShadowFadeDistance (float distance)
  233. {
  234. Runtime.ValidateRefCounted (this);
  235. Light_SetShadowFadeDistance (handle, distance);
  236. }
  237. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  238. internal static extern void Light_SetShadowBias (IntPtr handle, ref BiasParameters parameters);
  239. /// <summary>
  240. /// Set shadow depth bias parameters.
  241. /// </summary>
  242. private void SetShadowBias (BiasParameters parameters)
  243. {
  244. Runtime.ValidateRefCounted (this);
  245. Light_SetShadowBias (handle, ref parameters);
  246. }
  247. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  248. internal static extern void Light_SetShadowCascade (IntPtr handle, ref CascadeParameters parameters);
  249. /// <summary>
  250. /// Set directional light cascaded shadow parameters.
  251. /// </summary>
  252. private void SetShadowCascade (CascadeParameters parameters)
  253. {
  254. Runtime.ValidateRefCounted (this);
  255. Light_SetShadowCascade (handle, ref parameters);
  256. }
  257. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  258. internal static extern void Light_SetShadowFocus (IntPtr handle, ref FocusParameters parameters);
  259. /// <summary>
  260. /// Set shadow map focusing parameters.
  261. /// </summary>
  262. private void SetShadowFocus (FocusParameters parameters)
  263. {
  264. Runtime.ValidateRefCounted (this);
  265. Light_SetShadowFocus (handle, ref parameters);
  266. }
  267. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  268. internal static extern void Light_SetShadowIntensity (IntPtr handle, float intensity);
  269. /// <summary>
  270. /// Set light intensity in shadow between 0.0 - 1.0. 0.0 (the default) gives fully dark shadows.
  271. /// </summary>
  272. private void SetShadowIntensity (float intensity)
  273. {
  274. Runtime.ValidateRefCounted (this);
  275. Light_SetShadowIntensity (handle, intensity);
  276. }
  277. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  278. internal static extern void Light_SetShadowResolution (IntPtr handle, float resolution);
  279. /// <summary>
  280. /// Set shadow resolution between 0.25 - 1.0. Determines the shadow map to use.
  281. /// </summary>
  282. private void SetShadowResolution (float resolution)
  283. {
  284. Runtime.ValidateRefCounted (this);
  285. Light_SetShadowResolution (handle, resolution);
  286. }
  287. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  288. internal static extern void Light_SetShadowNearFarRatio (IntPtr handle, float nearFarRatio);
  289. /// <summary>
  290. /// Set shadow camera near/far clip distance ratio for spot and point lights. Does not affect directional lights, since they are orthographic and have near clip 0.
  291. /// </summary>
  292. private void SetShadowNearFarRatio (float nearFarRatio)
  293. {
  294. Runtime.ValidateRefCounted (this);
  295. Light_SetShadowNearFarRatio (handle, nearFarRatio);
  296. }
  297. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  298. internal static extern void Light_SetShadowMaxExtrusion (IntPtr handle, float extrusion);
  299. /// <summary>
  300. /// Set maximum shadow extrusion for directional lights. The actual extrusion will be the smaller of this and camera far clip. Default 1000.
  301. /// </summary>
  302. private void SetShadowMaxExtrusion (float extrusion)
  303. {
  304. Runtime.ValidateRefCounted (this);
  305. Light_SetShadowMaxExtrusion (handle, extrusion);
  306. }
  307. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  308. internal static extern void Light_SetRampTexture (IntPtr handle, IntPtr texture);
  309. /// <summary>
  310. /// Set range attenuation texture.
  311. /// </summary>
  312. private void SetRampTexture (Texture texture)
  313. {
  314. Runtime.ValidateRefCounted (this);
  315. Light_SetRampTexture (handle, (object)texture == null ? IntPtr.Zero : texture.Handle);
  316. }
  317. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  318. internal static extern void Light_SetShapeTexture (IntPtr handle, IntPtr texture);
  319. /// <summary>
  320. /// Set spotlight attenuation texture.
  321. /// </summary>
  322. private void SetShapeTexture (Texture texture)
  323. {
  324. Runtime.ValidateRefCounted (this);
  325. Light_SetShapeTexture (handle, (object)texture == null ? IntPtr.Zero : texture.Handle);
  326. }
  327. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  328. internal static extern LightType Light_GetLightType (IntPtr handle);
  329. /// <summary>
  330. /// Return light type.
  331. /// </summary>
  332. private LightType GetLightType ()
  333. {
  334. Runtime.ValidateRefCounted (this);
  335. return Light_GetLightType (handle);
  336. }
  337. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  338. internal static extern bool Light_GetPerVertex (IntPtr handle);
  339. /// <summary>
  340. /// Return vertex lighting mode.
  341. /// </summary>
  342. private bool GetPerVertex ()
  343. {
  344. Runtime.ValidateRefCounted (this);
  345. return Light_GetPerVertex (handle);
  346. }
  347. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  348. internal static extern Urho.Color Light_GetColor (IntPtr handle);
  349. /// <summary>
  350. /// Return color.
  351. /// </summary>
  352. private Urho.Color GetColor ()
  353. {
  354. Runtime.ValidateRefCounted (this);
  355. return Light_GetColor (handle);
  356. }
  357. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  358. internal static extern float Light_GetTemperature (IntPtr handle);
  359. /// <summary>
  360. /// Return the temperature of the light in Kelvin.
  361. /// </summary>
  362. private float GetTemperature ()
  363. {
  364. Runtime.ValidateRefCounted (this);
  365. return Light_GetTemperature (handle);
  366. }
  367. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  368. internal static extern float Light_GetRadius (IntPtr handle);
  369. /// <summary>
  370. /// Return area light mode radius. Works only with PBR shaders.
  371. /// </summary>
  372. private float GetRadius ()
  373. {
  374. Runtime.ValidateRefCounted (this);
  375. return Light_GetRadius (handle);
  376. }
  377. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  378. internal static extern float Light_GetLength (IntPtr handle);
  379. /// <summary>
  380. /// Return area tube light length. Works only with PBR shaders.
  381. /// </summary>
  382. private float GetLength ()
  383. {
  384. Runtime.ValidateRefCounted (this);
  385. return Light_GetLength (handle);
  386. }
  387. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  388. internal static extern bool Light_GetUsePhysicalValues (IntPtr handle);
  389. /// <summary>
  390. /// Return if light uses temperature and brightness in lumens.
  391. /// </summary>
  392. private bool GetUsePhysicalValues ()
  393. {
  394. Runtime.ValidateRefCounted (this);
  395. return Light_GetUsePhysicalValues (handle);
  396. }
  397. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  398. internal static extern Color Light_GetColorFromTemperature (IntPtr handle);
  399. /// <summary>
  400. /// Return the color value of the temperature in Kelvin.
  401. /// </summary>
  402. private Color GetColorFromTemperature ()
  403. {
  404. Runtime.ValidateRefCounted (this);
  405. return Light_GetColorFromTemperature (handle);
  406. }
  407. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  408. internal static extern float Light_GetSpecularIntensity (IntPtr handle);
  409. /// <summary>
  410. /// Return specular intensity.
  411. /// </summary>
  412. private float GetSpecularIntensity ()
  413. {
  414. Runtime.ValidateRefCounted (this);
  415. return Light_GetSpecularIntensity (handle);
  416. }
  417. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  418. internal static extern float Light_GetBrightness (IntPtr handle);
  419. /// <summary>
  420. /// Return brightness multiplier. Specified in lumens when "use physical values" is enabled.
  421. /// </summary>
  422. private float GetBrightness ()
  423. {
  424. Runtime.ValidateRefCounted (this);
  425. return Light_GetBrightness (handle);
  426. }
  427. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  428. internal static extern Color Light_GetEffectiveColor (IntPtr handle);
  429. /// <summary>
  430. /// Return effective color, multiplied by brightness and affected by temperature when "use physical values" is enabled. Alpha is always 1 so that can compare against the default black color to detect a light with no effect.
  431. /// </summary>
  432. private Color GetEffectiveColor ()
  433. {
  434. Runtime.ValidateRefCounted (this);
  435. return Light_GetEffectiveColor (handle);
  436. }
  437. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  438. internal static extern float Light_GetEffectiveSpecularIntensity (IntPtr handle);
  439. /// <summary>
  440. /// Return effective specular intensity, multiplied by absolute value of brightness.
  441. /// </summary>
  442. private float GetEffectiveSpecularIntensity ()
  443. {
  444. Runtime.ValidateRefCounted (this);
  445. return Light_GetEffectiveSpecularIntensity (handle);
  446. }
  447. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  448. internal static extern float Light_GetRange (IntPtr handle);
  449. /// <summary>
  450. /// Return range.
  451. /// </summary>
  452. private float GetRange ()
  453. {
  454. Runtime.ValidateRefCounted (this);
  455. return Light_GetRange (handle);
  456. }
  457. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  458. internal static extern float Light_GetFov (IntPtr handle);
  459. /// <summary>
  460. /// Return spotlight field of view.
  461. /// </summary>
  462. private float GetFov ()
  463. {
  464. Runtime.ValidateRefCounted (this);
  465. return Light_GetFov (handle);
  466. }
  467. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  468. internal static extern float Light_GetAspectRatio (IntPtr handle);
  469. /// <summary>
  470. /// Return spotlight aspect ratio.
  471. /// </summary>
  472. private float GetAspectRatio ()
  473. {
  474. Runtime.ValidateRefCounted (this);
  475. return Light_GetAspectRatio (handle);
  476. }
  477. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  478. internal static extern float Light_GetFadeDistance (IntPtr handle);
  479. /// <summary>
  480. /// Return fade start distance.
  481. /// </summary>
  482. private float GetFadeDistance ()
  483. {
  484. Runtime.ValidateRefCounted (this);
  485. return Light_GetFadeDistance (handle);
  486. }
  487. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  488. internal static extern float Light_GetShadowFadeDistance (IntPtr handle);
  489. /// <summary>
  490. /// Return shadow fade start distance.
  491. /// </summary>
  492. private float GetShadowFadeDistance ()
  493. {
  494. Runtime.ValidateRefCounted (this);
  495. return Light_GetShadowFadeDistance (handle);
  496. }
  497. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  498. internal static extern BiasParameters Light_GetShadowBias (IntPtr handle);
  499. /// <summary>
  500. /// Return shadow depth bias parameters.
  501. /// </summary>
  502. private BiasParameters GetShadowBias ()
  503. {
  504. Runtime.ValidateRefCounted (this);
  505. return Light_GetShadowBias (handle);
  506. }
  507. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  508. internal static extern CascadeParameters Light_GetShadowCascade (IntPtr handle);
  509. /// <summary>
  510. /// Return directional light cascaded shadow parameters.
  511. /// </summary>
  512. private CascadeParameters GetShadowCascade ()
  513. {
  514. Runtime.ValidateRefCounted (this);
  515. return Light_GetShadowCascade (handle);
  516. }
  517. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  518. internal static extern FocusParameters Light_GetShadowFocus (IntPtr handle);
  519. /// <summary>
  520. /// Return shadow map focus parameters.
  521. /// </summary>
  522. private FocusParameters GetShadowFocus ()
  523. {
  524. Runtime.ValidateRefCounted (this);
  525. return Light_GetShadowFocus (handle);
  526. }
  527. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  528. internal static extern float Light_GetShadowIntensity (IntPtr handle);
  529. /// <summary>
  530. /// Return light intensity in shadow.
  531. /// </summary>
  532. private float GetShadowIntensity ()
  533. {
  534. Runtime.ValidateRefCounted (this);
  535. return Light_GetShadowIntensity (handle);
  536. }
  537. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  538. internal static extern float Light_GetShadowResolution (IntPtr handle);
  539. /// <summary>
  540. /// Return shadow resolution.
  541. /// </summary>
  542. private float GetShadowResolution ()
  543. {
  544. Runtime.ValidateRefCounted (this);
  545. return Light_GetShadowResolution (handle);
  546. }
  547. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  548. internal static extern float Light_GetShadowNearFarRatio (IntPtr handle);
  549. /// <summary>
  550. /// Return shadow camera near/far clip distance ratio.
  551. /// </summary>
  552. private float GetShadowNearFarRatio ()
  553. {
  554. Runtime.ValidateRefCounted (this);
  555. return Light_GetShadowNearFarRatio (handle);
  556. }
  557. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  558. internal static extern float Light_GetShadowMaxExtrusion (IntPtr handle);
  559. /// <summary>
  560. /// Return maximum shadow extrusion distance for directional lights.
  561. /// </summary>
  562. private float GetShadowMaxExtrusion ()
  563. {
  564. Runtime.ValidateRefCounted (this);
  565. return Light_GetShadowMaxExtrusion (handle);
  566. }
  567. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  568. internal static extern IntPtr Light_GetRampTexture (IntPtr handle);
  569. /// <summary>
  570. /// Return range attenuation texture.
  571. /// </summary>
  572. private Texture GetRampTexture ()
  573. {
  574. Runtime.ValidateRefCounted (this);
  575. return Runtime.LookupObject<Texture> (Light_GetRampTexture (handle));
  576. }
  577. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  578. internal static extern IntPtr Light_GetShapeTexture (IntPtr handle);
  579. /// <summary>
  580. /// Return spotlight attenuation texture.
  581. /// </summary>
  582. private Texture GetShapeTexture ()
  583. {
  584. Runtime.ValidateRefCounted (this);
  585. return Runtime.LookupObject<Texture> (Light_GetShapeTexture (handle));
  586. }
  587. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  588. internal static extern IntPtr Light_GetFrustum (IntPtr handle);
  589. /// <summary>
  590. /// Return spotlight frustum.
  591. /// </summary>
  592. private Frustum GetFrustum ()
  593. {
  594. Runtime.ValidateRefCounted (this);
  595. return new Frustum (Light_GetFrustum (handle));
  596. }
  597. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  598. internal static extern IntPtr Light_GetViewSpaceFrustum (IntPtr handle, ref Urho.Matrix3x4 view);
  599. /// <summary>
  600. /// Return spotlight frustum in the specified view space.
  601. /// </summary>
  602. public Frustum GetViewSpaceFrustum (Urho.Matrix3x4 view)
  603. {
  604. Runtime.ValidateRefCounted (this);
  605. return new Frustum (Light_GetViewSpaceFrustum (handle, ref view));
  606. }
  607. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  608. internal static extern int Light_GetNumShadowSplits (IntPtr handle);
  609. /// <summary>
  610. /// Return number of shadow map cascade splits for a directional light, considering also graphics API limitations.
  611. /// </summary>
  612. private int GetNumShadowSplits ()
  613. {
  614. Runtime.ValidateRefCounted (this);
  615. return Light_GetNumShadowSplits (handle);
  616. }
  617. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  618. internal static extern bool Light_IsNegative (IntPtr handle);
  619. /// <summary>
  620. /// Return whether light has negative (darkening) color.
  621. /// </summary>
  622. private bool IsNegative ()
  623. {
  624. Runtime.ValidateRefCounted (this);
  625. return Light_IsNegative (handle);
  626. }
  627. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  628. internal static extern void Light_SetIntensitySortValue (IntPtr handle, float distance);
  629. /// <summary>
  630. /// Set sort value based on intensity and view distance.
  631. /// </summary>
  632. public void SetIntensitySortValue (float distance)
  633. {
  634. Runtime.ValidateRefCounted (this);
  635. Light_SetIntensitySortValue (handle, distance);
  636. }
  637. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  638. internal static extern void Light_SetIntensitySortValue0 (IntPtr handle, ref Urho.BoundingBox box);
  639. /// <summary>
  640. /// Set sort value based on overall intensity over a bounding box.
  641. /// </summary>
  642. public void SetIntensitySortValue (Urho.BoundingBox box)
  643. {
  644. Runtime.ValidateRefCounted (this);
  645. Light_SetIntensitySortValue0 (handle, ref box);
  646. }
  647. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  648. internal static extern void Light_SetLightQueue (IntPtr handle, LightBatchQueue* queue);
  649. /// <summary>
  650. /// Set light queue used for this light. Called by View.
  651. /// </summary>
  652. private void SetLightQueue (LightBatchQueue* queue)
  653. {
  654. Runtime.ValidateRefCounted (this);
  655. Light_SetLightQueue (handle, queue);
  656. }
  657. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  658. internal static extern Urho.Matrix3x4 Light_GetVolumeTransform (IntPtr handle, IntPtr camera);
  659. /// <summary>
  660. /// Return light volume model transform.
  661. /// </summary>
  662. public Urho.Matrix3x4 GetVolumeTransform (Camera camera)
  663. {
  664. Runtime.ValidateRefCounted (this);
  665. return Light_GetVolumeTransform (handle, (object)camera == null ? IntPtr.Zero : camera.Handle);
  666. }
  667. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  668. internal static extern LightBatchQueue* Light_GetLightQueue (IntPtr handle);
  669. /// <summary>
  670. /// Return light queue. Called by View.
  671. /// </summary>
  672. private LightBatchQueue* GetLightQueue ()
  673. {
  674. Runtime.ValidateRefCounted (this);
  675. return Light_GetLightQueue (handle);
  676. }
  677. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  678. internal static extern float Light_GetIntensityDivisor (IntPtr handle, float attenuation);
  679. /// <summary>
  680. /// Return a divisor value based on intensity for calculating the sort value.
  681. /// </summary>
  682. public float GetIntensityDivisor (float attenuation = 1f)
  683. {
  684. Runtime.ValidateRefCounted (this);
  685. return Light_GetIntensityDivisor (handle, attenuation);
  686. }
  687. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  688. internal static extern ResourceRef Light_GetRampTextureAttr (IntPtr handle);
  689. /// <summary>
  690. /// Return ramp texture attribute.
  691. /// </summary>
  692. private ResourceRef GetRampTextureAttr ()
  693. {
  694. Runtime.ValidateRefCounted (this);
  695. return Light_GetRampTextureAttr (handle);
  696. }
  697. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  698. internal static extern ResourceRef Light_GetShapeTextureAttr (IntPtr handle);
  699. /// <summary>
  700. /// Return shape texture attribute.
  701. /// </summary>
  702. private ResourceRef GetShapeTextureAttr ()
  703. {
  704. Runtime.ValidateRefCounted (this);
  705. return Light_GetShapeTextureAttr (handle);
  706. }
  707. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  708. internal static extern Matrix3x4 Light_GetFullscreenQuadTransform (IntPtr camera);
  709. /// <summary>
  710. /// Return a transform for deferred fullscreen quad (directional light) rendering.
  711. /// </summary>
  712. public static Matrix3x4 GetFullscreenQuadTransform (Camera camera)
  713. {
  714. Runtime.Validate (typeof(Light));
  715. return Light_GetFullscreenQuadTransform ((object)camera == null ? IntPtr.Zero : camera.Handle);
  716. }
  717. public override StringHash Type {
  718. get {
  719. return UrhoGetType ();
  720. }
  721. }
  722. public override string TypeName {
  723. get {
  724. return GetTypeName ();
  725. }
  726. }
  727. [Preserve]
  728. public new static StringHash TypeStatic {
  729. get {
  730. return GetTypeStatic ();
  731. }
  732. }
  733. public new static string TypeNameStatic {
  734. get {
  735. return GetTypeNameStatic ();
  736. }
  737. }
  738. /// <summary>
  739. /// Return light type.
  740. /// Or
  741. /// Set light type.
  742. /// </summary>
  743. public LightType LightType {
  744. get {
  745. return GetLightType ();
  746. }
  747. set {
  748. SetLightType (value);
  749. }
  750. }
  751. /// <summary>
  752. /// Return vertex lighting mode.
  753. /// Or
  754. /// Set vertex lighting mode.
  755. /// </summary>
  756. public bool PerVertex {
  757. get {
  758. return GetPerVertex ();
  759. }
  760. set {
  761. SetPerVertex (value);
  762. }
  763. }
  764. /// <summary>
  765. /// Return color.
  766. /// Or
  767. /// Set color.
  768. /// </summary>
  769. public Urho.Color Color {
  770. get {
  771. return GetColor ();
  772. }
  773. set {
  774. SetColor (value);
  775. }
  776. }
  777. /// <summary>
  778. /// Return the temperature of the light in Kelvin.
  779. /// Or
  780. /// Set temperature of the light in Kelvin. Modulates the light color when "use physical values" is enabled.
  781. /// </summary>
  782. public float Temperature {
  783. get {
  784. return GetTemperature ();
  785. }
  786. set {
  787. SetTemperature (value);
  788. }
  789. }
  790. /// <summary>
  791. /// Return area light mode radius. Works only with PBR shaders.
  792. /// Or
  793. /// Set area light radius. Greater than zero activates area light mode. Works only with PBR shaders.
  794. /// </summary>
  795. public float Radius {
  796. get {
  797. return GetRadius ();
  798. }
  799. set {
  800. SetRadius (value);
  801. }
  802. }
  803. /// <summary>
  804. /// Return area tube light length. Works only with PBR shaders.
  805. /// Or
  806. /// Set tube area light length. Works only with PBR shaders.
  807. /// </summary>
  808. public float Length {
  809. get {
  810. return GetLength ();
  811. }
  812. set {
  813. SetLength (value);
  814. }
  815. }
  816. /// <summary>
  817. /// Return if light uses temperature and brightness in lumens.
  818. /// Or
  819. /// Set use physical light values.
  820. /// </summary>
  821. public bool UsePhysicalValues {
  822. get {
  823. return GetUsePhysicalValues ();
  824. }
  825. set {
  826. SetUsePhysicalValues (value);
  827. }
  828. }
  829. /// <summary>
  830. /// Return specular intensity.
  831. /// Or
  832. /// Set specular intensity. Zero disables specular calculations.
  833. /// </summary>
  834. public float SpecularIntensity {
  835. get {
  836. return GetSpecularIntensity ();
  837. }
  838. set {
  839. SetSpecularIntensity (value);
  840. }
  841. }
  842. /// <summary>
  843. /// Return brightness multiplier. Specified in lumens when "use physical values" is enabled.
  844. /// Or
  845. /// Set light brightness multiplier. Both the color and specular intensity are multiplied with this. When "use physical values" is enabled, the value is specified in lumens.
  846. /// </summary>
  847. public float Brightness {
  848. get {
  849. return GetBrightness ();
  850. }
  851. set {
  852. SetBrightness (value);
  853. }
  854. }
  855. /// <summary>
  856. /// Return range.
  857. /// Or
  858. /// Set range.
  859. /// </summary>
  860. public float Range {
  861. get {
  862. return GetRange ();
  863. }
  864. set {
  865. SetRange (value);
  866. }
  867. }
  868. /// <summary>
  869. /// Return spotlight field of view.
  870. /// Or
  871. /// Set spotlight field of view.
  872. /// </summary>
  873. public float Fov {
  874. get {
  875. return GetFov ();
  876. }
  877. set {
  878. SetFov (value);
  879. }
  880. }
  881. /// <summary>
  882. /// Return spotlight aspect ratio.
  883. /// Or
  884. /// Set spotlight aspect ratio.
  885. /// </summary>
  886. public float AspectRatio {
  887. get {
  888. return GetAspectRatio ();
  889. }
  890. set {
  891. SetAspectRatio (value);
  892. }
  893. }
  894. /// <summary>
  895. /// Return fade start distance.
  896. /// Or
  897. /// Set fade out start distance.
  898. /// </summary>
  899. public float FadeDistance {
  900. get {
  901. return GetFadeDistance ();
  902. }
  903. set {
  904. SetFadeDistance (value);
  905. }
  906. }
  907. /// <summary>
  908. /// Return shadow fade start distance.
  909. /// Or
  910. /// Set shadow fade out start distance. Only has effect if shadow distance is also non-zero.
  911. /// </summary>
  912. public float ShadowFadeDistance {
  913. get {
  914. return GetShadowFadeDistance ();
  915. }
  916. set {
  917. SetShadowFadeDistance (value);
  918. }
  919. }
  920. /// <summary>
  921. /// Return shadow depth bias parameters.
  922. /// Or
  923. /// Set shadow depth bias parameters.
  924. /// </summary>
  925. public BiasParameters ShadowBias {
  926. get {
  927. return GetShadowBias ();
  928. }
  929. set {
  930. SetShadowBias (value);
  931. }
  932. }
  933. /// <summary>
  934. /// Return directional light cascaded shadow parameters.
  935. /// Or
  936. /// Set directional light cascaded shadow parameters.
  937. /// </summary>
  938. public CascadeParameters ShadowCascade {
  939. get {
  940. return GetShadowCascade ();
  941. }
  942. set {
  943. SetShadowCascade (value);
  944. }
  945. }
  946. /// <summary>
  947. /// Return shadow map focus parameters.
  948. /// Or
  949. /// Set shadow map focusing parameters.
  950. /// </summary>
  951. public FocusParameters ShadowFocus {
  952. get {
  953. return GetShadowFocus ();
  954. }
  955. set {
  956. SetShadowFocus (value);
  957. }
  958. }
  959. /// <summary>
  960. /// Return light intensity in shadow.
  961. /// Or
  962. /// Set light intensity in shadow between 0.0 - 1.0. 0.0 (the default) gives fully dark shadows.
  963. /// </summary>
  964. public float ShadowIntensity {
  965. get {
  966. return GetShadowIntensity ();
  967. }
  968. set {
  969. SetShadowIntensity (value);
  970. }
  971. }
  972. /// <summary>
  973. /// Return shadow resolution.
  974. /// Or
  975. /// Set shadow resolution between 0.25 - 1.0. Determines the shadow map to use.
  976. /// </summary>
  977. public float ShadowResolution {
  978. get {
  979. return GetShadowResolution ();
  980. }
  981. set {
  982. SetShadowResolution (value);
  983. }
  984. }
  985. /// <summary>
  986. /// Return shadow camera near/far clip distance ratio.
  987. /// Or
  988. /// Set shadow camera near/far clip distance ratio for spot and point lights. Does not affect directional lights, since they are orthographic and have near clip 0.
  989. /// </summary>
  990. public float ShadowNearFarRatio {
  991. get {
  992. return GetShadowNearFarRatio ();
  993. }
  994. set {
  995. SetShadowNearFarRatio (value);
  996. }
  997. }
  998. /// <summary>
  999. /// Return maximum shadow extrusion distance for directional lights.
  1000. /// Or
  1001. /// Set maximum shadow extrusion for directional lights. The actual extrusion will be the smaller of this and camera far clip. Default 1000.
  1002. /// </summary>
  1003. public float ShadowMaxExtrusion {
  1004. get {
  1005. return GetShadowMaxExtrusion ();
  1006. }
  1007. set {
  1008. SetShadowMaxExtrusion (value);
  1009. }
  1010. }
  1011. /// <summary>
  1012. /// Return range attenuation texture.
  1013. /// Or
  1014. /// Set range attenuation texture.
  1015. /// </summary>
  1016. public Texture RampTexture {
  1017. get {
  1018. return GetRampTexture ();
  1019. }
  1020. set {
  1021. SetRampTexture (value);
  1022. }
  1023. }
  1024. /// <summary>
  1025. /// Return spotlight attenuation texture.
  1026. /// Or
  1027. /// Set spotlight attenuation texture.
  1028. /// </summary>
  1029. public Texture ShapeTexture {
  1030. get {
  1031. return GetShapeTexture ();
  1032. }
  1033. set {
  1034. SetShapeTexture (value);
  1035. }
  1036. }
  1037. /// <summary>
  1038. /// Return the color value of the temperature in Kelvin.
  1039. /// </summary>
  1040. public Color ColorFromTemperature {
  1041. get {
  1042. return GetColorFromTemperature ();
  1043. }
  1044. }
  1045. /// <summary>
  1046. /// Return effective color, multiplied by brightness and affected by temperature when "use physical values" is enabled. Alpha is always 1 so that can compare against the default black color to detect a light with no effect.
  1047. /// </summary>
  1048. public Color EffectiveColor {
  1049. get {
  1050. return GetEffectiveColor ();
  1051. }
  1052. }
  1053. /// <summary>
  1054. /// Return effective specular intensity, multiplied by absolute value of brightness.
  1055. /// </summary>
  1056. public float EffectiveSpecularIntensity {
  1057. get {
  1058. return GetEffectiveSpecularIntensity ();
  1059. }
  1060. }
  1061. /// <summary>
  1062. /// Return spotlight frustum.
  1063. /// </summary>
  1064. public Frustum Frustum {
  1065. get {
  1066. return GetFrustum ();
  1067. }
  1068. }
  1069. /// <summary>
  1070. /// Return number of shadow map cascade splits for a directional light, considering also graphics API limitations.
  1071. /// </summary>
  1072. public int NumShadowSplits {
  1073. get {
  1074. return GetNumShadowSplits ();
  1075. }
  1076. }
  1077. /// <summary>
  1078. /// Return whether light has negative (darkening) color.
  1079. /// </summary>
  1080. public bool Negative {
  1081. get {
  1082. return IsNegative ();
  1083. }
  1084. }
  1085. /// <summary>
  1086. /// Return light queue. Called by View.
  1087. /// Or
  1088. /// Set light queue used for this light. Called by View.
  1089. /// </summary>
  1090. public LightBatchQueue* LightQueue {
  1091. get {
  1092. return GetLightQueue ();
  1093. }
  1094. set {
  1095. SetLightQueue (value);
  1096. }
  1097. }
  1098. /// <summary>
  1099. /// Return ramp texture attribute.
  1100. /// </summary>
  1101. public ResourceRef RampTextureAttr {
  1102. get {
  1103. return GetRampTextureAttr ();
  1104. }
  1105. }
  1106. /// <summary>
  1107. /// Return shape texture attribute.
  1108. /// </summary>
  1109. public ResourceRef ShapeTextureAttr {
  1110. get {
  1111. return GetShapeTextureAttr ();
  1112. }
  1113. }
  1114. }
  1115. }