18 #include "precompiled.h"
43 m_Base(base), m_Color(1.0f, 1.0f, 1.0f, 1.0f), m_Model(NULL), m_Outdated(false), m_Simulation(simulation)
47 template<
typename T,
typename S>
static void delete_pair_2nd(std::pair<T,S> v) {
delete v.second; }
58 const std::vector<u8>& variationKey,
65 for (std::multimap<CStr, CObjectBase::Samp>::iterator it = variation.
samplers.begin(); it != variation.
samplers.end(); ++it)
70 if (! variation.
color.empty())
72 std::stringstream str;
73 str << variation.
color;
75 if (! (str >> r >> g >> b))
85 std::vector<CObjectBase::Samp>::iterator samp;
89 textureProps.
SetWrap(GL_CLAMP_TO_BORDER);
111 std::vector<CObjectBase::Prop> props;
113 for (std::multimap<CStr, CObjectBase::Prop>::iterator it = variation.
props.begin(); it != variation.
props.end(); ++it)
114 props.push_back(it->second);
139 std::vector<CObjectBase::Samp>::iterator samp;
143 textureProps.
SetWrap(GL_CLAMP_TO_EDGE);
156 for (std::multimap<CStr, CObjectBase::Anim>::iterator it = variation.
anims.begin(); it != variation.
anims.end(); ++it)
158 CStr name = it->first.LowerCase();
162 if (name ==
"attack") name =
"melee";
163 else if (name ==
"chop") name =
"gather";
164 else if (name ==
"decay") name =
"corpse";
166 if (! it->second.m_FileName.empty())
168 CSkeletonAnim* anim = model->
BuildAnimation(it->second.m_FileName, name, it->second.m_Speed, it->second.m_ActionPos, it->second.m_ActionPos2, it->second.m_SoundPos);
198 for (
size_t p = 0; p < props.size(); p++)
225 if (ppn.Find(
"loaded-") == 0)
231 const SPropPoint* proppoint = modeldef->FindPropPoint(ppn.c_str());
257 SkeletonAnimMap::const_iterator lower =
m_Animations.lower_bound(animationName);
258 SkeletonAnimMap::const_iterator upper =
m_Animations.upper_bound(animationName);
259 size_t count = std::distance(lower, upper);
263 size_t id =
rand(0, count);
264 std::advance(lower,
id);
265 return lower->second;
270 std::vector<CSkeletonAnim*> anims;
272 SkeletonAnimMap::const_iterator lower =
m_Animations.lower_bound(animationName);
273 SkeletonAnimMap::const_iterator upper =
m_Animations.upper_bound(animationName);
274 for (SkeletonAnimMap::const_iterator it = lower; it != upper; ++it)
275 anims.push_back(it->second);
bool BuildVariation(const std::vector< std::set< CStr > > &selections, const std::vector< u8 > &variationKey, CObjectManager &objectManager)
Describes the position of a prop point within its parent model.
std::wstring m_ProjectileModelName
Represents the filename and GL parameters of a texture, for passing to CTextureManager::CreateTexture...
void AddSampler(const TextureSampler &texture)
std::vector< CObjectBase::Samp > m_Samplers
virtual CModelAbstract * Clone() const =0
CSkeletonAnimDef * m_AnimDef
CSkeletonAnimManager & GetSkeletonAnimManager() const
Public API for simulation system.
CTerrain * GetTerrain()
Get the terrain object that actors managed by this manager should be linked with (primarily for the p...
CMeshManager & GetMeshManager() const
CSkeletonAnim * BuildAnimation(const VfsPath &pathname, const CStr &name, float speed, float actionpos, float actionpos2, float soundpos)
Load raw animation frame animation from given file, and build an animation specific to this model...
CObjectEntry * FindObjectVariation(const CStrW &objname, const std::vector< std::set< CStr > > &selections)
bool SetAnimation(CSkeletonAnim *anim, bool once=false)
std::multimap< CStr, Samp > samplers
bool InitModel(const CModelDefPtr &modeldef)
const String & string() const
struct CObjectBase::@7 m_Properties
CSkeletonAnim * GetRandomAnimation(const CStr &animationName) const
Terrain decal definition.
std::multimap< CStr, Prop > props
void AddProp(const SPropPoint *point, CModelAbstract *model, CObjectEntry *objectentry, float minHeight=0.f, float maxHeight=0.f)
Add a prop to the model on the given point.
void AddAmmoProp(const SPropPoint *point, CModelAbstract *model, CObjectEntry *objectentry)
Add a prop to the model on the given point, and treat it as the ammo prop.
#define MODELFLAG_CASTSHADOWS
SkeletonAnimMap m_Animations
CObjectEntry(CObjectBase *base, CSimulation2 &simulation)
static void delete_pair_2nd(std::pair< T, S > v)
Abstract base class for graphical objects that are used by units, or as props attached to other CMode...
std::multimap< CStr, Anim > anims
std::vector< CSkeletonAnim * > GetAnimations(const CStr &animationName) const
CModelDefPtr GetMesh(const VfsPath &pathname)
const Variation BuildVariation(const std::vector< u8 > &variationKey)
virtual CModel * ToCModel()
Dynamic cast.
Particle emitter model, for attaching emitters as props on other models.
void CalcStaticObjectBounds()
Auxiliary method; calculates object space bounds of this model, based solely on vertex positions...
CMaterial & GetMaterial()
size_t rand(size_t min_inclusive, size_t max_exclusive)
return random integer in [min, max).
void SetWrap(GLint wrap)
Set wrapping mode (typically GL_REPEAT, GL_CLAMP_TO_EDGE, etc).
CSimulation2 & m_Simulation
void AddStaticUniform(const char *key, const CVector4D &value)
void SetMaterial(const CMaterial &material)
boost::shared_ptr< CModelDef > CModelDefPtr
shared_ptr< CTexture > CTexturePtr