public bool CreateGBuffer(MyMwmData mwmData, int lodNum, ref HashSet <string> setMaterialNames) { UniqueId = MyManagers.IDGenerator.GBufferLods.Generate(); LodNum = lodNum; IB = MyManagers.ModelBuffers.GetOrCreateIB(mwmData); VB0 = MyManagers.ModelBuffers.GetOrCreateVB0(mwmData); VB1 = MyManagers.ModelBuffers.GetOrCreateVB1(mwmData); VertexInputComponents = MyManagers.ModelBuffers.CreateStandardVertexInputComponents(mwmData); m_instanceMaterialsStrategy.Init(); BoundingBox = mwmData.BoundindBox; HighlightSections = null; Parts = new List <MyPart>(); GlassParts = null; int offset = 0; foreach (var mwmPartInfo in mwmData.PartInfos) { // Making of parts is connected to the creating index buffer. It will worth to do it much more connected in future int indicesCount = mwmPartInfo.m_indices.Count; string materialName = mwmPartInfo.GetMaterialName(); if (mwmPartInfo.Technique != MyMeshDrawTechnique.GLASS) { MyMeshDrawTechnique technique = mwmPartInfo.Technique; string cmFilepath = MyMwmUtils.GetColorMetalTexture(mwmPartInfo, mwmData.MwmContentPath); string ngFilepath = MyMwmUtils.GetNormalGlossTexture(mwmPartInfo, mwmData.MwmContentPath); string extFilepath = MyMwmUtils.GetExtensionTexture(mwmPartInfo, mwmData.MwmContentPath); string alphamaskFilepath = MyMwmUtils.GetAlphamaskTexture(mwmPartInfo, mwmData.MwmContentPath); MyStandardMaterial material = MyManagers.Materials.GetOrCreateStandardMaterial(materialName, technique, cmFilepath, ngFilepath, extFilepath, alphamaskFilepath); MyPart part = new MyPart(); part.InitForGBuffer(this, materialName, mwmData.MwmContentPath, mwmPartInfo, material, offset, indicesCount, 0); Parts.Add(part); } else { MyGlassMaterial glassMaterial = MyManagers.Materials.GetGlassMaterial(materialName); MyPart part = new MyPart(); part.InitForGlass(this, mwmPartInfo.GetMaterialName(), glassMaterial, mwmPartInfo.Technique, offset, indicesCount, 0); if (GlassParts == null) { GlassParts = new List <MyPart>(); } GlassParts.Add(part); // glass parts are rendered by different pipeline than the regular "solid" geometry } offset += indicesCount; setMaterialNames.Add(materialName); } return(true); }
// this method will create parts that way, that it will concatenate following parts into single part public bool CreateDepth(MyMwmData mwmData, int lodNum, ref HashSet <string> setMaterialNames) { UniqueId = MyManagers.IDGenerator.DepthLods.Generate(); LodNum = lodNum; IB = MyManagers.ModelBuffers.GetOrCreateIB(mwmData); VB0 = MyManagers.ModelBuffers.GetOrCreateVB0(mwmData); VB1 = null; VertexInputComponents = MyManagers.ModelBuffers.CreateShadowVertexInputComponents(mwmData); m_instanceMaterialsStrategy.Init(); HighlightSections = null; Parts = new List <MyPart>(); GlassParts = null; int indicesStart = 0; int indicesCount = 0; foreach (var mwmPartInfo in mwmData.PartInfos) { string materialName = mwmPartInfo.GetMaterialName(); int partIndicesCount = mwmPartInfo.m_indices.Count; if (MyMwmUtils.NoShadowCasterMaterials.Contains(materialName) && mwmPartInfo.Technique != MyMeshDrawTechnique.GLASS) // glass is not loaded and rendered for GBuffer rendering { // if the current part should be skipped, we will check, whether the previous parts will create a merged part if (indicesCount != 0) { MyPart part = new MyPart(); part.InitForDepth(this, "ShadowProxy", MyMeshDrawTechnique.MESH, indicesStart, indicesCount, 0); Parts.Add(part); } indicesStart += indicesCount; indicesCount = 0; indicesStart += partIndicesCount; } else { indicesCount += partIndicesCount; } setMaterialNames.Add(materialName); } if (indicesCount != 0) { MyPart part = new MyPart(); part.InitForDepth(this, "ShadowProxy", MyMeshDrawTechnique.MESH, indicesStart, indicesCount, 0); Parts.Add(part); } return(true); }
public void Init(MyLod parent, MyMeshSectionInfo info, List <MyPart> parts) { DebugName = info.Name; Parts = new MyPart[info.Meshes.Count]; for (int i = 0; i < Parts.Length; i++) { MyMeshSectionMeshInfo partInfo = info.Meshes[i]; string partName = partInfo.MaterialName; MyPart part = FindPart(parts, partName); int startIndex = part.StartIndex + partInfo.StartIndex; int indicesCount = partInfo.IndexCount; MyRenderProxy.Assert(partInfo.StartIndex + partInfo.IndexCount <= part.IndicesCount, "Section indices referencing indices out of the part"); Parts[i] = new MyPart(); Parts[i].InitForHighlight(parent, partName, part.Technique, startIndex, indicesCount, 0); } }
public bool CreateHighlight(MyMwmData mwmData, int lodNum, ref HashSet <string> setMaterialNames) { UniqueId = -1; LodNum = lodNum; IB = MyManagers.ModelBuffers.GetOrCreateIB(mwmData); VB0 = MyManagers.ModelBuffers.GetOrCreateVB0(mwmData); VB1 = MyManagers.ModelBuffers.GetOrCreateVB1(mwmData); VertexInputComponents = MyManagers.ModelBuffers.CreateShadowVertexInputComponents(mwmData); m_instanceMaterialsStrategy.Init(); BoundingBox = mwmData.BoundindBox; int offset = 0; // a little bit confusion, but for highlights, there is no difference between solid geometry and glass geometry, therefore glass parts are not filled and everything is in the parts Parts = new List <MyPart>(); GlassParts = null; foreach (var mwmPartInfo in mwmData.PartInfos) { string materialName = mwmPartInfo.GetMaterialName(); int indicesCount = mwmPartInfo.m_indices.Count; MyPart part = new MyPart(); part.InitForHighlight(this, mwmPartInfo.GetMaterialName(), mwmPartInfo.Technique, offset, indicesCount, 0); Parts.Add(part); offset += indicesCount; setMaterialNames.Add(materialName); } HighlightSections = null; if (mwmData.SectionInfos != null && mwmData.SectionInfos.Count > 0) { HighlightSections = new Dictionary <string, MySection>(mwmData.SectionInfos.Count); for (int i = 0; i < mwmData.SectionInfos.Count; i++) { MyMeshSectionInfo sectionInfo = mwmData.SectionInfos[i]; MySection section = new MySection(); section.Init(this, sectionInfo, Parts); HighlightSections.Add(sectionInfo.Name, section); } } return(true); }
public bool CreateHighlight(MyMwmData mwmData, int lodNum, ref HashSet <string> setMaterialNames) { UniqueId = -1; LodNum = lodNum; IB = MyManagers.ModelBuffers.GetOrCreateIB(mwmData); VB0 = MyManagers.ModelBuffers.GetOrCreateVB0(mwmData); VB1 = MyManagers.ModelBuffers.GetOrCreateVB1(mwmData); VertexInputComponents = MyManagers.ModelBuffers.CreateShadowVertexInputComponents(mwmData); m_instanceMaterialsStrategy.Init(); BoundingBox = mwmData.BoundindBox; int offset = 0; Parts = new List <MyPart>(); foreach (var mwmPartInfo in mwmData.PartInfos) { string materialName = mwmPartInfo.GetMaterialName(); int indicesCount = mwmPartInfo.m_indices.Count; MyPart part = new MyPart(); part.InitForHighlight(this, mwmPartInfo.GetMaterialName(), mwmPartInfo.Technique, offset, indicesCount, 0); Parts.Add(part); offset += indicesCount; setMaterialNames.Add(materialName); } Sections = null; if (mwmData.SectionInfos != null && mwmData.SectionInfos.Count > 0) { Sections = new Dictionary <string, MySection>(mwmData.SectionInfos.Count); for (int i = 0; i < mwmData.SectionInfos.Count; i++) { MyMeshSectionInfo sectionInfo = mwmData.SectionInfos[i]; MySection section = new MySection(); section.Init(this, sectionInfo, Parts); Sections.Add(sectionInfo.Name, section); } } return(true); }