private void AddShapeCore(Shape newShape, bool @do) { newShape.OnBeingAdded(this); _core.Shapes.Add(newShape); if (AfterShapesAdded != null && @do) AfterShapesAdded(Range.Single(newShape)); }
public static Shape Load(string fn) { if (!System.IO.File.Exists(fn)) throw new System.Exception("File not found: " + fn); System.IO.BinaryReader br = new System.IO.BinaryReader(new System.IO.FileStream(fn, System.IO.FileMode.Open)); Shape s = new Shape(); s.Width = br.ReadInt32(); s.Height = br.ReadInt32(); s.matrix = new bool[s.Width, s.Height]; try { for (int x = 0; x < s.Width; x++) for (int y = 0; y < s.Height; y++) s.notEmptyCellsCount += (s.matrix[x, y] = br.ReadBoolean()) ? 1 : 0; } catch (System.IO.EndOfStreamException) { throw new System.Exception("Invalid data for shape " + fn); } br.Close(); s.CreateTexture(); return s; }
/// <summary> /// Adds an image to a page using the supplied paragraph. /// </summary> /// <param name="para">The paragraph to an an image to.</param> /// <param name="page">The page number the paragraph appears on.</param> public static void AddImageToPage(Paragraph para, int page) { Document doc = (Document)para.Document; DocumentBuilder builder = new DocumentBuilder(doc); builder.MoveTo(para); // Add a logo to the top left of the page. The image is placed infront of all other text. Shape shape = builder.InsertImage(gDataDir + "Aspose Logo.png", RelativeHorizontalPosition.Page, 60, RelativeVerticalPosition.Page, 60, -1, -1, WrapType.None); // Add a textbox next to the image which contains some text consisting of the page number. Shape textBox = new Shape(doc, ShapeType.TextBox); // We want a floating shape relative to the page. textBox.WrapType = WrapType.None; textBox.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; textBox.RelativeVerticalPosition = RelativeVerticalPosition.Page; // Set the textbox position. textBox.Height = 30; textBox.Width = 200; textBox.Left = 150; textBox.Top = 80; // Add the textbox and set text. textBox.AppendChild(new Paragraph(doc)); builder.InsertNode(textBox); builder.MoveTo(textBox.FirstChild); builder.Writeln("This is a custom note for page " + page); }
/// <override></override> public override void CopyFrom(Shape source) { base.CopyFrom(source); // Copy size if the source is a DiameterShape if (source is DiameterShapeBase) internalDiameter = ((DiameterShapeBase) source).DiameterInternal; else { // If not, try to calculate the size a good as possible Rectangle srcBounds = Geometry.InvalidRectangle; if (source is PathBasedPlanarShape) { PathBasedPlanarShape src = (PathBasedPlanarShape) source; // Calculate the bounds of the (unrotated) resize handles because with // GetBoundingRectangle(), we receive the bounds including the children's bounds List<Point> pointBuffer = new List<Point>(); int centerX = src.X; int centerY = src.Y; float angleDeg = Geometry.TenthsOfDegreeToDegrees(-src.Angle); foreach (ControlPointId id in source.GetControlPointIds(ControlPointCapabilities.Resize)) pointBuffer.Add(Geometry.RotatePoint(centerX, centerY, angleDeg, source.GetControlPointPosition(id))); Geometry.CalcBoundingRectangle(pointBuffer, out srcBounds); } else { // Generic approach: try to fit into the bounding rectangle srcBounds = source.GetBoundingRectangle(true); } // // Calculate new size if (Geometry.IsValid(srcBounds)) { float scale = Geometry.CalcScaleFactor(DiameterInternal, DiameterInternal, srcBounds.Width, srcBounds.Height); DiameterInternal = (int) Math.Round(DiameterInternal*scale); } } }
//--------------------------------- // Indexing //--------------------------------- public override Field[] CreateIndexableFields(Shape shape) { var rect = shape as Rectangle; if (rect != null) return CreateIndexableFields(rect); throw new InvalidOperationException("Can only index Rectangle, not " + shape); }
// Returns true if the two shapes that are pased as parameters are next to // each other, either vertically or horizontally. public static bool AreVerticalOrHorizontalNeighbors(Shape s1, Shape s2) { return (s1.Column == s2.Column || s1.Row == s2.Row) && Mathf.Abs(s1.Column - s2.Column) <= 1 && Mathf.Abs(s1.Row - s2.Row) <= 1; }
public static Shape DropConnection( Shape source, Shape target, string masterNameU) { return DropConnection(source, target, masterNameU, ClassConnections.Right, ClassConnections.Top); }
private Texture2D CreateTexture(Shape shape, object[] textureData) { // ignore any texture data. var bounds = shape.Bounds; Color[] colorArr = new Color[bounds.Width * bounds.Height]; int index = 0; for (int x = 0; x < bounds.Width; x++) { for (int y = 0; y < bounds.Height; y++) { index = y * bounds.Width + x; if (shape.Contains(x + bounds.X, y + bounds.Y)) colorArr[index] = Color.White; else colorArr[index] = Color.Transparent; } } Texture2D texture = new Texture2D(_renderer.GraphicsDevice, bounds.Width, bounds.Height); texture.SetData(colorArr); return texture; }
public void TestCleanup() { _physics.Dispose(); _physics = null; _shape = null; }
public static void Run() { // ExStart:ConnectVisioSubShapes // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Shapes(); // Set sub shape ids long shapeFromId = 2; long shapeToId = 4; // Load diagram Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); // Access a particular page Page page = diagram.Pages.GetPage("Page-3"); // Initialize connector shape Shape shape = new Shape(); shape.Line.EndArrow.Value = 4; shape.Line.LineWeight.Value = 0.01388; // Add shape long connecter1Id = diagram.AddShape(shape, "Dynamic connector", page.ID); // Connect sub-shapes page.ConnectShapesViaConnector(shapeFromId, ConnectionPointPlace.Right, shapeToId, ConnectionPointPlace.Left, connecter1Id); // Save Visio drawing diagram.Save(dataDir + "ConnectVisioSubShapes_out.vsdx", SaveFileFormat.VSDX); // ExEnd:ConnectVisioSubShapes }
public override AbstractField[] CreateIndexableFields(Shape shape) { var point = shape as Point; if (point != null) { var f = new AbstractField[2]; var f0 = new NumericField(fieldNameX, precisionStep, Field.Store.NO, true) {OmitNorms = true, OmitTermFreqAndPositions = true}; f0.SetDoubleValue(point.GetX()); f[0] = f0; var f1 = new NumericField(fieldNameY, precisionStep, Field.Store.NO, true) {OmitNorms = true, OmitTermFreqAndPositions = true}; f1.SetDoubleValue(point.GetY()); f[1] = f1; return f; } if (!ignoreIncompatibleGeometry) { throw new ArgumentException("TwoDoublesStrategy can not index: " + shape); } return new AbstractField[0]; // nothing (solr does not support null) }
/// <summary> /// Displays a dialog showing various information on the given shape: /// Template, shape type, shape library and the shape's control points including their capabilities and connected shapes. /// </summary> public ShapeInfoDialog(Project project, Shape shape) { if (project == null) throw new ArgumentNullException("project"); if (shape == null) throw new ArgumentNullException("shape"); InitializeComponent(); this.project = project; Rectangle shapeBounds = shape.GetBoundingRectangle(false); this.shape = shape; this.shapeClone = shape.Clone(); this.shapeClone.Fit(0, 0, shapeBounds.Width, shapeBounds.Height); this.diagram.Size = shapeBounds.Size; this.diagram.Shapes.Add(shapeClone); diagramSetController.Project = project; display.DrawDiagramSheet = false; display.Diagram = diagram; display.ShowGrid = false; display.GripSize = 5; display.HighQualityRendering = true; display.RenderingQualityHighQuality = RenderingQuality.MaximumQuality; display.CurrentTool = tool; UpdateShapeInfo(); }
public static void RenderShapeToStream(string dataDir, Shape shape) { //ExStart //ExFor:ShapeRenderer //ExFor:ShapeRenderer.#ctor(ShapeBase) //ExFor:ImageSaveOptions.ImageColorMode //ExFor:ImageSaveOptions.ImageBrightness //ExFor:ShapeRenderer.Save(Stream, ImageSaveOptions) //ExId:RenderShapeToStream //ExSummary:Shows how to render a shape independent of the document to a JPEG image and save it to a stream. // We can also retrieve the renderer for a shape by using the ShapeRenderer constructor. ShapeRenderer r = new ShapeRenderer(shape); // Define custom options which control how the image is rendered. Render the shape to the vector format EMF. ImageSaveOptions imageOptions = new ImageSaveOptions(SaveFormat.Jpeg) { // Output the image in gray scale ImageColorMode = ImageColorMode.Grayscale, // Reduce the brightness a bit (default is 0.5f). ImageBrightness = 0.45f }; FileStream stream = new FileStream(dataDir + "TestFile.RenderToStream Out.jpg", FileMode.CreateNew); // Save the rendered image to the stream using different options. r.Save(stream, imageOptions); //ExEnd }
public bool CollisionMovingDown(Shape fallingShape, Dictionary<int, Tile> fallenTiles) { if (HitBottomOfGrid(fallingShape) || HitFallenShapesMovingDownwards(fallingShape, fallenTiles)) return true; return false; }
public bool CollisionMovingRight(Shape fallingShape, Dictionary<int, Tile> fallenTiles) { if (HitRightSideOfGrid(fallingShape) || HitFallenShapesMovingRight(fallingShape, fallenTiles)) return true; return false; }
public Card(CardColor color, Shape shape, Fill fill, int count) { #region validation if (color == CardColor.Other) { throw new InvalidCardException("color", color); } if (shape == Shape.Other) { throw new InvalidCardException("shape", shape); } if (fill == Fill.Other) { throw new InvalidCardException("fill", fill); } if (count > 3 || count < 1) { throw new InvalidCardException("count", count); } #endregion validation this.Color = color; this.Shape = shape; this.Fill = fill; this.Count = count; }
public static void RenderShapeToGraphics(string dataDir, Shape shape) { ShapeRenderer r = shape.GetShapeRenderer(); // Find the size that the shape will be rendered to at the specified scale and resolution. Size shapeSizeInPixels = r.GetSizeInPixels(1.0f, 96.0f); // Rotating the shape may result in clipping as the image canvas is too small. Find the longest side // and make sure that the graphics canvas is large enough to compensate for this. int maxSide = Math.Max(shapeSizeInPixels.Width, shapeSizeInPixels.Height); using (Bitmap image = new Bitmap((int)(maxSide * 1.25), (int)(maxSide * 1.25))) { // Rendering to a graphics object means we can specify settings and transformations to be applied to // the shape that is rendered. In our case we will rotate the rendered shape. using (Graphics gr = Graphics.FromImage(image)) { // Clear the shape with the background color of the document. gr.Clear(shape.Document.PageColor); // Center the rotation using translation method below gr.TranslateTransform((float)image.Width / 8, (float)image.Height / 2); // Rotate the image by 45 degrees. gr.RotateTransform(45); // Undo the translation. gr.TranslateTransform(-(float)image.Width / 8, -(float)image.Height / 2); // Render the shape onto the graphics object. r.RenderToSize(gr, 0, 0, shapeSizeInPixels.Width, shapeSizeInPixels.Height); } dataDir = dataDir + "TestFile.RenderToGraphics_out_.png"; image.Save(dataDir, ImageFormat.Png); Console.WriteLine("\nShape rendered to graphics successfully.\nFile saved at " + dataDir); } }
public Blocker(Utilities.Graphics.AnimatedSprite sprite, Shape colShape, bool isAbovePlayer, float maxSpeed = 0.0f, float mass = 1.0f) : base(colShape, Single.PositiveInfinity, maxSpeed) { IsAbovePlayer = isAbovePlayer; Sprite = sprite; Mass = mass; }
private void Awake() { _shape = GetComponent<Shape>(); _collider = GetComponent<CircleCollider2D>(); _offsets = new float[_shape.m_resolution]; RandomizeTime(); }
public PhysxTriangleMesh(PhysxPhysicWorld PhysxPhysicWorld, IModelo model,Microsoft.Xna.Framework.Matrix localTransformation, Microsoft.Xna.Framework.Matrix worldTransformation, Microsoft.Xna.Framework.Vector3 scale, MaterialDescription MaterialDescription) { Microsoft.Xna.Framework.Vector3[] vertices = null; int[] indices = null; ExtractData(ref vertices, ref indices, model); TriangleMeshDesc meshDesc = new TriangleMeshDesc(); Vector3[] points = new Vector3[vertices.Count()]; for (int i = 0; i < vertices.Count(); i++) { points[i] = vertices[i].AsPhysX(); } meshDesc.Points = points; meshDesc.SetTriangles<int>(indices); //meshDesc.Triangles = indices; MemoryStream ms = new MemoryStream(); if(PhysxPhysicWorld.Cooking.CookTriangleMesh(meshDesc,ms)==false) { PloobsEngine.Engine.Logger.ActiveLogger.LogMessage("Cant Cook Model",Engine.Logger.LogLevel.FatalError); } ms.Position = 0; TriangleMesh triangleMesh = PhysxPhysicWorld.Physix.CreateTriangleMesh(ms); staticActor = PhysxPhysicWorld.Physix.CreateRigidStatic(worldTransformation.AsPhysX()); TriangleMeshGeometry TriangleMeshGeometry = new TriangleMeshGeometry(triangleMesh,new MeshScale(scale.AsPhysX(),Quaternion.Identity)); material = PhysxPhysicWorld.Physix.CreateMaterial(MaterialDescription.StaticFriction, MaterialDescription.DynamicFriction, MaterialDescription.Bounciness); aTriMeshShape = staticActor.CreateShape(TriangleMeshGeometry, material, localTransformation.AsPhysX()); this.Scale = scale; }
public SpatialArgs(SpatialOperation operation, Shape shape) { if (operation == null || shape == null) throw new ArgumentException("operation and shape are required"); this.Operation = operation; this.Shape = shape; }
public IList<Shape> Execute(StyleOption option, EffectsDesigner designer, ImageItem source, Shape imageShape) { designer.ApplyPseudoTextWhenNoTextShapes(); if ((option.IsUseBannerStyle || option.IsUseFrostedGlassBannerStyle) && (option.GetTextBoxPosition() == Position.Left || option.GetTextBoxPosition() == Position.Centre || option.GetTextBoxPosition() == Position.Right)) { designer.ApplyTextWrapping(); } else if (option.IsUseCircleStyle || option.IsUseOutlineStyle) { designer.ApplyTextWrapping(); } else { designer.RecoverTextWrapping(); } ApplyTextEffect(option, designer); designer.ApplyTextGlowEffect(option.IsUseTextGlow, option.TextGlowColor); return new List<Shape>(); }
public static void FixConnectorTextControl(Shape shape) { if (Common.GetShapeType(shape) == ShapeTypes.Connector) { string pinX = Common.GetCellFormula(shape, "TxtPinX"); // if the current TxtPinX already is updating another cell via setatref, we don't need to // do anything if (!pinX.Contains("SETATREF")) { shape.AddNamedRow((short)VisSectionIndices.visSectionControls, "TextPosition", 0); // get old values and reuse them if we already have text string pinY = Common.GetCellFormula(shape, "TxtPinY"); if (shape.Text.Length > 0) { shape.get_CellsU("Controls.TextPosition.X").Formula = pinX; shape.get_CellsU("Controls.TextPosition.Y").Formula = pinY; } else { shape.get_CellsU("Controls.TextPosition.Y").FormulaU = "Height*0.5"; shape.get_CellsU("Controls.TextPosition.X").FormulaU = "Width*0.5"; } shape.get_CellsU("Controls.TextPosition.XDyn").FormulaU = "Controls.TextPosition.X"; shape.get_CellsU("Controls.TextPosition.YDyn").FormulaU = "Controls.TextPosition.Y"; shape.get_CellsU("Controls.TextPosition.XCon").FormulaU = "IF(OR(STRSAME(SHAPETEXT(TheText),\"\"),HideText),5,0)"; shape.get_CellsU("Controls.TextPosition.CanGlue").FormulaU = "FALSE"; shape.get_CellsU("Controls.TextPosition.Prompt").FormulaU = "\"Reposition Text\""; shape.get_CellsU("TxtPinX").FormulaU = "SETATREF(Controls.TextPosition)"; shape.get_CellsU("TxtPinY").FormulaU = "SETATREF(Controls.TextPosition.Y)"; } } }
/// <summary> /// Checks if the current shape is of the same type as the parameter /// </summary> /// <param name="otherShape"></param> /// <returns></returns> public bool IsSameType(Shape otherShape) { if (otherShape == null || !(otherShape is Shape)) throw new ArgumentException("otherShape"); return string.Compare(this.Type, (otherShape as Shape).Type) == 0; }
/// <override></override> public override void CopyFrom(Shape source) { base.CopyFrom(source); if (source is CircularArcBase) { // Vertices and CapStyles will be copied by the base class // so there's nothing left to do here... } }
public static string cardToString(int val, Shape shape) { string str = System.String.Empty; if (val <= 0 || val >= 14) return str; str = val.ToString(); switch (shape) { case Shape.Club: str += "c"; break; case Shape.Diamond: str += "d"; break; case Shape.Heart: str += "h"; break; case Shape.Spade: str += "s"; break; } return str; }
/** * \brief If passed a valid ProBuilder::Shape, create it! Non-valid shape is Shape.Custom. * \code{.cs} * // Example usage: * pb_Object myNewPrism = ProBuilder.CreatePrimitive(ProBuilder.Shape.Prism); * \endcode * @param shape The primitive type to create. Always creates the shape with default parameters (if applicable). * \returns The new pb_Object. */ public static pb_Object CreatePrimitive(Shape shape) { pb_Object pb; switch(shape) { case Shape.Cube: pb = pb_Shape_Generator.CubeGenerator(Vector3.one); break; case Shape.Prism: pb = pb_Shape_Generator.PrismGenerator(Vector3.one); break; case Shape.Stair: // steps, width, height, depth, extend sides to floor, generate back, platforms only pb = pb_Shape_Generator.StairGenerator(5, 2f, 5f, 7f, true, true, false); break; case Shape.Cylinder: pb = pb_Shape_Generator.CylinderGenerator(6, 1.5f, 4f, 2); break; case Shape.Plane: pb = pb_Shape_Generator.PlaneGenerator(2f, 2f, 3, 3, Axis.Up, false); break; default: return null; } // pb.Refresh(); return pb; }
public DistanceGrid(Shape shape, Scalar spacing) { if (shape == null) { throw new ArgumentNullException("shape"); } if (spacing <= 0) { throw new ArgumentOutOfRangeException("spacing"); } //prepare the shape. Matrix2D old = shape.Matrix; Matrix2D ident = Matrix2D.Identity; shape.ApplyMatrix(ref ident); shape.CalcBoundingBox2D(); this.box = shape.BoundingBox2D; this.gridSpacing = spacing; this.gridSpacingInv = 1 / spacing; int xSize = (int)Math.Ceiling((box.Upper.X - box.Lower.X) * gridSpacingInv) + 2; int ySize = (int)Math.Ceiling((box.Upper.Y - box.Lower.Y) * gridSpacingInv) + 2; this.nodes = new Scalar[xSize, ySize]; Vector2D vector; vector.X = box.Lower.X; for (int x = 0; x < xSize; ++x, vector.X += spacing) { vector.Y = box.Lower.Y; for (int y = 0; y < ySize; ++y, vector.Y += spacing) { nodes[x, y] = shape.GetDistance(vector); } } //restore the shape shape.ApplyMatrix(ref old); shape.CalcBoundingBox2D(); }
static void Main() { var shapes = new Shape[numberOfShapes]; for (int i = 0; i < shapes.Length; i++) { switch (vladoRandoma.Next() % 3) { case 0: shapes[i] = new Triangle(widths[vladoRandoma.Next(0, widths.Length)], heights[vladoRandoma.Next(0, heights.Length)]); break; case 1: shapes[i] = new Rectangle(widths[vladoRandoma.Next(0, widths.Length)], heights[vladoRandoma.Next(0, heights.Length)]); break; case 2: shapes[i] = new Circle(heights[vladoRandoma.Next(0, heights.Length)]); break; default: break; } } foreach (var item in shapes) { Console.WriteLine(item.ToString().Replace(',', '.')); } }
/** * Create a new TableCell. This constructor is used when a new shape is Created. * * @param parent the parent of this Shape. For example, if this text box is a cell * in a table then the parent is Table. */ public TableCell(Shape parent){ base(parent); SetShapeType(ShapeTypes.Rectangle); //_txtRun.SetRunType(TextHeaderAtom.HALF_BODY_TYPE); //_txtRun.GetRichTextRuns()[0].SetFlag(false, 0, false); }
public void Describe(DescribeContext context) { Func <IShapeFactory, object> form = shape => { var f = Shape.Form( Id: "DateTimeFilter", _Operator: Shape.SelectList( Id: "operator", Name: "Operator", Title: T("Operator"), Size: 1, Multiple: false ), _FieldSetOption: Shape.FieldSet( _ValueTypeDate: Shape.Radio( Id: "value-type-date", Name: "ValueType", Title: T("A date"), Value: "0", Checked: true, Description: T("Please use this format: YYYY-MM-DD hh:mm:ss. e.g., 2010-04-12 would filter on the whole day. You can also use the Date token like this: {Date.Format:yyyy-MM-dd}") ), _ValueTypeSpan: Shape.Radio( Id: "value-type-timespan", Name: "ValueType", Title: T("An offset from the current time"), Value: "1", Description: T("You can provide time in the past by using negative values. e.g., -1 day") ) ), _FieldSetSingle: Shape.FieldSet( Id: "fieldset-single", _Value: Shape.TextBox( Id: "value", Name: "Value", Title: T("Value"), Classes: new [] { "tokenized" } ), _ValueUnit: Shape.SelectList( Id: "value-unit", Name: "ValueUnit", Title: T("Unit"), Size: 1, Multiple: false ) ), _FieldSetMin: Shape.FieldSet( Id: "fieldset-min", _Min: Shape.TextBox( Id: "min", Name: "Min", Title: T("Min"), Classes: new[] { "tokenized" } ), _MinUnit: Shape.SelectList( Id: "min-unit", Name: "MinUnit", Title: T("Unit"), Size: 1, Multiple: false ) ), _FieldSetMax: Shape.FieldSet( Id: "fieldset-max", _Max: Shape.TextBox( Id: "max", Name: "Max", Title: T("Max"), Classes: new[] { "tokenized" } ), _MaxUnit: Shape.SelectList( Id: "max-unit", Name: "MaxUnit", Title: T("Unit"), Size: 1, Multiple: false ) ) ); _resourceManager.Value.Require("script", "jQuery"); _resourceManager.Value.Include("script", "~/Modules/Orchard.Projections/Scripts/datetime-editor-filter.js", "~/Modules/Orchard.Projections/Scripts/datetime-editor-filter.js"); _resourceManager.Value.Include("stylesheet", "~/Modules/Orchard.Projections/Styles/datetime-editor-filter.css", "~/Modules/Orchard.Projections/Styles/datetime-editor-filter.css"); f._Operator.Add(new SelectListItem { Value = Convert.ToString(DateTimeOperator.LessThan), Text = T("Is less than").Text }); f._Operator.Add(new SelectListItem { Value = Convert.ToString(DateTimeOperator.LessThanEquals), Text = T("Is less than or equal to").Text }); f._Operator.Add(new SelectListItem { Value = Convert.ToString(DateTimeOperator.Equals), Text = T("Is equal to").Text }); f._Operator.Add(new SelectListItem { Value = Convert.ToString(DateTimeOperator.NotEquals), Text = T("Is not equal to").Text }); f._Operator.Add(new SelectListItem { Value = Convert.ToString(DateTimeOperator.GreaterThanEquals), Text = T("Is greater than or equal to").Text }); f._Operator.Add(new SelectListItem { Value = Convert.ToString(DateTimeOperator.GreaterThan), Text = T("Is greater than").Text }); f._Operator.Add(new SelectListItem { Value = Convert.ToString(DateTimeOperator.Between), Text = T("Is between").Text }); f._Operator.Add(new SelectListItem { Value = Convert.ToString(DateTimeOperator.NotBetween), Text = T("Is not between").Text }); foreach (var unit in new[] { f._FieldSetSingle._ValueUnit, f._FieldSetMin._MinUnit, f._FieldSetMax._MaxUnit }) { unit.Add(new SelectListItem { Value = Convert.ToString(DateTimeSpan.Year), Text = T("Year").Text }); unit.Add(new SelectListItem { Value = Convert.ToString(DateTimeSpan.Month), Text = T("Month").Text }); unit.Add(new SelectListItem { Value = Convert.ToString(DateTimeSpan.Day), Text = T("Day").Text }); unit.Add(new SelectListItem { Value = Convert.ToString(DateTimeSpan.Hour), Text = T("Hour").Text }); unit.Add(new SelectListItem { Value = Convert.ToString(DateTimeSpan.Minute), Text = T("Minute").Text }); unit.Add(new SelectListItem { Value = Convert.ToString(DateTimeSpan.Second), Text = T("Second").Text }); } return(f); }; context.Form(FormName, form); }
/// <summary> /// Constructor which initialize elements with 0 /// type and shape are given. /// </summary> /// <param name="shape">Shape of NDArray</param> /// <remarks>This constructor calls <see cref="IStorage.Allocate(NumSharp.Shape,System.Type)"/></remarks> public NDArray(Shape shape) : base(InfoOf <T> .NPTypeCode, shape) { }
public void Replace(object sender, EventArgs args) { bool IsWiiU = (GetResFileU() != null); OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Supported Formats|*.bfobj;*.fbx;*.dae; *.obj;|" + "Bfres Object (shape/vertices) |*.bfobj|" + "FBX |*.fbx|" + "DAE |*.dae|" + "OBJ |*.obj|" + "All files(*.*)|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { string ext = System.IO.Path.GetExtension(ofd.FileName); ext = ext.ToLower(); switch (ext) { case ".bfobj": Shape shp = new Shape(); shp.Import(ofd.FileName, VertexBuffer); shp.Name = Text; shp.MaterialIndex = (ushort)MaterialIndex; BfresSwitch.ReadShapesVertices(this, shp, VertexBuffer, GetModelList()[ModelIndex]); break; default: AssimpData assimp = new AssimpData(); assimp.LoadFile(ofd.FileName); AssimpMeshSelector selector = new AssimpMeshSelector(); selector.LoadMeshes(assimp, Index); if (selector.ShowDialog() == DialogResult.OK) { if (assimp.objects.Count == 0) { MessageBox.Show("No models found!"); return; } BfresModelImportSettings settings = new BfresModelImportSettings(); settings.SetModelAttributes(assimp.objects[0]); if (settings.ShowDialog() == DialogResult.OK) { STGenericObject obj = selector.GetSelectedMesh(); Cursor.Current = Cursors.WaitCursor; VertexBufferIndex = obj.VertexBufferIndex; vertices = obj.vertices; CreateBoneList(obj, (FMDL)Parent.Parent); VertexSkinCount = obj.MaxSkinInfluenceCount; vertexAttributes = settings.CreateNewAttributes(); lodMeshes = obj.lodMeshes; CreateNewBoundingBoxes(); SaveShape(IsWiiU); SaveVertexBuffer(IsWiiU); Cursor.Current = Cursors.Default; } } break; } UpdateVertexData(); } }
public Obstacle(Shape shape, Image image) : base(shape, image) { }
public IList <Shape> Execute(StyleOption option, EffectsDesigner designer, ImageItem source, Shape imageShape, Settings settings) { List <Shape> result = new List <Shape>(); if (option.IsUseOverlayStyle) { Shape backgroundOverlayShape = designer.ApplyOverlayEffect(option.OverlayColor, option.OverlayTransparency); result.Add(backgroundOverlayShape); } return(result); }
public void fillShape(Shape shape) { fillPolygon(shape.getPolygon().getVertices(), shape.getPolygon().getTriangles().toArray()); }
public void drawShape(Shape shape) { drawPolygon(shape.getPolygon().getVertices()); }
public static void printArea(Shape s) { Console.WriteLine("{0} area = {1}", s.GetType().Name, s.Area.ToString()); }
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart) { var previosPbv = previousDrawn == null ? null : (VerticalBezierPointView)previousDrawn.View; Container.Segments.Remove(Segment); Container.Segments.Insert(index, Segment); if (IsNew) { if (previosPbv != null && !previosPbv.IsNew) { Segment.Point1 = previosPbv.Segment.Point3; Segment.Point2 = previosPbv.Segment.Point3; Segment.Point3 = previosPbv.Segment.Point3; if (DataLabel != null) { Canvas.SetTop(DataLabel, Canvas.GetTop(previosPbv.DataLabel)); Canvas.SetLeft(DataLabel, Canvas.GetLeft(previosPbv.DataLabel)); } if (Shape != null) { Canvas.SetTop(Shape, Canvas.GetTop(previosPbv.Shape)); Canvas.SetLeft(Shape, Canvas.GetLeft(previosPbv.Shape)); } } else { Segment.Point1 = new Point(0, Data.Point1.Y); Segment.Point2 = new Point(0, Data.Point2.Y); Segment.Point3 = new Point(0, Data.Point3.Y); if (DataLabel != null) { Canvas.SetTop(DataLabel, current.ChartLocation.Y - DataLabel.ActualHeight * .5); Canvas.SetLeft(DataLabel, 0); } if (Shape != null) { Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height * .5); Canvas.SetLeft(Shape, 0); } } } #region No Animated if (chart.View.DisableAnimations) { Segment.Point1 = Data.Point1.AsPoint(); Segment.Point2 = Data.Point2.AsPoint(); Segment.Point3 = Data.Point3.AsPoint(); if (HoverShape != null) { Canvas.SetLeft(HoverShape, current.ChartLocation.X - HoverShape.Width * .5); Canvas.SetTop(HoverShape, current.ChartLocation.Y - HoverShape.Height * .5); } if (Shape != null) { Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width * .5); Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height * .5); } if (DataLabel != null) { DataLabel.UpdateLayout(); var xl = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart); var yl = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart); Canvas.SetLeft(DataLabel, xl); Canvas.SetTop(DataLabel, yl); } return; } #endregion Segment.BeginAnimation(BezierSegment.Point1Property, new PointAnimation(Segment.Point1, Data.Point1.AsPoint(), chart.View.AnimationsSpeed)); Segment.BeginAnimation(BezierSegment.Point2Property, new PointAnimation(Segment.Point2, Data.Point2.AsPoint(), chart.View.AnimationsSpeed)); Segment.BeginAnimation(BezierSegment.Point3Property, new PointAnimation(Segment.Point3, Data.Point3.AsPoint(), chart.View.AnimationsSpeed)); if (Shape != null) { if (double.IsNaN(Canvas.GetLeft(Shape))) { Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width * .5); Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height * .5); } else { Shape.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(current.ChartLocation.X - Shape.Width * .5, chart.View.AnimationsSpeed)); Shape.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(current.ChartLocation.Y - Shape.Height * .5, chart.View.AnimationsSpeed)); } } if (DataLabel != null) { DataLabel.UpdateLayout(); var xl = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart); var yl = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart); DataLabel.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(xl, chart.View.AnimationsSpeed)); DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(yl, chart.View.AnimationsSpeed)); } if (HoverShape != null) { Canvas.SetLeft(HoverShape, current.ChartLocation.X - HoverShape.Width * .5); Canvas.SetTop(HoverShape, current.ChartLocation.Y - HoverShape.Height * .5); } }
public override double Calculate(Shape shape) { return(shape.Perimeter()); }
public override string ToString() { return(Shape.ToRegexString(Stratum.CharacterDefinitionTable, true)); }
public static void webApiControllerAction(Shape shape) { // just call the appropriate printArea for the derived type printArea(shape); }
public override void SyncFormat(Shape formatShape, Shape newShape) { newShape.Top = formatShape.Top; }
/// <summary> /// Creates and returns a new shape owner for a shape and the given entity. /// Applies a given transform to the new shapeOwner. /// </summary> /// <returns>Returns the id of the newly created shapeOwner</returns> public static uint CreateShapeOwnerWithTransform(this CollisionObject entity, Transform transform, Shape shape) { var newShapeOwnerId = entity.CreateShapeOwner(shape); entity.ShapeOwnerAddShape(newShapeOwnerId, shape); entity.ShapeOwnerSetTransform(newShapeOwnerId, transform); return(newShapeOwnerId); }
public Goal(float x, float y, float z, Color rayColor, Shape shape, float collisionRadius, char icon = ' ', ConsoleColor color = ConsoleColor.White) : base(x, y, z, rayColor, shape, collisionRadius, icon, color) { _collisionRadius = collisionRadius; }
public override bool CanCopy(Shape formatShape) { return(true); }
/// <summary>Gets the distance from the border.</summary> /// <param name="shape">The shape of the container control.</param> /// <returns>The internal control distance.</returns> public static int CalculateBorderCurve(Shape shape) { return((shape.Rounding / 2) + shape.Thickness + 1); }
public void Create(Vector3 objectPosition, Vector3 objectScale, Quaternion objectOrientation, int maxPlank, Vector3 plankScale, float plankDistance) { Shape box = scene.Factory.ShapeManager.Find("Box"); Shape box2Convex1 = scene.Factory.ShapeManager.Find("Box2Convex1"); PhysicsObject objectRoot = null; PhysicsObject objectBase = null; objectRoot = scene.Factory.PhysicsObjectManager.Create("Box 2" + instanceIndexName); Vector3 plankScale1 = plankScale; Vector3 plankScale2 = plankScale; plankScale2.X *= 0.5f; for (int i = 0; i < maxPlank; i++) { objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Plank Up " + i.ToString() + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box; objectBase.UserDataStr = "Box"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(i * 2.0f * (plankScale1.X + plankDistance) - maxPlank * (plankScale1.X + plankDistance) + (plankScale1.X + plankDistance), 0.0f, maxPlank * (plankScale1.X + plankDistance) - plankScale1.Z - plankDistance); objectBase.InitLocalTransform.SetScale(plankScale1); objectBase.Integral.SetDensity(1.0f); } for (int i = 0; i < maxPlank; i++) { objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Plank Down " + i.ToString() + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box; objectBase.UserDataStr = "Box"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(i * 2.0f * (plankScale1.X + plankDistance) - maxPlank * (plankScale1.X + plankDistance) + (plankScale1.X + plankDistance), 0.0f, -maxPlank * (plankScale1.X + plankDistance) + plankScale1.Z + plankDistance); objectBase.InitLocalTransform.SetScale(plankScale1); objectBase.Integral.SetDensity(1.0f); } for (int i = 0; i < maxPlank; i++) { objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Plank Right " + i.ToString() + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box; objectBase.UserDataStr = "Box"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(maxPlank * (plankScale1.X + plankDistance) + plankScale1.Z - plankDistance, 0.0f, i * 2.0f * (plankScale1.X + plankDistance) - maxPlank * (plankScale1.X + plankDistance) + (plankScale1.X + plankDistance)); objectBase.InitLocalTransform.SetScale(plankScale1.Z, plankScale1.Y, plankScale1.X); objectBase.Integral.SetDensity(1.0f); } for (int i = 0; i < maxPlank; i++) { objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Plank Left " + i.ToString() + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box; objectBase.UserDataStr = "Box"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(-maxPlank * (plankScale1.X + plankDistance) - plankScale1.Z + plankDistance, 0.0f, i * 2.0f * (plankScale1.X + plankDistance) - maxPlank * (plankScale1.X + plankDistance) + (plankScale1.X + plankDistance)); objectBase.InitLocalTransform.SetScale(plankScale1.Z, plankScale1.Y, plankScale1.X); objectBase.Integral.SetDensity(1.0f); } for (int i = 0; i < maxPlank; i++) { objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Plank Top " + i.ToString() + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box; objectBase.UserDataStr = "Box"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(i * 2.0f * (plankScale1.X + plankDistance) - maxPlank * (plankScale1.X + plankDistance) + (plankScale1.X + plankDistance), plankScale1.Y - plankScale1.Z - plankDistance, 0.0f); objectBase.InitLocalTransform.SetScale(plankScale1.X, plankScale1.Z, maxPlank * (plankScale1.X + plankDistance) - plankDistance); objectBase.Integral.SetDensity(1.0f); } for (int i = 0; i < maxPlank; i++) { objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Plank Bottom " + i.ToString() + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box; objectBase.UserDataStr = "Box"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(i * 2.0f * (plankScale1.X + plankDistance) - maxPlank * (plankScale1.X + plankDistance) + (plankScale1.X + plankDistance), -plankScale1.Y + plankScale1.Z + plankDistance, 0.0f); objectBase.InitLocalTransform.SetScale(plankScale1.X, plankScale1.Z, maxPlank * (plankScale1.X + plankDistance) - plankDistance); objectBase.Integral.SetDensity(1.0f); } objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Up 1" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(-maxPlank * (plankScale1.X + plankDistance) + plankScale2.X + plankDistance, 0.0f, maxPlank * (plankScale1.X + plankDistance) + plankScale2.Z - plankDistance); objectBase.InitLocalTransform.SetScale(ref plankScale2); objectBase.Integral.SetDensity(1.0f); objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Up 2" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(maxPlank * (plankScale1.X + plankDistance) - plankScale2.X - plankDistance, 0.0f, maxPlank * (plankScale1.X + plankDistance) + plankScale2.Z - plankDistance); objectBase.InitLocalTransform.SetOrientation(Quaternion.FromAxisAngle(Vector3.UnitZ, MathHelper.DegreesToRadians(180.0f))); objectBase.InitLocalTransform.SetScale(ref plankScale2); objectBase.Integral.SetDensity(1.0f); objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Up 3" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(0.0f, plankScale1.Y - plankScale2.X, maxPlank * (plankScale1.X + plankDistance) + plankScale2.Z - plankDistance); objectBase.InitLocalTransform.SetOrientation(Quaternion.FromAxisAngle(Vector3.UnitZ, MathHelper.DegreesToRadians(90.0f))); objectBase.InitLocalTransform.SetScale(plankScale2.X, maxPlank * (plankScale1.X + plankDistance) - plankDistance, plankScale2.Z); objectBase.Integral.SetDensity(1.0f); objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Up 4" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(0.0f, -plankScale1.Y + plankScale2.X, maxPlank * (plankScale1.X + plankDistance) + plankScale2.Z - plankDistance); objectBase.InitLocalTransform.SetOrientation(Quaternion.FromAxisAngle(Vector3.UnitZ, MathHelper.DegreesToRadians(-90.0f))); objectBase.InitLocalTransform.SetScale(plankScale2.X, maxPlank * (plankScale1.X + plankDistance) - plankDistance, plankScale2.Z); objectBase.Integral.SetDensity(1.0f); objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Down 1" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(-maxPlank * (plankScale1.X + plankDistance) + plankScale2.X + plankDistance, 0.0f, -maxPlank * (plankScale1.X + plankDistance) - plankScale2.Z + plankDistance); objectBase.InitLocalTransform.SetScale(ref plankScale2); objectBase.Integral.SetDensity(1.0f); objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Down 2" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(maxPlank * (plankScale1.X + plankDistance) - plankScale2.X - plankDistance, 0.0f, -maxPlank * (plankScale1.X + plankDistance) - plankScale2.Z + plankDistance); objectBase.InitLocalTransform.SetOrientation(Quaternion.FromAxisAngle(Vector3.UnitZ, MathHelper.DegreesToRadians(180.0f))); objectBase.InitLocalTransform.SetScale(ref plankScale2); objectBase.Integral.SetDensity(1.0f); objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Down 3" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(0.0f, plankScale1.Y - plankScale2.X, -maxPlank * (plankScale1.X + plankDistance) - plankScale2.Z + plankDistance); objectBase.InitLocalTransform.SetOrientation(Quaternion.FromAxisAngle(Vector3.UnitZ, MathHelper.DegreesToRadians(90.0f))); objectBase.InitLocalTransform.SetScale(plankScale2.X, maxPlank * (plankScale1.X + plankDistance) - plankDistance, plankScale2.Z); objectBase.Integral.SetDensity(1.0f); objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Down 4" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(0.0f, -plankScale1.Y + plankScale2.X, -maxPlank * (plankScale1.X + plankDistance) - plankScale2.Z + plankDistance); objectBase.InitLocalTransform.SetOrientation(Quaternion.FromAxisAngle(Vector3.UnitZ, MathHelper.DegreesToRadians(-90.0f))); objectBase.InitLocalTransform.SetScale(plankScale2.X, maxPlank * (plankScale1.X + plankDistance) - plankDistance, plankScale2.Z); objectBase.Integral.SetDensity(1.0f); objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Top 1" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(-maxPlank * (plankScale1.X + plankDistance) + plankScale2.X + plankDistance, plankScale1.Y + plankScale2.Z, 0.0f); objectBase.InitLocalTransform.SetOrientation(Quaternion.FromAxisAngle(Vector3.UnitX, MathHelper.DegreesToRadians(90.0f))); objectBase.InitLocalTransform.SetScale(plankScale2.X, maxPlank * (plankScale1.X + plankDistance) - plankDistance, plankScale2.Z); objectBase.Integral.SetDensity(1.0f); objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Top 2" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(maxPlank * (plankScale1.X + plankDistance) - plankScale2.X - plankDistance, plankScale1.Y + plankScale2.Z, 0.0f); objectBase.InitLocalTransform.SetOrientation(Quaternion.FromAxisAngle(Vector3.UnitX, MathHelper.DegreesToRadians(90.0f)) * Quaternion.FromAxisAngle(Vector3.UnitZ, MathHelper.DegreesToRadians(180.0f))); objectBase.InitLocalTransform.SetScale(plankScale2.X, maxPlank * (plankScale1.X + plankDistance) - plankDistance, plankScale2.Z); objectBase.Integral.SetDensity(1.0f); objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Top 3" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(0.0f, plankScale1.Y + plankScale2.Z, maxPlank * (plankScale1.X + plankDistance) - plankScale2.X - plankDistance); objectBase.InitLocalTransform.SetOrientation(Quaternion.FromAxisAngle(Vector3.UnitX, MathHelper.DegreesToRadians(90.0f)) * Quaternion.FromAxisAngle(Vector3.UnitY, MathHelper.DegreesToRadians(-90.0f))); objectBase.InitLocalTransform.SetScale(plankScale2.X, maxPlank * (plankScale1.X + plankDistance) - plankDistance, plankScale2.Z); objectBase.Integral.SetDensity(1.0f); objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Top 4" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(0.0f, plankScale1.Y + plankScale2.Z, -maxPlank * (plankScale1.X + plankDistance) + plankScale2.X + plankDistance); objectBase.InitLocalTransform.SetOrientation(Quaternion.FromAxisAngle(Vector3.UnitX, MathHelper.DegreesToRadians(90.0f)) * Quaternion.FromAxisAngle(Vector3.UnitY, MathHelper.DegreesToRadians(90.0f))); objectBase.InitLocalTransform.SetScale(plankScale2.X, maxPlank * (plankScale1.X + plankDistance) - plankDistance, plankScale2.Z); objectBase.Integral.SetDensity(1.0f); objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Bottom 1" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(-maxPlank * (plankScale1.X + plankDistance) + plankScale2.X + plankDistance, -plankScale1.Y - plankScale2.Z, 0.0f); objectBase.InitLocalTransform.SetOrientation(Quaternion.FromAxisAngle(Vector3.UnitX, MathHelper.DegreesToRadians(90.0f))); objectBase.InitLocalTransform.SetScale(plankScale2.X, maxPlank * (plankScale1.X + plankDistance) - plankDistance, plankScale2.Z); objectBase.Integral.SetDensity(1.0f); objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Bottom 2" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(maxPlank * (plankScale1.X + plankDistance) - plankScale2.X - plankDistance, -plankScale1.Y - plankScale2.Z, 0.0f); objectBase.InitLocalTransform.SetOrientation(Quaternion.FromAxisAngle(Vector3.UnitX, MathHelper.DegreesToRadians(90.0f)) * Quaternion.FromAxisAngle(Vector3.UnitZ, MathHelper.DegreesToRadians(180.0f))); objectBase.InitLocalTransform.SetScale(plankScale2.X, maxPlank * (plankScale1.X + plankDistance) - plankDistance, plankScale2.Z); objectBase.Integral.SetDensity(1.0f); objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Bottom 3" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(0.0f, -plankScale1.Y - plankScale2.Z, maxPlank * (plankScale1.X + plankDistance) - plankScale2.X - plankDistance); objectBase.InitLocalTransform.SetOrientation(Quaternion.FromAxisAngle(Vector3.UnitX, MathHelper.DegreesToRadians(90.0f)) * Quaternion.FromAxisAngle(Vector3.UnitY, MathHelper.DegreesToRadians(-90.0f))); objectBase.InitLocalTransform.SetScale(plankScale2.X, maxPlank * (plankScale1.X + plankDistance) - plankDistance, plankScale2.Z); objectBase.Integral.SetDensity(1.0f); objectBase = scene.Factory.PhysicsObjectManager.Create("Box 2 Convex Plank Bottom 4" + instanceIndexName); objectRoot.AddChildPhysicsObject(objectBase); objectBase.Shape = box2Convex1; objectBase.UserDataStr = "Box2Convex1"; objectBase.Material.UserDataStr = "Wood2"; objectBase.Material.RigidGroup = true; objectBase.Material.MinBreakRigidGroupVelocity = 50.0f; objectBase.Material.SetSpecular(0.1f, 0.1f, 0.1f); objectBase.CreateSound(true); objectBase.InitLocalTransform.SetPosition(0.0f, -plankScale1.Y - plankScale2.Z, -maxPlank * (plankScale1.X + plankDistance) + plankScale2.X + plankDistance); objectBase.InitLocalTransform.SetOrientation(Quaternion.FromAxisAngle(Vector3.UnitX, MathHelper.DegreesToRadians(90.0f)) * Quaternion.FromAxisAngle(Vector3.UnitY, MathHelper.DegreesToRadians(90.0f))); objectBase.InitLocalTransform.SetScale(plankScale2.X, maxPlank * (plankScale1.X + plankDistance) - plankDistance, plankScale2.Z); objectBase.Integral.SetDensity(1.0f); objectRoot.InitLocalTransform.SetOrientation(ref objectOrientation); objectRoot.InitLocalTransform.SetScale(ref objectScale); objectRoot.InitLocalTransform.SetPosition(ref objectPosition); scene.UpdateFromInitLocalTransform(objectRoot); }
/// <summary> /// 将一组形状以指定的值定位在Chart的某一坐标轴中。 /// </summary> /// <param name="ShapesToLocate">要进行定位的形状</param> /// <param name="Ax">此形状将要定位的轴</param> /// <param name="Values">此形状在Chart中所处的值</param> /// <param name="percents">将形状按指定的百分比的宽度或者高度的部位定位到坐标轴的指定值的位置。 /// 如果其值设定为0,则表示此形状的左端(或上端)定位在设定的位置处, /// 如果其值为100,则表示此形状的右端(或下端)定位在设置的位置处。</param> /// <remarks></remarks> public static void setPositionInChart(Axis Ax, Shape[] ShapesToLocate, double[] Values, double[] Percents = null) { // ------------------------------------------------------ //检查输入的数组中的元素个数是否相同 int Count = ShapesToLocate.Length; if (Values.Length != Count) { MessageBox.Show("输入数组中的元素个数不相同。", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Percents != null) { if (Percents.Count() != 1 & Percents.Length != Count) { MessageBox.Show("输入数组中的元素个数不相同。", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } // ------------------------------------------------------ Chart cht = (Chart)Ax.Parent; // double max = Ax.MaximumScale; double min = Ax.MinimumScale; // PlotArea PlotA = cht.PlotArea; // ------------------------------------------------------ Shape shp = default(Shape); double Value = 0; double Percent = Percents[0]; double PositionInChartByValue = 0; // ------------------------------------------------------ switch (Ax.Type) { case XlAxisType.xlCategory: //横向X轴 break; case XlAxisType.xlValue: //竖向Y轴 if (Ax.ReversePlotOrder == false) //顺序刻度值,说明Y轴数据为下边小上边大 { for (UInt16 i = 0; i <= Count - 1; i++) { shp = ShapesToLocate[i]; Value = Values[i]; if (Percents.Count() > 1) { Percent = Percents[i]; } PositionInChartByValue = PlotA.InsideTop + PlotA.InsideHeight * (max - Value) / (max - min); shp.Top = (float)(PositionInChartByValue - Percent * shp.Width); } } else //逆序刻度值,说明Y轴数据为上边小下边大 { for (UInt16 i = 0; i <= Count - 1; i++) { shp = ShapesToLocate[i]; Value = Values[i]; if (Percents.Count() > 1) { Percent = Percents[i]; } PositionInChartByValue = PlotA.InsideTop + PlotA.InsideHeight * (Value - min) / (max - min); shp.Top = (float)(PositionInChartByValue - Percent * shp.Width); } } break; case XlAxisType.xlSeriesAxis: MessageBox.Show("暂时不知道这是什么坐标轴", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } }
/// <summary>Creates a border type path.</summary> /// <param name="rectangle">The rectangle.</param> /// <param name="shape">The shape.</param> /// <returns>Border graphics path.</returns> public static GraphicsPath CreateBorderTypePath(Rectangle rectangle, Shape shape) { return(CreateBorderTypePath(rectangle, shape.Rounding, shape.Thickness, shape.Type)); }
public World(Shape sh) { this.shapes = new List<Shape>(); this.addShape(sh); }
/// <summary>Draws a border with the specified shape.</summary> /// <param name="graphics">The graphics to draw on.</param> /// <param name="rectangle">The rectangle.</param> /// <param name="shape">The shape.</param> public static void DrawBorder(Graphics graphics, Rectangle rectangle, Shape shape) { DrawBorder(graphics, rectangle, shape.Color, shape.Rounding, shape.Thickness, shape.Type); }
public void TesselateShape() { CompositeShape compositeShape = entity.Properties.Client.Shape; Shape entityShape = entity.Properties.Client.LoadedShape; if (entityShape == null) { return; } ShapeElement headElement = null; // Only for player entity for now if (entityShape.Elements != null && HeadControl) { headElement = FindHead(entityShape.Elements); } entityShape.ResolveAndLoadJoints(headElement); ITexPositionSource texSource = GetTextureSource(); MeshData meshdata; if (entity.Properties.Client.Shape.VoxelizeTexture) { int altTexNumber = entity.WatchedAttributes.GetInt("textureIndex", 0); TextureAtlasPosition pos = texSource["all"]; CompositeTexture tex = altTexNumber == 0 ? entity.Properties.Client.FirstTexture : entity.Properties.Client.FirstTexture.Alternates[altTexNumber - 1]; meshdata = capi.Tesselator.VoxelizeTexture(tex, capi.EntityTextureAtlas.Size, pos); for (int i = 0; i < meshdata.xyz.Length; i += 3) { meshdata.xyz[i] -= 0.125f; meshdata.xyz[i + 1] -= 0.5f; meshdata.xyz[i + 2] += 0.125f / 2; } curAnimator = new BlendEntityAnimator(entity, new Animation[0], new ShapeElement[0], new Dictionary <int, AnimationJoint>()); } else { string animDictkey = (entity.Code + entity.Properties.Client.Shape.Base.ToString()); try { capi.Tesselator.TesselateShapeWithJointIds("entity", entityShape, out meshdata, texSource, new Vec3f(), compositeShape.QuantityElements, compositeShape.SelectiveElements); } catch (Exception e) { capi.World.Logger.Fatal("Failed tesselating entity {0} with id {1}. Entity will probably be invisible!. The teselator threw {2}", entity.Code, entity.EntityId, e); curAnimator = new BlendEntityAnimator(entity, entityShape.Animations, entityShape.Elements, entityShape.JointsById, headElement); return; } // We cache animations because they are cpu intensive to calculate if (AnimationsByShape.ContainsKey(animDictkey)) { entityShape.Animations = AnimationsByShape[animDictkey]; } else { for (int i = 0; entityShape.Animations != null && i < entityShape.Animations.Length; i++) { entityShape.Animations[i].GenerateAllFrames(entityShape.Elements, entityShape.JointsById); } AnimationsByShape[animDictkey] = entityShape.Animations; } curAnimator = new BlendEntityAnimator(entity, entityShape.Animations, entityShape.Elements, entityShape.JointsById, headElement); } meshdata.Rgba2 = null; if (meshRefOpaque != null) { capi.Render.DeleteMesh(meshRefOpaque); meshRefOpaque = null; } if (meshRefOit != null) { capi.Render.DeleteMesh(meshRefOit); meshRefOit = null; } MeshData opaqueMesh = meshdata.Clone().Clear(); MeshData oitMesh = meshdata.Clone().Clear(); opaqueMesh.AddMeshData(meshdata, EnumChunkRenderPass.Opaque); oitMesh.AddMeshData(meshdata, EnumChunkRenderPass.Transparent); if (opaqueMesh.VerticesCount > 0) { meshRefOpaque = capi.Render.UploadMesh(opaqueMesh); } if (oitMesh.VerticesCount > 0) { meshRefOit = capi.Render.UploadMesh(oitMesh); } }
/// <summary> /// Add a <see cref="Shape"/> to the list of shapes present in the world. /// </summary> /// <param name="sh"></param> public void addShape(Shape sh) => shapes.Add(sh);
public void RemoveNodeShape(Shape shape) { nodesAndShapes.Remove(shape); RemoveShape(shape); }
public ITensor Create(Shape shape, string name) => throw new NotImplementedException();
public Link?GetLinkForShape(Shape shape) => linksAndArrows.Contains(shape) ? linksAndArrows[shape] : (Link?)null;
/// <summary> /// return the direction from a point to the shape. /// </summary> /// <param name="Shape"></param> /// <param name="FromPoint"></param> /// <returns></returns> public SideToShapeInfo(ShapeSide Side, Shape Shape) { this.Side = Side; this.Shape = Shape; WhichDirection? horizDir = null; LineCoordinates horizSide = null; HorizontalIntersect horizIntersect = null; WhichDirection? vertDir = null; LineCoordinates vertSide = null; VerticalIntersect vertIntersect = null; var br = Shape.GetBoundedRect(); if (Side.LineCoor.TopMost > br.Bottom) { vertDir = WhichDirection.Up; horizSide = Shape.GetSide(WhichSide.Bottom); if (Side.LineCoor.IsHorizontal) { horizIntersect = LineCoordinates.HorizontalIntersect(Side.LineCoor, horizSide); } } else if (Side.LineCoor.BottomMost < br.Top) { vertDir = WhichDirection.Down; horizSide = Shape.GetSide(WhichSide.Top); if (Side.LineCoor.IsHorizontal) { horizIntersect = LineCoordinates.HorizontalIntersect(Side.LineCoor, horizSide); } } if (Side.LineCoor.LeftMost > br.Right) { horizDir = WhichDirection.Left; vertSide = Shape.GetSide(WhichSide.Right); if (Side.LineCoor.IsVertical) { vertIntersect = LineCoordinates.VerticalIntersect(Side.LineCoor, vertSide); } } else if (Side.LineCoor.RightMost < br.Left) { horizDir = WhichDirection.Right; vertSide = Shape.GetSide(WhichSide.Left); if (Side.LineCoor.IsVertical) { vertIntersect = LineCoordinates.VerticalIntersect(Side.LineCoor, vertSide); } } // setup the vertical side of the shape that faces the side. if (vertSide == null) { var rightSide = new ShapeSide(Shape, WhichSide.Right); var leftSide = new ShapeSide(Shape, WhichSide.Left); if (Side.RightMost > rightSide.RightMost) { vertSide = rightSide.LineCoor; } else if (Side.LeftMost < leftSide.LeftMost) { vertSide = leftSide.LineCoor; } } // setup the horizontal side of the shape that faces the side. if (horizSide == null) { var bottomSide = new ShapeSide(Shape, WhichSide.Bottom); var topSide = new ShapeSide(Shape, WhichSide.Top); if (Side.BottomMost > bottomSide.BottomMost) { horizSide = bottomSide.LineCoor; } else if (Side.TopMost < topSide.TopMost) { horizSide = topSide.LineCoor; } } this.HorizDirection = horizDir; this.HorizSide = horizSide; this.HorizIntersect = horizIntersect; this.VertDirection = vertDir; this.VertSide = vertSide; this.VertIntersect = vertIntersect; }
public Node GetNodeForShape(Shape shape) => nodesAndShapes.Contains(shape) ? nodesAndShapes[shape] : null;
public void RegisterShapeForNode(Node node, Shape shape) { nodesAndShapes[node] = shape; presentersManager.GetPresenterFor(node).Apply(shape); }