mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 07:21:12 +00:00
add light references to scene (light configuration not complete yet)
This commit is contained in:
parent
47790e6feb
commit
c515e9b67e
@ -12,6 +12,7 @@
|
||||
|
||||
#include "store.hpp"
|
||||
#include "esm/records.hpp"
|
||||
#include "esm/loadcell.hpp"
|
||||
#include <mangle/tools/str_exception.hpp>
|
||||
#include <list>
|
||||
|
||||
|
@ -1,7 +1,54 @@
|
||||
#include "cell.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "esm_store/cell_store.hpp"
|
||||
|
||||
using namespace MWRender;
|
||||
|
||||
template<typename T>
|
||||
void insertObj(CellRender& cellRender, const T& liveRef)
|
||||
{
|
||||
assert (liveRef.base != NULL);
|
||||
const std::string &model = liveRef.base->model;
|
||||
if(!model.empty())
|
||||
{
|
||||
cellRender.insertBegin (liveRef.ref);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertEnd();
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
void insertObj(CellRender& cellRender, const ESMS::LiveCellRef<ESM::Light>& liveRef)
|
||||
{
|
||||
assert (liveRef.base != NULL);
|
||||
const std::string &model = liveRef.base->model;
|
||||
if(!model.empty())
|
||||
{
|
||||
cellRender.insertBegin (liveRef.ref);
|
||||
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
|
||||
int color = liveRef.base->data.color;
|
||||
|
||||
cellRender.insertLight ((color >> 24) & 255, (color >> 16) & 255, (color >> 8) & 255,
|
||||
liveRef.base->data.radius);
|
||||
|
||||
cellRender.insertEnd();
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void insertCellRefList (CellRender& cellRender, const T& cellRefList)
|
||||
{
|
||||
for(typename T::List::const_iterator it = cellRefList.list.begin();
|
||||
it != cellRefList.list.end(); it++)
|
||||
{
|
||||
insertObj (cellRender, *it);
|
||||
}
|
||||
}
|
||||
|
||||
void CellRender::insertCell(const ESMS::CellStore &cell)
|
||||
{
|
||||
// Loop through all references in the cell
|
||||
@ -27,16 +74,4 @@ void CellRender::insertCell(const ESMS::CellStore &cell)
|
||||
insertCellRefList (*this, cell.weapons);
|
||||
}
|
||||
|
||||
template<>
|
||||
void MWRender::insertObj(CellRender& cellRender, const ESMS::LiveCellRef<ESM::Light>& liveRef)
|
||||
{
|
||||
assert (liveRef.base != NULL);
|
||||
const std::string &model = liveRef.base->model;
|
||||
if(!model.empty())
|
||||
{
|
||||
cellRender.insertBegin (liveRef.ref);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,17 @@
|
||||
#ifndef _GAME_RENDER_CELL_H
|
||||
#define _GAME_RENDER_CELL_H
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
#include "esm_store/cell_store.hpp"
|
||||
#include "mwscene.hpp"
|
||||
namespace ESM
|
||||
{
|
||||
class CellRef;
|
||||
}
|
||||
|
||||
namespace ESMS
|
||||
{
|
||||
class CellStore;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
@ -18,42 +25,19 @@ namespace MWRender
|
||||
virtual ~CellRender() {}
|
||||
|
||||
/// start inserting a new reference.
|
||||
virtual void insertBegin (const ESMS::CellRef &ref) = 0;
|
||||
virtual void insertBegin (const ESM::CellRef &ref) = 0;
|
||||
|
||||
/// insert a mesh related to the most recent insertBegin call.
|
||||
virtual void insertMesh(const std::string &mesh) = 0;
|
||||
|
||||
/// insert a light related to the most recent insertBegin call.
|
||||
virtual void insertLight(float r, float g, float b, float radius) = 0;
|
||||
|
||||
/// finish inserting a new reference and return a handle to it.
|
||||
virtual std::string insertEnd() = 0;
|
||||
|
||||
void insertCell(const ESMS::CellStore &cell);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void insertObj(CellRender& cellRender, const T& liveRef)
|
||||
{
|
||||
assert (liveRef.base != NULL);
|
||||
const std::string &model = liveRef.base->model;
|
||||
if(!model.empty())
|
||||
{
|
||||
cellRender.insertBegin (liveRef.ref);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertEnd();
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
void insertObj(CellRender& cellRender, const ESMS::LiveCellRef<ESM::Light>& liveRef);
|
||||
|
||||
template<typename T>
|
||||
void insertCellRefList (CellRender& cellRender, const T& cellRefList)
|
||||
{
|
||||
for(typename T::List::const_iterator it = cellRefList.list.begin();
|
||||
it != cellRefList.list.end(); it++)
|
||||
{
|
||||
insertObj (cellRender, *it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,9 +1,10 @@
|
||||
#include "interior.hpp"
|
||||
|
||||
|
||||
#include <OgreEntity.h>
|
||||
#include <OgreLight.h>
|
||||
|
||||
#include "nifogre/ogre_nif_loader.hpp"
|
||||
#include "mwscene.hpp"
|
||||
|
||||
using namespace MWRender;
|
||||
using namespace Ogre;
|
||||
@ -11,7 +12,7 @@ using namespace ESMS;
|
||||
|
||||
// start inserting a new reference.
|
||||
|
||||
void InteriorCellRender::insertBegin (const ESMS::CellRef &ref)
|
||||
void InteriorCellRender::insertBegin (const ESM::CellRef &ref)
|
||||
{
|
||||
assert (!insert);
|
||||
|
||||
@ -49,6 +50,21 @@ void InteriorCellRender::insertMesh(const std::string &mesh)
|
||||
insert->attachObject(ent);
|
||||
}
|
||||
|
||||
// insert a light related to the most recent insertBegin call.
|
||||
void InteriorCellRender::insertLight(float r, float g, float b, float radius)
|
||||
{
|
||||
assert (insert);
|
||||
|
||||
Ogre::Light *light = scene.getMgr()->createLight();
|
||||
light->setDiffuseColour (r, g, b);
|
||||
|
||||
float cval=0.0f, lval=0.0f, qval=0.0f;
|
||||
|
||||
light->setAttenuation(10*radius, cval, lval, qval);
|
||||
|
||||
insert->attachObject(light);
|
||||
}
|
||||
|
||||
// finish inserting a new reference and return a handle to it.
|
||||
|
||||
std::string InteriorCellRender::insertEnd()
|
||||
|
@ -2,9 +2,17 @@
|
||||
#define _GAME_RENDER_INTERIOR_H
|
||||
|
||||
#include "cell.hpp"
|
||||
#include "esm_store/cell_store.hpp"
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class SceneNode;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
class MWScene;
|
||||
|
||||
/**
|
||||
This class is responsible for inserting meshes and other
|
||||
rendering objects from the given cell into the given rendering
|
||||
@ -25,11 +33,14 @@ namespace MWRender
|
||||
Ogre::SceneNode *insert;
|
||||
|
||||
/// start inserting a new reference.
|
||||
virtual void insertBegin (const ESMS::CellRef &ref);
|
||||
virtual void insertBegin (const ESM::CellRef &ref);
|
||||
|
||||
/// insert a mesh related to the most recent insertBegin call.
|
||||
virtual void insertMesh(const std::string &mesh);
|
||||
|
||||
/// insert a light related to the most recent insertBegin call.
|
||||
virtual void insertLight(float r, float g, float b, float radius);
|
||||
|
||||
/// finish inserting a new reference and return a handle to it.
|
||||
virtual std::string insertEnd();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user