/*public Matrix GetTranslationMatrix() { * Matrix outMatrix; * var tl = new Vector3(Position.X, Position.Y, -1.0f); * Matrix.CreateTranslation(tl.X, tl.Y, tl.Z, outMatrix); * return outMatrix; * }*/ public PositionedQuad(TexturedQuad quad, Vector2 position) { Texture = quad.Texture; Vertices = quad.Vertices; Position = position; Show = true; ScaleX = quad.ScaleX; ScaleY = quad.ScaleY; GenerateVertices(); }
public void GenerateTiles() { this.Tiles = new TexturedQuad[tileCount]; for (var y = 0; y < rows; y++) { for (var x = 0; x < columns; x++) { var tq = new TexturedQuad() { ScaleX = (this.ScaleX / columns / this.ScaleX), ScaleY = (this.ScaleY / rows), ScaleZ = (1f), Texture = this._spriteSheet }; tq.GenerateVerticesWithSubsection(x * tileWidth, y * tileHeight, tileWidth, tileHeight); this.Tiles[x + y * columns] = tq; } } }
public VertexPositionNormalTexture[] GetPositionedTile(TexturedQuad Tile, Vector2 Position, float scale = 1, float angle = 0, float cameraZ = -1f) { VertexPositionNormalTexture[] outVerts = new VertexPositionNormalTexture[6]; for (int i = 0; i < Tile.Vertices.Length; i++) { outVerts[i].TextureCoordinate = Tile.Vertices[i].TextureCoordinate; outVerts[i].Normal = Tile.Vertices[i].Normal; // FIXME: Make separate version allowing rotation /* * outVerts[i].Position = Vector3.Transform(Tile.Vertices[i].Position, Matrix.CreateRotationX(Rotation.X)); * outVerts[i].Position = Vector3.Transform(outVerts[i].Position, Matrix.CreateRotationY(Rotation.Y)); * outVerts[i].Position = Vector3.Transform(outVerts[i].Position, Matrix.CreateRotationZ(Rotation.Z)); */ outVerts[i].Position = Tile.Vertices[i].Position; if (angle != 0) { outVerts[i].Position = Vector3.Transform(outVerts[i].Position, Matrix.CreateRotationZ(-angle)); } if (scale != 1) { outVerts[i].Position = Vector3.Transform(outVerts[i].Position, Matrix.CreateScale(scale)); } //if (this.CameraPosition != Vector3.Zero) //{ //var rcam = new Vector3(0, -0.1f, 1f); //outVerts[i].Position = Vector3.Transform(outVerts[i].Position, Matrix.CreateLookAt(outVerts[i].Position, rcam, Vector3.Up)); outVerts[i].Position = Vector3.Transform(outVerts[i].Position, Matrix.CreateRotationX((float)0.5f)); //outVerts[i].Position = Vector3.Transform(outVerts[i].Position, Matrix.CreateRotationY(Rotation.Y)); //outVerts[i].Position = Vector3.Transform(outVerts[i].Position, Matrix.CreateRotationZ(Rotation.Z)); //} outVerts[i].Position = Vector3.Transform(outVerts[i].Position, Matrix.CreateTranslation(new Vector3(Position.X, Position.Y, -0.95f))); } return(outVerts); }