コード例 #1
0
        static PrintMeshSO emit_new_print_mesh(DMesh3 mesh, DMeshSO fromParent)
        {
            PrintMeshSO newSO = new PrintMeshSO();

            newSO.Create(mesh, CCMaterials.PrintMeshMaterial);
            CCActions.AddNewPrintMesh(newSO);
            if (fromParent != null)
            {
                newSO.SetLocalScale(fromParent.GetLocalScale());
                newSO.SetLocalFrame(fromParent.GetLocalFrame(CoordSpace.SceneCoords), CoordSpace.SceneCoords);
            }
            else
            {
                throw new NotImplementedException("have not implemented this path yet...");
                // estimate frame??
            }

            return(newSO);
        }
コード例 #2
0
ファイル: Actions_Scene.cs プロジェクト: tomleetv/Cotangent
        public static void DuplicateSelectedObjects(bool bInteractive)
        {
            List <SceneObject> duplicate = new List <SceneObject>(CC.ActiveScene.Selected);

            foreach (var existingSO in duplicate)
            {
                if (existingSO is PrintMeshSO == false)
                {
                    throw new NotSupportedException("CCActions.DuplicateSelectedObjects: currently can only delete print meshes?");
                }

                PrintMeshSO dupeSO = (existingSO as PrintMeshSO).DuplicateSubtype <PrintMeshSO>();
                dupeSO.Name = UniqueNames.GetNext(existingSO.Name);
                AddNewPrintMesh(dupeSO);

                // If we have multi-select, then we duplicated relative to a transient group that will
                // go away. So, update position using scene coords
                if (existingSO.Parent is FScene == false)
                {
                    var sceneF = existingSO.GetLocalFrame(CoordSpace.SceneCoords);
                    dupeSO.SetLocalFrame(sceneF, CoordSpace.SceneCoords);
                    Vector3f scaleL = existingSO.GetLocalScale();
                    Vector3f scaleS = SceneTransforms.ObjectToSceneV(existingSO, scaleL);
                    float    scale  = scaleS.Length / scaleL.Length;
                    dupeSO.SetLocalScale(scale * Vector3f.One);
                }

                if (dupeSO.CanAutoUpdateFromSource() && dupeSO.AutoUpdateOnSourceFileChange == true)
                {
                    CC.FileMonitor.AddMesh(dupeSO);
                }
            }
            if (bInteractive)
            {
                CC.ActiveScene.History.PushInteractionCheckpoint();
            }
        }