Merge remote-tracking branch 'greye/player-model' into next

This commit is contained in:
Marc Zinnschlag 2012-11-10 12:36:01 +01:00
commit d15eb6cd17
14 changed files with 343 additions and 225 deletions

View file

@ -62,7 +62,7 @@ namespace MWBase
virtual void setPlayerName (const std::string& name) = 0; virtual void setPlayerName (const std::string& name) = 0;
///< Set player name. ///< Set player name.
virtual void setPlayerRace (const std::string& id, bool male) = 0; virtual void setPlayerRace (const std::string& id, bool male, const std::string &head, const std::string &hair) = 0;
///< Set player race. ///< Set player race.
virtual void setPlayerBirthsign (const std::string& id) = 0; virtual void setPlayerBirthsign (const std::string& id) = 0;

View file

@ -7,6 +7,7 @@
#include "review.hpp" #include "review.hpp"
#include "dialogue.hpp" #include "dialogue.hpp"
#include "mode.hpp" #include "mode.hpp"
#include "inventorywindow.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
@ -459,9 +460,16 @@ void CharacterCreation::onRaceDialogBack()
{ {
if (mRaceDialog) if (mRaceDialog)
{ {
mPlayerRaceId = mRaceDialog->getRaceId(); const ESM::NPC &data = mRaceDialog->getResult();
if (!mPlayerRaceId.empty()) mPlayerRaceId = data.mId;
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); if (!mPlayerRaceId.empty()) {
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(
data.mId,
data.isMale(),
data.mHead,
data.mHair
);
}
mWM->removeDialog(mRaceDialog); mWM->removeDialog(mRaceDialog);
mRaceDialog = 0; mRaceDialog = 0;
} }
@ -474,10 +482,18 @@ void CharacterCreation::onRaceDialogDone(WindowBase* parWindow)
{ {
if (mRaceDialog) if (mRaceDialog)
{ {
mPlayerRaceId = mRaceDialog->getRaceId(); const ESM::NPC &data = mRaceDialog->getResult();
mWM->setValue("race", mPlayerRaceId); mPlayerRaceId = data.mRace;
if (!mPlayerRaceId.empty()) if (!mPlayerRaceId.empty()) {
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); MWBase::Environment::get().getMechanicsManager()->setPlayerRace(
data.mRace,
data.isMale(),
data.mHead,
data.mHair
);
}
mWM->getInventoryWindow()->rebuildAvatar();
mWM->removeDialog(mRaceDialog); mWM->removeDialog(mRaceDialog);
mRaceDialog = 0; mRaceDialog = 0;
} }

View file

@ -28,6 +28,10 @@ namespace MWGui
MWWorld::Ptr getAvatarSelectedItem(int x, int y); MWWorld::Ptr getAvatarSelectedItem(int x, int y);
void rebuildAvatar() {
mPreview.rebuild();
}
protected: protected:
MyGUI::Widget* mAvatar; MyGUI::Widget* mAvatar;
MyGUI::ImageBox* mAvatarImage; MyGUI::ImageBox* mAvatarImage;

View file

@ -214,6 +214,29 @@ void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index)
return; return;
mCurrentRaceId = *raceId; mCurrentRaceId = *raceId;
ESM::NPC record = mPreview->getPrototype();
record.mRace = mCurrentRaceId;
record.setIsMale(mGenderIndex == 0);
std::string prefix =
"b_n_" + mCurrentRaceId + ((record.isMale()) ? "_m_" : "_f_");
record.mHead = prefix + "head_01";
record.mHair = prefix + "hair_01";
const MWWorld::Store<ESM::BodyPart> &parts =
MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>();
if (parts.search(record.mHair) == 0) {
record.mHair = prefix + "hair01";
}
mFaceIndex = 0;
mHairIndex = 0;
mPreview->setPrototype(record);
updateSkills(); updateSkills();
updateSpellPowers(); updateSpellPowers();
} }

View file

@ -34,6 +34,7 @@ namespace MWGui
GM_Female GM_Female
}; };
const ESM::NPC &getResult() const { return mPreview->getPrototype(); }
const std::string &getRaceId() const { return mCurrentRaceId; } const std::string &getRaceId() const { return mCurrentRaceId; }
Gender getGender() const { return mGenderIndex == 0 ? GM_Male : GM_Female; } Gender getGender() const { return mGenderIndex == 0 ? GM_Male : GM_Female; }
// getFace() // getFace()

View file

@ -318,7 +318,7 @@ namespace MWMechanics
mUpdatePlayer = true; mUpdatePlayer = true;
} }
void MechanicsManager::setPlayerRace (const std::string& race, bool male) void MechanicsManager::setPlayerRace (const std::string& race, bool male, const std::string &head, const std::string &hair)
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
@ -326,11 +326,9 @@ namespace MWMechanics
*world->getPlayer().getPlayer().get<ESM::NPC>()->mBase; *world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
player.mRace = race; player.mRace = race;
player.mHead = head;
player.mFlags |= ESM::NPC::Female; player.mHair = hair;
if (male) { player.setIsMale(male);
player.mFlags ^= ESM::NPC::Female;
}
world->createRecord(player); world->createRecord(player);

View file

@ -64,7 +64,7 @@ namespace MWMechanics
virtual void setPlayerName (const std::string& name); virtual void setPlayerName (const std::string& name);
///< Set player name. ///< Set player name.
virtual void setPlayerRace (const std::string& id, bool male); virtual void setPlayerRace (const std::string& id, bool male, const std::string &head, const std::string &hair);
///< Set player race. ///< Set player race.
virtual void setPlayerBirthsign (const std::string& id); virtual void setPlayerBirthsign (const std::string& id);

