Mercurial > fife-parpg
comparison engine/core/view/renderers/instancerenderer.h @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children | 90005975cdbb |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 /*************************************************************************** | |
2 * Copyright (C) 2005-2008 by the FIFE team * | |
3 * http://www.fifengine.de * | |
4 * This file is part of FIFE. * | |
5 * * | |
6 * FIFE is free software; you can redistribute it and/or modify * | |
7 * it under the terms of the GNU General Public License as published by * | |
8 * the Free Software Foundation; either version 2 of the License, or * | |
9 * (at your option) any later version. * | |
10 * * | |
11 * This program is distributed in the hope that it will be useful, * | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 * GNU General Public License for more details. * | |
15 * * | |
16 * You should have received a copy of the GNU General Public License * | |
17 * along with this program; if not, write to the * | |
18 * Free Software Foundation, Inc., * | |
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | |
20 ***************************************************************************/ | |
21 | |
22 #ifndef FIFE_INSTANCERENDERER_H | |
23 #define FIFE_INSTANCERENDERER_H | |
24 | |
25 // Standard C++ library includes | |
26 | |
27 // 3rd party library includes | |
28 | |
29 // FIFE includes | |
30 // These includes are split up in two parts, separated by one empty line | |
31 // First block: files included from the FIFE root src directory | |
32 // Second block: files included from the same folder | |
33 #include "view/rendererbase.h" | |
34 | |
35 namespace FIFE { | |
36 class Location; | |
37 class RenderBackend; | |
38 class ImagePool; | |
39 class AnimationPool; | |
40 class InstanceVisualCacheItem; | |
41 | |
42 class InstanceRenderer: public RendererBase { | |
43 public: | |
44 /** constructor. | |
45 * @param renderbackend to use | |
46 * @param imagepool image pool where from fetch images | |
47 * @param animpool animation pool where from fetch images | |
48 */ | |
49 InstanceRenderer(RenderBackend* renderbackend, int position, ImagePool* imagepool, AnimationPool* animpool); | |
50 | |
51 InstanceRenderer(const InstanceRenderer& old); | |
52 | |
53 RendererBase* clone(); | |
54 | |
55 /** Destructor. | |
56 */ | |
57 virtual ~InstanceRenderer(); | |
58 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances); | |
59 std::string getName() { return "InstanceRenderer"; } | |
60 | |
61 /** Marks given instance to be outlined with given parameters | |
62 */ | |
63 void addOutlined(Instance* instance, int r, int g, int b, int width); | |
64 | |
65 /** Marks given instance to be colored with given parameters | |
66 */ | |
67 void addColored(Instance* instance, int r, int g, int b); | |
68 | |
69 /** Removes instance from outlining list | |
70 */ | |
71 void removeOutlined(Instance* instance); | |
72 | |
73 /** Removes instance from coloring list | |
74 */ | |
75 void removeColored(Instance* instance); | |
76 | |
77 /** Removes all outlines | |
78 */ | |
79 void removeAllOutlines(); | |
80 | |
81 /** Removes all coloring | |
82 */ | |
83 void removeAllColored(); | |
84 | |
85 /** Gets instance for interface access | |
86 */ | |
87 static InstanceRenderer* getInstance(IRendererContainer* cnt); | |
88 | |
89 void reset(); | |
90 | |
91 private: | |
92 ImagePool* m_imagepool; | |
93 AnimationPool* m_animationpool; | |
94 | |
95 // contains per-instance information for outline drawing | |
96 class OutlineInfo { | |
97 public: | |
98 uint8_t r; | |
99 uint8_t g; | |
100 uint8_t b; | |
101 int width; | |
102 Image* outline; | |
103 Image* curimg; | |
104 OutlineInfo(); | |
105 ~OutlineInfo(); | |
106 }; | |
107 // contains per-instance information for overlay drawing | |
108 class ColoringInfo { | |
109 public: | |
110 uint8_t r; | |
111 uint8_t g; | |
112 uint8_t b; | |
113 Image* overlay; | |
114 Image* curimg; | |
115 ColoringInfo(); | |
116 ~ColoringInfo(); | |
117 }; | |
118 typedef std::map<Instance*, OutlineInfo> InstanceToOutlines_t; | |
119 typedef std::map<Layer*, InstanceToOutlines_t> LayerToOutlineMap_t; | |
120 typedef std::map<Instance*, ColoringInfo> InstanceToColoring_t; | |
121 typedef std::map<Layer*, InstanceToColoring_t> LayerToColoringMap_t; | |
122 // mapping of layer -> instance -> outlineinfo | |
123 LayerToOutlineMap_t m_layer_to_outlinemap; | |
124 LayerToColoringMap_t m_layer_to_coloringmap; | |
125 | |
126 /** Binds new outline (if needed) to the instance's OutlineInfo | |
127 */ | |
128 Image* bindOutline(OutlineInfo& info, InstanceVisualCacheItem& vc, Camera* cam); | |
129 Image* bindColoring(ColoringInfo& info, InstanceVisualCacheItem& vc, Camera* cam); | |
130 }; | |
131 } | |
132 | |
133 #endif |