예제 #1
0
		public void Render(ITessellator tessellator)
		{
			var color = tessellator.CurrentColor;

			// TODO: If this is an entity tile, then don't adjust the color...?

			// This will cause tile images to become darker as they move into the background layers.
			var layer =  -tessellator.Transform(Vector3.Zero).Z;
			if (layer < _numChunkLayers)
			{
				var multiplier = 1.0 - (_numChunkLayers - layer) / (_numChunkLayers * 2); // + 0.25f;
				tessellator.BindColor(Color.FromArgb((int)MathHelper.Clamp(color.R * multiplier, 0, 255), (int)MathHelper.Clamp(color.G * multiplier, 0, 255), (int)MathHelper.Clamp(color.B * multiplier, 0, 255)));
			}

			if (Transform != null)
			{
				tessellator.PushTransform();
				Transform.Apply(tessellator);

				_tileSet.Render(tessellator, TileIndex, Transform.MirrorX, Transform.MirrorY);
				tessellator.PopTransform();
			}
			else
			{
				_tileSet.Render(tessellator, TileIndex);
			}

			tessellator.BindColor(color);
		}
예제 #2
0
        public void Render(ITessellator tessellator)
        {
            var color = tessellator.CurrentColor;

            // TODO: If this is an entity tile, then don't adjust the color...?

            // This will cause tile images to become darker as they move into the background layers.
            var layer = -tessellator.Transform(Vector3.Zero).Z;

            if (layer < _numChunkLayers)
            {
                var multiplier = 1.0 - (_numChunkLayers - layer) / (_numChunkLayers * 2);                 // + 0.25f;
                tessellator.BindColor(Color.FromArgb((int)MathHelper.Clamp(color.R * multiplier, 0, 255), (int)MathHelper.Clamp(color.G * multiplier, 0, 255), (int)MathHelper.Clamp(color.B * multiplier, 0, 255)));
            }

            if (Transform != null)
            {
                tessellator.PushTransform();
                Transform.Apply(tessellator);

                _tileSet.Render(tessellator, TileIndex, Transform.MirrorX, Transform.MirrorY);
                tessellator.PopTransform();
            }
            else
            {
                _tileSet.Render(tessellator, TileIndex);
            }

            tessellator.BindColor(color);
        }
예제 #3
0
        /// <summary>
        /// Calculate a scale according to the current position.
        /// </summary>
        /// <remarks>
        /// This assumes you are inside of RenderContent, and handles pushing and popping the current transformation accordingly.
        /// </remarks>
        protected void Scale(ITessellator tessellator, float scale)
        {
            var position = tessellator.Transform(Vector2.Zero);

            tessellator.PopTransform();
            tessellator.PushTransform();
            tessellator.Scale(scale, scale);
            tessellator.Translate(position);
        }
예제 #4
0
		public void Apply(ITessellator tessellator)
		{
			var position = tessellator.Transform(Vector2.Zero);
			tessellator.Translate(-position);
			tessellator.Scale(Scale.X, Scale.Y);
			tessellator.Rotate(Rotation, 0, 0, 1);
			tessellator.Translate(Translation);
			tessellator.Translate(position);
		}
예제 #5
0
        public void Apply(ITessellator tessellator)
        {
            var position = tessellator.Transform(Vector2.Zero);

            tessellator.Translate(-position);
            tessellator.Scale(Scale.X, Scale.Y);
            tessellator.Rotate(Rotation, 0, 0, 1);
            tessellator.Translate(Translation);
            tessellator.Translate(position);
        }
예제 #6
0
        public void RenderText(ITessellator tessellator, string format, params object[] args)
        {
            Vector2 unitX = tessellator.Transform(Vector2.UnitX * (IsNormalized ? 1 : Width)) - tessellator.Transform(Vector2.Zero);

            format = string.Format(format, args);
            for (var index = 0; index < format.Length; index++)
            {
                Render(tessellator, (int)format[index]);
                tessellator.Translate(unitX);
            }

            tessellator.Translate(-unitX * format.Length);
        }
