public override void OnActive() { bool lineVisible = !SketchControlsScript.m_Instance.IsUserInteractingWithUI(); if (PromoManager.m_Instance.HintLine.gameObject.activeSelf != lineVisible) { m_HintObject.Activate(lineVisible); PromoManager.m_Instance.HintLine.gameObject.SetActive(lineVisible); } if (lineVisible) { TrTransform xfBrush = TrTransform.FromTransform( InputManager.m_Instance.GetBrushControllerAttachPoint()); TrTransform xfTarget = new TrTransform(); xfTarget.translation = PanelManager.m_Instance.GetAdminPanel().transform.position; xfBrush.rotation = Quaternion.LookRotation( (xfTarget.translation - xfBrush.translation).normalized, Vector3.up); xfTarget.rotation = xfBrush.rotation; PromoManager.m_Instance.HintLine.UpdateLine(xfBrush, xfTarget); } bool panelClick = SketchControlsScript.m_Instance.IsUserInteractingWithUI() && InputManager.m_Instance.GetCommand(InputManager.SketchCommands.Activate); if (PromoManager.m_Instance.ShouldPausePromos && (!SketchControlsScript.m_Instance.IsUserInteractingWithUI() || panelClick)) { m_ControllerSwapped = InputManager.m_Instance.ControllersAreSwapping(); m_Request = RequestingState.ToHide; } }
void OnDrawGizmosSelected() { if (m_AutoUpdate) { Gizmos.color = Color.blue; // Draw start and end points. TrTransform target = TrTransform.FromTransform(transform); Vector3 vTransformedOffset = transform.TransformPoint(m_AutoPositionOffset); TrTransform origin = new TrTransform(); origin.translation = vTransformedOffset; origin.rotation = transform.rotation; Gizmos.DrawLine(origin.translation, target.translation); // Draw normal at start. Gizmos.color = Color.green; Quaternion qStartRot = transform.rotation * Quaternion.Euler(m_AutoRotationOrigin); Vector3 vStartForward = qStartRot * Vector3.forward; Gizmos.DrawLine(origin.translation, origin.translation + (vStartForward * 0.25f)); // Draw normal at end. Gizmos.color = Color.red; Quaternion qEndRot = transform.rotation * Quaternion.Euler(m_AutoRotationTarget); Vector3 vEndForward = qEndRot * Vector3.forward; Gizmos.DrawLine(target.translation, target.translation + (vEndForward * 0.25f)); } }
public override Axis GetScaleAxis( Vector3 handA, Vector3 handB, out Vector3 axisVec, out float extent) { // Unexpected -- normally we're only called during a 2-handed manipulation Debug.Assert(m_LockedManipulationAxis != null); Axis axis = m_LockedManipulationAxis ?? Axis.Invalid; float parentScale = TrTransform.FromTransform(transform.parent).scale; // Fill in axisVec, extent switch (axis) { case Axis.X: case Axis.Y: case Axis.Z: Vector3 axisVec_LS = Vector3.zero; axisVec_LS[(int)axis] = 1; axisVec = transform.TransformDirection(axisVec_LS); extent = parentScale * Extents[(int)axis]; break; case Axis.Invalid: axisVec = default(Vector3); extent = default(float); break; default: throw new NotImplementedException(axis.ToString()); } return(axis); }
public override void FindClosestPointOnSurface(Vector3 pos, out Vector3 surfacePos, out Vector3 surfaceNorm) { // The closest-point functions operate on an unrotated ellipsoid at the origin. // I'll call that coordinate system "ellipse space (ES)". // "object space (OS)" is the true scale-compensated object-space coordinate system. // Take (uniform) scale from parent, but no scale from this object. // Our local scale is instead treated as Extents TrTransform xfWorldFromEllipse = TrTransform.FromTransform(transform.parent) * TrTransform.TR(transform.localPosition, transform.localRotation); TrTransform xfEllipseFromWorld = xfWorldFromEllipse.inverse; Vector3 halfExtent = Extents * .5f; Vector3 pos_OS = transform.InverseTransformPoint(pos); Vector3 pos_ES = xfEllipseFromWorld * pos; Vector3 closest_ES = MathEllipsoidAnton.ClosestPointEllipsoid(halfExtent, pos_ES); // Transform from ES -> OS, get the OS normal, then transform OS -> WS. // Normals are axial, so OS -> WS uses the inv-transpose. That all ends // up simplifying to this: surfaceNorm = transform.rotation * CDiv(closest_ES, CMul(halfExtent, halfExtent)).normalized; surfacePos = xfWorldFromEllipse * closest_ES; }
void UpdateSymmetryPointerTransforms() { switch (m_CurrentSymmetryMode) { case SymmetryMode.SinglePlane: { Plane plane = m_SymmetryWidgetScript.ReflectionPlane; TrTransform xf0 = TrTransform.FromTransform(m_MainPointerData.m_Script.transform); TrTransform xf1 = plane.ReflectPoseKeepHandedness(xf0); xf1.ToTransform(m_Pointers[1].m_Script.transform); // This is a hack. // In the event that the user is painting on a plane stencil and that stencil is // orthogonal to the symmetry plane, the main pointer and mirrored pointer will // have the same depth and their strokes will overlap, causing z-fighting. if (WidgetManager.m_Instance.ActiveStencil != null) { m_Pointers[1].m_Script.transform.position += m_Pointers[1].m_Script.transform.forward * m_SymmetryPointerStencilBoost; } break; } case SymmetryMode.FourAroundY: { TrTransform pointer0 = TrTransform.FromTransform(m_MainPointerData.m_Script.transform); // aboutY is an operator that rotates worldspace objects N degrees around the widget's Y TrTransform aboutY; { var xfWidget = TrTransform.FromTransform(m_SymmetryWidget); float angle = 360f / m_NumActivePointers; aboutY = TrTransform.TR(Vector3.zero, Quaternion.AngleAxis(angle, Vector3.up)); // convert from widget-local coords to world coords aboutY = xfWidget * aboutY * xfWidget.inverse; } TrTransform cur = TrTransform.identity; for (int i = 1; i < m_NumActivePointers; ++i) { cur = aboutY * cur; // stack another rotation on top var tmp = (cur * pointer0); // Work around 2018.3.x Mono parse bug tmp.ToTransform(m_Pointers[i].m_Script.transform); } break; } case SymmetryMode.DebugMultiple: { var xf0 = m_Pointers[0].m_Script.transform; for (int i = 1; i < m_NumActivePointers; ++i) { var xf = m_Pointers[i].m_Script.transform; xf.position = xf0.position + m_SymmetryDebugMultipleOffset * i; xf.rotation = xf0.rotation; } break; } } }
override public void Init(GameObject rParent, string sText) { if (m_CurrentState == State.Uninitialized) { //create buttons for worst case m_IconCountFullPage = m_IconGridHeightFullPage * m_IconGridWidthFullPage; m_Icons = new ImageIcon[m_IconCountFullPage]; var xfWithUniformScale = TrTransform.FromTransform(transform); xfWithUniformScale.scale = transform.localScale.x; Vector3 vBaseIconPosition = xfWithUniformScale * m_BaseButtonOffset; for (int y = 0; y < m_IconGridHeightFullPage; ++y) { for (int x = 0; x < m_IconGridWidthFullPage; ++x) { int iIndex = (m_IconGridWidthFullPage * y) + x; m_Icons[iIndex] = new ImageIcon(); m_Icons[iIndex].m_Icon = Instantiate(m_ButtonPrefab); m_Icons[iIndex].m_IconScript = m_Icons[iIndex].m_Icon.GetComponent <BaseButton>(); InitIcon(m_Icons[iIndex]); //scale icon for pop-up, and then late-init it so the scale is cached correctly Vector3 vIconScale = m_Icons[iIndex].m_Icon.transform.localScale; vIconScale.Set(m_ButtonWidth, m_ButtonWidth, m_ButtonWidth); vIconScale *= transform.localScale.x; m_Icons[iIndex].m_Icon.transform.localScale = vIconScale; m_BaseIconScale = vIconScale.x; Vector3 vPos = vBaseIconPosition; vPos += (transform.right * (float)x * m_IconSpacing * transform.localScale.x); vPos += (-transform.up * (float)y * m_IconSpacing * transform.localScale.x); m_Icons[iIndex].m_Icon.transform.position = vPos; m_Icons[iIndex].m_Icon.transform.rotation = transform.rotation; m_Icons[iIndex].m_Icon.transform.parent = transform; // Register after parent has been assisgned. m_Icons[iIndex].m_IconScript.RegisterComponent(); } } //default to first page highlighted m_PageIndex = 0; m_BaseIndex = 0; if (m_DataCount <= m_IconCountFullPage) { m_NumPages = 1; } else { m_NumPages = ((m_DataCount - 1) / m_IconCountNavPage) + 1; } } //base modifies scale, so we want to do this after we create our icons base.Init(rParent, sText); RefreshPage(); }
public void ForceClippingPlanes(MultiCamStyle style) { MultiCamCaptureObject obj = m_CaptureObjects[(int)style]; TrTransform xf = TrTransform.FromTransform(obj.m_CameraComponent.transform); float scale = App.ActiveCanvas.Pose.scale; obj.m_CameraComponent.nearClipPlane = obj.m_CameraClipPlanesBase.x * scale; obj.m_CameraComponent.farClipPlane = obj.m_CameraClipPlanesBase.y * scale; Debug.Log($"machk: forcing clip: {obj.m_CameraClipPlanesBase.x}->{obj.m_CameraClipPlanesBase.y} x{scale}"); }
public CameraPathPositionKnotMetadata AsSerializable() { return(new CameraPathPositionKnotMetadata { Xf = TrTransform.FromTransform(transform), TangentMagnitude = TangentMagnitude, }); }
public static void AddMarkerPoint(Transform transform) { SketchMemoryScript.m_Instance.PerformAndRecordCommand( new CreateWidgetCommand(m_Instance.MarkerPointPrefab, TrTransform.FromTransform(transform)) ); // SketchControlsScript.m_Instance.EatGazeObjectInput(); // SelectionManager.m_Instance.RemoveFromSelection(false); }
public override Axis GetScaleAxis( Vector3 handA, Vector3 handB, out Vector3 axisVec, out float extent) { // Unexpected -- normally we're only called during a 2-handed manipulation Debug.Assert(m_LockedManipulationAxis != null); Axis axis = m_LockedManipulationAxis ?? Axis.Invalid; float parentScale = TrTransform.FromTransform(transform.parent).scale; Vector3 delta = handB - handA; Vector3 extents = Extents; // Fill in axisVec, extent switch (axis) { case Axis.X: case Axis.Y: case Axis.Z: { Vector3 axisVec_OS = Vector3.zero; axisVec_OS[(int)axis] = 1; axisVec = transform.TransformDirection(axisVec_OS); extent = parentScale * extents[(int)axis]; break; } case Axis.YZ: { Vector3 plane = transform.rotation * new Vector3(1, 0, 0); axisVec = (delta - Vector3.Dot(delta, plane) * plane).normalized; extent = parentScale * Mathf.Max(extents[1], extents[2]); break; } case Axis.XZ: { Vector3 plane = transform.rotation * new Vector3(0, 1, 0); axisVec = (delta - Vector3.Dot(delta, plane) * plane).normalized; extent = parentScale * Mathf.Max(extents[0], extents[2]); break; } case Axis.XY: { Vector3 plane = transform.rotation * new Vector3(0, 0, 1); axisVec = (delta - Vector3.Dot(delta, plane) * plane).normalized; extent = parentScale * Mathf.Max(extents[0], extents[1]); break; } case Axis.Invalid: axisVec = default(Vector3); extent = default(float); break; default: throw new NotImplementedException(axis.ToString()); } return(axis); }
override protected void OnButtonPressed() { if (WidgetManager.m_Instance.StencilsDisabled) { WidgetManager.m_Instance.StencilsDisabled = false; } SketchMemoryScript.m_Instance.PerformAndRecordCommand(new CreateWidgetCommand( WidgetManager.m_Instance.GetStencilPrefab(m_Type), TrTransform.FromTransform(transform))); SketchControlsScript.m_Instance.EatGazeObjectInput(); SelectionManager.m_Instance.RemoveFromSelection(false); }
public void TestRelativeAccessor_UnrelatedGet() { var root = RandomTransform(); var left = RandomTransform(root, 2); var right = RandomTransform(root); var AsRight = new TransformExtensions.RelativeAccessor(right); VeryLooseEqual(TrTransform.FromTransform(right) * AsRight[left], TrTransform.FromTransform(left)); }
override protected void OnShow() { base.OnShow(); TrTransform xfSpawn = TrTransform.FromTransform(ViewpointScript.Head); InitIntroAnim(xfSpawn, xfSpawn, true); m_IntroAnimState = IntroAnimState.In; m_IntroAnimValue = 0.0f; }
void AlignPointLineToPanels() { TrTransform xfBrush = TrTransform.FromTransform( InputManager.m_Instance.GetBrushControllerAttachPoint()); TrTransform xfTarget = new TrTransform(); xfTarget.translation = PanelManager.m_Instance. GetFixedPanelPosClosestToPoint(xfBrush.translation); xfBrush.rotation = Quaternion.LookRotation( (xfTarget.translation - xfBrush.translation).normalized, Vector3.up); xfTarget.rotation = xfBrush.rotation; m_IntroPointHintArrowLine.UpdateLine(xfBrush, xfTarget); }
void AlignHintLine() { TrTransform xfBrush = TrTransform.FromTransform( InputManager.m_Instance.GetBrushControllerAttachPoint()); TrTransform xfTarget = new TrTransform(); xfTarget.translation = TrTransform.FromTransform(m_Panel.WidgetSibling.transform).translation; xfBrush.rotation = Quaternion.LookRotation( (xfTarget.translation - xfBrush.translation).normalized, Vector3.up); xfTarget.rotation = xfBrush.rotation; PromoManager.m_Instance.HintLine.UpdateLine(xfBrush, xfTarget); }
// -------------------------------------------------------------------------------------------- // // Tracking Methods // -------------------------------------------------------------------------------------------- // /// Clears the callbacks that get called when a new pose is received. The callbacks are saved /// So that they can be restored later with RestorePoseTracking. public void DisablePoseTracking() { m_TrackingBackupXf = TrTransform.FromTransform(GetVrCamera().transform); if (NewControllerPosesApplied == null) { m_OldOnPoseApplied = Array.Empty <Action>(); } else { m_OldOnPoseApplied = NewControllerPosesApplied.GetInvocationList().Cast <Action>().ToArray(); } NewControllerPosesApplied = null; }
public void TestGlobalAccessor() { var AsGlobal = new TransformExtensions.GlobalAccessor(); var root = RandomTransform(); var child = RandomTransform(root, 2); var xfGlobal = RandomTr(); AsGlobal[child] = xfGlobal; VeryLooseEqual(xfGlobal, TrTransform.FromTransform(child)); VeryLooseEqual(xfGlobal, AsGlobal[child]); UnityEngine.Object.DestroyImmediate(root.gameObject); }
public void TestRelativeAccessor_AncestorSet() { var root = RandomTransform(); var child = RandomTransform(root, 2); var AsAncestor = new TransformExtensions.RelativeAccessor(child.parent.parent); var xf = RandomTr(); AsAncestor[child] = xf; VeryLooseEqual(AsAncestor[child], xf); VeryLooseEqual(TrTransform.FromTransform(child.parent.parent) * xf, TrTransform.FromTransform(child)); UnityEngine.Object.DestroyImmediate(root.gameObject); }
override protected void OnUserEndInteracting() { base.OnUserEndInteracting(); if (!m_EatInteractingInput) { // Finalize our move commands with the current state of whatever's being actively modified. switch (m_ActiveKnot.knot.KnotType) { case CameraPathKnot.Type.Position: if (m_ActiveKnot.control == 0) { SketchMemoryScript.m_Instance.PerformAndRecordCommand( new MovePositionKnotCommand(m_Path, m_ActiveKnot, TrTransform.FromTransform(m_ActiveKnot.knot.transform), true)); } else { CameraPathPositionKnot pk = m_ActiveKnot.knot as CameraPathPositionKnot; Vector3 knotFwd = m_ActiveKnot.knot.transform.forward; SketchMemoryScript.m_Instance.PerformAndRecordCommand( new ModifyPositionKnotCommand( m_Path, m_ActiveKnot, pk.TangentMagnitude, knotFwd, final:true)); } break; case CameraPathKnot.Type.Rotation: case CameraPathKnot.Type.Speed: case CameraPathKnot.Type.Fov: // Reset any PreviewWidget overrides. m_ActiveKnot.knot.gameObject.SetActive(true); InputManager.Wand.Geometry.PreviewKnotHint.Activate(false); InputManager.Brush.Geometry.PreviewKnotHint.Activate(false); SketchControlsScript.m_Instance.CameraPathCaptureRig.OverridePreviewWidgetPathT(null); if (m_ActiveKnot.control == 0) { SketchMemoryScript.m_Instance.PerformAndRecordCommand( new MoveConstrainedKnotCommand(m_Path, m_ActiveKnot, m_ActiveKnot.knot.transform.rotation, final:true)); } else { if (m_ActiveKnot.knot.KnotType == CameraPathKnot.Type.Speed) { CameraPathSpeedKnot sk = m_ActiveKnot.knot as CameraPathSpeedKnot; SketchMemoryScript.m_Instance.PerformAndRecordCommand( new ModifySpeedKnotCommand(sk, sk.SpeedValue)); } else if (m_ActiveKnot.knot.KnotType == CameraPathKnot.Type.Fov) { CameraPathFovKnot fk = m_ActiveKnot.knot as CameraPathFovKnot; SketchMemoryScript.m_Instance.PerformAndRecordCommand( new ModifyFovKnotCommand(fk, fk.FovValue)); } } break; } } m_KnotEditingLastInputXf = null; m_ActiveKnot = null; }
void AlignHintLine() { TrTransform xfBrush = TrTransform.FromTransform( InputManager.m_Instance.GetBrushControllerAttachPoint()); TrTransform xfTarget = new TrTransform(); var sketchbookPanel = PanelManager.m_Instance.GetSketchBookPanel(); if (sketchbookPanel != null) { xfTarget.translation = TrTransform.FromTransform( sketchbookPanel.transform).translation; xfBrush.rotation = Quaternion.LookRotation( (xfTarget.translation - xfBrush.translation).normalized, Vector3.up); xfTarget.rotation = xfBrush.rotation; PromoManager.m_Instance.HintLine.UpdateLine(xfBrush, xfTarget); } }
void CreateEnvironment(Environment.RenderSettingsLite env) { //change lightning environment if requested is different from current if (m_RoomGeometryName != env.m_EnvironmentPrefab) { Destroy(m_RoomGeometry); Destroy(m_RoomReverbZone); GameObject rNewEnvironment = Resources.Load <GameObject>(env.m_EnvironmentPrefab); if (rNewEnvironment != null) { m_RoomGeometry = Instantiate(rNewEnvironment); Transform t = m_RoomGeometry.transform; Debug.Assert(TrTransform.FromTransform(t) == TrTransform.identity); t.SetParent(App.Instance.m_EnvironmentTransform, false); // Create reverb zone but do not set its parent. It should live in room space. GameObject rNewReverbZone = Resources.Load <GameObject>(env.m_EnvironmentReverbZonePrefab); m_RoomReverbZone = Instantiate(rNewReverbZone); // Construct lists of objects that are only in low or only in high LOD. m_EnvironmentObjectsLowLOD = new List <GameObject>(); m_EnvironmentObjectsHighLOD = new List <GameObject>(); foreach (Transform child in m_RoomGeometry.transform) { if (IsLowLod(child)) { m_EnvironmentObjectsLowLOD.Add(child.gameObject); } else if (IsHighLod(child)) { m_EnvironmentObjectsHighLOD.Add(child.gameObject); } } } else { // Clear LOD lists and room geo reference m_RoomGeometry = null; m_RoomReverbZone = null; m_EnvironmentObjectsLowLOD = new List <GameObject>(); m_EnvironmentObjectsHighLOD = new List <GameObject>(); } // for b/37256058: crash seems to happen between this and the intro sketch load System.Console.WriteLine("Setenv: Unload 1"); Resources.UnloadUnusedAssets(); System.Console.WriteLine("Setenv: Unload 2"); m_RoomGeometryName = env.m_EnvironmentPrefab; } }
void Update() { if (m_AutoUpdate) { TrTransform target = TrTransform.FromTransform(transform); Vector3 vTransformedOffset = transform.TransformPoint(m_AutoPositionOffset); TrTransform origin = new TrTransform(); origin.translation = vTransformedOffset; origin.rotation = transform.rotation * Quaternion.Euler(m_AutoRotationOrigin); target.rotation = transform.rotation * Quaternion.Euler(m_AutoRotationTarget); UpdateLine(origin, target); } }
public override Axis GetScaleAxis( Vector3 handA, Vector3 handB, out Vector3 axisVec, out float extent) { // Unexpected -- normally we're only called during a 2-handed manipulation Debug.Assert(m_LockedManipulationAxis != null); Axis axis = m_LockedManipulationAxis ?? Axis.Invalid; float parentScale = TrTransform.FromTransform(transform.parent).scale; // Fill in axisVec, extent switch (axis) { case Axis.Y: { Vector3 axisVec_LS = Vector3.zero; axisVec_LS[(int)axis] = 1; axisVec = transform.TransformDirection(axisVec_LS); extent = parentScale * Extents[(int)axis]; break; } case Axis.XZ: { // Flatten the vector between the controllers with respect to "up" and use that as the axis // to perform the non-uniform scale. Vector3 vHands = handB - handA; vHands -= transform.up * Vector3.Dot(transform.up, vHands); axisVec = vHands.normalized; // Make sure caller doesn't try to do anything funny with this axis, like // index into Extents[], create their own axis direction, etc extent = parentScale * Extents[0]; break; } case Axis.Invalid: axisVec = default(Vector3); extent = default(float); break; default: throw new NotImplementedException(axis.ToString()); } return(axis); }
public void BringToUser() { // Get brush controller and place a little in front and a little higher. Vector3 controllerPos = InputManager.m_Instance.GetController(InputManager.ControllerName.Brush).position; Vector3 headPos = ViewpointScript.Head.position; Vector3 headToController = controllerPos - headPos; Vector3 offset = headToController.normalized * m_JumpToUserControllerOffsetDistance + Vector3.up * m_JumpToUserControllerYOffset; TrTransform xf_GS = TrTransform.TR(controllerPos + offset, transform.rotation); // The transform we built was global space, but we need it in widget local for the command. TrTransform newXf = TrTransform.FromTransform(m_NonScaleChild.parent).inverse *xf_GS; SketchMemoryScript.m_Instance.PerformAndRecordCommand( new MoveWidgetCommand(this, newXf, CustomDimension, final: true), discardIfNotMerged: false); }
/// Given the position of a main pointer, find a corresponding symmetry position. /// Results are undefined unless you pass MainPointer or one of its /// dedicated symmetry pointers. public TrTransform GetSymmetryTransformFor(PointerScript pointer, TrTransform xfMain) { int child = pointer.ChildIndex; // "active pointers" is the number of pointers the symmetry widget is using, // including the main pointer. if (child == 0 || child >= m_NumActivePointers) { return(xfMain); } // This needs to be kept in sync with UpdateSymmetryPointerTransforms switch (m_CurrentSymmetryMode) { case SymmetryMode.SinglePlane: { return(m_SymmetryWidgetScript.ReflectionPlane.ReflectPoseKeepHandedness(xfMain)); } case SymmetryMode.FourAroundY: { // aboutY is an operator that rotates worldspace objects N degrees around the widget's Y TrTransform aboutY; { var xfWidget = TrTransform.FromTransform(m_SymmetryWidget); float angle = (360f * child) / m_NumActivePointers; aboutY = TrTransform.TR(Vector3.zero, Quaternion.AngleAxis(angle, Vector3.up)); // convert from widget-local coords to world coords aboutY = aboutY.TransformBy(xfWidget); } return(aboutY * xfMain); } case SymmetryMode.DebugMultiple: { var xfLift = TrTransform.T(m_SymmetryDebugMultipleOffset * child); return(xfLift * xfMain); } default: return(xfMain); } }
public override Bounds GetBounds_SelectionCanvasSpace() { if (m_Collider != null) { SphereCollider sphere = m_Collider as SphereCollider; TrTransform colliderToCanvasXf = App.Scene.SelectionCanvas.Pose.inverse * TrTransform.FromTransform(m_Collider.transform); Bounds bounds = new Bounds(colliderToCanvasXf * sphere.center, Vector3.zero); // Spheres are invariant with rotation, so take out the rotation from the transform and just // add the two opposing corners. colliderToCanvasXf.rotation = Quaternion.identity; bounds.Encapsulate(colliderToCanvasXf * (sphere.center + sphere.radius * Vector3.one)); bounds.Encapsulate(colliderToCanvasXf * (sphere.center - sphere.radius * Vector3.one)); return(bounds); } return(base.GetBounds_SelectionCanvasSpace()); }
override protected void OnButtonPressed() { // If we're flagged as 'always spawn', make sure we're hidden and always spawn. if (m_AlwaysSpawn) { PanelManager.m_Instance.DismissNonCorePanel(m_Type); SketchControlsScript.m_Instance.OpenPanelOfType(m_Type, TrTransform.FromTransform(transform)); } else { if (m_ToggleActive) { PanelManager.m_Instance.DismissNonCorePanel(m_Type); } else { SketchControlsScript.m_Instance.OpenPanelOfType(m_Type, TrTransform.FromTransform(transform)); } } }
private bool HasSwapGestureCompleted() { TrTransform base1 = TrTransform.FromTransform(Brush.Geometry.BaseAttachPoint); TrTransform base2 = TrTransform.FromTransform(Wand.Geometry.BaseAttachPoint); float meters = Vector3.Distance(base1.translation, base2.translation) * App.UNITS_TO_METERS; if (m_InhibitControllerSwap) { if (meters > kSwapResetDistMeters) { m_InhibitControllerSwap = false; } return(false); } else { // Controllers should only swap when there is no active input. bool bActiveInput = GetCommand(SketchCommands.Activate) && App.Instance.IsInStateThatAllowsPainting(); bool forwardsOpposed = Vector3.Angle(base1.forward, base2.forward) > kSwapForwardAngle; bool velocitiesOpposed = Vector3.Angle(Wand.m_Velocity, Brush.m_Velocity) > kSwapVelocityAngle; bool minControllerAccelerationReached = (Brush.m_Acceleration.magnitude > kSwapAcceleration || Wand.m_Acceleration.magnitude > kSwapAcceleration); bool closeEnough = (meters < kSwapDistMeters); bool shouldSwap = !bActiveInput && forwardsOpposed && velocitiesOpposed && minControllerAccelerationReached && closeEnough; if (shouldSwap) { m_InhibitControllerSwap = true; var fxPos = Vector3.Lerp(base1.translation, base2.translation, 0.5f); Instantiate(m_SwapEffect, fxPos, Quaternion.identity); PointerManager.m_Instance.DisablePointerPreviewLine(); } return(shouldSwap); } }
public void FlipSelection() { // Flip the selection. TrTransform selectionFromWorldSpace = TrTransform.FromTransform(App.Scene.SelectionCanvas.transform).inverse; Plane flipPlaneInSelectionSpace = new Plane( selectionFromWorldSpace * m_SelectionWidget.transform.position, selectionFromWorldSpace * ViewpointScript.Head.position, selectionFromWorldSpace * (ViewpointScript.Head.position + Vector3.up)); #if false // useful for precise testing if (PointerManager.m_Instance.SymmetryPlane_RS is Plane plane_RS) { flipPlaneInSelectionSpace = App.Scene.SelectionCanvas.Pose.inverse * plane_RS; } #endif SketchMemoryScript.m_Instance.PerformAndRecordCommand( new FlipSelectionCommand(m_SelectedStrokes, m_SelectedWidgets, flipPlaneInSelectionSpace)); }
public override Bounds GetBounds_SelectionCanvasSpace() { if (m_BoxCollider != null) { TrTransform boxColliderToCanvasXf = App.Scene.SelectionCanvas.Pose.inverse * TrTransform.FromTransform(m_BoxCollider.transform); Bounds bounds = new Bounds(boxColliderToCanvasXf * m_BoxCollider.center, Vector3.zero); // Transform the corners of the widget bounds into canvas space and extend the total bounds // to encapsulate them. for (int i = 0; i < 8; i++) { bounds.Encapsulate(boxColliderToCanvasXf * (m_BoxCollider.center + Vector3.Scale( m_BoxCollider.size, new Vector3((i & 1) == 0 ? -0.5f : 0.5f, (i & 2) == 0 ? -0.5f : 0.5f, (i & 4) == 0 ? -0.5f : 0.5f)))); } return(bounds); } return(new Bounds()); }