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 "editor/contedit.hh"


10  #include "m_flow.hh"


11  #include "input.hh"


12  #include "g1_speed.hh"


13  #include "objs/stank.hh"


14  #include "g1_render.hh"


15  #include "editor/editor.hh"


16 


17  i4_spline_class::point *g1_controller_edit_class::find_spline_point(sw32 mx, sw32 my,


18  w32 instance)


19  {


20  i4_spline_class *s[MAX_SPLINE_EDIT];


21  int t=get_current_splines(s,MAX_SPLINE_EDIT);


22 


23 


24  r1_vert rv;


25  i4_spline_class::point *first=0, *last=0;


26 


27 


28  for (w32 i=0; i<t; i++)


29  {


30  i4_spline_class::point *c=s[i]>begin();


31  for (;c;c=c>next)


32  {


33  if (g1_render.project_point(i4_3d_point_class(c>x, c>y, c>z),


34  rv,


35  g1_context.transform))


36  {


37  if (abs((sw32)rv.pxmx)<3 && abs((sw32)rv.pymy)<3)


38  {


39  if (instance)


40  instance;


41  else


42  return c;


43  }


44  }


45  }


46  }


47  return 0;


48  }


49 


50 


51  void g1_controller_edit_class::clear_selected_points()


52  {


53  i4_bool change=i4_F;


54 


55  g1_editor_instance.add_undo(G1_MAP_MOVIE);


56 


57  i4_spline_class *s[MAX_SPLINE_EDIT];


58  int t=get_current_splines(s,MAX_SPLINE_EDIT);


59 


60  i4_spline_class::point *c;


61 


62  for (int i=0; i<t; i++)


63  for (c=s[i]>begin(); c; c=c>next)


64  if (c>selected)


65  {


66  c>selected=i4_F;


67  change=i4_T;


68  }


69 


70  if (change)


71  changed();


72  }


73 


74  void g1_controller_edit_class::select_points_in_area(sw32 x1, sw32 y1, sw32 x2, sw32 y2,


75  g1_mode_handler::select_modifier)


76  {


77  /* clear_selected_points();


78 


79  if (!map>current_movie)


80  return ;


81 


82  g1_movie_flow_class *flow=map>current_movie;


83 


84  sw32 dx1,dy1,dx2,dy2;


85  drag_area(dx1,dy1,dx2,dy2);


86  i4_bool change=i4_F;


87 


88  float x,y;


89  i4_spline_class::point *first=0, *last=0;


90 


91 


92  if (flow && flow>current())


93  {


94  for (w32 i=0; i<2; i++)


95  {


96  i4_spline_class::point *c;


97  if (i==0)


98  c=flow>current()>camera.begin();


99  else


100  c=flow>current()>target.begin();


101 


102  for (;c;c=c>next)


103  {


104  if (project_point(i4_3d_point_class(c>x, c>y, c>z),


105  x,y,


106  &g1_context))


107  {


108  if (x>=dx1 && y>=dy1 && x<=dx2 && y<=dy2)


109  {


110  if (!c>selected)


111  {


112  c>selected=i4_T;


113  change=i4_T;


114  }


115  }


116  }


117  }


118  }


119  }


120 


121  if (change)


122  {


123  refresh();


124  changed();


125  }*/


126  }


127 


128 


129  void g1_controller_edit_class::add_movie_control_point(int list_number)


