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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/sg/matrix (Version 11.3.0) and /externals/g4tools/include/tools/sg/matrix (Version 11.1.1)


  1 // Copyright (C) 2010, Guy Barrand. All rights      1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.            2 // See the file tools.license for terms.
  3                                                     3 
  4 #ifndef tools_sg_matrix                             4 #ifndef tools_sg_matrix
  5 #define tools_sg_matrix                             5 #define tools_sg_matrix
  6                                                     6 
  7 #include "node"                                     7 #include "node"
  8 #include "sf_mat4f"                                 8 #include "sf_mat4f"
  9 #include "../lina/mat4f"                            9 #include "../lina/mat4f"
 10 #include "render_action"                           10 #include "render_action"
 11 #include "pick_action"                             11 #include "pick_action"
 12 #include "bbox_action"                             12 #include "bbox_action"
 13 #include "event_action"                            13 #include "event_action"
 14 #include "visible_action"                          14 #include "visible_action"
 15                                                    15 
 16 namespace tools {                                  16 namespace tools {
 17 namespace sg {                                     17 namespace sg {
 18                                                    18 
 19 class matrix : public node {                       19 class matrix : public node {
 20   TOOLS_NODE(matrix,tools::sg::matrix,node)        20   TOOLS_NODE(matrix,tools::sg::matrix,node)
 21 public:                                            21 public:
 22   sf_mat4f mtx;                                    22   sf_mat4f mtx;
 23 public:                                            23 public:
 24   virtual const desc_fields& node_desc_fields(     24   virtual const desc_fields& node_desc_fields() const {
 25     TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::mat     25     TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::matrix)
 26     static const desc_fields s_v(parent::node_     26     static const desc_fields s_v(parent::node_desc_fields(),1, //WARNING : take care of count.
 27       TOOLS_ARG_FIELD_DESC(mtx)                    27       TOOLS_ARG_FIELD_DESC(mtx)
 28     );                                             28     );
 29     return s_v;                                    29     return s_v;
 30   }                                                30   }
 31 private:                                           31 private:
 32   void add_fields(){                               32   void add_fields(){
 33     add_field(&mtx);                               33     add_field(&mtx);
 34   }                                                34   }
 35 public:                                            35 public:
 36   virtual void render(render_action& a_action)     36   virtual void render(render_action& a_action) {
 37     a_action.model_matrix().mul_mtx(mtx.value(     37     a_action.model_matrix().mul_mtx(mtx.value(),m_tmp);
 38     a_action.state().m_model = a_action.model_     38     a_action.state().m_model = a_action.model_matrix();
 39     a_action.load_model_matrix(a_action.model_     39     a_action.load_model_matrix(a_action.model_matrix());
 40   }                                                40   }
 41   virtual void pick(pick_action& a_action) {       41   virtual void pick(pick_action& a_action) {
 42     a_action.model_matrix().mul_mtx(mtx.value(     42     a_action.model_matrix().mul_mtx(mtx.value(),m_tmp);
 43     a_action.state().m_model = a_action.model_     43     a_action.state().m_model = a_action.model_matrix();
 44   }                                                44   }
 45   virtual void bbox(bbox_action& a_action) {       45   virtual void bbox(bbox_action& a_action) {
 46     a_action.model_matrix().mul_mtx(mtx.value(     46     a_action.model_matrix().mul_mtx(mtx.value(),m_tmp);
 47     a_action.state().m_model = a_action.model_     47     a_action.state().m_model = a_action.model_matrix();
 48   }                                                48   }
 49   virtual void event(event_action& a_action) {     49   virtual void event(event_action& a_action) {
 50     a_action.model_matrix().mul_mtx(mtx.value(     50     a_action.model_matrix().mul_mtx(mtx.value(),m_tmp);
 51     a_action.state().m_model = a_action.model_     51     a_action.state().m_model = a_action.model_matrix();
 52   }                                                52   }
 53   virtual void get_matrix(get_matrix_action& a     53   virtual void get_matrix(get_matrix_action& a_action) {
 54     a_action.model_matrix().mul_mtx(mtx.value(     54     a_action.model_matrix().mul_mtx(mtx.value(),m_tmp);
 55     a_action.state().m_model = a_action.model_     55     a_action.state().m_model = a_action.model_matrix();
 56   }                                                56   }
 57   virtual void is_visible(visible_action& a_ac     57   virtual void is_visible(visible_action& a_action) {
 58     a_action.model_matrix().mul_mtx(mtx.value(     58     a_action.model_matrix().mul_mtx(mtx.value(),m_tmp);
 59     a_action.state().m_model = a_action.model_     59     a_action.state().m_model = a_action.model_matrix();
 60   }                                                60   }
 61 public:                                            61 public:
 62   matrix():parent(),mtx(mat4f()) {                 62   matrix():parent(),mtx(mat4f()) {
 63 #ifdef TOOLS_MEM                                   63 #ifdef TOOLS_MEM
 64     mem::increment(s_class().c_str());             64     mem::increment(s_class().c_str());
 65 #endif                                             65 #endif
 66     add_fields();                                  66     add_fields();
 67     mtx.set_identity();                            67     mtx.set_identity();
 68   }                                                68   }
 69   virtual ~matrix(){                               69   virtual ~matrix(){
 70 #ifdef TOOLS_MEM                                   70 #ifdef TOOLS_MEM
 71     mem::decrement(s_class().c_str());             71     mem::decrement(s_class().c_str());
 72 #endif                                             72 #endif
 73   }                                                73   }
 74 public:                                            74 public:
 75   matrix(const matrix& a_from):parent(a_from),     75   matrix(const matrix& a_from):parent(a_from),mtx(a_from.mtx) {
 76 #ifdef TOOLS_MEM                                   76 #ifdef TOOLS_MEM
 77     mem::increment(s_class().c_str());             77     mem::increment(s_class().c_str());
 78 #endif                                             78 #endif
 79     add_fields();                                  79     add_fields();
 80   }                                                80   }
 81   matrix& operator=(const matrix& a_from){         81   matrix& operator=(const matrix& a_from){
 82     parent::operator=(a_from);                     82     parent::operator=(a_from);
 83     mtx = a_from.mtx;                              83     mtx = a_from.mtx;
 84     return *this;                                  84     return *this;
 85   }                                                85   }
 86 public:                                            86 public:
 87   // shortcuts :                                   87   // shortcuts :
 88   void set_identity() {mtx.set_identity();}        88   void set_identity() {mtx.set_identity();}
 89                                                    89 
 90   void set_translate(float a_x,float a_y,float     90   void set_translate(float a_x,float a_y,float a_z) {mtx.set_translate(a_x,a_y,a_z);}
 91   void set_translate(const vec3f& a_v) {mtx.se     91   void set_translate(const vec3f& a_v) {mtx.set_translate(a_v);}
 92                                                    92 
 93   void set_scale(float a_x,float a_y,float a_z     93   void set_scale(float a_x,float a_y,float a_z) {mtx.set_scale(a_x,a_y,a_z);}
 94   void set_scale(float a_s) {mtx.set_scale(a_s     94   void set_scale(float a_s) {mtx.set_scale(a_s);}
 95                                                    95 
 96   void set_rotate(float a_x,float a_y,float a_     96   void set_rotate(float a_x,float a_y,float a_z,float a_angle) {mtx.set_rotate(a_x,a_y,a_z,a_angle);}
 97   void set_rotate(const vec3f& a_v,float a_ang     97   void set_rotate(const vec3f& a_v,float a_angle) {mtx.set_rotate(a_v,a_angle);}
 98   bool set_rotate(const vec3f& a_from,const ve     98   bool set_rotate(const vec3f& a_from,const vec3f& a_to) {return mtx.set_rotate(a_from,a_to,m_tmp);}
 99                                                    99 
100   void mul_mtx(const mat4f& a_m) {mtx.mul_mtx(    100   void mul_mtx(const mat4f& a_m) {mtx.mul_mtx(a_m,m_tmp);}
101                                                   101 
102   void mul_translate(float a_x,float a_y,float    102   void mul_translate(float a_x,float a_y,float a_z) {mtx.mul_translate(a_x,a_y,a_z);}
103   void mul_translate(const vec3f& a_v) {mtx.mu    103   void mul_translate(const vec3f& a_v) {mtx.mul_translate(a_v);}
104   void mul_scale(float a_x,float a_y,float a_z    104   void mul_scale(float a_x,float a_y,float a_z) {mtx.mul_scale(a_x,a_y,a_z);}
105   void mul_scale(float a_s) {mtx.mul_scale(a_s    105   void mul_scale(float a_s) {mtx.mul_scale(a_s);}
106                                                   106 
107   void mul_rotate(float a_x,float a_y,float a_    107   void mul_rotate(float a_x,float a_y,float a_z,float a_angle) {mtx.mul_rotate(a_x,a_y,a_z,a_angle);}
108                                                   108 
109   void mul_rotate(const vec3f& a_v,float a_ang    109   void mul_rotate(const vec3f& a_v,float a_angle) {mtx.mul_rotate(a_v,a_angle);}
110   void mul_rotate(const vec4f& a_v) {mtx.mul_r    110   void mul_rotate(const vec4f& a_v) {mtx.mul_rotate(a_v.v0(),a_v.v1(),a_v.v2(),a_v.v3());}
111                                                   111 
112   void left_mul_rotate(float a_x,float a_y,flo    112   void left_mul_rotate(float a_x,float a_y,float a_z,float a_angle) {mtx.left_mul_rotate(a_x,a_y,a_z,a_angle);}
113                                                   113 
114   void left_mul_scale(float a_x,float a_y,floa    114   void left_mul_scale(float a_x,float a_y,float a_z) {mtx.left_mul_scale(a_x,a_y,a_z);}
115                                                   115 
116   void left_mul_translate(float a_x,float a_y,    116   void left_mul_translate(float a_x,float a_y,float a_z) {mtx.left_mul_translate(a_x,a_y,a_z);}
117                                                   117 
118   void left_mul_translate(const vec3f& a_v) {m    118   void left_mul_translate(const vec3f& a_v) {mtx.left_mul_translate(a_v);}
119                                                   119 
120   bool mul_rotate(const vec3f& a_from,const ve    120   bool mul_rotate(const vec3f& a_from,const vec3f& a_to) {return mtx.mul_rotate(a_from,a_to,m_tmp);}
121 protected:                                        121 protected:
122   float m_tmp[16]; //OPTIMIZATION                 122   float m_tmp[16]; //OPTIMIZATION
123 };                                                123 };
124                                                   124 
125 }}                                                125 }}
126                                                   126 
127 #endif                                            127 #endif