示例#1
0
    private void FixedUpdate()
    {
        Vector3 m3 = Input.mousePosition;

        m3.z = 10;
        m3   = Camera.main.ScreenToWorldPoint(m3);

        if (Input.GetMouseButton(0))
        {
            lineMarkerEnd.SetActive(true);
            lineMarkerEnd.transform.position = m3;


            Vector3[] lineVerts = { intersectionMarker.transform.position, m3 };
            //lineRenderer.SetPositions(lineVerts);
            if (lineRenderer == null)
            {
                FindIntersectionPoint(lineSource.transform.position, m3);
                lineRenderer = PolygonUtilities.DrawLine(line, lineVerts, Color.gray, .02f, "Sprites/Default");
                lineCollider = PolygonUtilities.AddLineCollider(line);
            }
            else
            {
                lineRenderer.SetPositions(lineVerts);
            }
        }
        else
        {
            if (lineRenderer != null)
            {
                PolygonUtilities.SetSizeAndOrient(lineSource.transform, lineRenderer, lineCollider);
            }
        }
    }
    public void Initialize()
    {
        /* Create mesh renderer */
        MeshRenderer meshRenderer = PolygonUtilities.AddMeshRenderer(gameObject, "UI/Default");


        /* Create mesh filter */
        mesh = PolygonUtilities.AddMesh(gameObject);

        vertices = GenerateVertices();

        mesh.vertices = vertices;

        mesh.triangles = GetTriangles();

        mesh.normals = GetNormals();

        mesh.uv = GetUVs();

        meshRenderer.sharedMaterial.color = color;

        /* Create collider for dragging */
        PolygonUtilities.BuildColliderForDrag(gameObject, radius);

        /* Create borders */
        PolygonUtilities.DrawBorder(gameObject, vertices,
                                    borderColor, .08f, "Sprites/Default");

        InitializeTexObjects();

        minY = vertices[0].y;
        Debug.Log(vertices.Length);

        for (int i = 0; i < vertices.Length; i++)
        {
            Debug.Log(vertices[i].y);
            if (minY > vertices[i].y)
            {
                minY = vertices[i].y;
            }
        }

        float v = (radius - minY) / 2;

        midY = v + minY;

        resizeHandles(north, HandlePosition.N);
        resizeHandles(northEast, HandlePosition.NE);
        resizeHandles(northWest, HandlePosition.NW);
        resizeHandles(west, HandlePosition.W);
        resizeHandles(east, HandlePosition.E);
        resizeHandles(southEast, HandlePosition.SE);
        resizeHandles(south, HandlePosition.S);
        resizeHandles(southWest, HandlePosition.SW);
    }
示例#3
0
    private void ScaleW(Vector3 m3)
    {
        Vector3 delta = m3 - mouseLastPosition;

        delta.y = 0;
        delta.x = -1 * delta.x * .25f;
        delta.z = 0;
        Vector3 newScale = targetTransform.localScale + delta;

        PolygonUtilities.ScaleAround(targetTransform.gameObject, polyGenerator.east.transform.position, newScale);
    }
示例#4
0
    // Update is called once per frame
    void Update()
    {
        HealthSlider.value = health;
        if (health <= 0)
        {
            Destroy(gameObject);
        }


        // check if enemy is inside body
        PolygonUtilities BodyPlygonUtilities = Body.GetComponent <PolygonUtilities>();

        Vector2[]            BodyShape            = BodyPlygonUtilities.polygonPoints;
        IsPointInsidePolygon isPointInsidePolygon = Body.GetComponent <IsPointInsidePolygon>();

        IsInsideBody = isPointInsidePolygon.IsPointInPolygon(transform.position, BodyShape);
    }
示例#5
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject       body      = GameObject.Find("Body");
        PolygonUtilities polyUtils = body.GetComponent <PolygonUtilities>();

        Vector2[] bodyPlyPoints = polyUtils.polygonPoints;
        for (int i = 0; i < bodyPlyPoints.Length; i++)
        {
            Vector2 Point = bodyPlyPoints[i];
            Point.x *= 10;
            Point.y *= 10;

            Point.x = Mathf.FloorToInt(Point.x);
            Point.y = Mathf.FloorToInt(Point.y);

            bodyPlyPoints[i] = Point;
        }
        //System.Array.Reverse(bodyPlyPoints);
        vertices2D = bodyPlyPoints;


        Triangulator tr = new Triangulator(vertices2D);

        int[] indices = tr.Triangulate();
        // Create the Vector3 vertices
        Vector3[] vertices = new Vector3[vertices2D.Length];
        for (int i = 0; i < vertices.Length; i++)
        {
            vertices[i] = new Vector3(vertices2D[i].x, vertices2D[i].y, 0);
        }

        // Create the mesh
        Mesh msh = new Mesh();

        msh.vertices  = vertices;
        msh.triangles = indices;
        msh.RecalculateNormals();
        msh.RecalculateBounds();

        // Set up game object with mesh;
        gameObject.AddComponent(typeof(MeshRenderer));
        MeshFilter filter = gameObject.AddComponent(typeof(MeshFilter)) as MeshFilter;

        filter.mesh = msh;
    }
示例#6
0
        public async Task <IActionResult> Export(string data)
        {
            int[] idsToExport = null;
            try
            {
                idsToExport = Array.ConvertAll(data.Split(","), id => int.Parse(id));
            }
            catch (NullReferenceException ex)
            {
                //TODO log ex
                return(StatusCode(500, "data parameter cannot be empty"));
            }
            catch (FormatException ex)
            {
                //TODO log ex
                return(StatusCode(500, "data parameter should be numeric polygons ids seprated  by comma"));
            }

            ConcurrentBag <FileEntity> fileList = new ConcurrentBag <FileEntity>();

            var polygonsRows = await _polymapService.ListPolygonsByIds(idsToExport);

            var apiKey = _config.GetSection("AppSettings").GetSection("MapApiKey").Value;

            Parallel.ForEach(polygonsRows, polygon =>
            {
                fileList.Add(_polymapService.GetPdfFileForPolygon(PolygonUtilities.GetMapUrl(polygon.LocationCoordinates, apiKey), polygon.Id));
            });

            var response = PrepareFileContentRersult(fileList);

            if (response != null)
            {
                return(response);
            }

            return(StatusCode(404, "All polygon ids provided is not exists."));
        }
示例#7
0
    public static void CreateFigure(ObjectType typeOfObject)
    {
        string nameOfObject = typeOfObject.ToString() + "_" + ++_S.objectCount;

        PolygonUtilities.SpawnFigure(nameOfObject, typeOfObject);
    }