1 //  ----------------------------------------------------------
2 //
3 //  Copyright (C) 2002 Brad Wasson <bard@systemtoolbox.com>
4 //
5 //  This file is part of 3ddesktop.
6 //
7 //  3ddesktop is free software; you can redistribute it and/or modify it
8 //  under the terms of the GNU General Public License as published by
9 //  the Free Software Foundation; either version 2, or (at your option)
10 //  any later version.
11 //
12 //  3ddesktop is distributed in the hope that it will be useful, but
13 //  WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //  GNU General Public License for more details.
16 //
17 //  You should have received a copy of the GNU General Public License
18 //  along with 3ddesktop; see the file COPYING.   If not, write to
19 //  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 
22 #ifndef _ARRANGE_HPP
23 #define _ARRANGE_HPP
24 
25 #include "3ddesk.h"
26 #include "face.hpp"
27 #include "faceset.hpp"
28 #include "move.hpp" // for Movement
29 #include "xutil.hpp"
30 #include "config.hpp"
31 #include "camera.hpp"
32 
33 
34 // ===================================================================
35 //  Arranagement - abstract base class
36 //    This defines the interface to the derived classes below.  Allows
37 //    a generic pointer to "Arranagement" to be used whose calls to the
38 //    virtual functions are then sent to the derived class.
39 // ===================================================================
40 class Arrangement {
41 protected:
42     //int number_of_faces;
43     int current_face;
44 
45     int n_columns;
46     int n_rows;
47 
48     int current_col;
49     int current_row;
50 
51     Movement::MOVE_TYPE move_type;
52 
53     float face_width;
54     float face_height;
55 
56     Movement oscillation;
57     float oscillation_value;
58 
59     // entry/exist z offset speed
60     float ee_speed_z;
61 
62     Movement z_off_mv;
63 
64     // the current z offset changed by the above movement
65     float z_offset;
66 
67     // this is the z offset that makes the current face match the screen
68     // (all the edges of the quad are aligned with the edges of the
69     // screen) It's calculated dynamically based on the screen dimensions
70     float z_offset_close;
71 
72     // this is the space between the viewer and the face at a distance
73     float z_offset_distance;
74 
75     Config *cfg;
76 
77     FaceSet *face_set;
78 
79     Camera *camera;
80 
81     GLuint face_list;
82 
83     Movement goto_face_mv;
84     float goto_face_val;
85     float per_face_change;
86 
87 public:
88     Arrangement (FaceSet *fs, Config *c);
89     virtual ~Arrangement ();
90 
91     //virtual ~Arrangement() { };
92 
93     virtual int cant_exit_in_goto(void);
94 
95     virtual void goto_right(void);
96     virtual void goto_left(void);
97 
98     virtual void goto_up(void);
99     virtual void goto_down(void);
100     virtual void goto_random_face(void);
101 
102     virtual float goto_face (int face);
103     virtual float goto_face (int col, int row);
104     virtual float goto_face(desktop_coords_t dest);
105     virtual int in_goto (void);
106 
107     // methods that must be implemented by derived classes
108     virtual int get_type(void) = 0;
109     virtual float get_base_z_offset(void) = 0;
110     virtual float get_distant_z_offset(void) = 0;
111     virtual void do_movement(void) = 0;
112     virtual void position_faces(void) = 0;
113     virtual void position_lighting(void);
114     virtual void render();
115     virtual void make_display_list(void);
116     virtual void set_current_face (int col, int row);
117     virtual void calculate_faces (VDesktops & vdesks) = 0;
118 
119     // movement hooks for controling entry and exit movements (zoom
120     // out and zoom in etc)
121     virtual void entry_movement_start(void);
122     virtual void entry_exit_move(void);
123     virtual void exit_movement_start(void);
124     virtual void exit_movement_cancel(void);
125     virtual int is_entry_movement_done(void);
126     virtual int is_exit_movement_done(void);
127 
128     virtual int allow_blending(void);
129 
130     // "locally" defined functions
131     int get_current_column(void);
132     int get_number_of_columns(void);
133     int get_current_row(void);
134     int get_number_of_rows(void);
135     float get_current_z_offset(void);
136     void set_z_offset_distance(float zod);
137     void set_transparency (float t);
138     void set_active (int i);
139 };
140 
141 
142 
143 
144 class CarouselArrangement : public Arrangement {
145 private:
146     Movement x_rot_mv;
147 
148     float side_angle;
149 
150     float x_rot_final;
151     float X_Rot;
152 
153     float radius;
154 
155     //int current_face;
156     int n_faces;
157 
158 public:
159     CarouselArrangement(VDesktops &vdesks, float fw, float fh,
160 			FaceSet *fs, Config *c, Camera *cam);
161 
162     void calculate_faces(VDesktops & vdesks);
163 
164     void goto_random_face(void);
165     void goto_right(void);
166     void goto_left(void);
167 
168     int get_type(void);
169     void set_current_face (int c, int r);
170     float get_base_z_offset(void);
171     float get_distant_z_offset(void);
172     void do_movement(void);
173     void position_faces(void);
174 
175     // Entry/Exit movement functions
176     void entry_movement_start(void);
177     void exit_movement_start(void);
178     void exit_movement_cancel(void);
179     void entry_exit_move(void);
180 };
181 
182 
183 #if !defined (ONE_ARRANAGEMENT_ONLY)
184 
185 class CylinderArrangement : public Arrangement {
186 private:
187     float two_face_gap;
188 
189     float side_angle;
190 
191     Movement x_rot_mv;
192 
193     float X_Rot;
194 
195     float x_rot_final;
196 
197     //int current_face;
198     int n_faces;
199 
200 public:
201     CylinderArrangement(VDesktops &vdesks, float fw, float fh,
202 			FaceSet *fs, Config *c, Camera *cam);
203 
204     void calculate_faces(VDesktops & vdesks);
205 
206     void goto_random_face(void);
207     void goto_right(void);
208     void goto_left(void);
209 
210     int get_type(void);
211     void set_current_face (int c, int r);
212     float get_base_z_offset(void);
213     float get_distant_z_offset(void);
214     void do_movement(void);
215     void position_faces(void);
216 
217     // Entry/Exit movement functions
218     void entry_movement_start(void);
219     void exit_movement_start(void);
220     void exit_movement_cancel(void);
221     void entry_exit_move(void);
222 
223 };
224 
225 
226 class ViewMasterArrangement : public Arrangement {
227 private:
228     //int current_face;
229     int n_faces;
230 
231     float between_angle;
232     float center_distance;
233 
234 public:
235     ViewMasterArrangement(VDesktops &vdesks, float fw, float fh,
236                           FaceSet *fs, Config *c, Camera *cam);
237 
238     void calculate_faces(VDesktops & vdesks);
239 
240     int get_type(void);
241     void goto_random_face(void);
242     void goto_right(void);
243     void goto_left(void);
244 
245     void set_current_face (int c, int r);
246     float get_base_z_offset(void);
247     float get_distant_z_offset(void);
248     void do_movement(void);
249     void position_faces(void);
250     void render();
251 };
252 
253 
254 
255 class PriceIsRightArrangement : public Arrangement {
256 private:
257     //int current_face;
258     int n_faces;
259 
260     float side_angle;
261 
262     float radius;
263 public:
264     PriceIsRightArrangement(VDesktops &vdesks, float fw, float fh,
265                             FaceSet *fs, Config *c, Camera *cam);
266 
267     void calculate_faces(VDesktops & vdesks);
268 
269     int get_type(void);
270     void goto_random_face(void);
271     void goto_right(void);
272     void goto_left(void);
273 
274     void set_current_face (int c, int r);
275     float get_base_z_offset(void);
276     float get_distant_z_offset(void);
277     void do_movement(void);
278     void position_faces(void);
279 };
280 
281 
282 class LinearArrangement : public Arrangement {
283 private:
284     float between;
285 
286     Movement x_trans_mv;
287     float X_Trans;
288 
289     Movement y_trans_mv;
290     float Y_Trans;
291 
292     Movement spin_mv;
293     float spin_z_rot;
294 
295 public:
296     LinearArrangement(VDesktops &vdesks, float fw, float fh,
297                       FaceSet *fs, Config *c, Camera *cam);
298 
299     void calculate_faces(VDesktops & vdesks);
300     int get_type(void);
301     void set_current_face (int col, int row);
302     float get_base_z_offset(void);
303     float get_distant_z_offset(void);
304 
305     void goto_right(void);
306     void goto_left(void);
307     void goto_up(void);
308     void goto_down(void);
309 
310     int in_goto (void);
311 
312     float goto_face(desktop_coords_t dest);
313     void do_movement(void);
314     void position_faces(void);
315     void position_lighting(void);
316     void render();
317 
318     // Entry/Exit movement functions which add spinning on exit
319     void entry_exit_move(void);
320     void exit_movement_start(void);
321     void exit_movement_cancel(void);
322 
323 };
324 
325 
326 class FlipArrangement : public Arrangement {
327 private:
328     Face *face_A;
329     Face *face_B;
330 
331     Face *showing_face;
332 
333     Movement spin_mv;
334     float spin_val;
335 
336     //GLint texture[MAX_FACES];
337 
338     //int current_face;
339     int n_faces;
340 public:
341     FlipArrangement(VDesktops &vdesks, float fw, float fh,
342                     FaceSet *fs, Config *c, Camera *cam);
343 
344     ~FlipArrangement ();
345 
346     int cant_exit_in_goto(void);
347     int in_goto (void);
348 
349     void calculate_faces(VDesktops & vdesks);
350     int get_type(void);
351     void render();
352     void make_display_list(void);
353     void load_texture_data (int i, int texture_size, unsigned char *data);
354     void set_current_face (int c, int r);
355     float get_base_z_offset(void);
356     float get_distant_z_offset(void);
357     void do_movement(void);
358     void position_faces(void);
359 
360     void goto_down(void);
361     void goto_up(void);
362     float goto_face (desktop_coords_t dest);
363     void goto_random_face(void);
364     void goto_right(void);
365     void goto_left(void);
366 
367     int allow_blending(void);
368 
369     // Entry/Exit movement functions
370     void entry_movement_start(void);
371     void exit_movement_start(void);
372     void exit_movement_cancel(void);
373     void entry_exit_move(void);
374     int is_entry_movement_done(void);
375     int is_exit_movement_done(void);
376 };
377 
378 
379 
380 
381 #endif // if !defined (ONE_ARRANAGEMENT_ONLY)
382 
383 #endif // _ARRANAGE_HPP
384