source: golgotha/src/maxtool/translate.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: 1.9 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 "lisp/li_init.hh"
10#include "m1_info.hh"
11#include "max_object.hh"
12#include "render.hh"
13
14
15class m1_translate_state_class : public m1_utility_state_class
16{
17public:
18  virtual i4_bool mouse_drag()
19  {
20    g1_quad_object_class *obj=m1_info.obj;
21   
22    if (obj)
23    {
24      // get translation
25      i4_3d_vector point,ray;
26      i4_float px,py;
27     
28      px = (i4_float(last_x())-center_x())/(center_x()*scale_x());
29      py = (i4_float(last_y())-center_y())/(center_y()*scale_y());
30      m1_render_window->transform.inverse_transform(i4_3d_vector(px,py,1.0), point);
31     
32      px = (i4_float(mouse_x())-center_x())/(center_x()*scale_x());
33      py = (i4_float(mouse_y())-center_y())/(center_y()*scale_y());
34      m1_render_window->transform.inverse_transform(i4_3d_vector(px,py,1.0), ray);
35      ray -= point;
36     
37      g1_vert_class *src_vert = obj->get_verts(m1_info.current_animation, m1_info.current_frame);
38     
39      for (int i=0; i<obj->num_vertex; i++)
40      {
41        if (i==m1_info.preselect_point)
42          src_vert[i].v += ray;
43      }
44      return i4_T;
45    }
46    return i4_F;
47  }
48
49};
50
51static m1_translate_state_class translate;
52
53li_object *m1_translate(li_object *o, li_environment *env)
54{
55  if (m1_info.obj && m1_info.preselect_point)
56    m1_render_window->set_state(&translate);
57
58  return 0;
59}
60
61li_automatic_add_function(m1_translate, "translate_point");
Note: See TracBrowser for help on using the repository browser.