g4tools  5.4.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tools::sg::matrix_action Class Reference
Inheritance diagram for tools::sg::matrix_action:
Inheritance graph
[legend]
Collaboration diagram for tools::sg::matrix_action:
Collaboration graph
[legend]

Public Member Functions

 matrix_action (std::ostream &a_out, unsigned int a_ww, unsigned int a_wh)
 
virtual ~matrix_action ()
 
 matrix_action (const matrix_action &a_from)
 
matrix_actionoperator= (const matrix_action &a_from)
 
void push_matrices ()
 
void pop_matrices ()
 
mat4fprojection_matrix ()
 
mat4fmodel_matrix ()
 
bool end () const
 
int cur () const
 
bool project_point (float &a_x, float &a_y, float &a_z, float &a_w)
 
void model_point (float &a_x, float &a_y, float &a_z, float &a_w)
 
void projected_origin (float &a_x, float &a_y, float &a_z)
 
- Public Member Functions inherited from tools::sg::win_action
 win_action (std::ostream &a_out, unsigned int a_ww, unsigned int a_wh)
 
virtual ~win_action ()
 
unsigned int ww () const
 
unsigned int wh () const
 
- Public Member Functions inherited from tools::sg::action
virtual void * cast (const std::string &a_class) const
 
virtual const std::string & s_cls () const =0
 
 action (std::ostream &a_out)
 
virtual ~action ()
 
std::ostream & out () const
 
- Public Member Functions inherited from tools::sg::states
 states (unsigned int a_ww, unsigned int a_wh)
 
virtual ~states ()
 
const sg::statestate () const
 
sg::statestate ()
 
void pop_state ()
 
void push_state ()
 
void save_state (const sg::state &a_state)
 
const sg::statesaved_state () const
 
sg::statesaved_state ()
 

Protected Member Functions

void reset ()
 
- Protected Member Functions inherited from tools::sg::win_action
 win_action (const win_action &a_from)
 
win_actionoperator= (const win_action &a_from)
 
- Protected Member Functions inherited from tools::sg::action
 action (const action &a_from)
 
actionoperator= (const action &)
 
- Protected Member Functions inherited from tools::sg::states
 states (const states &a_from)
 
statesoperator= (const states &a_from)
 

Protected Attributes

std::vector< mat4fm_projs
 
std::vector< mat4fm_models
 
int m_cur
 
mat4f m_identity
 
- Protected Attributes inherited from tools::sg::win_action
unsigned int m_ww
 
unsigned int m_wh
 
- Protected Attributes inherited from tools::sg::action
std::ostream & m_out
 
- Protected Attributes inherited from tools::sg::states
std::vector< sg::statem_states
 
sg::state m_state
 
sg::state m_saved_state
 

Detailed Description

Definition at line 15 of file matrix_action.

Constructor & Destructor Documentation

◆ matrix_action() [1/2]

tools::sg::matrix_action::matrix_action ( std::ostream &  a_out,
unsigned int  a_ww,
unsigned int  a_wh 
)
inline

Definition at line 18 of file matrix_action.

19  :parent(a_out,a_ww,a_wh)
20  ,states(a_ww,a_wh)
21  ,m_cur(0)
22  ,m_landscape(true)
23  {
24  m_projs.resize(5);
25  m_models.resize(5);
26  reset();
27  m_identity.set_identity();
28  }

◆ ~matrix_action()

virtual tools::sg::matrix_action::~matrix_action ( )
inlinevirtual

Definition at line 29 of file matrix_action.

29 {}

◆ matrix_action() [2/2]

tools::sg::matrix_action::matrix_action ( const matrix_action a_from)
inline

Definition at line 31 of file matrix_action.

32  :parent(a_from)
33  ,states(a_from)
34  ,m_projs(a_from.m_projs)
35  ,m_models(a_from.m_models)
36  ,m_cur(a_from.m_cur)
37  ,m_landscape(a_from.m_landscape)
38  {
39  m_identity.set_identity();
40  }

Member Function Documentation

◆ cur()

int tools::sg::matrix_action::cur ( ) const
inline

Definition at line 76 of file matrix_action.

76 {return m_cur;}

◆ end()

bool tools::sg::matrix_action::end ( ) const
inline

Definition at line 75 of file matrix_action.

75 {return m_cur==0?true:false;}

◆ model_matrix()

mat4f& tools::sg::matrix_action::model_matrix ( )
inline

Definition at line 73 of file matrix_action.

73 {return m_models[m_cur];}

◆ model_point()

void tools::sg::matrix_action::model_point ( float &  a_x,
float &  a_y,
float &  a_z,
float &  a_w 
)
inline

Definition at line 95 of file matrix_action.

95  {
96  a_w = 1;
97  model_matrix().mul_4f(a_x,a_y,a_z,a_w);
98  }

◆ operator=()

matrix_action& tools::sg::matrix_action::operator= ( const matrix_action a_from)
inline

Definition at line 41 of file matrix_action.

41  {
42  parent::operator=(a_from);
43  states::operator=(a_from);
44  m_projs = a_from.m_projs;
45  m_models = a_from.m_models;
46  m_cur = a_from.m_cur;
47  m_landscape = a_from.m_landscape;
48  return *this;
49  }

◆ pop_matrices()

void tools::sg::matrix_action::pop_matrices ( )
inline

Definition at line 66 of file matrix_action.

66  {
67  m_cur--;
68 //OPTIMIZATION : in fact the two lines below are not needed !
69 // m_state.m_proj = m_projs[m_cur];
70 // m_state.m_model = m_models[m_cur];
71  }

◆ project_point()

bool tools::sg::matrix_action::project_point ( float &  a_x,
float &  a_y,
float &  a_z,
float &  a_w 
)
inline

Definition at line 78 of file matrix_action.

78  {
79  a_w = 1;
80  model_matrix().mul_4f(a_x,a_y,a_z,a_w);
81  projection_matrix().mul_4f(a_x,a_y,a_z,a_w);
82  if(a_w==0.0F) return false;
83  a_x /= a_w;
84  a_y /= a_w;
85  a_z /= a_w;
86  return true;
87  }

◆ projected_origin()

void tools::sg::matrix_action::projected_origin ( float &  a_x,
float &  a_y,
float &  a_z 
)
inline

Definition at line 101 of file matrix_action.

101  {
102  a_x = 0;
103  a_y = 0;
104  a_z = 0;
105  float w;
106  project_point(a_x,a_y,a_z,w); //if render : in [-1,1][-1,1]
107  }

◆ projection_matrix()

mat4f& tools::sg::matrix_action::projection_matrix ( )
inline

Definition at line 72 of file matrix_action.

72 {return m_projs[m_cur];}

◆ push_matrices()

void tools::sg::matrix_action::push_matrices ( )
inline

Definition at line 51 of file matrix_action.

51  {
52  if((m_cur+1)>=(int)m_projs.size()) {
53  m_projs.resize(m_projs.size()+5);
54  m_models.resize(m_models.size()+5);
55  }
56  m_cur++;
57  m_projs[m_cur].set_matrix(m_projs[m_cur-1]);
58  m_models[m_cur].set_matrix(m_models[m_cur-1]);
59 //OPTIMIZATION : in fact the two lines below are not needed !
60 // m_state.m_proj = m_projs[m_cur];
61 // m_state.m_model = m_models[m_cur];
62  }

◆ reset()

void tools::sg::matrix_action::reset ( )
inlineprotected

Definition at line 110 of file matrix_action.

110  {
111  m_cur = 0;
112  if(m_landscape) {
113  m_projs[m_cur].set_identity();
114  } else {
115  m_projs[m_cur].set_matrix(0,-1,0,0,
116  1, 0,0,0,
117  0, 0,1,0,
118  0, 0,0,1);
119  }
120  m_models[m_cur].set_identity();
121  sg::state& _state = state();
122  _state.m_proj = m_projs[m_cur];
123  _state.m_model = m_models[m_cur];
124  }

Member Data Documentation

◆ m_cur

int tools::sg::matrix_action::m_cur
protected

Definition at line 128 of file matrix_action.

◆ m_identity

mat4f tools::sg::matrix_action::m_identity
protected

Definition at line 129 of file matrix_action.

◆ m_models

std::vector<mat4f> tools::sg::matrix_action::m_models
protected

Definition at line 127 of file matrix_action.

◆ m_projs

std::vector<mat4f> tools::sg::matrix_action::m_projs
protected

Definition at line 126 of file matrix_action.


The documentation for this class was generated from the following file:
tools::sg::matrix_action::m_models
std::vector< mat4f > m_models
Definition: matrix_action:127
tools::sg::matrix_action::model_matrix
mat4f & model_matrix()
Definition: matrix_action:73
tools::sg::matrix_action::reset
void reset()
Definition: matrix_action:110
tools::sg::matrix_action::m_projs
std::vector< mat4f > m_projs
Definition: matrix_action:126
tools::mat4f::mul_4f
void mul_4f(float &a_x, float &a_y, float &a_z, float &a_w) const
Definition: mat4f:61
tools::sg::states::states
states(unsigned int a_ww, unsigned int a_wh)
Definition: states:26
tools::sg::matrix_action::project_point
bool project_point(float &a_x, float &a_y, float &a_z, float &a_w)
Definition: matrix_action:78
tools::sg::matrix_action::m_identity
mat4f m_identity
Definition: matrix_action:129
tools::sg::matrix_action::m_cur
int m_cur
Definition: matrix_action:128
tools::sg::states::state
const sg::state & state() const
Definition: states:76
tools::sg::matrix_action::projection_matrix
mat4f & projection_matrix()
Definition: matrix_action:72
tools::sg::states::operator=
states & operator=(const states &a_from)
Definition: states:53