コード例 #1
0
        protected override bool defineCmd()
        {
            JSIApp           app          = (JSIApp)this.mApp;
            JSIAppPolyline2D curPtCurve2D =
                app.getPtCurve2DMgr().getCurPtCurve2D();

            curPtCurve2D.setPts(
                app.getPenMarkMgr().getLastPenMark().getPts());
            return(true);
        }
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }