scg3  0.6
GeometryCoreFactory.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright 2014 Volker Ahlers
11  *
12  * Licensed under the Apache License, Version 2.0 (the "License");
13  * you may not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  * http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */
24 
25 #ifndef GEOMETRYCOREFACTORY_H_
26 #define GEOMETRYCOREFACTORY_H_
27 
28 #include <string>
29 #include <vector>
30 #include "scg_glew.h"
31 #include "scg_glm.h"
32 #include "scg_internals.h"
33 
34 namespace scg {
35 
36 
41 
42 public:
43 
48 
55  GeometryCoreFactory(const std::string& filePath);
56 
60  virtual ~GeometryCoreFactory();
61 
68  void addFilePath(const std::string& filePath);
69 
79  GeometryCoreSP createModelFromOBJFile(const std::string& fileName);
80 
87  GeometryCoreSP createRectangle(glm::vec2 sizeXY);
88 
95  GeometryCoreSP createCube(GLfloat size);
96 
103  GeometryCoreSP createCuboid(glm::vec3 sizeXYZ);
104 
114  GeometryCoreSP createSphere(GLfloat radius, int nSlices, int nStacks);
115 
127  GeometryCoreSP createCone(GLfloat radius, GLfloat height,
128  int nSlices, int nStacks, bool hasCap = true);
129 
141  GeometryCoreSP createCylinder(GLfloat radius, GLfloat height,
142  int nSlices, int nStacks, bool hasCaps = true);
143 
157  GeometryCoreSP createConicalFrustum(GLfloat baseRadius, GLfloat topRadius,
158  GLfloat height, int nSlices, int nStacks, bool hasCaps = true);
159 
169  GeometryCoreSP createTeapot(GLfloat size);
170 
179  GeometryCoreSP createTeapotFlat(GLfloat size);
180 
187  GeometryCoreSP createXYZAxes(GLfloat size);
188 
195  GeometryCoreSP createRGBCube(GLfloat size);
196 
197 protected:
198 
202  struct FaceEntry {
204  : vertex(0), texCoord(0), normal(0) {
205  }
206  int vertex;
207  int texCoord;
208  int normal;
209  };
210 
214  struct Face{
216  : nTriangles(0) {
217  }
219  std::vector<FaceEntry> entries;
220  };
221 
225  struct OBJModel {
227  : nVertices(0), nTriangles(0) {
228  }
231  std::vector<glm::vec3> vertices;
232  std::vector<glm::vec2> texCoords;
233  std::vector<glm::vec3> normals;
234  std::vector<Face> faces;
235  };
236 
244  int loadOBJFile_(const std::string& fileName, OBJModel& model) const;
245 
246 protected:
247 
248  std::vector<std::string> filePaths_;
249 
250 };
251 
252 
253 } /* namespace scg */
254 
255 #endif /* GEOMETRYCOREFACTORY_H_ */
GeometryCoreSP createCuboid(glm::vec3 sizeXYZ)
GeometryCoreSP createConicalFrustum(GLfloat baseRadius, GLfloat topRadius, GLfloat height, int nSlices, int nStacks, bool hasCaps=true)
A core that contains geometry information to be rendered.
Definition: GeometryCore.h:53
Local header file for GLM OpenGL Mathematics library.
GeometryCoreSP createRGBCube(GLfloat size)
int vertex
GeometryCoreSP createCube(GLfloat size)
void addFilePath(const std::string &filePath)
std::vector< FaceEntry > entries
int normal
int texCoord
GeometryCoreSP createSphere(GLfloat radius, int nSlices, int nStacks)
GeometryCoreSP createCone(GLfloat radius, GLfloat height, int nSlices, int nStacks, bool hasCap=true)
std::vector< std::string > filePaths_
FaceEntry()
Local header file for GLEW library.
GeometryCoreSP createTeapot(GLfloat size)
int loadOBJFile_(const std::string &fileName, OBJModel &model) const
GeometryCoreSP createRectangle(glm::vec2 sizeXY)
GeometryCoreSP createCylinder(GLfloat radius, GLfloat height, int nSlices, int nStacks, bool hasCaps=true)
GeometryCoreSP createTeapotFlat(GLfloat size)
GeometryCoreSP createXYZAxes(GLfloat size)
A factory to create geometry cores.
Definition: Animation.h:28
Internal definitions required by most classes.
GeometryCoreSP createModelFromOBJFile(const std::string &fileName)