00001 //=========================================================================== 00002 /* 00003 This file is part of the CHAI 3D visualization and haptics libraries. 00004 Copyright (C) 2003-2009 by CHAI 3D. All rights reserved. 00005 00006 This library is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License("GPL") version 2 00008 as published by the Free Software Foundation. 00009 00010 For using the CHAI 3D libraries with software that can not be combined 00011 with the GNU GPL, and for taking advantage of the additional benefits 00012 of our support services, please contact CHAI 3D about acquiring a 00013 Professional Edition License. 00014 00015 \author <http://www.chai3d.org> 00016 \author Francois Conti 00017 \version 2.0.0 $Rev: 251 $ 00018 */ 00019 //=========================================================================== 00020 00021 //--------------------------------------------------------------------------- 00022 #ifndef CWorldH 00023 #define CWorldH 00024 //--------------------------------------------------------------------------- 00025 #include "extras/CGlobals.h" 00026 #include "scenegraph/CCamera.h" 00027 #include "scenegraph/CGenericObject.h" 00028 #include "graphics/CTriangle.h" 00029 #include "graphics/CTexture2D.h" 00030 #include "graphics/CColor.h" 00031 #include <vector> 00032 //--------------------------------------------------------------------------- 00033 class cLight; 00034 //--------------------------------------------------------------------------- 00036 #define CHAI_MAXIMUM_OPENGL_LIGHT_COUNT 8 00037 //--------------------------------------------------------------------------- 00038 00039 //=========================================================================== 00047 //=========================================================================== 00048 00049 //=========================================================================== 00059 //=========================================================================== 00060 class cWorld : public cGenericObject 00061 { 00062 00063 public: 00064 00065 //----------------------------------------------------------------------- 00066 // CONSTRUCTOR & DESTRUCTOR: 00067 //----------------------------------------------------------------------- 00068 00070 cWorld(); 00071 00073 virtual ~cWorld(); 00074 00075 00076 //----------------------------------------------------------------------- 00077 // METHODS: 00078 //----------------------------------------------------------------------- 00079 00081 void setBackgroundColor(const GLfloat a_red, 00082 const GLfloat a_green, 00083 const GLfloat a_blue); 00084 00086 void setBackgroundColor(const cColorf& a_color); 00087 00089 cColorf getBackgroundColor() const { return (m_backgroundColor); } 00090 00092 void enableLightSourceRendering(bool enable) { m_renderLightSources = enable; } 00093 00095 cTexture2D* newTexture(); 00096 00098 cTexture2D* getTexture(unsigned int a_index) { return (m_textures[a_index]); }; 00099 00101 void addTexture(cTexture2D* a_texture); 00102 00104 bool removeTexture(cTexture2D* a_texture); 00105 00107 bool deleteTexture(cTexture2D* a_texture); 00108 00110 void deleteAllTextures(); 00111 00113 virtual bool computeCollisionDetection(cVector3d& a_segmentPointA, 00114 cVector3d& a_segmentPointB, 00115 cCollisionRecorder& a_recorder, 00116 cCollisionSettings& a_settings); 00117 00119 virtual void render(const int a_renderMode=0); 00120 00122 virtual cLight* getLightSource(int index); 00123 00125 virtual void onDisplayReset(const bool a_affectChildren = true); 00126 00128 double m_worldModelView[16]; 00129 00130 00131 protected: 00132 00133 //----------------------------------------------------------------------- 00134 // FRIENDS: 00135 //----------------------------------------------------------------------- 00136 friend class cLight; 00137 00138 00139 //----------------------------------------------------------------------- 00140 // METHODS: 00141 //----------------------------------------------------------------------- 00142 00144 bool addLightSource(cLight* a_light); 00145 00147 bool removeLightSource(cLight* a_light); 00148 00149 00150 //----------------------------------------------------------------------- 00151 // MEMBERS: 00152 //----------------------------------------------------------------------- 00153 00155 cColorf m_backgroundColor; 00156 00158 vector<cTexture2D*> m_textures; 00159 00161 vector<cLight*> m_lights; 00162 00164 bool m_renderLightSources; 00165 00167 bool m_performingDisplayReset; 00168 }; 00169 00170 //--------------------------------------------------------------------------- 00171 #endif 00172 //--------------------------------------------------------------------------- 00173