first commit
This commit is contained in:
50
include/framework/math/vector_nml.h
Normal file
50
include/framework/math/vector_nml.h
Normal file
@ -0,0 +1,50 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
GSFramework
|
||||
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#ifndef __NVECTORNML__
|
||||
#define __NVECTORNML__
|
||||
|
||||
|
||||
#include "metafile/nml.h"
|
||||
#include "math/vector.h"
|
||||
|
||||
|
||||
namespace GS {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
template <class T> NML::Tag *tVectorAsMetaTag(const tVector2 <T> &v, const char *id)
|
||||
{
|
||||
NML::Tag *root = id ? new NML::Tag(id) : new NML::Tag("Vector2");
|
||||
|
||||
if (root)
|
||||
{
|
||||
root->AddChild("X", v.x);
|
||||
root->AddChild("Y", v.y);
|
||||
}
|
||||
return root;
|
||||
}
|
||||
template <class T> bool tVectorFromMetaTag(tVector2 <T> &v, NML::Tag &tag)
|
||||
{
|
||||
NML::Tag *t;
|
||||
List <NML::Tag *> ::Iterator i(tag.GetTags().GetRoot());
|
||||
|
||||
if ((t = i.ObjectPtr()) == NULL)
|
||||
return false;
|
||||
v.x = t->GetReal();
|
||||
++i;
|
||||
|
||||
if ((t = i.ObjectPtr()) == NULL)
|
||||
return false;
|
||||
v.y = t->GetReal();
|
||||
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
} // GS
|
||||
|
||||
|
||||
#endif // __NVECTORNML__
|
||||
Reference in New Issue
Block a user