NGL  6.5
The NCCA Graphics Library
Obj.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 Jon Macey
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #ifndef OBJ_H_
18 #define OBJ_H_
19 //----------------------------------------------------------------------------------------------------------------------
22 //----------------------------------------------------------------------------------------------------------------------
23 // must include types.h first for Real and GLEW if required
24 #include "Types.h"
25 #include <vector>
26 #include "Texture.h"
27 #include <iostream>
28 #include <fstream>
29 #include <string>
30 #include <memory>
31 #include <vector>
32 #include "Vec4.h"
33 #include "AbstractMesh.h"
34 #include "BBox.h"
35 #include "RibExport.h"
36 #include <cmath>
37 
38 namespace ngl
39 {
40 //----------------------------------------------------------------------------------------------------------------------
51 //----------------------------------------------------------------------------------------------------------------------
52 
54 {
55 
56 public :
57 
58  //----------------------------------------------------------------------------------------------------------------------
60  //----------------------------------------------------------------------------------------------------------------------
61  Obj() noexcept: AbstractMesh(){;}
62  //----------------------------------------------------------------------------------------------------------------------
65  //----------------------------------------------------------------------------------------------------------------------
66  explicit Obj( const std::string& _fname ,bool _calcBB=true) noexcept;
67  //----------------------------------------------------------------------------------------------------------------------
71  //----------------------------------------------------------------------------------------------------------------------
72  explicit Obj( const std::string& _fname, const std::string& _texName,bool _calcBB=true ) noexcept;
73  // avoid _texName being converted to bool via explicit conversion
74  explicit Obj( const char *_fname, const char *_texName,bool _calcBB=true ) noexcept;
75  //----------------------------------------------------------------------------------------------------------------------
79  //----------------------------------------------------------------------------------------------------------------------
80  bool load(const std::string& _fname, bool _calcBB=true ) noexcept;
81  //----------------------------------------------------------------------------------------------------------------------
84  //----------------------------------------------------------------------------------------------------------------------
85  void save( const std::string& _fname ) const noexcept;
86 
87 protected :
88  //----------------------------------------------------------------------------------------------------------------------
91  //----------------------------------------------------------------------------------------------------------------------
92  virtual void parseVertex( const char *_begin ) noexcept;
93  //----------------------------------------------------------------------------------------------------------------------
96  //----------------------------------------------------------------------------------------------------------------------
97  virtual void parseNormal( const char *_begin ) noexcept;
98  //----------------------------------------------------------------------------------------------------------------------
101  //----------------------------------------------------------------------------------------------------------------------
102  virtual void parseTextureCoordinate( const char * _begin ) noexcept;
103  //----------------------------------------------------------------------------------------------------------------------
106  //----------------------------------------------------------------------------------------------------------------------
107  virtual void parseFace( const char * _begin ) noexcept;
108 
109 };
110 
111 }
112 
113 
114 #endif
115 //----------------------------------------------------------------------------------------------------------------------
116 
a simple texture loader / GL texture object
main definition of types and namespace
#define NGL_DLLEXPORT
Definition: Types.h:65
a series of classes used to define an abstract 3D mesh of Faces, Vertex Normals and TexCords ...
implementation files for RibExport class
Definition: AABB.cpp:22
encapsulates a 4d Homogenous Point / Vector object
an abstract base mesh used to build specific meshes such as Obj
Definition: AbstractMesh.h:105
a simple rib exporter function
a simple bounding box class
used to load in an alias wave front obj format file and draw using open gl has been completly re-writ...
Definition: Obj.h:53
GLsizei const GLchar *const * string
Definition: glew.h:1847
Obj() noexcept
default constructor
Definition: Obj.h:61