Пример #1
0
        public virtual void Setup()
        {
            // push history stream, so that we can do undo/redo internal to tool,
            // that will not end up in external history
            push_history_stream();

            // clear selection here so that multi-select GroupSO goes away, otherwise
            // when we copy frmaes below, they are relative to that GroupSO, and things move
            inputSelection = new List <SceneObject>(Scene.Selected);
            set_allow_selection_changes(true);
            Scene.ClearSelection();
            set_allow_selection_changes(false);

            objects = new List <TargetObject>();
            foreach (var so in InputSOs)
            {
                TargetObject o = new TargetObject();

                o.SO         = so;
                o.InputMeshV = new DVector <double>(o.SO.Mesh.VerticesBuffer);
                if (o.SO.Mesh.HasVertexNormals)
                {
                    o.InputMeshN = new DVector <float>(o.SO.Mesh.NormalsBuffer);
                }
                o.objFrame            = so.GetLocalFrame(CoordSpace.ObjectCoords);
                o.sceneFrame          = so.GetLocalFrame(CoordSpace.SceneCoords);
                o.sceneToObjUnitScale = SceneTransforms.SceneToObject(o.SO, 1.0f);

                o.localScale  = so.GetLocalScale();
                o.localBounds = so.GetLocalBoundingBox();
                Box3f sb = so.GetBoundingBox(CoordSpace.SceneCoords);
                o.sceneBounds = sb.ToAABB();

                o.curLocalScale = o.localScale;
                o.curSceneFrame = o.sceneFrame;

                objects.Add(o);
            }

            if (false && objects.Count == 1)
            {
                originalDims = objects[0].localBounds;
            }
            else
            {
                originalDims = objects[0].sceneBounds;
                for (int k = 1; k < objects.Count; ++k)
                {
                    originalDims.Contain(objects[k].sceneBounds);
                }
            }
            currentDims   = originalDims;
            sharedOriginS = (Vector3f)originalDims.Point(0, -1, 0);

            initialize_parameters();
        }
Пример #2
0
        virtual public AxisAlignedBox3f GetLocalBoundingBox()
        {
            if (vChildren.Count == 0)
            {
                return(new AxisAlignedBox3f(Vector3f.Zero, 0.5f));
            }
            Box3d combine = vChildren[0].GetBoundingBox(CoordSpace.SceneCoords);

            for (int k = 1; k < vChildren.Count; ++k)
            {
                Box3d childbox = vChildren[k].GetBoundingBox(CoordSpace.SceneCoords);
                combine = Box3d.Merge(ref combine, ref childbox);
            }
            Box3f boxLocal = SceneTransforms.SceneToObject(this, (Box3f)combine);

            return(boxLocal.ToAABB());
        }
Пример #3
0
        public static void RecenterAboveOrigin(FScene scene, SceneObject so, bool bInteractive)
        {
            Frame3f          curFrameO = so.GetLocalFrame(CoordSpace.ObjectCoords);
            AxisAlignedBox3f bounds    = so.GetLocalBoundingBox();
            Box3f            box       = new Box3f(bounds);

            box = curFrameO.FromFrame(ref box);
            AxisAlignedBox3f boundsS = box.ToAABB();

            Vector3f c  = boundsS.Center - 0.5f * boundsS.Height * Vector3f.AxisY;
            Vector3f dt = -c;

            if (dt.MaxAbs > MathUtil.ZeroTolerancef)
            {
                Frame3f           newFrameO = curFrameO.Translated(dt);
                TransformSOChange change    = new TransformSOChange(so, curFrameO, newFrameO, CoordSpace.ObjectCoords);
                scene.History.PushChange(change, false);
                if (bInteractive)
                {
                    scene.History.PushInteractionCheckpoint();
                }
            }
        }