moved component out and about

This commit is contained in:
Hartmut Seichter 2018-04-03 17:35:25 +02:00
parent 75d55faa31
commit 75fb4c27f7
7 changed files with 59 additions and 29 deletions

View file

@ -104,9 +104,11 @@ public:
return vector<4,T>(x(),y(),z(),w); return vector<4,T>(x(),y(),z(),w);
} }
#if _GCC_STUPID_
inline std::tuple<T,T,T> values() const { inline std::tuple<T,T,T> values() const {
return std::make_tuple(x(),y(),z()); return std::make_tuple(x(),y(),z());
} }
#endif

View file

@ -12,7 +12,6 @@ int main(int argc,char **argv) {
std::cout << "m = " << pw::serialize::matrix(m) << std::endl; std::cout << "m = " << pw::serialize::matrix(m) << std::endl;
std::cout << "row_stride() : " << m.row_stride() << std::endl; std::cout << "row_stride() : " << m.row_stride() << std::endl;
std::cout << "col_stride() : " << m.col_stride() << std::endl; std::cout << "col_stride() : " << m.col_stride() << std::endl;
std::cout << "rows() : " << m.rows() << std::endl; std::cout << "rows() : " << m.rows() << std::endl;

View file

@ -0,0 +1,29 @@
#ifndef PW_SCENE_COMPONENT_HPP
#define PW_SCENE_COMPONENT_HPP
#include <pw/core/globals.hpp>
#include <string>
#include <vector>
namespace pw {
/**
* @brief components represent attributes of the scene nodes
*/
class component {
public:
typedef std::shared_ptr<component> ref;
typedef std::vector<ref> array;
//! only very few components can be attached multiple times
virtual bool singular() const { return true; }
protected:
std::string _name;
};
}
#endif

View file

@ -2,14 +2,16 @@
#define PW_SCENE_NODE_HPP #define PW_SCENE_NODE_HPP
#include <pw/core/globals.hpp> #include <pw/core/globals.hpp>
#include <pw/scene/component.hpp>
#include <string> #include <string>
#include <vector> #include <vector>
namespace pw { namespace pw {
class component; /**
* @brief nodes are representing the hierarchical structore fo the scene graph
*/
class node { class node {
public: public:
@ -54,6 +56,8 @@ protected:
ref_array _children; ref_array _children;
ptr_array _parents; ptr_array _parents;
component::array _components;
std::string _name; std::string _name;
}; };

View file

@ -1,29 +1,30 @@
set(hdrs set(hdrs
../include/pw/scene/node.hpp ../include/pw/scene/component.hpp
) ../include/pw/scene/node.hpp
)
set(srcs set(srcs
node.cpp node.cpp
nodepath.cpp nodepath.cpp
component.cpp component.cpp
) )
add_library(pwscene add_library(pwscene
STATIC STATIC
${hdrs} ${hdrs}
${srcs} ${srcs}
) )
target_include_directories( target_include_directories(
pwscene pwscene
PUBLIC PUBLIC
../include ../include
) )
target_include_directories( target_include_directories(
pwscene pwscene
PUBLIC PUBLIC
) )
target_link_libraries(pwscene pwcore) target_link_libraries(pwscene pwcore)

View file

@ -1,3 +1,6 @@
#include "pw/scene/component.hpp"
#include <pw/core/vector.hpp> #include <pw/core/vector.hpp>
#include <pw/core/quaternion.hpp> #include <pw/core/quaternion.hpp>
@ -5,14 +8,6 @@
namespace pw { namespace pw {
class component {
std::string _name;
//! only very few components can be attached multiple times
virtual bool singular() const { return true; }
};
class transform : public component { class transform : public component {
matrix44d _local; matrix44d _local;

View file

@ -53,7 +53,7 @@ void lua_state::load_modules() {
"x", scripting::property(scripting::resolve<const Scalar&() const>(&vector3d::x), &vector3d::set_x), "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), "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), "z", scripting::property(scripting::resolve<const Scalar&() const>(&vector3d::z), &vector3d::set_z),
"v",&vector3d::values, // "v",&vector3d::values,
"clone",&vector3d::clone "clone",&vector3d::clone
); );