Пример #1
0
        /// <summary>
        /// adds an expand/contract-type plane/leg intersection thing at the given frame
        /// </summary>
        public static void EmitPlaneBandExpansionFromTool(SceneObject targetLegSO, Frame3f planeFrameS)
        {
            PlaneIntersectionCurveSO curveSO = PlaneIntersectionCurveSO.CreateFromPlane(
                targetLegSO as DMeshSO, planeFrameS, OrthogenMaterials.PlaneCurveMaterial,
                targetLegSO.GetScene(), OrthogenUI.CurveOnSurfaceOffsetTol);

            AddNewPlaneBandExpansion(curveSO);

            // [RMS] this is called at end
            OG.Context.RegisterNextFrameAction(() => {
                OG.Scene.Select(curveSO, true);
            });
        }
Пример #2
0
        /// <summary>
        /// adds an expand/contract-type plane/leg intersection thing to the datamodel
        /// </summary>
        public static ModelingOperator AddNewPlaneBandExpansion(PlaneIntersectionCurveSO curveSO)
        {
            curveSO.AssignSOMaterial(OrthogenMaterials.PlaneCurveMaterial);
            curveSO.Name = "PlaneBandExpansion";
            curveSO.RootGameObject.SetLayer(OrthogenMaterials.CurvesLayer);

            // create and associate deformation op
            var deformOp = OG.Leg.AppendPlaneBandExpansion(curveSO);

            OG.Model.RegisterDeleteSOAction(curveSO, MakeDeleteLegDeformationAction(deformOp));
            OG.Model.RegisterSelectSOAction(curveSO, MakeSelectLegDeformationAction(deformOp));

            return(deformOp);
        }
Пример #3
0
        /// <summary>
        /// adds an expand/contract-type plane/leg intersection thing at the given frame
        /// </summary>
        public static void EmitOffsetBandFromTool(SceneObject targetLegSO, Frame3f startFrameS, Frame3f endFrameS)
        {
            Frame3f midFrame = new Frame3f((startFrameS.Origin + endFrameS.Origin) * 0.5f);
            PlaneIntersectionCurveSO curveSO = PlaneIntersectionCurveSO.CreateFromPlane(
                targetLegSO as DMeshSO, midFrame, OrthogenMaterials.PlaneCurveMaterial,
                targetLegSO.GetScene(), OrthogenUI.CurveOnSurfaceOffsetTol);

            curveSO.Name = "PlaneBandExpansion";
            curveSO.RootGameObject.SetLayer(OrthogenMaterials.CurvesLayer);

            // create and associate deformation op
            PlaneBandExpansionOp deformOp = OG.Leg.AppendPlaneBandExpansion(curveSO) as PlaneBandExpansionOp;

            deformOp.BandDistance = startFrameS.Origin.Distance(endFrameS.Origin) * 0.5;


            OG.Model.RegisterDeleteSOAction(curveSO, MakeDeleteLegDeformationAction(deformOp));
            OG.Model.RegisterSelectSOAction(curveSO, MakeSelectLegDeformationAction(deformOp));

            // [RMS] this is called at end
            OG.Context.RegisterNextFrameAction(() => {
                OG.Scene.Select(curveSO, true);
            });
        }
