コード例 #1
0
 void Awake()
 {
     cutter      = GetComponent <Cutter>();
     cutCollider = GetComponent <Collider>();
     targetPos   = FindObjectOfType <CutterTarget>().transform.position;
     cutAnim     = GetComponent <CutAnim>();
 }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;

        if (Physics.Raycast(start.position, (end.position - start.position), out hit, Vector3.Distance(start.position, end.position), cubeLayer))
        {
            if (!traced)
            {
                if (hit.transform.InverseTransformPoint(hit.point).y > 0.4f)
                {
                    OnHit.Invoke();
                }
                else
                {
                    OnMiss.Invoke();
                }

                Cutter.Cut(hit.transform, hit.point, cutColor);

                traced = true;
            }
        }
        else
        {
            traced = false;
        }



        line.SetPosition(0, start.position);
        line.SetPosition(1, end.position);
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonUp(0))
        {
            Ray        ray = myCamera.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            lastRayOrigin    = ray.origin;
            lastRayDirection = ray.direction;

            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.tag == "Cuttable")
                {
                    float sqr = hit.collider.bounds.size.sqrMagnitude;
                    sqr = sqr / 2;

                    Vector3 direction = Vector3.Cross(-ray.direction, myCamera.transform.TransformDirection(Vector3.forward)).normalized *sqr;

                    lastPoint  = hit.point;
                    lastNormal = direction;

                    Cutter.Cut(hit.collider.gameObject, lastPoint, lastNormal, cutMaterial, fillCut, addRigidbody);
                }
            }
        }

        DrawPlane(lastPoint, lastNormal);
        Debug.DrawRay(lastRayOrigin, lastRayDirection * 100.0f, Color.blue, 10.0f);
    }
コード例 #4
0
ファイル: MeshGenerator.cs プロジェクト: rohitvuppala/BoSSS
 public MeshGenerator(MeshingAlgorithm.State settings)
 {
     cutter          = new Cutter <T>();
     boundingBox     = settings.BoundingBox;
     boundaryLines   = BoundaryLine.ToLines(settings.Boundary);
     boundaryHandler = new PeriodicBoundaryHandler <T>(settings.PeriodicMap);
 }
コード例 #5
0
        public void Convert()
        {
            GerberFile input = new GerberFile(InputPath);

            using (FileStream fs = new FileStream(OutputPath, FileMode.Create, FileAccess.ReadWrite))
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    Cutter cutter = new Cutter(sw);
                    //cutter.PreStartDistance = 0.2;
                    cutter.PostEndDistance = 0.175;
                    cutter.MoveHeight      = 3;
                    cutter.CutterDiameter  = 1;

                    List <ISegment> segments = new List <ISegment>();

                    segments = input.GetSegments();

                    segments = segments.OrderBy(s => s.Heading).ToList();
                    foreach (LineSegment segment in segments)
                    {
                        cutter.Render(segment);
                        Canvas.LineSegment(segment, Scale);
                    }
                }
        }
コード例 #6
0
    void CreateSlicePlane(GameObject obj)
    {
        Vector3 centre = (pointA + pointB) / 2;
        Vector3 up     = Vector3.Cross((pointB - pointA), (pointC - pointA)).normalized;

        Cutter.Cut(obj, centre, up, null, true, true);
    }
コード例 #7
0
ファイル: DrawCut.cs プロジェクト: Naani2203/SpaceCutter
    void CreateSlicePlane()
    {
        Vector3 centre = (pointA + pointB) / 2;
        Vector3 up     = Vector3.Cross((pointA - pointB), (pointA - cam.transform.position)).normalized;


        Cutter.Cut(obj, centre, up, Mat, true, true);
    }
コード例 #8
0
        override public void createGeometry()
        {
            var block = getCityBlock();

            geometry = block.compactness >= 0.7 ?
                       Cutter.radial(block, null, Ward.ALLEY) :
                       Cutter.semiRadial(block, null, Ward.ALLEY);
        }
