#include <pw/core/vector.hpp>
#include <pw/core/serialize.hpp>
#include <pw/scene/node.hpp>
#include <pw/scene/transform.hpp>

#include <pw/core/serialize.hpp>

#include <iostream>

void print_node_path(pw::node::ref node) {

	auto parents = node->path();

	std::cout << node->name() << " - ";
	for (auto p : node->path()) {
		std::cout << " p:'" << p->name() << "'";
	}

	std::cout << std::endl;

}

int main(int argc,char **argv) {

    using namespace pw;

	node::ref n = std::make_shared<node>();
	n->set_name("root");

    // check
    {
		n->add_child()->set_name("node");
    }

    std::cout << "n name: " << n->name() << std::endl;
    std::cout << "n leaf: " << n->is_leaf() << std::endl;
    std::cout << "n root: " << n->is_root() << std::endl;

	std::cout << "s name: " << n->children().front()->name() << std::endl;
    std::cout << "s leaf: " << n->children()[0]->is_leaf() << std::endl;
    std::cout << "s root: " << n->children()[0]->is_root() << std::endl;


    // thats the only and most ugly way to register a component
//    new component(n.get());

	n->add_component(std::make_shared<transform>());

    std::cout << "n components: " << n->components().size() << std::endl;


	print_node_path((n));

//	auto t = n->transform();

//	if (t)
        std::cout << n->transform().local()(0,0) << std::endl;
//	else {
//		std::cerr << "no transform?" << std::endl;
//	}




    return 0;
}
