public static void UnsubscribeClientAxisChange(EAxis _eClientAxis, NotifyClientAxisChange _nCallback) { if (s_cInstance.m_mClientAxisCallbacks.ContainsKey(_eClientAxis)) { s_cInstance.m_mClientAxisCallbacks[_eClientAxis].Remove(_nCallback); } }
// Returns a cardinal direction (useful for menus) public EInputDirection GetDirection(EAxis Axis) { EInputDirection Direction = EInputDirection.None; float Dir = GetAxis(Axis); if (Axis == EAxis.X) { if (Direction < 0) { Direction = EInputDirection.Left; } else if (Direction > 0) { Direction = EInputDirection.Right; } } else { if (Direction < 0) { Direction = EInputDirection.Up; } else if (Direction > 0) { Direction = EInputDirection.Down; } } return(Direction); }
public AutoRangeEventArgs(View3d.ESceneBounds who, EAxis axes) { Who = who; Axes = axes; ViewBBox = BBox.Reset; Handled = false; }
// 在此初始化参数 protected override void OnCreate() { axis = (EAxis)Utility.ToEnumInt(parameters["axis"]); obj1 = Utility.ToObject(parameters["object1"]); obj2 = Utility.ToObject(parameters["object2"]); comp = Utility.ToCompare(parameters["compare"]); amt = Utility.ToSingle(missionVars, parameters["amount"]); }
public void Mirror(EAxis MirrorAxis, EAxis FlipAxis) { // We do convert to Matrix for mirroring. FMatrix M = ToMatrixWithScale(); M.Mirror(MirrorAxis, FlipAxis); SetFromMatrix(M); }
public float DoComp(float value, EConType conType, EPosType posType, EAxis pointType) { if (ContainsKey(conType)) { value = this[conType].DoComp(value, posType, pointType); } return(value); }
public Axis(EAxis eAxis, KeyCode positive, KeyCode negative, KeyCode altPositive, KeyCode altNegative) { Name = eAxis.ToString(); EAxis = eAxis; Positive = positive; Negative = negative; AltPositive = altPositive; AltNegative = altNegative; }
public static EAxis DrawAxisBtnMask(GUIContent label, EAxis eAffect, float labelWidth = 80f) { bool active = false; EditorGUILayout.BeginHorizontal(); { GUILayout.Label(label, GUILayout.Width(labelWidth)); active = (eAffect & EAxis.X) != 0; EUtil.PushBackgroundColor(active ? kSelectedBtnColor : Color.white); if (GUILayout.Button("X", EditorStyles.toolbarButton)) { if (active) { eAffect &= ~EAxis.X; } else { eAffect |= EAxis.X; } } EUtil.PopBackgroundColor(); active = (eAffect & EAxis.Y) != 0; EUtil.PushBackgroundColor(active ? kSelectedBtnColor : Color.white); if (GUILayout.Button("Y", EditorStyles.toolbarButton)) { if (active) { eAffect &= ~EAxis.Y; } else { eAffect |= EAxis.Y; } } EUtil.PopBackgroundColor(); active = (eAffect & EAxis.Z) != 0; EUtil.PushBackgroundColor(active ? kSelectedBtnColor : Color.white); if (GUILayout.Button("Z", EditorStyles.toolbarButton)) { if (active) { eAffect &= ~EAxis.Z; } else { eAffect |= EAxis.Z; } } EUtil.PopBackgroundColor(); } EditorGUILayout.EndHorizontal(); return(eAffect); }
public static void SubscribeClientAxisChange(EAxis _eClientAxis, NotifyClientAxisChange _nCallback) { if (!s_cInstance.m_mClientAxisCallbacks.ContainsKey(_eClientAxis)) { s_cInstance.m_mClientAxisCallbacks.Add(_eClientAxis, new List <NotifyClientAxisChange>()); } s_cInstance.m_mClientAxisCallbacks[_eClientAxis].Add(_nCallback); }
private void SelectedAxis(EAxis axis) { m_eCurrentAxis = axis; List <Color> colors = new List <Color>(); SetColor(colors, m_eCurrentAxis == EAxis.X ? m_pSelectColor : m_pXColor, m_pVtNums[0]); SetColor(colors, m_eCurrentAxis == EAxis.Y ? m_pSelectColor : m_pYColor, m_pVtNums[1]); SetColor(colors, m_eCurrentAxis == EAxis.Z ? m_pSelectColor : m_pZColor, m_pVtNums[2]); m_pMesh.SetColors(colors); }
public float GetAxisDelta(EAxis eAxis) { Axis axis = Axi.Find(x => x.EAxis == eAxis); if (axis != null) { return(axis.Delta); } return(0); }
public float GetAxis(EAxis eAxis) { Axis axis = Axi.Find(x => x.EAxis == eAxis); if (axis != null) { return(axis.Value); } return(0); }
private void Update() { _scale(); if (Input.GetMouseButtonDown(0) && m_eCurrentAxis != EAxis.None) { m_stMousePosition = Input.mousePosition; m_bTracking = true; } if (Input.GetMouseButtonUp(0) && m_eCurrentAxis != EAxis.None) { SelectedAxis(EAxis.None); m_bTracking = false; StartCoroutine(delayRelease()); } if (!m_bTracking) { Camera cam = RenderCamera; Ray ray = cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100, 1 << m_iLayer)) { float rv, rh; GetAngle(hit.point, out rv, out rh); float angle = 0; EAxis axis = FindClosetAxis(rv, rh, out angle); SelectedAxis(axis); if (OnAxisChanged != null) { OnAxisChanged(axis, angle); } } } else if (m_eCurrentAxis != EAxis.None) { if (!EnableFreeRotate && m_eCurrentAxis == EAxis.All) { //do nothing } else { Vector3 delta = TrackBall(Input.mousePosition); m_pSphere.transform.localRotation *= Quaternion.Euler(delta); if (OnRotateChanged != null) { OnRotateChanged(m_eCurrentAxis, delta); } } } }
void InvokeAxisEvent(EAxis _eAxis, float _fValue) { if (m_mAxisCallbacks.ContainsKey(_eAxis)) { List <NotifyAxisChange> aSubscribers = m_mAxisCallbacks[_eAxis]; foreach (NotifyAxisChange cSubscriber in aSubscribers) { cSubscriber(_eAxis, _fValue); } } }
void InvokeClientClientAxisEvent(EAxis _eClientAxis, ulong _ulPlayerId, float _fValue) { if (m_mClientAxisCallbacks.ContainsKey(_eClientAxis)) { List <NotifyClientAxisChange> aSubscribers = m_mClientAxisCallbacks[_eClientAxis]; foreach (NotifyClientAxisChange cSubscriber in aSubscribers) { cSubscriber(_eClientAxis, _ulPlayerId, _fValue); } } }
public FVector GetUnitAxis(EAxis InAxis) { if (InAxis == EAxis.X) { return(TransformVectorNoScale(new FVector(1.0f, 0.0f, 0.0f))); } else if (InAxis == EAxis.Y) { return(TransformVectorNoScale(new FVector(0.0f, 1.0f, 0.0f))); } return(TransformVectorNoScale(new FVector(0.0f, 0.0f, 1.0f))); }
public Vector GetScaledAxis(EAxis InAxis) { if (InAxis == EAxis.X) { return(TransformVector(new Vector(1.0f, 0.0f, 0.0f))); } else if (InAxis == EAxis.Y) { return(TransformVector(new Vector(0.0f, 1.0f, 0.0f))); } return(TransformVector(new Vector(0.0f, 0.0f, 1.0f))); }
// 分割 public void Split(EAxis normalAxis, out Space left, out Space right) { Vector3 center = SpaceBounds.center; Vector3 size = SpaceBounds.size; Bounds bounds; if (normalAxis == EAxis.X) { SplitAxis = EAxis.X; size.x *= 0.5f; center.x -= SpaceBounds.size.x * 0.25f; bounds = new Bounds(center, size); left = new Space(bounds); center.x += SpaceBounds.size.x * 0.5f; bounds = new Bounds(center, size); right = new Space(bounds); } else if (normalAxis == EAxis.Y) { SplitAxis = EAxis.Y; size.y *= 0.5f; center.y -= SpaceBounds.size.y * 0.25f; bounds = new Bounds(center, size); left = new Space(bounds); center.y += SpaceBounds.size.y * 0.5f; bounds = new Bounds(center, size); right = new Space(bounds); } else if (normalAxis == EAxis.Z) { SplitAxis = EAxis.Z; size.z *= 0.5f; center.z -= SpaceBounds.size.z * 0.25f; bounds = new Bounds(center, size); left = new Space(bounds); center.z += SpaceBounds.size.z * 0.5f; bounds = new Bounds(center, size); right = new Space(bounds); } else { left = null; right = null; } }
public void Set(float value, EPosType posType, EAxis pointType) { CompPNT pnt; if (ContainsKey(posType)) { pnt = this[posType]; } else { pnt = new CompPNT(); Add(posType, pnt); } pnt.Set(value, pointType); }
public void Set(float value, EConType conType, EPosType posType, EAxis pointType) { CompPOS pos; if (ContainsKey(conType)) { pos = this[conType]; } else { pos = new CompPOS(); Add(conType, pos); } pos.Set(value, posType, pointType); }
/// <summary> /// Get a specific component of the vector, given a specific axis by enum /// </summary> public float GetComponentForAxis(EAxis axis) { switch (axis) { case EAxis.X: return(Roll); case EAxis.Y: return(Pitch); case EAxis.Z: return(Yaw); default: return(0.0f); } }
/// <summary> /// set next move position if availabel and start moving /// invert direction because enemy hit some wall or end /// </summary> protected override void SetNextPositionIfValid(Point point) { if (IsValidMove(point)) { nextPosition = new Vector3(point.x, nextPosition.y, point.y); canMove = false; isMoving = true; } else { InvertDirection(); //change direction evertime the enemy hits a deadend axis = GetRandomAxis(); direction = axis == EAxis.Vertical ? GetRandomVerticalDirection() : GetRandomHorizontalDirection(); } }
private Vector3 UpdateFollowingAxes(Vector3 value, EAxis axis) { if (!axis.HasFlag(EAxis.X)) { value = new Vector3(0, value.y, value.z); } if (!axis.HasFlag(EAxis.Y)) { value = new Vector3(value.x, 0, value.z); } if (!axis.HasFlag(EAxis.Z)) { value = new Vector3(value.x, value.y, 0); } return(value); }
/// <summary> /// Set a specified componet of the vector, given a specific axis by enum /// </summary> public void SetComponentForAxis(EAxis axis, float component) { switch (axis) { case EAxis.X: Roll = component; break; case EAxis.Y: Pitch = component; break; case EAxis.Z: Yaw = component; break; } }
private Vector3 InvertAxes(Vector3 value, EAxis axis) { if (axis.HasFlag(EAxis.X)) { value = new Vector3(-value.x, value.y, value.z); } if (axis.HasFlag(EAxis.Y)) { value = new Vector3(value.x, -value.y, value.z); } if (axis.HasFlag(EAxis.Z)) { value = new Vector3(value.x, value.y, -value.z); } return(value); }
/** * get axis of this matrix scaled by the scale of the matrix * * @param i index into the axis of the matrix * @ return vector of the axis */ public FVector GetScaledAxis(EAxis InAxis) { switch (InAxis) { case EAxis.X: return(new FVector(this[0, 0], this[0, 1], this[0, 2])); case EAxis.Y: return(new FVector(this[1, 0], this[1, 1], this[1, 2])); case EAxis.Z: return(new FVector(this[2, 0], this[2, 1], this[2, 2])); default: return(FVector.ZeroVector); } }
public static void Flip(this Transform t, EAxis direction) { Vector3 scale = t.localScale; if (direction.HasFlag(EAxis.X)) { scale.x *= -1.0f; } if (direction.HasFlag(EAxis.Y)) { scale.y *= -1.0f; } if (direction.HasFlag(EAxis.Z)) { scale.z *= -1.0f; } t.localScale = scale; }
private Vector3 UpdateFollowingAxes(Vector3 firstValue, Vector3 secondValue, EAxis axis) { Vector3 value = (firstValue + secondValue) / 2; if (!axis.HasFlag(EAxis.X)) { value = new Vector3(0, (firstValue.y + secondValue.y) / 2, (firstValue.z + secondValue.z) / 2); } if (!axis.HasFlag(EAxis.Y)) { value = new Vector3((firstValue.x + secondValue.x) / 2, 0, (firstValue.x + secondValue.x) / 2); } if (!axis.HasFlag(EAxis.Z)) { value = new Vector3((firstValue.x + secondValue.x) / 2, (firstValue.y + secondValue.y) / 2, 0); } return(value); }
private Vector3 CompueteRotateDir(Vector3 offset, EAxis type) { if (offset.x + offset.y == 0) { return(Vector3.zero); } Vector3 startPos = m_pSphere.transform.position; Vector3 start = Camera.main.WorldToScreenPoint(startPos); Vector3 axis; Vector3 end; if (type == EAxis.X) { end = Camera.main.WorldToScreenPoint(startPos + m_pSphere.transform.right * 2); axis = Vector3.right; } else if (type == EAxis.Y) { end = Camera.main.WorldToScreenPoint(startPos + m_pSphere.transform.up * 2); axis = Vector3.up; } else { end = Camera.main.WorldToScreenPoint(startPos + m_pSphere.transform.forward * 2); axis = Vector3.forward; } Vector3 axisDir = end - start; axisDir.Normalize(); axisDir = Vector3.Cross(Vector3.forward, axisDir); float moveLen = axisDir.x * offset.x + axisDir.y * offset.y; float mx = moveLen * axis.x; float my = moveLen * axis.y; float mz = moveLen * axis.z; return(new Vector3(mx, my, mz)); }
private void _DoMapping(Vector3 srcData, ref Vector3 dstData) { for (int i = 0; i < 3; ++i) { EAxis fromMap = m_mapping[i]; if (fromMap == EAxis.None) { continue; } float t = 0; switch (fromMap) { case EAxis.X: t = Misc.InverseLerp(m_srcFrom.x, m_srcTo.x, srcData.x); break; case EAxis.Y: t = Misc.InverseLerp(m_srcFrom.y, m_srcTo.y, srcData.y); break; case EAxis.Z: t = Misc.InverseLerp(m_srcFrom.z, m_srcTo.z, srcData.z); break; default: Dbg.LogErr("TransformMapping._DoMapping: unexpected fromMap: {0}", fromMap); break; } if (!m_extrapolate) { t = Mathf.Clamp01(t); } switch (i) { case 0: dstData.x = Misc.Lerp(m_dstFrom.x, m_dstTo.x, t); break; case 1: dstData.y = Misc.Lerp(m_dstFrom.y, m_dstTo.y, t); break; case 2: dstData.z = Misc.Lerp(m_dstFrom.z, m_dstTo.z, t); break; } } }
Vector3 GetAxisVector(EAxis eAxis, float fLength) { if(eAxis == EAxis.X) return new Vector3(fLength, 0.0f, 0.0f); if(eAxis == EAxis.Y) return new Vector3(0.0f, fLength, 0.0f); if(eAxis == EAxis.Z) return new Vector3(0.0f, 0.0f, fLength); if(eAxis == EAxis.MinusX) return new Vector3(-fLength, 0.0f, 0.0f); if(eAxis == EAxis.MinusY) return new Vector3(0.0f, -fLength, 0.0f); if(eAxis == EAxis.MinusZ) return new Vector3(0.0f, 0.0f, -fLength); return Vector3.zero; }