#ifndef rdo_solid_H #define rdo_solid_H /* Solid primitives for scene description. */ #define rdo_solid_H_COPYRIGHT "Copyright © 2008 Danillo Pereira and J. Stolfi, UNICAMP" /* Last edited on 2024-12-21 11:51:16 by stolfi */ #include #include #include #include #include typedef enum { solid_type_Ovoid, /* An axis-aligned ellipsoid. */ solid_type_Brick, /* An axis-aligned box. */ solid_type_None /* When there is no primitive solid. */ } solid_type_t; /* A code that identifies the general type of a primitive geometric solid. */ typedef struct solid_t { solid_type_t type; /* Type of primitive solid. */ point3_t corner[2]; /* Scene coords of two opposite corners of enclosing box. */ char *name; /* Name of macro-object to which this solid belongs. */ int ifn; /* Index of finish in finish list, or -1 if unknown/undefined. */ } solid_t; /* Describes an instance of a primitive solid object in the scene. All objects with the same {name} will get the same finish; if they are emitters, they will all be part of a single light source. */ void rdo_solid_write(FILE *wr, solid_t *sd); /* Writes the solid instance {*sd} to file {wr}. */ solid_t rdo_solid_read(FILE *rd); /* Reads a solid instance from file {rd}, in the format produced by {rdo_solid_write}. */ void rdo_solid_get_normal(solid_t *sd, point3_t *position, vector3_t *normal); /* Assumes that the point {position} lies on the surface of solid {sd}. Places into {*normal} the unit vector that is perpendicular to the solid's surface at that point, directed outwards. */ void rdo_solid_get_normal_ovoid(point3_t corner[], point3_t *position, vector3_t *normal); void rdo_solid_get_normal_brick(point3_t corner[], point3_t *position, vector3_t *normal); /* Similar to {rdo_solid_get_normal}, but for a solid of a specific type, with the encolsing box spanned by {corner[0],corner[1]}. */ /* LISTS OF SOLIDS */ vec_typedef(solid_vec_t, solid_vec, solid_t); /* Defines the type {solid_vec_t} as a self-delimited vector of solid instances, {v.e[0..v.ne-1]}. Also defines the functions {solid_vec_new()}, {solid_vec_expand()}, {solid_vec_trim()}, {solid_vec_free()}. */ void rdo_solid_vec_write(FILE *wr, solid_vec_t *sds); /* Writes to file {wr} a description of the list of solids {sds}. */ solid_vec_t rdo_solid_vec_read(FILE *rd); /* Reads from file {rd} a description of a list of solids, in the format created by {rdo_solid_vec_write}. */ void rdo_solid_vec_bounding_box(solid_vec_t *sds, point3_t corner[]); /* Places in {corner[0],corner[1]} the lowest and highest corner of the minimal bounding box of the solids {sds}. */ #endif