예제 #7
0
        private void Render(ITessellator tessellator, PlayerEntity entity)
        {
            tessellator.PushTransform();

            var origin = tessellator.Transform(Vector3.Zero);

            tessellator.LoadIdentity();
            tessellator.Scale(entity.Size, entity.Size);
            tessellator.Translate(origin);
            //tessellator.Translate(0.1f, 0.1f); // center on the current tile position

            tessellator.Translate(entity.Position);             // move to the entity's position

            _playerTile.Render(tessellator);
            tessellator.PopTransform();
        }
예제 #8
0
		private void Render(ITessellator tessellator, BlockEntity entity)
		{
			var color = tessellator.CurrentColor;
			tessellator.BindColor(Color.FromArgb(196, entity.IsSelected ? Color.Red : Color.White));
			tessellator.PushTransform();

			var origin = tessellator.Transform(Vector3.Zero);

			tessellator.LoadIdentity();
			tessellator.Scale(entity.Size, entity.Size);
			tessellator.Translate(-entity.Size / 2, -entity.Size / 2); // center the rotation
			tessellator.Rotate(entity.Rotation, 0, 0, 1);
			tessellator.Translate(entity.Size, entity.Size);
			tessellator.Translate(origin);
			//tessellator.Translate(entity.Size, entity.Size); // center on the current tile position
			tessellator.Translate(entity.Position); // move to the entity's position

			BlockRegistry.Instance.GetById(entity.BlockID).Renderer.Render(tessellator);

			tessellator.PopTransform();
			tessellator.BindColor(color); // TODO: Is this still needed?
		}
예제 #9
0
        private void Render(ITessellator tessellator, BlockEntity entity)
        {
            var color = tessellator.CurrentColor;

            tessellator.BindColor(Color.FromArgb(196, entity.IsSelected ? Color.Red : Color.White));
            tessellator.PushTransform();

            var origin = tessellator.Transform(Vector3.Zero);

            tessellator.LoadIdentity();
            tessellator.Scale(entity.Size, entity.Size);
            tessellator.Translate(-entity.Size / 2, -entity.Size / 2);             // center the rotation
            tessellator.Rotate(entity.Rotation, 0, 0, 1);
            tessellator.Translate(entity.Size, entity.Size);
            tessellator.Translate(origin);
            //tessellator.Translate(entity.Size, entity.Size); // center on the current tile position
            tessellator.Translate(entity.Position);             // move to the entity's position

            BlockRegistry.Instance.GetById(entity.BlockID).Renderer.Render(tessellator);

            tessellator.PopTransform();
            tessellator.BindColor(color);             // TODO: Is this still needed?
        }
예제 #10
0
		public void RenderText(ITessellator tessellator, string format, params object[] args)
		{
			Vector2 unitX = tessellator.Transform(Vector2.UnitX * (IsNormalized ? 1 : Width)) - tessellator.Transform(Vector2.Zero);

			format = string.Format(format, args);
			for (var index = 0; index < format.Length; index++)
			{
				Render(tessellator, (int)format[index]);
				tessellator.Translate(unitX);
			}

			tessellator.Translate(-unitX * format.Length);
		}
예제 #11
0
		/// <summary>
		/// Calculate a scale according to the current position.
		/// </summary>
		/// <remarks>
		/// This assumes you are inside of RenderContent, and handles pushing and popping the current transformation accordingly.
		/// </remarks>
		protected void Scale(ITessellator tessellator, float scale)
		{
			var position = tessellator.Transform(Vector2.Zero);
			tessellator.PopTransform();
			tessellator.PushTransform();
			tessellator.Scale(scale, scale);
			tessellator.Translate(position);
		}
예제 #12
0
		private void Render(ITessellator tessellator, PlayerEntity entity)
		{
			tessellator.PushTransform();

			var origin = tessellator.Transform(Vector3.Zero);

			tessellator.LoadIdentity();
			tessellator.Scale(entity.Size, entity.Size);
			tessellator.Translate(origin);
			//tessellator.Translate(0.1f, 0.1f); // center on the current tile position

			tessellator.Translate(entity.Position); // move to the entity's position

			_playerTile.Render(tessellator);
			tessellator.PopTransform();
		}