protected Matrix4 CalculateWorldMatrix(ItemViewbob viewbob) { SimpleCamera camera = OwnerPlayer.GetCamera(); if (OwnerPlayer.IsRenderingThirdperson) { return(Matrix4.CreateScale(ThirdpersonScale) * Matrix4.CreateTranslation(0, 1.5f, -0.25f) * Matrix4.CreateRotationX(MathHelper.ToRadians(ModelRotation.X)) * Matrix4.CreateRotationY(MathHelper.ToRadians(ModelRotation.Y)) * Matrix4.CreateRotationZ(MathHelper.ToRadians(viewbob.CurrentTilt + ModelRotation.Z)) * Matrix4.CreateTranslation(ModelOffset + viewbob.CurrentViewBob + new Vector3(-1.35f, 0, -viewbob.CurrentKickback + -2)) * Matrix4.CreateRotationX(MathHelper.ToRadians(camera.Pitch)) * Matrix4.CreateRotationY(MathHelper.ToRadians(-camera.Yaw) + MathHelper.Pi) * Matrix4.CreateTranslation(OwnerPlayer.Transform.Position + new Vector3(0, OwnerPlayer.Size.Y / 2f - 1.5f, 0))); } else { return(Matrix4.CreateRotationX(MathHelper.ToRadians(ModelRotation.X + viewbob.CurrentSway.X)) * Matrix4.CreateRotationY(MathHelper.ToRadians(ModelRotation.Y + viewbob.CurrentSway.Y)) * Matrix4.CreateRotationZ(MathHelper.ToRadians(viewbob.CurrentTilt + ModelRotation.Z + viewbob.CurrentSway.Y * 0.5f)) * Matrix4.CreateTranslation(ModelOffset + viewbob.CurrentViewBob + new Vector3(0, 0, -viewbob.CurrentKickback)) * Matrix4.CreateRotationX(MathHelper.ToRadians(camera.Pitch)) * Matrix4.CreateRotationY(MathHelper.ToRadians(-camera.Yaw) + MathHelper.Pi) * Matrix4.CreateTranslation(camera.OffsetPosition)); } }
public void Draw(EntityRenderer entRenderer, ItemViewbob viewbob) { // Render item in hand if (SelectedItem != null) { if (SelectedItem.Type.HasFlag(ItemType.Gun)) { Gun gun = (Gun)SelectedItem; // Render muzzle flash ((ClientMuzzleFlash)muzzleFlash).Render(gun, entRenderer, viewbob); } SelectedItem.Draw(viewbob); } }
public void Render(Gun gun, EntityRenderer entRenderer, ItemViewbob viewbob) { if (muzzleFlashTime > 0) { Matrix4 flashMatrix; if (ownerPlayer.IsRenderingThirdperson) { flashMatrix = Matrix4.CreateTranslation(gun.MuzzleFlashOffset) * Matrix4.CreateScale(gun.ThirdpersonScale) * Matrix4.CreateTranslation(0, 1.5f, -0.25f) * Matrix4.CreateRotationZ(MathHelper.ToRadians(viewbob.CurrentTilt)) * Matrix4.CreateTranslation(gun.ModelOffset + viewbob.CurrentViewBob + new Vector3(-1.35f, 0, -viewbob.CurrentKickback + -2)) * Matrix4.CreateRotationX(MathHelper.ToRadians(camera.Pitch)) * Matrix4.CreateRotationY(MathHelper.ToRadians(-camera.Yaw) - MathHelper.Pi) * Matrix4.CreateTranslation(ownerPlayer.Transform.Position + new Vector3(0, ownerPlayer.Size.Y / 2f - 1.5f, 0)); } else { flashMatrix = Matrix4.CreateTranslation(gun.MuzzleFlashOffset) * Matrix4.CreateRotationX(MathHelper.ToRadians(viewbob.CurrentSway.X)) * Matrix4.CreateRotationY(MathHelper.ToRadians(viewbob.CurrentSway.Y)) * Matrix4.CreateRotationZ(MathHelper.ToRadians(viewbob.CurrentTilt + viewbob.CurrentSway.Y * 0.5f)) * Matrix4.CreateTranslation(gun.ModelOffset + viewbob.CurrentViewBob + new Vector3(0, 0, -viewbob.CurrentKickback)) * Matrix4.CreateRotationX(MathHelper.ToRadians(camera.Pitch)) * Matrix4.CreateRotationY(MathHelper.ToRadians(-camera.Yaw) - MathHelper.Pi) * Matrix4.CreateTranslation(camera.OffsetPosition); } light.Position = flashMatrix.ExtractTranslation(); light.LightPower = (muzzleFlashTime / MUZZLE_FLASH_COOLDOWN) * MUZZLE_FLASH_LIGHT_POWER; flashCube.RenderFront = !ownerPlayer.IsRenderingThirdperson; entRenderer.Batch(flashCube, flashMatrix); } else { light.Visible = false; } }
public ItemManager(MasterRenderer renderer, Player ownerPlayer, World world, ItemViewbob viewbob) { this.renderer = renderer; this.viewbob = viewbob; OwnerPlayer = ownerPlayer; World = world; if (GlobalNetwork.IsClient) { muzzleFlash = new ClientMuzzleFlash(renderer, ownerPlayer); } else { muzzleFlash = new ServerMuzzleFlash(); } SelectedItemIndex = -1; }
public override void Draw(ItemViewbob viewbob) { if (OwnerPlayer.NumBlocks > 0) { byte r = (byte)MathHelper.Clamp(BlockColor.R + 10, 0, 255); byte g = (byte)MathHelper.Clamp(BlockColor.G + 10, 0, 255); byte b = (byte)MathHelper.Clamp(BlockColor.B + 10, 0, 255); cursorCube.ColorOverlay = new Color(r, g, b); if (holdingDown) { RayDraw(); } else if (mouseOverBlock) { entRenderer.Batch(cursorCube, Matrix4.CreateTranslation(globalMousePosition * Block.CUBE_3D_SIZE)); } Renderer.ColorOverlay = BlockColor; base.Draw(viewbob); } }
public virtual void Draw(ItemViewbob viewbob) { Renderer.Lighting = OwnerPlayer.Lighting; Renderer.RenderFront = !OwnerPlayer.IsRenderingThirdperson; Renderer.WorldMatrix = CalculateWorldMatrix(viewbob); }