protected override bool defineCmd() { JSIApp app = (JSIApp)this.mApp; JSIPerspCameraPerson cp = app.getPerspCameraPerson(); // create a plane on the pivot, directly facing the camera. Plane pivotPlane = new Plane(-cp.getView(), cp.getPivot()); // project the previous screen point to the plane. Ray prevPtRay = cp.getCamera().ScreenPointToRay(this.mPrevPt); float prevPtDist = float.NaN; pivotPlane.Raycast(prevPtRay, out prevPtDist); Vector3 prevPtOnPlane = prevPtRay.GetPoint(prevPtDist); // project the current screen point to the plane. Ray curPtRay = cp.getCamera().ScreenPointToRay(this.mCurPt); float curPtDist = float.NaN; pivotPlane.Raycast(curPtRay, out curPtDist); Vector3 curPtOnPlane = curPtRay.GetPoint(curPtDist); // calculate the position difference between the two points. Vector3 offset = curPtOnPlane - prevPtOnPlane; // update the postion of the camera. cp.setEye(cp.getEye() - offset); return(true); }
public override void handlePenUp(Vector2 pt) { JSIApp app = (JSIApp)this.mScenario.getApp(); JSICmdToAddCurPtCurve2DToPtCurve2Ds.execute(app); XCmdToChangeScene.execute(app, this.mReturnScene, null); }
protected override bool defineCmd() { JSIApp app = (JSIApp)this.mApp; JSIPerspCameraPerson cp = app.getPerspCameraPerson(); // create the ground plane. Plane groundPlane = new Plane(Vector3.up, Vector3.zero); // project the previous screen point to the plane. Ray prevPtRay = cp.getCamera().ScreenPointToRay(this.mPrevPt); float prevPtDist = float.NaN; groundPlane.Raycast(prevPtRay, out prevPtDist); Vector3 prevPtOnPlane = prevPtRay.GetPoint(prevPtDist); // project the previous screen point to the plane. Ray curPtRay = cp.getCamera().ScreenPointToRay(this.mCurPt); float curPtDist = float.NaN; groundPlane.Raycast(curPtRay, out curPtDist); Vector3 curPtOnPlane = curPtRay.GetPoint(curPtDist); // calculate position difference between the two points. Vector3 diff = curPtOnPlane - prevPtOnPlane; // update the position of the selected standing card JSIEditStandingCardScenario scenario = JSIEditStandingCardScenario.getSingleton(); JSIStandingCard standingCardToMove = scenario.getSelectedStandingCard(); standingCardToMove.getGameObject().transform.position += diff; return(true); }
protected override bool defineCmd() { JSIApp app = (JSIApp)this.mApp; JSIPerspCameraPerson cp = app.getPerspCameraPerson(); // calculate the normal vector of the card plane. Vector3 normalDir = Vector3.ProjectOnPlane(-cp.getView(), Vector3.up).normalized; // define card dimensions. float cardWidth = 1.0f; float cardHeight = 2.0f; Vector3 cardCenter = new Vector3(0.0f, cardHeight / 2.0f, 0.0f); Vector3 cardZDir = -normalDir; Vector3 cardYDir = Vector3.up; Vector3 cardXDir = Vector3.Cross(cardYDir, cardZDir); Quaternion rot = Quaternion.LookRotation(cardZDir, cardYDir); // create a new stadning card JSIStandingCard sc = new JSIStandingCard("EmptyStandingCard", cardWidth, cardHeight, cardCenter, rot, null); // add the standing card to its mgr app.getStandingCardMgr().getStandingCards().Add(sc); return(true); }
public override void getReady() { // JSIApp app = (JSIApp) this.mScenario.getApp(); // JSIEditStandingCardScenario scenario = // (JSIEditStandingCardScenario)this.mScenario; // // selecte the card to roate // JSIStandingCard standingCardToMove = // scenario.selectStandingCardByStand(); // scenario.setSelectedStandingCard(standingCardToMove); JSIApp app = (JSIApp)this.mScenario.getApp(); // deactivate stands. // deactivate scale handles. foreach (JSIStandingCard sc in app.getStandingCardMgr().getStandingCards()) { sc.getStand().getGameObject().SetActive(false); sc.getScaleHandle().getGameObject().SetActive(false); } // highlight selected stand. JSIEditStandingCardScenario scenario = (JSIEditStandingCardScenario)this.mScenario; scenario.getSelectedStandingCard().getStand().getGameObject(). SetActive(true); scenario.getSelectedStandingCard().highlightStand(true); }
private JSICmdToMoveStandingCard(XApp app) : base(app) { JSIApp jsi = (JSIApp)this.mApp; JSIPenMark pm = jsi.getPenMarkMgr().getLastPenMark(); this.mPrevPt = pm.getRecentPt(1); this.mCurPt = pm.getRecentPt(0); }
public override void handlePenDown(Vector2 pt) { JSIApp app = (JSIApp)this.mScenario.getApp(); XCmdToChangeScene.execute(app, JSINavigateScenario.DollyCameraScene.getSingleton(), this.mReturnScene); }
// private constructor private JSICmdToDollyCamera(XApp app) : base(app) { JSIApp jsi = (JSIApp)this.mApp; JSIPenMark pm = jsi.getPenMarkMgr().getLastPenMark(); this.mPrevPt = pm.getRecentPt(1); this.mCurPt = pm.getRecentPt(0); }
public override void handlePenUp(Vector2 pt) { JSIApp app = (JSIApp)this.mScenario.getApp(); XCmdToChangeScene.execute(app, JSINavigateScenario.TranslateReadyScene.getSingleton(), this.mReturnScene); }
protected override bool defineCmd() { JSIApp app = (JSIApp)this.mApp; JSIAppPolyline2D curPtCurve2D = app.getPtCurve2DMgr().getCurPtCurve2D(); curPtCurve2D.setPts( app.getPenMarkMgr().getLastPenMark().getPts()); return(true); }
public override void handleKeyUp(KeyCode kc) { JSIApp app = (JSIApp)this.mScenario.getApp(); switch (kc) { case KeyCode.LeftControl: XCmdToChangeScene.execute(app, this.mReturnScene, null); break; } }
public override void handleKeyUp(KeyCode kc) { JSIApp app = (JSIApp)this.mScenario.getApp(); switch (kc) { case KeyCode.Return: JSICmdToCreateEmptyStandingCard.execute(app); break; } }
protected override bool defineCmd() { JSIApp app = (JSIApp)this.mApp; JSIEditStandingCardScenario scenario = JSIEditStandingCardScenario.getSingleton(); this.mSelectedStandingCard = scenario.selectStandingCardByStand(); scenario.setSelectedStandingCard(this.mSelectedStandingCard); return(true); }
public override void getReady() { JSIApp app = (JSIApp)this.mScenario.getApp(); JSIEditStandingCardScenario scenario = (JSIEditStandingCardScenario)this.mScenario; // selecte the card to roate JSIStandingCard standingCardToRotate = scenario.selectStandingCardByStand(); scenario.setSelectedStandingCard(standingCardToRotate); }
public override void getReady() { JSIApp app = (JSIApp)this.mScenario.getApp(); // deactivate stands. // deactivate scale handles. foreach (JSIStandingCard sc in app.getStandingCardMgr().getStandingCards()) { sc.getStand().getGameObject().SetActive(false); sc.getScaleHandle().getGameObject().SetActive(false); } }
// methods public override void handleKeyDown(KeyCode kc) { JSIApp app = (JSIApp)this.mScenario.getApp(); switch (kc) { case KeyCode.LeftAlt: XCmdToChangeScene.execute(app, JSIEditStandingCardScenario.MoveStandingCardScene. getSingleton(), this.mReturnScene); break; } }
// methods public override void handleKeyDown(KeyCode kc) { JSIApp app = (JSIApp)this.mScenario.getApp(); switch (kc) { case KeyCode.LeftAlt: XCmdToChangeScene.execute(app, JSINavigateScenario.TranslateReadyScene.getSingleton(), this.mReturnScene); break; } }
protected override bool defineCmd() { JSIApp app = (JSIApp)this.mApp; List <Vector2> pts = new List <Vector2>(); pts.Add(this.mPt); JSIAppPolyline2D ptCurve2D = new JSIAppPolyline2D( "PtCurve2D", pts, JSIPtCurve2DMgr.PT_CURVE_WIDTH, JSIPtCurve2DMgr.PT_CURVE_COLOR); app.getPtCurve2DMgr().setCurPtCurve2D(ptCurve2D); return(true); }
public override void handleKeyUp(KeyCode kc) { JSIApp app = (JSIApp)this.mScenario.getApp(); switch (kc) { case KeyCode.LeftControl: XCmdToChangeScene.execute(app, this.mReturnScene, null); break; case KeyCode.LeftAlt: XCmdToChangeScene.execute(app, JSINavigateScenario.TumbleCameraScene.getSingleton(), this.mReturnScene); break; } }
public override void handlePenDown(Vector2 pt) { JSIApp app = (JSIApp)this.mScenario.getApp(); foreach (JSIStandingCard sc in app.getStandingCardMgr().getStandingCards()) { if (app.getCursor().hits(sc.getScaleHandle())) { JSICmdToSelectSmallestStandingCardByScaleHandle. execute(app); XCmdToChangeScene.execute(app, JSIEditStandingCardScenario. ScaleStandingCardScene.getSingleton(), this); return; } } }
protected override bool defineCmd() { JSIApp app = (JSIApp)this.mApp; JSIPerspCameraPerson cp = app.getPerspCameraPerson(); // create the ground plane. Plane groundPlane = new Plane(Vector3.up, Vector3.zero); // project the previous screen point to the plane. Ray prevPtRay = cp.getCamera().ScreenPointToRay(this.mPrevPt); float prevPtDist = float.NaN; groundPlane.Raycast(prevPtRay, out prevPtDist); Vector3 prevPtOnPlane = prevPtRay.GetPoint(prevPtDist); // project the previous screen point to the plane. Ray curPtRay = cp.getCamera().ScreenPointToRay(this.mCurPt); float curPtDist = float.NaN; groundPlane.Raycast(curPtRay, out curPtDist); Vector3 curPtOnPlane = curPtRay.GetPoint(curPtDist); // calculate rotation JSIEditStandingCardScenario scenario = JSIEditStandingCardScenario.getSingleton(); JSIStandingCard standingCardToRotate = scenario.getSelectedStandingCard(); JSIAppCircle3D stand = standingCardToRotate.getStand(); Vector3 standCtr = stand.getGameObject().transform.position; Quaternion prevRot = Quaternion.LookRotation( Vector3.up, prevPtOnPlane - standCtr); Quaternion curRot = Quaternion.LookRotation( Vector3.up, curPtOnPlane - standCtr); Quaternion delRot = curRot * Quaternion.Inverse(prevRot); standingCardToRotate.getGameObject().transform.rotation = delRot * standingCardToRotate.getGameObject().transform.rotation; return(true); }
public override void handlePenDown(Vector2 pt) { JSIApp app = (JSIApp)this.mScenario.getApp(); foreach (JSIStandingCard sc in app.getStandingCardMgr().getStandingCards()) { if (app.getCursor().hits(sc.getStand())) { XCmdToChangeScene.execute(app, JSIEditStandingCardScenario. RotateStandingCardScene.getSingleton(), this.mReturnScene); return; } } XCmdToChangeScene.execute(app, JSINavigateScenario.TumbleCameraScene.getSingleton(), this.mReturnScene); }
protected override bool defineCmd() { JSIApp app = (JSIApp)this.mApp; JSIAppPolyline2D curPtCurve2D = app.getPtCurve2DMgr().getCurPtCurve2D(); JSIPolyline2D polyline = (JSIPolyline2D)curPtCurve2D.getGeom2D(); if (polyline.getPts().Count > 2) { app.getPtCurve2DMgr().getPtCurve2Ds().Add(curPtCurve2D); app.getPtCurve2DMgr().setCurPtCurve2D(null); } else { app.getPtCurve2DMgr().getCurPtCurve2D().destroyGameObject(); app.getPtCurve2DMgr().setCurPtCurve2D(null); } return(true); }
protected override bool defineCmd() { JSIApp app = (JSIApp)this.mApp; JSIPerspCameraPerson cp = app.getPerspCameraPerson(); float dx = this.mCurPt.x - this.mPrevPt.x; float dy = this.mCurPt.y - this.mPrevPt.y; float dAzimuth = 180.0f * dx / Screen.width; float dZenith = -180.0f * dy / Screen.height; // Quaternion qa = Quaternion.AngleAxis(dAzimuth, Vector3.up); Quaternion qa = Quaternion.AngleAxis(dAzimuth, cp.getUp()); Quaternion qz = Quaternion.AngleAxis(dZenith, cp.getRight()); Vector3 pivotToEye = cp.getEye() - cp.getPivot(); Vector3 nextEye = cp.getPivot() + qa * qz * pivotToEye; Vector3 nextView = qa * qz * cp.getView(); cp.setEye(nextEye); cp.setView(nextView); return(true); }
public JSIStandingCard selectStandingCardByScaleHandle() { JSIApp app = (JSIApp)this.mApp; List <JSIStandingCard> hitStandingCards = new List <JSIStandingCard>(); foreach (JSIStandingCard standingCard in app.getStandingCardMgr().getStandingCards()) { if (app.getCursor().hits(standingCard.getScaleHandle())) { hitStandingCards.Add(standingCard); } } if (hitStandingCards.Count == 0) { return(null); } // find and return the smallest standing card among ths hit ones. float minWidth = Mathf.Infinity; JSIStandingCard smallestStandingCard = null; foreach (JSIStandingCard standingCard in hitStandingCards) { JSIAppRect3D card = standingCard.getCard(); JSIRect3D rect = (JSIRect3D)card.getGeom3D(); if (rect.getWidth() < minWidth) { smallestStandingCard = standingCard; minWidth = rect.getWidth(); } } return(smallestStandingCard); }
protected override bool defineCmd() { JSIApp app = (JSIApp)this.mApp; JSIPerspCameraPerson cp = app.getPerspCameraPerson(); // check if there exist 2D point curves. if (app.getPtCurve2DMgr().getPtCurve2Ds().Count == 0) { return(false); } //find the lowest 2D point. Vector2 lowestPt2D = this.calcLowestPt2D( app.getPtCurve2DMgr().getPtCurve2Ds()); // calculate the lowest 3D point. Ray lowestPtRay = cp.getCamera().ScreenPointToRay(lowestPt2D); Plane groundPlane = new Plane(Vector3.up, Vector3.zero); float lowestPtDist = float.NaN; groundPlane.Raycast(lowestPtRay, out lowestPtDist); Vector3 lowestPt3D = lowestPtRay.GetPoint(lowestPtDist); // calculate the noraml vector of the card plane. Vector3 normalDir = Vector3.ProjectOnPlane( -cp.getView(), Vector3.up).normalized; // calculate 3D point curves by projecting 2D point curves // to the plane. Plane cardPlane = new Plane(normalDir, lowestPt3D); List <JSIAppPolyline3D> ptCurve3Ds = this.calcProjectedPtCurve3Ds( app.getPtCurve2DMgr().getPtCurve2Ds(), cardPlane, cp.getCamera()); // clear 2D point curves. foreach (JSIAppPolyline2D ptCurve2D in app.getPtCurve2DMgr().getPtCurve2Ds()) { ptCurve2D.destroyGameObject(); } app.getPtCurve2DMgr().getPtCurve2Ds().Clear(); // calculate Vector3 cardZDir = -normalDir; Vector3 cardYDir = Vector3.up; Vector3 cardXDir = Vector3.Cross(cardYDir, cardZDir).normalized; Vector3 cardCtr = this.calcCardCtr(ptCurve3Ds, lowestPt3D, cardXDir, cardYDir, cardZDir); // calculate the local 3D List <JSIAppPolyline3D> localPtCurve3Ds = this.createLocalPtCurve3Ds(ptCurve3Ds, cardCtr, cardXDir, cardYDir, cardZDir); // clear 3D point curves. foreach (JSIAppPolyline3D ptCurve3D in ptCurve3Ds) { ptCurve3D.destroyGameObject(); } ptCurve3Ds.Clear(); // create a new standing card. float cardWidth = this.calcCardWidth(localPtCurve3Ds); float cardHeight = this.calcCardHeight(localPtCurve3Ds); Quaternion q = Quaternion.LookRotation(cardZDir, cardYDir); JSIStandingCard sc = new JSIStandingCard("StandingCard", cardWidth, cardHeight, cardCtr, q, localPtCurve3Ds); // add the standing car to its manager. app.getStandingCardMgr().getStandingCards().Add(sc); return(true); }
public override void handlePenDrag(Vector2 pt) { JSIApp app = (JSIApp)this.mScenario.getApp(); JSICmdToUpdateCurPtCurve2D.execute(app); }
// private constructor private JSICmdToAddCurPtCurve2DToPtCurve2Ds(XApp app) : base(app) { JSIApp jsi = (JSIApp)this.mApp; }
public override void handlePenDrag(Vector2 pt) { JSIApp app = (JSIApp)this.mScenario.getApp(); JSICmdToMoveStandingCard.execute(app); }
public override void handlePenDrag(Vector2 pt) { JSIApp app = (JSIApp)this.mScenario.getApp(); JSICmdToDollyCamera.execute(app); }