Пример #1
0
        public Surface(Vector3i coord, Dir dir)
        {
            this.coord = coord;
            this.dir   = dir;
            var vector = DirUtils.GetUnitVector(dir);

            normal     = vector.to_f();
            coordAbove = coord + vector;
            identifier = coord.x + "," + coord.y + "," + coord.z + "," + dir;

            point      = new Vector3(coord.x, coord.y, coord.z) + normal * 0.5f;
            pointAbove = new Vector3(coordAbove.x, coordAbove.y, coordAbove.z);

            rotation = DirUtils.GetRotation(dir);

            uvVectors = DirUtils.GetUV(dir);
        }
Пример #2
0
        public Vector3 GetGravityVector(Vector3 position, float tolerance)
        {
            var dirs = GetGravities(position, tolerance);

            if (dirs.Count == 0)
            {
                return(new Vector3());
            }

            var v = new Vector3();

            foreach (var dir in dirs)
            {
                v += DirUtils.GetUnitVector(dir).to_f();
            }

            return(v);
        }
Пример #3
0
        private void initSurfaces(Vector3i coord)
        {
            var block = map[coord];

            foreach (var dir in DirUtils.Dirs)
            {
                var hasGravity = block.HasGravity(dir);
                // Has gravity
                if (!hasGravity)
                {
                    continue;
                }
                // Not blocked
                var nextCoord = coord + DirUtils.GetUnitVector(dir);
                if (HasVoxel(nextCoord))
                {
                    continue;
                }
                var surface = block.AddSurface(dir);
                surface.isWater = block.type == TerrianBlockType.Water;
                surfaceLookUp [surface.identifier] = surface;
            }
        }
Пример #4
0
 public static Vector3i NextCoord(this Vector3i coord, Dir dir)
 {
     return(coord + DirUtils.GetUnitVector(dir));
 }