public void AddSprite(ref TRS quad, Vector2i tile_index, ref Matrix3 mat) { Vector2 x = quad.X; Vector2 y = quad.Y; TextureInfo.CachedTileData cachedTiledData = this.m_current_texture_info.GetCachedTiledData(ref tile_index); this.m_v0 = new Vector4(this.transform_point(ref mat, quad.T), cachedTiledData.UV_00); this.m_v1 = new Vector4(this.transform_point(ref mat, quad.T + x), cachedTiledData.UV_10); this.m_v2 = new Vector4(this.transform_point(ref mat, quad.T + y), cachedTiledData.UV_01); this.m_v3 = new Vector4(this.transform_point(ref mat, quad.T + x + y), cachedTiledData.UV_11); this.add_quad(); }
public void AddSprite(ref TRS quad, Vector2i tile_index) { Vector2 x = quad.X; Vector2 y = quad.Y; TextureInfo.CachedTileData cachedTiledData = this.m_current_texture_info.GetCachedTiledData(ref tile_index); this.m_v0 = new Vector4(quad.T, cachedTiledData.UV_00); this.m_v1 = new Vector4(quad.T + x, cachedTiledData.UV_10); this.m_v2 = new Vector4(quad.T + y, cachedTiledData.UV_01); this.m_v3 = new Vector4(quad.T + x + y, cachedTiledData.UV_11); this.add_quad(); }
public void AddSprite(ref TRS quad, ref TRS uv, ref Matrix3 mat) { Vector2 x = quad.X; Vector2 y = quad.Y; Vector2 x2 = uv.X; Vector2 y2 = uv.Y; this.m_v0 = new Vector4(this.transform_point(ref mat, quad.T), uv.T); this.m_v1 = new Vector4(this.transform_point(ref mat, quad.T + x), uv.T + x2); this.m_v2 = new Vector4(this.transform_point(ref mat, quad.T + y), uv.T + y2); this.m_v3 = new Vector4(this.transform_point(ref mat, quad.T + x + y), uv.T + x2 + y2); this.add_quad(); }
public void AddSprite(ref TRS quad, ref TRS uv) { Vector2 x = quad.X; Vector2 y = quad.Y; Vector2 x2 = uv.X; Vector2 y2 = uv.Y; this.m_v0 = new Vector4(quad.T, uv.T); this.m_v1 = new Vector4(quad.T + x, uv.T + x2); this.m_v2 = new Vector4(quad.T + y, uv.T + y2); this.m_v3 = new Vector4(quad.T + x + y, uv.T + x2 + y2); this.add_quad(); }
public Bounds2 DrawTextDebug(string str, Vector2 bottom_left_start_pos, float char_height, bool draw = true, SpriteRenderer.ISpriteShader shader = null) { if (null == shader) { shader = this.m_default_font_shader; } float num = char_height / (float)EmbeddedDebugFontData.CharSizei.Y; Vector2 vector = new Vector2(-1f, 1f); Vector2 vector2 = vector * num; TRS tRS = default(TRS); tRS.R = Math._10; tRS.S = EmbeddedDebugFontData.CharSizef * num; tRS.T = bottom_left_start_pos; Vector2 max = bottom_left_start_pos; float x = tRS.T.X; if (draw) { this.DefaultFontShader.SetUVTransform(ref Math.UV_TransformFlipV); this.BeginSprites(this.m_embedded_font_texture_info, this.DefaultFontShader, str.Length); } for (int i = 0; i < str.Length; i++) { if (str[i] == '\n') { tRS.T -= new Vector2(0f, tRS.S.Y + vector2.Y); tRS.T.X = x; } else { if (draw) { int num2 = (int)(str[i] - ' '); if (num2 < 0 || num2 >= EmbeddedDebugFontData.NumChars) { num2 = 31; } this.AddSprite(ref tRS, new Vector2i(num2, 0)); } tRS.T += new Vector2(tRS.S.X + vector2.X, 0f); max.X = FMath.Max(tRS.T.X, max.X); max.Y = FMath.Min(tRS.T.Y, max.Y); } } if (draw) { this.EndSprites(); } return(Bounds2.SafeBounds(bottom_left_start_pos + new Vector2(0f, tRS.S.Y), max)); }
public static TRS Tile(Vector2i num_tiles, Vector2i tile_index, TRS source_area) { Vector2 vector = num_tiles.Vector2(); Vector2 vector2 = tile_index.Vector2(); Vector2 vector3 = source_area.S / vector; Vector2 x = source_area.X; Vector2 y = source_area.Y; return(new TRS { T = source_area.T + vector2 * vector3, R = source_area.R, S = vector3 }); }
public void Initialize(Texture2D texture, Vector2i num_tiles, TRS source_area) { this.Texture = texture; this.TileSizeInUV = source_area.S / num_tiles.Vector2(); this.NumTiles = num_tiles; this.m_tiles_uvs = new TextureInfo.CachedTileData[num_tiles.Product()]; for (int i = 0; i < this.NumTiles.Y; i++) { for (int j = 0; j < this.NumTiles.X; j++) { Vector2i tile_index = new Vector2i(j, i); TRS tRS = TRS.Tile(this.NumTiles, tile_index, source_area); int num = tile_index.X + tile_index.Y * this.NumTiles.X; this.m_tiles_uvs[num] = new TextureInfo.CachedTileData { UV_00 = tRS.Point00, UV_10 = tRS.Point10, UV_01 = tRS.Point01, UV_11 = tRS.Point11 }; } } }
public TextureInfo(Texture2D texture, Vector2i num_tiles, TRS source_area) { this.Initialize(texture, num_tiles, source_area); }