private void DumpCubeTexture(NovaTexture texture, BabylonTexture babylonTexture, BabylonScene babylonScene) { var textureFilename = Path.Combine(texture.LoadedTexture.Directory, texture.LoadedTexture.Filename); var baseName = Path.GetFileNameWithoutExtension(texture.LoadedTexture.Filename); babylonTexture.isCube = true; babylonTexture.name = baseName; baseName = Path.Combine(babylonScene.OutputPath, baseName); if (!File.Exists(textureFilename)) { texture.LoadedTexture.SaveToDDS(false, textureFilename); } if (!alreadyExportedTextures.Contains(textureFilename)) { alreadyExportedTextures.Add(textureFilename); // Use SharpDX to extract face images var form = new Form { ClientSize = new Size(64, 64) }; var device = new Device(new Direct3D(), 0, DeviceType.Hardware, form.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters(form.ClientSize.Width, form.ClientSize.Height)); var cubeTexture = CubeTexture.FromFile(device, textureFilename); using (var surface = cubeTexture.GetCubeMapSurface(CubeMapFace.PositiveX, 0)) { Surface.ToFile(surface, baseName + "_px.jpg", ImageFileFormat.Jpg); } using (var surface = cubeTexture.GetCubeMapSurface(CubeMapFace.PositiveY, 0)) { Surface.ToFile(surface, baseName + "_py.jpg", ImageFileFormat.Jpg); } using (var surface = cubeTexture.GetCubeMapSurface(CubeMapFace.PositiveZ, 0)) { Surface.ToFile(surface, baseName + "_pz.jpg", ImageFileFormat.Jpg); } using (var surface = cubeTexture.GetCubeMapSurface(CubeMapFace.NegativeX, 0)) { Surface.ToFile(surface, baseName + "_nx.jpg", ImageFileFormat.Jpg); } using (var surface = cubeTexture.GetCubeMapSurface(CubeMapFace.NegativeY, 0)) { Surface.ToFile(surface, baseName + "_ny.jpg", ImageFileFormat.Jpg); } using (var surface = cubeTexture.GetCubeMapSurface(CubeMapFace.NegativeZ, 0)) { Surface.ToFile(surface, baseName + "_nz.jpg", ImageFileFormat.Jpg); } cubeTexture.Dispose(); device.Dispose(); form.Dispose(); } }