View file

@ -48,8 +48,9 @@ namespace MWRender
mNode->setVisible (false); mNode->setVisible (false);
mCamera->setPosition(mPosition); Ogre::Vector3 scale = mNode->getScale();
mCamera->lookAt(mLookAt); mCamera->setPosition(mPosition * scale);
mCamera->lookAt(mLookAt * scale);
mCamera->setNearClipDistance (0.01); mCamera->setNearClipDistance (0.01);
mCamera->setFarClipDistance (1000); mCamera->setFarClipDistance (1000);
@ -80,6 +81,22 @@ namespace MWRender
delete mAnimation; delete mAnimation;
} }
void CharacterPreview::rebuild()
{
assert(mAnimation);
delete mAnimation;
mAnimation = new NpcAnimation(mCharacter, mNode,
MWWorld::Class::get(mCharacter).getInventoryStore (mCharacter), RV_PlayerPreview);
mNode->setVisible (false);
Ogre::Vector3 scale = mNode->getScale();
mCamera->setPosition(mPosition * scale);
mCamera->lookAt(mLookAt * scale);
onSetup();
}
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
@ -128,8 +145,10 @@ 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, 120, -35), Ogre::Vector3(0,125,0))
, mRef(&mBase)
{ {
mBase = *mCharacter.get<ESM::NPC>()->mBase;
mCharacter = MWWorld::Ptr(&mRef, mCharacter.getCell());
} }
void RaceSelectionPreview::update(float angle) void RaceSelectionPreview::update(float angle)
@ -141,4 +160,11 @@ namespace MWRender
mNode->setVisible (false); mNode->setVisible (false);
} }
void RaceSelectionPreview::setPrototype(const ESM::NPC &proto)
{
mBase = proto;
mBase.mId = "player";
rebuild();
update(0);
}
} }

View file

@ -4,6 +4,7 @@
#include <OgreRenderTarget.h> #include <OgreRenderTarget.h>
#include <OgreMaterialManager.h> #include <OgreMaterialManager.h>
#include <components/esm/loadnpc.hpp>
#include "externalrendering.hpp" #include "externalrendering.hpp"
@ -32,6 +33,7 @@ namespace MWRender
virtual void setup (Ogre::SceneManager *sceneManager); virtual void setup (Ogre::SceneManager *sceneManager);
virtual void onSetup(); virtual void onSetup();
virtual void rebuild();
protected: protected:
Ogre::TexturePtr mTexture; Ogre::TexturePtr mTexture;
@ -77,10 +79,19 @@ namespace MWRender
class RaceSelectionPreview : public CharacterPreview class RaceSelectionPreview : public CharacterPreview
{ {
ESM::NPC mBase;
MWWorld::LiveCellRef<ESM::NPC> mRef;
public: public:
RaceSelectionPreview(); RaceSelectionPreview();
void update(float angle); void update(float angle);
const ESM::NPC &getPrototype() const {
return mBase;
}
void setPrototype(const ESM::NPC &proto);
}; };
} }

View file

@ -17,44 +17,54 @@ using namespace NifOgre;
namespace MWRender{ namespace MWRender{
NpcAnimation::~NpcAnimation() NpcAnimation::~NpcAnimation()
{ {
removeEntities(head); removeEntities(mHead);
removeEntities(hair); removeEntities(mHair);
removeEntities(neck); removeEntities(mNeck);
removeEntities(chest); removeEntities(mChest);
removeEntities(groin); removeEntities(mGroin);
removeEntities(skirt); removeEntities(mSkirt);
removeEntities(rHand); removeEntities(mHandL);
removeEntities(lHand); removeEntities(mHandR);
removeEntities(rWrist); removeEntities(mWristL);
removeEntities(lWrist); removeEntities(mWristR);
removeEntities(rForearm); removeEntities(mForearmL);
removeEntities(lForearm); removeEntities(mForearmR);
removeEntities(rupperArm); removeEntities(mUpperArmL);
removeEntities(lupperArm); removeEntities(mUpperArmR);
removeEntities(rfoot); removeEntities(mFootL);
removeEntities(lfoot); removeEntities(mFootR);
removeEntities(rAnkle); removeEntities(mAnkleL);
removeEntities(lAnkle); removeEntities(mAnkleR);
removeEntities(rKnee); removeEntities(mKneeL);
removeEntities(lKnee); removeEntities(mKneeR);
removeEntities(rUpperLeg); removeEntities(mUpperLegL);
removeEntities(lUpperLeg); removeEntities(mUpperLegR);
removeEntities(rclavicle); removeEntities(mClavicleL);
removeEntities(lclavicle); removeEntities(mClavicleR);
removeEntities(tail); removeEntities(mTail);
} }
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)
: Animation(), mStateID(-1), mInv(_inv), timeToChange(0), mVisibilityFlags(visibilityFlags), : Animation(),
robe(mInv.end()), helmet(mInv.end()), shirt(mInv.end()), mStateID(-1),
cuirass(mInv.end()), greaves(mInv.end()), mInv(inv),
leftpauldron(mInv.end()), rightpauldron(mInv.end()), mTimeToChange(0),
boots(mInv.end()), mVisibilityFlags(visibilityFlags),
leftglove(mInv.end()), rightglove(mInv.end()), skirtiter(mInv.end()), mRobe(mInv.end()),
pants(mInv.end()) mHelmet(mInv.end()),
mShirt(mInv.end()),
mCuirass(mInv.end()),
mGreaves(mInv.end()),
mPauldronL(mInv.end()),
mPauldronR(mInv.end()),
mBoots(mInv.end()),
mPants(mInv.end()),
mGloveL(mInv.end()),
mGloveR(mInv.end()),
mSkirtIter(mInv.end())
{ {
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); mNpc = ptr.get<ESM::NPC>()->mBase;
for (int init = 0; init < 27; init++) for (int init = 0; init < 27; init++)
{ {
@ -64,24 +74,18 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor
const MWWorld::ESMStore &store = const MWWorld::ESMStore &store =
MWBase::Environment::get().getWorld()->getStore(); MWBase::Environment::get().getWorld()->getStore();
const ESM::Race *race = store.get<ESM::Race>().find(ref->mBase->mRace); const ESM::Race *race = store.get<ESM::Race>().find(mNpc->mRace);
std::string hairID = ref->mBase->mHair; mHeadModel = "meshes\\" + store.get<ESM::BodyPart>().find(mNpc->mHead)->mModel;
std::string headID = ref->mBase->mHead; mHairModel = "meshes\\" + store.get<ESM::BodyPart>().find(mNpc->mHair)->mModel;
headModel = "meshes\\" + store.get<ESM::BodyPart>().find(headID)->mModel;
hairModel = "meshes\\" + store.get<ESM::BodyPart>().find(hairID)->mModel;
npcName = ref->mBase->mName;
isFemale = !!(ref->mBase->mFlags&ESM::NPC::Female);
isBeast = !!(race->mData.mFlags&ESM::Race::Beast);
bodyRaceID = "b_n_"+ref->mBase->mRace;
std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower);
mBodyPrefix = "b_n_" + mNpc->mRace;
std::transform(mBodyPrefix.begin(), mBodyPrefix.end(), mBodyPrefix.begin(), ::tolower);
mInsert = node; mInsert = node;
assert(mInsert); assert(mInsert);
bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0;
std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif"); std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif");
mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, smodel); mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, smodel);
@ -125,7 +129,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor
} }
float scale = race->mData.mHeight.mMale; float scale = race->mData.mHeight.mMale;
if (isFemale) { if (!mNpc->isMale()) {
scale = race->mData.mHeight.mFemale; scale = race->mData.mHeight.mFemale;
} }
mInsert->scale(scale, scale, scale); mInsert->scale(scale, scale, scale);
@ -141,18 +145,18 @@ void NpcAnimation::updateParts()
MWWorld::ContainerStoreIterator *iter; MWWorld::ContainerStoreIterator *iter;
int slot; int slot;
} slotlist[] = { } slotlist[] = {
{ &robe, MWWorld::InventoryStore::Slot_Robe }, { &mRobe, MWWorld::InventoryStore::Slot_Robe },
{ &skirtiter, MWWorld::InventoryStore::Slot_Skirt }, { &mSkirtIter, MWWorld::InventoryStore::Slot_Skirt },
{ &helmet, MWWorld::InventoryStore::Slot_Helmet }, { &mHelmet, MWWorld::InventoryStore::Slot_Helmet },
{ &cuirass, MWWorld::InventoryStore::Slot_Cuirass }, { &mCuirass, MWWorld::InventoryStore::Slot_Cuirass },
{ &greaves, MWWorld::InventoryStore::Slot_Greaves }, { &mGreaves, MWWorld::InventoryStore::Slot_Greaves },
{ &leftpauldron, MWWorld::InventoryStore::Slot_LeftPauldron }, { &mPauldronL, MWWorld::InventoryStore::Slot_LeftPauldron },
{ &rightpauldron, MWWorld::InventoryStore::Slot_RightPauldron }, { &mPauldronR, MWWorld::InventoryStore::Slot_RightPauldron },
{ &boots, MWWorld::InventoryStore::Slot_Boots }, { &mBoots, MWWorld::InventoryStore::Slot_Boots },
{ &leftglove, MWWorld::InventoryStore::Slot_LeftGauntlet }, { &mGloveL, MWWorld::InventoryStore::Slot_LeftGauntlet },
{ &rightglove, MWWorld::InventoryStore::Slot_RightGauntlet }, { &mGloveR, MWWorld::InventoryStore::Slot_RightGauntlet },
{ &shirt, MWWorld::InventoryStore::Slot_Shirt }, { &mShirt, MWWorld::InventoryStore::Slot_Shirt },
{ &pants, MWWorld::InventoryStore::Slot_Pants }, { &mPants, MWWorld::InventoryStore::Slot_Pants },
}; };
for(size_t i = 0;i < sizeof(slotlist)/sizeof(slotlist[0]);i++) for(size_t i = 0;i < sizeof(slotlist)/sizeof(slotlist[0]);i++)
{ {
@ -167,9 +171,9 @@ void NpcAnimation::updateParts()
if(apparelChanged) if(apparelChanged)
{ {
if(robe != mInv.end()) if(mRobe != mInv.end())
{ {
MWWorld::Ptr ptr = *robe; MWWorld::Ptr ptr = *mRobe;
const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->mBase; const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->mBase;
std::vector<ESM::PartReference> parts = clothes->mParts.mParts; std::vector<ESM::PartReference> parts = clothes->mParts.mParts;
@ -187,9 +191,9 @@ void NpcAnimation::updateParts()
reserveIndividualPart(ESM::PRT_RPauldron, MWWorld::InventoryStore::Slot_Robe, 5); reserveIndividualPart(ESM::PRT_RPauldron, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_LPauldron, MWWorld::InventoryStore::Slot_Robe, 5); reserveIndividualPart(ESM::PRT_LPauldron, MWWorld::InventoryStore::Slot_Robe, 5);
} }
if(skirtiter != mInv.end()) if(mSkirtIter != mInv.end())
{ {
MWWorld::Ptr ptr = *skirtiter; MWWorld::Ptr ptr = *mSkirtIter;
const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->mBase; const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->mBase;
std::vector<ESM::PartReference> parts = clothes->mParts.mParts; std::vector<ESM::PartReference> parts = clothes->mParts.mParts;
@ -199,103 +203,103 @@ void NpcAnimation::updateParts()
reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Skirt, 4); reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Skirt, 4);
} }
if(helmet != mInv.end()) if(mHelmet != mInv.end())
{ {
removeIndividualPart(ESM::PRT_Hair); removeIndividualPart(ESM::PRT_Hair);
const ESM::Armor *armor = (helmet->get<ESM::Armor>())->mBase; const ESM::Armor *armor = (mHelmet->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Helmet, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_Helmet, 3, parts);
} }
if(cuirass != mInv.end()) if(mCuirass != mInv.end())
{ {
const ESM::Armor *armor = (cuirass->get<ESM::Armor>())->mBase; const ESM::Armor *armor = (mCuirass->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Cuirass, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_Cuirass, 3, parts);
} }
if(greaves != mInv.end()) if(mGreaves != mInv.end())
{ {
const ESM::Armor *armor = (greaves->get<ESM::Armor>())->mBase; const ESM::Armor *armor = (mGreaves->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts);
} }
if(leftpauldron != mInv.end()) if(mPauldronL != mInv.end())
{ {
const ESM::Armor *armor = (leftpauldron->get<ESM::Armor>())->mBase; const ESM::Armor *armor = (mPauldronL->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_LeftPauldron, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_LeftPauldron, 3, parts);
} }
if(rightpauldron != mInv.end()) if(mPauldronR != mInv.end())
{ {
const ESM::Armor *armor = (rightpauldron->get<ESM::Armor>())->mBase; const ESM::Armor *armor = (mPauldronR->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts);
} }
if(boots != mInv.end()) if(mBoots != mInv.end())
{ {
if(boots->getTypeName() == typeid(ESM::Clothing).name()) if(mBoots->getTypeName() == typeid(ESM::Clothing).name())
{ {
const ESM::Clothing *clothes = (boots->get<ESM::Clothing>())->mBase; const ESM::Clothing *clothes = (mBoots->get<ESM::Clothing>())->mBase;
std::vector<ESM::PartReference> parts = clothes->mParts.mParts; std::vector<ESM::PartReference> parts = clothes->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Boots, 2, parts); addPartGroup(MWWorld::InventoryStore::Slot_Boots, 2, parts);
} }
else if(boots->getTypeName() == typeid(ESM::Armor).name()) else if(mBoots->getTypeName() == typeid(ESM::Armor).name())
{ {
const ESM::Armor *armor = (boots->get<ESM::Armor>())->mBase; const ESM::Armor *armor = (mBoots->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Boots, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_Boots, 3, parts);
} }
} }
if(leftglove != mInv.end()) if(mGloveL != mInv.end())
{ {
if(leftglove->getTypeName() == typeid(ESM::Clothing).name()) if(mGloveL->getTypeName() == typeid(ESM::Clothing).name())
{ {
const ESM::Clothing *clothes = (leftglove->get<ESM::Clothing>())->mBase; const ESM::Clothing *clothes = (mGloveL->get<ESM::Clothing>())->mBase;
std::vector<ESM::PartReference> parts = clothes->mParts.mParts; std::vector<ESM::PartReference> parts = clothes->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 2, parts); addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 2, parts);
} }
else else
{ {
const ESM::Armor *armor = (leftglove->get<ESM::Armor>())->mBase; const ESM::Armor *armor = (mGloveL->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 3, parts);
} }
} }
if(rightglove != mInv.end()) if(mGloveR != mInv.end())
{ {
if(rightglove->getTypeName() == typeid(ESM::Clothing).name()) if(mGloveR->getTypeName() == typeid(ESM::Clothing).name())
{ {
const ESM::Clothing *clothes = (rightglove->get<ESM::Clothing>())->mBase; const ESM::Clothing *clothes = (mGloveR->get<ESM::Clothing>())->mBase;
std::vector<ESM::PartReference> parts = clothes->mParts.mParts; std::vector<ESM::PartReference> parts = clothes->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 2, parts); addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 2, parts);
} }
else else
{ {
const ESM::Armor *armor = (rightglove->get<ESM::Armor>())->mBase; const ESM::Armor *armor = (mGloveR->get<ESM::Armor>())->mBase;
std::vector<ESM::PartReference> parts = armor->mParts.mParts; std::vector<ESM::PartReference> parts = armor->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 3, parts); addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 3, parts);
} }
} }
if(shirt != mInv.end()) if(mShirt != mInv.end())
{ {
const ESM::Clothing *clothes = (shirt->get<ESM::Clothing>())->mBase; const ESM::Clothing *clothes = (mShirt->get<ESM::Clothing>())->mBase;
std::vector<ESM::PartReference> parts = clothes->mParts.mParts; std::vector<ESM::PartReference> parts = clothes->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Shirt, 2, parts); addPartGroup(MWWorld::InventoryStore::Slot_Shirt, 2, parts);
} }
if(pants != mInv.end()) if(mPants != mInv.end())
{ {
const ESM::Clothing *clothes = (pants->get<ESM::Clothing>())->mBase; const ESM::Clothing *clothes = (mPants->get<ESM::Clothing>())->mBase;
std::vector<ESM::PartReference> parts = clothes->mParts.mParts; std::vector<ESM::PartReference> parts = clothes->mParts.mParts;
addPartGroup(MWWorld::InventoryStore::Slot_Pants, 2, parts); addPartGroup(MWWorld::InventoryStore::Slot_Pants, 2, parts);
} }
} }
if(mPartPriorities[ESM::PRT_Head] < 1) if(mPartPriorities[ESM::PRT_Head] < 1)
addOrReplaceIndividualPart(ESM::PRT_Head, -1,1, headModel); addOrReplaceIndividualPart(ESM::PRT_Head, -1,1, mHeadModel);
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, hairModel); addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1, mHairModel);
static const struct { static const struct {
ESM::PartReferenceType type; ESM::PartReferenceType type;
@ -329,20 +333,21 @@ void NpcAnimation::updateParts()
if(mPartPriorities[PartTypeList[i].type] < 1) if(mPartPriorities[PartTypeList[i].type] < 1)
{ {
const ESM::BodyPart *part = NULL; const ESM::BodyPart *part = NULL;
bool tryfemale = isFemale; const MWWorld::Store<ESM::BodyPart> &partStore =
int ni = 0; store.get<ESM::BodyPart>();
do {
part = store.get<ESM::BodyPart>().search(bodyRaceID+(tryfemale?"_f_":"_m_")+PartTypeList[i].name[ni]);
if(part) break;
ni ^= 1; if (!mNpc->isMale()) {
if(ni == 0) part = partStore.search(mBodyPrefix + "_f_" + PartTypeList[i].name[0]);
{ if (part == 0) {
if(!tryfemale) part = partStore.search(mBodyPrefix + "_f_" + PartTypeList[i].name[1]);
break;
tryfemale = false;
} }
} while(1); }
if (part == 0) {
part = partStore.search(mBodyPrefix + "_m_" + PartTypeList[i].name[0]);
}
if (part == 0) {
part = partStore.search(mBodyPrefix + "_m_" + PartTypeList[i].name[1]);
}
if(part) if(part)
addOrReplaceIndividualPart(PartTypeList[i].type, -1,1, "meshes\\"+part->mModel); addOrReplaceIndividualPart(PartTypeList[i].type, -1,1, "meshes\\"+part->mModel);
@ -365,12 +370,12 @@ NifOgre::EntityList NpcAnimation::insertBoundedPart(const std::string &mesh, int
void NpcAnimation::runAnimation(float timepassed) void NpcAnimation::runAnimation(float timepassed)
{ {
if(timeToChange > .2) if(mTimeToChange > .2)
{ {
timeToChange = 0; mTimeToChange = 0;
updateParts(); updateParts();
} }
timeToChange += timepassed; mTimeToChange += timepassed;
Animation::runAnimation(timepassed); Animation::runAnimation(timepassed);
} }
@ -395,61 +400,61 @@ void NpcAnimation::removeIndividualPart(int type)
mPartslots[type] = -1; mPartslots[type] = -1;
if(type == ESM::PRT_Head) //0 if(type == ESM::PRT_Head) //0
removeEntities(head); removeEntities(mHead);
else if(type == ESM::PRT_Hair) //1 else if(type == ESM::PRT_Hair) //1
removeEntities(hair); removeEntities(mHair);
else if(type == ESM::PRT_Neck) //2 else if(type == ESM::PRT_Neck) //2
removeEntities(neck); removeEntities(mNeck);
else if(type == ESM::PRT_Cuirass)//3 else if(type == ESM::PRT_Cuirass)//3
removeEntities(chest); removeEntities(mChest);
else if(type == ESM::PRT_Groin)//4 else if(type == ESM::PRT_Groin)//4
removeEntities(groin); removeEntities(mGroin);
else if(type == ESM::PRT_Skirt)//5 else if(type == ESM::PRT_Skirt)//5
removeEntities(skirt); removeEntities(mSkirt);
else if(type == ESM::PRT_RHand)//6 else if(type == ESM::PRT_RHand)//6
removeEntities(rHand); removeEntities(mHandR);
else if(type == ESM::PRT_LHand)//7 else if(type == ESM::PRT_LHand)//7
removeEntities(lHand); removeEntities(mHandL);
else if(type == ESM::PRT_RWrist)//8 else if(type == ESM::PRT_RWrist)//8
removeEntities(rWrist); removeEntities(mWristR);
else if(type == ESM::PRT_LWrist) //9 else if(type == ESM::PRT_LWrist) //9
removeEntities(lWrist); removeEntities(mWristL);
else if(type == ESM::PRT_Shield) //10 else if(type == ESM::PRT_Shield) //10
{ {
} }
else if(type == ESM::PRT_RForearm) //11 else if(type == ESM::PRT_RForearm) //11
removeEntities(rForearm); removeEntities(mForearmR);
else if(type == ESM::PRT_LForearm) //12 else if(type == ESM::PRT_LForearm) //12
removeEntities(lForearm); removeEntities(mForearmL);
else if(type == ESM::PRT_RUpperarm) //13 else if(type == ESM::PRT_RUpperarm) //13
removeEntities(rupperArm); removeEntities(mUpperArmR);
else if(type == ESM::PRT_LUpperarm) //14 else if(type == ESM::PRT_LUpperarm) //14
removeEntities(lupperArm); removeEntities(mUpperArmL);
else if(type == ESM::PRT_RFoot) //15 else if(type == ESM::PRT_RFoot) //15
removeEntities(rfoot); removeEntities(mFootR);
else if(type == ESM::PRT_LFoot) //16 else if(type == ESM::PRT_LFoot) //16
removeEntities(lfoot); removeEntities(mFootL);
else if(type == ESM::PRT_RAnkle) //17 else if(type == ESM::PRT_RAnkle) //17
removeEntities(rAnkle); removeEntities(mAnkleR);
else if(type == ESM::PRT_LAnkle) //18 else if(type == ESM::PRT_LAnkle) //18
removeEntities(lAnkle); removeEntities(mAnkleL);
else if(type == ESM::PRT_RKnee) //19 else if(type == ESM::PRT_RKnee) //19
removeEntities(rKnee); removeEntities(mKneeR);
else if(type == ESM::PRT_LKnee) //20 else if(type == ESM::PRT_LKnee) //20
removeEntities(lKnee); removeEntities(mKneeL);
else if(type == ESM::PRT_RLeg) //21 else if(type == ESM::PRT_RLeg) //21
removeEntities(rUpperLeg); removeEntities(mUpperLegR);
else if(type == ESM::PRT_LLeg) //22 else if(type == ESM::PRT_LLeg) //22
removeEntities(lUpperLeg); removeEntities(mUpperLegL);
else if(type == ESM::PRT_RPauldron) //23 else if(type == ESM::PRT_RPauldron) //23
removeEntities(rclavicle); removeEntities(mClavicleR);
else if(type == ESM::PRT_LPauldron) //24 else if(type == ESM::PRT_LPauldron) //24
removeEntities(lclavicle); removeEntities(mClavicleL);
else if(type == ESM::PRT_Weapon) //25 else if(type == ESM::PRT_Weapon) //25
{ {
} }
else if(type == ESM::PRT_Tail) //26 else if(type == ESM::PRT_Tail) //26
removeEntities(tail); removeEntities(mTail);
} }
void NpcAnimation::reserveIndividualPart(int type, int group, int priority) void NpcAnimation::reserveIndividualPart(int type, int group, int priority)
@ -482,83 +487,83 @@ bool NpcAnimation::addOrReplaceIndividualPart(int type, int group, int priority,
switch(type) switch(type)
{ {
case ESM::PRT_Head: //0 case ESM::PRT_Head: //0
head = insertBoundedPart(mesh, group, "Head"); mHead = insertBoundedPart(mesh, group, "Head");
break; break;
case ESM::PRT_Hair: //1 case ESM::PRT_Hair: //1
hair = insertBoundedPart(mesh, group, "Head"); mHair = insertBoundedPart(mesh, group, "Head");
break; break;
case ESM::PRT_Neck: //2 case ESM::PRT_Neck: //2
neck = insertBoundedPart(mesh, group, "Neck"); mNeck = insertBoundedPart(mesh, group, "Neck");
break; break;
case ESM::PRT_Cuirass: //3 case ESM::PRT_Cuirass: //3
chest = insertBoundedPart(mesh, group, "Chest"); mChest = insertBoundedPart(mesh, group, "Chest");
break; break;
case ESM::PRT_Groin: //4 case ESM::PRT_Groin: //4
groin = insertBoundedPart(mesh, group, "Groin"); mGroin = insertBoundedPart(mesh, group, "Groin");
break; break;
case ESM::PRT_Skirt: //5 case ESM::PRT_Skirt: //5
skirt = insertBoundedPart(mesh, group, "Groin"); mSkirt = insertBoundedPart(mesh, group, "Groin");
break; break;
case ESM::PRT_RHand: //6 case ESM::PRT_RHand: //6
rHand = insertBoundedPart(mesh, group, "Right Hand"); mHandR = insertBoundedPart(mesh, group, "Right Hand");
break; break;
case ESM::PRT_LHand: //7 case ESM::PRT_LHand: //7
lHand = insertBoundedPart(mesh, group, "Left Hand"); mHandL = insertBoundedPart(mesh, group, "Left Hand");
break; break;
case ESM::PRT_RWrist: //8 case ESM::PRT_RWrist: //8
rWrist = insertBoundedPart(mesh, group, "Right Wrist"); mWristR = insertBoundedPart(mesh, group, "Right Wrist");
break; break;
case ESM::PRT_LWrist: //9 case ESM::PRT_LWrist: //9
lWrist = insertBoundedPart(mesh, group, "Left Wrist"); mWristL = insertBoundedPart(mesh, group, "Left Wrist");
break; break;
case ESM::PRT_Shield: //10 case ESM::PRT_Shield: //10
break; break;
case ESM::PRT_RForearm: //11 case ESM::PRT_RForearm: //11
rForearm = insertBoundedPart(mesh, group, "Right Forearm"); mForearmR = insertBoundedPart(mesh, group, "Right Forearm");
break; break;
case ESM::PRT_LForearm: //12 case ESM::PRT_LForearm: //12
lForearm = insertBoundedPart(mesh, group, "Left Forearm"); mForearmL = insertBoundedPart(mesh, group, "Left Forearm");
break; break;
case ESM::PRT_RUpperarm: //13 case ESM::PRT_RUpperarm: //13
rupperArm = insertBoundedPart(mesh, group, "Right Upper Arm"); mUpperArmR = insertBoundedPart(mesh, group, "Right Upper Arm");
break; break;
case ESM::PRT_LUpperarm: //14 case ESM::PRT_LUpperarm: //14
lupperArm = insertBoundedPart(mesh, group, "Left Upper Arm"); mUpperArmL = insertBoundedPart(mesh, group, "Left Upper Arm");
break; break;
case ESM::PRT_RFoot: //15 case ESM::PRT_RFoot: //15
rfoot = insertBoundedPart(mesh, group, "Right Foot"); mFootR = insertBoundedPart(mesh, group, "Right Foot");
break; break;
case ESM::PRT_LFoot: //16 case ESM::PRT_LFoot: //16
lfoot = insertBoundedPart(mesh, group, "Left Foot"); mFootL = insertBoundedPart(mesh, group, "Left Foot");
break; break;
case ESM::PRT_RAnkle: //17 case ESM::PRT_RAnkle: //17
rAnkle = insertBoundedPart(mesh, group, "Right Ankle"); mAnkleR = insertBoundedPart(mesh, group, "Right Ankle");
break; break;
case ESM::PRT_LAnkle: //18 case ESM::PRT_LAnkle: //18
lAnkle = insertBoundedPart(mesh, group, "Left Ankle"); mAnkleL = insertBoundedPart(mesh, group, "Left Ankle");
break; break;
case ESM::PRT_RKnee: //19 case ESM::PRT_RKnee: //19
rKnee = insertBoundedPart(mesh, group, "Right Knee"); mKneeR = insertBoundedPart(mesh, group, "Right Knee");
break; break;
case ESM::PRT_LKnee: //20 case ESM::PRT_LKnee: //20
lKnee = insertBoundedPart(mesh, group, "Left Knee"); mKneeL = insertBoundedPart(mesh, group, "Left Knee");
break; break;
case ESM::PRT_RLeg: //21 case ESM::PRT_RLeg: //21
rUpperLeg = insertBoundedPart(mesh, group, "Right Upper Leg"); mUpperLegR = insertBoundedPart(mesh, group, "Right Upper Leg");
break; break;
case ESM::PRT_LLeg: //22 case ESM::PRT_LLeg: //22
lUpperLeg = insertBoundedPart(mesh, group, "Left Upper Leg"); mUpperLegL = insertBoundedPart(mesh, group, "Left Upper Leg");
break; break;
case ESM::PRT_RPauldron: //23 case ESM::PRT_RPauldron: //23
rclavicle = insertBoundedPart(mesh , group, "Right Clavicle"); mClavicleR = insertBoundedPart(mesh , group, "Right Clavicle");
break; break;
case ESM::PRT_LPauldron: //24 case ESM::PRT_LPauldron: //24
lclavicle = insertBoundedPart(mesh, group, "Left Clavicle"); mClavicleL = insertBoundedPart(mesh, group, "Left Clavicle");
break; break;
case ESM::PRT_Weapon: //25 case ESM::PRT_Weapon: //25
break; break;
case ESM::PRT_Tail: //26 case ESM::PRT_Tail: //26
tail = insertBoundedPart(mesh, group, "Tail"); mTail = insertBoundedPart(mesh, group, "Tail");
break; break;
} }
return true; return true;
@ -570,14 +575,14 @@ void NpcAnimation::addPartGroup(int group, int priority, std::vector<ESM::PartRe
{ {
ESM::PartReference &part = parts[i]; ESM::PartReference &part = parts[i];
const MWWorld::Store<ESM::BodyPart> &parts = const MWWorld::Store<ESM::BodyPart> &partStore =
MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>(); MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>();
const ESM::BodyPart *bodypart = 0; const ESM::BodyPart *bodypart = 0;
if(isFemale) if(!mNpc->isMale())
bodypart = parts.search(part.mFemale); bodypart = partStore.search(part.mFemale);
if(!bodypart) if(!bodypart)
bodypart = parts.search(part.mMale); bodypart = partStore.search(part.mMale);
if(bodypart) if(bodypart)
addOrReplaceIndividualPart(part.mPart, group, priority,"meshes\\" + bodypart->mModel); addOrReplaceIndividualPart(part.mPart, group, priority,"meshes\\" + bodypart->mModel);

View file

@ -8,6 +8,11 @@
#include "../mwclass/npc.hpp" #include "../mwclass/npc.hpp"
#include "../mwworld/containerstore.hpp" #include "../mwworld/containerstore.hpp"
namespace ESM
{
struct NPC;
}
namespace MWRender{ namespace MWRender{
class NpcAnimation: public Animation{ class NpcAnimation: public Animation{
@ -19,57 +24,57 @@ private:
int mPartPriorities[27]; int mPartPriorities[27];
//Bounded Parts //Bounded Parts
NifOgre::EntityList lclavicle; NifOgre::EntityList mClavicleL;
NifOgre::EntityList rclavicle; NifOgre::EntityList mClavicleR;
NifOgre::EntityList rupperArm; NifOgre::EntityList mUpperArmL;
NifOgre::EntityList lupperArm; NifOgre::EntityList mUpperArmR;
NifOgre::EntityList rUpperLeg; NifOgre::EntityList mUpperLegL;
NifOgre::EntityList lUpperLeg; NifOgre::EntityList mUpperLegR;
NifOgre::EntityList lForearm; NifOgre::EntityList mForearmL;
NifOgre::EntityList rForearm; NifOgre::EntityList mForearmR;
NifOgre::EntityList lWrist; NifOgre::EntityList mWristL;
NifOgre::EntityList rWrist; NifOgre::EntityList mWristR;
NifOgre::EntityList rKnee; NifOgre::EntityList mKneeR;
NifOgre::EntityList lKnee; NifOgre::EntityList mKneeL;
NifOgre::EntityList neck; NifOgre::EntityList mNeck;
NifOgre::EntityList rAnkle; NifOgre::EntityList mAnkleL;
NifOgre::EntityList lAnkle; NifOgre::EntityList mAnkleR;
NifOgre::EntityList groin; NifOgre::EntityList mGroin;
NifOgre::EntityList skirt; NifOgre::EntityList mSkirt;
NifOgre::EntityList lfoot; NifOgre::EntityList mFootL;
NifOgre::EntityList rfoot; NifOgre::EntityList mFootR;
NifOgre::EntityList hair; NifOgre::EntityList mHair;
NifOgre::EntityList rHand; NifOgre::EntityList mHandL;
NifOgre::EntityList lHand; NifOgre::EntityList mHandR;
NifOgre::EntityList head; NifOgre::EntityList mHead;
NifOgre::EntityList chest; NifOgre::EntityList mChest;
NifOgre::EntityList tail; NifOgre::EntityList mTail;
bool isBeast; const ESM::NPC *mNpc;
bool isFemale; std::string mHeadModel;
std::string headModel; std::string mHairModel;
std::string hairModel; std::string mBodyPrefix;
std::string npcName;
std::string bodyRaceID;
float timeToChange; float mTimeToChange;
MWWorld::ContainerStoreIterator robe; MWWorld::ContainerStoreIterator mRobe;
MWWorld::ContainerStoreIterator helmet; MWWorld::ContainerStoreIterator mHelmet;
MWWorld::ContainerStoreIterator shirt; MWWorld::ContainerStoreIterator mShirt;
MWWorld::ContainerStoreIterator cuirass; MWWorld::ContainerStoreIterator mCuirass;
MWWorld::ContainerStoreIterator greaves; MWWorld::ContainerStoreIterator mGreaves;
MWWorld::ContainerStoreIterator leftpauldron; MWWorld::ContainerStoreIterator mPauldronL;
MWWorld::ContainerStoreIterator rightpauldron; MWWorld::ContainerStoreIterator mPauldronR;
MWWorld::ContainerStoreIterator boots; MWWorld::ContainerStoreIterator mBoots;
MWWorld::ContainerStoreIterator pants; MWWorld::ContainerStoreIterator mPants;
MWWorld::ContainerStoreIterator leftglove; MWWorld::ContainerStoreIterator mGloveL;
MWWorld::ContainerStoreIterator rightglove; MWWorld::ContainerStoreIterator mGloveR;
MWWorld::ContainerStoreIterator skirtiter; MWWorld::ContainerStoreIterator mSkirtIter;
int mVisibilityFlags; int mVisibilityFlags;
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);
virtual ~NpcAnimation(); virtual ~NpcAnimation();
NifOgre::EntityList insertBoundedPart(const std::string &mesh, int group, const std::string &bonename); NifOgre::EntityList insertBoundedPart(const std::string &mesh, int group, const std::string &bonename);
virtual void runAnimation(float timepassed); virtual void runAnimation(float timepassed);

View file

@ -18,6 +18,7 @@ namespace MWRender
: mCamera(camera), : mCamera(camera),
mPlayerNode(node), mPlayerNode(node),
mCameraNode(mPlayerNode->createChildSceneNode()), mCameraNode(mPlayerNode->createChildSceneNode()),
mAnimation(0),
mFirstPersonView(true), mFirstPersonView(true),
mPreviewMode(false), mPreviewMode(false),
mFreeLook(true), mFreeLook(true),
@ -309,6 +310,9 @@ namespace MWRender
void Player::setAnimation(NpcAnimation *anim) void Player::setAnimation(NpcAnimation *anim)
{ {
if (mAnimation) {
delete mAnimation;
}
mAnimation = anim; mAnimation = anim;
} }

View file

@ -801,7 +801,21 @@ namespace MWWorld
const ESM::NPC *World::createRecord(const ESM::NPC &record) const ESM::NPC *World::createRecord(const ESM::NPC &record)
{ {
return mStore.insert(record); bool update = false;
if (StringUtils::ciEqual(record.mId, "player")) {
const ESM::NPC *player =
mPlayer->getPlayer().get<ESM::NPC>()->mBase;
update = record.isMale() != player->isMale() ||
!StringUtils::ciEqual(record.mRace, player->mRace) ||
!StringUtils::ciEqual(record.mHead, player->mHead) ||
!StringUtils::ciEqual(record.mHair, player->mHair);
}
const ESM::NPC *ret = mStore.insert(record);
if (update) {
mRendering->renderPlayer(mPlayer->getPlayer());
}
return ret;
} }
void World::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, void World::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode,

View file

@ -117,6 +117,17 @@ struct NPC
// Implementation moved to load_impl.cpp // Implementation moved to load_impl.cpp
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
bool isMale() const {
return (mFlags & Female) == 0;
}
void setIsMale(bool value) {
mFlags |= Female;
if (value) {
mFlags ^= Female;
}
}
}; };
} }
#endif #endif