My Project
rayScene.h
1 #ifndef SCENE_INCLUDED
2 #define SCENE_INCLUDED
3 #include <GL/glew.h>
4 #include <GL/glut.h>
5 #include <Util/geometry.h>
6 #include <Image/image.h>
7 #include "rayShape.h"
8 #include "rayLight.h"
9 #include "rayGroup.h"
10 #include "rayKey.h"
11 #include "rayCamera.h"
12 
13 #define STRING_BUFFER_SIZE 200
14 
25 };
26 
28 class RayVertex {
29 public:
31  int index;
38 
40  int read(FILE* fp);
43  void write(FILE* fp=stdout);
44 };
45 
46 
48 class RayMaterial {
49 public:
51  int index;
65  double refind;
67  class RayTexture *tex;
69  char foo[STRING_BUFFER_SIZE];
70 
71  RayMaterial(void);
72 
74  int read(FILE* fp,int& textureIndex);
77  void write(FILE* fp=stdout);
78 
80  void drawOpenGL(void);
81 };
82 
84 class RayTexture{
85 public:
87  int index;
89  char filename[STRING_BUFFER_SIZE];
92 
93  RayTexture(void);
94  ~RayTexture(void);
96  int read(FILE* fp);
99  void write(FILE* fp=stdout);
100 
102  GLuint openGLHandle;
103 
105  void setUpOpenGL(void);
106 };
107 
109 class RayFile{
110 public:
112  int index;
114  char filename[STRING_BUFFER_SIZE];
116  class RayScene* scene;
117 
118  ~RayFile(void);
119 
121  int read(FILE* fp,int transformType);
124  void write(FILE* fp=stdout);
125 };
126 
128 class RayScene{
129  RayVertex* vertices;
130  int vertexNum;
131  RayMaterial* materials;
132  int materialNum;
133  RayTexture* textures;
134  int textureNum;
135  RayFile* rayFiles;
136  int rayFileNum;
137  RayKeyFile* keyFiles;
138  RayKeyData* keyData;
139  int keyFileNum;
140 
141  void ParseError(const char *);
142  void ParseLineError(int , const char *);
143  void ParseGroup(FILE* fp,int& cmndCtr,class RayGroup* current);
144  void ParseJoint(FILE* fp,int& cmndCtr,class RayGroup* current);
145  int ParseShape(FILE* fp,const char* keyword,int cmndCtr,class RayGroup* current);
146 public:
154  class RayLight** lights;
156  int lightNum;
159 
160  RayScene(void);
161  ~RayScene(void);
162 
164  RayMaterial* getMaterial(int index);
165 
167  int read(char* fileName,int transformType=RayKeyData::MATRIX);
169  int read(FILE* fp,int transformType);
171  int write(char* fileName);
173  int write(FILE* fp=stdout);
174 
176  // Ray-Tracing stuff //
178  int RayTrace(const int& width,const int& height,const int& rLimit,const double& cLimit,Image32& img);
179 
181  static Point3D Reflect(Point3D v,Point3D n);
182 
187  static int Refract(Point3D v,Point3D n,double ir,Point3D& refract);
188 
190  static Ray3D GetRay(RayCamera* camera,int i,int j,int width,int height);
191 
196  Point3D GetColor(Ray3D ray,int rDepth,Point3D cLimit);
197 
199  // OpenGL stuff //
201 
202  void RayView(const int& width,const int& height,const int& cplx,const int& factor=RayKeyData::MATRIX);
203 
205  void drawOpenGL(void);
206 
208  void setUpOpenGL(int cplx);
209 
211  void setCurrentTime(double t,int curveFit=LINEAR);
212 };
213 
214 #endif // SCENE_INCLUDED
215 
216 
Point3D specular
Definition: rayScene.h:57
Point3D ambient
Definition: rayScene.h:148
Definition: rayScene.h:84
int read(FILE *fp)
Definition: rayGroup.cpp:63
Point2D texCoordinate
Definition: rayScene.h:24
Definition: rayScene.h:109
int index
Definition: rayScene.h:87
Point3D iCoordinate
Definition: rayScene.h:20
Point3D normal
Definition: rayScene.h:35
Definition: rayKey.h:35
Point2D texCoordinate
Definition: rayScene.h:37
double refind
Definition: rayScene.h:65
Definition: rayScene.h:16
Definition: geometry.h:81
Definition: geometry.h:11
class StaticRayGroup * group
Definition: rayScene.h:158
Point3D transparent
Definition: rayScene.h:61
Definition: rayGroup.h:26
Image32 * img
Definition: rayScene.h:91
int index
Definition: rayScene.h:112
Point3D normal
Definition: rayScene.h:22
Definition: rayGroup.h:70
int read(FILE *fp)
Definition: rayScene.cpp:85
Point3D ambient
Definition: rayScene.h:53
Point3D background
Definition: rayScene.h:150
Definition: rayScene.h:48
int read(char *fileName, int transformType=RayKeyData::MATRIX)
Definition: rayScene.cpp:220
int index
Definition: rayScene.h:31
Point3D position
Definition: rayScene.h:33
void write(FILE *fp=stdout)
Definition: rayScene.cpp:112
Definition: geometry.h:182
Point3D diffuse
Definition: rayScene.h:55
class RayScene * scene
Definition: rayScene.h:116
double specularFallOff
Definition: rayScene.h:63
int lightNum
Definition: rayScene.h:156
int index
Definition: rayScene.h:51
int write(char *fileName)
Definition: rayScene.cpp:168
class RayTexture * tex
Definition: rayScene.h:67
Definition: rayKey.h:7
GLuint openGLHandle
Definition: rayScene.h:102
int drawOpenGL(int materialIndex)
Definition: rayGroup.todo.cpp:24
class RayLight ** lights
Definition: rayScene.h:154
Definition: rayScene.h:128
void write(int indent, FILE *fp=stdout)
Definition: rayGroup.cpp:38
Definition: rayLight.h:7
Definition: image.h:47
Point3D emissive
Definition: rayScene.h:59
Definition: rayScene.h:28
RayCamera * camera
Definition: rayScene.h:152
void setUpOpenGL(int cplx)
Definition: rayGroup.cpp:52
Definition: rayCamera.h:6
class RayMaterial * material
Definition: rayScene.h:18