FIFE 2008.0
|
00001 /*************************************************************************** 00002 * Copyright (C) 2005-2008 by the FIFE team * 00003 * http://www.fifengine.de * 00004 * This file is part of FIFE. * 00005 * * 00006 * FIFE is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the * 00018 * Free Software Foundation, Inc., * 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 00020 ***************************************************************************/ 00021 00022 #ifndef FIFE_INSTANCERENDERER_H 00023 #define FIFE_INSTANCERENDERER_H 00024 00025 // Standard C++ library includes 00026 #include <string> 00027 #include <list> 00028 00029 // 3rd party library includes 00030 00031 // FIFE includes 00032 // These includes are split up in two parts, separated by one empty line 00033 // First block: files included from the FIFE root src directory 00034 // Second block: files included from the same folder 00035 #include "view/rendererbase.h" 00036 00037 namespace FIFE { 00038 class Location; 00039 class RenderBackend; 00040 class ImagePool; 00041 class AnimationPool; 00042 00043 class InstanceRenderer: public RendererBase { 00044 public: 00050 InstanceRenderer(RenderBackend* renderbackend, int position, ImagePool* imagepool, AnimationPool* animpool); 00051 00052 InstanceRenderer(const InstanceRenderer& old); 00053 00054 RendererBase* clone(); 00055 00058 virtual ~InstanceRenderer(); 00059 void render(Camera* cam, Layer* layer, RenderList& instances); 00060 std::string getName() { return "InstanceRenderer"; } 00061 00064 void addOutlined(Instance* instance, int r, int g, int b, int width); 00065 00068 void addColored(Instance* instance, int r, int g, int b); 00069 00072 void addTransparentArea(Instance* instance, const std::list<std::string> &groups, unsigned int w, unsigned int h, unsigned char trans, bool front = true); 00073 00076 void removeOutlined(Instance* instance); 00077 00080 void removeColored(Instance* instance); 00081 00084 void removeTransparentArea(Instance* instance); 00085 00088 void removeAllOutlines(); 00089 00092 void removeAllColored(); 00093 00096 void removeAllTransparentAreas(); 00097 00101 void addIgnoreLight(const std::list<std::string> &groups); 00102 00105 void removeIgnoreLight(const std::list<std::string> &groups); 00106 00109 void removeAllIgnoreLight(); 00110 00113 static InstanceRenderer* getInstance(IRendererContainer* cnt); 00114 00117 RenderBackend* getRenderBackend() const {return m_renderbackend;} 00118 00119 void reset(); 00120 00121 private: 00122 ImagePool* m_imagepool; 00123 AnimationPool* m_animationpool; 00124 bool m_area_layer; 00125 std::list<std::string> m_unlit_groups; 00126 00127 // contains per-instance information for outline drawing 00128 class OutlineInfo { 00129 public: 00130 uint8_t r; 00131 uint8_t g; 00132 uint8_t b; 00133 int width; 00134 bool dirty; 00135 Image* outline; 00136 Image* curimg; 00137 OutlineInfo(); 00138 ~OutlineInfo(); 00139 }; 00140 // contains per-instance information for overlay drawing 00141 class ColoringInfo { 00142 public: 00143 uint8_t r; 00144 uint8_t g; 00145 uint8_t b; 00146 bool dirty; 00147 Image* overlay; 00148 Image* curimg; 00149 ColoringInfo(); 00150 ~ColoringInfo(); 00151 }; 00152 class AreaInfo { 00153 public: 00154 Instance* instance; 00155 //std::string groups; 00156 std::list<std::string> groups; 00157 unsigned int w; 00158 unsigned int h; 00159 unsigned char trans; 00160 bool front; 00161 float z; 00162 AreaInfo(); 00163 ~AreaInfo(); 00164 }; 00165 typedef std::map<Instance*, OutlineInfo> InstanceToOutlines_t; 00166 typedef std::map<Instance*, ColoringInfo> InstanceToColoring_t; 00167 typedef std::map<Instance*, AreaInfo> InstanceToAreas_t; 00168 00169 InstanceToOutlines_t m_instance_outlines; 00170 InstanceToColoring_t m_instance_colorings; 00171 InstanceToAreas_t m_instance_areas; 00172 00175 Image* bindOutline(OutlineInfo& info, RenderItem& vc, Camera* cam); 00176 Image* bindColoring(ColoringInfo& info, RenderItem& vc, Camera* cam); 00177 }; 00178 } 00179 00180 #endif