//rotation type private Vector2 getPos(TexturePoint t) { if (t == TexturePoint.mid) { return(new Vector2(0.5f, 0.5f)); } if (t == TexturePoint.left) { return(new Vector2(0f, 0.5f)); } if (t == TexturePoint.right) { return(new Vector2(1f, 0.5f)); } if (t == TexturePoint.top) { return(new Vector2(0.5f, 0f)); } if (t == TexturePoint.bottom) { return(new Vector2(0.5f, 1f)); } return(Vector2.Zero); }
private void TexturePoints() { //for (int i = 0; i < mainTexture.width; i++) //{ // for (int j = 0; j < mainTexture.height; j++) // { // TexturePoint texPoint = new TexturePoint(); // texPoint.coordinate = new Vector3(i, 0, j); // texturePoints.Add(texPoint); // } //} float wallWidthRatio = wallToPaint.GetComponent <MeshCollider>().bounds.size.x / mainTexture.width; float wallHeightRatio = wallToPaint.GetComponent <MeshCollider>().bounds.size.y / mainTexture.height; for (float i = wallWidthRatio * (-mainTexture.width / 2); i < wallWidthRatio * mainTexture.width / 2; i += wallWidthRatio) { for (float j = wallHeightRatio * (-mainTexture.height / 2); j < wallHeightRatio * mainTexture.height / 2; j += wallHeightRatio) { TexturePoint texPoint = new TexturePoint(); texPoint.coordinate = wallToPaint.transform.position + new Vector3(i, j, 0); texturePoints.Add(texPoint); } } }
//render stuff public void drawPart(Vector2 point, Vector2 size, Double angle, Texture2D t, double l, TexturePoint rotationType, Vector2 shift) { //Gets where to rotate Vector2 pos = getPos(rotationType); Vector2 rotationPos = (new Vector2(t.Width, t.Height) * pos) + shift; Rectangle rectangle = new Rectangle((int)point.X, (int)point.Y, (int)size.X, (int)size.Y); spriteBatch.Draw(t, rectangle, null, Color.White, (float)angle, rotationPos, SpriteEffects.None, (float)l); }