Ocean
MtlParser.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_MTL_PARSER_H
9 #define META_OCEAN_SCENEDESCRIPTION_SDL_OBJ_MTL_PARSER_H
10 
14 
15 #include <vector>
16 
17 namespace Ocean
18 {
19 
20 namespace SceneDescription
21 {
22 
23 namespace SDL
24 {
25 
26 namespace OBJ
27 {
28 
29 /**
30  * This class implements a obj material parser able to parse mtl files.
31  * @ingroup scenedescriptionsdlobj
32  */
33 class OCEAN_SCENEDESCRIPTION_SDL_OBJ_EXPORT MtlParser
34 {
35  public:
36 
37  /**
38  * Definition of a vector holding materials.
39  */
40  typedef std::vector<Material> Materials;
41 
42  protected:
43 
44  /**
45  * Definition of a scanner token.
46  */
48 
49  public:
50 
51  /**
52  * Creates a new obj mtl parser.
53  * @param filename Name of the mtl file to parse
54  */
55  MtlParser(const std::string& filename);
56 
57  /**
58  * Parses the mtl file and returns all parsed material objects.
59  * @return The resulting materials
60  * @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
61  */
62  Materials parse(bool* cancel = nullptr);
63 
64  protected:
65 
66  /**
67  * Parses a obj material.
68  * @param materials The materials to which the parsed material object will be added
69  */
70  void parseMaterial(Materials& materials);
71 
72  /**
73  * Parses the ambient color.
74  * @param material Material receiving the ambient color
75  */
76  void parseAmbientColor(Material& material);
77 
78  /**
79  * Parses the dissolve value.
80  * @param material Material receiving the dissolve value
81  */
82  void parseDissolve(Material& material);
83 
84  /**
85  * Parses the diffuse color.
86  * @param material Material receiving the diffuse color
87  */
88  void parseDiffuseColor(Material& material);
89 
90  /**
91  * Parses the ambient texture name.
92  * @param material Material receiving the ambient texture name
93  */
94  void parseAmbientTexture(Material& material);
95 
96  /**
97  * Parses the diffuse texture name.
98  * @param material Material receiving the diffuse texture name
99  */
100  void parseDiffuseTexture(Material& material);
101 
102  /**
103  * Parses the emissive color.
104  * @param material Material receiving the emissive color
105  */
106  void parseEmissiveColor(Material& material);
107 
108  /**
109  * Parses the optical density value.
110  * @param material Material receiving the density value
111  */
112  void parseOpticalDensity(Material& material);
113 
114  /**
115  * Parses the illumination model.
116  * @param material Material receiving the illumination model
117  */
119 
120  /**
121  * Parses the spcular color.
122  * @param material Material receiving the specular color
123  */
124  void parseSpecularColor(Material& material);
125 
126  /**
127  * Parses the specular highlight.
128  * @param material Meterial receiving the specular highlight value
129  */
131 
132  /**
133  * Parses the transmission filter value.
134  * @param material Meterial receiving the specular highlight value
135  */
137 
138  /**
139  * Parses the transparency value.
140  * @param material Meterial receiving the transparency value
141  */
142  void parseTransparency(Material& material);
143 
144  /**
145  * Parses an unsupported keyword.
146  */
148 
149  /**
150  * Parses a float value.
151  * @return Parsed float value
152  */
154 
155  protected:
156 
157  /// Scanner able to scan obj mtl token.
159 };
160 
161 }
162 
163 }
164 
165 }
166 
167 }
168 
169 #endif // META_OCEAN_SCENEDESCRIPTION_SDL_OBJ_MTL_PARSER_H
This class implements a token for the scanner.
Definition: Scanner.h:43
This class hold a material defined in a mtl obj material file.
Definition: scenedescription/sdl/obj/Material.h:38
This class implements a obj material parser able to parse mtl files.
Definition: MtlParser.h:34
void parseAmbientTexture(Material &material)
Parses the ambient texture name.
MtlScanner::Token Token
Definition of a scanner token.
Definition: MtlParser.h:47
MtlParser(const std::string &filename)
Creates a new obj mtl parser.
void parseAmbientColor(Material &material)
Parses the ambient color.
void parseDiffuseTexture(Material &material)
Parses the diffuse texture name.
std::vector< Material > Materials
Definition of a vector holding materials.
Definition: MtlParser.h:40
void parseSpecularColor(Material &material)
Parses the spcular color.
void parseMaterial(Materials &materials)
Parses a obj material.
void parseDissolve(Material &material)
Parses the dissolve value.
void parseDiffuseColor(Material &material)
Parses the diffuse color.
Materials parse(bool *cancel=nullptr)
Parses the mtl file and returns all parsed material objects.
Scalar parseFloat()
Parses a float value.
void parseUnsupportedKeyword()
Parses an unsupported keyword.
void parseSpecularHighlight(Material &material)
Parses the specular highlight.
void parseEmissiveColor(Material &material)
Parses the emissive color.
void parseIlluminationModel(Material &material)
Parses the illumination model.
void parseTransparency(Material &material)
Parses the transparency value.
void parseOpticalDensity(Material &material)
Parses the optical density value.
MtlScanner scanner_
Scanner able to scan obj mtl token.
Definition: MtlParser.h:158
void parseTransmissionFilter(Material &material)
Parses the transmission filter value.
This class implements a scanner able to scan obj mtl token.
Definition: MtlScanner.h:32
float Scalar
Definition of a scalar type.
Definition: Math.h:128
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15