Example #1
0
        public static CubeFace TransformFace(CubeFace face, OpenCog.Map.OCBlockDirection dir)
        {
            if (face == CubeFace.Top || face == CubeFace.Bottom)
            {
                return(face);
            }

            //Front, Right, Back, Left
            //0      90     180   270

            int angle = 0;

            if (face == CubeFace.Right)
            {
                angle = 90;
            }
            if (face == CubeFace.Back)
            {
                angle = 180;
            }
            if (face == CubeFace.Left)
            {
                angle = 270;
            }

            if (dir == OpenCog.Map.OCBlockDirection.X_MINUS)
            {
                angle += 90;
            }
            if (dir == OpenCog.Map.OCBlockDirection.Z_MINUS)
            {
                angle += 180;
            }
            if (dir == OpenCog.Map.OCBlockDirection.X_PLUS)
            {
                angle += 270;
            }

            angle %= 360;

            if (angle == 0)
            {
                return(CubeFace.Front);
            }
            if (angle == 90)
            {
                return(CubeFace.Right);
            }
            if (angle == 180)
            {
                return(CubeFace.Back);
            }
            if (angle == 270)
            {
                return(CubeFace.Left);
            }

            return(CubeFace.Front);
        }
Example #2
0
        public static void Build(Vector3i localPos, Vector3i worldPos, OpenCog.Map.OCMap map, OpenCog.Builder.OCMeshBuilder mesh, bool onlyLight)
        {
            OpenCog.Map.OCBlockData block = map.GetBlock(worldPos);
            OCCubeBlock             cube  = (OCCubeBlock)block.block;

            OpenCog.Map.OCBlockDirection direction = block.GetDirection();

            for (int i = 0; i < 6; i++)
            {
                OCCubeBlock.CubeFace face    = faces[i];
                Vector3i             dir     = directions[i];
                Vector3i             nearPos = worldPos + dir;
                if (IsFaceVisible(map, nearPos))
                {
                    if (!onlyLight)
                    {
                        BuildFace(face, cube, direction, localPos, mesh);
                    }
                    BuildFaceLight(face, map, worldPos, mesh);
                }
            }
        }
Example #3
0
 public UnityEngine.Vector2[] GetFaceUV(CubeFace face, OpenCog.Map.OCBlockDirection dir)
 {
     face = TransformFace(face, dir);
     return(_texCoords[(int)face]);
 }
Example #4
0
        private static void BuildFace(OpenCog.BlockSet.BaseBlockSet.OCCubeBlock.CubeFace face, OpenCog.BlockSet.BaseBlockSet.OCCubeBlock cube, OpenCog.Map.OCBlockDirection direction, Vector3 localPos, OpenCog.Builder.OCMeshBuilder mesh)
        {
            int iFace = (int)face;

            mesh.AddFaceIndices(cube.AtlasID);
            mesh.AddVertices(vertices[iFace], localPos);
            mesh.AddNormals(normals[iFace]);
            mesh.AddTexCoords(cube.GetFaceUV(face, direction));
        }