public static ColorValue ToColorValue(this aiColor4D c) { return(new ColorValue() { Alpha = c.a, Red = c.r, Green = c.g, Blue = c.b }); }
public aiColor4D(aiColor4D o) : this(AssimpPINVOKE.new_aiColor4D__SWIG_3(aiColor4D.getCPtr(o)), true) { if (AssimpPINVOKE.SWIGPendingException.Pending) { throw AssimpPINVOKE.SWIGPendingException.Retrieve(); } }
public aiColor4D __subnset__(aiColor4D o) { aiColor4D ret = new aiColor4D(AssimpPINVOKE.aiColor4D___subnset__(swigCPtr, aiColor4D.getCPtr(o)), false); if (AssimpPINVOKE.SWIGPendingException.Pending) { throw AssimpPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public bool SetColorReflective(aiColor4D INPUT) { bool ret = assimp_swigPINVOKE.aiMaterial_SetColorReflective(swigCPtr, aiColor4D.getCPtr(INPUT)); if (assimp_swigPINVOKE.SWIGPendingException.Pending) { throw assimp_swigPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public bool __nequal__(aiColor4D other) { bool ret = AssimpPINVOKE.aiColor4D___nequal__(swigCPtr, aiColor4D.getCPtr(other)); if (AssimpPINVOKE.SWIGPendingException.Pending) { throw AssimpPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public bool GetColorTransparent(aiColor4D OUTPUT) { bool ret = assimp_swigPINVOKE.aiMaterial_GetColorTransparent(swigCPtr, aiColor4D.getCPtr(OUTPUT)); if (assimp_swigPINVOKE.SWIGPendingException.Pending) { throw assimp_swigPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public bool __nequal__(aiColor4D other) { bool ret = AssimpPINVOKE.aiColor4D___nequal__(swigCPtr, aiColor4D.getCPtr(other)); if (AssimpPINVOKE.SWIGPendingException.Pending) throw AssimpPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public aiColor4D __divnset__(float f) { aiColor4D ret = new aiColor4D(AssimpPINVOKE.aiColor4D___divnset__(swigCPtr, f), false); return ret; }
public aiColor4D __subnset__(aiColor4D o) { aiColor4D ret = new aiColor4D(AssimpPINVOKE.aiColor4D___subnset__(swigCPtr, aiColor4D.getCPtr(o)), false); if (AssimpPINVOKE.SWIGPendingException.Pending) throw AssimpPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public aiColor4D(aiColor4D o) : this(AssimpPINVOKE.new_aiColor4D__SWIG_3(aiColor4D.getCPtr(o)), true) { if (AssimpPINVOKE.SWIGPendingException.Pending) throw AssimpPINVOKE.SWIGPendingException.Retrieve(); }
internal static HandleRef getCPtr(aiColor4D obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
public bool GetEmissive(aiColor4D INOUT) { bool ret = AssimpPINVOKE.aiMaterial_GetEmissive(swigCPtr, aiColor4D.getCPtr(INOUT)); return ret; }
public bool GetEmissive(aiColor4D INOUT) { bool ret = AssimpPINVOKE.aiMaterial_GetEmissive(swigCPtr, aiColor4D.getCPtr(INOUT)); return(ret); }
public aiColor4D __divnset__(float f) { aiColor4D ret = new aiColor4D(AssimpPINVOKE.aiColor4D___divnset__(swigCPtr, f), false); return(ret); }
internal static HandleRef getCPtr(aiColor4D obj) { return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr); }
private static Material FromAssimp(Module.Import.Assimp.Context context, aiScene scene, aiMaterial material_data) { Material material = new Material(); // Initialize dictionaries before hand because we do not know in advance wich ones we will need material.floats = new Dictionary <string, float>(); material.colors = new Dictionary <string, Color>(); material.textures = new Dictionary <string, TextureParams>(); // Name using (aiString material_name = new aiString()) { if (material_data.GetName(material_name)) { material.name = material_name.ToString(); } } // shader material.shader = Constants.defaultAssimpShader; // Shininess float shininess; if (material_data.GetShininess(out shininess)) { aiShadingMode shading; if (material_data.GetShadingModel(out shading)) { if (shading != aiShadingMode.aiShadingMode_Blinn && shading != aiShadingMode.aiShadingMode_Phong) { // Unsupported shading model Debug.LogWarningFormat("The shading model for material {0} is not supported. The value for the shininess is likely to be incorrect.", material.name); } } const int factor = 128; // unity shader factor shininess /= factor; } // Gloss float gloss; if (material_data.GetShininessStrength(out gloss)) { shininess *= gloss; } // Reflectivity float reflectivity; if (material_data.GetReflectivity(out reflectivity)) { material.floats.Add(Assimp.Convert.unityMetallicValueName, reflectivity); } material.floats.Add(Assimp.Convert.unityGlossinessValueName, Smoothness(shininess, reflectivity)); // Colors foreach (KeyValuePair <string, Assimp.Convert.GetColor> pair in Assimp.Convert.GetColors(material_data)) { using (aiColor4D color = new aiColor4D()) { if (pair.Value(color)) { Color unity_color = Assimp.Convert.AssimpToUnity.Color(color); bool set_color = true; switch (pair.Key) { case Assimp.Convert.unityDiffuseColorName: // Global opacity float opacity; if (material_data.GetOpacity(out opacity) && opacity < 1.0f) { unity_color.a = opacity; material.floats.Add(Assimp.Convert.unityRenderModeName, (float)CLARTE.Shaders.Standard.Utility.BlendMode.TRANSPARENT); } break; case Assimp.Convert.unitySpecularColorName: // Specular color must be very close to black unity_color = 0.1f * unity_color; break; case Assimp.Convert.unityEmissiveColorName: if (!CLARTE.Shaders.Standard.Utility.ShouldEmissionBeEnabled(unity_color)) { set_color = false; } break; } if (set_color) { material.colors.Add(pair.Key, unity_color); } } } } // Textures foreach (KeyValuePair <string, aiTextureType> pair in Assimp.Convert.textureTypes) { // Make a copy to avoid problem of loop variable captured by reference by lambda expression string texture_key = pair.Key; aiTextureType texture_type = pair.Value; context.threads.AddTask(() => Texture.FromAssimp(context, material, scene, material_data, texture_key, texture_type, reflectivity)); } // We must dispose of the given parameter to free unused memory. However other tasks may still be using this material (i.e. textures), so we will let the garbage collector do it's job. //material_data.Dispose(); context.progress.Update(ASSIMP_PROGRESS_FACTOR); return(material); }
private void ToAssimp(Module.Export.Assimp.Context context, Scene scene, aiMaterial assimp_material) { // Name if (!string.IsNullOrEmpty(name)) { using (aiString assimp_material_name = new aiString(name)) { assimp_material.SetName(assimp_material_name.Unmanaged()); } } // Set flag for transparent texture if the shader use transparency if (renderQueue == (int)UnityEngine.Rendering.RenderQueue.Transparent) { assimp_material.SetTextureFlags(aiTextureType.aiTextureType_DIFFUSE, 0, aiTextureFlags.aiTextureFlags_UseAlpha); } // Reflectivity float reflectivity; if (floats == null || !floats.TryGetValue("_Metallic", out reflectivity)) { reflectivity = 0f; } assimp_material.SetReflectivity(reflectivity); // Shininess float smoothness; if (floats == null || !floats.TryGetValue("_Glossiness", out smoothness)) { smoothness = 0f; } float shininess = 2.0f * smoothness - (reflectivity > 0.0f ? reflectivity : 0.0f); if (shininess > 0.0f) { const int factor = 128; // unity shader factor assimp_material.SetShadingModel(aiShadingMode.aiShadingMode_Phong); assimp_material.SetShininess(shininess * factor); assimp_material.SetShininessStrength(1.0f); } else { assimp_material.SetShadingModel(aiShadingMode.aiShadingMode_Gouraud); } // Colors if (colors != null) { foreach (KeyValuePair <string, Assimp.Convert.SetColor> pair in Assimp.Convert.SetColors(assimp_material)) { if (colors.ContainsKey(pair.Key)) { Color unity_color = colors[pair.Key]; switch (pair.Key) { case Assimp.Convert.unityDiffuseColorName: if (unity_color.a < 1.0f) { assimp_material.SetOpacity(unity_color.a); } break; case Assimp.Convert.unitySpecularColorName: // Revert specular color to original value unity_color = 10.0f * unity_color; break; default: break; } using (aiColor4D color = Assimp.Convert.UnityToAssimp.Color(unity_color)) { pair.Value(color); } } } } // Textures if (textures != null) { Dictionary <Texture, aiTextureType> textures_types = new Dictionary <Texture, aiTextureType>(); // Get supported textures foreach (KeyValuePair <string, aiTextureType> pair in Assimp.Convert.textureTypes) { if (textures.ContainsKey(pair.Key)) { Texture texture = scene.textures[textures[pair.Key].index]; if (texture != null) { textures_types.Add(texture, pair.Value); } } } // Export each supported textures foreach (KeyValuePair <Texture, aiTextureType> texture_pair in textures_types) { // Make a copy to avoid problem of loop variable captured by reference by lambda expression Texture texture = texture_pair.Key; aiTextureType texture_type = texture_pair.Value; context.threads.AddTask(() => texture.ToAssimp(context, texture_type, assimp_material)); } } context.progress.Update(ASSIMP_PROGRESS_FACTOR); }
internal static Color Color(aiColor4D assimp) { return(new Color(assimp.r, assimp.g, assimp.b, assimp.a)); }