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

Public Member Functions

virtual float near_height () const
 
virtual void zoom (float a_fac)
 
virtual camera_type type () const
 
virtual const desc_fieldsnode_desc_fields () const
 
 perspective ()
 
virtual ~perspective ()
 
 perspective (const perspective &a_from)
 
perspectiveoperator= (const perspective &a_from)
 
bool operator== (const perspective &a_from) const
 
bool operator!= (const perspective &a_from) const
 
void dump (std::ostream &a_out)
 
- Public Member Functions inherited from tools::sg::base_camera
virtual void render (render_action &a_action)
 
virtual void pick (pick_action &a_action)
 
virtual void event (event_action &a_action)
 
virtual void get_matrix (get_matrix_action &a_action)
 
virtual void is_visible (visible_action &a_action)
 
virtual ~base_camera ()
 
void direction (vec3f &a_dir) const
 
void rotate_around_direction (float a_delta)
 
void rotate_around_z (float a_delta)
 
void rotate_around_up (float a_delta)
 
void rotate_around_x (float a_delta)
 
void rotate_around_x_at_focal (float a_delta)
 
void rotate_around_y_at_focal (float a_delta)
 
void rotate_around_z_at_focal (float a_delta)
 
void rotate_to_dir (const vec3f &a_dir)
 
void pane_to (float a_x, float a_y, float a_z)
 
void translate_along_side (float a_delta)
 
void translate_along_up (float a_delta)
 
void translate_along_dir (float a_delta)
 
bool look_at (const vec3f &a_dir, const vec3f &a_up)
 
void dump (std::ostream &a_out)
 
bool is_type_ortho () const
 
bool height_at_focal (float &a_h) const
 
void astro_orientation (float a_ra, float a_dec)
 
bool update_motion (int a_move)
 
- Public Member Functions inherited from tools::sg::node
virtual void * cast (const std::string &a_class) const
 
virtual const std::string & s_cls () const =0
 
virtual nodecopy () const =0
 
virtual unsigned int cls_version () const
 
virtual void bbox (bbox_action &)
 
virtual void search (search_action &a_action)
 
virtual bool write (write_action &a_action)
 
virtual bool read (read_action &a_action)
 
virtual void protocol_one_fields (std::vector< field * > &a_fields) const
 
virtual bool draw_in_frame_buffer () const
 
virtual bool touched ()
 
virtual void reset_touched ()
 
 node ()
 
virtual ~node ()
 
void touch ()
 
fieldfield_from_desc (const field_desc &a_desc) const
 
void dump_field_descs (std::ostream &a_out) const
 
fieldfind_field_by_name (const std::string &a_name) const
 

Public Attributes

sf< float > height_angle
 
- Public Attributes inherited from tools::sg::base_camera
sf< float > znear
 
sf< float > zfar
 
sf_vec3f position
 
sf_rotf orientation
 
sf< float > dx
 
sf< float > da
 
sf< float > ds
 
sf< float > focal
 

Protected Member Functions

virtual void get_lrbt (unsigned int a_ww, unsigned int a_wh, float &a_l, float &a_r, float &a_b, float &a_t)
 
- Protected Member Functions inherited from tools::sg::base_camera
 base_camera ()
 
 base_camera (const base_camera &a_from)
 
base_cameraoperator= (const base_camera &a_from)
 
bool operator== (const base_camera &a_from) const
 
void update_sg (std::ostream &a_out)
 
void _mult_matrix (matrix_action &a_action)
 
void set_state (matrix_action &a_action)
 
- Protected Member Functions inherited from tools::sg::node
 node (const node &)
 
nodeoperator= (const node &)
 
void add_field (field *a_field)
 
bool write_fields (write_action &a_action)
 
bool read_fields (read_action &a_action)
 
field_desc::offset_t field_offset (const field *a_field) const
 
fieldfind_field (const field_desc &a_rdesc) const
 
void check_fields (std::ostream &a_out) const
 

Additional Inherited Members

- Static Protected Member Functions inherited from tools::sg::base_camera
static const vec4< float > & id_orientation ()
 
- Protected Attributes inherited from tools::sg::base_camera
sf_vec4f m_lrbt
 
mat4f m_proj
 
float m_tmp [16]
 

Detailed Description

Definition at line 14 of file perspective.

Constructor & Destructor Documentation

◆ perspective() [1/2]

tools::sg::perspective::perspective ( )
inline

Definition at line 42 of file perspective.

43  :parent()
44  ,height_angle(fpi()/4.0f) //45 degrees.
45  {
46 #ifdef TOOLS_MEM
47  mem::increment(s_class().c_str());
48 #endif
49  add_fields();
50  }

