Merge remote branch 'zinnschlag/master'

actorid
Star-Demon 14 years ago
commit d4dccc0b54

@ -209,7 +209,8 @@ find_path (UUID_INCLUDE_DIR uuid/uuid.h)
include_directories(${UUID_INCLUDE_DIR})
endif (WIN32)
if (MSVC10)
set(PLATFORM_INCLUDE_DIR "")
set(PLATFORM_INCLUDE_DIR "")
add_definitions(-DMYGUI_DONT_REPLACE_NULLPTR)
endif()
# Dependencies

@ -16,6 +16,12 @@
#include "../mwmechanics/mechanicsmanager.hpp"
#include <OgreSceneNode.h>
namespace
{
const Ogre::Radian kOgrePi (Ogre::Math::PI);
const Ogre::Radian kOgrePiOverTwo (Ogre::Math::PI / Ogre::Real(2.0));
}
namespace MWClass
{
std::string Npc::getId (const MWWorld::Ptr& ptr) const
@ -107,18 +113,18 @@ namespace MWClass
std::string upperarmpath[2] = {npcName + "chest", npcName + "upper arm"};
if (groin){
cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, Ogre::Radian(3.14), npcName + "groin", addresses, numbers);
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, Ogre::Radian(3.14), npcName + "tail", addresses, numbers, "tail");
cellRender.insertMesh("tail\\" + tail->model, Ogre::Vector3(0 , 0, -76), axis, kOgrePi, npcName + "tail", addresses, numbers, "tail");
//std::cout << "TAIL\n";
}
//addresses[1] = npcName + "groin";
if(upperleg){
cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( 6, 0, -16), axis, Ogre::Radian(3.14), npcName + "upper leg", addresses, numbers); //-18
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";
@ -158,9 +164,9 @@ namespace MWClass
}
if(feet){
cellRender.insertMesh ("foot\\" + feet->model, Ogre::Vector3( 7, 4, -16), axis, Ogre::Radian(3.14), npcName + "foot", addresses, numbers); //9, 0, -14
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, Ogre::Radian(3.14), npcName + "foot2", addresses2, numbers);
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);
@ -169,20 +175,20 @@ namespace MWClass
if (arm){
//010
cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(-12.5, 0, 104), Ogre::Vector3(0, 1, 0), Ogre::Radian(-3.14 / 2), npcName + "upper arm", upperleft, uppernumbers); //1, 0,.75
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), Ogre::Radian(3.14), npcName + "upper arm2", upperright, uppernumbers);
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), Ogre::Radian(3.14/2), upperleft, uppernumbers);
cellRender.rotateMesh(Ogre::Vector3(0, 1, 0), kOgrePiOverTwo, upperleft, uppernumbers);
}
if (forearm)
{
//addresses[1] = npcName + "upper arm";
cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm", upperleft, uppernumbers);
cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm2", upperright, uppernumbers);
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";
}
@ -192,14 +198,14 @@ namespace MWClass
{
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), Ogre::Radian(3.14), 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), Ogre::Radian(3.14), npcName + "forearm2", upperright, uppernumbers);
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), Ogre::Radian(3.14), npcName + "wrist", upperleft, uppernumbers);
cellRender.insertMesh("meshes\\" + wrist->model, Ogre::Vector3(-9.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "wrist2", upperright, uppernumbers);
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";
}
@ -215,11 +221,11 @@ namespace MWClass
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), Ogre::Radian(3.14), 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), Ogre::Radian(3.14), npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,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 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.rotateMesh(Ogre::Vector3(0, 0,0), Ogre::Radian(3.14), upperleft, uppernumbers);
//cellRender.rotateMesh(Ogre::Vector3(0, 0,0), kOgrePi, upperleft, uppernumbers);
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers);
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers);
}
@ -232,9 +238,9 @@ namespace MWClass
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), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110
//cellRender.insertMesh("meshes\\" + hands->model, Ogre::Vector3(42, 0,110), Ogre::Vector3(1, 0, 0), Ogre::Radian(3.14), 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), Ogre::Radian(3.14), npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,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\\" + hands->model, Ogre::Vector3(42, 0,110), Ogre::Vector3(1, 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);
@ -244,7 +250,7 @@ namespace MWClass
//neck will reset chest counter
if(neck)
{
cellRender.insertMesh ("meshes\\" + neck->model, Ogre::Vector3( 0, 0, 120), axis, Ogre::Radian(3.14), npcName + "neck", neckandup, neckNumbers);
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);

