Some cleanup

c++11
scrawl 10 years ago
parent 460304b069
commit 1a19cd3607

@ -1,5 +1,7 @@
#include "animation.hpp" #include "animation.hpp"
#include <iomanip>
#include <osg/PositionAttitudeTransform> #include <osg/PositionAttitudeTransform>
#include <osg/TexGen> #include <osg/TexGen>
#include <osg/TexEnvCombine> #include <osg/TexEnvCombine>
@ -91,6 +93,16 @@ namespace MWRender
mInsert->removeChild(mObjectRoot); mInsert->removeChild(mObjectRoot);
} }
void Animation::updatePtr(const MWWorld::Ptr &ptr)
{
mPtr = ptr;
}
void Animation::addAnimSource(const std::string &model)
{
}
osg::Vec3f Animation::runAnimation(float duration) osg::Vec3f Animation::runAnimation(float duration)
{ {
updateEffects(duration); updateEffects(duration);

@ -1,9 +1,6 @@
#ifndef GAME_RENDER_ANIMATION_H #ifndef GAME_RENDER_ANIMATION_H
#define GAME_RENDER_ANIMATION_H #define GAME_RENDER_ANIMATION_H
#include <OgreController.h>
#include <OgreVector3.h>
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include <components/nifosg/controller.hpp> #include <components/nifosg/controller.hpp>
@ -55,7 +52,7 @@ protected:
/* This is the number of *discrete* groups. */ /* This is the number of *discrete* groups. */
static const size_t sNumGroups = 4; static const size_t sNumGroups = 4;
class AnimationTime : public Ogre::ControllerValue<Ogre::Real> class AnimationTime : public SceneUtil::ControllerSource
{ {
private: private:
Animation *mAnimation; Animation *mAnimation;
@ -71,8 +68,7 @@ protected:
const std::string &getAnimName() const const std::string &getAnimName() const
{ return mAnimationName; } { return mAnimationName; }
virtual Ogre::Real getValue() const; virtual float getValue();
virtual void setValue(Ogre::Real value);
}; };
class NullAnimationTime : public SceneUtil::ControllerSource class NullAnimationTime : public SceneUtil::ControllerSource
@ -85,14 +81,15 @@ protected:
}; };
/*
struct AnimSource : public Ogre::AnimationAlloc { struct AnimSource : public Ogre::AnimationAlloc {
//NifOgre::TextKeyMap mTextKeys; //NifOgre::TextKeyMap mTextKeys;
std::vector<Ogre::Controller<Ogre::Real> > mControllers[sNumGroups]; std::vector<Ogre::Controller<Ogre::Real> > mControllers[sNumGroups];
}; };
typedef std::vector< Ogre::SharedPtr<AnimSource> > AnimSourceList; typedef std::vector< Ogre::SharedPtr<AnimSource> > AnimSourceList;
*/
struct AnimState { struct AnimState {
Ogre::SharedPtr<AnimSource> mSource; //Ogre::SharedPtr<AnimSource> mSource;
float mStartTime; float mStartTime;
float mLoopStartTime; float mLoopStartTime;
float mLoopStopTime; float mLoopStopTime;
@ -115,8 +112,6 @@ protected:
}; };
typedef std::map<std::string,AnimState> AnimStateMap; typedef std::map<std::string,AnimState> AnimStateMap;
typedef std::map<Ogre::MovableObject*,std::string> ObjectAttachMap;
osg::ref_ptr<osg::Group> mInsert; osg::ref_ptr<osg::Group> mInsert;
osg::ref_ptr<osg::Node> mObjectRoot; osg::ref_ptr<osg::Node> mObjectRoot;
@ -204,7 +199,7 @@ protected:
/* Adds the keyframe controllers in the specified model as a new animation source. Note that /* Adds the keyframe controllers in the specified model as a new animation source. Note that
* the filename portion of the provided model name will be prepended with 'x', and the .nif * the filename portion of the provided model name will be prepended with 'x', and the .nif
* extension will be replaced with .kf. */ * extension will be replaced with .kf. */
//void addAnimSource(const std::string &model); void addAnimSource(const std::string &model);
/** Adds an additional light to the given node using the specified ESM record. */ /** Adds an additional light to the given node using the specified ESM record. */
void addExtraLight(osg::ref_ptr<osg::Group> parent, const ESM::Light *light); void addExtraLight(osg::ref_ptr<osg::Group> parent, const ESM::Light *light);
@ -238,7 +233,7 @@ public:
void removeEffect (int effectId); void removeEffect (int effectId);
void getLoopingEffects (std::vector<int>& out); void getLoopingEffects (std::vector<int>& out);
//void updatePtr(const MWWorld::Ptr &ptr); void updatePtr(const MWWorld::Ptr &ptr);
//bool hasAnimation(const std::string &anim); //bool hasAnimation(const std::string &anim);

