private void GetComponents()
 {
     meshGen         = GetComponent <MeshGenerator>();
     _randomSprite   = GetComponent <RandomSprite>();
     _planeBuilder   = GetComponent <PlaneBuilder>();
     signNumber      = GetComponent <NumberExample>();
     _navMeshSurface = GetComponentInParent <NavMeshSurface>();
 }
Ejemplo n.º 2
0
    public static Mesh CreateOnlyBackUntextured(PlaneBuilder builder)
    {
        int numberOfVerticesWidth  = builder.NumberOfSegmentsWidth + 1;
        int numberOfVerticesHeight = builder.NumberOfSegmentsHeight + 1;
        int numberOfVertices       = numberOfVerticesWidth * numberOfVerticesHeight;

        float segmentSizeWidth  = builder.Width / builder.NumberOfSegmentsWidth;
        float segmentSizeHeight = builder.Height / builder.NumberOfSegmentsHeight;

        Vector3[] vertices  = new Vector3[numberOfVertices];
        Vector2[] uvs       = null;
        int[]     triangles = new int[builder.NumberOfSegmentsWidth * builder.NumberOfSegmentsHeight * 6];

        Vector2 shifts = CalculatePivotShift(builder.Pivot, builder.Width, builder.Height);

        Quaternion rotation = Quaternion.Euler(builder.Rotation);

        for (int y = 0; y < numberOfVerticesHeight; y++)
        {
            for (int x = 0; x < numberOfVerticesWidth; x++)
            {
                int n = y * numberOfVerticesWidth + x;

                vertices[n] = rotation * new Vector3(x * segmentSizeWidth - shifts[0], y * segmentSizeHeight - shifts[1], 0);
            }
        }

        int index = 0;

        for (int y = 0; y < builder.NumberOfSegmentsHeight; y++)
        {
            for (int x = 0; x < builder.NumberOfSegmentsWidth; x++)
            {
                triangles[index]     = y * numberOfVerticesWidth + x;
                triangles[index + 1] = y * numberOfVerticesWidth + (x + 1);
                triangles[index + 2] = (y + 1) * numberOfVerticesWidth + x;

                triangles[index + 3] = y * numberOfVerticesWidth + (x + 1);
                triangles[index + 4] = (y + 1) * numberOfVerticesWidth + (x + 1);
                triangles[index + 5] = (y + 1) * numberOfVerticesWidth + x;
                index += 6;
            }
        }

        Mesh mesh = new Mesh()
        {
            vertices  = vertices,
            triangles = triangles,
            uv        = uvs,
        };

        mesh.RecalculateNormals();

        return(mesh);
    }
Ejemplo n.º 3
0
    public List <IMazeElement> GetNeighboursOfMazeElement(IMazeElement mazeElement)
    {
        List <IMazeElement> NeighboursList = new List <IMazeElement>();

        NeighboursList.Add(PlaneBuilder.GetFromMazeArray(Mathf.Clamp((int)mazeElement.Index.x - 1, 0, (int)PlaneBuilder.IntagerNumberOfMazeElementsOnXAndY.x - 1), (int)mazeElement.Index.y));
        NeighboursList.Add(PlaneBuilder.GetFromMazeArray(Mathf.Clamp((int)mazeElement.Index.x + 1, 0, (int)PlaneBuilder.IntagerNumberOfMazeElementsOnXAndY.x - 1), (int)mazeElement.Index.y));
        NeighboursList.Add(PlaneBuilder.GetFromMazeArray((int)mazeElement.Index.x, Mathf.Clamp((int)mazeElement.Index.y - 1, 0, (int)PlaneBuilder.IntagerNumberOfMazeElementsOnXAndY.y - 1)));
        NeighboursList.Add(PlaneBuilder.GetFromMazeArray((int)mazeElement.Index.x, Mathf.Clamp((int)mazeElement.Index.y + 1, 0, (int)PlaneBuilder.IntagerNumberOfMazeElementsOnXAndY.y - 1)));


        return(NeighboursList);
    }
