From bcf3e45ff68a071afa248a659ab5dd1bd6a44a88 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Wed, 18 Jan 2012 22:00:03 -0500 Subject: [PATCH 01/30] Proper buffer designation --- apps/openmw/mwrender/npcanimation.cpp | 1 + components/nifogre/ogre_nif_loader.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 0ff679507..063ecbc84 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -79,6 +79,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O } textmappings = NIFLoader::getSingletonPtr()->getTextIndices(smodel); insert->attachObject(base); + if(female) insert->scale(race->data.height.female, race->data.height.female, race->data.height.female); diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 92a5713a3..4c2865642 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -220,7 +220,7 @@ void NIFLoader::createMaterial(const String &name, //Hardware Skinning code, textures may be the wrong color if enabled - /*if(!mSkel.isNull()){ + /* if(!mSkel.isNull()){ material->removeAllTechniques(); Ogre::Technique* tech = material->createTechnique(); @@ -358,7 +358,7 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton().createVertexBuffer( VertexElement::getTypeSize(VET_FLOAT3), - numVerts, HardwareBuffer::HBU_STATIC_WRITE_ONLY, false); + numVerts, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false); if(flip) { @@ -391,7 +391,7 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std decl->addElement(nextBuf, 0, VET_FLOAT3, VES_NORMAL); vbuf = HardwareBufferManager::getSingleton().createVertexBuffer( VertexElement::getTypeSize(VET_FLOAT3), - numVerts, HardwareBuffer::HBU_STATIC_WRITE_ONLY, false); + numVerts, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false); if(flip) { From ec6243dd77433b3bbc9617a93e1bfe57faa0cdae Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Tue, 24 Jan 2012 16:01:29 +0400 Subject: [PATCH 02/30] fixed compilation problem with llvm clang: constant type explicitly set to float --- components/nifogre/ogre_nif_loader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index c62f59ea3..c286d9514 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -1268,7 +1268,7 @@ void NIFLoader::loadResource(Resource *resource) Nif::Node *o = dynamic_cast(f->target.getPtr()); Nif::NiKeyframeDataPtr data = f->data; - if (f->timeStart == 10000000000000000) + if (f->timeStart == 10000000000000000.0f) continue; data->setBonename(o->name.toString()); data->setStartTime(f->timeStart); From 6de0847b86e0b9cea6e272f32ae3e6540a9191b5 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Wed, 25 Jan 2012 01:21:30 -0500 Subject: [PATCH 03/30] Slightly better performance on animation --- apps/openmw/mwrender/animation.cpp | 143 ++++----------------- apps/openmw/mwrender/animation.hpp | 1 + apps/openmw/mwrender/creatureanimation.cpp | 1 + apps/openmw/mwrender/npcanimation.cpp | 26 +--- apps/openmw/mwrender/renderingmanager.cpp | 18 ++- components/nifogre/ogre_nif_loader.cpp | 1 + 6 files changed, 47 insertions(+), 143 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 3bd160e6d..3ae1a0fa7 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -101,7 +101,7 @@ namespace MWRender{ } void Animation::handleShapes(std::vector* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel){ - bool useHandles = skel == creaturemodel->getSkeleton(); + bool useHandles = false; shapeNumber = 0; std::vector::iterator allshapesiter; @@ -186,62 +186,56 @@ namespace MWRender{ Ogre::Vector3 currentVertex = (*allvertices)[verIndex]; Nif::NiSkinData::BoneInfoCopy* boneinfocopy = &(allshapesiter->boneinfo[inds[0].boneinfocopyindex]); Ogre::Bone *bonePtr = 0; - if(useHandles) - { - bonePtr = skel->getBone(boneinfocopy->bonehandle); - } - else - bonePtr = skel->getBone(boneinfocopy->bonename); + + - Ogre::Vector3 vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans; - Ogre::Quaternion vecRot = bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation; - + Ogre::Vector3 vecPos; //= bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans; + Ogre::Quaternion vecRot; //= bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation; + std::map::iterator result = vecRotPos.find(boneinfocopy); - /*if(vecPosRot.find(boneinfocopy->bonehandle) == vecPosRot.end()){ + if(result == vecRotPos.end()){ + bonePtr = skel->getBone(boneinfocopy->bonename); + vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans; vecRot = bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation; - if(useHandles){ + PosAndRot both; both.vecPos = vecPos; both.vecRot = vecRot; - vecPosRot[boneinfocopy->bonehandle] = both; - } + vecRotPos[boneinfocopy] = both; + } else{ - PosAndRot both = vecPosRot[boneinfocopy->bonehandle]; + PosAndRot both = result->second; vecPos = both.vecPos; vecRot = both.vecRot; - }*/ + } Ogre::Vector3 absVertPos = (vecPos + vecRot * currentVertex) * inds[0].weight; for(int i = 1; i < inds.size(); i++){ boneinfocopy = &(allshapesiter->boneinfo[inds[i].boneinfocopyindex]); - if(useHandles) - bonePtr = skel->getBone(boneinfocopy->bonehandle); - else - bonePtr = skel->getBone(boneinfocopy->bonename); - vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans; - vecRot = bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation; + result = vecRotPos.find(boneinfocopy); + - /*if(vecPosRot.find(boneinfocopy->bonehandle) == vecPosRot.end()){ + if(result == vecRotPos.end()){ + bonePtr = skel->getBone(boneinfocopy->bonename); vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans; vecRot = bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation; - if(useHandles){ PosAndRot both; both.vecPos = vecPos; both.vecRot = vecRot; - vecPosRot[boneinfocopy->bonehandle] = both; - } + vecRotPos[boneinfocopy] = both; + } else{ - PosAndRot both = vecPosRot[boneinfocopy->bonehandle]; + PosAndRot both = result->second; vecPos = both.vecPos; vecRot = both.vecRot; - }*/ + } absVertPos += (vecPos + vecRot * currentVertex) * inds[i].weight; @@ -253,76 +247,9 @@ namespace MWRender{ *(addr+2) = absVertPos.z; } - /*for (unsigned int i = 0; i < boneinfovector.size(); i++) - { - Nif::NiSkinData::BoneInfoCopy boneinfo = boneinfovector[i]; - if(skel->hasBone(boneinfo.bonename)){ - Ogre::Bone *bonePtr = skel->getBone(boneinfo.bonename); - Ogre::Vector3 vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfo.trafo.trans; - Ogre::Quaternion vecRot = bonePtr->_getDerivedOrientation() * boneinfo.trafo.rotation; - - for (unsigned int j=0; j < boneinfo.weights.size(); j++) - { - unsigned int verIndex = boneinfo.weights[j].vertex; - if(vertices.find(verIndex) == vertices.end()) - { - Ogre::Vector3 absVertPos = vecPos + vecRot * allvertices[verIndex]; - absVertPos = absVertPos * boneinfo.weights[j].weight; - vertices.insert(verIndex); - Ogre::Real* addr = (pReal + 3 * verIndex); - *addr = absVertPos.x; - *(addr+1) = absVertPos.y; - *(addr+2) = absVertPos.z; - - - } - else - { - - Ogre::Vector3 absVertPos = vecPos + vecRot * allvertices[verIndex]; - absVertPos = absVertPos * boneinfo.weights[j].weight; - Ogre::Vector3 old = Ogre::Vector3(pReal + 3 * verIndex); - absVertPos = absVertPos + old; - Ogre::Real* addr = (pReal + 3 * verIndex); - *addr = absVertPos.x; - *(addr+1) = absVertPos.y; - *(addr+2) = absVertPos.z; - - //std::cout << "Vertex" << verIndex << "Weight: " << boneinfo.weights[i].weight << "was seen twice\n"; - - } - - /*if(normals.find(verIndex) == normals.end()) - { - Ogre::Vector3 absNormalsPos = vecRot * allnormals[verIndex]; - absNormalsPos = absNormalsPos * boneinfo.weights[j].weight; - normals.insert(verIndex); - Ogre::Real* addr = (pRealNormal + 3 * verIndex); - *addr = absNormalsPos.x; - *(addr+1) = absNormalsPos.y; - *(addr+2) = absNormalsPos.z; - } - else - { - Ogre::Vector3 absNormalsPos = vecRot * allnormals[verIndex]; - absNormalsPos = absNormalsPos * boneinfo.weights[j].weight; - Ogre::Vector3 old = Ogre::Vector3(pRealNormal + 3 * verIndex); - absNormalsPos = absNormalsPos + old; - - Ogre::Real* addr = (pRealNormal + 3 * verIndex); - *addr = absNormalsPos.x; - *(addr+1) = absNormalsPos.y; - *(addr+2) = absNormalsPos.z; - - }*/ - - //} - //} - - //} //Comment out - ; + } else { @@ -469,20 +396,19 @@ namespace MWRender{ //base->_updateAnimation(); base->_notifyMoved(); - for(unsigned int i = 0; i < entityparts.size(); i++){ + for(unsigned int i = 0; i < entityparts.size(); i++){ Ogre::SkeletonInstance* skel = entityparts[i]->getSkeleton(); Ogre::Bone* b = skel->getRootBone(); b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3));//This is a trick skel->_updateTransforms(); - // skel->_notifyManualBonesDirty(); entityparts[i]->getAllAnimationStates()->_notifyDirty(); - //entityparts[i]->_updateAnimation(); entityparts[i]->_notifyMoved(); } + std::vector::iterator iter; int slot = 0; if(transformations){ @@ -490,7 +416,7 @@ namespace MWRender{ if(time < iter->getStartTime() || time < startTime || time > iter->getStopTime()) { slot++; - //iter++; + continue; } @@ -546,22 +472,7 @@ namespace MWRender{ //base->_updateAnimation(); base->_notifyMoved(); } - for(int i = 0; i < entityparts.size(); i++){ - skel = entityparts[i]->getSkeleton(); - if(skel->hasBone(iter->getBonename())){ - Ogre::Bone* bone = skel->getBone(iter->getBonename()); - if(bTrans) - bone->setPosition(t); - if(bQuats) - bone->setOrientation(r); - - skel->_updateTransforms(); - //skel->_notifyManualBonesDirty(); - entityparts[i]->getAllAnimationStates()->_notifyDirty(); - // entityparts[i]->_updateAnimation(); - entityparts[i]->_notifyMoved(); - } - } + slot++; } } diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 15c25707c..bad7eca15 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -26,6 +26,7 @@ class Animation{ Ogre::SceneNode* insert; OEngine::Render::OgreRenderer &mRend; MWWorld::Environment& mEnvironment; + std::map vecRotPos; static std::map mUniqueIDs; diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index c2b95186b..ffcfdcea9 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -38,6 +38,7 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environme } void CreatureAnimation::runAnimation(float timepassed){ + vecRotPos.clear(); if(animate > 0){ //Add the amount of time passed to time diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 063ecbc84..4776dc110 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -250,6 +250,7 @@ void NpcAnimation::insertFreePart(const std::string &mesh, const std::string suf void NpcAnimation::runAnimation(float timepassed){ + //1. Add the amount of time passed to time //2. Handle the animation transforms dependent on time @@ -270,36 +271,19 @@ void NpcAnimation::runAnimation(float timepassed){ handleAnimationTransforms(); Ogre::Vector3 current = insert->_getWorldAABB().getCenter(); - //This is the attempt at npc physics - //mEnvironment.mWorld->setObjectPhysicsPosition(insert->getName(), current); - - - - /*if(base->hasSkeleton()) - { - - Ogre::Quaternion boneQuat = rotate; - Ogre::Vector3 boneTrans = trans; - mEnvironment.mWorld->setObjectPhysicsPosition(insert->getName(), boneTrans + insert->getPosition()); - //mEnvironment.mWorld->setObjectPhysicsRotation(insert->getName(), boneQuat * insert->getOrientation()); - - }*/ + std::vector*>::iterator shapepartsiter = shapeparts.begin(); std::vector::iterator entitypartsiter = entityparts.begin(); while(shapepartsiter != shapeparts.end()) { + vecRotPos.clear(); std::vector* shapes = *shapepartsiter; Ogre::Entity* theentity = *entitypartsiter; - /* - Pass* pass = theentity->getSubEntity(0)->getMaterial()->getBestTechnique()->getPass(0); - if (pass->hasVertexProgram() && pass->getVertexProgram()->isSkeletalAnimationIncluded()) - std::cout << "It's hardware\n"; - else - std::cout << "It's software\n";*/ + - handleShapes(shapes, theentity, theentity->getSkeleton()); + handleShapes(shapes, theentity, base->getSkeleton()); shapepartsiter++; entitypartsiter++; } diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index fff141263..a4b51b082 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -25,6 +25,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const :mRendering(_rend), mObjects(mRendering), mDebugging(engine), mActors(mRendering, environment) { mRendering.createScene("PlayerCam", 55, 5); + //mSkyManager = 0; mSkyManager = MWRender::SkyManager::create(mRendering.getWindow(), mRendering.getCamera(), resDir); // Set default mipmap level (NB some APIs ignore this) @@ -126,27 +127,32 @@ void RenderingManager::update (float duration){ void RenderingManager::skyEnable () { + if(mSkyManager) mSkyManager->enable(); } void RenderingManager::skyDisable () { - mSkyManager->disable(); + if(mSkyManager) + mSkyManager->disable(); } void RenderingManager::skySetHour (double hour) { - mSkyManager->setHour(hour); + if(mSkyManager) + mSkyManager->setHour(hour); } void RenderingManager::skySetDate (int day, int month) { - mSkyManager->setDate(day, month); + if(mSkyManager) + mSkyManager->setDate(day, month); } int RenderingManager::skyGetMasserPhase() const { + return mSkyManager->getMasserPhase(); } @@ -155,9 +161,9 @@ int RenderingManager::skyGetSecundaPhase() const return mSkyManager->getSecundaPhase(); } -void RenderingManager::skySetMoonColour (bool red) -{ - mSkyManager->setMoonColour(red); +void RenderingManager::skySetMoonColour (bool red){ + if(mSkyManager) + mSkyManager->setMoonColour(red); } bool RenderingManager::toggleRenderMode(int mode){ return mDebugging.toggleRenderMode(mode); diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 4c2865642..d836a27a4 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -424,6 +424,7 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std bind->setBinding(nextBuf++, vbuf); } + // Vertex colors if (data->colors.length) { From 1da519a91496e7e72a4de22f645bfa249a7d4db7 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sun, 29 Jan 2012 00:42:55 -0500 Subject: [PATCH 04/30] Some cleanup --- apps/openmw/mwrender/animation.cpp | 30 +++++++++++--------------- apps/openmw/mwrender/npcanimation.cpp | 16 +++++--------- components/nifogre/ogre_nif_loader.cpp | 19 +++++++++------- components/nifogre/ogre_nif_loader.hpp | 2 -- 4 files changed, 28 insertions(+), 39 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 3ae1a0fa7..96d65e00d 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -124,8 +124,7 @@ namespace MWRender{ //std::cout << "Name " << copy.sname << "\n"; Ogre::HardwareVertexBufferSharedPtr vbuf = creaturemodel->getMesh()->getSubMesh(copy.sname)->vertexData->vertexBufferBinding->getBuffer(0); Ogre::Real* pReal = static_cast(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL)); - //Ogre::HardwareVertexBufferSharedPtr vbufNormal = creaturemodel->getMesh()->getSubMesh(copy.sname)->vertexData->vertexBufferBinding->getBuffer(1); - // Ogre::Real* pRealNormal = static_cast(vbufNormal->lock(Ogre::HardwareBuffer::HBL_NORMAL)); + std::vector initialVertices = copy.morph.getInitialVertices(); //Each shape has multiple indices @@ -184,13 +183,14 @@ namespace MWRender{ std::vector inds = iter->second; int verIndex = iter->first; Ogre::Vector3 currentVertex = (*allvertices)[verIndex]; + Ogre::Vector3 currentNormal = (*allnormals)[verIndex]; Nif::NiSkinData::BoneInfoCopy* boneinfocopy = &(allshapesiter->boneinfo[inds[0].boneinfocopyindex]); Ogre::Bone *bonePtr = 0; - Ogre::Vector3 vecPos; //= bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans; - Ogre::Quaternion vecRot; //= bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation; + Ogre::Vector3 vecPos; + Ogre::Quaternion vecRot; std::map::iterator result = vecRotPos.find(boneinfocopy); if(result == vecRotPos.end()){ @@ -213,6 +213,7 @@ namespace MWRender{ } Ogre::Vector3 absVertPos = (vecPos + vecRot * currentVertex) * inds[0].weight; + for(int i = 1; i < inds.size(); i++){ @@ -239,12 +240,14 @@ namespace MWRender{ absVertPos += (vecPos + vecRot * currentVertex) * inds[i].weight; + } Ogre::Real* addr = (pReal + 3 * verIndex); *addr = absVertPos.x; *(addr+1) = absVertPos.y; *(addr+2) = absVertPos.z; + } @@ -321,7 +324,7 @@ namespace MWRender{ } vbuf->unlock(); - //vbufNormal->unlock(); + } } @@ -394,18 +397,15 @@ namespace MWRender{ base->getAllAnimationStates()->_notifyDirty(); //base->_updateAnimation(); - base->_notifyMoved(); + //base->_notifyMoved(); for(unsigned int i = 0; i < entityparts.size(); i++){ - Ogre::SkeletonInstance* skel = entityparts[i]->getSkeleton(); + //Ogre::SkeletonInstance* skel = entityparts[i]->getSkeleton(); Ogre::Bone* b = skel->getRootBone(); b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3));//This is a trick - - skel->_updateTransforms(); entityparts[i]->getAllAnimationStates()->_notifyDirty(); - entityparts[i]->_notifyMoved(); } @@ -416,9 +416,7 @@ namespace MWRender{ if(time < iter->getStartTime() || time < startTime || time > iter->getStopTime()) { slot++; - - continue; - + continue; } float x; @@ -439,7 +437,6 @@ namespace MWRender{ timeIndex(time, ttime, tindexI[slot], tindexJ, x); - //std::cout << "X: " << x << " X2: " << x2 << "\n"; Ogre::Vector3 t; Ogre::Quaternion r; @@ -454,7 +451,6 @@ namespace MWRender{ bool bQuats = quats.size() > 0; if(bQuats){ r = Ogre::Quaternion::Slerp(x2, quats[rindexI[slot]], quats[rindexJ], true); - //bone->setOrientation(r); } skel = base->getSkeleton(); if(skel->hasBone(iter->getBonename())){ @@ -467,10 +463,8 @@ namespace MWRender{ skel->_updateTransforms(); - //skel->_notifyManualBonesDirty(); base->getAllAnimationStates()->_notifyDirty(); - //base->_updateAnimation(); - base->_notifyMoved(); + } slot++; diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 4776dc110..40db0006c 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -43,14 +43,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2); bool female = tolower(secondtolast) == 'f'; bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_"; - /*std::cout << "Race: " << ref->base->race ; - if(female){ - std::cout << " Sex: Female" << " Height: " << race->data.height.female << "\n"; - } - else{ - std::cout << " Sex: Male" << " Height: " << race->data.height.male << "\n"; - }*/ - + std::string smodel = "meshes\\base_anim.nif"; @@ -65,7 +58,6 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O base = mRend.getScene()->createEntity(smodel); base->setSkipAnimationStateUpdate(true); //Magical line of code, this makes the bones //stay in the same place when we skipanim, or open a gui window - if(transformations = (NIFLoader::getSingletonPtr())->getAnim(smodel)){ @@ -116,7 +108,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O const ESM::BodyPart* wristr = wristl; const ESM::BodyPart* armr = arml; - + if(upperleg){ insertBoundedPart("meshes\\" + upperleg->model + "*|", "Left Upper Leg"); insertBoundedPart("meshes\\" + upperleg->model, "Right Upper Leg"); @@ -178,7 +170,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O if(clavicler) insertBoundedPart("meshes\\" + clavicler->model , "Right Clavicle", base);*/ - + if(neck) { insertBoundedPart("meshes\\" + neck->model, "Neck"); @@ -187,6 +179,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O insertBoundedPart("meshes\\" + head->model, "Head"); if(hair) insertBoundedPart("meshes\\" + hair->model, "Head"); + if (chest){ insertFreePart("meshes\\" + chest->model, ">\"", insert); @@ -214,6 +207,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O } Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){ + NIFLoader::load(mesh); Entity* ent = mRend.getScene()->createEntity(mesh); diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index d836a27a4..4e3864a67 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -220,14 +220,14 @@ void NIFLoader::createMaterial(const String &name, //Hardware Skinning code, textures may be the wrong color if enabled - /* if(!mSkel.isNull()){ - material->removeAllTechniques(); + + /*material->removeAllTechniques(); Ogre::Technique* tech = material->createTechnique(); //tech->setSchemeName("blahblah"); Pass* pass = tech->createPass(); - pass->setVertexProgram("Ogre/HardwareSkinningFourWeights"); - }*/ + pass->setVertexProgram("Ogre/BasicVertexPrograms/AmbientOneTexture");*/ + // This assigns the texture to this material. If the texture name is // a file name, and this file exists (in a resource directory), it @@ -888,6 +888,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou boneIndex++; } + } else @@ -1154,6 +1155,10 @@ void NIFLoader::loadResource(Resource *resource) bool hasAnim = false; bool baddin = false; bNiTri = true; + if(name == "meshes\\base_anim.nif" || name == "meshes\\base_animkna.nif") + { + bNiTri = false; + } if(suffix == '*') { @@ -1304,15 +1309,13 @@ void NIFLoader::loadResource(Resource *resource) mesh->_setBounds(mBoundingBox, false); } - if (!mSkel.isNull()) + if (!mSkel.isNull() ) { mesh->_notifySkeleton(mSkel); } } -void NIFLoader::addInMesh(Ogre::Mesh* input){ - addin.push_back(input); -} + diff --git a/components/nifogre/ogre_nif_loader.hpp b/components/nifogre/ogre_nif_loader.hpp index fd1620822..b1e0943f5 100644 --- a/components/nifogre/ogre_nif_loader.hpp +++ b/components/nifogre/ogre_nif_loader.hpp @@ -111,7 +111,6 @@ class NIFLoader : Ogre::ManualResourceLoader std::vector* getAnim(std::string name); std::vector* getShapes(std::string name); std::map* getTextIndices(std::string name); - void addInMesh(Ogre::Mesh* input); Ogre::Vector3 convertVector3(const Nif::Vector& vec); @@ -188,7 +187,6 @@ class NIFLoader : Ogre::ManualResourceLoader std::map,ciLessBoost> alltextmappings; std::map,ciLessBoost> allanimmap; std::map,ciLessBoost> allshapesmap; - std::vector addin; std::vector mAnim; std::vector mS; From a301fc355e13fd906152b9d2db2145e220b7316a Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sun, 29 Jan 2012 23:28:05 +0400 Subject: [PATCH 05/30] Feature #162 - Need to create app bundle using CMake, not by hand In progress. Still need to handle dynamically loaded libs (Ogre & Qt plugins) --- CMakeLists.txt | 129 +++++++++++++++++++++++++++---------- apps/openmw/CMakeLists.txt | 4 -- 2 files changed, 96 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 723d10b34..156035ccb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,38 @@ project(OpenMW) -IF (APPLE) - set(APP_BUNDLE_DIR "${OpenMW_BINARY_DIR}/OpenMW.app") +if (APPLE) + set(APP_BUNDLE_NAME "${CMAKE_PROJECT_NAME}.app") + + set(APP_BUNDLE_DIR "${OpenMW_BINARY_DIR}/${APP_BUNDLE_NAME}") # using 10.6 sdk set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk") -ENDIF (APPLE) + + # This override needed to handle cases where some dependencies already fixed up, + # so BundleUtilities cannot find them + + #function(gp_resolve_item_override context item exepath dirs resolved_item resolved) + # message(STATUS "gp_resolve_item_override for ${item} with ${exepath} and ${dirs}") + # if(item MATCHES "@executable_path" AND resolved) + # if (item MATCHES "Frameworks") # if it is a framework + # # get last segment of path + # get_filename_component(fname "${item}" NAME_WE) + # # now cycle through dirs + # find_library(ri NAMES ${fname} PATHS ${exepath} ${dirs}) + # if (ri) + # message(STATUS "found ${ri} for ${item}") + # set(${resolved_item_var} ri) + # endif() + # endif() + # endif() + #endfunction(gp_resolve_item_override) + + #gp_resolve_item_override("" "@executable_path/../Frameworks/Ogre.framework" + # /Users/corristo/Projects/OpenMW/build/OpenMW.app/Contents/MacOS + # "" + # "" + # "") +endif (APPLE) # Macros @@ -268,36 +295,6 @@ if (CMAKE_COMPILER_IS_GNUCC) add_definitions (-Wall) endif (CMAKE_COMPILER_IS_GNUCC) -# Apple bundling -# TODO REWRITE! -if (APPLE) - set(MISC_FILES - ${APP_BUNDLE_DIR}/Contents/MacOS/openmw.cfg - ${APP_BUNDLE_DIR}/Contents/MacOS/plugins.cfg) - - set(OGRE_PLUGINS - ${APP_BUNDLE_DIR}/Contents/Plugins/*) - -install(FILES ${MISC_FILES} DESTINATION ../MacOS) -install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Plugins" DESTINATION ..) -install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Resources/resources" DESTINATION ../Resources) -set(CPACK_GENERATOR "Bundle") -set(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/files/mac/Info.plist") -set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw.icns") -set(CPACK_BUNDLE_NAME "OpenMW") -set(CPACK_PACKAGE_VERSION ${OPENMW_VERSION}) -set(CPACK_PACKAGE_VERSION_MAJOR ${OPENMW_VERSION_MAJOR}) -set(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO}) -set(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE}) - -include(CPack) - -set(CMAKE_EXE_LINKER_FLAGS "-arch i386") -set(CMAKE_CXX_FLAGS "-arch i386") - -endif (APPLE) - - if(DPKG_PROGRAM) SET(CMAKE_INSTALL_PREFIX "/usr") @@ -405,3 +402,69 @@ if (WIN32) #set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") #set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS") endif() + +# Apple bundling +# TODO REWRITE! +if (APPLE) + set(MISC_FILES + ${APP_BUNDLE_DIR}/Contents/MacOS/openmw.cfg + ${APP_BUNDLE_DIR}/Contents/MacOS/plugins.cfg) + + set(OGRE_PLUGINS + ${APP_BUNDLE_DIR}/Contents/Plugins/*) + +#install(FILES ${MISC_FILES} DESTINATION ../MacOS) +#install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Plugins" DESTINATION ..) +#install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Resources/resources" DESTINATION ../Resources) +install(DIRECTORY "${APP_BUNDLE_DIR}" DESTINATION . COMPONENT Runtime) +set(CPACK_GENERATOR "DragNDrop") +# set(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/files/mac/Info.plist") +# set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw.icns") +# set(CPACK_BUNDLE_NAME "OpenMW") +set(CPACK_PACKAGE_VERSION ${OPENMW_VERSION}) +set(CPACK_PACKAGE_VERSION_MAJOR ${OPENMW_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO}) +set(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE}) + +set(APPS "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_NAME}") +set(DIRS "") + +INSTALL(CODE " + set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_SYSTEM_FRAMEWORK_PATH ${CMAKE_SYSTEM_FRAMEWORK_PATH}) + + set(OPENMW_RESOLVED_ITEMS \"\") + + function(gp_resolve_item_override context item exepath dirs resolved_item_var resolved_var) + if(item MATCHES \"@executable_path\" AND NOT \${\${resolved_var}}) + if (item MATCHES \"Frameworks\") # if it is a framework + # get last segment of path + get_filename_component(fname \"\${item}\" NAME_WE) + find_library(ri NAMES \${fname} PATHS \${exepath} \${dirs} /Library/Frameworks) + if (ri) + message(STATUS \"found \${ri} for \${item}\") + string(REGEX REPLACE \"^.*/Frameworks/.*\\\\.framework\" \"\" item_part \${item}) + set(ri \"\${ri}\${item_part}\") + set(\${resolved_item_var} \${ri} PARENT_SCOPE) + set(\${resolved_var} 1 PARENT_SCOPE) + set(OPENMW_RESOLVED_ITEMS \${_OPENMW_RESOLVED_ITEMS} \${ri}) + endif() + else() + # code path for standard (non-framework) libs (ogre & qt pugins) + endif() + endif() + endfunction(gp_resolve_item_override) + + cmake_policy(SET CMP0009 OLD) + set(BU_CHMOD_BUNDLE_ITEMS ON) + include(BundleUtilities) + fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\") + " COMPONENT Runtime) + +include(CPack) + +set(CMAKE_EXE_LINKER_FLAGS "-arch i386") +set(CMAKE_CXX_FLAGS "-arch i386") + +endif (APPLE) \ No newline at end of file diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index e9e548c0e..d8fe3deb5 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -86,10 +86,6 @@ target_link_libraries(openmw if(APPLE) find_library(CARBON_FRAMEWORK Carbon) target_link_libraries(openmw ${CARBON_FRAMEWORK}) - install(TARGETS openmw - BUNDLE DESTINATION . - RUNTIME DESTINATION ../MacOS - COMPONENT Runtime) endif(APPLE) if(DPKG_PROGRAM) From 705b2955a0c522036fba85cea90df982900d16cb Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Mon, 30 Jan 2012 00:28:02 +0400 Subject: [PATCH 06/30] Feature #162 - Need to create app bundle using CMake, not by hand. In progress, working towards plugins support. --- CMakeLists.txt | 57 ++++++++++++++++---------------------------- files/mac/Info.plist | 2 +- 2 files changed, 21 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 156035ccb..740ec83bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,31 +7,6 @@ if (APPLE) # using 10.6 sdk set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk") - - # This override needed to handle cases where some dependencies already fixed up, - # so BundleUtilities cannot find them - - #function(gp_resolve_item_override context item exepath dirs resolved_item resolved) - # message(STATUS "gp_resolve_item_override for ${item} with ${exepath} and ${dirs}") - # if(item MATCHES "@executable_path" AND resolved) - # if (item MATCHES "Frameworks") # if it is a framework - # # get last segment of path - # get_filename_component(fname "${item}" NAME_WE) - # # now cycle through dirs - # find_library(ri NAMES ${fname} PATHS ${exepath} ${dirs}) - # if (ri) - # message(STATUS "found ${ri} for ${item}") - # set(${resolved_item_var} ri) - # endif() - # endif() - # endif() - #endfunction(gp_resolve_item_override) - - #gp_resolve_item_override("" "@executable_path/../Frameworks/Ogre.framework" - # /Users/corristo/Projects/OpenMW/build/OpenMW.app/Contents/MacOS - # "" - # "" - # "") endif (APPLE) # Macros @@ -227,6 +202,13 @@ include_directories("." link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR}) +if(APPLE) + # List used Ogre plugins + SET(USED_OGRE_PLUGINS "RenderSystem_GL" + "Plugin_OctreeSceneManager" + "Plugin_ParticleFX") +endif(APPLE) + add_subdirectory( extern/caelum ) add_subdirectory( extern/mygui_3.0.1 ) @@ -270,22 +252,17 @@ if (APPLE) "${OpenMW_BINARY_DIR}/plugins.cfg") configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist - "${APP_BUNDLE_DIR}/Contents/Info.plist" COPYONLY) + "${APP_BUNDLE_DIR}/Contents/Info.plist") configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns "${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY) - # prepare plugins - configure_file(${OGRE_PLUGIN_DIR}/RenderSystem_GL.dylib - "${APP_BUNDLE_DIR}/Contents/Plugins/RenderSystem_GL.dylib" COPYONLY) - - configure_file(${OGRE_PLUGIN_DIR}/Plugin_OctreeSceneManager.dylib - "${APP_BUNDLE_DIR}/Contents/Plugins/Plugin_OctreeSceneManager.dylib" COPYONLY) - - configure_file(${OGRE_PLUGIN_DIR}/Plugin_ParticleFX.dylib - "${APP_BUNDLE_DIR}/Contents/Plugins/Plugin_ParticleFX.dylib" COPYONLY) - + foreach(plugin ${USED_OGRE_PLUGINS}) + configure_file("${OGRE_PLUGIN_DIR}/${plugin}.dylib" + "${APP_BUNDLE_DIR}/Contents/Plugins/${plugin}.dylib" + COPYONLY) + endforeach() endif (APPLE) @@ -427,6 +404,12 @@ set(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO}) set(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE}) set(APPS "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_NAME}") +set(PLUGINS "") + +foreach(plugin ${USED_OGRE_PLUGINS}) + set(PLUGINS ${PLUGINS} "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_NAME}/Contents/Plugins/${plugin}.dylib") +endforeach() + set(DIRS "") INSTALL(CODE " @@ -459,7 +442,7 @@ INSTALL(CODE " cmake_policy(SET CMP0009 OLD) set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) - fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\") + fixup_bundle(\"${APPS}\" \"${PLUGINS}\" \"${DIRS}\") " COMPONENT Runtime) include(CPack) diff --git a/files/mac/Info.plist b/files/mac/Info.plist index 1872425e7..bc7efd075 100644 --- a/files/mac/Info.plist +++ b/files/mac/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 0.10 + ${OPENMW_VERSION} CSResourcesFileMapped LSRequiresCarbon From 4fe31fbd61d112fd01838027c1e64c88c01ec69f Mon Sep 17 00:00:00 2001 From: "Alexander \"Ace\" Olofsson" Date: Sun, 29 Jan 2012 23:08:02 +0100 Subject: [PATCH 07/30] Simple windows packaging with CPack (NSIS) --- CMakeLists.txt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 723d10b34..b22181148 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -351,6 +351,34 @@ if(DPKG_PROGRAM) include(CPack) endif(DPKG_PROGRAM) +if(WIN32) + FILE(GLOB files "${OpenMW_BINARY_DIR}/Release/*.*") + INSTALL(FILES ${files} DESTINATION ".") + INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "." RENAME "openmw.cfg") + INSTALL(FILES "${OpenMW_BINARY_DIR}/launcher.cfg" "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION ".") + INSTALL(FILES "${OpenMW_BINARY_DIR}/vcredist_x86.exe" DESTINATION "redist") + INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION ".") + + SET(CPACK_GENERATOR "NSIS") + SET(CPACK_PACKAGE_NAME "OpenMW") + SET(CPACK_PACKAGE_VENDOR "OpenMW.org") + SET(CPACK_PACKAGE_VERSION ${OPENMW_VERSION}) + SET(CPACK_PACKAGE_VERSION_MAJOR ${OPENMW_VERSION_MAJOR}) + SET(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO}) + SET(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE}) + SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW;esmtool;Esmtool;omwlauncher;OpenMW Launcher") + SET(CPACK_PACKAGE_DESCRIPTION_FILE "${OpenMW_SOURCE_DIR}/readme.txt") + SET(CPACK_RESOURCE_FILE_LICENSE "${OpenMW_SOURCE_DIR}/GPL3.txt") + SET(CPACK_NSIS_EXECUTABLES_DIRECTORY ".") + SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "ExecWait '\\\"$INSTDIR\\\\redist\\\\vcredist_x86.exe\\\" /q'" ) + SET(CPACK_NSIS_DISPLAY_NAME "OpenMW") + SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.openmw.org") + SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.openmw.org") + SET(CPACK_NSIS_INSTALLED_ICON_NAME "omwlauncher.exe") + + include(CPack) +endif(WIN32) + # Components add_subdirectory (components) From 72c4f752127ced4508e791d367fee8af8ccbe58d Mon Sep 17 00:00:00 2001 From: "Alexander \"Ace\" Olofsson" Date: Sun, 29 Jan 2012 23:12:40 +0100 Subject: [PATCH 08/30] Only install redist if it exists --- CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b22181148..40752c7f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -356,7 +356,6 @@ if(WIN32) INSTALL(FILES ${files} DESTINATION ".") INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "." RENAME "openmw.cfg") INSTALL(FILES "${OpenMW_BINARY_DIR}/launcher.cfg" "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION ".") - INSTALL(FILES "${OpenMW_BINARY_DIR}/vcredist_x86.exe" DESTINATION "redist") INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION ".") SET(CPACK_GENERATOR "NSIS") @@ -370,12 +369,16 @@ if(WIN32) SET(CPACK_PACKAGE_DESCRIPTION_FILE "${OpenMW_SOURCE_DIR}/readme.txt") SET(CPACK_RESOURCE_FILE_LICENSE "${OpenMW_SOURCE_DIR}/GPL3.txt") SET(CPACK_NSIS_EXECUTABLES_DIRECTORY ".") - SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "ExecWait '\\\"$INSTDIR\\\\redist\\\\vcredist_x86.exe\\\" /q'" ) SET(CPACK_NSIS_DISPLAY_NAME "OpenMW") SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.openmw.org") SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.openmw.org") SET(CPACK_NSIS_INSTALLED_ICON_NAME "omwlauncher.exe") + if(EXISTS "${OpenMW_BINARY_DIR}/vcredist_x86.exe") + INSTALL(FILES "${OpenMW_BINARY_DIR}/vcredist_x86.exe" DESTINATION "redist") + SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "ExecWait '\\\"$INSTDIR\\\\redist\\\\vcredist_x86.exe\\\" /q'" ) + endif(EXISTS "${OpenMW_BINARY_DIR}/vcredist_x86.exe") + include(CPack) endif(WIN32) From 9c73fa6b6d61ca1632b129423a28b9c523d2be82 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sun, 29 Jan 2012 17:50:51 -0500 Subject: [PATCH 09/30] Physics sort of fixed --- apps/openmw/mwworld/scene.cpp | 16 +++++++++------- apps/openmw/mwworld/world.cpp | 7 +++++++ apps/openmw/mwworld/world.hpp | 1 + 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index b08a52aac..624c65d57 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -60,12 +60,12 @@ namespace MWWorld std::cout << "Unloading cell\n"; ListHandles functor; - MWWorld::Ptr::CellStore* active = *iter; + - active->forEach(functor); + (*iter)->forEach(functor); { @@ -77,12 +77,13 @@ namespace MWWorld mPhysics->removeObject (node->getName()); } } - mRendering.removeCell(active); + mRendering.removeCell(*iter); //mPhysics->removeObject("Unnamed_43"); - mWorld->getLocalScripts().clearCell (active); - mEnvironment.mMechanicsManager->dropActors (active); - mEnvironment.mSoundManager->stopSound (active); - mActiveCells.erase(active); + mWorld->getLocalScripts().clearCell (*iter); + mEnvironment.mMechanicsManager->dropActors (*iter); + mEnvironment.mSoundManager->stopSound (*iter); + mActiveCells.erase(*iter); + } @@ -108,6 +109,7 @@ namespace MWWorld void Scene::playerCellChange (Ptr::CellStore *cell, const ESM::Position& position, bool adjustPlayerPos) { + mWorld->makeNewPlayer(); if (adjustPlayerPos) mWorld->getPlayer().setPos (position.pos[0], position.pos[1], position.pos[2]); diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 2232e8a1d..f655b6143 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -182,6 +182,13 @@ namespace MWWorld } + void World::makeNewPlayer(){ + MWRender::Player* play = &(mRendering.getPlayer()); + delete mPlayer; + mPlayer = new MWWorld::Player (play, mStore.npcs.find ("player"), *this); + mPhysics->addActor (mPlayer->getPlayer().getRefData().getHandle(), "", Ogre::Vector3 (0, 0, 0)); + } + World::~World() { delete mWorldScene; diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 235d203a6..71231998a 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -220,6 +220,7 @@ namespace MWWorld /// references that are currently not in the rendered scene should be ignored. void setObjectPhysicsRotation(const std::string& handle,Ogre::Quaternion quat); void setObjectPhysicsPosition(const std::string& handle,Ogre::Vector3 vector); + void makeNewPlayer(); }; } From d2b3c1dbac91c68d00455ca8cb20c5b9988506a8 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sun, 29 Jan 2012 18:13:43 -0500 Subject: [PATCH 10/30] Collision may be working correctly --- apps/openmw/mwworld/world.cpp | 10 ++++++++-- apps/openmw/mwworld/world.hpp | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index f655b6143..4439d4c66 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -148,7 +148,7 @@ namespace MWWorld const std::string& master, const boost::filesystem::path& resDir, bool newGame, Environment& environment, const std::string& encoding) : mRendering (renderer,resDir, physEng, environment),mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0), - mSky (false), mEnvironment (environment), mNextDynamicRecord (0), mCells (mStore, mEsm, *this) + mSky (false), bCollision(false), mEnvironment (environment), mNextDynamicRecord (0), mCells (mStore, mEsm, *this) { mPhysEngine = physEng; @@ -183,10 +183,15 @@ namespace MWWorld } void World::makeNewPlayer(){ + bool initialCollision = bCollision; + if(bCollision) + toggleCollisionMode(); MWRender::Player* play = &(mRendering.getPlayer()); delete mPlayer; mPlayer = new MWWorld::Player (play, mStore.npcs.find ("player"), *this); mPhysics->addActor (mPlayer->getPlayer().getRefData().getHandle(), "", Ogre::Vector3 (0, 0, 0)); + if(initialCollision) + toggleCollisionMode(); } World::~World() @@ -619,7 +624,8 @@ namespace MWWorld bool World::toggleCollisionMode() { - return mPhysics->toggleCollisionMode(); + bCollision = mPhysics->toggleCollisionMode(); + return bCollision; } bool World::toggleRenderMode (RenderMode mode) diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 71231998a..eef2f8da3 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -77,6 +77,7 @@ namespace MWWorld bool mSky; Environment& mEnvironment; int mNextDynamicRecord; + bool bCollision; Cells mCells; From 2d0e83a2cf55da1f4830bd587d5f6505a96228cb Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Mon, 30 Jan 2012 00:06:29 -0500 Subject: [PATCH 11/30] Reversing changes --- apps/openmw/mwworld/scene.cpp | 1 - apps/openmw/mwworld/world.cpp | 11 ----------- apps/openmw/mwworld/world.hpp | 2 +- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 624c65d57..1b86ce4fa 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -109,7 +109,6 @@ namespace MWWorld void Scene::playerCellChange (Ptr::CellStore *cell, const ESM::Position& position, bool adjustPlayerPos) { - mWorld->makeNewPlayer(); if (adjustPlayerPos) mWorld->getPlayer().setPos (position.pos[0], position.pos[1], position.pos[2]); diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 4439d4c66..a5fcfe093 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -182,17 +182,6 @@ namespace MWWorld } - void World::makeNewPlayer(){ - bool initialCollision = bCollision; - if(bCollision) - toggleCollisionMode(); - MWRender::Player* play = &(mRendering.getPlayer()); - delete mPlayer; - mPlayer = new MWWorld::Player (play, mStore.npcs.find ("player"), *this); - mPhysics->addActor (mPlayer->getPlayer().getRefData().getHandle(), "", Ogre::Vector3 (0, 0, 0)); - if(initialCollision) - toggleCollisionMode(); - } World::~World() { diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index eef2f8da3..db5b0b9cc 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -221,7 +221,7 @@ namespace MWWorld /// references that are currently not in the rendered scene should be ignored. void setObjectPhysicsRotation(const std::string& handle,Ogre::Quaternion quat); void setObjectPhysicsPosition(const std::string& handle,Ogre::Vector3 vector); - void makeNewPlayer(); + }; } From 472d88e2c558f5dbcf96cf99f1b8b026b8506efb Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Wed, 1 Feb 2012 20:48:13 +0400 Subject: [PATCH 12/30] Feature #162 - Need to create app bundle using CMake, not by hand WIP --- CMakeLists.txt | 120 +++++++++++++++++++---------------- apps/launcher/CMakeLists.txt | 18 ++++++ 2 files changed, 82 insertions(+), 56 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 740ec83bd..50ed5e1c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -381,69 +381,77 @@ if (WIN32) endif() # Apple bundling -# TODO REWRITE! if (APPLE) set(MISC_FILES ${APP_BUNDLE_DIR}/Contents/MacOS/openmw.cfg ${APP_BUNDLE_DIR}/Contents/MacOS/plugins.cfg) - set(OGRE_PLUGINS - ${APP_BUNDLE_DIR}/Contents/Plugins/*) - -#install(FILES ${MISC_FILES} DESTINATION ../MacOS) -#install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Plugins" DESTINATION ..) -#install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Resources/resources" DESTINATION ../Resources) -install(DIRECTORY "${APP_BUNDLE_DIR}" DESTINATION . COMPONENT Runtime) -set(CPACK_GENERATOR "DragNDrop") -# set(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/files/mac/Info.plist") -# set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw.icns") -# set(CPACK_BUNDLE_NAME "OpenMW") -set(CPACK_PACKAGE_VERSION ${OPENMW_VERSION}) -set(CPACK_PACKAGE_VERSION_MAJOR ${OPENMW_VERSION_MAJOR}) -set(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO}) -set(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE}) - -set(APPS "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_NAME}") -set(PLUGINS "") - -foreach(plugin ${USED_OGRE_PLUGINS}) - set(PLUGINS ${PLUGINS} "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_NAME}/Contents/Plugins/${plugin}.dylib") -endforeach() - -set(DIRS "") - -INSTALL(CODE " - set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES}) - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - set(CMAKE_SYSTEM_FRAMEWORK_PATH ${CMAKE_SYSTEM_FRAMEWORK_PATH}) - - set(OPENMW_RESOLVED_ITEMS \"\") - - function(gp_resolve_item_override context item exepath dirs resolved_item_var resolved_var) - if(item MATCHES \"@executable_path\" AND NOT \${\${resolved_var}}) - if (item MATCHES \"Frameworks\") # if it is a framework - # get last segment of path - get_filename_component(fname \"\${item}\" NAME_WE) - find_library(ri NAMES \${fname} PATHS \${exepath} \${dirs} /Library/Frameworks) - if (ri) - message(STATUS \"found \${ri} for \${item}\") - string(REGEX REPLACE \"^.*/Frameworks/.*\\\\.framework\" \"\" item_part \${item}) - set(ri \"\${ri}\${item_part}\") - set(\${resolved_item_var} \${ri} PARENT_SCOPE) - set(\${resolved_var} 1 PARENT_SCOPE) - set(OPENMW_RESOLVED_ITEMS \${_OPENMW_RESOLVED_ITEMS} \${ri}) + #install(FILES ${MISC_FILES} DESTINATION ../MacOS) + #install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Plugins" DESTINATION ..) + #install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Resources/resources" DESTINATION ../Resources) + install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION . COMPONENT Runtime) + set(CPACK_GENERATOR "DragNDrop") + # set(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/files/mac/Info.plist") + # set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw.icns") + # set(CPACK_BUNDLE_NAME "OpenMW") + set(CPACK_PACKAGE_VERSION ${OPENMW_VERSION}) + set(CPACK_PACKAGE_VERSION_MAJOR ${OPENMW_VERSION_MAJOR}) + set(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO}) + set(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE}) + + set(APPS "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_NAME}") + set(PLUGINS "") + + # Scan Plugins dir for *.dylibs + file(GLOB ALL_PLUGINS "${APP_BUNDLE_DIR}/Contents/Plugins/*.dylib") + + foreach(PLUGIN ${ALL_PLUGINS}) + get_filename_component(PLUGIN_FILENAME ${PLUGIN} NAME) + set(PLUGINS ${PLUGINS} "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_NAME}/Contents/Plugins/${PLUGIN_FILENAME}") + endforeach() + + #For now, search unresolved dependencies only in default system paths, so if you put unresolveable (i.e. with @executable_path in id name) lib or framework somewhere else, it would fail + set(DIRS "") + + # Overriding item resolving during installation, it needed if + # some library already has be "fixed up", i.e. its id name contains @executable_path, + # but library is not embedded in bundle. For example, it's Ogre.framework from Ogre SDK. + # Current implementation of GetPrerequsities/BundleUtilities doesn't handle that case. + # + # Current limitations: + # 1. Handles only frameworks, not simple libs + INSTALL(CODE " + set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_SYSTEM_FRAMEWORK_PATH ${CMAKE_SYSTEM_FRAMEWORK_PATH}) + + set(OPENMW_RESOLVED_ITEMS \"\") + + function(gp_resolve_item_override context item exepath dirs resolved_item_var resolved_var) + if(item MATCHES \"@executable_path\" AND NOT \${\${resolved_var}}) + if (item MATCHES \"Frameworks\") # if it is a framework + # get last segment of path + get_filename_component(fname \"\${item}\" NAME_WE) + find_library(ri NAMES \${fname} PATHS \${exepath} \${dirs} /Library/Frameworks) + if (ri) + message(STATUS \"found \${ri} for \${item}\") + string(REGEX REPLACE \"^.*/Frameworks/.*\\\\.framework\" \"\" item_part \${item}) + set(ri \"\${ri}\${item_part}\") + set(\${resolved_item_var} \${ri} PARENT_SCOPE) + set(\${resolved_var} 1 PARENT_SCOPE) + set(OPENMW_RESOLVED_ITEMS \${_OPENMW_RESOLVED_ITEMS} \${ri}) + endif() + else() + # code path for standard (non-framework) libs (ogre & qt pugins) endif() - else() - # code path for standard (non-framework) libs (ogre & qt pugins) endif() - endif() - endfunction(gp_resolve_item_override) - - cmake_policy(SET CMP0009 OLD) - set(BU_CHMOD_BUNDLE_ITEMS ON) - include(BundleUtilities) - fixup_bundle(\"${APPS}\" \"${PLUGINS}\" \"${DIRS}\") - " COMPONENT Runtime) + endfunction(gp_resolve_item_override) + + cmake_policy(SET CMP0009 OLD) + set(BU_CHMOD_BUNDLE_ITEMS ON) + include(BundleUtilities) + fixup_bundle(\"${APPS}\" \"${PLUGINS}\" \"${DIRS}\") + " COMPONENT Runtime) include(CPack) diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index 2fc3189fc..235bec6ab 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -49,6 +49,17 @@ QT4_WRAP_CPP(MOC_SRCS ${LAUNCHER_HEADER_MOC}) include(${QT_USE_FILE}) +# list here plugins that can't be detected statically, but loaded in runtime +# it needed for packaging automatisation +#set(USED_QT_PLUGINS imageformats/libqgif +# imageformats/libqico +# imageformats/libqjpeg +# imageformats/libqmng +# imageformats/libqsvg +# imageformats/libqtga +# imageformats/libqtiff) +# It seems that launcher works without this plugins, but it loads them into memory if they exists + # Main executable add_executable(omwlauncher ${LAUNCHER} @@ -73,6 +84,13 @@ if (APPLE) "${APP_BUNDLE_DIR}/../launcher.qss") configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss "${APP_BUNDLE_DIR}/../launcher.cfg") + + # copy used QT plugins into ${APP_BUNDLE_DIR}/Contents/Plugins + #foreach(PLUGIN ${USED_QT_PLUGINS}) + # get_filename_component(PLUGIN_FILENAME ${PLUGIN} NAME) + # configure_file("${QT_PLUGINS_DIR}/${PLUGIN}.dylib" "${APP_BUNDLE_DIR}/Contents/Plugins/${PLUGIN_FILENAME}.dylib" COPYONLY) + #endforeach() + else() configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.qss") From ee021548050d15219096dba07854f3f932c76603 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 4 Feb 2012 10:48:15 +0100 Subject: [PATCH 13/30] lights without a mesh were not rendered --- apps/openmw/mwclass/light.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 3890899b0..0009c575b 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -23,19 +23,19 @@ namespace MWClass assert (ref->base != NULL); const std::string &model = ref->base->model; - + + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); + if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertMesh(ptr, "meshes\\" + model); - const int color = ref->base->data.color; - const float r = ((color >> 0) & 0xFF) / 255.0f; - const float g = ((color >> 8) & 0xFF) / 255.0f; - const float b = ((color >> 16) & 0xFF) / 255.0f; - const float radius = float (ref->base->data.radius); - objects.insertLight (ptr, r, g, b, radius); - } + + const int color = ref->base->data.color; + const float r = ((color >> 0) & 0xFF) / 255.0f; + const float g = ((color >> 8) & 0xFF) / 255.0f; + const float b = ((color >> 16) & 0xFF) / 255.0f; + const float radius = float (ref->base->data.radius); + objects.insertLight (ptr, r, g, b, radius); } void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const @@ -43,13 +43,12 @@ namespace MWClass ESMS::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->base->model; assert (ref->base != NULL); + const std::string &model = ref->base->model; + if(!model.empty()){ physics.insertObjectPhysics(ptr, "meshes\\" + model); } - } void Light::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const From c471aa950f89bf674a49d7ea2f5a385643954eb5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 6 Feb 2012 09:42:24 +0100 Subject: [PATCH 14/30] re-enabled batching for statics; fixed a misplaced assert --- apps/openmw/mwclass/static.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index 946da311d..24d36dc1e 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -15,11 +15,11 @@ namespace MWClass assert (ref->base != NULL); const std::string &model = ref->base->model; - + if (!model.empty()) { MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); objects.insertMesh(ptr, "meshes\\" + model); } } @@ -29,13 +29,12 @@ namespace MWClass ESMS::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->base->model; assert (ref->base != NULL); + const std::string &model = ref->base->model; + if(!model.empty()){ physics.insertObjectPhysics(ptr, "meshes\\" + model); } - } std::string Static::getName (const MWWorld::Ptr& ptr) const From e1600d9a2a57b235c8b6b2851cd62fa96928e57d Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 6 Feb 2012 10:29:18 +0100 Subject: [PATCH 15/30] fixed movable object cleanup for ordinary objects --- apps/openmw/mwrender/objects.cpp | 19 ++++++++++++++++++- apps/openmw/mwrender/objects.hpp | 9 +++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index 1e3b4dda0..d04751ff3 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -23,6 +23,17 @@ bool Objects::lightOutQuadInLin = false; int Objects::uniqueID = 0; +void Objects::clearSceneNode (Ogre::SceneNode *node) +{ + /// \todo This should probably be moved into OpenEngine at some point. + for (int i=node->numAttachedObjects()-1; i>=0; --i) + { + Ogre::MovableObject *object = node->getAttachedObject (i); + node->detachObject (object); + mRend.getScene()->destroyMovableObject (object); + } +} + void Objects::setMwRoot(Ogre::SceneNode* root){ mMwRoot = root; } @@ -59,6 +70,7 @@ void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ // Rotates first around z, then y, then x insert->setOrientation(xr*yr*zr); + if (!enabled) insert->setVisible (false); ptr.getRefData().setBaseNode(insert); @@ -145,6 +157,7 @@ bool Objects::deleteObject (const MWWorld::Ptr& ptr) mCellSceneNodes.begin()); iter!=mCellSceneNodes.end(); ++iter) if (iter->second==parent) { + clearSceneNode (base); base->removeAndDestroyAllChildren(); mRend.getScene()->destroySceneNode (base); ptr.getRefData().setBaseNode (0); @@ -161,13 +174,16 @@ void Objects::removeCell(MWWorld::Ptr::CellStore* store){ if(mCellSceneNodes.find(store) != mCellSceneNodes.end()) { Ogre::SceneNode* base = mCellSceneNodes[store]; + + for (int i=0; inumChildren(); ++i) + clearSceneNode (static_cast (base->getChild (i))); + base->removeAndDestroyAllChildren(); mCellSceneNodes.erase(store); mRend.getScene()->destroySceneNode(base); base = 0; } - if(mSG.find(store) != mSG.end()) { Ogre::StaticGeometry* sg = mSG[store]; @@ -176,6 +192,7 @@ void Objects::removeCell(MWWorld::Ptr::CellStore* store){ sg = 0; } } + void Objects::buildStaticGeometry(ESMS::CellStore& cell){ if(mSG.find(&cell) != mSG.end()) { diff --git a/apps/openmw/mwrender/objects.hpp b/apps/openmw/mwrender/objects.hpp index 6cd465fdd..737f9acec 100644 --- a/apps/openmw/mwrender/objects.hpp +++ b/apps/openmw/mwrender/objects.hpp @@ -1,11 +1,12 @@ #ifndef _GAME_RENDER_OBJECTS_H #define _GAME_RENDER_OBJECTS_H -#include "components/esm_store/cell_store.hpp" +#include + +#include #include "../mwworld/refdata.hpp" #include "../mwworld/ptr.hpp" -#include namespace MWRender{ @@ -30,6 +31,10 @@ class Objects{ static float lightQuadraticRadiusMult; static bool lightOutQuadInLin; + + void clearSceneNode (Ogre::SceneNode *node); + ///< Remove all movable objects from \a node. + public: Objects(OEngine::Render::OgreRenderer& _rend): mRend(_rend){} ~Objects(){} From 784c6fe0ffc0e645c97485c1b4cce6aa2f4ff6b2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 6 Feb 2012 10:41:13 +0100 Subject: [PATCH 16/30] some cleanup --- apps/openmw/mwrender/objects.cpp | 121 ++++++++++++++++--------------- apps/openmw/mwrender/objects.hpp | 8 +- 2 files changed, 67 insertions(+), 62 deletions(-) diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index d04751ff3..4e2a3caab 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -1,11 +1,11 @@ #include "objects.hpp" + #include + #include -using namespace Ogre; using namespace MWRender; - bool Objects::lightConst = false; float Objects::lightConstValue = 0.0f; @@ -30,14 +30,17 @@ void Objects::clearSceneNode (Ogre::SceneNode *node) { Ogre::MovableObject *object = node->getAttachedObject (i); node->detachObject (object); - mRend.getScene()->destroyMovableObject (object); + mRenderer.getScene()->destroyMovableObject (object); } } -void Objects::setMwRoot(Ogre::SceneNode* root){ +void Objects::setMwRoot(Ogre::SceneNode* root) +{ mMwRoot = root; } -void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ + +void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_) +{ Ogre::SceneNode* root = mMwRoot; Ogre::SceneNode* cellnode; if(mCellSceneNodes.find(ptr.getCell()) == mCellSceneNodes.end()) @@ -60,91 +63,91 @@ void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ f = ptr.getCellRef().pos.rot; // Rotate around X axis - Quaternion xr(Radian(-f[0]), Vector3::UNIT_X); + Ogre::Quaternion xr(Ogre::Radian(-f[0]), Ogre::Vector3::UNIT_X); // Rotate around Y axis - Quaternion yr(Radian(-f[1]), Vector3::UNIT_Y); + Ogre::Quaternion yr(Ogre::Radian(-f[1]), Ogre::Vector3::UNIT_Y); // Rotate around Z axis - Quaternion zr(Radian(-f[2]), Vector3::UNIT_Z); + Ogre::Quaternion zr(Ogre::Radian(-f[2]), Ogre::Vector3::UNIT_Z); - // Rotates first around z, then y, then x + // Rotates first around z, then y, then x insert->setOrientation(xr*yr*zr); if (!enabled) insert->setVisible (false); ptr.getRefData().setBaseNode(insert); - isStatic = static_; - - + mIsStatic = static_; } -void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh){ + +void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh) +{ Ogre::SceneNode* insert = ptr.getRefData().getBaseNode(); assert(insert); NifOgre::NIFLoader::load(mesh); - Entity *ent = mRend.getScene()->createEntity(mesh); + Ogre::Entity *ent = mRenderer.getScene()->createEntity(mesh); - if(!isStatic) + if(!mIsStatic) { insert->attachObject(ent); } else { Ogre::StaticGeometry* sg = 0; - if(mSG.find(ptr.getCell()) == mSG.end()) + if(mStaticGeometry.find(ptr.getCell()) == mStaticGeometry.end()) { uniqueID = uniqueID +1; - sg = mRend.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID)); + sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID)); //Create the scenenode and put it in the map - mSG[ptr.getCell()] = sg; + mStaticGeometry[ptr.getCell()] = sg; } else { - sg = mSG[ptr.getCell()]; + sg = mStaticGeometry[ptr.getCell()]; } sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale()); sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000)); - - mRend.getScene()->destroyEntity(ent); + mRenderer.getScene()->destroyEntity(ent); } - - } -void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius){ - Ogre::SceneNode* insert = mRend.getScene()->getSceneNode(ptr.getRefData().getHandle()); + +void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius) +{ + Ogre::SceneNode* insert = mRenderer.getScene()->getSceneNode(ptr.getRefData().getHandle()); assert(insert); - Ogre::Light *light = mRend.getScene()->createLight(); + Ogre::Light *light = mRenderer.getScene()->createLight(); light->setDiffuseColour (r, g, b); float cval=0.0f, lval=0.0f, qval=0.0f; if(lightConst) cval = lightConstValue; - if(!lightOutQuadInLin) - { - if(lightLinear) - radius *= lightLinearRadiusMult; - if(lightQuadratic) - radius *= lightQuadraticRadiusMult; - - if(lightLinear) - lval = lightLinearValue / pow(radius, lightLinearMethod); - if(lightQuadratic) - qval = lightQuadraticValue / pow(radius, lightQuadraticMethod); - } - else - { - // FIXME: - // Do quadratic or linear, depending if we're in an exterior or interior - // cell, respectively. Ignore lightLinear and lightQuadratic. - } - - light->setAttenuation(10*radius, cval, lval, qval); - - insert->attachObject(light); + + if(!lightOutQuadInLin) + { + if(lightLinear) + radius *= lightLinearRadiusMult; + if(lightQuadratic) + radius *= lightQuadraticRadiusMult; + + if(lightLinear) + lval = lightLinearValue / pow(radius, lightLinearMethod); + if(lightQuadratic) + qval = lightQuadraticValue / pow(radius, lightQuadraticMethod); + } + else + { + // FIXME: + // Do quadratic or linear, depending if we're in an exterior or interior + // cell, respectively. Ignore lightLinear and lightQuadratic. + } + + light->setAttenuation(10*radius, cval, lval, qval); + + insert->attachObject(light); } bool Objects::deleteObject (const MWWorld::Ptr& ptr) @@ -159,7 +162,7 @@ bool Objects::deleteObject (const MWWorld::Ptr& ptr) { clearSceneNode (base); base->removeAndDestroyAllChildren(); - mRend.getScene()->destroySceneNode (base); + mRenderer.getScene()->destroySceneNode (base); ptr.getRefData().setBaseNode (0); return true; } @@ -170,7 +173,8 @@ bool Objects::deleteObject (const MWWorld::Ptr& ptr) return true; } -void Objects::removeCell(MWWorld::Ptr::CellStore* store){ +void Objects::removeCell(MWWorld::Ptr::CellStore* store) +{ if(mCellSceneNodes.find(store) != mCellSceneNodes.end()) { Ogre::SceneNode* base = mCellSceneNodes[store]; @@ -180,23 +184,24 @@ void Objects::removeCell(MWWorld::Ptr::CellStore* store){ base->removeAndDestroyAllChildren(); mCellSceneNodes.erase(store); - mRend.getScene()->destroySceneNode(base); + mRenderer.getScene()->destroySceneNode(base); base = 0; } - if(mSG.find(store) != mSG.end()) + if(mStaticGeometry.find(store) != mStaticGeometry.end()) { - Ogre::StaticGeometry* sg = mSG[store]; - mSG.erase(store); - mRend.getScene()->destroyStaticGeometry (sg); + Ogre::StaticGeometry* sg = mStaticGeometry[store]; + mStaticGeometry.erase(store); + mRenderer.getScene()->destroyStaticGeometry (sg); sg = 0; } } -void Objects::buildStaticGeometry(ESMS::CellStore& cell){ - if(mSG.find(&cell) != mSG.end()) +void Objects::buildStaticGeometry(ESMS::CellStore& cell) +{ + if(mStaticGeometry.find(&cell) != mStaticGeometry.end()) { - Ogre::StaticGeometry* sg = mSG[&cell]; + Ogre::StaticGeometry* sg = mStaticGeometry[&cell]; sg->build(); } } diff --git a/apps/openmw/mwrender/objects.hpp b/apps/openmw/mwrender/objects.hpp index 737f9acec..d58455b9f 100644 --- a/apps/openmw/mwrender/objects.hpp +++ b/apps/openmw/mwrender/objects.hpp @@ -11,11 +11,11 @@ namespace MWRender{ class Objects{ - OEngine::Render::OgreRenderer &mRend; + OEngine::Render::OgreRenderer &mRenderer; std::map mCellSceneNodes; - std::map mSG; + std::map mStaticGeometry; Ogre::SceneNode* mMwRoot; - bool isStatic; + bool mIsStatic; static int uniqueID; static bool lightConst; static float lightConstValue; @@ -36,7 +36,7 @@ class Objects{ ///< Remove all movable objects from \a node. public: - Objects(OEngine::Render::OgreRenderer& _rend): mRend(_rend){} + Objects(OEngine::Render::OgreRenderer& renderer): mRenderer (renderer){} ~Objects(){} void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_); void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh); From 597e670eef30025c1e49303dc5ed0afaf87a5304 Mon Sep 17 00:00:00 2001 From: gugus Date: Wed, 8 Feb 2012 00:32:22 +0100 Subject: [PATCH 17/30] corrected the light problem --- apps/openmw/mwrender/renderingmanager.cpp | 13 +++++++++---- apps/openmw/mwrender/renderingmanager.hpp | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index c5cf8be5d..bc33951e7 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -54,10 +54,12 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const cameraPitchNode->attachObject(mRendering.getCamera()); mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode); + mSun = 0; } RenderingManager::~RenderingManager () { + //TODO: destroy mSun? delete mPlayer; delete mSkyManager; } @@ -204,12 +206,15 @@ void RenderingManager::configureAmbient(ESMS::CellStore &mCell // Create a "sun" that shines light downwards. It doesn't look // completely right, but leave it for now. - Ogre::Light *light = mRendering.getScene()->createLight(); + if(!mSun) + { + mSun = mRendering.getScene()->createLight(); + } Ogre::ColourValue colour; colour.setAsABGR (mCell.cell->ambi.sunlight); - light->setDiffuseColour (colour); - light->setType(Ogre::Light::LT_DIRECTIONAL); - light->setDirection(0,-1,0); + mSun->setDiffuseColour (colour); + mSun->setType(Ogre::Light::LT_DIRECTIONAL); + mSun->setDirection(0,-1,0); } // Switch through lighting modes. diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 084f89cb0..ca5d95a3f 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -118,6 +118,7 @@ class RenderingManager: private RenderingInterface { int mAmbientMode; Ogre::ColourValue mAmbientColor; + Ogre::Light* mSun; /// Root node for all objects added to the scene. This is rotated so /// that the OGRE coordinate system matches that used internally in From 4fcb72105424a81a3ffb33f80be9d667b05d1576 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 10 Feb 2012 14:59:22 +0100 Subject: [PATCH 18/30] openengine update (physics crash workaround --- libs/openengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openengine b/libs/openengine index 6c7e5d00e..4a188f282 160000 --- a/libs/openengine +++ b/libs/openengine @@ -1 +1 @@ -Subproject commit 6c7e5d00e4f5bf954afe15f10e56f03520abfee4 +Subproject commit 4a188f2820c037ca4ad8ef35492d3857ea8d7df8 From 17b1546dc1694b5419287c7b7d8c5e86a39e83e3 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Fri, 10 Feb 2012 19:17:49 +0100 Subject: [PATCH 19/30] Changed the way screenshots are created (Bug #191) --- apps/openmw/engine.cpp | 22 ++++++++++++++++++++++ apps/openmw/engine.hpp | 3 +++ apps/openmw/mwinput/inputmanager.cpp | 15 +-------------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index ee3a6181a..3579977b0 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -462,6 +462,28 @@ void OMW::Engine::activate() } } +void OMW::Engine::screenshot() +{ + // Count screenshots. + int shotCount = 0; + + const std::string screenshotPath = mCfgMgr.getLocalConfigPath().string(); + + // Find the first unused filename with a do-while + std::ostringstream stream; + do + { + // Reset the stream + stream.str(""); + stream.clear(); + + stream << screenshotPath << "screenshot" << std::setw(3) << std::setfill('0') << shotCount++ << ".png"; + + } while (boost::filesystem::exists(stream.str())); + + mOgre->screenshot(stream.str()); +} + void OMW::Engine::setCompileAll (bool all) { mCompileAll = all; diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 02d108f0a..88eea728e 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -152,6 +152,9 @@ namespace OMW /// Activate the focussed object. void activate(); + /// Write screenshot to file. + void screenshot(); + /// Compile all scripts (excludign dialogue scripts) at startup? void setCompileAll (bool all); diff --git a/apps/openmw/mwinput/inputmanager.cpp b/apps/openmw/mwinput/inputmanager.cpp index e0c819a71..a5d590b85 100644 --- a/apps/openmw/mwinput/inputmanager.cpp +++ b/apps/openmw/mwinput/inputmanager.cpp @@ -83,27 +83,14 @@ namespace MWInput MWGui::WindowManager &windows; OMW::Engine& mEngine; - // Count screenshots. - int shotCount; - /* InputImpl Methods */ - // Write screenshot to file. void screenshot() { - - // Find the first unused filename with a do-while - char buf[50]; - do - { - snprintf(buf, 50, "screenshot%03d.png", shotCount++); - } while (boost::filesystem::exists(buf)); - - ogre.screenshot(buf); + mEngine.screenshot(); } - /* toggleInventory() is called when the user presses the button to toggle the inventory screen. */ void toggleInventory() { From bc71fb47e018d2c23ce77483d9da646c43bcb7d0 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 10 Feb 2012 21:24:33 +0100 Subject: [PATCH 20/30] minor fix --- apps/openmw/mwinput/inputmanager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/openmw/mwinput/inputmanager.cpp b/apps/openmw/mwinput/inputmanager.cpp index a5d590b85..88534ddda 100644 --- a/apps/openmw/mwinput/inputmanager.cpp +++ b/apps/openmw/mwinput/inputmanager.cpp @@ -170,8 +170,7 @@ namespace MWInput poller(input), player(_player), windows(_windows), - mEngine (engine), - shotCount(0) + mEngine (engine) { using namespace OEngine::Input; using namespace OEngine::Render; From a0ac6e51502368792ee8ddfa3b650dd7366b3760 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 12 Feb 2012 12:35:29 +0100 Subject: [PATCH 21/30] cells were sometimes not fully loaded --- apps/openmw/mwworld/cells.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index 143ce557b..079c888aa 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -63,9 +63,10 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y) result = mExteriors.insert (std::make_pair ( std::make_pair (x, y), Ptr::CellStore (cell))).first; + } + if (result->second.mState!=Ptr::CellStore::State_Loaded) result->second.load (mStore, mReader); - } return &result->second; } @@ -79,9 +80,10 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getInterior (const std::string& name) const ESM::Cell *cell = mStore.cells.findInt (name); result = mInteriors.insert (std::make_pair (name, Ptr::CellStore (cell))).first; + } + if (result->second.mState!=Ptr::CellStore::State_Loaded) result->second.load (mStore, mReader); - } return &result->second; } From 8829d46bda4f09e365cd97b842abdfe4ef571286 Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Sun, 12 Feb 2012 15:45:08 +0100 Subject: [PATCH 22/30] Clean up compilation warnings. Clan up compilation warnings like "variable ... set but not used" introduced in some older and recent commits. Signed-off-by: Lukasz Gromanowski --- apps/esmtool/esmtool_cmd.c | 18 +++++++++--------- apps/openmw/mwgui/journalwindow.cpp | 4 ++-- apps/openmw/mwrender/animation.cpp | 2 +- apps/openmw/mwrender/npcanimation.cpp | 2 +- components/nif/data.hpp | 4 ++-- components/nifogre/ogre_nif_loader.cpp | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/esmtool/esmtool_cmd.c b/apps/esmtool/esmtool_cmd.c index d6556d9e7..3fce77de2 100644 --- a/apps/esmtool/esmtool_cmd.c +++ b/apps/esmtool/esmtool_cmd.c @@ -926,13 +926,13 @@ int update_arg(void *field, char **orig_field, const char *long_opt, char short_opt, const char *additional_error) { - char *stop_char = 0; - const char *val = value; - int found; + //char *stop_char = 0; + //const char *val = value; + //int found; FIX_UNUSED (field); - stop_char = 0; - found = 0; + //stop_char = 0; + //found = 0; if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) { @@ -955,8 +955,8 @@ int update_arg(void *field, char **orig_field, (*prev_given)++; if (field_given) (*field_given)++; - if (possible_values) - val = possible_values[found]; + //if (possible_values) + //val = possible_values[found]; switch(arg_type) { default: @@ -996,7 +996,7 @@ cmdline_parser_internal ( int override; int initialize; - int check_required; + //int check_required; int check_ambiguity; char *optarg; @@ -1008,7 +1008,7 @@ cmdline_parser_internal ( override = params->override; initialize = params->initialize; - check_required = params->check_required; + //check_required = params->check_required; check_ambiguity = params->check_ambiguity; if (initialize) diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 457a07582..3f3c89f39 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -32,8 +32,8 @@ book formatText(std::string text,book mBook,int maxLine, int lineSize) mBook.pages.pop_back(); } - std::string::iterator wordBegin = text.begin(); - std::string::iterator wordEnd; + //std::string::iterator wordBegin = text.begin(); + //std::string::iterator wordEnd; std::string cText = text; diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 5a9731d2d..056550e74 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -499,7 +499,7 @@ namespace MWRender{ std::vector quats = iter->getQuat(); std::vector ttime = iter->gettTime(); - std::vector::iterator ttimeiter = ttime.begin(); + //std::vector::iterator ttimeiter = ttime.begin(); std::vector rtime = iter->getrTime(); int rindexJ = 0; diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 863f7577b..fe48aa321 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -267,7 +267,7 @@ void NpcAnimation::runAnimation(float timepassed){ } handleAnimationTransforms(); - Ogre::Vector3 current = insert->_getWorldAABB().getCenter(); + //Ogre::Vector3 current = insert->_getWorldAABB().getCenter(); std::vector*>::iterator shapepartsiter = shapeparts.begin(); std::vector::iterator entitypartsiter = entityparts.begin(); diff --git a/components/nif/data.hpp b/components/nif/data.hpp index 9e28e1534..df9079758 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -473,7 +473,7 @@ void read(NIFFile *nif) int vertCount = nif->getInt(); nif->getByte(); int magic = nif->getInt(); - int type = nif->getInt(); + /*int type =*/ nif->getInt(); for(int i = 0; i < vertCount; i++){ float x = nif->getFloat(); @@ -485,7 +485,7 @@ void read(NIFFile *nif) for(int i=1; igetInt(); - type = nif->getInt(); + /*type =*/ nif->getInt(); std::vector current; std::vector currentTime; for(int i = 0; i < magic; i++){ diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index c62f59ea3..2662f0c97 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -1150,7 +1150,7 @@ void NIFLoader::loadResource(Resource *resource) char suffix = name.at(name.length() - 2); bool addAnim = true; bool hasAnim = false; - bool baddin = false; + //bool baddin = false; bNiTri = true; if(suffix == '*') @@ -1168,7 +1168,7 @@ void NIFLoader::loadResource(Resource *resource) } else if(suffix == '>') { - baddin = true; + //baddin = true; bNiTri = true; std::string sub = name.substr(name.length() - 6, 4); From 5a42c6c6f59242f447a30c3ef9c4721db21f54cd Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Mon, 13 Feb 2012 10:31:43 +0400 Subject: [PATCH 23/30] Feature #162 - Need to create app bundle using CMake, not by hand WIP. Removed libpng dependency from launcher --- CMakeLists.txt | 15 +++++++++------ apps/launcher/CMakeLists.txt | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 50ed5e1c1..ef31dae07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -382,14 +382,17 @@ endif() # Apple bundling if (APPLE) - set(MISC_FILES - ${APP_BUNDLE_DIR}/Contents/MacOS/openmw.cfg - ${APP_BUNDLE_DIR}/Contents/MacOS/plugins.cfg) + set(INSTALL_SUBDIR OpenMW) #install(FILES ${MISC_FILES} DESTINATION ../MacOS) #install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Plugins" DESTINATION ..) #install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Resources/resources" DESTINATION ../Resources) - install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION . COMPONENT Runtime) + install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) + install(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) + install(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" RENAME "openmw.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) + + install(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) + install(FILES "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) set(CPACK_GENERATOR "DragNDrop") # set(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/files/mac/Info.plist") # set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw.icns") @@ -399,7 +402,7 @@ if (APPLE) set(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO}) set(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE}) - set(APPS "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_NAME}") + set(APPS "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}") set(PLUGINS "") # Scan Plugins dir for *.dylibs @@ -407,7 +410,7 @@ if (APPLE) foreach(PLUGIN ${ALL_PLUGINS}) get_filename_component(PLUGIN_FILENAME ${PLUGIN} NAME) - set(PLUGINS ${PLUGINS} "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_NAME}/Contents/Plugins/${PLUGIN_FILENAME}") + set(PLUGINS ${PLUGINS} "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Plugins/${PLUGIN_FILENAME}") endforeach() #For now, search unresolved dependencies only in default system paths, so if you put unresolveable (i.e. with @executable_path in id name) lib or framework somewhere else, it would fail diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index 235bec6ab..e46a06205 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -41,8 +41,8 @@ source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER} ${LAUNCHER_HEADER_MOC find_package(Qt4 REQUIRED) set(QT_USE_QTGUI 1) -find_package(PNG REQUIRED) -include_directories(${PNG_INCLUDE_DIR}) +#find_package(PNG REQUIRED) +#include_directories(${PNG_INCLUDE_DIR}) QT4_ADD_RESOURCES(RCC_SRCS resources.qrc) QT4_WRAP_CPP(MOC_SRCS ${LAUNCHER_HEADER_MOC}) @@ -71,7 +71,7 @@ target_link_libraries(omwlauncher ${Boost_LIBRARIES} ${OGRE_LIBRARIES} ${QT_LIBRARIES} - ${PNG_LIBRARY} +# ${PNG_LIBRARY} components ) From 6a71cf21b0faf400db173b8dea3983f3e265fca2 Mon Sep 17 00:00:00 2001 From: "Alexander \"Ace\" Olofsson" Date: Thu, 16 Feb 2012 08:52:26 +0100 Subject: [PATCH 24/30] Added OpenAL redistributable to OpenMW installer --- CMakeLists.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d556ae147..9c702be2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -348,10 +348,18 @@ if(WIN32) SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.openmw.org") SET(CPACK_NSIS_INSTALLED_ICON_NAME "omwlauncher.exe") - if(EXISTS "${OpenMW_BINARY_DIR}/vcredist_x86.exe") - INSTALL(FILES "${OpenMW_BINARY_DIR}/vcredist_x86.exe" DESTINATION "redist") + SET(VCREDIST "${OpenMW_BINARY_DIR}/vcredist_x86.exe") + if(EXISTS ${VCREDIST}) + INSTALL(FILES ${VCREDIST} DESTINATION "redist") SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "ExecWait '\\\"$INSTDIR\\\\redist\\\\vcredist_x86.exe\\\" /q'" ) - endif(EXISTS "${OpenMW_BINARY_DIR}/vcredist_x86.exe") + endif(EXISTS ${VCREDIST}) + + SET(OALREDIST "${OpenMW_BINARY_DIR}/oalinst.exe") + if(EXISTS ${OALREDIST}) + INSTALL(FILES ${OALREDIST} DESTINATION "redist") + SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS} + ExecWait '\\\"$INSTDIR\\\\redist\\\\oalinst.exe\\\" /s'" ) + endif(EXISTS ${OALREDIST}) include(CPack) endif(WIN32) From 2217847c5753be314a51b1b9263ecc7bdffbec76 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 18 Feb 2012 15:29:40 -0500 Subject: [PATCH 25/30] Fixing a crash --- components/nifogre/ogre_nif_loader.cpp | 23 +++++++++++++++++++++-- components/nifogre/ogre_nif_loader.hpp | 4 +++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 4e3864a67..2ac05f2c8 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -531,6 +531,8 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std { sub->addBoneAssignment(*it); } + if(mSkel.isNull()) + needBoneAssignments.push_back(sub); } // Helper math functions. Reinventing linear algebra for the win! @@ -945,7 +947,8 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou { // Add this vertex set to the bounding box bounds.add(optr, numVerts); - shapes.push_back(copy); + if(addShapes) + shapes.push_back(copy); // Create the submesh createOgreSubMesh(shape, material, vertexBoneAssignments); @@ -1066,9 +1069,11 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, //FIXME: "Bip01" isn't every time the root bone if (node->name == "Bip01" || node->name == "Root Bone") //root node, create a skeleton { - + addShapes = true; mSkel = SkeletonManager::getSingleton().create(getSkeletonName(), resourceGroup, true); } + else if (!mSkel.isNull() && !parentBone) + addShapes = false; if (!mSkel.isNull()) //if there is a skeleton { @@ -1143,8 +1148,11 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, void NIFLoader::loadResource(Resource *resource) { + addShapes = false; allanim.clear(); shapes.clear(); + needBoneAssignments.clear(); + // needBoneAssignments.clear(); mBoundingBox.setNull(); mesh = 0; mSkel.setNull(); @@ -1311,6 +1319,17 @@ void NIFLoader::loadResource(Resource *resource) if (!mSkel.isNull() ) { + for(std::vector::iterator iter = needBoneAssignments.begin(); iter != needBoneAssignments.end(); iter++) + { + int boneIndex = mSkel->getNumBones() - 1; + VertexBoneAssignment vba; + vba.boneIndex = boneIndex; + vba.vertexIndex = 0; + vba.weight = 1; + + + (*iter)->addBoneAssignment(vba); + } mesh->_notifySkeleton(mSkel); } } diff --git a/components/nifogre/ogre_nif_loader.hpp b/components/nifogre/ogre_nif_loader.hpp index b1e0943f5..1361ffaca 100644 --- a/components/nifogre/ogre_nif_loader.hpp +++ b/components/nifogre/ogre_nif_loader.hpp @@ -121,7 +121,7 @@ class NIFLoader : Ogre::ManualResourceLoader private: NIFLoader() : mNormaliseNormals(false), resourceGroup("General"), resourceName(""), flip(false), - mFlipVertexWinding(false), mOutputAnimFiles(false) {} + mFlipVertexWinding(false), mOutputAnimFiles(false), addShapes(false) {} NIFLoader(NIFLoader& n) {} void calculateTransform(); @@ -189,6 +189,8 @@ class NIFLoader : Ogre::ManualResourceLoader std::map,ciLessBoost> allshapesmap; std::vector mAnim; std::vector mS; + std::vector needBoneAssignments; + bool addShapes; }; From e58f2f5363ec8f6f6b3c960335bdc8544f958b8a Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sun, 19 Feb 2012 02:01:15 -0500 Subject: [PATCH 26/30] Eliminating unnecessary data from skeletons and shape saving --- apps/openmw/class2/activator.cpp | 66 ++++++ apps/openmw/class2/activator.hpp | 28 +++ apps/openmw/class2/apparatus.cpp | 81 ++++++++ apps/openmw/class2/apparatus.hpp | 37 ++++ apps/openmw/class2/armor.cpp | 93 +++++++++ apps/openmw/class2/armor.hpp | 43 ++++ apps/openmw/class2/book.cpp | 83 ++++++++ apps/openmw/class2/book.hpp | 37 ++++ apps/openmw/class2/classes.cpp | 50 +++++ apps/openmw/class2/classes.hpp | 10 + apps/openmw/class2/clothing.cpp | 81 ++++++++ apps/openmw/class2/clothing.hpp | 37 ++++ apps/openmw/class2/container.cpp | 80 +++++++ apps/openmw/class2/container.hpp | 33 +++ apps/openmw/class2/containerutil.hpp | 28 +++ apps/openmw/class2/creature.cpp | 138 +++++++++++++ apps/openmw/class2/creature.hpp | 51 +++++ apps/openmw/class2/creaturelevlist.cpp | 19 ++ apps/openmw/class2/creaturelevlist.hpp | 20 ++ apps/openmw/class2/door.cpp | 129 ++++++++++++ apps/openmw/class2/door.hpp | 39 ++++ apps/openmw/class2/ingredient.cpp | 82 ++++++++ apps/openmw/class2/ingredient.hpp | 37 ++++ apps/openmw/class2/itemlevlist.cpp | 19 ++ apps/openmw/class2/itemlevlist.hpp | 20 ++ apps/openmw/class2/light.cpp | 110 ++++++++++ apps/openmw/class2/light.hpp | 42 ++++ apps/openmw/class2/lockpick.cpp | 81 ++++++++ apps/openmw/class2/lockpick.hpp | 37 ++++ apps/openmw/class2/misc.cpp | 80 +++++++ apps/openmw/class2/misc.hpp | 37 ++++ apps/openmw/class2/npc.cpp | 276 +++++++++++++++++++++++++ apps/openmw/class2/npc.hpp | 72 +++++++ apps/openmw/class2/potion.cpp | 81 ++++++++ apps/openmw/class2/potion.hpp | 37 ++++ apps/openmw/class2/probe.cpp | 81 ++++++++ apps/openmw/class2/probe.hpp | 37 ++++ apps/openmw/class2/repair.cpp | 80 +++++++ apps/openmw/class2/repair.hpp | 37 ++++ apps/openmw/class2/static.cpp | 52 +++++ apps/openmw/class2/static.hpp | 26 +++ apps/openmw/class2/weapon.cpp | 94 +++++++++ apps/openmw/class2/weapon.hpp | 43 ++++ apps/openmw/mwrender/animation.cpp | 7 +- components/nifogre/ogre_nif_loader.cpp | 19 +- components/nifogre/ogre_nif_loader.hpp | 4 +- 46 files changed, 2661 insertions(+), 13 deletions(-) create mode 100644 apps/openmw/class2/activator.cpp create mode 100644 apps/openmw/class2/activator.hpp create mode 100644 apps/openmw/class2/apparatus.cpp create mode 100644 apps/openmw/class2/apparatus.hpp create mode 100644 apps/openmw/class2/armor.cpp create mode 100644 apps/openmw/class2/armor.hpp create mode 100644 apps/openmw/class2/book.cpp create mode 100644 apps/openmw/class2/book.hpp create mode 100644 apps/openmw/class2/classes.cpp create mode 100644 apps/openmw/class2/classes.hpp create mode 100644 apps/openmw/class2/clothing.cpp create mode 100644 apps/openmw/class2/clothing.hpp create mode 100644 apps/openmw/class2/container.cpp create mode 100644 apps/openmw/class2/container.hpp create mode 100644 apps/openmw/class2/containerutil.hpp create mode 100644 apps/openmw/class2/creature.cpp create mode 100644 apps/openmw/class2/creature.hpp create mode 100644 apps/openmw/class2/creaturelevlist.cpp create mode 100644 apps/openmw/class2/creaturelevlist.hpp create mode 100644 apps/openmw/class2/door.cpp create mode 100644 apps/openmw/class2/door.hpp create mode 100644 apps/openmw/class2/ingredient.cpp create mode 100644 apps/openmw/class2/ingredient.hpp create mode 100644 apps/openmw/class2/itemlevlist.cpp create mode 100644 apps/openmw/class2/itemlevlist.hpp create mode 100644 apps/openmw/class2/light.cpp create mode 100644 apps/openmw/class2/light.hpp create mode 100644 apps/openmw/class2/lockpick.cpp create mode 100644 apps/openmw/class2/lockpick.hpp create mode 100644 apps/openmw/class2/misc.cpp create mode 100644 apps/openmw/class2/misc.hpp create mode 100644 apps/openmw/class2/npc.cpp create mode 100644 apps/openmw/class2/npc.hpp create mode 100644 apps/openmw/class2/potion.cpp create mode 100644 apps/openmw/class2/potion.hpp create mode 100644 apps/openmw/class2/probe.cpp create mode 100644 apps/openmw/class2/probe.hpp create mode 100644 apps/openmw/class2/repair.cpp create mode 100644 apps/openmw/class2/repair.hpp create mode 100644 apps/openmw/class2/static.cpp create mode 100644 apps/openmw/class2/static.hpp create mode 100644 apps/openmw/class2/weapon.cpp create mode 100644 apps/openmw/class2/weapon.hpp diff --git a/apps/openmw/class2/activator.cpp b/apps/openmw/class2/activator.cpp new file mode 100644 index 000000000..086cb433d --- /dev/null +++ b/apps/openmw/class2/activator.cpp @@ -0,0 +1,66 @@ + +#include "activator.hpp" +#include "../mwrender/objects.hpp" + +#include + +#include + +#include "../mwworld/ptr.hpp" + + +namespace MWClass +{ + void Activator::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); + objects.insertMesh(ptr, "meshes\\" + model); + } + } + + void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + std::string Activator::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->name; + } + + std::string Activator::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Activator::registerSelf() + { + boost::shared_ptr instance (new Activator); + + registerClass (typeid (ESM::Activator).name(), instance); + } +} diff --git a/apps/openmw/class2/activator.hpp b/apps/openmw/class2/activator.hpp new file mode 100644 index 000000000..08be8a5ff --- /dev/null +++ b/apps/openmw/class2/activator.hpp @@ -0,0 +1,28 @@ +#ifndef GAME_MWCLASS_ACTIVATOR_H +#define GAME_MWCLASS_ACTIVATOR_H + +#include "../mwworld/class.hpp" + +namespace MWClass +{ + class Activator : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/apparatus.cpp b/apps/openmw/class2/apparatus.cpp new file mode 100644 index 000000000..4c5ba0721 --- /dev/null +++ b/apps/openmw/class2/apparatus.cpp @@ -0,0 +1,81 @@ + +#include "apparatus.hpp" + +#include + +#include + +#include "../mwworld/ptr.hpp" +#include "../mwworld/actiontake.hpp" + + +#include "containerutil.hpp" + +namespace MWClass +{ + void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); + objects.insertMesh(ptr, "meshes\\" + model); + } + } + + void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + std::string Apparatus::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->name; + } + + boost::shared_ptr Apparatus::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + return boost::shared_ptr ( + new MWWorld::ActionTake (ptr)); + } + + void Apparatus::insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const + { + insertIntoContainerStore (ptr, containerStore.appas); + } + + std::string Apparatus::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Apparatus::registerSelf() + { + boost::shared_ptr instance (new Apparatus); + + registerClass (typeid (ESM::Apparatus).name(), instance); + } +} diff --git a/apps/openmw/class2/apparatus.hpp b/apps/openmw/class2/apparatus.hpp new file mode 100644 index 000000000..4c8a2c0e2 --- /dev/null +++ b/apps/openmw/class2/apparatus.hpp @@ -0,0 +1,37 @@ +#ifndef GAME_MWCLASS_APPARATUS_H +#define GAME_MWCLASS_APPARATUS_H + +#include "../mwworld/class.hpp" +#include "../mwrender/objects.hpp" + +namespace MWClass +{ + class Apparatus : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + + virtual void insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const; + ///< Insert into a containe + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/armor.cpp b/apps/openmw/class2/armor.cpp new file mode 100644 index 000000000..2ad1dbfa2 --- /dev/null +++ b/apps/openmw/class2/armor.cpp @@ -0,0 +1,93 @@ + +#include "armor.hpp" + +#include + +#include + +#include "../mwworld/ptr.hpp" +#include "../mwworld/actiontake.hpp" + + +#include "containerutil.hpp" + +namespace MWClass +{ + void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); + objects.insertMesh(ptr, "meshes\\" + model); + } + } + + void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + std::string Armor::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->name; + } + + boost::shared_ptr Armor::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + return boost::shared_ptr ( + new MWWorld::ActionTake (ptr)); + } + + bool Armor::hasItemHealth (const MWWorld::Ptr& ptr) const + { + return true; + } + + int Armor::getItemMaxHealth (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->data.health; + } + + void Armor::insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const + { + insertIntoContainerStore (ptr, containerStore.armors); + } + + std::string Armor::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Armor::registerSelf() + { + boost::shared_ptr instance (new Armor); + + registerClass (typeid (ESM::Armor).name(), instance); + } +} diff --git a/apps/openmw/class2/armor.hpp b/apps/openmw/class2/armor.hpp new file mode 100644 index 000000000..c5f9812b7 --- /dev/null +++ b/apps/openmw/class2/armor.hpp @@ -0,0 +1,43 @@ +#ifndef GAME_MWCLASS_ARMOR_H +#define GAME_MWCLASS_ARMOR_H + +#include "../mwworld/class.hpp" +#include "../mwrender/objects.hpp" + +namespace MWClass +{ + class Armor : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + + virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const; + ///< \return Item health data available? + + virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const; + ///< Return item max health or throw an exception, if class does not have item health + + virtual void insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const; + ///< Insert into a containe + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/book.cpp b/apps/openmw/class2/book.cpp new file mode 100644 index 000000000..5c0d8767a --- /dev/null +++ b/apps/openmw/class2/book.cpp @@ -0,0 +1,83 @@ + +#include "book.hpp" + +#include + +#include + +#include "../mwworld/ptr.hpp" +#include "../mwworld/actiontake.hpp" + + +#include "containerutil.hpp" + +namespace MWClass +{ + void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); + objects.insertMesh(ptr, "meshes\\" + model); + } + } + + void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + std::string Book::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->name; + } + + boost::shared_ptr Book::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + // TODO implement reading + + return boost::shared_ptr ( + new MWWorld::ActionTake (ptr)); + } + + void Book::insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const + { + insertIntoContainerStore (ptr, containerStore.books); + } + + std::string Book::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Book::registerSelf() + { + boost::shared_ptr instance (new Book); + + registerClass (typeid (ESM::Book).name(), instance); + } +} diff --git a/apps/openmw/class2/book.hpp b/apps/openmw/class2/book.hpp new file mode 100644 index 000000000..f0e38cceb --- /dev/null +++ b/apps/openmw/class2/book.hpp @@ -0,0 +1,37 @@ +#ifndef GAME_MWCLASS_BOOK_H +#define GAME_MWCLASS_BOOK_H + +#include "../mwworld/class.hpp" +#include "../mwrender/objects.hpp" + +namespace MWClass +{ + class Book : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + + virtual void insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const; + ///< Insert into a containe + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/classes.cpp b/apps/openmw/class2/classes.cpp new file mode 100644 index 000000000..e9538a6cb --- /dev/null +++ b/apps/openmw/class2/classes.cpp @@ -0,0 +1,50 @@ + +#include "classes.hpp" + +#include "activator.hpp" +#include "creature.hpp" +#include "npc.hpp" +#include "weapon.hpp" +#include "armor.hpp" +#include "potion.hpp" +#include "apparatus.hpp" +#include "book.hpp" +#include "clothing.hpp" +#include "container.hpp" +#include "door.hpp" +#include "ingredient.hpp" +#include "creaturelevlist.hpp" +#include "itemlevlist.hpp" +#include "light.hpp" +#include "lockpick.hpp" +#include "misc.hpp" +#include "probe.hpp" +#include "repair.hpp" +#include "static.hpp" + +namespace MWClass +{ + void registerClasses() + { + Activator::registerSelf(); + Creature::registerSelf(); + Npc::registerSelf(); + Weapon::registerSelf(); + Armor::registerSelf(); + Potion::registerSelf(); + Apparatus::registerSelf(); + Book::registerSelf(); + Clothing::registerSelf(); + Container::registerSelf(); + Door::registerSelf(); + Ingredient::registerSelf(); + CreatureLevList::registerSelf(); + ItemLevList::registerSelf(); + Light::registerSelf(); + Lockpick::registerSelf(); + Miscellaneous::registerSelf(); + Probe::registerSelf(); + Repair::registerSelf(); + Static::registerSelf(); + } +} diff --git a/apps/openmw/class2/classes.hpp b/apps/openmw/class2/classes.hpp new file mode 100644 index 000000000..0ab90b677 --- /dev/null +++ b/apps/openmw/class2/classes.hpp @@ -0,0 +1,10 @@ +#ifndef GAME_MWCLASS_CLASSES_H +#define GAME_MWCLASS_CLASSES_H + +namespace MWClass +{ + void registerClasses(); + ///< register all known classes +} + +#endif diff --git a/apps/openmw/class2/clothing.cpp b/apps/openmw/class2/clothing.cpp new file mode 100644 index 000000000..b81a181f4 --- /dev/null +++ b/apps/openmw/class2/clothing.cpp @@ -0,0 +1,81 @@ + +#include "clothing.hpp" + +#include + +#include + +#include "../mwworld/ptr.hpp" +#include "../mwworld/actiontake.hpp" + + +#include "containerutil.hpp" + +namespace MWClass +{ + void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); + objects.insertMesh(ptr, "meshes\\" + model); + } + } + + void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + std::string Clothing::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->name; + } + + boost::shared_ptr Clothing::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + return boost::shared_ptr ( + new MWWorld::ActionTake (ptr)); + } + + void Clothing::insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const + { + insertIntoContainerStore (ptr, containerStore.clothes); + } + + std::string Clothing::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Clothing::registerSelf() + { + boost::shared_ptr instance (new Clothing); + + registerClass (typeid (ESM::Clothing).name(), instance); + } +} diff --git a/apps/openmw/class2/clothing.hpp b/apps/openmw/class2/clothing.hpp new file mode 100644 index 000000000..76c2c4a3e --- /dev/null +++ b/apps/openmw/class2/clothing.hpp @@ -0,0 +1,37 @@ +#ifndef GAME_MWCLASS_CLOTHING_H +#define GAME_MWCLASS_CLOTHING_H + +#include "../mwworld/class.hpp" +#include "../mwrender/objects.hpp" + +namespace MWClass +{ + class Clothing : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + + virtual void insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const; + ///< Insert into a containe + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/container.cpp b/apps/openmw/class2/container.cpp new file mode 100644 index 000000000..fff3a9bda --- /dev/null +++ b/apps/openmw/class2/container.cpp @@ -0,0 +1,80 @@ + +#include "container.hpp" + +#include + +#include + +#include "../mwworld/ptr.hpp" + +namespace MWClass +{ + void Container::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); + objects.insertMesh(ptr, "meshes\\" + model); + } + } + + void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + std::string Container::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->name; + } + + MWWorld::ContainerStore& Container::getContainerStore (const MWWorld::Ptr& ptr) + const + { + if (!ptr.getRefData().getContainerStore().get()) + { + boost::shared_ptr > store ( + new MWWorld::ContainerStore); + + // TODO add initial content + + ptr.getRefData().getContainerStore() = store; + } + + return *ptr.getRefData().getContainerStore(); + } + + std::string Container::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Container::registerSelf() + { + boost::shared_ptr instance (new Container); + + registerClass (typeid (ESM::Container).name(), instance); + } +} diff --git a/apps/openmw/class2/container.hpp b/apps/openmw/class2/container.hpp new file mode 100644 index 000000000..01763870a --- /dev/null +++ b/apps/openmw/class2/container.hpp @@ -0,0 +1,33 @@ +#ifndef GAME_MWCLASS_CONTAINER_H +#define GAME_MWCLASS_CONTAINER_H + +#include "../mwworld/class.hpp" +#include "../mwrender/objects.hpp" + +namespace MWClass +{ + class Container : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual MWWorld::ContainerStore& getContainerStore ( + const MWWorld::Ptr& ptr) const; + ///< Return container store + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/containerutil.hpp b/apps/openmw/class2/containerutil.hpp new file mode 100644 index 000000000..76bdf0236 --- /dev/null +++ b/apps/openmw/class2/containerutil.hpp @@ -0,0 +1,28 @@ +#ifndef GAME_MWCLASS_CONTAINERUTIL_H +#define GAME_MWCLASS_CONTAINERUTIL_H + +#include + +#include "../mwworld/ptr.hpp" +#include "../mwworld/containerstore.hpp" + +namespace MWClass +{ + template + void insertIntoContainerStore (const MWWorld::Ptr& ptr, + ESMS::CellRefList& containerStore) + { + if (!ptr.isEmpty()) + { + // TODO check stacking + + ESMS::LiveCellRef cellRef(ptr.getCellRef(), ptr.get()->base); + cellRef.mData = ptr.getRefData(); + + containerStore.list.push_back (cellRef); + + } + } +} + +#endif diff --git a/apps/openmw/class2/creature.cpp b/apps/openmw/class2/creature.cpp new file mode 100644 index 000000000..5aa203a49 --- /dev/null +++ b/apps/openmw/class2/creature.cpp @@ -0,0 +1,138 @@ + +#include "creature.hpp" + +#include + +#include "../mwmechanics/creaturestats.hpp" + +#include "../mwworld/ptr.hpp" +#include "../mwworld/actiontalk.hpp" +#include "../mwworld/environment.hpp" + + +#include "../mwmechanics/mechanicsmanager.hpp" + +namespace MWClass +{ + std::string Creature::getId (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->mId; + } + + void Creature::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + + /*ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + {*/ + MWRender::Actors& actors = renderingInterface.getActors(); + actors.insertCreature(ptr); + + } + + void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertActorPhysics(ptr, "meshes\\" + model); + } + + } + + void Creature::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + environment.mMechanicsManager->addActor (ptr); + } + + void Creature::disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + environment.mMechanicsManager->removeActor (ptr); + } + + std::string Creature::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->name; + } + + MWMechanics::CreatureStats& Creature::getCreatureStats (const MWWorld::Ptr& ptr) const + { + if (!ptr.getRefData().getCreatureStats().get()) + { + boost::shared_ptr stats ( + new MWMechanics::CreatureStats); + + ESMS::LiveCellRef *ref = ptr.get(); + + stats->mAttributes[0].set (ref->base->data.strength); + stats->mAttributes[1].set (ref->base->data.intelligence); + stats->mAttributes[2].set (ref->base->data.willpower); + stats->mAttributes[3].set (ref->base->data.agility); + stats->mAttributes[4].set (ref->base->data.speed); + stats->mAttributes[5].set (ref->base->data.endurance); + stats->mAttributes[6].set (ref->base->data.personality); + stats->mAttributes[7].set (ref->base->data.luck); + stats->mDynamic[0].set (ref->base->data.health); + stats->mDynamic[1].set (ref->base->data.mana); + stats->mDynamic[2].set (ref->base->data.fatigue); + + stats->mLevel = ref->base->data.level; + + ptr.getRefData().getCreatureStats() = stats; + } + + return *ptr.getRefData().getCreatureStats(); + } + + boost::shared_ptr Creature::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); + } + + MWWorld::ContainerStore& Creature::getContainerStore (const MWWorld::Ptr& ptr) + const + { + if (!ptr.getRefData().getContainerStore().get()) + { + boost::shared_ptr > store ( + new MWWorld::ContainerStore); + + // TODO add initial content + + ptr.getRefData().getContainerStore() = store; + } + + return *ptr.getRefData().getContainerStore(); + } + + std::string Creature::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Creature::registerSelf() + { + boost::shared_ptr instance (new Creature); + + registerClass (typeid (ESM::Creature).name(), instance); + } +} diff --git a/apps/openmw/class2/creature.hpp b/apps/openmw/class2/creature.hpp new file mode 100644 index 000000000..b7b654bc0 --- /dev/null +++ b/apps/openmw/class2/creature.hpp @@ -0,0 +1,51 @@ +#ifndef GAME_MWCLASS_CREATURE_H +#define GAME_MWCLASS_CREATURE_H + +#include "../mwworld/class.hpp" +#include "../mwrender/renderinginterface.hpp" +#include "../mwrender/actors.hpp" + + +namespace MWClass +{ + class Creature : public MWWorld::Class + { + public: + + virtual std::string getId (const MWWorld::Ptr& ptr) const; + ///< Return ID of \a ptr + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< Enable reference; only does the non-rendering part + + virtual void disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< Enable reference; only does the non-rendering part + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const; + ///< Return creature stats + + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + + virtual MWWorld::ContainerStore& getContainerStore ( + const MWWorld::Ptr& ptr) const; + ///< Return container store + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/creaturelevlist.cpp b/apps/openmw/class2/creaturelevlist.cpp new file mode 100644 index 000000000..53dd34bb4 --- /dev/null +++ b/apps/openmw/class2/creaturelevlist.cpp @@ -0,0 +1,19 @@ + +#include "creaturelevlist.hpp" + +#include + +namespace MWClass +{ + std::string CreatureLevList::getName (const MWWorld::Ptr& ptr) const + { + return ""; + } + + void CreatureLevList::registerSelf() + { + boost::shared_ptr instance (new CreatureLevList); + + registerClass (typeid (ESM::CreatureLevList).name(), instance); + } +} diff --git a/apps/openmw/class2/creaturelevlist.hpp b/apps/openmw/class2/creaturelevlist.hpp new file mode 100644 index 000000000..81965efd5 --- /dev/null +++ b/apps/openmw/class2/creaturelevlist.hpp @@ -0,0 +1,20 @@ +#ifndef GAME_MWCLASS_CREATURELEVLIST_H +#define GAME_MWCLASS_CREATURELEVLIST_H + +#include "../mwworld/class.hpp" + +namespace MWClass +{ + class CreatureLevList : public MWWorld::Class + { + public: + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/door.cpp b/apps/openmw/class2/door.cpp new file mode 100644 index 000000000..baced8a9c --- /dev/null +++ b/apps/openmw/class2/door.cpp @@ -0,0 +1,129 @@ + +#include "door.hpp" + +#include + +#include + +#include "../mwworld/player.hpp" +#include "../mwworld/ptr.hpp" +#include "../mwworld/nullaction.hpp" +#include "../mwworld/actionteleport.hpp" +#include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" + +#include "../mwrender/objects.hpp" + +#include + +namespace MWClass +{ + void Door::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); + objects.insertMesh(ptr, "meshes\\" + model); + } + } + + void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + std::string Door::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + if (ref->ref.teleport && !ref->ref.destCell.empty()) // TODO doors that lead to exteriors + return ref->ref.destCell; + + return ref->base->name; + } + + boost::shared_ptr Door::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + if (ptr.getCellRef().lockLevel>0) + { + // TODO check for key + // TODO report failure to player (message, sound?). Look up behaviour of original MW. + std::cout << "Locked!" << std::endl; + return boost::shared_ptr (new MWWorld::NullAction); + } + + // TODO check trap + + if (ref->ref.teleport) + { + // teleport door + if (environment.mWorld->getPlayer().getPlayer()==actor) + { + // the player is using the door + return boost::shared_ptr ( + new MWWorld::ActionTeleportPlayer (ref->ref.destCell, ref->ref.doorDest)); + } + else + { + // another NPC or a create is using the door + // TODO return action for teleporting other NPC/creature + return boost::shared_ptr (new MWWorld::NullAction); + } + } + else + { + // animated door + // TODO return action for rotating the door + return boost::shared_ptr (new MWWorld::NullAction); + } + } + + void Door::lock (const MWWorld::Ptr& ptr, int lockLevel) const + { + if (lockLevel<0) + lockLevel = 0; + + ptr.getCellRef().lockLevel = lockLevel; + } + + void Door::unlock (const MWWorld::Ptr& ptr) const + { + ptr.getCellRef().lockLevel = 0; + } + + std::string Door::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Door::registerSelf() + { + boost::shared_ptr instance (new Door); + + registerClass (typeid (ESM::Door).name(), instance); + } +} diff --git a/apps/openmw/class2/door.hpp b/apps/openmw/class2/door.hpp new file mode 100644 index 000000000..c230cf357 --- /dev/null +++ b/apps/openmw/class2/door.hpp @@ -0,0 +1,39 @@ +#ifndef GAME_MWCLASS_DOOR_H +#define GAME_MWCLASS_DOOR_H + +#include "../mwworld/class.hpp" +#include "../mwrender/objects.hpp" + +namespace MWClass +{ + class Door : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + + virtual void lock (const MWWorld::Ptr& ptr, int lockLevel) const; + ///< Lock object + + virtual void unlock (const MWWorld::Ptr& ptr) const; + ///< Unlock object + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/ingredient.cpp b/apps/openmw/class2/ingredient.cpp new file mode 100644 index 000000000..42e3d11e4 --- /dev/null +++ b/apps/openmw/class2/ingredient.cpp @@ -0,0 +1,82 @@ + +#include "ingredient.hpp" + +#include + +#include + +#include "../mwworld/ptr.hpp" +#include "../mwworld/actiontake.hpp" + + +#include "containerutil.hpp" + +namespace MWClass +{ + void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); + objects.insertMesh(ptr, "meshes\\" + model); + } + } + + void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + std::string Ingredient::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->name; + } + + boost::shared_ptr Ingredient::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + return boost::shared_ptr ( + new MWWorld::ActionTake (ptr)); + } + + void Ingredient::insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const + { + insertIntoContainerStore (ptr, containerStore.ingreds); + } + + std::string Ingredient::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Ingredient::registerSelf() + { + boost::shared_ptr instance (new Ingredient); + + registerClass (typeid (ESM::Ingredient).name(), instance); + } +} diff --git a/apps/openmw/class2/ingredient.hpp b/apps/openmw/class2/ingredient.hpp new file mode 100644 index 000000000..47bd1a9e5 --- /dev/null +++ b/apps/openmw/class2/ingredient.hpp @@ -0,0 +1,37 @@ +#ifndef GAME_MWCLASS_INGREDIENT_H +#define GAME_MWCLASS_INGREDIENT_H + +#include "../mwworld/class.hpp" +#include "../mwrender/objects.hpp" + +namespace MWClass +{ + class Ingredient : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + + virtual void insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const; + ///< Insert into a containe + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/itemlevlist.cpp b/apps/openmw/class2/itemlevlist.cpp new file mode 100644 index 000000000..6ed9ab2e5 --- /dev/null +++ b/apps/openmw/class2/itemlevlist.cpp @@ -0,0 +1,19 @@ + +#include "itemlevlist.hpp" + +#include + +namespace MWClass +{ + std::string ItemLevList::getName (const MWWorld::Ptr& ptr) const + { + return ""; + } + + void ItemLevList::registerSelf() + { + boost::shared_ptr instance (new ItemLevList); + + registerClass (typeid (ESM::ItemLevList).name(), instance); + } +} diff --git a/apps/openmw/class2/itemlevlist.hpp b/apps/openmw/class2/itemlevlist.hpp new file mode 100644 index 000000000..0b71b072c --- /dev/null +++ b/apps/openmw/class2/itemlevlist.hpp @@ -0,0 +1,20 @@ +#ifndef GAME_MWCLASS_ITEMLEVLIST_H +#define GAME_MWCLASS_ITEMLEVLIST_H + +#include "../mwworld/class.hpp" + +namespace MWClass +{ + class ItemLevList : public MWWorld::Class + { + public: + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/light.cpp b/apps/openmw/class2/light.cpp new file mode 100644 index 000000000..a3ceea4a6 --- /dev/null +++ b/apps/openmw/class2/light.cpp @@ -0,0 +1,110 @@ + +#include "light.hpp" + +#include + +#include + +#include "../mwworld/ptr.hpp" +#include "../mwworld/actiontake.hpp" +#include "../mwworld/nullaction.hpp" +#include "../mwworld/environment.hpp" + +#include "../mwsound/soundmanager.hpp" + +#include "containerutil.hpp" + +namespace MWClass +{ + void Light::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); + objects.insertMesh(ptr, "meshes\\" + model); + const int color = ref->base->data.color; + const float r = ((color >> 0) & 0xFF) / 255.0f; + const float g = ((color >> 8) & 0xFF) / 255.0f; + const float b = ((color >> 16) & 0xFF) / 255.0f; + const float radius = float (ref->base->data.radius); + objects.insertLight (ptr, r, g, b, radius); + } + } + + void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + void Light::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + if (!ref->base->sound.empty()) + { + environment.mSoundManager->playSound3D (ptr, ref->base->sound, 1.0, 1.0, true); + } + } + + std::string Light::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + if (ref->base->model.empty()) + return ""; + + return ref->base->name; + } + + boost::shared_ptr Light::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + if (!(ref->base->data.flags & ESM::Light::Carry)) + return boost::shared_ptr (new MWWorld::NullAction); + + return boost::shared_ptr ( + new MWWorld::ActionTake (ptr)); + } + + void Light::insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const + { + insertIntoContainerStore (ptr, containerStore.lights); + } + + std::string Light::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Light::registerSelf() + { + boost::shared_ptr instance (new Light); + + registerClass (typeid (ESM::Light).name(), instance); + } +} diff --git a/apps/openmw/class2/light.hpp b/apps/openmw/class2/light.hpp new file mode 100644 index 000000000..34421ff51 --- /dev/null +++ b/apps/openmw/class2/light.hpp @@ -0,0 +1,42 @@ +#ifndef GAME_MWCLASS_LIGHT_H +#define GAME_MWCLASS_LIGHT_H + +#include "../mwworld/class.hpp" +#include "../mwrender/objects.hpp" + +namespace MWClass +{ + class Light : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< Enable reference; only does the non-rendering part + /// \attention This is not the same as the script instruction with the same name. References + /// should only be enabled while in an active cell. + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + + virtual void insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const; + ///< Insert into a containe + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/lockpick.cpp b/apps/openmw/class2/lockpick.cpp new file mode 100644 index 000000000..c07d5592c --- /dev/null +++ b/apps/openmw/class2/lockpick.cpp @@ -0,0 +1,81 @@ + +#include "lockpick.hpp" + +#include + +#include + +#include "../mwworld/ptr.hpp" +#include "../mwworld/actiontake.hpp" + +#include "containerutil.hpp" + +namespace MWClass +{ + void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); + objects.insertMesh(ptr, "meshes\\" + model); + } + } + + void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + + std::string Lockpick::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->name; + } + + boost::shared_ptr Lockpick::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + return boost::shared_ptr ( + new MWWorld::ActionTake (ptr)); + } + + void Lockpick::insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const + { + insertIntoContainerStore (ptr, containerStore.lockpicks); + } + + std::string Lockpick::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Lockpick::registerSelf() + { + boost::shared_ptr instance (new Lockpick); + + registerClass (typeid (ESM::Tool).name(), instance); + } +} diff --git a/apps/openmw/class2/lockpick.hpp b/apps/openmw/class2/lockpick.hpp new file mode 100644 index 000000000..c5f1539b4 --- /dev/null +++ b/apps/openmw/class2/lockpick.hpp @@ -0,0 +1,37 @@ +#ifndef GAME_MWCLASS_LOCKPICK_H +#define GAME_MWCLASS_LOCKPICK_H + +#include "../mwworld/class.hpp" +#include "../mwrender/objects.hpp" + +namespace MWClass +{ + class Lockpick : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + + virtual void insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const; + ///< Insert into a containe + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/misc.cpp b/apps/openmw/class2/misc.cpp new file mode 100644 index 000000000..a58142905 --- /dev/null +++ b/apps/openmw/class2/misc.cpp @@ -0,0 +1,80 @@ + +#include "misc.hpp" + +#include + +#include + +#include "../mwworld/ptr.hpp" +#include "../mwworld/actiontake.hpp" + +#include "containerutil.hpp" + +namespace MWClass +{ + void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); + objects.insertMesh(ptr, "meshes\\" + model); + } + } + + void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + std::string Miscellaneous::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->name; + } + + boost::shared_ptr Miscellaneous::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + return boost::shared_ptr ( + new MWWorld::ActionTake (ptr)); + } + + void Miscellaneous::insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const + { + insertIntoContainerStore (ptr, containerStore.miscItems); + } + + std::string Miscellaneous::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Miscellaneous::registerSelf() + { + boost::shared_ptr instance (new Miscellaneous); + + registerClass (typeid (ESM::Miscellaneous).name(), instance); + } +} diff --git a/apps/openmw/class2/misc.hpp b/apps/openmw/class2/misc.hpp new file mode 100644 index 000000000..36ee2c1b2 --- /dev/null +++ b/apps/openmw/class2/misc.hpp @@ -0,0 +1,37 @@ +#ifndef GAME_MWCLASS_MISC_H +#define GAME_MWCLASS_MISC_H + +#include "../mwworld/class.hpp" +#include "../mwrender/objects.hpp" + +namespace MWClass +{ + class Miscellaneous : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + + virtual void insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const; + ///< Insert into a containe + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/npc.cpp b/apps/openmw/class2/npc.cpp new file mode 100644 index 000000000..acb0a5a35 --- /dev/null +++ b/apps/openmw/class2/npc.cpp @@ -0,0 +1,276 @@ + +#include "npc.hpp" + +#include + +#include "../mwmechanics/creaturestats.hpp" +#include "../mwmechanics/npcstats.hpp" + +#include "../mwworld/ptr.hpp" +#include "../mwworld/actiontalk.hpp" +#include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" + +#include "../mwmechanics/mechanicsmanager.hpp" +#include + +namespace +{ + const Ogre::Radian kOgrePi (Ogre::Math::PI); + const Ogre::Radian kOgrePiOverTwo (Ogre::Math::PI / Ogre::Real(2.0)); +} + +namespace MWClass +{ + std::string Npc::getId (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->mId; + } + + void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + renderingInterface.getActors().insertNPC(ptr); + } + + void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + + + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + std::string headID = ref->base->head; + std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4); + bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_"; + + + std::string smodel = "meshes\\base_anim.nif"; + if(beast) + smodel = "meshes\\base_animkna.nif"; + physics.insertActorPhysics(ptr, smodel); + + + } + + void Npc::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + environment.mMechanicsManager->addActor (ptr); + } + + void Npc::disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + environment.mMechanicsManager->removeActor (ptr); + } + + std::string Npc::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->name; + } + + MWMechanics::CreatureStats& Npc::getCreatureStats (const MWWorld::Ptr& ptr) const + { + if (!ptr.getRefData().getCreatureStats().get()) + { + boost::shared_ptr stats ( + new MWMechanics::CreatureStats); + + ESMS::LiveCellRef *ref = ptr.get(); + + stats->mAttributes[0].set (ref->base->npdt52.strength); + stats->mAttributes[1].set (ref->base->npdt52.intelligence); + stats->mAttributes[2].set (ref->base->npdt52.willpower); + stats->mAttributes[3].set (ref->base->npdt52.agility); + stats->mAttributes[4].set (ref->base->npdt52.speed); + stats->mAttributes[5].set (ref->base->npdt52.endurance); + stats->mAttributes[6].set (ref->base->npdt52.personality); + stats->mAttributes[7].set (ref->base->npdt52.luck); + stats->mDynamic[0].set (ref->base->npdt52.health); + stats->mDynamic[1].set (ref->base->npdt52.mana); + stats->mDynamic[2].set (ref->base->npdt52.fatigue); + + stats->mLevel = ref->base->npdt52.level; + + ptr.getRefData().getCreatureStats() = stats; + } + + return *ptr.getRefData().getCreatureStats(); + } + + MWMechanics::NpcStats& Npc::getNpcStats (const MWWorld::Ptr& ptr) const + { + if (!ptr.getRefData().getNpcStats().get()) + { + boost::shared_ptr stats ( + new MWMechanics::NpcStats); + + ESMS::LiveCellRef *ref = ptr.get(); + + if (!ref->base->faction.empty()) + { + // TODO research how initial rank is stored. The information in loadnpc.hpp are at + // best very unclear. + stats->mFactionRank[ref->base->faction] = 0; + } + + for (int i=0; i<27; ++i) + stats->mSkill[i].setBase (ref->base->npdt52.skills[i]); + + ptr.getRefData().getNpcStats() = stats; + } + + return *ptr.getRefData().getNpcStats(); + } + + boost::shared_ptr Npc::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); + } + + MWWorld::ContainerStore& Npc::getContainerStore (const MWWorld::Ptr& ptr) + const + { + if (!ptr.getRefData().getContainerStore().get()) + { + boost::shared_ptr > store ( + new MWWorld::ContainerStore); + + // TODO add initial content + + ptr.getRefData().getContainerStore() = store; + } + + return *ptr.getRefData().getContainerStore(); + } + + std::string Npc::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Npc::setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const + { + MWMechanics::NpcStats& stats = getNpcStats (ptr); + + switch (stance) + { + case Run: + + stats.mForceRun = force; + break; + + case Sneak: + + stats.mForceSneak = force; + break; + + case Combat: + + throw std::runtime_error ("combat stance not enforcable for NPCs"); + } + } + + void Npc::setStance (const MWWorld::Ptr& ptr, Stance stance, bool set) const + { + MWMechanics::NpcStats& stats = getNpcStats (ptr); + + switch (stance) + { + case Run: + + stats.mRun = set; + break; + + case Sneak: + + stats.mSneak = set; + break; + + case Combat: + + stats.mCombat = set; + break; + } + } + + bool Npc::getStance (const MWWorld::Ptr& ptr, Stance stance, bool ignoreForce) const + { + MWMechanics::NpcStats& stats = getNpcStats (ptr); + + switch (stance) + { + case Run: + + if (!ignoreForce && stats.mForceRun) + return true; + + return stats.mRun; + + case Sneak: + + if (!ignoreForce && stats.mForceSneak) + return true; + + return stats.mSneak; + + case Combat: + + return stats.mCombat; + } + + return false; + } + + float Npc::getSpeed (const MWWorld::Ptr& ptr) const + { + return getStance (ptr, Run) ? 600 : 300; // TODO calculate these values from stats + } + + MWMechanics::Movement& Npc::getMovementSettings (const MWWorld::Ptr& ptr) const + { + if (!ptr.getRefData().getMovement().get()) + { + boost::shared_ptr movement ( + new MWMechanics::Movement); + + ptr.getRefData().getMovement() = movement; + } + + return *ptr.getRefData().getMovement(); + } + + Ogre::Vector3 Npc::getMovementVector (const MWWorld::Ptr& ptr) const + { + Ogre::Vector3 vector (0, 0, 0); + + if (ptr.getRefData().getMovement().get()) + { + vector.x = - ptr.getRefData().getMovement()->mLeftRight * 200; + vector.y = ptr.getRefData().getMovement()->mForwardBackward * 200; + + if (getStance (ptr, Run, false)) + vector *= 2; + } + + return vector; + } + + void Npc::registerSelf() + { + boost::shared_ptr instance (new Npc); + + registerClass (typeid (ESM::NPC).name(), instance); + } +} diff --git a/apps/openmw/class2/npc.hpp b/apps/openmw/class2/npc.hpp new file mode 100644 index 000000000..cc9dbef7f --- /dev/null +++ b/apps/openmw/class2/npc.hpp @@ -0,0 +1,72 @@ +#ifndef GAME_MWCLASS_NPC_H +#define GAME_MWCLASS_NPC_H + +#include "../mwworld/class.hpp" + + +namespace MWClass +{ + class Npc : public MWWorld::Class + { + public: + + virtual std::string getId (const MWWorld::Ptr& ptr) const; + ///< Return ID of \a ptr + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< Enable reference; only does the non-rendering part + + virtual void disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< Enable reference; only does the non-rendering part + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const; + ///< Return creature stats + + virtual MWMechanics::NpcStats& getNpcStats (const MWWorld::Ptr& ptr) const; + ///< Return NPC stats + + virtual MWWorld::ContainerStore& getContainerStore ( + const MWWorld::Ptr& ptr) const; + ///< Return container store + + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + virtual void setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const; + ///< Force or unforce a stance. + + virtual void setStance (const MWWorld::Ptr& ptr, Stance stance, bool set) const; + ///< Set or unset a stance. + + virtual bool getStance (const MWWorld::Ptr& ptr, Stance stance, bool ignoreForce = false) + const; + ////< Check if a stance is active or not. + + virtual float getSpeed (const MWWorld::Ptr& ptr) const; + ///< Return movement speed. + + virtual MWMechanics::Movement& getMovementSettings (const MWWorld::Ptr& ptr) const; + ///< Return desired movement. + + virtual Ogre::Vector3 getMovementVector (const MWWorld::Ptr& ptr) const; + ///< Return desired movement vector (determined based on movement settings, + /// stance and stats). + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/potion.cpp b/apps/openmw/class2/potion.cpp new file mode 100644 index 000000000..0ab1c7aad --- /dev/null +++ b/apps/openmw/class2/potion.cpp @@ -0,0 +1,81 @@ + +#include "potion.hpp" + +#include + +#include + +#include "../mwworld/ptr.hpp" +#include "../mwworld/actiontake.hpp" + + +#include "containerutil.hpp" + +namespace MWClass +{ + void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); + objects.insertMesh(ptr, "meshes\\" + model); + } + } + + void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + std::string Potion::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->name; + } + + boost::shared_ptr Potion::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + return boost::shared_ptr ( + new MWWorld::ActionTake (ptr)); + } + + void Potion::insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const + { + insertIntoContainerStore (ptr, containerStore.potions); + } + + std::string Potion::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Potion::registerSelf() + { + boost::shared_ptr instance (new Potion); + + registerClass (typeid (ESM::Potion).name(), instance); + } +} diff --git a/apps/openmw/class2/potion.hpp b/apps/openmw/class2/potion.hpp new file mode 100644 index 000000000..85678121f --- /dev/null +++ b/apps/openmw/class2/potion.hpp @@ -0,0 +1,37 @@ +#ifndef GAME_MWCLASS_POTION_H +#define GAME_MWCLASS_POTION_H + +#include "../mwworld/class.hpp" +#include "../mwrender/objects.hpp" + +namespace MWClass +{ + class Potion : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + + virtual void insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const; + ///< Insert into a containe + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/probe.cpp b/apps/openmw/class2/probe.cpp new file mode 100644 index 000000000..83c0e1ef4 --- /dev/null +++ b/apps/openmw/class2/probe.cpp @@ -0,0 +1,81 @@ + +#include "probe.hpp" + +#include + +#include + +#include "../mwworld/ptr.hpp" +#include "../mwworld/actiontake.hpp" + +#include "containerutil.hpp" +#include "../mwrender/objects.hpp" + +namespace MWClass +{ + void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); + objects.insertMesh(ptr, "meshes\\" + model); + } + } + + void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + + std::string Probe::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->name; + } + boost::shared_ptr Probe::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + return boost::shared_ptr ( + new MWWorld::ActionTake (ptr)); + } + + void Probe::insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const + { + insertIntoContainerStore (ptr, containerStore.probes); + } + + std::string Probe::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Probe::registerSelf() + { + boost::shared_ptr instance (new Probe); + + registerClass (typeid (ESM::Probe).name(), instance); + } +} diff --git a/apps/openmw/class2/probe.hpp b/apps/openmw/class2/probe.hpp new file mode 100644 index 000000000..d7b9df738 --- /dev/null +++ b/apps/openmw/class2/probe.hpp @@ -0,0 +1,37 @@ +#ifndef GAME_MWCLASS_PROBE_H +#define GAME_MWCLASS_PROBE_H + +#include "../mwworld/class.hpp" + + +namespace MWClass +{ + class Probe : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + + virtual void insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const; + ///< Insert into a containe + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/repair.cpp b/apps/openmw/class2/repair.cpp new file mode 100644 index 000000000..feee7e988 --- /dev/null +++ b/apps/openmw/class2/repair.cpp @@ -0,0 +1,80 @@ + +#include "repair.hpp" + +#include + +#include + +#include "../mwworld/ptr.hpp" +#include "../mwworld/actiontake.hpp" + +#include "containerutil.hpp" + +namespace MWClass +{ + void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); + objects.insertMesh(ptr, "meshes\\" + model); + } + } + + void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + std::string Repair::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->name; + } + + boost::shared_ptr Repair::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + return boost::shared_ptr ( + new MWWorld::ActionTake (ptr)); + } + + void Repair::insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const + { + insertIntoContainerStore (ptr, containerStore.repairs); + } + + std::string Repair::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Repair::registerSelf() + { + boost::shared_ptr instance (new Repair); + + registerClass (typeid (ESM::Repair).name(), instance); + } +} diff --git a/apps/openmw/class2/repair.hpp b/apps/openmw/class2/repair.hpp new file mode 100644 index 000000000..1e0ea5178 --- /dev/null +++ b/apps/openmw/class2/repair.hpp @@ -0,0 +1,37 @@ +#ifndef GAME_MWCLASS_REPAIR_H +#define GAME_MWCLASS_REPAIR_H + +#include "../mwworld/class.hpp" +#include "../mwrender/objects.hpp" + +namespace MWClass +{ + class Repair : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + + virtual void insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const; + ///< Insert into a containe + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/static.cpp b/apps/openmw/class2/static.cpp new file mode 100644 index 000000000..af14bb306 --- /dev/null +++ b/apps/openmw/class2/static.cpp @@ -0,0 +1,52 @@ + +#include "static.hpp" + +#include + +#include "../mwworld/ptr.hpp" + + +namespace MWClass +{ + void Static::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); + objects.insertMesh(ptr, "meshes\\" + model); + } + } + + void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + std::string Static::getName (const MWWorld::Ptr& ptr) const + { + return ""; + } + + void Static::registerSelf() + { + boost::shared_ptr instance (new Static); + + registerClass (typeid (ESM::Static).name(), instance); + } +} diff --git a/apps/openmw/class2/static.hpp b/apps/openmw/class2/static.hpp new file mode 100644 index 000000000..be3fdb180 --- /dev/null +++ b/apps/openmw/class2/static.hpp @@ -0,0 +1,26 @@ +#ifndef GAME_MWCLASS_STATIC_H +#define GAME_MWCLASS_STATIC_H + +#include "../mwworld/class.hpp" +#include "../mwrender/objects.hpp" + +namespace MWClass +{ + class Static : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/class2/weapon.cpp b/apps/openmw/class2/weapon.cpp new file mode 100644 index 000000000..d5f7e6853 --- /dev/null +++ b/apps/openmw/class2/weapon.cpp @@ -0,0 +1,94 @@ + +#include "weapon.hpp" + +#include + +#include + +#include "../mwworld/ptr.hpp" +#include "../mwworld/actiontake.hpp" + + +#include "containerutil.hpp" + +namespace MWClass +{ + void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + + if (!model.empty()) + { + MWRender::Objects& objects = renderingInterface.getObjects(); + objects.insertBegin(ptr, ptr.getRefData().isEnabled(),true); + objects.insertMesh(ptr, "meshes\\" + model); + } + } + + void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + + const std::string &model = ref->base->model; + assert (ref->base != NULL); + if(!model.empty()){ + physics.insertObjectPhysics(ptr, "meshes\\" + model); + } + + } + + std::string Weapon::getName (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->name; + } + + boost::shared_ptr Weapon::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + return boost::shared_ptr ( + new MWWorld::ActionTake (ptr)); + } + + bool Weapon::hasItemHealth (const MWWorld::Ptr& ptr) const + { + return true; + } + + int Weapon::getItemMaxHealth (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->data.health; + } + + void Weapon::insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const + { + insertIntoContainerStore (ptr, containerStore.weapons); + } + + std::string Weapon::getScript (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->script; + } + + void Weapon::registerSelf() + { + boost::shared_ptr instance (new Weapon); + + registerClass (typeid (ESM::Weapon).name(), instance); + } +} diff --git a/apps/openmw/class2/weapon.hpp b/apps/openmw/class2/weapon.hpp new file mode 100644 index 000000000..79bc4d4de --- /dev/null +++ b/apps/openmw/class2/weapon.hpp @@ -0,0 +1,43 @@ +#ifndef GAME_MWCLASS_WEAPON_H +#define GAME_MWCLASS_WEAPON_H + +#include "../mwworld/class.hpp" +#include "../mwrender/objects.hpp" + +namespace MWClass +{ + class Weapon : public MWWorld::Class + { + public: + + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + ///< Add reference into a cell for rendering + + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + + virtual std::string getName (const MWWorld::Ptr& ptr) const; + ///< \return name (the one that is to be presented to the user; not the internal one); + /// can return an empty string. + + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + + virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const; + ///< \return Item health data available? + + virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const; + ///< Return item max health or throw an exception, if class does not have item health + + virtual void insertIntoContainer (const MWWorld::Ptr& ptr, + MWWorld::ContainerStore& containerStore) const; + ///< Insert into a containe + + virtual std::string getScript (const MWWorld::Ptr& ptr) const; + ///< Return name of the script attached to ptr + + static void registerSelf(); + }; +} + +#endif diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 96d65e00d..4013d69fe 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -261,11 +261,13 @@ namespace MWRender{ Ogre::Vector3 shapetrans = copy.trafo.trans; float shapescale = copy.trafo.scale; std::vector boneSequence = copy.boneSequence; - std::vector::iterator boneSequenceIter = boneSequence.begin(); + Ogre::Vector3 transmult; Ogre::Quaternion rotmult; float scale; - if(skel->hasBone(*boneSequenceIter)){ + if(boneSequence.size() > 0){ + std::vector::iterator boneSequenceIter = boneSequence.begin(); + if(skel->hasBone(*boneSequenceIter)){ Ogre::Bone *bonePtr = skel->getBone(*boneSequenceIter); @@ -292,6 +294,7 @@ namespace MWRender{ //std::cout << "Position: " << transmult << "Rotation: " << rotmult << "\n"; } + } else { transmult = shapetrans; diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 2ac05f2c8..68cd532e9 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -583,6 +583,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou { assert(shape != NULL); + bool saveTheShape = inTheSkeletonTree; // Interpret flags bool hidden = (flags & 0x01) != 0; // Not displayed bool collide = (flags & 0x02) != 0; // Use mesh for collision @@ -741,6 +742,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou std::list vertexBoneAssignments; Nif::NiTriShapeCopy copy = shape->clone(); + if(!shape->controller.empty()) { Nif::Controller* cont = shape->controller.getPtr(); @@ -750,6 +752,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou copy.morph = morph->data.get(); copy.morph.setStartTime(morph->timeStart); copy.morph.setStopTime(morph->timeStop); + saveTheShape = true; } } @@ -928,10 +931,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou } if(!mSkel.isNull() ){ int boneIndex; - Ogre::Bone *parentBone = mSkel->getBone(boneSequence[boneSequence.size() - 1]); - if(parentBone) - boneIndex = parentBone->getHandle(); - else + boneIndex = mSkel->getNumBones() - 1; for(int i = 0; i < numVerts; i++){ VertexBoneAssignment vba; @@ -947,7 +947,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou { // Add this vertex set to the bounding box bounds.add(optr, numVerts); - if(addShapes) + if(saveTheShape) shapes.push_back(copy); // Create the submesh @@ -1069,21 +1069,22 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, //FIXME: "Bip01" isn't every time the root bone if (node->name == "Bip01" || node->name == "Root Bone") //root node, create a skeleton { - addShapes = true; + inTheSkeletonTree = true; mSkel = SkeletonManager::getSingleton().create(getSkeletonName(), resourceGroup, true); } else if (!mSkel.isNull() && !parentBone) - addShapes = false; + inTheSkeletonTree = false; if (!mSkel.isNull()) //if there is a skeleton { std::string name = node->name.toString(); - boneSequence.push_back(name); + // Quick-n-dirty workaround for the fact that several // bones may have the same name. if(!mSkel->hasBone(name)) { + boneSequence.push_back(name); bone = mSkel->createBone(name); if (parentBone) @@ -1148,7 +1149,7 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, void NIFLoader::loadResource(Resource *resource) { - addShapes = false; + inTheSkeletonTree = false; allanim.clear(); shapes.clear(); needBoneAssignments.clear(); diff --git a/components/nifogre/ogre_nif_loader.hpp b/components/nifogre/ogre_nif_loader.hpp index 1361ffaca..b43d2992c 100644 --- a/components/nifogre/ogre_nif_loader.hpp +++ b/components/nifogre/ogre_nif_loader.hpp @@ -121,7 +121,7 @@ class NIFLoader : Ogre::ManualResourceLoader private: NIFLoader() : mNormaliseNormals(false), resourceGroup("General"), resourceName(""), flip(false), - mFlipVertexWinding(false), mOutputAnimFiles(false), addShapes(false) {} + mFlipVertexWinding(false), mOutputAnimFiles(false), inTheSkeletonTree(false) {} NIFLoader(NIFLoader& n) {} void calculateTransform(); @@ -190,7 +190,7 @@ class NIFLoader : Ogre::ManualResourceLoader std::vector mAnim; std::vector mS; std::vector needBoneAssignments; - bool addShapes; + bool inTheSkeletonTree; }; From e330c22d68ab8f850a00e1b8a3a299595ccce775 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sun, 19 Feb 2012 02:04:47 -0500 Subject: [PATCH 27/30] Removing unneeded files --- apps/openmw/class2/activator.cpp | 66 ------ apps/openmw/class2/activator.hpp | 28 --- apps/openmw/class2/apparatus.cpp | 81 -------- apps/openmw/class2/apparatus.hpp | 37 ---- apps/openmw/class2/armor.cpp | 93 --------- apps/openmw/class2/armor.hpp | 43 ---- apps/openmw/class2/book.cpp | 83 -------- apps/openmw/class2/book.hpp | 37 ---- apps/openmw/class2/classes.cpp | 50 ----- apps/openmw/class2/classes.hpp | 10 - apps/openmw/class2/clothing.cpp | 81 -------- apps/openmw/class2/clothing.hpp | 37 ---- apps/openmw/class2/container.cpp | 80 ------- apps/openmw/class2/container.hpp | 33 --- apps/openmw/class2/containerutil.hpp | 28 --- apps/openmw/class2/creature.cpp | 138 ------------- apps/openmw/class2/creature.hpp | 51 ----- apps/openmw/class2/creaturelevlist.cpp | 19 -- apps/openmw/class2/creaturelevlist.hpp | 20 -- apps/openmw/class2/door.cpp | 129 ------------ apps/openmw/class2/door.hpp | 39 ---- apps/openmw/class2/ingredient.cpp | 82 -------- apps/openmw/class2/ingredient.hpp | 37 ---- apps/openmw/class2/itemlevlist.cpp | 19 -- apps/openmw/class2/itemlevlist.hpp | 20 -- apps/openmw/class2/light.cpp | 110 ---------- apps/openmw/class2/light.hpp | 42 ---- apps/openmw/class2/lockpick.cpp | 81 -------- apps/openmw/class2/lockpick.hpp | 37 ---- apps/openmw/class2/misc.cpp | 80 ------- apps/openmw/class2/misc.hpp | 37 ---- apps/openmw/class2/npc.cpp | 276 ------------------------- apps/openmw/class2/npc.hpp | 72 ------- apps/openmw/class2/potion.cpp | 81 -------- apps/openmw/class2/potion.hpp | 37 ---- apps/openmw/class2/probe.cpp | 81 -------- apps/openmw/class2/probe.hpp | 37 ---- apps/openmw/class2/repair.cpp | 80 ------- apps/openmw/class2/repair.hpp | 37 ---- apps/openmw/class2/static.cpp | 52 ----- apps/openmw/class2/static.hpp | 26 --- apps/openmw/class2/weapon.cpp | 94 --------- apps/openmw/class2/weapon.hpp | 43 ---- 43 files changed, 2644 deletions(-) delete mode 100644 apps/openmw/class2/activator.cpp delete mode 100644 apps/openmw/class2/activator.hpp delete mode 100644 apps/openmw/class2/apparatus.cpp delete mode 100644 apps/openmw/class2/apparatus.hpp delete mode 100644 apps/openmw/class2/armor.cpp delete mode 100644 apps/openmw/class2/armor.hpp delete mode 100644 apps/openmw/class2/book.cpp delete mode 100644 apps/openmw/class2/book.hpp delete mode 100644 apps/openmw/class2/classes.cpp delete mode 100644 apps/openmw/class2/classes.hpp delete mode 100644 apps/openmw/class2/clothing.cpp delete mode 100644 apps/openmw/class2/clothing.hpp delete mode 100644 apps/openmw/class2/container.cpp delete mode 100644 apps/openmw/class2/container.hpp delete mode 100644 apps/openmw/class2/containerutil.hpp delete mode 100644 apps/openmw/class2/creature.cpp delete mode 100644 apps/openmw/class2/creature.hpp delete mode 100644 apps/openmw/class2/creaturelevlist.cpp delete mode 100644 apps/openmw/class2/creaturelevlist.hpp delete mode 100644 apps/openmw/class2/door.cpp delete mode 100644 apps/openmw/class2/door.hpp delete mode 100644 apps/openmw/class2/ingredient.cpp delete mode 100644 apps/openmw/class2/ingredient.hpp delete mode 100644 apps/openmw/class2/itemlevlist.cpp delete mode 100644 apps/openmw/class2/itemlevlist.hpp delete mode 100644 apps/openmw/class2/light.cpp delete mode 100644 apps/openmw/class2/light.hpp delete mode 100644 apps/openmw/class2/lockpick.cpp delete mode 100644 apps/openmw/class2/lockpick.hpp delete mode 100644 apps/openmw/class2/misc.cpp delete mode 100644 apps/openmw/class2/misc.hpp delete mode 100644 apps/openmw/class2/npc.cpp delete mode 100644 apps/openmw/class2/npc.hpp delete mode 100644 apps/openmw/class2/potion.cpp delete mode 100644 apps/openmw/class2/potion.hpp delete mode 100644 apps/openmw/class2/probe.cpp delete mode 100644 apps/openmw/class2/probe.hpp delete mode 100644 apps/openmw/class2/repair.cpp delete mode 100644 apps/openmw/class2/repair.hpp delete mode 100644 apps/openmw/class2/static.cpp delete mode 100644 apps/openmw/class2/static.hpp delete mode 100644 apps/openmw/class2/weapon.cpp delete mode 100644 apps/openmw/class2/weapon.hpp diff --git a/apps/openmw/class2/activator.cpp b/apps/openmw/class2/activator.cpp deleted file mode 100644 index 086cb433d..000000000 --- a/apps/openmw/class2/activator.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -#include "activator.hpp" -#include "../mwrender/objects.hpp" - -#include - -#include - -#include "../mwworld/ptr.hpp" - - -namespace MWClass -{ - void Activator::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); - objects.insertMesh(ptr, "meshes\\" + model); - } - } - - void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - std::string Activator::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->name; - } - - std::string Activator::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Activator::registerSelf() - { - boost::shared_ptr instance (new Activator); - - registerClass (typeid (ESM::Activator).name(), instance); - } -} diff --git a/apps/openmw/class2/activator.hpp b/apps/openmw/class2/activator.hpp deleted file mode 100644 index 08be8a5ff..000000000 --- a/apps/openmw/class2/activator.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef GAME_MWCLASS_ACTIVATOR_H -#define GAME_MWCLASS_ACTIVATOR_H - -#include "../mwworld/class.hpp" - -namespace MWClass -{ - class Activator : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/apparatus.cpp b/apps/openmw/class2/apparatus.cpp deleted file mode 100644 index 4c5ba0721..000000000 --- a/apps/openmw/class2/apparatus.cpp +++ /dev/null @@ -1,81 +0,0 @@ - -#include "apparatus.hpp" - -#include - -#include - -#include "../mwworld/ptr.hpp" -#include "../mwworld/actiontake.hpp" - - -#include "containerutil.hpp" - -namespace MWClass -{ - void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); - objects.insertMesh(ptr, "meshes\\" + model); - } - } - - void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - std::string Apparatus::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->name; - } - - boost::shared_ptr Apparatus::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - return boost::shared_ptr ( - new MWWorld::ActionTake (ptr)); - } - - void Apparatus::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.appas); - } - - std::string Apparatus::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Apparatus::registerSelf() - { - boost::shared_ptr instance (new Apparatus); - - registerClass (typeid (ESM::Apparatus).name(), instance); - } -} diff --git a/apps/openmw/class2/apparatus.hpp b/apps/openmw/class2/apparatus.hpp deleted file mode 100644 index 4c8a2c0e2..000000000 --- a/apps/openmw/class2/apparatus.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef GAME_MWCLASS_APPARATUS_H -#define GAME_MWCLASS_APPARATUS_H - -#include "../mwworld/class.hpp" -#include "../mwrender/objects.hpp" - -namespace MWClass -{ - class Apparatus : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; - ///< Generate action for activation - - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/armor.cpp b/apps/openmw/class2/armor.cpp deleted file mode 100644 index 2ad1dbfa2..000000000 --- a/apps/openmw/class2/armor.cpp +++ /dev/null @@ -1,93 +0,0 @@ - -#include "armor.hpp" - -#include - -#include - -#include "../mwworld/ptr.hpp" -#include "../mwworld/actiontake.hpp" - - -#include "containerutil.hpp" - -namespace MWClass -{ - void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); - objects.insertMesh(ptr, "meshes\\" + model); - } - } - - void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - std::string Armor::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->name; - } - - boost::shared_ptr Armor::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - return boost::shared_ptr ( - new MWWorld::ActionTake (ptr)); - } - - bool Armor::hasItemHealth (const MWWorld::Ptr& ptr) const - { - return true; - } - - int Armor::getItemMaxHealth (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->data.health; - } - - void Armor::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.armors); - } - - std::string Armor::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Armor::registerSelf() - { - boost::shared_ptr instance (new Armor); - - registerClass (typeid (ESM::Armor).name(), instance); - } -} diff --git a/apps/openmw/class2/armor.hpp b/apps/openmw/class2/armor.hpp deleted file mode 100644 index c5f9812b7..000000000 --- a/apps/openmw/class2/armor.hpp +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef GAME_MWCLASS_ARMOR_H -#define GAME_MWCLASS_ARMOR_H - -#include "../mwworld/class.hpp" -#include "../mwrender/objects.hpp" - -namespace MWClass -{ - class Armor : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; - ///< Generate action for activation - - virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const; - ///< \return Item health data available? - - virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const; - ///< Return item max health or throw an exception, if class does not have item health - - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/book.cpp b/apps/openmw/class2/book.cpp deleted file mode 100644 index 5c0d8767a..000000000 --- a/apps/openmw/class2/book.cpp +++ /dev/null @@ -1,83 +0,0 @@ - -#include "book.hpp" - -#include - -#include - -#include "../mwworld/ptr.hpp" -#include "../mwworld/actiontake.hpp" - - -#include "containerutil.hpp" - -namespace MWClass -{ - void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); - objects.insertMesh(ptr, "meshes\\" + model); - } - } - - void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - std::string Book::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->name; - } - - boost::shared_ptr Book::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - // TODO implement reading - - return boost::shared_ptr ( - new MWWorld::ActionTake (ptr)); - } - - void Book::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.books); - } - - std::string Book::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Book::registerSelf() - { - boost::shared_ptr instance (new Book); - - registerClass (typeid (ESM::Book).name(), instance); - } -} diff --git a/apps/openmw/class2/book.hpp b/apps/openmw/class2/book.hpp deleted file mode 100644 index f0e38cceb..000000000 --- a/apps/openmw/class2/book.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef GAME_MWCLASS_BOOK_H -#define GAME_MWCLASS_BOOK_H - -#include "../mwworld/class.hpp" -#include "../mwrender/objects.hpp" - -namespace MWClass -{ - class Book : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; - ///< Generate action for activation - - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/classes.cpp b/apps/openmw/class2/classes.cpp deleted file mode 100644 index e9538a6cb..000000000 --- a/apps/openmw/class2/classes.cpp +++ /dev/null @@ -1,50 +0,0 @@ - -#include "classes.hpp" - -#include "activator.hpp" -#include "creature.hpp" -#include "npc.hpp" -#include "weapon.hpp" -#include "armor.hpp" -#include "potion.hpp" -#include "apparatus.hpp" -#include "book.hpp" -#include "clothing.hpp" -#include "container.hpp" -#include "door.hpp" -#include "ingredient.hpp" -#include "creaturelevlist.hpp" -#include "itemlevlist.hpp" -#include "light.hpp" -#include "lockpick.hpp" -#include "misc.hpp" -#include "probe.hpp" -#include "repair.hpp" -#include "static.hpp" - -namespace MWClass -{ - void registerClasses() - { - Activator::registerSelf(); - Creature::registerSelf(); - Npc::registerSelf(); - Weapon::registerSelf(); - Armor::registerSelf(); - Potion::registerSelf(); - Apparatus::registerSelf(); - Book::registerSelf(); - Clothing::registerSelf(); - Container::registerSelf(); - Door::registerSelf(); - Ingredient::registerSelf(); - CreatureLevList::registerSelf(); - ItemLevList::registerSelf(); - Light::registerSelf(); - Lockpick::registerSelf(); - Miscellaneous::registerSelf(); - Probe::registerSelf(); - Repair::registerSelf(); - Static::registerSelf(); - } -} diff --git a/apps/openmw/class2/classes.hpp b/apps/openmw/class2/classes.hpp deleted file mode 100644 index 0ab90b677..000000000 --- a/apps/openmw/class2/classes.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef GAME_MWCLASS_CLASSES_H -#define GAME_MWCLASS_CLASSES_H - -namespace MWClass -{ - void registerClasses(); - ///< register all known classes -} - -#endif diff --git a/apps/openmw/class2/clothing.cpp b/apps/openmw/class2/clothing.cpp deleted file mode 100644 index b81a181f4..000000000 --- a/apps/openmw/class2/clothing.cpp +++ /dev/null @@ -1,81 +0,0 @@ - -#include "clothing.hpp" - -#include - -#include - -#include "../mwworld/ptr.hpp" -#include "../mwworld/actiontake.hpp" - - -#include "containerutil.hpp" - -namespace MWClass -{ - void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); - objects.insertMesh(ptr, "meshes\\" + model); - } - } - - void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - std::string Clothing::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->name; - } - - boost::shared_ptr Clothing::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - return boost::shared_ptr ( - new MWWorld::ActionTake (ptr)); - } - - void Clothing::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.clothes); - } - - std::string Clothing::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Clothing::registerSelf() - { - boost::shared_ptr instance (new Clothing); - - registerClass (typeid (ESM::Clothing).name(), instance); - } -} diff --git a/apps/openmw/class2/clothing.hpp b/apps/openmw/class2/clothing.hpp deleted file mode 100644 index 76c2c4a3e..000000000 --- a/apps/openmw/class2/clothing.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef GAME_MWCLASS_CLOTHING_H -#define GAME_MWCLASS_CLOTHING_H - -#include "../mwworld/class.hpp" -#include "../mwrender/objects.hpp" - -namespace MWClass -{ - class Clothing : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; - ///< Generate action for activation - - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/container.cpp b/apps/openmw/class2/container.cpp deleted file mode 100644 index fff3a9bda..000000000 --- a/apps/openmw/class2/container.cpp +++ /dev/null @@ -1,80 +0,0 @@ - -#include "container.hpp" - -#include - -#include - -#include "../mwworld/ptr.hpp" - -namespace MWClass -{ - void Container::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); - objects.insertMesh(ptr, "meshes\\" + model); - } - } - - void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - std::string Container::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->name; - } - - MWWorld::ContainerStore& Container::getContainerStore (const MWWorld::Ptr& ptr) - const - { - if (!ptr.getRefData().getContainerStore().get()) - { - boost::shared_ptr > store ( - new MWWorld::ContainerStore); - - // TODO add initial content - - ptr.getRefData().getContainerStore() = store; - } - - return *ptr.getRefData().getContainerStore(); - } - - std::string Container::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Container::registerSelf() - { - boost::shared_ptr instance (new Container); - - registerClass (typeid (ESM::Container).name(), instance); - } -} diff --git a/apps/openmw/class2/container.hpp b/apps/openmw/class2/container.hpp deleted file mode 100644 index 01763870a..000000000 --- a/apps/openmw/class2/container.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef GAME_MWCLASS_CONTAINER_H -#define GAME_MWCLASS_CONTAINER_H - -#include "../mwworld/class.hpp" -#include "../mwrender/objects.hpp" - -namespace MWClass -{ - class Container : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual MWWorld::ContainerStore& getContainerStore ( - const MWWorld::Ptr& ptr) const; - ///< Return container store - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/containerutil.hpp b/apps/openmw/class2/containerutil.hpp deleted file mode 100644 index 76bdf0236..000000000 --- a/apps/openmw/class2/containerutil.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef GAME_MWCLASS_CONTAINERUTIL_H -#define GAME_MWCLASS_CONTAINERUTIL_H - -#include - -#include "../mwworld/ptr.hpp" -#include "../mwworld/containerstore.hpp" - -namespace MWClass -{ - template - void insertIntoContainerStore (const MWWorld::Ptr& ptr, - ESMS::CellRefList& containerStore) - { - if (!ptr.isEmpty()) - { - // TODO check stacking - - ESMS::LiveCellRef cellRef(ptr.getCellRef(), ptr.get()->base); - cellRef.mData = ptr.getRefData(); - - containerStore.list.push_back (cellRef); - - } - } -} - -#endif diff --git a/apps/openmw/class2/creature.cpp b/apps/openmw/class2/creature.cpp deleted file mode 100644 index 5aa203a49..000000000 --- a/apps/openmw/class2/creature.cpp +++ /dev/null @@ -1,138 +0,0 @@ - -#include "creature.hpp" - -#include - -#include "../mwmechanics/creaturestats.hpp" - -#include "../mwworld/ptr.hpp" -#include "../mwworld/actiontalk.hpp" -#include "../mwworld/environment.hpp" - - -#include "../mwmechanics/mechanicsmanager.hpp" - -namespace MWClass -{ - std::string Creature::getId (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->mId; - } - - void Creature::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - - /*ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - {*/ - MWRender::Actors& actors = renderingInterface.getActors(); - actors.insertCreature(ptr); - - } - - void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertActorPhysics(ptr, "meshes\\" + model); - } - - } - - void Creature::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const - { - environment.mMechanicsManager->addActor (ptr); - } - - void Creature::disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const - { - environment.mMechanicsManager->removeActor (ptr); - } - - std::string Creature::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->name; - } - - MWMechanics::CreatureStats& Creature::getCreatureStats (const MWWorld::Ptr& ptr) const - { - if (!ptr.getRefData().getCreatureStats().get()) - { - boost::shared_ptr stats ( - new MWMechanics::CreatureStats); - - ESMS::LiveCellRef *ref = ptr.get(); - - stats->mAttributes[0].set (ref->base->data.strength); - stats->mAttributes[1].set (ref->base->data.intelligence); - stats->mAttributes[2].set (ref->base->data.willpower); - stats->mAttributes[3].set (ref->base->data.agility); - stats->mAttributes[4].set (ref->base->data.speed); - stats->mAttributes[5].set (ref->base->data.endurance); - stats->mAttributes[6].set (ref->base->data.personality); - stats->mAttributes[7].set (ref->base->data.luck); - stats->mDynamic[0].set (ref->base->data.health); - stats->mDynamic[1].set (ref->base->data.mana); - stats->mDynamic[2].set (ref->base->data.fatigue); - - stats->mLevel = ref->base->data.level; - - ptr.getRefData().getCreatureStats() = stats; - } - - return *ptr.getRefData().getCreatureStats(); - } - - boost::shared_ptr Creature::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); - } - - MWWorld::ContainerStore& Creature::getContainerStore (const MWWorld::Ptr& ptr) - const - { - if (!ptr.getRefData().getContainerStore().get()) - { - boost::shared_ptr > store ( - new MWWorld::ContainerStore); - - // TODO add initial content - - ptr.getRefData().getContainerStore() = store; - } - - return *ptr.getRefData().getContainerStore(); - } - - std::string Creature::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Creature::registerSelf() - { - boost::shared_ptr instance (new Creature); - - registerClass (typeid (ESM::Creature).name(), instance); - } -} diff --git a/apps/openmw/class2/creature.hpp b/apps/openmw/class2/creature.hpp deleted file mode 100644 index b7b654bc0..000000000 --- a/apps/openmw/class2/creature.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef GAME_MWCLASS_CREATURE_H -#define GAME_MWCLASS_CREATURE_H - -#include "../mwworld/class.hpp" -#include "../mwrender/renderinginterface.hpp" -#include "../mwrender/actors.hpp" - - -namespace MWClass -{ - class Creature : public MWWorld::Class - { - public: - - virtual std::string getId (const MWWorld::Ptr& ptr) const; - ///< Return ID of \a ptr - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; - ///< Enable reference; only does the non-rendering part - - virtual void disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; - ///< Enable reference; only does the non-rendering part - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const; - ///< Return creature stats - - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; - ///< Generate action for activation - - virtual MWWorld::ContainerStore& getContainerStore ( - const MWWorld::Ptr& ptr) const; - ///< Return container store - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/creaturelevlist.cpp b/apps/openmw/class2/creaturelevlist.cpp deleted file mode 100644 index 53dd34bb4..000000000 --- a/apps/openmw/class2/creaturelevlist.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -#include "creaturelevlist.hpp" - -#include - -namespace MWClass -{ - std::string CreatureLevList::getName (const MWWorld::Ptr& ptr) const - { - return ""; - } - - void CreatureLevList::registerSelf() - { - boost::shared_ptr instance (new CreatureLevList); - - registerClass (typeid (ESM::CreatureLevList).name(), instance); - } -} diff --git a/apps/openmw/class2/creaturelevlist.hpp b/apps/openmw/class2/creaturelevlist.hpp deleted file mode 100644 index 81965efd5..000000000 --- a/apps/openmw/class2/creaturelevlist.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef GAME_MWCLASS_CREATURELEVLIST_H -#define GAME_MWCLASS_CREATURELEVLIST_H - -#include "../mwworld/class.hpp" - -namespace MWClass -{ - class CreatureLevList : public MWWorld::Class - { - public: - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/door.cpp b/apps/openmw/class2/door.cpp deleted file mode 100644 index baced8a9c..000000000 --- a/apps/openmw/class2/door.cpp +++ /dev/null @@ -1,129 +0,0 @@ - -#include "door.hpp" - -#include - -#include - -#include "../mwworld/player.hpp" -#include "../mwworld/ptr.hpp" -#include "../mwworld/nullaction.hpp" -#include "../mwworld/actionteleport.hpp" -#include "../mwworld/environment.hpp" -#include "../mwworld/world.hpp" - -#include "../mwrender/objects.hpp" - -#include - -namespace MWClass -{ - void Door::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); - objects.insertMesh(ptr, "meshes\\" + model); - } - } - - void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - std::string Door::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - if (ref->ref.teleport && !ref->ref.destCell.empty()) // TODO doors that lead to exteriors - return ref->ref.destCell; - - return ref->base->name; - } - - boost::shared_ptr Door::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - if (ptr.getCellRef().lockLevel>0) - { - // TODO check for key - // TODO report failure to player (message, sound?). Look up behaviour of original MW. - std::cout << "Locked!" << std::endl; - return boost::shared_ptr (new MWWorld::NullAction); - } - - // TODO check trap - - if (ref->ref.teleport) - { - // teleport door - if (environment.mWorld->getPlayer().getPlayer()==actor) - { - // the player is using the door - return boost::shared_ptr ( - new MWWorld::ActionTeleportPlayer (ref->ref.destCell, ref->ref.doorDest)); - } - else - { - // another NPC or a create is using the door - // TODO return action for teleporting other NPC/creature - return boost::shared_ptr (new MWWorld::NullAction); - } - } - else - { - // animated door - // TODO return action for rotating the door - return boost::shared_ptr (new MWWorld::NullAction); - } - } - - void Door::lock (const MWWorld::Ptr& ptr, int lockLevel) const - { - if (lockLevel<0) - lockLevel = 0; - - ptr.getCellRef().lockLevel = lockLevel; - } - - void Door::unlock (const MWWorld::Ptr& ptr) const - { - ptr.getCellRef().lockLevel = 0; - } - - std::string Door::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Door::registerSelf() - { - boost::shared_ptr instance (new Door); - - registerClass (typeid (ESM::Door).name(), instance); - } -} diff --git a/apps/openmw/class2/door.hpp b/apps/openmw/class2/door.hpp deleted file mode 100644 index c230cf357..000000000 --- a/apps/openmw/class2/door.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef GAME_MWCLASS_DOOR_H -#define GAME_MWCLASS_DOOR_H - -#include "../mwworld/class.hpp" -#include "../mwrender/objects.hpp" - -namespace MWClass -{ - class Door : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; - ///< Generate action for activation - - virtual void lock (const MWWorld::Ptr& ptr, int lockLevel) const; - ///< Lock object - - virtual void unlock (const MWWorld::Ptr& ptr) const; - ///< Unlock object - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/ingredient.cpp b/apps/openmw/class2/ingredient.cpp deleted file mode 100644 index 42e3d11e4..000000000 --- a/apps/openmw/class2/ingredient.cpp +++ /dev/null @@ -1,82 +0,0 @@ - -#include "ingredient.hpp" - -#include - -#include - -#include "../mwworld/ptr.hpp" -#include "../mwworld/actiontake.hpp" - - -#include "containerutil.hpp" - -namespace MWClass -{ - void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); - objects.insertMesh(ptr, "meshes\\" + model); - } - } - - void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - std::string Ingredient::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->name; - } - - boost::shared_ptr Ingredient::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - return boost::shared_ptr ( - new MWWorld::ActionTake (ptr)); - } - - void Ingredient::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.ingreds); - } - - std::string Ingredient::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Ingredient::registerSelf() - { - boost::shared_ptr instance (new Ingredient); - - registerClass (typeid (ESM::Ingredient).name(), instance); - } -} diff --git a/apps/openmw/class2/ingredient.hpp b/apps/openmw/class2/ingredient.hpp deleted file mode 100644 index 47bd1a9e5..000000000 --- a/apps/openmw/class2/ingredient.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef GAME_MWCLASS_INGREDIENT_H -#define GAME_MWCLASS_INGREDIENT_H - -#include "../mwworld/class.hpp" -#include "../mwrender/objects.hpp" - -namespace MWClass -{ - class Ingredient : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; - ///< Generate action for activation - - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/itemlevlist.cpp b/apps/openmw/class2/itemlevlist.cpp deleted file mode 100644 index 6ed9ab2e5..000000000 --- a/apps/openmw/class2/itemlevlist.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -#include "itemlevlist.hpp" - -#include - -namespace MWClass -{ - std::string ItemLevList::getName (const MWWorld::Ptr& ptr) const - { - return ""; - } - - void ItemLevList::registerSelf() - { - boost::shared_ptr instance (new ItemLevList); - - registerClass (typeid (ESM::ItemLevList).name(), instance); - } -} diff --git a/apps/openmw/class2/itemlevlist.hpp b/apps/openmw/class2/itemlevlist.hpp deleted file mode 100644 index 0b71b072c..000000000 --- a/apps/openmw/class2/itemlevlist.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef GAME_MWCLASS_ITEMLEVLIST_H -#define GAME_MWCLASS_ITEMLEVLIST_H - -#include "../mwworld/class.hpp" - -namespace MWClass -{ - class ItemLevList : public MWWorld::Class - { - public: - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/light.cpp b/apps/openmw/class2/light.cpp deleted file mode 100644 index a3ceea4a6..000000000 --- a/apps/openmw/class2/light.cpp +++ /dev/null @@ -1,110 +0,0 @@ - -#include "light.hpp" - -#include - -#include - -#include "../mwworld/ptr.hpp" -#include "../mwworld/actiontake.hpp" -#include "../mwworld/nullaction.hpp" -#include "../mwworld/environment.hpp" - -#include "../mwsound/soundmanager.hpp" - -#include "containerutil.hpp" - -namespace MWClass -{ - void Light::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); - objects.insertMesh(ptr, "meshes\\" + model); - const int color = ref->base->data.color; - const float r = ((color >> 0) & 0xFF) / 255.0f; - const float g = ((color >> 8) & 0xFF) / 255.0f; - const float b = ((color >> 16) & 0xFF) / 255.0f; - const float radius = float (ref->base->data.radius); - objects.insertLight (ptr, r, g, b, radius); - } - } - - void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - void Light::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - if (!ref->base->sound.empty()) - { - environment.mSoundManager->playSound3D (ptr, ref->base->sound, 1.0, 1.0, true); - } - } - - std::string Light::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - if (ref->base->model.empty()) - return ""; - - return ref->base->name; - } - - boost::shared_ptr Light::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - if (!(ref->base->data.flags & ESM::Light::Carry)) - return boost::shared_ptr (new MWWorld::NullAction); - - return boost::shared_ptr ( - new MWWorld::ActionTake (ptr)); - } - - void Light::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.lights); - } - - std::string Light::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Light::registerSelf() - { - boost::shared_ptr instance (new Light); - - registerClass (typeid (ESM::Light).name(), instance); - } -} diff --git a/apps/openmw/class2/light.hpp b/apps/openmw/class2/light.hpp deleted file mode 100644 index 34421ff51..000000000 --- a/apps/openmw/class2/light.hpp +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef GAME_MWCLASS_LIGHT_H -#define GAME_MWCLASS_LIGHT_H - -#include "../mwworld/class.hpp" -#include "../mwrender/objects.hpp" - -namespace MWClass -{ - class Light : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; - ///< Enable reference; only does the non-rendering part - /// \attention This is not the same as the script instruction with the same name. References - /// should only be enabled while in an active cell. - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; - ///< Generate action for activation - - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/lockpick.cpp b/apps/openmw/class2/lockpick.cpp deleted file mode 100644 index c07d5592c..000000000 --- a/apps/openmw/class2/lockpick.cpp +++ /dev/null @@ -1,81 +0,0 @@ - -#include "lockpick.hpp" - -#include - -#include - -#include "../mwworld/ptr.hpp" -#include "../mwworld/actiontake.hpp" - -#include "containerutil.hpp" - -namespace MWClass -{ - void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); - objects.insertMesh(ptr, "meshes\\" + model); - } - } - - void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - - std::string Lockpick::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->name; - } - - boost::shared_ptr Lockpick::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - return boost::shared_ptr ( - new MWWorld::ActionTake (ptr)); - } - - void Lockpick::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.lockpicks); - } - - std::string Lockpick::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Lockpick::registerSelf() - { - boost::shared_ptr instance (new Lockpick); - - registerClass (typeid (ESM::Tool).name(), instance); - } -} diff --git a/apps/openmw/class2/lockpick.hpp b/apps/openmw/class2/lockpick.hpp deleted file mode 100644 index c5f1539b4..000000000 --- a/apps/openmw/class2/lockpick.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef GAME_MWCLASS_LOCKPICK_H -#define GAME_MWCLASS_LOCKPICK_H - -#include "../mwworld/class.hpp" -#include "../mwrender/objects.hpp" - -namespace MWClass -{ - class Lockpick : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; - ///< Generate action for activation - - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/misc.cpp b/apps/openmw/class2/misc.cpp deleted file mode 100644 index a58142905..000000000 --- a/apps/openmw/class2/misc.cpp +++ /dev/null @@ -1,80 +0,0 @@ - -#include "misc.hpp" - -#include - -#include - -#include "../mwworld/ptr.hpp" -#include "../mwworld/actiontake.hpp" - -#include "containerutil.hpp" - -namespace MWClass -{ - void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); - objects.insertMesh(ptr, "meshes\\" + model); - } - } - - void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - std::string Miscellaneous::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->name; - } - - boost::shared_ptr Miscellaneous::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - return boost::shared_ptr ( - new MWWorld::ActionTake (ptr)); - } - - void Miscellaneous::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.miscItems); - } - - std::string Miscellaneous::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Miscellaneous::registerSelf() - { - boost::shared_ptr instance (new Miscellaneous); - - registerClass (typeid (ESM::Miscellaneous).name(), instance); - } -} diff --git a/apps/openmw/class2/misc.hpp b/apps/openmw/class2/misc.hpp deleted file mode 100644 index 36ee2c1b2..000000000 --- a/apps/openmw/class2/misc.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef GAME_MWCLASS_MISC_H -#define GAME_MWCLASS_MISC_H - -#include "../mwworld/class.hpp" -#include "../mwrender/objects.hpp" - -namespace MWClass -{ - class Miscellaneous : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; - ///< Generate action for activation - - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/npc.cpp b/apps/openmw/class2/npc.cpp deleted file mode 100644 index acb0a5a35..000000000 --- a/apps/openmw/class2/npc.cpp +++ /dev/null @@ -1,276 +0,0 @@ - -#include "npc.hpp" - -#include - -#include "../mwmechanics/creaturestats.hpp" -#include "../mwmechanics/npcstats.hpp" - -#include "../mwworld/ptr.hpp" -#include "../mwworld/actiontalk.hpp" -#include "../mwworld/environment.hpp" -#include "../mwworld/world.hpp" - -#include "../mwmechanics/mechanicsmanager.hpp" -#include - -namespace -{ - const Ogre::Radian kOgrePi (Ogre::Math::PI); - const Ogre::Radian kOgrePiOverTwo (Ogre::Math::PI / Ogre::Real(2.0)); -} - -namespace MWClass -{ - std::string Npc::getId (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->mId; - } - - void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - renderingInterface.getActors().insertNPC(ptr); - } - - void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - - - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - std::string headID = ref->base->head; - std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4); - bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_"; - - - std::string smodel = "meshes\\base_anim.nif"; - if(beast) - smodel = "meshes\\base_animkna.nif"; - physics.insertActorPhysics(ptr, smodel); - - - } - - void Npc::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const - { - environment.mMechanicsManager->addActor (ptr); - } - - void Npc::disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const - { - environment.mMechanicsManager->removeActor (ptr); - } - - std::string Npc::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->name; - } - - MWMechanics::CreatureStats& Npc::getCreatureStats (const MWWorld::Ptr& ptr) const - { - if (!ptr.getRefData().getCreatureStats().get()) - { - boost::shared_ptr stats ( - new MWMechanics::CreatureStats); - - ESMS::LiveCellRef *ref = ptr.get(); - - stats->mAttributes[0].set (ref->base->npdt52.strength); - stats->mAttributes[1].set (ref->base->npdt52.intelligence); - stats->mAttributes[2].set (ref->base->npdt52.willpower); - stats->mAttributes[3].set (ref->base->npdt52.agility); - stats->mAttributes[4].set (ref->base->npdt52.speed); - stats->mAttributes[5].set (ref->base->npdt52.endurance); - stats->mAttributes[6].set (ref->base->npdt52.personality); - stats->mAttributes[7].set (ref->base->npdt52.luck); - stats->mDynamic[0].set (ref->base->npdt52.health); - stats->mDynamic[1].set (ref->base->npdt52.mana); - stats->mDynamic[2].set (ref->base->npdt52.fatigue); - - stats->mLevel = ref->base->npdt52.level; - - ptr.getRefData().getCreatureStats() = stats; - } - - return *ptr.getRefData().getCreatureStats(); - } - - MWMechanics::NpcStats& Npc::getNpcStats (const MWWorld::Ptr& ptr) const - { - if (!ptr.getRefData().getNpcStats().get()) - { - boost::shared_ptr stats ( - new MWMechanics::NpcStats); - - ESMS::LiveCellRef *ref = ptr.get(); - - if (!ref->base->faction.empty()) - { - // TODO research how initial rank is stored. The information in loadnpc.hpp are at - // best very unclear. - stats->mFactionRank[ref->base->faction] = 0; - } - - for (int i=0; i<27; ++i) - stats->mSkill[i].setBase (ref->base->npdt52.skills[i]); - - ptr.getRefData().getNpcStats() = stats; - } - - return *ptr.getRefData().getNpcStats(); - } - - boost::shared_ptr Npc::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); - } - - MWWorld::ContainerStore& Npc::getContainerStore (const MWWorld::Ptr& ptr) - const - { - if (!ptr.getRefData().getContainerStore().get()) - { - boost::shared_ptr > store ( - new MWWorld::ContainerStore); - - // TODO add initial content - - ptr.getRefData().getContainerStore() = store; - } - - return *ptr.getRefData().getContainerStore(); - } - - std::string Npc::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Npc::setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const - { - MWMechanics::NpcStats& stats = getNpcStats (ptr); - - switch (stance) - { - case Run: - - stats.mForceRun = force; - break; - - case Sneak: - - stats.mForceSneak = force; - break; - - case Combat: - - throw std::runtime_error ("combat stance not enforcable for NPCs"); - } - } - - void Npc::setStance (const MWWorld::Ptr& ptr, Stance stance, bool set) const - { - MWMechanics::NpcStats& stats = getNpcStats (ptr); - - switch (stance) - { - case Run: - - stats.mRun = set; - break; - - case Sneak: - - stats.mSneak = set; - break; - - case Combat: - - stats.mCombat = set; - break; - } - } - - bool Npc::getStance (const MWWorld::Ptr& ptr, Stance stance, bool ignoreForce) const - { - MWMechanics::NpcStats& stats = getNpcStats (ptr); - - switch (stance) - { - case Run: - - if (!ignoreForce && stats.mForceRun) - return true; - - return stats.mRun; - - case Sneak: - - if (!ignoreForce && stats.mForceSneak) - return true; - - return stats.mSneak; - - case Combat: - - return stats.mCombat; - } - - return false; - } - - float Npc::getSpeed (const MWWorld::Ptr& ptr) const - { - return getStance (ptr, Run) ? 600 : 300; // TODO calculate these values from stats - } - - MWMechanics::Movement& Npc::getMovementSettings (const MWWorld::Ptr& ptr) const - { - if (!ptr.getRefData().getMovement().get()) - { - boost::shared_ptr movement ( - new MWMechanics::Movement); - - ptr.getRefData().getMovement() = movement; - } - - return *ptr.getRefData().getMovement(); - } - - Ogre::Vector3 Npc::getMovementVector (const MWWorld::Ptr& ptr) const - { - Ogre::Vector3 vector (0, 0, 0); - - if (ptr.getRefData().getMovement().get()) - { - vector.x = - ptr.getRefData().getMovement()->mLeftRight * 200; - vector.y = ptr.getRefData().getMovement()->mForwardBackward * 200; - - if (getStance (ptr, Run, false)) - vector *= 2; - } - - return vector; - } - - void Npc::registerSelf() - { - boost::shared_ptr instance (new Npc); - - registerClass (typeid (ESM::NPC).name(), instance); - } -} diff --git a/apps/openmw/class2/npc.hpp b/apps/openmw/class2/npc.hpp deleted file mode 100644 index cc9dbef7f..000000000 --- a/apps/openmw/class2/npc.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef GAME_MWCLASS_NPC_H -#define GAME_MWCLASS_NPC_H - -#include "../mwworld/class.hpp" - - -namespace MWClass -{ - class Npc : public MWWorld::Class - { - public: - - virtual std::string getId (const MWWorld::Ptr& ptr) const; - ///< Return ID of \a ptr - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; - ///< Enable reference; only does the non-rendering part - - virtual void disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; - ///< Enable reference; only does the non-rendering part - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const; - ///< Return creature stats - - virtual MWMechanics::NpcStats& getNpcStats (const MWWorld::Ptr& ptr) const; - ///< Return NPC stats - - virtual MWWorld::ContainerStore& getContainerStore ( - const MWWorld::Ptr& ptr) const; - ///< Return container store - - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; - ///< Generate action for activation - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - virtual void setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const; - ///< Force or unforce a stance. - - virtual void setStance (const MWWorld::Ptr& ptr, Stance stance, bool set) const; - ///< Set or unset a stance. - - virtual bool getStance (const MWWorld::Ptr& ptr, Stance stance, bool ignoreForce = false) - const; - ////< Check if a stance is active or not. - - virtual float getSpeed (const MWWorld::Ptr& ptr) const; - ///< Return movement speed. - - virtual MWMechanics::Movement& getMovementSettings (const MWWorld::Ptr& ptr) const; - ///< Return desired movement. - - virtual Ogre::Vector3 getMovementVector (const MWWorld::Ptr& ptr) const; - ///< Return desired movement vector (determined based on movement settings, - /// stance and stats). - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/potion.cpp b/apps/openmw/class2/potion.cpp deleted file mode 100644 index 0ab1c7aad..000000000 --- a/apps/openmw/class2/potion.cpp +++ /dev/null @@ -1,81 +0,0 @@ - -#include "potion.hpp" - -#include - -#include - -#include "../mwworld/ptr.hpp" -#include "../mwworld/actiontake.hpp" - - -#include "containerutil.hpp" - -namespace MWClass -{ - void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); - objects.insertMesh(ptr, "meshes\\" + model); - } - } - - void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - std::string Potion::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->name; - } - - boost::shared_ptr Potion::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - return boost::shared_ptr ( - new MWWorld::ActionTake (ptr)); - } - - void Potion::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.potions); - } - - std::string Potion::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Potion::registerSelf() - { - boost::shared_ptr instance (new Potion); - - registerClass (typeid (ESM::Potion).name(), instance); - } -} diff --git a/apps/openmw/class2/potion.hpp b/apps/openmw/class2/potion.hpp deleted file mode 100644 index 85678121f..000000000 --- a/apps/openmw/class2/potion.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef GAME_MWCLASS_POTION_H -#define GAME_MWCLASS_POTION_H - -#include "../mwworld/class.hpp" -#include "../mwrender/objects.hpp" - -namespace MWClass -{ - class Potion : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; - ///< Generate action for activation - - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/probe.cpp b/apps/openmw/class2/probe.cpp deleted file mode 100644 index 83c0e1ef4..000000000 --- a/apps/openmw/class2/probe.cpp +++ /dev/null @@ -1,81 +0,0 @@ - -#include "probe.hpp" - -#include - -#include - -#include "../mwworld/ptr.hpp" -#include "../mwworld/actiontake.hpp" - -#include "containerutil.hpp" -#include "../mwrender/objects.hpp" - -namespace MWClass -{ - void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); - objects.insertMesh(ptr, "meshes\\" + model); - } - } - - void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - - std::string Probe::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->name; - } - boost::shared_ptr Probe::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - return boost::shared_ptr ( - new MWWorld::ActionTake (ptr)); - } - - void Probe::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.probes); - } - - std::string Probe::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Probe::registerSelf() - { - boost::shared_ptr instance (new Probe); - - registerClass (typeid (ESM::Probe).name(), instance); - } -} diff --git a/apps/openmw/class2/probe.hpp b/apps/openmw/class2/probe.hpp deleted file mode 100644 index d7b9df738..000000000 --- a/apps/openmw/class2/probe.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef GAME_MWCLASS_PROBE_H -#define GAME_MWCLASS_PROBE_H - -#include "../mwworld/class.hpp" - - -namespace MWClass -{ - class Probe : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; - ///< Generate action for activation - - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/repair.cpp b/apps/openmw/class2/repair.cpp deleted file mode 100644 index feee7e988..000000000 --- a/apps/openmw/class2/repair.cpp +++ /dev/null @@ -1,80 +0,0 @@ - -#include "repair.hpp" - -#include - -#include - -#include "../mwworld/ptr.hpp" -#include "../mwworld/actiontake.hpp" - -#include "containerutil.hpp" - -namespace MWClass -{ - void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); - objects.insertMesh(ptr, "meshes\\" + model); - } - } - - void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - std::string Repair::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->name; - } - - boost::shared_ptr Repair::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - return boost::shared_ptr ( - new MWWorld::ActionTake (ptr)); - } - - void Repair::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.repairs); - } - - std::string Repair::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Repair::registerSelf() - { - boost::shared_ptr instance (new Repair); - - registerClass (typeid (ESM::Repair).name(), instance); - } -} diff --git a/apps/openmw/class2/repair.hpp b/apps/openmw/class2/repair.hpp deleted file mode 100644 index 1e0ea5178..000000000 --- a/apps/openmw/class2/repair.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef GAME_MWCLASS_REPAIR_H -#define GAME_MWCLASS_REPAIR_H - -#include "../mwworld/class.hpp" -#include "../mwrender/objects.hpp" - -namespace MWClass -{ - class Repair : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; - ///< Generate action for activation - - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/static.cpp b/apps/openmw/class2/static.cpp deleted file mode 100644 index af14bb306..000000000 --- a/apps/openmw/class2/static.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -#include "static.hpp" - -#include - -#include "../mwworld/ptr.hpp" - - -namespace MWClass -{ - void Static::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true); - objects.insertMesh(ptr, "meshes\\" + model); - } - } - - void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - std::string Static::getName (const MWWorld::Ptr& ptr) const - { - return ""; - } - - void Static::registerSelf() - { - boost::shared_ptr instance (new Static); - - registerClass (typeid (ESM::Static).name(), instance); - } -} diff --git a/apps/openmw/class2/static.hpp b/apps/openmw/class2/static.hpp deleted file mode 100644 index be3fdb180..000000000 --- a/apps/openmw/class2/static.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef GAME_MWCLASS_STATIC_H -#define GAME_MWCLASS_STATIC_H - -#include "../mwworld/class.hpp" -#include "../mwrender/objects.hpp" - -namespace MWClass -{ - class Static : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - static void registerSelf(); - }; -} - -#endif diff --git a/apps/openmw/class2/weapon.cpp b/apps/openmw/class2/weapon.cpp deleted file mode 100644 index d5f7e6853..000000000 --- a/apps/openmw/class2/weapon.cpp +++ /dev/null @@ -1,94 +0,0 @@ - -#include "weapon.hpp" - -#include - -#include - -#include "../mwworld/ptr.hpp" -#include "../mwworld/actiontake.hpp" - - -#include "containerutil.hpp" - -namespace MWClass -{ - void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Objects& objects = renderingInterface.getObjects(); - objects.insertBegin(ptr, ptr.getRefData().isEnabled(),true); - objects.insertMesh(ptr, "meshes\\" + model); - } - } - - void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - - const std::string &model = ref->base->model; - assert (ref->base != NULL); - if(!model.empty()){ - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - - } - - std::string Weapon::getName (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->name; - } - - boost::shared_ptr Weapon::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - return boost::shared_ptr ( - new MWWorld::ActionTake (ptr)); - } - - bool Weapon::hasItemHealth (const MWWorld::Ptr& ptr) const - { - return true; - } - - int Weapon::getItemMaxHealth (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->data.health; - } - - void Weapon::insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const - { - insertIntoContainerStore (ptr, containerStore.weapons); - } - - std::string Weapon::getScript (const MWWorld::Ptr& ptr) const - { - ESMS::LiveCellRef *ref = - ptr.get(); - - return ref->base->script; - } - - void Weapon::registerSelf() - { - boost::shared_ptr instance (new Weapon); - - registerClass (typeid (ESM::Weapon).name(), instance); - } -} diff --git a/apps/openmw/class2/weapon.hpp b/apps/openmw/class2/weapon.hpp deleted file mode 100644 index 79bc4d4de..000000000 --- a/apps/openmw/class2/weapon.hpp +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef GAME_MWCLASS_WEAPON_H -#define GAME_MWCLASS_WEAPON_H - -#include "../mwworld/class.hpp" -#include "../mwrender/objects.hpp" - -namespace MWClass -{ - class Weapon : public MWWorld::Class - { - public: - - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - ///< Add reference into a cell for rendering - - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; - - virtual std::string getName (const MWWorld::Ptr& ptr) const; - ///< \return name (the one that is to be presented to the user; not the internal one); - /// can return an empty string. - - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; - ///< Generate action for activation - - virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const; - ///< \return Item health data available? - - virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const; - ///< Return item max health or throw an exception, if class does not have item health - - virtual void insertIntoContainer (const MWWorld::Ptr& ptr, - MWWorld::ContainerStore& containerStore) const; - ///< Insert into a containe - - virtual std::string getScript (const MWWorld::Ptr& ptr) const; - ///< Return name of the script attached to ptr - - static void registerSelf(); - }; -} - -#endif From 7e1e746201cb60546b950860140f0b94b8966f17 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sun, 19 Feb 2012 17:59:50 -0500 Subject: [PATCH 28/30] More changes --- apps/openmw/mwrender/animation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 4013d69fe..c9078cb9c 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -216,7 +216,7 @@ namespace MWRender{ - for(int i = 1; i < inds.size(); i++){ + for(std::size_t i = 1; i < inds.size(); i++){ boneinfocopy = &(allshapesiter->boneinfo[inds[i].boneinfocopyindex]); result = vecRotPos.find(boneinfocopy); From 7eae24bb45b5d595e98fcf3ef16be421103b149c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 20 Feb 2012 14:02:24 +0100 Subject: [PATCH 29/30] some fixes --- apps/openmw/mwrender/animation.cpp | 133 ++++++++++++++--------------- 1 file changed, 66 insertions(+), 67 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index c9078cb9c..63855f3b8 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -18,7 +18,7 @@ namespace MWRender{ mUniqueIDs[copy] = mUniqueIDs[copy] + 1; counter = mUniqueIDs[copy]; } - + std::stringstream out; if(counter > 99 && counter < 1000) out << "0"; @@ -38,7 +38,7 @@ namespace MWRender{ time = startTime; } else if(textmappings){ - + std::string startName = groupname + ": loop start"; std::string stopName = groupname + ": loop stop"; @@ -49,7 +49,7 @@ namespace MWRender{ stopName = groupname + ": loop stop"; for(std::map::iterator iter = textmappings->begin(); iter != textmappings->end(); iter++){ - + std::string current = iter->first.substr(0, startName.size()); std::transform(current.begin(), current.end(), current.begin(), ::tolower); std::string current2 = iter->first.substr(0, stopName.size()); @@ -71,9 +71,9 @@ namespace MWRender{ if(!first){ startName = groupname + ": start"; stopName = groupname + ": stop"; - + for(std::map::iterator iter = textmappings->begin(); iter != textmappings->end(); iter++){ - + std::string current = iter->first.substr(0, startName.size()); std::transform(current.begin(), current.end(), current.begin(), ::tolower); std::string current2 = iter->first.substr(0, stopName.size()); @@ -92,24 +92,23 @@ namespace MWRender{ } } } - + } - + } void Animation::stopScript(){ animate = 0; } void Animation::handleShapes(std::vector* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel){ - bool useHandles = false; shapeNumber = 0; - + std::vector::iterator allshapesiter; for(allshapesiter = allshapes->begin(); allshapesiter != allshapes->end(); allshapesiter++) - + { //std::map vecPosRot; - + Nif::NiTriShapeCopy& copy = *allshapesiter; std::vector* allvertices = ©.vertices; std::vector* allnormals = ©.normals; @@ -119,12 +118,12 @@ namespace MWRender{ //std::set vertices; //std::set normals; //std::vector boneinfovector = copy.boneinfo; - std::map>* verticesToChange = ©.vertsToWeights; - + std::map >* verticesToChange = ©.vertsToWeights; + //std::cout << "Name " << copy.sname << "\n"; Ogre::HardwareVertexBufferSharedPtr vbuf = creaturemodel->getMesh()->getSubMesh(copy.sname)->vertexData->vertexBufferBinding->getBuffer(0); Ogre::Real* pReal = static_cast(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL)); - + std::vector initialVertices = copy.morph.getInitialVertices(); //Each shape has multiple indices @@ -134,7 +133,7 @@ namespace MWRender{ if(copy.vertices.size() == initialVertices.size()) { //Create if it doesn't already exist - if(shapeIndexI.size() == shapeNumber) + if(shapeIndexI.size() == static_cast (shapeNumber)) { std::vector vec; shapeIndexI.push_back(vec); @@ -164,10 +163,10 @@ namespace MWRender{ } - + } - + allvertices = &initialVertices; } shapeNumber++; @@ -176,8 +175,8 @@ namespace MWRender{ if(verticesToChange->size() > 0){ - - for(std::map>::iterator iter = verticesToChange->begin(); + + for(std::map >::iterator iter = verticesToChange->begin(); iter != verticesToChange->end(); iter++) { std::vector inds = iter->second; @@ -186,25 +185,25 @@ namespace MWRender{ Ogre::Vector3 currentNormal = (*allnormals)[verIndex]; Nif::NiSkinData::BoneInfoCopy* boneinfocopy = &(allshapesiter->boneinfo[inds[0].boneinfocopyindex]); Ogre::Bone *bonePtr = 0; - - - + + + Ogre::Vector3 vecPos; - Ogre::Quaternion vecRot; + Ogre::Quaternion vecRot; std::map::iterator result = vecRotPos.find(boneinfocopy); - + if(result == vecRotPos.end()){ bonePtr = skel->getBone(boneinfocopy->bonename); - + vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans; vecRot = bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation; - - + + PosAndRot both; both.vecPos = vecPos; both.vecRot = vecRot; vecRotPos[boneinfocopy] = both; - + } else{ PosAndRot both = result->second; @@ -213,24 +212,24 @@ namespace MWRender{ } Ogre::Vector3 absVertPos = (vecPos + vecRot * currentVertex) * inds[0].weight; - - + + for(std::size_t i = 1; i < inds.size(); i++){ boneinfocopy = &(allshapesiter->boneinfo[inds[i].boneinfocopyindex]); result = vecRotPos.find(boneinfocopy); - + if(result == vecRotPos.end()){ bonePtr = skel->getBone(boneinfocopy->bonename); vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans; vecRot = bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation; - + PosAndRot both; both.vecPos = vecPos; both.vecRot = vecRot; vecRotPos[boneinfocopy] = both; - + } else{ PosAndRot both = result->second; @@ -238,22 +237,22 @@ namespace MWRender{ vecRot = both.vecRot; } - + absVertPos += (vecPos + vecRot * currentVertex) * inds[i].weight; - - + + } Ogre::Real* addr = (pReal + 3 * verIndex); *addr = absVertPos.x; *(addr+1) = absVertPos.y; *(addr+2) = absVertPos.z; - + } - - - - - } + + + + + } else { //Ogre::Bone *bonePtr = creaturemodel->getSkeleton()->getBone(copy.bonename); @@ -261,7 +260,7 @@ namespace MWRender{ Ogre::Vector3 shapetrans = copy.trafo.trans; float shapescale = copy.trafo.scale; std::vector boneSequence = copy.boneSequence; - + Ogre::Vector3 transmult; Ogre::Quaternion rotmult; float scale; @@ -269,9 +268,9 @@ namespace MWRender{ std::vector::iterator boneSequenceIter = boneSequence.begin(); if(skel->hasBone(*boneSequenceIter)){ Ogre::Bone *bonePtr = skel->getBone(*boneSequenceIter); - - - + + + transmult = bonePtr->getPosition(); rotmult = bonePtr->getOrientation(); @@ -301,13 +300,13 @@ namespace MWRender{ rotmult = shaperot; scale = shapescale; } - - - + + + // Computes C = B + AxC*scale // final_vector = old_vector + old_rotation*new_vector*old_scale/ - + for(unsigned int i = 0; i < allvertices->size(); i++){ Ogre::Vector3 current = transmult + rotmult * (*allvertices)[i]; Ogre::Real* addr = pReal + i * 3; @@ -327,7 +326,7 @@ namespace MWRender{ } vbuf->unlock(); - + } } @@ -347,10 +346,10 @@ namespace MWRender{ x = 0.0; return true; } - + if ( i < 0 || i >= count ) i = 0; - + float tI = times[i]; if ( time > tI ) { @@ -390,11 +389,11 @@ namespace MWRender{ void Animation::handleAnimationTransforms(){ Ogre::SkeletonInstance* skel = base->getSkeleton(); - + Ogre::Bone* b = skel->getRootBone(); b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3)); //This is a trick - + skel->_updateTransforms(); //skel->_notifyManualBonesDirty(); @@ -419,17 +418,17 @@ namespace MWRender{ if(time < iter->getStartTime() || time < startTime || time > iter->getStopTime()) { slot++; - continue; + continue; } float x; float x2; - + std::vector quats = iter->getQuat(); std::vector ttime = iter->gettTime(); std::vector::iterator ttimeiter = ttime.begin(); - + std::vector rtime = iter->getrTime(); int rindexJ = 0; timeIndex(time, rtime, rindexI[slot], rindexJ, x2); @@ -442,15 +441,15 @@ namespace MWRender{ Ogre::Vector3 t; Ogre::Quaternion r; - + bool bTrans = translist1.size() > 0; if(bTrans){ Ogre::Vector3 v1 = translist1[tindexI[slot]]; Ogre::Vector3 v2 = translist1[tindexJ]; t = (v1 + (v2 - v1) * x); - + } - + bool bQuats = quats.size() > 0; if(bQuats){ r = Ogre::Quaternion::Slerp(x2, quats[rindexI[slot]], quats[rindexJ], true); @@ -463,16 +462,16 @@ namespace MWRender{ if(bQuats) bone->setOrientation(r); - - + + skel->_updateTransforms(); base->getAllAnimationStates()->_notifyDirty(); - - } - + + } + slot++; } } } -} \ No newline at end of file +} From 781b16a00e9e1571fd955c50eda070e2dfa4eb39 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 20 Feb 2012 14:07:16 +0100 Subject: [PATCH 30/30] removed bCollision variable from World --- apps/openmw/mwworld/world.cpp | 5 ++--- apps/openmw/mwworld/world.hpp | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 73439ff64..c9e177566 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -148,7 +148,7 @@ namespace MWWorld const std::string& master, const boost::filesystem::path& resDir, bool newGame, Environment& environment, const std::string& encoding) : mRendering (renderer,resDir, physEng, environment),mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0), - mSky (false), bCollision(false), mEnvironment (environment), mNextDynamicRecord (0), mCells (mStore, mEsm, *this) + mSky (false), mEnvironment (environment), mNextDynamicRecord (0), mCells (mStore, mEsm, *this) { mPhysEngine = physEng; @@ -612,8 +612,7 @@ namespace MWWorld bool World::toggleCollisionMode() { - bCollision = mPhysics->toggleCollisionMode(); - return bCollision; + return mPhysics->toggleCollisionMode();; } bool World::toggleRenderMode (RenderMode mode) diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index b4c61eebb..59cddb1c1 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -77,7 +77,6 @@ namespace MWWorld bool mSky; Environment& mEnvironment; int mNextDynamicRecord; - bool bCollision; Cells mCells;