public Location GetEyePosition() { Location renderrelpos = GetWeldSpot(); Location start = renderrelpos + new Location(0, 0, CBHHeight * (CBody.StanceManager.CurrentStance == Stance.Standing ? 1.8 : 1.5)); if (tAnim != null) { SingleAnimationNode head = tAnim.GetNode("special06.r"); Dictionary <string, Matrix> adjs = new Dictionary <string, Matrix>(SavedAdjustments); Matrix rotforw = Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitX, -(float)(Direction.Pitch / 1.75f * Utilities.PI180))); adjs["spine04"] = GetAdjustment("spine04") * rotforw; Matrix m4 = Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)((-Direction.Yaw + 270) * Utilities.PI180) % 360f)) * head.GetBoneTotalMatrix(0, adjs) * (rotforw * Matrix.CreateTranslation(new Vector3(0, 0, 0.2f))); m4.Transpose(); Location end = renderrelpos + new Location(m4.Translation) * 1.5f; start.Z = end.Z; // FUTURE: Maybe handle player rotation? double len = (end - start).Length(); Location normdir = (end - start) / len; RayCastResult rcr; if (TheRegion.SpecialCaseRayTrace(start, normdir, (float)len, MaterialSolidity.FULLSOLID, IgnoreThis, out rcr)) { return(new Location(rcr.HitData.Location + rcr.HitData.Normal * 0.2f)); } return(end); } else { return(start); } }
public override Location GetEyePosition() { if (tAnim != null) { SingleAnimationNode head = tAnim.GetNode("special06.r"); Dictionary <string, Matrix> adjs = new Dictionary <string, Matrix>(); Matrix rotforw = Matrix.CreateFromQuaternion(BEPUutilities.Quaternion.CreateFromAxisAngle(Vector3.UnitX, -(double)(Direction.Pitch / 1.75f * Utilities.PI180))); adjs["spine05"] = rotforw; Matrix m4 = Matrix.CreateFromQuaternion(BEPUutilities.Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (double)((-Direction.Yaw + 270) * Utilities.PI180) % 360f)) * head.GetBoneTotalMatrix(0, adjs) * (rotforw * Matrix.CreateTranslation(new Vector3(0, 0, 0.2f))); m4.Transpose(); return(GetPosition() + new Location(m4.Translation) * 1.5f); } else { return(GetPosition() + new Location(0, 0, CBHHeight * (CBody.StanceManager.CurrentStance == Stance.Standing ? 1.8 : 1.5))); } }
public Location GetEyePosition() { Location renderrelpos = GetWeldSpot(); Location start = renderrelpos + new Location(0, 0, CBHHeight * (CBody.StanceManager.CurrentStance == Stance.Standing ? 1.8 : 1.5)); if (tAnim != null) { SingleAnimationNode head = tAnim.GetNode("special06.r"); Dictionary <string, Matrix> adjs = new Dictionary <string, Matrix>(SavedAdjustments); Matrix rotforw = Matrix.CreateFromQuaternion(BEPUutilities.Quaternion.CreateFromAxisAngle(Vector3.UnitX, -(float)(Direction.Pitch / 1.75f * Utilities.PI180))); adjs["spine04"] = GetAdjustment("spine04") * rotforw; Matrix m4 = Matrix.CreateFromQuaternion(BEPUutilities.Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)((-Direction.Yaw + 270) * Utilities.PI180) % 360f)) * head.GetBoneTotalMatrix(0, adjs) * (rotforw * Matrix.CreateTranslation(new Vector3(0, 0, 0.2f))); m4.Transpose(); return(renderrelpos + new Location(m4.Translation) * 1.5f); } else { return(start); } }
// 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"); }
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); } }