Back to index

radiance  4R0+20100331
rhdobj.h
Go to the documentation of this file.
00001 /* RCSid: $Id: rhdobj.h,v 3.9 2005/01/07 20:33:02 greg Exp $ */
00002 /*
00003  * Header file for object display routines for rholo drivers.
00004  */
00005 #ifndef _RAD_RHDOBJ_H_
00006 #define _RAD_RHDOBJ_H_
00007 
00008 #ifdef __cplusplus
00009 extern "C" {
00010 #endif
00011 
00012                             /* additional user commands */
00013 #define DO_LOAD             0             /* load octree object */
00014 #define DO_UNLOAD    1             /* unload (free) octree object */
00015 #define DO_XFORM     2             /* set/print object transform */
00016 #define DO_MOVE             3             /* add to object transform */
00017 #define DO_UNMOVE    4             /* undo last transform change */
00018 #define DO_DUP              5             /* duplicate object */
00019 #define DO_SHOW             6             /* show object (low quality) */
00020 #define DO_LIGHT     7             /* illuminate object (high quality) */
00021 #define DO_HIDE             8             /* hide object */
00022 #define DO_OBJECT    9             /* print object statistics */
00023 
00024 #define DO_NCMDS     10            /* number of object display commands */
00025 
00026                                    /* commands entered on stdin only */
00027 #define DO_INIT             {"load","clear","xform","move","unmove","dup",\
00028                             "show","light","hide","object"}
00029 
00030 /*******************************************************************
00031  * The following routines are available for calling from the driver:
00032 
00033 int
00034 (*dobj_lightsamp)(c, p, v)  : apply next sample for local light sources
00035 COLR   c;                   : pixel color (RGBE)
00036 FVECT  p;                   : world intersection point
00037 FVECT  v;                   : ray direction vector
00038 
00039 If the pointer to the function dobj_lightsamp is non-NULL, then the
00040 dev_value() driver routine should call this rather than use a
00041 given sample in its own data structures.  This pointer is set
00042 in the dobj_lighting() function described below, which may be
00043 called indirectly by the dobj_command() function.
00044 
00045 
00046 int
00047 dobj_command(cmd, args)            : check/run object display command
00048 char   *cmd, *args;         : command name and argument string
00049 
00050 Check to see if this is an object display command, and return -1 if
00051 it isn't.  If it is a valid command that results in some visible
00052 change, return non-zero, otherwise return 0.  Error messages should
00053 be printed with error(COMMAND,err).
00054 
00055 
00056 double
00057 dobj_trace(nm, rorg, rdir)  : check for ray intersection with objects
00058 char   nm[];                : object name (modified)
00059 FVECT  rorg, rdir;          : ray origin and direction
00060 
00061 Check to see if the given ray intersects the given object,
00062 returning the distance the ray traveled if it did, or FHUGE if it didn't.
00063 If nm contains "*", then all visible objects are checked and the name
00064 of the intersected object is returned, or "" if none.  If nm is NULL,
00065 then all visible objects are checked, but the name is not returned.
00066 
00067 
00068 int
00069 dobj_render()               : render visible objects to OpenGL
00070 
00071 Renders all display objects using OpenGL, assuming desired view has
00072 been set.  This routine also assumes that the tone-mapping library
00073 is being used to set exposure, and it queries this information to
00074 adjust light sources as necessary for illuminated objects.  Returns
00075 the number of objects rendered.
00076 
00077 
00078 void
00079 dobj_cleanup()                     : clean up data structures
00080 
00081 Frees all allocated data structures and objects.
00082 
00083 
00084 ++++ The following routines are usually called through dobj_command() ++++
00085 
00086 
00087 int
00088 dobj_load(oct, nam)         : create/load an octree object
00089 char   *oct, *nam;          : octree and object name
00090 
00091 Load an octree for rendering as a local object, giving it the indicated name.
00092 Returns 1 on success, 0 on failure (with COMMAND error message).
00093 
00094 
00095 int
00096 dobj_unload(nam)            : free the named object
00097 char   *nam;                : object name
00098 
00099 Free all memory associated with the named object.
00100 Returns 1 on success, 0 on failure (with COMMAND error message).
00101 
00102 
00103 int
00104 dobj_xform(nam, add, ac, av)       : set/add transform for nam
00105 char   *nam;                : object name
00106 int    add;                 : add to transform or create new one?
00107 int    ac;                  : transform argument count
00108 char   *av[];               : transform arguments
00109 
00110 Set or add to the transform for the named object.
00111 Returns 1 on success, 0 on failure (with COMMAND error message).
00112 
00113 
00114 int
00115 dobj_unmove()               : undo last transform change
00116 
00117 Undo the last transform change.
00118 Returns 1 on success, 0 on failure (with COMMAND error message).
00119 
00120 
00121 int
00122 dobj_dup(oldnm, nam)        : duplicate object oldnm as nam
00123 char   *oldnm, *nam;
00124 
00125 Duplicate the named object and give the copy a new name.
00126 Returns 1 on success, 0 on failure (with COMMAND error message).
00127 
00128 
00129 int
00130 dobj_lighting(nam, cn)             : set up lighting for display object
00131 char   *nam;                : object name
00132 int    cn;                  : new drawing code
00133 
00134 Set the lighting of the named object to DO_SHOW, DO_HIDE or DO_LIGHT.
00135 Change lighting of all objects if nam is "*".
00136 Returns 1 on success, 0 on failure (with COMMAND error message).
00137 
00138 
00139 int
00140 dobj_putstats(nam, fp)             : print object statistics
00141 char   *nam;                : object name
00142 FILE   *fp;                 : output file
00143 
00144 Print current position, size and transform for the named object,
00145 or all objects if nam is "*".
00146 Returns 1 on success, 0 on failure (with COMMAND error message).
00147 
00148 
00149  ******************************************************************/
00150 
00151 extern TMstruct      *tmGlobal;
00152 
00153 extern char   rhdcmd[DO_NCMDS][8];
00154 
00155 /* pointer to function to get lights */
00156 extern void   (*dobj_lightsamp)(COLR clr, FVECT direc, FVECT pos);
00157 
00158 
00159 extern int dobj_cleanup(void);
00160 extern int dobj_command(char *cmd, register char *args);
00161 extern int dobj_render(void);
00162 extern double dobj_trace(char nm[], FVECT  rorg, FVECT  rdir);
00163 extern int dobj_load(char   *oct, char    *nam);
00164 extern int dobj_unload(char *nam);
00165 extern int dobj_xform(char  *nam, int     rel, int      ac, char      **av);
00166 extern int dobj_putstats(char      *nam, FILE    *fp);
00167 extern int dobj_unmove(void);
00168 extern int dobj_dup(char    *oldnm, char  *nam);
00169 extern int dobj_lighting(char      *nam, int     cn);
00170 
00171 
00172 #ifdef __cplusplus
00173 }
00174 #endif
00175 #endif /* _RAD_RHDOBJ_H_ */
00176