Пример #1
0
        public void EndDraw()
        {
            if (preview.Curve.ArcLength > 2 * SamplingRate)
            {
                if (EmitNewCurveF == null)
                {
                    // store undo/redo record for new primitive
                    SOMaterial  mat     = (CurveMaterialF == null) ? scene.DefaultCurveSOMaterial : CurveMaterialF();
                    PolyCurveSO CurveSO = preview.BuildSO(mat, 1.0f);
                    scene.History.PushChange(
                        new AddSOChange()
                    {
                        scene = scene, so = CurveSO, bKeepWorldPosition = false
                    });

                    // link ?
                    if (AttachCurveToSurface)
                    {
                        scene.History.PushChange(
                            new SOAddFrameLinkChangeOp(CurveSO, Target as TransformableSO));
                    }

                    scene.History.PushInteractionCheckpoint();
                }
                else
                {
                    EmitNewCurveF(preview);
                }
            }

            preview.Destroy();
            preview = null;

            //SavedSettings.Save("DrawSurfaceCurveTool_width", width);
        }
Пример #2
0
        public virtual SceneObject BuildPolyCurveSO(FScene scene, TypedAttribSet attributes)
        {
            PolyCurveSO so = new PolyCurveSO();

            so.Create(scene.DefaultSOMaterial);
            RestorePolyCurveSOType(scene, attributes, so);
            return(so);
        }
 public static void EmitPolyCurveSO(SceneSerializer s, IOutputStream o, PolyCurveSO so)
 {
     o.AddAttribute(IOStrings.ASOName, so.Name);
     o.AddAttribute(IOStrings.ASOUuid, so.UUID);
     s.EmitTransform(o, so);
     s.EmitMaterial(o, so.GetAssignedSOMaterial());
     o.AddAttribute(IOStrings.APolyCurve3, so.Curve.Vertices);
     o.AddAttribute(IOStrings.APolyCurveClosed, so.Curve.Closed);
 }
Пример #4
0
        public override SceneObject Duplicate()
        {
            PolyCurveSO copy = new PolyCurveSO();

            copy.Curve = new DCurve3(this.curve);
            copy.Create(this.GetAssignedSOMaterial());
            copy.SetLocalFrame(
                this.GetLocalFrame(CoordSpace.ObjectCoords), CoordSpace.ObjectCoords);
            copy.SetLocalScale(this.GetLocalScale());
            return(copy);
        }
Пример #5
0
 public virtual PolyCurveSO BuildSO(SOMaterial material, float scale = 1.0f)
 {
     return((PolyCurveSO)BuildSO((curveIn) => {
         PolyCurveSO so = new PolyCurveSO()
         {
             Curve = curveIn
         };
         so.Create(material);
         return so;
     }, material, scale));
 }
Пример #6
0
        void project_to_target()
        {
            PolyCurveSO sourceSO = targets[0];
            DCurve3     curve    = sourceSO.Curve;
            int         N        = curve.VertexCount;

            for (int i = 0; i < N; ++i)
            {
                Vector3f v  = (Vector3f)curve[i];
                Vector3f vW = SceneTransforms.TransformTo(v, sourceSO, CoordSpace.ObjectCoords, CoordSpace.WorldCoords);
                vW       = (Vector3f)ProjectionTarget.Project(vW);
                curve[i] = SceneTransforms.TransformTo(vW, sourceSO, CoordSpace.WorldCoords, CoordSpace.ObjectCoords);
            }
        }
Пример #7
0
        public virtual void EndDraw()
        {
            in_draw = false;
            if (preview == null)
            {
                return;
            }
            if (preview.Curve.VertexCount > 2 && preview.Curve.ArcLength > 2 * SamplingRateScene)
            {
                // update Closed state because in some cases we change this during drawing
                // (ie when drawing multi-point curve, but closing at end)
                preview.Closed = this.Closed;

                if (EmitNewCurveF == null)
                {
                    // store undo/redo record for new primitive
                    SOMaterial  mat     = (CurveMaterialF == null) ? Scene.DefaultCurveSOMaterial : CurveMaterialF();
                    PolyCurveSO CurveSO = preview.BuildSO(mat, 1.0f);
                    Scene.History.PushChange(
                        new AddSOChange()
                    {
                        scene = Scene, so = CurveSO, bKeepWorldPosition = false
                    });

                    // link ?
                    if (AttachCurveToSurface)
                    {
                        Scene.History.PushChange(
                            new SOAddFrameLinkChangeOp(CurveSO, Target));
                    }

                    Scene.History.PushInteractionCheckpoint();
                }
                else
                {
                    EmitNewCurveF(preview);
                }
            }

            preview.Destroy();
            preview = null;

            //SavedSettings.Save("DrawSurfaceCurveTool_width", width);
        }
Пример #8
0
        public virtual SceneObject BuildPolyCurveSO(FScene scene, TypedAttribSet attributes)
        {
            PolyCurveSO so = new PolyCurveSO();

            so.Create(scene.DefaultSOMaterial);
            safe_set_property_s(attributes, IOStrings.ASOName, (s) => { so.Name = s; });
            RestoreTransform(so, attributes);
            RestoreMaterial(so, attributes);

            if (check_key_or_debug_print(attributes, IOStrings.APolyCurve3))
            {
                VectorArray3d v = attributes[IOStrings.APolyCurve3] as VectorArray3d;
                so.Curve.SetVertices(v);
            }
            if (check_key_or_debug_print(attributes, IOStrings.APolyCurveClosed))
            {
                so.Curve.Closed = (bool)attributes[IOStrings.APolyCurveClosed];
            }

            return(so);
        }
 public static void Emit(this SceneSerializer s, IOutputStream o, PolyCurveSO so)
 {
     o.AddAttribute(IOStrings.ASOType, IOStrings.TypePolyCurve);
     EmitPolyCurveSO(s, o, so);
 }
Пример #10
0
        public virtual void RestorePolyCurveSOType(FScene scene, TypedAttribSet attributes, PolyCurveSO so)
        {
            RestoreSOInfo(so, attributes);
            RestoreTransform(so, attributes);
            RestoreMaterial(so, attributes);

            if (check_key_or_debug_print(attributes, IOStrings.APolyCurve3))
            {
                VectorArray3d v = attributes[IOStrings.APolyCurve3] as VectorArray3d;
                so.Curve.SetVertices(v);
            }
            if (check_key_or_debug_print(attributes, IOStrings.APolyCurveClosed))
            {
                so.Curve.Closed = (bool)attributes[IOStrings.APolyCurveClosed];
            }
        }