public void TestLoadTexture() { XNAGame game = new XNAGame(); TexturePool pool = new TexturePool(); game.AddXNAObject(pool); game.DrawFps = true; RAMTexture tex = DefaultMeshes.GetTestTexture(); game.DrawEvent += delegate { //We should do this ACTUALLY in real usage situations, but it proves we cache the data. game.SpriteBatch.Begin(); int row = 0; int col = 0; int width = 10; for (int i = 0; i < 100; i++) { row = i / width; col = i % width; game.SpriteBatch.Draw(pool.LoadTexture(tex), new Rectangle(10 + col * 40, 10 + row * 40, 40, 40), Color.White); } game.SpriteBatch.End(); }; game.Run(); }
private ITexture findDiskTexture(string filePath) { if (!System.IO.File.Exists(filePath)) { Console.WriteLine("Texture not found on disk: (" + filePath + ")"); return(null); } var searchTex = textureFactory.FindTexture(delegate(ITexture tex) { var data = tex.GetCoreData(); return(data.StorageType == TextureCoreData.TextureStorageType.Disk && data.DiskFilePath == filePath); }); if (searchTex != null) { return(searchTex); } var ret = new RAMTexture(); ret.GetCoreData().StorageType = TextureCoreData.TextureStorageType.Disk; ret.GetCoreData().DiskFilePath = filePath; textureFactory.AddTexture(ret); return(ret); }
private static RAMTexture createTexture(string filename) { var tex = new RAMTexture(); var data = tex.GetCoreData(); data.StorageType = TextureCoreData.TextureStorageType.Disk; data.DiskFilePath = filename; return(tex); }
static DCFiles() { UVCheckerMap10_512 = createTexture( TWDir.GameData.CreateSubdirectory(@"Rendering\UVChecker-map\UVCheckerMaps") .GetFile("UVCheckerMap10-512.png") .FullName); UVCheckerMap11_512 = createTexture( TWDir.GameData.CreateSubdirectory(@"Rendering\UVChecker-map\UVCheckerMaps") .GetFile("UVCheckerMap11-512.png") .FullName); }
public static RAMTexture loadTexture(string file) { var tex = new RAMTexture(); var data = tex.GetCoreData(); data.StorageType = TextureCoreData.TextureStorageType.Disk; data.DiskFilePath = file; /*data.StorageType = TextureCoreData.TextureStorageType.Assembly; * data.Assembly = Assembly.GetExecutingAssembly(); * data.AssemblyResourceName = "MHGameWork.TheWizards.Tests.OBJParser.Files.maps.BrickRound0030_7_S.jpg";*/ return(tex); }
public static RAMTexture GetTestTexture() { var tex = new RAMTexture(); var data = tex.GetCoreData(); data.StorageType = TextureCoreData.TextureStorageType.Disk; data.DiskFilePath = TWDir.GameData.CreateSubdirectory("Core").FullName + "\\nova.png"; /*data.StorageType = TextureCoreData.TextureStorageType.Assembly; * data.Assembly = Assembly.GetExecutingAssembly(); * data.AssemblyResourceName = "MHGameWork.TheWizards.Tests.OBJParser.Files.maps.BrickRound0030_7_S.jpg";*/ return(tex); }
public void TestExport() { var tex = new RAMTexture(); tex.GetCoreData().DiskFilePath = "trolo.png"; var mesh = UtilityMeshes.CreateBoxWithTexture(tex, new Vector3(10, 10, 10)); var exporter = new OBJExporter(); var objMesh = exporter.ConvertFromTWMesh(mesh); exporter.SaveToFile(objMesh, TWDir.GameData.CreateSubdirectory("Scattered\\Tests").FullName + "\\OBJExporterTrolo.obj"); }
private ITexture findAssemblyTexture(string filePath) { var fi = new FileInfo(filePath); for (int i = 0; i < resolvePaths.Count; i++) { var rp = resolvePaths[i]; var names = rp.Assembly.GetManifestResourceNames(); for (int j = 0; j < names.Length; j++) { var name = names[j]; if (!name.StartsWith(rp.Path)) { continue; } if (name.Substring(rp.Path.Length + 1) != fi.Name) { continue; } var searchTex = textureFactory.FindTexture(delegate(ITexture tex) { var data = tex.GetCoreData(); return(data.StorageType == TextureCoreData.TextureStorageType.Assembly && data.Assembly == rp.Assembly && data.AssemblyResourceName == name); }); if (searchTex != null) { return(searchTex); } var ret = new RAMTexture(); ret.GetCoreData().StorageType = TextureCoreData.TextureStorageType.Assembly; ret.GetCoreData().Assembly = rp.Assembly; ret.GetCoreData().AssemblyResourceName = name; textureFactory.AddTexture(ret); return(ret); } } return(null); }
public void TestExportComplex() { var tex = new RAMTexture(); tex.GetCoreData().DiskFilePath = "trolo.png"; var meshFact = new EngineMeshFactory(new RAMTextureFactory()); var mesh = meshFact.loadMeshFromFile(TWDir.GameData.FullName + "\\Core\\MerchantsHouse.obj", TWDir.GameData.FullName + "\\Core\\MerchantsHouse.mtl", "MerchantsHouse.mtl"); var exporter = new OBJExporter(); var objMesh = exporter.ConvertFromTWMesh(mesh); exporter.SaveToFile(objMesh, TWDir.GameData.CreateSubdirectory("Scattered\\Tests").FullName + "\\OBJExporterHouse.obj"); }
public VoxelCustomRenderer(DX11Game game, DeferredRenderer dRenderer, DualContouringMeshBuilder dcMeshBuilder, DualContouringAlgorithm dcAlgo, MeshRenderDataFactory renderDataFactory) { this.game = game; this.dRenderer = dRenderer; this.dcMeshBuilder = dcMeshBuilder; this.dcAlgo = dcAlgo; this.renderDataFactory = renderDataFactory; var tex = new RAMTexture(); defaultMaterial = new DCVoxelMaterial() { Texture = DCFiles.UVCheckerMap11_512 }; objectBuffer = DeferredMaterial.CreatePerObjectCB(game); }
public void TestLoadTexture() { DX11Game game = new DX11Game(); var pool = new TexturePool(game); RAMTexture tex = RenderingTestsHelper.GetTestTexture(); game.GameLoopEvent += delegate { //We should do this ACTUALLY in real usage situations, but it proves we cache the data. int row = 0; int col = 0; int width = 10; for (int i = 0; i < 100; i++) { row = i / width; col = i % width; game.TextureRenderer.Draw(pool.LoadTexture(tex), new Vector2(10 + col * 40, 10 + row * 40), new Vector2(40, 40)); } }; game.Run(); }