#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;

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


	// add a child
	auto c = std::make_shared<node>();
	c->set_name("child-node");
	n->add_child(c);

	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().front()->is_leaf() << std::endl;
	std::cout << "s root: " << n->children().front()->is_root() << std::endl;


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


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

	n->transform().set_translation(5,4,3);

	std::cout << "c transform g  " << serialize::matrix(n->transform().global()) << std::endl;
	std::cout << "c transform gi " << serialize::matrix(n->transform().global_inverse()) << std::endl;
	std::cout << "c transform l  " << serialize::matrix(n->transform().local()) << std::endl;


	//n->add_component_<transform>();

	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;
}
