public ScrollBar(int width) { width_ = width; min_ = 0; max_ = width_; boundingBox_ = new BoundingBox2D(Vector2.Zero, new Vector2(width_, W),0f); }
private void DrawPlayers() { if (CVars.ESP.DrawPlayers) { foreach (Character character in ESP_UpdateOBJs.GetPlayerList()) { Color color = this.playerColor.Get(); string equippedItemName = Local.GetEquippedItemName(character.transform); BoundingBox2D boxd = new BoundingBox2D(character); if (boxd.IsValid) { float x = boxd.X; float y = boxd.Y; float width = boxd.Width; float height = boxd.Height; float num5 = Vector3.Distance(character.transform.position, ESP_UpdateOBJs.LocalCharacter.transform.position); Canvas.DrawString(new Vector2(x + (width / 2f), y - 22f), color, Canvas.TextFlags.TEXT_FLAG_DROPSHADOW, character.playerClient.userName); Canvas.DrawString(new Vector2(x + (width / 2f), (y + height) + 2f), color, Canvas.TextFlags.TEXT_FLAG_DROPSHADOW, ((int)num5).ToString()); Canvas.DrawBoxOutlines(new Vector2(x, y), new Vector2(width, height), 1f, color); if (equippedItemName != string.Empty) { Vector2 vector = Canvas.TextBounds(equippedItemName); Canvas.DrawString(new Vector2((x - vector.x) - 8f, (y + (height / 2f)) - (vector.y / 2f)), color, Canvas.TextFlags.TEXT_FLAG_OUTLINED, equippedItemName); } } } } }
public override void Deserialize(XElement element) { if (element.Element("boundingBox") != null) { if (BoundingBox2D == null) { BoundingBox2D = new BoundingBox2D(); } BoundingBox2D.Deserialize(element.Element("boundingBox")); } int collisionPriority = int.MaxValue; if (element.Element("priority") != null) { int.TryParse(element.Element("priority").Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out collisionPriority); } CollisionPriority = collisionPriority; bool solid = true; if (element.Element("solid") != null) { bool.TryParse(element.Element("solid").Value, out solid); } Solid = solid; }
public void showAgain(Vector2 pos) { this.Location = new System.Drawing.Point((int)(pos.X + Browser.Instance.clientBounds.Min.X), (int)(pos.Y + Browser.Instance.clientBounds.Min.Y)); this.Show(); IsShown = true; boundingBox = new BoundingBox2D(new Vector2(pos.X, pos.Y), new Vector2(pos.X + width, pos.Y + height), 0f); }
public override void CalcBoundingBox2D() { ray2DEffects.Clear(); float timepassed = totalTime - lifeTime.TimeLeft; int length = positions.Length; BoundingBox2D box = null; IControlable source = weaponInfo.LastBody; for (int pos = 0; pos < length; ++pos) { if (timepassed >= startTimes[pos] && timepassed <= startTimes[pos] + lifeTimes[pos]) { Vector2D start = Vector2D.Rotate(source.Current.Position.Angular + positions[pos], Vector2D.XAxis) * source.BoundingRadius + source.Current.Position.Linear; Vector2D Direction = Vector2D.Rotate(source.Current.Position.Angular + directions[pos], Vector2D.XAxis); RaySegment2D segment = new RaySegment2D(start, Direction, distances[pos]); if (box == null) { box = segment.BoundingBox2D; } else { box = BoundingBox2D.From2BoundingBox2Ds(box, segment.BoundingBox2D); } ray2DEffects.Add(new SelectiveImpulseRay(lifeTime, segment, impulses[pos], BodyFlags.IgnoreGravity)); } } if (box == null) { box = new BoundingBox2D(Vector2D.Zero, Vector2D.Zero); } this.boundingBox2D = box; }
/// <summary> /// Create a 2D bounding box that contain all given points /// </summary> /// <param name="point_list"></param> /// <returns></returns> private static BoundingBox2D CreateBoundingBox2DFromPointList(Vector3 [] point_list) { BoundingBox2D bb_ret = new BoundingBox2D(); bb_ret.min = new Vector2(float.MaxValue, float.MaxValue); bb_ret.max = new Vector2(float.MinValue, float.MinValue); foreach (var point in point_list) { // get bb in 2d var screen_pos = GTAUtils.Convert3DPostoScreenPos(point); if (screen_pos.X == -1f || screen_pos.Y == -1f) { return(null); } // update bb bb_ret.min.X = Math.Min(bb_ret.min.X, screen_pos.X); bb_ret.min.Y = Math.Min(bb_ret.min.Y, screen_pos.Y); bb_ret.max.X = Math.Max(bb_ret.max.X, screen_pos.X); bb_ret.max.Y = Math.Max(bb_ret.max.Y, screen_pos.Y); } return(bb_ret); }
private float GetParamSpacing(RootBlox rootBlox) { BoundingBox2D rootBBox = GameObjectHelper.getBoundingBoxInWorld(rootBlox.gameObject); float rootBloxWidth = GameObjectHelper.getWidthFromBBox(rootBBox); float bloxParamSpacing = rootBloxWidth / 10; return(bloxParamSpacing); }
public void Intersect_Intersects_ReturnTrue(int x, int y) { var box = new BoundingBox2D(new Vector2(10, 10), new Size(10, 10)); var result = box.Intersects(new Vector2(x, y)); Assert.That(result, Is.True); }
public void Update() { BoundingBox2D playerBox = player.NewBoundingBox; CheckLava(playerBox); CheckPlatforms(playerBox); CheckHazards(playerBox); }
private float GetVerticalSpacing(RootBlox rootBlox) { BoundingBox2D rootBBox = GameObjectHelper.getBoundingBoxInWorld(rootBlox.gameObject); float rootBloxHeight = GameObjectHelper.getHeightFromBBox(rootBBox); float bloxVerticalSpacing = 2 * rootBloxHeight / 3; return(bloxVerticalSpacing); }
public PhotoTag(List<String> tags) { //tags.Add("Color"); foreach (String t in tags) tagBox[t] = new BoundingBox2D(); allTags = tags; activeTagList = new List<String>(); }
public void ShouldGet9Area() { var rectangle = new BoundingBox2D <Int32>(); rectangle.Width = 3; rectangle.Height = 3; Assert.Equals(9, rectangle.GetArea()); }
public bool Equals(object obj) { if (obj is BoundingBox2D) { BoundingBox2D v = (BoundingBox2D)obj; return(this.PMin == v.PMin && this.PMax == v.PMin); } return(false); }
public ListItem(string textValue, Vector2 localPosition) { localPosition += new Vector2(padding); this.localPosition = localPosition; text = new Text(font, textValue, Vector2.Zero, OriginLocations.TOP_LEFT, Color.Black); BoundingBox = new BoundingBox2D(Vector2.Zero, boxWidth, boxHeight); }
public void Init(IMy2DClipmapManager parent, int x, int y, int lod, ref BoundingBox2D bounds) { m_manager = (MyPlanetEnvironmentComponent)parent; var bounds3D = new BoundingBoxD(new Vector3D(bounds.Min, 0), new Vector3D(bounds.Max, 0)); Lod = lod; Face = m_manager.ActiveFace; var matrix = m_manager.ActiveClipmap.WorldMatrix; bounds3D = bounds3D.Transform(matrix); Coords = new Vector2I(x, y); Id = MyPlanetSectorId.MakeSectorId(x, y, m_manager.ActiveFace, lod); m_manager.RegisterProxy(this); MyEnvironmentSectorParameters sectorParams; matrix.Translation = Vector3D.Zero; sectorParams.SurfaceBasisX = Vector3.Transform(new Vector3(bounds.Width / 2, 0, 0), matrix); sectorParams.SurfaceBasisY = Vector3.Transform(new Vector3(0, bounds.Height / 2, 0), matrix); sectorParams.Center = bounds3D.Center; if (lod > m_manager.MaxLod) { return; } if (!m_manager.TryGetSector(Id, out EnvironmentSector)) { sectorParams.SectorId = Id; sectorParams.EntityId = MyPlanetSectorId.MakeSectorId(x, y, m_manager.ActiveFace, lod); sectorParams.Bounds = m_manager.GetBoundingShape(ref sectorParams.Center, ref sectorParams.SurfaceBasisX, ref sectorParams.SurfaceBasisY);; sectorParams.Environment = m_manager.EnvironmentDefinition; sectorParams.DataRange = new BoundingBox2I(Coords << lod, ((Coords + 1) << lod) - 1); sectorParams.Provider = m_manager.Providers[m_manager.ActiveFace]; EnvironmentSector = m_manager.EnvironmentDefinition.CreateSector(); EnvironmentSector.Init(m_manager, ref sectorParams); m_manager.Planet.AddChildEntity((MyEntity)EnvironmentSector); } m_manager.EnqueueOperation(this, lod); LodSet = lod; EnvironmentSector.OnLodCommit += sector_OnMyLodCommit; }
public static void FillBoundingBox(SpriteBatch sb, BoundingBox2D boundingBox, Color color) { int width = (int)boundingBox.Width; int height = (int)boundingBox.Height; int x = (int)boundingBox.Center.X - width / 2; int y = (int)boundingBox.Center.Y - height / 2; sb.Draw(whitePixel, new Rectangle(x, y, width, height), color); }
public override void CopyInto(IBaseComponent newObject) { var collisionComp = newObject as CollisionComponent; Debug.Assert(collisionComp != null, "collisionComp != null"); collisionComp.BoundingBox2D = (BoundingBox2D)BoundingBox2D.DeepCopy(); collisionComp.CollisionPriority = CollisionPriority; base.CopyInto(newObject); }
public StationarySpikes(Platform platform) : base(HazardTypes.STATIONARY_SPIKES) { BoundingBox2D platformBox = platform.BoundingBox; position = new Vector2(platformBox.Left, platformBox.Bottom); numSpikes = (int)platformBox.Width / textureWidth; BoundingBox = new BoundingBox2D(new Vector2(platformBox.Center.X, platformBox.Bottom), platformBox.Width, platformBox.Height); Active = true; }
private void CheckPlatforms(BoundingBox2D playerBox) { foreach (Platform platform in platforms) { BoundingBox2D platformBox = platform.BoundingBox; if (playerBox.Intersects(platformBox)) { player.RegisterPlatformCollision(platform); } } }
public void Init(IMy2DClipmapManager parent, int x, int y, int lod, ref BoundingBox2D bounds) { m_manager = (MyPlanetEnvironmentComponent)parent; var bounds3D = new BoundingBoxD(new Vector3D(bounds.Min, 0), new Vector3D(bounds.Max, 0)); Lod = lod; Face = m_manager.ActiveFace; var matrix = m_manager.ActiveClipmap.WorldMatrix; bounds3D = bounds3D.Transform(matrix); Coords = new Vector2I(x, y); Id = MyPlanetSectorId.MakeSectorId(x, y, m_manager.ActiveFace, lod); m_manager.RegisterProxy(this); MyEnvironmentSectorParameters sectorParams; matrix.Translation = Vector3D.Zero; sectorParams.SurfaceBasisX = Vector3.Transform(new Vector3(bounds.Width / 2, 0, 0), matrix); sectorParams.SurfaceBasisY = Vector3.Transform(new Vector3(0, bounds.Height / 2, 0), matrix); sectorParams.Center = bounds3D.Center; if (lod > m_manager.MaxLod) return; if (!m_manager.TryGetSector(Id, out EnvironmentSector)) { sectorParams.SectorId = Id; sectorParams.EntityId = MyPlanetSectorId.MakeSectorId(x, y, m_manager.ActiveFace, lod); sectorParams.Bounds = m_manager.GetBoundingShape(ref sectorParams.Center, ref sectorParams.SurfaceBasisX, ref sectorParams.SurfaceBasisY); ; sectorParams.Environment = m_manager.EnvironmentDefinition; sectorParams.DataRange = new BoundingBox2I(Coords << lod, ((Coords + 1) << lod) - 1); sectorParams.Provider = m_manager.Providers[m_manager.ActiveFace]; EnvironmentSector = m_manager.EnvironmentDefinition.CreateSector(); EnvironmentSector.Init(m_manager, ref sectorParams); m_manager.Planet.AddChildEntity((MyEntity)EnvironmentSector); } m_manager.EnqueueOperation(this, lod); LodSet = lod; EnvironmentSector.OnLodCommit += sector_OnMyLodCommit; }
public WindowState(Size ViewableAreaSize, float Scale, Vector2D CameraPosition) { this.ViewableAreaSize = ViewableAreaSize; this.Scale = Scale; this.CameraPosition = CameraPosition; Vector2D tmp = new Vector2D(ViewableAreaSize.Width / (2 * Scale), ViewableAreaSize.Height / (2 * Scale)); this.Offset = tmp - CameraPosition; Vector2D OtherBound = -tmp - CameraPosition; this.ScreenBoundingBox = new BoundingBox2D(CameraPosition + tmp, CameraPosition - tmp); }
public static void Build(RooFile Room) { if (Room == null) { return; } room = Room; if (BuildStarted != null) { BuildStarted(null, new EventArgs()); } /////////////////////////////////////////////////////////////// BoundingBox2D box = Room.GetBoundingBox2D(true); Polygon poly = new Polygon(); poly.Add(box.Min); poly.Add(box.Min + new V2(box.Max.X - box.Min.X, 0f)); poly.Add(box.Max); poly.Add(box.Max - new V2(box.Max.X - box.Min.X, 0f)); /////////////////////////////////////////////////////////////// // clean up old data from room Room.Walls.Clear(); Room.BSPTree.Clear(); foreach (RooSector sector in Room.Sectors) { sector.Walls.Clear(); sector.Sides.Clear(); } // convert roomeditor walls to roowall for (int i = 0; i < Room.WallsEditor.Count; i++) { RooWall wall = Room.WallsEditor[i].ToRooWall(RooFile.VERSIONHIGHRESGRID, Room); Room.Walls.Add(wall); } /////////////////////////////////////////////////////////////// RooBSPItem tree = BuildNode(Room.Walls, poly, 0); /////////////////////////////////////////////////////////////// FillNode(tree, Room.BSPTree); SetNums(Room.BSPTree); }
public void NestObject(GameObject secondObject) { RootBlox rootBlox = GetRootBlox(); if (rootBlox != null && NestingActive) { if (secondObject.GetComponent <ABlox>() != null && secondObject != null && ValidateNesting(secondObject)) { ABlox secondObjectBlox = secondObject.GetComponent <ABlox>(); Vector2 thisObjectPosition = this.gameObject.transform.position; Vector2 secondObjectPosition = secondObject.transform.position; RectTransform gameObjectTransform = this.gameObject.GetComponent <RectTransform>(); RectTransform collidedObjectTransform = secondObject.GetComponent <RectTransform>(); BoundingBox2D thisBBox = GameObjectHelper.getBoundingBoxInWorld(this.gameObject); BoundingBox2D secondObjBBox = GameObjectHelper.getBoundingBoxInWorld(secondObject); float thisObjectWidth = GameObjectHelper.getWidthFromBBox(thisBBox); float secondObjectWidth = GameObjectHelper.getWidthFromBBox(secondObjBBox); float thisObjectHeight = GameObjectHelper.getHeightFromBBox(thisBBox); float secondObjectHeight = GameObjectHelper.getHeightFromBBox(secondObjBBox); //checks if second object top is bellow this object center if (secondObjBBox.top.y < thisObjectPosition.y) { if (!secondObjectBlox.IsParam && ValidateNestToBottom(secondObject) && MathHelper.IsNearby(secondObjBBox.left.x, thisBBox.left.x, thisObjectWidth / 4)) { AddToBottom(secondObjectBlox); OnNestToBottom(); } else if (!secondObjectBlox.IsParam && ValidateNestToBottomIdented(secondObject) && MathHelper.IsNearby(secondObjBBox.left.x, thisBBox.bottom.x, thisObjectWidth / 4)) { AddToBottomIdented(secondObjectBlox); OnNestToBottomIdented(); } } else //if it is above { // Checks if the left parth of the second object is near the right part of the first, and verifies if they are kind of aligned if (ValidateNestToTheSide(secondObject) && MathHelper.IsNearby(secondObjBBox.left.y, thisBBox.right.y, thisObjectHeight / 4) && MathHelper.IsNearby(secondObjBBox.left.x, thisBBox.right.x, thisObjectWidth / 4)) { // Nest side to side AddParam(secondObjectBlox); OnNestToSide(); } } OnNest(); SetAllBloxesPositionsOnScreen(); } } }
protected void LookAtTrajectory(Trajectory2D trajectory) { if (trajectory.Count > 0) { BoundingBox2D boundingBox = trajectory.BuildBoundingBox(); LookAt(boundingBox.Center.X, boundingBox.Center.Y, 1.1 * boundingBox.Width, 1.1 * boundingBox.Height); focusedTrajectory = trajectory; } else { focusedTrajectory = null; } }
public Platform(Vector2 position, HazardTypes hazardType, bool moving) { Texture2D texture = ContentLoader.LoadTexture("Platform"); sprite = new Sprite(texture, position); BoundingBox = new BoundingBox2D(position, texture.Width, texture.Height); Moving = moving; if (hazardType != HazardTypes.NONE) { CreateHazard(hazardType); } }
/// <summary> /// Creates a RooWall instance based on this RooWallEditor instance. /// </summary> /// <param name="RooVersion"></param> /// <param name="Room"></param> /// <returns></returns> public RooWall ToRooWall(uint RooVersion, RooFile Room) { if (Room == null) { return(null); } V2 q1, q2; // first try get boundingbox as defined by 'Things' BoundingBox2D box = Room.GetBoundingBox2DFromThings(); // no thingsbox? build based on editorwalls if (box == BoundingBox2D.NULL) { box = Room.GetBoundingBox2D(false); } // 1) Convert from 1:64 to 1:1024 // 2) Modify coordinate system (y-axis different) q1.X = (P0.X - box.Min.X) * 16f; q1.Y = (box.Max.Y - P0.Y) * 16f; q2.X = (P1.X - box.Min.X) * 16f; q2.Y = (box.Max.Y - P1.Y) * 16f; // sidenum in editorwall is 0 to n ( 0=unset) // sectnum in editorwall is -1 to n (-1=unset) RooWall wall = new RooWall( RooVersion, 0, (ushort)this.FileSideDef1, // no +1 (ushort)this.FileSideDef2, // no +1 q1, q2, Side1XOffset, Side2XOffset, Side1YOffset, Side2YOffset, (ushort)(Side1Sector + 1), // +1 mapping (ushort)(Side2Sector + 1)); // +1 mapping // now resolve the object references from indices // and fill in heights wall.ResolveIndices(Room); wall.CalculateWallSideHeights(); // done return(wall); }
public PointF[] GetDots(Size ViewableAreaSize, Vector2D cameraPosition, float scale) { Vector2D tmp = new Vector2D(ViewableAreaSize.Width / (2 * scale), ViewableAreaSize.Height / (2 * scale)); Vector2D Offset = tmp - cameraPosition; BoundingBox2D screenbox = new BoundingBox2D(cameraPosition + tmp, cameraPosition - tmp); Vector2D startpos = new Vector2D(); Vector2D endpos = new Vector2D(); startpos.X = size.X * (float)Math.Floor(screenbox.Lower.X * sizeInv.X); startpos.Y = size.Y * (float)Math.Floor(screenbox.Lower.Y * sizeInv.Y); endpos.X = size.X * (float)Math.Floor(screenbox.Upper.X * sizeInv.X); endpos.Y = size.Y * (float)Math.Floor(screenbox.Upper.Y * sizeInv.Y); startpos += Offset; endpos += Offset; int length = dots.Length; List <PointF> returnvalue = new List <PointF>(); Vector2D pos = new Vector2D(); for (pos.X = startpos.X; pos.X <= endpos.X; pos.X += size.X) { for (pos.Y = startpos.Y; pos.Y <= endpos.Y; pos.Y += size.Y) { Vector2D[] values = OperationHelper.ArrayRefOp <Vector2D, Vector2D, Vector2D>( dots, ref pos, Vector2D.Add); OperationHelper.ArrayRefOp <Vector2D, float, Vector2D>( values, ref scale, values, Vector2D.Multiply); //Vector2D[] values = Vector2D.Translate(pos,dots); //values = Vector2D.Multiply(scale,values); for (int vpos = 0; vpos < length; ++vpos) { PointF point = new PointF(); point.X = (float)values[vpos].X; point.Y = (float)values[vpos].Y; returnvalue.Add(point); } if (returnvalue.Count > maxdots) { return(returnvalue.ToArray()); } } } return(returnvalue.ToArray()); }
public RetractableSpikes(Platform platform) : base(HazardTypes.RETRACTABLE_SPIKES) { BoundingBox2D platformBox = platform.BoundingBox; numSpikes = (int)platformBox.Width / textureWidth; platformTop = (int)platformBox.Top; partialExtensionTarget = platformTop - PARTIAL_EXTENSION_LENGTH; fullExtensionTarget = platformTop - texture.Height; position = new Vector2(platformBox.Left, platformTop); BoundingBox = new BoundingBox2D(platformBox); stateTimer = new Timer(RETRACTED_DURATION, PartiallyExtend, false); extensionState = ExtensionStates.NONE; }
/// <summary> /// Constructor by values /// </summary> /// <param name="RooVersion"></param> /// <param name="BoundingBox"></param> /// <param name="A"></param> /// <param name="B"></param> /// <param name="C"></param> /// <param name="Right"></param> /// <param name="Left"></param> /// <param name="LineDefReference"></param> public RooPartitionLine( uint RooVersion, BoundingBox2D BoundingBox, Real A, Real B, Real C, ushort Right, ushort Left, ushort LineDefReference) : base(RooVersion) { this.A = A; this.B = B; this.C = C; this.Right = Right; this.Left = Left; this.WallReference = LineDefReference; this.BoundingBox = BoundingBox; }
public static void CustomizePolygon(this IFixture fixture) { const int polygonExteriorBufferCoordinate = 50; var pointFixture = new Fixture(); pointFixture.Customize <Point>(customization => customization.FromFactory(generator => new Point( generator.Next(polygonExteriorBufferCoordinate - 1), generator.Next(polygonExteriorBufferCoordinate - 1) ) ).OmitAutoProperties() ); fixture.Customize <Polygon>(customization => customization.FromFactory(generator => { const int pointsPerRing = 4; var ringCount = generator.Next(1, 10); var points = pointFixture.CreateMany <Point>(ringCount * pointsPerRing).ToArray(); var parts = new int[ringCount]; var offset = 0; for (var ringIndex = 0; ringIndex < ringCount; ringIndex++) { points[pointsPerRing * ringIndex + pointsPerRing - 1] = points[pointsPerRing * ringIndex]; // end = start parts[ringIndex] = offset; offset += pointsPerRing; } //Exterior ring needs to be bigger than the interior rings for (var index = 0; index < pointsPerRing; index++) { points[index] = new Point( points[index].X + polygonExteriorBufferCoordinate, points[index].Y + polygonExteriorBufferCoordinate ); } var boundingBox = new BoundingBox2D( points.Min(p => p.X), points.Min(p => p.Y), points.Max(p => p.X), points.Max(p => p.Y) ); return(new Polygon(boundingBox, parts, points)); }).OmitAutoProperties() ); }
private CollisionDirections GetCollisionDirection(BoundingBox2D playerBox, BoundingBox2D hazardBox, HazardTypes hazardType) { switch (hazardType) { case HazardTypes.STATIONARY_SPIKES: return(CollisionDirections.UP); case HazardTypes.RETRACTABLE_SPIKES: return(CollisionDirections.DOWN); case HazardTypes.LAVA_FALLS: return(playerBox.Left < hazardBox.Left ? CollisionDirections.RIGHT : CollisionDirections.LEFT); } return(CollisionDirections.NONE); }
public void DrawDots(WindowState state) { Vector2D Offset = state.Offset; BoundingBox2D screenbox = state.ScreenBoundingBox; Vector2D startpos = new Vector2D(); Vector2D endpos = new Vector2D(); startpos.X = size.X * (float)Math.Floor(screenbox.Lower.X * sizeInv.X); startpos.Y = size.Y * (float)Math.Floor(screenbox.Lower.Y * sizeInv.Y); endpos.X = size.X * (float)Math.Floor(screenbox.Upper.X * sizeInv.X); endpos.Y = size.Y * (float)Math.Floor(screenbox.Upper.Y * sizeInv.Y); startpos += Offset; endpos += Offset; int length = dots.Length; Vector2D pos = new Vector2D(); int count = 0; Gl.glBegin(Gl.GL_POINTS); for (pos.X = startpos.X; pos.X <= endpos.X; pos.X += size.X) { for (pos.Y = startpos.Y; pos.Y <= endpos.Y; pos.Y += size.Y) { Matrix3x3 matrix = Matrix3x3.FromScale(new Vector2D(state.Scale, state.Scale)) * Matrix3x3.FromTranslate2D(pos); // Vector2D[] values = Vector2D.Transform(matrix, dots); Vector2D[] values = OperationHelper.ArrayRefOp <Matrix3x3, Vector2D, Vector2D>( ref matrix, dots, Vector2D.Multiply); for (int vpos = 0; vpos < length; ++vpos) { state.DrawPoint(values[vpos], colors[vpos]); count++; } if (count > maxdots) { return; } } } Gl.glEnd(); }
public static void DrawBoundingBox(SpriteBatch sb, BoundingBox2D boundingBox, Color color) { int width = (int)boundingBox.Width; int height = (int)boundingBox.Height; int x = (int)boundingBox.Center.X - width / 2; int y = (int)boundingBox.Center.Y - height / 2; Rectangle destinationRectLeft = new Rectangle(x, y, 1, height); Rectangle destinationRectRight = new Rectangle(x + width, y, 1, height); Rectangle destinationRectTop = new Rectangle(x, y, width, 1); Rectangle destinationRectBottom = new Rectangle(x, y + height, width, 1); sb.Draw(whitePixel, destinationRectLeft, color); sb.Draw(whitePixel, destinationRectRight, color); sb.Draw(whitePixel, destinationRectTop, color); sb.Draw(whitePixel, destinationRectBottom, color); }
/// <summary> /// Positions the blox params on screen /// </summary> /// <param name="blox"></param> protected void SetBloxParamsPositionOnScreen(ABlox blox, float paramSpacing, bool nestingActive = true) { ABlox previousBloxInLine = blox; BoundingBox2D bloxBBox = GameObjectHelper.getBoundingBoxInWorld(blox.gameObject); float bloxWidth = GameObjectHelper.getWidthFromBBox(bloxBBox); foreach (ABlox param in blox.BloxParams) { param.SetNestingState(nestingActive); BoundingBox2D paramBBox = GameObjectHelper.getBoundingBoxInWorld(param.gameObject); float paramWidth = GameObjectHelper.getWidthFromBBox(paramBBox); Vector2 paramPosition = previousBloxInLine.transform.position; paramPosition.x += (bloxWidth + paramWidth) / 2 + paramSpacing; param.transform.position = paramPosition; previousBloxInLine = param; } }
public void ShowTextBox(Vector2 pos, Stroke st) { this.Location = new System.Drawing.Point((int)(pos.X + SystemParameter.clientBounds.Min.X), (int)(pos.Y + SystemParameter.clientBounds.Min.Y)); this.Show(); IsShown = true; boundingBox = new BoundingBox2D(new Vector2(pos.X , pos.Y), new Vector2(pos.X + width, pos.Y + height), 0f); s = st; }
public unsafe void Split(BoundingBox2D* childBoxes, ref IMy2DClipmapNodeHandler[] children) { m_split = true; for (int i = 0; i < 4; ++i) children[i].Init(m_manager, (Coords.X << 1) + (i & 1), (Coords.Y << 1) + ((i >> 1) & 1), Lod - 1, ref childBoxes[i]); if (EnvironmentSector != null) // if we have so do our children. { for (int i = 0; i < 4; ++i) { m_children[i] = (MyPlanetEnvironmentClipmapProxy)children[i]; m_children[i].m_parent = this; } } }
public void Render(SpriteBatch batch, int windowWidth, Texture2D sb1, Texture2D sb2) { if (width_ != windowWidth) { min_ = (int)((double)min_ * (double)windowWidth / (double)width_); max_ = (int)((double)max_ * (double)windowWidth / (double)width_); width_ = windowWidth; } boundingBox_ = new BoundingBox2D(Vector2.Zero, new Vector2(width_, W), 0f); Vector2 scale1 = new Vector2((float)width_ / (float)sb1.Width, 1f); Vector2 scale2 = new Vector2((float)(max_ - min_) / (float)sb2.Width, 1f); Color whiteAlpha = new Color(255, 255, 255, 128); //batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); batch.Draw(sb1, Vector2.Zero, null, whiteAlpha, 0f, Vector2.Zero, scale1, SpriteEffects.None, 0f); whiteAlpha.A = (byte)192; batch.Draw(sb2, Vector2.UnitX * (float)min_, null, whiteAlpha, 0f, Vector2.Zero, scale2, SpriteEffects.None, 0f); //batch.End(); }
//left 2; right 2; up & down 4; alignment public List<int> drawTags(int startX, int startY, float angleDisplay) { int YOffset = 0; int resultWidth = 0; if (allTags.Count > 1) { foreach (String tag in allTags) { Dictionary<String, int> result = parseText(tag, width - left - right); if (result.Values.First() > 1) resultWidth = 250; else if (resultWidth < 250 && resultWidth < ResourceManager.font_.MeasureString(tag).Length() + 5) resultWidth = (int)ResourceManager.font_.MeasureString(tag).Length() + 5; if (activeTagList.Contains(tag)) { Browser.Instance.batch_.DrawString(ResourceManager.font_, result.Keys.First(), new Vector2(startX + left, startY + YOffset), Color.Red); } else Browser.Instance.batch_.DrawString(ResourceManager.font_, result.Keys.First(), new Vector2(startX + left, startY + YOffset), Color.Gray); Vector2 size = ResourceManager.font_.MeasureString(tag); //create bounding box for every tag tagBox[tag] = new BoundingBox2D(new Vector2(startX, startY + YOffset), new Vector2(startX + resultWidth, startY + YOffset + size.Y * result.Values.First()), angleDisplay); YOffset +=(int) size.Y * result.Values.First()+ up; } //createBox(startX, startY, angleDisplay); } List<int> maxSize = new List<int>(); maxSize.Add(resultWidth); maxSize.Add(YOffset); return maxSize; }
public GameObject(GameplayScreen pParent) { m_pParent = pParent; m_pBoundingBox2D = new BoundingBox2D(0, 0, 0, 0); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { #if CALC_FPS experimentForm_.LogUpdateTime(gameTime, photos_.Count); #endif #if NoEyeTrack #else eyeTrackingForm_.ScreenBounds = screenBounds; #endif clientBounds = new BoundingBox2D(new Vector2(Window.ClientBounds.Left, Window.ClientBounds.Top), new Vector2(Window.ClientBounds.Right, Window.ClientBounds.Bottom), 0f); #region 指点设备状态更新 //touchDevices.Clear(); pdCollection.initialize(); inputController.trigerDock(); // アイトラッカをポインティングデバイスとして追加 #if NoEyeTrack #else if (eyeTrackingForm_.IsTracking) { // 両目の視点の平均を利用 利用视点的平均值 pointingDevices.Add(new PointingDevice(-1, PointingDevice.DeviceType.EyeTracker, eyeTrackingForm_.GazePosition - clientBounds.Min)); draggedPhotos_.Add(new List<SDraggedPhoto>()); //// 左右の視点を別々に利用 //pointingDevices.Add(new PointingDevice(-2, PointingDevice.DeviceType.EyeTracker, eyeTrackingForm_.LeftGazePosition - clientBounds.Min)); //pointingDevices.Add(new PointingDevice(-3, PointingDevice.DeviceType.EyeTracker, eyeTrackingForm_.RightGazePosition - clientBounds.Min)); } #endif #endregion /// /// 用户的操作 /// #region keyboard keyboard.getKeyboardState(); #endregion //strokeGroup.remove(); photoDisplay.photoInitialize(); inputController.check(); photoDisplay.photoBehavior(); //pdCollection.removeTouchMap(rawInput.TouchRemoveList); rawInput.removeTouchMap();//remove not-existing touch point; if remove in touchup function, can't detect tap. base.Update(gameTime); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { #if CALC_FPS experimentForm_.LogUpdateTime(gameTime, photos_.Count); #endif #if NoEyeTrack #else eyeTrackingForm_.ScreenBounds = screenBounds; #endif if ((this.control.Focused && focus) || !deactivated) { clientBounds = new BoundingBox2D(new Vector2(Window.ClientBounds.Left, Window.ClientBounds.Top), new Vector2(Window.ClientBounds.Right, Window.ClientBounds.Bottom), 0f); #region 指点设备状态更新 //touchDevices.Clear(); pdCollection.initialize(); inputController.trigerDock(); if (BoxPosUpdate) { strokeGroup.PositionUpdate(); wall.UpdateWall(); } // アイトラッカをポインティングデバイスとして追加 #if NoEyeTrack #else if (eyeTrackingForm_.IsTracking) { // 両目の視点の平均を利用 利用视点的平均值 pointingDevices.Add(new PointingDevice(-1, PointingDevice.DeviceType.EyeTracker, eyeTrackingForm_.GazePosition - clientBounds.Min)); draggedPhotos_.Add(new List<SDraggedPhoto>()); //// 左右の視点を別々に利用 //pointingDevices.Add(new PointingDevice(-2, PointingDevice.DeviceType.EyeTracker, eyeTrackingForm_.LeftGazePosition - clientBounds.Min)); //pointingDevices.Add(new PointingDevice(-3, PointingDevice.DeviceType.EyeTracker, eyeTrackingForm_.RightGazePosition - clientBounds.Min)); } #endif #endregion /// /// 用户的操作 /// #region keyboard keyboard.getKeyboardState(); if (keyboard.altKey && keyboard.ctrlKey && keyboard.isKeyDown(Keys.Z)) { photoDisplay.Stop = false; } if (keyboard.altKey && keyboard.ctrlKey && keyboard.isKeyDown(Keys.X)) { photoDisplay.Stop = true; } #endregion //(window is not focused and deactivated is false) indicates focus is in textboxes photoDisplay.photoInitialize(); inputController.check(); photoDisplay.photoBehavior(); BoxPosUpdate = false; } else { inputController.clearStrokeUnderDrawing(); } //if deactivated is true, the app is deactivated if (deactivated && this.control.Focused) { // bool flag = false; // for (int i = 0; i < strokeGroup.textboxList.Count; i++) // { // if (strokeGroup.textboxList[i] != null && strokeGroup.textboxList[i].IfFocused()) // { // flag = true; // break; // } // } deactivated = false; for (int i = 0; i < strokeGroup.textboxList.Count; i++) { if (strokeGroup.textboxList[i] != null && strokeGroup.textboxList[i].IsShown) { strokeGroup.textboxList[i].Show(); } } } //if window lost focus && focus is not in textbox or wall form, //then we guess the focus is in other threads, so textbox's topmost should set to false //if (wall.IfFocused()) // Console.WriteLine("true"); if (!focus && !this.control.Focused && !wall.IfFocused()) { //Console.WriteLine("coming"); bool flag = false; for (int i = 0; i < strokeGroup.textboxList.Count; i++) { if (strokeGroup.textboxList[i] != null && strokeGroup.textboxList[i].IfFocused()) { flag = true; break; } } if (!flag) { for (int i = 0; i < strokeGroup.textboxList.Count; i++) { if (strokeGroup.textboxList[i] != null) { strokeGroup.textboxList[i].Hide(); } } //photoDisplay.clearActive(); deactivated = true; } } //if (deactivated) // Console.WriteLine("what!"); rawInput.removeTouchMap();//remove not-existing touch point; if remove in touchup function, can't detect tap. focus = this.control.Focused; base.Update(gameTime); }
public void ScaleAt(float tScale) { scale_ = tScale; boundingBox_ = new BoundingBox2D(position_ - center_ * scale_, position_ + center_ * scale_, 0f); }
public void MoveAt(Vector2 tPos) { position_ = tPos; boundingBox_ = new BoundingBox2D(position_ - center_ * scale_, position_ + center_ * scale_, 0f); }
//public void Unload() //{ // if (texture_ != null) // { // texture_.Dispose(); // texture_ = null; // } //} public void Move() { position_ += velocity_; boundingBox_ = new BoundingBox2D(position_ - center_ * scale_, position_ + center_ * scale_, 0f); }
public void Load() { //Assembly assembly = Assembly.GetExecutingAssembly(); //if (null == texture_) { center_ = new Vector2(ResourceManager.texture_[iconID_].Width, ResourceManager.texture_[iconID_].Height) * 0.5f; boundingBox_ = new BoundingBox2D(position_ - center_, position_ + center_, 0f); } }
public void Render(SpriteBatch batch, SpriteFont font, Texture2D tex) { // フォントの大きさを基準に吹き出しの大きさを変える int a = this.Left; int b = this.Right; Vector2 fontMeasure = font.MeasureString(text_); //if (isDel_) //{ // scaleTarget_ = -Vector2.One; //} //else { scaleTarget_.X = fontMeasure.X / (float)InWidth; scaleTarget_.Y = fontMeasure.Y / (float)InHeight; if (type_ == FukiType.ToolTip) { scaleTarget_ *= 0.7f; } } // 出てくるときに揺らす //if (type_ != FukiType.DateTime) { float tempWeight = 1f / 5f; vScale_.X += (scaleTarget_.X - scale_.X) * tempWeight; vScale_.Y += (scaleTarget_.Y - scale_.Y) * tempWeight; tempWeight = 0.5f; vScale_ *= tempWeight; scale_ += vScale_; } // boundingBox を更新 Vector2 center = new Vector2((float)Width / 2f, (float)Height / 2f); boundingBox_ = new BoundingBox2D(position_ - center * scale_, position_ + center * scale_, 0f); if (scale_.X >= 0 && scale_.Y >= 0) { float depth = Math.Min(1f, 0.5f * (float)Math.Exp(scale_.X - scaleTarget_.X)); float ep = 0.0000001f; depth = Math.Max(ep, depth); batch.Draw(tex, position_, null, Color.White, 0f, center, scale_, SpriteEffects.None, depth); center = fontMeasure * 0.5f; Vector2 stringScale = new Vector2(scale_.X * InWidth / fontMeasure.X, scale_.Y * InHeight / fontMeasure.Y); batch.DrawString(font, text_, position_, Color.Black, 0f, center, stringScale, SpriteEffects.None, depth - ep); } }
/// <summary> /// アトラクター選択後の処理 /// </summary> public void End() { if (isDel_) { scale_ -= 0.5f; } else { position_ += velocity_ * (1.0f / 60.0f); scale_ += vscale_ * (1.0f / 60.0f); #if NO_ROTATION #else angle_ += (float)(Math.Sign(vangle_) * Math.PI) * (1.0f / 60.0f); while (angle_ > Math.PI) { angle_ -= (float)Math.PI * 2f; } while (angle_ < -Math.PI) { angle_ += (float)Math.PI * 2f; } #endif } //bounding box if (IsGazeds && ptag.allTags != null && maxTagSize != Vector2.Zero && ptag.allTags.Count > 0) { //Console.WriteLine(velocity_); ////ptag.createBox(this.PositionDisplay.X + this.WidthDisplay / 2, this.PositionDisplay.Y - this.HeightDisplay / 2, angleDisplay_); //int positionLarger = (int)Math.Max(position_.Y - center_.Y * scale_ - (float)((1d - Math.Exp(-(double)scale_)) * (double)Browser.MAR + 2d) + maxTagSize[1], position_.Y + center_.Y * scale_ + (float)((1d - Math.Exp(-(double)scale_)) * (double)Browser.MAR + 2d)); ////(int)(position_.Y - center_.Y * scale_ - (float)((1d - Math.Exp(-(double)scale_)) * (double)Browser.MAR + 2d) + maxTagSize[1]); // int positionDisplayLarger = (int)Math.Max(positionDisplay_.Y - center_.Y * scaleDisplay_ - (float)((1d - Math.Exp(-(double)scaleDisplay_)) * (double)Browser.MAR + 2d) + maxTagSize[1], positionDisplay_.Y + center_.Y * scaleDisplay_ + (float)((1d - Math.Exp(-(double)scaleDisplay_)) * (double)Browser.MAR + 2d)); //(int)(positionDisplay_.Y - center_.Y * scaleDisplay_ - (float)((1d - Math.Exp(-(double)scaleDisplay_)) * (double)Browser.MAR + 2d) + maxTagSize[1]); boundingBox_ = new BoundingBox2D( position_ - center_ * scale_ - Vector2.One * (float)((1d - Math.Exp(-(double)scale_)) * (double)Browser.MAR + 2d), position_ + center_ * scale_ + Vector2.One * (float)((1d - Math.Exp(-(double)scale_)) * (double)Browser.MAR + 2d) + maxTagSize, angle_); boundingBoxDisplay_ = new BoundingBox2D( positionDisplay_ - center_ * scaleDisplay_ - Vector2.One * (float)((1d - Math.Exp(-(double)scaleDisplay_)) * (double)Browser.MAR + 2d), positionDisplay_ + center_ * scaleDisplay_ + Vector2.One * (float)((1d - Math.Exp(-(double)scaleDisplay_)) * (double)Browser.MAR + 2d) + maxTagSize, angleDisplay_); } else { boundingBox_ = new BoundingBox2D( position_ - center_ * scale_ - Vector2.One * (float)((1d - Math.Exp(-(double)scale_)) * (double)Browser.MAR + 2d), position_ + center_ * scale_ + Vector2.One * (float)((1d - Math.Exp(-(double)scale_)) * (double)Browser.MAR + 2d), angle_); boundingBoxDisplay_ = new BoundingBox2D( positionDisplay_ - center_ * scaleDisplay_ - Vector2.One * (float)((1d - Math.Exp(-(double)scaleDisplay_)) * (double)Browser.MAR + 2d), positionDisplay_ + center_ * scaleDisplay_ + Vector2.One * (float)((1d - Math.Exp(-(double)scaleDisplay_)) * (double)Browser.MAR + 2d), angleDisplay_); } }
//public ContainmentType BoundingContains(Vector2 pos) //{ // if (scale_.X > 0 && scale_.Y > 0) // { // return boundingBox_.Contains(pos); // } // else // { // return ContainmentType.Disjoint; // } //} public void MoveAtH(float x) { position_.X = x; Vector2 scaledCenter = new Vector2(scale_.X * (float)Width / 2f, scale_.Y * (float)Height / 2f); boundingBox_ = new BoundingBox2D(position_ - scaledCenter, position_ + scaledCenter, 0f); }
public override void LoadContent(Microsoft.Xna.Framework.Content.ContentManager pContent) { if (m_nPlayer == 0) return; Texture2D pTexture = null; try { pTexture = pContent.Load<Texture2D>("GFX\\Players\\player" + m_nPlayer + ""); } catch (ArgumentException e) { Console.WriteLine(e.ToString()); } this.Animation = new SimpleAnimation(pTexture, Vector2.Zero, 1, 4, 200); this.BoundingBox = new BoundingBox2D(this.Animation.Position.X, this.Animation.Position.Y, 2, 2); m_pMovementBoundingBox = new BoundingBox2D(this.Animation.Position.X, this.Animation.Position.Y, 2, 2); m_pFont = pContent.Load<SpriteFont>("GFX\\Fonts\\defaultFont"); m_rgWeapons[0] = new Weapon(); m_rgWeapons[0].Color = Color.Blue; m_rgWeapons[0].Damage = this.Parent.GameConfiguration.WeaponBulletDamage[0];//1.5f; m_rgWeapons[0].Name = "Assault carbine"; m_rgWeapons[0].ReloadTime = this.Parent.GameConfiguration.WeaponReloadTime[0]; m_rgWeapons[0].Speed = this.Parent.GameConfiguration.WeaponBulletSpeed[0]; m_rgWeapons[0].Animation = new SimpleAnimation(pContent.Load<Texture2D>("GFX\\Weapons\\standardgun"), this.Animation.Position, 1, 4, this.Parent.GameConfiguration.WeaponAnimationSpeeds[0]); m_rgWeapons[0].Animation.DepthLayer = 0.239f; m_rgWeapons[0].Animation.Loop = false; m_rgWeapons[0].Animation.Play = false; m_rgWeapons[0].Icon = pContent.Load<Texture2D>("GFX\\Weapons\\weapon1_icon"); m_rgWeapons[0].Sound = pContent.Load<SoundEffect>("SFX\\weapon1"); m_rgWeapons[1] = new Weapon(); m_rgWeapons[1].Color = Color.Red; m_rgWeapons[1].Damage = this.Parent.GameConfiguration.WeaponBulletDamage[1]; m_rgWeapons[1].Name = "Minigun"; m_rgWeapons[1].ReloadTime = this.Parent.GameConfiguration.WeaponReloadTime[1]; m_rgWeapons[1].Speed = this.Parent.GameConfiguration.WeaponBulletSpeed[1]; m_rgWeapons[1].Animation = new SimpleAnimation(pContent.Load<Texture2D>("GFX\\Weapons\\minigun"), this.Animation.Position, 1, 4, this.Parent.GameConfiguration.WeaponAnimationSpeeds[1]); m_rgWeapons[1].Animation.DepthLayer = 0.239f; m_rgWeapons[1].Animation.Loop = false; m_rgWeapons[1].Animation.Play = false; m_rgWeapons[1].Icon = pContent.Load<Texture2D>("GFX\\Weapons\\weapon1_icon"); m_rgWeapons[1].Sound = pContent.Load<SoundEffect>("SFX\\weapon1"); m_rgWeapons[2] = new Weapon(); m_rgWeapons[2].Color = Color.Red; m_rgWeapons[2].Damage = this.Parent.GameConfiguration.WeaponBulletDamage[2]; m_rgWeapons[2].Name = "Railgun"; m_rgWeapons[2].ReloadTime = this.Parent.GameConfiguration.WeaponReloadTime[2]; m_rgWeapons[2].Speed = this.Parent.GameConfiguration.WeaponBulletSpeed[2]; m_rgWeapons[2].Animation = new SimpleAnimation(pContent.Load<Texture2D>("GFX\\Weapons\\railgun"), this.Animation.Position, 1, 4, this.Parent.GameConfiguration.WeaponAnimationSpeeds[2]); m_rgWeapons[2].Animation.DepthLayer = 0.239f; m_rgWeapons[2].Animation.Loop = false; m_rgWeapons[2].Animation.Play = false; m_rgWeapons[2].Icon = pContent.Load<Texture2D>("GFX\\Weapons\\weapon1_icon"); m_rgWeapons[2].Sound = pContent.Load<SoundEffect>("SFX\\weapon1"); m_rgWeapons[2].GunType = GunTypes.RAILGUN; m_rgWeapons[3] = new Weapon(); m_rgWeapons[3].Color = Color.Red; m_rgWeapons[3].Damage = this.Parent.GameConfiguration.WeaponBulletDamage[3]; m_rgWeapons[3].Name = "Shotgun"; m_rgWeapons[3].ReloadTime = this.Parent.GameConfiguration.WeaponReloadTime[3]; m_rgWeapons[3].Speed = this.Parent.GameConfiguration.WeaponBulletSpeed[3]; m_rgWeapons[3].Animation = new SimpleAnimation(pContent.Load<Texture2D>("GFX\\Weapons\\shotgun"), this.Animation.Position, 1, 4, this.Parent.GameConfiguration.WeaponAnimationSpeeds[3]); m_rgWeapons[3].Animation.DepthLayer = 0.239f; m_rgWeapons[3].Animation.Loop = false; m_rgWeapons[3].Animation.Play = false; m_rgWeapons[3].Icon = pContent.Load<Texture2D>("GFX\\Weapons\\weapon1_icon"); m_rgWeapons[3].Sound = pContent.Load<SoundEffect>("SFX\\weapon1"); m_rgWeapons[3].GunType = GunTypes.SHOTGUN; m_rgWeapons[4] = new Weapon(); m_rgWeapons[4].Color = Color.Red; m_rgWeapons[4].Damage = this.Parent.GameConfiguration.WeaponBulletDamage[4]; m_rgWeapons[4].Name = "Rocket launcher"; m_rgWeapons[4].ReloadTime = this.Parent.GameConfiguration.WeaponReloadTime[4]; m_rgWeapons[4].Speed = this.Parent.GameConfiguration.WeaponBulletSpeed[4]; m_rgWeapons[4].Animation = new SimpleAnimation(pContent.Load<Texture2D>("GFX\\Weapons\\rocketlauncher_temp"), this.Animation.Position, 1, 4, this.Parent.GameConfiguration.WeaponAnimationSpeeds[4]); m_rgWeapons[4].Animation.DepthLayer = 0.239f; m_rgWeapons[4].Animation.Loop = false; m_rgWeapons[4].Animation.Play = false; m_rgWeapons[4].Icon = pContent.Load<Texture2D>("GFX\\Weapons\\weapon1_icon"); m_rgWeapons[4].Sound = pContent.Load<SoundEffect>("SFX\\weapon1"); m_rgWeapons[4].GunType = GunTypes.ROCKET; base.LoadContent(pContent); }
public void MoveAtV(float y) { position_.Y = y; Vector2 scaledCenter = new Vector2(scaleTarget_.X * (float)Width / 2f, scaleTarget_.Y * (float)Height / 2f); boundingBox_ = new BoundingBox2D(position_ - scaledCenter, position_ + scaledCenter, 0f); }
// 构造函数 public Browser(string[] args) { // 图形和内容管理器实例化 graphics_ = new GraphicsDeviceManager(this); // 抗锯齿有效 graphics_.PreferMultiSampling = true; // 设置窗口大小 ClientHeight = 768; ClientWidth = 1366; graphics_.PreferredBackBufferWidth = ClientWidth; graphics_.PreferredBackBufferHeight = ClientHeight; // 设置窗口名称 this.Window.Title = Title; // 可以调整窗口大小 this.Window.AllowUserResizing = true; // 窗口不显示鼠标 this.IsMouseVisible = false; // 是否固定60 FPS(詳細はXNAの仕様を参照 http://blogs.msdn.com/ito/archive/2007/03/08/2-update.aspx) #if CALC_FPS this.IsFixedTimeStep = false; #else this.IsFixedTimeStep = true; this.TargetElapsedTime = TimeSpan.FromSeconds(1d / 60d); #endif graphics_.ApplyChanges(); // 读取设定文件(图像日志) //controlPanel_.ReadPhotoLogs(photoLog_); //controlPanel_.ReadPeopleLogs(peopleTags); IntPtr hWnd = this.Window.Handle; control = System.Windows.Forms.Control.FromHandle(hWnd); this.Window.ClientSizeChanged += new EventHandler<EventArgs>(Window_ClientSizeChanged); //batch_ = new SpriteBatch(this.GraphicsDevice); //provide global access to game instance, so other classes can access graphicsdevice Instance = this; clientBounds = new BoundingBox2D(new Vector2(Window.ClientBounds.Left, Window.ClientBounds.Top), new Vector2(Window.ClientBounds.Right, Window.ClientBounds.Bottom), 0f); rawInput = new RawInputForm(); pdCollection = rawInput.pdCollection; systemState = new SystemState(); if (args.Length > 0) profilePath = args[0]; else profilePath = "profile.ini"; }