mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 06:23:52 +00:00
OpenCS: create light sources
This commit is contained in:
parent
e7bb8878f3
commit
7f967153ef
2 changed files with 33 additions and 2 deletions
|
@ -17,7 +17,9 @@
|
||||||
#include "../../model/world/refidcollection.hpp"
|
#include "../../model/world/refidcollection.hpp"
|
||||||
|
|
||||||
#include <components/resource/scenemanager.hpp>
|
#include <components/resource/scenemanager.hpp>
|
||||||
#include <components/sceneutil/clone.hpp>
|
#include <components/sceneutil/lightutil.hpp>
|
||||||
|
#include <components/sceneutil/lightmanager.hpp>
|
||||||
|
#include <components/fallback/fallback.hpp>
|
||||||
|
|
||||||
#include "mask.hpp"
|
#include "mask.hpp"
|
||||||
|
|
||||||
|
@ -62,6 +64,7 @@ void CSVRender::Object::update()
|
||||||
const CSMWorld::RefIdCollection& referenceables = mData.getReferenceables();
|
const CSMWorld::RefIdCollection& referenceables = mData.getReferenceables();
|
||||||
|
|
||||||
int index = referenceables.searchId (mReferenceableId);
|
int index = referenceables.searchId (mReferenceableId);
|
||||||
|
const ESM::Light* light = NULL;
|
||||||
|
|
||||||
if (index==-1)
|
if (index==-1)
|
||||||
error = 1;
|
error = 1;
|
||||||
|
@ -73,6 +76,14 @@ void CSVRender::Object::update()
|
||||||
referenceables.findColumnIndex (CSMWorld::Columns::ColumnId_Model)).
|
referenceables.findColumnIndex (CSMWorld::Columns::ColumnId_Model)).
|
||||||
toString().toUtf8().constData();
|
toString().toUtf8().constData();
|
||||||
|
|
||||||
|
int recordType =
|
||||||
|
referenceables.getData (index,
|
||||||
|
referenceables.findColumnIndex(CSMWorld::Columns::ColumnId_RecordType)).toInt();
|
||||||
|
if (recordType == CSMWorld::UniversalId::Type_Light)
|
||||||
|
{
|
||||||
|
light = &dynamic_cast<const CSMWorld::Record<ESM::Light>& >(referenceables.getRecord(index)).get();
|
||||||
|
}
|
||||||
|
|
||||||
if (model.empty())
|
if (model.empty())
|
||||||
error = 2;
|
error = 2;
|
||||||
}
|
}
|
||||||
|
@ -97,6 +108,21 @@ void CSVRender::Object::update()
|
||||||
std::cerr << e.what() << std::endl;
|
std::cerr << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (light)
|
||||||
|
{
|
||||||
|
const Fallback::Map* fallback = mData.getFallbackMap();
|
||||||
|
static bool outQuadInLin = fallback->getFallbackBool("LightAttenuation_OutQuadInLin");
|
||||||
|
static bool useQuadratic = fallback->getFallbackBool("LightAttenuation_UseQuadratic");
|
||||||
|
static float quadraticValue = fallback->getFallbackFloat("LightAttenuation_QuadraticValue");
|
||||||
|
static float quadraticRadiusMult = fallback->getFallbackFloat("LightAttenuation_QuadraticRadiusMult");
|
||||||
|
static bool useLinear = fallback->getFallbackBool("LightAttenuation_UseLinear");
|
||||||
|
static float linearRadiusMult = fallback->getFallbackFloat("LightAttenuation_LinearRadiusMult");
|
||||||
|
static float linearValue = fallback->getFallbackFloat("LightAttenuation_LinearValue");
|
||||||
|
bool isExterior = false; // FIXME
|
||||||
|
SceneUtil::addLight(mBaseNode, light, Mask_ParticleSystem, ~0u, isExterior, outQuadInLin, useQuadratic,
|
||||||
|
quadraticValue, quadraticRadiusMult, useLinear, linearRadiusMult, linearValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::Object::adjustTransform()
|
void CSVRender::Object::adjustTransform()
|
||||||
|
@ -131,6 +157,8 @@ CSVRender::Object::Object (CSMWorld::Data& data, osg::Group* parentNode,
|
||||||
: mData (data), mBaseNode(0), mSelected(false), mParentNode(parentNode), mResourceSystem(data.getResourceSystem().get()), mForceBaseToZero (forceBaseToZero)
|
: mData (data), mBaseNode(0), mSelected(false), mParentNode(parentNode), mResourceSystem(data.getResourceSystem().get()), mForceBaseToZero (forceBaseToZero)
|
||||||
{
|
{
|
||||||
mBaseNode = new osg::PositionAttitudeTransform;
|
mBaseNode = new osg::PositionAttitudeTransform;
|
||||||
|
mBaseNode->addCullCallback(new SceneUtil::LightListCallback);
|
||||||
|
|
||||||
mOutline = new osgFX::Scribe;
|
mOutline = new osgFX::Scribe;
|
||||||
mOutline->addChild(mBaseNode);
|
mOutline->addChild(mBaseNode);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <components/resource/scenemanager.hpp>
|
#include <components/resource/scenemanager.hpp>
|
||||||
#include <components/resource/resourcesystem.hpp>
|
#include <components/resource/resourcesystem.hpp>
|
||||||
|
#include <components/sceneutil/lightmanager.hpp>
|
||||||
|
|
||||||
#include "../widget/scenetoolmode.hpp"
|
#include "../widget/scenetoolmode.hpp"
|
||||||
|
|
||||||
|
@ -64,7 +65,9 @@ RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f)
|
||||||
mView->getCamera()->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) );
|
mView->getCamera()->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) );
|
||||||
mView->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0f, 10000.0f );
|
mView->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0f, 10000.0f );
|
||||||
|
|
||||||
mRootNode = new osg::Group;
|
SceneUtil::LightManager* lightMgr = new SceneUtil::LightManager;
|
||||||
|
lightMgr->setStartLight(1);
|
||||||
|
mRootNode = lightMgr;
|
||||||
|
|
||||||
mView->getCamera()->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
|
mView->getCamera()->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
|
||||||
mView->getCamera()->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
|
mView->getCamera()->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
|
||||||
|
|
Loading…
Reference in a new issue