コード例 #9
0
    public void CutSelection()
    {
        List <string> selection = selectionManager.GetSelection();

        Cutter.DetachMesh(selection.ToArray());

        // Deselect all the current selection
        selectionManager.DeselectAll();
    }
コード例 #10
0
    public override string RenderEx(string text, int id)
    {
        if (string.IsNullOrEmpty(text))
        {
            return(string.Empty);
        }

        return(base.RenderEx(Cutter.Cut(text, id), id));
    }
コード例 #11
0
    private void Start()
    {
        cutter           = GetComponent <Cutter>();
        rb               = GetComponent <Rigidbody2D>();
        asc              = GetComponent <AudioSource>();
        collisionImpulse = GetComponent <CinemachineCollisionImpulseSource>();

        asc.PlayOneShot(fallingSounds[Random.Range(0, fallingSounds.Length)]);
    }
コード例 #12
0
ファイル: GoatEvil.cs プロジェクト: knuke/GoatNinja
  public void Awake()
  {
    playArea = new Plane(new Vector3(0, 0, -1), 0);
    cutter = GetComponent<Cutter>();
    cut = false;
    hp = GameObject.FindGameObjectWithTag("hp").GetComponent<Text>().GetComponent<live>();
    //gascloud = (GameObject)Instantiate(gas, gameObject.transform.position, gameObject.transform.rotation);
    //Destroy(gascloud, 10);

    }
コード例 #13
0
ファイル: Page.cs プロジェクト: belmirojr/dblog
    public virtual string RenderEx(string text, int id)
    {
        if (string.IsNullOrEmpty(text))
        {
            return(string.Empty);
        }

        ReferencesRedirector redirector = new ReferencesRedirector(id, "Post");

        return(Renderer.RenderEx(Cutter.DeleteCut(text), ConfigurationManager.AppSettings["url"], redirector.ReferUri));
    }
コード例 #14
0
 void OnTriggerEnter(Collider other)
 {
     Debug.Log("Test SaberCollision OnTriggerEnter");
     cutter.OnLineDrawn(
         start: trackingPoint.prevPosition,
         end: trackingPoint.currPosition,
         Cutter.GetDepth(
             trackingPoint.prevPosition,
             trackingPoint.currPosition,
             suberRotation.transform.position),
         new GameObject[] { other.gameObject });
 }
コード例 #15
0
 public ActionResult AddCutter(Cutter cutter)
 {
     if (ModelState.IsValid)
     {
         db.Cutters.Add(cutter);
         db.SaveChanges();
         return(RedirectToAction("CutterForm"));
     }
     else
     {
         return(View());
     }
 }
コード例 #16
0
 public ActionResult EditCutter(Cutter cutter)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cutter).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("CutterForm"));
     }
     else
     {
         return(View());
     }
 }
コード例 #17
0
ファイル: CardStorageFactory.cs プロジェクト: ilmen/AliasGame
        public CardStorage GetCardStorage()
        {
            var wordFact = new WordFactory();

            var shuffler = new Shuffler<string>();
            var cutter = new Cutter<string>();
            var cardFact = new CardFactory(10, shuffler, cutter);

            var words = wordFact.GetAllWords();
            var cards = cardFact.GetCards(words);

            return new CardStorage(words, cards);
        }
コード例 #18
0
    void Start()
    {
        _cb = _shape.GetComponent <CustomBoundryBox>();

        _trailrenderer = GetComponent <TrailRenderer>();

        _circle = new Circle(transform.position, _CIRCLE_RADIUS);

        _mainCam  = Camera.main;
        _polygon  = _cb.ToArray();
        _startPos = _cb.PolygonCenter;
        _endPos   = _cb.PolygonCenter;

        _cutter          = new Cutter();
        _distanceFromCam = Mathf.Abs(_mainCam.transform.position.z - _shape.transform.position.z);
    }
コード例 #19
0
    void Start()
    {
        // temp
        control = new PlayerWormController(controllerNum);

        wormEater = head.GetComponent <Cutter>();

        segments.Add(segment);
        for (var i = 1; i < numSegments; i++)
        {
            segments.Add(Instantiate(segment, segment.transform.parent));
        }

        trail = new List <Vector3> {
            head.transform.position
        };
    }