130  {


131  g1_editor_instance.add_undo(G1_MAP_MOVIE);


132 


133  i4_spline_class *s[MAX_SPLINE_EDIT];


134  w32 list_number_2;


135  int t=get_current_splines(s,MAX_SPLINE_EDIT);


136 


137  i4_float h=0;


138  if (list_number == g1_cut_scene_class::CAMERA)


139  h=2;


140  else if (list_number == g1_cut_scene_class::TARGET)


141  h=0.2;


142 


143  if (list_number<t)


144  {


145  i4_float gx,gy, dx,dy;


146  if (!view_to_game(last_mouse_x, last_mouse_y, gx,gy, dx,dy))


147  return;


148 


149  h+=get_map()>terrain_height(gx, gy);


150 


151  #if 0 //movie hack that no longer works


152  if (g1_input.button_1() && list_number==g1_cut_scene_class::CAMERA)


153  {


154 


155  list_number_2 = g1_cut_scene_class::TARGET;


156 


157  g1_player_piece_class *p;


158  p=(g1_player_piece_class *)get_map()>find_object_by_id(g1_supertank_type,


159  g1_default_player);


160  gx = p>x;


161  gy = p>y;


162  h = p>h;


163 


164  i4_3d_point_class view_dir,view_adj;


165 


166  i4_transform_class tank_trans,tmp;


167  tank_trans.identity();


168 


169  p>cam_pitch = p>groundpitch;//*sin(p>base_angle) + p>groundroll*cos(p>base_angle);


170  p>cam_roll = p>groundroll;// *sin(p>base_angle)  p>groundpitch*cos(p>base_angle);


171 


172  tmp.rotate_z((p>base_angle));


173  tank_trans.multiply(tmp);


174 


175  tmp.rotate_y((p>cam_pitch));


176  tank_trans.multiply(tmp);


177 


178  tmp.rotate_x((p>cam_roll));


179  tank_trans.multiply(tmp);


180 


181  tank_trans.transform(i4_3d_point_class(1,0,0),view_dir);


182  tank_trans.transform(i4_3d_point_class(0.25,0.023,0.15),view_adj);


183 


184  gx += view_adj.x;


185  gy += view_adj.y;


186  h += view_adj.z;


187 


188  view_dir.x += gx;


189  view_dir.y += gy;


190  view_dir.z += h;


191 


192  if (s[list_number_2]>total())


193  {


194  w32 last_time=s[list_number_2]>get_control_point(s[list_number_2]>total()1)>frame;


195  s[list_number_2]>add_control_point(view_dir.x, view_dir.y, view_dir.z, last_time + G1_MOVIE_HZ);


196  }


197  else


198  s[list_number_2]>add_control_point(view_dir.x, view_dir.y, view_dir.z, 0);


199  }


200  #endif


201 


202  if (s[list_number]>total())


203  {


204  w32 last_time=s[list_number]>get_control_point(s[list_number]>total()1)>frame;


205  s[list_number]>add_control_point(gx, gy, h, last_time + G1_MOVIE_HZ);


206  }


207  else


208  s[list_number]>add_control_point(gx, gy, h, 0);


209 


210  refresh();


211  changed();


212  }


213  }


214 


215  void g1_controller_edit_class::delete_selected_points()


216  {


217  g1_editor_instance.add_undo(G1_MAP_MOVIE);


218 


219  i4_spline_class *s[MAX_SPLINE_EDIT];


220  int t=get_current_splines(s,MAX_SPLINE_EDIT);


221  for (int i=0; i<t; i++)


222  s[i]>delete_selected();


223 


224  refresh();


225  changed();


226  }


227 


228  void g1_controller_edit_class::insert_control_points()


229  {


230  g1_editor_instance.add_undo(G1_MAP_MOVIE);


231 


232  i4_spline_class *s[MAX_SPLINE_EDIT];


233  int t=get_current_splines(s,MAX_SPLINE_EDIT);


234 


235  for (int i=0; i<t; i++)


236  s[i]>insert_control_points();


237 


238  refresh();


239  changed();


240  }


241 


242  void g1_controller_edit_class::move_selected_points(i4_float xa, i4_float ya, i4_float za)


243  {


244  g1_editor_instance.add_undo(G1_MAP_MOVIE);


245 


246  i4_spline_class *s[MAX_SPLINE_EDIT];


247  int t=get_current_splines(s,MAX_SPLINE_EDIT);


248 


249  for (int i=0; i<t; i++)


250  {


251  i4_spline_class::point *c=s[i]>begin();


252 


253  for (;c;c=c>next)


254  {


255  if (c>selected)


256  {


257  c>x+=xa;


258  c>y+=ya;


259  c>z+=za;


260  }


261  }


262 


263  changed();


264  refresh();


265  }


266  }


267 


268 


269 


270 

