Пример #1
0
        public void Draw(MyEffectDistantImpostors effect)
        {
            LoadInDraw();
            
            Device device = MyMinerGame.Static.GraphicsDevice;
            RasterizerState.CullNone.Apply();
            MyStateObjects.NonPremultiplied_NoAlphaWrite_BlendState.Apply();
            MyStateObjects.DistantImpostorsDepthStencilState.Apply();


            Matrix projection = Matrix.CreatePerspectiveFieldOfView(MyCamera.Zoom.GetFOV(), MyCamera.ForwardAspectRatio, 1000, 10000000);
            effect.SetViewProjectionMatrix(MyCamera.ViewMatrix * projection);
            effect.SetSunDirection(-MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized());
            MyCamera.SetupBaseEffect(effect);

            foreach (MyVoxelMapImpostorGroup group in m_voxelMapImpostorGroups)
            {
                group.Draw(effect, MyImpostorType.Billboards);
            }

            BlendState.NonPremultiplied.Apply();

            foreach (MyVoxelMapImpostorGroup group in m_voxelMapImpostorGroups)
            {
                group.Draw(effect, MyImpostorType.Nebula);
            }
        }
        public void Draw(MyEffectDistantImpostors effect)
        {
            int trianglesCount = m_impostors.Count * MyDistantObjectsImpostorsConstants.TRIANGLES_PER_IMPOSTOR;
            if (trianglesCount <= 0) return;

            CopyToVertexBuffer();

            Device device = MyMinerGame.Static.GraphicsDevice;
            RasterizerState.CullNone.Apply();
            BlendState.NonPremultiplied.Apply();
            DepthStencilState.None.Apply();

            Matrix projection = Matrix.CreatePerspectiveFieldOfView(MyCamera.Zoom.GetFOV(), MyCamera.ForwardAspectRatio, 1000, 10000000);

            effect.SetWorldMatrix(Matrix.CreateTranslation(-MyCamera.Position));
            effect.SetViewProjectionMatrix(MyCamera.ViewMatrix * projection);
            effect.SetSunDirection(-MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized());

            for (int i = 0; i < m_impostorProperties.Length; i++)
            {
                effect.SetImpostorTexture(m_impostorProperties[i].Texture);
                effect.SetTechnique(m_impostorProperties[i].LitBySun ? MyEffectDistantImpostors.Technique.ColoredLit : MyEffectDistantImpostors.Technique.Colored);
                device.DrawUserPrimitives(PrimitiveType.TriangleList, m_impostorProperties[i].IndexStart, MyVoxelMapImpostorsConstants.TRIANGLES_PER_IMPOSTOR * m_impostorProperties[i].Count, m_vertices);              
            }
        }
Пример #3
0
            public void PrepareForDraw(MyEffectDistantImpostors effect)
            {            
                if (!ImpostorProperties.Enabled)
                    return;

                if (ImpostorProperties.ImpostorType == MyImpostorType.Nebula)
                {
                    Matrix mat = Matrix.CreateScale(ImpostorProperties.MinDistance) * Matrix.CreateTranslation(MyCamera.Position * 0.5f);

                    Matrix projection = Matrix.CreatePerspectiveFieldOfView(MyCamera.Zoom.GetFOV(), MyCamera.ForwardAspectRatio, 1000, 10000000);

                    effect.SetWorldMatrix(mat);
                    effect.SetViewProjectionMatrix(MyCamera.ViewMatrix * projection);
                    effect.SetScale(ImpostorProperties.Radius * 0.00018f);
                    effect.SetColor(ImpostorProperties.Color);

                    effect.SetContrastAndIntensity(new Vector2(ImpostorProperties.Contrast, ImpostorProperties.Intensity));
                    effect.SetAnimation(m_animationTime);
                    effect.SetCameraPos(MyCamera.Position);
                    effect.SetSunDirection(-MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized());

                    effect.SetTechnique(MyEffectDistantImpostors.Technique.Textured3D);

                    effect.Begin();
                    MySimpleObjectDraw.ModelSphere.Render();
                    effect.End();
                }  
            }