amino  1.0-beta2
Lightweight Robot Utility Library
scene_geom.h
Go to the documentation of this file.
1 /* -*- mode: C; c-basic-offset: 4; -*- */
2 /* ex: set shiftwidth=4 tabstop=4 expandtab: */
3 /*
4  * Copyright (c) 2015, Rice University
5  * All rights reserved.
6  *
7  * Author(s): Neil T. Dantam <ntd@rice.edu>
8  *
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of copyright holder the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
23  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
27  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #ifndef AMINO_RX_SCENE_GEOM_H
39 #define AMINO_RX_SCENE_GEOM_H
40 
46 /*-----------*/
47 /*- Options -*/
48 /*-----------*/
49 
56 struct aa_rx_geom_opt;
57 
61 AA_API struct aa_rx_geom_opt*
63 
67 AA_API void
68 aa_rx_geom_opt_destroy(struct aa_rx_geom_opt*);
69 
73 AA_API void
75  struct aa_rx_geom_opt *opt,
76  int no_shadow );
77 
81 AA_API int
82 aa_rx_geom_opt_get_no_shadow ( const struct aa_rx_geom_opt *opt );
83 
87 AA_API int
88 aa_rx_geom_opt_get_visual ( const struct aa_rx_geom_opt *opt );
89 
93 AA_API int
94 aa_rx_geom_opt_get_collision ( const struct aa_rx_geom_opt *opt );
95 
99 AA_API double
100 aa_rx_geom_opt_get_color_red ( const struct aa_rx_geom_opt *opt );
101 
105 AA_API double
106 aa_rx_geom_opt_get_color_blue ( const struct aa_rx_geom_opt *opt );
107 
108 
112 AA_API double
113 aa_rx_geom_opt_get_color_green ( const struct aa_rx_geom_opt *opt );
114 
118 AA_API double
119 aa_rx_geom_opt_get_alpha ( const struct aa_rx_geom_opt *opt );
120 
124 AA_API double
125 aa_rx_geom_opt_get_specular_red ( const struct aa_rx_geom_opt *opt );
126 
130 AA_API double
131 aa_rx_geom_opt_get_specular_blue ( const struct aa_rx_geom_opt *opt );
132 
136 AA_API double
137 aa_rx_geom_opt_get_specular_green ( const struct aa_rx_geom_opt *opt );
138 
142 AA_API void
144  struct aa_rx_geom_opt *opt,
145  double red, double blue, double green );
146 
150 AA_API void
152  struct aa_rx_geom_opt *opt,
153  double alpha );
154 
160 AA_API void
162  struct aa_rx_geom_opt *opt,
163  int visual );
164 
170 AA_API void
172  struct aa_rx_geom_opt *opt,
173  int collision );
174 
178 AA_API void
180  struct aa_rx_geom_opt *opt,
181  double red, double green, double blue );
182 
183 
187 AA_API void
189  struct aa_rx_geom_opt *opt,
190  double scale );
191 
195 AA_API double
197  const struct aa_rx_geom_opt *opt );
198 
199 /*----------*/
200 /*- Shapes -*/
201 /*----------*/
202 
203 
207 AA_API struct aa_rx_geom *
208 aa_rx_geom_copy( struct aa_rx_geom *src );
209 
213 AA_API void
214 aa_rx_geom_destroy( struct aa_rx_geom *geom );
215 
227 };
228 
232 AA_API const char *aa_rx_geom_shape_str( enum aa_rx_geom_shape shape );
233 
241  double dimension[3];
242 };
243 
248  double radius;
249 };
250 
255  double height;
256  double radius;
257 };
258 
263  double height;
264  double start_radius;
265  double end_radius;
266 };
267 
268 
273  double dimension[2];
274  double delta[2];
275  double width;
276 };
277 
287 AA_API void *
288 aa_rx_geom_shape ( const struct aa_rx_geom *g,
289  enum aa_rx_geom_shape *shape_type );
290 
294 AA_API struct aa_rx_geom *
296  struct aa_rx_geom_opt *opt,
297  const double dimension[3] );
298 
302 AA_API struct aa_rx_geom *
304  struct aa_rx_geom_opt *opt,
305  double radius );
306 
310 AA_API struct aa_rx_geom *
312  struct aa_rx_geom_opt *opt,
313  double height,
314  double radius );
315 
319 AA_API struct aa_rx_geom *
321  struct aa_rx_geom_opt *opt,
322  double height,
323  double start_radius,
324  double end_radius );
325 
329 AA_API struct aa_rx_geom *
331  struct aa_rx_geom_opt *opt,
332  const double dimension[2],
333  const double delta[2],
334  double width );
335 
339 AA_API const struct aa_rx_geom_opt*
340 aa_rx_geom_get_opt ( const struct aa_rx_geom *geom );
341 
345 AA_API struct aa_rx_cl_geom *
346 aa_rx_geom_get_collision ( const struct aa_rx_geom *geom );
347 
351 AA_API void
352 aa_rx_geom_set_collision ( struct aa_rx_geom *geom, struct aa_rx_cl_geom * );
353 
357 struct aa_rx_mesh;
358 
362 AA_API struct aa_rx_mesh* aa_rx_mesh_create();
363 
367 AA_API void aa_rx_mesh_destroy( struct aa_rx_mesh * mesh );
368 
373  struct aa_rx_mesh *mesh, size_t n,
374  const float *vectors, int copy );
375 
379 AA_API const float *aa_rx_mesh_get_vertices (
380  const struct aa_rx_mesh *mesh, size_t *size );
381 
385 AA_API const unsigned *aa_rx_mesh_get_indices (
386  const struct aa_rx_mesh *mesh, size_t *size );
387 
392  struct aa_rx_mesh *mesh, size_t n,
393  const float *normals, int copy );
394 
399  struct aa_rx_mesh *mesh, size_t n,
400  const unsigned *indices, int copy );
401 
406  struct aa_rx_mesh *mesh,
407  size_t width, size_t height,
408  const uint8_t *rgba, int copy );
409 
414  struct aa_rx_mesh *mesh,
415  size_t n, const float *uv, int copy );
416 
421  struct aa_rx_mesh *mesh,
422  const struct aa_rx_geom_opt *opt );
423 
427 AA_API struct aa_rx_geom *
429  struct aa_rx_geom_opt *opt,
430  struct aa_rx_mesh *mesh );
431 
435 AA_API void
437  struct aa_rx_sg *sg,
438  const char *frame,
439  struct aa_rx_geom *geom );
440 
444 AA_API unsigned
445 aa_rx_geom_refcount ( const struct aa_rx_geom *g );
446 
450 AA_API unsigned
451 aa_rx_mesh_refcount ( const struct aa_rx_mesh *sg );
452 
453 #endif /*AMINO_RX_SCENE_GEOM_H*/
AA_API double aa_rx_geom_opt_get_specular_blue(const struct aa_rx_geom_opt *opt)
Get blue specular value.
AA_API void aa_rx_geom_set_collision(struct aa_rx_geom *geom, struct aa_rx_cl_geom *)
Set the collision object for the geometry object.
AA_API void aa_rx_mesh_destroy(struct aa_rx_mesh *mesh)
Destroy the mesh.
Shape for a box.
Definition: scene_geom.h:237
AA_API void aa_rx_mesh_set_indices(struct aa_rx_mesh *mesh, size_t n, const unsigned *indices, int copy)
Set the mesh indices.
AA_API double aa_rx_geom_opt_get_alpha(const struct aa_rx_geom_opt *opt)
Get alpha value.
Invalid shape.
Definition: scene_geom.h:220
Container for scene geometry.
Definition: rxtype.h:56
aa_rx_geom_shape
Enumeration of geometry shape types.
Definition: scene_geom.h:219
AA_API const struct aa_rx_geom_opt * aa_rx_geom_get_opt(const struct aa_rx_geom *geom)
Return the options for the geometry object.
AA_API struct aa_rx_geom * aa_rx_geom_box(struct aa_rx_geom_opt *opt, const double dimension[3])
Create a box.
double end_radius
radius at cone top (z=height)
Definition: scene_geom.h:265
AA_API void aa_rx_geom_opt_set_no_shadow(struct aa_rx_geom_opt *opt, int no_shadow)
Set no-shadow option.
AA_API int aa_rx_geom_opt_get_no_shadow(const struct aa_rx_geom_opt *opt)
Get no-shadow option.
AA_API void aa_rx_geom_destroy(struct aa_rx_geom *geom)
Destroy a geometry struct.
Shape for a cylinder.
Definition: scene_geom.h:254
AA_API void aa_rx_mesh_set_uv(struct aa_rx_mesh *mesh, size_t n, const float *uv, int copy)
Set the mesh colors and uv values.
double height
height of the cone
Definition: scene_geom.h:263
AA_API unsigned aa_rx_geom_refcount(const struct aa_rx_geom *g)
Return the reference count value of `g&#39;.
AA_API void aa_rx_geom_opt_set_specular3(struct aa_rx_geom_opt *opt, double red, double green, double blue)
Set specular reflection.
AA_API int aa_rx_geom_opt_get_collision(const struct aa_rx_geom_opt *opt)
Get collision option.
AA_API double aa_rx_geom_opt_get_color_green(const struct aa_rx_geom_opt *opt)
Get green color value.
AA_API double aa_rx_geom_opt_get_color_blue(const struct aa_rx_geom_opt *opt)
Get blue color value.
AA_API void aa_rx_mesh_set_vertices(struct aa_rx_mesh *mesh, size_t n, const float *vectors, int copy)
Set the mesh vertices.
A cone shape.
Definition: scene_geom.h:225
AA_API double aa_rx_geom_opt_get_scale(const struct aa_rx_geom_opt *opt)
Get mesh scaling.
Shape for a grid.
Definition: scene_geom.h:272
AA_API const float * aa_rx_mesh_get_vertices(const struct aa_rx_mesh *mesh, size_t *size)
Get the mesh vertices.
AA_API struct aa_rx_geom * aa_rx_geom_sphere(struct aa_rx_geom_opt *opt, double radius)
Create a sphere.
AA_API void aa_rx_geom_opt_set_scale(struct aa_rx_geom_opt *opt, double scale)
Set mesh scaling.
Opaque type for a scene_graph.
double radius
sphere&#39;s radius
Definition: scene_geom.h:248
AA_API void aa_rx_mesh_set_normals(struct aa_rx_mesh *mesh, size_t n, const float *normals, int copy)
Set the mesh normals.
AA_API const char * aa_rx_geom_shape_str(enum aa_rx_geom_shape shape)
Return a string for the shape type.
AA_API struct aa_rx_geom * aa_rx_geom_cone(struct aa_rx_geom_opt *opt, double height, double start_radius, double end_radius)
Create a cone.
AA_API struct aa_rx_geom * aa_rx_geom_cylinder(struct aa_rx_geom_opt *opt, double height, double radius)
Create a cylinder.
double start_radius
radius at cone base (z=0)
Definition: scene_geom.h:264
double dimension[3]
x, y, z dimensions of the box
Definition: scene_geom.h:241
AA_API struct aa_rx_cl_geom * aa_rx_geom_get_collision(const struct aa_rx_geom *geom)
Return the collision object for the geometry object.
AA_API const unsigned * aa_rx_mesh_get_indices(const struct aa_rx_mesh *mesh, size_t *size)
Get the mesh indices.
double radius
cylinder&#39;s radius
Definition: scene_geom.h:256
AA_API struct aa_rx_geom * aa_rx_geom_copy(struct aa_rx_geom *src)
Copy a geometry struct.
AA_API void aa_rx_geom_attach(struct aa_rx_sg *sg, const char *frame, struct aa_rx_geom *geom)
Attach geometry to the scene graph.
AA_API struct aa_rx_geom_opt * aa_rx_geom_opt_create()
Create a geometry option struct.
double width
width of each line
Definition: scene_geom.h:275
AA_API void aa_rx_geom_opt_set_visual(struct aa_rx_geom_opt *opt, int visual)
Set visual flag.
#define AA_API
calling and name mangling convention for functions
Definition: amino.h:95
AA_API int aa_rx_geom_opt_get_visual(const struct aa_rx_geom_opt *opt)
Get visual option.
AA_API double aa_rx_geom_opt_get_specular_green(const struct aa_rx_geom_opt *opt)
Get green specular value.
Shape for a sphere.
Definition: scene_geom.h:247
AA_API struct aa_rx_geom * aa_rx_geom_mesh(struct aa_rx_geom_opt *opt, struct aa_rx_mesh *mesh)
Attach a mesh to frame.
AA_API struct aa_rx_geom * aa_rx_geom_grid(struct aa_rx_geom_opt *opt, const double dimension[2], const double delta[2], double width)
Create a grid.
AA_API void aa_rx_mesh_set_texture(struct aa_rx_mesh *mesh, const struct aa_rx_geom_opt *opt)
Set the mesh texture parameters.
AA_API struct aa_rx_mesh * aa_rx_mesh_create()
Create a mesh.
AA_API void aa_rx_mesh_set_rgba(struct aa_rx_mesh *mesh, size_t width, size_t height, const uint8_t *rgba, int copy)
Set the mesh colors and alpha.
AA_API void aa_rx_geom_opt_set_color3(struct aa_rx_geom_opt *opt, double red, double blue, double green)
Set color option.
AA_API double aa_rx_geom_opt_get_color_red(const struct aa_rx_geom_opt *opt)
Get red color value.
A triangular mesh shape.
Definition: scene_geom.h:221
double height
cylinder&#39;s height
Definition: scene_geom.h:255
Shape for a cone.
Definition: scene_geom.h:262
AA_API void aa_rx_geom_opt_set_alpha(struct aa_rx_geom_opt *opt, double alpha)
Set alpha (transparency) option.
A box (cube) shape.
Definition: scene_geom.h:222
AA_API void aa_rx_geom_opt_destroy(struct aa_rx_geom_opt *)
Destroy a geometry option struct.
A grid-lines shape.
Definition: scene_geom.h:226
A cylinder shape.
Definition: scene_geom.h:224
A sphere (ball) shape.
Definition: scene_geom.h:223
AA_API void aa_rx_geom_opt_set_collision(struct aa_rx_geom_opt *opt, int collision)
Set collision flag.
AA_API unsigned aa_rx_mesh_refcount(const struct aa_rx_mesh *sg)
Return the reference count value of `m&#39;.
AA_API double aa_rx_geom_opt_get_specular_red(const struct aa_rx_geom_opt *opt)
Get red specular value.