void getUnitMeterScalingAndUpAxisTransform(TiXmlDocument& doc, btTransform& tr, float& unitMeterScaling) { TiXmlElement* unitMeter = doc.RootElement()->FirstChildElement("asset")->FirstChildElement("unit"); if (unitMeter) { const char* meterText = unitMeter->Attribute("meter"); printf("meterText=%s\n", meterText); unitMeterScaling = atof(meterText); } TiXmlElement* upAxisElem = doc.RootElement()->FirstChildElement("asset")->FirstChildElement("up_axis"); if (upAxisElem) { std::string upAxisTxt = upAxisElem->GetText(); if (upAxisTxt == "X_UP") { btQuaternion y2x(btVector3(0,0,1),SIMD_HALF_PI); tr.setRotation(y2x); } if (upAxisTxt == "Y_UP") { //assume Y_UP for now, to be compatible with assimp? } if (upAxisTxt == "Z_UP") { btQuaternion y2z(btVector3(1,0,0),-SIMD_HALF_PI); tr.setRotation(y2z); } } }
void getUnitMeterScalingAndUpAxisTransform(TiXmlDocument& doc, btTransform& tr, float& unitMeterScaling, int clientUpAxis) { ///todo(erwincoumans) those up-axis transformations have been quickly coded without rigorous testing TiXmlElement* unitMeter = doc.RootElement()->FirstChildElement("asset")->FirstChildElement("unit"); if (unitMeter) { const char* meterText = unitMeter->Attribute("meter"); printf("meterText=%s\n", meterText); unitMeterScaling = atof(meterText); } TiXmlElement* upAxisElem = doc.RootElement()->FirstChildElement("asset")->FirstChildElement("up_axis"); if (upAxisElem) { switch (clientUpAxis) { case 1: { std::string upAxisTxt = upAxisElem->GetText(); if (upAxisTxt == "X_UP") { btQuaternion x2y(btVector3(0,0,1),SIMD_HALF_PI); tr.setRotation(x2y); } if (upAxisTxt == "Y_UP") { //assume Y_UP for now, to be compatible with assimp? //client and COLLADA are both Z_UP so no transform needed (identity) } if (upAxisTxt == "Z_UP") { btQuaternion z2y(btVector3(1,0,0),-SIMD_HALF_PI); tr.setRotation(z2y); } break; } case 2: { std::string upAxisTxt = upAxisElem->GetText(); if (upAxisTxt == "X_UP") { btQuaternion x2z(btVector3(0,1,0),-SIMD_HALF_PI); tr.setRotation(x2z); } if (upAxisTxt == "Y_UP") { btQuaternion y2z(btVector3(1,0,0),SIMD_HALF_PI); tr.setRotation(y2z); } if (upAxisTxt == "Z_UP") { //client and COLLADA are both Z_UP so no transform needed (identity) } break; } case 0: default: { //we don't support X or other up axis btAssert(0); } }; } }