Esempio n. 1
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();
                Util.gDevAssert(IsUniformScale(scale));
                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);
        }
Esempio n. 2
0
 public TransformGizmoChange change;        // [TODO] shouldn't be using gizmo change for this?
 public GrabInfo(Cockpit cockpit, TransformableSO so, Frame3f handF)
 {
     this.cockpit      = cockpit;
     this.so           = so;
     this.startHandF   = handF;
     this.startObjFW   = so.GetLocalFrame(CoordSpace.WorldCoords);
     this.startObjRelF = this.startHandF.ToFrame(this.startObjFW);
     this.stickDelta   = Vector2f.Zero;
     change            = new TransformGizmoChange()
     {
         parentSO          = new WeakReference(so),
         parentBefore      = so.GetLocalFrame(CoordSpace.SceneCoords),
         parentScaleBefore = so.GetLocalScale()
     };
 }
Esempio n. 3
0
        /// <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(TransformableSO so, float objectDim)
        {
            float           sceneDim = objectDim;
            TransformableSO 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 TransformableSO);
            }
            if (curSO == null)
            {
                DebugUtil.Error("SceneTransforms.TransformTo: found null parent SO!");
            }
            return(sceneDim);
        }