Ejemplo n.º 4
0
    void Awake()
    {
        MazeElementBounds = MazeElementPrefab.GetComponent <SpriteRenderer>().bounds;
        GamePlaneBounds   = new Bounds(transform.Find("Sprite").position, transform.Find("Sprite").GetComponent <SpriteRenderer>().bounds.size);

        MazeElementAndGapSumOn = new Vector2(MazeElementSidesLenght.x + MazeElementGapBetween, MazeElementSidesLenght.y + MazeElementGapBetween);

        gamePlaneBuilder = new PlaneBuilder(
            new FirstUpLeftMazeElementPositionProvider(this, this),
            new NumberOfMazeElementsInGamePlaneArea(this),
            this,
            this);
        CreateGamePlaneGridInScene();
    }
Ejemplo n.º 5
0
    public void _2_2_GetNeighboursOfMazeElement_CheckIfresultIsEqualWithCorrect()
    {
        Vector2       gamePlaneSize = new Vector2(10, 10);
        IPlaneBuilder planeBoundry  = GetPlaneBuilderMock(gamePlaneSize);
        PlaneBuilder  planeBuilder  = Substitute.For <PlaneBuilder>();

        planeBuilder.SetPlaneController(planeBoundry);

        IMazeElement        currentMazeElement       = planeBoundry.GetFromMazeArray(2, 8);
        List <IMazeElement> neighbourMazeElementList = planeBuilder.GetNeighboursOfMazeElement(currentMazeElement);

        List <IMazeElement> list = CreateNeighbourList(planeBoundry, currentMazeElement);

        Assert.AreEqual(neighbourMazeElementList, list);
    }
Ejemplo n.º 6
0
        public string Post([FromBody] List <JObject> value)
        {
            string result;

            try
            {
                //llama la estructura del conector

                DataSet structure = new DataSet();

                SQLTransaction ejecutar = new SQLTransaction();
                structure  = ejecutar.GetStruct();
                planeBuild = new PlaneBuilder();


                if (value != null)
                {
                    plane.Append(planeBuild.BuildInitial(structure, value[0]));                  //construye linea inicial

                    for (int j = 0; j < value.Count; j++)                                        //recorre la lista de registros a enviar
                    {
                        string  ConectorType = (string)value[j]["Conector"];                     //extrae el nombre del conector
                        JObject json         = value[j];                                         //extrae json del conector a enviar

                        plane.Append(planeBuild.BuildMasters(structure, json, ref consectLine)); //construye encabezados o maestros
                        string Pano = plane.ToString();
                        plane.Append(planeBuild.BuildDetails(structure, json, ref consectLine)); //construye movimientos
                    }

                    plane.Append(planeBuild.BuildFinal(structure, value[0], ref consectLine));//construye linea final


                    string Plano             = plane.ToString();
                    String PlanoSinEtiquetas = Plano.Replace("<Linea>", "").Replace("</Linea>", "");
                    string cia = PlanoSinEtiquetas.Substring(17, 1);
                    //var SavePlane = new StreamWriter($@"C:\inetpub\wwwroot\SKYApi\planos\Pedido{DateTime.Now.ToString("ddMMyyyy")}.txt");
                    //SavePlane.WriteLine(PlanoSinEtiquetas);
                    //SavePlane.Close();
                    result = planeBuild.SendInformationWS(Plano, cia);
                    return(result);
                }
                return("No se envio ningun Body..");
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
    // Update is called once per frame
    void Update()
    {
        PlaneBuilder planeBuilder = new PlaneBuilder();

        planeBuilder.SetUpSubmeshes(subMeshSize);

        MeshFilter   meshFilter   = this.GetComponent <MeshFilter>();
        MeshRenderer meshrenderer = this.GetComponent <MeshRenderer>();
        MeshCollider meshcollider = this.GetComponent <MeshCollider>();

        //create points of plane
        Vector3[,] points = new Vector3[width, height];

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                points[x, y] = new Vector3(cellSize * x, cellSize * y);
            }
        }


        //create the quads

        int submesh = 0;

        for (int x = 0; x < width - 1; x++)
        {
            for (int y = 0; y < height - 1; y++)
            {
                Vector3 bRight = points[x, y];
                Vector3 bLeft  = points[x + 1, y];
                Vector3 tRight = points[x, y + 1];
                Vector3 tLeft  = points[x + 1, y + 1];

                //create 2 triangles that make up a quad
                planeBuilder.BuildMeshTriangle(bLeft, tRight, tLeft, submesh % subMeshSize);
                planeBuilder.BuildMeshTriangle(bLeft, bRight, tRight, submesh % subMeshSize);
            }

            submesh++;
        }

        meshFilter.mesh         = planeBuilder.CreateMesh();
        meshcollider.sharedMesh = meshFilter.mesh;
        planeBuilder.AddMaterials(meshrenderer);
    }
