source: golgotha/src/maxtool/render.hh @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 4.8 KB
Line 
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 __M1_RENDER_HH_
10#define __M1_RENDER_HH_
11
12#include "time/time.hh"
13#include "window/window.hh"
14#include "window/wmanager.hh"
15#include "math/transform.hh"
16#include "math/point.hh"
17#include "obj3d.hh"
18#include "r1_api.hh"
19#include "light.hh"
20#include "max_object.hh"
21#include "player_type.hh"
22#include "m1_info.hh"
23
24class m1_utility_state_class;
25
26class m1_utility_window_class : public i4_parent_window_class
27{                                           
28private:
29  int grab;
30  int last_x, last_y, last_but;
31
32  i4_float center_x, center_y, scale_x, scale_y;
33  void calc_params()
34  //{{{
35  {
36    int win_w=width(), win_h=height();
37    w32 max_dim=win_w > win_h ? win_w : win_h;
38
39    center_x=(i4_float)win_w/2.0;
40    center_y=(i4_float)win_h/2.0;
41
42    scale_x = (float)max_dim/win_w;
43    scale_y = (float)max_dim/win_h;
44  }
45  //}}}
46
47  friend m1_utility_state_class;
48  m1_utility_state_class *state;
49
50  i4_bool animating;
51
52  i4_time_class last_time;
53
54  m1_poly_object_class *get_obj() { return m1_info.obj; }
55
56  w32 draws_needed;
57
58  i4_float focal_length() { return 300; }
59
60  i4_window_manager_class *wm;
61  r1_render_api_class *api;
62
63  void drop_files(int t_files, i4_str **filenames);
64public:
65
66  enum
67  // Grab Masks for input
68  {
69    LEFT_BUTTON   = 1,
70    RIGHT_BUTTON  = 2,
71    MIDDLE_BUTTON = 4,
72    LEFT_KEY      = 8,
73    RIGHT_KEY     = 16,
74    MIDDLE_KEY    = 32,
75    LEFT   = LEFT_BUTTON | LEFT_KEY,
76    RIGHT  = RIGHT_BUTTON | RIGHT_KEY,
77    MIDDLE = MIDDLE_BUTTON | MIDDLE_KEY,
78  };
79
80  w32 background_color;
81  i4_angle theta,phi;
82  i4_float dist, pan_x, pan_y, pan_z;
83  g1_player_type current_player;
84  i4_transform_class transform;
85
86
87  char *name() { return "m1_utility_window_class"; }
88
89  m1_utility_window_class(w16 window_width,
90                          w16 window_height,
91                          r1_render_api_class *api,
92                          i4_window_manager_class *wm,
93                          i4_float theta,
94                          i4_float phi,
95                          i4_float dist);
96
97  void init();
98  void recenter();
99  void recalc_view();
100
101  i4_bool is_animating() const { return animating; }
102  void set_animation(i4_bool on) { last_time.get(); animating = on; request_redraw(); }
103
104  void get_configuration(i4_float &_theta,
105                         i4_float &_phi,
106                         i4_float &_dist)
107  //{{{
108  {
109    _theta=theta;
110    _phi=phi;
111    _dist=dist;
112  }
113  //}}}
114
115  virtual void receive_event(i4_event *ev);
116
117  i4_bool project_point(const i4_3d_point_class &p, r1_vert &v);
118  void draw_3d_text(i4_3d_point_class p1, const i4_const_str &text,
119                    w32 color,
120                    i4_draw_context_class &context);
121  void draw_3d_line(i4_3d_point_class p1,i4_3d_point_class p2,i4_color color, i4_bool on_top=i4_F);
122  void draw_3d_point(i4_3d_point_class p, i4_color color, i4_bool on_top=i4_F);
123  void draw_plane(const i4_3d_vector &u, const i4_3d_vector &v, w8 color);
124  void update_object(i4_float time);
125  void render_object(i4_draw_context_class &context);
126
127  virtual void parent_draw(i4_draw_context_class &context);
128 
129  void set_current_player(g1_player_type player) { current_player=player; }
130
131  void pan(i4_float x, i4_float y);
132
133  void set_object(const i4_const_str &filename);
134  void select_poly(int poly_num);
135
136  i4_bool find_hit(int mouse_x, int mouse_y);
137  void xlate_selected(int fromx, int fromy, int tox, int toy);
138
139  void set_state(m1_utility_state_class *_state)
140  //{{{
141  {
142    state = _state;
143  }
144  //}}}
145
146  void restore_state();
147};
148
149class m1_utility_state_class
150{
151public:
152  i4_float center_x() const;
153  i4_float center_y() const;
154  i4_float scale_x() const;
155  i4_float scale_y() const;
156
157  int width() const;
158  int height() const;
159
160  int mouse_x() const;
161  int mouse_y() const;
162  int buttons() const;
163
164  int last_x() const;
165  int last_y() const;
166
167  virtual i4_bool mouse_down() { return i4_F; }
168  virtual i4_bool mouse_drag() { return i4_F; }
169  virtual i4_bool mouse_up()   { return i4_F; }
170};
171
172extern i4_event_handler_reference_class<m1_utility_window_class> m1_render_window;
173
174inline w32 m1_texture_memory_size() { return 2048*1024; }
175
176#endif
177
178//{{{ Emacs Locals
179// Local Variables:
180// folded-file: t
181// End:
182//}}}
Note: See TracBrowser for help on using the repository browser.