@ -55,8 +55,8 @@ StatsWindow::StatsWindow (MWWorld::Environment& environment)
for (int i = 0; i < ESM::Skill::Length; ++i)
{
skillValues.insert(std::pair<int, MWMechanics::Stat<float> >(i, MWMechanics::Stat<float>()));
skillWidgetMap.insert(std::pair<int, MyGUI::StaticTextPtr>(i, nullptr));
skillValues.insert(std::make_pair(i, MWMechanics::Stat<float>()));
skillWidgetMap.insert(std::make_pair(i, static_cast<MyGUI::StaticText*> (0)));
}
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);

@ -81,8 +81,8 @@ ReviewDialog::ReviewDialog(MWWorld::Environment& environment)
for (int i = 0; i < ESM::Skill::Length; ++i)
{
skillValues.insert(std::pair<int, MWMechanics::Stat<float> >(i, MWMechanics::Stat<float>()));
skillWidgetMap.insert(std::pair<int, MyGUI::StaticTextPtr>(i, nullptr));
skillValues.insert(std::make_pair(i, MWMechanics::Stat<float>()));
skillWidgetMap.insert(std::make_pair(i, static_cast<MyGUI::StaticText*> (0)));
}
static_cast<MyGUI::WindowPtr>(mMainWidget)->eventWindowChangeCoord = MyGUI::newDelegate(this, &ReviewDialog::onWindowResize);

