private void OnItemAdd(object sender, EventArgs e) { BoxPosition bPosNew = new BoxPosition(new Vector3D(PtMin.X, PtMin.Y, 0.0), HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); if (!BoxInteraction.HaveIntersection(Layer.Positions, Dimensions, SelectedIndex, bPosNew)) { Layer.AddPosition(bPosNew); SelectedIndex = Layer.Positions.Count - 1; Invalidate(); } else { MessageBox.Show(Resources.ID_CANNOTADD); } }
public Box(uint pickId, BundleProperties bundleProperties) { // dimensions PickId = pickId; _dim[0] = bundleProperties.Length; _dim[1] = bundleProperties.Width; _dim[2] = bundleProperties.Height; // box position BoxPosition = new BoxPosition(Vector3D.Zero, HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); // colors Colors = Enumerable.Repeat <Color>(bundleProperties.Color, 6).ToArray(); // specific BundleFlats = bundleProperties.NoFlats; IsBundle = bundleProperties.IsBundle; }
protected void update_labels() { AxisAlignedBox2f localBounds = BoxModel.LocalBounds(this); foreach (var pair in Labels) { float t = (float)(pair.Key); PositionLabel labelinfo = pair.Value; if (labelinfo.go == null) { BoxPosition boxPos = BoxPosition.CenterTop; if (labelinfo.position == LabelPositionType.CenteredAbove) { boxPos = BoxPosition.CenterBottom; } else if (labelinfo.position == LabelPositionType.BelowLeftAligned) { boxPos = BoxPosition.TopLeft; } else if (labelinfo.position == LabelPositionType.BelowRightAligned) { boxPos = BoxPosition.TopRight; } labelinfo.go = GameObjectFactory.CreateTextMeshGO("sliderlabel_" + labelinfo.text, labelinfo.text, labelinfo.color, LabelTextHeight, boxPos); AppendNewGO(labelinfo.go, rootGO, false); } if (labelinfo.position == LabelPositionType.CenteredBelow || labelinfo.position == LabelPositionType.BelowLeftAligned || labelinfo.position == LabelPositionType.BelowRightAligned) { BoxModel.MoveTo(labelinfo.go, localBounds.BottomLeft, -Height * 0.01f); } else if (labelinfo.position == LabelPositionType.CenteredAbove) { BoxModel.MoveTo(labelinfo.go, localBounds.TopLeft, -Height * 0.01f); } else { throw new NotSupportedException("HUDSliderBase.update_labels : unhandled LabelPositionType"); } BoxModel.Translate(labelinfo.go, new Vector2f(t * Width, 0) + labelinfo.offset); } }
public Box(uint pickId, PackableBrick packable, BoxPosition bPosition) : base(pickId, packable.Length, packable.Width, packable.Height, bPosition) { // colors Colors = Enumerable.Repeat(Color.Chocolate, 6).ToArray(); if (packable is PackProperties) { } else { BProperties bProperties = PackableToBProperties(packable); if (null == bProperties) { throw new Exception(string.Format("Type {0} cannot be handled by Box constructor", packable.GetType().ToString())); } Colors = bProperties.Colors; IsBundle = bProperties.IsBundle; // is box ? if (bProperties is BoxProperties boxProperties) { List <Pair <HalfAxis.HAxis, Texture> > textures = boxProperties.TextureList; foreach (Pair <HalfAxis.HAxis, Texture> tex in textures) { int iIndex = (int)tex.first; if (null == TextureLists[iIndex]) { TextureLists[iIndex] = new List <Texture>(); } TextureLists[iIndex].Add(tex.second); } TapeWidth = boxProperties.TapeWidth; TapeColor = boxProperties.TapeColor; } // is bundle ? else if (bProperties.IsBundle) { if (bProperties is BundleProperties bundleProp) { BundleFlats = bundleProp.NoFlats; } } } if (packable is PackableBrickNamed packableBrickNamed) { StrapperList = new List <PalletStrapper>(packableBrickNamed.StrapperSet.Strappers); } }
// creates a button in the desired geometry shape public void Create() { entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDLabel")); bgMesh = AppendMeshGO("background", HUDUtil.MakeBackgroundMesh(Shape), MaterialUtil.CreateFlatMaterialF(BackgroundColor), entry); bgMesh.RotateD(Vector3f.AxisX, -90.0f); if (EnableBorder) { HUDShape borderShape = Shape; borderShape.Radius += BorderWidth; borderShape.Height += 2 * BorderWidth; borderShape.Width += 2 * BorderWidth; border = AppendMeshGO("border", HUDUtil.MakeBackgroundMesh(borderShape), MaterialUtil.CreateFlatMaterialF(BorderColor), entry); border.RotateD(Vector3f.AxisX, -90.0f); border.Translate(-0.001f * Vector3f.AxisY, true); } BoxPosition horzAlign = BoxPosition.CenterLeft; if (AlignmentHorz == HorizontalAlignment.Center) { horzAlign = BoxPosition.Center; } else if (AlignmentHorz == HorizontalAlignment.Right) { horzAlign = BoxPosition.CenterRight; } textMesh = GameObjectFactory.CreateTextMeshGO( "text", Text, TextColor, TextHeight, horzAlign, SceneGraphConfig.TextLabelZOffset); textMesh.TextObject.SetFixedWidth(Shape.Width); textMesh.TextObject.SetOverflowMode(TextOverflowMode.Ellipses); Vector2f toPos = BoxModel.GetBoxPosition(this, horzAlign); BoxModel.Translate(textMesh, Vector2f.Zero, toPos); AppendNewGO(textMesh, entry, false); MaterialUtil.DisableShadows(RootGameObject); }
public Box(uint pickId, PackProperties packProperties, BoxPosition bPosition) { // sanity checks CheckPosition(bPosition); // dimensions _pickId = pickId; _dim[0] = packProperties.Length; _dim[1] = packProperties.Width; _dim[2] = packProperties.Height; // box position _boxPosition = new BoxPosition(Vector3D.Zero, HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); // colors _colors = Enumerable.Repeat <Color>(Color.Chocolate, 6).ToArray(); // set position _boxPosition = bPosition; }
public static BoxPosition ToTop(BoxPosition p) { if (p == BoxPosition.BottomLeft || p == BoxPosition.CenterLeft) { return(BoxPosition.TopLeft); } else if (p == BoxPosition.CenterBottom || p == BoxPosition.Center) { return(BoxPosition.CenterTop); } else if (p == BoxPosition.BottomRight || p == BoxPosition.CenterRight) { return(BoxPosition.TopRight); } return(p); }
public Box(uint pickId, PackableBrick packable, LayerPosition bPosition) { // sanity checks CheckPosition(bPosition); // dimensions PickId = pickId; _dim[0] = packable.Length; _dim[1] = packable.Width; _dim[2] = packable.Height; // set position BoxPosition = new BoxPosition(bPosition.Position, bPosition.LengthAxis, bPosition.WidthAxis); // colors Colors = Enumerable.Repeat(Color.Chocolate, 6).ToArray(); BProperties bProperties = PackableToBProperties(packable); if (null != bProperties) { Colors = bProperties.Colors; if (bProperties is BoxProperties boxProperties) { List <Pair <HalfAxis.HAxis, Texture> > textures = boxProperties.TextureList; foreach (Pair <HalfAxis.HAxis, Texture> tex in textures) { int iIndex = (int)tex.first; if (null == TextureLists[iIndex]) { TextureLists[iIndex] = new List <Texture>(); } TextureLists[iIndex].Add(tex.second); } TapeWidth = boxProperties.TapeWidth; TapeColor = boxProperties.TapeColor; } // IsBundle ? IsBundle = bProperties.IsBundle; if (packable is BundleProperties bundleProp) { BundleFlats = bundleProp.NoFlats; } } if (packable is PackableBrickNamed packableBrickNamed) { StrapperList = new List <Strapper>(packableBrickNamed.StrapperSet.Strappers); } }
public Box(uint pickId, double length, double width, double height, BoxPosition boxPosition) : base(pickId, length, width, height, boxPosition) { // colors & textures Colors = new Color[6]; Colors[0] = Color.Red; Colors[1] = Color.Red; Colors[2] = Color.Green; Colors[3] = Color.Green; Colors[4] = Color.Blue; Colors[5] = Color.Blue; for (int i = 0; i < 6; ++i) { TextureLists[i] = null; } }
private void OnMouseDown(object sender, MouseEventArgs e) { foreach (var item in ArrowButtons) { if (item.Value.Contains(e.Location)) { StartMove(item.Key); return; } } if (null != _rotateRectangle && _rotateRectangle.Contains(e.Location)) { BoxPosition pos = Layer.Positions[SelectedIndex].RotateZ90(Dimensions); Layer.Positions[SelectedIndex] = pos; Moving = true; } }
public Box(uint pickId, PackProperties packProperties, BoxPosition bPosition) { // sanity checks CheckPosition(bPosition); // dimensions PickId = pickId; _dim[0] = packProperties.Length; _dim[1] = packProperties.Width; _dim[2] = packProperties.Height; // box position BoxPosition = new BoxPosition(Vector3D.Zero, HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); // colors Colors = Enumerable.Repeat(Color.Chocolate, 6).ToArray(); // set position BoxPosition = bPosition; // stappers StrapperList = new List <Strapper>(packProperties.StrapperSet.Strappers); }
public Box(uint pickId, InterlayerProperties interlayerProperties, BoxPosition bPosition) { _pickId = pickId; _dim[0] = interlayerProperties.Length; _dim[1] = interlayerProperties.Width; _dim[2] = interlayerProperties.Thickness; _colors = new Color[6]; for (int i = 0; i < 6; ++i) { _colors[i] = interlayerProperties.Color; } // set position Position = bPosition.Position; // set direction length LengthAxis = HalfAxis.ToVector3D(bPosition.DirectionLength); // set direction width WidthAxis = HalfAxis.ToVector3D(bPosition.DirectionWidth); }
public Pack(uint pickId, PackProperties packProperties, BoxPosition position) : base(pickId, packProperties, position) { _packProperties = packProperties; _arrangement = _packProperties.Arrangement; if (packProperties.Content is PackableBrick boxProperties) { _innerBox = new Box(0, boxProperties); } else if (packProperties.Content is CylinderProperties cylProp) { _innerBox = new Cylinder(0, cylProp); } else if (packProperties.Content is BottleProperties bottleProp) { _innerBox = new Bottle(0, bottleProp); } ForceTransparency = false; }
public void MoveMax(HalfAxis.HAxis moveDir) { // sanity check if (!IsSelectionValid) { return; } // update position BoxPosition bpos = Positions[SelectedIndex]; double distance = 0; if (BoxInteraction.MinDistance(Positions, DimCase, SelectedIndex, moveDir, ref distance)) { } if (distance > 0) { Positions[SelectedIndex] = bpos.Translate(moveDir, distance); } ; }
public Box(uint pickId, PackProperties packProperties, BoxPosition bPosition) { if (!bPosition.IsValid) { throw new GraphicsException("Invalid BoxPosition: can not create box"); } _pickId = pickId; _dim[0] = packProperties.Length; _dim[1] = packProperties.Width; _dim[2] = packProperties.Height; _colors = Enumerable.Repeat <Color>(Color.Chocolate, 6).ToArray(); // set position Position = bPosition.Position; // set direction length LengthAxis = HalfAxis.ToVector3D(bPosition.DirectionLength); // set direction width WidthAxis = HalfAxis.ToVector3D(bPosition.DirectionWidth); }
public override void OnDrawResizeHandleShape(Graphics gfx, BoxPosition handle, Node node, RectangleF rectHandle) { using (Pen pen = new Pen(Color.FromArgb(68, 108, 157))) { pen.Width = 1f / gfx.PageScale; pen.DashStyle = DashStyle.Solid; pen.Color = Color.FromArgb(77, 115, 153); // Create brush to fill PinPoint interiors using (Brush brush = new SolidBrush(Color.FromArgb(99, 154, 231))) { using (GraphicsPath gp = PathFactory.CreateEllipse(rectHandle)) { gfx.FillPath(brush, gp); // Outline handle gfx.DrawPath(pen, gp); } } } }
private bool CuboidToSolItem(List <ContentItem> contentItems, Vector3D offset, Cuboid cuboid, out int index, out BoxPosition pos) { index = 0; pos = BoxPosition.Zero; try { index = int.Parse(cuboid.Tag.ToString()); BoxProperties bProperties = IDToBox((uint)index); pos = BoxPosition.FromPositionDimension( new Vector3D((double)cuboid.X, (double)cuboid.Y, (double)cuboid.Z) + offset, new Vector3D((double)cuboid.Width, (double)cuboid.Height, (double)cuboid.Depth), new Vector3D(bProperties.Length, bProperties.Width, bProperties.Height) ); return(true); } catch (Exception ex) { _log.Error(ex.Message); } return(false); }
public Box(uint pickId, double length, double width, double height, BoxPosition boxPosition) { _pickId = pickId; // dimensions _dim[0] = length; _dim[1] = width; _dim[2] = height; // box position _boxPosition = boxPosition; // colors & textures _colors = new Color[6]; _colors[0] = Color.Red; _colors[1] = Color.Red; _colors[2] = Color.Green; _colors[3] = Color.Green; _colors[4] = Color.Blue; _colors[5] = Color.Blue; for (int i = 0; i < 6; ++i) { _textureLists[i] = null; } }
public Box(uint pickId, double length, double width, double height) { PickId = pickId; // dimensions _dim[0] = length; _dim[1] = width; _dim[2] = height; // box position BoxPosition = new BoxPosition(Vector3D.Zero); // colors & texturezs Colors = new Color[6]; Colors[0] = Color.Red; Colors[1] = Color.Red; Colors[2] = Color.Green; Colors[3] = Color.Green; Colors[4] = Color.Blue; Colors[5] = Color.Blue; for (int i = 0; i < 6; ++i) { TextureLists[i] = null; } }
/// <summary> /// Returns a point orthogonal to the two endpoints of the line. /// </summary> /// <param name="ptBegin"></param> /// <param name="ptEnd"></param> /// <param name="row">Row number of point to calculate</param> /// <param name="col">Column number of point to calculate</param> /// <param name="padLeft"></param> /// <param name="padRight"></param> /// <param name="padTop"></param> /// <param name="padBottom"></param> /// <returns>A logical point that is orthogonal to the two line endpoints</returns> /// <remarks> /// The row and column are used to index a 5x5 matrix of points that /// surround the two endpoints. All of the points in the matrix are orthogonal /// to the endpoints. The matrix can be thought of as two rectangles and a /// point in the center. The outer rectangle contains 16 points and the inner /// rectangle contains 8 points (16+8+1=25). The endpoints always lie in /// either the 2nd or 4th column and the 2nd or 4th row. In other words, the /// endpoints are always two of the four corners of the inner rectangle. The /// outer rectangle is calculated by inflating the inner rectangle using the /// padding value passed in. /// </remarks> public static PointF GetOrthogonalPoint(PointF ptBegin, PointF ptEnd, int row, int col, float padLeft, float padRight, float padTop, float padBottom) { PointF orthogonalPt = new PointF(0, 0); RectangleF rcInner = Geometry.CreateRect(ptBegin, ptEnd); float outerLeft = rcInner.Left - padLeft; float outerTop = rcInner.Top - padTop; float outerWidth = rcInner.Width + padLeft + padRight; float outerHeight = rcInner.Height + padTop + padBottom; RectangleF rcOuter = new RectangleF(outerLeft, outerTop, outerWidth, outerHeight); RectangleF rcOuterHorz = new RectangleF(outerLeft, rcInner.Top, outerWidth, rcInner.Height); RectangleF rcOuterVert = new RectangleF(rcInner.Left, outerTop, rcInner.Width, outerHeight); BoxPosition ctlPt = Geometry.orthogonalCtlPts[row, col]; if ((row < 1 || row > 3) && (col < 1 || col > 3)) { // One of the outer corners orthogonalPt = Geometry.GetAnchorPoint(rcOuter, ctlPt); } else if (row < 1 || row > 3) { // Top or bottom row orthogonalPt = Geometry.GetAnchorPoint(rcOuterVert, ctlPt); } else if (col < 1 || col > 3) { // Left or right column orthogonalPt = Geometry.GetAnchorPoint(rcOuterHorz, ctlPt); } else { // Inner rectangle orthogonalPt = Geometry.GetAnchorPoint(rcInner, ctlPt); } return(orthogonalPt); }
private bool CuboidToSolItem(List <ContentItem> contentItems, Vector3D offset, Cuboid cuboid, out int index, out BoxPosition pos) { index = 0; pos = BoxPosition.Zero; if (cuboid.Tag is BoxProperties bProperties) { try { index = contentItems.FindIndex(ci => ci.MatchDimensions((double)cuboid.Width, (double)cuboid.Depth, (double)cuboid.Height)); pos = BoxPosition.FromPositionDimension( new Vector3D((double)cuboid.X, (double)cuboid.Y, (double)cuboid.Z) + offset, new Vector3D((double)cuboid.Width, (double)cuboid.Height, (double)cuboid.Depth), new Vector3D(bProperties.Length, bProperties.Width, bProperties.Height) ); return(true); } catch (Exception ex) { _log.Error(ex.Message); } } return(false); }
// creates a button in the desired geometry shape public void Create() { entry = new GameObject(UniqueNames.GetNext("HUDTextEntry")); Mesh mesh = MeshGenerators.CreateTrivialRect(Width, Height, MeshGenerators.UVRegionType.FullUVSquare); backgroundMaterial = MaterialUtil.CreateFlatMaterialF(BackgroundColor); activeBackgroundMaterial = MaterialUtil.CreateFlatMaterialF(ActiveBackgroundColor); bgMesh = AppendMeshGO("background", mesh, backgroundMaterial, entry); bgMesh.transform.Rotate(Vector3.right, -90.0f); // ?? BoxPosition horzAlign = BoxPosition.CenterLeft; if (AlignmentHorz == HorizontalAlignment.Center) { horzAlign = BoxPosition.Center; } else if (AlignmentHorz == HorizontalAlignment.Right) { horzAlign = BoxPosition.CenterRight; } textMesh = GameObjectFactory.CreateTextMeshGO( "text", Text, TextColor, TextHeight, horzAlign, SceneGraphConfig.TextLabelZOffset); Vector2f toPos = BoxModel.GetBoxPosition(this, horzAlign); BoxModel.Translate(textMesh, Vector2f.Zero, toPos); AppendNewGO(textMesh, entry, false); cursor = GameObjectFactory.CreateRectangleGO("cursor", Height * 0.1f, Height * 0.8f, Colorf.VideoBlack, false); BoxModel.Translate(cursor, Vector2f.Zero, this.Bounds2D.CenterLeft, -Height * 0.1f); cursor.RotateD(Vector3f.AxisX, -90.0f); AppendNewGO(cursor, entry, false); cursor.SetVisible(false); }
private List <PackPalletSolution> GenerateSolutions() { List <PackPalletSolution> solutions = new List <PackPalletSolution>(); HalfAxis.HAxis[] axes = { HalfAxis.HAxis.AXIS_Z_N, HalfAxis.HAxis.AXIS_Z_P }; // loop throught all patterns foreach (LayerPattern pattern in _patterns) { // loop throught all axes foreach (HalfAxis.HAxis axis in axes) // axis { // loop through Layer layer = new Layer(_packProperties, _palletProperties, _constraintSet, axis, false); double actualLength = 0.0, actualWidth = 0.0; if (!pattern.GetLayerDimensionsChecked(layer, out actualLength, out actualWidth)) { continue; } pattern.GenerateLayer(layer, actualLength, actualWidth); // filter by layer weight if (_constraintSet.MaximumLayerWeight.Activated && (layer.Count * _packProperties.Weight > _constraintSet.MaximumLayerWeight.Value)) { continue; } // filter by maximum space if (_constraintSet.MaximumSpaceAllowed.Activated && layer.MaximumSpace > _constraintSet.MaximumSpaceAllowed.Value) { continue; } double layerHeight = layer.BoxHeight; string title = string.Format("{0}-{1}", pattern.Name, axis.ToString()); double zLayer = 0.0; BoxLayer boxLayer = new BoxLayer(zLayer, ""); foreach (LayerPosition layerPos in layer) { LayerPosition layerPosTemp = AdjustLayerPosition(layerPos); BoxPosition boxPos = new BoxPosition( layerPosTemp.Position - (0.5 * _constraintSet.OverhangX) * Vector3D.XAxis - (0.5 * _constraintSet.OverhangY) * Vector3D.YAxis + zLayer * Vector3D.ZAxis , layerPosTemp.LengthAxis , layerPosTemp.WidthAxis ); boxLayer.Add(boxPos); } boxLayer.MaximumSpace = layer.MaximumSpace; BBox3D layerBBox = boxLayer.BoundingBox(_packProperties); // filter by overhangX if (_constraintSet.MinOverhangX.Activated && (0.5 * (layerBBox.Length - _palletProperties.Length) < _constraintSet.MinOverhangX.Value)) { continue; } // filter by overhangY if (_constraintSet.MinOverhangY.Activated && (0.5 * (layerBBox.Width - _palletProperties.Width) < _constraintSet.MinOverhangY.Value)) { continue; } double interlayerThickness = null != _interlayerProperties ? _interlayerProperties.Thickness : 0; double interlayerWeight = null != _interlayerProperties ? _interlayerProperties.Weight : 0; PackPalletSolution sol = new PackPalletSolution(null, title, boxLayer); int noLayer = 1, noInterlayer = (null != _interlayerProperties && _constraintSet.HasFirstInterlayer) ? 1 : 0; bool maxHeightReached = _constraintSet.MaximumPalletHeight.Activated && (_packProperties.Height + noInterlayer * interlayerThickness + noLayer * layer.BoxHeight) > _constraintSet.MaximumPalletHeight.Value; bool maxWeightReached = _constraintSet.MaximumPalletWeight.Activated && (_palletProperties.Weight + noInterlayer * interlayerWeight + noLayer * boxLayer.Count * _packProperties.Weight > _constraintSet.MaximumPalletWeight.Value); noLayer = 0; noInterlayer = 0; int iCountInterlayer = 0, iCountSwap = 1; bool bSwap = false; while (!maxHeightReached && !maxWeightReached) { bool bInterlayer = (0 == iCountInterlayer) && ((noLayer != 0) || _constraintSet.HasFirstInterlayer); // actually insert new layer sol.AddLayer(bSwap, bInterlayer); // increment number of layers noLayer++; noInterlayer += (bInterlayer ? 1 : 0); // update iCountInterlayer && iCountSwap ++iCountInterlayer; if (iCountInterlayer >= _constraintSet.InterlayerPeriod) { iCountInterlayer = 0; } ++iCountSwap; if (iCountSwap > _constraintSet.LayerSwapPeriod) { iCountSwap = 1; bSwap = !bSwap; } // update maxHeightReached & maxWeightReached maxHeightReached = _constraintSet.MaximumPalletHeight.Activated && (_palletProperties.Height + (noInterlayer + (iCountInterlayer == 0 ? 1 : 0)) * interlayerThickness + (noLayer + 1) * layer.BoxHeight) > _constraintSet.MaximumPalletHeight.Value; maxWeightReached = _constraintSet.MaximumPalletWeight.Activated && (_palletProperties.Weight + (noInterlayer + (iCountInterlayer == 0 ? 1 : 0)) * interlayerWeight + (noLayer + 1) * boxLayer.Count * _packProperties.Weight > _constraintSet.MaximumPalletWeight.Value); } if (sol.PackCount > 0) { solutions.Add(sol); } } // axis } // pattern solutions.Sort(); return(solutions); }
private BoxPosition GetPosition(int i, int j, int k, int dim0, int dim1) { PackableBrick packable = _packProperties.Content as PackableBrick; double boxLength = packable.Dim(dim0); double boxWidth = packable.Dim(dim1); double boxHeight = packable.Dim(3 - dim0 - dim1); HalfAxis.HAxis dirLength = HalfAxis.HAxis.AXIS_X_P; HalfAxis.HAxis dirWidth = HalfAxis.HAxis.AXIS_Y_P; Vector3D vPosition = Vector3D.Zero; if (0 == dim0 && 1 == dim1) { dirLength = HalfAxis.HAxis.AXIS_X_P; dirWidth = HalfAxis.HAxis.AXIS_Y_P; vPosition = Vector3D.Zero; } else if (0 == dim0 && 2 == dim1) { dirLength = HalfAxis.HAxis.AXIS_X_P; dirWidth = HalfAxis.HAxis.AXIS_Z_N; vPosition = new Vector3D(0.0, 0.0, packable.Width); } else if (1 == dim0 && 0 == dim1) { dirLength = HalfAxis.HAxis.AXIS_Y_P; dirWidth = HalfAxis.HAxis.AXIS_X_N; vPosition = new Vector3D(packable.Width, 0.0, 0.0); } else if (1 == dim0 && 2 == dim1) { dirLength = HalfAxis.HAxis.AXIS_Z_N; dirWidth = HalfAxis.HAxis.AXIS_X_P; vPosition = new Vector3D(0.0, packable.Height, packable.Length); } else if (2 == dim0 && 0 == dim1) { dirLength = HalfAxis.HAxis.AXIS_Y_P; dirWidth = HalfAxis.HAxis.AXIS_Z_N; vPosition = new Vector3D(packable.Height, 0.0, packable.Width); } else if (2 == dim0 && 1 == dim1) { dirLength = HalfAxis.HAxis.AXIS_Z_P; dirWidth = HalfAxis.HAxis.AXIS_Y_P; vPosition = new Vector3D(packable.Height, 0.0, 0.0); } // add offset vPosition += Vector3D.Zero; Vector3D vOffset = new Vector3D( 0.5 * (_packProperties.Length - _packProperties.InnerLength) , 0.5 * (_packProperties.Width - _packProperties.InnerWidth) , 0.5 * (_packProperties.Height - _packProperties.InnerHeight) ); // apply global transformation using _dir0 / _dir1 return(BoxPosition.Transform( new BoxPosition( vPosition + vOffset + new Vector3D(i * boxLength, j * boxWidth, k * boxHeight) , dirLength , dirWidth) , GlobalTransformation )); }
/// <summary> /// constructs a Func that returns a 2D point /// </summary> public static Func <Vector2f> BoxPointInterpF(IBoxModelElement element, BoxPosition pos1, BoxPosition pos2, float alpha) { Func <Vector2f> f = () => { Vector2f p1 = BoxModel.GetBoxPosition(element, pos1); Vector2f p2 = BoxModel.GetBoxPosition(element, pos2); return(Vector2f.Lerp(p1, p2, alpha)); }; return(f); }
public void Draw(Graphics3D graphics) { if (null == _truckSolution) { throw new Exception("No trucksolution defined!"); } // draw truck Truck truck = new Truck(_truckSolution.ParentTruckAnalysis.TruckProperties); truck.DrawBegin(graphics); truck.DrawEnd(graphics); // get pallet height CasePalletAnalysis analysis = _truckSolution.ParentTruckAnalysis.ParentAnalysis; double palletLength = _truckSolution.ParentTruckAnalysis.ParentSolution.PalletLength; double palletWidth = _truckSolution.ParentTruckAnalysis.ParentSolution.PalletWidth; double palletHeight = _truckSolution.ParentTruckAnalysis.ParentSolution.PalletHeight; // get parent pallet solution CasePalletSolution sol = _truckSolution.ParentTruckAnalysis.ParentSolution; // draw solution uint pickIdGlobal = 0; for (int i = 0; i < _truckSolution.NoLayers; ++i) { foreach (BoxPosition bPositionLayer in _truckSolution.Layer) { BoxPosition bPalletPosition = new BoxPosition( new Vector3D( bPositionLayer.Position.X , bPositionLayer.Position.Y , bPositionLayer.Position.Z + palletHeight * i) , bPositionLayer.DirectionLength , bPositionLayer.DirectionWidth); if (_showDetails) { // build transformation Transform3D transformPallet = bPalletPosition.Transformation; // draw pallet Pallet pallet = new Pallet(analysis.PalletProperties); pallet.Draw(graphics, transformPallet); // draw solution uint pickId = 0; foreach (ILayer layer in sol) { Layer3DBox bLayer = layer as Layer3DBox; if (null != bLayer) { foreach (BoxPosition bPosition in bLayer) { graphics.AddBox(new Box(pickId++, analysis.BProperties, BoxPosition.Transform(bPosition, transformPallet))); } } InterlayerPos interlayerPos = layer as InterlayerPos; if (null != interlayerPos) { BoxPosition iPos = new BoxPosition(new Vector3D(0.0, 0.0, interlayerPos.ZLow), HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); graphics.AddBox(new Box(pickId++, analysis.InterlayerProperties, BoxPosition.Transform(iPos, transformPallet))); } } } else { Box b = new Box(pickIdGlobal++, new BoxProperties(null, palletLength, palletWidth, palletHeight), bPalletPosition); b.SetAllFacesColor(Color.Chocolate); graphics.AddBox(b); } } } // fluch graphics.UseBoxelOrderer = false; // can not use boxel orderer for full truck view -> too slow... }
public static fTextAreaGameObject CreateTextAreaGO( string sName, string sText, Colorf textColor, float fTextHeight, Vector2f areaDimensions, HorizontalAlignment alignment = HorizontalAlignment.Left, BoxPosition textOrigin = BoxPosition.Center, float fOffsetZ = -0.01f) { GameObject textGO = new GameObject(sName); TextMeshPro tm = textGO.AddComponent <TextMeshPro>(); //tm.isOrthographic = false; switch (alignment) { case HorizontalAlignment.Left: tm.alignment = TextAlignmentOptions.TopLeft; break; case HorizontalAlignment.Center: tm.alignment = TextAlignmentOptions.Center; break; case HorizontalAlignment.Right: tm.alignment = TextAlignmentOptions.TopRight; break; } tm.enableWordWrapping = true; tm.autoSizeTextContainer = false; tm.fontSize = 16; tm.text = sText; tm.color = textColor; // ignore material changes when we add to GameObjectSet textGO.AddComponent <IgnoreMaterialChanges>(); textGO.AddComponent <TextMeshProAlphaMultiply>(); // use our textmesh material instead //MaterialUtil.SetTextMeshDefaultMaterial(tm); TextContainer container = textGO.GetComponent <TextContainer>(); container.isAutoFitting = false; container.anchorPosition = TextContainerAnchors.TopLeft; if (alignment != HorizontalAlignment.Left) { throw new NotSupportedException("CreateTextAreaGO: currently only Left-aligned text is supported"); } //switch ( alignment ) { // case HorizontalAlignment.Left: // container.anchorPosition = TextContainerAnchors.TopLeft; break; // case HorizontalAlignment.Center: // container.anchorPosition = TextContainerAnchors.Middle; break; // case HorizontalAlignment.Right: // container.anchorPosition = TextContainerAnchors.TopRight; break; //} tm.ForceMeshUpdate(); // set container width and height to just contain text AxisAlignedBox3f bounds = tm.bounds; Vector2f size = new Vector2f(bounds.Width, bounds.Height); // Now we want to scale text to hit our target height, but if we scale by size.y // then the scaling will vary by text height (eg "m" will get same height as "My"). // However: 1) size.y varies with tm.fontSize, but it's not clear how. // 2) fontInfo.LineHeight tells us the height we want but doesn't change w/ tm.fontSize // I tried a few values and the relationship is linear. It is in the ballpark // of just being 10x...actually closer to 11x. No other values in fontInfo have a nice // round-number relationship. But this value is probably font-dependent!! float t = tm.fontSize / tm.font.fontInfo.LineHeight; float magic_k = 10.929f; // [RMS] solve-for-x given a few different fontSize values float font_size_y = magic_k * t; float fScaleH = fTextHeight / font_size_y; tm.transform.localScale = new Vector3(fScaleH, fScaleH, fScaleH); float fTextWidth = fScaleH * size.x; // set container size now that we know text scaling factor container.width = areaDimensions.x / fScaleH; container.height = areaDimensions.y / fScaleH; // by default text origin is top-left if (textOrigin == BoxPosition.Center) { tm.transform.Translate(-fTextWidth / 2.0f, fTextHeight / 2.0f, fOffsetZ); } else if (textOrigin == BoxPosition.BottomLeft) { tm.transform.Translate(0, fTextHeight, fOffsetZ); } else if (textOrigin == BoxPosition.TopRight) { tm.transform.Translate(-fTextWidth, 0, fOffsetZ); } else if (textOrigin == BoxPosition.BottomRight) { tm.transform.Translate(-fTextWidth, fTextHeight, fOffsetZ); } else if (textOrigin == BoxPosition.CenterLeft) { tm.transform.Translate(0, fTextHeight / 2.0f, fOffsetZ); } else if (textOrigin == BoxPosition.CenterRight) { tm.transform.Translate(-fTextWidth, fTextHeight / 2.0f, fOffsetZ); } else if (textOrigin == BoxPosition.CenterTop) { tm.transform.Translate(-fTextWidth / 2.0f, 0, fOffsetZ); } else if (textOrigin == BoxPosition.CenterBottom) { tm.transform.Translate(-fTextWidth / 2.0f, fTextHeight, fOffsetZ); } textGO.GetComponent <Renderer>().material.renderQueue = SceneGraphConfig.TextRendererQueue; return(new fTextAreaGameObject(textGO, new fText(tm, TextType.TextMeshPro), areaDimensions)); //new Vector2f(fTextWidth, fTextHeight) ); }
// [TODO] currently only allows for left-justified text. // Can support center/right, but the translate block needs to be rewritten // (can we generalize as target-center of 2D bbox?? public static fTextGameObject CreateTextMeshProGO( string sName, string sText, Colorf textColor, float fTextHeight, BoxPosition textOrigin = BoxPosition.Center, float fOffsetZ = -0.01f) { GameObject textGO = new GameObject(sName); TextMeshProExt tm = textGO.AddComponent <TextMeshProExt>(); //tm.isOrthographic = false; tm.alignment = TextAlignmentOptions.TopLeft; tm.enableWordWrapping = false; tm.autoSizeTextContainer = true; tm.fontSize = 16; tm.text = sText; tm.color = textColor; // ignore material changes when we add to GameObjectSet textGO.AddComponent <IgnoreMaterialChanges>(); textGO.AddComponent <TextMeshProAlphaMultiply>(); // use our textmesh material instead //MaterialUtil.SetTextMeshDefaultMaterial(tm); TextContainer container = textGO.GetComponent <TextContainer>(); container.isAutoFitting = true; container.anchorPosition = TextContainerAnchors.TopLeft; if (textOrigin == BoxPosition.Center) { container.anchorPosition = TextContainerAnchors.Middle; tm.alignment = TextAlignmentOptions.Center; } else if (textOrigin == BoxPosition.BottomLeft) { container.anchorPosition = TextContainerAnchors.BottomLeft; tm.alignment = TextAlignmentOptions.BottomLeft; } else if (textOrigin == BoxPosition.TopRight) { container.anchorPosition = TextContainerAnchors.TopRight; tm.alignment = TextAlignmentOptions.TopRight; } else if (textOrigin == BoxPosition.BottomRight) { container.anchorPosition = TextContainerAnchors.BottomRight; tm.alignment = TextAlignmentOptions.BottomRight; } else if (textOrigin == BoxPosition.CenterLeft) { container.anchorPosition = TextContainerAnchors.Left; tm.alignment = TextAlignmentOptions.Left; } else if (textOrigin == BoxPosition.CenterRight) { container.anchorPosition = TextContainerAnchors.Right; tm.alignment = TextAlignmentOptions.Right; } else if (textOrigin == BoxPosition.CenterTop) { container.anchorPosition = TextContainerAnchors.Top; tm.alignment = TextAlignmentOptions.Top; } else if (textOrigin == BoxPosition.CenterBottom) { container.anchorPosition = TextContainerAnchors.Bottom; tm.alignment = TextAlignmentOptions.Bottom; } tm.ForceMeshUpdate(); // set container width and height to just contain text AxisAlignedBox3f bounds = tm.bounds; Vector2f size = new Vector2f(bounds.Width, bounds.Height); container.width = size.x + 1; container.height = size.y + 1; // Now we want to scale text to hit our target height, but if we scale by size.y // then the scaling will vary by text height (eg "m" will get same height as "My"). // However: 1) size.y varies with tm.fontSize, but it's not clear how. // 2) fontInfo.LineHeight tells us the height we want but doesn't change w/ tm.fontSize // I tried a few values and the relationship is linear. It is in the ballpark // of just being 10x...actually closer to 11x. No other values in fontInfo have a nice // round-number relationship. But this value is probably font-dependent!! float t = tm.fontSize / tm.font.fontInfo.LineHeight; float magic_k = 10.929f; // [RMS] solve-for-x given a few different fontSize values float font_size_y = magic_k * t; tm.fontSizeYScale = 1 / font_size_y; tm.SetTextSizeFromHeight(fTextHeight); //float fScaleH = fTextHeight / font_size_y; //tm.transform.localScale = new Vector3f(fScaleH, fScaleH, fScaleH); float fTextWidth = tm.GetTextScaleForHeight(fTextHeight) * size.x; textGO.GetComponent <Renderer>().material.renderQueue = SceneGraphConfig.TextRendererQueue; return(new fTextGameObject(textGO, new fText(tm, TextType.TextMeshPro), new Vector2f(fTextWidth, fTextHeight))); }
public ImageInst(AnalysisHomo analysis, Vector3D dims, BoxPosition boxPosition) { _analysis = analysis; _dims = dims; _boxPosition = boxPosition; }
public void CreateAnimation(uint caseIndex, uint caseCount, List <object> listAnimationObjects, BoxPosition bPos) { /* * const int iStep = 5; * _zOffset = _palletSolution.PalletHeight + 100.0; * * // build list of time * List<double> listTime = new List<double>(); * List<string> listInterp = new List<string>(); * listTime.Add(0.0); * listInterp.Add("LINEAR"); * for (int i = 0; i < iStep; ++i) * { * listTime.Add(((double)caseIndex + (double)i / (double)(iStep - 1))); * listInterp.Add("LINEAR"); * } * listTime.Add(caseCount); * listInterp.Add("LINEAR"); * * BProperties bProperties = _palletSolution.Analysis.BProperties; * PalletProperties pProperties = _palletSolution.Analysis.PalletProperties; * * double yOffset = 0.5 * (_palletSolution.Analysis.PalletProperties.Width - bProperties.Length); * BoxPosition bPosFinal = GetFinalBoxPosition(caseIndex); * * List<BoxPosition> listBoxPosition = new List<BoxPosition>(); * // -1. * listBoxPosition.Add(GetInitialBoxPosition(caseIndex)); * // 0. initialbox position * listBoxPosition.Add(GetInitialBoxPosition(caseIndex)); * // 1. position at out storing area * listBoxPosition.Add(new BoxPosition(new Vector3D(_xOffset, yOffset, _zOffset), HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N)); * // 2. position above pallet * listBoxPosition.Add(new BoxPosition(new Vector3D(pProperties.Length * 0.5, pProperties.Width * 0.5, _zOffset), bPosFinal.DirectionLength, bPosFinal.DirectionWidth)); * // 3. position above final position * listBoxPosition.Add(new BoxPosition(new Vector3D(bPosFinal.Position.X, bPosFinal.Position.Y, _zOffset), bPosFinal.DirectionLength, bPosFinal.DirectionWidth)); * // 4. final position * listBoxPosition.Add(bPosFinal); * // 5. * listBoxPosition.Add(bPosFinal); * * List<double> listX = new List<double>(); * List<double> listY = new List<double>(); * List<double> listZ = new List<double>(); * List<double> listRX = new List<double>(); * List<double> listRY = new List<double>(); * List<double> listRZ = new List<double>(); * * BoxPosition bPprev0 = listBoxPosition[0]; * listX.Add(bPprev0.Position.X); * listY.Add(bPprev0.Position.Y); * listZ.Add(bPprev0.Position.Z); * Vector3D vRotPrev0 = bPprev0.Transformation.Rotations; * listRX.Add(vRotPrev0.X); * listRY.Add(vRotPrev0.Y); * listRZ.Add(vRotPrev0.Z); * * for (int i = 1; i < listBoxPosition.Count; ++i) * { * BoxPosition bP = listBoxPosition[i]; * listX.Add(bP.Position.X); * listY.Add(bP.Position.Y); * listZ.Add(bP.Position.Z); * Vector3D vRot = bP.Transformation.Rotations; * listRX.Add(vRot.X); * listRY.Add(vRot.Y); * listRZ.Add(vRot.Z); * } * * // time * source sTime = new source() * { * id = string.Format("sTime_{0}_ID", caseIndex), * name = string.Format("sTime_{0}", caseIndex), * Item = new float_array() * { * id = string.Format("fa_time_{0}_ID", caseIndex), * count = (ulong)listTime.Count, * Values = listTime.ToArray() * }, * technique_common = new sourceTechnique_common() * { * accessor = new accessor() * { * source = string.Format("#fa_time_{0}_ID", caseIndex), * count = (ulong)listTime.Count, * stride = 1, * param = new param[] * { * new param() { name="TIME", type="float" } * } * } * } * }; * listAnimationObjects.Add(sTime); * * // interp * source sInterp = new source() * { * id = string.Format("sInterp_{0}_ID", caseIndex), * name = string.Format("sInterp_{0}", caseIndex), * Item = new Name_array() * { * id = string.Format("na_interp_{0}_ID", caseIndex), * count = (ulong)listInterp.Count, * Values = listInterp.ToArray() * }, * technique_common = new sourceTechnique_common() * { * accessor = new accessor() * { * source = string.Format("#na_interp_{0}_ID", caseIndex), * count = (ulong)listInterp.Count, * stride = 1, * param = new param[] * { * new param() { name="INTERPOLATION", type="name" } * } * } * } * }; * listAnimationObjects.Add(sInterp); * * CreateChannel(listAnimationObjects, caseIndex, "X", "TIME", string.Format("CaseNode_{0}_ID/t.X", caseIndex), listX); * CreateChannel(listAnimationObjects, caseIndex, "Y", "TIME", string.Format("CaseNode_{0}_ID/t.Y", caseIndex), listY); * CreateChannel(listAnimationObjects, caseIndex, "Z", "TIME", string.Format("CaseNode_{0}_ID/t.Z", caseIndex), listZ); * CreateChannel(listAnimationObjects, caseIndex, "RX", "ANGLE", string.Format("CaseNode_{0}_ID/rx.ANGLE", caseIndex), listRX); * CreateChannel(listAnimationObjects, caseIndex, "RY", "ANGLE", string.Format("CaseNode_{0}_ID/ry.ANGLE", caseIndex), listRY); * CreateChannel(listAnimationObjects, caseIndex, "RZ", "ANGLE", string.Format("CaseNode_{0}_ID/rz.ANGLE", caseIndex), listRZ); */ }