Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

PhxGraphicsEngine.h

00001 #ifndef PHX_GRAPHICS_ENGINE_H
00002 #define PHX_GRAPHICS_ENGINE_H
00003 
00004 #include <Phx/PhxConfig.h>
00005 #include <Phx/PhxTypes.h>
00006 #include <Phx/Core/PhxNamedInterface.h>
00007 #include <Phx/Util/PhxMatrix.h>
00008 #include <Phx/Util/PhxQuaternion.h>
00009 #include <Phx/Util/PhxColor.h>
00010 
00011 namespace Phx {
00012 
00013 
00052   class GraphicsEngine : public NamedInterface {
00053   public:
00054     const static NamedInterface::Type  INTERFACE_TYPE;
00055     const static String                INTERFACE_TYPE_NAME;
00056 
00057     const static NamedInterface::Identifier GRAPHICS_ENGINE_IDENTIFIER;
00058     const static String                     GRAPHICS_ENGINE_NAME;
00059 
00060 
00061     // Scene-graph node types
00062     class Node;
00063     class Light;
00064     class DirectionalLight;
00065     class PointLight;
00066     //class SpotLight;
00067     class Geometry;
00068     //class BillboardGroup;
00069     class Camera;
00070 
00071     // Resource types
00072     class MeshInterface;
00073     class MaterialInterface;
00074 
00075     // Descriptions for various elements
00076     class GeometryDescription;
00077     class MeshDescription;
00078     class MaterialDescription;
00079     class LightDescription;
00080 
00081 
00082     // Resource interfaces
00083     virtual Ptr<MeshInterface> newMeshInterface(const String& meshName) = 0;
00084     virtual Ptr<MeshInterface> newMeshInterface(const Ptr<const MeshDescription>& description) = 0;
00085     virtual Ptr<MaterialInterface> newMaterialInterface(const String& materialName) = 0;
00086     virtual Ptr<MaterialInterface> newMaterialInterface(const Ptr<const MaterialDescription>& description) = 0;
00087 
00088     // Scene graph node interfaces
00089     /*Ptr<PointLight> newPointLight(void);
00090     Ptr<PointLight> newPointLight(const Ptr<const LightDescription>& description);
00091     Ptr<DirectionalLight> newDirectionalLight(void);
00092     Ptr<DirectionalLight> newDirectionalLight(const Ptr<const LightDescription>& description);
00093     */
00094     virtual Ptr<Geometry> newGeometry(void) = 0;
00095     virtual Ptr<Geometry> newGeometry(const Ptr<const GeometryDescription>& description) = 0;
00096     virtual Ptr<Camera> newCamera(const String& cameraName) = 0;
00097 
00098 
00099 
00100     // ------- primary client interface --------
00101 
00102     // Camera control
00103     virtual String currentCamera(void) const = 0;
00104     virtual void currentCamera(const String& cameraName) = 0;
00105     // std::vector<String> cameraNames(void) const = 0;
00106   };
00107 
00108   class GraphicsEngine::Node : public LockedPtrInterface<Node> {
00109   public:
00110     virtual void newChild(const Ptr<Node>& node) = 0;
00111     virtual void deleteChild(const Ptr<Node>& node) = 0;
00112     virtual Ptr<Node> child(const Ptr<Node>& node) const = 0;
00113     virtual Ptr<Node> child(uint32_t index) const = 0;
00114     virtual uint32_t childCount(void) const = 0;
00115 
00116     virtual void position(const Vector3& position) = 0;
00117     virtual void orientation(const Quaternion& orientation) = 0;
00118 
00119   private:
00120   };
00121   
00122   class GraphicsEngine::Geometry : public GraphicsEngine::Node {
00123   public:
00124     virtual void mesh(const String& meshName) = 0;
00125     String mesh(void) const { return mMeshName; }
00126 
00127   protected:
00128     void setMesh(const String& meshName) { mMeshName = meshName; }
00129   private:
00130     String mMeshName;
00131   };
00132 
00136   class GraphicsEngine::Camera : public GraphicsEngine::Node {
00137   public:
00138     virtual void fieldOfView(double fovRadians) = 0;
00139     virtual double fieldOfView(void) const = 0;
00140 
00141   protected:
00142     void setName(const String& name) { mName = name; }
00143   private:
00144     String mName;
00145   };
00146 
00147 
00158   class GraphicsEngine::MeshInterface : public LockedPtrInterface<MeshInterface> {
00159   public:
00160     class SubMesh;
00161     virtual Ptr<SubMesh> subMesh(uint32_t index) = 0;
00162     virtual uint32_t subMeshCount(void) const = 0;
00163 
00170     String name() const { return mName; }
00171 
00172   protected:
00173     void setName(const String& name) { mName = name; }
00174   private:
00175     String mName;
00176   };
00177 
00178   class GraphicsEngine::MeshInterface::SubMesh : public LockedPtrInterface<SubMesh> {
00179   public:
00180     virtual Vector3 vertex(uint32_t index) const = 0;
00181     virtual uint32_t vertexCount(void) const = 0;
00182     virtual String material(void) const = 0;
00183   };
00184 
00185 
00199   class GraphicsEngine::MaterialInterface : public LockedPtrInterface<MaterialInterface> {
00200   public:
00201 
00211     virtual void shininess(double shininess) = 0;
00212     
00217     double shininess(void) const { return mShininess; }
00218     
00231     virtual void specular(const RgbaColor& specular) = 0;
00232     
00238     const RgbaColor& specular(void) const { return mSpecular; }
00239     
00246     virtual void ambient(const RgbaColor& ambient) = 0;
00247     
00253     const RgbaColor& ambient(void) const { return mAmbient; }
00254     
00264     virtual void diffuse(const RgbaColor& diffuse) = 0;
00265 
00271     const RgbaColor& diffuse(void) const { return mDiffuse; }
00272     
00278     virtual void emission(const RgbaColor& emission) = 0;
00279     
00285     const RgbaColor& emission(void) const { return mEmission; }
00286     
00293     String name() const { return mName; }
00294 
00295   private:
00296     String mName;
00297     double mShininess;
00298     RgbaColor mSpecular;
00299     RgbaColor mDiffuse;
00300     RgbaColor mAmbient;
00301     RgbaColor mEmission;
00302     
00303   protected:
00304     void setName(const String& name) { mName = name; }
00305     void setShininess(double s) { mShininess = s; }
00306     void setDiffuse(const RgbaColor& c) { mDiffuse = c; }
00307     void setAmbient(const RgbaColor& c) { mAmbient = c; }
00308     void setSpecular(const RgbaColor& c) { mSpecular = c; }
00309     void setEmission(const RgbaColor& c) { mEmission = c; }
00310   };
00311 
00312 
00313   // ---------- DESCRIPTIONS ----------
00314 
00318   class GraphicsEngine::LightDescription : public Description {
00319   public:
00329     virtual void specular(const RgbaColor& specular) = 0;
00330     
00335     const RgbaColor& specular(void) const { return mSpecular; }
00336     
00343     virtual void ambient(const RgbaColor& ambient) = 0;
00344     
00350     const RgbaColor& ambient(void) const { return mAmbient; }
00351     
00361     virtual void diffuse(const RgbaColor& diffuse) = 0;
00362     
00368     const RgbaColor& diffuse(void) const { return mDiffuse; }
00369 
00370   private:
00371     RgbaColor mSpecular;
00372     RgbaColor mDiffuse;
00373     RgbaColor mAmbient;
00374     
00375   protected:
00376     void setDiffuse(const RgbaColor& c) { mDiffuse = c; }
00377     void setAmbient(const RgbaColor& c) { mAmbient = c; }
00378     void setSpecular(const RgbaColor& c) { mSpecular = c; }
00379   };
00380 
00381 
00391   class GraphicsEngine::MeshDescription : public Description { 
00392   public:
00407     virtual void resourceName(const String& resourceName) = 0;
00408     const String& resourceName(void) const { return mResourceName; }
00409 
00410   private:
00411     String mResourceName;
00412   protected:
00413     void setResourceName(const String& name) { mResourceName = name; }
00414   };
00415   
00416   
00420   class GraphicsEngine::MaterialDescription : public Description {
00421   public:
00422     virtual void resourceName(const String& resourceName) = 0;
00423     const String& resourceName(void) const { return mResourceName; }
00424 
00434     virtual void shininess(double shininess) = 0;
00435     
00440     double shininess(void) const { return mShininess; }
00441     
00454     virtual void specular(const RgbaColor& specular) = 0;
00455     
00461     const RgbaColor& specular(void) const { return mSpecular; }
00462     
00469     virtual void ambient(const RgbaColor& ambient) = 0;
00470     
00476     const RgbaColor& ambient(void) const { return mAmbient; }
00477     
00487     virtual void diffuse(const RgbaColor& diffuse) = 0;
00488 
00494     const RgbaColor& diffuse(void) const { return mDiffuse; }
00495     
00501     virtual void emission(const RgbaColor& emission) = 0;
00502     
00508     const RgbaColor& emission(void) const { return mEmission; }
00509     
00510   private:
00511     String mResourceName;
00512     double mShininess;
00513     RgbaColor mSpecular;
00514     RgbaColor mDiffuse;
00515     RgbaColor mAmbient;
00516     RgbaColor mEmission;
00517     
00518   protected:
00519     void setResourceName(const String& name) { mResourceName = name; }
00520     void setShininess(double s) { mShininess = s; }
00521     void setDiffuse(const RgbaColor& c) { mDiffuse = c; }
00522     void setAmbient(const RgbaColor& c) { mAmbient = c; }
00523     void setSpecular(const RgbaColor& c) { mSpecular = c; }
00524     void setEmission(const RgbaColor& c) { mEmission = c; }
00525   };
00526 
00527  
00528   
00529 }; // namespace Phx
00530 
00531 
00532 #endif /* PHX_GRAPHICS_ENGINE_H */

Generated on Wed Dec 21 22:05:37 2005 for Phoenix OSFS by  doxygen 1.4.2