public aiTexture GetEmbeddedTexture(string filename) { global::System.IntPtr cPtr = assimp_swigPINVOKE.aiScene_GetEmbeddedTexture(swigCPtr, filename); aiTexture ret = (cPtr == global::System.IntPtr.Zero) ? null : new aiTexture(cPtr, false); return(ret); }
private void LoadFromAssimp(Module.Import.Assimp.Context context, string filename, aiScene scene) { if (!string.IsNullOrEmpty(filename)) { byte[] tex; if (filename[0] == '*') { // Embeded texture string index_str = filename.Remove(0, 1); uint index; if (uint.TryParse(index_str, out index)) { using (aiTextureArray array = scene.Textures) { if (index < array.Size()) { using (aiTexture texture = array.Get(index)) { DecodeTexture(filename, texture.data); } } else { Debug.LogError("Invalid embeded texture index \"" + index + "\" (out of bound)."); } } } else { Debug.LogError("Invalid embeded texture name \"" + filename + "\" (not an index)."); } } else if (context.importer != null && (tex = context.importer.GetTexture(filename)) != null) { DecodeTexture(filename, tex); } else { LoadFromFile(context.path, filename); } } }
internal static HandleRef getCPtr(aiTexture obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
internal static HandleRef getCPtr(aiTexture obj) { return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr); }
private void ToAssimp(Module.Export.Assimp.Context context, string texture_name, aiTextureType texture_type, aiMaterial material) { if (!string.IsNullOrEmpty(texture_name)) { string final_texture_name = null; if (texture_name.Length >= 1 && texture_name[0] == '*') { // Special textures if (texture_name.Length >= 3 && texture_name[1] == '*') { switch (texture_name[2]) { case 'N': // New normal texture generated from height map texture_type = aiTextureType.aiTextureType_HEIGHT; final_texture_name = texture_name.Substring(3); break; case 'A': // Secondary texture encoded in alpha channel string[] textures = texture_name.Substring(3).Split('|'); if (textures.Length == 2) { ToAssimp(context, textures[0], texture_type, material); switch (texture_type) { case aiTextureType.aiTextureType_DIFFUSE: texture_type = aiTextureType.aiTextureType_OPACITY; break; case aiTextureType.aiTextureType_SPECULAR: texture_type = aiTextureType.aiTextureType_SHININESS; break; default: break; } ToAssimp(context, textures[1], texture_type, material); } else { throw new FormatException("The texture + alpha should contain identifiers to only two original textures"); } break; case 'E': // Empty texture break; default: break; } } else // Embeded texture { if (unityTexture != null) { using (aiTextureArray textures = context.scene.Textures) { uint index = textures.Size(); final_texture_name = "*" + index; using (aiTexture texture = new aiTexture()) { texture.data = unityTexture.EncodeToPNG(); texture.achFormatHint = "png"; textures.Set(index, texture.Unmanaged()); } } } } } else { final_texture_name = texture_name; } if (final_texture_name != null) { using (aiString assimp_texture_name = new aiString(final_texture_name)) { lock (material) { material.SetTexturePath(texture_type, 0, assimp_texture_name.Unmanaged()); } } context.progress.Update(ASSIMP_PROGRESS_FACTOR); } } }