Did a bit more Collada physics importing work.
Also did a quick workaround to allow different camera UP. This demo stuff really needs to be cleaned up now!
This commit is contained in:
@@ -24,7 +24,7 @@ using namespace FUDaeWriter;
|
||||
FCDPhysicsSceneNode::FCDPhysicsSceneNode(FCDocument* document) : FCDEntity(document, "PhysicsSceneNode")
|
||||
{
|
||||
//FIXME: no default values are specified in the 1.4 spec!
|
||||
gravity.x = 0.f; gravity.y = -9.8f; gravity.z = 0.f;
|
||||
gravity.x = 0.f; gravity.y = 0.f; gravity.z = -9.8f;
|
||||
timestep = 1.f;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,13 +52,13 @@ FUStatus FCDTTranslation::LoadFromXML(xmlNode* node)
|
||||
}
|
||||
|
||||
// Write the <translate> node to the COLLADA xml document
|
||||
xmlNode* FCDTTranslation::WriteToXML(xmlNode* parentNode) const
|
||||
{
|
||||
string content = FUStringConversion::ToString(translation);
|
||||
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_TRANSLATE_ELEMENT, content);
|
||||
GetDocument()->WriteAnimatedValueToXML(&translation.x, transformNode, "translation");
|
||||
return transformNode;
|
||||
}
|
||||
xmlNode* FCDTTranslation::WriteToXML(xmlNode* parentNode) const
|
||||
{
|
||||
string content = FUStringConversion::ToString(translation);
|
||||
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_TRANSLATE_ELEMENT, content);
|
||||
GetDocument()->WriteAnimatedValueToXML(&translation.x, transformNode, "translation");
|
||||
return transformNode;
|
||||
}
|
||||
|
||||
FMMatrix44 FCDTTranslation::ToMatrix() const
|
||||
{
|
||||
@@ -111,14 +111,14 @@ FUStatus FCDTRotation::LoadFromXML(xmlNode* node)
|
||||
}
|
||||
|
||||
// Write the <rotate> node to the COLLADA xml document
|
||||
xmlNode* FCDTRotation::WriteToXML(xmlNode* parent) const
|
||||
{
|
||||
globalSBuilder.clear();
|
||||
FUStringConversion::ToString(globalSBuilder, axis); globalSBuilder += ' '; globalSBuilder += angle;
|
||||
xmlNode* transformNode = FUDaeWriter::AddChild(parent, DAE_ROTATE_ELEMENT, globalSBuilder);
|
||||
GetDocument()->WriteAnimatedValueToXML(&axis.x, transformNode, "rotation");
|
||||
return transformNode;
|
||||
}
|
||||
xmlNode* FCDTRotation::WriteToXML(xmlNode* parent) const
|
||||
{
|
||||
globalSBuilder.clear();
|
||||
FUStringConversion::ToString(globalSBuilder, axis); globalSBuilder += ' '; globalSBuilder += angle;
|
||||
xmlNode* transformNode = FUDaeWriter::AddChild(parent, DAE_ROTATE_ELEMENT, globalSBuilder);
|
||||
GetDocument()->WriteAnimatedValueToXML(&axis.x, transformNode, "rotation");
|
||||
return transformNode;
|
||||
}
|
||||
|
||||
FMMatrix44 FCDTRotation::ToMatrix() const
|
||||
{
|
||||
@@ -174,12 +174,12 @@ FUStatus FCDTScale::LoadFromXML(xmlNode* node)
|
||||
}
|
||||
|
||||
// Write the <scale> node to the COLLADA xml document
|
||||
xmlNode* FCDTScale::WriteToXML(xmlNode* parentNode) const
|
||||
{
|
||||
string content = FUStringConversion::ToString(scale);
|
||||
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_SCALE_ELEMENT, content);
|
||||
GetDocument()->WriteAnimatedValueToXML(&scale.x, transformNode, "scale");
|
||||
return transformNode;
|
||||
xmlNode* FCDTScale::WriteToXML(xmlNode* parentNode) const
|
||||
{
|
||||
string content = FUStringConversion::ToString(scale);
|
||||
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_SCALE_ELEMENT, content);
|
||||
GetDocument()->WriteAnimatedValueToXML(&scale.x, transformNode, "scale");
|
||||
return transformNode;
|
||||
}
|
||||
|
||||
FMMatrix44 FCDTScale::ToMatrix() const
|
||||
@@ -225,12 +225,12 @@ FUStatus FCDTMatrix::LoadFromXML(xmlNode* node)
|
||||
}
|
||||
|
||||
// Write the <matrix> node to the COLLADA xml document
|
||||
xmlNode* FCDTMatrix::WriteToXML(xmlNode* parentNode) const
|
||||
{
|
||||
string content = FUStringConversion::ToString(transform);
|
||||
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_MATRIX_ELEMENT, content);
|
||||
GetDocument()->WriteAnimatedValueToXML(&transform[0][0], transformNode, "transform");
|
||||
return transformNode;
|
||||
xmlNode* FCDTMatrix::WriteToXML(xmlNode* parentNode) const
|
||||
{
|
||||
string content = FUStringConversion::ToString(transform);
|
||||
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_MATRIX_ELEMENT, content);
|
||||
GetDocument()->WriteAnimatedValueToXML(&transform[0][0], transformNode, "transform");
|
||||
return transformNode;
|
||||
}
|
||||
|
||||
FCDAnimated* FCDTMatrix::GetAnimated()
|
||||
@@ -274,14 +274,14 @@ FUStatus FCDTLookAt::LoadFromXML(xmlNode* lookAtNode)
|
||||
}
|
||||
|
||||
// Write the <lookat> node to the COLLADA xml document
|
||||
xmlNode* FCDTLookAt::WriteToXML(xmlNode* parentNode) const
|
||||
{
|
||||
globalSBuilder.clear();
|
||||
FUStringConversion::ToString(globalSBuilder, position); globalSBuilder += ' ';
|
||||
FUStringConversion::ToString(globalSBuilder, target); globalSBuilder += ' ';
|
||||
FUStringConversion::ToString(globalSBuilder, up);
|
||||
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_LOOKAT_ELEMENT, globalSBuilder);
|
||||
return transformNode;
|
||||
xmlNode* FCDTLookAt::WriteToXML(xmlNode* parentNode) const
|
||||
{
|
||||
globalSBuilder.clear();
|
||||
FUStringConversion::ToString(globalSBuilder, position); globalSBuilder += ' ';
|
||||
FUStringConversion::ToString(globalSBuilder, target); globalSBuilder += ' ';
|
||||
FUStringConversion::ToString(globalSBuilder, up);
|
||||
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_LOOKAT_ELEMENT, globalSBuilder);
|
||||
return transformNode;
|
||||
}
|
||||
|
||||
FMMatrix44 FCDTLookAt::ToMatrix() const
|
||||
@@ -346,15 +346,15 @@ FUStatus FCDTSkew::LoadFromXML(xmlNode* skewNode)
|
||||
}
|
||||
|
||||
// Write the <lookat> node to the COLLADA xml document
|
||||
xmlNode* FCDTSkew::WriteToXML(xmlNode* parentNode) const
|
||||
{
|
||||
globalSBuilder.clear();
|
||||
globalSBuilder.set(angle); globalSBuilder += ' ';
|
||||
FUStringConversion::ToString(globalSBuilder, rotateAxis); globalSBuilder += ' ';
|
||||
FUStringConversion::ToString(globalSBuilder, aroundAxis);
|
||||
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_SKEW_ELEMENT, globalSBuilder);
|
||||
GetDocument()->WriteAnimatedValueToXML(&angle, transformNode, "skew");
|
||||
return transformNode;
|
||||
xmlNode* FCDTSkew::WriteToXML(xmlNode* parentNode) const
|
||||
{
|
||||
globalSBuilder.clear();
|
||||
globalSBuilder.set(angle); globalSBuilder += ' ';
|
||||
FUStringConversion::ToString(globalSBuilder, rotateAxis); globalSBuilder += ' ';
|
||||
FUStringConversion::ToString(globalSBuilder, aroundAxis);
|
||||
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_SKEW_ELEMENT, globalSBuilder);
|
||||
GetDocument()->WriteAnimatedValueToXML(&angle, transformNode, "skew");
|
||||
return transformNode;
|
||||
}
|
||||
|
||||
FMMatrix44 FCDTSkew::ToMatrix() const
|
||||
@@ -389,30 +389,30 @@ bool FCDTSkew::IsAnimated() const
|
||||
return GetDocument()->IsValueAnimated(&angle);
|
||||
}
|
||||
|
||||
// Creates a new COLLADA transform, given a transform type.
|
||||
FCDTransform* FCDTFactory::CreateTransform(FCDocument* document, FCDSceneNode* parent, FCDTransform::Type type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case FCDTransform::TRANSLATION: return new FCDTTranslation(document, parent);
|
||||
case FCDTransform::ROTATION: return new FCDTRotation(document, parent);
|
||||
case FCDTransform::SCALE: return new FCDTScale(document, parent);
|
||||
case FCDTransform::SKEW: return new FCDTSkew(document, parent);
|
||||
case FCDTransform::MATRIX: return new FCDTMatrix(document, parent);
|
||||
case FCDTransform::LOOKAT: return new FCDTLookAt(document, parent);
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Imports a COLLADA transform, given an XML tree node.
|
||||
FCDTransform* FCDTFactory::CreateTransform(FCDocument* document, FCDSceneNode* parent, xmlNode* node)
|
||||
{
|
||||
FCDTransform* transform = NULL;
|
||||
if (IsEquivalent(node->name, DAE_ROTATE_ELEMENT)) transform = new FCDTRotation(document, parent);
|
||||
else if (IsEquivalent(node->name, DAE_TRANSLATE_ELEMENT)) transform = new FCDTTranslation(document, parent);
|
||||
else if (IsEquivalent(node->name, DAE_SCALE_ELEMENT)) transform = new FCDTScale(document, parent);
|
||||
else if (IsEquivalent(node->name, DAE_SKEW_ELEMENT)) transform = new FCDTSkew(document, parent);
|
||||
else if (IsEquivalent(node->name, DAE_MATRIX_ELEMENT)) transform = new FCDTMatrix(document, parent);
|
||||
else if (IsEquivalent(node->name, DAE_LOOKAT_ELEMENT)) transform = new FCDTLookAt(document, parent);
|
||||
return transform;
|
||||
}
|
||||
// Creates a new COLLADA transform, given a transform type.
|
||||
FCDTransform* FCDTFactory::CreateTransform(FCDocument* document, FCDSceneNode* parent, FCDTransform::Type type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case FCDTransform::TRANSLATION: return new FCDTTranslation(document, parent);
|
||||
case FCDTransform::ROTATION: return new FCDTRotation(document, parent);
|
||||
case FCDTransform::SCALE: return new FCDTScale(document, parent);
|
||||
case FCDTransform::SKEW: return new FCDTSkew(document, parent);
|
||||
case FCDTransform::MATRIX: return new FCDTMatrix(document, parent);
|
||||
case FCDTransform::LOOKAT: return new FCDTLookAt(document, parent);
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Imports a COLLADA transform, given an XML tree node.
|
||||
FCDTransform* FCDTFactory::CreateTransform(FCDocument* document, FCDSceneNode* parent, xmlNode* node)
|
||||
{
|
||||
FCDTransform* transform = NULL;
|
||||
if (IsEquivalent(node->name, DAE_ROTATE_ELEMENT)) transform = new FCDTRotation(document, parent);
|
||||
else if (IsEquivalent(node->name, DAE_TRANSLATE_ELEMENT)) transform = new FCDTTranslation(document, parent);
|
||||
else if (IsEquivalent(node->name, DAE_SCALE_ELEMENT)) transform = new FCDTScale(document, parent);
|
||||
else if (IsEquivalent(node->name, DAE_SKEW_ELEMENT)) transform = new FCDTSkew(document, parent);
|
||||
else if (IsEquivalent(node->name, DAE_MATRIX_ELEMENT)) transform = new FCDTMatrix(document, parent);
|
||||
else if (IsEquivalent(node->name, DAE_LOOKAT_ELEMENT)) transform = new FCDTLookAt(document, parent);
|
||||
return transform;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,171 +8,174 @@
|
||||
Copyright (C) 2005-2006 Autodesk Media Entertainment
|
||||
MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "FUtils/FUXmlParser.h"
|
||||
|
||||
#define xmlT(a) (const xmlChar*) (a)
|
||||
|
||||
namespace FUXmlParser
|
||||
{
|
||||
// Returns the first child node of a given type
|
||||
xmlNode* FindChildByType(xmlNode* parent, const char* type)
|
||||
{
|
||||
if (parent != NULL)
|
||||
{
|
||||
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
||||
{
|
||||
if (child->type == XML_ELEMENT_NODE)
|
||||
{
|
||||
if (IsEquivalent(child->name, type)) return child;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// return the first child node of a given name
|
||||
xmlNode* FindChildByName(xmlNode* parent, const char* name)
|
||||
{
|
||||
if (parent != NULL)
|
||||
{
|
||||
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
||||
{
|
||||
if (child->type == XML_ELEMENT_NODE)
|
||||
{
|
||||
string str_name = ReadNodeProperty(child, "name");
|
||||
if (str_name == name) return child;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// return the first child node of a given property value
|
||||
xmlNode* FindChildByProperty(xmlNode* parent, const char* prop, const char* val )
|
||||
{
|
||||
if (parent != NULL)
|
||||
{
|
||||
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
||||
{
|
||||
string str_pop = ReadNodeProperty(child, prop);
|
||||
if (str_pop == val) return child;
|
||||
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// return the first node in list of a given property
|
||||
xmlNode* FindNodeInListByProperty(xmlNodeList list, const char* property, const char* prop)
|
||||
{
|
||||
for (xmlNodeList::iterator it = list.begin(); it != list.end(); ++it)
|
||||
{
|
||||
xmlNode* element = *it;
|
||||
string str_prop = ReadNodeProperty(element, property);
|
||||
if (str_prop == prop) return element;
|
||||
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Retrieves all the child nodes of a given type
|
||||
void FindChildrenByType(xmlNode* parent, const char* type, xmlNodeList& nodes)
|
||||
{
|
||||
if (parent != NULL)
|
||||
{
|
||||
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
||||
{
|
||||
if (child->type == XML_ELEMENT_NODE)
|
||||
{
|
||||
if (IsEquivalent(child->name, type)) nodes.push_back(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Returns whether the given node has the given property
|
||||
bool HasNodeProperty(xmlNode* node, const char* property)
|
||||
{
|
||||
xmlAttr* attribute = xmlHasProp(node, xmlT(property));
|
||||
return attribute != NULL;
|
||||
}
|
||||
|
||||
// Returns the string value of a node's property
|
||||
string ReadNodeProperty(xmlNode* node, const char* property)
|
||||
{
|
||||
string ret;
|
||||
if (node != NULL && property != NULL)
|
||||
{
|
||||
xmlChar* data = xmlGetProp(node, xmlT(property));
|
||||
if (data != NULL) ret = (const char*) data;
|
||||
xmlFree(data);
|
||||
}
|
||||
|
||||
// Process the string for special characters
|
||||
XmlToString(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Returns the CRC value of a node's property
|
||||
FUCrc32::crc32 ReadNodePropertyCRC(xmlNode* node, const char* property)
|
||||
{
|
||||
FUCrc32::crc32 ret = 0;
|
||||
if (node != NULL && property != NULL)
|
||||
{
|
||||
xmlChar* data = xmlGetProp(node, xmlT(property));
|
||||
if (data != NULL) ret = FUCrc32::CRC32((const char*) data);
|
||||
xmlFree(data);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Returns the text content directly attached to a node
|
||||
const char* ReadNodeContentDirect(xmlNode* node)
|
||||
{
|
||||
if (node == NULL || node->children == NULL
|
||||
|| node->children->type != XML_TEXT_NODE || node->children->content == NULL) return "";
|
||||
return (const char*) node->children->content;
|
||||
}
|
||||
|
||||
// Returns the inner text content of a node
|
||||
string ReadNodeContentFull(xmlNode* node)
|
||||
{
|
||||
string ret;
|
||||
if (node != NULL)
|
||||
{
|
||||
xmlChar* content = xmlNodeGetContent(node);
|
||||
ret = (const char*) content;
|
||||
xmlFree(content);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Convert a XML string to a text string: handles the '%' character
|
||||
void XmlToString(string& s)
|
||||
{
|
||||
if (s.find('%') == string::npos) return;
|
||||
|
||||
// Replace all the '%XX' characters by the equivalent hex value
|
||||
const char* original = s.c_str();
|
||||
uint32 length = (uint32) s.length();
|
||||
char* copy = new char[length],* p = copy;
|
||||
for (uint32 i = 0; i < length; ++i, ++p)
|
||||
{
|
||||
char c = original[i];
|
||||
if (c != '%' || i >= length - 2) *p = c;
|
||||
else
|
||||
{
|
||||
char* dummy;
|
||||
p[0] = original[i + 1]; p[1] = original[i + 2]; p[2] = 0;
|
||||
uint32 v = strtoul(p, &dummy, 16);
|
||||
*p = (char) v;
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
*p = 0;
|
||||
s = copy;
|
||||
}
|
||||
};
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "FUtils/FUXmlParser.h"
|
||||
|
||||
#define xmlT(a) (const xmlChar*) (a)
|
||||
|
||||
namespace FUXmlParser
|
||||
{
|
||||
// Returns the first child node of a given type
|
||||
xmlNode* FindChildByType(xmlNode* parent, const char* type)
|
||||
{
|
||||
if (parent != NULL)
|
||||
{
|
||||
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
||||
{
|
||||
if (child->type == XML_ELEMENT_NODE)
|
||||
{
|
||||
if (IsEquivalent(child->name, type)) return child;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// return the first child node of a given name
|
||||
xmlNode* FindChildByName(xmlNode* parent, const char* name)
|
||||
{
|
||||
if (parent != NULL)
|
||||
{
|
||||
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
||||
{
|
||||
if (child->type == XML_ELEMENT_NODE)
|
||||
{
|
||||
string str_name = ReadNodeProperty(child, "name");
|
||||
if (str_name == name) return child;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// return the first child node of a given property value
|
||||
xmlNode* FindChildByProperty(xmlNode* parent, const char* prop, const char* val )
|
||||
{
|
||||
if (parent != NULL)
|
||||
{
|
||||
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
||||
{
|
||||
string str_pop = ReadNodeProperty(child, prop);
|
||||
if (str_pop == val) return child;
|
||||
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// return the first node in list of a given property
|
||||
xmlNode* FindNodeInListByProperty(xmlNodeList list, const char* property, const char* prop)
|
||||
{
|
||||
for (xmlNodeList::iterator it = list.begin(); it != list.end(); ++it)
|
||||
{
|
||||
xmlNode* element = *it;
|
||||
string str_prop = ReadNodeProperty(element, property);
|
||||
if (str_prop == prop) return element;
|
||||
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Retrieves all the child nodes of a given type
|
||||
void FindChildrenByType(xmlNode* parent, const char* type, xmlNodeList& nodes)
|
||||
{
|
||||
if (parent != NULL)
|
||||
{
|
||||
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
||||
{
|
||||
if (child->type == XML_ELEMENT_NODE)
|
||||
{
|
||||
if (IsEquivalent(child->name, type)) nodes.push_back(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Returns whether the given node has the given property
|
||||
bool HasNodeProperty(xmlNode* node, const char* property)
|
||||
{
|
||||
xmlAttr* attribute = xmlHasProp(node, xmlT(property));
|
||||
return attribute != NULL;
|
||||
}
|
||||
|
||||
// Returns the string value of a node's property
|
||||
string ReadNodeProperty(xmlNode* node, const char* property)
|
||||
{
|
||||
string ret="";
|
||||
if (node != NULL && property != NULL)
|
||||
{
|
||||
xmlChar* data = xmlGetProp(node, xmlT(property));
|
||||
if (data != NULL)
|
||||
{
|
||||
ret = (const char*) data;
|
||||
}
|
||||
xmlFree(data);
|
||||
}
|
||||
|
||||
// Process the string for special characters
|
||||
XmlToString(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Returns the CRC value of a node's property
|
||||
FUCrc32::crc32 ReadNodePropertyCRC(xmlNode* node, const char* property)
|
||||
{
|
||||
FUCrc32::crc32 ret = 0;
|
||||
if (node != NULL && property != NULL)
|
||||
{
|
||||
xmlChar* data = xmlGetProp(node, xmlT(property));
|
||||
if (data != NULL) ret = FUCrc32::CRC32((const char*) data);
|
||||
xmlFree(data);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Returns the text content directly attached to a node
|
||||
const char* ReadNodeContentDirect(xmlNode* node)
|
||||
{
|
||||
if (node == NULL || node->children == NULL
|
||||
|| node->children->type != XML_TEXT_NODE || node->children->content == NULL) return "";
|
||||
return (const char*) node->children->content;
|
||||
}
|
||||
|
||||
// Returns the inner text content of a node
|
||||
string ReadNodeContentFull(xmlNode* node)
|
||||
{
|
||||
string ret;
|
||||
if (node != NULL)
|
||||
{
|
||||
xmlChar* content = xmlNodeGetContent(node);
|
||||
ret = (const char*) content;
|
||||
xmlFree(content);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Convert a XML string to a text string: handles the '%' character
|
||||
void XmlToString(string& s)
|
||||
{
|
||||
if (s.find('%') == string::npos) return;
|
||||
|
||||
// Replace all the '%XX' characters by the equivalent hex value
|
||||
const char* original = s.c_str();
|
||||
uint32 length = (uint32) s.length();
|
||||
char* copy = new char[length],* p = copy;
|
||||
for (uint32 i = 0; i < length; ++i, ++p)
|
||||
{
|
||||
char c = original[i];
|
||||
if (c != '%' || i >= length - 2) *p = c;
|
||||
else
|
||||
{
|
||||
char* dummy;
|
||||
p[0] = original[i + 1]; p[1] = original[i + 2]; p[2] = 0;
|
||||
uint32 v = strtoul(p, &dummy, 16);
|
||||
*p = (char) v;
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
*p = 0;
|
||||
s = copy;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -535,6 +535,7 @@ PHY_IPhysicsController* CcdPhysicsController::GetReplica()
|
||||
DefaultMotionState::DefaultMotionState()
|
||||
{
|
||||
m_worldTransform.setIdentity();
|
||||
m_localScaling.setValue(1.f,1.f,1.f);
|
||||
}
|
||||
|
||||
|
||||
@@ -552,9 +553,9 @@ void DefaultMotionState::getWorldPosition(float& posX,float& posY,float& posZ)
|
||||
|
||||
void DefaultMotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
|
||||
{
|
||||
scaleX = 1.;
|
||||
scaleY = 1.;
|
||||
scaleZ = 1.;
|
||||
scaleX = m_localScaling.getX();
|
||||
scaleY = m_localScaling.getY();
|
||||
scaleZ = m_localScaling.getZ();
|
||||
}
|
||||
|
||||
void DefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
|
||||
|
||||
@@ -208,6 +208,7 @@ class DefaultMotionState : public PHY_IMotionState
|
||||
virtual void calculateWorldTransformations();
|
||||
|
||||
SimdTransform m_worldTransform;
|
||||
SimdVector3 m_localScaling;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user