mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 02:53:51 +00:00
Use a method to set the visibility flags and render queue.
This commit is contained in:
parent
434f3ac8c8
commit
50bb92beb3
5 changed files with 35 additions and 63 deletions
|
@ -1,10 +1,5 @@
|
||||||
#include "activatoranimation.hpp"
|
#include "activatoranimation.hpp"
|
||||||
|
|
||||||
#include <OgreEntity.h>
|
|
||||||
#include <OgreParticleSystem.h>
|
|
||||||
#include <OgreSceneManager.h>
|
|
||||||
#include <OgreSubEntity.h>
|
|
||||||
|
|
||||||
#include "renderconst.hpp"
|
#include "renderconst.hpp"
|
||||||
|
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
@ -27,24 +22,7 @@ ActivatorAnimation::ActivatorAnimation(const MWWorld::Ptr &ptr)
|
||||||
const std::string name = "meshes\\"+ref->mBase->mModel;
|
const std::string name = "meshes\\"+ref->mBase->mModel;
|
||||||
|
|
||||||
addObjectList(mPtr.getRefData().getBaseNode(), name, false);
|
addObjectList(mPtr.getRefData().getBaseNode(), name, false);
|
||||||
const NifOgre::ObjectList &objlist = mObjectLists.back();
|
setRenderProperties(mObjectLists.back(), RV_Misc, RQG_Main, RQG_Alpha);
|
||||||
for(size_t i = 0;i < objlist.mEntities.size();i++)
|
|
||||||
{
|
|
||||||
Ogre::Entity *ent = objlist.mEntities[i];
|
|
||||||
ent->setVisibilityFlags(RV_Misc);
|
|
||||||
|
|
||||||
for(unsigned int j=0; j < ent->getNumSubEntities(); ++j)
|
|
||||||
{
|
|
||||||
Ogre::SubEntity* subEnt = ent->getSubEntity(j);
|
|
||||||
subEnt->setRenderQueueGroup(subEnt->getMaterial()->isTransparent() ? RQG_Alpha : RQG_Main);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(size_t i = 0;i < objlist.mParticles.size();i++)
|
|
||||||
{
|
|
||||||
Ogre::ParticleSystem *part = objlist.mParticles[i];
|
|
||||||
part->setVisibilityFlags(RV_Misc);
|
|
||||||
part->setRenderQueueGroup(RQG_Alpha);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include <OgreSkeletonManager.h>
|
#include <OgreSkeletonManager.h>
|
||||||
#include <OgreSkeletonInstance.h>
|
#include <OgreSkeletonInstance.h>
|
||||||
#include <OgreEntity.h>
|
#include <OgreEntity.h>
|
||||||
|
#include <OgreSubEntity.h>
|
||||||
|
#include <OgreParticleSystem.h>
|
||||||
#include <OgreBone.h>
|
#include <OgreBone.h>
|
||||||
#include <OgreSubMesh.h>
|
#include <OgreSubMesh.h>
|
||||||
#include <OgreSceneManager.h>
|
#include <OgreSceneManager.h>
|
||||||
|
@ -150,6 +152,30 @@ void Animation::addObjectList(Ogre::SceneNode *node, const std::string &model, b
|
||||||
mCurrentControllers = &objlist.mControllers;
|
mCurrentControllers = &objlist.mControllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Animation::setRenderProperties(const NifOgre::ObjectList &objlist, Ogre::uint32 visflags, Ogre::uint8 solidqueue, Ogre::uint8 transqueue)
|
||||||
|
{
|
||||||
|
for(size_t i = 0;i < objlist.mEntities.size();i++)
|
||||||
|
{
|
||||||
|
Ogre::Entity *ent = objlist.mEntities[i];
|
||||||
|
if(visflags != 0)
|
||||||
|
ent->setVisibilityFlags(visflags);
|
||||||
|
|
||||||
|
for(unsigned int j = 0;j < ent->getNumSubEntities();++j)
|
||||||
|
{
|
||||||
|
Ogre::SubEntity* subEnt = ent->getSubEntity(j);
|
||||||
|
subEnt->setRenderQueueGroup(subEnt->getMaterial()->isTransparent() ? transqueue : solidqueue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(size_t i = 0;i < objlist.mParticles.size();i++)
|
||||||
|
{
|
||||||
|
Ogre::ParticleSystem *part = objlist.mParticles[i];
|
||||||
|
if(visflags != 0)
|
||||||
|
part->setVisibilityFlags(visflags);
|
||||||
|
// TODO: Check particle material for actual transparency
|
||||||
|
part->setRenderQueueGroup(transqueue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Ogre::Node *Animation::getNode(const std::string &name)
|
Ogre::Node *Animation::getNode(const std::string &name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,6 +85,8 @@ protected:
|
||||||
void addObjectList(Ogre::SceneNode *node, const std::string &model, bool baseonly);
|
void addObjectList(Ogre::SceneNode *node, const std::string &model, bool baseonly);
|
||||||
static void destroyObjectList(Ogre::SceneManager *sceneMgr, NifOgre::ObjectList &objects);
|
static void destroyObjectList(Ogre::SceneManager *sceneMgr, NifOgre::ObjectList &objects);
|
||||||
|
|
||||||
|
static void setRenderProperties(const NifOgre::ObjectList &objlist, Ogre::uint32 visflags, Ogre::uint8 solidqueue, Ogre::uint8 transqueue);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Animation(const MWWorld::Ptr &ptr);
|
Animation(const MWWorld::Ptr &ptr);
|
||||||
virtual ~Animation();
|
virtual ~Animation();
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
#include "creatureanimation.hpp"
|
#include "creatureanimation.hpp"
|
||||||
|
|
||||||
#include <OgreEntity.h>
|
|
||||||
#include <OgreParticleSystem.h>
|
|
||||||
#include <OgreSceneManager.h>
|
|
||||||
#include <OgreSubEntity.h>
|
|
||||||
|
|
||||||
#include "renderconst.hpp"
|
#include "renderconst.hpp"
|
||||||
|
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
@ -30,25 +25,7 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr &ptr)
|
||||||
addObjectList(mPtr.getRefData().getBaseNode(), "meshes\\base_anim.nif", true);
|
addObjectList(mPtr.getRefData().getBaseNode(), "meshes\\base_anim.nif", true);
|
||||||
|
|
||||||
addObjectList(mPtr.getRefData().getBaseNode(), model, false);
|
addObjectList(mPtr.getRefData().getBaseNode(), model, false);
|
||||||
|
setRenderProperties(mObjectLists.back(), RV_Actors, RQG_Main, RQG_Alpha);
|
||||||
const NifOgre::ObjectList &objlist = mObjectLists.back();
|
|
||||||
for(size_t i = 0;i < objlist.mEntities.size();i++)
|
|
||||||
{
|
|
||||||
Ogre::Entity *ent = objlist.mEntities[i];
|
|
||||||
ent->setVisibilityFlags(RV_Actors);
|
|
||||||
|
|
||||||
for(unsigned int j=0; j < ent->getNumSubEntities(); ++j)
|
|
||||||
{
|
|
||||||
Ogre::SubEntity* subEnt = ent->getSubEntity(j);
|
|
||||||
subEnt->setRenderQueueGroup(subEnt->getMaterial()->isTransparent() ? RQG_Alpha : RQG_Main);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(size_t i = 0;i < objlist.mParticles.size();i++)
|
|
||||||
{
|
|
||||||
Ogre::ParticleSystem *part = objlist.mParticles[i];
|
|
||||||
part->setVisibilityFlags(RV_Actors);
|
|
||||||
part->setRenderQueueGroup(RQG_Alpha);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -361,25 +361,13 @@ void NpcAnimation::updateParts(bool forceupdate)
|
||||||
NifOgre::ObjectList NpcAnimation::insertBoundedPart(const std::string &model, int group, const std::string &bonename)
|
NifOgre::ObjectList NpcAnimation::insertBoundedPart(const std::string &model, int group, const std::string &bonename)
|
||||||
{
|
{
|
||||||
NifOgre::ObjectList objects = NifOgre::Loader::createObjects(mSkelBase, bonename, mInsert, model);
|
NifOgre::ObjectList objects = NifOgre::Loader::createObjects(mSkelBase, bonename, mInsert, model);
|
||||||
for(size_t i = 0;i < objects.mEntities.size();i++)
|
setRenderProperties(objects, mVisibilityFlags, RQG_Main, RQG_Alpha);
|
||||||
{
|
|
||||||
objects.mEntities[i]->getUserObjectBindings().setUserAny(Ogre::Any(group));
|
|
||||||
if(mVisibilityFlags != 0)
|
|
||||||
objects.mEntities[i]->setVisibilityFlags(mVisibilityFlags);
|
|
||||||
|
|
||||||
for(unsigned int j=0; j < objects.mEntities[i]->getNumSubEntities(); ++j)
|
for(size_t i = 0;i < objects.mEntities.size();i++)
|
||||||
{
|
objects.mEntities[i]->getUserObjectBindings().setUserAny(Ogre::Any(group));
|
||||||
Ogre::SubEntity* subEnt = objects.mEntities[i]->getSubEntity(j);
|
|
||||||
subEnt->setRenderQueueGroup(subEnt->getMaterial()->isTransparent() ? RQG_Alpha : RQG_Main);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(size_t i = 0;i < objects.mParticles.size();i++)
|
for(size_t i = 0;i < objects.mParticles.size();i++)
|
||||||
{
|
|
||||||
objects.mParticles[i]->getUserObjectBindings().setUserAny(Ogre::Any(group));
|
objects.mParticles[i]->getUserObjectBindings().setUserAny(Ogre::Any(group));
|
||||||
if(mVisibilityFlags != 0)
|
|
||||||
objects.mParticles[i]->setVisibilityFlags(mVisibilityFlags);
|
|
||||||
objects.mParticles[i]->setRenderQueueGroup(RQG_Alpha);
|
|
||||||
}
|
|
||||||
if(objects.mSkelBase)
|
if(objects.mSkelBase)
|
||||||
{
|
{
|
||||||
Ogre::AnimationStateSet *aset = objects.mSkelBase->getAllAnimationStates();
|
Ogre::AnimationStateSet *aset = objects.mSkelBase->getAllAnimationStates();
|
||||||
|
@ -395,6 +383,7 @@ NifOgre::ObjectList NpcAnimation::insertBoundedPart(const std::string &model, in
|
||||||
while(boneiter.hasMoreElements())
|
while(boneiter.hasMoreElements())
|
||||||
boneiter.getNext()->setManuallyControlled(true);
|
boneiter.getNext()->setManuallyControlled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return objects;
|
return objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue