public aiMaterialVectorEnumerator(aiMaterialVector collection) { collectionRef = collection; currentIndex = -1; currentObject = null; currentSize = collectionRef.Count; }
public aiMaterialVector(aiMaterialVector other) : this(AssimpPINVOKE.new_aiMaterialVector__SWIG_1(aiMaterialVector.getCPtr(other)), true) { if (AssimpPINVOKE.SWIGPendingException.Pending) { throw AssimpPINVOKE.SWIGPendingException.Retrieve(); } }
private aiMaterialVector GetmMaterials() { IntPtr cPtr = AssimpPINVOKE.aiScene_GetmMaterials(swigCPtr); aiMaterialVector ret = (cPtr == IntPtr.Zero) ? null : new aiMaterialVector(cPtr, true); return(ret); }
private void CacheMaterials(aiMaterialVector materials) { var numMaterials = materials.Count; materialCache = new ExtendedMaterial[numMaterials]; textureCache = new Dictionary <string, Texture>(); for (int i = 0; i < numMaterials; ++i) { var material = materials[i]; var dxExtendedMaterial = new ExtendedMaterial(); var dxMaterial = new Material(); dxMaterial.AmbientColor = material.Ambient.ToColorValue(); dxMaterial.DiffuseColor = material.Diffuse.ToColorValue(); dxMaterial.EmissiveColor = material.Emissive.ToColorValue(); dxMaterial.SpecularColor = material.Specular.ToColorValue(); dxMaterial.SpecularSharpness = material.ShininessStrength; dxExtendedMaterial.Material3D = dxMaterial; dxExtendedMaterial.TextureFilename = material.TextureDiffuse0; materialCache[i] = dxExtendedMaterial; var textureFilename = dxExtendedMaterial.TextureFilename; if (!string.IsNullOrEmpty(textureFilename) && !textureCache.ContainsKey(textureFilename)) { textureCache.Add(textureFilename, CreateTexture(textureFilename)); } } }
public void SetRange(int index, aiMaterialVector values) { AssimpPINVOKE.aiMaterialVector_SetRange(swigCPtr, index, aiMaterialVector.getCPtr(values)); if (AssimpPINVOKE.SWIGPendingException.Pending) { throw AssimpPINVOKE.SWIGPendingException.Retrieve(); } }
public model CreateMesh(Device device, aiMesh aiMesh, aiMaterialVector mMaterials, String directory) { var numFaces = (int)aiMesh.mNumFaces; var numVertices = (int)aiMesh.mNumVertices; var aiPositions = aiMesh.mVertices; var aiNormals = aiMesh.mNormals; var aiTextureCoordsAll = aiMesh.mTextureCoords; var aiTextureCoords = (aiTextureCoordsAll != null) ? aiTextureCoordsAll[0] : null; VertexPostitionTexture[] VertexPostitionTextures = new VertexPostitionTexture[aiMesh.mNumVertices]; for (int j = 0; j < aiMesh.mNumVertices; j++) { VertexPostitionTextures[j].position = new Vector3(aiMesh.mVertices[j].x, aiMesh.mVertices[j].y, aiMesh.mVertices[j].z); VertexPostitionTextures[j].textcoord = new Vector2(aiMesh.mTextureCoords[0][j].x, aiMesh.mTextureCoords[0][j].y); } ///being brute =P int SizeInBytes = Marshal.SizeOf(typeof(VertexPostitionTexture)); BufferDescription bd = new BufferDescription(SizeInBytes * (int)aiMesh.mNumVertices, ResourceUsage.Immutable, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, SizeInBytes); var vertices = Buffer.Create <VertexPostitionTexture>(device, VertexPostitionTextures, bd); var aiFaces = aiMesh.mFaces; var dxIndices = new uint[numFaces * 3]; for (int i = 0; i < numFaces; ++i) { var aiFace = aiFaces[i]; var aiIndices = aiFace.mIndices; for (int j = 0; j < 3; ++j) { dxIndices[i * 3 + j] = (uint)aiIndices[j]; } } BufferDescription bi = new BufferDescription(sizeof(uint) * numFaces * 3, ResourceUsage.Immutable, BindFlags.IndexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, sizeof(uint)); var indices = Buffer.Create <uint>(device, dxIndices, bd); model modelteste = new model(); modelteste.indices = indices; modelteste.numberIndices = numFaces * 3; modelteste.vertex = vertices; modelteste.numberVertices = numVertices; aiString difuse = new aiString(); mMaterials[(int)aiMesh.mMaterialIndex].GetTextureDiffuse0(difuse); modelteste.difuseTextureName = difuse.Data; String fullPath = String.IsNullOrEmpty(directory) ? modelteste.difuseTextureName : Path.Combine(directory, modelteste.difuseTextureName); modelteste.ShaderResourceView = ShaderResourceView.FromFile(device, fullPath); return(modelteste); }
public static aiMaterialVector Repeat(aiMaterial value, int count) { IntPtr cPtr = AssimpPINVOKE.aiMaterialVector_Repeat(aiMaterial.getCPtr(value), count); aiMaterialVector ret = (cPtr == IntPtr.Zero) ? null : new aiMaterialVector(cPtr, true); if (AssimpPINVOKE.SWIGPendingException.Pending) { throw AssimpPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public aiMaterialVector GetRange(int index, int count) { IntPtr cPtr = AssimpPINVOKE.aiMaterialVector_GetRange(swigCPtr, index, count); aiMaterialVector ret = (cPtr == IntPtr.Zero) ? null : new aiMaterialVector(cPtr, true); if (AssimpPINVOKE.SWIGPendingException.Pending) { throw AssimpPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public model CreateMesh(Device device, aiMesh aiMesh, aiMaterialVector mMaterials, String directory) { var numFaces = (int)aiMesh.mNumFaces; var numVertices = (int)aiMesh.mNumVertices; var aiPositions = aiMesh.mVertices; var aiNormals = aiMesh.mNormals; var aiTextureCoordsAll = aiMesh.mTextureCoords; var aiTextureCoords = (aiTextureCoordsAll != null) ? aiTextureCoordsAll[0] : null; VertexPostitionTexture[] VertexPostitionTextures = new VertexPostitionTexture[aiMesh.mNumVertices]; for (int j = 0; j < aiMesh.mNumVertices; j++) { VertexPostitionTextures[j].position = new Vector3(aiMesh.mVertices[j].x, aiMesh.mVertices[j].y, aiMesh.mVertices[j].z); VertexPostitionTextures[j].textcoord = new Vector2(aiMesh.mTextureCoords[0][j].x, aiMesh.mTextureCoords[0][j].y); } ///being brute =P int SizeInBytes = Marshal.SizeOf(typeof(VertexPostitionTexture)); BufferDescription bd = new BufferDescription(SizeInBytes * (int)aiMesh.mNumVertices, ResourceUsage.Immutable, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, SizeInBytes); var vertices = Buffer.Create<VertexPostitionTexture>(device, VertexPostitionTextures, bd); var aiFaces = aiMesh.mFaces; var dxIndices = new uint[numFaces * 3]; for (int i = 0; i < numFaces; ++i) { var aiFace = aiFaces[i]; var aiIndices = aiFace.mIndices; for (int j = 0; j < 3; ++j) { dxIndices[i * 3 + j] = (uint)aiIndices[j]; } } BufferDescription bi = new BufferDescription(sizeof(uint) * numFaces * 3, ResourceUsage.Immutable, BindFlags.IndexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, sizeof(uint)); var indices = Buffer.Create<uint>(device, dxIndices, bd); model modelteste = new model(); modelteste.indices = indices; modelteste.numberIndices = numFaces * 3; modelteste.vertex = vertices; modelteste.numberVertices = numVertices; aiString difuse = new aiString(); mMaterials[(int)aiMesh.mMaterialIndex].GetTextureDiffuse0(difuse); modelteste.difuseTextureName = difuse.Data; String fullPath = String.IsNullOrEmpty(directory) ? modelteste.difuseTextureName : Path.Combine(directory, modelteste.difuseTextureName); modelteste.ShaderResourceView = ShaderResourceView.FromFile(device, fullPath); return modelteste; }
private void CacheMaterials(aiMaterialVector materials) { var numMaterials = materials.Count; materialCache = new ExtendedMaterial[numMaterials]; textureCache = new Dictionary<string, Texture>(); for (int i = 0; i < numMaterials; ++i) { var material = materials[i]; var dxExtendedMaterial = new ExtendedMaterial(); var dxMaterial = new Material(); dxMaterial.AmbientColor = material.Ambient.ToColorValue(); dxMaterial.DiffuseColor = material.Diffuse.ToColorValue(); dxMaterial.EmissiveColor = material.Emissive.ToColorValue(); dxMaterial.SpecularColor = material.Specular.ToColorValue(); dxMaterial.SpecularSharpness = material.ShininessStrength; dxExtendedMaterial.Material3D = dxMaterial; dxExtendedMaterial.TextureFilename = material.TextureDiffuse0; materialCache[i] = dxExtendedMaterial; var textureFilename = dxExtendedMaterial.TextureFilename; if (!string.IsNullOrEmpty(textureFilename) && !textureCache.ContainsKey(textureFilename)) { textureCache.Add(textureFilename, CreateTexture(textureFilename)); } } }
internal static HandleRef getCPtr(aiMaterialVector obj) { return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr); }