1 |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
|
3 |
/* SCCSid "$SunId$ SGI" */ |
4 |
|
5 |
/* |
6 |
* Header file for object display routines for rholo drivers. |
7 |
*/ |
8 |
|
9 |
/* additional user commands */ |
10 |
#define DO_LOAD 0 /* load octree object */ |
11 |
#define DO_UNLOAD 1 /* unload (free) octree object */ |
12 |
#define DO_XFORM 2 /* set/print object transform */ |
13 |
#define DO_MOVE 3 /* add to object transform */ |
14 |
#define DO_UNMOVE 4 /* undo last transform change */ |
15 |
#define DO_DUP 5 /* duplicate object */ |
16 |
#define DO_SHOW 6 /* show object (low quality) */ |
17 |
#define DO_LIGHT 7 /* illuminate object (high quality) */ |
18 |
#define DO_HIDE 8 /* hide object */ |
19 |
#define DO_OBJECT 9 /* print object statistics */ |
20 |
|
21 |
#define DO_NCMDS 10 /* number of object display commands */ |
22 |
|
23 |
/* commands entered on stdin only */ |
24 |
#define DO_INIT {"load","clear","xform","move","unmove","dup",\ |
25 |
"show","light","hide","object"} |
26 |
|
27 |
/******************************************************************* |
28 |
* The following routines are available for calling from the driver: |
29 |
|
30 |
int |
31 |
(*dobj_lightsamp)(c, p, v) : apply next sample for local light sources |
32 |
COLR c; : pixel color (RGBE) |
33 |
FVECT p; : world intersection point |
34 |
FVECT v; : ray direction vector |
35 |
|
36 |
If the pointer to the function dobj_lightsamp is non-NULL, then the |
37 |
dev_value() driver routine should call this rather than use a |
38 |
given sample in its own data structures. This pointer is set |
39 |
in the dobj_lighting() function described below, which may be |
40 |
called indirectly by the dobj_command() function. |
41 |
|
42 |
|
43 |
int |
44 |
dobj_command(cmd, args) : check/run object display command |
45 |
char *cmd, *args; : command name and argument string |
46 |
|
47 |
Check to see if this is an object display command, and return the command |
48 |
number after running it if it is, or -1 if it isn't. Error messages should |
49 |
be printed with error(COMMAND,err). |
50 |
|
51 |
|
52 |
double |
53 |
dobj_trace(nm, rorg, rdir) : check for ray intersection with objects |
54 |
char nm[]; : object name (modified) |
55 |
FVECT rorg, rdir; : ray origin and direction |
56 |
|
57 |
Check to see if the given ray intersects the given object, |
58 |
returning the distance the ray traveled if it did, or FHUGE if it didn't. |
59 |
If nm contains "*", then all visible objects are checked and the name |
60 |
of the intersected object is returned, or "" if none. If nm is NULL, |
61 |
then all visible objects are checked, but the name is not returned. |
62 |
|
63 |
|
64 |
int |
65 |
dobj_render() : render visible objects to OpenGL |
66 |
|
67 |
Renders all display objects using OpenGL, assuming desired view has |
68 |
been set. This routine also assumes that the tone-mapping library |
69 |
is being used to set exposure, and it queries this information to |
70 |
adjust light sources as necessary for illuminated objects. Returns |
71 |
the number of objects rendered. |
72 |
|
73 |
|
74 |
void |
75 |
dobj_cleanup() : clean up data structures |
76 |
|
77 |
Frees all allocated data structures and objects. |
78 |
|
79 |
|
80 |
++++ The following routines are usually called through dobj_command() ++++ |
81 |
|
82 |
|
83 |
int |
84 |
dobj_load(oct, nam) : create/load an octree object |
85 |
char *oct, *nam; : octree and object name |
86 |
|
87 |
Load an octree for rendering as a local object, giving it the indicated name. |
88 |
Returns 1 on success, 0 on failure (with COMMAND error message). |
89 |
|
90 |
|
91 |
int |
92 |
dobj_unload(nam) : free the named object |
93 |
char *nam; : object name |
94 |
|
95 |
Free all memory associated with the named object. |
96 |
Returns 1 on success, 0 on failure (with COMMAND error message). |
97 |
|
98 |
|
99 |
int |
100 |
dobj_xform(nam, add, ac, av) : set/add transform for nam |
101 |
char *nam; : object name |
102 |
int add; : add to transform or create new one? |
103 |
int ac; : transform argument count |
104 |
char *av[]; : transform arguments |
105 |
|
106 |
Set or add to the transform for the named object. |
107 |
Returns 1 on success, 0 on failure (with COMMAND error message). |
108 |
|
109 |
|
110 |
int |
111 |
dobj_unmove() : undo last transform change |
112 |
|
113 |
Undo the last transform change. |
114 |
Returns 1 on success, 0 on failure (with COMMAND error message). |
115 |
|
116 |
|
117 |
int |
118 |
dobj_dup(oldnm, nam) : duplicate object oldnm as nam |
119 |
char *oldnm, *nam; |
120 |
|
121 |
Duplicate the named object and give the copy a new name. |
122 |
Returns 1 on success, 0 on failure (with COMMAND error message). |
123 |
|
124 |
|
125 |
int |
126 |
dobj_lighting(nam, cn) : set up lighting for display object |
127 |
char *nam; : object name |
128 |
int cn; : new drawing code |
129 |
|
130 |
Set the lighting of the named object to DO_SHOW, DO_HIDE or DO_LIGHT. |
131 |
Change lighting of all objects if nam is "*". |
132 |
Returns 1 on success, 0 on failure (with COMMAND error message). |
133 |
|
134 |
|
135 |
int |
136 |
dobj_putstats(nam, fp) : print object statistics |
137 |
char *nam; : object name |
138 |
FILE *fp; : output file |
139 |
|
140 |
Print current position, size and transform for the named object, |
141 |
or all objects if nam is "*". |
142 |
Returns 1 on success, 0 on failure (with COMMAND error message). |
143 |
|
144 |
|
145 |
******************************************************************/ |
146 |
|
147 |
|
148 |
extern double dobj_trace(); |
149 |
|
150 |
extern char rhdcmd[DO_NCMDS][8]; |
151 |
|
152 |
extern int (*dobj_lightsamp)(); /* pointer to function to get lights */ |