mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:23:52 +00:00
Merge pull request #1688
This commit is contained in:
commit
bdf1070852
1 changed files with 17 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include "characterpreview.hpp"
|
#include "characterpreview.hpp"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <osg/Material>
|
#include <osg/Material>
|
||||||
|
@ -13,6 +14,7 @@
|
||||||
#include <osgUtil/IntersectionVisitor>
|
#include <osgUtil/IntersectionVisitor>
|
||||||
#include <osgUtil/LineSegmentIntersector>
|
#include <osgUtil/LineSegmentIntersector>
|
||||||
|
|
||||||
|
#include <components/fallback/fallback.hpp>
|
||||||
#include <components/sceneutil/lightmanager.hpp>
|
#include <components/sceneutil/lightmanager.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
@ -161,11 +163,22 @@ namespace MWRender
|
||||||
lightmodel->setAmbientIntensity(osg::Vec4(0.25, 0.25, 0.25, 1.0));
|
lightmodel->setAmbientIntensity(osg::Vec4(0.25, 0.25, 0.25, 1.0));
|
||||||
stateset->setAttributeAndModes(lightmodel, osg::StateAttribute::ON);
|
stateset->setAttributeAndModes(lightmodel, osg::StateAttribute::ON);
|
||||||
|
|
||||||
/// \todo Read the fallback values from INIImporter (Inventory:Directional*) ?
|
|
||||||
osg::ref_ptr<osg::Light> light = new osg::Light;
|
osg::ref_ptr<osg::Light> light = new osg::Light;
|
||||||
light->setPosition(osg::Vec4(-0.3,0.3,0.7, 0.0));
|
const Fallback::Map* fallback = MWBase::Environment::get().getWorld()->getFallback();
|
||||||
light->setDiffuse(osg::Vec4(1,1,1,1));
|
float diffuseR = fallback->getFallbackFloat("Inventory_DirectionalDiffuseR");
|
||||||
light->setAmbient(osg::Vec4(0,0,0,1));
|
float diffuseG = fallback->getFallbackFloat("Inventory_DirectionalDiffuseG");
|
||||||
|
float diffuseB = fallback->getFallbackFloat("Inventory_DirectionalDiffuseB");
|
||||||
|
float ambientR = fallback->getFallbackFloat("Inventory_DirectionalAmbientR");
|
||||||
|
float ambientG = fallback->getFallbackFloat("Inventory_DirectionalAmbientG");
|
||||||
|
float ambientB = fallback->getFallbackFloat("Inventory_DirectionalAmbientB");
|
||||||
|
float azimuth = osg::DegreesToRadians(180.f - fallback->getFallbackFloat("Inventory_DirectionalRotationX"));
|
||||||
|
float altitude = osg::DegreesToRadians(fallback->getFallbackFloat("Inventory_DirectionalRotationY"));
|
||||||
|
float positionX = std::cos(azimuth) * std::sin(altitude);
|
||||||
|
float positionY = std::sin(azimuth) * std::sin(altitude);
|
||||||
|
float positionZ = std::cos(altitude);
|
||||||
|
light->setPosition(osg::Vec4(positionX,positionY,positionZ, 0.0));
|
||||||
|
light->setDiffuse(osg::Vec4(diffuseR,diffuseG,diffuseB,1));
|
||||||
|
light->setAmbient(osg::Vec4(ambientR,ambientG,ambientB,1));
|
||||||
light->setSpecular(osg::Vec4(0,0,0,0));
|
light->setSpecular(osg::Vec4(0,0,0,0));
|
||||||
light->setLightNum(0);
|
light->setLightNum(0);
|
||||||
light->setConstantAttenuation(1.f);
|
light->setConstantAttenuation(1.f);
|
||||||
|
|
Loading…
Reference in a new issue