instancerenderer.h

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 
00027 // 3rd party library includes
00028 
00029 // FIFE includes
00030 // These includes are split up in two parts, separated by one empty line
00031 // First block: files included from the FIFE root src directory
00032 // Second block: files included from the same folder
00033 #include "view/rendererbase.h"
00034 
00035 namespace FIFE {
00036     class Location;
00037     class RenderBackend;
00038     class ImagePool;
00039     class AnimationPool;
00040     class InstanceVisualCacheItem;
00041 
00042     class InstanceRenderer: public RendererBase {
00043     public:
00049         InstanceRenderer(RenderBackend* renderbackend, int position, ImagePool* imagepool, AnimationPool* animpool);
00050         
00051         InstanceRenderer(const InstanceRenderer& old);
00052         
00053         RendererBase* clone();
00054 
00057         virtual ~InstanceRenderer();
00058         void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances);
00059         std::string getName() { return "InstanceRenderer"; }
00060 
00063         void addOutlined(Instance* instance, int r, int g, int b, int width);
00064         
00067         void addColored(Instance* instance, int r, int g, int b);
00068         
00071         void removeOutlined(Instance* instance);
00072         
00075         void removeColored(Instance* instance);
00076         
00079         void removeAllOutlines();
00080         
00083         void removeAllColored();
00084         
00087         static InstanceRenderer* getInstance(IRendererContainer* cnt);
00088         
00089         void reset();
00090 
00091     private:
00092         ImagePool* m_imagepool;
00093         AnimationPool* m_animationpool;
00094         
00095         // contains per-instance information for outline drawing
00096         class OutlineInfo {
00097         public:
00098             uint8_t r;
00099             uint8_t g;
00100             uint8_t b;
00101             int width;
00102             Image* outline;
00103             Image* curimg;
00104             OutlineInfo();
00105             ~OutlineInfo();
00106         };
00107         // contains per-instance information for overlay drawing
00108         class ColoringInfo {
00109         public:
00110             uint8_t r;
00111             uint8_t g;
00112             uint8_t b;
00113             Image* overlay;
00114             Image* curimg;
00115             ColoringInfo();
00116             ~ColoringInfo();
00117         };
00118         typedef std::map<Instance*, OutlineInfo> InstanceToOutlines_t;
00119         typedef std::map<Instance*, ColoringInfo> InstanceToColoring_t;
00120         
00121         InstanceToOutlines_t m_instance_outlines;
00122         InstanceToColoring_t m_instance_colorings;
00123         
00126         Image* bindOutline(OutlineInfo& info, InstanceVisualCacheItem& vc, Camera* cam);
00127         Image* bindColoring(ColoringInfo& info, InstanceVisualCacheItem& vc, Camera* cam);
00128     };
00129 }
00130 
00131 #endif
Generated by  doxygen 1.6.2-20100208