#include "script_core.hpp"

#include "pw/core/vector.hpp"
#include "pw/core/quaternion.hpp"
#include "pw/core/axisangle.hpp"


namespace pw {

void script_core::load(sol::table &ns)
{

	typedef double Scalar;

	ns.set("pi",pw::pi<Scalar>());


	ns.new_usertype<vector3d>("vector3",
							  sol::constructors<vector3d(), vector3d(Scalar,Scalar,Scalar)>(),
							  "set",&vector3d::set,
							  "x", scripting::property(scripting::resolve<const Scalar&() const>(&vector3d::x), &vector3d::set_x),
							  "y", scripting::property(scripting::resolve<const Scalar&() const>(&vector3d::y), &vector3d::set_y),
							  "z", scripting::property(scripting::resolve<const Scalar&() const>(&vector3d::z), &vector3d::set_z),
							  "norm",&vector3d::norm,
							  "cross",&vector3d::cross,
							  "dot",&vector3d::dot,
							  //									  sol::meta_function::addition, sol::resolve<vector3d(const vector3d&, const vector3d&)>(::operator+),
							  //									  sol::meta_function::subtraction, &vector3d::operator-
							  //                                      "v",&vector3d::values,
							  "clone",&vector3d::clone
							  );

	ns.new_usertype<quaterniond>("quaternion",
								 sol::constructors<quaterniond(), quaterniond(Scalar,Scalar,Scalar,Scalar)>(),
								 "set",&quaterniond::set,
								 "x", scripting::property(scripting::resolve<const Scalar&() const>(&quaterniond::x), &quaterniond::set_x),
								 "y", scripting::property(scripting::resolve<const Scalar&() const>(&quaterniond::y), &quaterniond::set_y),
								 "z", scripting::property(scripting::resolve<const Scalar&() const>(&quaterniond::z), &quaterniond::set_z),
								 "w", scripting::property(scripting::resolve<const Scalar&() const>(&quaterniond::w), &quaterniond::set_w),
								 "dot",&quaterniond::dot,
								 "inverse",scripting::readonly_property(&quaterniond::inverse),
								 "normalized",&quaterniond::normalized,
								 "lerp",&quaterniond::lerp
								 //                                      "v",&vector3d::values,
								 //                                      "clone",&vector3d::clone
								 );

	ns.new_usertype<axisangled>("axisangle",
								sol::constructors<axisangled(), axisangled(vector3d,Scalar)>(),
								"axis",scripting::property(&axisangled::axis,&axisangled::set_axis),
								"angle",scripting::property(&axisangled::angle,&axisangled::set_angle)
								);
}





}
