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(); } }
void DumpTexture(NovaTexture texture, BabylonTexture babylonTexture, BabylonScene babylonScene) { babylonTexture.level = texture.Level; babylonTexture.hasAlpha = texture.HasAlpha; babylonTexture.coordinatesMode = (int)texture.MapType; if (texture.LoadedTexture.IsCube) { DumpCubeTexture(texture, babylonTexture, babylonScene); return; } babylonTexture.name = texture.Name; babylonTexture.uOffset = texture.UOffset; babylonTexture.vOffset = texture.VOffset; babylonTexture.uScale = texture.UScale; babylonTexture.vScale = texture.VScale; babylonTexture.uAng = texture.UAng; babylonTexture.vAng = texture.VAng; babylonTexture.wAng = texture.WAng; switch (texture.UAddressMode) { case NovaTextureAddress.Wrap: babylonTexture.wrapU = 1; break; case NovaTextureAddress.Mirror: babylonTexture.wrapU = 2; break; case NovaTextureAddress.Clamp: babylonTexture.wrapU = 0; break; } switch (texture.VAddressMode) { case NovaTextureAddress.Wrap: babylonTexture.wrapV = 1; break; case NovaTextureAddress.Mirror: babylonTexture.wrapV = 2; break; case NovaTextureAddress.Clamp: babylonTexture.wrapV = 0; break; } babylonTexture.coordinatesIndex = texture.MapCoordinateIndex; DumpTextureAnimation(texture, babylonTexture); babylonTexture.name = CopyTexture(texture, babylonScene); }
void DumpTextureAnimation(NovaTexture texture, BabylonTexture babylonTexture) { var animations = new List <BabylonAnimation>(); DumpInterpolator("Texture UOffset", "uOffset", texture.UOffsetInterpolator, texture.ParentScene, animations); DumpInterpolator("Texture VOffset", "vOffset", texture.VOffsetInterpolator, texture.ParentScene, animations); DumpInterpolator("Texture UScale", "uScale", texture.UScaleInterpolator, texture.ParentScene, animations); DumpInterpolator("Texture VScale", "vScale", texture.VScaleInterpolator, texture.ParentScene, animations); babylonTexture.animations = animations.ToArray(); }
private void DumpRenderTargetTexture(NovaTexture texture, BabylonTexture babylonTexture, int renderSize, float level, NovaMirroredObjectsList renderList) { babylonTexture.level = level; babylonTexture.hasAlpha = false; babylonTexture.coordinatesMode = (int)NovaTexture.NovaTextureMapType.Projection; babylonTexture.name = texture.Name; babylonTexture.uOffset = texture.UOffset; babylonTexture.vOffset = texture.VOffset; babylonTexture.uScale = texture.UScale; babylonTexture.vScale = texture.VScale; babylonTexture.uAng = texture.UAng; babylonTexture.vAng = texture.VAng; babylonTexture.wAng = texture.WAng; switch (texture.UAddressMode) { case NovaTextureAddress.Wrap: babylonTexture.wrapU = 1; break; case NovaTextureAddress.Mirror: babylonTexture.wrapU = 2; break; case NovaTextureAddress.Clamp: babylonTexture.wrapU = 0; break; } switch (texture.VAddressMode) { case NovaTextureAddress.Wrap: babylonTexture.wrapV = 1; break; case NovaTextureAddress.Mirror: babylonTexture.wrapV = 2; break; case NovaTextureAddress.Clamp: babylonTexture.wrapV = 0; break; } babylonTexture.coordinatesIndex = texture.MapCoordinateIndex; DumpTextureAnimation(texture, babylonTexture); babylonTexture.isRenderTarget = true; babylonTexture.renderTargetSize = renderSize; babylonTexture.renderList = renderList.Select(o => o.ID.ToString()).ToArray(); }
string CopyTexture(NovaTexture texture, BabylonScene babylonScene) { string name = texture.Name; // Data if (!alreadyExportedTextures.Contains(texture.Name + texture.HasAlpha)) { alreadyExportedTextures.Add(texture.Name + texture.HasAlpha); if (Path.GetExtension(texture.Name).ToLower() == ".dds" || Path.GetExtension(texture.Name).ToLower() == ".bmp") { name = Path.GetFileNameWithoutExtension(texture.Name) + ".png"; var alreadyExists = File.Exists(Path.Combine(babylonScene.OutputPath, name)); texture.LoadedTexture.SaveToPNG(Path.Combine(babylonScene.OutputPath, name)); if (!texture.HasAlpha) { var oldPath = Path.Combine(babylonScene.OutputPath, name); var bmp = Image.FromFile(oldPath); name = Path.GetFileNameWithoutExtension(texture.Name) + ".jpg"; bmp.Save(Path.Combine(babylonScene.OutputPath, name), ImageFormat.Jpeg); bmp.Dispose(); if (!alreadyExists) { File.Delete(oldPath); } } } else { var sourceFile = Path.Combine(texture.Directory, texture.Filename); File.Copy(sourceFile, Path.Combine(babylonScene.OutputPath, Path.GetFileName(sourceFile)), true); } } else { if (Path.GetExtension(texture.Name).ToLower() == ".dds" || Path.GetExtension(texture.Name).ToLower() == ".bmp") { name = Path.GetFileNameWithoutExtension(texture.Name) + (texture.HasAlpha ? ".png" : ".jpg"); } } return(name); }
string CopyTexture(NovaTexture texture, BabylonScene babylonScene) { string name = texture.Name; // Data if (!alreadyExportedTextures.Contains(texture.Name + texture.HasAlpha)) { alreadyExportedTextures.Add(texture.Name + texture.HasAlpha); if (Path.GetExtension(texture.Name).ToLower() == ".dds" || Path.GetExtension(texture.Name).ToLower() == ".bmp") { name = Path.GetFileNameWithoutExtension(texture.Name) + ".png"; var alreadyExists = File.Exists(Path.Combine(babylonScene.OutputPath, name)); texture.LoadedTexture.SaveToPNG(Path.Combine(babylonScene.OutputPath, name)); if (!texture.HasAlpha) { var oldPath = Path.Combine(babylonScene.OutputPath, name); var bmp = Image.FromFile(oldPath); name = Path.GetFileNameWithoutExtension(texture.Name) + ".jpg"; bmp.Save(Path.Combine(babylonScene.OutputPath, name), ImageFormat.Jpeg); bmp.Dispose(); if (!alreadyExists) { File.Delete(oldPath); } } } else { var sourceFile = Path.Combine(texture.Directory, texture.Filename); File.Copy(sourceFile, Path.Combine(babylonScene.OutputPath, Path.GetFileName(sourceFile)), true); } } else { if (Path.GetExtension(texture.Name).ToLower() == ".dds" || Path.GetExtension(texture.Name).ToLower() == ".bmp") { name = Path.GetFileNameWithoutExtension(texture.Name) + (texture.HasAlpha ? ".png" : ".jpg"); } } return name; }
void DumpTextureAnimation(NovaTexture texture, BabylonTexture babylonTexture) { var animations = new List<BabylonAnimation>(); DumpInterpolator("Texture UOffset", "uOffset", texture.UOffsetInterpolator, texture.ParentScene, animations); DumpInterpolator("Texture VOffset", "vOffset", texture.VOffsetInterpolator, texture.ParentScene, animations); DumpInterpolator("Texture UScale", "uScale", texture.UScaleInterpolator, texture.ParentScene, animations); DumpInterpolator("Texture VScale", "vScale", texture.VScaleInterpolator, texture.ParentScene, animations); babylonTexture.animations = animations.ToArray(); }
string CopyTexture(NovaTexture texture, BabylonScene babylonScene) { string name = texture.Name; // Data if (!alreadyExportedTextures.Contains(texture.Name)) { alreadyExportedTextures.Add(texture.Name); if (Path.GetExtension(texture.Name).ToLower() == ".dds" || Path.GetExtension(texture.Name).ToLower() == ".bmp") { name = Path.GetFileNameWithoutExtension(texture.Name) + ".png"; texture.LoadedTexture.SaveToPNG(Path.Combine(babylonScene.OutputPath, name)); } else { var sourceFile = Path.Combine(texture.Directory, texture.Filename); File.Copy(sourceFile, Path.Combine(babylonScene.OutputPath, Path.GetFileName(sourceFile)), true); } } else { if (Path.GetExtension(texture.Name).ToLower() == ".dds" || Path.GetExtension(texture.Name).ToLower() == ".bmp") { name = Path.GetFileNameWithoutExtension(texture.Name) + ".png"; } } return name; }