Beispiel #1
0
        public override void Render()
        {
            if (!Visible)
            {
                return;
            }
            TheClient.SetEnts();
            BEPUutilities.RigidTransform rt = new BEPUutilities.RigidTransform(GetPosition().ToBVector(), GetOrientation());
            BEPUutilities.Vector3        bmin;
            BEPUutilities.Vector3        bmax;
            BEPUutilities.RigidTransform.Transform(ref ModelMin, ref rt, out bmin);
            BEPUutilities.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    = (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();
            }
            model.Draw(); // TODO: Animation?
        }
Beispiel #2
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)?
 }
Beispiel #3
0
 public void RenderPlants()
 {
     if (TheClient.CVars.r_plants.ValueB)
     {
         TheClient.SetEnts();
         RenderGrass();
     }
 }
Beispiel #4
0
        public override void Render()
        {
            TheClient.SetEnts();
            TheClient.Textures.White.Bind();
            Matrix4d mat = Matrix4d.Scale(0.05f, 0.2f, 0.05f) * GetTransformationMatrix();

            TheClient.MainWorldView.SetMatrix(2, mat);
            TheClient.Rendering.SetColor(GColor);
            model.Draw();
            TheClient.Rendering.SetColor(Color4.White);
        }
Beispiel #5
0
 public override void Render()
 {
     if (NeedsRender)
     {
         NeedsRender = false;
         if (Text != pText)
         {
             Destroy();
             pText = Text;
         }
         size = TheClient.FontSets.Standard.MeasureFancyLinesOfText(Text);
         if (GLTexture <= 0)
         {
             GLTexture = GL.GenTexture();
             GL.BindTexture(TextureTarget.Texture2D, GLTexture);
             GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)size.X + 2, (int)size.Y + 2, 0, OpenTK.Graphics.OpenGL4.PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
             GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
             GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
             GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
             GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);
             GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureCompareMode, (int)TextureCompareMode.CompareRefToTexture);
             GLFBO = GL.GenFramebuffer();
             GL.BindFramebuffer(FramebufferTarget.Framebuffer, GLFBO);
             GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, GLTexture, 0);
             GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
         }
         GL.BindFramebuffer(FramebufferTarget.Framebuffer, GLFBO);
         if (!TheClient.MainWorldView.BufferDontTouch)
         {
             GL.DrawBuffer(DrawBufferMode.ColorAttachment0);
         }
         GL.Disable(EnableCap.DepthTest);
         GL.Disable(EnableCap.CullFace);
         GL.Viewport(0, 0, (int)size.X, (int)size.Y);
         GL.ClearBuffer(ClearBuffer.Color, 0, new float[] { BackColor.X, BackColor.Y, BackColor.Z, BackColor.W });
         TheClient.Ortho = Matrix4.CreateOrthographicOffCenter(0, (float)size.X, (float)size.Y, 0, -1, 1);
         TheClient.FontSets.Standard.DrawColoredText("^0" + Text, new Location(1, 1, 0), int.MaxValue, 1, true, "^r^0");
         GL.BindFramebuffer(FramebufferTarget.Framebuffer, TheClient.MainWorldView.cFBO);
         TheClient.MainWorldView.SetViewPort();
         GL.Enable(EnableCap.DepthTest);
         GL.Enable(EnableCap.CullFace);
         if (!TheClient.MainWorldView.BufferDontTouch)
         {
             GL.DrawBuffer(TheClient.MainWorldView.BufferMode);
         }
     }
     NeedsRender     = true; // TEMP.
     TheClient.isVox = true;
     TheClient.SetEnts();
     GL.BindTexture(TextureTarget.Texture2D, GLTexture);
     GL.Disable(EnableCap.CullFace);
     TheClient.Rendering.RenderBillboard(Position, Scale * new Location(size.X * -0.01, size.Y * 0.01, 1f), TheClient.MainWorldView.CameraPos, TheClient.MainWorldView, (float)Math.PI * 0.5f);
     GL.Enable(EnableCap.CullFace);
 }
 public override void Render()
 {
     TheClient.SetEnts();
     if (TheClient.RenderTextures)
     {
         TheClient.Textures.White.Bind();
     }
     if (model != null)
     {
         TheClient.Rendering.SetMinimumLight(0f);
         BEPUutilities.Matrix matang = BEPUutilities.Matrix.CreateFromQuaternion(Angles);
         //matang.Transpose();
         Matrix4d matang4 = new Matrix4d(matang.M11, matang.M12, matang.M13, matang.M14,
                                         matang.M21, matang.M22, matang.M23, matang.M24,
                                         matang.M31, matang.M32, matang.M33, matang.M34,
                                         matang.M41, matang.M42, matang.M43, matang.M44);
         Matrix4d mat = matang4 * Matrix4d.CreateTranslation(ClientUtilities.ConvertD(GetPosition()));
         TheClient.MainWorldView.SetMatrix(2, mat);
         model.Draw(); // TODO: Animation?
         if (model.Name == "projectiles/arrow.dae")
         {
             float offs = 0.1f;
             BEPUutilities.Vector3 offz;
             BEPUutilities.Quaternion.TransformZ(offs, ref Angles, out offz);
             BEPUutilities.Vector3 offx;
             BEPUutilities.Quaternion.TransformX(offs, ref Angles, out offx);
             TheClient.Particles.Engine.AddEffect(ParticleEffectType.LINE, (o) => ppos + new Location(offz),
                                                  (o) => Position + new Location(offz), (o) => 1f, 1f, Location.One,
                                                  Location.One, true, TheClient.Textures.GetTexture("common/smoke"), 0.5f);
             TheClient.Particles.Engine.AddEffect(ParticleEffectType.LINE, (o) => ppos - new Location(offz),
                                                  (o) => Position - new Location(offz), (o) => 1f, 1f, Location.One,
                                                  Location.One, true, TheClient.Textures.GetTexture("common/smoke"), 0.5f);
             TheClient.Particles.Engine.AddEffect(ParticleEffectType.LINE, (o) => ppos + new Location(offx),
                                                  (o) => Position + new Location(offx), (o) => 1f, 1f, Location.One,
                                                  Location.One, true, TheClient.Textures.GetTexture("common/smoke"), 0.5f);
             TheClient.Particles.Engine.AddEffect(ParticleEffectType.LINE, (o) => ppos - new Location(offx),
                                                  (o) => Position - new Location(offx), (o) => 1f, 1f, Location.One,
                                                  Location.One, true, TheClient.Textures.GetTexture("common/smoke"), 0.5f);
             ppos = Position;
         }
     }
     else
     {
         TheClient.Rendering.SetMinimumLight(1f);
         TheClient.Rendering.SetColor(Color4.DarkRed);
         TheClient.Rendering.RenderCylinder(GetPosition(), GetPosition() - Velocity / 20f, 0.01f);
         TheClient.Particles.Engine.AddEffect(ParticleEffectType.CYLINDER, (o) => ppos, (o) => Position, (o) => 0.01f, 2f,
                                              Location.One, Location.One, true, TheClient.Textures.GetTexture("white"));
         ppos = Position;
         TheClient.Rendering.SetColor(Color4.White);
     }
 }
