public MoveController(int num) { _data = new MoveData(); _dirty = true; gemState = new PSMoveSharpGemState(); sphereState = new PSMoveSharpSphereState(); imageState = new PSMoveSharpImageState(); Connected = false; Num = num; }
private void UpdateSphereState(int num) { PSMoveSharpSphereState sphereState = state.sphereStates[num]; sphereColor[num].r = sphereState.r; sphereColor[num].g = sphereState.g; sphereColor[num].b = sphereState.b; isTracking[num] = (sphereState.tracking == 1); trackingHue[num] = (int)sphereState.tracking_hue; }
public void Update(PSMoveSharpState state) { gemState = state.gemStates[Num]; sphereState = state.sphereStates[Num]; imageState = state.imageStates[Num]; Connected = (state.gemStatus[Num].connected == 1); _dirty = true; }
public void Update(PSMoveSharpGemState gemState, PSMoveSharpSphereState sphereState, PSMoveSharpImageState imageState) { // gem state Position = PSMoveUtil.Float4ToVector3(gemState.pos)/100; Velocity = PSMoveUtil.Float4ToVector3(gemState.vel)/100; Acceleration = PSMoveUtil.Float4ToVector3(gemState.accel)/100; QOrientation = PSMoveUtil.Float4ToQuaternion(gemState.quat); Orientation = QOrientation.eulerAngles; AngularVelocity = PSMoveUtil.Float4ToVector3(gemState.angvel) * Mathf.Rad2Deg; AngularAcceleration = PSMoveUtil.Float4ToVector3(gemState.angaccel) * Mathf.Rad2Deg; HandlePosition = PSMoveUtil.Float4ToVector3(gemState.handle_pos)/100; HandleVelocity = PSMoveUtil.Float4ToVector3(gemState.handle_vel)/100; HandleAcceleration = PSMoveUtil.Float4ToVector3(gemState.handle_accel)/100; PrevButtons = Buttons; Buttons = MoveButton.None; if((gemState.pad.digitalbuttons & PSMoveSharpConstants.ctrlSquare) != 0) Buttons |= MoveButton.Square; if((gemState.pad.digitalbuttons & PSMoveSharpConstants.ctrlCross) != 0) Buttons |= MoveButton.Cross; if((gemState.pad.digitalbuttons & PSMoveSharpConstants.ctrlCircle) != 0) Buttons |= MoveButton.Circle; if((gemState.pad.digitalbuttons & PSMoveSharpConstants.ctrlTriangle) != 0) Buttons |= MoveButton.Triangle; if((gemState.pad.digitalbuttons & PSMoveSharpConstants.ctrlTick) != 0) Buttons |= MoveButton.Move; if((gemState.pad.digitalbuttons & PSMoveSharpConstants.ctrlStart) != 0) Buttons |= MoveButton.Start; if((gemState.pad.digitalbuttons & PSMoveSharpConstants.ctrlSelect) != 0) Buttons |= MoveButton.Select; ValueT = gemState.pad.analog_trigger; if(ValueT >= thresholdT) Buttons |= MoveButton.T; // sphere state SphereColor = new Color(sphereState.r, sphereState.g, sphereState.b); IsTracking = (sphereState.tracking == 1); TrackingHue = (int)sphereState.tracking_hue; // image state SpherePixelPosition = new Vector2(imageState.u, imageState.v); SpherePixelRadius = imageState.r; SphereProjectionPosition = new Vector2(imageState.projectionx, imageState.projectiony); SphereDistance = imageState.distance/100; SphereVisible = (imageState.visible == 1); SphereRadiusValid = (imageState.r_valid == 1); }
public void Update(PSMoveSharpGemState gemState, PSMoveSharpSphereState sphereState, PSMoveSharpImageState imageState) { // gem state Position = PSMoveUtil.Float4ToVector3(gemState.pos) / 100; Velocity = PSMoveUtil.Float4ToVector3(gemState.vel) / 100; Acceleration = PSMoveUtil.Float4ToVector3(gemState.accel) / 100; QOrientation = PSMoveUtil.Float4ToQuaternion(gemState.quat); Orientation = QOrientation.eulerAngles; AngularVelocity = PSMoveUtil.Float4ToVector3(gemState.angvel) * Mathf.Rad2Deg; AngularAcceleration = PSMoveUtil.Float4ToVector3(gemState.angaccel) * Mathf.Rad2Deg; HandlePosition = PSMoveUtil.Float4ToVector3(gemState.handle_pos) / 100; HandleVelocity = PSMoveUtil.Float4ToVector3(gemState.handle_vel) / 100; HandleAcceleration = PSMoveUtil.Float4ToVector3(gemState.handle_accel) / 100; PrevButtons = Buttons; Buttons = MoveButton.None; if ((gemState.pad.digitalbuttons & PSMoveSharpConstants.ctrlSquare) != 0) { Buttons |= MoveButton.Square; } if ((gemState.pad.digitalbuttons & PSMoveSharpConstants.ctrlCross) != 0) { Buttons |= MoveButton.Cross; } if ((gemState.pad.digitalbuttons & PSMoveSharpConstants.ctrlCircle) != 0) { Buttons |= MoveButton.Circle; } if ((gemState.pad.digitalbuttons & PSMoveSharpConstants.ctrlTriangle) != 0) { Buttons |= MoveButton.Triangle; } if ((gemState.pad.digitalbuttons & PSMoveSharpConstants.ctrlTick) != 0) { Buttons |= MoveButton.Move; } if ((gemState.pad.digitalbuttons & PSMoveSharpConstants.ctrlStart) != 0) { Buttons |= MoveButton.Start; } if ((gemState.pad.digitalbuttons & PSMoveSharpConstants.ctrlSelect) != 0) { Buttons |= MoveButton.Select; } ValueT = gemState.pad.analog_trigger; if (ValueT >= thresholdT) { Buttons |= MoveButton.T; } // sphere state SphereColor = new Color(sphereState.r, sphereState.g, sphereState.b); IsTracking = (sphereState.tracking == 1); TrackingHue = (int)sphereState.tracking_hue; // image state SpherePixelPosition = new Vector2(imageState.u, imageState.v); SpherePixelRadius = imageState.r; SphereProjectionPosition = new Vector2(imageState.projectionx, imageState.projectiony); SphereDistance = imageState.distance / 100; SphereVisible = (imageState.visible == 1); SphereRadiusValid = (imageState.r_valid == 1); }
public PSMoveSharpState() { serverConfig = new PSMoveSharpServerConfig(); gemStatus = new PSMoveSharpStatus[PSMoveSharpNumMoveControllers]; gemStates = new PSMoveSharpGemState[PSMoveSharpNumMoveControllers]; imageStates = new PSMoveSharpImageState[PSMoveSharpNumMoveControllers]; pointerStates = new PSMoveSharpPointerState[PSMoveSharpNumMoveControllers]; sphereStates = new PSMoveSharpSphereState[PSMoveSharpNumMoveControllers]; for (int i = 0; i < PSMoveSharpNumMoveControllers; i++) { sphereStates[i] = new PSMoveSharpSphereState(); } cameraState = new PSMoveSharpCameraState(); padData = new PSMoveSharpNavPadData[PSMoveSharpNavInfo.PSMoveSharpNumNavControllers]; for (int i = 0; i < PSMoveSharpNavInfo.PSMoveSharpNumNavControllers; i++) { padData[i] = new PSMoveSharpNavPadData(); } navInfo = new PSMoveSharpNavInfo(); positionPointerStates = new PSMoveSharpPositionPointerState[PSMoveSharpNumMoveControllers]; for (int i = 0; i < PSMoveSharpNumMoveControllers; i++) { positionPointerStates[i] = new PSMoveSharpPositionPointerState(); } }