@ -190,12 +190,12 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> par
mViewMode(viewMode), mViewMode(viewMode),
mShowWeapons(false), mShowWeapons(false),
mShowCarriedLeft(true), mShowCarriedLeft(true),
mFirstPersonOffset(0.f, 0.f, 0.f), //mFirstPersonOffset(0.f, 0.f, 0.f),
mAlpha(1.f), mAlpha(1.f),
mNpcType(Type_Normal), mNpcType(Type_Normal),
mSoundsDisabled(disableSounds), mSoundsDisabled(disableSounds)
mHeadPitch(0.f), //mHeadPitch(0.f),
mHeadYaw(0.f) //mHeadYaw(0.f)
{ {
mNpc = mPtr.get<ESM::NPC>()->mBase; mNpc = mPtr.get<ESM::NPC>()->mBase;
@ -562,11 +562,11 @@ void NpcAnimation::updateParts()
if (wasArrowAttached) if (wasArrowAttached)
attachArrow(); attachArrow();
} }
/*
void NpcAnimation::addFirstPersonOffset(const Ogre::Vector3 &offset) void NpcAnimation::addFirstPersonOffset(const Ogre::Vector3 &offset)
{ {
mFirstPersonOffset += offset; mFirstPersonOffset += offset;
} }*/
Animation::PartHolderPtr NpcAnimation::insertBoundedPart(const std::string& model, int group, const std::string& bonename, const std::string& bonefilter, bool enchantedGlow, osg::Vec4f* glowColor) Animation::PartHolderPtr NpcAnimation::insertBoundedPart(const std::string& model, int group, const std::string& bonename, const std::string& bonefilter, bool enchantedGlow, osg::Vec4f* glowColor)
{ {
@ -903,6 +903,7 @@ void NpcAnimation::setVampire(bool vampire)
} }
} }
/*
void NpcAnimation::setHeadPitch(Ogre::Radian pitch) void NpcAnimation::setHeadPitch(Ogre::Radian pitch)
{ {
mHeadPitch = pitch; mHeadPitch = pitch;
@ -922,5 +923,6 @@ Ogre::Radian NpcAnimation::getHeadYaw() const
{ {
return mHeadYaw; return mHeadYaw;
} }
*/
} }