コード例 #20
0
        public static List <Polygon> createAlleys(Polygon p, float minSq, float gridChaos, float sizeChaos, float emptyProb = 0.04f, bool split = true)
        {
            // Looking for the longest edge to cut it
            Point v      = null;
            var   length = -1.0;

            p.forEdge((p0, p1) =>
            {
                var len = (p0.vec - p1.vec).magnitude;
                if (len > length)
                {
                    length = len;
                    v      = p0;
                }
            });

            var spread = 0.8 * gridChaos;
            var ratio  = (1 - spread) / 2 + Random.value * spread;

            // Trying to keep buildings rectangular even in chaotic wards
            var angleSpread = Mathf.PI / 6 * gridChaos * (p.square < minSq * 4 ? 0.0 : 1);
            var b           = (Random.value - 0.5) * angleSpread;

            var halves = Cutter.bisect(p, v, (float)ratio, (float)b, split ? ALLEY : BUILDING_GAP);

            var buildings = new List <Polygon>();

            foreach (var half in halves)
            {
                if (half.square < minSq * Mathf.Pow(2, (float)(4 * sizeChaos * (Random.value - 0.5))))
                {
                    if (Random.value > emptyProb)
                    {
                        buildings.Add(half);
                    }
                }
                else
                {
                    buildings = buildings.Concat(
                        createAlleys(half, minSq, gridChaos, sizeChaos, emptyProb, half.square > minSq / (Random.value * Random.value))
                        ).ToList();
                }
            }

            return(buildings);
        }
コード例 #21
0
 // Når noget rammer knivens trigger, som sidder ved det skarpe stykke på kniven.
 private void OnTriggerEnter(Collider other)
 {
     // Hvis tingen der rammer kniven har tagget "CutableFood".
     if (other.CompareTag("CutableFood") && canCutAgain && pickedUp)
     {
         // Da skæringen foregår med en usynlig plan, udregner vi hvor midten af planen er, og hvad normalvektoren er til planen er.
         // Midten ligger i midten af det skarpe på kniven.
         Vector3 centre = (pointA.position + pointB.position) / 2;
         // Normalvektoren er vektoren for krydsproduktet mellem de tre punkter i planen, med længden 1.
         Vector3 up = Vector3.Cross(pointA.position - centre, pointC.position - centre).normalized;
         // Vi beder nu cutter scriptet om at udregne, hvordan maden skal skæres.
         Cutter.Cut(other.gameObject, centre, up, null, true, true);
         // Der kan nu ikke skæres igen, før kniven er flyttet.
         canCutAgain = false;
         lastCutPos  = transform.position;
     }
 }
コード例 #22
0
        public ActionResult DeleteCutter(int?id)
        {
            welcomInscription();
            if (id == null)
            {
                return(HttpNotFound());
            }

            Cutter b = db.Cutters.Find(id);

            if (b == null)
            {
                return(HttpNotFound());
            }

            return(View(b));
        }
