Пример #1
0
        public override bool PrepareRender(ICamera camera, NebulaRenderer nr, SystemRenderer sys)
        {
            var visible = (
                LightOn &&
                Vector3.DistanceSquared(camera.Position, pos) < CULL &&
                camera.Frustum.Intersects(new BoundingSphere(pos, equip.BulbSize * 3))
                );

            this.sys = sys;
            bool showLight = !equip.Animated || !lt_on;

            if (equip.EmitRange > 0 && showLight && camera.Frustum.Intersects(new BoundingSphere(pos, equip.EmitRange)))
            {
                sys.PointLightDX(pos, equip.EmitRange, new Color4(equip.GlowColor, 1), equip.EmitAttenuation);
            }
            if (visible)
            {
                sys.AddObject(this);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        public override bool PrepareRender(ICamera camera, NebulaRenderer nr, SystemRenderer sys)
        {
            _worldSph = World;
            if (Spin != Vector3.Zero)
            {
                _worldSph = (Matrix4x4.CreateRotationX((float)spinX) *
                             Matrix4x4.CreateRotationY((float)spinY) *
                             Matrix4x4.CreateRotationZ((float)spinZ)) * World;
            }
            this.sysr = sys;
            if (Nebula != null && nr != Nebula)
            {
                return(false);
            }
            var dsq = Vector3.DistanceSquared(pos, camera.Position);

            if (LODRanges != null)             //Fastest cull
            {
                var maxd = LODRanges[LODRanges.Length - 1] * sysr.LODMultiplier;
                maxd *= maxd;
                if (dsq > maxd)
                {
                    CurrentLevel = -1;
                    return(false);
                }
            }

            bool visible = false;

            if (Model != null)
            {
                visibleParts = new BitArray128();
                for (int i = 0; i < Model.AllParts.Length; i++)
                {
                    var part = Model.AllParts[i];
                    if (!part.Active || part.Mesh == null)
                    {
                        continue;
                    }
                    var center = Vector3.Transform(part.Mesh.Center, part.LocalTransform * World);
                    var lvl    = GetLevel(part, center, camera.Position);
                    if (lvl != -1)
                    {
                        var bsphere = new BoundingSphere(center, part.Mesh.Radius);
                        if (camera.Frustum.Intersects(bsphere))
                        {
                            visible         = true;
                            visibleParts[i] = true;
                        }
                    }
                }
            }

            if (visible)
            {
                sysr.AddObject(this);
            }
            return(visible);
        }
Пример #3
0
 public override bool PrepareRender(ICamera camera, NebulaRenderer nr, SystemRenderer sys)
 {
     this.sys     = sys;
     dist         = VectorMath.DistanceSquared(pos, camera.Position);
     fx.Resources = sys.Game.ResourceManager;
     if (Active && dist < (20000 * 20000))
     {
         sys.AddObject(this);
         return(true);
     }
     return(false);
 }
Пример #4
0
        public override bool PrepareRender(ICamera camera, NebulaRenderer nr, SystemRenderer sys)
        {
            var position = Vector3.Transform(Vector3.Zero, transform);
            var bsphere  = new BoundingSphere(position, RADIUS);

            if (camera.Frustum.Intersects(bsphere))
            {
                sys.AddObject(this);
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public override bool PrepareRender(ICamera camera, NebulaRenderer nr, SystemRenderer sys)
 {
     beams       = sys.Beams;
     renderCount = 0;
     for (int i = 0; i < Projectiles.Projectiles.Length; i++)
     {
         if (Projectiles.Projectiles[i].Alive)
         {
             toRender[renderCount++] = Projectiles.Projectiles[i];
         }
     }
     if (renderCount > 0)
     {
         sys.AddObject(this);
     }
     return(true);
 }
Пример #6
0
 public override bool PrepareRender(ICamera camera, NebulaRenderer nr, SystemRenderer sys)
 {
     if (fx == null)
     {
         return(false);
     }
     this.sys     = sys;
     cameraPos    = camera.Position;
     dist         = VectorMath.DistanceSquared(pos, camera.Position);
     fx.Resources = sys.ResourceManager;
     if (Active && dist < (20000 * 20000))
     {
         sys.AddObject(this);
         fx.Pool = sys.FxPool;
         return(true);
     }
     fx.Pool = null;
     return(false);
 }
Пример #7
0
 public override bool PrepareRender(ICamera camera, NebulaRenderer nr, SystemRenderer sys)
 {
     beams       = sys.Beams;
     renderCount = 0;
     for (int i = 0; i < Projectiles.Projectiles.Length; i++)
     {
         if (Projectiles.Projectiles[i].Alive)
         {
             if (Projectiles.Projectiles[i].Effect != null)
             {
                 Projectiles.Projectiles[i].Effect.Resources = sys.ResourceManager;
                 Projectiles.Projectiles[i].Effect.Pool      = sys.FxPool;
             }
             toRender[renderCount++] = Projectiles.Projectiles[i];
         }
     }
     if (renderCount > 0)
     {
         sys.AddObject(this);
     }
     return(true);
 }
Пример #8
0
        public override bool PrepareRender(ICamera camera, NebulaRenderer nr, SystemRenderer sys)
        {
            var visible = (
                VectorMath.DistanceSquared(camera.Position, pos) < CULL &&
                camera.Frustum.Intersects(new BoundingSphere(pos, equip.BulbSize * 3))
                );

            this.sys = sys;
            if (visible)
            {
                sys.AddObject(this);
                return(true);
            }
            else
            {
                return(false);
            }

            /*if (lt_on && camera.Frustum.Intersects(new BoundingSphere(pos, 100)))
             *          {
             *                  sys.PointLightDX(pos, 50, new Color4(equip.GlowColor, 1), new Vector3(1, 0.01f, 0.000055f));
             *          }*///TODO: Configurable
        }
Пример #9
0
        public override bool PrepareRender(ICamera camera, NebulaRenderer nr, SystemRenderer sys)
        {
            this.sysr = sys;
            if (Nebula != null && nr != Nebula)
            {
                return(false);
            }
            var dsq = VectorMath.DistanceSquared(pos, camera.Position);

            if (LODRanges != null)             //Fastest cull
            {
                var maxd = LODRanges[LODRanges.Length - 1] * sysr.LODMultiplier;
                maxd *= maxd;
                if (dsq > maxd)
                {
                    return(false);
                }
            }
            if (Model != null)
            {
                if (Model.Levels.Length != 0)
                {
                    var center = VectorMath.Transform(Model.Levels[0].Center, World);
                    var lvl    = GetLevel(Model, center, camera.Position);
                    if (lvl == null)
                    {
                        return(false);
                    }
                    var bsphere = new BoundingSphere(
                        center,
                        Model.Levels[0].Radius
                        );
                    if (!camera.Frustum.Intersects(bsphere))
                    {
                        return(false);                                     //Culled
                    }
                    sys.AddObject(this);
                    return(true);
                }
            }
            else if (Cmp != null || CmpParts != null)
            {
                //Check if -something- renders
                var  partCol  = (IEnumerable <Part>)CmpParts ?? Cmp.Parts;
                bool cmpParts = CmpParts != null;
                foreach (Part p in partCol)
                {
                    if (cmpParts)
                    {
                        p.Update(camera, TimeSpan.Zero, TimeSpan.FromSeconds(sysr.Game.TotalTime));
                    }
                    var     model = p.Model;
                    Matrix4 w     = World;
                    if (p.Construct != null)
                    {
                        w = p.Construct.Transform * World;
                    }
                    if (model.Levels.Length > 0)
                    {
                        var center = VectorMath.Transform(model.Levels[0].Center, w);
                        var lvl    = GetLevel(model, center, camera.Position);
                        if (lvl == null)
                        {
                            continue;
                        }
                        var bsphere = new BoundingSphere(
                            center,
                            model.Levels[0].Radius
                            );
                        if (camera.Frustum.Intersects(bsphere))
                        {
                            sys.AddObject(this);
                            return(true);
                        }
                    }
                }
                return(false);
            }
            else if (Sph != null)
            {
                var bsphere = new BoundingSphere(
                    pos,
                    Math.Max(Sph.Radius, radiusAtmosphere));
                if (!camera.Frustum.Intersects(bsphere))
                {
                    return(false);
                }
                sys.AddObject(this);
                return(true);
            }
            return(false);
        }
Пример #10
0
 public override bool PrepareRender(ICamera camera, NebulaRenderer nr, SystemRenderer sys)
 {
     sysr = sys;
     sys.AddObject(this);
     return(true);
 }