Beispiel #7
0
 public void RenderGrass()
 {
     if (TheClient.MainWorldView.FBOid == FBOID.FORWARD_SOLID)
     {
         TheClient.Engine.Shaders3D.s_forw_grass = TheClient.Engine.Shaders3D.s_forw_grass.Bind();
         GL.Uniform1(6, (float)TheClient.GlobalTickTimeLocal);
         GL.Uniform4(12, new Vector4(ClientUtilities.Convert(TheClient.MainWorldView.FogCol), TheClient.MainWorldView.FogAlpha));
         float fogDist = 1.0f / TheClient.FogMaxDist();
         fogDist *= fogDist;
         GL.Uniform1(13, fogDist);
         //GL.Uniform2(14, new Vector2(TheClient.CVars.r_znear.ValueF, TheClient.ZFar()));
         GL.UniformMatrix4(1, false, ref TheClient.MainWorldView.PrimaryMatrix);
     }
     else if (TheClient.MainWorldView.FBOid == FBOID.MAIN)
     {
         TheClient.Engine.Shaders3D.s_fbo_grass = TheClient.Engine.Shaders3D.s_fbo_grass.Bind();
         GL.UniformMatrix4(1, false, ref TheClient.MainWorldView.PrimaryMatrix);
     }
     else if (TheClient.MainWorldView.FBOid == FBOID.SHADOWS && TheClient.MainWorldView.TranspShadows)
     {
         TheClient.Engine.Shaders3D.s_shadow_grass = TheClient.Engine.Shaders3D.s_shadow_grass.Bind();
     }
     else
     {
         return;
     }
     GL.ActiveTexture(TextureUnit.Texture3);
     GL.BindTexture(TextureTarget.Texture2DArray, 0);
     GL.ActiveTexture(TextureUnit.Texture2);
     GL.BindTexture(TextureTarget.Texture2DArray, 0);
     GL.ActiveTexture(TextureUnit.Texture1);
     GL.BindTexture(TextureTarget.Texture2DArray, 0);
     GL.ActiveTexture(TextureUnit.Texture0);
     GL.BindTexture(TextureTarget.Texture2DArray, TheClient.GrassTextureID);
     GL.Uniform1(6, (float)GlobalTickTimeLocal);
     GL.Uniform3(7, ClientUtilities.Convert(ActualWind));
     GL.Uniform1(8, TheClient.CVars.r_plantdistance.ValueF * TheClient.CVars.r_plantdistance.ValueF);
     TheClient.Rendering.SetColor(GetSunAdjust(), TheClient.MainWorldView);
     foreach (Chunk chunk in chToRender)
     {
         if (chunk.Plant_VAO != -1)
         {
             Matrix4d mat = Matrix4d.CreateTranslation(ClientUtilities.ConvertD(chunk.WorldPosition.ToLocation() * Chunk.CHUNK_SIZE));
             TheClient.MainWorldView.SetMatrix(2, mat);
             GL.BindVertexArray(chunk.Plant_VAO);
             GL.DrawElements(PrimitiveType.Points, chunk.Plant_C, DrawElementsType.UnsignedInt, IntPtr.Zero);
         }
     }
     TheClient.isVox = true;
     TheClient.SetEnts();
 }
