public Capture Update_SetWorldScale(InputState input, CaptureData data) { // need both controllers to have valid positions if (input.bLeftControllerActive == false || input.bRightControllerActive == false) { return(Capture.Continue); } //float fSceneScale = cockpit.ActiveScene.GetSceneScale(); HandInfo hi = (HandInfo)data.custom_data; hi.UpdateSetWorldScale(input.vLeftSpatialWorldRay, input.vRightSpatialWorldRay); return(Capture.Continue); }
public override Capture BeginCapture(InputState input, CaptureSide eSide) { HandInfo hi = new HandInfo(); hi.eMode = ActionMode.TransformCamera; Frame3f camFrame = cockpit.ActiveCamera.GetWorldFrame(); // if both rays hit scene and are within a few visual degrees, then we // we pull out a sphere and use it to re-scale the world. // Otherwise do normal hand-transform actions AnyRayHit hit1, hit2; bool bHit1 = cockpit.Scene.FindSceneRayIntersection(input.vLeftSpatialWorldRay, out hit1); bool bHit2 = cockpit.Scene.FindSceneRayIntersection(input.vRightSpatialWorldRay, out hit2); if (bHit1 && bHit2) { Vector3 avg = (hit1.hitPos + hit2.hitPos) * 0.5f; float d = VRUtil.GetVRRadiusForVisualAngle(avg, camFrame.Origin, 2.0f); if ((hit1.hitPos - hit2.hitPos).Length < d) { hi.eMode = ActionMode.SetWorldScale; Frame3f centerF = cockpit.Scene.SceneFrame; centerF.Origin = avg; Frame3f planeF = new Frame3f(centerF.Origin, camFrame.Z); hi.BeginSetWorldScale(centerF, planeF, 2 * d); hi.UpdateSetWorldScale(input.vLeftSpatialWorldRay, input.vRightSpatialWorldRay); } } hi.leftStartF = input.LeftHandFrame; hi.rightStartF = input.RightHandFrame; hi.camState = cockpit.ActiveCamera.Manipulator().GetCurrentState(cockpit.Scene); hi.camRight = camFrame.X; hi.camForward = camFrame.Z; cockpit.ActiveCamera.SetTargetVisible(true); return(Capture.Begin(this, CaptureSide.Both, hi)); }