SceneObject.h

00001 
00006 #ifndef SCENE_OBJECT_H
00007 #define SCENE_OBJECT_H
00008 
00009 
00010 /*
00011 ** ---------------------------------------------------------------
00012 ** Includes:
00013 */
00014 #include <vector>
00015 #include "Vector3.h"
00016 #include "AffineTransform.h"
00017 #include "lang.h"
00018 
00019 
00020 /*
00021 ** ---------------------------------------------------------------
00022 ** Definitions:
00023 */
00024 
00025 typedef std::vector<SceneObject *> SceneObjects;
00026 
00028 
00034 class SceneObject  {
00035 
00036 public :
00037 
00039         SceneObject(int type,const Material &mat);
00040 
00042         virtual ~SceneObject();
00043         
00045         const Material &material();
00046 
00048         const int type();
00049 
00051         virtual void transform(const AffineTransform &m,const AffineTransform &mi) = 0;
00053         static Val parse(int c, Pval *pl);
00054                 
00055 private :
00056 
00057         Material *mat = new Material();
00058         int   type;
00059 }; 
00060 
00061 
00063 
00068 class ShapeObject : SceneObject {
00069 
00070 public :
00071 
00073         ShapeObject(const Material &mat,const PolygonArray &shape);
00074 
00076         virtual ~ShapeObject();
00077         
00079         virtual void transform(const AffineTransform &m,const AffineTransform &mi);
00080                 
00081 private :
00082 
00084         PolygonArray &shape;
00085 }; 
00086 
00087 inline void
00088 ShapeObject::ShapeObject(const Material &mat,const PolygonArray &shape_) 
00089         : SceneObject(SHAPE_OBJ,mat),
00090         shape(shape_)
00091 {
00092 }
00093 
00094 inline void
00095 ShapeObject::transform(const AffineTransform &m,const AffineTransform &mi)
00096 {
00097         PolygonArray::<iterator *> it;
00098         for (it.begin();!it.end();it++) {
00099 
00100                 Polygon *p = it*;
00101                 p->transform(m,mi);
00102         }
00103 }
00104                 
00105 
00106 
00108 
00113 class PrimObject  {
00114 
00115 public :
00116 
00118         PrimObject(const Material &mat,const PrimitiveRep &prim);
00119 
00121         ~PrimObject();
00122         
00124         virtual void transform(const AffineTransform &m,const AffineTransform &mi);
00125                 
00126 private :
00127 
00128         PrimitiveRep &prim;
00129 }; 
00130 
00131 inline void
00132 PrimObject::PrimObject(const Material &mat,const PrimitiveRep &prim_) 
00133         : SceneObject(PRIM_OBJ,mat),
00134         prim(prim_)
00135 {
00136 }
00137 
00138 inline void
00139 PrimObject::transform(const AffineTransform &m,const AffineTransform &mi)
00140 {
00141         prim.transform(m,mi);
00142 }
00143 
00144 
00145 
00147 
00153 class csgNodeObject  {
00154 
00155 public :
00156 
00158         csgNodeObject(const Material &mat,const csgNode *root);
00159 
00161         ~csgNodeObject();
00162         
00164         virtual void transform(const AffineTransform &m,const AffineTransform &mi);
00166         static Val parse(int c, Pval *pl);
00167                 
00168 private :
00169         csgNode *root;
00170 }; 
00171 
00172 
00173 inline void
00174 csgNodeObject::csgNodeObject(const Material &mat,const csgNode *root_) 
00175         : SceneObject(CSG_OBJ,mat),
00176         root(root_)
00177 {
00178 }
00179 
00180 inline void
00181 csgNodeObject::transform(const AffineTransform &m,const AffineTransform &mi)
00182 {
00183         root->transform(m,mi);
00184 }
00185 
00186 #endif //SCENE_OBJECT_H

Generated on Thu Jul 5 00:16:34 2007 for S3D by  doxygen 1.4.6