00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- 00002 00003 this file is part of rcssserver3D 00004 Fri May 9 2003 00005 Copyright (C) 2002,2003 Koblenz University 00006 Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group 00007 $Id: light.h,v 1.8 2004/04/22 17:57:13 rollmark Exp $ 00008 00009 This program is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; version 2 of the License. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00021 */ 00022 #ifndef KEROSIN_LIGHT_H 00023 #define KEROSIN_LIGHT_H 00024 00025 #include <kerosin/openglserver/glbase.h> 00026 #include "staticmesh.h" 00027 #include "oxygen/geometryserver/indexbuffer.h" 00028 #include "oxygen/sceneserver/basenode.h" 00029 00030 namespace kerosin 00031 { 00032 class OpenGLServer; 00033 00034 class Light : public oxygen::BaseNode 00035 { 00036 // 00037 // Function 00038 // 00039 public: 00040 Light(); 00041 00043 float GetRadius() const; 00044 00046 void SetRadius(float radius); 00047 00049 virtual void Prepare(); 00050 00052 void RenderLitMesh(boost::shared_ptr<StaticMesh> mesh); 00053 00055 void FlushCache(); 00056 00058 void ComputeBoundingBox(); 00059 00061 void SetAmbient(const RGBA& ambient); 00062 00064 const RGBA& GetAmbient(); 00065 00067 void SetDiffuse(const RGBA& diffuse); 00068 00070 const RGBA& GetDiffuse(); 00071 00073 void SetSpecular(const RGBA& specular); 00074 00076 const RGBA& GetSpecular(); 00077 00078 protected: 00080 virtual void OnLink(); 00081 00083 virtual void OnUnlink(); 00084 00085 virtual void DeterminePotentiallyLitTriangles(boost::shared_ptr<StaticMesh>& mesh, 00086 std::vector<unsigned int>& triangles); 00087 00088 // 00089 // Members 00090 // 00091 protected: 00093 RGBA mDiffuse; 00094 00096 RGBA mAmbient; 00097 00099 RGBA mSpecular; 00100 00102 int mGLLight; 00103 00104 float mRadius; 00105 unsigned int mVP; 00106 unsigned int mFP; 00107 00109 salt::Vector3f mOldPos; 00110 00112 salt::Matrix mMeshOldTransform; 00113 00115 bool mCacheFlushed; 00116 00117 // indices of influenced triangles 00118 std::vector<unsigned int> mTriangles; 00119 00120 // per-material cached indices 00121 std::vector<oxygen::IndexBuffer> mCachedIndices; 00122 00124 boost::shared_ptr<OpenGLServer> mOpenGLServer; 00125 }; 00126 00127 DECLARE_CLASS(Light); 00128 00129 } //namespace kerosin 00130 00131 #endif //KEROSIN_LIGHT_H