r3d_importer.odin 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* r3d_importer.odin -- R3D Importer Module.
  2. *
  3. * Copyright (c) 2025-2026 Le Juez Victor
  4. *
  5. * This software is provided 'as-is', without any express or implied warranty.
  6. * For conditions of distribution and use, see accompanying LICENSE file.
  7. */
  8. package r3d
  9. import rl "vendor:raylib"
  10. when ODIN_OS == .Windows {
  11. foreign import lib {
  12. "windows/libr3d.a",
  13. "system:raylib",
  14. "system:assimp",
  15. }
  16. } else when ODIN_OS == .Linux {
  17. foreign import lib {
  18. "linux/libr3d.a",
  19. "system:raylib",
  20. "system:assimp",
  21. }
  22. } else when ODIN_OS == .Darwin {
  23. foreign import lib {
  24. "darwin/libr3d.a",
  25. "system:raylib",
  26. "system:assimp",
  27. }
  28. }
  29. Importer :: struct {}
  30. @(default_calling_convention="c", link_prefix="R3D_")
  31. foreign lib {
  32. /**
  33. * @brief Load an importer from a file.
  34. *
  35. * Creates an importer instance from the specified file path.
  36. * The file is parsed once and can be reused to extract multiple
  37. * resources such as models and animations.
  38. *
  39. * @param filePath Path to the asset file.
  40. * @param flags Importer behavior flags.
  41. *
  42. * @return Pointer to a new importer instance, or NULL on failure.
  43. */
  44. LoadImporter :: proc(filePath: cstring, flags: ImportFlags) -> ^Importer ---
  45. /**
  46. * @brief Load an importer from a memory buffer.
  47. *
  48. * Creates an importer instance from in-memory asset data.
  49. * This is useful for embedded assets or streamed content.
  50. *
  51. * @param data Pointer to the asset data.
  52. * @param size Size of the data buffer in bytes.
  53. * @param hint Optional file format hint (may be NULL).
  54. * @param flags Importer behavior flags.
  55. *
  56. * @return Pointer to a new importer instance, or NULL on failure.
  57. */
  58. LoadImporterFromMemory :: proc(data: rawptr, size: u32, hint: cstring, flags: ImportFlags) -> ^Importer ---
  59. /**
  60. * @brief Destroy an importer instance.
  61. *
  62. * Frees all resources associated with the importer.
  63. * Any models or animations extracted from it remain valid.
  64. *
  65. * @param importer Importer instance to destroy.
  66. */
  67. UnloadImporter :: proc(importer: ^Importer) ---
  68. }
  69. /**
  70. * @typedef R3D_ImportFlags
  71. * @brief Flags controlling importer behavior.
  72. *
  73. * These flags define how the importer processes the source asset.
  74. */
  75. ImportFlag :: enum u32 {
  76. /**
  77. * @brief Keep a CPU-side copy of mesh data.
  78. *
  79. * When enabled, raw mesh data is preserved in RAM after model import.
  80. */
  81. MESH_DATA = 0,
  82. /**
  83. * @brief Enable high-quality import processing.
  84. *
  85. * When enabled, the importer uses a higher-quality post-processing
  86. * (e.g. smooth normals, mesh optimization, data validation).
  87. * This mode is intended for editor usage and offline processing.
  88. *
  89. * When disabled, a faster import preset is used, suitable for runtime.
  90. */
  91. QUALITY = 1,
  92. }
  93. ImportFlags :: bit_set[ImportFlag; u32]