* Replaced nondescript NullPointerException in OBJLoader with proper exception for missing material in MTL git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7026 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
@ -188,20 +188,22 @@ void main(){
specularColor.rgb *= texture2D(m_ColorRamp, vec2(light.y, 0.0)).rgb;
#endif
// Workaround, since it is not possible to modify varying variables
vec4 SpecularSum2 = SpecularSum;
#ifdef USE_REFLECTION
vec4 refColor = Optics_GetEnvColor(m_EnvMap, refVec.xyz);
// Interpolate light specularity toward reflection color
// Multiply result by specular map
specularColor = mix(SpecularSum * light.y, refColor, refVec.w) * specularColor;
specularColor = mix(SpecularSum2 * light.y, refColor, refVec.w) * specularColor;
SpecularSum = vec4(1.0);
SpecularSum2 = vec4(1.0);
light.y = 1.0;
gl_FragColor = AmbientSum * diffuseColor +
DiffuseSum * diffuseColor * light.x +
SpecularSum * specularColor * light.y;
SpecularSum2 * specularColor * light.y;
gl_FragColor.a = alpha;
}
@ -332,6 +332,9 @@ public final class OBJLoader implements AssetLoader {
}else if (cmd.equals("usemtl")){
// use material from MTL lib for the following faces
currentMatName = scan.next();
if (!matList.containsKey(currentMatName))
throw new IOException("Cannot locate material " + currentMatName + " in MTL file!");
}else if (cmd.equals("mtllib")){
// specify MTL lib to use for this OBJ file
String mtllib = scan.nextLine().trim();