In order to create animations hierarchy of bones and parts of a model needs to be preserved. It can be achived using directed acyclic graphs, but trees have many advantages, one of which is their simplicity. Class enables user to create hierarchical tree, modify its structure and provide iterator which can notify whenever it changes level during iteration. Why is it important? This feature provides a convenient way to concatenate tranformations.
ms::tree<int> myTree;
auto it = myTree.begin();
myTree.insert_s(it, 10);
for (auto it = myTree.begin(); it != myTree.end(); ++it) {
std::cout << *it << " ";
}
auto sibling = myTree.has_sibling(it, ms::tree<int>::sibling::left);
if (sibling) {
std::cout << "Left sibling exists.";
}
myTree.clear();
for (auto it = myTree.begin(); it != myTree.end(); ++it) {
std::cout << *it << " ";
}
for (auto it = myTree.rbegin(); it != myTree.rend(); ++it) {
std::cout << *it << " ";
}
auto it = myTree.begin();
myTree.erase(it);
In file named "tree.hpp"
Only one
There is no need of compilation. It is a header only, one class lib.
If you would like to install the library once and for all I suggest using CMake and running the snippet placed below.
$ git clone https://github.com/mateuszstompor/tree.git
$ cd tree
$ mkdir build && cd build
$ cmake ..
$ make install
Yes, the entire project is tested and works correctly.
To use the class, you need one of the listed compilers to build your project.
If you wish to use the class on Windows, please compile with the __WIN32__
flag.
- GCC, version 9.0
- clang, version 11.0
Contributions are welcome! Please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.
For support or inquiries, please open an issue on the GitHub repository.