-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.hh
More file actions
68 lines (64 loc) · 1.9 KB
/
view.hh
File metadata and controls
68 lines (64 loc) · 1.9 KB
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
#ifndef _VIEW_HH
#define _VIEW_HH
#include "scene.hh"
#include "frame_buffer.hh"
class view: public model, public FrameBuffer
{
public:
view();
// preload with a new model generated from the named file
view(const char *filename);
~view();
// get pointers to internal objects
scene *get_scene() const;
// perspective functions
void ortho(); // use orthogonal projection
void perspective(); // use perspective projection
int toggle_perspective(); // toggle projection type and return new type
int refresh(); // refresh projection and return type
// snap to world or object origin
int snap();
// adjust width or depth of image plane
void inc_width();
void dec_width();
void inc_depth();
void dec_depth();
// adjust depth of near and far planes
void move_near_plane(double delta);
void move_far_plane(double delta);
// select object at specific point
void select(int x, int y);
void render_from_buffer();
protected:
scene *scn;
int bf; // bitfield used to store boolean variables
double width, depth; // radius of the image plane and distance from camera
double near, far; // near and far viewing planes
// propagate state changes of axes
void on_set_axes();
void on_unset_axes();
void on_set_box();
void on_unset_box();
// render the scene
virtual void do_render();
void fill_buffer();
// calculate ray from pixel coordinates
void cast_ray(double x, double y, point &orig, point &dir);
};
class orbital_view : public view
{
public:
orbital_view();
orbital_view(const char *filename);
// manipulate the view
void rotate(double dphi, double dtheta); // rotate around the origin
void zoom(double dr); // move toward or away from the object
protected:
double r; // radial coordinate
double theta; // polar angle
double phi; // azimuthal angle
static const double rate = 3.1415927 / 40;
// render the scene
void do_render();
};
#endif /* _VIEW_HH */