132 lines
4.5 KiB
C++
132 lines
4.5 KiB
C++
/* -----------------------------------------------------------------------------
|
|
GSFramework
|
|
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
|
----------------------------------------------------------------------------- */
|
|
|
|
|
|
#include "motion/motion_channel.h"
|
|
#include "log/log.h"
|
|
|
|
using namespace GS::Core;
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
bool MotionChannel::FromMetaTag(GS::NML::Tag &tag)
|
|
{
|
|
if (tag.name != "Channel")
|
|
__ERR__(__LOG_E__ << "Could not parse motion channel, incorrect root tag (" << tag.name << ").\n", false)
|
|
|
|
// Parse root tags.
|
|
NMLTagForeach(pt, tag)
|
|
{
|
|
if (pt->name == "Curve")
|
|
Curve::FromMetaTag(*pt);
|
|
|
|
else if (pt->name == "Id")
|
|
{
|
|
String chn(pt->GetString());
|
|
|
|
if (chn == "PositionX") type = XPos;
|
|
else if (chn == "PositionY") type = YPos;
|
|
else if (chn == "PositionZ") type = ZPos;
|
|
else if (chn == "RotationX") type = XRot;
|
|
else if (chn == "RotationY") type = YRot;
|
|
else if (chn == "RotationZ") type = ZRot;
|
|
else if (chn == "ScaleX") type = XScl;
|
|
else if (chn == "ScaleY") type = YScl;
|
|
else if (chn == "ScaleZ") type = ZScl;
|
|
|
|
else if (chn == "PivotX") type = XPiv;
|
|
else if (chn == "PivotY") type = YPiv;
|
|
else if (chn == "PivotZ") type = ZPiv;
|
|
|
|
else if (chn == "DiffuseR") type = RDif;
|
|
else if (chn == "DiffuseG") type = GDif;
|
|
else if (chn == "DiffuseB") type = BDif;
|
|
else if (chn == "SpecularR") type = RSpc;
|
|
else if (chn == "SpecularG") type = GSpc;
|
|
else if (chn == "SpecularB") type = BSpc;
|
|
|
|
else if (chn == "DiffuseI") type = DiffuseIntensity;
|
|
else if (chn == "SpecularI") type = SpecularIntensity;
|
|
|
|
else if (chn == "ConeAngle") type = ConeAngle;
|
|
else if (chn == "EdgeAngle") type = EdgeAngle;
|
|
|
|
else if (chn == "Alpha") type = Alpha;
|
|
|
|
else if (chn == "Zoom") type = ZoomFactor;
|
|
|
|
else if (chn == "Range") type = Range;
|
|
|
|
else if (chn == "FogStart") type = FogStart;
|
|
else if (chn == "FogEnd") type = FogEnd;
|
|
else if (chn == "FogR") type = RFog;
|
|
else if (chn == "FogG") type = GFog;
|
|
else if (chn == "FogB") type = BFog;
|
|
|
|
else __LOG_W__ << "Unknown channel id '" << chn << "'.\n";
|
|
}
|
|
else __LOG_W__ << "Unknown tag '" << pt->name << "' in <Channel>.\n";
|
|
}
|
|
return true;
|
|
}
|
|
GS::NML::Tag *MotionChannel::AsMetaTag() const
|
|
{
|
|
NML::Tag *root = new NML::Tag("Channel");
|
|
if (!root)
|
|
__ERR__(__LOG_E__ << "Could not create channel root tag to serialize.\n", NULL)
|
|
|
|
// Serialize underlying curve.
|
|
root->AddChild(Curve::AsMetaTag());
|
|
|
|
// Channel type.
|
|
switch (type)
|
|
{
|
|
case XPos: root->AddChild("Id", "PositionX"); break;
|
|
case YPos: root->AddChild("Id", "PositionY"); break;
|
|
case ZPos: root->AddChild("Id", "PositionZ"); break;
|
|
case XRot: root->AddChild("Id", "RotationX"); break;
|
|
case YRot: root->AddChild("Id", "RotationY"); break;
|
|
case ZRot: root->AddChild("Id", "RotationZ"); break;
|
|
case XScl: root->AddChild("Id", "ScaleX"); break;
|
|
case YScl: root->AddChild("Id", "ScaleY"); break;
|
|
case ZScl: root->AddChild("Id", "ScaleZ"); break;
|
|
|
|
case XPiv: root->AddChild("Id", "PivotX"); break;
|
|
case YPiv: root->AddChild("Id", "PivotY"); break;
|
|
case ZPiv: root->AddChild("Id", "PivotZ"); break;
|
|
|
|
case RDif: root->AddChild("Id", "DiffuseR"); break;
|
|
case GDif: root->AddChild("Id", "DiffuseG"); break;
|
|
case BDif: root->AddChild("Id", "DiffuseB"); break;
|
|
case RSpc: root->AddChild("Id", "SpecularR"); break;
|
|
case GSpc: root->AddChild("Id", "SpecularG"); break;
|
|
case BSpc: root->AddChild("Id", "SpecularB"); break;
|
|
|
|
case DiffuseIntensity: root->AddChild("Id", "DiffuseI"); break;
|
|
case SpecularIntensity: root->AddChild("Id", "SpecularI"); break;
|
|
|
|
case ConeAngle: root->AddChild("Id", "ConeAngle"); break;
|
|
case EdgeAngle: root->AddChild("Id", "EdgeAngle"); break;
|
|
|
|
case Alpha: root->AddChild("Id", "Alpha"); break;
|
|
|
|
case ZoomFactor: root->AddChild("Id", "Zoom"); break;
|
|
|
|
case Range: root->AddChild("Id", "Range"); break;
|
|
|
|
case FogStart: root->AddChild("Id", "FogStart"); break;
|
|
case FogEnd: root->AddChild("Id", "FogEnd"); break;
|
|
case RFog: root->AddChild("Id", "FogR"); break;
|
|
case GFog: root->AddChild("Id", "FogG"); break;
|
|
case BFog: root->AddChild("Id", "FogB"); break;
|
|
|
|
default:
|
|
__LOG_W__ << "Unknown motion channel type (" << type << ").\n";
|
|
break;
|
|
}
|
|
return root;
|
|
}
|
|
//------------------------------------------------------------------------------
|