1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #ifndef G1_CAMERA_HH
|
---|
10 | #define G1_CAMERA_HH
|
---|
11 |
|
---|
12 | #include "math/num_type.hh"
|
---|
13 | #include "math/vector.hh"
|
---|
14 | #include "reference.hh"
|
---|
15 | #include "g1_object.hh"
|
---|
16 |
|
---|
17 | class g1_loader_class; // golg/saver.hh
|
---|
18 | class g1_saver_class; // golg/saver.hh
|
---|
19 | class i4_transform_class; // i4/math/transform.hh
|
---|
20 | class g1_object_class; // golg/g1_object.hh
|
---|
21 |
|
---|
22 | enum g1_view_mode_type
|
---|
23 | {
|
---|
24 | G1_EDIT_MODE, // camera is set exactly by someone without outside influence
|
---|
25 | G1_STRATEGY_MODE, // camera looks down from fixed hieght above ground
|
---|
26 | G1_ACTION_MODE, // camera follow objects from 1st person
|
---|
27 | G1_FOLLOW_MODE, // camera follows objects from 3rd person
|
---|
28 | G1_CAMERA_MODE, // camera follows spline set down by the editor
|
---|
29 | G1_WATCH_MODE, // camera wanders around looking at interesting things
|
---|
30 | G1_CIRCLE_WAIT // camera is circling an object/location until the user presses a key
|
---|
31 | };
|
---|
32 |
|
---|
33 | enum g1_watch_type // priorities for the camera
|
---|
34 | {
|
---|
35 | G1_WATCH_INVALID, // indicates camera event is not in use
|
---|
36 | G1_WATCH_IDLE, // lowest priority, vehicles moving
|
---|
37 | G1_WATCH_EVENT, // heli take off, bridge assembly, etc.
|
---|
38 | G1_WATCH_FIRE, // shots fired
|
---|
39 | G1_WATCH_HIT, // someone got hit
|
---|
40 | G1_WATCH_EXPLOSION, // someone blew up
|
---|
41 | G1_WATCH_USER, // user wants top look here
|
---|
42 | G1_WATCH_FORCE // force the camera here (base blown up)
|
---|
43 | };
|
---|
44 |
|
---|
45 |
|
---|
46 |
|
---|
47 | struct g1_camera_info_struct
|
---|
48 | {
|
---|
49 | i4_float gx, gy, gz;
|
---|
50 | i4_float ground_x_rotate, ground_y_rotate;
|
---|
51 | i4_float ground_rotate, // rotation about game z
|
---|
52 | horizon_rotate, // rotation up/down
|
---|
53 | roll;
|
---|
54 |
|
---|
55 | void defaults();
|
---|
56 | g1_camera_info_struct() { defaults(); }
|
---|
57 | void load(g1_loader_class *fp);
|
---|
58 | void save(g1_saver_class *fp);
|
---|
59 |
|
---|
60 | };
|
---|
61 |
|
---|
62 | struct g1_camera_event
|
---|
63 | {
|
---|
64 | g1_typed_reference_class<g1_object_class> camera_at;
|
---|
65 | g1_watch_type type; // type of camera shot this is
|
---|
66 | // object we are sort of tracking (0 if not tracking)
|
---|
67 | g1_typed_reference_class<g1_object_class> follow_object;
|
---|
68 | int min_time, max_time; // min/max times to sustain camera shot (in ticks)
|
---|
69 | int time_elapsed; // time that we've spent on this shot already (in ticks)
|
---|
70 |
|
---|
71 | g1_camera_event();
|
---|
72 | void object_ids_changed(); // call after level is reloaded
|
---|
73 | };
|
---|
74 |
|
---|
75 |
|
---|
76 | struct g1_view_state_class
|
---|
77 | {
|
---|
78 | enum { DATA_VERSION=1 };
|
---|
79 |
|
---|
80 | i4_3d_vector move_offset; // next time the camera updates it will move this distance (not z)
|
---|
81 |
|
---|
82 | struct circle_info
|
---|
83 | {
|
---|
84 | float zvel,
|
---|
85 | theta, theta_vel,
|
---|
86 | dist, dist_vel;
|
---|
87 |
|
---|
88 | i4_3d_vector looking_at;
|
---|
89 | } circle;
|
---|
90 |
|
---|
91 |
|
---|
92 | g1_typed_reference_class<g1_object_class> camera1, camera2;
|
---|
93 |
|
---|
94 | g1_camera_event next_cam, current_cam;
|
---|
95 |
|
---|
96 |
|
---|
97 |
|
---|
98 |
|
---|
99 | w32 follow_object_id;
|
---|
100 | w32 ticks_to_watch_spot;
|
---|
101 |
|
---|
102 | g1_view_mode_type view_mode;
|
---|
103 | g1_watch_type watch_type;
|
---|
104 |
|
---|
105 | g1_camera_info_struct start, // when the camera is zooming from one location to another
|
---|
106 | end;
|
---|
107 |
|
---|
108 | // where is the camera between start and end? 1.0 = end, 0.0 = start
|
---|
109 | float start_end_interpolate_fraction;
|
---|
110 |
|
---|
111 | // how much is added to the above fraction in each tick, calculated by how many ticks
|
---|
112 | // you want the camera to take to get to it's destination
|
---|
113 | float start_end_interpolate_fraction_step;
|
---|
114 |
|
---|
115 | // do not set this directly, it is calculated from start and end
|
---|
116 | g1_camera_info_struct current;
|
---|
117 |
|
---|
118 |
|
---|
119 | i4_bool start_invalid; // when the game first starts, the start camera is invalid
|
---|
120 |
|
---|
121 |
|
---|
122 | void defaults();
|
---|
123 |
|
---|
124 | void update_circle_mode();
|
---|
125 | void update_follow_mode();
|
---|
126 | void update_action_mode();
|
---|
127 | void update_watch_mode();
|
---|
128 | void update_camera_mode();
|
---|
129 | void update_strategy_mode();
|
---|
130 | void update_edit_mode();
|
---|
131 | void use_next_cam();
|
---|
132 | public:
|
---|
133 | i4_transform_class *get_transform();
|
---|
134 | void get_camera_pos(i4_3d_vector &v);
|
---|
135 | // returns the sqaured distance to the camera
|
---|
136 | float dist_sqrd(const i4_3d_vector &v);
|
---|
137 |
|
---|
138 | void load(g1_loader_class *fp);
|
---|
139 | void save(g1_saver_class *fp);
|
---|
140 |
|
---|
141 | g1_view_state_class();
|
---|
142 | g1_camera_info_struct *get_camera(); // calculates current and returns a pointer to it
|
---|
143 | void update(); // should be called after every tick, updates end camera pos
|
---|
144 |
|
---|
145 | g1_view_mode_type get_view_mode() { return view_mode; }
|
---|
146 | void set_view_mode(g1_view_mode_type mode) { view_mode=mode; }
|
---|
147 |
|
---|
148 | void calc_transform(i4_transform_class &t);
|
---|
149 |
|
---|
150 | void suggest_camera_mode(g1_view_mode_type mode,
|
---|
151 | w32 follow_object_global_id=0);
|
---|
152 |
|
---|
153 | // called by radar map
|
---|
154 | void set_camera_position(float game_x, float game_y);
|
---|
155 |
|
---|
156 | void suggest_camera_event(g1_camera_event &event);
|
---|
157 |
|
---|
158 | void rotate(i4_float about_game_z, i4_float up_down);
|
---|
159 | void pan(i4_float x, i4_float y, i4_float z);
|
---|
160 | void zoom(float dist);
|
---|
161 | };
|
---|
162 |
|
---|
163 | g1_view_state_class *g1_current_view_state();
|
---|
164 |
|
---|
165 | #endif
|
---|
166 |
|
---|
167 |
|
---|
168 |
|
---|
169 |
|
---|
170 |
|
---|
171 |
|
---|
172 |
|
---|