bsp.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include "atto/gl.h"
  3. #include "atto/math.h"
  4. struct AABB { struct AVec3f min, max; };
  5. struct Plane { struct AVec3f n; float d; };
  6. struct BSPModelVertex {
  7. struct AVec3f vertex;
  8. struct AVec3f normal;
  9. struct AVec2f lightmap_uv;
  10. };
  11. struct BSPDraw {
  12. AGLBuffer vbo;
  13. AGLTexture texture;
  14. unsigned int start, count;
  15. struct AVec4f model;
  16. };
  17. /* TODO
  18. struct BSPNode {
  19. struct AABB aabb;
  20. struct {
  21. struct BSPDraw *p;
  22. unsigned n;
  23. } draw;
  24. struct Plane plane;
  25. int left, right;
  26. };
  27. */
  28. struct BSPModel {
  29. struct AABB aabb;
  30. AGLTexture lightmap;
  31. AGLBuffer ibo;
  32. unsigned int draws_count;
  33. struct BSPDraw *draws;
  34. };
  35. struct ICollection;
  36. struct MemoryPool;
  37. struct TemporaryPool;
  38. struct BSPLoadModelContext {
  39. struct ICollection *collection;
  40. struct MemoryPool *pool;
  41. struct TemporaryPool *tmp;
  42. /* allocated by caller, populated by callee */
  43. struct BSPModel *model;
  44. };
  45. enum BSPLoadResult {
  46. BSPLoadResult_Success,
  47. BSPLoadResult_ErrorFileOpen,
  48. BSPLoadResult_ErrorFileFormat,
  49. BSPLoadResult_ErrorMemory,
  50. BSPLoadResult_ErrorTempMemory,
  51. BSPLoadResult_ErrorCapabilities
  52. };
  53. enum BSPLoadResult bspLoadWorldspawn(struct BSPLoadModelContext context, const char *mapname);