/// <summary> /// Creates a new <see cref="CapturedImageFrame"/> instance from the <paramref name="stream"/> specified. /// </summary> /// <param name="stream">Captured image stream.</param> /// <param name="encoding">Encoding used to capture the frame <paramref name="stream"/></param> /// <param name="orientation">Camera orientation.</param> /// <param name="cameraType">Camera type.</param> /// <returns>Captured image frame.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="stream"/> is <see langword="null"/>. /// <para>-or-</para> /// <paramref name="encoding"/> is <see langword="null"/>. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="stream"/> cannot be read. /// <para>-or-</para> /// <paramref name="stream"/> is empty. /// </exception> public static CapturedImageFrame CreateFromStream(IRandomAccessStream stream, ImageEncodingProperties encoding, PageOrientation orientation, CameraType cameraType) { if (stream == null) { throw new ArgumentNullException("stream"); } if (!stream.CanRead) { throw new ArgumentException("Stream cannot be read.", "stream"); } if (stream.Size == 0) { throw new ArgumentException("Stream is empty.", "stream"); } if (encoding == null) { throw new ArgumentNullException("encoding"); } return(new CapturedImageFrame { Rotation = OrientationHelper.ConvertOrientationToRotation(orientation, cameraType), Flip = OrientationHelper.ConvertOrientationToFlip(orientation, cameraType), Stream = stream, Height = encoding.Height, Width = encoding.Width }); }
private View getStartView(RecyclerView.LayoutManager layoutManager, OrientationHelper helper) { var linearLayoutManager = (LinearLayoutManager)layoutManager; var firstChildIndex = linearLayoutManager.FindFirstVisibleItemPosition(); if (firstChildIndex == RecyclerView.NoPosition) { return(null); } subject.OnNext(linearLayoutManager.FindFirstCompletelyVisibleItemPosition() + 1); var lastItemIndex = linearLayoutManager.ItemCount - 1; var isLastItem = linearLayoutManager.FindLastCompletelyVisibleItemPosition() == lastItemIndex; if (isLastItem) { return(null); } var firstView = layoutManager.FindViewByPosition(firstChildIndex); var decoratedEnd = helper.GetDecoratedEnd(firstView); var threshold = helper.GetDecoratedMeasurement(firstView) / 2; if (decoratedEnd >= threshold && decoratedEnd > 0) { return(firstView); } return(layoutManager.FindViewByPosition(firstChildIndex + 1)); }
/// <summary> /// Creates a new <see cref="CapturedImageFrame"/> instance from the <paramref name="frame"/> specified. /// </summary> /// <param name="frame">Captured frame.</param> /// <param name="orientation">Camera orientation.</param> /// <param name="cameraType">Camera type.</param> /// <returns>Captured image frame.</returns> /// <exception cref="ArgumentNullException"><paramref name="frame"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentException"> /// <paramref name="frame"/> stream cannot be read. /// <para>-or-</para> /// <paramref name="frame"/> stream is empty. /// </exception> public static CapturedImageFrame CreateFromCapturedFrame(CapturedFrame frame, PageOrientation orientation, CameraType cameraType) { if (frame == null) { throw new ArgumentNullException("frame"); } if (!frame.CanRead) { throw new ArgumentException("Frame stream cannot be read.", "frame"); } if (frame.Size == 0) { throw new ArgumentException("Frame stream is empty.", "frame"); } return(new CapturedImageFrame { Rotation = OrientationHelper.ConvertOrientationToRotation(orientation, cameraType), Flip = OrientationHelper.ConvertOrientationToFlip(orientation, cameraType), Stream = frame, Height = frame.Height, Width = frame.Width }); }
private void UpdateWallCaps() { if (wallCapPrefab == null) { return; } // Go through each direction and ensure the wallcap is present. for (Direction direction = Direction.North; direction < Direction.NorthWest; direction += 2) { int i = (int)direction / 2; // Get the direction this applies to for the external world Direction outsideDirection = DirectionHelper.Apply(OrientationHelper.ToPrincipalDirection(TileState.orientation), direction); bool isPresent = adjacents.Adjacent(outsideDirection) == 1; if (isPresent && wallCaps[i] == null) { wallCaps[i] = SpawnWallCap(direction); wallCaps[i].name = $"WallCap{i}"; } else if (!isPresent && wallCaps[i] != null) { EditorAndRuntime.Destroy(wallCaps[i]); wallCaps[i] = null; } } }
public override void Start() { base.Start(); driveBehavior = DriveBehavior.None; vehicleControls = GetComponent <VehicleControls>(); turretTransform = transform.Find("Turret"); turret = turretTransform.GetComponent <SheepTurret>(); turret.owner = gameObject; myRigidBody = GetComponent <Rigidbody2D>(); if (reversePosition) { reverseFactor *= -1; } acceleration = Random.value; if (reversePosition) { OrientationHelper.RotateTransform(turretTransform, 180); } foreach (Transform child in transform.Find("Body").transform) { CarWheel wheel = child.GetComponent <CarWheel>(); if (wheel) { wheel.vehicleControls = vehicleControls; } } }
// Use this for initialization void Start() { loadMarker = transform.Find("LoadMarker").GetComponent <LoadMarker>(); loadMarker.road = this; roads.Add(this); // transform.eulerAngles = new Vector3( // 1, // transform.eulerAngles.y, // transform.eulerAngles.z); if (GameController.gameStarted) { foreach (Transform child in transform.Find("Spawns")) { float randomValue = Random.value; if (randomValue <= hazardChance) { GameObject rock = Instantiate(Resources.Load("Rock"), SpawnPosition(child.transform.position), Quaternion.identity) as GameObject; rock.transform.localScale = rock.transform.localScale * .1f; } else if (randomValue <= hazardChance + neutralChance) { GameObject neutralContainer = Instantiate(Resources.Load("Minions/Neutral Container"), SpawnPosition(child.transform.position), Quaternion.identity) as GameObject; Transform neutralBody = neutralContainer.transform.Find("Ship").transform; neutralBody.GetComponent <Entity>().neutral = true; OrientationHelper.RotateTransform(neutralBody.transform, -90); } } } }
public void ParseNames() { Assert.Equal(ExifOrientation.Horizontal, OrientationHelper.Parse("h")); Assert.Equal(ExifOrientation.Rotate90, OrientationHelper.Parse("rotate90")); Assert.Equal(ExifOrientation.Rotate180, OrientationHelper.Parse("rotate180")); Assert.Equal(ExifOrientation.Rotate270, OrientationHelper.Parse("rotate270")); }
private void UpdateWallCaps() { if (wallCapPrefab == null) { return; } // Go through each direction and ensure the wallcap is present. for (Direction direction = Direction.North; direction < Direction.NorthWest; direction += 2) { int i = (int)direction / 2; // Get the direction this applies to for the external world Direction outsideDirection = DirectionHelper.Apply(OrientationHelper.ToPrincipalDirection(TileState.orientation), direction); bool isPresent = adjacents.Adjacent(outsideDirection) == 1; if (isPresent && wallCaps[i] == null) { wallCaps[i] = EditorAndRuntime.InstantiatePrefab(wallCapPrefab, transform); wallCaps[i].name = $"WallCap{i}"; var cardinal = DirectionHelper.ToCardinalVector(DirectionHelper.Apply(Direction.East, direction)); var rotation = DirectionHelper.AngleBetween(Direction.South, direction); wallCaps[i].transform.localRotation = Quaternion.Euler(0, rotation, 0); wallCaps[i].transform.localPosition = new Vector3(cardinal.Item1, 0, cardinal.Item2); } else if (!isPresent && wallCaps[i] != null) { EditorAndRuntime.Destroy(wallCaps[i]); wallCaps[i] = null; } } }
private static bool IsEdgeLip(Collider2D col) { bool isLeft = col.transform.gameObject.layer == _leftClimbLayer; RaycastHit2D hit = Physics2D.Raycast((isLeft ? col.GetTopLeft() : col.GetTopRight()) + new Vector3(isLeft ? -0.3f : 0.3f, 0), OrientationHelper.GetDownwardVector(col.transform), ConstantVariables.MaxLipHeight, Layers.Platforms); return(hit); }
public void AssignFromView(View referenceChild, int position) { Coordinate = LayoutFillingStartsFromEnd ? OrientationHelper.GetDecoratedEnd(referenceChild) + OrientationHelper.TotalSpaceChange : OrientationHelper.GetDecoratedStart(referenceChild); Position = position; }
protected override void OnStateUpdate(DoorState prevState = new DoorState()) { float rotation = OrientationHelper.AngleBetween(Orientation.Horizontal, TileState.orientation); transform.localRotation = Quaternion.Euler(0, rotation, 0); UpdateWallCaps(); }
public void OnApplicationFocus(bool focus) { if (focus) { OrientationHelper.LockRotation(_gameState == GameState.Playing); //InitLandscapeSupportAndroid(); } }
public AnchorInfo(OrientationHelper orientationHelper, int anchorCount) { this.anchorCount = anchorCount; OrientationHelper = orientationHelper; Position = RecyclerView.NoPosition; Coordinate = InvalidOffset; IsValid = false; LayoutFillingStartsFromEnd = false; }
public void MovePivotDown() { Vector3 v = OrientationHelper.GetDownwardVector(Pivot.transform); Vector3 movement = v.normalized * 0.5f; UpdatePivot = false; Pivot.transform.Translate(movement, Space.World); }
protected override int VisiblePortion(AView view, OrientationHelper orientationHelper, bool rtl) { if (rtl) { return(orientationHelper.TotalSpace - orientationHelper.GetDecoratedStart(view)); } return(orientationHelper.GetDecoratedEnd(view)); }
private void UpdateMeshAndDirection() { // Count number of connections along cardinal (which is all that we use atm) var generalCardinals = generalAdjacents.GetCardinalInfo(); float rotation = 0.0f; Mesh mesh; if (generalCardinals.IsO()) { mesh = o; } else if (generalCardinals.IsC()) { mesh = c; rotation = DirectionHelper.AngleBetween(Direction.North, generalCardinals.GetOnlyPositive()); } else if (generalCardinals.IsI()) { // Check for specific connections var specificCardinals = specificAdjacents.GetCardinalInfo(); if (specificCardinals.numConnections == 1) { mesh = iBorder; rotation = DirectionHelper.AngleBetween(Direction.South, specificCardinals.GetOnlyPositive()); } else { mesh = specificCardinals.numConnections == 2 ? i : iAlone; rotation = OrientationHelper.AngleBetween(Orientation.Vertical, generalCardinals.GetFirstOrientation()); } } else if (generalCardinals.IsL()) { mesh = l; rotation = DirectionHelper.AngleBetween(Direction.NorthEast, generalCardinals.GetCornerDirection()); } else if (generalCardinals.IsT()) { mesh = t; rotation = DirectionHelper.AngleBetween(Direction.South, generalCardinals.GetOnlyNegative()); } else { mesh = x; } if (filter == null) { filter = GetComponent <MeshFilter>(); } filter.mesh = mesh; transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles.x, rotation, transform.localRotation.eulerAngles.z); }
public void ParseCodes() { Assert.Equal(ExifOrientation.Horizontal, OrientationHelper.Parse("1")); Assert.Equal(ExifOrientation.FlipHorizontal, OrientationHelper.Parse("2")); Assert.Equal(ExifOrientation.Rotate180, OrientationHelper.Parse("3")); Assert.Equal(ExifOrientation.FlipVertical, OrientationHelper.Parse("4")); Assert.Equal(ExifOrientation.Transpose, OrientationHelper.Parse("5")); Assert.Equal(ExifOrientation.Rotate90, OrientationHelper.Parse("6")); Assert.Equal(ExifOrientation.Transverse, OrientationHelper.Parse("7")); Assert.Equal(ExifOrientation.Rotate270, OrientationHelper.Parse("8")); }
public void GameOver() { if (gameState == GameState.Paused) { gameSceneManager.PauseButtonClicked(); } OrientationHelper.LockRotation(false); //TryLoadResults(); gameSceneManager.GameOver(); postAttempts = 0; gameState = GameState.Results; //Invoke("ShowResultsScreen", 2.5f); }
/// <summary> /// this method is a bit hacky since I did not know where to place it. I may move it to a better /// place somewhen in the future /// </summary> /// <param name="ray"></param> /// <param name="entity"></param> public bool GetIntersectionPoint( ref Ray3 ray, Entity entity, out Vector3 outIsectPt ) { // find the matching collision entity (in order to get the alignedbox3tree CollisionEntity collisionEntity = testList.GetCollisionEntity(entity); if (collisionEntity == null) { outIsectPt = Vector3.Zero; return(false); } Debug.Assert(collisionEntity.VolumeType == VolumeType.AlignedBox3Tree); if (collisionEntity.VolumeType != VolumeType.AlignedBox3Tree) { outIsectPt = Vector3.Zero; return(false); } // get world transform of from the given entity Matrix worldTransform; AlignedBox3Tree tree = (AlignedBox3Tree)collisionEntity.Volumes[0]; OrientationHelper.CalculateWorldTransform(entity, out worldTransform); // transform the ray into the coordinate system of the entity Matrix worldToEntityTransform = Matrix.Invert(worldTransform); Matrix inverseTransposeWorldToEntityTransform = Matrix.Transpose(Matrix.Invert(worldToEntityTransform)); Vector3 entitySpaceRayOrigin = Vector3.Transform(ray.Origin, worldToEntityTransform); Vector3 entitySpaceRayDirection = Vector3.Transform(ray.Direction, inverseTransposeWorldToEntityTransform); entitySpaceRayDirection.Normalize(); Ray3 entitySpaceRay = new Ray3(entitySpaceRayOrigin, entitySpaceRayDirection); float t; // parameter on ray, outIsectPt = ray.Origin + t * ray.Direction; bool intersection = GetIntersectionPoint(ref entitySpaceRay, tree.Root, tree.Positions, out t); if (intersection) { outIsectPt = Vector3.Transform(entitySpaceRay.Origin + t * entitySpaceRay.Direction, worldTransform); } else { outIsectPt = Vector3.Zero; } return(intersection); }
public void MovePivotAlongSurface(DirectionTravelling direction, float distance) { Vector3 v = OrientationHelper.GetSurfaceVectorTowardsRight(Pivot.transform); if (direction == DirectionTravelling.Left) { v = -v; } Vector3 movement = v.normalized * distance; UpdatePivot = false; Pivot.transform.Translate(movement, Space.World); }
void Awake() { SettingsManager.Initialize(); OrientationHelper.InitLandscapeSupportAndroid(); if (current) { DestroyImmediate(gameObject); } else { DontDestroyOnLoad(gameObject); current = this; } }
public override View FindSnapView(RecyclerView.LayoutManager layoutManager) { if (!(layoutManager is LinearLayoutManager)) { return(base.FindSnapView(layoutManager)); } OrientationHelper helper = layoutManager.CanScrollHorizontally() ? GetHorizontalHelper(layoutManager) : GetVerticalHelper(layoutManager); var startView = GetStartView(layoutManager, helper, out int viewPosition); // System.Diagnostics.Debug.WriteLine($"DEBUG_SCROLL: FindSnapView ( viewPosition: {viewPosition} )"); return(startView); }
private void InitializeMenuScene() { ConfigureNavigation(navigationEnabled); CustomizeScrollers(); OrientationHelper.LockRotation(false); if (!menuSceneManager) { //tutorialController = FindObjectOfType<TutorialController>(); //settingsCanvasGroup = FindObjectOfType<CanvasGroup>(); menuSceneManager = FindObjectOfType <MenuSceneManager>(); } if (fadeInOnLoad) { menuSceneManager.FadeOutLoadingScreen(); } }
private static bool IsUprightAccessible(Collider2D col, Vector3 playerCentre, BoxCollider2D playerCol) { if (col.IsUpright() == false) { return(true); } Vector2 playerPosition = col.bounds.center - playerCentre; float angleDirection = AngleDir(OrientationHelper.GetDownwardVector(col.transform), playerPosition); bool onRight = angleDirection > 0; return((col.transform.gameObject.layer == LayerMask.NameToLayer(Layers.RightClimbSpot) && onRight) || (col.transform.gameObject.layer == LayerMask.NameToLayer(Layers.LeftClimbSpot)) && !onRight); }
void AttachHardwareButtonHandlers() { PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; if (frame != null) { PhoneApplicationPage page = frame.Content as PhoneApplicationPage; if (page != null) { page.BackKeyPress += new EventHandler <CancelEventArgs>(page_BackKeyPress); this.orientationHelper = new OrientationHelper(this.CordovaBrowser, page); } } }
private void UpdateMeshAndDirection() { // Count number of connections along cardinal (which is all that we use atm) var cardinalInfo = adjacents.GetCardinalInfo(); // Determine rotation and mesh specially for every single case. // TODO: add meshes mentioned in header to script float rotation = 0.0f; Mesh mesh; if (cardinalInfo.IsO()) { mesh = o; } else if (cardinalInfo.IsC()) { mesh = c; rotation = DirectionHelper.AngleBetween(Direction.North, cardinalInfo.GetOnlyPositive()); } else if (cardinalInfo.IsI()) { mesh = i; rotation = OrientationHelper.AngleBetween(Orientation.Vertical, cardinalInfo.GetFirstOrientation()); } else if (cardinalInfo.IsL()) { mesh = l; rotation = DirectionHelper.AngleBetween(Direction.NorthEast, cardinalInfo.GetCornerDirection()); } else if (cardinalInfo.IsT()) { mesh = t; rotation = DirectionHelper.AngleBetween(Direction.South, cardinalInfo.GetOnlyNegative()); } else // Must be X { mesh = xAll; } if (filter == null) { filter = GetComponent <MeshFilter>(); } filter.mesh = mesh; transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles.x, rotation, transform.localRotation.eulerAngles.z); }
internal static int GetSelectedSquare(int width, int height, int x, int y, int scale) { OrientationHelper orientation = GetOrientationParameters(width, height, scale); for (int i = 0; i < orientation.WidthMul; i++) { for (int j = 0; j < orientation.HeightMul; j++) { if (x >= i * orientation.BlockWidth && x <= (i + 1) * orientation.BlockWidth && y >= j * orientation.BlockHeight && y <= (j + 1) * orientation.BlockHeight) { return(i + orientation.WidthMul * j); } } } return(-1); }
/* * browserDecorators are a collection of plugin-like classes (IBrowserDecorator) that add some bit of functionality to the browser. * These are somewhat different than plugins in that they are usually not async and patch a browser feature that we would * already expect to have. Essentially these are browser polyfills that are patched from the outside in. * */ void CreateDecorators() { XHRHelper xhrProxy = new XHRHelper(); xhrProxy.Browser = CordovaBrowser; browserDecorators.Add("XHRLOCAL", xhrProxy); OrientationHelper orientHelper = new OrientationHelper(); orientHelper.Browser = CordovaBrowser; browserDecorators.Add("Orientation", orientHelper); ConsoleHelper console = new ConsoleHelper(); console.Browser = CordovaBrowser; browserDecorators.Add("ConsoleLog", console); }
/// <summary> /// Updates the preview position and rotation. /// </summary> private void UpdatePreviewPosition() { // Apply a mirror effect for front facing camera. double scaleX = this.cameraType == CameraType.FrontFacing ? -1.0 : 1.0; if (this.PreviewBrush != null) { int angle = OrientationHelper.GetRotationAngle(this.orientation); this.PreviewBrush.RelativeTransform = new CompositeTransform { CenterY = 0.5, CenterX = 0.5, Rotation = angle, ScaleX = scaleX }; } // Update the slide off animation with the correct starting and ending points. this.ReviewImageSlideOffTranslateStart.Value = this.LivePreviewTransform.TranslateX; this.ReviewImageSlideOffTranslateEnd.Value = this.ReviewImageSlideOffTranslateStart.Value - this.ActualWidth; }
internal static Bitmap UpdatePreviewImage(int width, int height, int selectedSector, int scale, int x, int y) { OrientationHelper orientation = GetOrientationParameters(width, height, scale); var tile = new Bitmap(width, height); try { BitmapData bmd = tile.LockBits(new Rectangle(0, 0, tile.Width, tile.Height), ImageLockMode.ReadOnly, tile.PixelFormat); unsafe { byte *start = (byte *)bmd.Scan0; for (int j = 0; j < bmd.Height; j++) { byte *row = start + (j * bmd.Stride); for (int i = 0; i < bmd.Width; i++) { Color color = Color.Green; for (int cntX = 0; cntX <= orientation.WidthMul; cntX++) { for (int cntY = 0; cntY <= orientation.HeightMul; cntY++) { if (i >= cntX * orientation.BlockWidth - 1 && i <= cntX * orientation.BlockWidth + 1 || j >= cntY * orientation.BlockHeight - 1 && j <= cntY * orientation.BlockHeight + 1) { color = Color.Black; break; } } } if (x > -1 && y > -1 && selectedSector != -1 && color == Color.Green && selectedSector == GetSelectedSquare(width, height, i, j, scale)) { color = Color.Red; } SetPixelBGRA(row, i * pixelSize, color); } } } tile.UnlockBits(bmd); } catch (InvalidOperationException e) { } return(tile); }