BRL-CAD
anim.h
Go to the documentation of this file.
1/* A N I M . H
2 * BRL-CAD
3 *
4 * Copyright (c) 1993-2023 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library 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 this file; see the file named COPYING for more
18 * information.
19 */
20/** @file rt/anim.h
21 *
22 */
23
24#ifndef RT_ANIM_H
25#define RT_ANIM_H
26
27#include "common.h"
28
29/* system headers */
30#include <stdio.h> /* for FILE */
31
32/* interface headers */
33#include "vmath.h"
34#include "bu/vls.h"
35#include "bu/file.h"
36#include "rt/defines.h"
37#include "rt/mater.h"
38#include "rt/db_fullpath.h"
39
40__BEGIN_DECLS
41
42struct db_i; /* forward declaration */
43
44/**
45 * Each one of these structures specifies an arc in the tree that is
46 * to be operated on for animation purposes. More than one animation
47 * operation may be applied at any given arc. The directory structure
48 * points to a linked list of animate structures (built by
49 * rt_anim_add()), and the operations are processed in the order
50 * given.
51 */
52struct anim_mat {
53 int anm_op; /**< @brief ANM_RSTACK, ANM_RARC... */
54 mat_t anm_mat; /**< @brief Matrix */
55};
56#define ANM_RSTACK 1 /**< @brief Replace stacked matrix */
57#define ANM_RARC 2 /**< @brief Replace arc matrix */
58#define ANM_LMUL 3 /**< @brief Left (root side) mul */
59#define ANM_RMUL 4 /**< @brief Right (leaf side) mul */
60#define ANM_RBOTH 5 /**< @brief Replace stack, arc=Idn */
61
63 uint32_t magic;
64 int anp_op; /**< @brief RT_ANP_REPLACE, etc. */
65 struct bu_vls anp_shader; /**< @brief Update string */
66};
67#define RT_ANP_REPLACE 1 /**< @brief Replace shader string */
68#define RT_ANP_APPEND 2 /**< @brief Append to shader string */
69#define RT_CK_ANP(_p) BU_CKMAG((_p), RT_ANP_MAGIC, "rt_anim_property")
70
72 int anc_rgb[3]; /**< @brief New color */
73};
74
75
76struct animate {
77 uint32_t magic; /**< @brief magic number */
78 struct animate * an_forw; /**< @brief forward link */
79 struct db_full_path an_path; /**< @brief (sub)-path pattern */
80 int an_type; /**< @brief AN_MATRIX, AN_COLOR... */
85 float anu_t;
87};
88#define RT_AN_MATRIX 1 /**< @brief Matrix animation */
89#define RT_AN_MATERIAL 2 /**< @brief Material property anim */
90#define RT_AN_COLOR 3 /**< @brief Material color anim */
91#define RT_AN_SOLID 4 /**< @brief Solid parameter anim */
92#define RT_AN_TEMPERATURE 5 /**< @brief Region temperature */
93
94#define ANIM_NULL ((struct animate *)0)
95#define RT_CK_ANIMATE(_p) BU_CKMAG((_p), ANIMATE_MAGIC, "animate")
96
97__END_DECLS
98
99/* db_anim.c */
100RT_EXPORT extern struct animate *db_parse_1anim(struct db_i *dbip,
101 int argc,
102 const char **argv);
103
104
105/**
106 * A common parser for mged and rt. Experimental. Not the best name
107 * for this.
108 */
109RT_EXPORT extern int db_parse_anim(struct db_i *dbip,
110 int argc,
111 const char **argv);
112
113/**
114 * Add a user-supplied animate structure to the end of the chain of
115 * such structures hanging from the directory structure of the last
116 * node of the path specifier. When 'root' is non-zero, this matrix
117 * is located at the root of the tree itself, rather than an arc, and
118 * is stored differently.
119 *
120 * In the future, might want to check to make sure that callers
121 * directory references are in the right database (dbip).
122 */
123RT_EXPORT extern int db_add_anim(struct db_i *dbip,
124 struct animate *anp,
125 int root);
126
127/**
128 * Perform the one animation operation. Leave results in form that
129 * additional operations can be cascaded.
130 *
131 * Note that 'materp' may be a null pointer, signifying that the
132 * region has already been finalized above this point in the tree.
133 */
134RT_EXPORT extern int db_do_anim(struct animate *anp,
135 mat_t stack,
136 mat_t arc,
137 struct mater_info *materp);
138
139/**
140 * Release chain of animation structures
141 *
142 * An unfortunate choice of name.
143 */
144RT_EXPORT extern void db_free_anim(struct db_i *dbip);
145
146/**
147 * Writes 'count' bytes into at file offset 'offset' from buffer at
148 * 'addr'. A wrapper for the UNIX write() sys-call that takes into
149 * account syscall semaphores, stdio-only machines, and in-memory
150 * buffering.
151 *
152 * Returns -
153 * 0 OK
154 * -1 FAILURE
155 */
156/* should be HIDDEN */
157RT_EXPORT extern void db_write_anim(FILE *fop,
158 struct animate *anp);
159
160/**
161 * Parse one "anim" type command into an "animate" structure.
162 *
163 * argv[1] must be the "a/b" path spec,
164 * argv[2] indicates what is to be animated on that arc.
165 */
166RT_EXPORT extern struct animate *db_parse_1anim(struct db_i *dbip,
167 int argc,
168 const char **argv);
169
170
171/**
172 * Free one animation structure
173 */
174RT_EXPORT extern void db_free_1anim(struct animate *anp);
175
176
177/**
178 * 'arc' may be a null pointer, signifying an identity matrix.
179 * 'materp' may be a null pointer, signifying that the region has
180 * already been finalized above this point in the tree.
181 */
182RT_EXPORT extern void db_apply_anims(struct db_full_path *pathp,
183 struct directory *dp,
184 mat_t stck,
185 mat_t arc,
186 struct mater_info *materp);
187
188
189#endif /* RT_ANIM_H */
190
191/*
192 * Local Variables:
193 * tab-width: 8
194 * mode: C
195 * indent-tabs-mode: t
196 * c-file-style: "stroustrup"
197 * End:
198 * ex: shiftwidth=4 tabstop=8
199 */
Header file for the BRL-CAD common definitions.
fastf_t mat_t[ELEMENTS_PER_MAT]
4x4 matrix
Definition: vmath.h:366
int db_add_anim(struct db_i *dbip, struct animate *anp, int root)
struct animate * db_parse_1anim(struct db_i *dbip, int argc, const char **argv)
void db_free_1anim(struct animate *anp)
int db_do_anim(struct animate *anp, mat_t stack, mat_t arc, struct mater_info *materp)
void db_free_anim(struct db_i *dbip)
void db_apply_anims(struct db_full_path *pathp, struct directory *dp, mat_t stck, mat_t arc, struct mater_info *materp)
int db_parse_anim(struct db_i *dbip, int argc, const char **argv)
void db_write_anim(FILE *fop, struct animate *anp)
Definition: anim.h:52
mat_t anm_mat
Matrix.
Definition: anim.h:54
int anm_op
ANM_RSTACK, ANM_RARC...
Definition: anim.h:53
Definition: anim.h:76
struct animate * an_forw
forward link
Definition: anim.h:78
int an_type
AN_MATRIX, AN_COLOR...
Definition: anim.h:80
uint32_t magic
magic number
Definition: anim.h:77
union animate::animate_specific an_u
struct db_full_path an_path
(sub)-path pattern
Definition: anim.h:79
Definition: vls.h:53
int anc_rgb[3]
New color.
Definition: anim.h:72
uint32_t magic
Definition: anim.h:63
struct bu_vls anp_shader
Update string.
Definition: anim.h:65
int anp_op
RT_ANP_REPLACE, etc.
Definition: anim.h:64
struct anim_mat anu_m
Definition: anim.h:82
struct rt_anim_property anu_p
Definition: anim.h:83
struct rt_anim_color anu_c
Definition: anim.h:84
fundamental vector, matrix, quaternion math macros