コード例 #23
0
        public ActionResult EditCutter(int?id)
        {
            welcomInscription();
            if (id == null)
            {
                return(HttpNotFound());
            }

            Cutter cutters = db.Cutters.Find(id);

            if (cutters == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Id = cutters.Id;
            return(View(cutters));
        }
コード例 #24
0
        public ActionResult DeleteConfirmed(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            Cutter b = db.Cutters.Find(id);

            if (b == null)
            {
                return(HttpNotFound());
            }

            db.Cutters.Remove(b);
            db.SaveChanges();
            return(RedirectToAction("CutterForm"));
        }
コード例 #25
0
        public IActionResult LinkEdit(Link model)
        {
            if (ModelState.IsValid)
            {
                if (repo.AlreadyInBD(model))
                {
                    ViewBag.Error = "Ссылка уже есть в базе данных";
                    return(View(model));
                }

                model.CreationTime = DateTime.Now.ToString("dd:MM:yyyy");
                model.ShortName    = Cutter.GetShortLink();
                repo.SaveLink(model);
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
コード例 #26
0
    private void OnTriggerEnter(Collider col)
    {
        var fruit = col.GetComponent <Fruit>();

        if (fruit != null)
        {
            Slice?.Invoke();

            Vector2 contactPoint = col.ClosestPoint(_collider.transform.position);

            Vector3 normal = new Vector3(direction.y, -direction.x, 0);


            Destroy(Instantiate(fruit.vfx, col.transform.position, Quaternion.FromToRotation(fruit.vfx.transform.right, direction)), 2);
            Cutter.CutGameobject(col.gameObject, contactPoint, normal, true);

            Destroy(col.gameObject);
        }
    }
コード例 #27
0
        public IActionResult CreateLink([FromForm] string url)
        {
            if (string.IsNullOrWhiteSpace(url))
            {
                ModelState.AddModelError("", "Поле не может быть пустым.");
                return(View());
            }
            if (!url.Contains("http"))
            {
                url = "http://" + url;
            }
            var baseUrl = $"{Request.Scheme}://{Request.Host}/"; // Создание базовой ссылки нашего хоста
            var cut     = new Cutter();

            var urls = db.CuttLinks.ToList();

            if (urls.Count == 0)
            {
                cut.GenerateToken();
            }
            else
            {
                // проверяем на совпадение токенов
                // каждый раз создается новый токен
                while (urls.Exists(u => u.Token == cut.GenerateToken().Token))
                {
                    ;
                }
            }

            var cutUrl = new CuttLink
            {
                Url      = url,
                Token    = cut.Token,
                ShortUrl = baseUrl + cut.Token
            };

            db.CuttLinks.Add(cutUrl);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
コード例 #28
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
            {
                GameObject victim = hit.collider.gameObject;
                if (victim.tag != "Safe")
                {
                    if (angle == Angle.Up)
                    {
                        Cutter.Cut(victim, hit.point, Vector3.up, null, true, true);
                    }
                    else if (angle == Angle.Forward)
                    {
                        Cutter.Cut(victim, hit.point, Vector3.forward, null, true, true);
                    }
                }
            }
        }
    }
コード例 #29
0
ファイル: Program.cs プロジェクト: ultrasonic59/StencilG
        static void Main(string[] args)
        {
            string     path  = Path.Combine(Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath), "test.gcode");
            GerberFile input = new GerberFile("C:\\Users\\Master\\Documents\\TestSMT.ger");

            using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.ReadWrite))
                using (StreamWriter sw = new StreamWriter(fs)){
                    Cutter cutter = new Cutter(sw);
                    //cutter.PreStartDistance = 0.2;
                    cutter.PostEndDistance = 0.175;
                    cutter.MoveHeight      = 3;
                    cutter.CutterDiameter  = 1;

                    List <ISegment> segments = new List <ISegment>();

                    segments = input.GetSegments();

                    segments = segments.OrderBy(s => s.Heading).ToList();
                    foreach (LineSegment segment in segments)
                    {
                        cutter.Render(segment);
                    }
                }
        }
コード例 #30
0
ファイル: Goat.cs プロジェクト: knuke/GoatNinja
 public void Awake()
 {
   playArea = new Plane(new Vector3(0, 0, -1), 0);
   cutter = GetComponent<Cutter>();
   cut = false;
 }
