00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "mmsgui/3d/mms3dmaterial.h"
00034
00035
00036 int MMS3DMaterial::material_cnt = 0;
00037
00038
00039 MMS3D_MATERIAL MMS3DMaterial::mat_buffer[MMS3DMaterial::MAT_SIZE] = {
00040
00041 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00042 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00043 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00044 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00045 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00046 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00047 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00048 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00049 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00050 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00051 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00052 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00053 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00054 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00055 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00056 {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
00057
00058
00059
00060 {0.00,0.00,0.00,1.00, 0.00,0.00,0.00,1.00, 0.00,0.00,0.00,1.00, 0.00,0.00,0.00,1.00, 0.000},
00061 {0.00,0.00,0.00,1.00, 0.50,0.00,0.00,1.00, 1.00,0.00,0.00,1.00, 0.00,0.00,0.00,1.00, 0.000},
00062 {0.00,0.00,0.00,1.00, 0.00,0.50,0.00,1.00, 0.00,1.00,0.00,1.00, 0.00,0.00,0.00,1.00, 0.000},
00063 {0.00,0.00,0.00,1.00, 0.00,0.00,0.50,1.00, 0.00,0.00,1.00,1.00, 0.00,0.00,0.00,1.00, 0.000},
00064 {0.00,0.00,0.00,1.00, 0.50,0.50,0.00,1.00, 1.00,1.00,0.00,1.00, 0.00,0.00,0.00,1.00, 0.000},
00065 {0.00,0.00,0.00,1.00, 0.00,0.50,0.50,1.00, 0.00,1.00,1.00,1.00, 0.00,0.00,0.00,1.00, 0.000},
00066 {0.00,0.00,0.00,1.00, 0.50,0.00,0.50,1.00, 1.00,0.00,1.00,1.00, 0.00,0.00,0.00,1.00, 0.000},
00067 {0.00,0.00,0.00,1.00, 0.50,0.50,0.50,1.00, 1.00,1.00,1.00,1.00, 0.00,0.00,0.00,1.00, 0.000},
00068
00069
00070
00071 {0.00,0.00,0.00,1.00, 0.14,0.22,0.16,1.00, 0.54,0.89,0.63,1.00, 0.32,0.32,0.32,1.00, 0.100},
00072 {0.00,0.00,0.00,1.00, 0.14,0.22,0.16,0.90, 0.54,0.89,0.63,0.90, 0.32,0.32,0.32,0.90, 0.100},
00073 {0.00,0.00,0.00,1.00, 0.05,0.05,0.07,1.00, 0.18,0.17,0.23,1.00, 0.33,0.33,0.35,1.00, 0.300},
00074 {0.00,0.00,0.00,1.00, 0.05,0.05,0.07,0.80, 0.18,0.17,0.23,0.80, 0.33,0.33,0.35,0.80, 0.300},
00075 {0.00,0.00,0.00,1.00, 0.25,0.21,0.21,1.00, 0.99,0.83,0.83,1.00, 0.30,0.30,0.30,1.00, 0.088},
00076 {0.00,0.00,0.00,1.00, 0.25,0.21,0.21,0.90, 0.99,0.83,0.83,0.90, 0.30,0.30,0.30,0.90, 0.088},
00077 {0.00,0.00,0.00,1.00, 0.17,0.01,0.01,1.00, 0.61,0.04,0.04,1.00, 0.73,0.63,0.63,1.00, 0.600},
00078 {0.00,0.00,0.00,1.00, 0.17,0.01,0.01,0.50, 0.61,0.04,0.04,0.50, 0.73,0.63,0.63,0.50, 0.600},
00079 {0.00,0.00,0.00,1.00, 0.02,0.17,0.02,1.00, 0.08,0.61,0.08,1.00, 0.63,0.73,0.63,1.00, 0.600},
00080 {0.00,0.00,0.00,1.00, 0.02,0.17,0.02,0.50, 0.08,0.61,0.08,0.50, 0.63,0.73,0.63,0.50, 0.600},
00081 {0.00,0.00,0.00,1.00, 0.10,0.19,0.17,1.00, 0.40,0.74,0.69,1.00, 0.30,0.31,0.31,1.00, 0.100},
00082 {0.00,0.00,0.00,1.00, 0.10,0.19,0.17,0.80, 0.40,0.74,0.69,0.80, 0.30,0.31,0.31,0.80, 0.100},
00083
00084
00085
00086 {0.00,0.00,0.00,1.00, 0.00,0.00,0.00,1.00, 0.01,0.01,0.01,1.00, 0.50,0.50,0.50,1.00, 0.250},
00087 {0.00,0.00,0.00,1.00, 0.00,0.00,0.00,1.00, 0.50,0.00,0.00,1.00, 0.70,0.60,0.60,1.00, 0.250},
00088 {0.00,0.00,0.00,1.00, 0.00,0.00,0.00,1.00, 0.10,0.35,0.10,1.00, 0.45,0.55,0.45,1.00, 0.250},
00089 {0.00,0.00,0.00,1.00, 0.00,0.00,0.00,1.00, 0.00,0.00,0.50,1.00, 0.60,0.60,0.70,1.00, 0.250},
00090 {0.00,0.00,0.00,1.00, 0.00,0.00,0.00,1.00, 0.50,0.50,0.00,1.00, 0.60,0.60,0.50,1.00, 0.250},
00091 {0.00,0.00,0.00,1.00, 0.00,0.10,0.06,1.00, 0.00,0.51,0.51,1.00, 0.50,0.50,0.50,1.00, 0.250},
00092 {0.00,0.00,0.00,1.00, 0.06,0.00,0.06,1.00, 0.51,0.00,0.51,1.00, 0.50,0.50,0.50,1.00, 0.250},
00093 {0.00,0.00,0.00,1.00, 0.00,0.00,0.00,1.00, 0.55,0.55,0.55,1.00, 0.70,0.70,0.70,1.00, 0.250},
00094 {0.00,0.00,0.00,1.00, 0.02,0.02,0.02,1.00, 0.01,0.01,0.01,1.00, 0.40,0.40,0.40,1.00, 0.078},
00095 {0.00,0.00,0.00,1.00, 0.05,0.00,0.00,1.00, 0.50,0.40,0.40,1.00, 0.70,0.04,0.04,1.00, 0.078},
00096 {0.00,0.00,0.00,1.00, 0.00,0.05,0.00,1.00, 0.40,0.50,0.40,1.00, 0.04,0.70,0.04,1.00, 0.078},
00097 {0.00,0.00,0.00,1.00, 0.00,0.00,0.05,1.00, 0.40,0.40,0.50,1.00, 0.04,0.04,0.70,1.00, 0.078},
00098 {0.00,0.00,0.00,1.00, 0.05,0.05,0.00,1.00, 0.50,0.50,0.40,1.00, 0.70,0.70,0.04,1.00, 0.078},
00099 {0.00,0.00,0.00,1.00, 0.00,0.05,0.05,1.00, 0.40,0.50,0.50,1.00, 0.04,0.70,0.70,1.00, 0.078},
00100 {0.00,0.00,0.00,1.00, 0.05,0.00,0.05,1.00, 0.50,0.40,0.50,1.00, 0.70,0.04,0.70,1.00, 0.078},
00101 {0.00,0.00,0.00,1.00, 0.05,0.05,0.05,1.00, 0.50,0.50,0.50,1.00, 0.70,0.70,0.70,1.00, 0.078},
00102
00103
00104
00105 {0.00,0.00,0.00,1.00, 0.21,0.13,0.05,1.00, 0.71,0.43,0.18,1.00, 0.39,0.27,0.17,1.00, 0.200},
00106 {0.00,0.00,0.00,1.00, 0.25,0.15,0.06,1.00, 0.40,0.24,0.10,1.00, 0.77,0.46,0.20,1.00, 0.600},
00107 {0.00,0.00,0.00,1.00, 0.25,0.25,0.25,1.00, 0.40,0.40,0.40,1.00, 0.77,0.77,0.77,1.00, 0.600},
00108 {0.00,0.00,0.00,1.00, 0.25,0.20,0.07,1.00, 0.75,0.61,0.23,1.00, 0.63,0.65,0.37,1.00, 0.400},
00109 {0.00,0.00,0.00,1.00, 0.25,0.22,0.06,1.00, 0.35,0.31,0.09,1.00, 0.80,0.72,0.21,1.00, 0.650},
00110 {0.00,0.00,0.00,1.00, 0.19,0.07,0.02,1.00, 0.70,0.27,0.08,1.00, 0.26,0.14,0.09,1.00, 0.100},
00111 {0.00,0.00,0.00,1.00, 0.23,0.09,0.03,1.00, 0.55,0.21,0.07,1.00, 0.58,0.22,0.07,1.00, 0.400},
00112 {0.00,0.00,0.00,1.00, 0.33,0.22,0.03,1.00, 0.78,0.57,0.11,1.00, 0.99,0.94,0.81,1.00, 0.218},
00113 {0.00,0.00,0.00,1.00, 0.19,0.19,0.19,1.00, 0.51,0.51,0.51,1.00, 0.51,0.51,0.51,1.00, 0.400},
00114 {0.00,0.00,0.00,1.00, 0.23,0.23,0.23,1.00, 0.28,0.28,0.28,1.00, 0.77,0.77,0.77,1.00, 0.700},
00115 {0.00,0.00,0.00,1.00, 0.11,0.06,0.11,1.00, 0.43,0.47,0.54,1.00, 0.33,0.33,0.52,1.00, 0.077}
00116 };
00117
00118
00119 MMS3DMaterial::MMS3DMaterial() {
00120 }
00121
00122 void MMS3DMaterial::getBuffer(MMS3D_MATERIAL **mat_buffer) {
00123 *mat_buffer = this->mat_buffer;
00124 }
00125
00126 int MMS3DMaterial::genMaterial(MMSFBColor emission, MMSFBColor ambient, MMSFBColor diffuse, MMSFBColor specular, unsigned char shininess) {
00127 if (this->material_cnt > MAT_MAX_USER_DEFINED) {
00128
00129 return MAT_NOTSET;
00130 }
00131
00132
00133 mat_buffer[this->material_cnt].s.emission.r = (float)emission.r / 255;
00134 mat_buffer[this->material_cnt].s.emission.g = (float)emission.g / 255;
00135 mat_buffer[this->material_cnt].s.emission.b = (float)emission.b / 255;
00136 mat_buffer[this->material_cnt].s.emission.a = (float)emission.a / 255;
00137 mat_buffer[this->material_cnt].s.ambient.r = (float)ambient.r / 255;
00138 mat_buffer[this->material_cnt].s.ambient.g = (float)ambient.g / 255;
00139 mat_buffer[this->material_cnt].s.ambient.b = (float)ambient.b / 255;
00140 mat_buffer[this->material_cnt].s.ambient.a = (float)ambient.a / 255;
00141 mat_buffer[this->material_cnt].s.diffuse.r = (float)diffuse.r / 255;
00142 mat_buffer[this->material_cnt].s.diffuse.g = (float)diffuse.g / 255;
00143 mat_buffer[this->material_cnt].s.diffuse.b = (float)diffuse.b / 255;
00144 mat_buffer[this->material_cnt].s.diffuse.a = (float)diffuse.a / 255;
00145 mat_buffer[this->material_cnt].s.specular.r = (float)specular.r / 255;
00146 mat_buffer[this->material_cnt].s.specular.g = (float)specular.g / 255;
00147 mat_buffer[this->material_cnt].s.specular.b = (float)specular.b / 255;
00148 mat_buffer[this->material_cnt].s.specular.a = (float)specular.a / 255;
00149 mat_buffer[this->material_cnt].s.shininess = (float)shininess / 255;
00150 this->material_cnt++;
00151 return this->material_cnt - 1;
00152 }
00153
00154
00155