@ -90,7 +90,7 @@ private:
int mPartslots[ESM::PRT_Count]; //Each part slot is taken by clothing, armor, or is empty int mPartslots[ESM::PRT_Count]; //Each part slot is taken by clothing, armor, or is empty
int mPartPriorities[ESM::PRT_Count]; int mPartPriorities[ESM::PRT_Count];
Ogre::Vector3 mFirstPersonOffset; //Ogre::Vector3 mFirstPersonOffset;
boost::shared_ptr<HeadAnimationTime> mHeadAnimationTime; boost::shared_ptr<HeadAnimationTime> mHeadAnimationTime;
//Ogre::SharedPtr<WeaponAnimationTime> mWeaponAnimationTime; //Ogre::SharedPtr<WeaponAnimationTime> mWeaponAnimationTime;
@ -98,8 +98,8 @@ private:
float mAlpha; float mAlpha;
bool mSoundsDisabled; bool mSoundsDisabled;
Ogre::Radian mHeadYaw; //Ogre::Radian mHeadYaw;
Ogre::Radian mHeadPitch; //Ogre::Radian mHeadPitch;
void updateNpcBase(); void updateNpcBase();
@ -144,10 +144,10 @@ public:
/// to indicate the facing orientation of the character. /// to indicate the facing orientation of the character.
virtual void setPitchFactor(float factor) { mPitchFactor = factor; } virtual void setPitchFactor(float factor) { mPitchFactor = factor; }
virtual void setHeadPitch(Ogre::Radian pitch); //virtual void setHeadPitch(Ogre::Radian pitch);
virtual void setHeadYaw(Ogre::Radian yaw); //virtual void setHeadYaw(Ogre::Radian yaw);
virtual Ogre::Radian getHeadPitch() const; //virtual Ogre::Radian getHeadPitch() const;
virtual Ogre::Radian getHeadYaw() const; //virtual Ogre::Radian getHeadYaw() const;
virtual void showWeapons(bool showWeapon); virtual void showWeapons(bool showWeapon);
virtual void showCarriedLeft(bool show); virtual void showCarriedLeft(bool show);
@ -167,7 +167,7 @@ public:
/// \brief Applies a translation to the arms and hands. /// \brief Applies a translation to the arms and hands.
/// This may be called multiple times before the animation /// This may be called multiple times before the animation
/// is updated to add additional offsets. /// is updated to add additional offsets.
void addFirstPersonOffset(const Ogre::Vector3 &offset); //void addFirstPersonOffset(const Ogre::Vector3 &offset);
/// Rebuilds the NPC, updating their root model, animation sources, and equipment. /// Rebuilds the NPC, updating their root model, animation sources, and equipment.
void rebuild(); void rebuild();

@ -1,9 +1,9 @@
#ifndef GAME_RENDER_OBJECTS_H #ifndef GAME_RENDER_OBJECTS_H
#define GAME_RENDER_OBJECTS_H #define GAME_RENDER_OBJECTS_H
#include <OgreAxisAlignedBox.h> #include <map>
#include <memory>
#include <components/resource/resourcesystem.hpp> #include <string>
#include <osg/ref_ptr> #include <osg/ref_ptr>
@ -12,6 +12,11 @@ namespace osg
class Group; class Group;
} }
namespace Resource
{
class ResourceSystem;
}
namespace MWWorld namespace MWWorld
{ {
class Ptr; class Ptr;

@ -10,12 +10,12 @@
#include <osgViewer/Viewer> #include <osgViewer/Viewer>
#include <components/resource/resourcesystem.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include <components/sceneutil/util.hpp> #include <components/sceneutil/util.hpp>
#include <components/sceneutil/lightmanager.hpp> #include <components/sceneutil/lightmanager.hpp>
#include <components/sceneutil/statesetupdater.hpp> #include <components/sceneutil/statesetupdater.hpp>
#include <components/esm/loadcell.hpp> #include <components/esm/loadcell.hpp>

@ -5,6 +5,8 @@
#include <components/nif/niffile.hpp> #include <components/nif/niffile.hpp>
#include <components/misc/resourcehelpers.hpp> #include <components/misc/resourcehelpers.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/vfs/manager.hpp>
#include <osg/PositionAttitudeTransform> #include <osg/PositionAttitudeTransform>

@ -44,7 +44,7 @@ namespace NifOsg
public: public:
TextKeyMap mTextKeys; TextKeyMap mTextKeys;
std::map<std::string, osg::ref_ptr<SourcedKeyframeController> > mKeyframeControllers; std::map<std::string, osg::ref_ptr<const SourcedKeyframeController> > mKeyframeControllers;
}; };
/// The main class responsible for loading NIF files into an OSG-Scenegraph. /// The main class responsible for loading NIF files into an OSG-Scenegraph.
@ -53,7 +53,6 @@ namespace NifOsg
class Loader class Loader
{ {
public: public:
// TODO: add text keys as user data on the node
/// Create a scene graph for the given NIF. Auto-detects when skinning is used and calls loadAsSkeleton instead. /// Create a scene graph for the given NIF. Auto-detects when skinning is used and calls loadAsSkeleton instead.
/// @param node The parent of the new root node for the created scene graph. /// @param node The parent of the new root node for the created scene graph.
static osg::ref_ptr<osg::Node> load(Nif::NIFFilePtr file, Resource::TextureManager* textureManager); static osg::ref_ptr<osg::Node> load(Nif::NIFFilePtr file, Resource::TextureManager* textureManager);

Loading…
Cancel
Save