public void generateMeshes()
        {
            bool             meshIsOnMap = false;
            OpenSimplexNoise n           = new OpenSimplexNoise(openSimplexNoiseSeed);

            for (int i = 0; i < meshesOriginPointGrid.Count; i++)
            {
                lock (meshesLock)
                {
                    foreach (Mesh mesh in meshes)
                    {
                        meshIsOnMap = false;

                        if (mesh.originPoint == meshesOriginPointGrid[i])
                        {
                            meshIsOnMap = true;
                            break;
                        }
                    }
                }

                if (!meshIsOnMap && (meshesOriginPointGrid[i] - camera.Position).Length < (float)meshSize * renderDistance)
                {
                    Mesh meshToAdd = new Mesh(meshResolution, meshSize, meshesOriginPointGrid[i], new Vector3(1.0f, 1.0f, 1.0f), shader, normalsShader);
                    meshToAdd.generateMesh();
                    float[] noiseValues = n.getNoise(meshToAdd.getVertices(), 0.5f);
                    meshToAdd.applyNoise(noiseValues);
                    meshesToAdd.Add(meshToAdd);
                }
            }

            meshesOriginPointGrid.Clear();
        }
Exemple #2
0
 public void MeshGenerationResolutionOneVertices()
 {
     Vector3[] actualVertices = new Vector3[4] {
         new Vector3(0f, 0f, 0f), new Vector3(2f, 0f, 0f), new Vector3(0f, 0f, 2f), new Vector3(2f, 0f, 2f)
     };
     mesh = new PracaInzynierska.Mesh(1, 2, new Vector3(0, 0, 0), new Vector3(0, 0, 0));
     mesh.generateMesh();
     Assert.Equal(actualVertices, mesh.getVertices());
 }
Exemple #3
0
 public void MeshGenerationLength(uint resolution, uint actualLength)
 {
     mesh = new PracaInzynierska.Mesh(resolution, 2, new Vector3(0, 0, 0), new Vector3(0, 0, 0));
     Assert.Equal(actualLength, (uint)mesh.getVertices().Length);
 }