added visibility flags for everything

actorid
scrawl 13 years ago
parent fd45208196
commit 8aea311797

@ -1,4 +1,5 @@
#include "creatureanimation.hpp"
#include "renderconst.hpp"
#include "../mwworld/world.hpp"
@ -20,6 +21,7 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environme
std::string meshNumbered = mesh + getUniqueID(mesh) + ">|";
NifOgre::NIFLoader::load(meshNumbered);
base = mRend.getScene()->createEntity(meshNumbered);
base->setVisibilityFlags(RV_Actors);
std::string meshZero = mesh + "0000>|";
if((transformations = (NIFLoader::getSingletonPtr())->getAnim(meshZero))){

@ -4,6 +4,7 @@
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "renderconst.hpp"
#include <OgreOverlayManager.h>
#include <OgreMaterialManager.h>
@ -211,7 +212,7 @@ void LocalMap::render(const float x, const float y,
vp->setOverlaysEnabled(false);
vp->setShadowsEnabled(false);
vp->setBackgroundColour(ColourValue(0, 0, 0));
//vp->setVisibilityMask( ... );
vp->setVisibilityMask(RV_Map);
rtt->update();

@ -1,5 +1,6 @@
#include "npcanimation.hpp"
#include "../mwworld/world.hpp"
#include "renderconst.hpp"
using namespace Ogre;
@ -65,6 +66,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
NifOgre::NIFLoader::load(smodel);
base = mRend.getScene()->createEntity(smodel);
base->setVisibilityFlags(RV_Actors);
base->setSkipAnimationStateUpdate(true); //Magical line of code, this makes the bones
//stay in the same place when we skipanim, or open a gui window

@ -4,6 +4,7 @@
#include <components/nifogre/ogre_nif_loader.hpp>
#include <components/settings/settings.hpp>
#include "renderconst.hpp"
using namespace MWRender;
@ -116,7 +117,8 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh)
{
insert->attachObject(ent);
ent->setRenderingDistance(small ? Settings::Manager::getInt("small object distance", "Viewing distance") : 0); /// \todo config value
ent->setRenderingDistance(small ? Settings::Manager::getInt("small object distance", "Viewing distance") : 0);
ent->setVisibilityFlags(mIsStatic ? (small ? RV_StaticsSmall : RV_Statics) : RV_Misc);
}
else
{
@ -158,6 +160,8 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh)
sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale());
sg->setVisibilityFlags(small ? RV_StaticsSmall : RV_Statics);
mRenderer.getScene()->destroyEntity(ent);
}
}

@ -0,0 +1,44 @@
#ifndef GAME_RENDER_CONST_H
#define GAME_RENDER_CONST_H
#include <OgreRenderQueue.h>
namespace MWRender
{
// Render queue groups
/// \todo
// Visibility flags
enum VisibilityFlags
{
// Terrain
RV_Terrain = 1,
// Statics (e.g. trees, houses)
RV_Statics = 2,
// Small statics
RV_StaticsSmall = 4,
// Water
RV_Water = 8,
// Actors (player, npcs, creatures)
RV_Actors = 16,
// Misc objects (containers, dynamic objects)
RV_Misc = 32,
RV_Sky = 64,
RV_Map = RV_Terrain + RV_Statics + RV_StaticsSmall + RV_Misc + RV_Water,
/// \todo markers (normally hidden)
RV_All = 255
};
}
#endif

@ -112,8 +112,7 @@ void RenderingManager::removeCell (MWWorld::Ptr::CellStore *store)
void RenderingManager::removeWater ()
{
if(mWater){
delete mWater;
mWater = 0;
mWater->setActive(false);
}
}
@ -188,8 +187,7 @@ void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store){
mWater = new MWRender::Water(mRendering.getCamera(), store->cell);
else
mWater->changeCell(store->cell);
//else
mWater->setActive(true);
}
else
removeWater();

