public override bool Draw(MyRenderObject renderObject)
        {
            if (base.Draw(renderObject) == false) return false;
          //  if (IsControlledByPlayer()) return true;

            Matrix worldMatrix = WorldMatrix;
            List<MyModelDummy> muzzles = GetMuzzleFlashMatrix();
            Vector3 muzzleFlashPosition = MyUtils.GetTransform(muzzles[m_activeMuzzle].Matrix.Translation, ref worldMatrix);

            // Draw muzzle flash:
            int dt = MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot;
            if (dt <= MyMachineGunConstants.MUZZLE_FLASH_MACHINE_GUN_LIFESPAN && m_muzzleFlashLength > 0)
            {
                MyParticleEffects.GenerateMuzzleFlash(muzzleFlashPosition, worldMatrix.Forward, m_muzzleFlashRadius, m_muzzleFlashLength);
            }

            // Draw smoke:
            if (m_shotSmoke != null)
            {
                m_shotSmoke.UserBirthMultiplier = m_smokeToGenerate;
                m_shotSmoke.WorldMatrix = Matrix.CreateTranslation(muzzleFlashPosition);
            }

            return true;
        }
Exemplo n.º 2
0
        public override bool Draw(MyRenderObject renderObject)
        {
            if (!base.Draw(renderObject))
                return false;            

            return true;
        }
