Skip to content

Commit

Permalink
changed: handle <shininess> independent of <specular> : some comments
Browse files Browse the repository at this point in the history
git-svn-id: https://opensg.vrsource.org/svn/trunk@2247 4683daeb-ad0f-0410-a623-93161e962ae5
  • Loading branch information
cneumann committed Dec 29, 2009
1 parent 3a08fd9 commit 5167810
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
49 changes: 47 additions & 2 deletions Source/System/FileIO/Collada/OSGColladaEffect.cpp
Expand Up @@ -45,6 +45,7 @@
#ifdef OSG_WITH_COLLADA

#include "OSGColladaLog.h"
#include "OSGColladaGlobal.h"
#include "OSGColladaImage.h"
#include "OSGColladaSampler2D.h"
#include "OSGColladaInstanceEffect.h"
Expand Down Expand Up @@ -192,12 +193,13 @@ ColladaEffect::createInstance(ColladaInstanceElement *colInstElem)
}
}

// XXX TODO: do we always need to create a new material?
editInstStore().push_back(retVal);

return retVal;
}

/*! Return parameter of the effect (\c <newparam> tags) with the given \a name.
*/
daeElement *
ColladaEffect::findDOMParam(const std::string &name) const
{
Expand All @@ -216,6 +218,9 @@ ColladaEffect::findDOMParam(const std::string &name) const
}
}

/*! Return the loader element for the parameter of the effect (\c <newparam>
tags) with the given \a name.
*/
ColladaElement *
ColladaEffect::findParam(const std::string &name) const
{
Expand Down Expand Up @@ -243,6 +248,10 @@ ColladaEffect::~ColladaEffect(void)
{
}

/*! Fills internal data structures for \c <profile_COMMON>.
This mainly collects relevant parameters so they can be looked up
efficiently when creating an instance of this effect.
*/
void
ColladaEffect::readProfileCommon(domProfile_COMMON *prof)
{
Expand Down Expand Up @@ -321,6 +330,9 @@ ColladaEffect::readProfileCG(domProfile_CG *prof)
SWARNING << "ColladaEffect::readProfileCG: NIY." << std::endl;
}

/*! Create an OpenSG material that matches this \c <profile_COMMON> material
(to the extent possible).
*/
MaterialTransitPtr
ColladaEffect::createInstanceProfileCommon(
domProfile_COMMON *prof, domEffect *effect,
Expand Down Expand Up @@ -394,6 +406,9 @@ ColladaEffect::createInstanceProfileCommon(
ChunkMaterialUnrecPtr mat = ChunkMaterial::create();
MaterialChunkUnrecPtr matChunk = MaterialChunk::create();

getGlobal()->getStatCollector()->getElem(
ColladaGlobal::statNMaterialCreated)->inc();

if(emission != NULL)
{
domCommon_color_or_texture_type::domColorRef color;
Expand Down Expand Up @@ -587,6 +602,25 @@ ColladaEffect::createInstanceProfileCommon(
}
}

if(shininess != NULL)
{
domCommon_float_or_param_type::domFloatRef value;
domCommon_float_or_param_type::domParamRef param;

fillFloatParam(shininess, value, param);

if(value != NULL)
{
matChunk->setShininess(value->getValue());
}
else if(param != NULL)
{
SWARNING << "ColladaEffect::createInstanceProfileCommon: "
<< "<shininess>/<param> not supported."
<< std::endl;
}
}

mat->addChunk(matChunk);

return MaterialTransitPtr(mat);
Expand Down Expand Up @@ -645,7 +679,18 @@ ColladaEffect::fillColorParamTex(
}
}


void
ColladaEffect::fillFloatParam(
domCommon_float_or_param_type *floatParam,
domCommon_float_or_param_type::domFloatRef &floatOut,
domCommon_float_or_param_type::domParamRef &paramOut )
{
if(floatParam != NULL)
{
floatOut = floatParam->getFloat();
paramOut = floatParam->getParam();
}
}

OSG_END_NAMESPACE

Expand Down
7 changes: 6 additions & 1 deletion Source/System/FileIO/Collada/OSGColladaEffect.h
Expand Up @@ -53,6 +53,7 @@
#include <dom/domFx_sampler2D_common.h>
#include <dom/domFx_surface_common.h>
#include <dom/domCommon_color_or_texture_type.h>
#include <dom/domCommon_float_or_param_type.h>

// forward decl
class domProfile_COMMON;
Expand Down Expand Up @@ -163,7 +164,11 @@ class OSG_FILEIO_DLLMAPPING ColladaEffect : public ColladaInstantiableElement
domCommon_color_or_texture_type *colTex,
domCommon_color_or_texture_type::domColorRef &colOut,
domCommon_color_or_texture_type::domParamRef &paramOut,
domCommon_color_or_texture_type::domTextureRef &texOut );
domCommon_color_or_texture_type::domTextureRef &texOut );
void fillFloatParam (
domCommon_float_or_param_type *floatParam,
domCommon_float_or_param_type::domFloatRef &floatOut,
domCommon_float_or_param_type::domParamRef &paramOut );

static ColladaElementRegistrationHelper _regHelper;

Expand Down

0 comments on commit 5167810

Please sign in to comment.