private void RenderFrame(int frameIndex, int diffuseSlot, int normalSlot, int specularSlot) { if (frameIndex < 0 || frameIndex >= this.Frames.Count) { return; } SdkMeshFrame frame = this.Frames[frameIndex]; if (frame.MeshIndex != -1) { this.RenderMesh(frame.MeshIndex, diffuseSlot, normalSlot, specularSlot); } // Render our children if (frame.ChildFrameIndex != -1) { this.RenderFrame(frame.ChildFrameIndex, diffuseSlot, normalSlot, specularSlot); } // Render our siblings if (frame.SiblingFrameIndex != -1) { this.RenderFrame(frame.SiblingFrameIndex, diffuseSlot, normalSlot, specularSlot); } }
public static SdkMeshFile FromFile(D3D11Device device, D3D11DeviceContext deviceContext, string fileName) { if (device == null) { throw new ArgumentNullException(nameof(device)); } if (deviceContext == null) { throw new ArgumentNullException(nameof(deviceContext)); } if (string.IsNullOrEmpty(fileName)) { throw new ArgumentNullException(nameof(fileName)); } var file = new SdkMeshFile { _d3dDevice = device, _d3dDeviceContext = deviceContext, FilePath = fileName, FileDirectory = Path.GetDirectoryName(fileName) }; SdkMeshRawFile rawFile = SdkMeshRawFile.FromFile(file.FilePath); foreach (SdkMeshRawMaterial rawMaterial in rawFile.Materials) { var material = new SdkMeshMaterial(file._d3dDevice, file._d3dDeviceContext, file.FileDirectory, rawMaterial); file.Materials.Add(material); } foreach (SdkMeshRawMesh rawMesh in rawFile.Meshes) { var mesh = new SdkMeshMesh(file._d3dDevice, rawFile, rawMesh); file.Meshes.Add(mesh); } foreach (SdkMeshRawFrame rawFrame in rawFile.Frames) { var frame = new SdkMeshFrame(rawFrame); file.Frames.Add(frame); } string animFilePath = file.FilePath + "_anim"; if (File.Exists(animFilePath)) { SdkMeshRawAnimFile rawAnimFile = SdkMeshRawAnimFile.FromFile(animFilePath); file.AnimationFrameTransformType = rawAnimFile.Header.FrameTransformType; file.AnimationKeysCount = rawAnimFile.Header.NumAnimationKeys; file.AnimationFPS = rawAnimFile.Header.AnimationFPS; foreach (SdkMeshRawAnimFrameData rawFrame in rawAnimFile.AnimationFrames) { var frame = new SdkMeshAnimationFrame(rawFrame); file.AnimationFrames.Add(frame); } for (int index = 0; index < file.AnimationFrames.Count; index++) { SdkMeshFrame frame = file.FindFrame(file.AnimationFrames[index].FrameName); if (frame != null) { frame.UpdateAnimationFrameIndex(index); } } } return(file); }