Exemplo n.º 3
0
        public override bool Draw(MyRenderObject renderObject)
        {
            base.Draw(renderObject);

                        //  Draw muzzle flash
            int deltaTime = MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot;
            if (deltaTime <= MyMachineGunConstants.MUZZLE_FLASH_MACHINE_GUN_LIFESPAN)
            {
                float FAKE_RADIUS = MyMwcUtils.GetRandomFloat(0.5f, 1.5f);
                float FAKE_THICKNESS = MyMwcUtils.GetRandomFloat(FAKE_RADIUS - 0.1f, FAKE_RADIUS);
                float FAKE_LENGTH = MyMwcUtils.GetRandomFloat(7, 8);
                float FAKE_ANGLE = MyMwcUtils.GetRandomFloat(0, MathHelper.PiOver2);

                //float colorComponent = 1;
                float colorComponent = 1 - (float)deltaTime / (float)MyMachineGunConstants.MUZZLE_FLASH_MACHINE_GUN_LIFESPAN;
                colorComponent = 1 - (float)Math.Pow(colorComponent, 5);
                colorComponent *= 1.3f;
                //Vector4 color = new Vector4(1.0f, 1.0f, 1.0f, 1);
                Vector4 color = new Vector4(colorComponent, colorComponent, colorComponent, 1);

                Vector3 muzzleInWorldSpace = m_positionMuzzleInWorldSpace + WorldMatrix.Up * 0.2f;

                MyTransparentGeometry.AddLineBillboard(MyTransparentMaterialEnum.MuzzleFlashMachineGunSide, color, muzzleInWorldSpace - WorldMatrix.Forward * 1.0f,
                    WorldMatrix.Forward, FAKE_LENGTH, FAKE_THICKNESS);
                MyTransparentGeometry.AddPointBillboard(MyTransparentMaterialEnum.MuzzleFlashMachineGunFront, color, muzzleInWorldSpace, FAKE_RADIUS, FAKE_ANGLE);
            }
            return true;
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
0
 public override bool Draw(MyRenderObject renderObject)
 {
    // return false;
     if (!MyGuiScreenGamePlay.Static.IsControlledByPlayer(PrefabParent))
     {
         return base.Draw(renderObject);
     }
     return true;
 }
Exemplo n.º 6
0
        public override bool Draw(MyRenderObject renderObject)
        {
            if (MyFakes.STRANGE_PARTICLES_WHEN_DUST_ON_STATIC_ASTEROIDS)
            {
                MyTransparentGeometry.AddPointBillboard(MyTransparentMaterialEnum.Smoke, new Vector4(0.1f, 0.1f, 0.1f, 1.0f),
                    GetPosition(), 800, GetPosition().Length());

                MyTransparentGeometry.AddPointBillboard(MyTransparentMaterialEnum.Smoke, new Vector4(0.1f, 0.1f, 0.1f, 1.0f),
                    GetPosition() + (Vector3.Normalize(MyCamera.Position - this.GetPosition()) * 250f), 300, GetPosition().Length() * 2.564f);
            }

            return base.Draw(renderObject);
        }
Exemplo n.º 7
0
 public override bool Draw(MyRenderObject renderObject = null)
 {
     return base.Draw(renderObject);
 }
 public override bool Draw(MyRenderObject renderObject)
 {
     base.Draw(renderObject);            
     /*if (!IsControlledByPlayer())
     {
         //return base.Draw();
     }
     else
     {
         //DrawCrossHair();
     }*/
     return true;
 }
Exemplo n.º 9
0
 public static void AddRenderObjectToDraw(MyRenderObject renderObject)
 {
     m_renderObjectsToDraw.Add(renderObject);
     m_entitiesToDebugDraw.Add(renderObject.Entity);
 }
Exemplo n.º 10
0
        public override bool Draw(MyRenderObject renderObject = null)
        {
            if (MyMwcFinalBuildConstants.DrawVoxelContentAsBillboards)
                DrawVoxelsAsBillboards();

            return base.Draw(renderObject);
        }
Exemplo n.º 11
0
        //  Draw muzzle flash not matter if in frustum (it's because it's above the frustum)
        public override bool Draw(MyRenderObject renderObject)
        {
            if (base.Draw(renderObject) == false) return false;
            
            m_barrel.Draw();

            if (MyMinerGame.IsPaused())
                return false;

            //  Draw muzzle flash
            int deltaTime = MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot;
            if (deltaTime <= MyMachineGunConstants.MUZZLE_FLASH_MACHINE_GUN_LIFESPAN)
            {
                MyParticleEffects.GenerateMuzzleFlash(m_positionMuzzleInWorldSpace, WorldMatrix.Forward, m_muzzleFlashRadius, m_muzzleFlashLength, MyRender.GetCurrentLodDrawPass() == MyLodTypeEnum.LOD_NEAR);
            }

            if (m_smokeEffect != null)
                m_smokeEffect.Near = MyRender.GetCurrentLodDrawPass() == MyLodTypeEnum.LOD_NEAR;

            return true;
        }
Exemplo n.º 12
0
 public override bool Draw(MyRenderObject renderObject = null)
 {
     if (BuilderActive)
     {
         MyRender.AddRenderObjectToDraw(RenderObjects[0]);
         return true;
     }
     return false;
 }
Exemplo n.º 13
0
        public override bool Draw(MyRenderObject renderObject)
        {
            bool draw = base.Draw(renderObject);

            if (draw && m_hologramState != HologramState.Deactivated)
            {
                Vector3 maxScale = MyHologramConstants.FLICKER_MAX_SIZE * Vector3.One;
                Vector3 minScale = new Vector3(.01f);
                Vector3 clampedScale = Vector3.Clamp(m_scale, minScale, maxScale);
                m_hologramShip.SetWorldMatrix(Matrix.CreateScale(clampedScale) * m_hologramBaseMatrix);

                m_hologramShip.Draw();
            }

            return draw;
        }
Exemplo n.º 14
0
 public override bool Draw(MyRenderObject renderObject)
 {
     bool retval = true;
     retval = base.Draw(renderObject);
          
     return retval;
 }
Exemplo n.º 15
0
        public override bool Draw(MyRenderObject renderObject)
        {
            if (!base.Draw(renderObject))
                return false;

            if (ModelLod0 != null) ModelLod0.LoadInDraw();
            if (ModelLod1 != null) ModelLod1.LoadInDraw();

            return true;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Draws this object's model and return true. If object isn't in frustum or for whatever reason we won't draw it, return false.
        /// </summary>
        /// <returns></returns>
        public override bool Draw(MyRenderObject renderObject = null)
        {
            if (!MyFakes.DRAW_PLAYER_MINER_SHIP)
                return false;

            if (this == MySession.PlayerShip && /*IsRenderingInsidePlayerShip()*/
                MyGuiScreenGamePlay.IsRenderingInsideEntity(MySession.PlayerShip))
            {
                return false;
            }

            float distance = Vector3.Distance(this.GetPosition(), MyCamera.Position);

            //  If camera sits in the player ship, we won't draw the ship, reflector and guns.
            if (Render.MyRender.GetCurrentLodDrawPass() == MyLodTypeEnum.LOD0)
            {
                // TODO: Go ahead and do it in customization screen then!
                //ModelLod0.LoadInDraw(); //if we dont call it here, there will be no GPU data if ship is added through customization screen

                base.Draw(renderObject);

                if (distance < MySmallShipConstants.MAX_UPDATE_DISTANCE)
                {
                    MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Smallship thrusts");
                    DrawEngineThrusts();
                    MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

                    //  We need to draw reflectors always, because they aren't contained in ship's model bounding sphere
                    MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Smallship reflectors LOD0");
                    DrawReflectors();
                    MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                }
            }
            else if (Render.MyRender.GetCurrentLodDrawPass() == MyLodTypeEnum.LOD1 && (ModelLod1 != null))
            {
                // TODO: Go ahead and do it in customization screen then!
                // ModelLod1.LoadInDraw(); //if we dont call it here, there will be no GPU data if ship is added through customization screen

                base.Draw();

                //  We need to draw reflectors always, because they aren't contained in ship's model bounding sphere
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Smallship reflectors LOD1");
                DrawReflectors();
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
            }
            else if (Render.MyRender.GetCurrentLodDrawPass() == MyLodTypeEnum.LOD0 || MyRender.GetCurrentLodDrawPass() == MyLodTypeEnum.LOD_NEAR)
            {
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Smallship thrusts 2");
                DrawEngineThrusts();
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
            }

            if (Render.MyRender.GetCurrentLodDrawPass() != MyLodTypeEnum.LOD1)
            {
                bool drawGuns = true;
                if (this == MySession.PlayerShip)
                {
                    if (!MyGuiScreenGamePlay.Static.IsGameActive() || MyGuiScreenGamePlay.Static.IsEditorActive())
                    {
                        drawGuns = false;
                    }
                }

                if (MyRender.CurrentRenderSetup.CallerID.Value != MyRenderCallerEnum.Main)
                    drawGuns = false;

                drawGuns &= distance < MySmallShipConstants.MAX_UPDATE_DISTANCE;

                if (drawGuns)
                {
                    float maxDistanceForGuns = MyLodConstants.MAX_DISTANCE_FOR_DRAWING_MINER_SHIP_GUNS * (MySession.Is25DSector ?  2 : 1);

                    if (Vector3.Distance(MyCamera.Position, GetPosition()) <= maxDistanceForGuns && Children.Count > 0)
                    {
                        //  Do not draw guns if this is player. Reason is that in large positions guns aren't at precise positions and if viewed from the ship, user will note shakiness.
                        //  But for guns on other players it is not visible.
                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Smallship weapons");
                        Weapons.Draw();
                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                    }
                }
            }

            //  We return true, but in this case it means nothing. Caller don't need it.
            return true;
        }
Exemplo n.º 17
0
        protected override void InitRenderObjects()
        {
            m_renderObjects = new MyRenderObject[RenderCellsCount.X * RenderCellsCount.Y * RenderCellsCount.Z];

            int i = 0;
            MyMwcVector3Int cellCoord;
            for (cellCoord.X = 0; cellCoord.X < RenderCellsCount.X; cellCoord.X++)
            {
                for (cellCoord.Y = 0; cellCoord.Y < RenderCellsCount.Y; cellCoord.Y++)
                {
                    for (cellCoord.Z = 0; cellCoord.Z < RenderCellsCount.Z; cellCoord.Z++)
                    {
                        m_renderObjects[i++] = new MyRenderObject(this, cellCoord);
                    }
                }
            }
        }
Exemplo n.º 18
0
        //  Draw muzzle flash not matter if in frustum (it's because it's above the frustum)
        public override bool Draw(MyRenderObject renderObject)
        {
            if (base.Draw(renderObject) == false) return false;

            //  Draw muzzle flash
            int deltaTime = MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot;
            if (deltaTime <= MyMachineGunConstants.MUZZLE_FLASH_MACHINE_GUN_LIFESPAN)
            {
                MyParticleEffects.GenerateMuzzleFlash(m_positionMuzzleInWorldSpace + WorldMatrix.Forward, WorldMatrix.Forward, 0.4f, 0.7f);
            }

            return true;
        }
Exemplo n.º 19
0
        public override bool Draw(MyRenderObject renderObject)
        {
        //    return base.Draw();

//            if (IsOn())
            {
                Matrix world = WorldMatrix;
                Vector4 color = new Vector4(0f, 0f, 1f, 0.5f);

                if (EntityDetectorType == MyEntityDetectorType.Sphere)
                {
                    MySimpleObjectDraw.DrawTransparentSphere(ref world, m_radius, ref color, true, 1);
                }
                else if (EntityDetectorType == MyEntityDetectorType.Box)
                {
                    BoundingBox bBox = new BoundingBox(-m_extent, m_extent);
                    MySimpleObjectDraw.DrawTransparentBox(ref world, ref bBox, ref color, true, 1);
                }
            }
            return true;
        }
Exemplo n.º 20
0
        public override bool Draw(MyRenderObject renderObject)
        {
            bool retVal = base.Draw(renderObject);

            foreach (MyEntity child in Children)
            {
                child.Draw();
            }

            return retVal;
        }
Exemplo n.º 21
0
        /// <summary>
        /// Draws this object's model and return true. If object isn't in frustum or for whatever reason we won't draw it, return false.
        /// </summary>
        /// <returns></returns>
        public virtual bool Draw(MyRenderObject renderObject = null)
        {
            if (IsVisible())
            {
                MyRender.AddRenderObjectToDraw(renderObject ?? RenderObjects[0]);
                return true;
            }

            return false;
        }
Exemplo n.º 22
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;
        }
Exemplo n.º 23
0
        public override bool Draw(MyRenderObject renderObject)
        {
            var s = base.WorldAABB.Size();
            if (!MyGuiScreenGamePlay.Static.IsGameActive())
            {
                Matrix world = Matrix.CreateWorld(WorldMatrix.Translation, WorldMatrix.Forward, WorldMatrix.Up);
                Vector4 color = Color.Green.ToVector4();
                color.W *= 0.3f;
                BoundingBox localBoundingBox = new BoundingBox(-Size / 2f, Size / 2f);
                MySimpleObjectDraw.DrawTransparentBox(ref world, ref localBoundingBox, ref color, true, 1);
            }
            //base.Draw();

            if (IsWorking())
            {
                m_scanningPart.Draw();
            }
            return true;
        }                                    
Exemplo n.º 24
0
        public override bool Draw(MyRenderObject renderObject)
        {
            if (!base.Draw(renderObject))
                return false;

            //if (IsWorking())
            /*{
                Matrix world = Matrix.CreateWorld(WorldMatrix.Translation + ModelLod0.BoundingSphere.Center, WorldMatrix.Forward, WorldMatrix.Up);
                MyTransparentMaterialEnum? faceMaterial;
                MyTransparentMaterialEnum? lineMaterial;
                Vector4 color;
                SetTransparentParameters(out color, out faceMaterial, out lineMaterial);
                if (faceMaterial.HasValue)
                {
                    BoundingBox localBoundingBox = m_localBoundingBox;
                    MySimpleObjectDraw.DrawTransparentBox(ref world, ref localBoundingBox, ref color, true, 1, faceMaterial, lineMaterial);
                }
            }*/

            return true;
        }
Exemplo n.º 25
0
        /// <summary>
        /// Draw
        /// </summary>
        /// <returns></returns>
        public override bool Draw(MyRenderObject renderObject)
        {
            if (base.Draw(renderObject))
            {
                if (m_lamps != null)
                {
                    for (int i = 0; i < m_lamps.Count; i++)
                    {
                        m_lamps[i].Item1.Draw();
                    }
                }

                if (MyFakes.SHOW_UNPOWERED_PREFABS)
                {
                    m_diffuseColor = ElectricCapacity > 0 ? Vector3.One : Vector3.One * 0.3f;
                }

                /*  //Crashes in parallel update because object could have been deleted
                foreach (MyParticleEffect sparkEffect in m_sparkEffects)
                {
                    //sparkEffect.WasVisibleLastFrame = LastFrameVisibilityEnum.VisibleLastFrame;
                    sparkEffect.RenderCounter = MyRender.RenderCounter;
                } */

                foreach (var effect in m_effects)
                {
                    MyParticlesManager.CustomDraw(effect.Item1);
                }
                if (m_smokeEffects != null)
                {
                    foreach (var effect in m_smokeEffects)
                    {
                        if (effect != null)
                        {
                            MyParticlesManager.CustomDraw(effect);
                        }
                    }
                }
                return true;
            }
            return false;
        }
Exemplo n.º 26
0
 // This method overrides parent draw, that expects that phys object has Model. VoxelHandShape doesnt, so we cant call parent's draw.
 public override bool Draw(MyRenderObject renderObject = null)
 {
     DrawShape();            
     return true;
 }
Exemplo n.º 27
0
        void PrepareCascadesForDraw()
        {
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("UpdateFrustums");

            SunLightDirection = -MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized();
            SunPosition       = 100000 * -SunLightDirection;
            UpdateFrustums();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            // Set casting shadows geometry

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("update entities");

            int frustumIndex = 0;

            foreach (MyOrthographicCamera lightCamera in m_lightCameras)
            {
                if (m_skip[frustumIndex])
                {
                    frustumIndex++;
                    continue;
                }

                m_renderElementsForShadows.Clear();
                m_transparentRenderElementsForShadows.Clear();
                m_castingRenderObjectsUnique.Clear();

                MyRender.GetRenderProfiler().StartProfilingBlock("OverlapAllBoundingBox");


                BoundingBox     castersBox     = lightCamera.BoundingBox;     //Cannot use unscaled - incorrect result because of different cascade viewport size
                BoundingFrustum castersFrustum = lightCamera.BoundingFrustum; //Cannot use unscaled - incorrect result because of different cascade viewport size
                //MyRender.PrepareEntitiesForDraw(ref castersBox, (MyOcclusionQueryID)(frustumIndex + 1), m_castingRenderObjects, m_occlusionQueriesLists[frustumIndex], ref MyPerformanceCounter.PerCameraDraw.ShadowEntitiesOccluded[frustumIndex]);
                MyRender.PrepareEntitiesForDraw(ref castersFrustum, lightCamera.Position, 1, (MyOcclusionQueryID)(frustumIndex + 1), m_castingRenderObjects, m_castingCullObjects, null, ref MyPerformanceCounter.PerCameraDraw.ShadowEntitiesOccluded[frustumIndex]);

                MyRender.GetRenderProfiler().EndProfilingBlock();

                MyRender.GetRenderProfiler().StartProfilingBlock("m_castingRenderObjects");

                int c       = 0;
                int skipped = 0;

                while (c < m_castingRenderObjects.Count)
                {
                    MyRenderObject renderObject = (MyRenderObject)m_castingRenderObjects[c];
                    MyEntity       entity       = renderObject.Entity;

                    //TODO: Appears in Chinese Escape when reloaded several times
                    //System.Diagnostics.Debug.Assert(!entity.NearFlag);

                    if (RespectCastShadowsFlags)
                    {
                        System.Diagnostics.Debug.Assert(!(entity is MyDummyPoint) && !(entity is MinerWars.AppCode.Game.Entities.WayPoints.MyWayPoint));

                        if ((renderObject.ShadowCastUpdateInterval > 0) && ((MyRender.RenderCounter % renderObject.ShadowCastUpdateInterval) == 0))
                        {
                            renderObject.NeedsResolveCastShadow = true;
                            //We have to leave last value, because true when not casting shadow make radiation to ship
                            // renderObject.CastShadow = true;
                        }

                        if (renderObject.NeedsResolveCastShadow)
                        { //Resolve raycast to sun
                            if (renderObject.CastShadowJob == null)
                            {
                                renderObject.CastShadowJob  = new MyCastShadowJob(entity);
                                renderObject.CastShadowTask = ParallelTasks.Parallel.Start(renderObject.CastShadowJob);
                            }
                            else
                            if (renderObject.CastShadowTask.IsComplete)
                            {
                                renderObject.CastShadow             = renderObject.CastShadowJob.VisibleFromSun;
                                renderObject.CastShadowTask         = new ParallelTasks.Task();
                                renderObject.CastShadowJob          = null;
                                renderObject.NeedsResolveCastShadow = false;
                            }
                        }

                        if (!renderObject.NeedsResolveCastShadow && !renderObject.CastShadow)
                        {
                            m_castingRenderObjects.RemoveAtFast(c);
                            skipped++;
                            continue;
                        }
                    }
                    else
                    {
                        renderObject.NeedsResolveCastShadow = true;
                    }

                    /*
                     * //Skip object depending on their size and cascade
                     * if (entity.WorldVolume.Radius < (frustumIndex + 1) * 5)
                     * {
                     *  m_castingRenderObjects.RemoveAtFast(c);
                     *  continue;
                     * }
                     */

                    if (entity != null)
                    {
                        if (!m_castingRenderObjectsUnique.Contains(renderObject))
                        {
                            m_castingRenderObjectsUnique.Add(renderObject);

                            if (frustumIndex < MyRenderConstants.RenderQualityProfile.ShadowCascadeLODTreshold)
                            {
                                if (entity is MyVoxelMap)
                                {
                                    //(entity as MyVoxelMap).GetRenderElementsForShadowmap(m_renderElementsForShadows, ref castersBox, castersFrustum, MyLodTypeEnum.LOD0, true);
                                    (entity as MyVoxelMap).GetRenderElementsForShadowmap(m_renderElementsForShadows, renderObject.RenderCellCoord.Value, MyLodTypeEnum.LOD0, true);
                                }

                                else
                                if (entity.ModelLod0 != null)
                                {
                                    MyRender.CollectRenderElementsForShadowmap(m_renderElementsForShadows, m_transparentRenderElementsForShadows,
                                                                               entity, entity.ModelLod0);
                                }
                            }
                            else
                            {
                                if (entity is MyVoxelMap)
                                {
                                    (entity as MyVoxelMap).GetRenderElementsForShadowmap(m_renderElementsForShadows, renderObject.RenderCellCoord.Value, MyLodTypeEnum.LOD1, true);
                                }
                                else
                                if (entity.ModelLod1 != null)
                                {
                                    MyRender.CollectRenderElementsForShadowmap(m_renderElementsForShadows, m_transparentRenderElementsForShadows,
                                                                               entity, entity.ModelLod1);
                                }
                            }
                        }
                    }

                    c++;
                }

                MyRender.GetRenderProfiler().EndProfilingBlock();

                //Sorting VBs to minimize VB switches
                m_renderElementsForShadows.Sort(m_shadowElementsComparer);

                lightCamera.CastingRenderElements = m_renderElementsForShadows;

                MyPerformanceCounter.PerCameraDraw.RenderElementsInShadows += m_renderElementsForShadows.Count;

                frustumIndex++;
            }

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }
Exemplo n.º 28
0
        public override bool Draw(MyRenderObject renderObject)
        {
            if (base.Draw(renderObject) == false) return false;

            //  Draw flare at the end or back of the missile
            //  Color and range is same as for missile's dynamic light
            if (m_light != null)
            {
                if ((m_initTime - m_elapsedMiliseconds) <= 0)
                {
                    MyTransparentGeometry.AddPointBillboard(MyTransparentMaterialEnum.ReflectorGlareAlphaBlended, m_light.Color,
                        WorldMatrix.Translation - 1.1f * WorldMatrix.Forward * ModelLod0.BoundingSphere.Radius, m_light.Range * 0.02f, 0);
                }
                else
                {
                    float delta = m_elapsedMiliseconds / m_initTime;

                    MyTransparentGeometry.AddPointBillboard(MyTransparentMaterialEnum.ReflectorGlareAlphaBlended, m_light.Color,
                        WorldMatrix.Translation - WorldMatrix.Forward * ModelLod0.BoundingSphere.Radius, m_light.Range * 0.005f * delta * delta, 0);
                }
            }
            return true;
        }
Exemplo n.º 29
0
        public override bool Draw(MyRenderObject renderObject)
        {
            bool drawDebug = MyRender.IsModuleEnabled(MyRenderStage.DebugDraw, MyRenderModuleEnum.InfluenceSpheres);
            var isEditorOrDebugDraw = MyGuiScreenGamePlay.Static.IsEditorActive() || drawDebug;

            if (isEditorOrDebugDraw && MyRender.GetCurrentLodDrawPass() == MyLodTypeEnum.LOD0 && !MyEntities.IsTypeHidden(typeof(MyInfluenceSphere)))
            {
                Matrix worldMatrix = WorldMatrix;

                var innerColor = Color.White.ToVector4();
                var innerSphere = new BoundingSphere(worldMatrix.Translation, RadiusMin);
                MySimpleObjectDraw.DrawTransparentSphere(ref worldMatrix, innerSphere.Radius, ref innerColor, true, 12,
                                                         MyTransparentMaterialEnum.ObjectiveDummyFace,
                                                         MyTransparentMaterialEnum.ObjectiveDummyLine);

                var outerColor = 0.5f * innerColor;
                var outerSphere = new BoundingSphere(worldMatrix.Translation, RadiusMax);
                MySimpleObjectDraw.DrawTransparentSphere(ref worldMatrix, outerSphere.Radius, ref outerColor, true, 12,
                                                         MyTransparentMaterialEnum.ObjectiveDummyFace,
                                                         MyTransparentMaterialEnum.ObjectiveDummyLine);
            }

            return true;
        }