FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
visual.h
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 *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library 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 GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_VIEW_VISUAL_H
23 #define FIFE_VIEW_VISUAL_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 "model/metamodel/abstractvisual.h"
34 #include "util/math/angles.h"
35 #include "util/structures/rect.h"
36 
37 namespace FIFE {
38  class Object;
39  class Instance;
40  class Action;
41  class Image;
42  class Camera;
43 
49  class Visual2DGfx: public AbstractVisual {
50  public:
53  virtual ~Visual2DGfx();
54 
58  void setTransparency(uint8_t transparency) { m_transparency = transparency; }
59 
63  unsigned int getTransparency() { return m_transparency; }
64 
68  void setVisible(bool visible) { m_visible = visible; }
69 
73  unsigned int isVisible() { return m_visible; }
74 
75  protected:
78  Visual2DGfx();
79 
80  uint8_t m_transparency;
81  uint8_t m_visible;
82 
83  };
84 
87  class ObjectVisual: public Visual2DGfx {
88  public:
91  static ObjectVisual* create(Object* object);
92 
95  virtual ~ObjectVisual();
96 
106  void addStaticImage(unsigned int angle, int image_index);
107 
111  int getStaticImageIndexByAngle(int angle);
112 
116  int getClosestMatchingAngle(int angle);
117 
120  void getStaticImageAngles(std::vector<int>& angles);
121 
122  private:
125  ObjectVisual();
126 
127  type_angle2id m_angle2img;
128  };
129 
130 
133  class InstanceVisual: public Visual2DGfx {
134  public:
137  static InstanceVisual* create(Instance* instance);
138 
141  virtual ~InstanceVisual();
142 
148  void setStackPosition(int stackposition) { m_stackposition = stackposition; }
149 
153  int getStackPosition() { return m_stackposition; }
154 
155  private:
158  InstanceVisual();
159  int m_stackposition;
160  };
161 
164  class ActionVisual: public Visual2DGfx {
165  public:
168  static ActionVisual* create(Action* action);
169 
172  virtual ~ActionVisual();
173 
176  void addAnimation(unsigned int angle, int animation_index);
177 
181  int getAnimationIndexByAngle(int angle);
182 
185  void getActionImageAngles(std::vector<int>& angles);
186 
187  private:
190  ActionVisual();
191 
192  // animations associated with this action (handles to pool)
193  // mapping = direction -> animation
194  type_angle2id m_animations;
195  };
196 
197 }
198 #endif