OpenFlight-plugin with extended attributes.

Added the addtional properties (terrain, roofline and footprint) alongside with the SMC/FID attributes. Also I added the newly added IRMaterial to the per-geode properties.
Added the Texture-EffectId and the mapping index as a user-value to the texture object.
Naming scheme is the same as for the per-vertex/geode attributes.
This commit is contained in:
Sebastian Messerschmidt 2016-06-09 10:15:38 +01:00 committed by Robert Osfield
parent 6db4ec5c08
commit 7ccf16b83d
2 changed files with 55 additions and 5 deletions

View File

@ -12,7 +12,7 @@
*/
//
// OpenFlight® loader for OpenSceneGraph
// OpenFlight loader for OpenSceneGraph
//
// Copyright (C) 2005-2007 Brede Johansen
//
@ -20,6 +20,7 @@
#include <osg/MatrixTransform>
#include <osg/Texture2D>
#include <osg/TexEnv>
#include <osg/ValueObject>
#include "Registry.h"
#include "Document.h"
@ -189,8 +190,8 @@ class Multitexture : public Record
{
int16 textureIndex = in.readInt16();
int16 effect = in.readInt16();
/*int16 mappingIndex =*/ in.readInt16();
/*uint16 data =*/ in.readUInt16();
int16 mappingIndex = in.readInt16();
uint16 data = in.readUInt16();
osg::ref_ptr<osg::StateSet> texturePoolStateset = document.getOrCreateTexturePool()->get(textureIndex);
if (stateset.valid() && texturePoolStateset.valid())
@ -198,8 +199,15 @@ class Multitexture : public Record
// Apply texture from texture pool.
osg::Texture* texture = dynamic_cast<osg::Texture*>(texturePoolStateset->getTextureAttribute(0,osg::StateAttribute::TEXTURE));
if (texture)
{
stateset->setTextureAttributeAndModes(layer,texture,osg::StateAttribute::ON);
if (document.getPreserveNonOsgAttrsAsUserData())
{
texture->setUserValue("<UA::TexEffect>", effect);
texture->setUserValue("<UA::TexMappingIdx>", mappingIndex);
texture->setUserValue("<UA::TexData>", data);
}
}
// Apply texture environment
switch (effect)
{

View File

@ -475,6 +475,24 @@ protected:
_geometry->setUserValue("<UA:FID>", feature);
}
// terrain
if (document.getPreserveNonOsgAttrsAsUserData() && 0 != isTerrain())
{
_geometry->setUserValue("<UA:Terrain>", true);
}
// roofline
if (document.getPreserveNonOsgAttrsAsUserData() && 0 != isRoofline())
{
_geometry->setUserValue("<UA:Roofline>", true);
}
// footprint
if (document.getPreserveNonOsgAttrsAsUserData() && 0 != isFootprint())
{
_geometry->setUserValue("<UA:Footprint>", true);
}
// Shaders
if (shaderIndex >= 0)
{
@ -957,7 +975,7 @@ protected:
int materialIndex = in.readInt16(-1);
int16 surface = in.readInt16();
int16 feature = in.readInt16();
/*int32 IRMaterial =*/ in.readInt32(-1);
int32 IRMaterial = in.readInt32(-1);
_transparency = in.readUInt16(0);
// version > 13
/*uint8 influenceLOD =*/ in.readUInt8();
@ -1048,6 +1066,12 @@ protected:
_geode->setUserValue("<UA:IRC>", IRColor);
}
// IR Material ID (IRM)
if (document.getPreserveNonOsgAttrsAsUserData() && 0 != IRMaterial)
{
_geode->setUserValue("<UA:IRM>", IRMaterial);
}
// surface (SMC)
if (document.getPreserveNonOsgAttrsAsUserData() && 0 != surface)
{
@ -1060,6 +1084,24 @@ protected:
_geode->setUserValue("<UA:FID>", feature);
}
// terrain
if (document.getPreserveNonOsgAttrsAsUserData() && 0 != isTerrain())
{
_geode->setUserValue("<UA:Terrain>", true);
}
// roofline
if (document.getPreserveNonOsgAttrsAsUserData() && 0 != isRoofline())
{
_geode->setUserValue("<UA:Roofline>", true);
}
// footprint
if (document.getPreserveNonOsgAttrsAsUserData() && 0 != isFootprint())
{
_geode->setUserValue("<UA:Footprint>", true);
}
// Shaders
if (shaderIndex >= 0)
{