예제 #1
0
 public override void Render()
 {
     if (!Visible || model.Meshes.Count == 0)
     {
         return;
     }
     TheClient.SetEnts();
     RigidTransform rt = new RigidTransform(Body.Position, Body.Orientation);
     BEPUutilities.Vector3 bmin;
     BEPUutilities.Vector3 bmax;
     RigidTransform.Transform(ref ModelMin, ref rt, out bmin);
     RigidTransform.Transform(ref ModelMax, ref rt, out bmax);
     if (TheClient.MainWorldView.CFrust != null && !TheClient.MainWorldView.CFrust.ContainsBox(bmin, bmax))
     {
         return;
     }
     Matrix4d orient = GetOrientationMatrix();
     Matrix4d mat = transform * (Matrix4d.Scale(ClientUtilities.ConvertD(scale)) * orient * Matrix4d.CreateTranslation(ClientUtilities.ConvertD(GetPosition())));
     TheClient.MainWorldView.SetMatrix(2, mat);
     TheClient.Rendering.SetMinimumLight(0.0f);
     if (model.Meshes[0].vbo.Tex == null)
     {
         TheClient.Textures.White.Bind();
     }
     if (TheClient.CVars.r_fast.ValueB || !TheClient.CVars.r_lighting.ValueB)
     {
         OpenTK.Vector4 sadj = TheRegion.GetSunAdjust();
         float skyl = TheRegion.GetSkyLightBase(GetPosition() + new Location(0, 0, ModelMax.Z));
         TheClient.Rendering.SetColor(new OpenTK.Vector4(sadj.X * skyl, sadj.Y * skyl, sadj.Z * skyl, 1.0f));
     }
     model.Draw(); // TODO: Animation(s)?
 }
예제 #2
0
        /// <summary>
        /// General entity render.
        /// </summary>
        public override void Render()
        {
            if (!Visible || model.Meshes.Count == 0)
            {
                return;
            }
            TheClient.SetEnts();
            RigidTransform rt = new RigidTransform(Body.Position, Body.Orientation);

            RigidTransform.Transform(ref ModelMin, ref rt, out BEPUutilities.Vector3 bmin);
            RigidTransform.Transform(ref ModelMax, ref rt, out BEPUutilities.Vector3 bmax);
            if (TheClient.MainWorldView.CFrust != null && !TheClient.MainWorldView.CFrust.ContainsBox(new Location(bmin), new Location(bmax)))
            {
                return;
            }
            double maxr   = TheClient.CVars.r_modeldistance.ValueF;
            double distsq = GetPosition().DistanceSquared(TheClient.MainWorldView.RenderRelative);

            if (GenBlockShadows && distsq > maxr * maxr) // TODO: LOD-able option?
            {
                // TODO: Rotation?
                model.DrawLOD(GetPosition() + ClientUtilities.ConvertD(transform.ExtractTranslation()), TheClient.MainWorldView);
                return;
            }
            Matrix4d orient = GetOrientationMatrix();
            Matrix4d mat    = (Matrix4d.Scale(ClientUtilities.ConvertD(scale)) * transform
                               * Matrix4d.CreateTranslation(ClientUtilities.ConvertD(new Location(Body.CollisionInformation.LocalPosition)))
                               * orient * Matrix4d.CreateTranslation(ClientUtilities.ConvertD(GetPosition())));

            TheClient.MainWorldView.SetMatrix(2, mat);
            if (!TheClient.MainWorldView.RenderingShadows)
            {
                TheClient.Rendering.SetMinimumLight(0.0f, TheClient.MainWorldView);
            }
            if (model.Meshes[0].vbo.Tex == null)
            {
                TheClient.Textures.White.Bind();
            }
            if (!TheClient.MainWorldView.RenderingShadows && ((TheClient.CVars.r_fast.ValueB && !TheClient.CVars.r_forward_lights.ValueB) || !TheClient.CVars.r_lighting.ValueB))
            {
                OpenTK.Vector4 sadj = TheRegion.GetSunAdjust();
                float          skyl = TheRegion.GetSkyLightBase(GetPosition() + new Location(0, 0, ModelMax.Z));
                TheClient.Rendering.SetColor(new OpenTK.Vector4(sadj.X * skyl, sadj.Y * skyl, sadj.Z * skyl, 1.0f), TheClient.MainWorldView);
            }
            model.Draw(); // TODO: Animation(s)?
        }