当前位置: 首页>>代码示例>>C#>>正文


C# PhysicsObject.getBBRelativeToWorld方法代码示例

本文整理汇总了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);
        }
开发者ID:danielpcox,项目名称:Crisis-at-Swiss-Station,代码行数:52,代码来源:Editor.cs


注:本文中的PhysicsObject.getBBRelativeToWorld方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。