Пример #4
0
        /// <summary>
        /// parse the DataModel section of the save file, and restore the scene/datamodel as necessary
        /// </summary>
        /// <param name="xml"></param>
        protected virtual void RestoreDataModel(XmlDocument xml)
        {
            // look up root datamodel (should only be one)
            XmlNodeList datamodels = xml.SelectNodes("//DataModel");
            XmlNode     datamodel  = datamodels[0];


            // find scan
            ScanSO scanSO = OG.Scene.FindSceneObjectsOfType <ScanSO>().FirstOrDefault();

            if (scanSO == null)
            {
                throw new Exception("OGSerializer.RestoreDataModel: no ScanSO?");
            }

            // [TODO] we have scanIn and scanOut, don't we?!?
            // start in scan state, restore the scan
            OGActions.RestoreSocketDesignFromScan(OG.Context, scanSO);


            // [TODO] should only do this transition if user has accepted scan
            //    (probably should have some current-state field in datamodel)
            OG.TransitionToState(RectifyState.Identifier);


            // restore LegModel deformation ops
            XmlNodeList deformationOps = datamodel.SelectNodes("LegDeformOp");

            foreach (XmlNode opNode in deformationOps)
            {
                string type    = opNode.Attributes["OpType"].InnerText;
                string so_uuid = opNode.Attributes["SceneObjectUUID"].InnerText;

                if (type == typeof(EnclosedRegionOffsetOp).ToString())
                {
                    EnclosedPatchSO patchSO = OG.Scene.FindByUUID(so_uuid) as EnclosedPatchSO;
                    var             newOp   = OGActions.AddNewRegionDeformation(patchSO, LegModel.LegDeformationTypes.Offset);
                    double          offset  = 0.0f;
                    if (double.TryParse(opNode.Attributes["Offset"].InnerText, out offset))
                    {
                        (newOp as EnclosedRegionOffsetOp).PushPullDistance = offset;
                    }
                }
                else if (type == typeof(EnclosedRegionSmoothOp).ToString())
                {
                    EnclosedPatchSO patchSO = OG.Scene.FindByUUID(so_uuid) as EnclosedPatchSO;
                    var             newOp   = OGActions.AddNewRegionDeformation(patchSO, LegModel.LegDeformationTypes.Smooth);
                    double          smooth  = 0.0f;
                    if (double.TryParse(opNode.Attributes["Smooth"].InnerText, out smooth))
                    {
                        (newOp as EnclosedRegionSmoothOp).SmoothAlpha = smooth;
                    }
                    double offset = 0.0f;
                    if (double.TryParse(opNode.Attributes["Offset"].InnerText, out offset))
                    {
                        (newOp as EnclosedRegionSmoothOp).OffsetDistance = offset;
                    }
                }
                else if (type == typeof(PlaneBandExpansionOp).ToString())
                {
                    PlaneIntersectionCurveSO curveSO = OG.Scene.FindByUUID(so_uuid) as PlaneIntersectionCurveSO;
                    var    newOp  = OGActions.AddNewPlaneBandExpansion(curveSO);
                    double extent = 0.0f;
                    if (double.TryParse(opNode.Attributes["Extent"].InnerText, out extent))
                    {
                        (newOp as PlaneBandExpansionOp).BandDistance = extent;
                    }
                    double offset = 0.0f;
                    if (double.TryParse(opNode.Attributes["Offset"].InnerText, out offset))
                    {
                        (newOp as PlaneBandExpansionOp).PushPullDistance = offset;
                    }
                    Vector3d origin = TryParseVector3(opNode.Attributes["Origin"].InnerText);
                    (newOp as PlaneBandExpansionOp).Origin = origin;
                    Vector3d normal = TryParseVector3(opNode.Attributes["Normal"].InnerText);
                    (newOp as PlaneBandExpansionOp).Normal = normal;
                }
                else if (type == typeof(LengthenOp).ToString())
                {
                    LengthenPivotSO pivotSO = OG.Scene.FindByUUID(so_uuid) as LengthenPivotSO;
                    LengthenOp      newOp   = OGActions.AddNewLengthenOp(pivotSO);
                    double          offset  = 0.0f;
                    if (double.TryParse(opNode.Attributes["Distance"].InnerText, out offset))
                    {
                        newOp.LengthenDistance = offset;
                    }
                }
            }


            // if we have a trimloop, restore it
            TrimLoopSO trimSO = OG.Scene.FindSceneObjectsOfType <TrimLoopSO>().FirstOrDefault();

            if (trimSO != null)
            {
                OG.TransitionToState(SocketDesignState.Identifier);
                OGActions.AddNewTrimCurve(trimSO);
            }

            // [TODO] restore socket enabled, parameters, etc
        }