ImportOptions.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using System.Runtime.CompilerServices;
  5. using BansheeEngine;
  6. namespace BansheeEditor
  7. {
  8. /** @addtogroup Library
  9. * @{
  10. */
  11. /// <summary>
  12. /// Base class for all import options. Allows control over how is a specific resource type imported.
  13. /// </summary>
  14. public class ImportOptions : ScriptObject
  15. {
  16. }
  17. /// <summary>
  18. /// Provides options for controlling how is a texture resource imported.
  19. /// </summary>
  20. public class TextureImportOptions : ImportOptions
  21. {
  22. /// <summary>
  23. /// Creates new texture import options with default values.
  24. /// </summary>
  25. public TextureImportOptions()
  26. {
  27. Internal_CreateInstance(this);
  28. }
  29. /// <summary>
  30. /// Pixel format to import as.
  31. /// </summary>
  32. public PixelFormat Format
  33. {
  34. get { return Internal_GetPixelFormat(mCachedPtr); }
  35. set { Internal_SetPixelFormat(mCachedPtr, value); }
  36. }
  37. /// <summary>
  38. /// Determines whether the imported texture will have mipmaps generated.
  39. /// </summary>
  40. public bool GenerateMipmaps
  41. {
  42. get { return Internal_GetGenerateMipmaps(mCachedPtr); }
  43. set { Internal_SetGenerateMipmaps(mCachedPtr, value); }
  44. }
  45. /// <summary>
  46. /// Maximum mipmap level to generate, if mipmap generation is enabled.
  47. /// </summary>
  48. public int MaxMipmapLevel
  49. {
  50. get { return Internal_GetMaxMipmapLevel(mCachedPtr); }
  51. set { Internal_SetMaxMipmapLevel(mCachedPtr, value); }
  52. }
  53. /// <summary>
  54. /// Determines whether the texture data is also stored in main memory, available for fast CPU access.
  55. /// </summary>
  56. public bool CPUReadable
  57. {
  58. get { return Internal_GetCPUReadable(mCachedPtr); }
  59. set { Internal_SetCPUReadable(mCachedPtr, value); }
  60. }
  61. /// <summary>
  62. /// Determines should the texture data be treated as if its in sRGB (gamma) space. Such texture will be converted by
  63. /// hardware to linear space before use on the GPU.
  64. /// </summary>
  65. public bool IsSRGB
  66. {
  67. get { return Internal_GetIsSRGB(mCachedPtr); }
  68. set { Internal_SetIsSRGB(mCachedPtr, value); }
  69. }
  70. [MethodImpl(MethodImplOptions.InternalCall)]
  71. private static extern void Internal_CreateInstance(TextureImportOptions instance);
  72. [MethodImpl(MethodImplOptions.InternalCall)]
  73. private static extern PixelFormat Internal_GetPixelFormat(IntPtr thisPtr);
  74. [MethodImpl(MethodImplOptions.InternalCall)]
  75. private static extern void Internal_SetPixelFormat(IntPtr thisPtr, PixelFormat value);
  76. [MethodImpl(MethodImplOptions.InternalCall)]
  77. private static extern bool Internal_GetGenerateMipmaps(IntPtr thisPtr);
  78. [MethodImpl(MethodImplOptions.InternalCall)]
  79. private static extern void Internal_SetGenerateMipmaps(IntPtr thisPtr, bool value);
  80. [MethodImpl(MethodImplOptions.InternalCall)]
  81. private static extern int Internal_GetMaxMipmapLevel(IntPtr thisPtr);
  82. [MethodImpl(MethodImplOptions.InternalCall)]
  83. private static extern void Internal_SetMaxMipmapLevel(IntPtr thisPtr, int value);
  84. [MethodImpl(MethodImplOptions.InternalCall)]
  85. private static extern bool Internal_GetCPUReadable(IntPtr thisPtr);
  86. [MethodImpl(MethodImplOptions.InternalCall)]
  87. private static extern void Internal_SetCPUReadable(IntPtr thisPtr, bool value);
  88. [MethodImpl(MethodImplOptions.InternalCall)]
  89. private static extern bool Internal_GetIsSRGB(IntPtr thisPtr);
  90. [MethodImpl(MethodImplOptions.InternalCall)]
  91. private static extern void Internal_SetIsSRGB(IntPtr thisPtr, bool value);
  92. }
  93. /// <summary>
  94. /// Information about how to split an AnimationClip into multiple separate clips.
  95. /// </summary>
  96. public class AnimationSplitInfo
  97. {
  98. public AnimationSplitInfo() { }
  99. public AnimationSplitInfo(string name, int startFrame, int endFrame, bool isAdditive)
  100. {
  101. this.name = name;
  102. this.startFrame = startFrame;
  103. this.endFrame = endFrame;
  104. this.isAdditive = isAdditive;
  105. }
  106. public string name;
  107. public int startFrame = 0;
  108. public int endFrame = 0;
  109. public bool isAdditive = false;
  110. }
  111. /// <summary>
  112. /// Provides options for controlling how is a mesh resource imported.
  113. /// </summary>
  114. public class MeshImportOptions : ImportOptions
  115. {
  116. /// <summary>
  117. /// Creates new mesh import options with default values.
  118. /// </summary>
  119. public MeshImportOptions()
  120. {
  121. Internal_CreateInstance(this);
  122. }
  123. /// <summary>
  124. /// Determines whether the mesh data is also stored in main memory, available for fast CPU access.
  125. /// </summary>
  126. public bool CPUReadable
  127. {
  128. get { return Internal_GetCPUReadable(mCachedPtr); }
  129. set { Internal_SetCPUReadable(mCachedPtr, value); }
  130. }
  131. /// <summary>
  132. /// Controls should mesh normals be imported if available.
  133. /// </summary>
  134. public bool ImportNormals
  135. {
  136. get { return Internal_GetImportNormals(mCachedPtr); }
  137. set { Internal_SetImportNormals(mCachedPtr, value); }
  138. }
  139. /// <summary>
  140. /// Controls should mesh tangents/bitangents be imported if available.
  141. /// </summary>
  142. public bool ImportTangents
  143. {
  144. get { return Internal_GetImportTangents(mCachedPtr); }
  145. set { Internal_SetImportTangents(mCachedPtr, value); }
  146. }
  147. /// <summary>
  148. /// Controls should mesh skin data like bone weights, indices and bind poses be imported if available.
  149. /// </summary>
  150. public bool ImportSkin
  151. {
  152. get { return Internal_GetImportSkin(mCachedPtr); }
  153. set { Internal_SetImportSkin(mCachedPtr, value); }
  154. }
  155. /// <summary>
  156. /// Controls should animation clips be imported if available.
  157. /// </summary>
  158. public bool ImportAnimation
  159. {
  160. get { return Internal_GetImportAnimation(mCachedPtr); }
  161. set { Internal_SetImportAnimation(mCachedPtr, value); }
  162. }
  163. /// <summary>
  164. /// Controls should mesh blend shapes be imported if available.
  165. /// </summary>
  166. public bool ImportBlendShapes
  167. {
  168. get { return Internal_GetImportBlendShapes(mCachedPtr); }
  169. set { Internal_SetImportBlendShapes(mCachedPtr, value); }
  170. }
  171. /// <summary>
  172. /// Uniformly scales the imported mesh by the specified value.
  173. /// </summary>
  174. public float Scale
  175. {
  176. get { return Internal_GetScale(mCachedPtr); }
  177. set { Internal_SetScale(mCachedPtr, value); }
  178. }
  179. /// <summary>
  180. /// Determines if keyframe reduction is enabled. Keyframe reduction will reduce the number of key-frames in an
  181. /// animation clip by removing identical keyframes, and therefore reducing the size of the clip.
  182. /// </summary>
  183. public bool KeyframeReduction
  184. {
  185. get { return Internal_GetKeyFrameReduction(mCachedPtr); }
  186. set { Internal_SetKeyFrameReduction(mCachedPtr, value); }
  187. }
  188. /// <summary>
  189. /// Controls what type (if any) of collision mesh should be imported.
  190. /// </summary>
  191. public CollisionMeshType CollisionMeshType
  192. {
  193. get { return (CollisionMeshType)Internal_GetCollisionMeshType(mCachedPtr); }
  194. set { Internal_SetCollisionMeshType(mCachedPtr, (int)value); }
  195. }
  196. /// <summary>
  197. /// Split information that allows you to split the animation clip contained in the mesh file into multiple separate
  198. /// clips. The split always applies to the first clip in the file (if the file contains multiple), other clips are
  199. /// imported as is.
  200. /// </summary>
  201. public AnimationSplitInfo[] AnimationClipSplits
  202. {
  203. get { return Internal_GetAnimationClipSplits(mCachedPtr); }
  204. set { Internal_SetAnimationClipSplits(mCachedPtr, value); }
  205. }
  206. [MethodImpl(MethodImplOptions.InternalCall)]
  207. private static extern void Internal_CreateInstance(MeshImportOptions instance);
  208. [MethodImpl(MethodImplOptions.InternalCall)]
  209. private static extern bool Internal_GetCPUReadable(IntPtr thisPtr);
  210. [MethodImpl(MethodImplOptions.InternalCall)]
  211. private static extern void Internal_SetCPUReadable(IntPtr thisPtr, bool value);
  212. [MethodImpl(MethodImplOptions.InternalCall)]
  213. private static extern bool Internal_GetImportNormals(IntPtr thisPtr);
  214. [MethodImpl(MethodImplOptions.InternalCall)]
  215. private static extern void Internal_SetImportNormals(IntPtr thisPtr, bool value);
  216. [MethodImpl(MethodImplOptions.InternalCall)]
  217. private static extern bool Internal_GetImportTangents(IntPtr thisPtr);
  218. [MethodImpl(MethodImplOptions.InternalCall)]
  219. private static extern void Internal_SetImportTangents(IntPtr thisPtr, bool value);
  220. [MethodImpl(MethodImplOptions.InternalCall)]
  221. private static extern bool Internal_GetImportSkin(IntPtr thisPtr);
  222. [MethodImpl(MethodImplOptions.InternalCall)]
  223. private static extern void Internal_SetImportSkin(IntPtr thisPtr, bool value);
  224. [MethodImpl(MethodImplOptions.InternalCall)]
  225. private static extern bool Internal_GetImportAnimation(IntPtr thisPtr);
  226. [MethodImpl(MethodImplOptions.InternalCall)]
  227. private static extern void Internal_SetImportAnimation(IntPtr thisPtr, bool value);
  228. [MethodImpl(MethodImplOptions.InternalCall)]
  229. private static extern bool Internal_GetImportBlendShapes(IntPtr thisPtr);
  230. [MethodImpl(MethodImplOptions.InternalCall)]
  231. private static extern void Internal_SetImportBlendShapes(IntPtr thisPtr, bool value);
  232. [MethodImpl(MethodImplOptions.InternalCall)]
  233. private static extern bool Internal_GetKeyFrameReduction(IntPtr thisPtr);
  234. [MethodImpl(MethodImplOptions.InternalCall)]
  235. private static extern void Internal_SetKeyFrameReduction(IntPtr thisPtr, bool value);
  236. [MethodImpl(MethodImplOptions.InternalCall)]
  237. private static extern AnimationSplitInfo[] Internal_GetAnimationClipSplits(IntPtr thisPtr);
  238. [MethodImpl(MethodImplOptions.InternalCall)]
  239. private static extern void Internal_SetAnimationClipSplits(IntPtr thisPtr, AnimationSplitInfo[] value);
  240. [MethodImpl(MethodImplOptions.InternalCall)]
  241. private static extern float Internal_GetScale(IntPtr thisPtr);
  242. [MethodImpl(MethodImplOptions.InternalCall)]
  243. private static extern void Internal_SetScale(IntPtr thisPtr, float value);
  244. [MethodImpl(MethodImplOptions.InternalCall)]
  245. private static extern int Internal_GetCollisionMeshType(IntPtr thisPtr);
  246. [MethodImpl(MethodImplOptions.InternalCall)]
  247. private static extern void Internal_SetCollisionMeshType(IntPtr thisPtr, int value);
  248. }
  249. /// <summary>
  250. /// Controls what type of collision mesh should be imported during mesh import.
  251. /// </summary>
  252. public enum CollisionMeshType // Note: Must match C++ enum CollisionMeshImport
  253. {
  254. /// <summary>
  255. /// No collision mesh will be imported.
  256. /// </summary>
  257. None,
  258. /// <summary>
  259. /// Normal triangle mesh will be imported.
  260. /// </summary>
  261. Normal,
  262. /// <summary>
  263. /// A convex hull will be generated from the source mesh.
  264. /// </summary>
  265. Convex
  266. }
  267. /// <summary>
  268. /// Import options that provide various options for controlling how is a font resource imported.
  269. /// </summary>
  270. public class FontImportOptions : ImportOptions
  271. {
  272. /// <summary>
  273. /// Creates new font import options with default values.
  274. /// </summary>
  275. public FontImportOptions()
  276. {
  277. Internal_CreateInstance(this);
  278. }
  279. /// <summary>
  280. /// Font sizes in points that are to be imported.
  281. /// </summary>
  282. public int[] FontSizes
  283. {
  284. get { return Internal_GetFontSizes(mCachedPtr); }
  285. set { Internal_SetFontSizes(mCachedPtr, value); }
  286. }
  287. /// <summary>
  288. /// Dots per inch resolution to use when rendering the characters into the texture.
  289. /// </summary>
  290. public int DPI
  291. {
  292. get { return Internal_GetDPI(mCachedPtr); }
  293. set { Internal_SetDPI(mCachedPtr, value); }
  294. }
  295. /// <summary>
  296. /// Determines rendering mode used when rendering the characters into the bitmap.
  297. /// </summary>
  298. public FontRenderMode RenderMode
  299. {
  300. get { return Internal_GetRenderMode(mCachedPtr); }
  301. set { Internal_SetRenderMode(mCachedPtr, value); }
  302. }
  303. /// <summary>
  304. /// Determines should the characters be rendered in bold style.
  305. /// </summary>
  306. public bool Bold
  307. {
  308. get { return Internal_GetBold(mCachedPtr); }
  309. set { Internal_SetBold(mCachedPtr, value); }
  310. }
  311. /// <summary>
  312. /// Determines should the characters be rendered in italic style.
  313. /// </summary>
  314. public bool Italic
  315. {
  316. get { return Internal_GetItalic(mCachedPtr); }
  317. set { Internal_SetItalic(mCachedPtr, value); }
  318. }
  319. /// <summary>
  320. /// Determines character ranges to import from the font. Ranges are defined as unicode numbers.
  321. /// </summary>
  322. public CharRange[] CharRanges
  323. {
  324. get { return Internal_GetCharRanges(mCachedPtr); }
  325. set { Internal_SetCharRanges(mCachedPtr, value); }
  326. }
  327. [MethodImpl(MethodImplOptions.InternalCall)]
  328. private static extern void Internal_CreateInstance(FontImportOptions instance);
  329. [MethodImpl(MethodImplOptions.InternalCall)]
  330. private static extern int[] Internal_GetFontSizes(IntPtr thisPtr);
  331. [MethodImpl(MethodImplOptions.InternalCall)]
  332. private static extern void Internal_SetFontSizes(IntPtr thisPtr, int[] value);
  333. [MethodImpl(MethodImplOptions.InternalCall)]
  334. private static extern int Internal_GetDPI(IntPtr thisPtr);
  335. [MethodImpl(MethodImplOptions.InternalCall)]
  336. private static extern void Internal_SetDPI(IntPtr thisPtr, int value);
  337. [MethodImpl(MethodImplOptions.InternalCall)]
  338. private static extern FontRenderMode Internal_GetRenderMode(IntPtr thisPtr);
  339. [MethodImpl(MethodImplOptions.InternalCall)]
  340. private static extern void Internal_SetRenderMode(IntPtr thisPtr, FontRenderMode value);
  341. [MethodImpl(MethodImplOptions.InternalCall)]
  342. private static extern bool Internal_GetBold(IntPtr thisPtr);
  343. [MethodImpl(MethodImplOptions.InternalCall)]
  344. private static extern void Internal_SetBold(IntPtr thisPtr, bool value);
  345. [MethodImpl(MethodImplOptions.InternalCall)]
  346. private static extern bool Internal_GetItalic(IntPtr thisPtr);
  347. [MethodImpl(MethodImplOptions.InternalCall)]
  348. private static extern void Internal_SetItalic(IntPtr thisPtr, bool value);
  349. [MethodImpl(MethodImplOptions.InternalCall)]
  350. private static extern CharRange[] Internal_GetCharRanges(IntPtr thisPtr);
  351. [MethodImpl(MethodImplOptions.InternalCall)]
  352. private static extern void Internal_SetCharRanges(IntPtr thisPtr, CharRange[] value);
  353. }
  354. /// <summary>
  355. /// Provides various options for controlling how is a script file imported.
  356. /// </summary>
  357. public class ScriptCodeImportOptions : ImportOptions
  358. {
  359. /// <summary>
  360. /// Creates new script import options with default values.
  361. /// </summary>
  362. public ScriptCodeImportOptions()
  363. {
  364. Internal_CreateInstance(this);
  365. }
  366. /// <summary>
  367. /// Determines whether the script is editor-only or a normal game script. Editor scripts are compiled in a separate
  368. /// assembly and may reference editor specific functionality, but are not available in the final game code.
  369. /// </summary>
  370. public bool EditorScript
  371. {
  372. get { return Internal_IsEditorScript(mCachedPtr); }
  373. set { Internal_SetEditorScript(mCachedPtr, value); }
  374. }
  375. [MethodImpl(MethodImplOptions.InternalCall)]
  376. private static extern void Internal_CreateInstance(ScriptCodeImportOptions instance);
  377. [MethodImpl(MethodImplOptions.InternalCall)]
  378. private static extern bool Internal_IsEditorScript(IntPtr thisPtr);
  379. [MethodImpl(MethodImplOptions.InternalCall)]
  380. private static extern void Internal_SetEditorScript(IntPtr thisPtr, bool value);
  381. }
  382. /// <summary>
  383. /// Determines how is a font rendered into the bitmap texture.
  384. /// </summary>
  385. public enum FontRenderMode // Note: Must match C++ enum FontRenderMode
  386. {
  387. /// <summary>Render antialiased fonts without hinting (slightly more blurry).</summary>
  388. Smooth,
  389. /// <summary>Render non-antialiased fonts without hinting (slightly more blurry).</summary>
  390. Raster,
  391. /// <summary>Render antialiased fonts with hinting.</summary>
  392. HintedSmooth,
  393. /// <summary>Render non-antialiased fonts with hinting.</summary>
  394. HintedRaster
  395. }
  396. /// <summary>
  397. /// Provides various options for controlling how is an audio clip file imported.
  398. /// </summary>
  399. public class AudioClipImportOptions : ImportOptions
  400. {
  401. /// <summary>
  402. /// Creates new audio clip import options with default values.
  403. /// </summary>
  404. public AudioClipImportOptions()
  405. {
  406. Internal_CreateInstance(this);
  407. }
  408. /// <summary>
  409. /// Format to import the audio clip as.
  410. /// </summary>
  411. public AudioFormat Format
  412. {
  413. get { return Internal_GetFormat(mCachedPtr); }
  414. set { Internal_SetFormat(mCachedPtr, value); }
  415. }
  416. /// <summary>
  417. /// Determines how is audio data loaded into memory.
  418. /// </summary>
  419. public AudioReadMode ReadMode
  420. {
  421. get { return Internal_GetReadMode(mCachedPtr); }
  422. set { Internal_SetReadMode(mCachedPtr, value); }
  423. }
  424. /// <summary>
  425. /// Determines will the clip be played as spatial (3D) audio or as normal audio.
  426. /// </summary>
  427. public bool Is3D
  428. {
  429. get { return Internal_GetIs3D(mCachedPtr); }
  430. set { Internal_SetIs3D(mCachedPtr, value); }
  431. }
  432. /// <summary>
  433. /// Size of a single sample in bits.
  434. /// </summary>
  435. public AudioBitDepth BitDepth
  436. {
  437. get
  438. {
  439. int bits = Internal_GetBitDepth(mCachedPtr);
  440. switch (bits)
  441. {
  442. case 8:
  443. return AudioBitDepth.Bits8;
  444. case 16:
  445. return AudioBitDepth.Bits16;
  446. case 24:
  447. return AudioBitDepth.Bits24;
  448. case 32:
  449. return AudioBitDepth.Bits32;
  450. }
  451. return AudioBitDepth.Bits16;
  452. }
  453. set { Internal_SetBitDepth(mCachedPtr, (int)value); }
  454. }
  455. [MethodImpl(MethodImplOptions.InternalCall)]
  456. private static extern void Internal_CreateInstance(AudioClipImportOptions instance);
  457. [MethodImpl(MethodImplOptions.InternalCall)]
  458. private static extern AudioFormat Internal_GetFormat(IntPtr thisPtr);
  459. [MethodImpl(MethodImplOptions.InternalCall)]
  460. private static extern void Internal_SetFormat(IntPtr thisPtr, AudioFormat format);
  461. [MethodImpl(MethodImplOptions.InternalCall)]
  462. private static extern AudioReadMode Internal_GetReadMode(IntPtr thisPtr);
  463. [MethodImpl(MethodImplOptions.InternalCall)]
  464. private static extern void Internal_SetReadMode(IntPtr thisPtr, AudioReadMode readMode);
  465. [MethodImpl(MethodImplOptions.InternalCall)]
  466. private static extern bool Internal_GetIs3D(IntPtr thisPtr);
  467. [MethodImpl(MethodImplOptions.InternalCall)]
  468. private static extern void Internal_SetIs3D(IntPtr thisPtr, bool is3d);
  469. [MethodImpl(MethodImplOptions.InternalCall)]
  470. private static extern int Internal_GetBitDepth(IntPtr thisPtr);
  471. [MethodImpl(MethodImplOptions.InternalCall)]
  472. private static extern void Internal_SetBitDepth(IntPtr thisPtr, int bitDepth);
  473. }
  474. /** @} */
  475. }