float f_update(Pillo.PilloID pillo) { Vector3 acceleration = PilloController.GetAccelero(pillo); float angleX = Vector3.Angle (Vector3.right, acceleration) - 90; float angleZ = Vector3.Angle (Vector3.up, acceleration) - 90; Quaternion accelQ = Quaternion.Euler (angleX, 0, angleZ); float accelZ = accelQ.eulerAngles.z; //Debug.Log (accelZ); //Debug.Log("Accelz" + acceleration); //Debug.Log (PilloController.GetSensor (pillo)); PilloController.GetSensor(pillo); //if (PilloController.GetSensor (pillo) < 0.05f) { // newSmooth [(int)pillo] = 0.05f; // oldSmooth[(int)pillo] = 0.05f; //if (PilloController.GetSensor (pillo) > 0.95f) { // newSmooth [(int)pillo] = 0.95f; // oldSmooth[(int)pillo] = 0.95f; //} else { newSmooth[(int)pillo] = (PilloController.GetSensor(pillo)/100)*100; //} float tempFloat = newSmooth[(int)pillo] * smoothFactor + oldSmooth[(int)pillo]*(1-smoothFactor); oldSmooth[(int)pillo] = tempFloat; //tempfloat = smoothed value return tempFloat; }
void _update(Pillo.PilloID pillo) { // set height based on Pillo sensor, and use calibrated values if available Vector3 tmp = m_slider[(int)pillo].transform.position; tmp.y = 10 * PilloController.GetSensor(pillo,PilloController.IsPilloCalibrated(pillo)); m_slider[(int)pillo].transform.position = tmp; // show Pillo orientation based on accelerometer Vector3 acceleration = PilloController.GetAccelero(pillo); float angleX = Vector3.Angle (Vector3.right, acceleration) - 90; float angleZ = Vector3.Angle (Vector3.up, acceleration) - 90; m_slider [(int)pillo].transform.rotation = Quaternion.Euler(angleX, 0, angleZ); }