FIFE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
renderitem.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2013 by the FIFE team *
3  * http://www.fifengine.net *
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 // Standard C++ library includes
23 
24 // 3rd party library includes
25 
26 // FIFE includes
27 // These includes are split up in two parts, separated by one empty line
28 // First block: files included from the FIFE root src directory
29 // Second block: files included from the same folder
31 #include "model/metamodel/object.h"
32 #include "model/metamodel/action.h"
33 
34 #include "visual.h"
35 #include "renderitem.h"
36 
37 namespace FIFE {
38  const int32_t STATIC_IMAGE_NOT_INITIALIZED = -2;
39 
41  instance(parent),
42  screenpoint(),
43  dimensions(),
44  transparency(255),
45  currentFrame(-1),
46  m_cachedStaticImgId(STATIC_IMAGE_NOT_INITIALIZED),
47  m_cachedStaticImgAngle(0) {
48  }
49 
51  if (static_cast<int32_t>(angle) != m_cachedStaticImgAngle) {
53  }
55  return m_cachedStaticImgId;
56  }
57  if(!instance->getObject()->getVisual<ObjectVisual>()) {
58  return -1;
59  }
60 
62  m_cachedStaticImgAngle = angle;
63  return m_cachedStaticImgId;
64  }
65 
67  instance = 0;
68  dimensions = Rect();
69  image.reset();
70  transparency = 255;
71  currentFrame = -1;
73  }
74 }
int32_t getStaticImageIndexByAngle(uint32_t angle, Instance *instance)
Returns closest matching static image for given angle.
Definition: renderitem.cpp:50
void reset(T *ptr=0)
reset this pointer to a null shared pointer this can be used to lower the reference count of the shar...
Definition: sharedptr.h:164
RenderItem(Instance *parent)
Definition: renderitem.cpp:40
Instance * instance
Definition: renderitem.h:45
T * getVisual() const
Gets used visualization.
Definition: object.h:122
Object * getObject()
Gets object where this instance is instantiated from.
Definition: instance.cpp:280
int32_t m_cachedStaticImgAngle
Definition: renderitem.h:79
Object visual contains data that is needed for visualizing objects.
Definition: visual.h:65
ImagePtr image
Definition: renderitem.h:67
RectType< int32_t > Rect
Definition: rect.h:258
unsigned int uint32_t
Definition: core.h:40
int32_t m_cachedStaticImgId
Definition: renderitem.h:78
uint8_t transparency
Definition: renderitem.h:73
An Instance is an &quot;instantiation&quot; of an Object at a Location.
Definition: instance.h:97
const int32_t STATIC_IMAGE_NOT_INITIALIZED
Definition: renderitem.cpp:38
void reset()
Resets the important values.
Definition: renderitem.cpp:66
int32_t currentFrame
Definition: renderitem.h:76