doc-map-parsing.txt 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. oopless-parser.hpp / oopless-parser.cpp
  2. Parses Reflex's .map file, both version 6 and version 8.
  3. Reflex Map Format
  4. Reflex maps are plain text files featuring keywords and indentation levels.
  5. Reflex map keywords:
  6. Ordered by indentation level (outer to inner).
  7. "global"
  8. "prefab"
  9. "entity"
  10. "brush"
  11. "vertices"
  12. "faces"
  13. "vertices" and "faces", sharing the level, are contained in brushes.
  14. "brush" and "entity", sharing the level are contained in prefabs.
  15. "global" largely behaves the same as prefabs.
  16. There are two distinct map formats from Reflex- V6 and V8.
  17. V6 was the map format before the addition of prefabs (V8 feature).
  18. As far as the conversion process is concerned:
  19. 'global' and 'prefab' are containers for map objects.
  20. 'entity' and 'brush' are map objects (but entity may contain a brush).
  21. 'vertices' and 'faces' are details of brushes.
  22. Brush Data
  23. Brushes contain faces and vertices.
  24. A brush's faces and vertices are listed in its "faces" and "vertices".
  25. Vertex Data
  26. A vertex contains 3 floats representing a coordinate.
  27. Reflex uses a right-handed coordinate system while idTech engine uses left.
  28. Face Data
  29. Faces contain the texture definition, indices, & the texture to be applied.
  30. Each field in the line, being the entire face, is separated by space.
  31. The first 5 fields are always data for the texture definition.
  32. In order,
  33. * texture x offset
  34. * texture y offset
  35. * texture x scale
  36. * texture y scale
  37. * texture rotation
  38. The next fields are integers being indices for the list of vertices for
  39. the brush.
  40. Followed by an hex digit for the color code in sRGB to apply to the face.
  41. Then followed by the path to the texture asset.
  42. Parsing States
  43. GLOBAL or PREFAB -> {BRUSH, ENTITY}
  44. BRUSH -> {FACES, VERTICES}
  45. VERTICES -> {FACES, BRUSH, ENTITY}
  46. FACES -> {VERTICES, BRUSH, ENTITY, PREFAB}
  47. ENTITY -> {ENTITY, BRUSH, PREFAB}
  48. In all observations, VERTICES are defined before FACES.
  49. Entities may contain brushes as a part of its data; however it is not
  50. reflected in indentation levels in Reflex. Thus for the conversion,
  51. brushes must be contained in the entity string, and converted in a
  52. different phase (because the worldspawn entity in idTech excludes
  53. entity-brushes). The parser transitions out of handling the entity when
  54. it hits the brush keyword and the entity's type does not match is not of
  55. a specific set of types.
  56. Implementation Overview
  57. Each parsing function:
  58. - assumes by the time it is called, the respective keyword has already
  59. been advanced past.
  60. - retrieves the next line from the input stream
  61. - detects next possible parsing states
  62. - will output its respective data structure