Пример #1
0
        public void Initialize(asgCameraMode mode, asgPlayerActor player, float cameraForce, Vector2 targetOffset)
        {
            cameraMode = mode;
            this.cameraForce = cameraForce;
            if (gxtDisplayManager.SingletonIsInitialized)
            {
                gxtDisplayManager.Singleton.resolutionChanged += OnResolutionChanged;
            }

            gxtOBB tmp = Camera.GetViewOBB();
            cameraSafeZone = new gxtOBB(tmp.Position, tmp.Extents * 0.8f, tmp.Rotation);
            if (gxtDisplayManager.SingletonIsInitialized)
            {
                gxtDisplayManager.Singleton.resolutionChanged += OnResolutionChanged;
            }

            // cameraSpeed is in screen space
            cameraSpeed = 3.0f;
            cameraBody = new gxtRigidBody();
            cameraBody.MotionType = gxtRigidyBodyMotion.DYNAMIC;
            cameraBody.AngularDamping = 1.0f;
            cameraBody.Damping = 1.0f;
            cameraBody.IgnoreGravity = true;
            cameraBody.Mass = 2.0f;
            cameraBody.CanSleep = false;
            cameraBody.Awake = true;
            player.World.AddRigidBody(cameraBody);

            this.player = player;
            this.offset = targetOffset;
        }
Пример #2
0
        public static Vector2[] ComputeVerticesFromOBB(gxtOBB obb)
        {
            Vector2[] verts = new Vector2[4];

            Vector2 c = obb.Position;
            Vector2 r = obb.Extents;
            Vector2 localX = obb.localX;
            Vector2 localY = obb.localY;

            verts[0] = (c - (r.X * localX) - (r.Y * localY));
            verts[1] = (c - (r.X * localX) + (r.Y * localY));
            verts[2] = (c + (r.X * localX) + (r.Y * localY));
            verts[3] = (c + (r.X * localX) - (r.Y * localY));

            return verts;
        }
Пример #3
0
 /// <summary>
 /// Converts an OBB to a valid polygon with 4 vertices
 /// </summary>
 /// <param name="obb">OBB</param>
 /// <returns>Polygon</returns>
 public static gxtPolygon ComputePolygonFromOBB(gxtOBB obb)
 {
     return new gxtPolygon(ComputeVerticesFromOBB(obb));
 }
Пример #4
0
 /// <summary>
 /// Determines if an obb object is intersecting the camera obb
 /// </summary>
 /// <param name="obb"></param>
 /// <returns></returns>
 public bool IsOnScreen(gxtOBB obb)
 {
     return GetViewOBB().Intersects(obb);
 }
Пример #5
0
 /// <summary>
 /// Determines if an object's obb is fully contained inside the 
 /// camera obb
 /// </summary>
 /// <param name="obb"></param>
 /// <returns></returns>
 public bool IsFullyOnScreen(gxtOBB obb)
 {
     return GetViewOBB().Contains(obb);
 }