◆ ~perspective()

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

Definition at line 51 of file perspective.

51  {
52 #ifdef TOOLS_MEM
53  mem::decrement(s_class().c_str());
54 #endif
55  }

◆ perspective() [2/2]

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

Definition at line 57 of file perspective.

58  :parent(a_from)
59  ,height_angle(a_from.height_angle)
60  {
61 #ifdef TOOLS_MEM
62  mem::increment(s_class().c_str());
63 #endif
64  add_fields();
65  }

Member Function Documentation

◆ dump()

void tools::sg::perspective::dump ( std::ostream &  a_out)
inline

Definition at line 81 of file perspective.

81  {
82  parent::dump(a_out);
83  a_out << " height_angle " << height_angle.value() << std::endl;
84  }

◆ get_lrbt()

virtual void tools::sg::perspective::get_lrbt ( unsigned int  a_ww,
unsigned int  a_wh,
float &  a_l,
float &  a_r,
float &  a_b,
float &  a_t 
)
inlineprotectedvirtual

Implements tools::sg::base_camera.

Definition at line 87 of file perspective.

88  {
89  float aspect = float(a_ww)/float(a_wh);
90  float hh = near_height()*0.5f;
91  a_l = -aspect*hh;
92  a_r = aspect*hh;
93  a_b = -hh;
94  a_t = hh;
95  }

◆ near_height()

virtual float tools::sg::perspective::near_height ( ) const
inlinevirtual

Implements tools::sg::base_camera.

Definition at line 17 of file perspective.

17  {
18  return 2.0f*znear.value()*ftan(height_angle.value()*0.5f);
19  }

◆ node_desc_fields()

virtual const desc_fields& tools::sg::perspective::node_desc_fields ( ) const
inlinevirtual

Reimplemented from tools::sg::base_camera.

Definition at line 30 of file perspective.

30  {
32  static const desc_fields s_v(parent::node_desc_fields(),1, //WARNING : take care of count.
34  );
35  return s_v;
36  }

◆ operator!=()

bool tools::sg::perspective::operator!= ( const perspective a_from) const
inline

Definition at line 77 of file perspective.

77  {
78  return !operator==(a_from);
79  }

◆ operator=()

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

Definition at line 66 of file perspective.

66  {
67  parent::operator=(a_from);
68  height_angle = a_from.height_angle;
69  return *this;
70  }

◆ operator==()

bool tools::sg::perspective::operator== ( const perspective a_from) const
inline

Definition at line 72 of file perspective.

72  {
73  if(!parent::operator==(a_from)) return false;
74  if(height_angle!=a_from.height_angle) return false;
75  return true;
76  }

◆ type()

virtual camera_type tools::sg::perspective::type ( ) const
inlinevirtual

Implements tools::sg::base_camera.

Definition at line 26 of file perspective.

26 {return camera_perspective;}

◆ zoom()

virtual void tools::sg::perspective::zoom ( float  a_fac)
inlinevirtual

Implements tools::sg::base_camera.

Definition at line 20 of file perspective.

20  {
21  //for exa :
22  // a_fac = 0.99f is a zoom in
23  // a_fac = 1.01f is a zoom out
25  }

Member Data Documentation

◆ height_angle

sf<float> tools::sg::perspective::height_angle

Definition at line 28 of file perspective.


The documentation for this class was generated from the following file:
tools::sg::perspective::height_angle
sf< float > height_angle
Definition: perspective:28
tools::fpi
float fpi()
Definition: mathf:11
tools::dump
void dump(std::ostream &a_out, const tools::array< T > &a_array, const std::string &a_title)
Definition: array:519
tools::ftan
float ftan(const float &x)
Definition: mathf:46
tools::sg::perspective::near_height
virtual float near_height() const
Definition: perspective:17
tools::sg::camera_perspective
@ camera_perspective
Definition: enums:169
TOOLS_FIELD_DESC_NODE_CLASS
#define TOOLS_FIELD_DESC_NODE_CLASS(a__class)
Definition: field:68
tools::sg::perspective::operator==
bool operator==(const perspective &a_from) const
Definition: perspective:72
tools::sg::bsf::value
T & value()
Definition: bsf:98
tools::sg::base_camera::znear
sf< float > znear
Definition: base_camera:27
tools::sg::perspective
Definition: perspective:14
TOOLS_ARG_FIELD_DESC
#define TOOLS_ARG_FIELD_DESC(a__field)
Definition: field:71