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 
41 #include "rxtype.h"
42 
48 /*-----------*/
49 /*- Options -*/
50 /*-----------*/
51 
55 AA_API struct aa_rx_geom_opt*
57 
61 AA_API void
63 
67 AA_API void
69  struct aa_rx_geom_opt *opt,
70  int no_shadow );
71 
75 AA_API int
77 
81 AA_API int
83 
87 AA_API int
89 
93 AA_API double
95 
99 AA_API double
101 
102 
106 AA_API double
108 
112 AA_API double
114 
118 AA_API double
120 
124 AA_API double
126 
130 AA_API double
132 
136 AA_API void
138  struct aa_rx_geom_opt *opt,
139  double red, double blue, double green );
140 
144 AA_API void
146  struct aa_rx_geom_opt *opt,
147  double alpha );
148 
154 AA_API void
156  struct aa_rx_geom_opt *opt,
157  int visual );
158 
164 AA_API void
166  struct aa_rx_geom_opt *opt,
167  int collision );
168 
172 AA_API void
174  struct aa_rx_geom_opt *opt,
175  double red, double green, double blue );
176 
177 
181 AA_API void
183  struct aa_rx_geom_opt *opt,
184  double scale );
185 
189 AA_API double
191  const struct aa_rx_geom_opt *opt );
192 
193 /*----------*/
194 /*- Shapes -*/
195 /*----------*/
196 
197 
201 AA_API struct aa_rx_geom *
203 
207 AA_API struct aa_rx_geom *
208 aa_rx_geom_modify_opt( struct aa_rx_geom *src, struct aa_rx_geom_opt *opt );
209 
213 AA_API void
215 
229 };
230 
234 AA_API const char *aa_rx_geom_shape_str( enum aa_rx_geom_shape shape );
235 
243  double dimension[3];
244 };
245 
250  double radius;
251 };
252 
257  double height;
258  double radius;
259 };
260 
265  double height;
266  double start_radius;
267  double end_radius;
268 };
269 
270 
275  double dimension[2];
276  double delta[2];
277  double width;
278 };
279 
284  double angle;
285  double major_radius;
286  double minor_radius;
287 };
288 
298 AA_API void *
299 aa_rx_geom_shape ( const struct aa_rx_geom *g,
300  enum aa_rx_geom_shape *shape_type );
301 
305 AA_API struct aa_rx_geom *
307  struct aa_rx_geom_opt *opt,
308  const double dimension[3] );
309 
313 AA_API struct aa_rx_geom *
315  struct aa_rx_geom_opt *opt,
316  double radius );
317 
321 AA_API struct aa_rx_geom *
323  struct aa_rx_geom_opt *opt,
324  double height,
325  double radius );
326 
330 AA_API struct aa_rx_geom *
332  struct aa_rx_geom_opt *opt,
333  double height,
334  double start_radius,
335  double end_radius );
336 
340 AA_API struct aa_rx_geom *
342  struct aa_rx_geom_opt *opt,
343  const double dimension[2],
344  const double delta[2],
345  double width );
346 
347 
351 AA_API struct aa_rx_geom *
353  struct aa_rx_geom_opt *opt,
354  double angle,
355  double major_radius,
356  double minor_radius
357  );
358 
362 AA_API const struct aa_rx_geom_opt*
363 aa_rx_geom_get_opt ( const struct aa_rx_geom *geom );
364 
368 AA_API struct aa_rx_cl_geom *
369 aa_rx_geom_get_collision ( const struct aa_rx_geom *geom );
370 
374 AA_API void
375 aa_rx_geom_set_collision ( struct aa_rx_geom *geom, struct aa_rx_cl_geom * );
376 
380 struct aa_rx_mesh;
381 
385 AA_API struct aa_rx_mesh* aa_rx_mesh_create();
386 
390 AA_API void aa_rx_mesh_destroy( struct aa_rx_mesh * mesh );
391 
396  struct aa_rx_mesh *mesh, size_t n,
397  const float *vectors, int copy );
398 
403  const struct aa_rx_mesh *mesh, size_t *size );
404 
409  const struct aa_rx_mesh *mesh, size_t *size );
410 
415  struct aa_rx_mesh *mesh, size_t n,
416  const float *normals, int copy );
417 
422  struct aa_rx_mesh *mesh, size_t n,
423  const unsigned *indices, int copy );
424 
429  struct aa_rx_mesh *mesh,
430  size_t width, size_t height,
431  const uint8_t *rgba, int copy );
432 
437  struct aa_rx_mesh *mesh,
438  size_t n, const float *uv, int copy );
439 
444  struct aa_rx_mesh *mesh,
445  const struct aa_rx_geom_opt *opt );
446 
450 AA_API struct aa_rx_geom *
452  struct aa_rx_geom_opt *opt,
453  struct aa_rx_mesh *mesh );
454 
458 AA_API void
460  struct aa_rx_sg *sg,
461  const char *frame,
462  struct aa_rx_geom *geom );
463 
467 AA_API unsigned
468 aa_rx_geom_refcount ( const struct aa_rx_geom *g );
469 
473 AA_API unsigned
474 aa_rx_mesh_refcount ( const struct aa_rx_mesh *sg );
475 
476 #endif /*AMINO_RX_SCENE_GEOM_H*/
#define AA_API
calling and name mangling convention for functions
Definition: amino.h:95
Scenegraph-related type declarations.
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_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.
AA_API void aa_rx_geom_destroy(struct aa_rx_geom *geom)
Destroy a geometry struct.
AA_API struct aa_rx_geom * aa_rx_geom_modify_opt(struct aa_rx_geom *src, struct aa_rx_geom_opt *opt)
Copy and modify options of a geometry struct.
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 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_opt_set_collision(struct aa_rx_geom_opt *opt, int collision)
Set collision flag.
AA_API double aa_rx_geom_opt_get_specular_green(const struct aa_rx_geom_opt *opt)
Get green specular value.
AA_API double aa_rx_geom_opt_get_specular_red(const struct aa_rx_geom_opt *opt)
Get red specular value.
AA_API double aa_rx_geom_opt_get_color_red(const struct aa_rx_geom_opt *opt)
Get red color value.
AA_API int aa_rx_geom_opt_get_visual(const struct aa_rx_geom_opt *opt)
Get visual option.
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.
AA_API void aa_rx_geom_opt_set_visual(struct aa_rx_geom_opt *opt, int visual)
Set visual flag.
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 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.
AA_API double aa_rx_geom_opt_get_scale(const struct aa_rx_geom_opt *opt)
Get mesh scaling.
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 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_geom_opt_set_color3(struct aa_rx_geom_opt *opt, double red, double blue, double green)
Set color option.
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 int aa_rx_geom_opt_get_no_shadow(const struct aa_rx_geom_opt *opt)
Get no-shadow option.
AA_API int aa_rx_geom_opt_get_collision(const struct aa_rx_geom_opt *opt)
Get collision option.
AA_API struct aa_rx_geom * aa_rx_geom_torus(struct aa_rx_geom_opt *opt, double angle, double major_radius, double minor_radius)
Create a torus.
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 struct aa_rx_geom * aa_rx_geom_box(struct aa_rx_geom_opt *opt, const double dimension[3])
Create a box.
AA_API void aa_rx_geom_opt_set_alpha(struct aa_rx_geom_opt *opt, double alpha)
Set alpha (transparency) option.
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 const unsigned * aa_rx_mesh_get_indices(const struct aa_rx_mesh *mesh, size_t *size)
Get the mesh indices.
aa_rx_geom_shape
Enumeration of geometry shape types.
Definition: scene_geom.h:219
@ AA_RX_GRID
A grid-lines shape.
Definition: scene_geom.h:226
@ AA_RX_CONE
A cone shape.
Definition: scene_geom.h:225
@ AA_RX_CYLINDER
A cylinder shape.
Definition: scene_geom.h:224
@ AA_RX_OCTREE
A octree shape.
Definition: scene_geom.h:228
@ AA_RX_BOX
A box (cube) shape.
Definition: scene_geom.h:222
@ AA_RX_SPHERE
A sphere (ball) shape.
Definition: scene_geom.h:223
@ AA_RX_NOSHAPE
Invalid shape.
Definition: scene_geom.h:220
@ AA_RX_MESH
A triangular mesh shape.
Definition: scene_geom.h:221
@ AA_RX_TORUS
A torus shape.
Definition: scene_geom.h:227
AA_API void aa_rx_geom_opt_destroy(struct aa_rx_geom_opt *)
Destroy a geometry option struct.
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 void aa_rx_mesh_destroy(struct aa_rx_mesh *mesh)
Destroy the mesh.
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 const float * aa_rx_mesh_get_vertices(const struct aa_rx_mesh *mesh, size_t *size)
Get the mesh vertices.
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_geom * aa_rx_geom_cylinder(struct aa_rx_geom_opt *opt, double height, double radius)
Create a cylinder.
AA_API void aa_rx_geom_opt_set_scale(struct aa_rx_geom_opt *opt, double scale)
Set mesh scaling.
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 struct aa_rx_mesh * aa_rx_mesh_create()
Create a mesh.
AA_API struct aa_rx_geom_opt * aa_rx_geom_opt_create()
Create a geometry option struct.
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_sphere(struct aa_rx_geom_opt *opt, double radius)
Create a sphere.
AA_API unsigned aa_rx_geom_refcount(const struct aa_rx_geom *g)
Return the reference count value of ‘g’.
AA_API unsigned aa_rx_mesh_refcount(const struct aa_rx_mesh *sg)
Return the reference count value of ‘m’.
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.
Opaque structure for geometry options.
Definition: rxtype.h:69
Container for scene geometry.
Definition: rxtype.h:63
Opaque type for a scene_graph.
Shape for a box.
Definition: scene_geom.h:239
double dimension[3]
x, y, z dimensions of the box
Definition: scene_geom.h:243
Shape for a cone.
Definition: scene_geom.h:264
double end_radius
radius at cone top (z=height)
Definition: scene_geom.h:267
double height
height of the cone
Definition: scene_geom.h:265
double start_radius
radius at cone base (z=0)
Definition: scene_geom.h:266
Shape for a cylinder.
Definition: scene_geom.h:256
double height
cylinder's height
Definition: scene_geom.h:257
double radius
cylinder's radius
Definition: scene_geom.h:258
Shape for a grid.
Definition: scene_geom.h:274
double delta[2]
x, y line spacing of the grid
Definition: scene_geom.h:276
double width
width of each line
Definition: scene_geom.h:277
double dimension[2]
x, y dimensions of the grid
Definition: scene_geom.h:275
Shape for a sphere.
Definition: scene_geom.h:249
double radius
sphere's radius
Definition: scene_geom.h:250
Shape for a torus.
Definition: scene_geom.h:283
double angle
arc angle of the torus
Definition: scene_geom.h:284
double major_radius
major torus radius
Definition: scene_geom.h:285
double minor_radius
minor torus radius
Definition: scene_geom.h:286