mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
Merge remote branch 'jhooks/mwrender' into mwrender
Conflicts: apps/openmw/engine.cpp - fixed code that did not compile - removed tons of tabs - more clean up
This commit is contained in:
commit
51d5c7cd59
76 changed files with 1413 additions and 2204 deletions
|
@ -16,7 +16,7 @@ set(GAME_HEADER
|
|||
source_group(game FILES ${GAME} ${GAME_HEADER})
|
||||
|
||||
add_openmw_dir (mwrender
|
||||
rendering_manager mwscene cellimp interior exterior sky player
|
||||
renderingmanager debugging sky player npcs creatures objects renderinginterface
|
||||
)
|
||||
|
||||
add_openmw_dir (mwinput
|
||||
|
|
|
@ -68,6 +68,7 @@ void OMW::Engine::executeLocalScripts()
|
|||
|
||||
void OMW::Engine::updateFocusReport (float duration)
|
||||
{
|
||||
|
||||
if ((mFocusTDiff += duration)>0.25)
|
||||
{
|
||||
mFocusTDiff = 0;
|
||||
|
@ -80,8 +81,10 @@ void OMW::Engine::updateFocusReport (float duration)
|
|||
{
|
||||
MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle);
|
||||
|
||||
if (!ptr.isEmpty())
|
||||
if (!ptr.isEmpty()){
|
||||
name = MWWorld::Class::get (ptr).getName (ptr);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (name!=mFocusName)
|
||||
|
@ -284,6 +287,7 @@ void OMW::Engine::setReportFocus (bool report)
|
|||
|
||||
void OMW::Engine::go()
|
||||
{
|
||||
mFocusTDiff = 0;
|
||||
assert (!mEnvironment.mWorld);
|
||||
assert (!mCellName.empty());
|
||||
assert (!mMaster.empty());
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
#include "activator.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
#include <components/esm/loadacti.hpp>
|
||||
|
||||
|
@ -7,27 +8,39 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Activator::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Activator::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Activator>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
||||
void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Activator>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string Activator::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -9,10 +9,11 @@ namespace MWClass
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -8,29 +8,41 @@
|
|||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "containerutil.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Apparatus::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Apparatus>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
||||
void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Apparatus>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string Apparatus::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_APPARATUS_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -9,10 +10,11 @@ namespace MWClass
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -8,29 +8,40 @@
|
|||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "containerutil.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Armor::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Armor>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
||||
void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Armor>();
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string Armor::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_ARMOR_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -9,10 +10,11 @@ namespace MWClass
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -8,29 +8,41 @@
|
|||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "containerutil.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Book::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Book>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
||||
void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Book>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string Book::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_BOOK_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -9,10 +10,11 @@ namespace MWClass
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -8,29 +8,41 @@
|
|||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "containerutil.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Clothing::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Clothing>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
||||
void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Clothing>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string Clothing::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_CLOTHING_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -9,10 +10,11 @@ namespace MWClass
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -7,27 +7,38 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Container::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Container::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Container>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
||||
void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Container>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string Container::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_CONTAINER_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -9,10 +10,11 @@ namespace MWClass
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "../mwworld/actiontalk.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||
|
||||
|
@ -23,21 +22,36 @@ namespace MWClass
|
|||
return ref->base->mId;
|
||||
}
|
||||
|
||||
void Creature::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Creature::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
/*
|
||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Creature>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh("meshes\\" + model);
|
||||
cellRender.insertActorPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Creatures& creatures = renderingInterface.getCreatures();
|
||||
//creatures.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
//creatures.insertMesh(ptr, "meshes\\" + model);
|
||||
}*/
|
||||
}
|
||||
|
||||
void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
/*
|
||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Creature>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertActorPhysics(ptr, "meshes\\" + model);
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
void Creature::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_CREATURE_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/creatures.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -12,10 +13,11 @@ namespace MWClass
|
|||
virtual std::string getId (const MWWorld::Ptr& ptr) const;
|
||||
///< Return ID of \a ptr
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
|
||||
///< Enable reference; only does the non-rendering part
|
||||
|
||||
|
|
|
@ -12,29 +12,42 @@
|
|||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/world.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Door::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Door::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Door>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
||||
void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Door>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string Door::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_DOOR_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -9,10 +10,11 @@ namespace MWClass
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -8,29 +8,42 @@
|
|||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "containerutil.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Ingredient::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Ingredient>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
||||
void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Ingredient>();
|
||||
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string Ingredient::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_INGREDIENT_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -9,10 +10,11 @@ namespace MWClass
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -10,41 +10,48 @@
|
|||
#include "../mwworld/nullaction.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
#include "containerutil.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Light::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Light::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Light>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
|
||||
// Extract the color and convert to floating point
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
const int color = ref->base->data.color;
|
||||
const float r = ((color >> 0) & 0xFF) / 255.0f;
|
||||
const float g = ((color >> 8) & 0xFF) / 255.0f;
|
||||
const float b = ((color >> 16) & 0xFF) / 255.0f;
|
||||
const float radius = float (ref->base->data.radius);
|
||||
cellRender.insertLight (r, g, b, radius);
|
||||
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
objects.insertLight (ptr, r, g, b, radius);
|
||||
}
|
||||
}
|
||||
|
||||
void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Light>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Light::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_LIGHT_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -9,10 +10,11 @@ namespace MWClass
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
|
||||
///< Enable reference; only does the non-rendering part
|
||||
/// \attention This is not the same as the script instruction with the same name. References
|
||||
|
|
|
@ -8,29 +8,41 @@
|
|||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "containerutil.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Lockpick::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Tool>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
||||
void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Tool>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
std::string Lockpick::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_LOCKPICK_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -9,10 +10,11 @@ namespace MWClass
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -8,29 +8,40 @@
|
|||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "containerutil.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Miscellaneous::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Miscellaneous>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
||||
void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Miscellaneous>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string Miscellaneous::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_MISC_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -9,10 +10,11 @@ namespace MWClass
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/world.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||
#include <OgreSceneNode.h>
|
||||
|
||||
|
@ -32,229 +30,37 @@ namespace MWClass
|
|||
return ref->base->mId;
|
||||
}
|
||||
|
||||
void Npc::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
//Ogre::SceneNode *chest;
|
||||
/*
|
||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::NPC>();
|
||||
|
||||
//Store scenenodes by npc's name + bodypart [0] , npc's name + bodypart [1]
|
||||
//Ex. Fargothchest , Fargothneck
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
std::string hairID = ref->base->hair;
|
||||
std::string headID = ref->base->head;
|
||||
|
||||
// very ugly workaround to stop OGRE from chocking on non-unique scene node handles
|
||||
static int uniqueId = 0;
|
||||
|
||||
std::ostringstream stream;
|
||||
stream << "npc$" << uniqueId++;
|
||||
|
||||
std::string npcName = stream.str(); // ref->base->name;
|
||||
//std::cout << "NPC: " << npcName << "\n";
|
||||
|
||||
//get the part of the bodypart id which describes the race and the gender
|
||||
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
|
||||
std::string headModel = "meshes\\" +
|
||||
environment.mWorld->getStore().bodyParts.find(headID)->model;
|
||||
|
||||
std::string hairModel = "meshes\\" +
|
||||
environment.mWorld->getStore().bodyParts.find(hairID)->model;
|
||||
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
|
||||
|
||||
//TODO: define consts for each bodypart e.g. chest, foot, wrist... and put the parts in the
|
||||
// right place
|
||||
const ESM::BodyPart *bodyPart =
|
||||
environment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest");
|
||||
|
||||
//bodyPart->model->
|
||||
Ogre::Vector3 pos = Ogre::Vector3( 20, 20, 20);
|
||||
Ogre::Vector3 axis = Ogre::Vector3( 0, 0, 1);
|
||||
Ogre::Radian angle = Ogre::Radian(0);
|
||||
|
||||
std::string addresses[6] = {"", "", "", "","", ""};
|
||||
std::string addresses2[6] = {"", "", "", "", "", ""};
|
||||
std::string upperleft[5] = {"", "", "", "", ""};
|
||||
std::string upperright[5] = {"", "", "", "", ""};
|
||||
std::string neckandup[5] = {"", "", "","",""};
|
||||
int numbers = 0;
|
||||
int uppernumbers = 0;
|
||||
int neckNumbers = 0;
|
||||
|
||||
if (bodyPart){
|
||||
|
||||
cellRender.insertMesh("meshes\\" + bodyPart->model, pos, axis, angle, npcName + "chest", addresses, numbers, true); //2 0
|
||||
addresses2[numbers] = npcName + "chest";
|
||||
addresses[numbers++] = npcName + "chest";
|
||||
upperleft[uppernumbers] = npcName + "chest";
|
||||
upperright[uppernumbers++] = npcName + "chest";
|
||||
neckandup[neckNumbers++] = npcName + "chest";
|
||||
}
|
||||
|
||||
|
||||
const ESM::BodyPart *upperleg = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg");
|
||||
const ESM::BodyPart *groin = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin");
|
||||
const ESM::BodyPart *arm = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm");
|
||||
const ESM::BodyPart *neck = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "neck");
|
||||
const ESM::BodyPart *knee = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee");
|
||||
const ESM::BodyPart *ankle = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle");
|
||||
const ESM::BodyPart *foot = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot");
|
||||
const ESM::BodyPart *feet = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet");
|
||||
const ESM::BodyPart *tail = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "tail");
|
||||
const ESM::BodyPart *wrist = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist");
|
||||
const ESM::BodyPart *forearm = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm");
|
||||
const ESM::BodyPart *hand = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand.1st");
|
||||
const ESM::BodyPart *hands = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands.1st");
|
||||
|
||||
|
||||
Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75);
|
||||
|
||||
if (groin){
|
||||
cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers);
|
||||
addresses2[numbers] = npcName + "groin";
|
||||
addresses[numbers++] = npcName + "groin";
|
||||
}
|
||||
if (tail) {
|
||||
cellRender.insertMesh("tail\\" + tail->model, Ogre::Vector3(0 , 0, -76), axis, kOgrePi, npcName + "tail", addresses, numbers, "tail");
|
||||
}
|
||||
|
||||
|
||||
if(upperleg){
|
||||
cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( 6, 0, -16), axis, kOgrePi, npcName + "upper leg", addresses, numbers); //-18
|
||||
cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( -6, 0, -16), axis, Ogre::Radian(0), npcName + "upper leg2", addresses2, numbers);
|
||||
addresses2[numbers] = npcName + "upper leg2";
|
||||
addresses[numbers++] = npcName + "upper leg";
|
||||
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers);
|
||||
}
|
||||
if(knee)
|
||||
if (!model.empty())
|
||||
{
|
||||
cellRender.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -1, -23), axis, Ogre::Radian(0), npcName + "knee", addresses, numbers);
|
||||
//cellRender.rotateMesh(Ogre::Vector3(0, 1, 0), Ogre::Radian (1), npcName + "upper arm");
|
||||
cellRender.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -1, -23), axis, Ogre::Radian(0), npcName + "knee2", addresses2, numbers);
|
||||
|
||||
addresses2[numbers] = npcName + "knee2";
|
||||
addresses[numbers++] = npcName + "knee";
|
||||
MWRender::Npcs& npcs = renderingInterface.getNPCs();
|
||||
//npcs.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
//npcs.insertMesh(ptr, "meshes\\" + model);
|
||||
}*/
|
||||
}
|
||||
if(ankle){
|
||||
|
||||
cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0, 0, -20), axis, Ogre::Radian(0), npcName + "ankle", addresses, numbers); //-1
|
||||
cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0,0, -20), axis, Ogre::Radian(0), npcName + "ankle2", addresses2, numbers); //-1
|
||||
|
||||
addresses2[numbers] = npcName + "ankle2";
|
||||
addresses[numbers++] = npcName + "ankle";
|
||||
}
|
||||
if(foot){
|
||||
if(bodyRaceID.compare("b_n_khajiit_m_") == 0)
|
||||
void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
feet = foot;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -4, -15), axis, Ogre::Radian(0), npcName + "foot", addresses, numbers);
|
||||
|
||||
cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -4, -15), axis, Ogre::Radian(0), npcName + "foot2", addresses2, numbers);
|
||||
addresses2[numbers] = npcName + "foot2";
|
||||
addresses[numbers++] = npcName + "foot";
|
||||
}
|
||||
//cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers);
|
||||
}
|
||||
if(feet){
|
||||
|
||||
cellRender.insertMesh ("foot\\" + feet->model, Ogre::Vector3( 7, 4, -16), axis, kOgrePi, npcName + "foot", addresses, numbers); //9, 0, -14
|
||||
|
||||
cellRender.insertMesh ("foot\\" + feet->model, Ogre::Vector3( 7, 4, -16), axis, kOgrePi, npcName + "foot2", addresses2, numbers);
|
||||
addresses2[numbers] = npcName + "foot2";
|
||||
addresses[numbers++] = npcName + "foot";
|
||||
//cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers);
|
||||
}
|
||||
/*
|
||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::NPC>();
|
||||
|
||||
|
||||
if (arm){
|
||||
//010
|
||||
cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(-12.5, 0, 104), Ogre::Vector3(0, 1, 0), -kOgrePiOverTwo, npcName + "upper arm", upperleft, uppernumbers); //1, 0,.75
|
||||
//cellRender.rotateMesh(Ogre::Vector3(1, 0, 0), Ogre::Radian (.45), upperarmpath, 2); //-.5, 0, -.75
|
||||
cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(12.5, 0, 105), Ogre::Vector3(-.5, 0, -.75), kOgrePi, npcName + "upper arm2", upperright, uppernumbers);
|
||||
upperleft[uppernumbers] = npcName + "upper arm";
|
||||
upperright[uppernumbers++] = npcName + "upper arm2";
|
||||
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); //1 -1 1
|
||||
cellRender.rotateMesh(Ogre::Vector3(0, .1, 0), kOgrePiOverTwo, upperleft, uppernumbers);
|
||||
}
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertActorPhysics(ptr, "meshes\\" + model);
|
||||
}*/
|
||||
|
||||
if (forearm)
|
||||
{
|
||||
//addresses[1] = npcName + "upper arm";
|
||||
cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "forearm", upperleft, uppernumbers);
|
||||
cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "forearm2", upperright, uppernumbers);
|
||||
upperleft[uppernumbers] = npcName + "forearm";
|
||||
upperright[uppernumbers++] = npcName + "forearm2";
|
||||
}
|
||||
//else
|
||||
// std::cout << npcName << "has no forearm";
|
||||
if (wrist)
|
||||
{
|
||||
if(upperleft[uppernumbers - 1].compare(npcName + "upper arm") == 0)
|
||||
{
|
||||
cellRender.insertMesh("meshes\\b\\B_N_Argonian_M_Forearm.nif", Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "forearm", upperleft, uppernumbers);
|
||||
cellRender.insertMesh("meshes\\b\\B_N_Argonian_M_Forearm.nif", Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "forearm2", upperright, uppernumbers);
|
||||
upperleft[uppernumbers] = npcName + "forearm";
|
||||
upperright[uppernumbers++] = npcName + "forearm2";
|
||||
|
||||
}
|
||||
cellRender.insertMesh("meshes\\" + wrist->model, Ogre::Vector3(-9.5, 0, 0), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "wrist", upperleft, uppernumbers);
|
||||
cellRender.insertMesh("meshes\\" + wrist->model, Ogre::Vector3(-9.5, 0, 0), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "wrist2", upperright, uppernumbers);
|
||||
upperleft[uppernumbers] = npcName + "wrist";
|
||||
upperright[uppernumbers++] = npcName + "wrist2";
|
||||
}
|
||||
|
||||
|
||||
if(hand)
|
||||
{
|
||||
std::string pass;
|
||||
if(hand->model.compare("b\\B_N_Dark Elf_F_Hands.1st.NIF")==0 && bodyRaceID.compare("b_n_dark elf_m_") == 0)
|
||||
pass = "b\\B_N_Dark Elf_M_Hands.1st.NIF";
|
||||
else
|
||||
pass = hand->model;
|
||||
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "hand", upperleft, uppernumbers,false); //0, 100, -100 0,0,120
|
||||
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0,0), kOgrePi, npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120
|
||||
upperleft[uppernumbers] = npcName + "hand";
|
||||
upperright[uppernumbers++] = npcName + "hand2";
|
||||
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers);
|
||||
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers);
|
||||
}
|
||||
if(hands)
|
||||
{
|
||||
std::string pass;
|
||||
if(hands->model.compare("b\\B_N_Redguard_F_Hands.1st.nif")==0 && bodyRaceID.compare("b_n_redguard_m_") == 0)
|
||||
pass = "b\\B_N_Redguard_M_Hands.1st.nif";
|
||||
else if(hands->model.compare("b\\B_N_Imperial_M_Hands.1st.nif") == 0 && bodyRaceID.compare("b_n_nord_m_") == 0)
|
||||
pass = "b\\B_N_Nord_M_Hands.1st.nif";
|
||||
else
|
||||
pass =hands->model; //-50, 0, -120
|
||||
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1,-110), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110
|
||||
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120
|
||||
upperleft[uppernumbers] = npcName + "hand";
|
||||
upperright[uppernumbers++] = npcName + "hand2";
|
||||
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers);
|
||||
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers);
|
||||
}
|
||||
|
||||
//neck will reset chest counter
|
||||
if(neck)
|
||||
{
|
||||
cellRender.insertMesh ("meshes\\" + neck->model, Ogre::Vector3( 0, 0, 120), axis, kOgrePi, npcName + "neck", neckandup, neckNumbers);
|
||||
neckandup[neckNumbers++] = npcName + "neck";
|
||||
}
|
||||
cellRender.insertMesh (headModel, Ogre::Vector3( 0, 0, 5), axis, Ogre::Radian(0), npcName + "head", neckandup, neckNumbers);
|
||||
neckandup[neckNumbers++] = npcName + "head";
|
||||
cellRender.insertMesh (hairModel, Ogre::Vector3( 0, -1, 0), axis, Ogre::Radian(0), npcName + "hair", neckandup, neckNumbers);
|
||||
|
||||
cellRender.insertActorPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
}
|
||||
|
||||
void Npc::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_NPC_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/npcs.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -12,10 +13,11 @@ namespace MWClass
|
|||
virtual std::string getId (const MWWorld::Ptr& ptr) const;
|
||||
///< Return ID of \a ptr
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
|
||||
///< Enable reference; only does the non-rendering part
|
||||
|
||||
|
|
|
@ -8,29 +8,41 @@
|
|||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "containerutil.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Potion::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Potion>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
||||
void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Potion>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string Potion::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_POTION_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -9,10 +10,11 @@ namespace MWClass
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -8,29 +8,42 @@
|
|||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "containerutil.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Probe::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Probe>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
||||
void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Probe>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
std::string Probe::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
|
||||
|
@ -38,7 +51,6 @@ namespace MWClass
|
|||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
|
||||
{
|
||||
|
|
|
@ -3,16 +3,18 @@
|
|||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Probe : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -8,29 +8,40 @@
|
|||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "containerutil.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Repair::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Repair>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
||||
void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Repair>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string Repair::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_REPAIR_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -9,10 +10,11 @@ namespace MWClass
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -5,27 +5,39 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Static::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Static::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Static, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Static>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData, true);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
||||
void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Static, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Static>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string Static::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
return "";
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_STATIC_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -9,10 +10,11 @@ namespace MWClass
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -8,29 +8,41 @@
|
|||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "containerutil.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Weapon::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Weapon>();
|
||||
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
||||
void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Weapon>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string Weapon::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWCLASS_WEAPON_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -9,10 +10,11 @@ namespace MWClass
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -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
|
2
apps/openmw/mwrender/creatures.cpp
Normal file
2
apps/openmw/mwrender/creatures.cpp
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "creatures.hpp"
|
||||
using namespace MWRender;
|
10
apps/openmw/mwrender/creatures.hpp
Normal file
10
apps/openmw/mwrender/creatures.hpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef _GAME_RENDER_CREATURES_H
|
||||
#define _GAME_RENDER_CREATURES_H
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
|
||||
namespace MWRender{
|
||||
class Creatures{
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
38
apps/openmw/mwrender/debugging.cpp
Normal file
38
apps/openmw/mwrender/debugging.cpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
#include "debugging.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "OgreRoot.h"
|
||||
#include "OgreRenderWindow.h"
|
||||
#include "OgreSceneManager.h"
|
||||
#include "OgreViewport.h"
|
||||
#include "OgreCamera.h"
|
||||
#include "OgreTextureManager.h"
|
||||
|
||||
#include "../mwworld/world.hpp" // these includes can be removed once the static-hack is gone
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include <components/esm/loadstat.hpp>
|
||||
|
||||
#include "player.hpp"
|
||||
|
||||
using namespace MWRender;
|
||||
using namespace Ogre;
|
||||
|
||||
Debugging::Debugging(OEngine::Physic::PhysicEngine* engine){
|
||||
eng = engine;
|
||||
}
|
||||
|
||||
|
||||
bool Debugging::toggleRenderMode (int mode){
|
||||
switch (mode)
|
||||
{
|
||||
case MWWorld::World::Render_CollisionDebug:
|
||||
|
||||
// TODO use a proper function instead of accessing the member variable
|
||||
// directly.
|
||||
eng->setDebugRenderingMode (!eng->isDebugCreated);
|
||||
return eng->isDebugCreated;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
43
apps/openmw/mwrender/debugging.hpp
Normal file
43
apps/openmw/mwrender/debugging.hpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
#ifndef _GAME_RENDER_MWSCENE_H
|
||||
#define _GAME_RENDER_MWSCENE_H
|
||||
|
||||
#include <utility>
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
#include <openengine/bullet/physic.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class Camera;
|
||||
class Viewport;
|
||||
class SceneManager;
|
||||
class SceneNode;
|
||||
class RaySceneQuery;
|
||||
class Quaternion;
|
||||
class Vector3;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class World;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
class Player;
|
||||
|
||||
class Debugging{
|
||||
OEngine::Physic::PhysicEngine* eng;
|
||||
|
||||
|
||||
public:
|
||||
Debugging(OEngine::Physic::PhysicEngine* engine);
|
||||
bool toggleRenderMode (int mode);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,454 +0,0 @@
|
|||
#include "exterior.hpp"
|
||||
|
||||
#include <OgreEntity.h>
|
||||
#include <OgreLight.h>
|
||||
#include <OgreSceneNode.h>
|
||||
#include <OgreCamera.h>
|
||||
#include <OgreSceneManager.h>
|
||||
|
||||
#include <components/nifogre/ogre_nif_loader.hpp>
|
||||
#include "mwscene.hpp"
|
||||
#include <libs/mangle/vfs/servers/ogre_vfs.hpp>
|
||||
#include "mwscene.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,
|
||||
MWScene &_scene, MWWorld::PhysicsSystem *physics)
|
||||
: mCell(_cell), mEnvironment (environment), mScene(_scene), mPhysics(physics), mBase(NULL), mInsert(NULL), mAmbientMode (0)
|
||||
{
|
||||
uniqueID = uniqueID +1;
|
||||
sg = mScene.getMgr()->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 = mScene.getMgr()->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 = mScene.getMgr()->createEntity(mesh);
|
||||
|
||||
if(!isStatic)
|
||||
{
|
||||
mInsert->attachObject(ent);
|
||||
}
|
||||
else
|
||||
{
|
||||
sg->addEntity(ent,mInsert->_getDerivedPosition(),mInsert->_getDerivedOrientation(),mInsert->_getDerivedScale());
|
||||
sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000));
|
||||
mScene.getMgr()->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 = mScene.getMgr()->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 = mScene.getMgr()->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;
|
||||
|
||||
mScene.getMgr()->setFog (FOG_LINEAR, color, 0, low, high);
|
||||
mScene.getCamera()->setFarClipDistance (high + 10);
|
||||
mScene.getViewport()->setBackgroundColour (color);
|
||||
}
|
||||
|
||||
void ExteriorCellRender::setAmbientMode()
|
||||
{
|
||||
switch (mAmbientMode)
|
||||
{
|
||||
case 0:
|
||||
|
||||
mScene.getMgr()->setAmbientLight(mAmbientColor);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
mScene.getMgr()->setAmbientLight(0.7f*mAmbientColor + 0.3f*ColourValue(1,1,1));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
mScene.getMgr()->setAmbientLight(ColourValue(1,1,1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ExteriorCellRender::show()
|
||||
{
|
||||
// FIXME: this one may be the bug
|
||||
mBase = mScene.getRoot()->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();
|
||||
mScene.getMgr()->destroySceneNode(mBase);
|
||||
}
|
||||
|
||||
mBase = 0;
|
||||
|
||||
if (sg)
|
||||
{
|
||||
mScene.getMgr()->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())
|
||||
mScene.getMgr()->getSceneNode (handle)->setVisible (true);
|
||||
}
|
||||
|
||||
void ExteriorCellRender::disable (const std::string& handle)
|
||||
{
|
||||
if (!handle.empty())
|
||||
mScene.getMgr()->getSceneNode (handle)->setVisible (false);
|
||||
}
|
||||
|
||||
void ExteriorCellRender::deleteObject (const std::string& handle)
|
||||
{
|
||||
if (!handle.empty())
|
||||
{
|
||||
Ogre::SceneNode *node = mScene.getMgr()->getSceneNode (handle);
|
||||
node->removeAndDestroyAllChildren();
|
||||
mScene.getMgr()->destroySceneNode (node);
|
||||
}
|
||||
}
|
|
@ -1,138 +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 MWScene;
|
||||
|
||||
/**
|
||||
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;
|
||||
MWScene &mScene;
|
||||
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,
|
||||
MWScene &_scene, 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 <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 "mwscene.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 = scene.getMgr()->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 = scene.getMgr()->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 = scene.getMgr()->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 = scene.getMgr()->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;
|
||||
|
||||
scene.getMgr()->setFog (FOG_LINEAR, color, 0, low, high);
|
||||
scene.getCamera()->setFarClipDistance (high + 10);
|
||||
scene.getViewport()->setBackgroundColour (color);
|
||||
}
|
||||
|
||||
void InteriorCellRender::setAmbientMode()
|
||||
{
|
||||
switch (ambientMode)
|
||||
{
|
||||
case 0:
|
||||
|
||||
scene.getMgr()->setAmbientLight(ambientColor);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
scene.getMgr()->setAmbientLight(0.7f*ambientColor + 0.3f*ColourValue(1,1,1));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
scene.getMgr()->setAmbientLight(ColourValue(1,1,1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void InteriorCellRender::show()
|
||||
{
|
||||
base = scene.getRoot()->createChildSceneNode();
|
||||
|
||||
configureAmbient();
|
||||
configureFog();
|
||||
|
||||
insertCell(cell, mEnvironment);
|
||||
}
|
||||
|
||||
void InteriorCellRender::hide()
|
||||
{
|
||||
if(base)
|
||||
base->setVisible(false);
|
||||
}
|
||||
|
||||
void InteriorCellRender::destroy()
|
||||
{
|
||||
if(base)
|
||||
{
|
||||
base->removeAndDestroyAllChildren();
|
||||
scene.getMgr()->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())
|
||||
scene.getMgr()->getSceneNode (handle)->setVisible (true);
|
||||
}
|
||||
|
||||
void InteriorCellRender::disable (const std::string& handle)
|
||||
{
|
||||
if (!handle.empty())
|
||||
scene.getMgr()->getSceneNode (handle)->setVisible (false);
|
||||
}
|
||||
|
||||
void InteriorCellRender::deleteObject (const std::string& handle)
|
||||
{
|
||||
if (!handle.empty())
|
||||
{
|
||||
Ogre::SceneNode *node = scene.getMgr()->getSceneNode (handle);
|
||||
node->removeAndDestroyAllChildren();
|
||||
scene.getMgr()->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,131 +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 MWScene;
|
||||
|
||||
/**
|
||||
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;
|
||||
MWScene &scene;
|
||||
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,
|
||||
MWScene &_scene, MWWorld::PhysicsSystem *physics)
|
||||
: cell(_cell), mEnvironment (environment), scene(_scene), base(NULL), insert(NULL), ambientMode (0)
|
||||
{
|
||||
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
|
|
@ -1,89 +0,0 @@
|
|||
#include "mwscene.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "OgreRoot.h"
|
||||
#include "OgreRenderWindow.h"
|
||||
#include "OgreSceneManager.h"
|
||||
#include "OgreViewport.h"
|
||||
#include "OgreCamera.h"
|
||||
#include "OgreTextureManager.h"
|
||||
|
||||
#include "../mwworld/world.hpp" // these includes can be removed once the static-hack is gone
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include <components/esm/loadstat.hpp>
|
||||
|
||||
#include "player.hpp"
|
||||
|
||||
using namespace MWRender;
|
||||
using namespace Ogre;
|
||||
|
||||
MWScene::MWScene(OEngine::Render::OgreRenderer &_rend , OEngine::Physic::PhysicEngine* physEng)
|
||||
: rend(_rend)
|
||||
{
|
||||
eng = physEng;
|
||||
rend.createScene("PlayerCam", 55, 5);
|
||||
|
||||
// Set default mipmap level (NB some APIs ignore this)
|
||||
TextureManager::getSingleton().setDefaultNumMipmaps(5);
|
||||
|
||||
// Load resources
|
||||
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
|
||||
|
||||
// Turn the entire scene (represented by the 'root' node) -90
|
||||
// degrees around the x axis. This makes Z go upwards, and Y go into
|
||||
// the screen (when x is to the right.) This is the orientation that
|
||||
// Morrowind uses, and it automagically makes everything work as it
|
||||
// should.
|
||||
SceneNode *rt = rend.getScene()->getRootSceneNode();
|
||||
mwRoot = rt->createChildSceneNode();
|
||||
mwRoot->pitch(Degree(-90));
|
||||
|
||||
//used to obtain ingame information of ogre objects (which are faced or selected)
|
||||
mRaySceneQuery = rend.getScene()->createRayQuery(Ray());
|
||||
|
||||
Ogre::SceneNode *playerNode = mwRoot->createChildSceneNode ("player");
|
||||
playerNode->pitch(Degree(90));
|
||||
Ogre::SceneNode *cameraYawNode = playerNode->createChildSceneNode();
|
||||
Ogre::SceneNode *cameraPitchNode = cameraYawNode->createChildSceneNode();
|
||||
cameraPitchNode->attachObject(getCamera());
|
||||
|
||||
|
||||
mPlayer = new MWRender::Player (getCamera(), playerNode->getName());
|
||||
}
|
||||
|
||||
MWScene::~MWScene()
|
||||
{
|
||||
delete mPlayer;
|
||||
}
|
||||
|
||||
std::pair<std::string, float> MWScene::getFacedHandle (MWWorld::World& world)
|
||||
{
|
||||
std::string handle = "";
|
||||
|
||||
//get a ray pointing to the center of the viewport
|
||||
Ray centerRay = getCamera()->getCameraToViewportRay(
|
||||
getViewport()->getWidth()/2,
|
||||
getViewport()->getHeight()/2);
|
||||
//let's avoid the capsule shape of the player.
|
||||
centerRay.setOrigin(centerRay.getOrigin() + 20*centerRay.getDirection());
|
||||
btVector3 from(centerRay.getOrigin().x,-centerRay.getOrigin().z,centerRay.getOrigin().y);
|
||||
btVector3 to(centerRay.getPoint(500).x,-centerRay.getPoint(500).z,centerRay.getPoint(500).y);
|
||||
|
||||
return eng->rayTest(from,to);
|
||||
}
|
||||
|
||||
bool MWScene::toggleRenderMode (int mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case MWWorld::World::Render_CollisionDebug:
|
||||
|
||||
// TODO use a proper function instead of accessing the member variable
|
||||
// directly.
|
||||
eng->setDebugRenderingMode (!eng->isDebugCreated);
|
||||
return eng->isDebugCreated;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
#ifndef _GAME_RENDER_MWSCENE_H
|
||||
#define _GAME_RENDER_MWSCENE_H
|
||||
|
||||
#include <utility>
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
#include <openengine/bullet/physic.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class Camera;
|
||||
class Viewport;
|
||||
class SceneManager;
|
||||
class SceneNode;
|
||||
class RaySceneQuery;
|
||||
class Quaternion;
|
||||
class Vector3;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class World;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
class Player;
|
||||
|
||||
/// \brief 3D-scene (rendering and physics)
|
||||
|
||||
class MWScene
|
||||
{
|
||||
OEngine::Render::OgreRenderer &rend;
|
||||
|
||||
/// Root node for all objects added to the scene. This is rotated so
|
||||
/// that the OGRE coordinate system matches that used internally in
|
||||
/// Morrowind.
|
||||
Ogre::SceneNode *mwRoot;
|
||||
Ogre::RaySceneQuery *mRaySceneQuery;
|
||||
|
||||
OEngine::Physic::PhysicEngine* eng;
|
||||
|
||||
MWRender::Player *mPlayer;
|
||||
|
||||
public:
|
||||
|
||||
MWScene (OEngine::Render::OgreRenderer &_rend , OEngine::Physic::PhysicEngine* physEng);
|
||||
|
||||
~MWScene();
|
||||
|
||||
Ogre::Camera *getCamera() { return rend.getCamera(); }
|
||||
Ogre::SceneNode *getRoot() { return mwRoot; }
|
||||
Ogre::SceneManager *getMgr() { return rend.getScene(); }
|
||||
Ogre::Viewport *getViewport() { return rend.getViewport(); }
|
||||
Ogre::RaySceneQuery *getRaySceneQuery() { return mRaySceneQuery; }
|
||||
MWRender::Player *getPlayer() { return mPlayer; }
|
||||
|
||||
/// Gets the handle of the object the player is looking at
|
||||
/// pair<name, distance>
|
||||
/// name is empty and distance = -1 if there is no object which
|
||||
/// can be faced
|
||||
std::pair<std::string, float> getFacedHandle (MWWorld::World& world);
|
||||
|
||||
/// Toggle render mode
|
||||
/// \todo Using an int instead of a enum here to avoid cyclic includes. Will be fixed
|
||||
/// when the mw*-refactoring is done.
|
||||
/// \return Resulting mode
|
||||
bool toggleRenderMode (int mode);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
2
apps/openmw/mwrender/npcs.cpp
Normal file
2
apps/openmw/mwrender/npcs.cpp
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "npcs.hpp"
|
||||
using namespace MWRender;
|
9
apps/openmw/mwrender/npcs.hpp
Normal file
9
apps/openmw/mwrender/npcs.hpp
Normal file
|
@ -0,0 +1,9 @@
|
|||
#ifndef _GAME_RENDER_NPCS_H
|
||||
#define _GAME_RENDER_NPCS_H
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
namespace MWRender{
|
||||
class Npcs{
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
185
apps/openmw/mwrender/objects.cpp
Normal file
185
apps/openmw/mwrender/objects.cpp
Normal file
|
@ -0,0 +1,185 @@
|
|||
#include "objects.hpp"
|
||||
#include <OgreSceneNode.h>
|
||||
#include <components/nifogre/ogre_nif_loader.hpp>
|
||||
|
||||
using namespace Ogre;
|
||||
using namespace MWRender;
|
||||
|
||||
|
||||
bool Objects::lightConst = false;
|
||||
float Objects::lightConstValue = 0.0f;
|
||||
|
||||
bool Objects::lightLinear = true;
|
||||
int Objects::lightLinearMethod = 1;
|
||||
float Objects::lightLinearValue = 3;
|
||||
float Objects::lightLinearRadiusMult = 1;
|
||||
|
||||
bool Objects::lightQuadratic = false;
|
||||
int Objects::lightQuadraticMethod = 2;
|
||||
float Objects::lightQuadraticValue = 16;
|
||||
float Objects::lightQuadraticRadiusMult = 1;
|
||||
|
||||
bool Objects::lightOutQuadInLin = false;
|
||||
|
||||
int Objects::uniqueID = 0;
|
||||
|
||||
void Objects::setMwRoot(Ogre::SceneNode* root){
|
||||
mwRoot = root;
|
||||
}
|
||||
void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){
|
||||
Ogre::SceneNode* root = mwRoot;
|
||||
Ogre::SceneNode* cellnode;
|
||||
if(mCellSceneNodes.find(ptr.getCell()) == mCellSceneNodes.end())
|
||||
{
|
||||
//Create the scenenode and put it in the map
|
||||
cellnode = root->createChildSceneNode();
|
||||
mCellSceneNodes[ptr.getCell()] = cellnode;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellnode = mCellSceneNodes[ptr.getCell()];
|
||||
}
|
||||
|
||||
Ogre::SceneNode* insert = cellnode->createChildSceneNode();
|
||||
const float *f = ptr.getRefData().getPosition().pos;
|
||||
insert->setPosition(f[0], f[1], f[2]);
|
||||
insert->setScale(ptr.getCellRef().scale, ptr.getCellRef().scale, ptr.getCellRef().scale);
|
||||
|
||||
// Convert MW rotation to a quaternion:
|
||||
f = ptr.getCellRef().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);
|
||||
if (!enabled)
|
||||
insert->setVisible (false);
|
||||
ptr.getRefData().setBaseNode(insert);
|
||||
isStatic = static_;
|
||||
|
||||
|
||||
}
|
||||
void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh){
|
||||
Ogre::SceneNode* insert = ptr.getRefData().getBaseNode();
|
||||
assert(insert);
|
||||
|
||||
NifOgre::NIFLoader::load(mesh);
|
||||
Entity *ent = mRend.getScene()->createEntity(mesh);
|
||||
|
||||
if(!isStatic)
|
||||
{
|
||||
insert->attachObject(ent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ogre::StaticGeometry* sg = 0;
|
||||
if(mSG.find(ptr.getCell()) == mSG.end())
|
||||
{
|
||||
uniqueID = uniqueID +1;
|
||||
sg = mRend.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
|
||||
//Create the scenenode and put it in the map
|
||||
mSG[ptr.getCell()] = sg;
|
||||
}
|
||||
else
|
||||
{
|
||||
sg = mSG[ptr.getCell()];
|
||||
}
|
||||
|
||||
sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale());
|
||||
sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000));
|
||||
|
||||
|
||||
mRend.getScene()->destroyEntity(ent);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius){
|
||||
Ogre::SceneNode* insert = mRend.getScene()->getSceneNode(ptr.getRefData().getHandle());
|
||||
assert(insert);
|
||||
Ogre::Light *light = mRend.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);
|
||||
}
|
||||
|
||||
bool Objects::deleteObject (const MWWorld::Ptr& ptr)
|
||||
{
|
||||
if (Ogre::SceneNode *base = ptr.getRefData().getBaseNode())
|
||||
{
|
||||
Ogre::SceneNode *parent = base->getParentSceneNode();
|
||||
|
||||
for (std::map<MWWorld::Ptr::CellStore *, Ogre::SceneNode *>::const_iterator iter (
|
||||
mCellSceneNodes.begin()); iter!=mCellSceneNodes.end(); ++iter)
|
||||
if (iter->second==parent)
|
||||
{
|
||||
base->removeAndDestroyAllChildren();
|
||||
mRend.getScene()->destroySceneNode (base);
|
||||
ptr.getRefData().setBaseNode (0);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Objects::removeCell(MWWorld::Ptr::CellStore* store){
|
||||
if(mCellSceneNodes.find(store) != mCellSceneNodes.end())
|
||||
{
|
||||
Ogre::SceneNode* base = mCellSceneNodes[store];
|
||||
base->removeAndDestroyAllChildren();
|
||||
mCellSceneNodes.erase(store);
|
||||
mRend.getScene()->destroySceneNode(base);
|
||||
base = 0;
|
||||
}
|
||||
|
||||
|
||||
if(mSG.find(store) != mSG.end())
|
||||
{
|
||||
Ogre::StaticGeometry* sg = mSG[store];
|
||||
mSG.erase(store);
|
||||
mRend.getScene()->destroyStaticGeometry (sg);
|
||||
sg = 0;
|
||||
}
|
||||
}
|
||||
void Objects::buildStaticGeometry(ESMS::CellStore<MWWorld::RefData>& cell){
|
||||
if(mSG.find(&cell) != mSG.end())
|
||||
{
|
||||
Ogre::StaticGeometry* sg = mSG[&cell];
|
||||
sg->build();
|
||||
}
|
||||
}
|
48
apps/openmw/mwrender/objects.hpp
Normal file
48
apps/openmw/mwrender/objects.hpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
#ifndef _GAME_RENDER_OBJECTS_H
|
||||
#define _GAME_RENDER_OBJECTS_H
|
||||
|
||||
#include "components/esm_store/cell_store.hpp"
|
||||
|
||||
#include "../mwworld/refdata.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
|
||||
namespace MWRender{
|
||||
|
||||
class Objects{
|
||||
OEngine::Render::OgreRenderer &mRend;
|
||||
std::map<MWWorld::Ptr::CellStore *, Ogre::SceneNode *> mCellSceneNodes;
|
||||
std::map<MWWorld::Ptr::CellStore *, Ogre::StaticGeometry*> mSG;
|
||||
Ogre::SceneNode* mwRoot;
|
||||
bool isStatic;
|
||||
static int uniqueID;
|
||||
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;
|
||||
public:
|
||||
Objects(OEngine::Render::OgreRenderer& _rend): mRend(_rend){}
|
||||
~Objects(){}
|
||||
void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_);
|
||||
void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh);
|
||||
void insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius);
|
||||
|
||||
bool deleteObject (const MWWorld::Ptr& ptr);
|
||||
///< \return found?
|
||||
|
||||
void removeCell(MWWorld::Ptr::CellStore* store);
|
||||
void buildStaticGeometry(ESMS::CellStore<MWWorld::RefData> &cell);
|
||||
void setMwRoot(Ogre::SceneNode* root);
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace MWRender
|
||||
{
|
||||
Player::Player (Ogre::Camera *camera, const std::string& handle)
|
||||
: mCamera (camera), mHandle (handle)
|
||||
Player::Player (Ogre::Camera *camera, Ogre::SceneNode* node)
|
||||
: mCamera (camera), mNode (node)
|
||||
{}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWRENDER_PLAYER_H
|
||||
|
||||
#include <iostream>
|
||||
#include <Ogre.h>
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
|
@ -14,15 +15,16 @@ namespace MWRender
|
|||
class Player
|
||||
{
|
||||
Ogre::Camera *mCamera;
|
||||
std::string mHandle;
|
||||
Ogre::SceneNode* mNode;
|
||||
|
||||
public:
|
||||
|
||||
Player (Ogre::Camera *camera, const std::string& handle);
|
||||
Player (Ogre::Camera *camera, Ogre::SceneNode* mNode);
|
||||
|
||||
Ogre::Camera *getCamera() { return mCamera; }
|
||||
|
||||
std::string getHandle() const { return mHandle; }
|
||||
std::string getHandle() const { return mNode->getName(); }
|
||||
Ogre::SceneNode* getNode() {return mNode;}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
#include "rendering_manager.hpp"
|
||||
|
||||
namespace MWRender {
|
||||
|
||||
RenderingManager::RenderingManager (SkyManager *skyManager) :
|
||||
mSkyManager(skyManager)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RenderingManager::~RenderingManager ()
|
||||
{
|
||||
delete mSkyManager;
|
||||
}
|
||||
|
||||
void RenderingManager::skyEnable ()
|
||||
{
|
||||
mSkyManager->enable();
|
||||
}
|
||||
|
||||
void RenderingManager::skyDisable ()
|
||||
{
|
||||
mSkyManager->disable();
|
||||
}
|
||||
|
||||
void RenderingManager::skySetHour (double hour)
|
||||
{
|
||||
mSkyManager->setHour(hour);
|
||||
}
|
||||
|
||||
|
||||
void RenderingManager::skySetDate (int day, int month)
|
||||
{
|
||||
mSkyManager->setDate(day, month);
|
||||
}
|
||||
|
||||
int RenderingManager::skyGetMasserPhase() const
|
||||
{
|
||||
return mSkyManager->getMasserPhase();
|
||||
}
|
||||
|
||||
int RenderingManager::skyGetSecundaPhase() const
|
||||
{
|
||||
return mSkyManager->getSecundaPhase();
|
||||
}
|
||||
|
||||
void RenderingManager::skySetMoonColour (bool red)
|
||||
{
|
||||
mSkyManager->setMoonColour(red);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
#ifndef _GAME_RENDERING_MANAGER_H
|
||||
#define _GAME_RENDERING_MANAGER_H
|
||||
|
||||
|
||||
#include "sky.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
#include <openengine/bullet/physic.hpp>
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
|
||||
class RenderingManager {
|
||||
public:
|
||||
RenderingManager(SkyManager *skyManager);
|
||||
~RenderingManager();
|
||||
|
||||
void removeCell (MWWorld::Ptr::CellStore *store); // TODO do we want this?
|
||||
|
||||
void addObject (const MWWorld::Ptr& ptr, MWWorld::Ptr::CellStore *store);
|
||||
void removeObject (const MWWorld::Ptr& ptr, MWWorld::Ptr::CellStore *store);
|
||||
|
||||
void moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position);
|
||||
void scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale);
|
||||
void rotateObject (const MWWorld::Ptr& ptr, const::Ogre::Quaternion& orientation);
|
||||
void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store);
|
||||
|
||||
void setPhysicsDebugRendering (bool);
|
||||
bool getPhysicsDebugRendering() const;
|
||||
|
||||
void update (float duration);
|
||||
|
||||
void skyEnable ();
|
||||
void skyDisable ();
|
||||
void skySetHour (double hour);
|
||||
void skySetDate (int day, int month);
|
||||
int skyGetMasserPhase() const;
|
||||
int skyGetSecundaPhase() const;
|
||||
void skySetMoonColour (bool red);
|
||||
|
||||
private:
|
||||
|
||||
SkyManager* mSkyManager;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
17
apps/openmw/mwrender/renderinginterface.hpp
Normal file
17
apps/openmw/mwrender/renderinginterface.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef _GAME_RENDERING_INTERFACE_H
|
||||
#define _GAME_RENDERING_INTERFACE_H
|
||||
namespace MWRender{
|
||||
class Npcs;
|
||||
class Creatures;
|
||||
class Objects;
|
||||
class Player;
|
||||
class RenderingInterface{
|
||||
public:
|
||||
virtual MWRender::Npcs& getNPCs() = 0;
|
||||
virtual MWRender::Creatures& getCreatures() = 0;
|
||||
virtual MWRender::Objects& getObjects() = 0;
|
||||
virtual MWRender::Player& getPlayer() = 0;
|
||||
virtual ~RenderingInterface(){};
|
||||
};
|
||||
}
|
||||
#endif
|
230
apps/openmw/mwrender/renderingmanager.cpp
Normal file
230
apps/openmw/mwrender/renderingmanager.cpp
Normal file
|
@ -0,0 +1,230 @@
|
|||
#include "renderingmanager.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "OgreRoot.h"
|
||||
#include "OgreRenderWindow.h"
|
||||
#include "OgreSceneManager.h"
|
||||
#include "OgreViewport.h"
|
||||
#include "OgreCamera.h"
|
||||
#include "OgreTextureManager.h"
|
||||
|
||||
#include "../mwworld/world.hpp" // these includes can be removed once the static-hack is gone
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include <components/esm/loadstat.hpp>
|
||||
|
||||
|
||||
using namespace MWRender;
|
||||
using namespace Ogre;
|
||||
|
||||
namespace MWRender {
|
||||
|
||||
|
||||
|
||||
RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine)
|
||||
:rend(_rend), objects(rend), mDebugging(engine)
|
||||
{
|
||||
rend.createScene("PlayerCam", 55, 5);
|
||||
mSkyManager = MWRender::SkyManager::create(rend.getWindow(), rend.getCamera(), resDir);
|
||||
|
||||
// Set default mipmap level (NB some APIs ignore this)
|
||||
TextureManager::getSingleton().setDefaultNumMipmaps(5);
|
||||
|
||||
// Load resources
|
||||
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
|
||||
|
||||
// Turn the entire scene (represented by the 'root' node) -90
|
||||
// degrees around the x axis. This makes Z go upwards, and Y go into
|
||||
// the screen (when x is to the right.) This is the orientation that
|
||||
// Morrowind uses, and it automagically makes everything work as it
|
||||
// should.
|
||||
SceneNode *rt = rend.getScene()->getRootSceneNode();
|
||||
mwRoot = rt->createChildSceneNode();
|
||||
mwRoot->pitch(Degree(-90));
|
||||
objects.setMwRoot(mwRoot);
|
||||
|
||||
//used to obtain ingame information of ogre objects (which are faced or selected)
|
||||
mRaySceneQuery = rend.getScene()->createRayQuery(Ray());
|
||||
|
||||
Ogre::SceneNode *playerNode = mwRoot->createChildSceneNode ("player");
|
||||
playerNode->pitch(Degree(90));
|
||||
Ogre::SceneNode *cameraYawNode = playerNode->createChildSceneNode();
|
||||
Ogre::SceneNode *cameraPitchNode = cameraYawNode->createChildSceneNode();
|
||||
cameraPitchNode->attachObject(rend.getCamera());
|
||||
|
||||
mPlayer = new MWRender::Player (rend.getCamera(), playerNode);
|
||||
}
|
||||
|
||||
RenderingManager::~RenderingManager ()
|
||||
{
|
||||
delete mPlayer;
|
||||
delete mSkyManager;
|
||||
}
|
||||
|
||||
MWRender::Npcs& RenderingManager::getNPCs(){
|
||||
return npcs;
|
||||
}
|
||||
MWRender::Objects& RenderingManager::getObjects(){
|
||||
return objects;
|
||||
}
|
||||
MWRender::Creatures& RenderingManager::getCreatures(){
|
||||
return creatures;
|
||||
}
|
||||
MWRender::Player& RenderingManager::getPlayer(){
|
||||
return (*mPlayer);
|
||||
}
|
||||
|
||||
void RenderingManager::removeCell (MWWorld::Ptr::CellStore *store){
|
||||
objects.removeCell(store);
|
||||
}
|
||||
|
||||
void RenderingManager::cellAdded (MWWorld::Ptr::CellStore *store)
|
||||
{
|
||||
objects.buildStaticGeometry (*store);
|
||||
}
|
||||
|
||||
void RenderingManager::addObject (const MWWorld::Ptr& ptr){
|
||||
const MWWorld::Class& class_ =
|
||||
MWWorld::Class::get (ptr);
|
||||
class_.insertObjectRendering(ptr, *this);
|
||||
|
||||
}
|
||||
void RenderingManager::removeObject (const MWWorld::Ptr& ptr)
|
||||
{
|
||||
if (!objects.deleteObject (ptr))
|
||||
{
|
||||
/// \todo delete non-object MW-references
|
||||
}
|
||||
}
|
||||
|
||||
void RenderingManager::moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position)
|
||||
{
|
||||
/// \todo move this to the rendering-subsystems
|
||||
rend.getScene()->getSceneNode (ptr.getRefData().getHandle())->
|
||||
setPosition (position);
|
||||
}
|
||||
|
||||
void RenderingManager::scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale){
|
||||
|
||||
}
|
||||
void RenderingManager::rotateObject (const MWWorld::Ptr& ptr, const::Ogre::Quaternion& orientation){
|
||||
|
||||
}
|
||||
void RenderingManager::moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store){
|
||||
|
||||
}
|
||||
|
||||
void RenderingManager::update (float duration){
|
||||
|
||||
|
||||
}
|
||||
|
||||
void RenderingManager::skyEnable ()
|
||||
{
|
||||
mSkyManager->enable();
|
||||
}
|
||||
|
||||
void RenderingManager::skyDisable ()
|
||||
{
|
||||
mSkyManager->disable();
|
||||
}
|
||||
|
||||
void RenderingManager::skySetHour (double hour)
|
||||
{
|
||||
mSkyManager->setHour(hour);
|
||||
}
|
||||
|
||||
|
||||
void RenderingManager::skySetDate (int day, int month)
|
||||
{
|
||||
mSkyManager->setDate(day, month);
|
||||
}
|
||||
|
||||
int RenderingManager::skyGetMasserPhase() const
|
||||
{
|
||||
return mSkyManager->getMasserPhase();
|
||||
}
|
||||
|
||||
int RenderingManager::skyGetSecundaPhase() const
|
||||
{
|
||||
return mSkyManager->getSecundaPhase();
|
||||
}
|
||||
|
||||
void RenderingManager::skySetMoonColour (bool red)
|
||||
{
|
||||
mSkyManager->setMoonColour(red);
|
||||
}
|
||||
bool RenderingManager::toggleRenderMode(int mode){
|
||||
return mDebugging.toggleRenderMode(mode);
|
||||
}
|
||||
|
||||
void RenderingManager::configureFog(ESMS::CellStore<MWWorld::RefData> &mCell)
|
||||
{
|
||||
Ogre::ColourValue color;
|
||||
color.setAsABGR (mCell.cell->ambi.fog);
|
||||
|
||||
float high = 4500 + 9000 * (1-mCell.cell->ambi.fogDensity);
|
||||
float low = 200;
|
||||
|
||||
rend.getScene()->setFog (FOG_LINEAR, color, 0, low, high);
|
||||
rend.getCamera()->setFarClipDistance (high + 10);
|
||||
rend.getViewport()->setBackgroundColour (color);
|
||||
}
|
||||
|
||||
void RenderingManager::setAmbientMode()
|
||||
{
|
||||
switch (mAmbientMode)
|
||||
{
|
||||
case 0:
|
||||
|
||||
rend.getScene()->setAmbientLight(mAmbientColor);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
rend.getScene()->setAmbientLight(0.7f*mAmbientColor + 0.3f*ColourValue(1,1,1));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
rend.getScene()->setAmbientLight(ColourValue(1,1,1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderingManager::configureAmbient(ESMS::CellStore<MWWorld::RefData> &mCell)
|
||||
{
|
||||
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 = rend.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);
|
||||
}
|
||||
// Switch through lighting modes.
|
||||
|
||||
void RenderingManager::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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
125
apps/openmw/mwrender/renderingmanager.hpp
Normal file
125
apps/openmw/mwrender/renderingmanager.hpp
Normal file
|
@ -0,0 +1,125 @@
|
|||
#ifndef _GAME_RENDERING_MANAGER_H
|
||||
#define _GAME_RENDERING_MANAGER_H
|
||||
|
||||
|
||||
#include "sky.hpp"
|
||||
#include "debugging.hpp"
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
#include <utility>
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
#include <openengine/bullet/physic.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include "renderinginterface.hpp"
|
||||
#include "npcs.hpp"
|
||||
#include "creatures.hpp"
|
||||
#include "objects.hpp"
|
||||
#include "player.hpp"
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class Camera;
|
||||
class Viewport;
|
||||
class SceneManager;
|
||||
class SceneNode;
|
||||
class RaySceneQuery;
|
||||
class Quaternion;
|
||||
class Vector3;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class World;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
|
||||
|
||||
|
||||
class RenderingManager: private RenderingInterface {
|
||||
|
||||
private:
|
||||
|
||||
virtual MWRender::Npcs& getNPCs();
|
||||
virtual MWRender::Creatures& getCreatures();
|
||||
virtual MWRender::Objects& getObjects();
|
||||
|
||||
public:
|
||||
RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine);
|
||||
virtual ~RenderingManager();
|
||||
|
||||
virtual MWRender::Player& getPlayer(); /// \todo move this to private again as soon as
|
||||
/// MWWorld::Player has been rewritten to not need access
|
||||
/// to internal details of the rendering system anymore
|
||||
|
||||
void toggleLight();
|
||||
bool toggleRenderMode(int mode);
|
||||
|
||||
void removeCell (MWWorld::Ptr::CellStore *store);
|
||||
|
||||
/// \todo this function should be removed later. Instead the rendering subsystems should track
|
||||
/// when rebatching is needed and update automatically at the end of each frame.
|
||||
void cellAdded (MWWorld::Ptr::CellStore *store);
|
||||
|
||||
void addObject (const MWWorld::Ptr& ptr);
|
||||
void removeObject (const MWWorld::Ptr& ptr);
|
||||
|
||||
void moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position);
|
||||
void scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale);
|
||||
void rotateObject (const MWWorld::Ptr& ptr, const::Ogre::Quaternion& orientation);
|
||||
|
||||
/// \param store Cell the object was in previously (\a ptr has already been updated to the new cell).
|
||||
void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store);
|
||||
|
||||
void update (float duration);
|
||||
|
||||
void skyEnable ();
|
||||
void skyDisable ();
|
||||
void skySetHour (double hour);
|
||||
void skySetDate (int day, int month);
|
||||
int skyGetMasserPhase() const;
|
||||
int skyGetSecundaPhase() const;
|
||||
void skySetMoonColour (bool red);
|
||||
void configureAmbient(ESMS::CellStore<MWWorld::RefData> &mCell);
|
||||
/// configure fog according to cell
|
||||
void configureFog(ESMS::CellStore<MWWorld::RefData> &mCell);
|
||||
|
||||
private:
|
||||
|
||||
void setAmbientMode();
|
||||
SkyManager* mSkyManager;
|
||||
OEngine::Render::OgreRenderer &rend;
|
||||
Ogre::Camera* camera;
|
||||
MWRender::Npcs npcs;
|
||||
MWRender::Creatures creatures;
|
||||
MWRender::Objects objects;
|
||||
|
||||
// 0 normal, 1 more bright, 2 max
|
||||
int mAmbientMode;
|
||||
|
||||
Ogre::ColourValue mAmbientColor;
|
||||
|
||||
/// Root node for all objects added to the scene. This is rotated so
|
||||
/// that the OGRE coordinate system matches that used internally in
|
||||
/// Morrowind.
|
||||
Ogre::SceneNode *mwRoot;
|
||||
Ogre::RaySceneQuery *mRaySceneQuery;
|
||||
|
||||
OEngine::Physic::PhysicEngine* eng;
|
||||
|
||||
MWRender::Player *mPlayer;
|
||||
MWRender::Debugging mDebugging;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -16,12 +16,12 @@ namespace MWWorld
|
|||
/// List all (Ogre-)handles.
|
||||
struct ListHandles
|
||||
{
|
||||
std::vector<std::string> mHandles;
|
||||
std::vector<Ogre::SceneNode*> mHandles;
|
||||
|
||||
bool operator() (ESM::CellRef& ref, RefData& data)
|
||||
{
|
||||
std::string handle = data.getHandle();
|
||||
if (!handle.empty())
|
||||
Ogre::SceneNode* handle = data.getBaseNode();
|
||||
if (handle)
|
||||
mHandles.push_back (handle);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -21,10 +21,12 @@ namespace MWWorld
|
|||
throw std::runtime_error ("class does not support ID retrieval");
|
||||
}
|
||||
|
||||
void Class::insertObj (const Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
void Class::insertObjectRendering (const Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
|
||||
}
|
||||
void Class::insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const{
|
||||
|
||||
}
|
||||
|
||||
void Class::enable (const Ptr& ptr, MWWorld::Environment& environment) const
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "action.hpp"
|
||||
#include "containerstore.hpp"
|
||||
#include "refdata.hpp"
|
||||
#include "../mwrender/renderinginterface.hpp"
|
||||
#include "physicssystem.hpp"
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
|
@ -59,8 +61,10 @@ namespace MWWorld
|
|||
///< Return ID of \a ptr or throw an exception, if class does not support ID retrieval
|
||||
/// (default implementation: throw an exception)
|
||||
|
||||
virtual void insertObj (const Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
|
||||
|
||||
virtual void insertObjectRendering (const Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||
virtual void insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
|
||||
///< Add reference into a cell for rendering (default implementation: don't render anything).
|
||||
|
||||
virtual void enable (const Ptr& ptr, MWWorld::Environment& environment) const;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include <stdexcept>
|
||||
|
||||
#include "physicssystem.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/world.hpp" // FIXME
|
||||
|
@ -10,6 +12,7 @@
|
|||
#include "OgreTextureManager.h"
|
||||
|
||||
|
||||
using namespace Ogre;
|
||||
namespace MWWorld
|
||||
{
|
||||
|
||||
|
@ -23,6 +26,22 @@ namespace MWWorld
|
|||
{
|
||||
|
||||
}
|
||||
std::pair<std::string, float> PhysicsSystem::getFacedHandle (MWWorld::World& world)
|
||||
{
|
||||
std::string handle = "";
|
||||
|
||||
//get a ray pointing to the center of the viewport
|
||||
Ray centerRay = mRender.getCamera()->getCameraToViewportRay(
|
||||
mRender.getViewport()->getWidth()/2,
|
||||
mRender.getViewport()->getHeight()/2);
|
||||
//let's avoid the capsule shape of the player.
|
||||
centerRay.setOrigin(centerRay.getOrigin() + 20*centerRay.getDirection());
|
||||
btVector3 from(centerRay.getOrigin().x,-centerRay.getOrigin().z,centerRay.getOrigin().y);
|
||||
btVector3 to(centerRay.getPoint(500).x,-centerRay.getPoint(500).z,centerRay.getPoint(500).y);
|
||||
|
||||
return mEngine->rayTest(from,to);
|
||||
}
|
||||
|
||||
|
||||
std::vector< std::pair<std::string, Ogre::Vector3> > PhysicsSystem::doPhysics (float duration,
|
||||
const std::vector<std::pair<std::string, Ogre::Vector3> >& actors)
|
||||
|
@ -136,8 +155,11 @@ namespace MWWorld
|
|||
bool PhysicsSystem::toggleCollisionMode()
|
||||
{
|
||||
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
|
||||
{
|
||||
if (it->first=="player")
|
||||
{
|
||||
OEngine::Physic::PhysicActor* act = it->second;
|
||||
|
||||
bool cmode = act->getCollisionMode();
|
||||
if(cmode)
|
||||
{
|
||||
|
@ -156,9 +178,20 @@ namespace MWWorld
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false; // This should never happen, but it shall not bother us now, since
|
||||
// this part of the code needs a rewrite anyway.
|
||||
throw std::logic_error ("can't find player");
|
||||
}
|
||||
|
||||
void PhysicsSystem::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string model){
|
||||
Ogre::SceneNode* node = ptr.getRefData().getBaseNode();
|
||||
addObject (node->getName(), model, node->getOrientation(),
|
||||
node->getScale().x, node->getPosition());
|
||||
}
|
||||
|
||||
void PhysicsSystem::insertActorPhysics(const MWWorld::Ptr& ptr, const std::string model){
|
||||
Ogre::SceneNode* node = ptr.getRefData().getBaseNode();
|
||||
addActor (node->getName(), model, node->getPosition());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <vector>
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
#include <openengine/bullet/physic.hpp>
|
||||
#include "ptr.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
|
@ -32,6 +33,11 @@ namespace MWWorld
|
|||
void scaleObject (const std::string& handle, float scale);
|
||||
|
||||
bool toggleCollisionMode();
|
||||
std::pair<std::string, float> getFacedHandle (MWWorld::World& world);
|
||||
|
||||
void insertObjectPhysics(const MWWorld::Ptr& ptr, std::string model);
|
||||
|
||||
void insertActorPhysics(const MWWorld::Ptr&, std::string model);
|
||||
|
||||
private:
|
||||
OEngine::Render::OgreRenderer &mRender;
|
||||
|
|
|
@ -22,7 +22,8 @@ namespace MWWorld
|
|||
playerPos[0] = playerPos[1] = playerPos[2] = 0;
|
||||
|
||||
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.
|
||||
mClass = new ESM::Class (*world.getStore().classes.find (player->cls));
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "../mwmechanics/movement.hpp"
|
||||
|
||||
#include "containerstore.hpp"
|
||||
#include <Ogre.h>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
@ -22,7 +23,8 @@ namespace MWWorld
|
|||
{
|
||||
class RefData
|
||||
{
|
||||
std::string mHandle;
|
||||
Ogre::SceneNode* mBaseNode;
|
||||
|
||||
|
||||
MWScript::Locals mLocals; // if we find the overhead of heaving a locals
|
||||
// object in the refdata of refs without a script,
|
||||
|
@ -43,16 +45,24 @@ namespace MWWorld
|
|||
|
||||
ESM::Position mPosition;
|
||||
|
||||
|
||||
public:
|
||||
/// @param cr Used to copy constant data such as position into this class where it can
|
||||
/// be altered without effecting the original data. This makes it possible
|
||||
/// to reset the position as the orignal data is still held in the CellRef
|
||||
RefData(const ESMS::CellRef& cr) : mHasLocals (false), mEnabled (true),
|
||||
RefData(const ESMS::CellRef& cr) : mBaseNode(0), mHasLocals (false), mEnabled (true),
|
||||
mCount (1), mPosition(cr.pos) {}
|
||||
|
||||
|
||||
std::string getHandle()
|
||||
{
|
||||
return mHandle;
|
||||
return mBaseNode->getName();
|
||||
}
|
||||
Ogre::SceneNode* getBaseNode(){
|
||||
return mBaseNode;
|
||||
}
|
||||
void setBaseNode(Ogre::SceneNode* base){
|
||||
mBaseNode = base;
|
||||
}
|
||||
|
||||
int getCount() const
|
||||
|
@ -69,10 +79,6 @@ namespace MWWorld
|
|||
}
|
||||
}
|
||||
|
||||
void setHandle (const std::string& handle)
|
||||
{
|
||||
mHandle = handle;
|
||||
}
|
||||
|
||||
void setCount (int count)
|
||||
{
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#include "scene.hpp"
|
||||
#include "world.hpp"
|
||||
|
||||
#include "../mwrender/interior.hpp"
|
||||
#include "../mwrender/exterior.hpp"
|
||||
|
||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||
|
||||
|
@ -18,11 +16,13 @@
|
|||
namespace {
|
||||
|
||||
template<typename T>
|
||||
void insertCellRefList (T& cellRefList, ESMS::CellStore<MWWorld::RefData> &cell)
|
||||
void insertCellRefList(MWRender::RenderingManager& rendering, MWWorld::Environment& environment,
|
||||
T& cellRefList, ESMS::CellStore<MWWorld::RefData> &cell, MWWorld::PhysicsSystem& physics)
|
||||
{
|
||||
if (!cellRefList.list.empty())
|
||||
{
|
||||
//const MWWorld::Class& class_ = MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.list.begin(), &cell));
|
||||
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++)
|
||||
|
@ -30,11 +30,18 @@ void insertCellRefList (T& cellRefList, ESMS::CellStore<MWWorld::RefData> &cell)
|
|||
if (it->mData.getCount() || it->mData.isEnabled())
|
||||
{
|
||||
MWWorld::Ptr ptr (&*it, &cell);
|
||||
/* TODO: call
|
||||
* RenderingManager.insertObject
|
||||
* class_.insertObjectPhysic
|
||||
* class_.insertObjectMechanics
|
||||
*/
|
||||
|
||||
try
|
||||
{
|
||||
rendering.addObject(ptr);
|
||||
class_.insertObject(ptr, physics, environment);
|
||||
class_.enable (ptr, environment);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::string error ("error during rendering: ");
|
||||
std::cerr << error + e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,39 +53,49 @@ void insertCellRefList (T& cellRefList, ESMS::CellStore<MWWorld::RefData> &cell)
|
|||
namespace MWWorld
|
||||
{
|
||||
|
||||
void Scene::unloadCell (CellRenderCollection::iterator iter)
|
||||
void Scene::unloadCell (CellStoreCollection::iterator iter)
|
||||
{
|
||||
|
||||
ListHandles functor;
|
||||
iter->first->forEach<ListHandles>(functor);
|
||||
|
||||
{ // silence annoying g++ warning
|
||||
for (std::vector<std::string>::const_iterator iter (functor.mHandles.begin());
|
||||
iter!=functor.mHandles.end(); ++iter)
|
||||
mPhysics->removeObject (*iter);
|
||||
MWWorld::Ptr::CellStore* active = *iter;
|
||||
mRendering.removeCell(active);
|
||||
|
||||
active->forEach<ListHandles>(functor);
|
||||
|
||||
{
|
||||
|
||||
|
||||
// silence annoying g++ warning
|
||||
for (std::vector<Ogre::SceneNode*>::const_iterator iter (functor.mHandles.begin());
|
||||
iter!=functor.mHandles.end(); ++iter){
|
||||
Ogre::SceneNode* node = *iter;
|
||||
mPhysics->removeObject (node->getName());
|
||||
}
|
||||
|
||||
mWorld->getLocalScripts().clearCell (iter->first);
|
||||
|
||||
mEnvironment.mMechanicsManager->dropActors (iter->first);
|
||||
mEnvironment.mSoundManager->stopSound (iter->first);
|
||||
delete iter->second;
|
||||
}
|
||||
mWorld->getLocalScripts().clearCell (active);
|
||||
mEnvironment.mMechanicsManager->dropActors (active);
|
||||
mEnvironment.mSoundManager->stopSound (active);
|
||||
mActiveCells.erase (iter);
|
||||
}
|
||||
|
||||
void Scene::loadCell (Ptr::CellStore *cell, MWRender::CellRender *render)
|
||||
void Scene::loadCell (Ptr::CellStore *cell)
|
||||
{
|
||||
// register local scripts
|
||||
mWorld->getLocalScripts().addCell (cell);
|
||||
|
||||
// This connects the cell data with the rendering scene.
|
||||
std::pair<CellRenderCollection::iterator, bool> result =
|
||||
mActiveCells.insert (std::make_pair (cell, render));
|
||||
|
||||
if (result.second)
|
||||
{
|
||||
// Load the cell and insert it into the renderer
|
||||
result.first->second->show();
|
||||
|
||||
std::pair<CellStoreCollection::iterator, bool> result =
|
||||
mActiveCells.insert(cell);
|
||||
if(result.second){
|
||||
insertCell(*cell, mEnvironment);
|
||||
mRendering.cellAdded (cell);
|
||||
mRendering.configureAmbient(*cell);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Scene::playerCellChange (Ptr::CellStore *cell, const ESM::Position& position,
|
||||
|
@ -98,14 +115,14 @@ namespace MWWorld
|
|||
// remove active
|
||||
mEnvironment.mMechanicsManager->removeActor (mWorld->getPlayer().getPlayer());
|
||||
|
||||
CellRenderCollection::iterator active = mActiveCells.begin();
|
||||
CellStoreCollection::iterator active = mActiveCells.begin();
|
||||
|
||||
while (active!=mActiveCells.end())
|
||||
{
|
||||
if (!(active->first->cell->data.flags & ESM::Cell::Interior))
|
||||
if (!((*active)->cell->data.flags & ESM::Cell::Interior))
|
||||
{
|
||||
if (std::abs (X-active->first->cell->data.gridX)<=1 &&
|
||||
std::abs (Y-active->first->cell->data.gridY)<=1)
|
||||
if (std::abs (X-(*active)->cell->data.gridX)<=1 &&
|
||||
std::abs (Y-(*active)->cell->data.gridY)<=1)
|
||||
{
|
||||
// keep cells within the new 3x3 grid
|
||||
++active;
|
||||
|
@ -120,14 +137,14 @@ namespace MWWorld
|
|||
for (int x=X-1; x<=X+1; ++x)
|
||||
for (int y=Y-1; y<=Y+1; ++y)
|
||||
{
|
||||
CellRenderCollection::iterator iter = mActiveCells.begin();
|
||||
CellStoreCollection::iterator iter = mActiveCells.begin();
|
||||
|
||||
while (iter!=mActiveCells.end())
|
||||
{
|
||||
assert (!(iter->first->cell->data.flags & ESM::Cell::Interior));
|
||||
assert (!((*iter)->cell->data.flags & ESM::Cell::Interior));
|
||||
|
||||
if (x==iter->first->cell->data.gridX &&
|
||||
y==iter->first->cell->data.gridY)
|
||||
if (x==(*iter)->cell->data.gridX &&
|
||||
y==(*iter)->cell->data.gridY)
|
||||
break;
|
||||
|
||||
++iter;
|
||||
|
@ -137,19 +154,19 @@ namespace MWWorld
|
|||
{
|
||||
Ptr::CellStore *cell = mWorld->getExterior(x, y);
|
||||
|
||||
loadCell (cell, new MWRender::ExteriorCellRender (*cell, mEnvironment, mScene, mPhysics));
|
||||
loadCell (cell);
|
||||
}
|
||||
}
|
||||
|
||||
// find current cell
|
||||
CellRenderCollection::iterator iter = mActiveCells.begin();
|
||||
CellStoreCollection::iterator iter = mActiveCells.begin();
|
||||
|
||||
while (iter!=mActiveCells.end())
|
||||
{
|
||||
assert (!(iter->first->cell->data.flags & ESM::Cell::Interior));
|
||||
assert (!((*iter)->cell->data.flags & ESM::Cell::Interior));
|
||||
|
||||
if (X==iter->first->cell->data.gridX &&
|
||||
Y==iter->first->cell->data.gridY)
|
||||
if (X==(*iter)->cell->data.gridX &&
|
||||
Y==(*iter)->cell->data.gridY)
|
||||
break;
|
||||
|
||||
++iter;
|
||||
|
@ -157,7 +174,7 @@ namespace MWWorld
|
|||
|
||||
assert (iter!=mActiveCells.end());
|
||||
|
||||
mCurrentCell = iter->first;
|
||||
mCurrentCell = *iter;
|
||||
|
||||
// adjust player
|
||||
playerCellChange (mWorld->getExterior(X, Y), position, adjustPlayerPos);
|
||||
|
@ -168,17 +185,15 @@ namespace MWWorld
|
|||
mCellChanged = true;
|
||||
}
|
||||
|
||||
Scene::Scene (Environment& environment, World *world, MWRender::MWScene& scene, PhysicsSystem *physics)
|
||||
: mScene (scene), mCurrentCell (0),
|
||||
mCellChanged (false), mEnvironment (environment), mWorld(world), mPhysics(physics)
|
||||
//We need the ogre renderer and a scene node.
|
||||
Scene::Scene (Environment& environment, World *world, MWRender::RenderingManager& rendering, PhysicsSystem *physics)
|
||||
: mCurrentCell (0), mCellChanged (false), mEnvironment (environment), mWorld(world),
|
||||
mPhysics(physics), mRendering(rendering)
|
||||
{
|
||||
}
|
||||
|
||||
Scene::~Scene()
|
||||
{
|
||||
for (CellRenderCollection::iterator iter (mActiveCells.begin());
|
||||
iter!=mActiveCells.end(); ++iter)
|
||||
delete iter->second;
|
||||
}
|
||||
|
||||
bool Scene::hasCellChanged() const
|
||||
|
@ -186,15 +201,16 @@ namespace MWWorld
|
|||
return mCellChanged;
|
||||
}
|
||||
|
||||
const Scene::CellRenderCollection& Scene::getActiveCells() const
|
||||
const Scene::CellStoreCollection& Scene::getActiveCells() const
|
||||
{
|
||||
return mActiveCells;
|
||||
}
|
||||
|
||||
void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
|
||||
{
|
||||
std::cout << "Changing to interior\n";
|
||||
// remove active
|
||||
CellRenderCollection::iterator active = mActiveCells.begin();
|
||||
CellStoreCollection::iterator active = mActiveCells.begin();
|
||||
|
||||
while (active!=mActiveCells.end())
|
||||
{
|
||||
|
@ -205,7 +221,7 @@ namespace MWWorld
|
|||
std::cout << "cellName:" << cellName << std::endl;
|
||||
Ptr::CellStore *cell = mWorld->getInterior(cellName);
|
||||
|
||||
loadCell (cell, new MWRender::InteriorCellRender (*cell, mEnvironment, mScene, mPhysics));
|
||||
loadCell (cell);
|
||||
|
||||
// adjust player
|
||||
mCurrentCell = cell;
|
||||
|
@ -215,7 +231,6 @@ namespace MWWorld
|
|||
mWorld->adjustSky();
|
||||
|
||||
mCellChanged = true;
|
||||
//currentRegion->name = "";
|
||||
}
|
||||
|
||||
void Scene::changeToExteriorCell (const ESM::Position& position)
|
||||
|
@ -238,36 +253,31 @@ namespace MWWorld
|
|||
mCellChanged = false;
|
||||
}
|
||||
|
||||
/*#include <cassert>
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/ptr.hpp"*/
|
||||
|
||||
void Scene::insertCell(ESMS::CellStore<MWWorld::RefData> &cell)
|
||||
void Scene::insertCell(ESMS::CellStore<MWWorld::RefData> &cell,
|
||||
MWWorld::Environment& environment)
|
||||
{
|
||||
// Loop through all references in the cell
|
||||
insertCellRefList (cell.activators, cell);
|
||||
insertCellRefList (cell.potions, cell);
|
||||
insertCellRefList (cell.appas, cell);
|
||||
insertCellRefList (cell.armors, cell);
|
||||
insertCellRefList (cell.books, cell);
|
||||
insertCellRefList (cell.clothes, cell);
|
||||
insertCellRefList (cell.containers, cell);
|
||||
insertCellRefList (cell.creatures, cell);
|
||||
insertCellRefList (cell.doors, cell);
|
||||
insertCellRefList (cell.ingreds, cell);
|
||||
insertCellRefList (cell.creatureLists, cell);
|
||||
insertCellRefList (cell.itemLists, cell);
|
||||
insertCellRefList (cell.lights, cell);
|
||||
insertCellRefList (cell.lockpicks, cell);
|
||||
insertCellRefList (cell.miscItems, cell);
|
||||
insertCellRefList (cell.npcs, cell);
|
||||
insertCellRefList (cell.probes, cell);
|
||||
insertCellRefList (cell.repairs, cell);
|
||||
insertCellRefList (cell.statics, cell);
|
||||
insertCellRefList (cell.weapons, cell);
|
||||
insertCellRefList(mRendering, environment, cell.activators, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.potions, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.appas, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.armors, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.books, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.clothes, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.containers, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.creatures, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.doors, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.ingreds, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.creatureLists, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.itemLists, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.lights, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.lockpicks, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.miscItems, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.npcs, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.probes, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.repairs, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.statics, cell, *mPhysics);
|
||||
insertCellRefList(mRendering, environment, cell.weapons, cell, *mPhysics);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,17 +6,18 @@
|
|||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <openengine/bullet/physic.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwrender/mwscene.hpp"
|
||||
#include "physicssystem.hpp"
|
||||
#include "../mwrender/renderingmanager.hpp"
|
||||
#include "../mwrender/renderinginterface.hpp"
|
||||
|
||||
#include "physicssystem.hpp"
|
||||
#include "refdata.hpp"
|
||||
#include "ptr.hpp"
|
||||
#include "globals.hpp"
|
||||
|
||||
#include <openengine/bullet/physic.hpp>
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class Vector3;
|
||||
|
@ -53,29 +54,32 @@ namespace MWWorld
|
|||
|
||||
public:
|
||||
|
||||
typedef std::map<Ptr::CellStore *, MWRender::CellRender *> CellRenderCollection;
|
||||
typedef std::set<Ptr::CellStore *> CellStoreCollection;
|
||||
|
||||
private:
|
||||
|
||||
MWRender::MWScene& mScene;
|
||||
Ptr::CellStore *mCurrentCell; // the cell, the player is in
|
||||
CellRenderCollection mActiveCells;
|
||||
//OEngine::Render::OgreRenderer& mRenderer;
|
||||
Ptr::CellStore* mCurrentCell; // the cell, the player is in
|
||||
CellStoreCollection mActiveCells;
|
||||
bool mCellChanged;
|
||||
Environment& mEnvironment;
|
||||
World *mWorld;
|
||||
PhysicsSystem *mPhysics;
|
||||
MWRender::RenderingManager& mRendering;
|
||||
|
||||
void playerCellChange (Ptr::CellStore *cell, const ESM::Position& position,
|
||||
bool adjustPlayerPos = true);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
Scene (Environment& environment, World *world, MWRender::MWScene& scene, PhysicsSystem *physics);
|
||||
Scene (Environment& environment, World *world, MWRender::RenderingManager& rendering, PhysicsSystem *physics);
|
||||
|
||||
~Scene();
|
||||
|
||||
void unloadCell (CellRenderCollection::iterator iter);
|
||||
void unloadCell (CellStoreCollection::iterator iter);
|
||||
|
||||
void loadCell (Ptr::CellStore *cell, MWRender::CellRender *render);
|
||||
void loadCell (Ptr::CellStore *cell);
|
||||
|
||||
void changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos);
|
||||
///< Move from exterior to interior or from interior cell to a different
|
||||
|
@ -83,7 +87,7 @@ namespace MWWorld
|
|||
|
||||
Ptr::CellStore* getCurrentCell ();
|
||||
|
||||
const CellRenderCollection& getActiveCells () const;
|
||||
const CellStoreCollection& getActiveCells () const;
|
||||
|
||||
bool hasCellChanged() const;
|
||||
///< Has the player moved to a different cell, since the last frame?
|
||||
|
@ -96,9 +100,7 @@ namespace MWWorld
|
|||
|
||||
void markCellAsUnchanged();
|
||||
|
||||
// std::string getFacedHandle();
|
||||
|
||||
void insertCell(ESMS::CellStore<MWWorld::RefData> &cell);
|
||||
void insertCell(ESMS::CellStore<MWWorld::RefData> &cell, MWWorld::Environment& environment);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
#include <components/files/collections.hpp>
|
||||
|
||||
#include "../mwrender/sky.hpp"
|
||||
#include "../mwrender/interior.hpp"
|
||||
#include "../mwrender/exterior.hpp"
|
||||
#include "../mwrender/player.hpp"
|
||||
|
||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||
|
||||
|
@ -54,12 +53,13 @@ namespace
|
|||
|
||||
for (iterator iter (refList.list.begin()); iter!=refList.list.end(); ++iter)
|
||||
{
|
||||
if(iter->mData.getBaseNode()){
|
||||
if (iter->mData.getHandle()==handle)
|
||||
{
|
||||
return &*iter;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -71,75 +71,46 @@ namespace MWWorld
|
|||
if (ESMS::LiveCellRef<ESM::Activator, RefData> *ref =
|
||||
searchViaHandle (handle, cell.activators))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Potion, RefData> *ref = searchViaHandle (handle, cell.potions))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Apparatus, RefData> *ref = searchViaHandle (handle, cell.appas))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Armor, RefData> *ref = searchViaHandle (handle, cell.armors))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Book, RefData> *ref = searchViaHandle (handle, cell.books))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Clothing, RefData> *ref = searchViaHandle (handle, cell.clothes))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Container, RefData> *ref =
|
||||
searchViaHandle (handle, cell.containers))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Creature, RefData> *ref =
|
||||
searchViaHandle (handle, cell.creatures))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Door, RefData> *ref = searchViaHandle (handle, cell.doors))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Ingredient, RefData> *ref =
|
||||
searchViaHandle (handle, cell.ingreds))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Light, RefData> *ref = searchViaHandle (handle, cell.lights))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = searchViaHandle (handle, cell.lockpicks))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Miscellaneous, RefData> *ref = searchViaHandle (handle, cell.miscItems))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::NPC, RefData> *ref = searchViaHandle (handle, cell.npcs))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Probe, RefData> *ref = searchViaHandle (handle, cell.probes))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Repair, RefData> *ref = searchViaHandle (handle, cell.repairs))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Static, RefData> *ref = searchViaHandle (handle, cell.statics))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
if (ESMS::LiveCellRef<ESM::Weapon, RefData> *ref = searchViaHandle (handle, cell.weapons))
|
||||
return Ptr (ref, &cell);
|
||||
|
||||
return Ptr();
|
||||
}
|
||||
|
||||
MWRender::CellRender *World::searchRender (Ptr::CellStore *store)
|
||||
{
|
||||
Scene::CellRenderCollection::const_iterator iter = mWorldScene->getActiveCells().find (store);
|
||||
|
||||
if (iter!=mWorldScene->getActiveCells().end())
|
||||
{
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int World::getDaysPerMonth (int month) const
|
||||
{
|
||||
|
@ -176,7 +147,7 @@ namespace MWWorld
|
|||
const Files::Collections& fileCollections,
|
||||
const std::string& master, const boost::filesystem::path& resDir,
|
||||
bool newGame, Environment& environment, const std::string& encoding)
|
||||
: mScene (renderer,physEng), mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0),
|
||||
: mRendering (renderer,resDir, physEng),mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0),
|
||||
mSky (false), mEnvironment (environment), mNextDynamicRecord (0), mCells (mStore, mEsm, *this)
|
||||
{
|
||||
mPhysEngine = physEng;
|
||||
|
@ -192,7 +163,8 @@ namespace MWWorld
|
|||
mEsm.open (masterPath.string());
|
||||
mStore.load (mEsm);
|
||||
|
||||
mPlayer = new MWWorld::Player (mScene.getPlayer(), mStore.npcs.find ("player"), *this);
|
||||
MWRender::Player* play = &(mRendering.getPlayer());
|
||||
mPlayer = new MWWorld::Player (play, mStore.npcs.find ("player"), *this);
|
||||
mPhysics->addActor (mPlayer->getPlayer().getRefData().getHandle(), "", Ogre::Vector3 (0, 0, 0));
|
||||
|
||||
// global variables
|
||||
|
@ -206,18 +178,18 @@ namespace MWWorld
|
|||
|
||||
mPhysEngine = physEng;
|
||||
|
||||
mWorldScene = new Scene(environment, this, mScene, mPhysics);
|
||||
mRenderingManager = new MWRender::RenderingManager(
|
||||
MWRender::SkyManager::create(renderer.getWindow(), mScene.getCamera(), resDir)
|
||||
);
|
||||
mWorldScene = new Scene(environment, this, mRendering, mPhysics);
|
||||
|
||||
}
|
||||
|
||||
World::~World()
|
||||
{
|
||||
delete mWorldScene;
|
||||
delete mGlobalVariables;
|
||||
delete mPlayer;
|
||||
|
||||
delete mPhysics;
|
||||
|
||||
delete mPlayer;
|
||||
}
|
||||
|
||||
const ESM::Cell *World::getExterior (const std::string& cellName) const
|
||||
|
@ -303,10 +275,11 @@ namespace MWWorld
|
|||
}
|
||||
|
||||
// active cells
|
||||
for (Scene::CellRenderCollection::const_iterator iter (mWorldScene->getActiveCells().begin());
|
||||
for (Scene::CellStoreCollection::const_iterator iter (mWorldScene->getActiveCells().begin());
|
||||
iter!=mWorldScene->getActiveCells().end(); ++iter)
|
||||
{
|
||||
Ptr ptr = mCells.getPtr (name, *iter->first);
|
||||
Ptr::CellStore* cellstore = *iter;
|
||||
Ptr ptr = mCells.getPtr (name, *cellstore);
|
||||
|
||||
if (!ptr.isEmpty())
|
||||
return ptr;
|
||||
|
@ -327,11 +300,11 @@ namespace MWWorld
|
|||
{
|
||||
if (mPlayer->getPlayer().getRefData().getHandle()==handle)
|
||||
return mPlayer->getPlayer();
|
||||
|
||||
for (Scene::CellRenderCollection::const_iterator iter (mWorldScene->getActiveCells().begin());
|
||||
for (Scene::CellStoreCollection::const_iterator iter (mWorldScene->getActiveCells().begin());
|
||||
iter!=mWorldScene->getActiveCells().end(); ++iter)
|
||||
{
|
||||
Ptr ptr = getPtrViaHandle (handle, *iter->first);
|
||||
Ptr::CellStore* cellstore = *iter;
|
||||
Ptr ptr = getPtrViaHandle (handle, *cellstore);
|
||||
|
||||
if (!ptr.isEmpty())
|
||||
return ptr;
|
||||
|
@ -346,13 +319,12 @@ namespace MWWorld
|
|||
{
|
||||
reference.getRefData().enable();
|
||||
|
||||
if (MWRender::CellRender *render = searchRender (reference.getCell()))
|
||||
{
|
||||
render->enable (reference.getRefData().getHandle());
|
||||
|
||||
if (mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end())
|
||||
//render->enable (reference.getRefData().getHandle());
|
||||
if(mWorldScene->getActiveCells().find (reference.getCell()) != mWorldScene->getActiveCells().end())
|
||||
Class::get (reference).enable (reference, mEnvironment);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,16 +334,14 @@ namespace MWWorld
|
|||
{
|
||||
reference.getRefData().disable();
|
||||
|
||||
if (MWRender::CellRender *render = searchRender (reference.getCell()))
|
||||
{
|
||||
render->disable (reference.getRefData().getHandle());
|
||||
|
||||
if (mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end())
|
||||
{
|
||||
//render->disable (reference.getRefData().getHandle());
|
||||
if(mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end()){
|
||||
Class::get (reference).disable (reference, mEnvironment);
|
||||
mEnvironment.mSoundManager->stopSound3D (reference);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -398,7 +368,7 @@ namespace MWWorld
|
|||
|
||||
mGlobalVariables->setFloat ("gamehour", hour);
|
||||
|
||||
mRenderingManager->skySetHour (hour);
|
||||
mRendering.skySetHour (hour);
|
||||
|
||||
if (days>0)
|
||||
setDay (days + mGlobalVariables->getInt ("day"));
|
||||
|
@ -433,7 +403,7 @@ namespace MWWorld
|
|||
mGlobalVariables->setInt ("day", day);
|
||||
mGlobalVariables->setInt ("month", month);
|
||||
|
||||
mRenderingManager->skySetDate (day, month);
|
||||
mRendering.skySetDate (day, month);
|
||||
}
|
||||
|
||||
void World::setMonth (int month)
|
||||
|
@ -454,7 +424,7 @@ namespace MWWorld
|
|||
if (years>0)
|
||||
mGlobalVariables->setInt ("year", years+mGlobalVariables->getInt ("year"));
|
||||
|
||||
mRenderingManager->skySetDate (mGlobalVariables->getInt ("day"), month);
|
||||
mRendering.skySetDate (mGlobalVariables->getInt ("day"), month);
|
||||
}
|
||||
|
||||
bool World::toggleSky()
|
||||
|
@ -462,34 +432,34 @@ namespace MWWorld
|
|||
if (mSky)
|
||||
{
|
||||
mSky = false;
|
||||
mRenderingManager->skyDisable();
|
||||
mRendering.skyDisable();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mSky = true;
|
||||
// TODO check for extorior or interior with sky.
|
||||
mRenderingManager->skySetHour (mGlobalVariables->getFloat ("gamehour"));
|
||||
mRenderingManager->skySetDate (mGlobalVariables->getInt ("day"),
|
||||
mRendering.skySetHour (mGlobalVariables->getFloat ("gamehour"));
|
||||
mRendering.skySetDate (mGlobalVariables->getInt ("day"),
|
||||
mGlobalVariables->getInt ("month"));
|
||||
mRenderingManager->skyEnable();
|
||||
mRendering.skyEnable();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int World::getMasserPhase() const
|
||||
{
|
||||
return mRenderingManager->skyGetMasserPhase();
|
||||
return mRendering.skyGetMasserPhase();
|
||||
}
|
||||
|
||||
int World::getSecundaPhase() const
|
||||
{
|
||||
return mRenderingManager->skyGetSecundaPhase();
|
||||
return mRendering.skyGetSecundaPhase();
|
||||
}
|
||||
|
||||
void World::setMoonColour (bool red)
|
||||
{
|
||||
mRenderingManager->skySetMoonColour (red);
|
||||
mRendering.skySetMoonColour (red);
|
||||
}
|
||||
|
||||
float World::getTimeScaleFactor() const
|
||||
|
@ -514,7 +484,7 @@ namespace MWWorld
|
|||
|
||||
std::string World::getFacedHandle()
|
||||
{
|
||||
std::pair<std::string, float> result = mScene.getFacedHandle (*this);
|
||||
std::pair<std::string, float> result = mPhysics->getFacedHandle (*this);
|
||||
|
||||
if (result.first.empty() ||
|
||||
result.second>getStore().gameSettings.find ("iMaxActivateDist")->i)
|
||||
|
@ -529,21 +499,16 @@ namespace MWWorld
|
|||
{
|
||||
ptr.getRefData().setCount (0);
|
||||
|
||||
if (MWRender::CellRender *render = searchRender (ptr.getCell()))
|
||||
{
|
||||
if (mWorldScene->getActiveCells().find (ptr.getCell())!=mWorldScene->getActiveCells().end())
|
||||
{
|
||||
Class::get (ptr).disable (ptr, mEnvironment);
|
||||
|
||||
if (mWorldScene->getActiveCells().find (ptr.getCell())!=mWorldScene->getActiveCells().end()){
|
||||
// Class::get (ptr).disable (ptr, mEnvironment); /// \todo this line needs to be removed
|
||||
mEnvironment.mSoundManager->stopSound3D (ptr);
|
||||
|
||||
mPhysics->removeObject (ptr.getRefData().getHandle());
|
||||
mRendering.removeObject(ptr);
|
||||
|
||||
mLocalScripts.remove (ptr);
|
||||
}
|
||||
|
||||
render->deleteObject (ptr.getRefData().getHandle());
|
||||
ptr.getRefData().setHandle ("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -575,11 +540,9 @@ namespace MWWorld
|
|||
}
|
||||
}
|
||||
|
||||
// \todo cell change for non-player ref
|
||||
/// \todo cell change for non-player ref
|
||||
|
||||
// \todo this should go into the new scene class and eventually into the objects/actors classes.
|
||||
mScene.getMgr()->getSceneNode (ptr.getRefData().getHandle())->
|
||||
setPosition (Ogre::Vector3 (x, y, z));
|
||||
mRendering.moveObject (ptr, Ogre::Vector3 (x, y, z));
|
||||
}
|
||||
|
||||
void World::moveObject (Ptr ptr, float x, float y, float z)
|
||||
|
@ -653,7 +616,7 @@ namespace MWWorld
|
|||
|
||||
bool World::toggleRenderMode (RenderMode mode)
|
||||
{
|
||||
return mScene.toggleRenderMode (mode);
|
||||
return mRendering.toggleRenderMode (mode);
|
||||
}
|
||||
|
||||
std::pair<std::string, const ESM::Potion *> World::createRecord (const ESM::Potion& record)
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwrender/mwscene.hpp"
|
||||
#include "../mwrender/rendering_manager.hpp"
|
||||
#include "../mwrender/debugging.hpp"
|
||||
#include "../mwrender/renderingmanager.hpp"
|
||||
|
||||
#include "refdata.hpp"
|
||||
#include "ptr.hpp"
|
||||
|
@ -65,7 +65,8 @@ namespace MWWorld
|
|||
|
||||
private:
|
||||
|
||||
MWRender::MWScene mScene;
|
||||
MWRender::RenderingManager mRendering;
|
||||
|
||||
MWWorld::Scene *mWorldScene;
|
||||
MWWorld::Player *mPlayer;
|
||||
ESM::ESMReader mEsm;
|
||||
|
@ -75,7 +76,6 @@ namespace MWWorld
|
|||
MWWorld::PhysicsSystem *mPhysics;
|
||||
bool mSky;
|
||||
Environment& mEnvironment;
|
||||
MWRender::RenderingManager *mRenderingManager;
|
||||
int mNextDynamicRecord;
|
||||
|
||||
Cells mCells;
|
||||
|
@ -88,7 +88,6 @@ namespace MWWorld
|
|||
|
||||
Ptr getPtrViaHandle (const std::string& handle, Ptr::CellStore& cellStore);
|
||||
|
||||
MWRender::CellRender *searchRender (Ptr::CellStore *store);
|
||||
|
||||
int getDaysPerMonth (int month) const;
|
||||
|
||||
|
@ -134,8 +133,10 @@ namespace MWWorld
|
|||
Ptr getPtrViaHandle (const std::string& handle);
|
||||
///< Return a pointer to a liveCellRef with the given Ogre handle.
|
||||
|
||||
/// \todo enable reference in the OGRE scene
|
||||
void enable (Ptr reference);
|
||||
|
||||
/// \todo 5disable reference in the OGRE scene
|
||||
void disable (Ptr reference);
|
||||
|
||||
void advanceTime (double hours);
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <components/files/linuxpath.hpp>
|
||||
namespace Files { typedef LinuxPath TargetPathType; }
|
||||
|
||||
#elif defined(__WIN32) || defined(__WINDOWS__)
|
||||
#elif defined(__WIN32) || defined(__WINDOWS__) || defined (_WINDOWS)
|
||||
#include <components/files/windowspath.hpp>
|
||||
namespace Files { typedef WindowsPath TargetPathType; }
|
||||
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
#include <cstring>
|
||||
|
||||
#include <windows.h>
|
||||
#include <shobj.h>
|
||||
#include <shlobj.h>
|
||||
#include <Shlwapi.h>
|
||||
|
||||
#pragma comment(lib, "Shlwapi.lib")
|
||||
|
||||
namespace Files
|
||||
{
|
||||
|
|
|
@ -231,7 +231,7 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags,
|
|||
else if (node->recType == Nif::RC_NiTriShape && (isCollisionNode || !hasCollisionNode))
|
||||
{
|
||||
cShape->collide = true;
|
||||
handleNiTriShape(dynamic_cast<Nif::NiTriShape*>(node), flags,finalRot,finalPos,finalScale,raycastingOnly);
|
||||
handleNiTriShape(dynamic_cast<Nif::NiTriShape*>(node), flags,finalRot,finalPos,parentScale,raycastingOnly);
|
||||
}
|
||||
else if(node->recType == Nif::RC_RootCollisionNode)
|
||||
{
|
||||
|
@ -269,27 +269,6 @@ void ManualBulletShapeLoader::handleNiTriShape(Nif::NiTriShape *shape, int flags
|
|||
// bother setting it up.
|
||||
return;
|
||||
|
||||
btTransform tr;
|
||||
tr.setRotation(getbtQuat(parentRot));
|
||||
tr.setOrigin(btVector3(parentPos.x,parentPos.y,parentPos.z));
|
||||
|
||||
// Bounding box collision isn't implemented, always use mesh for now.
|
||||
/*if (bbcollide)
|
||||
{
|
||||
return;
|
||||
std::cout << "bbcolide?";
|
||||
//TODO: check whether it's half box or not (is there a /2?)
|
||||
NodeShape = new btBoxShape(btVector3(shape->boundXYZ->array[0]/2.,shape->boundXYZ->array[1]/2.,shape->boundXYZ->array[2]/2.));
|
||||
std::cout << "bbcolide12121212121";
|
||||
currentShape->addChildShape(tr,NodeShape);
|
||||
std::cout << "aaaaaaaaaaaaa";
|
||||
return;
|
||||
collide = true;
|
||||
bbcollide = false;
|
||||
}*/
|
||||
|
||||
/* Do in-place transformation.the only needed transfo is the scale. (maybe not in fact)
|
||||
*/
|
||||
|
||||
Nif::NiTriShapeData *data = shape->data.getPtr();
|
||||
|
||||
|
@ -298,10 +277,13 @@ void ManualBulletShapeLoader::handleNiTriShape(Nif::NiTriShape *shape, int flags
|
|||
|
||||
for(unsigned int i=0; i < data->triangles.length; i = i+3)
|
||||
{
|
||||
btVector3 b1(vertices[triangles[i+0]*3]*parentScale,vertices[triangles[i+0]*3+1]*parentScale,vertices[triangles[i+0]*3+2]*parentScale);
|
||||
btVector3 b2(vertices[triangles[i+1]*3]*parentScale,vertices[triangles[i+1]*3+1]*parentScale,vertices[triangles[i+1]*3+2]*parentScale);
|
||||
btVector3 b3(vertices[triangles[i+2]*3]*parentScale,vertices[triangles[i+2]*3+1]*parentScale,vertices[triangles[i+2]*3+2]*parentScale);
|
||||
mTriMesh->addTriangle(b1,b2,b3);
|
||||
Ogre::Vector3 b1(vertices[triangles[i+0]*3]*parentScale,vertices[triangles[i+0]*3+1]*parentScale,vertices[triangles[i+0]*3+2]*parentScale);
|
||||
Ogre::Vector3 b2(vertices[triangles[i+1]*3]*parentScale,vertices[triangles[i+1]*3+1]*parentScale,vertices[triangles[i+1]*3+2]*parentScale);
|
||||
Ogre::Vector3 b3(vertices[triangles[i+2]*3]*parentScale,vertices[triangles[i+2]*3+1]*parentScale,vertices[triangles[i+2]*3+2]*parentScale);
|
||||
b1 = parentRot * b1 + parentPos;
|
||||
b2 = parentRot * b2 + parentPos;
|
||||
b3 = parentRot * b3 + parentPos;
|
||||
mTriMesh->addTriangle(btVector3(b1.x,b1.y,b1.z),btVector3(b2.x,b2.y,b2.z),btVector3(b3.x,b3.y,b3.z));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue