Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override bool Draw(MyRenderObject renderObject)
        {
            bool drawOk = base.Draw(renderObject);

            if (drawOk)
            {
                if (m_particleEffect != null)
                {
                    MyParticlesManager.CustomDraw(m_particleEffect);
                }
            }

            return(drawOk);
        }
Пример #2
0
        public override bool Draw(MyRenderObject renderObject)
        {
            if (Render.MyRender.GetCurrentLodDrawPass() == MyLodTypeEnum.LOD0)
            {
                if (IsDummyVisible())
                {
                    base.Draw(renderObject);

                    Vector4 color;
                    switch (DummyFlags)
                    {
                    case MyDummyPointFlags.NONE: color = new Vector4(0.5f, 0.7f, 0.1f, 0.3f); break;

                    case MyDummyPointFlags.SAFE_AREA: color = new Vector4(0.2f, 0.3f, 0.22f, 0.1f); break;

                    case MyDummyPointFlags.DETECTOR: color = new Vector4(0.12f, 0.1f, 0.7f, 0.3f); break;

                    case MyDummyPointFlags.PARTICLE: color = new Vector4(0.6f, 0.05f, 0.1f, 0.3f); break;

                    default: color = new Vector4(0.6f, 0.6f, 0.7f, 0.3f); break;
                    }
                    if ((DummyFlags & MyDummyPointFlags.COLOR_AREA) != 0)
                    {
                        color = Color;  // color Color areas with their area color (overriding the default color). I like to write "color".
                    }
                    Matrix worldMatrix = WorldMatrix;

                    if ((int)(DummyFlags & MyDummyPointFlags.TEXTURE_QUAD) > 0)
                    {
                        BoundingBox localAABB = LocalAABB;
                        MySimpleObjectDraw.DrawWireFramedBox(ref worldMatrix, ref localAABB, ref color, 0.01f, 1, LineMaterial);

                        if (!string.IsNullOrEmpty(Name))
                        {
                            //var tex = MinerWars.AppCode.Game.Textures.MyTextureManager.GetTexture<MinerWars.AppCode.Game.Textures.MyTexture2D>(Name);
                            int i = 0;
                            foreach (MyTransparentMaterialEnum trEnum in Enum.GetValues(typeof(MyTransparentMaterialEnum)))
                            {
                                if (MyTransparentMaterialConstants.MyTransparentMaterialStrings[i] == Name)
                                {
                                    Vector4 quadColor = Vector4.One;
                                    MyQuad  quad;
                                    Vector3 position     = GetPosition();
                                    Vector3 zeroPosition = Vector3.Zero;

                                    var   texture = MyTransparentGeometry.GetTexture(trEnum);
                                    float ratio   = texture.Height / (float)texture.Width;

                                    MyUtils.GenerateQuad(out quad, ref position, WorldAABB.Size().X *ratio, WorldAABB.Size().X, ref worldMatrix);
                                    MyTransparentGeometry.AddQuad(trEnum, ref quad, ref quadColor, ref position);
                                }
                                i++;
                            }
                        }
                    }
                    else
                    {
                        if (Type == MyDummyPointType.Box)
                        {
                            BoundingBox localAABB = LocalAABB;
                            MySimpleObjectDraw.DrawTransparentBox(ref worldMatrix, ref localAABB, ref color, true, 1, FaceMaterial, LineMaterial);
                        }
                        else
                        {
                            BoundingSphere localSphere = new BoundingSphere(worldMatrix.Translation, Radius);
                            MySimpleObjectDraw.DrawTransparentSphere(ref worldMatrix, localSphere.Radius, ref color, true, 12, FaceMaterial, LineMaterial);
                        }
                    }
                }

                if (ParticleEffect != null && IsVisible() && Enabled)
                {
                    Vector4 particleColor = Color == Vector4.Zero ? Vector4.One : Color;
                    ParticleEffect.UserColorMultiplier = particleColor;
                    ParticleEffect.UserScale           = UserScale;

                    UpdateWorldVolume();

                    MyParticlesManager.CustomDraw(ParticleEffect);
                }
            }

            return(false);
        }