Beispiel #8
0
 public void RenderSimpler()
 {
     if (!Visible || model.Meshes.Count == 0)
     {
         return;
     }
     TheClient.SetEnts();
     Matrix4d mat = GetTransformationMatrix();
     TheClient.MainWorldView.SetMatrix(2, mat);
     if (model.Meshes[0].vbo.Tex == null)
     {
         TheClient.Textures.White.Bind();
     }
     model.Draw(); // TODO: Animation?
 }
Beispiel #9
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)?
        }
Beispiel #10
0
        public override void Render()
        {
            TheClient.SetEnts();
            TheClient.Rendering.SetColor(TheClient.Rendering.AdaptColor(ClientUtilities.Convert(GetPosition()), color));
            TheClient.Rendering.SetMinimumLight(0.0f);
            // TODO: Prevent model flipping (Possibly related to animation?)
            Matrix4d mat = PreRot * Matrix4d.CreateRotationZ((Direction.Yaw * Utilities.PI180)) * Matrix4d.CreateTranslation(ClientUtilities.ConvertD(GetPosition()));

            TheClient.MainWorldView.SetMatrix(2, mat);
            model.CustomAnimationAdjustments = new Dictionary <string, Matrix4>(SavedAdjustmentsOTK);
            model.Draw(aHTime, hAnim, aTTime, tAnim, aLTime, lAnim);
            TheClient.Rendering.SetColor(Color4.White);
            // TODO: Render held item!
            if (IsTyping)
            {
                TheClient.Textures.GetTexture("ui/game/typing").Bind(); // TODO: store!
                TheClient.Rendering.RenderBillboard(GetPosition() + new Location(0, 0, 4), new Location(2), TheClient.MainWorldView.CameraPos);
            }
        }
 public override void Render()
 {
     TheClient.SetEnts();
     TheClient.Rendering.SetColor(TheClient.Rendering.AdaptColor(ClientUtilities.Convert(GetPosition()), color));
     TheClient.Rendering.SetMinimumLight(0.0f);
     ActualModelRender();
     if (ShouldShine)
     {
         TheClient.Rendering.EnableShine(false);
         TheClient.Rendering.SetColor(new Vector4(ShineColor.X, ShineColor.Y, ShineColor.Z, ShineColor.W * 0.25f));
         ActualModelRender();
         TheClient.Rendering.DisableShine();
     }
     TheClient.Rendering.SetColor(Color4.White);
     if (IsTyping)
     {
         TheClient.Textures.GetTexture("ui/game/typing").Bind(); // TODO: store!
         TheClient.Rendering.RenderBillboard(GetPosition() + new Location(0, 0, 4), new Location(2), TheClient.MainWorldView.CameraPos);
     }
 }