コード例 #31
0
        //private-----------------------------------------------------------------
        private MetaData parseMastercamAPT(Queue <string> lines)
        {
            string   line;
            Indirv   current_indirv   = new Indirv();
            Point    current_position = new Point(0.0, 0.0, 0.0);
            int      current_tool     = -1;
            MetaData metadata         = new MetaData();

            while (!lines.Peek().Contains("FINI"))//data parsing
            {
                if (lines.Peek().Contains("$$Machine Group-"))
                {
                    MachineGroup mg = new MachineGroup();
                    mg.ID = Convert.ToInt32(lines.Peek().Substring("$$Machine Group-".Length));

                    while (!lines.Peek().Contains("FINI") || (lines.Peek().Contains("$$Machine Group-") && (Convert.ToInt32(lines.Peek().Substring("$$Machine Group-".Length)) == mg.ID)))
                    {
                        lines.Dequeue();
                        ToolpathGroup tpg = new ToolpathGroup();
                        tpg.ID++;

                        while (!lines.Peek().Contains("$$Machine Group-") && !lines.Peek().Contains("FINI"))
                        {
                            line = lines.Dequeue();
                            if (line.Contains("PARTNO/"))
                            {
                                metadata.PartNo = line.Substring("PARTNO/".Length);
                                continue;
                            }

                            if (line.Contains("UNITS/"))
                            {
                                metadata.Units = line.Substring("UNITS/".Length);
                                metadata.Units = metadata.Units.Replace(" ", string.Empty);
                                continue;
                            }

                            if (line.Contains("MULTAX/"))
                            {
                                metadata.Multax = line.Substring("MULTAX/".Length);
                                metadata.Multax = metadata.Multax.Replace(" ", string.Empty);
                                continue;
                            }

                            //if (line.Contains("MACHIN/"))
                            //{
                            //    string[] substrings = Regex.Split(line.Substring("MACHIN/".Length), ",");
                            //    metadata.Machin = substrings[0].Replace(" ", string.Empty);
                            //    continue;
                            //}

                            if (line.Contains("CUTTER/"))
                            {
                                Cutter   tool       = new Cutter();
                                string[] substrings = Regex.Split(line.Substring("CUTTER/".Length), ",");
                                tool.Diameter = Convert.ToDouble(substrings[0].Replace(" ", string.Empty));
                                //tpg.tpgtool.length = Convert.ToDouble(substrings[1].Replace(" ", string.Empty));

                                line      = lines.Dequeue();
                                tool.Name = line.Substring("TPRINT/".Length);

                                line = lines.Dequeue();
                                string[] substrings2 = Regex.Split(line.Substring("LOAD/".Length), ",");
                                current_tool = tpg.Tool = tool.ID = Convert.ToInt32(substrings2[1].Replace(" ", string.Empty).Replace(".", string.Empty));

                                if (!metadata.CutterTools.ContainsKey(tool.ID))
                                {
                                    metadata.CutterTools.Add(tool.ID, tool);
                                }

                                continue;
                            }

                            if (line.Contains("RAPID"))
                            {
                                tpg.MachiningData.Add(new Rapid());
                                continue;
                            }

                            if (line.Contains("GOTO/"))
                            {
                                GoTo gotoxyz = new GoTo();
                                gotoxyz.parseGoto(line);
                                tpg.MachiningData.Add(gotoxyz);
                                current_position = gotoxyz.point;
                                continue;
                            }

                            if (line.Contains("INDIRV/"))
                            {
                                Indirv indirv = new Indirv();
                                indirv.parseIndirv(line);
                                tpg.MachiningData.Add(indirv);
                                current_indirv = indirv;
                                continue;
                            }

                            if (line.Contains("CIRCLE/"))
                            {
                                Circle circle = new Circle();
                                circle.parseCircle(current_indirv, current_position, line, lines.Dequeue(), lines.Dequeue());
                                tpg.MachiningData.Add(circle);
                                current_position = circle.endpoint;
                                continue;
                            }

                            if (line.Contains("FEDRAT/"))
                            {
                                Feedrate fedrat = new Feedrate();
                                fedrat.parseFedrat(line);
                                tpg.MachiningData.Add(fedrat);
                                continue;
                            }

                            if (line.Contains("SPINDL/"))
                            {
                                SpindleSpeed spindle = new SpindleSpeed();
                                spindle.parseSpindleSpeed(line);
                                tpg.MachiningData.Add(spindle);
                                continue;
                            }

                            if (line.Contains("COOLNT/"))
                            {
                                Coolant coolant = new Coolant();
                                coolant.parseCoolant(line);
                                tpg.MachiningData.Add(coolant);
                                continue;
                            }
                        }
                        if (tpg.Tool == -1)
                        {
                            tpg.Tool = current_tool;
                        }

                        mg.Operations.Add(tpg);     //add toolpath to list
                    }
                    metadata.MachineGroups.Add(mg); //add current machine group to list
                }
                else
                {
                    lines.Dequeue();
                }
            }
            lines.Dequeue();
            return(metadata);
        }