@ -12,7 +12,7 @@
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "occlusionquery.hpp"
#include "renderconst.hpp"
using namespace MWRender;
using namespace Ogre;
@ -92,6 +92,7 @@ void BillboardObject::init(const String& textureName,
mBBSet->setRenderQueueGroup(RENDER_QUEUE_MAIN+2);
mBBSet->setBillboardType(BBT_PERPENDICULAR_COMMON);
mBBSet->setCommonDirection( -position.normalisedCopy() );
mBBSet->setVisibilityFlags(RV_Sky);
mNode = rootNode->createChildSceneNode();
mNode->setPosition(finalPosition);
mNode->attachObject(mBBSet);
@ -376,6 +377,7 @@ void SkyManager::create()
MeshPtr mesh = NifOgre::NIFLoader::load("meshes\\sky_night_01.nif");
Entity* night1_ent = mSceneMgr->createEntity("meshes\\sky_night_01.nif");
night1_ent->setRenderQueueGroup(RENDER_QUEUE_SKIES_EARLY+1);
night1_ent->setVisibilityFlags(RV_Sky);
mAtmosphereNight = mRootNode->createChildSceneNode();
mAtmosphereNight->attachObject(night1_ent);
@ -449,6 +451,7 @@ void SkyManager::create()
ModVertexAlpha(atmosphere_ent, 0);
atmosphere_ent->setRenderQueueGroup(RENDER_QUEUE_SKIES_EARLY);
atmosphere_ent->setVisibilityFlags(RV_Sky);
mAtmosphereDay = mRootNode->createChildSceneNode();
mAtmosphereDay->attachObject(atmosphere_ent);
mAtmosphereMaterial = atmosphere_ent->getSubEntity(0)->getMaterial();
@ -485,6 +488,7 @@ void SkyManager::create()
// Clouds
NifOgre::NIFLoader::load("meshes\\sky_clouds_01.nif");
Entity* clouds_ent = mSceneMgr->createEntity("meshes\\sky_clouds_01.nif");
clouds_ent->setVisibilityFlags(RV_Sky);
clouds_ent->setRenderQueueGroup(RENDER_QUEUE_SKIES_EARLY+5);
SceneNode* clouds_node = mRootNode->createChildSceneNode();
clouds_node->attachObject(clouds_ent);

@ -6,6 +6,7 @@
#include "terrainmaterial.hpp"
#include "terrain.hpp"
#include "renderconst.hpp"
using namespace Ogre;
@ -159,6 +160,7 @@ namespace MWRender
x * numTextures, y * numTextures,
numTextures,
indexes);
terrain->setVisibilityFlags(RV_Terrain);
if ( land && land->landData->usingColours )
{

@ -8,7 +8,8 @@ namespace MWRender
Water::Water (Ogre::Camera *camera, const ESM::Cell* cell) :
mCamera (camera), mViewport (camera->getViewport()), mSceneManager (camera->getSceneManager()),
mIsUnderwater(false)
mIsUnderwater(false), mReflectDistance(0), mVisibilityFlags(0), mOldCameraFarClip(0),
mReflectionTarget(0), mRefractionTarget(0), mActive(1)
{
try
{
@ -25,9 +26,16 @@ Water::Water (Ogre::Camera *camera, const ESM::Cell* cell) :
MeshManager::getSingleton().createPlane("water", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, mWaterPlane, CELL_SIZE*5, CELL_SIZE * 5, 10, 10, true, 1, 3,5, Vector3::UNIT_Z);
mWater = mSceneManager->createEntity("water");
mWater->setVisibilityFlags(RV_Water);
mWater->setMaterialName("Examples/Water0");
mVisibilityFlags = RV_Terrain * Settings::Manager::getBool("reflect terrain", "Water")
+ RV_Statics * Settings::Manager::getBool("reflect statics", "Water")
+ RV_StaticsSmall * Settings::Manager::getBool("reflect small statics", "Water")
+ RV_Actors * Settings::Manager::getBool("reflect actors", "Water")
+ RV_Misc * Settings::Manager::getBool("reflect misc", "Water");
mReflectDistance = Settings::Manager::getInt("reflect distance", "Water");
mWaterNode = mSceneManager->getRootSceneNode()->createChildSceneNode();
mWaterNode->setPosition(0, mTop, 0);
@ -43,7 +51,7 @@ Water::Water (Ogre::Camera *camera, const ESM::Cell* cell) :
{
if (i==0 && !Settings::Manager::getBool("reflection", "Water")) continue;
if (i==1 && !Settings::Manager::getBool("refraction", "Water")) continue;
TexturePtr tex = TextureManager::getSingleton().createManual(i == 0 ? "WaterReflection" : "WaterRefraction",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, rttsize, rttsize, 0, PF_R8G8B8, TU_RENDERTARGET);
@ -52,7 +60,7 @@ Water::Water (Ogre::Camera *camera, const ESM::Cell* cell) :
vp->setOverlaysEnabled(false);
vp->setBackgroundColour(ColourValue(0.8f, 0.9f, 1.0f));
vp->setShadowsEnabled(false);
//vp->setVisibilityMask( ... );
vp->setVisibilityMask( (i == 0) ? mVisibilityFlags : RV_All);
rtt->addListener(this);
rtt->setActive(true);
@ -61,6 +69,13 @@ Water::Water (Ogre::Camera *camera, const ESM::Cell* cell) :
}
}
void Water::setActive(bool active)
{
mActive = active;
if (mReflectionTarget) mReflectionTarget->setActive(active);
if (mRefractionTarget) mRefractionTarget->setActive(active);
mWater->setVisible(active);
}
Water::~Water()
{
@ -91,11 +106,13 @@ void Water::setHeight(const float height)
void Water::toggle()
{
mWater->setVisible(!mWater->getVisible());
if (mActive)
mWater->setVisible(!mWater->getVisible());
}
void Water::checkUnderwater(float y)
{
if (!mActive) return;
if ((mIsUnderwater && y > mTop) || !mWater->isVisible() || mCamera->getPolygonMode() != Ogre::PM_SOLID)
{
try {
@ -122,6 +139,10 @@ void Water::preRenderTargetUpdate(const RenderTargetEvent& evt)
{
mWater->setVisible(false);
mOldCameraFarClip = mCamera->getFarClipDistance();
if (mReflectDistance != 0)
mCamera->setFarClipDistance(mReflectDistance);
if (evt.source == mReflectionTarget)
{
mCamera->enableCustomNearClipPlane(mWaterPlane);
@ -133,6 +154,8 @@ void Water::postRenderTargetUpdate(const RenderTargetEvent& evt)
{
mWater->setVisible(true);
mCamera->setFarClipDistance(mOldCameraFarClip);
if (evt.source == mReflectionTarget)
{
mCamera->disableReflection();

@ -4,6 +4,8 @@
#include <Ogre.h>
#include <components/esm/loadcell.hpp>
#include "renderconst.hpp"
namespace MWRender {
/// Water rendering
@ -19,6 +21,7 @@ namespace MWRender {
Ogre::Entity *mWater;
bool mIsUnderwater;
bool mActive;
int mTop;
Ogre::Vector3 getSceneNodeCoordinates(int gridX, int gridY);
@ -30,10 +33,16 @@ namespace MWRender {
Ogre::RenderTarget* mReflectionTarget;
Ogre::RenderTarget* mRefractionTarget;
int mVisibilityFlags;
int mReflectDistance;
int mOldCameraFarClip;
public:
Water (Ogre::Camera *camera, const ESM::Cell* cell);
~Water();
void setActive(bool active);
void toggle();
void checkUnderwater(float y);

@ -49,3 +49,16 @@ reflection = false
refraction = false
rtt size = 256
# 0 unlimited
reflect distance = 0
reflect terrain = true
reflect statics = true
reflect small statics = false
reflect actors = true
reflect misc = false

Loading…
Cancel
Save