protected override NewPrimitive ConvertCore(SnappedCone snapped) { var result = new NewCone(); result.Axis.Value = snapped.AxisResult; result.TopRadius.Value = snapped.TopRadiusResult; result.BottomRadius.Value = snapped.BottomRadiusResult; result.Length.Value = snapped.LengthResult; result.Center.Value = MathUtils3D.Lerp(snapped.TopCenterResult, snapped.BottomCenterResult, 0.5); return(result); }
public NewConeViewModel( UiState uiState = null, ICurveAssigner curveAssigner = null, IEventAggregator eventAggregator = null, IConstrainedOptimizer optimizer = null) : base(uiState, curveAssigner, eventAggregator, optimizer) { topRadius = 0.2; bottomRadius = 0.2; length = 0.5; axis = MathUtils3D.UnitZ; center = MathUtils3D.Origin; model = new NewCone(); UpdateModel(); }
private Visual3D CreateConeView(NewCone data) { var cylinder = new Cylinder(); cylinder.Bind(Cylinder.Radius1Property, () => data.TopRadius, radius => radius.Value); cylinder.Bind(Cylinder.Radius2Property, () => data.BottomRadius, radius => radius.Value); cylinder.Bind(Cylinder.Point1Property, () => data.Center, () => data.Axis, () => data.Length, (center, axis, length) => center.Value + 0.5 * length.Value * axis.Value.Normalized()); cylinder.Bind(Cylinder.Point2Property, () => data.Center, () => data.Axis, () => data.Length, (center, axis, length) => center.Value - 0.5 * length.Value * axis.Value.Normalized()); cylinder.Material = new DiffuseMaterial { Brush = Brushes.White }; return(cylinder); }
public void Init(NewCone newModel) { this.model = newModel; UpdateFromModel(); }
public NewPrimitive AddNewPrimitive(PrimitiveKinds primitiveKind, LineRange lineRange) { var pos3d = uiState.SketchPlane.PointFromRay(lineRange); if (pos3d != null) { undoHistory.Push(); switch (primitiveKind) { case PrimitiveKinds.Cylinder: var newCylinder = new NewCylinder(); newCylinder.Center.Value = pos3d.Value; newCylinder.Axis.Value = sketchPlane.YAxis; newCylinder.Diameter.Value = 0.2; newCylinder.Length.Value = 0.3; sessionData.NewPrimitives.Add(newCylinder); break; case PrimitiveKinds.Cone: var newCone = new NewCone(); newCone.Center.Value = pos3d.Value; newCone.Axis.Value = sketchPlane.YAxis; newCone.TopRadius.Value = 0.1; newCone.BottomRadius.Value = 0.2; newCone.Length.Value = 0.3; sessionData.NewPrimitives.Add(newCone); break; case PrimitiveKinds.Sphere: var newSphere = new NewSphere(); newSphere.Center.Value = pos3d.Value; newSphere.Radius.Value = 0.2; sessionData.NewPrimitives.Add(newSphere); break; case PrimitiveKinds.SGC: var newSGC = new NewStraightGenCylinder(); newSGC.Center.Value = pos3d.Value; newSGC.Axis.Value = sketchPlane.YAxis; newSGC.Length.Value = 0.3; newSGC.Components = SgcComponents.CreateNonLinear(20, 0.075, 0.05, 0.1); sessionData.NewPrimitives.Add(newSGC); break; case PrimitiveKinds.BGC: var newBGC = new NewBendedGenCylinder(); newBGC.Center.Value = pos3d.Value; newBGC.Axis.Value = sketchPlane.YAxis; newBGC.Length.Value = 0.3; newBGC.Components = BgcComponents.Create(20, 0.075, 0.15, newBGC.Center.Value, newBGC.Axis.Value, newBGC.Length.Value); sessionData.NewPrimitives.Add(newBGC); break; case PrimitiveKinds.Cuboid: var newCuboid = new NewCuboid(); Vector3D H = new Vector3D(0, 1, 0); Vector3D W = new Vector3D(1, 0, 0); Vector3D D = new Vector3D(0, 0, -1); newCuboid.Center.Value = pos3d.Value; newCuboid.H.Value = H; newCuboid.W.Value = W; newCuboid.D.Value = D; newCuboid.Width.Value = 0.3; newCuboid.Height.Value = 0.3; newCuboid.Depth.Value = 0.3; sessionData.NewPrimitives.Add(newCuboid); break; default: Trace.Fail("Invalid primitive kind"); break; } sessionData.NewPrimitives.Last().UpdateCurvesGeometry(); return(sessionData.NewPrimitives.Last()); } else { return(null); } }