本文整理汇总了C#中PhysicsObject.getBBRelativeToWorld方法的典型用法代码示例。如果您正苦于以下问题:C# PhysicsObject.getBBRelativeToWorld方法的具体用法?C# PhysicsObject.getBBRelativeToWorld怎么用?C# PhysicsObject.getBBRelativeToWorld使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicsObject
的用法示例。
在下文中一共展示了PhysicsObject.getBBRelativeToWorld方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: drawPhysicsObject
//Draws an arbitrary space object to the drawing pane.
private void drawPhysicsObject(PhysicsObject obj, PaintEventArgs e)
{
//Console.WriteLine(obj.TextureFilename + ".png");
//Console.WriteLine(currdir + "\\" + obj.TextureFilename + ".png");
Image img = Image.FromFile(currdir + "\\" + obj.TextureFilename + ".png");
//In order to do rotations and scaling in windows forms, we need to determine where
// the upper right, upper left, and lower left corners map to. We determine these, and
// tell the graphics to draw the image.
// unscale before rotating
//obj.Height = obj.Height / obj.scale;
//obj.Width = obj.Width / obj.scale;
// Hack to make the image representing a painted object draw correctly
if (obj is PaintedObject && !(obj is InstasteelObject) && !(obj is InstasteelCircleObject))
{
((PaintedObject)obj).Height = img.Height;
((PaintedObject)obj).Width = img.Width;
}
XnaRectangle bb = obj.getBBRelativeToWorld();
float s = obj.scale;
//Find the new point for the upper-left corner
DrawPoint upper_left = Conversion.Vector2ToDrawPoint(new Vector2(bb.X + bb.Width/2f, bb.Y + bb.Height/2f) + RotateVector2(new Vector2(-obj.Width/2f, -obj.Height/2f), obj.Angle));
DrawPoint upper_right = Conversion.Vector2ToDrawPoint(new Vector2(bb.X + bb.Width/2f, bb.Y + bb.Height/2) + RotateVector2(new Vector2(obj.Width - obj.Width/2f, -obj.Height/2f), obj.Angle));
DrawPoint lower_left = Conversion.Vector2ToDrawPoint(new Vector2(bb.X + bb.Width/2f, bb.Y + bb.Height/2) + RotateVector2(new Vector2(-obj.Width/2f, obj.Height - obj.Height/2f), obj.Angle));
// rescale after rotating
//obj.Height = obj.Height * obj.scale;
//obj.Width = obj.Width * obj.scale;
/*
DrawPoint upper_left = Conversion.Vector2ToDrawPoint(RotateVector2(new Vector2(bb.X, bb.Y), obj.Angle));
DrawPoint upper_right = Conversion.Vector2ToDrawPoint(RotateVector2(new Vector2(bb.X + bb.Width, bb.Y), obj.Angle));
DrawPoint lower_left = Conversion.Vector2ToDrawPoint(RotateVector2(new Vector2(bb.X, bb.Y + bb.Height), obj.Angle));
*/
//Define the point mapping.
DrawPoint[] destmapping = {upper_left, upper_right, lower_left};
DrawRect srcrect = new DrawRect(0,0,img.Width,img.Height);
//Draw the image with the specified position and scaling.
e.Graphics.DrawImage(img, destmapping, srcrect, GraphicsUnit.Pixel);
}