public OpStatus StepBack()
        {
            if (iCurrent == 0)
            {
                return(OpStatus.Success);        // weird but ok
            }
            IChangeOp op = vHistory[iCurrent - 1];

            DebugUtil.Log(2, "ChangeHistory.StepBack: reverting {0}", op.Identifier());
            OpStatus result = op.Revert();

            if (result.code != OpStatus.no_error)
            {
                DebugUtil.Error("[ChangeHistory::StepBack] Revert() of ChangeOp {0} failed - result was code {1} message {2}",
                                op.Identifier(), result.code, result.message);
                return(result);
            }

            iCurrent--;
            return(OpStatus.Success);
        }
        /// <summary>
        /// input objectF is in Object (local) coords of so, apply all intermediate
        /// transforms to get it to Scene coords
        /// </summary>
        public static Vector3f ObjectToSceneP(SceneObject so, Vector3f objectPt)
        {
            SceneObject curSO = so;

            while (curSO != null)
            {
                Frame3f  curF  = curSO.GetLocalFrame(CoordSpace.ObjectCoords);
                Vector3f scale = curSO.GetLocalScale();
                objectPt = curF.FromFrameP(objectPt * scale);
                SOParent parent = curSO.Parent;
                if (parent is FScene)
                {
                    return(objectPt);
                }
                curSO = (parent as SceneObject);
            }
            if (curSO == null)
            {
                DebugUtil.Error("SceneTransforms.ObjectToSceneP: found null parent SO!");
            }
            return(objectPt);
        }
        public OpStatus StepForward()
        {
            if (iCurrent == vHistory.Count)
            {
                return(OpStatus.Success);
            }

            IChangeOp op = vHistory[iCurrent];

            DebugUtil.Log(2, "ChangeHistory.StepForward: applying {0}", op.Identifier());
            OpStatus result = op.Apply();

            if (result.code != OpStatus.no_error)
            {
                DebugUtil.Error("[ChangeHistory::StepForward] Apply() of ChangeOp {0} failed - result was code {1} message {2}",
                                op.Identifier(), result.code, result.message);
                return(result);
            }

            iCurrent++;
            return(OpStatus.Success);
        }
        /// <summary>
        /// input dimension is in Object (local) coords of so, apply all intermediate
        /// transform scaling to get it to Scene coords
        /// </summary>
        public static float ObjectToScene(SceneObject so, float objectDim)
        {
            float       sceneDim = objectDim;
            SceneObject curSO    = so;

            while (curSO != null)
            {
                Vector3f scale = curSO.GetLocalScale();
                Util.gDevAssert(IsUniformScale(scale));
                sceneDim *= ((scale.x + scale.y + scale.z) / 3.0f);   // yikes!
                SOParent parent = curSO.Parent;
                if (parent is FScene)
                {
                    return(sceneDim);
                }
                curSO = (parent as SceneObject);
            }
            if (curSO == null)
            {
                DebugUtil.Error("SceneTransforms.ObjectToScene: found null parent SO!");
            }
            return(sceneDim);
        }
Beispiel #5
0
        /// <summary>
        /// input objectF is in Object (local) coords of so, apply all intermediate
        /// transforms to get it to Scene coords
        /// </summary>
        public static Frame3f ObjectToScene(TransformableSO so, Frame3f objectF)
        {
            Frame3f         sceneF = objectF;
            TransformableSO curSO  = so;

            while (curSO != null)
            {
                Frame3f  curF  = curSO.GetLocalFrame(CoordSpace.ObjectCoords);
                Vector3f scale = curSO.GetLocalScale();
                sceneF.Scale(scale);
                sceneF = curF.FromFrame(sceneF);
                SOParent parent = curSO.Parent;
                if (parent is FScene)
                {
                    return(sceneF);
                }
                curSO = (parent as TransformableSO);
            }
            if (curSO == null)
            {
                DebugUtil.Error("SceneTransforms.TransformTo: found null parent SO!");
            }
            return(sceneF);
        }
        /// <summary>
        /// Input objectV is a vector in local coords of SO, apply all intermediate inverse
        /// transforms to get it into scene coords.
        /// </summary>
        public static Vector3f ObjectToSceneV(SceneObject so, Vector3f objectV)
        {
            Vector3f    sceneV = objectV;
            SceneObject curSO  = so;

            while (curSO != null)
            {
                Frame3f  curF  = curSO.GetLocalFrame(CoordSpace.ObjectCoords);
                Vector3f scale = curSO.GetLocalScale();
                sceneV *= scale;
                sceneV  = curF.FromFrameV(ref sceneV);
                SOParent parent = curSO.Parent;
                if (parent is FScene)
                {
                    return(sceneV);
                }
                curSO = (parent as SceneObject);
            }
            if (curSO == null)
            {
                DebugUtil.Error("SceneTransforms.ObjectToSceneV: found null parent SO!");
            }
            return(sceneV);
        }