Changeset View
Changeset View
Standalone View
Standalone View
source/collada/CommonConvert.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | : xmlErrors(xmlErrors_) | ||||
FUError::AddErrorCallback(FUError::DEBUG_LEVEL, this, &FColladaErrorHandler::OnError); | FUError::AddErrorCallback(FUError::DEBUG_LEVEL, this, &FColladaErrorHandler::OnError); | ||||
FUError::AddErrorCallback(FUError::WARNING_LEVEL, this, &FColladaErrorHandler::OnError); | FUError::AddErrorCallback(FUError::WARNING_LEVEL, this, &FColladaErrorHandler::OnError); | ||||
FUError::AddErrorCallback(FUError::ERROR_LEVEL, this, &FColladaErrorHandler::OnError); | FUError::AddErrorCallback(FUError::ERROR_LEVEL, this, &FColladaErrorHandler::OnError); | ||||
} | } | ||||
FColladaErrorHandler::~FColladaErrorHandler() | FColladaErrorHandler::~FColladaErrorHandler() | ||||
{ | { | ||||
xmlSetGenericErrorFunc(NULL, NULL); | xmlSetGenericErrorFunc(nullptr, nullptr); | ||||
FUError::RemoveErrorCallback(FUError::DEBUG_LEVEL, this, &FColladaErrorHandler::OnError); | FUError::RemoveErrorCallback(FUError::DEBUG_LEVEL, this, &FColladaErrorHandler::OnError); | ||||
FUError::RemoveErrorCallback(FUError::WARNING_LEVEL, this, &FColladaErrorHandler::OnError); | FUError::RemoveErrorCallback(FUError::WARNING_LEVEL, this, &FColladaErrorHandler::OnError); | ||||
FUError::RemoveErrorCallback(FUError::ERROR_LEVEL, this, &FColladaErrorHandler::OnError); | FUError::RemoveErrorCallback(FUError::ERROR_LEVEL, this, &FColladaErrorHandler::OnError); | ||||
} | } | ||||
void FColladaErrorHandler::OnError(FUError::Level errorLevel, uint32 errorCode, uint32 UNUSED(lineNumber)) | void FColladaErrorHandler::OnError(FUError::Level errorLevel, uint32 errorCode, uint32 UNUSED(lineNumber)) | ||||
{ | { | ||||
Show All 15 Lines | |||||
////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////// | ||||
void FColladaDocument::LoadFromText(const char *text) | void FColladaDocument::LoadFromText(const char *text) | ||||
{ | { | ||||
document.reset(FCollada::NewTopDocument()); | document.reset(FCollada::NewTopDocument()); | ||||
const char* newText = NULL; | const char* newText = nullptr; | ||||
size_t newTextSize = 0; | size_t newTextSize = 0; | ||||
FixBrokenXML(text, &newText, &newTextSize); | FixBrokenXML(text, &newText, &newTextSize); | ||||
// Log(LOG_INFO, "%s", newText); | // Log(LOG_INFO, "%s", newText); | ||||
bool status = FCollada::LoadDocumentFromMemory("unknown.dae", document.get(), (void*)newText, newTextSize); | bool status = FCollada::LoadDocumentFromMemory("unknown.dae", document.get(), (void*)newText, newTextSize); | ||||
if (newText != text) | if (newText != text) | ||||
xmlFree((void*)newText); | xmlFree((void*)newText); | ||||
Show All 26 Lines | |||||
////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////// | ||||
CommonConvert::CommonConvert(const char* text, std::string& xmlErrors) | CommonConvert::CommonConvert(const char* text, std::string& xmlErrors) | ||||
: m_Err(xmlErrors) | : m_Err(xmlErrors) | ||||
{ | { | ||||
m_Doc.LoadFromText(text); | m_Doc.LoadFromText(text); | ||||
FCDSceneNode* root = m_Doc.GetDocument()->GetVisualSceneRoot(); | FCDSceneNode* root = m_Doc.GetDocument()->GetVisualSceneRoot(); | ||||
REQUIRE(root != NULL, "has root object"); | REQUIRE(root != nullptr, "has root object"); | ||||
// Find the instance to convert | // Find the instance to convert | ||||
if (! FindSingleInstance(root, m_Instance, m_EntityTransform)) | if (! FindSingleInstance(root, m_Instance, m_EntityTransform)) | ||||
throw ColladaException("Couldn't find object to convert"); | throw ColladaException("Couldn't find object to convert"); | ||||
assert(m_Instance); | assert(m_Instance); | ||||
Log(LOG_INFO, "Converting '%s'", m_Instance->GetEntity()->GetName().c_str()); | Log(LOG_INFO, "Converting '%s'", m_Instance->GetEntity()->GetName().c_str()); | ||||
▲ Show 20 Lines • Show All 227 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
const Skeleton& FindSkeleton(const FCDControllerInstance& controllerInstance) | const Skeleton& FindSkeleton(const FCDControllerInstance& controllerInstance) | ||||
{ | { | ||||
// I can't see any proper way to determine the real root of the skeleton, | // I can't see any proper way to determine the real root of the skeleton, | ||||
// so just choose an arbitrary bone and search upwards until we find a | // so just choose an arbitrary bone and search upwards until we find a | ||||
// recognised ancestor (or until we fall off the top of the tree) | // recognised ancestor (or until we fall off the top of the tree) | ||||
const Skeleton* skeleton = NULL; | const Skeleton* skeleton = nullptr; | ||||
const FCDSceneNode* joint = controllerInstance.GetJoint(0); | const FCDSceneNode* joint = controllerInstance.GetJoint(0); | ||||
while (joint && (skeleton = Skeleton::FindSkeleton(joint->GetName().c_str())) == NULL) | while (joint && (skeleton = Skeleton::FindSkeleton(joint->GetName().c_str())) == nullptr) | ||||
{ | { | ||||
joint = joint->GetParent(); | joint = joint->GetParent(); | ||||
} | } | ||||
REQUIRE(skeleton != NULL, "recognised skeleton structure"); | REQUIRE(skeleton != nullptr, "recognised skeleton structure"); | ||||
return *skeleton; | return *skeleton; | ||||
} | } | ||||
void TransformBones(std::vector<BoneTransform>& bones, const FMMatrix44& scaleTransform, bool yUp) | void TransformBones(std::vector<BoneTransform>& bones, const FMMatrix44& scaleTransform, bool yUp) | ||||
{ | { | ||||
for (size_t i = 0; i < bones.size(); ++i) | for (size_t i = 0; i < bones.size(); ++i) | ||||
{ | { | ||||
// Apply the desired transformation to the bone coordinates | // Apply the desired transformation to the bone coordinates | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator