TDME2 1.9.121
copyanimationsetups-main.cpp
Go to the documentation of this file.
1#include <cstdlib>
2#include <string>
3
4#include <tdme/tdme.h>
10#include <tdme/engine/Version.h>
15
26
27int main(int argc, char** argv)
28{
29 Console::println(string("copyanimationsetups ") + Version::getVersion());
30 Console::println(Version::getCopyright());
31 Console::println();
32 if (argc != 3) {
33 Console::println("Usage: copyanimationsetups sourcefile targetfile.tm");
34 Application::exit(1);
35 }
36 string sourceFileName = string(argv[1]);
37 string targetFileName = string(argv[2]);
38 try {
39 Console::println("Loading source model: " + sourceFileName);
40 auto srcModel = ModelReader::read(
41 FileSystem::getInstance()->getPathName(sourceFileName),
42 FileSystem::getInstance()->getFileName(sourceFileName)
43 );
44 Console::println("Loading target model: " + targetFileName);
45 auto targetModel = ModelReader::read(
46 FileSystem::getInstance()->getPathName(targetFileName),
47 FileSystem::getInstance()->getFileName(targetFileName)
48 );
49 Console::println("Clearing target animation setups");
50 targetModel->getAnimationSetups().clear();
51 for (auto& animationSetupIt: srcModel->getAnimationSetups()) {
52 auto srcAnimationSetup = animationSetupIt.second;
53 Console::println("Adding target animation setup: " + srcAnimationSetup->getId());
54 if (srcAnimationSetup->getOverlayFromNodeId().length() == 0) {
55 targetModel->addAnimationSetup(
56 srcAnimationSetup->getId(),
57 srcAnimationSetup->getStartFrame(),
58 srcAnimationSetup->getEndFrame(),
59 srcAnimationSetup->isLoop(),
60 srcAnimationSetup->getSpeed()
61 );
62 } else {
63 targetModel->addOverlayAnimationSetup(
64 srcAnimationSetup->getId(),
65 srcAnimationSetup->getOverlayFromNodeId(),
66 srcAnimationSetup->getStartFrame(),
67 srcAnimationSetup->getEndFrame(),
68 srcAnimationSetup->isLoop(),
69 srcAnimationSetup->getSpeed()
70 );
71 }
72 }
73 Console::println("Saving target model: " + targetFileName);
74 TMWriter::write(
75 targetModel,
76 FileSystem::getInstance()->getPathName(targetFileName),
77 FileSystem::getInstance()->getFileName(targetFileName)
78 );
79 } catch (Exception& exception) {
80 Console::println("An error occurred: " + string(exception.what()));
81 }
82}
Application base class, please make sure to allocate application on heap to have correct application ...
Definition: Application.h:37
Representation of a 3d model.
Definition: Model.h:32
File system singleton class.
Definition: FileSystem.h:14
Console class.
Definition: Console.h:26
int main(int argc, char **argv)
std::exception Exception
Exception base class.
Definition: Exception.h:19