source: golgotha/src/golg/overhead.cc @ 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: 5.3 KB
RevLine 
[80]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#include "controller.hh"
10#include "map_cell.hh"
11#include "resources.hh"
12#include "math/pi.hh"
13#include "sound_man.hh"
14#include "map.hh"
15#include "poly/poly.hh"
16#include "objs/stank.hh"
17#include "g1_render.hh"
18#include "time/profile.hh"
19#include "sky.hh"
20#include "r1_clip.hh"
21#include "g1_tint.hh"
22
23static i4_profile_class pf_draw_overhead("draw_overhead");
24
25void g1_object_controller_class::draw_overhead(g1_draw_context_class *context)
26{
27  w32 i;
28  pf_draw_overhead.start();
29
30#if 0
31  i4_polygon_class vp;
32
33  g1_camera_info_struct *camera=view.get_camera();
34 
35  if (view.get_view_mode()==G1_ACTION_MODE)
36  { 
37    i4_float a=i4_pi()/3.9,vd=g1_resources.visual_radius(),vb=3;
38 
39    i4_float cos_gma=cos(camera->ground_rotate-a),
40      sin_gma=sin(camera->ground_rotate-a),
41      cos_gpa=cos(camera->ground_rotate+a),
42      sin_gpa=sin(camera->ground_rotate+a);
43
44    vp.vert[0].v = i4_3d_point_class(camera->gx - cos_gma*vb, camera->gy - sin_gma*vb, 0);
45    vp.vert[1].v = i4_3d_point_class(camera->gx + cos_gpa*vd, camera->gy + sin_gpa*vd, 0);
46    vp.vert[2].v = i4_3d_point_class(camera->gx + cos_gma*vd, camera->gy + sin_gma*vd, 0);
47    vp.vert[3].v = i4_3d_point_class(camera->gx - cos_gpa*vb, camera->gy - sin_gpa*vb, 0);   
48
49    i4_float c0x,c0y,c1x,c1y,c2x,c2y,c3x,c3y,c4x,c4y;
50
51    c0x=camera->gx - cos_gma*vb; 
52    c0y=camera->gy - sin_gma*vb;
53
54    c1x=camera->gx + cos_gpa*vd;
55    c1y=camera->gy + sin_gpa*vd;
56
57    c2x=camera->gx + cos_gma*vd;
58    c2y=camera->gy + sin_gma*vd;
59
60    c3x=camera->gx - cos_gpa*vb; 
61    c3y=camera->gy - sin_gpa*vb;
62
63    vp.vert[0].v = i4_3d_point_class(c0x, c0y, 0);
64    vp.vert[1].v = i4_3d_point_class(c1x, c1y, 0);
65    vp.vert[2].v = i4_3d_point_class(c2x, c2y, 0);
66    vp.vert[3].v = i4_3d_point_class(c3x, c3y, 0);
67  }   
68  else
69  {       
70    sw32 top=-40,left=-40,bot=height()+40,right=width()+40;
71    i4_float dx1,dy1, dx2,dy2;
72    i4_3d_vector v0,v1,v2,v3, v3_1, v2_0;
73
74    if (!view_to_game(right, bot, v2.x, v2.y, dx1,dy1))
75      v2.set(camera->gx, camera->gy, 0);
76    v2.z=0;
77
78    if (!view_to_game(left,  bot, v3.x, v3.y, dx2,dy2))
79      v2.set(camera->gx, camera->gy, 0);
80    v3.z=0;
81
82    if (!view_to_game(left,  top, v0.x, v0.y, dx1,dy1) ||
83        view.get_view_mode()!=G1_STRATEGY_MODE)
84      v0.set(v3.x+dx1*g1_resources.visual_radius(), v3.y+dy1*g1_resources.visual_radius(), 0);
85    v0.z=0;
86
87    if (!view_to_game(right, top, v1.x, v1.y, dx2,dy2) ||
88        view.get_view_mode()!=G1_STRATEGY_MODE)
89      v1.set(v2.x+dx2*g1_resources.visual_radius(), v2.y+dy2*g1_resources.visual_radius(), 0);
90    else
91    {
92     
93    }
94
95    v1.z=0;
96
97    v3_1=i4_3d_vector(v1.x - v3.x, v1.y - v3.y,  0);  v3_1.normalize();
98    v2_0=i4_3d_vector(v0.x - v2.x, v0.y - v2.y, 0);   v2_0.normalize();
99
100    if ((v3_1.x==0 &&  v3_1.y==0 && v3_1.z==0) ||
101        (v2_0.x==0 &&  v2_0.y==0 && v2_0.z==0))
102    {
103      //i4_warning("uh oh....\n"); i hate this fucking warning -Trey
104      return ;
105    }
106   
107    // move these back
108    v2.x -= v2_0.x *1.5;   v2.y -= v2_0.y * 2.0;
109    v3.x -= v3_1.x *1.5;   v3.y -= v3_1.y * 2.0;
110     
111
112    // move these forward
113    v0.x += v2_0.x * 1.5;   v0.y += v2_0.y * 2.0;
114    v1.x += v3_1.x * 1.5;   v1.y += v3_1.y * 2.0;
115
116
117    vp.vert[0].v = v0;
118    vp.vert[1].v = v1;
119    vp.vert[2].v = v2;
120    vp.vert[3].v = v3; 
121
122  }
123
124  vp.t_verts=4; 
125
126  g1_visible_cell cell_list[3000];
127 
128  float xscale = g1_render.scale_x;
129  float yscale = g1_render.scale_y;
130
131  int t_vis=get_map()->calc_visible(*context->transform, &vp, cell_list, 3000, xscale, yscale);
132 
133//   if (get_track())
134//   {
135//     sw32 x,y,sx,ex,sy,ey;
136//     sx = i4_f_to_i(get_track()->x)-5; ex = sx + 10;
137//     sy = i4_f_to_i(get_track()->y)-5; ey = sy + 10;
138
139//     for (x=sx; x<ex; x++)
140//     for (y=sy; y<ey; y++)
141//     {
142//       if (x<0 || y<0 || x>=map->width() || y>=map->height()) continue;
143
144//       map->cell(x,y)->flags |= g1_map_cell_class::VISIBLE;
145//     }
146//   }
147 
148  r1_far_clip_z=1000;
149  if (view.get_view_mode()!=G1_STRATEGY_MODE)
150    g1_draw_sky(this, *camera,  transform, context);
151
152  if (view.get_view_mode()==G1_ACTION_MODE ||
153      view.get_view_mode()==G1_FOLLOW_MODE ||
154      view.get_view_mode()==G1_WATCH_MODE)
155    r1_far_clip_z=(float)(g1_resources.visual_radius() * 0.707106 - 2.0);
156
157                               
158  get_map()->fast_draw_cells(context, cell_list, t_vis);
159#endif
160  r1_far_clip_z=250.0;
161  g1_camera_info_struct *camera=view.get_camera();
162
163  if (g1_hurt_tint>0)
164    g1_render.r_api->set_color_tint(g1_hurt_tint_handles[g1_hurt_tint]);
165
166  if (view.get_view_mode()!=G1_STRATEGY_MODE)
167    g1_draw_sky(this, *camera,  transform, context);
168
169  get_map()->calc_map_lod(this);
170  get_map()->fast_draw_cells(context);
171
172  if (view.get_view_mode()!=G1_STRATEGY_MODE)
173    g1_render.r_api->set_color_tint(0);
174
175  pf_draw_overhead.stop();
176}
177
Note: See TracBrowser for help on using the repository browser.