Beispiel #12
0
        public override void Render()
        {
            if (model == null)
            {
                return;
            }
            TheClient.SetEnts();
            if (TheClient.RenderTextures)
            {
                TheClient.Textures.White.Bind();
            }
            TheClient.Rendering.SetMinimumLight(0f);
            BEPUutilities.Matrix matang = BEPUutilities.Matrix.CreateFromQuaternion(Angles);
            //matang.Transpose();
            Matrix4d matang4 = new Matrix4d(matang.M11, matang.M12, matang.M13, matang.M14,
                                            matang.M21, matang.M22, matang.M23, matang.M24,
                                            matang.M31, matang.M32, matang.M33, matang.M34,
                                            matang.M41, matang.M42, matang.M43, matang.M44);
            Matrix4d mat = matang4 * Matrix4d.CreateTranslation(ClientUtilities.ConvertD(GetPosition()));

            TheClient.MainWorldView.SetMatrix(2, mat);
            model.Draw(); // TODO: Animation?
        }
Beispiel #13
0
        // TODO: Merge with base.Render() as much as possible!
        public override void Render()
        {
            View3D.CheckError("Render - Player - Pre");
            Location renderrelpos = GetWeldSpot();

            if (TheClient.IsMainMenu || !TheClient.CVars.r_drawself.ValueB)
            {
                return;
            }
            TheClient.SetEnts();
            if (TheClient.CVars.n_debugmovement.ValueB)
            {
                if (ServerLocation.IsInfinite() || ServerLocation.IsNaN() || renderrelpos.IsInfinite() || renderrelpos.IsNaN())
                {
                    SysConsole.Output(OutputType.WARNING, "NaN server data");
                }
                else
                {
                    TheClient.Rendering.RenderLine(ServerLocation, renderrelpos);
                    View3D.CheckError("Render - Player - Line");
                    TheClient.Rendering.RenderLineBox(ServerLocation + new Location(-0.2), ServerLocation + new Location(0.2));
                    if (View3D.CheckError("Render - Player - LineBox"))
                    {
                        SysConsole.Output(OutputType.DEBUG, "Caught: " + (ServerLocation + new Location(-0.2)) + "::: " + (ServerLocation + new Location(0.2)));
                    }
                }
            }
            if (TheClient.VR != null)
            {
                return;
            }
            View3D.CheckError("Render - Player - 0");
            OpenTK.Matrix4d mat = OpenTK.Matrix4d.Scale(1.5f)
                                  * OpenTK.Matrix4d.CreateRotationZ((Direction.Yaw * Utilities.PI180))
                                  * PlayerAngleMat
                                  * OpenTK.Matrix4d.CreateTranslation(ClientUtilities.ConvertD(renderrelpos));
            TheClient.MainWorldView.SetMatrix(2, mat);
            TheClient.Rendering.SetMinimumLight(0.0f);
            model.CustomAnimationAdjustments = new Dictionary <string, OpenTK.Matrix4>(SavedAdjustmentsOTK)
            {
                // TODO: safe (no-collision) rotation check?
                { "spine04", GetAdjustmentOTK("spine04") * OpenTK.Matrix4.CreateRotationX(-(float)(Direction.Pitch / 2f * Utilities.PI180)) }
            };
            View3D.CheckError("Render - Player - 1");
            if (!TheClient.MainWorldView.RenderingShadows && TheClient.CVars.g_firstperson.ValueB)
            {
                model.CustomAnimationAdjustments["neck01"] = GetAdjustmentOTK("neck01") * OpenTK.Matrix4.CreateRotationX(-(float)(160f * Utilities.PI180));
            }
            else
            {
                model.CustomAnimationAdjustments["neck01"] = GetAdjustmentOTK("neck01");
            }
            model.Draw(aHTime, hAnim, aTTime, tAnim, aLTime, lAnim);
            Model mod   = TheClient.GetItemForSlot(TheClient.QuickBarPos).Mod;
            bool  hasjp = HasJetpack();

            View3D.CheckError("Render - Player - 2");
            if (!hasjp && tAnim != null && mod != null)
            {
                mat = OpenTK.Matrix4d.CreateTranslation(ClientUtilities.ConvertD(renderrelpos));
                TheClient.MainWorldView.SetMatrix(2, mat);
                Dictionary <string, Matrix> adjs = new Dictionary <string, Matrix>(SavedAdjustments);
                // TODO: Logic of this rotation math?
                Matrix rotforw = Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitX, ((float)(Direction.Pitch / 2f * Utilities.PI180) % 360f)));
                adjs["spine04"] = GetAdjustment("spine04") * rotforw;
                SingleAnimationNode hand = tAnim.GetNode("metacarpal2.r");
                Matrix m4 = Matrix.CreateScale(1.5f, 1.5f, 1.5f)
                            * (Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)((-Direction.Yaw + 90) * Utilities.PI180) % 360f))
                               * hand.GetBoneTotalMatrix(aTTime, adjs))
                            * Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)((-90) * Utilities.PI180) % 360f));
                OpenTK.Matrix4 bonemat = new OpenTK.Matrix4((float)m4.M11, (float)m4.M12, (float)m4.M13, (float)m4.M14,
                                                            (float)m4.M21, (float)m4.M22, (float)m4.M23, (float)m4.M24,
                                                            (float)m4.M31, (float)m4.M32, (float)m4.M33, (float)m4.M34,
                                                            (float)m4.M41, (float)m4.M42, (float)m4.M43, (float)m4.M44);
                GL.UniformMatrix4(100, false, ref bonemat);
                mod.LoadSkin(TheClient.Textures);
                mod.Draw();
                bonemat = OpenTK.Matrix4.Identity;
                GL.UniformMatrix4(100, false, ref bonemat);
            }
            View3D.CheckError("Render - Player - 3");
            if (hasjp)
            {
                // TODO: Abstractify!
                Model jetp = GetHeldItem().Mod;
                mat = OpenTK.Matrix4d.CreateTranslation(ClientUtilities.ConvertD(renderrelpos));
                TheClient.MainWorldView.SetMatrix(2, mat);
                Dictionary <string, Matrix> adjs = new Dictionary <string, Matrix>();
                Matrix rotforw = Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitX, ((float)(Direction.Pitch / 2f * Utilities.PI180) % 360f)));
                adjs["spine04"] = GetAdjustment("spine04") * rotforw;
                SingleAnimationNode spine = tAnim.GetNode("spine04");
                Matrix m4 = Matrix.CreateScale(1.5f, 1.5f, 1.5f)
                            * (Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)((-Direction.Yaw + 90) * Utilities.PI180) % 360f))
                               * spine.GetBoneTotalMatrix(aTTime, adjs))
                            * Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitX, (float)((90) * Utilities.PI180) % 360f));
                OpenTK.Matrix4 bonemat = new OpenTK.Matrix4((float)m4.M11, (float)m4.M12, (float)m4.M13, (float)m4.M14, (float)m4.M21, (float)m4.M22, (float)m4.M23, (float)m4.M24,
                                                            (float)m4.M31, (float)m4.M32, (float)m4.M33, (float)m4.M34, (float)m4.M41, (float)m4.M42, (float)m4.M43, (float)m4.M44);
                GL.UniformMatrix4(100, false, ref bonemat);
                jetp.LoadSkin(TheClient.Textures);
                jetp.Draw();
                bonemat = OpenTK.Matrix4.Identity;
                GL.UniformMatrix4(100, false, ref bonemat);
            }
            View3D.CheckError("Render - Player - 4");
            if (IsTyping)
            {
                TheClient.Textures.GetTexture("ui/game/typing").Bind(); // TODO: store!
                TheClient.Rendering.RenderBillboard(renderrelpos + new Location(0, 0, 4), new Location(2), TheClient.MainWorldView.CameraPos);
            }
            View3D.CheckError("Render - Player - Post");
        }
Beispiel #14
0
        public override void Render()
        {
            Location renderrelpos = GetWeldSpot();

            TheClient.SetEnts();
            // TODO: Merge with base.Render() as much as possible!
            if (TheClient.CVars.n_debugmovement.ValueB)
            {
                TheClient.Rendering.RenderLine(ServerLocation, renderrelpos);
                TheClient.Rendering.RenderLineBox(ServerLocation + new Location(-0.2), ServerLocation + new Location(0.2));
            }
            OpenTK.Matrix4d mat = OpenTK.Matrix4d.Scale(1.5f)
                                  * OpenTK.Matrix4d.CreateRotationZ((Direction.Yaw * Utilities.PI180))
                                  * PlayerAngleMat
                                  * OpenTK.Matrix4d.CreateTranslation(ClientUtilities.ConvertD(renderrelpos));
            TheClient.MainWorldView.SetMatrix(2, mat);
            TheClient.Rendering.SetMinimumLight(0.0f);
            model.CustomAnimationAdjustments = new Dictionary <string, OpenTK.Matrix4>(SavedAdjustmentsOTK);
            // TODO: safe (no-collision) rotation check?
            model.CustomAnimationAdjustments["spine04"] = GetAdjustmentOTK("spine04") * OpenTK.Matrix4.CreateRotationX(-(float)(Direction.Pitch / 2f * Utilities.PI180));
            if (!TheClient.MainWorldView.RenderingShadows && TheClient.CVars.g_firstperson.ValueB)
            {
                model.CustomAnimationAdjustments["neck01"] = GetAdjustmentOTK("neck01") * OpenTK.Matrix4.CreateRotationX(-(float)(160f * Utilities.PI180));
            }
            else
            {
                model.CustomAnimationAdjustments["neck01"] = GetAdjustmentOTK("neck01");
            }
            model.Draw(aHTime, hAnim, aTTime, tAnim, aLTime, lAnim);
            Model mod   = TheClient.GetItemForSlot(TheClient.QuickBarPos).Mod;
            bool  hasjp = HasJetpack();

            if (!hasjp && tAnim != null && mod != null)
            {
                mat = OpenTK.Matrix4d.CreateTranslation(ClientUtilities.ConvertD(renderrelpos));
                TheClient.MainWorldView.SetMatrix(2, mat);
                Dictionary <string, Matrix> adjs = new Dictionary <string, Matrix>(SavedAdjustments);
                Matrix rotforw = Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitX, ((float)(Direction.Pitch / 2f * Utilities.PI180) % 360f)));
                adjs["spine04"] = GetAdjustment("spine04") * rotforw;
                SingleAnimationNode hand = tAnim.GetNode("metacarpal2.r");
                Matrix m4 = Matrix.CreateScale(1.5f, 1.5f, 1.5f)
                            * (Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)((-Direction.Yaw + 90) * Utilities.PI180) % 360f))
                               * hand.GetBoneTotalMatrix(aTTime, adjs))
                            * Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)((-90) * Utilities.PI180) % 360f));
                OpenTK.Matrix4 bonemat = new OpenTK.Matrix4((float)m4.M11, (float)m4.M12, (float)m4.M13, (float)m4.M14,
                                                            (float)m4.M21, (float)m4.M22, (float)m4.M23, (float)m4.M24,
                                                            (float)m4.M31, (float)m4.M32, (float)m4.M33, (float)m4.M34,
                                                            (float)m4.M41, (float)m4.M42, (float)m4.M43, (float)m4.M44);
                GL.UniformMatrix4(40, false, ref bonemat);
                mod.LoadSkin(TheClient.Textures);
                mod.Draw();
                bonemat = OpenTK.Matrix4.Identity;
                GL.UniformMatrix4(40, false, ref bonemat);
            }
            if (hasjp)
            {
                // TODO: Abstractify!
                Model jetp = GetHeldItem().Mod;
                mat = OpenTK.Matrix4d.CreateTranslation(ClientUtilities.ConvertD(renderrelpos));
                TheClient.MainWorldView.SetMatrix(2, mat);
                Dictionary <string, Matrix> adjs = new Dictionary <string, Matrix>();
                Matrix rotforw = Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitX, ((float)(Direction.Pitch / 2f * Utilities.PI180) % 360f)));
                adjs["spine04"] = GetAdjustment("spine04") * rotforw;
                SingleAnimationNode spine = tAnim.GetNode("spine04");
                Matrix m4 = Matrix.CreateScale(1.5f, 1.5f, 1.5f)
                            * (Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)((-Direction.Yaw + 90) * Utilities.PI180) % 360f))
                               * spine.GetBoneTotalMatrix(aTTime, adjs))
                            * Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitX, (float)((90) * Utilities.PI180) % 360f));
                OpenTK.Matrix4 bonemat = new OpenTK.Matrix4((float)m4.M11, (float)m4.M12, (float)m4.M13, (float)m4.M14, (float)m4.M21, (float)m4.M22, (float)m4.M23, (float)m4.M24,
                                                            (float)m4.M31, (float)m4.M32, (float)m4.M33, (float)m4.M34, (float)m4.M41, (float)m4.M42, (float)m4.M43, (float)m4.M44);
                GL.UniformMatrix4(40, false, ref bonemat);
                jetp.LoadSkin(TheClient.Textures);
                jetp.Draw();
                bonemat = OpenTK.Matrix4.Identity;
                GL.UniformMatrix4(40, false, ref bonemat);
            }
            if (IsTyping)
            {
                TheClient.Textures.GetTexture("ui/game/typing").Bind(); // TODO: store!
                TheClient.Rendering.RenderBillboard(renderrelpos + new Location(0, 0, 4), new Location(2), TheClient.MainWorldView.CameraPos);
            }
        }
