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