1 /* Copyright (C) 1992-1998 The Geometry Center
2  * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips
3  *
4  * This file is part of Geomview.
5  *
6  * Geomview is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published
8  * by the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * Geomview is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with Geomview; see the file COPYING.  If not, write
18  * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
19  * USA, or visit http://www.gnu.org.
20  */
21 
22 #ifndef _GV_COMMON_TRANSFORM_H_
23 #define _GV_COMMON_TRANSFORM_H_
24 
25 #include "lang.h"
26 #include "drawer.h"
27 
28 typedef struct Motion {
29   int moving_id;
30   int center_id;
31   int frame_id;
32   void (*transform)();
33   float amount[3];
34   float timeunit;
35   float timeleft;	/* Nonzero if bounded animation */
36   int smooth;		/* Smooth animation, else linear */
37   struct Motion *next;
38 } Motion;
39 
40 int drawer_transform(int moving_id, int center_id, int frame_id,
41 		     Keyword transform_type,
42 		     float fx, float fy, float fz,
43 		     float timeunit,
44 		     char *repeat_type,
45 		     Keyword smoothanim);
46 
47 void drawer_position(int moving_id, int ref_id, char *position_type,
48 		     char *center);
49 void drawer_zoom(int id, float amount);
50 void drawer_scale(int id, float amount);
51 void set_motion(Motion *motion);
52 void apply_motion(Motion *motion, float dt);
53 
54 void insert_motion(Motion *motion);
55 void apply_all_motions(float dt);
56 void do_motion(float dt);
57 void delete_motion(Motion *m);
58 void delete_like_motions(Motion *m, float augmentby);
59 void drawer_post_xform(int id, Transform T);
60 
61 int e3space(void *data);
62 int h3space(void *data);
63 
64 void stop_motions(int id);
65 int motions_exist();
66 int real_id(int id);
67 
68 void make_center(char *objname, Point3 *pt);
69 void make_center_from_bbox(char *objname, int obj_id);
70 void make_center_from_pick(char *objname, Pick *pick, int focalcam);
71 
72 void drawer_set_ND_xform(int id, TransformN *T);
73 int real_id(int id);
74 
75 /* Get a geom's transform to its parent */
76 static inline TransformN *
get_geom_ND_transform(DGeom * dg)77 get_geom_ND_transform(DGeom *dg)
78 {
79   if (dg->NDT == NULL && drawerstate.NDim > 0) {
80     dg->NDT = TmNIdentity(TmNCreate(drawerstate.NDim, drawerstate.NDim, NULL));
81     GeomSet(dg->Item, CR_NDAXIS, dg->NDT, CR_END);
82     dg->bboxvalid = false; /* invalidate bounding box */
83   } else if (drawerstate.NDim == 0) {
84     TmNDelete(dg->NDT);
85     dg->NDT = NULL;
86   }
87   return REFGET(TransformN, dg->NDT);
88 }
89 
90 #endif /* _GV_COMMON_TRANSFORM_H_ */
91