コード例 #32
0
 public override void createGeometry()
 {
     geometry = Random.value < (0.4) ?
                Cutter.ring(getCityBlock(), 2 + Random.value * 4) :
                Ward.createOrthoBuilding(getCityBlock(), 50, 0.8f);
 }
コード例 #33
0
    // Update is called once per frame
    void Update()
    {
        if (!dragging && Input.GetMouseButtonDown(0))
        {
            start    = cam.ScreenToViewportPoint(Input.mousePosition);
            dragging = true;
        }

        if (dragging)
        {
            end = cam.ScreenToViewportPoint(Input.mousePosition);

            //* WE FIND THE OBJECT THAT INTERSECT WITH THE CUT *****************
            // Create the ray
            Ray ray = rayProvider.CreateRay();
            // Debug.Log(ray);

            // Check if the ray hits a selectable object
            selector.check(ray);
            // Get the selection
            if (selector.GetSelection() != null)
            {
                selection = selector.GetSelection();
            }
        }

        if (dragging && Input.GetMouseButtonUp(0))
        {
            // Finished dragging. We compute the direction of the vector formed by start and end
            end          = cam.ScreenToViewportPoint(Input.mousePosition);
            dragging     = false;
            cutDirection = end - start;

            // Debug.Log("Direction: " + cutDirection);
            if (selection != null)
            {
                // Debug.Log("Selection: " + selection.gameObject.transform + ", " + selection.name);
                // var coeffs = ParallelismCoefficient(selection, cutDirection, 0.0f);

                /*
                 * GameObject plane = GameObject.Find("PlaneCutter");
                 * plane.transform.position = selection.position;
                 * plane.transform.rotation = Quaternion.LookRotation(cutDirection);
                 */
                if (isCutting)
                {
                    Debug.Log("Selection: " + selection);
                    if (selection.parent != null)
                    {
                        Cutter.SplitOBJ(selection.parent.gameObject, selection, cutDirection);
                    }
                    else
                    {
                        Cutter.SplitOBJ(selection.gameObject, selection, cutDirection);
                    }
                }
            }
        }

        // Separate the object if we do not drag anymore and the
    }
コード例 #34
0
ファイル: ImageHelper.cs プロジェクト: shaohaiou/comopp
        /// <summary>
        /// 产生新的图片
        /// </summary>
        /// <param name="oldImage">原来的图片</param>
        /// <param name="cut">裁剪信息实体类</param>
        /// <returns></returns>
        public static Bitmap GenerateBitmap(Image oldImage, Cutter cut)
        {
            if (oldImage == null)
                throw new ArgumentNullException("oldImage");//源图片不存在

            Image newBitmap = new Bitmap(cut.SaveWidth, cut.SaveHeight);
            //重画源图片
            using (Graphics g = Graphics.FromImage(newBitmap))
            {
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.CompositingQuality = CompositingQuality.HighQuality;
                g.DrawImage(oldImage, new Rectangle(0, 0, cut.SaveWidth, cut.SaveHeight), new Rectangle(0, 0, cut.Width, cut.Height), GraphicsUnit.Pixel);
                g.Save();
            }

            Bitmap bmp = new Bitmap(cut.CutterWidth, cut.CutterHeight);

            using (Graphics g = Graphics.FromImage(bmp))
            {
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.CompositingQuality = CompositingQuality.HighQuality;
                g.DrawImage(newBitmap, 0, 0, new Rectangle(cut.X, cut.Y, cut.CutterWidth, cut.CutterHeight), GraphicsUnit.Pixel);
                g.Save();
                newBitmap.Dispose();
            }
            return bmp;
        }