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","unload","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 |
void |
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. |
71 |
|
72 |
|
73 |
void |
74 |
dobj_cleanup() : clean up data structures |
75 |
|
76 |
Frees all allocated data structures and objects. |
77 |
|
78 |
|
79 |
++++ The following routines are usually called through dobj_command() ++++ |
80 |
|
81 |
|
82 |
int |
83 |
dobj_load(oct, nam) : create/load an octree object |
84 |
char *oct, *nam; : octree and object name |
85 |
|
86 |
Load an octree for rendering as a local object, giving it the indicated name. |
87 |
Returns 1 on success, 0 on failure (with COMMAND error message). |
88 |
|
89 |
|
90 |
int |
91 |
dobj_unload(nam) : free the named object |
92 |
char *nam; : object name |
93 |
|
94 |
Free all memory associated with the named object. |
95 |
Returns 1 on success, 0 on failure (with COMMAND error message). |
96 |
|
97 |
|
98 |
int |
99 |
dobj_xform(nam, add, ac, av) : set/add transform for nam |
100 |
char *nam; : object name |
101 |
int add; : add to transform or create new one? |
102 |
int ac; : transform argument count |
103 |
char *av[]; : transform arguments |
104 |
|
105 |
Set or add to the transform for the named object. |
106 |
Returns 1 on success, 0 on failure (with COMMAND error message). |
107 |
|
108 |
|
109 |
int |
110 |
dobj_unmove() : undo last transform change |
111 |
|
112 |
Undo the last transform change. |
113 |
Returns 1 on success, 0 on failure (with COMMAND error message). |
114 |
|
115 |
|
116 |
int |
117 |
dobj_dup(oldnm, nam) : duplicate object oldnm as nam |
118 |
char *oldnm, *nam; |
119 |
|
120 |
Duplicate the named object and give the copy a new name. |
121 |
Returns 1 on success, 0 on failure (with COMMAND error message). |
122 |
|
123 |
|
124 |
int |
125 |
dobj_lighting(nam, cn) : set up lighting for display object |
126 |
char *nam; : object name |
127 |
int cn; : new drawing code |
128 |
|
129 |
Set the lighting of the named object to DO_SHOW, DO_HIDE or DO_LIGHT. |
130 |
Change lighting of all objects if nam is "*". |
131 |
Returns 1 on success, 0 on failure (with COMMAND error message). |
132 |
|
133 |
|
134 |
int |
135 |
dobj_putstats(nam, fp) : print object statistics |
136 |
char *nam; : object name |
137 |
FILE *fp; : output file |
138 |
|
139 |
Print current position, size and transform for the named object, |
140 |
or all objects if nam is "*". |
141 |
Returns 1 on success, 0 on failure (with COMMAND error message). |
142 |
|
143 |
|
144 |
******************************************************************/ |
145 |
|
146 |
|
147 |
extern double dobj_trace(); |
148 |
|
149 |
extern char rhdcmd[DO_NCMDS][8]; |
150 |
|
151 |
extern int (*dobj_lightsamp)(); /* pointer to function to get lights */ |