mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 07:23:51 +00:00
Player handle changed;Interior removed;Exterior removed;Cellimp removed; Probe fixed
This commit is contained in:
parent
9b94074472
commit
a0947cd432
16 changed files with 21 additions and 1314 deletions
|
@ -16,7 +16,7 @@ set(GAME_HEADER
|
||||||
source_group(game FILES ${GAME} ${GAME_HEADER})
|
source_group(game FILES ${GAME} ${GAME_HEADER})
|
||||||
|
|
||||||
add_openmw_dir (mwrender
|
add_openmw_dir (mwrender
|
||||||
renderingmanager debugging cellimp interior exterior sky player npcs creatures objects renderinginterface
|
renderingmanager debugging sky player npcs creatures objects renderinginterface
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwinput
|
add_openmw_dir (mwinput
|
||||||
|
|
|
@ -8,9 +8,8 @@
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
|
|
||||||
#include "../mwrender/cellimp.hpp"
|
|
||||||
|
|
||||||
#include "containerutil.hpp"
|
#include "containerutil.hpp"
|
||||||
|
#include "../mwrender/objects.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
@ -44,6 +43,14 @@ namespace MWClass
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string Probe::getName (const MWWorld::Ptr& ptr) const
|
||||||
|
{
|
||||||
|
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
|
||||||
|
ptr.get<ESM::Probe>();
|
||||||
|
|
||||||
|
return ref->base->name;
|
||||||
|
}
|
||||||
boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
|
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define GAME_MWCLASS_PROBE_H
|
#define GAME_MWCLASS_PROBE_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwrender/objects.hpp"
|
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
#include "../mwrender/cellimp.hpp"
|
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,67 +0,0 @@
|
||||||
#include "cellimp.hpp"
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <iostream>
|
|
||||||
#include <exception>
|
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
|
||||||
#include "../mwworld/ptr.hpp"
|
|
||||||
|
|
||||||
using namespace MWRender;
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void insertCellRefList (CellRenderImp& cellRender, MWWorld::Environment& environment,
|
|
||||||
T& cellRefList, ESMS::CellStore<MWWorld::RefData> &cell)
|
|
||||||
{
|
|
||||||
if (!cellRefList.list.empty())
|
|
||||||
{
|
|
||||||
const MWWorld::Class& class_ =
|
|
||||||
MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.list.begin(), &cell));
|
|
||||||
|
|
||||||
for (typename T::List::iterator it = cellRefList.list.begin();
|
|
||||||
it != cellRefList.list.end(); it++)
|
|
||||||
{
|
|
||||||
if (it->mData.getCount() || it->mData.isEnabled())
|
|
||||||
{
|
|
||||||
MWWorld::Ptr ptr (&*it, &cell);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
class_.insertObj (ptr, cellRender, environment);
|
|
||||||
class_.enable (ptr, environment);
|
|
||||||
}
|
|
||||||
catch (const std::exception& e)
|
|
||||||
{
|
|
||||||
std::string error ("error during rendering: ");
|
|
||||||
std::cerr << error + e.what() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CellRenderImp::insertCell(ESMS::CellStore<MWWorld::RefData> &cell,
|
|
||||||
MWWorld::Environment& environment)
|
|
||||||
{
|
|
||||||
// Loop through all references in the cell
|
|
||||||
insertCellRefList (*this, environment, cell.activators, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.potions, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.appas, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.armors, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.books, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.clothes, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.containers, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.creatures, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.doors, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.ingreds, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.creatureLists, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.itemLists, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.lights, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.lockpicks, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.miscItems, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.npcs, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.probes, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.repairs, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.statics, cell);
|
|
||||||
insertCellRefList (*this, environment, cell.weapons, cell);
|
|
||||||
}
|
|
|
@ -1,95 +0,0 @@
|
||||||
#ifndef _GAME_RENDER_CELLIMP_H
|
|
||||||
#define _GAME_RENDER_CELLIMP_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "components/esm_store/cell_store.hpp"
|
|
||||||
|
|
||||||
#include "../mwworld/refdata.hpp"
|
|
||||||
#include <OgreMath.h>
|
|
||||||
|
|
||||||
namespace Ogre
|
|
||||||
{
|
|
||||||
class SceneNode;
|
|
||||||
class Vector3;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace ESM
|
|
||||||
{
|
|
||||||
class CellRef;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWWorld
|
|
||||||
{
|
|
||||||
class Environment;
|
|
||||||
}
|
|
||||||
namespace MWRender
|
|
||||||
{
|
|
||||||
/// Base class for cell render, that implements inserting references into a cell in a
|
|
||||||
/// cell type- and render-engine-independent way.
|
|
||||||
|
|
||||||
class CellRenderImp
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CellRenderImp() {}
|
|
||||||
virtual ~CellRenderImp() {}
|
|
||||||
|
|
||||||
/// start inserting a new reference.
|
|
||||||
virtual void insertBegin (ESM::CellRef& ref, MWWorld::RefData& refData, bool static_ = false) = 0;
|
|
||||||
|
|
||||||
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements) = 0;
|
|
||||||
/// insert a mesh related to the most recent insertBegin call.
|
|
||||||
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst) = 0;
|
|
||||||
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements) = 0;
|
|
||||||
virtual void insertMesh(const std::string &mesh) = 0;
|
|
||||||
|
|
||||||
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements) = 0;
|
|
||||||
|
|
||||||
virtual void insertObjectPhysics() = 0;
|
|
||||||
|
|
||||||
virtual void insertActorPhysics() = 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 (bool Enable) = 0;
|
|
||||||
|
|
||||||
void insertCell(ESMS::CellStore<MWWorld::RefData> &cell, MWWorld::Environment& environment);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Exception-safe rendering
|
|
||||||
class Rendering
|
|
||||||
{
|
|
||||||
CellRenderImp& mCellRender;
|
|
||||||
bool mEnd;
|
|
||||||
|
|
||||||
// not implemented
|
|
||||||
Rendering (const Rendering&);
|
|
||||||
Rendering& operator= (const Rendering&);
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Rendering (CellRenderImp& cellRender, ESM::CellRef& ref, MWWorld::RefData& refData, bool static_ = false)
|
|
||||||
: mCellRender (cellRender), mEnd (false)
|
|
||||||
{
|
|
||||||
mCellRender.insertBegin (ref, refData, static_);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Rendering()
|
|
||||||
{
|
|
||||||
if (!mEnd)
|
|
||||||
mCellRender.insertEnd (false);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string end (bool enable)
|
|
||||||
{
|
|
||||||
assert (!mEnd);
|
|
||||||
mEnd = true;
|
|
||||||
return mCellRender.insertEnd (enable);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,455 +0,0 @@
|
||||||
#include "exterior.hpp"
|
|
||||||
#include "renderingmanager.hpp"
|
|
||||||
|
|
||||||
#include <OgreEntity.h>
|
|
||||||
#include <OgreLight.h>
|
|
||||||
#include <OgreSceneNode.h>
|
|
||||||
#include <OgreCamera.h>
|
|
||||||
#include <OgreSceneManager.h>
|
|
||||||
|
|
||||||
#include <components/nifogre/ogre_nif_loader.hpp>
|
|
||||||
#include <libs/mangle/vfs/servers/ogre_vfs.hpp>
|
|
||||||
#include <Ogre.h>
|
|
||||||
|
|
||||||
using namespace MWRender;
|
|
||||||
using namespace Ogre;
|
|
||||||
using namespace ESMS;
|
|
||||||
|
|
||||||
bool ExteriorCellRender::lightConst = false;
|
|
||||||
float ExteriorCellRender::lightConstValue = 0.0f;
|
|
||||||
|
|
||||||
bool ExteriorCellRender::lightLinear = true;
|
|
||||||
int ExteriorCellRender::lightLinearMethod = 1;
|
|
||||||
float ExteriorCellRender::lightLinearValue = 3;
|
|
||||||
float ExteriorCellRender::lightLinearRadiusMult = 1;
|
|
||||||
|
|
||||||
bool ExteriorCellRender::lightQuadratic = false;
|
|
||||||
int ExteriorCellRender::lightQuadraticMethod = 2;
|
|
||||||
float ExteriorCellRender::lightQuadraticValue = 16;
|
|
||||||
float ExteriorCellRender::lightQuadraticRadiusMult = 1;
|
|
||||||
|
|
||||||
bool ExteriorCellRender::lightOutQuadInLin = false;
|
|
||||||
|
|
||||||
int ExteriorCellRender::uniqueID = 0;
|
|
||||||
|
|
||||||
ExteriorCellRender::ExteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment,
|
|
||||||
OEngine::Render::OgreRenderer& renderer, Ogre::SceneNode *mwRoot,MWWorld::PhysicsSystem *physics)
|
|
||||||
: mCell(_cell), mEnvironment (environment), mRenderer(renderer), mPhysics(physics), mBase(NULL), mInsert(NULL), mAmbientMode (0)
|
|
||||||
{
|
|
||||||
mMwRoot = mwRoot;
|
|
||||||
uniqueID = uniqueID +1;
|
|
||||||
sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ExteriorCellRender::insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_)
|
|
||||||
{
|
|
||||||
assert (!mInsert);
|
|
||||||
|
|
||||||
isStatic = static_;
|
|
||||||
|
|
||||||
// Create and place scene node for this object
|
|
||||||
mInsert = mBase->createChildSceneNode();
|
|
||||||
|
|
||||||
const float *f = ref.pos.pos;
|
|
||||||
mInsert->setPosition(f[0], f[1], f[2]);
|
|
||||||
mInsert->setScale(ref.scale, ref.scale, ref.scale);
|
|
||||||
|
|
||||||
// Convert MW rotation to a quaternion:
|
|
||||||
f = ref.pos.rot;
|
|
||||||
|
|
||||||
// Rotate around X axis
|
|
||||||
Quaternion xr(Radian(-f[0]), Vector3::UNIT_X);
|
|
||||||
|
|
||||||
// Rotate around Y axis
|
|
||||||
Quaternion yr(Radian(-f[1]), Vector3::UNIT_Y);
|
|
||||||
|
|
||||||
// Rotate around Z axis
|
|
||||||
Quaternion zr(Radian(-f[2]), Vector3::UNIT_Z);
|
|
||||||
|
|
||||||
// Rotates first around z, then y, then x
|
|
||||||
mInsert->setOrientation(xr*yr*zr);
|
|
||||||
|
|
||||||
mInsertMesh.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ExteriorCellRender::rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements)
|
|
||||||
{
|
|
||||||
assert(mInsert);
|
|
||||||
Ogre::SceneNode *parent = mInsert;
|
|
||||||
//std::cout << "ELEMENTS:" << elements;
|
|
||||||
for (int i = 0; i < elements; i++){
|
|
||||||
if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
|
|
||||||
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneNodeName[i]));
|
|
||||||
}
|
|
||||||
parent->rotate(axis, angle);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements){
|
|
||||||
assert (mInsert);
|
|
||||||
//mInsert->
|
|
||||||
Ogre::SceneNode *parent = mInsert;
|
|
||||||
for (int i = 0; i < elements; i++){
|
|
||||||
if(sceneParent[i] != "" && parent->getChild(sceneParent[i]))
|
|
||||||
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneParent[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
mNpcPart = parent->createChildSceneNode(sceneNodeName);
|
|
||||||
NIFLoader::load(mesh);
|
|
||||||
MovableObject *ent = mScene.getMgr()->createEntity(mesh);
|
|
||||||
|
|
||||||
mNpcPart->translate(vec);
|
|
||||||
mNpcPart->rotate(axis, angle);
|
|
||||||
// mNpcPart->translate(vec);
|
|
||||||
//mNpcPart->rotate(axis, angle);
|
|
||||||
mNpcPart->attachObject(ent);
|
|
||||||
//mNpcPart->
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements)
|
|
||||||
{
|
|
||||||
insertMesh(mesh, vec, axis, angle, sceneNodeName, sceneParent, elements, true);
|
|
||||||
}
|
|
||||||
void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst){
|
|
||||||
|
|
||||||
assert (mInsert);
|
|
||||||
//mInsert->
|
|
||||||
Ogre::SceneNode *parent = mInsert;
|
|
||||||
for (int i = 0; i < elements; i++){
|
|
||||||
if(sceneParent[i] != "" && parent->getChild(sceneParent[i]))
|
|
||||||
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneParent[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
mNpcPart = parent->createChildSceneNode(sceneNodeName);
|
|
||||||
MeshPtr good2 = NifOgre::NIFLoader::load(mesh);
|
|
||||||
|
|
||||||
MovableObject *ent = mRenderer.getScene()->createEntity(mesh);
|
|
||||||
|
|
||||||
|
|
||||||
if(translateFirst){
|
|
||||||
mNpcPart->translate(vec);
|
|
||||||
mNpcPart->rotate(axis, angle);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
|
|
||||||
mNpcPart->rotate(axis, angle);
|
|
||||||
mNpcPart->translate(vec);
|
|
||||||
}
|
|
||||||
mNpcPart->attachObject(ent);
|
|
||||||
|
|
||||||
Ogre::MeshManager *m = MeshManager::getSingletonPtr();
|
|
||||||
const std::string beast1 ="meshes\\b\\B_N_Khajiit_F_Skins.nif";
|
|
||||||
const std::string beast2 ="meshes\\b\\B_N_Khajiit_M_Skins.nif";
|
|
||||||
const std::string beast3 ="meshes\\b\\B_N_Argonian_F_Skins.nif";
|
|
||||||
const std::string beast4 ="meshes\\b\\B_N_Argonian_M_Skins.nif";
|
|
||||||
|
|
||||||
const std::string beasttail1 ="tail\\b\\B_N_Khajiit_F_Skins.nif";
|
|
||||||
const std::string beasttail2 ="tail\\b\\B_N_Khajiit_M_Skins.nif";
|
|
||||||
const std::string beasttail3 ="tail\\b\\B_N_Argonian_F_Skins.nif";
|
|
||||||
const std::string beasttail4 ="tail\\b\\B_N_Argonian_M_Skins.nif";
|
|
||||||
|
|
||||||
const std::string beastfoot1 ="foot\\b\\B_N_Khajiit_F_Skins.nif";
|
|
||||||
const std::string beastfoot2 ="foot\\b\\B_N_Khajiit_M_Skins.nif";
|
|
||||||
const std::string beastfoot3 ="foot\\b\\B_N_Argonian_F_Skins.nif";
|
|
||||||
const std::string beastfoot4 ="foot\\b\\B_N_Argonian_M_Skins.nif";
|
|
||||||
if(mesh.compare(beast1) == 0 && m->getByName(beasttail1).isNull())
|
|
||||||
{
|
|
||||||
//std::cout << "CLONINGKHAJIITF\n";
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr tail = good2->clone(beasttail1);
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr foot = good2->clone(beastfoot1);
|
|
||||||
good2->reload();
|
|
||||||
}
|
|
||||||
else if(mesh.compare(beast2) == 0 && m->getByName(beasttail2).isNull())
|
|
||||||
{
|
|
||||||
//std::cout << "CLONINGKHAJIITM\n";
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr tail = good2->clone(beasttail2);
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr foot = good2->clone(beastfoot2);
|
|
||||||
good2->reload();
|
|
||||||
}
|
|
||||||
else if(mesh.compare(beast3) == 0 && m->getByName(beasttail3).isNull())
|
|
||||||
{
|
|
||||||
//std::cout << "CLONINGARGONIANF\n";
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr tail = good2->clone(beasttail3);
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr foot = good2->clone(beastfoot3);
|
|
||||||
good2->reload();
|
|
||||||
}
|
|
||||||
else if(mesh.compare(beast4) == 0 && m->getByName(beasttail4).isNull())
|
|
||||||
{
|
|
||||||
//std::cout << "CLONINGARGONIANM\n";
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr tail = good2->clone(beasttail4);
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr foot = good2->clone(beastfoot4);
|
|
||||||
good2->reload();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// insert a mesh related to the most recent insertBegin call.
|
|
||||||
|
|
||||||
void ExteriorCellRender::scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements)
|
|
||||||
{
|
|
||||||
assert(mInsert);
|
|
||||||
Ogre::SceneNode *parent = mInsert;
|
|
||||||
//std::cout << "ELEMENTS:" << elements;
|
|
||||||
for (int i = 0; i < elements; i++){
|
|
||||||
if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
|
|
||||||
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneNodeName[i]));
|
|
||||||
}
|
|
||||||
parent->scale(axis);
|
|
||||||
}
|
|
||||||
|
|
||||||
// insert a mesh related to the most recent insertBegin call.
|
|
||||||
|
|
||||||
|
|
||||||
void ExteriorCellRender::insertMesh(const std::string &mesh)
|
|
||||||
{
|
|
||||||
assert (mInsert);
|
|
||||||
|
|
||||||
NifOgre::NIFLoader::load(mesh);
|
|
||||||
Entity *ent = mRenderer.getScene()->createEntity(mesh);
|
|
||||||
|
|
||||||
if(!isStatic)
|
|
||||||
{
|
|
||||||
mInsert->attachObject(ent);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sg->addEntity(ent,mInsert->_getDerivedPosition(),mInsert->_getDerivedOrientation(),mInsert->_getDerivedScale());
|
|
||||||
sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000));
|
|
||||||
mRenderer.getScene()->destroyEntity(ent);
|
|
||||||
}
|
|
||||||
if (mInsertMesh.empty())
|
|
||||||
mInsertMesh = mesh;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExteriorCellRender::insertObjectPhysics()
|
|
||||||
{
|
|
||||||
if (!mInsertMesh.empty())
|
|
||||||
{
|
|
||||||
mPhysics->addObject (mInsert->getName(), mInsertMesh, mInsert->getOrientation(),
|
|
||||||
mInsert->getScale().x, mInsert->getPosition());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExteriorCellRender::insertActorPhysics()
|
|
||||||
{
|
|
||||||
mPhysics->addActor (mInsert->getName(), mInsertMesh, mInsert->getPosition());
|
|
||||||
}
|
|
||||||
|
|
||||||
// insert a light related to the most recent insertBegin call.
|
|
||||||
void ExteriorCellRender::insertLight(float r, float g, float b, float radius)
|
|
||||||
{
|
|
||||||
assert (mInsert);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
mInsert->attachObject(light);
|
|
||||||
}
|
|
||||||
|
|
||||||
// finish inserting a new reference and return a handle to it.
|
|
||||||
|
|
||||||
std::string ExteriorCellRender::insertEnd (bool enable)
|
|
||||||
{
|
|
||||||
assert (mInsert);
|
|
||||||
|
|
||||||
std::string handle = mInsert->getName();
|
|
||||||
|
|
||||||
if (!enable)
|
|
||||||
mInsert->setVisible (false);
|
|
||||||
|
|
||||||
mInsert = 0;
|
|
||||||
|
|
||||||
return handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
// configure lighting according to cell
|
|
||||||
|
|
||||||
void ExteriorCellRender::configureAmbient()
|
|
||||||
{
|
|
||||||
mAmbientColor.setAsABGR (mCell.cell->ambi.ambient);
|
|
||||||
setAmbientMode();
|
|
||||||
|
|
||||||
// Create a "sun" that shines light downwards. It doesn't look
|
|
||||||
// completely right, but leave it for now.
|
|
||||||
Ogre::Light *light = mRenderer.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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// configure fog according to cell
|
|
||||||
void ExteriorCellRender::configureFog()
|
|
||||||
{
|
|
||||||
Ogre::ColourValue color;
|
|
||||||
color.setAsABGR (mCell.cell->ambi.fog);
|
|
||||||
|
|
||||||
float high = 4500 + 9000 * (1-mCell.cell->ambi.fogDensity);
|
|
||||||
float low = 200;
|
|
||||||
|
|
||||||
mRenderer.getScene()->setFog (FOG_LINEAR, color, 0, low, high);
|
|
||||||
mRenderer.getCamera()->setFarClipDistance (high + 10);
|
|
||||||
mRenderer.getViewport()->setBackgroundColour (color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExteriorCellRender::setAmbientMode()
|
|
||||||
{
|
|
||||||
switch (mAmbientMode)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
|
|
||||||
mRenderer.getScene()->setAmbientLight(mAmbientColor);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
|
|
||||||
mRenderer.getScene()->setAmbientLight(0.7f*mAmbientColor + 0.3f*ColourValue(1,1,1));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
|
|
||||||
mRenderer.getScene()->setAmbientLight(ColourValue(1,1,1));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExteriorCellRender::show()
|
|
||||||
{
|
|
||||||
// FIXME: this one may be the bug
|
|
||||||
mBase = mMwRoot->createChildSceneNode();
|
|
||||||
|
|
||||||
configureAmbient();
|
|
||||||
configureFog();
|
|
||||||
|
|
||||||
insertCell(mCell, mEnvironment);
|
|
||||||
|
|
||||||
sg->build();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExteriorCellRender::hide()
|
|
||||||
{
|
|
||||||
if(mBase)
|
|
||||||
mBase->setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExteriorCellRender::destroyAllAttachedMovableObjects(Ogre::SceneNode* i_pSceneNode)
|
|
||||||
{
|
|
||||||
if ( !i_pSceneNode )
|
|
||||||
{
|
|
||||||
assert( false );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destroy all the attached objects
|
|
||||||
SceneNode::ObjectIterator itObject = i_pSceneNode->getAttachedObjectIterator();
|
|
||||||
|
|
||||||
while ( itObject.hasMoreElements() )
|
|
||||||
{
|
|
||||||
MovableObject* pObject = static_cast<MovableObject*>(itObject.getNext());
|
|
||||||
i_pSceneNode->getCreator()->destroyMovableObject( pObject );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Recurse to child SceneNodes
|
|
||||||
SceneNode::ChildNodeIterator itChild = i_pSceneNode->getChildIterator();
|
|
||||||
|
|
||||||
while ( itChild.hasMoreElements() )
|
|
||||||
{
|
|
||||||
SceneNode* pChildNode = static_cast<SceneNode*>(itChild.getNext());
|
|
||||||
destroyAllAttachedMovableObjects( pChildNode );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExteriorCellRender::destroy()
|
|
||||||
{
|
|
||||||
if(mBase)
|
|
||||||
{
|
|
||||||
destroyAllAttachedMovableObjects(mBase);
|
|
||||||
mBase->removeAndDestroyAllChildren();
|
|
||||||
mRenderer.getScene()->destroySceneNode(mBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
mBase = 0;
|
|
||||||
|
|
||||||
if (sg)
|
|
||||||
{
|
|
||||||
mRenderer.getScene()->destroyStaticGeometry (sg);
|
|
||||||
sg = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Switch through lighting modes.
|
|
||||||
|
|
||||||
void ExteriorCellRender::toggleLight()
|
|
||||||
{
|
|
||||||
if (mAmbientMode==2)
|
|
||||||
mAmbientMode = 0;
|
|
||||||
else
|
|
||||||
++mAmbientMode;
|
|
||||||
|
|
||||||
switch (mAmbientMode)
|
|
||||||
{
|
|
||||||
case 0: std::cout << "Setting lights to normal\n"; break;
|
|
||||||
case 1: std::cout << "Turning the lights up\n"; break;
|
|
||||||
case 2: std::cout << "Turning the lights to full\n"; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
setAmbientMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExteriorCellRender::enable (const std::string& handle)
|
|
||||||
{
|
|
||||||
if (!handle.empty())
|
|
||||||
mRenderer.getScene()->getSceneNode (handle)->setVisible (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExteriorCellRender::disable (const std::string& handle)
|
|
||||||
{
|
|
||||||
if (!handle.empty())
|
|
||||||
mRenderer.getScene()->getSceneNode (handle)->setVisible (false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExteriorCellRender::deleteObject (const std::string& handle)
|
|
||||||
{
|
|
||||||
if (!handle.empty())
|
|
||||||
{
|
|
||||||
Ogre::SceneNode *node = mRenderer.getScene()->getSceneNode (handle);
|
|
||||||
node->removeAndDestroyAllChildren();
|
|
||||||
mRenderer.getScene()->destroySceneNode (node);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,139 +0,0 @@
|
||||||
#ifndef _GAME_RENDER_EXTERIOR_H
|
|
||||||
#define _GAME_RENDER_EXTERIOR_H
|
|
||||||
|
|
||||||
#include "cell.hpp"
|
|
||||||
#include "cellimp.hpp"
|
|
||||||
#include "../mwworld/physicssystem.hpp"
|
|
||||||
|
|
||||||
#include "OgreColourValue.h"
|
|
||||||
#include <OgreMath.h>
|
|
||||||
#include <Ogre.h>
|
|
||||||
|
|
||||||
namespace Ogre
|
|
||||||
{
|
|
||||||
class SceneNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWWorld
|
|
||||||
{
|
|
||||||
class Environment;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWRender
|
|
||||||
{
|
|
||||||
class RenderingManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
This class is responsible for inserting meshes and other
|
|
||||||
rendering objects from the given cell into the given rendering
|
|
||||||
scene.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ExteriorCellRender : public CellRender, private CellRenderImp
|
|
||||||
{
|
|
||||||
|
|
||||||
static bool lightConst;
|
|
||||||
static float lightConstValue;
|
|
||||||
|
|
||||||
static bool lightLinear;
|
|
||||||
static int lightLinearMethod;
|
|
||||||
static float lightLinearValue;
|
|
||||||
static float lightLinearRadiusMult;
|
|
||||||
|
|
||||||
static bool lightQuadratic;
|
|
||||||
static int lightQuadraticMethod;
|
|
||||||
static float lightQuadraticValue;
|
|
||||||
static float lightQuadraticRadiusMult;
|
|
||||||
|
|
||||||
static bool lightOutQuadInLin;
|
|
||||||
|
|
||||||
ESMS::CellStore<MWWorld::RefData> &mCell;
|
|
||||||
MWWorld::Environment &mEnvironment;
|
|
||||||
OEngine::Render::OgreRenderer& mRenderer;
|
|
||||||
Ogre::SceneNode *mMwRoot;
|
|
||||||
MWWorld::PhysicsSystem *mPhysics;
|
|
||||||
|
|
||||||
/// The scene node that contains all objects belonging to this
|
|
||||||
/// cell.
|
|
||||||
Ogre::SceneNode *mBase;
|
|
||||||
|
|
||||||
Ogre::SceneNode *mInsert;
|
|
||||||
std::string mInsertMesh;
|
|
||||||
Ogre::SceneNode *mNpcPart;
|
|
||||||
|
|
||||||
//the static geometry
|
|
||||||
Ogre::StaticGeometry *sg;
|
|
||||||
bool isStatic;
|
|
||||||
|
|
||||||
// 0 normal, 1 more bright, 2 max
|
|
||||||
int mAmbientMode;
|
|
||||||
|
|
||||||
Ogre::ColourValue mAmbientColor;
|
|
||||||
|
|
||||||
/// start inserting a new reference.
|
|
||||||
virtual void insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_ = false);
|
|
||||||
|
|
||||||
/// insert a mesh related to the most recent insertBegin call.
|
|
||||||
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements);
|
|
||||||
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst);
|
|
||||||
|
|
||||||
virtual void insertMesh(const std::string &mesh);
|
|
||||||
|
|
||||||
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements);
|
|
||||||
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements);
|
|
||||||
|
|
||||||
virtual void insertObjectPhysics();
|
|
||||||
|
|
||||||
virtual void insertActorPhysics();
|
|
||||||
|
|
||||||
/// 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 (bool Enable);
|
|
||||||
|
|
||||||
/// configure lighting according to cell
|
|
||||||
void configureAmbient();
|
|
||||||
|
|
||||||
/// configure fog according to cell
|
|
||||||
void configureFog();
|
|
||||||
|
|
||||||
void setAmbientMode();
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
ExteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment,
|
|
||||||
OEngine::Render::OgreRenderer& renderer, Ogre::SceneNode *mwRoot, MWWorld::PhysicsSystem *physics);
|
|
||||||
|
|
||||||
virtual ~ExteriorCellRender() { destroy(); }
|
|
||||||
|
|
||||||
/// Make the cell visible. Load the cell if necessary.
|
|
||||||
virtual void show();
|
|
||||||
|
|
||||||
/// Remove the cell from rendering, but don't remove it from
|
|
||||||
/// memory.
|
|
||||||
virtual void hide();
|
|
||||||
|
|
||||||
/// Destroy all rendering objects connected with this cell.
|
|
||||||
virtual void destroy(); // comment by Zini: shouldn't this go into the destructor?
|
|
||||||
|
|
||||||
/// Switch through lighting modes.
|
|
||||||
void toggleLight();
|
|
||||||
|
|
||||||
/// Make the reference with the given handle visible.
|
|
||||||
virtual void enable (const std::string& handle);
|
|
||||||
|
|
||||||
/// Make the reference with the given handle invisible.
|
|
||||||
virtual void disable (const std::string& handle);
|
|
||||||
|
|
||||||
/// Remove the reference with the given handle permanently from the scene.
|
|
||||||
virtual void deleteObject (const std::string& handle);
|
|
||||||
|
|
||||||
void destroyAllAttachedMovableObjects(Ogre::SceneNode* i_pSceneNode);
|
|
||||||
|
|
||||||
static int uniqueID;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,409 +0,0 @@
|
||||||
#include "interior.hpp"
|
|
||||||
#include "renderingmanager.hpp"
|
|
||||||
|
|
||||||
#include <OgreEntity.h>
|
|
||||||
#include <OgreLight.h>
|
|
||||||
#include <OgreSceneNode.h>
|
|
||||||
#include <OgreCamera.h>
|
|
||||||
#include <OgreSceneManager.h>
|
|
||||||
#include <OgreMath.h>
|
|
||||||
|
|
||||||
#include <components/nifogre/ogre_nif_loader.hpp>
|
|
||||||
#include <Ogre.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <libs/mangle/vfs/servers/ogre_vfs.hpp>
|
|
||||||
|
|
||||||
using namespace MWRender;
|
|
||||||
using namespace Ogre;
|
|
||||||
using namespace ESMS;
|
|
||||||
|
|
||||||
bool InteriorCellRender::lightConst = false;
|
|
||||||
float InteriorCellRender::lightConstValue = 0.0f;
|
|
||||||
|
|
||||||
bool InteriorCellRender::lightLinear = true;
|
|
||||||
int InteriorCellRender::lightLinearMethod = 1;
|
|
||||||
float InteriorCellRender::lightLinearValue = 3;
|
|
||||||
float InteriorCellRender::lightLinearRadiusMult = 1;
|
|
||||||
|
|
||||||
bool InteriorCellRender::lightQuadratic = false;
|
|
||||||
int InteriorCellRender::lightQuadraticMethod = 2;
|
|
||||||
float InteriorCellRender::lightQuadraticValue = 16;
|
|
||||||
float InteriorCellRender::lightQuadraticRadiusMult = 1;
|
|
||||||
|
|
||||||
bool InteriorCellRender::lightOutQuadInLin = false;
|
|
||||||
|
|
||||||
// start inserting a new reference.
|
|
||||||
|
|
||||||
void InteriorCellRender::insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_)
|
|
||||||
{
|
|
||||||
assert (!insert);
|
|
||||||
|
|
||||||
// Create and place scene node for this object
|
|
||||||
insert = base->createChildSceneNode();
|
|
||||||
|
|
||||||
const float *f = refData.getPosition().pos;
|
|
||||||
insert->setPosition(f[0], f[1], f[2]);
|
|
||||||
insert->setScale(ref.scale, ref.scale, ref.scale);
|
|
||||||
|
|
||||||
// Convert MW rotation to a quaternion:
|
|
||||||
f = ref.pos.rot;
|
|
||||||
|
|
||||||
// Rotate around X axis
|
|
||||||
Quaternion xr(Radian(-f[0]), Vector3::UNIT_X);
|
|
||||||
|
|
||||||
// Rotate around Y axis
|
|
||||||
Quaternion yr(Radian(-f[1]), Vector3::UNIT_Y);
|
|
||||||
|
|
||||||
// Rotate around Z axis
|
|
||||||
Quaternion zr(Radian(-f[2]), Vector3::UNIT_Z);
|
|
||||||
|
|
||||||
// Rotates first around z, then y, then x
|
|
||||||
insert->setOrientation(xr*yr*zr);
|
|
||||||
|
|
||||||
mInsertMesh.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// insert a mesh related to the most recent insertBegin call.
|
|
||||||
void InteriorCellRender::rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements)
|
|
||||||
{
|
|
||||||
assert(insert);
|
|
||||||
Ogre::SceneNode *parent = insert;
|
|
||||||
//std::cout << "ELEMENTS:" << elements;
|
|
||||||
for (int i = 0; i < elements; i++){
|
|
||||||
if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
|
|
||||||
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneNodeName[i]));
|
|
||||||
}
|
|
||||||
parent->rotate(axis, angle);
|
|
||||||
}
|
|
||||||
// insert a mesh related to the most recent insertBegin call.
|
|
||||||
|
|
||||||
void InteriorCellRender::scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements)
|
|
||||||
{
|
|
||||||
assert(insert);
|
|
||||||
Ogre::SceneNode *parent = insert;
|
|
||||||
//std::cout << "ELEMENTS:" << elements;
|
|
||||||
for (int i = 0; i < elements; i++){
|
|
||||||
if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
|
|
||||||
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneNodeName[i]));
|
|
||||||
}
|
|
||||||
parent->scale(axis);
|
|
||||||
}
|
|
||||||
void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements)
|
|
||||||
{
|
|
||||||
insertMesh(mesh, vec, axis, angle, sceneNodeName, sceneParent, elements, true);
|
|
||||||
}
|
|
||||||
void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst){
|
|
||||||
|
|
||||||
assert (insert);
|
|
||||||
//insert->
|
|
||||||
Ogre::SceneNode *parent = insert;
|
|
||||||
for (int i = 0; i < elements; i++){
|
|
||||||
if(sceneParent[i] != "" && parent->getChild(sceneParent[i]))
|
|
||||||
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneParent[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
npcPart = parent->createChildSceneNode(sceneNodeName);
|
|
||||||
//npcPart->showBoundingBox(true);
|
|
||||||
|
|
||||||
MeshPtr good2 = NifOgre::NIFLoader::load(mesh);
|
|
||||||
|
|
||||||
MovableObject *ent = mRenderer.getScene()->createEntity(mesh);
|
|
||||||
//ent->extr
|
|
||||||
|
|
||||||
// MovableObject *ent2 = scene.getMgr()->createEntity(bounds
|
|
||||||
// );
|
|
||||||
//ent->
|
|
||||||
//std::cout << mesh << bounds << "\n";
|
|
||||||
|
|
||||||
if(translateFirst){
|
|
||||||
npcPart->translate(vec);
|
|
||||||
npcPart->rotate(axis, angle);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
|
|
||||||
npcPart->rotate(axis, angle);
|
|
||||||
npcPart->translate(vec);
|
|
||||||
}
|
|
||||||
|
|
||||||
npcPart->attachObject(ent);
|
|
||||||
Ogre::MeshManager *m = MeshManager::getSingletonPtr();
|
|
||||||
const std::string beast1 ="meshes\\b\\B_N_Khajiit_F_Skins.nif";
|
|
||||||
const std::string beast2 ="meshes\\b\\B_N_Khajiit_M_Skins.nif";
|
|
||||||
const std::string beast3 ="meshes\\b\\B_N_Argonian_F_Skins.nif";
|
|
||||||
const std::string beast4 ="meshes\\b\\B_N_Argonian_M_Skins.nif";
|
|
||||||
|
|
||||||
const std::string beasttail1 ="tail\\b\\B_N_Khajiit_F_Skins.nif";
|
|
||||||
const std::string beasttail2 ="tail\\b\\B_N_Khajiit_M_Skins.nif";
|
|
||||||
const std::string beasttail3 ="tail\\b\\B_N_Argonian_F_Skins.nif";
|
|
||||||
const std::string beasttail4 ="tail\\b\\B_N_Argonian_M_Skins.nif";
|
|
||||||
|
|
||||||
const std::string beastfoot1 ="foot\\b\\B_N_Khajiit_F_Skins.nif";
|
|
||||||
const std::string beastfoot2 ="foot\\b\\B_N_Khajiit_M_Skins.nif";
|
|
||||||
const std::string beastfoot3 ="foot\\b\\B_N_Argonian_F_Skins.nif";
|
|
||||||
const std::string beastfoot4 ="foot\\b\\B_N_Argonian_M_Skins.nif";
|
|
||||||
if(mesh.compare(beast1) == 0 && m->getByName(beasttail1).isNull())
|
|
||||||
{
|
|
||||||
//std::cout << "CLONINGKHAJIITF\n";
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr tail = good2->clone(beasttail1);
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr foot = good2->clone(beastfoot1);
|
|
||||||
good2->reload();
|
|
||||||
}
|
|
||||||
else if(mesh.compare(beast2) == 0 && m->getByName(beasttail2).isNull())
|
|
||||||
{
|
|
||||||
//std::cout << "CLONINGKHAJIITM\n";
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr tail = good2->clone(beasttail2);
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr foot = good2->clone(beastfoot2);
|
|
||||||
good2->reload();
|
|
||||||
}
|
|
||||||
else if(mesh.compare(beast3) == 0 && m->getByName(beasttail3).isNull())
|
|
||||||
{
|
|
||||||
//std::cout << "CLONINGARGONIANF\n";
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr tail = good2->clone(beasttail3);
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr foot = good2->clone(beastfoot3);
|
|
||||||
good2->reload();
|
|
||||||
}
|
|
||||||
else if(mesh.compare(beast4) == 0 && m->getByName(beasttail4).isNull())
|
|
||||||
{
|
|
||||||
//std::cout << "CLONINGARGONIANM\n";
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr tail = good2->clone(beasttail4);
|
|
||||||
good2->reload();
|
|
||||||
MeshPtr foot = good2->clone(beastfoot4);
|
|
||||||
good2->reload();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void InteriorCellRender::insertMesh(const std::string &mesh)
|
|
||||||
{
|
|
||||||
assert (insert);
|
|
||||||
|
|
||||||
NifOgre::NIFLoader::load(mesh);
|
|
||||||
MovableObject *ent = mRenderer.getScene()->createEntity(mesh);
|
|
||||||
insert->attachObject(ent);
|
|
||||||
|
|
||||||
if (mInsertMesh.empty())
|
|
||||||
mInsertMesh = mesh;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InteriorCellRender::insertObjectPhysics()
|
|
||||||
{
|
|
||||||
if (!mInsertMesh.empty())
|
|
||||||
{
|
|
||||||
mPhysics->addObject (insert->getName(), mInsertMesh, insert->getOrientation(),
|
|
||||||
insert->getScale().x, insert->getPosition());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void InteriorCellRender::insertActorPhysics()
|
|
||||||
{
|
|
||||||
mPhysics->addActor (insert->getName(), mInsertMesh, insert->getPosition());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 = 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// finish inserting a new reference and return a handle to it.
|
|
||||||
|
|
||||||
std::string InteriorCellRender::insertEnd (bool enable)
|
|
||||||
{
|
|
||||||
assert (insert);
|
|
||||||
|
|
||||||
std::string handle = insert->getName();
|
|
||||||
|
|
||||||
if (!enable)
|
|
||||||
insert->setVisible (false);
|
|
||||||
|
|
||||||
insert = 0;
|
|
||||||
|
|
||||||
return handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
// configure lighting according to cell
|
|
||||||
|
|
||||||
void InteriorCellRender::configureAmbient()
|
|
||||||
{
|
|
||||||
ambientColor.setAsABGR (cell.cell->ambi.ambient);
|
|
||||||
setAmbientMode();
|
|
||||||
|
|
||||||
// Create a "sun" that shines light downwards. It doesn't look
|
|
||||||
// completely right, but leave it for now.
|
|
||||||
Ogre::Light *light = mRenderer.getScene()->createLight();
|
|
||||||
Ogre::ColourValue colour;
|
|
||||||
colour.setAsABGR (cell.cell->ambi.sunlight);
|
|
||||||
light->setDiffuseColour (colour);
|
|
||||||
light->setType(Ogre::Light::LT_DIRECTIONAL);
|
|
||||||
light->setDirection(0,-1,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// configure fog according to cell
|
|
||||||
void InteriorCellRender::configureFog()
|
|
||||||
{
|
|
||||||
Ogre::ColourValue color;
|
|
||||||
color.setAsABGR (cell.cell->ambi.fog);
|
|
||||||
|
|
||||||
float high = 4500 + 9000 * (1-cell.cell->ambi.fogDensity);
|
|
||||||
float low = 200;
|
|
||||||
|
|
||||||
mRenderer.getScene()->setFog (FOG_LINEAR, color, 0, low, high);
|
|
||||||
mRenderer.getCamera()->setFarClipDistance (high + 10);
|
|
||||||
mRenderer.getViewport()->setBackgroundColour (color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InteriorCellRender::setAmbientMode()
|
|
||||||
{
|
|
||||||
switch (ambientMode)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
|
|
||||||
mRenderer.getScene()->setAmbientLight(ambientColor);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
|
|
||||||
mRenderer.getScene()->setAmbientLight(0.7f*ambientColor + 0.3f*ColourValue(1,1,1));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
|
|
||||||
mRenderer.getScene()->setAmbientLight(ColourValue(1,1,1));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void InteriorCellRender::show()
|
|
||||||
{
|
|
||||||
base = mMwRoot->createChildSceneNode();
|
|
||||||
|
|
||||||
configureAmbient();
|
|
||||||
configureFog();
|
|
||||||
|
|
||||||
insertCell(cell, mEnvironment);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InteriorCellRender::hide()
|
|
||||||
{
|
|
||||||
if(base)
|
|
||||||
base->setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InteriorCellRender::destroy()
|
|
||||||
{
|
|
||||||
if(base)
|
|
||||||
{
|
|
||||||
base->removeAndDestroyAllChildren();
|
|
||||||
mRenderer.getScene()->destroySceneNode(base);
|
|
||||||
}
|
|
||||||
|
|
||||||
base = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Switch through lighting modes.
|
|
||||||
|
|
||||||
void InteriorCellRender::toggleLight()
|
|
||||||
{
|
|
||||||
if (ambientMode==2)
|
|
||||||
ambientMode = 0;
|
|
||||||
else
|
|
||||||
++ambientMode;
|
|
||||||
|
|
||||||
switch (ambientMode)
|
|
||||||
{
|
|
||||||
case 0: std::cout << "Setting lights to normal\n"; break;
|
|
||||||
case 1: std::cout << "Turning the lights up\n"; break;
|
|
||||||
case 2: std::cout << "Turning the lights to full\n"; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
setAmbientMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InteriorCellRender::enable (const std::string& handle)
|
|
||||||
{
|
|
||||||
if (!handle.empty())
|
|
||||||
mRenderer.getScene()->getSceneNode (handle)->setVisible (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InteriorCellRender::disable (const std::string& handle)
|
|
||||||
{
|
|
||||||
if (!handle.empty())
|
|
||||||
mRenderer.getScene()->getSceneNode (handle)->setVisible (false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InteriorCellRender::deleteObject (const std::string& handle)
|
|
||||||
{
|
|
||||||
if (!handle.empty())
|
|
||||||
{
|
|
||||||
Ogre::SceneNode *node = mRenderer.getScene()->getSceneNode (handle);
|
|
||||||
node->removeAndDestroyAllChildren();
|
|
||||||
mRenderer.getScene()->destroySceneNode (node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Magic function from the internets. Might need this later.
|
|
||||||
/*
|
|
||||||
void Scene::DestroyAllAttachedMovableObjects( SceneNode* i_pSceneNode )
|
|
||||||
{
|
|
||||||
if ( !i_pSceneNode )
|
|
||||||
{
|
|
||||||
ASSERT( false );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destroy all the attached objects
|
|
||||||
SceneNode::ObjectIterator itObject = i_pSceneNode->getAttachedObjectIterator();
|
|
||||||
|
|
||||||
while ( itObject.hasMoreElements() )
|
|
||||||
{
|
|
||||||
MovableObject* pObject = static_cast<MovableObject*>(itObject.getNext());
|
|
||||||
i_pSceneNode->getCreator()->destroyMovableObject( pObject );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Recurse to child SceneNodes
|
|
||||||
SceneNode::ChildNodeIterator itChild = i_pSceneNode->getChildIterator();
|
|
||||||
|
|
||||||
while ( itChild.hasMoreElements() )
|
|
||||||
{
|
|
||||||
SceneNode* pChildNode = static_cast<SceneNode*>(itChild.getNext());
|
|
||||||
DestroyAllAttachedMovableObjects( pChildNode );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
|
@ -1,133 +0,0 @@
|
||||||
#ifndef _GAME_RENDER_INTERIOR_H
|
|
||||||
#define _GAME_RENDER_INTERIOR_H
|
|
||||||
|
|
||||||
#include "cell.hpp"
|
|
||||||
#include "cellimp.hpp"
|
|
||||||
#include "../mwworld/physicssystem.hpp"
|
|
||||||
|
|
||||||
#include "OgreColourValue.h"
|
|
||||||
#include <OgreSceneNode.h>
|
|
||||||
|
|
||||||
namespace Ogre
|
|
||||||
{
|
|
||||||
class SceneNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWWorld
|
|
||||||
{
|
|
||||||
class Environment;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWRender
|
|
||||||
{
|
|
||||||
class RenderingManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
This class is responsible for inserting meshes and other
|
|
||||||
rendering objects from the given cell into the given rendering
|
|
||||||
scene.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class InteriorCellRender : public CellRender, private CellRenderImp
|
|
||||||
{
|
|
||||||
//static bool isChest;
|
|
||||||
static bool lightConst;
|
|
||||||
static float lightConstValue;
|
|
||||||
|
|
||||||
static bool lightLinear;
|
|
||||||
static int lightLinearMethod;
|
|
||||||
static float lightLinearValue;
|
|
||||||
static float lightLinearRadiusMult;
|
|
||||||
|
|
||||||
static bool lightQuadratic;
|
|
||||||
static int lightQuadraticMethod;
|
|
||||||
static float lightQuadraticValue;
|
|
||||||
static float lightQuadraticRadiusMult;
|
|
||||||
|
|
||||||
static bool lightOutQuadInLin;
|
|
||||||
|
|
||||||
ESMS::CellStore<MWWorld::RefData> &cell;
|
|
||||||
MWWorld::Environment &mEnvironment;
|
|
||||||
OEngine::Render::OgreRenderer& mRenderer;
|
|
||||||
Ogre::SceneNode *mMwRoot;
|
|
||||||
MWWorld::PhysicsSystem *mPhysics;
|
|
||||||
|
|
||||||
/// The scene node that contains all objects belonging to this
|
|
||||||
/// cell.
|
|
||||||
Ogre::SceneNode *base;
|
|
||||||
|
|
||||||
Ogre::SceneNode *insert;
|
|
||||||
std::string mInsertMesh;
|
|
||||||
Ogre::SceneNode *npcPart;
|
|
||||||
|
|
||||||
// 0 normal, 1 more bright, 2 max
|
|
||||||
int ambientMode;
|
|
||||||
|
|
||||||
Ogre::ColourValue ambientColor;
|
|
||||||
|
|
||||||
/// start inserting a new reference.
|
|
||||||
virtual void insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_ = false);
|
|
||||||
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements);
|
|
||||||
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements);
|
|
||||||
/// insert a mesh related to the most recent insertBegin call.
|
|
||||||
virtual void insertMesh(const std::string &mesh);
|
|
||||||
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements);
|
|
||||||
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst);
|
|
||||||
|
|
||||||
virtual void insertObjectPhysics();
|
|
||||||
|
|
||||||
virtual void insertActorPhysics();
|
|
||||||
|
|
||||||
/// 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 (bool Enable);
|
|
||||||
|
|
||||||
/// configure lighting according to cell
|
|
||||||
void configureAmbient();
|
|
||||||
|
|
||||||
/// configure fog according to cell
|
|
||||||
void configureFog();
|
|
||||||
|
|
||||||
void setAmbientMode();
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
InteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment,
|
|
||||||
OEngine::Render::OgreRenderer& renderer, Ogre::SceneNode *mwRoot, MWWorld::PhysicsSystem *physics)
|
|
||||||
: cell(_cell), mEnvironment (environment), mRenderer(renderer), base(NULL), insert(NULL), ambientMode (0)
|
|
||||||
{
|
|
||||||
mMwRoot = mwRoot;
|
|
||||||
mPhysics = physics;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~InteriorCellRender() { destroy(); }
|
|
||||||
|
|
||||||
/// Make the cell visible. Load the cell if necessary.
|
|
||||||
//virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements);
|
|
||||||
virtual void show();
|
|
||||||
|
|
||||||
/// Remove the cell from rendering, but don't remove it from
|
|
||||||
/// memory.
|
|
||||||
virtual void hide();
|
|
||||||
|
|
||||||
/// Destroy all rendering objects connected with this cell.
|
|
||||||
virtual void destroy(); // comment by Zini: shouldn't this go into the destructor?
|
|
||||||
|
|
||||||
/// Switch through lighting modes.
|
|
||||||
void toggleLight();
|
|
||||||
|
|
||||||
/// Make the reference with the given handle visible.
|
|
||||||
virtual void enable (const std::string& handle);
|
|
||||||
|
|
||||||
/// Make the reference with the given handle invisible.
|
|
||||||
virtual void disable (const std::string& handle);
|
|
||||||
|
|
||||||
/// Remove the reference with the given handle permanently from the scene.
|
|
||||||
virtual void deleteObject (const std::string& handle);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
Player::Player (Ogre::Camera *camera, const std::string& handle)
|
Player::Player (Ogre::Camera *camera, Ogre::SceneNode* node)
|
||||||
: mCamera (camera), mHandle (handle)
|
: mCamera (camera), mNode (node)
|
||||||
{}
|
{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define GAME_MWRENDER_PLAYER_H
|
#define GAME_MWRENDER_PLAYER_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <Ogre.h>
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
{
|
{
|
||||||
|
@ -14,15 +15,16 @@ namespace MWRender
|
||||||
class Player
|
class Player
|
||||||
{
|
{
|
||||||
Ogre::Camera *mCamera;
|
Ogre::Camera *mCamera;
|
||||||
std::string mHandle;
|
Ogre::SceneNode* mNode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Player (Ogre::Camera *camera, const std::string& handle);
|
Player (Ogre::Camera *camera, Ogre::SceneNode* mNode);
|
||||||
|
|
||||||
Ogre::Camera *getCamera() { return mCamera; }
|
Ogre::Camera *getCamera() { return mCamera; }
|
||||||
|
|
||||||
std::string getHandle() const { return mHandle; }
|
std::string getHandle() const { return mNode->getName(); }
|
||||||
|
Ogre::SceneNode* getNode() {return mNode;}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
||||||
Ogre::SceneNode *cameraPitchNode = cameraYawNode->createChildSceneNode();
|
Ogre::SceneNode *cameraPitchNode = cameraYawNode->createChildSceneNode();
|
||||||
cameraPitchNode->attachObject(rend.getCamera());
|
cameraPitchNode->attachObject(rend.getCamera());
|
||||||
|
|
||||||
mPlayer = new MWRender::Player (rend.getCamera(), playerNode->getName());
|
mPlayer = new MWRender::Player (rend.getCamera(), playerNode);
|
||||||
|
|
||||||
//std::cout << "Three";
|
//std::cout << "Three";
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,8 @@ namespace MWWorld
|
||||||
playerPos[0] = playerPos[1] = playerPos[2] = 0;
|
playerPos[0] = playerPos[1] = playerPos[2] = 0;
|
||||||
|
|
||||||
std::cout << renderer->getHandle();
|
std::cout << renderer->getHandle();
|
||||||
mPlayer.mData.setHandle (renderer->getHandle());
|
|
||||||
|
mPlayer.mData.setBaseNode(renderer->getNode());
|
||||||
/// \todo Do not make a copy of classes defined in esm/p records.
|
/// \todo Do not make a copy of classes defined in esm/p records.
|
||||||
mClass = new ESM::Class (*world.getStore().classes.find (player->cls));
|
mClass = new ESM::Class (*world.getStore().classes.find (player->cls));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include "scene.hpp"
|
#include "scene.hpp"
|
||||||
#include "world.hpp"
|
#include "world.hpp"
|
||||||
|
|
||||||
#include "../mwrender/interior.hpp"
|
|
||||||
#include "../mwrender/exterior.hpp"
|
|
||||||
|
|
||||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
#include <components/files/collections.hpp>
|
#include <components/files/collections.hpp>
|
||||||
|
|
||||||
#include "../mwrender/sky.hpp"
|
#include "../mwrender/sky.hpp"
|
||||||
#include "../mwrender/interior.hpp"
|
|
||||||
#include "../mwrender/exterior.hpp"
|
|
||||||
#include "../mwrender/player.hpp"
|
#include "../mwrender/player.hpp"
|
||||||
|
|
||||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||||
|
|
Loading…
Reference in a new issue