public void Draw() { if (voxelGrid != null) { entReneder.Batch(voxelGrid, Vector3.Zero); } if (Model != null) { entReneder.Batch(Model, Vector3.Zero); } }
protected override void Draw() { if (mouseOverBlock) { entRenderer.Batch(cursorCube, Maths.CreateTransformationMatrix(globalMousePosition * Block.CUBE_3D_SIZE, 0, 0, 0, 1.01f)); } base.Draw(); }
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; } }
void RayDraw() { Vector3 startWorld = startGlobalPosition * Block.CUBE_3D_SIZE; Vector3 endWorld = endGlobalPosition * Block.CUBE_3D_SIZE; Ray ray = new Ray(startWorld, endWorld - startWorld); IndexPosition lastCIndex = IndexPosition.Zero, lastBIndex = new IndexPosition(-1, -1, -1); int bcount = 0; IndexPosition cIndex, bIndex; Chunk chunk; // Add start Terrain.GetLocalBlockCoords(startGlobalPosition, out cIndex, out bIndex); if (bcount < OwnerPlayer.NumBlocks && World.Terrain.Chunks.TryGetValue(cIndex, out chunk)) { bcount++; entRenderer.Batch(cursorCube, Matrix4.CreateTranslation(startGlobalPosition * Block.CUBE_3D_SIZE)); } // Add middle for (int _i = 0; _i < 1000; _i++) { if (bcount > OwnerPlayer.NumBlocks) { break; } float i = _i / 1000f; Vector3 worldPos = ray.Origin + ray.Direction * i; IndexPosition globalIndex = new IndexPosition( (int)(worldPos.X / Block.CUBE_SIZE), (int)(worldPos.Y / Block.CUBE_SIZE), (int)(worldPos.Z / Block.CUBE_SIZE)); Terrain.GetLocalBlockCoords(globalIndex, out cIndex, out bIndex); if (cIndex == lastCIndex && bIndex == lastBIndex || globalIndex == startGlobalPosition || globalIndex == endGlobalPosition) { continue; } lastCIndex = cIndex; lastBIndex = bIndex; if (World.Terrain.Chunks.TryGetValue(cIndex, out chunk)) { bcount++; entRenderer.Batch(cursorCube, Matrix4.CreateTranslation(globalIndex * Block.CUBE_3D_SIZE)); } } // Add end Terrain.GetLocalBlockCoords(endGlobalPosition, out cIndex, out bIndex); if (bcount < OwnerPlayer.NumBlocks && World.Terrain.Chunks.TryGetValue(cIndex, out chunk)) { bcount++; entRenderer.Batch(cursorCube, Matrix4.CreateTranslation(endGlobalPosition * Block.CUBE_3D_SIZE)); } }