Ocean
OBJParser.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_SCENEDESCRIPTION_SDL_OBJ_OBJ_PARSER_H
9 #define META_OCEAN_SCENEDESCRIPTION_SDL_OBJ_OBJ_PARSER_H
10 
13 
15 
16 namespace Ocean
17 {
18 
19 namespace SceneDescription
20 {
21 
22 namespace SDL
23 {
24 
25 namespace OBJ
26 {
27 
28 // Forward declaration
29 class OBJScene;
30 
31 /**
32  * This class implements a obj parser able to parse obj files.
33  * @ingroup scenegrpahobj
34  */
35 class OCEAN_SCENEDESCRIPTION_SDL_OBJ_EXPORT OBJParser
36 {
37  protected:
38 
39  /**
40  * Definition of a scanner token.
41  */
43 
44  public:
45 
46  /**
47  * Creates a new parser for obj files.
48  * @param filename Name of the file to parse
49  * @param progress Optional progress state receiving the parser progress recurrently
50  */
51  explicit OBJParser(const std::string& filename, float* progress = nullptr);
52 
53  /**
54  * Parses the given file and returns a node reference to the entire scene.
55  * @return Parsed scene
56  * @param cancel Cancel state allows the cancelation of a load process while loading process hasn't finished, if the cancel state is used the load process stops if the value is set to True
57  */
58  SDLSceneRef parse(bool* cancel = nullptr);
59 
60  protected:
61 
62  /**
63  * Parses a vertex.
64  * @param scene Scene receiving the parsed vertex
65  */
66  void parseVertex(OBJScene& scene);
67 
68  /**
69  * Parses a normal.
70  * @param scene Scene receiving the parsed normal
71  */
72  void parseNormal(OBJScene& scene);
73 
74  /**
75  * Parses a parameter.
76  * @param scene Scene receiving the parsed parameter
77  */
78  void parseParameter(OBJScene& scene);
79 
80  /**
81  * Parses a texture coordinate.
82  * @param scene Scene receiving the parsed texture coordinate
83  */
85 
86  /**
87  * Parses a new face.
88  * @param scene Scene receiving the parsed face
89  */
90  void parseFace(OBJScene& scene);
91 
92  /**
93  * Parses a group.
94  * @param scene Scene receiving the parsed group
95  */
96  void parseGroup(OBJScene& scene);
97 
98  /**
99  * Parses a line.
100  * @param scene Scene receiving the parsed line
101  */
102  void parseLine(OBJScene& scene);
103 
104  /**
105  * Parses a mtllib statement.
106  * @param scene Scene receiving the parsed material library
107  */
108  void parseMtlLib(OBJScene& scene);
109 
110  /**
111  * Parses a object name statement.
112  * @param scene Scene receiving the parsed object name
113  */
114  void parseObject(OBJScene& scene);
115 
116  /**
117  * Parses a point statement.
118  * @param scene Scene receiving the parsed point
119  */
120  void parsePoint(OBJScene& scene);
121 
122  /**
123  * Parses a usemtl statement.
124  * @param scene Scene receiving the parsed material
125  */
126  void parseUseMtl(OBJScene& scene);
127 
128  /**
129  * Parses a smoothing factor.
130  * @param scene Scene receiving the parsed smoothing factor
131  */
133 
134  /**
135  * Parses a float value.
136  * @return Parsed float value
137  */
139 
140  protected:
141 
142  /// Scanner scanning obj token.
144 };
145 
146 }
147 
148 }
149 
150 }
151 
152 }
153 
154 #endif // META_OCEAN_SCENEDESCRIPTION_SDL_OBJ_OBJ_PARSER_H
This class implements a token for the scanner.
Definition: Scanner.h:43
This class implements a obj parser able to parse obj files.
Definition: OBJParser.h:36
OBJParser(const std::string &filename, float *progress=nullptr)
Creates a new parser for obj files.
void parseLine(OBJScene &scene)
Parses a line.
void parseUseMtl(OBJScene &scene)
Parses a usemtl statement.
SDLSceneRef parse(bool *cancel=nullptr)
Parses the given file and returns a node reference to the entire scene.
OBJScanner scanner_
Scanner scanning obj token.
Definition: OBJParser.h:143
void parseNormal(OBJScene &scene)
Parses a normal.
void parseMtlLib(OBJScene &scene)
Parses a mtllib statement.
void parseVertex(OBJScene &scene)
Parses a vertex.
OBJScanner::Token Token
Definition of a scanner token.
Definition: OBJParser.h:42
void parseFace(OBJScene &scene)
Parses a new face.
void parseGroup(OBJScene &scene)
Parses a group.
void parseTextureCoordinate(OBJScene &scene)
Parses a texture coordinate.
void parsePoint(OBJScene &scene)
Parses a point statement.
void parseObject(OBJScene &scene)
Parses a object name statement.
Scalar parseFloat()
Parses a float value.
void parseSmoothingFactor(OBJScene &scene)
Parses a smoothing factor.
void parseParameter(OBJScene &scene)
Parses a parameter.
This class implements a scanner able to scan obj token.
Definition: OBJScanner.h:32
This class holds the entire scene contained in one obj file.
Definition: OBJScene.h:37
This template class implements a smart object reference which is a specialization of an ObjectRef obj...
Definition: SmartObjectRef.h:90
float Scalar
Definition of a scalar type.
Definition: Math.h:128
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15