public Point(Vector2S v, QuaternionS rotation) { this.position = new Vector2S(); this.position.x = (float)Math.Round(v.x, Decimals); this.position.y = (float)Math.Round(v.y, Decimals); this.rotation = rotation; }
public TransformS(Transform t) { if (t == null) { return; } pos = t.position; rot = t.rotation; scale = t.localScale; }
private static void ComputeLocalTranform(Animation anim) { // Validate input if (anim.frameList.Count < 2) { Debug.LogError("The Animation does not have enough Frames to compute velocities"); throw new Exception("The Animation does not have enough Frames to compute velocities"); } // Find local Positions foreach (Frame frame in anim.frameList) { // (TODO FINAL): set it to root and not hips // Root's Position and Rotation Vector3S rootP = frame.boneDataDict[Bone.Type.hips].position; QuaternionS rootQ = frame.boneDataDict[Bone.Type.hips].rotation; // For every bone of the Animation foreach (Bone.Type bt in Enum.GetValues(typeof(Bone.Type))) { // Local position considers root as 0 and root's up as up frame.boneDataDict[bt].SetLocalPosition(rootP, rootQ); } } // Find local Velocity foreach (Bone.Type bt in Enum.GetValues(typeof(Bone.Type))) { // Find the position of the first frame Vector3S lastLocalPosition = anim.frameList[0].boneDataDict[bt].localPosition; // Compute the velocities of all the Frames but the first for (int i = 1; i < anim.frameList.Count; i++) { anim.frameList[i].boneDataDict[bt].SetLocalVelocity(lastLocalPosition); lastLocalPosition = anim.frameList[i].boneDataDict[bt].localPosition; } // Set the velocity of the first Frame equal to the one in the second lastLocalPosition = anim.frameList[1].boneDataDict[bt].localPosition; anim.frameList[0].boneDataDict[bt].SetLocalVelocity(lastLocalPosition); } }
public Snippet GetLocalSnippet( int presentFrame) { // Validate input if (presentFrame < SalamanderController.FeaturePastPoints - 1 || presentFrame > points.Count - SalamanderController.FeaturePoints) { Debug.LogError("Attempt to create a Snippet the exceedes the past or the future limit"); throw new Exception("Attempt to create a Snippet the exceedes the past or the future limit"); } // Find present position and rotation Vector2S presentPosition = points[presentFrame].position; QuaternionS presentRotation = this.points[presentFrame].rotation; // Build the new Snippet Snippet snippet = new Snippet(); for (int i = 0; i < SalamanderController.SnippetSize; i++) { // Compute the position of the points relative to the present position and rotation // Create a Point at the current position int addingFrame = presentFrame - SalamanderController.FeaturePastPoints + 1 + i; Vector3 localPosition3D = new Vector3(this.points[addingFrame].position.x, 0, this.points[addingFrame].position.y); // Move it to the root localPosition3D.x -= presentPosition.x; localPosition3D.z -= presentPosition.y; // Rotate it to face upwards localPosition3D = Quaternion.Inverse((Quaternion)presentRotation) * localPosition3D; // Compute the new rotation QuaternionS localRotation = this.points[addingFrame].rotation * presentRotation; // Store the relative point to the snippet snippet.points[i] = new Point(localPosition3D.GetXZVector2(), localRotation); } return(snippet); }
public static Point getMedianPoint(List <Vector2S> positions) { Vector2S position = new Vector2S(0f, 0f); QuaternionS rotation; // Position foreach (Vector2S currentPosition in positions) { position += currentPosition; } position /= positions.Count; // Rotation Vector2S displacement2D = (positions[positions.Count - 1] - positions[0]); rotation = Quaternion.LookRotation( new Vector3(displacement2D.x, 0, displacement2D.y), Vector3.up); return(new Point(position, rotation)); }
public TransformS(Vector3 v, Quaternion q) { pos = v; rot = q; scale = Vector3.one; }
public BoneStateSample(Transform obj) { pos = new Vector3S(obj.localPosition); rot = new QuaternionS(obj.localRotation); scale = new Vector3S(obj.localScale); }
public BoneStateSample(Vector3 p,Quaternion r , Vector3 s) { pos = new Vector3S(p); rot = new QuaternionS(r); scale = new Vector3S(s); }
public void SetLocalPosition(Vector3S originPosition, QuaternionS originRotation) { this.localPosition = originRotation * (Vector3)(this.position - originPosition); }
public Data(Vector3S position, QuaternionS rotation) { this.position = position; this.rotation = rotation; }