NGL  6.5
The NCCA Graphics Library
RibExport.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 RIBEXPORT_H_
18 #define RIBEXPORT_H_
19 // must include types.h first for Real and GLEW if required
22 #include "Types.h"
23 #include <fstream>
24 #include <string>
25 
26 namespace ngl
27 {
28 
29 //----------------------------------------------------------------------------------------------------------------------
39 //----------------------------------------------------------------------------------------------------------------------
40 
42 {
43 public :
44  //----------------------------------------------------------------------------------------------------------------------
46  //----------------------------------------------------------------------------------------------------------------------
47  void writeTabs();
48  //----------------------------------------------------------------------------------------------------------------------
51  //----------------------------------------------------------------------------------------------------------------------
52  RibExport( const std::string &_fileName, bool _oneShot=false );
53  //----------------------------------------------------------------------------------------------------------------------
55  //----------------------------------------------------------------------------------------------------------------------
56  ~RibExport();
57  //----------------------------------------------------------------------------------------------------------------------
60  //----------------------------------------------------------------------------------------------------------------------
61  void comment( const std::string &_sText );
62  //----------------------------------------------------------------------------------------------------------------------
64  //----------------------------------------------------------------------------------------------------------------------
65  void open();
66  //----------------------------------------------------------------------------------------------------------------------
68  //----------------------------------------------------------------------------------------------------------------------
69  void close();
70  //----------------------------------------------------------------------------------------------------------------------
72  //----------------------------------------------------------------------------------------------------------------------
73  void WorldBegin();
74  //----------------------------------------------------------------------------------------------------------------------
76  //----------------------------------------------------------------------------------------------------------------------
77  void WorldEnd();
78  //----------------------------------------------------------------------------------------------------------------------
80  //----------------------------------------------------------------------------------------------------------------------
81  void AttributeBegin();
82  //----------------------------------------------------------------------------------------------------------------------
84  //----------------------------------------------------------------------------------------------------------------------
85  void AttributeEnd();
86  //----------------------------------------------------------------------------------------------------------------------
88  //----------------------------------------------------------------------------------------------------------------------
89  void TransformBegin();
90  //----------------------------------------------------------------------------------------------------------------------
92  //----------------------------------------------------------------------------------------------------------------------
93  void TransformEnd();
94  //----------------------------------------------------------------------------------------------------------------------
97  //----------------------------------------------------------------------------------------------------------------------
98  void writeToFile(std::string _string);
99  //----------------------------------------------------------------------------------------------------------------------
104  //----------------------------------------------------------------------------------------------------------------------
105  void Translate(const Real _x, const Real _y, const Real _z );
106  //----------------------------------------------------------------------------------------------------------------------
112  //----------------------------------------------------------------------------------------------------------------------
113  void Rotate( const Real _angle, const Real _x, const Real _y, const Real _z );
114 
115  //----------------------------------------------------------------------------------------------------------------------
120  //----------------------------------------------------------------------------------------------------------------------
121  void Scale( const Real _x, const Real _y, const Real _z );
122  //----------------------------------------------------------------------------------------------------------------------
128  //----------------------------------------------------------------------------------------------------------------------
129  void Sphere( const Real _radius, const Real _zMin, const Real _zMax, const Real _sweep );
130  //----------------------------------------------------------------------------------------------------------------------
136  //----------------------------------------------------------------------------------------------------------------------
137  void Cylinder(const Real _radius, const Real _zMin, const Real _zMax, const Real _sweep);
138  //----------------------------------------------------------------------------------------------------------------------
143  //----------------------------------------------------------------------------------------------------------------------
144  void Cone( const Real _height, const Real _radius, const Real _sweep );
145  //----------------------------------------------------------------------------------------------------------------------
151  //----------------------------------------------------------------------------------------------------------------------
152  void Paraboloid( const Real _topRad, const Real _zMin, const Real _zMax, const Real _sweep );
153  //----------------------------------------------------------------------------------------------------------------------
158  //----------------------------------------------------------------------------------------------------------------------
159  void Hyperboloid( const Real _p1, const Real _p2, const Real _sweep );
160  //----------------------------------------------------------------------------------------------------------------------
165  //----------------------------------------------------------------------------------------------------------------------
166  void Disk( const Real _height, const Real _radius, const Real _sweep );
167  //----------------------------------------------------------------------------------------------------------------------
174  //----------------------------------------------------------------------------------------------------------------------
175  void Torus( const Real _major,const Real _minor,const Real _phiMin, const Real _phiMax,const Real _sweep);
176  //----------------------------------------------------------------------------------------------------------------------
178  //----------------------------------------------------------------------------------------------------------------------
179  bool isOpen(){return m_isOpen;}
180  //----------------------------------------------------------------------------------------------------------------------
182  //----------------------------------------------------------------------------------------------------------------------
183  std::fstream & getStream(){return m_ribFile;}
184 
185 protected :
186  //----------------------------------------------------------------------------------------------------------------------
188  //----------------------------------------------------------------------------------------------------------------------
189  std::fstream m_ribFile;
190  //----------------------------------------------------------------------------------------------------------------------
192  //----------------------------------------------------------------------------------------------------------------------
194  //----------------------------------------------------------------------------------------------------------------------
196  //----------------------------------------------------------------------------------------------------------------------
198  //----------------------------------------------------------------------------------------------------------------------
200  //----------------------------------------------------------------------------------------------------------------------
202  //----------------------------------------------------------------------------------------------------------------------
204  //----------------------------------------------------------------------------------------------------------------------
206  //----------------------------------------------------------------------------------------------------------------------
208  //----------------------------------------------------------------------------------------------------------------------
210  //----------------------------------------------------------------------------------------------------------------------
212  //----------------------------------------------------------------------------------------------------------------------
213  int m_tabs;
214  //----------------------------------------------------------------------------------------------------------------------
216  //----------------------------------------------------------------------------------------------------------------------
217  bool m_isOpen;
218  //----------------------------------------------------------------------------------------------------------------------
220  //----------------------------------------------------------------------------------------------------------------------
221  bool m_oneShot;
222 };
223 } // end ngl namespace
224 
225 #endif
226 
227 //----------------------------------------------------------------------------------------------------------------------
228 
int m_tabs
the current tab level for auto tabing of rib file
Definition: RibExport.h:213
std::fstream & getStream()
a method to get the rib stream
Definition: RibExport.h:183
main definition of types and namespace
int m_frameNumber
Hold the frame number for calls to Frame.
Definition: RibExport.h:205
int m_worldCount
count calls to WorldBegin to ensure matching
Definition: RibExport.h:201
bool isOpen()
method to see if stream is open
Definition: RibExport.h:179
#define NGL_DLLEXPORT
Definition: Types.h:65
bool m_isOpen
if the stream is open
Definition: RibExport.h:217
implementation files for RibExport class
Definition: AABB.cpp:22
PRECISION Real
create a variable called Real which is the main data type we use (GLfloat for most cases) ...
Definition: Types.h:127
std::fstream m_ribFile
the RibFile stream opened in the ctor
Definition: RibExport.h:189
simple rib export class, attempts to auto tab the rib file etc. needs lots of work to make it complet...
Definition: RibExport.h:41
std::string m_ribFileName
The name of the RibFile.
Definition: RibExport.h:209
bool m_oneShot
we can use this once or multiple times
Definition: RibExport.h:221
int m_transformCount
count calls to TransformBegin to ensure matching
Definition: RibExport.h:197
GLsizei const GLchar *const * string
Definition: glew.h:1847
int m_attribCount
count calls to AttributeBegin to ensure matching
Definition: RibExport.h:193