forked from teamnwah/openmw-tes3coop
Merge branch 'raceselection' of https://github.com/scrawl/openmw
This commit is contained in:
commit
c0669f93ec
4 changed files with 41 additions and 7 deletions
|
@ -60,7 +60,7 @@ namespace MWRender
|
||||||
mNode = renderRoot->createChildSceneNode();
|
mNode = renderRoot->createChildSceneNode();
|
||||||
|
|
||||||
mAnimation = new NpcAnimation(mCharacter, mNode,
|
mAnimation = new NpcAnimation(mCharacter, mNode,
|
||||||
MWWorld::Class::get(mCharacter).getInventoryStore (mCharacter), 0);
|
MWWorld::Class::get(mCharacter).getInventoryStore (mCharacter), 0, renderHeadOnly());
|
||||||
|
|
||||||
mNode->setVisible (false);
|
mNode->setVisible (false);
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ namespace MWRender
|
||||||
delete mAnimation;
|
delete mAnimation;
|
||||||
|
|
||||||
mAnimation = new NpcAnimation(mCharacter, mNode,
|
mAnimation = new NpcAnimation(mCharacter, mNode,
|
||||||
MWWorld::Class::get(mCharacter).getInventoryStore (mCharacter), 0);
|
MWWorld::Class::get(mCharacter).getInventoryStore (mCharacter), 0, renderHeadOnly());
|
||||||
|
|
||||||
mNode->setVisible (false);
|
mNode->setVisible (false);
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ namespace MWRender
|
||||||
|
|
||||||
RaceSelectionPreview::RaceSelectionPreview()
|
RaceSelectionPreview::RaceSelectionPreview()
|
||||||
: CharacterPreview(MWBase::Environment::get().getWorld()->getPlayer().getPlayer(),
|
: CharacterPreview(MWBase::Environment::get().getWorld()->getPlayer().getPlayer(),
|
||||||
512, 512, "CharacterHeadPreview", Ogre::Vector3(0, 120, -35), Ogre::Vector3(0,125,0))
|
512, 512, "CharacterHeadPreview", Ogre::Vector3(0, 6, -35), Ogre::Vector3(0,125,0))
|
||||||
, mRef(&mBase)
|
, mRef(&mBase)
|
||||||
{
|
{
|
||||||
mBase = *mCharacter.get<ESM::NPC>()->mBase;
|
mBase = *mCharacter.get<ESM::NPC>()->mBase;
|
||||||
|
@ -173,6 +173,8 @@ namespace MWRender
|
||||||
mAnimation->runAnimation(0.0f);
|
mAnimation->runAnimation(0.0f);
|
||||||
mNode->roll(Ogre::Radian(angle), Ogre::SceneNode::TS_LOCAL);
|
mNode->roll(Ogre::Radian(angle), Ogre::SceneNode::TS_LOCAL);
|
||||||
|
|
||||||
|
updateCamera();
|
||||||
|
|
||||||
mNode->setVisible (true);
|
mNode->setVisible (true);
|
||||||
mRenderTarget->update();
|
mRenderTarget->update();
|
||||||
mNode->setVisible (false);
|
mNode->setVisible (false);
|
||||||
|
@ -189,5 +191,17 @@ namespace MWRender
|
||||||
void RaceSelectionPreview::onSetup ()
|
void RaceSelectionPreview::onSetup ()
|
||||||
{
|
{
|
||||||
mAnimation->play("idle", "start", "stop", false);
|
mAnimation->play("idle", "start", "stop", false);
|
||||||
|
|
||||||
|
updateCamera();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RaceSelectionPreview::updateCamera()
|
||||||
|
{
|
||||||
|
Ogre::Vector3 scale = mNode->getScale();
|
||||||
|
Ogre::Vector3 headOffset = mAnimation->getHeadNode()->_getDerivedPosition();
|
||||||
|
headOffset = mNode->convertLocalToWorldPosition(headOffset);
|
||||||
|
|
||||||
|
mCamera->setPosition(headOffset + mPosition * scale);
|
||||||
|
mCamera->lookAt(headOffset + mPosition*Ogre::Vector3(0,1,0) * scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ namespace MWRender
|
||||||
virtual void rebuild();
|
virtual void rebuild();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual bool renderHeadOnly() { return false; }
|
||||||
|
|
||||||
Ogre::TexturePtr mTexture;
|
Ogre::TexturePtr mTexture;
|
||||||
Ogre::RenderTarget* mRenderTarget;
|
Ogre::RenderTarget* mRenderTarget;
|
||||||
Ogre::Viewport* mViewport;
|
Ogre::Viewport* mViewport;
|
||||||
|
@ -82,6 +84,12 @@ namespace MWRender
|
||||||
ESM::NPC mBase;
|
ESM::NPC mBase;
|
||||||
MWWorld::LiveCellRef<ESM::NPC> mRef;
|
MWWorld::LiveCellRef<ESM::NPC> mRef;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual bool renderHeadOnly() { return true; }
|
||||||
|
|
||||||
|
void updateCamera();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RaceSelectionPreview();
|
RaceSelectionPreview();
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ NpcAnimation::~NpcAnimation()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags)
|
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags, bool headOnly)
|
||||||
: Animation(ptr),
|
: Animation(ptr),
|
||||||
mStateID(-1),
|
mStateID(-1),
|
||||||
mTimeToChange(0),
|
mTimeToChange(0),
|
||||||
|
@ -70,7 +70,8 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor
|
||||||
mPants(inv.end()),
|
mPants(inv.end()),
|
||||||
mGloveL(inv.end()),
|
mGloveL(inv.end()),
|
||||||
mGloveR(inv.end()),
|
mGloveR(inv.end()),
|
||||||
mSkirtIter(inv.end())
|
mSkirtIter(inv.end()),
|
||||||
|
mHeadOnly(headOnly)
|
||||||
{
|
{
|
||||||
mNpc = mPtr.get<ESM::NPC>()->mBase;
|
mNpc = mPtr.get<ESM::NPC>()->mBase;
|
||||||
|
|
||||||
|
@ -215,7 +216,7 @@ void NpcAnimation::updateParts(bool forceupdate)
|
||||||
if(!forceupdate)
|
if(!forceupdate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(size_t i = 0;i < slotlistsize;i++)
|
for(size_t i = 0;i < slotlistsize && !mHeadOnly;i++)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator iter = inv.getSlot(slotlist[i].slot);
|
MWWorld::ContainerStoreIterator iter = inv.getSlot(slotlist[i].slot);
|
||||||
|
|
||||||
|
@ -252,6 +253,9 @@ void NpcAnimation::updateParts(bool forceupdate)
|
||||||
if(mPartPriorities[ESM::PRT_Hair] < 1 && mPartPriorities[ESM::PRT_Head] <= 1)
|
if(mPartPriorities[ESM::PRT_Hair] < 1 && mPartPriorities[ESM::PRT_Head] <= 1)
|
||||||
addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1, mHairModel);
|
addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1, mHairModel);
|
||||||
|
|
||||||
|
if (mHeadOnly)
|
||||||
|
return;
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
ESM::PartReferenceType type;
|
ESM::PartReferenceType type;
|
||||||
const char name[2][12];
|
const char name[2][12];
|
||||||
|
@ -449,4 +453,9 @@ void NpcAnimation::addPartGroup(int group, int priority, const std::vector<ESM::
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ogre::Node* NpcAnimation::getHeadNode()
|
||||||
|
{
|
||||||
|
return mEntityList.mSkelBase->getSkeleton()->getBone("Bip01 Head");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ private:
|
||||||
std::string mHeadModel;
|
std::string mHeadModel;
|
||||||
std::string mHairModel;
|
std::string mHairModel;
|
||||||
std::string mBodyPrefix;
|
std::string mBodyPrefix;
|
||||||
|
bool mHeadOnly;
|
||||||
|
|
||||||
float mTimeToChange;
|
float mTimeToChange;
|
||||||
MWWorld::ContainerStoreIterator mRobe;
|
MWWorld::ContainerStoreIterator mRobe;
|
||||||
|
@ -73,11 +74,13 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node,
|
NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node,
|
||||||
MWWorld::InventoryStore& inv, int visibilityFlags);
|
MWWorld::InventoryStore& inv, int visibilityFlags, bool headOnly=false);
|
||||||
virtual ~NpcAnimation();
|
virtual ~NpcAnimation();
|
||||||
|
|
||||||
virtual Ogre::Vector3 runAnimation(float timepassed);
|
virtual Ogre::Vector3 runAnimation(float timepassed);
|
||||||
|
|
||||||
|
Ogre::Node* getHeadNode();
|
||||||
|
|
||||||
void forceUpdate()
|
void forceUpdate()
|
||||||
{ updateParts(true); }
|
{ updateParts(true); }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue