00001 /*
00002 File: SceneObjects.h
00003
00004 Function: Contains definitions of the fundamental scene objects and
00005 their attributes.
00006
00007 Author(s): Andrew Willmott
00008
00009 Copyright: (c) 1995-2000, Andrew Willmott
00010 */
00011
00012 #ifndef __SceneObjects__
00013 #define __SceneObjects__
00014
00015 #include "gcl/Scene.h"
00016 #include "gcl/SLContext.h"
00017 #include "gcl/Renderer.h"
00018 #include "gcl/Texture.h"
00019
00020
00021 // --- Primitives -------------------------------------------------------------
00022
00023
00024 class scPoly : public scPrimitive
00025 // polygonal mesh
00026 {
00027 public:
00028
00029 scPoly() : scPrimitive(pPoly) {};
00030 scPoly(const scPoly &sp) : scPrimitive(sp) {};
00031
00032 Void Draw(Renderer &r, SLContext *context);
00033 StrConst Label() const;
00034 Void Parse(istream &s);
00035
00036 Void DecimateSelf(Decimator &dec);
00037
00038 Object *Clone() const { return new scPoly(SELF); };
00039 };
00040
00041
00042 // --- Attributes -------------------------------------------------------------
00043
00044
00045 class scColour : public scAttribute, public Colour
00046 {
00047 public:
00048 scColour() : scAttribute(aColour), Colour() {};
00049 scColour(const Colour &c) : scAttribute(aColour), Colour(c) {};
00050
00051 Void Print(ostream &s) const
00052 { s << "colour " << (Colour &) SELF; };
00053 Void Parse(istream &s)
00054 { s >> (Colour &) SELF; };
00055
00056 Object *Clone() const { return new scColour(SELF); };
00057 };
00058
00059 class scTransform : public scAttribute, public Transform
00060 {
00061 public:
00062 scTransform() : scAttribute(aTransform), Transform() {};
00063 scTransform(const Transform &t) : scAttribute(aTransform), Transform(t) {};
00064
00065 Void Print(ostream &s) const
00066 { s << "transform " << (Transform &) SELF; };
00067 Void Parse(istream &s)
00068 { s >> (Transform &) SELF; };
00069
00070 Void ApplyActionSelf(scSceneAction &a);
00071
00072 Object *Clone() const { return new scTransform(SELF); };
00073 };
00074
00075 class scEmittance : public scAttribute, public Colour
00076 {
00077 public:
00078 scEmittance() : scAttribute(aEmittance), Colour() {};
00079 scEmittance(const Colour &c) : scAttribute(aEmittance), Colour(c) {};
00080
00081 Void Print(ostream &s) const
00082 { s << "emittance " << (Colour &) SELF; };
00083 Void Parse(istream &s)
00084 { s >> (Colour &) SELF; };
00085
00086 Object *Clone() const { return new scEmittance(SELF); };
00087 };
00088
00089 class scPoints : public scAttribute, public PointList
00090 {
00091 public:
00092 scPoints() : scAttribute(aPoints), PointList() {};
00093 scPoints(const PointList &pl) : scAttribute(aPoints), PointList(pl) {};
00094
00095 Void Apply(const Transform &m);
00096 Void Print(ostream &s) const
00097 { s << "points " << (PointList &) SELF; };
00098 Void Parse(istream &s)
00099 { s >> (PointList &) SELF; };
00100
00101 Object *Clone() const { return new scPoints(SELF); };
00102 };
00103
00104 class scCoords : public scAttribute, public CoordList
00105 {
00106 public:
00107 scCoords() : scAttribute(aCoords), CoordList() {};
00108 scCoords(const CoordList &pl) : scAttribute(aCoords), CoordList(pl) {};
00109
00110 Void Apply(const Transform &m);
00111 Void Print(ostream &s) const
00112 { s << "coords " << (CoordList &) SELF; };
00113 Void Parse(istream &s)
00114 { s >> (CoordList &) SELF; };
00115
00116 Object *Clone() const { return new scCoords(SELF); };
00117 };
00118
00119 class scColours : public scAttribute, public ColourList
00120 {
00121 public:
00122 scColours() : scAttribute(aColours) {};
00123
00124 Void Print(ostream &s) const
00125 { s << "colours " << (ColourList &) SELF; };
00126 Void Parse(istream &s)
00127 { s >> (ColourList &) SELF; };
00128
00129 Object *Clone() const { return new scColours(SELF); };
00130 };
00131
00132 class scNormals : public scAttribute, public VectorList
00133 {
00134 public:
00135 scNormals() : scAttribute(aNormals) {};
00136
00137 Void Print(ostream &s) const
00138 { s << "normals " << (VectorList &) SELF; };
00139 Void Parse(istream &s)
00140 { s >> (VectorList &) SELF; };
00141
00142 Object *Clone() const { return new scNormals(SELF); };
00143 };
00144
00145 class scIndexes : public scAttribute, public IndexList
00146 {
00147 public:
00148 scIndexes(scAttributeID id) :
00149 scAttribute(id), IndexList() {};
00150 scIndexes(scAttributeID id, const IndexList &il) :
00151 scAttribute(id), IndexList(il) {};
00152
00153 Void Print(ostream &s) const;
00154 Void Parse(istream &s)
00155 { s >> (IndexList &) SELF; };
00156
00157 Object *Clone() const
00158 { return new scIndexes(SELF); };
00159 };
00160
00161 typedef scIndexes scPointIndexes;
00162 typedef scIndexes scColourIndexes;
00163 typedef scIndexes scNormalIndexes;
00164 typedef scIndexes scCoordIndexes;
00165 typedef scIndexes scFaceIndexes;
00166
00167 class scCamera : public scAttribute, public Camera
00168 {
00169 public:
00170
00171 scCamera() : scAttribute(aCamera), Camera() {};
00172 scCamera(const Camera &c) : scAttribute(aCamera), Camera(c) {};
00173
00174 Void Print(ostream &s) const;
00175 Void Parse(istream &s);
00176
00177 Object *Clone() const { return new scCamera(SELF); };
00178 };
00179
00180 class scTexture : public scAttribute, public Texture
00181 {
00182 public:
00183
00184 scTexture() : scAttribute(aTexture), Texture() {};
00185 scTexture(const Texture &c) : scAttribute(aTexture), Texture(c) {};
00186
00187 Void Print(ostream &s) const;
00188 Void Parse(istream &s);
00189
00190 Object *Clone() const { return new scTexture(SELF); };
00191 };
00192
00193 class scMeshType : public scAttribute
00194 {
00195 public:
00196
00197 scMeshType() : scAttribute(aMeshType), itsType(renPoly) {};
00198
00199 Void Print(ostream &s) const;
00200 Void Parse(istream &s);
00201
00202 Object *Clone() const { return new scMeshType(SELF); };
00203
00204 RenderStyle itsType;
00205 };
00206
00207 #endif