@ -35,14 +35,14 @@ bool ExteriorCellRender::lightOutQuadInLin = false;
void ExteriorCellRender::insertBegin (ESM::CellRef &ref)
{
assert (!insert);
assert (!mInsert);
// Create and place scene node for this object
insert = base->createChildSceneNode();
mInsert = mBase->createChildSceneNode();
const float *f = ref.pos.pos;
insert->setPosition(f[0], f[1], f[2]);
insert->setScale(ref.scale, ref.scale, ref.scale);
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;
@ -57,14 +57,14 @@ void ExteriorCellRender::insertBegin (ESM::CellRef &ref)
Quaternion zr(Radian(-f[2]), Vector3::UNIT_Z);
// Rotates first around z, then y, then x
insert->setOrientation(xr*yr*zr);
mInsert->setOrientation(xr*yr*zr);
}
void ExteriorCellRender::rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements)
{
assert(insert);
Ogre::SceneNode *parent = insert;
assert(mInsert);
Ogre::SceneNode *parent = mInsert;
//std::cout << "ELEMENTS:" << elements;
for (int i = 0; i < elements; i++){
if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
@ -74,24 +74,24 @@ void ExteriorCellRender::rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std
}
/*
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 (insert);
//insert->
Ogre::SceneNode *parent = insert;
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]));
}
npcPart = parent->createChildSceneNode(sceneNodeName);
mNpcPart = parent->createChildSceneNode(sceneNodeName);
NIFLoader::load(mesh);
MovableObject *ent = scene.getMgr()->createEntity(mesh);
MovableObject *ent = mScene.getMgr()->createEntity(mesh);
npcPart->translate(vec);
npcPart->rotate(axis, angle);
// npcPart->translate(vec);
//npcPart->rotate(axis, angle);
npcPart->attachObject(ent);
//npcPart->
mNpcPart->translate(vec);
mNpcPart->rotate(axis, angle);
// mNpcPart->translate(vec);
//mNpcPart->rotate(axis, angle);
mNpcPart->attachObject(ent);
//mNpcPart->
}
*/
@ -101,30 +101,30 @@ void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec,
}
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 (insert);
//insert->
Ogre::SceneNode *parent = insert;
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]));
}
npcPart = parent->createChildSceneNode(sceneNodeName);
mNpcPart = parent->createChildSceneNode(sceneNodeName);
MeshPtr good2 = NIFLoader::load(mesh);
MovableObject *ent = scene.getMgr()->createEntity(mesh);
MovableObject *ent = mScene.getMgr()->createEntity(mesh);
if(translateFirst){
npcPart->translate(vec);
npcPart->rotate(axis, angle);
mNpcPart->translate(vec);
mNpcPart->rotate(axis, angle);
}
else{
npcPart->rotate(axis, angle);
npcPart->translate(vec);
mNpcPart->rotate(axis, angle);
mNpcPart->translate(vec);
}
npcPart->attachObject(ent);
mNpcPart->attachObject(ent);
Ogre::MeshManager *m = MeshManager::getSingletonPtr();
const std::string beast1 ="meshes\\b\\B_N_Khajiit_F_Skins.nif";
@ -182,8 +182,8 @@ void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec,
void ExteriorCellRender::scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements)
{
assert(insert);
Ogre::SceneNode *parent = insert;
assert(mInsert);
Ogre::SceneNode *parent = mInsert;
//std::cout << "ELEMENTS:" << elements;
for (int i = 0; i < elements; i++){
if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
@ -197,19 +197,19 @@ void ExteriorCellRender::scaleMesh(Ogre::Vector3 axis, std::string sceneNodeNam
void ExteriorCellRender::insertMesh(const std::string &mesh)
{
assert (insert);
assert (mInsert);
NIFLoader::load(mesh);
MovableObject *ent = scene.getMgr()->createEntity(mesh);
insert->attachObject(ent);
MovableObject *ent = mScene.getMgr()->createEntity(mesh);
mInsert->attachObject(ent);
}
// insert a light related to the most recent insertBegin call.
void ExteriorCellRender::insertLight(float r, float g, float b, float radius)
{
assert (insert);
assert (mInsert);
Ogre::Light *light = scene.getMgr()->createLight();
Ogre::Light *light = mScene.getMgr()->createLight();
light->setDiffuseColour (r, g, b);
float cval=0.0f, lval=0.0f, qval=0.0f;
@ -237,21 +237,21 @@ void ExteriorCellRender::insertLight(float r, float g, float b, float radius)
light->setAttenuation(10*radius, cval, lval, qval);
insert->attachObject(light);
mInsert->attachObject(light);
}
// finish inserting a new reference and return a handle to it.
std::string ExteriorCellRender::insertEnd (bool enable)
{
assert (insert);
assert (mInsert);
std::string handle = insert->getName();
std::string handle = mInsert->getName();
if (!enable)
insert->setVisible (false);
mInsert->setVisible (false);
insert = 0;
mInsert = 0;
return handle;
}
@ -260,14 +260,14 @@ std::string ExteriorCellRender::insertEnd (bool enable)
void ExteriorCellRender::configureAmbient()
{
ambientColor.setAsABGR (cell.cell->ambi.ambient);
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 = scene.getMgr()->createLight();
Ogre::Light *light = mScene.getMgr()->createLight();
Ogre::ColourValue colour;
colour.setAsABGR (cell.cell->ambi.sunlight);
colour.setAsABGR (mCell.cell->ambi.sunlight);
light->setDiffuseColour (colour);
light->setType(Ogre::Light::LT_DIRECTIONAL);
light->setDirection(0,-1,0);
@ -277,74 +277,74 @@ void ExteriorCellRender::configureAmbient()
void ExteriorCellRender::configureFog()
{
Ogre::ColourValue color;
color.setAsABGR (cell.cell->ambi.fog);
color.setAsABGR (mCell.cell->ambi.fog);
float high = 4500 + 9000 * (1-cell.cell->ambi.fogDensity);
float high = 4500 + 9000 * (1-mCell.cell->ambi.fogDensity);
float low = 200;
scene.getMgr()->setFog (FOG_LINEAR, color, 0, low, high);
scene.getCamera()->setFarClipDistance (high + 10);
scene.getViewport()->setBackgroundColour (color);
mScene.getMgr()->setFog (FOG_LINEAR, color, 0, low, high);
mScene.getCamera()->setFarClipDistance (high + 10);
mScene.getViewport()->setBackgroundColour (color);
}
void ExteriorCellRender::setAmbientMode()
{
switch (ambientMode)
switch (mAmbientMode)
{
case 0:
scene.getMgr()->setAmbientLight(ambientColor);
mScene.getMgr()->setAmbientLight(mAmbientColor);
break;
case 1:
scene.getMgr()->setAmbientLight(0.7f*ambientColor + 0.3f*ColourValue(1,1,1));
mScene.getMgr()->setAmbientLight(0.7f*mAmbientColor + 0.3f*ColourValue(1,1,1));
break;
case 2:
scene.getMgr()->setAmbientLight(ColourValue(1,1,1));
mScene.getMgr()->setAmbientLight(ColourValue(1,1,1));
break;
}
}
void ExteriorCellRender::show()
{
base = scene.getRoot()->createChildSceneNode();
mBase = mScene.getRoot()->createChildSceneNode();
configureAmbient();
configureFog();
insertCell(cell, mEnvironment);
insertCell(mCell, mEnvironment);
}
void ExteriorCellRender::hide()
{
if(base)
base->setVisible(false);
if(mBase)
mBase->setVisible(false);
}
void ExteriorCellRender::destroy()
{
if(base)
if(mBase)
{
base->removeAndDestroyAllChildren();
scene.getMgr()->destroySceneNode(base);
mBase->removeAndDestroyAllChildren();
mScene.getMgr()->destroySceneNode(mBase);
}
base = NULL;
mBase = NULL;
}
// Switch through lighting modes.
void ExteriorCellRender::toggleLight()
{
if (ambientMode==2)
ambientMode = 0;
if (mAmbientMode==2)
mAmbientMode = 0;
else
++ambientMode;
++mAmbientMode;
switch (ambientMode)
switch (mAmbientMode)
{
case 0: std::cout << "Setting lights to normal\n"; break;
case 1: std::cout << "Turning the lights up\n"; break;
@ -357,21 +357,21 @@ void ExteriorCellRender::toggleLight()
void ExteriorCellRender::enable (const std::string& handle)
{
if (!handle.empty())
scene.getMgr()->getSceneNode (handle)->setVisible (true);
mScene.getMgr()->getSceneNode (handle)->setVisible (true);
}
void ExteriorCellRender::disable (const std::string& handle)
{
if (!handle.empty())
scene.getMgr()->getSceneNode (handle)->setVisible (false);
mScene.getMgr()->getSceneNode (handle)->setVisible (false);
}
void ExteriorCellRender::deleteObject (const std::string& handle)
{
if (!handle.empty())
{
Ogre::SceneNode *node = scene.getMgr()->getSceneNode (handle);
Ogre::SceneNode *node = mScene.getMgr()->getSceneNode (handle);
node->removeAndDestroyAllChildren();
scene.getMgr()->destroySceneNode (node);
mScene.getMgr()->destroySceneNode (node);
}
}

@ -45,21 +45,21 @@ namespace MWRender
static bool lightOutQuadInLin;
ESMS::CellStore<MWWorld::RefData> &cell;
ESMS::CellStore<MWWorld::RefData> &mCell;
MWWorld::Environment &mEnvironment;
MWScene &scene;
MWScene &mScene;
/// The scene node that contains all objects belonging to this
/// cell.
Ogre::SceneNode *base;
Ogre::SceneNode *mBase;
Ogre::SceneNode *insert;
Ogre::SceneNode *npcPart;
Ogre::SceneNode *mInsert;
Ogre::SceneNode *mNpcPart;
// 0 normal, 1 more bright, 2 max
int ambientMode;
int mAmbientMode;
Ogre::ColourValue ambientColor;
Ogre::ColourValue mAmbientColor;
/// start inserting a new reference.
virtual void insertBegin (ESM::CellRef &ref);
@ -91,7 +91,7 @@ namespace MWRender
ExteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment,
MWScene &_scene)
: cell(_cell), mEnvironment (environment), scene(_scene), base(NULL), insert(NULL), ambientMode (0) {}
: mCell(_cell), mEnvironment (environment), mScene(_scene), mBase(NULL), mInsert(NULL), mAmbientMode (0) {}
virtual ~ExteriorCellRender() { destroy(); }

@ -152,15 +152,15 @@ public:
*
*************************************************************************/
int getVer() { return c.header.version; }
float getFVer() { return *((float*)&c.header.version); }
int getSpecial() { return spf; }
const std::string getAuthor() { return c.header.author.toString(); }
const std::string getDesc() { return c.header.desc.toString(); }
const SaveData &getSaveData() { return saveData; }
const MasterList &getMasters() { return masters; }
const NAME &retSubName() { return c.subName; }
uint32_t getSubSize() { return c.leftSub; }
int getVer() { return mCtx.header.version; }
float getFVer() { return *((float*)&mCtx.header.version); }
int getSpecial() { return mSpf; }
const std::string getAuthor() { return mCtx.header.author.toString(); }
const std::string getDesc() { return mCtx.header.desc.toString(); }
const SaveData &getSaveData() { return mSaveData; }
const MasterList &getMasters() { return mMasters; }
const NAME &retSubName() { return mCtx.subName; }
uint32_t getSubSize() { return mCtx.leftSub; }
/*************************************************************************
*
@ -174,22 +174,22 @@ public:
ESM_Context getContext()
{
// Update the file position before returning
c.filePos = esm->tell();
return c;
mCtx.filePos = mEsm->tell();
return mCtx;
}
/** Restore a previously saved context */
void restoreContext(const ESM_Context &rc)
{
// Reopen the file if necessary
if(c.filename != rc.filename)
if(mCtx.filename != rc.filename)
openRaw(rc.filename);
// Copy the data
c = rc;
mCtx = rc;
// Make sure we seek to the right place
esm->seek(c.filePos);
mEsm->seek(mCtx.filePos);
}
/** Close the file, resets all information. After calling close()
@ -197,14 +197,14 @@ public:
*/
void close()
{
esm.reset();
c.filename.clear();
c.leftFile = 0;
c.leftRec = 0;
c.leftSub = 0;
c.subCached = false;
c.recName.val = 0;
c.subName.val = 0;
mEsm.reset();
mCtx.filename.clear();
mCtx.leftFile = 0;
mCtx.leftRec = 0;
mCtx.leftSub = 0;
mCtx.subCached = false;
mCtx.recName.val = 0;
mCtx.subName.val = 0;
}
/// Raw opening. Opens the file and sets everything up but doesn't
@ -212,17 +212,17 @@ public:
void openRaw(Mangle::Stream::StreamPtr _esm, const std::string &name)
{
close();
esm = _esm;
c.filename = name;
c.leftFile = esm->size();
mEsm = _esm;
mCtx.filename = name;
mCtx.leftFile = mEsm->size();
// Flag certain files for special treatment, based on the file
// name.
const char *cstr = c.filename.c_str();
if(iends(cstr, "Morrowind.esm")) spf = SF_Morrowind;
else if(iends(cstr, "Tribunal.esm")) spf = SF_Tribunal;
else if(iends(cstr, "Bloodmoon.esm")) spf = SF_Bloodmoon;
else spf = SF_Other;
const char *cstr = mCtx.filename.c_str();
if(iends(cstr, "Morrowind.esm")) mSpf = SF_Morrowind;
else if(iends(cstr, "Tribunal.esm")) mSpf = SF_Tribunal;
else if(iends(cstr, "Bloodmoon.esm")) mSpf = SF_Bloodmoon;
else mSpf = SF_Other;
}
/// Load ES file from a new stream, parses the header. Closes the
@ -237,10 +237,10 @@ public:
getRecHeader();
// Get the header
getHNT(c.header, "HEDR", 300);
getHNT(mCtx.header, "HEDR", 300);
if(c.header.version != VER_12 &&
c.header.version != VER_13)
if(mCtx.header.version != VER_12 &&
mCtx.header.version != VER_13)
fail("Unsupported file format version");
while(isNextSub("MAST"))
@ -248,15 +248,15 @@ public:
MasterData m;
m.name = getHString();
m.size = getHNLong("DATA");
masters.push_back(m);
mMasters.push_back(m);
}
if(c.header.type == FT_ESS)
if(mCtx.header.type == FT_ESS)
{
// Savegame-related data
// Player position etc
getHNT(saveData, "GMDT", 124);
getHNT(mSaveData, "GMDT", 124);
/* Image properties, five ints. Is always:
Red-mask: 0xff0000
@ -332,7 +332,7 @@ public:
void getHT(X &x)
{
getSubHeader();
if(c.leftSub != sizeof(X))
if(mCtx.leftSub != sizeof(X))
fail("getHT(): subrecord size mismatch");
getT(x);
}
@ -371,23 +371,23 @@ public:
// them. For some reason, they break the rules, and contain a byte
// (value 0) even if the header says there is no data. If
// Morrowind accepts it, so should we.
if(c.leftSub == 0)
if(mCtx.leftSub == 0)
{
// Skip the following zero byte
c.leftRec--;
mCtx.leftRec--;
char c;
esm->read(&c,1);
mEsm->read(&c,1);
return "";
}
return getString(c.leftSub);
return getString(mCtx.leftSub);
}
// Read the given number of bytes from a subrecord
void getHExact(void*p, int size)
{
getSubHeader();
if(size !=static_cast<int> (c.leftSub))
if(size !=static_cast<int> (mCtx.leftSub))
fail("getHExact() size mismatch");
getExact(p,size);
}
@ -409,8 +409,8 @@ public:
void getSubNameIs(const char* name)
{
getSubName();
if(c.subName != name)
fail("Expected subrecord " + std::string(name) + " but got " + c.subName.toString());
if(mCtx.subName != name)
fail("Expected subrecord " + std::string(name) + " but got " + mCtx.subName.toString());
}
/** Checks if the next sub record name matches the parameter. If it
@ -420,16 +420,16 @@ public:
*/
bool isNextSub(const char* name)
{
if(!c.leftRec) return false;
if(!mCtx.leftRec) return false;
getSubName();
// If the name didn't match, then mark the it as 'cached' so it's
// available for the next call to getSubName.
c.subCached = (c.subName != name);
mCtx.subCached = (mCtx.subName != name);
// If subCached is false, then subName == name.
return !c.subCached;
return !mCtx.subCached;
}
// Read subrecord name. This gets called a LOT, so I've optimized it
@ -437,25 +437,25 @@ public:
void getSubName()
{
// If the name has already been read, do nothing
if(c.subCached)
if(mCtx.subCached)
{
c.subCached = false;
mCtx.subCached = false;
return;
}
// Don't bother with error checking, we will catch an EOF upon
// reading the subrecord data anyway.
esm->read(c.subName.name, 4);
c.leftRec -= 4;
mEsm->read(mCtx.subName.name, 4);
mCtx.leftRec -= 4;
}
// This is specially optimized for LoadINFO.
bool isEmptyOrGetName()
{
if(c.leftRec)
if(mCtx.leftRec)
{
esm->read(c.subName.name, 4);
c.leftRec -= 4;
mEsm->read(mCtx.subName.name, 4);
mCtx.leftRec -= 4;
return false;
}
return true;
@ -466,14 +466,14 @@ public:
void skipHSub()
{
getSubHeader();
skip(c.leftSub);
skip(mCtx.leftSub);
}
// Skip sub record and check its size
void skipHSubSize(int size)
{
skipHSub();
if(static_cast<int> (c.leftSub) != size)
if(static_cast<int> (mCtx.leftSub) != size)
fail("skipHSubSize() mismatch");
}
@ -482,17 +482,17 @@ public:
*/
void getSubHeader()
{
if(c.leftRec < 4)
if(mCtx.leftRec < 4)
fail("End of record while reading sub-record header");
// Get subrecord size
getT(c.leftSub);
getT(mCtx.leftSub);
// Adjust number of record bytes left
c.leftRec -= c.leftSub + 4;
mCtx.leftRec -= mCtx.leftSub + 4;
// Check that sizes added up
if(c.leftRec < 0)
if(mCtx.leftRec < 0)
fail("Not enough bytes left in record for this subrecord.");
}
@ -501,7 +501,7 @@ public:
void getSubHeaderIs(int size)
{
getSubHeader();
if(size != static_cast<int> (c.leftSub))
if(size != static_cast<int> (mCtx.leftSub))
fail("getSubHeaderIs(): Sub header mismatch");
}
@ -516,29 +516,29 @@ public:
{
if(!hasMoreRecs())
fail("No more records, getRecName() failed");
getName(c.recName);
c.leftFile -= 4;
getName(mCtx.recName);
mCtx.leftFile -= 4;
// Make sure we don't carry over any old cached subrecord
// names. This can happen in some cases when we skip parts of a
// record.
c.subCached = false;
mCtx.subCached = false;
return c.recName;
return mCtx.recName;
}
// Skip the rest of this record. Assumes the name and header have
// already been read
void skipRecord()
{
skip(c.leftRec);
c.leftRec = 0;
skip(mCtx.leftRec);
mCtx.leftRec = 0;
}
// Skip an entire record, including the header (but not the name)
void skipHRecord()
{
if(!c.leftFile) return;
if(!mCtx.leftFile) return;
getRecHeader();
skipRecord();
}
@ -551,26 +551,26 @@ public:
void getRecHeader(uint32_t &flags)
{
// General error checking
if(c.leftFile < 12)
if(mCtx.leftFile < 12)
fail("End of file while reading record header");
if(c.leftRec)
if(mCtx.leftRec)
fail("Previous record contains unread bytes");
getUint(c.leftRec);
getUint(mCtx.leftRec);
getUint(flags);// This header entry is always zero
getUint(flags);
c.leftFile -= 12;
mCtx.leftFile -= 12;
// Check that sizes add up
if(c.leftFile < c.leftRec)
if(mCtx.leftFile < mCtx.leftRec)
fail("Record size is larger than rest of file");
// Adjust number of bytes c.left in file
c.leftFile -= c.leftRec;
// Adjust number of bytes mCtx.left in file
mCtx.leftFile -= mCtx.leftRec;
}
bool hasMoreRecs() { return c.leftFile > 0; }
bool hasMoreSubs() { return c.leftRec > 0; }
bool hasMoreRecs() { return mCtx.leftFile > 0; }
bool hasMoreSubs() { return mCtx.leftRec > 0; }
/*************************************************************************
@ -584,7 +584,7 @@ public:
void getExact(void*x, int size)
{
int t = esm->read(x, size);
int t = mEsm->read(x, size);
if(t != size)
fail("Read error");
}
@ -596,14 +596,14 @@ public:
std::string getString(int size)
{
char *ptr = ToUTF8::getBuffer(size);
esm->read(ptr,size);
mEsm->read(ptr,size);
// Convert to UTF8 and return
return ToUTF8::getUtf8(ToUTF8::WINDOWS_1252);
}
void skip(int bytes) { esm->seek(esm->tell()+bytes); }
uint64_t getOffset() { return esm->tell(); }
void skip(int bytes) { mEsm->seek(mEsm->tell()+bytes); }
uint64_t getOffset() { return mEsm->tell(); }
/// Used for error handling
void fail(const std::string &msg)
@ -613,24 +613,24 @@ public:
stringstream ss;
ss << "ESM Error: " << msg;
ss << "\n File: " << c.filename;
ss << "\n Record: " << c.recName.toString();
ss << "\n Subrecord: " << c.subName.toString();
if(esm != NULL)
ss << "\n Offset: 0x" << hex << esm->tell();
ss << "\n File: " << mCtx.filename;
ss << "\n Record: " << mCtx.recName.toString();
ss << "\n Subrecord: " << mCtx.subName.toString();
if(mEsm != NULL)
ss << "\n Offset: 0x" << hex << mEsm->tell();
throw std::runtime_error(ss.str());
}
private:
Mangle::Stream::StreamPtr esm;
Mangle::Stream::StreamPtr mEsm;
ESM_Context c;
ESM_Context mCtx;
// Special file signifier (see SpecialFile enum above)
int spf;
int mSpf;
SaveData saveData;
MasterList masters;
SaveData mSaveData;
MasterList mMasters;
};
}
#endif

@ -1 +1 @@
Subproject commit 377e7d71ceea5a1ca166b8df9a03a5b68df83bc5
Subproject commit 7185eab18c29a0a5e03e44690d6bd8ece7e3792b

@ -6,7 +6,7 @@
// For GCC, just use strings.h (this applies to mingw too)
#if defined(__GNUC__)
# include <strings.h>
#elif defined(MSVC)
#elif defined(MSVC) || defined(_MSC_VER)
# pragma warning(disable: 4996)
# define strcasecmp stricmp
# define snprintf _snprintf

Loading…
Cancel
Save