public LatexEngine() { this.texWrapper_ = new TexWrapper(); this.AddEscapeSequenze(@"%##", @"##%"); this.AddEscapeSequenze(@"\verb|##", @"##|"); this.AddEscapeSequenze(@"\verb$##", @"##$"); // Regex does not work pretty good if you want to use groups in Regex. At the moment its not necessary //this.AddEscapeSequenzeRegex(@"\\verb.\#\#", @"\#\#."); //this.AddEscapeSequenzeRegex(@"\\verb(?<k84>.)\#\#", @"\#\#\k<k84>"); this.AddEscapeSequenze(@"\begin{comment}##", @"##\end{comment}"); }
public LatexEngine(FileInfo configFile) : this() { this.texWrapper_ = new TexWrapper(configFile); }
public LatexEngine(TexConfig config) : this() { this.texWrapper_ = new TexWrapper(config); }
public void Initialize(Device device, string sceneName) { m_ObjectLoader.Load(sceneName + ".obj"); m_ObjectLoader.LoadMaterials(sceneName + ".mtl"); m_MaterialsResources = new TexWrapper[m_ObjectLoader.m_MatTexMappingDiffuse.Count]; int counter = 0; foreach (var v in m_ObjectLoader.m_MatTexMappingDiffuse) { TexWrapper tex = new TexWrapper(); bool found = false; foreach (var t in m_MaterialsResources) { if (t.textureName == v.Value) { tex.name = v.Key; tex.textureName = v.Value; tex.textureObject = t.textureObject; tex.textureSrv = t.textureSrv; found = true; break; } } if (!found) { tex.name = v.Key; tex.textureName = v.Value; try { tex.textureObject = Texture2D.FromFile(device, v.Value); tex.textureSrv = new ShaderResourceView(device, tex.textureObject); } catch { tex.textureObject = null; tex.textureSrv = null; } } m_MaterialsResources[counter++] = tex; } int numVertices = m_ObjectLoader.m_Vertices.Count; int numIndices = m_ObjectLoader.m_Indices.Count; // create test vertex data, making sure to rewind the stream afterward var vertices = new DataStream(8 * sizeof(System.Single) * numVertices, true, true); foreach (var vertex in m_ObjectLoader.m_Vertices) { vertices.Write(new Vector3(vertex.x, vertex.y, vertex.z)); Vector3 normal = new Vector3(vertex.nx, vertex.ny, vertex.nz); vertices.Write(normal); Vector2 uv = new Vector2(vertex.u, vertex.v); vertices.Write(uv); } vertices.Position = 0; var indices = new DataStream(sizeof(System.Int32) * numIndices, true, true); foreach (var index in m_ObjectLoader.m_Indices) { indices.Write(index); } indices.Position = 0; // create the vertex layout and buffer var elements = new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0), new InputElement("NORMAL", 0, Format.R32G32B32_Float, 0), new InputElement("TEXCOORD", 0, Format.R32G32_Float, 0) }; m_SceneInputLayout = new InputLayout(device, ShaderManager.GetVertexShaderSignature("VertexScene"), elements); m_VertexBuffer = new Buffer(device, vertices, 8 * sizeof(System.Single) * numVertices, ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0); m_IndexBuffer = new Buffer(device, indices, 4 * numIndices, ResourceUsage.Default, BindFlags.IndexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0); }
public void Initialize(Device device, string sceneName) { m_ObjectLoader.Load(sceneName + ".obj"); m_ObjectLoader.LoadMaterials(sceneName + ".mtl"); m_MaterialsResources = new TexWrapper[m_ObjectLoader.m_MatTexMappingDiffuse.Count]; int counter = 0; foreach (var v in m_ObjectLoader.m_MatTexMappingDiffuse) { TexWrapper tex = new TexWrapper(); tex.name = v.Key; tex.textureNameDiffuse = v.Value; // try to find bump texture or revert to default string bumpTexName = "textures\\default_n.dds"; if (m_ObjectLoader.m_MatTexMappingNormalMap.ContainsKey(v.Key)) { bumpTexName = m_ObjectLoader.m_MatTexMappingNormalMap[v.Key]; } tex.textureNameBump = bumpTexName; try { tex.textureObjectDiffuse = Texture2D.FromFile(device, v.Value); tex.textureSrvDiffuse = new ShaderResourceView(device, tex.textureObjectDiffuse); tex.textureObjectBump = Texture2D.FromFile(device, tex.textureNameBump); tex.textureSrvBump = new ShaderResourceView(device, tex.textureObjectBump); } catch { tex.textureObjectDiffuse = null; tex.textureSrvDiffuse = null; tex.textureObjectBump = null; tex.textureSrvBump = null; } m_MaterialsResources[counter++] = tex; } int numVertices = m_ObjectLoader.m_Vertices.Count; int numIndices = m_ObjectLoader.m_Indices.Count; // create test vertex data, making sure to rewind the stream afterward var vertices = new DataStream(8 * sizeof(System.Single) * numVertices, true, true); foreach (var vertex in m_ObjectLoader.m_Vertices) { vertices.Write(new Vector3(vertex.x, vertex.y, vertex.z)); Vector3 normal = new Vector3(vertex.nx, vertex.ny, vertex.nz); vertices.Write(normal); Vector2 uv = new Vector2(vertex.u, vertex.v); vertices.Write(uv); } vertices.Position = 0; var indices = new DataStream(sizeof(System.Int32) * numIndices, true, true); foreach (var index in m_ObjectLoader.m_Indices) { indices.Write(index); } indices.Position = 0; // create the vertex layout and buffer var elements = new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0), new InputElement("NORMAL", 0, Format.R32G32B32_Float, 0), new InputElement("TEXCOORD", 0, Format.R32G32_Float, 0) }; m_SceneInputLayout = new InputLayout(device, ShaderManager.GetVertexShaderSignature("VertexScene"), elements); m_VertexBuffer = new Buffer(device, vertices, 8 * sizeof(System.Single) * numVertices, ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0); m_IndexBuffer = new Buffer(device, indices, 4 * numIndices, ResourceUsage.Default, BindFlags.IndexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0); }