64Vector3 * MetalMapManagerClass::_NormalTable = 0;
83 CurrentAmbient(0.0f, 0.0f, 0.0f),
84 CurrentMainLightColor(0.0f, 0.0f, 0.0f),
85 CurrentMainLightDir(1.0f, 0.0f, 0.0f),
86 CurrentCameraDir(1.0f,0.0f,0.0f),
92 initialize_normal_table();
98 for (
int lp = 0; ; lp++) {
99 sprintf(section,
"Metal%02d", lp);
110 Vector3 black(0.0f, 0.0f, 0.0f);
111 for (
int i = 0; i < lp; i++) {
112 sprintf(section,
"Metal%02d", i);
113 static const float cf = 0.003921568627451f;
115 color = ini.
Get_Point(section,
"AmbientColor", white_tpoint);
119 color = ini.
Get_Point(section,
"DiffuseColor", white_tpoint);
123 color = ini.
Get_Point(section,
"SpecularColor", white_tpoint);
127 float shininess = ini.
Get_Float(section,
"Shininess", 0.0f);
131 initialize_metal_params(lp, metal_params);
132 delete [] metal_params;
146 for (
int i = 0; i < lp; i++) {
151 tex_name.
Format(
"!m%02d.tga", i);
152 Textures[i]->Set_Texture_Name(tex_name);
173 for (
int i = 0; i < MapCount; i++) {
179 if (MetalParameters) {
180 delete [] MetalParameters;
201 if (id < 0 || id >= MapCount)
return 0;
242 CurrentAmbient = ambient;
243 CurrentMainLightColor = main_light_color;
244 CurrentMainLightDir = main_light_dir;
245 CurrentCameraDir= camera_dir;
264 Vector3 &l = CurrentMainLightDir;
284 for (
int i = 0; i < MapCount; i++) {
291 if (shinyness > 1.0f) {
293 specular = &(temp_specular[0]);
295 specular = &(n_dot_h[0]);
310 SurfaceClass * metal_map_surface = Textures[i]->Get_Surface_Level(0);
312 unsigned char *map=(
unsigned char *) metal_map_surface->
Lock(&pitch);
316 Vector3 result = ambient_color + (diffuse_color * n_dot_l[idx]) + (specular_color * specular[idx]);
319 unsigned char b,g,r,a;
331 *(
unsigned short*)&map[2*x]=tmp;
342 metal_map_surface->
Unlock();
360void MetalMapManagerClass::initialize_normal_table(
void)
373 Vector3 &normal = _normal_table[idx];
375 normal.
Set((step * (
float)x) - 1.0f, (step * (
float)y) - 1.0f, 0.0f);
376 float z2 = 1 - ((normal.
X * normal.
X) + (normal.
Y * normal.
Y));
385 _NormalTable = &(_normal_table[0]);
402void MetalMapManagerClass::initialize_metal_params(
int map_count, MetalParams *metal_params)
404 MapCount = map_count;
409 for (
int i = 0; i < MapCount; i++) {
412 MetalParameters[i] = metal_params[i];
413 assert(MetalParameters[i].AmbientColor.X >= 0.0f && MetalParameters[i].AmbientColor.X <= 1.0f);
414 assert(MetalParameters[i].AmbientColor.Y >= 0.0f && MetalParameters[i].AmbientColor.Y <= 1.0f);
415 assert(MetalParameters[i].AmbientColor.Z >= 0.0f && MetalParameters[i].AmbientColor.Z <= 1.0f);
416 assert(MetalParameters[i].DiffuseColor.X >= 0.0f && MetalParameters[i].DiffuseColor.X <= 1.0f);
417 assert(MetalParameters[i].DiffuseColor.Y >= 0.0f && MetalParameters[i].DiffuseColor.Y <= 1.0f);
418 assert(MetalParameters[i].DiffuseColor.Z >= 0.0f && MetalParameters[i].DiffuseColor.Z <= 1.0f);
419 assert(MetalParameters[i].SpecularColor.X >= 0.0f && MetalParameters[i].SpecularColor.X <= 1.0f);
420 assert(MetalParameters[i].SpecularColor.Y >= 0.0f && MetalParameters[i].SpecularColor.Y <= 1.0f);
421 assert(MetalParameters[i].SpecularColor.Z >= 0.0f && MetalParameters[i].SpecularColor.Z <= 1.0f);
422 assert(MetalParameters[i].Shininess > 0.0f);
TPoint3D< int > const Get_Point(char const *section, char const *entry, TPoint3D< int > const &defvalue) const
float Get_Float(char const *section, char const *entry, float defvalue=0.0f) const
INISection * Find_Section(char const *section) const
int _cdecl Format(const TCHAR *format,...)
WWINLINE void Update_Max(const Vector3 &a)
WWINLINE void Update_Min(const Vector3 &a)
WWINLINE void Set(float x, float y, float z)
static void ClampMin(float *dst, float *src, const float min, const int count)
static void Power(float *dst, float *src, const float pow, const int count)
static void DotProduct(float *dst, const Vector3 &a, const Vector3 *b, const int count)
static void Get_Device_Resolution(int &set_w, int &set_h, int &get_bits, bool &get_windowed)
static float Clamp(float val, float min=0.0f, float max=1.0f)
static float Floor(float val)
#define REF_PTR_RELEASE(x)