---------------------------------------------------------------------------- */
| 147 | |
| 148 | /* ---------------------------------------------------------------------------- */ |
| 149 | void apply_material(const C_STRUCT aiMaterial *mtl) |
| 150 | { |
| 151 | float c[4]; |
| 152 | |
| 153 | GLenum fill_mode; |
| 154 | int ret1, ret2; |
| 155 | C_STRUCT aiColor4D diffuse; |
| 156 | C_STRUCT aiColor4D specular; |
| 157 | C_STRUCT aiColor4D ambient; |
| 158 | C_STRUCT aiColor4D emission; |
| 159 | ai_real shininess, strength; |
| 160 | int two_sided; |
| 161 | int wireframe; |
| 162 | unsigned int max; |
| 163 | |
| 164 | set_float4(c, 0.8f, 0.8f, 0.8f, 1.0f); |
| 165 | if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_DIFFUSE, &diffuse)) |
| 166 | color4_to_float4(&diffuse, c); |
| 167 | glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, c); |
| 168 | |
| 169 | set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f); |
| 170 | if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_SPECULAR, &specular)) |
| 171 | color4_to_float4(&specular, c); |
| 172 | glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, c); |
| 173 | |
| 174 | set_float4(c, 0.2f, 0.2f, 0.2f, 1.0f); |
| 175 | if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_AMBIENT, &ambient)) |
| 176 | color4_to_float4(&ambient, c); |
| 177 | glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, c); |
| 178 | |
| 179 | set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f); |
| 180 | if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_EMISSIVE, &emission)) |
| 181 | color4_to_float4(&emission, c); |
| 182 | glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, c); |
| 183 | |
| 184 | max = 1; |
| 185 | ret1 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS, &shininess, &max); |
| 186 | if(ret1 == AI_SUCCESS) { |
| 187 | max = 1; |
| 188 | ret2 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS_STRENGTH, &strength, &max); |
| 189 | if(ret2 == AI_SUCCESS) |
| 190 | glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess * strength); |
| 191 | else |
| 192 | glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess); |
| 193 | } |
| 194 | else { |
| 195 | glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0f); |
| 196 | set_float4(c, 0.0f, 0.0f, 0.0f, 0.0f); |
| 197 | glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, c); |
| 198 | } |
| 199 | |
| 200 | max = 1; |
| 201 | if(AI_SUCCESS == aiGetMaterialIntegerArray(mtl, AI_MATKEY_ENABLE_WIREFRAME, &wireframe, &max)) |
| 202 | fill_mode = wireframe ? GL_LINE : GL_FILL; |
| 203 | else |
| 204 | fill_mode = GL_FILL; |
| 205 | glPolygonMode(GL_FRONT_AND_BACK, fill_mode); |
| 206 |
no test coverage detected