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 |
|
---|
15 | class m1_translate_state_class : public m1_utility_state_class
|
---|
16 | {
|
---|
17 | public:
|
---|
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 |
|
---|
51 | static m1_translate_state_class translate;
|
---|
52 |
|
---|
53 | li_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 |
|
---|
61 | li_automatic_add_function(m1_translate, "translate_point");
|
---|