/// <summary> /// Put a bone dataset into the pipeline /// and extract the delayed dataset. /// </summary> /// <param name="bone">the bone data to add into the queue</param> /// <returns>the delayed dataset</returns> /// public MoCapData Process(Bone bone) { if (firstPush) { // first piece of data > fill the whole pipeline with it for (int i = 0; i < pipeline.Length; i++) { pipeline[i].Store(bone); } firstPush = false; } else { pipeline[index].Store(bone); } index = (index + 1) % pipeline.Length; // manipulate data before returning MoCapData retValue = pipeline[index]; foreach (IModifier m in modifiers) { m.Process(ref retValue); } return(retValue); }
public void Process(ref MoCapData data) { if (!enabled) { return; } switch (axis) { case Axis.X_Axis: data.pos.x = -data.pos.x; data.rot.x = -data.rot.x; data.rot.w = -data.rot.w; break; case Axis.Y_Axis: data.pos.y = -data.pos.y; // TODO: not fully functional with rotation. Why? //data.rot.y = -data.rot.y; //data.rot.w = -data.rot.w; break; case Axis.Z_Axis: data.pos.z = -data.pos.z; data.rot.z = -data.rot.z; data.rot.w = -data.rot.w; break; } }
public void Process(ref MoCapData data) { // if (!enabled) return; // The actual delay happens in the MoCapDataBuffer class // by storing the data in a FIFO the length of which // is determined by the "delay" value of this component }
public void Process(ref MoCapData data) { if (!enabled) { return; } data.pos *= scaleFactor; data.length *= scaleFactor; }
public void Process(ref MoCapData data) { if (!enabled) { return; } switch (influence) { case Influence.Position: // TODO: Not very nice implementation so far data.pos.x += amount * Mathf.PerlinNoise(data.pos.y, data.pos.z); data.pos.y += amount * Mathf.PerlinNoise(data.pos.x, data.pos.z); data.pos.z += amount * Mathf.PerlinNoise(data.pos.x, data.pos.y); break; } }
public void Process(ref MoCapData data) { if (!enabled) { return; } foreach (string name in names) { if (data.buffer.Name.Equals(namePrefix + name)) { data.tracked = false; break; } } }
public void Process(ref MoCapData data) { if (!enabled) { return; } foreach (string name in names) { if (data.buffer.Name.Equals(namePrefix + name)) { data.pos *= scaleFactor; data.length *= scaleFactor; break; } } }
//// <summary> /// Called once per frame. /// </summary> /// void Update() { if (controllingBone == null) { return; } // update bones foreach (KeyValuePair <Bone, MoCapDataBuffer> entry in dataBuffers) { Bone bone = entry.Key; MoCapDataBuffer buffer = entry.Value; GameObject obj = buffer.GameObject; // pump data through buffer MoCapData data = buffer.Process(bone); // update hierarchy object if (data.tracked) { if ((trackingUsage == TrackingUsage.RotationOnly) || (trackingUsage == TrackingUsage.PositionAndRotation)) { obj.transform.localRotation = data.rot; } if ((trackingUsage == TrackingUsage.PositionOnly) || (trackingUsage == TrackingUsage.PositionAndRotation)) { obj.transform.localPosition = data.pos; } obj.SetActive(true); } else { // bone not tracked anymore, freeze or disable if (trackingLostBehaviour == TrackingLostBehaviour.Disable) { obj.SetActive(false); } } } }
/// <summary> /// Creates a new MoCap data buffer object. /// </summary> /// <param name="name">name of this buffer</param> /// <param name="owner">game object that owns this buffer</param> /// <param name="obj">game object to associate with this buffer</param> /// <param name="data">arbitrary object to associate with this buffer</param> /// public MoCapDataBuffer(string name, GameObject owner, GameObject obj, System.Object data = null) { // find any manipulators and store them modifiers = owner.GetComponents <IModifier>(); // specifically find the delay manipulator and set the FIFO size accordingly DelayModifier delayComponent = owner.GetComponent <DelayModifier>(); float delay = (delayComponent != null) ? delayComponent.delay : 0; int delayInFrames = Mathf.Max(1, 1 + (int)(delay * 60)); // TODO: Find out or define framerate somewhere central pipeline = new MoCapData[delayInFrames]; for (int i = 0; i < pipeline.Length; i++) { pipeline[i] = new MoCapData(this); } index = 0; firstPush = true; this.Name = name; this.GameObject = obj; this.DataObject = data; }