コード例 #1
0
    private void LowerEarthTokenRecievedComplete(WorldDataToken token)
    {
        for (int x = 0; x < token.Request.width; x++)
        {
            for (int y = 0; y < token.Request.height; y++)
            {
                token.SetUshort(x, y, (ushort)(token.GetUshort(x, y, UshortDataID.HeightLayerData) - 3), UshortDataID.HeightLayerData);
            }
        }

        // _worldDataAccessService.SaveToken(token, (WorldDataToken returnToken) => { });
    }
コード例 #2
0
    public void ChangeHeight(TerraVector position, int delta)
    {
        if (_currentToken == null)
        {
            throw new InvalidOperationException(string.Format("There is no current {0}", typeof(WorldDataToken)));
        }
        else
        {
            Mesh           mesh            = _renderMeshFilter.sharedMesh;
            List <Vector3> vectorTriangles = new List <Vector3>();
            var            triangles       = mesh.triangles;
            Vector3[]      vertices        = mesh.vertices;
            Color[]        colors          = mesh.colors;
            Vector2[]      uvs             = mesh.uv;
            Vector3[]      normals         = mesh.normals;


            ushort      currentValue = _currentToken.GetUshort(position.x - _currentToken.Request.left, position.y - _currentToken.Request.top, UshortDataID.HeightLayerData);
            TerraVector localVector  = _currentToken.ToLocal(position);
            int         vertPosition = (localVector.x * (_currentToken.Request.width + 1)) + localVector.y;
            _currentToken.SetUshort(localVector.x, localVector.y, (ushort)((int)currentValue + delta), UshortDataID.HeightLayerData);
            //vertices[vertPosition] = GetVertice(_currentToken, localVector.x, localVector.y);
            UpdateSurroundingHights(localVector, vertices, _currentToken);
            mesh.vertices = vertices;
            mesh.RecalculateNormals();
            mesh.RecalculateBounds();
            mesh.RecalculateTangents();

            /*vertices[localVector.x * localVector.y] =
             *  GetVertice(_currentToken, localVector.x, localVector.y);
             * _renderMeshFilter.sharedMesh.vertices = _renderMesh.vertices;
             *
             *
             *
             * //SetTriangles(_currentToken, localVector.x, localVector.y, triangles, vectorTriangles);
             *
             * mesh.Clear();
             *
             * mesh.vertices = vertices;
             * mesh.triangles = triangles;
             * mesh.uv = uvs;
             * mesh.colors = colors;
             * mesh.normals = normals;
             *
             * _renderMeshFilter.sharedMesh.RecalculateNormals();
             * _renderMeshFilter.sharedMesh.RecalculateBounds();
             * _renderMeshFilter.sharedMesh.RecalculateTangents();*/
            //RedrawCountdown = 1;
            // RenderGround(_currentToken);
        }
    }
コード例 #3
0
    private void MakeFlatTokenRecievedComplete(WorldDataToken token)
    {
        ushort height = token.GetUshort(token.Request.left, token.Request.top, UshortDataID.HeightLayerData);

        for (int x = 0; x < token.Request.width; x++)
        {
            for (int y = 0; y < token.Request.height; y++)
            {
                token.SetUshort(x, y, height, UshortDataID.HeightLayerData);
            }
        }

        // _worldDataAccessService.SaveToken(token, (WorldDataToken returnToken) => { });
    }