00001 #ifndef SCENEBUILDERFACTORIES_H 00002 #define SCENEBUILDERFACTORIES_H 00003 00004 00005 #include <string> 00006 #include <sstream> 00007 #include <map> 00008 #include <vector> 00009 00010 00011 class Camera; 00012 class Light; 00013 class Texture; 00014 class Shader; 00015 class Object; 00016 class Scene; 00017 class Animator; 00018 00019 00024 class SceneBuilderFactory 00025 { 00026 public: 00029 SceneBuilderFactory() 00030 { 00031 } 00032 00035 virtual ~SceneBuilderFactory() 00036 { 00037 } 00038 }; 00039 00040 00045 class CameraFactory : public SceneBuilderFactory 00046 { 00047 public: 00050 CameraFactory() 00051 { 00052 } 00053 00060 virtual Camera * create(const std::string & type, std::stringstream & line) = 0; 00061 }; 00062 00063 00068 class PerspectiveCameraFactory : public CameraFactory 00069 { 00070 public: 00073 PerspectiveCameraFactory() 00074 { 00075 } 00076 00083 virtual Camera * create(const std::string & type, std::stringstream & line); 00084 }; 00085 00086 00091 class DepthOfFieldCameraFactory : public CameraFactory 00092 { 00093 public: 00096 DepthOfFieldCameraFactory() 00097 { 00098 } 00099 00106 virtual Camera * create(const std::string & type, std::stringstream & line); 00107 }; 00108 00109 00114 class LightFactory : public SceneBuilderFactory 00115 { 00116 public: 00119 LightFactory() 00120 { 00121 } 00122 00129 virtual Light * create(const std::string & type, std::stringstream & line) = 0; 00130 }; 00131 00132 00137 class PointLightFactory : public LightFactory 00138 { 00139 public: 00142 PointLightFactory() 00143 { 00144 } 00145 00152 virtual Light * create(const std::string & type, std::stringstream & line); 00153 }; 00154 00155 00160 class QuadAreaLightFactory : public LightFactory 00161 { 00162 public: 00165 QuadAreaLightFactory() 00166 { 00167 } 00168 00175 virtual Light * create(const std::string & type, std::stringstream & line); 00176 }; 00177 00178 00183 class TextureFactory : public SceneBuilderFactory 00184 { 00185 public: 00188 TextureFactory() 00189 { 00190 } 00191 00198 virtual Texture * create(const std::string & type, std::stringstream & line) = 0; 00199 }; 00200 00201 00206 class Texture2DFactory : public TextureFactory 00207 { 00208 public: 00211 Texture2DFactory() 00212 { 00213 } 00214 00221 virtual Texture * create(const std::string & type, std::stringstream & line); 00222 }; 00223 00224 00229 class ShaderFactory : public SceneBuilderFactory 00230 { 00231 public: 00234 ShaderFactory() 00235 { 00236 } 00237 00245 virtual Shader * create(const std::string & type, std::stringstream & line, Scene * scene) = 0; 00246 }; 00247 00248 00253 class TexturedShaderFactory : public ShaderFactory 00254 { 00255 public: 00258 TexturedShaderFactory(std::map<std::string, Texture *> & textures) 00259 : mTextures(textures) 00260 { 00261 } 00262 00263 protected: 00265 std::map<std::string, Texture *> & mTextures; 00266 00268 Scene * mScene; 00269 00270 00276 void readTextures( std::stringstream & line, 00277 std::vector<Texture *> & texes ); 00284 void readBump( std::stringstream & line, 00285 Texture *& bump, 00286 float & bumppar ); 00287 }; 00288 00289 00294 class CloudShaderFactory : public TexturedShaderFactory 00295 { 00296 public: 00299 CloudShaderFactory(std::map<std::string, Texture *> & textures) 00300 : TexturedShaderFactory(textures) 00301 { 00302 } 00303 00311 virtual Shader * create(const std::string & type, std::stringstream & line, Scene * scene); 00312 }; 00313 00314 00319 class WoodShaderFactory : public TexturedShaderFactory 00320 { 00321 public: 00324 WoodShaderFactory(std::map<std::string, Texture *> & textures) 00325 : TexturedShaderFactory(textures) 00326 { 00327 } 00328 00336 virtual Shader * create(const std::string & type, std::stringstream & line, Scene * scene); 00337 }; 00338 00339 00344 class MirrorShaderFactory : public TexturedShaderFactory 00345 { 00346 public: 00349 MirrorShaderFactory(std::map<std::string, Texture *> & textures) 00350 : TexturedShaderFactory(textures) 00351 { 00352 } 00353 00361 virtual Shader * create(const std::string & type, std::stringstream & line, Scene * scene); 00362 }; 00363 00364 00369 class PhongShaderFactory : public TexturedShaderFactory 00370 { 00371 public: 00374 PhongShaderFactory(std::map<std::string, Texture *> & textures) 00375 : TexturedShaderFactory(textures) 00376 { 00377 } 00378 00386 virtual Shader * create(const std::string & type, std::stringstream & line, Scene * scene); 00387 }; 00388 00389 00394 class TransparentShaderFactory : public ShaderFactory 00395 { 00396 public: 00399 TransparentShaderFactory() 00400 { 00401 } 00402 00410 virtual Shader * create(const std::string & type, std::stringstream & line, Scene * scene); 00411 }; 00412 00413 00418 class CombineShaderFactory : public TexturedShaderFactory 00419 { 00420 public: 00423 CombineShaderFactory( std::map<std::string, Shader *> & shaders, 00424 std::map<std::string, Texture *> & textures ) 00425 : TexturedShaderFactory(textures), 00426 mShaders(shaders) 00427 { 00428 } 00429 00437 virtual Shader * create(const std::string & type, std::stringstream & line, Scene * scene); 00438 00439 private: 00441 std::map<std::string, Shader *> & mShaders; 00442 }; 00443 00444 00449 class RefractiveShaderFactory : public TexturedShaderFactory 00450 { 00451 public: 00454 RefractiveShaderFactory(std::map<std::string, Texture *> & textures) 00455 : TexturedShaderFactory(textures) 00456 { 00457 } 00458 00466 virtual Shader * create(const std::string & type, std::stringstream & line, Scene * scene); 00467 }; 00468 00469 00474 class CookTorranceShaderFactory : public TexturedShaderFactory 00475 { 00476 public: 00479 CookTorranceShaderFactory(std::map<std::string, Texture *> & textures) 00480 : TexturedShaderFactory(textures) 00481 { 00482 } 00483 00491 virtual Shader * create(const std::string & type, std::stringstream & line, Scene * scene); 00492 }; 00493 00494 00499 class ObjectFactory : public SceneBuilderFactory 00500 { 00501 public: 00504 ObjectFactory() 00505 { 00506 } 00507 00514 virtual Object * create(const std::string & type, std::stringstream & line) = 0; 00515 }; 00516 00517 00522 class ShadedObjectFactory : public ObjectFactory 00523 { 00524 public: 00527 ShadedObjectFactory(std::map<std::string, Shader *> & shaders) 00528 : ObjectFactory(), 00529 mShaders(shaders) 00530 { 00531 } 00532 00533 protected: 00535 std::map<std::string, Shader *> & mShaders; 00536 }; 00537 00538 00543 class OBJObjectFactory : public ShadedObjectFactory 00544 { 00545 public: 00548 OBJObjectFactory(std::map<std::string, Shader *> & shaders) 00549 : ShadedObjectFactory(shaders) 00550 { 00551 } 00552 00559 virtual Object * create(const std::string & type, std::stringstream & line); 00560 }; 00561 00562 00567 class SphereObjectFactory : public ShadedObjectFactory 00568 { 00569 public: 00572 SphereObjectFactory(std::map<std::string, Shader *> & shaders) 00573 : ShadedObjectFactory(shaders) 00574 { 00575 } 00576 00583 virtual Object * create(const std::string & type, std::stringstream & line); 00584 }; 00585 00586 00591 class CopyObjectFactory : public ObjectFactory 00592 { 00593 public: 00596 CopyObjectFactory(std::map<std::string, Object *> & objects) 00597 : ObjectFactory(), 00598 mObjects(objects) 00599 { 00600 } 00601 00608 virtual Object * create(const std::string & type, std::stringstream & line); 00609 00610 protected: 00612 std::map<std::string, Object *> & mObjects; 00613 }; 00614 00615 00620 class Transformator : public SceneBuilderFactory 00621 { 00622 public: 00625 Transformator(std::map<std::string, Object *> & objects) 00626 : mObjects(objects) 00627 { 00628 } 00629 00636 virtual bool transform(const std::string & type, std::stringstream & line) = 0; 00637 00638 protected: 00640 std::map<std::string, Object *> & mObjects; 00641 }; 00642 00643 00648 class Translator : public Transformator 00649 { 00650 public: 00653 Translator(std::map<std::string, Object *> & objects) 00654 : Transformator(objects) 00655 { 00656 } 00657 00664 virtual bool transform(const std::string & type, std::stringstream & line); 00665 }; 00666 00667 00672 class Rotator : public Transformator 00673 { 00674 public: 00677 Rotator(std::map<std::string, Object *> & objects) 00678 : Transformator(objects) 00679 { 00680 } 00681 00688 virtual bool transform(const std::string & type, std::stringstream & line); 00689 }; 00690 00691 00696 class Scaler : public Transformator 00697 { 00698 public: 00701 Scaler(std::map<std::string, Object *> & objects) 00702 : Transformator(objects) 00703 { 00704 } 00705 00712 virtual bool transform(const std::string & type, std::stringstream & line); 00713 }; 00714 00715 00720 class AnimatorParser : public SceneBuilderFactory 00721 { 00722 public: 00725 AnimatorParser(std::map<std::string, Object *> & objects) 00726 : mObjects(objects) 00727 { 00728 } 00729 00736 virtual Animator * create(const std::string & type, std::stringstream & line) = 0; 00737 00738 protected: 00740 std::map<std::string, Object *> & mObjects; 00741 }; 00742 00743 00748 class PhysicsStepParser : public AnimatorParser 00749 { 00750 public: 00753 PhysicsStepParser(std::map<std::string, Object *> & objects) 00754 : AnimatorParser(objects) 00755 { 00756 } 00757 00764 virtual Animator * create(const std::string & type, std::stringstream & line); 00765 }; 00766 00767 00768 #endif 00769