1 // material.hxx -- class to handle material properties
3 // Written by Curtis Olson, started May 1998.
5 // Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 // (Log is kept at end of this file)
30 # error This library requires C++
44 #if defined ( __sun__ )
45 extern "C" void *memmove(void *, const void *, size_t);
46 extern "C" void *memset(void *, int, size_t);
49 #include <string> // Standard C++ string library
50 #include <map> // STL associative "array"
52 #ifdef NEEDNAMESPACESTD
56 #include "fragment.hxx"
59 #define FG_MAX_MATERIAL_FRAGS 800
62 // Material property class
66 // OpenGL texture name
69 // file name of texture
70 char texture_name[256];
72 // material properties
73 GLfloat ambient[4], diffuse[4], specular[4], emissive[4];
76 // transient list of objects with this material type (used for sorting
77 // by material to reduce GL state changes when rendering the scene
78 fgFRAGMENT * list[FG_MAX_MATERIAL_FRAGS];
85 void init_sort_list( void );
86 int append_sort_list( fgFRAGMENT *object );
93 // Material management class
94 class fgMATERIAL_MGR {
98 // associative array of materials
99 map < string, fgMATERIAL, less<string> > material_map;
102 fgMATERIAL_MGR ( void );
104 // Load a library of material properties
105 int load_lib ( void );
107 // Initialize the transient list of fragments for each material property
108 void init_transient_material_lists( void );
111 ~fgMATERIAL_MGR ( void );
115 // global material management class
116 extern fgMATERIAL_MGR material_mgr;
119 #endif // _MATERIAL_HXX
123 // Revision 1.1 1998/08/25 16:51:24 curt
124 // Moved from ../Scenery
126 // Revision 1.10 1998/07/24 21:42:06 curt
127 // material.cxx: whups, double method declaration with no definition.
128 // obj.cxx: tweaks to avoid errors in SGI's CC.
129 // tile.cxx: optimizations by Norman Vine.
130 // tilemgr.cxx: optimizations by Norman Vine.
132 // Revision 1.9 1998/07/06 21:34:33 curt
133 // Added using namespace std for compilers that support this.
135 // Revision 1.8 1998/06/17 21:36:39 curt
136 // Load and manage multiple textures defined in the Materials library.
137 // Boost max material fagments for each material property to 800.
138 // Multiple texture support when rendering.
140 // Revision 1.7 1998/06/12 00:58:04 curt
141 // Build only static libraries.
142 // Declare memmove/memset for Sloaris.
144 // Revision 1.6 1998/06/06 01:09:31 curt
145 // I goofed on the log message in the last commit ... now fixed.
147 // Revision 1.5 1998/06/06 01:07:17 curt
148 // Increased per material fragment list size from 100 to 400.
149 // Now correctly draw viewable fragments in per material order.
151 // Revision 1.4 1998/06/05 22:39:53 curt
152 // Working on sorting by, and rendering by material properties.
154 // Revision 1.3 1998/06/03 00:47:50 curt
155 // No .h for STL includes.
156 // Minor view culling optimizations.
158 // Revision 1.2 1998/06/01 17:56:20 curt
159 // Incremental additions to material.cxx (not fully functional)
160 // Tweaked vfc_ratio math to avoid divide by zero.
162 // Revision 1.1 1998/05/30 01:56:45 curt
163 // Added material.cxx material.hxx