public SpriteFarseer(GraphicFactory factory, CircleShape shape, Color color) : base(ModelType.Texture) { if (assetCreator == null) { assetCreator = new FarseerAsset2DCreator(factory); } Texture = assetCreator.CreateCircleTexture(shape.Radius / 2, color, 1); Origin = new Vector2(Texture.Width / 2f, Texture.Height / 2f); }
/// <summary> /// /// </summary> /// <param name="factory"></param> /// <param name="shape"></param> /// <param name="color"></param> /// <param name="isInSimulationUnits"></param> public SpriteFarseer(GraphicFactory factory, PolygonShape shape, Color color, bool isInSimulationUnits = false) : base(ModelType.Texture) { if (assetCreator == null) { assetCreator = new FarseerAsset2DCreator(factory); } Vector2 scale = Vector2.One / 2; shape.Vertices.Scale(ref scale); if (isInSimulationUnits) { for (int i = 0; i < shape.Vertices.Count; i++) { shape.Vertices[i] = ConvertUnits.ToSimUnits(shape.Vertices[i]); } } Texture = assetCreator.CreateTextureFromVertices(shape.Vertices, color, 1); Origin = new Vector2(Texture.Width / 2f, Texture.Height / 2f); }