-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathscm-state.hpp
136 lines (104 loc) · 4.48 KB
/
scm-state.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Copyright (C) 2011-2012 Robert Kooima
//
// LIBSCM is free software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 of the License, or (at your option) any later
// version.
//
// This program is distributed in the hope that it will be useful, but WITH-
// OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
#ifndef SCM_STATE_HPP
#define SCM_STATE_HPP
#include <string>
#include <vector>
//------------------------------------------------------------------------------
class scm_scene;
//------------------------------------------------------------------------------
/// An scm_state defines a view configuration
///
/// A view configuration consists of the viewer's position and orientation, the
/// light source's position, and the environment being viewed. This environment
/// might be in a state of transition between two visualizations, so it consists
/// of references to scm_scenes to be applied to the foreground sphere and
/// background sphere at both the beginning and the end of a transition.
class scm_state
{
public:
/// @name Constructors
/// @{
scm_state();
scm_state(const scm_state&);
scm_state(const scm_state&,
const scm_state&, double t);
scm_state(const double *t,
const double *r,
const double *l);
/// @}
/// @name Basic mutators
/// @{
void set_name (const std::string&);
void set_foreground0(scm_scene *);
void set_foreground1(scm_scene *);
void set_background0(scm_scene *);
void set_background1(scm_scene *);
void set_orientation(const double *);
void set_position (const double *);
void set_light (const double *);
void set_distance (double);
void set_zoom (double);
void set_fade (double);
/// @}
/// @name Basic accessors
/// @{
const std::string& get_name() const { return name; }
scm_scene *get_foreground0() const { return foreground0; }
scm_scene *get_foreground1() const { return foreground1; }
scm_scene *get_background0() const { return background0; }
scm_scene *get_background1() const { return background1; }
double get_distance() const { return distance; }
double get_zoom() const { return zoom; }
double get_fade() const { return fade; }
void get_orientation(double *) const;
void get_position (double *) const;
void get_light (double *) const;
bool renderable() const { return foreground0
|| foreground1
|| background0
|| background1; }
/// @}
/// @name Derived methods
/// @{
void get_matrix (double *) const;
void get_up (double *) const;
void get_right (double *) const;
void get_forward(double *) const;
float get_current_ground() const;
float get_minimum_ground() const;
void set_pitch(double);
void set_matrix(const double *);
void transform_orientation(const double *);
void transform_position (const double *);
void transform_light (const double *);
/// @}
friend double operator-(const scm_state&, const scm_state&);
private:
std::string name; ///< State name
scm_scene *foreground0; ///< Starting foreground scene
scm_scene *foreground1; ///< Ending foreground scene
scm_scene *background0; ///< Starting background scene
scm_scene *background1; ///< Ending background scene
double orientation[4]; ///< Viewer orientation
double position[3]; ///< Viewer position vector (normalized)
double light[3]; ///< Light position vector (normalized)
double distance; ///< Viewer point distance
double zoom; ///< Magnification
double fade; ///< Transition progress
};
//------------------------------------------------------------------------------
typedef std::vector<scm_state> scm_state_v;
typedef std::vector<scm_state>::iterator scm_state_i;
typedef std::vector<scm_state>::const_iterator scm_state_c;
//------------------------------------------------------------------------------
#endif