Ejemplo n.º 8
0
    public static Mesh Create(PlaneBuilder builder)
    {
        if (!builder.FrontSided && !builder.BackSided)
        {
            return(null);
        }

        // Generate only front side
        if (builder.FrontSided && !builder.BackSided)
        {
            // with UV
            if (builder.GenerateUvMap)
            {
                return(CreateOnlyFrontTextured(builder));
            }
            else
            {
                return(CreateOnlyFrontUntextured(builder));
            }
        }
        // Generate only back side
        else if (!builder.FrontSided && builder.BackSided)
        {
            // with UV
            if (builder.GenerateUvMap)
            {
                return(CreateOnlyBackTextured(builder));
            }
            else
            {
                return(CreateOnlyBackUntextured(builder));
            }
        }
        // Generate double sided
        else
        {
            // with UV
            if (builder.GenerateUvMap)
            {
                return(CreateDoubleSidedTextured(builder));
            }
            else
            {
                return(CreateDoubleSidedUntextured(builder));
            }
        }
    }
Ejemplo n.º 9
0
        public void PlaneBuilderBuildsProperPlaneTest()
        {
            var plane = new PlaneBuilder();

            var result = plane.SetProductionYear(1997)
                         .SetBrand("Audi")
                         .SetKerbWeight(1000)
                         .SetColor(Color.Pink)
                         .SetMaxVelosity(300)
                         .Build();

            Assert.AreEqual(1997, result.ProductionYear);
            Assert.AreEqual("Audi", result.Brand);
            Assert.AreEqual(1000, result.KerbWeight);
            Assert.AreEqual(Color.Pink, result.Color);
            Assert.AreEqual(300, result.MaxVelocity);
        }
Ejemplo n.º 10
0
    void buildGround()
    {
        PlaneBuilder pBuilder = new PlaneBuilder();
        for (int x =0; x < mapSize -1; x++) //-1 as the bottom left of the quad is x/y but top left is x+1/y+1
        {
            for (int y =0; y < mapSize -1; y++)
            {
                Vector3[] verts = new Vector3[4];
                verts[0] = getHeight(x,y);
                verts[1] = getHeight(x +1,y);
                verts[2] = getHeight(x,y +1);
                verts[3] = getHeight(x +1,y +1);
                pBuilder.addQuad(verts);

            }
        }
        GetComponent<MeshFilter> ().mesh = pBuilder.compileMesh();//low polly map
    }
Ejemplo n.º 11
0
    Mesh getHighPollyQuad(int x, int y)
    {
        if(x < 0 || y < 0 || x > cityW.mapSize|| y > cityW.mapSize)
            Debug.LogError("the quad specified at " + x +", "+ y+" can not be found");

        x *= quadResolution;
        y *= quadResolution;
        PlaneBuilder plane = new PlaneBuilder();

        for(int xIndex =0; xIndex < quadResolution -1; xIndex++)
        {
            for(int yIndex =0; yIndex < quadResolution -1; yIndex++)
            {
                 //detailedHeightMap[x + xIndex,y + yIndex];
                addQuad(x + xIndex,y + yIndex, ref plane);
            }
        }
        return plane.compileMesh();
    }
Ejemplo n.º 12
0
    public void CreateGamePlaneGridInScene()
    {
        PlaneBuilder.IntagerNumberOfMazeElementsOnXAndY = numberOfMazeElementsInGamePlaneArea.IntagerNumberOfMazeElementOnXAndYAxisInGamePlaneArea();
        Vector3 positionOfMazeElement;
        Vector3 positionOfFirstUpLeftMazeElement            = firstUpLeftMazeElementPositionProvider.PositionOfFirstUpLeftMazeElementOnGamePlaneArea();
        Vector2 distanceBetweenTwoMazeElementsCentersOnAxis = CountDistanceBetweenTwoMazeElementsCentersOnAxis();

        PlaneBuilder.InitMazeArray();
        for (int i = 0; i < PlaneBuilder.IntagerNumberOfMazeElementsOnXAndY.x; i++)
        {
            positionOfMazeElement.x = positionOfFirstUpLeftMazeElement.x + i * distanceBetweenTwoMazeElementsCentersOnAxis.x;
            for (int j = 0; j < PlaneBuilder.IntagerNumberOfMazeElementsOnXAndY.y; j++)
            {
                positionOfMazeElement.y = positionOfFirstUpLeftMazeElement.y - j * distanceBetweenTwoMazeElementsCentersOnAxis.y;
                positionOfMazeElement.z = PlaneElementsBounds.GamePlaneBounds.center.z - 1;

                PlaneBuilder.CreateMazeElementPrefab(positionOfMazeElement, i, j);
            }
        }
    }
    public override void OnInspectorGUI()
    {
        planeMonoBehaviour = (PlaneMonoBehaviour)target;
        planeBuilder       = planeMonoBehaviour.Builder;

        BasePrimitiveMonoBehaviourEditor <PlaneBuilder> .GenerateBaseFields(planeBuilder);

        EditorGUI.BeginDisabledGroup(!planeBuilder.FrontSided && !planeBuilder.BackSided);

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Plane Settings", EditorStyles.boldLabel);
        planeBuilder.SetWidth(EditorGUILayout.FloatField("Width", planeBuilder.Width));
        planeBuilder.SetHeight(EditorGUILayout.FloatField("Height", planeBuilder.Height));

        planeBuilder.SetNumberOfSegmentsWidth(EditorGUILayout.IntField("Number Of Segments Width", planeBuilder.NumberOfSegmentsWidth));
        planeBuilder.SetNumberOfSegmentsHeight(EditorGUILayout.IntField("Number Of Segments Height", planeBuilder.NumberOfSegmentsHeight));

        EditorGUI.EndDisabledGroup();

        planeMonoBehaviour.RecreateMesh();
    }
Ejemplo n.º 14
0
        private void Form1_Load(object sender, EventArgs e)
        {
            SQLTransaction ejecutar   = new SQLTransaction();
            DataSet        structure  = new DataSet();
            PlaneBuilder   planeBuild = new PlaneBuilder();

            string filePath = @"C:\Interfaz_tu_compra\Excel_de_carque";//RUTA DONDE VA A LEER EXCEL

            try
            {
                //MessageBox.Show("inicio proceso");

                DirectoryInfo di = new DirectoryInfo(filePath);
                foreach (var fi in di.GetFiles("*.xlsx"))
                {
                    //MessageBox.Show("leyo archivo");

                    var                  file      = filePath + @"\" + fi.Name;
                    SLDocument           s1        = new SLDocument(file);
                    int                  idRow     = 2;
                    List <DoctoContable> jsonExcel = new List <DoctoContable>();

                    while (!string.IsNullOrEmpty(s1.GetCellValueAsString(idRow, 1)))//RECORRE EL EXCEL LEIDO
                    {
                        DoctoContable reg = new DoctoContable();

                        var cuenta = s1.GetCellValueAsString(idRow, 1);//VALIDA PARA QUE CUENTA SE VA A IR
                        if (cuenta == "11100503")
                        {
                            reg.F351_ID_AUXILIAR     = "11100503";
                            reg.F351_ID_FE           = "110201";
                            reg.F351_ID_TERCERO      = "";
                            reg.F351_DOCTO_BANCO     = "CG";
                            reg.F351_NRO_DOCTO_BANCO = s1.GetCellValueAsDateTime(idRow, 3).ToString("yyyyMMdd");
                        }
                        else if (cuenta == "53051502")
                        {
                            reg.F351_ID_AUXILIAR     = "53051502";
                            reg.F351_ID_FE           = "";
                            reg.F351_ID_TERCERO      = "890300279";
                            reg.F351_DOCTO_BANCO     = "";
                            reg.F351_NRO_DOCTO_BANCO = "0";
                        }
                        else
                        {
                            reg.F351_ID_AUXILIAR     = "28050502";
                            reg.F351_ID_FE           = "";
                            reg.F351_ID_TERCERO      = "890300279";
                            reg.F351_DOCTO_BANCO     = "";
                            reg.F351_NRO_DOCTO_BANCO = "0";
                        }
                        reg.F351_NOTAS = "SE RECLASIFICAN PAGOS TU COMPRA DEL DIA " + DateTime.Now.ToString("yyyyMMdd");

                        var tipo = s1.GetCellValueAsString(idRow, 4);//VALIDA SI ES DEBITO O CREDITO
                        if (tipo == "DB")
                        {
                            reg.F351_VALOR_DB = s1.GetCellValueAsString(idRow, 2);
                        }
                        else
                        {
                            reg.F351_VALOR_CR = s1.GetCellValueAsString(idRow, 2);
                        }

                        jsonExcel.Add(reg);
                        idRow++;
                    }



                    string fecha = DateTime.Now.ToString("yyyyMMdd");
                    fecha = @"""" + fecha + @"""";                                            //COMILLA DOBLE EN FECHA
                    string jsonDocto = JsonConvert.SerializeObject(jsonExcel);                //CONVERSION OBJETO EN JSON
                    jsonDocto = @"{ ""Conector"": ""Docto_Contable"",""F350_FECHA"":" + fecha //ADICION DE ENCABEZADO EN JSON DE DOCTO CONTABLE
                                + @",""F350_NOTAS"": ""SE RECLASIFICAN PAGOS TU COMPRA DEL DIA " + DateTime.Now.ToString("yyyyMMdd")
                                + @" "",""Movto_Contable"":" + jsonDocto + "}";

                    structure = ejecutar.GetStruct();//CONSULTA LA ESTRUCTURA

                    StringBuilder  plane       = new StringBuilder();
                    int            consectLine = 1;
                    JObject        jsonValue   = JObject.Parse(jsonDocto);
                    List <JObject> value       = new List <JObject>();
                    value.Add(jsonValue);

                    //MessageBox.Show("armo json");

                    if (value != null)                                                               //ARMA EL PLANO CON BASE EN EL JSON Y LA ESTRUCTURA
                    {
                        plane.Append(planeBuild.BuildInitial(structure, value[0]));                  //construye linea inicial

                        for (int j = 0; j < value.Count; j++)                                        //recorre la lista de registros a enviar
                        {
                            string  ConectorType = (string)value[j]["Conector"];                     //extrae el nombre del conector
                            JObject json         = value[j];                                         //extrae json del conector a enviar

                            plane.Append(planeBuild.BuildMasters(structure, json, ref consectLine)); //construye encabezados o maestros
                            string Pano = plane.ToString();
                            plane.Append(planeBuild.BuildDetails(structure, json, ref consectLine)); //construye movimientos
                        }

                        plane.Append(planeBuild.BuildFinal(structure, value[0], ref consectLine));//construye linea final

                        //MessageBox.Show("armo plano");

                        string Plano     = plane.ToString();
                        var    SavePlane = new StreamWriter($@"C:\Interfaz_tu_compra\Txt_unoee\{fi.Name}.txt");
                        SavePlane.WriteLine(Plano);
                        SavePlane.Close();

                        //MessageBox.Show("guardo plano");

                        fi.MoveTo($@"C:\Interfaz_tu_compra\Excel_de_carque\procesados\{fi.Name}");

                        //MessageBox.Show("movio plano");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw ex;
            }
            finally
            {
                Application.Exit();
            }
        }
Ejemplo n.º 15
0
    float[,] detailedHeightMap = null; //stored as a connected array

    #endregion Fields

    #region Methods

    void addQuad(int x, int y, ref PlaneBuilder pBuilder)
    {
        Vector3[] quadVerts = new Vector3[4]{getVert(x,y),getVert(x +1,y),getVert(x,y + 1),getVert(x + 1,y + 1)};
        //print(getVert(x,y).y);
        pBuilder.addQuad(quadVerts);
    }
 private void Awake()
 {
     planeMonoBehaviour = (PlaneMonoBehaviour)target;
     planeBuilder       = planeMonoBehaviour.Builder;
 }
Ejemplo n.º 17
0
    public static Mesh CreateDoubleSidedTextured(PlaneBuilder builder)
    {
        int numberOfVerticesWidth   = builder.NumberOfSegmentsWidth + 1;
        int numberOfVerticesHeight  = builder.NumberOfSegmentsHeight + 1;
        int numberOfVerticesOneSide = numberOfVerticesWidth * numberOfVerticesHeight;
        int numberOfVertices        = numberOfVerticesOneSide * 2;

        float segmentSizeWidth  = builder.Width / builder.NumberOfSegmentsWidth;
        float segmentSizeHeight = builder.Height / builder.NumberOfSegmentsHeight;

        float uvSegmentSizeWidth;
        float uvSegmentSizeHeight;

        if (builder.SizeRelative)
        {
            uvSegmentSizeWidth  = 1 / builder.NumberOfSegmentsWidth;
            uvSegmentSizeHeight = 1 / builder.NumberOfSegmentsHeight;
        }
        else
        {
            uvSegmentSizeWidth  = segmentSizeWidth;
            uvSegmentSizeHeight = segmentSizeHeight;
        }


        Vector3[] vertices = new Vector3[numberOfVertices];
        Vector2[] uvs      = new Vector2[numberOfVertices];

        int[] triangles = new int[builder.NumberOfSegmentsWidth * builder.NumberOfSegmentsHeight * 6 * 2];

        Vector2 shifts = CalculatePivotShift(builder.Pivot, builder.Width, builder.Height);

        Quaternion rotation = Quaternion.Euler(builder.Rotation);

        for (int y = 0; y < numberOfVerticesHeight; y++)
        {
            for (int x = 0; x < numberOfVerticesWidth; x++)
            {
                int n     = y * numberOfVerticesWidth + x;
                int backN = numberOfVerticesOneSide + n;

                // Generate for front vertice
                vertices[n] = rotation * new Vector3(x * segmentSizeWidth - shifts[0], y * segmentSizeHeight - shifts[1], 0);
                uvs[n]      = new Vector2
                              (
                    (x * uvSegmentSizeWidth + builder.UvOffset.x) * builder.UvTiling.x,
                    (y * uvSegmentSizeHeight + builder.UvOffset.y) * builder.UvTiling.y
                              );

                // Generate for back vertice
                vertices[backN] = vertices[n];
                uvs[backN]      = uvs[n];
            }
        }

        int index = 0;

        for (int y = 0; y < builder.NumberOfSegmentsHeight; y++)
        {
            for (int x = 0; x < builder.NumberOfSegmentsWidth; x++)
            {
                // Triangles for front segment
                triangles[index]     = y * numberOfVerticesWidth + x;
                triangles[index + 1] = (y + 1) * numberOfVerticesWidth + x;
                triangles[index + 2] = y * numberOfVerticesWidth + (x + 1);

                triangles[index + 3] = y * numberOfVerticesWidth + (x + 1);
                triangles[index + 4] = (y + 1) * numberOfVerticesWidth + x;
                triangles[index + 5] = (y + 1) * numberOfVerticesWidth + (x + 1);

                // Triangles for back segment
                triangles[index + 6] = numberOfVerticesOneSide + y * numberOfVerticesWidth + x;
                triangles[index + 7] = numberOfVerticesOneSide + y * numberOfVerticesWidth + (x + 1);
                triangles[index + 8] = numberOfVerticesOneSide + (y + 1) * numberOfVerticesWidth + x;

                triangles[index + 9]  = numberOfVerticesOneSide + y * numberOfVerticesWidth + (x + 1);
                triangles[index + 10] = numberOfVerticesOneSide + (y + 1) * numberOfVerticesWidth + (x + 1);
                triangles[index + 11] = numberOfVerticesOneSide + (y + 1) * numberOfVerticesWidth + x;
                index += 12;
            }
        }

        Mesh mesh = new Mesh()
        {
            vertices  = vertices,
            triangles = triangles,
            uv        = uvs,
        };

        mesh.RecalculateNormals();
        mesh.RecalculateTangents();

        return(mesh);
    }