Beispiel #15
0
        public void RenderClouds()
        {
            if (!TheClient.CVars.r_clouds.ValueB)
            {
                if (Cl_Pos.Count > 0)
                {
                    Cl_Pos  = new List <Vector3>();
                    Cl_Norm = new List <Vector3>();
                    Cl_TC   = new List <Vector2>();
                    Cl_Ind  = new List <uint>();
                }
                return;
            }
            if (ReClouds)
            {
                bool forceset = false;
                if (Cl_VAO == -1)
                {
                    Cl_VAO      = GL.GenVertexArray();
                    Cl_VBO_Pos  = GL.GenBuffer();
                    Cl_VBO_Norm = GL.GenBuffer();
                    Cl_VBO_TC   = GL.GenBuffer();
                    Cl_VBO_Tang = GL.GenBuffer();
                    Cl_VBO_Ind  = GL.GenBuffer();
                    Cl_VBO_Col  = GL.GenBuffer();
                    Cl_VBO_BID1 = GL.GenBuffer();
                    Cl_VBO_BID2 = GL.GenBuffer();
                    Cl_VBO_BWE1 = GL.GenBuffer();
                    Cl_VBO_BWE2 = GL.GenBuffer();
                    forceset    = true;
                }
                Cl_Pos.Clear();
                Cl_Norm.Clear();
                Cl_TC.Clear();
                Cl_Ind.Clear();
                foreach (Cloud cloud in Clouds)
                {
                    Location relang = Utilities.VectorToAngles(cloud.Position - TheClient.MainWorldView.CameraPos);
                    Matrix4  mat    = Matrix4.CreateRotationY((float)((relang.Y - 90) * Utilities.PI180))
                                      * Matrix4.CreateRotationZ((float)(relang.Z * Utilities.PI180))
                                      * Matrix4.CreateTranslation(ClientUtilities.Convert(cloud.Position));
                    for (int i = 0; i < cloud.Points.Count; i++)
                    {
                        Matrix4 pmat = Matrix4.CreateTranslation(-0.5f, -0.5f, 0f) * Matrix4.CreateScale(cloud.Sizes[i]) * mat * Matrix4.CreateTranslation(ClientUtilities.Convert(cloud.Points[i]));
                        Matrix4 nmat = pmat;
                        nmat[3, 0] = 0;
                        nmat[3, 1] = 0;
                        nmat[3, 2] = 0;
                        for (uint n = 0; n < 6; n++)
                        {
                            Cl_Ind.Add((uint)Cl_Ind.Count);
                            Cl_Col.Add(Vector4.One);
                            Cl_Norm.Add(Vector4.Transform(nmat, new Vector4(0, 0, 1, 1)).Xyz);
                            Vector4 p = Vector4.Transform(new Vector4(Cl_Vecer[n], 1f), pmat);
                            Cl_Pos.Add(p.Xyz / p.W);
                            Cl_TC.Add(Cl_TCer[n]);
                        }
                    }
                }
                Vector3[] pos   = Cl_Pos.ToArray();
                Vector3[] norm  = Cl_Norm.ToArray();
                Vector2[] tc    = Cl_TC.ToArray();
                Vector3[] tang  = VBO.TangentsFor(pos, norm, tc);
                Vector4[] col   = Cl_Col.ToArray();
                uint[]    ind   = Cl_Ind.ToArray();
                Vector4[] bdata = new Vector4[pos.Length];
                for (int i = 0; i < bdata.Length; i++)
                {
                    bdata[i] = new Vector4(0f, 0f, 0f, 0f);
                }
                BufferUsageHint BufferMode = BufferUsageHint.StreamDraw;
                GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_Pos);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(pos.Length * Vector3.SizeInBytes), pos, BufferMode);
                GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_Norm);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(norm.Length * Vector3.SizeInBytes), norm, BufferMode);
                GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_TC);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(tc.Length * Vector2.SizeInBytes), tc, BufferMode);
                GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_Tang);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(tang.Length * Vector3.SizeInBytes), tang, BufferMode);
                GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_Col);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(col.Length * Vector4.SizeInBytes), col, BufferMode);
                GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_BWE1);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(bdata.Length * Vector4.SizeInBytes), bdata, BufferMode);
                GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_BID1);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(bdata.Length * Vector4.SizeInBytes), bdata, BufferMode);
                GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_BWE2);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(bdata.Length * Vector4.SizeInBytes), bdata, BufferMode);
                GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_BID2);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(bdata.Length * Vector4.SizeInBytes), bdata, BufferMode);
                GL.BindBuffer(BufferTarget.ElementArrayBuffer, Cl_VBO_Ind);
                GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(ind.Length * sizeof(uint)), ind, BufferMode);
                if (forceset)
                {
                    GL.BindVertexArray(Cl_VAO);
                    GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_Pos);
                    GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
                    GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_Norm);
                    GL.VertexAttribPointer(1, 3, VertexAttribPointerType.Float, false, 0, 0);
                    GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_TC);
                    GL.VertexAttribPointer(2, 2, VertexAttribPointerType.Float, false, 0, 0);
                    GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_Tang);
                    GL.VertexAttribPointer(3, 3, VertexAttribPointerType.Float, false, 0, 0);
                    GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_Col);
                    GL.VertexAttribPointer(4, 4, VertexAttribPointerType.Float, false, 0, 0);
                    GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_BWE1);
                    GL.VertexAttribPointer(5, 4, VertexAttribPointerType.Float, false, 0, 0);
                    GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_BID1);
                    GL.VertexAttribPointer(6, 4, VertexAttribPointerType.Float, false, 0, 0);
                    GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_BWE2);
                    GL.VertexAttribPointer(7, 4, VertexAttribPointerType.Float, false, 0, 0);
                    GL.BindBuffer(BufferTarget.ArrayBuffer, Cl_VBO_BID2);
                    GL.VertexAttribPointer(8, 4, VertexAttribPointerType.Float, false, 0, 0);
                    GL.EnableVertexAttribArray(0);
                    GL.EnableVertexAttribArray(1);
                    GL.EnableVertexAttribArray(2);
                    GL.EnableVertexAttribArray(3);
                    GL.EnableVertexAttribArray(4);
                    GL.EnableVertexAttribArray(5);
                    GL.EnableVertexAttribArray(6);
                    GL.EnableVertexAttribArray(7);
                    GL.EnableVertexAttribArray(8);
                    GL.BindBuffer(BufferTarget.ElementArrayBuffer, Cl_VBO_Ind);
                }
                //ReClouds = false;
            }
            TheClient.SetEnts();
            TheClient.Textures.GetTexture("effects/clouds/cloud1").Bind(); // TODO: Cache!
            TheClient.MainWorldView.SetMatrix(2, Matrix4d.Identity);
            Matrix4 identity = Matrix4.Identity;

            GL.UniformMatrix4(40, false, ref identity);
            GL.BindVertexArray(Cl_VAO);
            GL.DrawElements(PrimitiveType.Triangles, Cl_Ind.Count, DrawElementsType.UnsignedInt, IntPtr.Zero);
        }