Exemplo n.º 1
0
        public void InitForHighlight(MyLod parent, string name, MyMeshDrawTechnique technique, int startIndex, int indicesCount,
                                     int startVertex)
        {
            m_shaderBundles = new MyShaderBundle[(int)2];  // the support for highlight is enabled only for 2 techniques
            m_shaderBundles[(int)MyInstanceLodState.Solid] = MyManagers.ShaderBundles.GetShaderBundle(MyRenderPassType.Highlight,
                                                                                                      technique,
                                                                                                      MyInstanceLodState.Solid,
                                                                                                      false,
                                                                                                      false,
                                                                                                      false);

            m_shaderBundles[(int)MyInstanceLodState.Transition] = MyManagers.ShaderBundles.GetShaderBundle(MyRenderPassType.Highlight,
                                                                                                           technique,
                                                                                                           MyInstanceLodState.Transition,
                                                                                                           false,
                                                                                                           false,
                                                                                                           false);

            Parent                      = parent;
            Name                        = name;
            Technique                   = technique;
            StandardMaterial            = null;
            GlassMaterial               = null;
            InstanceMaterialOffsetInLod = -1; // <- not used so far
            StartIndex                  = startIndex;
            IndicesCount                = indicesCount;
            StartVertex                 = startVertex;
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        public void InitForGBuffer(MyLod parent, string name, string contentPath, MyMeshPartInfo mwmPartInfo, MyStandardMaterial standardMaterial,
                                   int startIndex, int indicesCount, int startVertex)
        {
            MyRenderProxy.Assert(StartIndex == 0 && IndicesCount == 0 && StartVertex == 0, "The part has been initialised before!");
            MyRenderProxy.Assert(indicesCount != 0, "Invalid input");

            bool isCmTexture  = !string.IsNullOrEmpty(MyMwmUtils.GetColorMetalTexture(mwmPartInfo, contentPath));
            bool isNgTexture  = !string.IsNullOrEmpty(MyMwmUtils.GetNormalGlossTexture(mwmPartInfo, contentPath));
            bool isExtTexture = !string.IsNullOrEmpty(MyMwmUtils.GetExtensionTexture(mwmPartInfo, contentPath));

            Technique       = mwmPartInfo.Technique;
            m_shaderBundles = new MyShaderBundle[(int)MyInstanceLodState.StatesCount];
            m_shaderBundles[(int)MyInstanceLodState.Solid] = MyManagers.ShaderBundles.GetShaderBundle(MyRenderPassType.GBuffer,
                                                                                                      Technique,
                                                                                                      MyInstanceLodState.Solid,
                                                                                                      isCmTexture,
                                                                                                      isNgTexture,
                                                                                                      isExtTexture);
            m_shaderBundles[(int)MyInstanceLodState.Transition] = MyManagers.ShaderBundles.GetShaderBundle(MyRenderPassType.GBuffer,
                                                                                                           Technique,
                                                                                                           MyInstanceLodState.Transition,
                                                                                                           isCmTexture,
                                                                                                           isNgTexture,
                                                                                                           isExtTexture);
            m_shaderBundles[(int)MyInstanceLodState.Hologram] = MyManagers.ShaderBundles.GetShaderBundle(MyRenderPassType.GBuffer,
                                                                                                         Technique,
                                                                                                         MyInstanceLodState.Hologram,
                                                                                                         isCmTexture,
                                                                                                         isNgTexture,
                                                                                                         isExtTexture);
            m_shaderBundles[(int)MyInstanceLodState.Dithered] = MyManagers.ShaderBundles.GetShaderBundle(MyRenderPassType.GBuffer,
                                                                                                         Technique,
                                                                                                         MyInstanceLodState.Dithered,
                                                                                                         isCmTexture,
                                                                                                         isNgTexture,
                                                                                                         isExtTexture);
            Parent                      = parent;
            Name                        = name;
            StandardMaterial            = standardMaterial;
            GlassMaterial               = null;
            InstanceMaterialOffsetInLod = -1; // <- not used so far
            StartIndex                  = startIndex;
            IndicesCount                = indicesCount;
            StartVertex                 = startVertex;
        }
Exemplo n.º 4
0
        // The mwmData will be loaded and if there are link to another files with lods, they will be loaded
        bool LoadFromMwmData(MyMwmData firstLodMwmData, ICreateLodStrategy strategy)
        {
            m_tmpAllMaterialNames.Clear();
            MyLod firstLods = new MyLod();

            if (!strategy.CreateLod(firstLods, firstLodMwmData, 0, ref m_tmpAllMaterialNames))
            {
                MyRender11.Log.WriteLine(string.Format("Mwm '{0}' cannot be loaded as the 1st lod", firstLodMwmData.MwmFilepath));
                return(false);
            }

            // if no lods are specified inside of the mwm, models with the single lod will be created:
            if (firstLodMwmData.Lods.Length == 0)
            {
                CreateFromSingleLod(firstLods);
            }
            else // otherwise all lods will be loaded and initilised:
            {
                m_lodStrategyInfo.Init(firstLodMwmData.Lods);
                List <MyLod> multipleLods = new List <MyLod>();
                multipleLods.Add(firstLods);
                for (int i = 0; i < firstLodMwmData.Lods.Length; i++)
                {
                    string lodFilepath = firstLodMwmData.Lods[i].GetModelAbsoluteFilePath(firstLodMwmData.MwmFilepath);

                    MyLod     lod     = new MyLod();
                    MyMwmData mwmData = new MyMwmData();
                    if (!mwmData.LoadFromFile(lodFilepath))
                    {
                        MyRender11.Log.WriteLine(string.Format("Mwm '{0}' cannot be loaded as the other lod", lodFilepath));
                        continue;
                    }
                    strategy.CreateLod(lod, mwmData, i + 1, ref m_tmpAllMaterialNames);
                    multipleLods.Add(lod);
                }
                CreateFromMultipleLods(multipleLods);

                m_lodStrategyInfo.ReduceLodsCount(m_lods.Count);
            }

            m_instanceMaterialStrategy.Init(m_tmpAllMaterialNames);

            return(true);
        }
Exemplo n.º 5
0
        public void InitForDepth(MyLod parent, string name, MyMeshDrawTechnique technique, int startIndex, int indicesCount,
                                 int startVertex)
        {
            m_shaderBundles = new MyShaderBundle[(int)1];  // only solid rendering is enabled
            m_shaderBundles[(int)MyInstanceLodState.Solid] = MyManagers.ShaderBundles.GetShaderBundle(MyRenderPassType.Depth,
                                                                                                      technique,
                                                                                                      MyInstanceLodState.Solid,
                                                                                                      false,
                                                                                                      false,
                                                                                                      false);

            Parent                      = parent;
            Name                        = name;
            Technique                   = technique;
            StandardMaterial            = null;
            InstanceMaterialOffsetInLod = -1; // <- not used so far
            StartIndex                  = startIndex;
            IndicesCount                = indicesCount;
            StartVertex                 = startVertex;
        }
Exemplo n.º 6
0
 void CreateFromSingleLod(MyLod lod)
 {
     MyRenderProxy.Assert(m_lods == null);
     m_lods = new List <MyLod>();
     m_lods.Add(lod);
 }
Exemplo n.º 7
0
 public bool CreateLod(MyLod lod, MyMwmData lodMwmData, int lodNum, ref HashSet <string> setMaterialNames)
 {
     // material names set should not be applied
     return(lod.CreateHighlight(lodMwmData, lodNum, ref setMaterialNames));
 }
Exemplo n.º 8
0
 public bool CreateLod(MyLod lod, MyMwmData lodMwmData, int lodNum, ref HashSet <string> setMaterialNames)
 {
     return(lod.CreateGBuffer(lodMwmData, lodNum, ref setMaterialNames));
 }