private void AdjustChildSize(object sender, EventArgs e) { if (Children.Count > 0) { var aabb = UntransformedChildren.GetAxisAlignedBoundingBox(); ItemWithTransform.Matrix = Matrix4X4.Identity; var scale = Vector3.One; if (StretchZ) { scale.Z = SizeZ / aabb.ZSize; } ItemWithTransform.Matrix = ItemWithTransform.Matrix.ApplyAtPosition(aabb.Center, Matrix4X4.CreateScale(scale)); Matrix4X4 centering; if (AlternateCentering) { centering = GetCenteringTransformVisualCenter(UntransformedChildren, Diameter / 2); } else { centering = GetCenteringTransformExpandedToRadius(UntransformedChildren, Diameter / 2); } ItemWithTransform.Matrix = ItemWithTransform.Matrix.ApplyAtPosition(aabb.Center, centering); } }
public override void WrapItems(IEnumerable <IObject3D> items, UndoBuffer undoBuffer = null) { base.WrapItems(items, undoBuffer); // use source item as the wrapper may have cloned it var aabb = UntransformedChildren.GetAxisAlignedBoundingBox(); this.RotateAbout.Origin = aabb.Center; }
public override void WrapSelectedItemAndSelect(InteractiveScene scene) { base.WrapSelectedItemAndSelect(scene); // use source item as the wrapper may have cloned it var aabb = UntransformedChildren.GetAxisAlignedBoundingBox(); this.RotateAbout.Origin = aabb.Center; }
public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw) { if (layer.Scene.SelectedItem != null && layer.Scene.SelectedItem.DescendantsAndSelf().Where((i) => i == this).Any()) { var aabb = UntransformedChildren.GetAxisAlignedBoundingBox(); layer.World.RenderCylinderOutline(this.WorldMatrix(), aabb.Center, Diameter, aabb.ZSize, 30, Color.Red, 1, 1); } }
public override void WrapItems(IEnumerable <IObject3D> items, UndoBuffer undoBuffer = null) { base.WrapItems(items, undoBuffer); // use source item as it may be a copy of item by the time we have wrapped it var aabb = UntransformedChildren.GetAxisAlignedBoundingBox(); var newCenter = new Vector3(aabb.Center.X, aabb.Center.Y, aabb.MinXYZ.Z); UntransformedChildren.Translate(-newCenter); this.Translate(newCenter); }
public override void WrapSelectedItemAndSelect(InteractiveScene scene) { base.WrapSelectedItemAndSelect(scene); // use source item as it may be a copy of item by the time we have wrapped it var aabb = UntransformedChildren.GetAxisAlignedBoundingBox(); var newCenter = new Vector3(aabb.Center.X, aabb.Center.Y, aabb.MinXYZ.Z); UntransformedChildren.Translate(-newCenter); this.Translate(newCenter); }
private void AdjustChildSize(object sender, EventArgs e) { if (Children.Count > 0) { var aabb = UntransformedChildren.GetAxisAlignedBoundingBox(); ItemWithTransform.Matrix = Matrix4X4.Identity; var scale = Vector3.One; var width = Width.Value(this); var depth = Depth.Value(this); var height = Height.Value(this); if (StretchX) { scale.X = width / aabb.XSize; } if (StretchY) { scale.Y = depth / aabb.YSize; } if (StretchZ) { scale.Z = height / aabb.ZSize; } switch (LockProportion) { case LockProportions.None: break; case LockProportions.X_Y: var minXy = Math.Min(scale.X, scale.Y); scale.X = minXy; scale.Y = minXy; break; case LockProportions.X_Y_Z: var minXyz = Math.Min(Math.Min(scale.X, scale.Y), scale.Z); scale.X = minXyz; scale.Y = minXyz; scale.Z = minXyz; break; } if (aabb.XSize > 0 && aabb.YSize > 0 && aabb.ZSize > 0) { ItemWithTransform.Matrix = Object3DExtensions.ApplyAtPosition(ItemWithTransform.Matrix, aabb.Center, Matrix4X4.CreateScale(scale)); } } }
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { var aabb = UntransformedChildren.GetAxisAlignedBoundingBox(); var center = aabb.Center; var worldMatrix = this.WorldMatrix(); var width = Width.Value(this); var depth = Depth.Value(this); var height = Height.Value(this); var minXyz = center - new Vector3(width / 2, depth / 2, height / 2); var maxXyz = center + new Vector3(width / 2, depth / 2, height / 2); var bounds = new AxisAlignedBoundingBox(minXyz, maxXyz); layer.World.RenderAabb(bounds, worldMatrix, Color.Red, 1, 1); }
private void AdjustChildSize(object sender, EventArgs e) { if (Children.Count > 0) { var aabb = UntransformedChildren.GetAxisAlignedBoundingBox(); ItemWithTransform.Matrix = Matrix4X4.Identity; var scale = Vector3.One; if (StretchZ) { scale.Z = SizeZ / aabb.ZSize; } var minXy = Math.Min(scale.X, scale.Y); scale.X = minXy; scale.Y = minXy; ItemWithTransform.Matrix = Object3DExtensions.ApplyAtPosition(ItemWithTransform.Matrix, aabb.Center, Matrix4X4.CreateScale(scale)); } }