bsp.h 1.2 KB

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