private void CreateBoneLineNode(string filename) { EZMFile ezmFile = EZMFile.Load(filename); ezmFile.LoadTextures(); var rootElement = this.scene.RootNode; for (int i = 0; i < ezmFile.MeshSystem.Meshes.Length; i++) { EZMMesh mesh = ezmFile.MeshSystem.Meshes[i]; var model = new NodeLineModel(mesh.Skeleton.Bones); var node = NodeLineNode.Create(model); rootElement.Children.Add(node); } }
private void CreateTextureNode(string filename) { EZMFile ezmFile = EZMFile.Load(filename); ezmFile.LoadTextures(); var rootElement = this.scene.RootNode; for (int i = 0; i < ezmFile.MeshSystem.Meshes.Length; i++) { EZMMesh mesh = ezmFile.MeshSystem.Meshes[i]; EZMAnimation animation = ezmFile.MeshSystem.Animations.Length > 0 ? ezmFile.MeshSystem.Animations[0] : null; var container = new EZMVertexBufferContainer(mesh, animation); for (int j = 0; j < mesh.MeshSections.Length; j++) { var model = new EZMTextureModel(container, mesh.MeshSections[j]); var node = EZMTextureNode.Create(model); rootElement.Children.Add(node); } } }
/// <summary> /// Load textures and attach them to materials' tag property. /// </summary> /// <param name="ezmFile"></param> public static void LoadTextures(this EZMFile ezmFile) { if (ezmFile != null) { string directory = (new FileInfo(ezmFile.Fullname)).DirectoryName; foreach (var material in ezmFile.MeshSystem.Materials) { string filename = Path.Combine(directory, material.MetaData); var bitmap = new Bitmap(filename); bitmap.RotateFlip(RotateFlipType.Rotate180FlipX); var storage = new TexImageBitmap(bitmap); var texture = new Texture(storage, new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_REPEAT), new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_REPEAT), new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR), new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR)); texture.Initialize(); material.Tag = texture; } } }