private static void ApplyIndividualCalibrations(TuioObject tobj) { if (Settings.USE_INDIVIDUAL_CALIBRATION) // Modify object using calibration values before passing it on { int symbolID = tobj.getSymbolID(); // ERICSOCO ADDED if (symbolID > 4095) { throw new ArgumentOutOfRangeException(); } // Retrieve calibration values for this object float calA1 = MathHelper.ToRadians(Settings.CALIBRATIONS[symbolID, 0]); float calD = (float)Settings.CALIBRATIONS[symbolID, 1]; float calA2 = MathHelper.ToRadians(Settings.CALIBRATIONS[symbolID, 2]); // Assume that the tuioObject is the origin, and that its orientation vector points up (along the y-axis). // Create a position vector based on the calibration information that is offset from the tuioObject/origin. Vector2 offsetVector = new Vector2((float)Math.Cos(calA1), (float)Math.Sin(calA1)); offsetVector = Vector2.Multiply(offsetVector, calD); // Rotate vector around the origin by the TUIO object's orientation. Matrix tMatrix = Matrix.CreateRotationZ(tobj.getAngle()); // Translate vector by the TUIO object's position. tMatrix *= Matrix.CreateTranslation(tobj.getScreenX(Settings.RESOLUTION_X), tobj.getScreenY(Settings.RESOLUTION_Y), 0f); // Apply matrix transforms. offsetVector = Vector2.Transform(offsetVector, tMatrix); // Normalize to screen resolution. float offsetX = offsetVector.X / Settings.RESOLUTION_X; float offsetY = offsetVector.Y / Settings.RESOLUTION_Y; // Add other calibration angle to tuioObject angle. float offsetA = tobj.getAngle() + calA2; // Update the TUIO object. tobj.update(tobj.getTuioTime(), offsetX, offsetY, offsetA); /* // Add offset angle to tuioObject's rotation float offsetA = tobj.getAngle() + calA1; Vector2 offsetV = new Vector2((float)Math.Cos(offsetA), (float)Math.Sin(offsetA)); // Move fiducial point to data point // offsetV.Normalize(); Vector2 dataPoint = Vector2.Multiply(offsetV, calD); tobj.update(tobj.getTuioTime(), tobj.getX() + dataPoint.X / RESOLUTION_X, tobj.getY() + dataPoint.Y / RESOLUTION_Y, tobj.getAngle() + calA2); */ } }