24 using std::unique_ptr;
44 int main(
int argc,
char** argv)
46 Console::println(
string(
"scenefixmodelszup2yup ") + Version::getVersion());
47 Console::println(Version::getCopyright());
51 Console::println(
"Usage: scenefixmodelszup2yup scene");
52 Application::exit(Application::EXITCODE_FAILURE);
54 string sceneFileName = string(argv[1]);
56 Console::println(
"Loading scene: " + sceneFileName);
57 auto scene = unique_ptr<Scene>(
59 FileSystem::getInstance()->getPathName(sceneFileName),
60 FileSystem::getInstance()->getFileName(sceneFileName)
63 Console::println(
"Fixing scene models up axis from Z-Up to Y-Up");
67 auto sceneLibray = scene->getLibrary();
68 for (
auto i = 0; i < sceneLibray->getPrototypeCount(); i++) {
69 auto prototype = sceneLibray->getPrototypeAt(i);
70 if (prototype->getType() != Prototype_Type::MODEL)
continue;
71 prototype->getModel()->setImportTransformMatrix(prototype->getModel()->getImportTransformMatrix().clone().multiply(z2yUpMatrix));
72 prototype->getModel()->getBoundingBox()->getMin() = z2yUpMatrix.
multiply(prototype->getModel()->getBoundingBox()->getMin());
73 prototype->getModel()->getBoundingBox()->getMax() = z2yUpMatrix.
multiply(prototype->getModel()->getBoundingBox()->getMax());
74 prototype->getModel()->getBoundingBox()->update();
77 for (
auto i = 0; i < scene->getEntityCount(); i++) {
78 auto sceneEntity = scene->getEntityAt(i);
79 if (sceneEntity->getPrototype()->getType() != Prototype_Type::MODEL)
continue;
80 auto scale = sceneEntity->getTransform().getScale();
81 sceneEntity->getTransform().setScale(
Vector3(scale.getX(), scale.getZ(), scale.getY()));
82 auto rotationX = sceneEntity->getTransform().getRotationAngle(scene->getRotationOrder()->getAxisXIndex());
83 sceneEntity->getTransform().setRotationAngle(scene->getRotationOrder()->getAxisXIndex(), rotationX + 90);
84 sceneEntity->getTransform().update();
87 Console::println(
"Saving scene: " + sceneFileName);
89 FileSystem::getInstance()->getPathName(sceneFileName),
90 FileSystem::getInstance()->getFileName(sceneFileName),
94 Console::println(
"An error occurred: " +
string(exception.what()));
98 Application::exit(Application::EXITCODE_SUCCESS);
Application base class, please make sure to allocate application on heap to have correct application ...
Represents rotation orders of a model.
Scene prototype library definition.
Matrix4x4 class representing matrix4x4 mathematical structure and operations for 3d space.
Matrix4x4 & identity()
Creates identity matrix.
Vector3 multiply(const Vector3 &vector3) const
Multiplies this matrix with vector3.
Matrix4x4 & setAxes(const Vector3 &xAxis, const Vector3 &yAxis, const Vector3 &zAxis)
Set coordinate system axes.
Vector3 class representing vector3 mathematical structure and operations with x, y,...
File system singleton class.
std::exception Exception
Exception base class.
int main(int argc, char **argv)