mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 02:19:41 +00:00
Player rendering
This commit is contained in:
parent
b0804734e5
commit
bd8f0248f0
6 changed files with 53 additions and 18 deletions
|
@ -1318,6 +1318,8 @@ namespace MWMechanics
|
|||
|
||||
bool MechanicsManager::awarenessCheck(const MWWorld::Ptr &ptr, const MWWorld::Ptr &observer)
|
||||
{
|
||||
return false;
|
||||
|
||||
if (observer.getClass().getCreatureStats(observer).isDead() || !observer.getRefData().isEnabled())
|
||||
return false;
|
||||
|
||||
|
|
|
@ -866,6 +866,8 @@ namespace MWRender
|
|||
NodeMapVisitor visitor;
|
||||
mObjectRoot->accept(visitor);
|
||||
mNodeMap = visitor.getNodeMap();
|
||||
|
||||
mObjectRoot->addCullCallback(new SceneUtil::LightListCallback);
|
||||
}
|
||||
|
||||
osg::Group* Animation::getObjectRoot()
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
#include <osgParticle/ParticleSystem>
|
||||
#include <osgParticle/ParticleProcessor>
|
||||
|
||||
// light
|
||||
#include <components/sceneutil/lightmanager.hpp>
|
||||
|
||||
#include <components/resource/scenemanager.hpp>
|
||||
|
||||
#include <components/sceneutil/visitor.hpp>
|
||||
|
@ -112,9 +109,6 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh, bool
|
|||
|
||||
std::auto_ptr<ObjectAnimation> anim (new ObjectAnimation(ptr, mesh, mResourceSystem, allowLight));
|
||||
|
||||
if (anim->getObjectRoot())
|
||||
anim->getObjectRoot()->addCullCallback(new SceneUtil::LightListCallback);
|
||||
|
||||
if (!allowLight)
|
||||
{
|
||||
RemoveParticlesVisitor visitor;
|
||||
|
@ -137,9 +131,6 @@ void Objects::insertCreature(const MWWorld::Ptr &ptr, const std::string &mesh, b
|
|||
else
|
||||
anim.reset(new CreatureAnimation(ptr, mesh, mResourceSystem));
|
||||
|
||||
if (anim->getObjectRoot())
|
||||
anim->getObjectRoot()->addCullCallback(new SceneUtil::LightListCallback);
|
||||
|
||||
mObjects.insert(std::make_pair(ptr, anim.release()));
|
||||
}
|
||||
|
||||
|
@ -149,9 +140,6 @@ void Objects::insertNPC(const MWWorld::Ptr &ptr)
|
|||
|
||||
std::auto_ptr<NpcAnimation> anim (new NpcAnimation(ptr, osg::ref_ptr<osg::Group>(ptr.getRefData().getBaseNode()), mResourceSystem, 0));
|
||||
|
||||
if (anim->getObjectRoot())
|
||||
anim->getObjectRoot()->addCullCallback(new SceneUtil::LightListCallback);
|
||||
|
||||
mObjects.insert(std::make_pair(ptr, anim.release()));
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "sky.hpp"
|
||||
#include "effectmanager.hpp"
|
||||
#include "npcanimation.hpp"
|
||||
#include "vismask.hpp"
|
||||
|
||||
namespace MWRender
|
||||
|
@ -82,6 +83,7 @@ namespace MWRender
|
|||
, mResourceSystem(resourceSystem)
|
||||
{
|
||||
osg::ref_ptr<SceneUtil::LightManager> lightRoot = new SceneUtil::LightManager;
|
||||
mLightRoot = lightRoot;
|
||||
lightRoot->setStartLight(1);
|
||||
|
||||
mRootNode->addChild(lightRoot);
|
||||
|
@ -258,4 +260,31 @@ namespace MWRender
|
|||
return mObjects->getAnimation(ptr);
|
||||
}
|
||||
|
||||
MWRender::Animation* RenderingManager::getPlayerAnimation()
|
||||
{
|
||||
return mPlayerAnimation.get();
|
||||
}
|
||||
|
||||
void RenderingManager::setupPlayer(const MWWorld::Ptr &player)
|
||||
{
|
||||
if (!mPlayerNode)
|
||||
{
|
||||
mPlayerNode = new osg::PositionAttitudeTransform;
|
||||
mLightRoot->addChild(mPlayerNode);
|
||||
}
|
||||
|
||||
player.getRefData().setBaseNode(mPlayerNode);
|
||||
|
||||
//attachCameraTo(player);
|
||||
}
|
||||
|
||||
void RenderingManager::renderPlayer(const MWWorld::Ptr &player)
|
||||
{
|
||||
mPlayerAnimation.reset(new NpcAnimation(player, player.getRefData().getBaseNode(), mResourceSystem, 0));
|
||||
|
||||
//mCamera->setAnimation(mPlayerAnimation);
|
||||
//mWater->removeEmitter(ptr);
|
||||
//mWater->addEmitter(ptr);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
namespace osg
|
||||
{
|
||||
class Group;
|
||||
class PositionAttitudeTransform;
|
||||
}
|
||||
|
||||
namespace Resource
|
||||
|
@ -35,6 +36,7 @@ namespace MWRender
|
|||
|
||||
class EffectManager;
|
||||
class SkyManager;
|
||||
class NpcAnimation;
|
||||
|
||||
class RenderingManager : public MWRender::RenderingInterface
|
||||
{
|
||||
|
@ -78,11 +80,16 @@ namespace MWRender
|
|||
|
||||
void update(float dt, bool paused);
|
||||
|
||||
MWRender::Animation* getAnimation(const MWWorld::Ptr& ptr);
|
||||
Animation* getAnimation(const MWWorld::Ptr& ptr);
|
||||
Animation* getPlayerAnimation();
|
||||
|
||||
void setupPlayer(const MWWorld::Ptr& player);
|
||||
void renderPlayer(const MWWorld::Ptr& player);
|
||||
|
||||
private:
|
||||
osgViewer::Viewer& mViewer;
|
||||
osg::ref_ptr<osg::Group> mRootNode;
|
||||
osg::ref_ptr<osg::Group> mLightRoot;
|
||||
Resource::ResourceSystem* mResourceSystem;
|
||||
|
||||
osg::ref_ptr<osg::Light> mSunLight;
|
||||
|
@ -90,6 +97,8 @@ namespace MWRender
|
|||
std::auto_ptr<Objects> mObjects;
|
||||
std::auto_ptr<SkyManager> mSky;
|
||||
std::auto_ptr<EffectManager> mEffectManager;
|
||||
std::auto_ptr<NpcAnimation> mPlayerAnimation;
|
||||
osg::ref_ptr<osg::PositionAttitudeTransform> mPlayerNode;
|
||||
|
||||
osg::ref_ptr<StateUpdater> mStateUpdater;
|
||||
|
||||
|
|
|
@ -1563,7 +1563,8 @@ namespace MWWorld
|
|||
}
|
||||
const ESM::NPC *ret = mStore.insert(record);
|
||||
if (update) {
|
||||
//mRendering->renderPlayer(mPlayer->getPlayer());
|
||||
mRendering->renderPlayer(getPlayerPtr());
|
||||
scaleObject(getPlayerPtr(), 1.f); // apply race height
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -2120,18 +2121,20 @@ namespace MWWorld
|
|||
mPlayer->set(player);
|
||||
}
|
||||
|
||||
//Ptr ptr = mPlayer->getPlayer();
|
||||
//mRendering->setupPlayer(ptr);
|
||||
Ptr ptr = mPlayer->getPlayer();
|
||||
mRendering->setupPlayer(ptr);
|
||||
}
|
||||
|
||||
void World::renderPlayer()
|
||||
{
|
||||
//mRendering->renderPlayer(mPlayer->getPlayer());
|
||||
mRendering->renderPlayer(getPlayerPtr());
|
||||
|
||||
scaleObject(getPlayerPtr(), 1.f); // apply race height
|
||||
|
||||
// At this point the Animation object is live, and the CharacterController associated with it must be created.
|
||||
// It has to be done at this point: resetCamera below does animation->setViewMode -> CharacterController::forceStateUpdate
|
||||
// so we should make sure not to use a "stale" controller for that.
|
||||
MWBase::Environment::get().getMechanicsManager()->add(mPlayer->getPlayer());
|
||||
MWBase::Environment::get().getMechanicsManager()->add(getPlayerPtr());
|
||||
|
||||
std::string model = getPlayerPtr().getClass().getModel(getPlayerPtr());
|
||||
//model = Misc::ResourceHelpers::correctActorModelPath(model);
|
||||
|
@ -2163,6 +2166,8 @@ namespace MWWorld
|
|||
|
||||
MWRender::Animation* World::getAnimation(const MWWorld::Ptr &ptr)
|
||||
{
|
||||
if (ptr == getPlayerPtr())
|
||||
return mRendering->getPlayerAnimation();
|
||||
return mRendering->getAnimation(ptr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue