public MeshData GetMeshData(Chunk chunk, MeshLod meshLod)
    {
        Vector3 chunkCenterLocation = chunk.GetCenterPosition();

        // The number of points to skip for each mesh vertex
        int borderSize     = 1;
        int vertexInterval = meshLod.GetInterval();

        // Get points necessary for mesh, including a border of one borderSize unit
        IEnumerable <Point> allPoints = chunk.GetPoints(vertexInterval, borderSize);

        int chunkPointCount  = space.GetChunkCount(vertexInterval, 0);
        int totalPointCount  = space.GetChunkCount(vertexInterval, borderSize);
        int borderPointCount = totalPointCount - chunkPointCount;

        MeshHelper      meshHelper      = space.GetMeshHelper(chunk, vertexInterval, borderSize);
        MeshDataBuilder meshDataBuilder = new MeshDataBuilder(meshHelper, chunkPointCount, borderPointCount, vertexInterval, borderSize);

        foreach (Point point in allPoints)
        {
            // Get the height value for each point
            float value = terrainTransform.GetValue(point);

            // Verticies are centered in space give limitations on space size of meshes
            Vector3 vertex = point.GetPosition()
                             + space.GetNormalFromPosition(point.GetPosition()) * value
                             - chunkCenterLocation;

            meshDataBuilder.AddVertex(vertex);
        }

        return(meshDataBuilder.Build());
    }
Example #2
0
 public ScreenTextureComponent(string texturePath) : base(MeshDataBuilder.NDCQuadInvertedUV(), MaterialManager.CreateScreenMaterial(texturePath))
 {
 }
 public CrossLineComponent(int size, bool center) : base(MeshDataBuilder.CrossLine(), MaterialManager.DefaultLineMaterial)
 {
 }
Example #4
0
 public LineComponent(Vector3 start, Vector3 end, Vector4 colorStart, Vector4 colorEnd)
     : base(MeshDataBuilder.Line(start, end, colorStart, colorEnd), MaterialManager.DefaultLineMaterial)
 {
 }
 public GridPlaneComponent(int size, bool center) : base(MeshDataBuilder.Grid(size, center), MaterialManager.DefaultLineMaterial)
 {
 }
Example #6
0
 public static StaticMeshComponent DebugCube()
 {
     return(new StaticMeshComponent(MeshDataBuilder.DebugCube(), Material.Default));
 }
Example #7
0
 public RoundedCubeComponent() : base(MeshDataBuilder.RoundedCube(), Material.Default)
 {
 }
Example #8
0
 public DebugCubeComponent() : base(MeshDataBuilder.DebugCube(), Material.Default)
 {
 }