diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index 3cdc1f850..69a510803 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -7,8 +7,26 @@ #include "../mwworld/ptr.hpp" +#include "../mwrender/cellimp.hpp" + namespace MWClass { + void Activator::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Activator::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/activator.hpp b/apps/openmw/mwclass/activator.hpp index 66821a7c5..3b48796ac 100644 --- a/apps/openmw/mwclass/activator.hpp +++ b/apps/openmw/mwclass/activator.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 4b94d78d1..007b2ca77 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -8,10 +8,28 @@ #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 + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Apparatus::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/apparatus.hpp b/apps/openmw/mwclass/apparatus.hpp index 4a514c94d..c2e6e25e1 100644 --- a/apps/openmw/mwclass/apparatus.hpp +++ b/apps/openmw/mwclass/apparatus.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index f4236b5f6..5c06077b2 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -8,10 +8,28 @@ #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 + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Armor::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/armor.hpp b/apps/openmw/mwclass/armor.hpp index 217a74a76..040342a69 100644 --- a/apps/openmw/mwclass/armor.hpp +++ b/apps/openmw/mwclass/armor.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 3bea7d5b9..179a060c6 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -8,10 +8,28 @@ #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 + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Book::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/book.hpp b/apps/openmw/mwclass/book.hpp index 3f15e2278..70d1bca3b 100644 --- a/apps/openmw/mwclass/book.hpp +++ b/apps/openmw/mwclass/book.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index c0e43bc3e..c3bbfa9f0 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -8,10 +8,28 @@ #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 + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Clothing::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/clothing.hpp b/apps/openmw/mwclass/clothing.hpp index ea358be68..fb88e25df 100644 --- a/apps/openmw/mwclass/clothing.hpp +++ b/apps/openmw/mwclass/clothing.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 0cc516308..9c1ed7a89 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -7,8 +7,26 @@ #include "../mwworld/ptr.hpp" +#include "../mwrender/cellimp.hpp" + namespace MWClass { + void Container::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Container::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index baeac23c7..de54a9e68 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 8525e9142..86adfb71a 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -8,8 +8,26 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" +#include "../mwrender/cellimp.hpp" + namespace MWClass { + void Creature::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Creature::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/creature.hpp b/apps/openmw/mwclass/creature.hpp index e964a7708..18771491e 100644 --- a/apps/openmw/mwclass/creature.hpp +++ b/apps/openmw/mwclass/creature.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 2c4bd3562..6fd8f996c 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -13,8 +13,26 @@ #include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" +#include "../mwrender/cellimp.hpp" + namespace MWClass { + void Door::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Door::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/door.hpp b/apps/openmw/mwclass/door.hpp index fa3b6d657..b6bf8808e 100644 --- a/apps/openmw/mwclass/door.hpp +++ b/apps/openmw/mwclass/door.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 9162384af..29d66d012 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -8,10 +8,28 @@ #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 + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Ingredient::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/ingredient.hpp b/apps/openmw/mwclass/ingredient.hpp index d742fae8b..8b781ba2f 100644 --- a/apps/openmw/mwclass/ingredient.hpp +++ b/apps/openmw/mwclass/ingredient.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 7cb363bf8..73ef69dc5 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -9,10 +9,38 @@ #include "../mwworld/actiontake.hpp" #include "../mwworld/nullaction.hpp" +#include "../mwrender/cellimp.hpp" + #include "containerutil.hpp" namespace MWClass { + void Light::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + + cellRender.insertMesh ("meshes\\" + model); + + // Extract the color and convert to floating point + 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 (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Light::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/light.hpp b/apps/openmw/mwclass/light.hpp index 6d08d557c..9ac5c586b 100644 --- a/apps/openmw/mwclass/light.hpp +++ b/apps/openmw/mwclass/light.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index ab1969480..c87d1e128 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -8,10 +8,28 @@ #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 + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Lockpick::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/lockpick.hpp b/apps/openmw/mwclass/lockpick.hpp index e15d9daee..bb9866b8c 100644 --- a/apps/openmw/mwclass/lockpick.hpp +++ b/apps/openmw/mwclass/lockpick.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index f29a0be1f..57dca3148 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -8,10 +8,28 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" +#include "../mwrender/cellimp.hpp" + #include "containerutil.hpp" namespace MWClass { + void Misc::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Misc::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/misc.hpp b/apps/openmw/mwclass/misc.hpp index 01542baed..0da1f0d3a 100644 --- a/apps/openmw/mwclass/misc.hpp +++ b/apps/openmw/mwclass/misc.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 829b17e7e..09b589c67 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -7,9 +7,42 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" +#include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" + +#include "../mwrender/cellimp.hpp" namespace MWClass { + void Npc::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + + std::string headID = ref->base->head; + + //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; + + cellRender.insertBegin (ref->ref); + cellRender.insertMesh (headModel); + + //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"); + + if (bodyPart) + cellRender.insertMesh("meshes\\" + bodyPart->model); + + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + std::string Npc::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = @@ -49,7 +82,7 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const { return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); - } + } MWWorld::ContainerStore& Npc::getContainerStore (const MWWorld::Ptr& ptr) const diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index a2dd6f470..af00ff198 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 0799b2031..3fe38542b 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -8,10 +8,28 @@ #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 + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Potion::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/potion.hpp b/apps/openmw/mwclass/potion.hpp index 208c26c56..9bf3b34a8 100644 --- a/apps/openmw/mwclass/potion.hpp +++ b/apps/openmw/mwclass/potion.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 08ec391a8..bc6c4ba19 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -8,10 +8,28 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" +#include "../mwrender/cellimp.hpp" + #include "containerutil.hpp" namespace MWClass { + void Probe::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Probe::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/probe.hpp b/apps/openmw/mwclass/probe.hpp index c17d53dab..11399d2f6 100644 --- a/apps/openmw/mwclass/probe.hpp +++ b/apps/openmw/mwclass/probe.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index 9ed7f0e77..253569afe 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -8,10 +8,28 @@ #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 + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Repair::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/repair.hpp b/apps/openmw/mwclass/repair.hpp index 52d045ebe..3da591e01 100644 --- a/apps/openmw/mwclass/repair.hpp +++ b/apps/openmw/mwclass/repair.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index f2bc4f635..211d239c6 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -3,8 +3,28 @@ #include +#include "../mwworld/ptr.hpp" + +#include "../mwrender/cellimp.hpp" + namespace MWClass { + void Static::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Static::getName (const MWWorld::Ptr& ptr) const { return ""; diff --git a/apps/openmw/mwclass/static.hpp b/apps/openmw/mwclass/static.hpp index fb8080182..abbf6cd5f 100644 --- a/apps/openmw/mwclass/static.hpp +++ b/apps/openmw/mwclass/static.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index c292c32dd..5a941360a 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -8,10 +8,28 @@ #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 + { + ESMS::LiveCellRef *ref = + ptr.get(); + + assert (ref->base != NULL); + const std::string &model = ref->base->model; + if (!model.empty()) + { + cellRender.insertBegin (ref->ref); + cellRender.insertMesh ("meshes\\" + model); + ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled())); + } + } + std::string Weapon::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/weapon.hpp b/apps/openmw/mwclass/weapon.hpp index 6bc96381c..d9c7653dd 100644 --- a/apps/openmw/mwclass/weapon.hpp +++ b/apps/openmw/mwclass/weapon.hpp @@ -9,6 +9,10 @@ namespace MWClass { public: + virtual void insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, + MWWorld::Environment& environment) const; + ///< Add reference into a cell for rendering + 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. diff --git a/apps/openmw/mwrender/cellimp.cpp b/apps/openmw/mwrender/cellimp.cpp index 1f1034379..0b5e7c951 100644 --- a/apps/openmw/mwrender/cellimp.cpp +++ b/apps/openmw/mwrender/cellimp.cpp @@ -7,60 +7,6 @@ using namespace MWRender; -template -void insertObj(CellRenderImp& cellRender, T& liveRef, const ESMS::ESMStore& store) -{ - assert (liveRef.base != NULL); - const std::string &model = liveRef.base->model; - if(!model.empty()) - { - cellRender.insertBegin (liveRef.ref); - cellRender.insertMesh ("meshes\\" + model); - liveRef.mData.setHandle (cellRender.insertEnd (liveRef.mData.isEnabled())); - } -} - -template<> -void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef& liveRef, const ESMS::ESMStore& store) -{ - assert (liveRef.base != NULL); - const std::string &model = liveRef.base->model; - if(!model.empty()) - { - cellRender.insertBegin (liveRef.ref); - - cellRender.insertMesh ("meshes\\" + model); - - // Extract the color and convert to floating point - const int color = liveRef.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(liveRef.base->data.radius); - cellRender.insertLight(r, g, b, radius); - - liveRef.mData.setHandle (cellRender.insertEnd (liveRef.mData.isEnabled())); - } -} - -template<> -void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef& liveRef, const ESMS::ESMStore& store) -{ - std::string headID = liveRef.base->head; - - //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\\" + store.bodyParts.find(headID)->model; - - cellRender.insertBegin(liveRef.ref); - cellRender.insertMesh(headModel); - - //TODO: define consts for each bodypart e.g. chest, foot, wrist... and put the parts in the right place - cellRender.insertMesh("meshes\\" + store.bodyParts.find(bodyRaceID + "chest")->model); - - liveRef.mData.setHandle (cellRender.insertEnd (liveRef.mData.isEnabled())); -} - template void insertCellRefList (CellRenderImp& cellRender, MWWorld::Environment& environment, T& cellRefList, ESMS::CellStore &cell) @@ -93,8 +39,8 @@ void CellRenderImp::insertCell(ESMS::CellStore &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.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);