MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / rrCreateWeapon

Method rrCreateWeapon

source/render/RenderManager.cpp:865–889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

863}
864
865void RenderManager::rrCreateWeapon(Creature* curCreature, const Weapon* curWeapon, const std::string& hand)
866{
867 Ogre::Entity* ent = mSceneManager->getEntity(curCreature->getOgreNamePrefix() + curCreature->getName());
868 std::string weaponName = curWeapon->getOgreNamePrefix() + hand;
869 if(!ent->getSkeleton()->hasBone(weaponName))
870 {
871 OD_LOG_WRN("Tried to add weapons to entity \"" + ent->getName() + " \" using model \"" +
872 ent->getMesh()->getName() + "\" that is missing the required bone \"" +
873 curWeapon->getOgreNamePrefix() + hand + "\"");
874 return;
875 }
876 Ogre::Bone* weaponBone = ent->getSkeleton()->getBone(
877 curWeapon->getOgreNamePrefix() + hand);
878 Ogre::Entity* weaponEntity = mSceneManager->createEntity(curWeapon->getOgreNamePrefix()
879 + hand + "_" + curCreature->getName(),
880 curWeapon->getMeshName());
881
882 // Rotate by -90 degrees around the x-axis from the bone's rotation.
883 Ogre::Quaternion rotationQuaternion;
884 rotationQuaternion.FromAngleAxis(Ogre::Degree(-90.0), Ogre::Vector3(1.0,
885 0.0, 0.0));
886
887 ent->attachObjectToBone(weaponBone->getName(), weaponEntity,
888 rotationQuaternion);
889}
890
891void RenderManager::rrDestroyWeapon(Creature* curCreature, const Weapon* curWeapon, const std::string& hand)
892{

Callers 1

createMeshWeaponsMethod · 0.80

Calls 2

Vector3Class · 0.85
getOgreNamePrefixMethod · 0.45

Tested by

no test coverage detected