mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 20:23:53 +00:00
commit
3ef40676bc
3 changed files with 39 additions and 15 deletions
|
@ -36,14 +36,9 @@ namespace MWClass
|
|||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
|
||||
if (!model.empty())
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
|
||||
const int color = ref->mBase->mData.mColor;
|
||||
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->mBase->mData.mRadius);
|
||||
objects.insertLight (ptr, r, g, b, radius);
|
||||
objects.insertMesh(ptr, "meshes\\" + model, true);
|
||||
else
|
||||
objects.insertLight(ptr, NULL);
|
||||
}
|
||||
|
||||
void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||
|
|
|
@ -34,6 +34,18 @@ void Objects::clearSceneNode (Ogre::SceneNode *node)
|
|||
for (int i=node->numAttachedObjects()-1; i>=0; --i)
|
||||
{
|
||||
Ogre::MovableObject *object = node->getAttachedObject (i);
|
||||
|
||||
// for entities, destroy any objects attached to bones
|
||||
if (object->getTypeFlags () == Ogre::SceneManager::ENTITY_TYPE_MASK)
|
||||
{
|
||||
Ogre::Entity* ent = static_cast<Ogre::Entity*>(object);
|
||||
Ogre::Entity::ChildObjectListIterator children = ent->getAttachedObjectIterator ();
|
||||
while (children.hasMoreElements())
|
||||
{
|
||||
mRenderer.getScene ()->destroyMovableObject (children.getNext ());
|
||||
}
|
||||
}
|
||||
|
||||
node->detachObject (object);
|
||||
mRenderer.getScene()->destroyMovableObject (object);
|
||||
}
|
||||
|
@ -87,7 +99,7 @@ void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_)
|
|||
mIsStatic = static_;
|
||||
}
|
||||
|
||||
void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh)
|
||||
void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool light)
|
||||
{
|
||||
Ogre::SceneNode* insert = ptr.getRefData().getBaseNode();
|
||||
assert(insert);
|
||||
|
@ -204,17 +216,29 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh)
|
|||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
if (light)
|
||||
{
|
||||
insertLight(ptr, entities.mSkelBase);
|
||||
}
|
||||
}
|
||||
|
||||
void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius)
|
||||
void Objects::insertLight (const MWWorld::Ptr& ptr, Ogre::Entity* skelBase)
|
||||
{
|
||||
Ogre::SceneNode* insert = mRenderer.getScene()->getSceneNode(ptr.getRefData().getHandle());
|
||||
assert(insert);
|
||||
Ogre::Light *light = mRenderer.getScene()->createLight();
|
||||
light->setDiffuseColour (r, g, b);
|
||||
|
||||
MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>();
|
||||
|
||||
const int color = ref->mBase->mData.mColor;
|
||||
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->mBase->mData.mRadius);
|
||||
|
||||
Ogre::Light *light = mRenderer.getScene()->createLight();
|
||||
light->setDiffuseColour (r, g, b);
|
||||
|
||||
LightInfo info;
|
||||
info.name = light->getName();
|
||||
info.radius = radius;
|
||||
|
@ -265,7 +289,12 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, f
|
|||
light->setAttenuation(r*10, 0, 0, attenuation);
|
||||
}
|
||||
|
||||
insert->attachObject(light);
|
||||
// If there's an AttachLight bone, attach the light to that, otherwise attach it to the base scene node
|
||||
if (skelBase && skelBase->getSkeleton ()->hasBone ("AttachLight"))
|
||||
skelBase->attachObjectToBone ("AttachLight", light);
|
||||
else
|
||||
insert->attachObject(light);
|
||||
|
||||
mLights.push_back(info);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,8 +73,8 @@ public:
|
|||
Objects(OEngine::Render::OgreRenderer& renderer): mRenderer (renderer), mIsStatic(false) {}
|
||||
~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);
|
||||
void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool light=false);
|
||||
void insertLight (const MWWorld::Ptr& ptr, Ogre::Entity* skelBase);
|
||||
|
||||
void enableLights();
|
||||
void disableLights();
|
||||
|
|
Loading…
Reference in a new issue