Exemplo n.º 1
0
 public override IEnumerable <Vector3> GetVertices(IExplicitShape <GridPoint3> shape, GridMap <GridPoint3> map)
 {
     return(shape
            .Points
            .SelectMany(p => vertices[p.GetColor(colorFunction)]
                        .Select(q => map.GridToWorld(q + map.DeRound(p)))));
 }
Exemplo n.º 2
0
 public override IEnumerable <Vector3> GetVertices(IExplicitShape <int> shape, GridMap <int> map)
 {
     return(shape
            .Points
            .SelectMany(p => vertices[GLMathf.FloorMod((int)p, colorFunction.x0)]
                        .Select(q => map.GridToWorld(q + map.DeRound(p)))));
 }
Exemplo n.º 3
0
 public override IEnumerable <Vector3> GetNormals(IExplicitShape <GridPoint3> explicitShape, GridMap <GridPoint3> gridMap, bool flip)
 {
     return(explicitShape
            .Points
            .SelectMany(p => vertices[p.GetColor(colorFunction)]
                        .Select((q, i) => gridMap.GridToWorld(q + gridMap.DeRound(p) + (flip ? -normals[p.GetColor(colorFunction)][i] : normals[p.GetColor(colorFunction)][i])).normalized)));
 }
Exemplo n.º 4
0
 public override IEnumerable <Vector3> GetNormals(IExplicitShape <int> shape, GridMap <int> map, bool flip)
 {
     return(shape
            .Points
            .SelectMany(p => vertices[GLMathf.FloorMod(p, colorFunction.x0)]
                        .Select((q, i) => map.GridToWorld(q + map.DeRound(p) + (flip ? -normals[GLMathf.FloorMod(p, colorFunction.x0)][i] : normals[GLMathf.FloorMod(p, colorFunction.x0)][i])).normalized)));
 }
Exemplo n.º 5
0
        private static void UpdateOrientation <TPoint, TCell>(
            IGrid <TPoint, TCell> grid,
            GridMap <TPoint> map,
            TPoint point)

            where TCell : MonoBehaviour
        {
            var cell = grid[point];

            var newForward = map.GridToWorld(map.DeRound(point) + new Vector3(0, 0, 1)) - cell.transform.localPosition;

            cell.transform.forward = newForward;

            var newRight = map.GridToWorld(map.DeRound(point) + new Vector3(1, 0, 0)) - cell.transform.localPosition;

            cell.transform.right = newRight;

            var newUp = map.GridToWorld(map.DeRound(point) + new Vector3(0, 1, 0)) - cell.transform.localPosition;

            cell.transform.right = newUp;
        }
Exemplo n.º 6
0
        /// <inheritdoc/>
        public override IEnumerable <Vector3> GetVertices(IExplicitShape <GridPoint3> shape, GridMap <GridPoint3> map)
        {
            //var triangles = GetCellTriangles().ToArray();
            var vertices = GetCellVertices().ToArray();

            return(shape.Points.SelectMany(p => vertices.Select(q => map.GridToWorld(q + map.DeRound(p)))));
        }
Exemplo n.º 7
0
        /// <inheritdoc/>
        public override IEnumerable <Vector3> GetNormals(IExplicitShape <GridPoint3> explicitShape, GridMap <GridPoint3> gridMap, bool flip)
        {
            var normals  = GetCellNormals().ToArray();
            var vertices = GetCellVertices().ToArray();

            return(explicitShape.Points.SelectMany(p => vertices.Select((q, i) => gridMap.GridToWorld(q + gridMap.DeRound(p) + (flip ? -normals[i] : normals[i])).normalized)));
        }
Exemplo n.º 8
0
 public override IEnumerable <Vector3> GetVertices(IExplicitShape <int> shape, GridMap <int> map)
 {
     return(shape.Points.SelectMany(p => vertices.Select(q => map.GridToWorld(q + map.DeRound(p)))));
 }