public static NBTGameObject Create(string name, NBTChunk chunk, int layer, bool navigate = true) { GameObject go = new GameObject(name); go.transform.parent = chunk.transform; go.AddComponent <MeshFilter>(); go.layer = layer; if (navigate) { go.AddComponent <NavMeshSourceTag>(); } Material mat = new Material(Shader.Find("Custom/TextureArrayShader")); if (layer == 12) { mat.SetFloat("_Culling", 0); } go.AddComponent <MeshRenderer>().sharedMaterial = mat; go.AddComponent <MeshCollider>(); NBTGameObject nbtGO = go.AddComponent <NBTGameObject>(); nbtGO.mat = mat; nbtGO.nbtMesh.mesh.name = name; return(nbtGO); }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.blockData = blockData; FillMesh(chunk, ca, nbtGO.nbtMesh); }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.blockData = blockData; if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z - 1)) { FaceAttributes fa = GetFrontFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x + 1, pos.y, pos.z)) { FaceAttributes fa = GetRightFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x - 1, pos.y, pos.z)) { FaceAttributes fa = GetLeftFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z + 1)) { FaceAttributes fa = GetBackFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } AddFace(nbtGO.nbtMesh, GetTopFaceAttributes(chunk, nbtGO.nbtMesh, ca), ca); if (!chunk.HasOpaqueBlock(pos.x, pos.y - 1, pos.z)) { FaceAttributes fa = GetBottomFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } }
public static NBTGameObject Create(string name, Transform parent, int layer, bool isCollidable = true) { GameObject go = new GameObject(name); go.transform.parent = parent; go.AddComponent <MeshFilter>(); go.layer = layer; if (isCollidable) { go.AddComponent <MeshCollider>(); } string matPath = "Materials/block"; if (layer == 12) { matPath = "Materials/plant"; } go.AddComponent <MeshRenderer>().material = Resources.Load <Material>(matPath); go.AddComponent <NavMeshSourceTag>(); NBTGameObject nbtGO = go.AddComponent <NBTGameObject>(); nbtGO.mesh = new Mesh(); nbtGO.mesh.name = name; nbtGO.isCollidable = isCollidable; return(nbtGO); }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.blockData = blockData; InitBlockAttributes(chunk, ref ca); bool topIsSnow = chunk.GetBlockByte(pos.x, pos.y + 1, pos.z) == 78; if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z - 1)) { FaceAttributes fa = GetFrontFaceAttributes(chunk, nbtGO.nbtMesh, ca); if (topIsSnow) { fa.faceIndex = TextureArrayManager.GetIndexByName("grass_side_snowed"); } AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x + 1, pos.y, pos.z)) { FaceAttributes fa = GetRightFaceAttributes(chunk, nbtGO.nbtMesh, ca); if (topIsSnow) { fa.faceIndex = TextureArrayManager.GetIndexByName("grass_side_snowed"); } AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x - 1, pos.y, pos.z)) { FaceAttributes fa = GetLeftFaceAttributes(chunk, nbtGO.nbtMesh, ca); if (topIsSnow) { fa.faceIndex = TextureArrayManager.GetIndexByName("grass_side_snowed"); } AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z + 1)) { FaceAttributes fa = GetBackFaceAttributes(chunk, nbtGO.nbtMesh, ca); if (topIsSnow) { fa.faceIndex = TextureArrayManager.GetIndexByName("grass_side_snowed"); } AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y + 1, pos.z)) { FaceAttributes fa = GetTopFaceAttributes(chunk, nbtGO.nbtMesh, ca); if (topIsSnow) { fa.faceIndex = TextureArrayManager.GetIndexByName("snow"); } AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y - 1, pos.z)) { FaceAttributes fa = GetBottomFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.blockData = blockData; chunk.GetLights(pos.x, pos.y, pos.z, out float skyLight, out float blockLight); FaceAttributes fa = new FaceAttributes(); fa.faceIndex = GetPlantIndexByData(chunk, blockData); fa.color = Color.white; fa.skyLight = new float[] { skyLight, skyLight, skyLight, skyLight }; fa.blockLight = new float[] { blockLight, blockLight, blockLight, blockLight }; fa.normal = Vector3.zero; fa.uv = uv_zero; try { fa.pos = face1; AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = face2; AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = face3; AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = face4; AddFace(nbtGO.nbtMesh, fa, ca); } catch (System.Exception e) { Debug.Log(e.ToString() + "\n" + "pos=" + pos + ",data=" + blockData); } }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.blockData = blockData; AddDiagonalFace(chunk, nbtGO.nbtMesh, ca); AddAntiDiagonalFace(chunk, nbtGO.nbtMesh, ca); }
public NBTChunk() { gameObject = new GameObject("chunk (" + x + "," + z + ")"); transform = gameObject.transform; collidable = NBTGameObject.Create("Collidable", transform, LayerMask.NameToLayer("Chunk")); notCollidable = NBTGameObject.Create("NotCollidable", transform, LayerMask.NameToLayer("Plant")); water = NBTGameObject.Create("Water", transform, LayerMask.NameToLayer("Water"), false); }
public override void AddCube(NBTChunk chunk, byte data, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.worldPos.Set(pos.x + chunk.x * 16, pos.y, pos.z + chunk.z * 16); ca.blockData = data; FaceAttributes fa = new FaceAttributes(); fa.skyLight = skylight_default; fa.blockLight = blocklight_default; fa.pos = frontVertices_1; fa.normal = Vector3.forward; fa.faceIndex = GetFrontIndexByData(null, data); fa.uv = uv_side; fa.color = GetFrontTintColorByData(data); AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = backVertices_1; fa.normal = Vector3.back; fa.faceIndex = GetBackIndexByData(null, data); fa.uv = uv_side; fa.color = GetBackTintColorByData(data); AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = topVertices_1; fa.normal = Vector3.up; fa.faceIndex = GetTopIndexByData(null, data); fa.uv = GetTopRotationByData(data) == Rotation.Right ? uv_right : uv_zero; fa.color = GetTopTintColorByData(data); AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = bottomVertices_1; fa.normal = Vector3.down; fa.faceIndex = GetBottomIndexByData(null, data); fa.uv = GetBottomRotationByData(data) == Rotation.Right ? uv_right : uv_zero; fa.color = GetBottomTintColorByData(data); AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = leftVertices_1; fa.normal = Vector3.left; fa.faceIndex = GetLeftIndexByData(null, data); fa.uv = uv_side; fa.color = GetLeftTintColorByData(data); AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = rightVertices_1; fa.normal = Vector3.right; fa.faceIndex = GetRightIndexByData(null, data); fa.uv = uv_side; fa.color = GetRightTintColorByData(data); AddFace(nbtGO.nbtMesh, fa, ca); }
public NBTChunk() { gameObject = new GameObject("chunk (" + x + "," + z + ")"); transform = gameObject.transform; collidable = NBTGameObject.Create("Collidable", this, LayerMask.NameToLayer("Chunk")); notCollidable = NBTGameObject.Create("NotCollidable", this, LayerMask.NameToLayer("Plant"), false); water = NBTGameObject.CreateWater("Water", this, LayerMask.NameToLayer("Water")); special = new GameObject("special"); special.transform.parent = transform; special.transform.localPosition = Vector3.zero; }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { UnityEngine.Profiling.Profiler.BeginSample(GetType().Name + " AddCube"); GameObject chest_prefab = Resources.Load <GameObject>("Meshes/entity/chest/chest_prefab"); GameObject chest = Object.Instantiate(chest_prefab); chest.transform.parent = chunk.special.transform; chest.transform.localPosition = pos; UnityEngine.Profiling.Profiler.EndSample(); }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { Debug.Log("bed addcube"); Mesh mesh = GetMesh(blockData); GameObject bed = new GameObject("bed"); bed.transform.parent = chunk.special.transform; bed.transform.localPosition = pos; bed.AddComponent <MeshFilter>().sharedMesh = mesh; bed.AddComponent <MeshRenderer>().sharedMaterial = GetMaterial(blockData); bed.AddComponent <MeshCollider>().sharedMesh = mesh; bed.layer = LayerMask.NameToLayer("Chunk"); }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.blockData = blockData; InitBlockAttributes(chunk, ref ca); if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z - 1)) { FaceAttributes fa = GetFrontFaceAttributes(chunk, nbtGO.nbtMesh, ca); fa.pos = frontVertices; fa.uv = uv_side; AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x + 1, pos.y, pos.z)) { FaceAttributes fa = GetRightFaceAttributes(chunk, nbtGO.nbtMesh, ca); fa.pos = rightVertices; fa.uv = uv_side; AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x - 1, pos.y, pos.z)) { FaceAttributes fa = GetLeftFaceAttributes(chunk, nbtGO.nbtMesh, ca); fa.pos = leftVertices; fa.uv = uv_side; AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z + 1)) { FaceAttributes fa = GetBackFaceAttributes(chunk, nbtGO.nbtMesh, ca); fa.pos = backVertices; fa.uv = uv_side; AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y + 1, pos.z)) { FaceAttributes fa = GetTopFaceAttributes(chunk, nbtGO.nbtMesh, ca); fa.pos = topVertices; AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y - 1, pos.z)) { FaceAttributes fa = GetBottomFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } }
public static NBTGameObject CreateWater(string name, NBTChunk chunk, int layer) { GameObject go = new GameObject(name); go.transform.parent = chunk.transform; go.AddComponent <MeshFilter>(); go.layer = layer; Material mat = Resources.Load <Material>("Materials/block/water_still"); go.AddComponent <MeshRenderer>().sharedMaterial = mat; go.AddComponent <MeshCollider>(); NBTGameObject nbtGO = go.AddComponent <NBTGameObject>(); nbtGO.mat = mat; nbtGO.nbtMesh.mesh.name = name; return(nbtGO); }
public virtual void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.worldPos.Set(pos.x + chunk.x * 16, pos.y, pos.z + chunk.z * 16); ca.blockData = blockData; InitBlockAttributes(chunk, ref ca); if (ca.front.exist == 0) { FaceAttributes fa = GetFrontFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } if (ca.right.exist == 0) { FaceAttributes fa = GetRightFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } if (ca.left.exist == 0) { FaceAttributes fa = GetLeftFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } if (ca.back.exist == 0) { FaceAttributes fa = GetBackFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } if (ca.top.exist == 0) { FaceAttributes fa = GetTopFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } if (ca.bottom.exist == 0) { FaceAttributes fa = GetBottomFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { UnityEngine.Profiling.Profiler.BeginSample(GetType().Name + " AddCube"); int faceIndex = TextureArrayManager.GetIndexByName(fenceName); MeshData mesh = GetMesh(chunk, pos); chunk.GetLights(pos.x, pos.y, pos.z, out float skyLight, out float blockLight); NBTMesh nbtMesh = nbtGO.nbtMesh; ushort startIndex = nbtMesh.vertexCount; for (int i = 0; i < mesh.vertices.Length; i++) { SetVertex(nbtMesh, mesh.vertices[i] + pos, faceIndex, mesh.uv[i], skyLight, blockLight, Color.white, mesh.normals[i]); } foreach (int index in mesh.triangles) { nbtMesh.triangleArray[nbtMesh.triangleCount++] = (ushort)(startIndex + index); } UnityEngine.Profiling.Profiler.EndSample(); }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.blockData = blockData; chunk.GetBlockData(pos.x, pos.y, pos.z - 1, out byte frontType, out byte frontData); chunk.GetBlockData(pos.x, pos.y, pos.z + 1, out byte backType, out byte backData); chunk.GetBlockData(pos.x - 1, pos.y, pos.z, out byte leftType, out byte leftData); chunk.GetBlockData(pos.x + 1, pos.y, pos.z, out byte rightType, out byte rightData); chunk.GetBlockData(pos.x, pos.y - 1, pos.z, out byte bottomType, out byte bottomData); chunk.GetBlockData(pos.x, pos.y + 1, pos.z, out byte topType, out byte topData); bool selfIsVerticalWater = IsVerticalWater(blockData); chunk.GetLights(pos.x, pos.y, pos.z, out float skyLight, out float blockLight); fa.color = Color.white; fa.skyLight = skylight_default; fa.blockLight = blocklight_default; fa.uv = uv_zero; if (NBTGeneratorManager.IsTransparent(frontType) && frontType != TYPE_WATER) { if (selfIsVerticalWater) { fa.pos[0] = nearBottomLeft; fa.pos[1] = nearTopLeft; fa.pos[2] = nearTopRight; fa.pos[3] = nearBottomRight; } else { fa.pos[0] = nearBottomLeft; fa.pos[1] = nearTopLeft_still; fa.pos[2] = nearTopRight_still; fa.pos[3] = nearBottomRight; } fa.normal = Vector3.forward; AddFace(nbtGO.nbtMesh, fa, ca); } if (NBTGeneratorManager.IsTransparent(backType) && backType != TYPE_WATER) { if (selfIsVerticalWater) { fa.pos[0] = farBottomRight; fa.pos[1] = farTopRight; fa.pos[2] = farTopLeft; fa.pos[3] = farBottomLeft; } else { fa.pos[0] = farBottomRight; fa.pos[1] = farTopRight_still; fa.pos[2] = farTopLeft_still; fa.pos[3] = farBottomLeft; } fa.normal = Vector3.back; AddFace(nbtGO.nbtMesh, fa, ca); } if (NBTGeneratorManager.IsTransparent(leftType) && leftType != TYPE_WATER) { if (selfIsVerticalWater) { fa.pos[0] = farBottomLeft; fa.pos[1] = farTopLeft; fa.pos[2] = nearTopLeft; fa.pos[3] = nearBottomLeft; } else { fa.pos[0] = farBottomLeft; fa.pos[1] = farTopLeft_still; fa.pos[2] = nearTopLeft_still; fa.pos[3] = nearBottomLeft; } fa.normal = Vector3.left; AddFace(nbtGO.nbtMesh, fa, ca); } if (NBTGeneratorManager.IsTransparent(rightType) && rightType != TYPE_WATER) { if (selfIsVerticalWater) { fa.pos[0] = nearBottomRight; fa.pos[1] = nearTopRight; fa.pos[2] = farTopRight; fa.pos[3] = farBottomRight; } else { fa.pos[0] = nearBottomRight; fa.pos[1] = nearTopRight_still; fa.pos[2] = farTopRight_still; fa.pos[3] = farBottomRight; } fa.normal = Vector3.right; AddFace(nbtGO.nbtMesh, fa, ca); } if (NBTGeneratorManager.IsTransparent(topType) && topType != TYPE_WATER) { if (selfIsVerticalWater) { fa.pos[0] = farTopRight; fa.pos[1] = nearTopRight; fa.pos[2] = nearTopLeft; fa.pos[3] = farTopLeft; } else { bool leftIsVerticalWater = IsVerticalWater(leftData, leftType); bool rightIsVerticalWater = IsVerticalWater(rightData, rightType); bool frontIsVerticalWater = IsVerticalWater(frontData, frontType); bool backIsVerticalWater = IsVerticalWater(backData, backType); fa.pos[0] = backIsVerticalWater || rightIsVerticalWater ? farTopRight : farTopRight_still; fa.pos[1] = frontIsVerticalWater || rightIsVerticalWater ? nearTopRight : nearTopRight_still; fa.pos[2] = frontIsVerticalWater || leftIsVerticalWater ? nearTopLeft : nearTopLeft_still; fa.pos[3] = backIsVerticalWater || leftIsVerticalWater ? farTopLeft : farTopLeft_still; } fa.normal = Vector3.up; AddFace(nbtGO.nbtMesh, fa, ca); } if (NBTGeneratorManager.IsTransparent(bottomType) && bottomType != TYPE_WATER) { fa.pos[0] = nearBottomRight; fa.pos[1] = farBottomRight; fa.pos[2] = farBottomLeft; fa.pos[3] = nearBottomLeft; fa.normal = Vector3.down; AddFace(nbtGO.nbtMesh, fa, ca); } }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int localPosition, NBTGameObject nbtGO) { MeshData mesh = GetMesh(chunk, localPosition, blockData); int faceIndex = TextureArrayManager.GetIndexByName(stairsName); chunk.GetLights(localPosition.x, localPosition.y + 1, localPosition.z, out float skyLight, out float blockLight); NBTMesh nbtMesh = nbtGO.nbtMesh; ushort startIndex = nbtMesh.vertexCount; for (int i = 0; i < mesh.vertices.Length; i++) { SetVertex(nbtMesh, mesh.vertices[i] + localPosition, faceIndex, mesh.uv[i], skyLight, blockLight, Color.white, Vector3.zero); } foreach (int index in mesh.triangles) { nbtMesh.triangleArray[nbtMesh.triangleCount++] = (ushort)(startIndex + index); } }
public override void AddCube(NBTChunk chunk, byte blockData, byte skyLight, Vector3Int pos, NBTGameObject nbtGO) { this.pos = pos; this.blockData = blockData; vertices = nbtGO.vertexList; triangles = nbtGO.triangles; topIndex = GetTopIndexByData(chunk, blockData); bottomIndex = GetBottomIndexByData(chunk, blockData); frontIndex = GetFrontIndexByData(chunk, blockData); backIndex = GetBackIndexByData(chunk, blockData); leftIndex = GetLeftIndexByData(chunk, blockData); rightIndex = GetRightIndexByData(chunk, blockData); topColor = GetTopTintColorByData(chunk, blockData); bottomColor = GetBottomTintColorByData(chunk, blockData); frontColor = GetFrontTintColorByData(chunk, blockData); backColor = GetBackTintColorByData(chunk, blockData); leftColor = GetLeftTintColorByData(chunk, blockData); rightColor = GetRightTintColorByData(chunk, blockData); if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z - 1)) { AddFrontFace(blockData); } if (!chunk.HasOpaqueBlock(pos.x + 1, pos.y, pos.z)) { AddRightFace(blockData); } if (!chunk.HasOpaqueBlock(pos.x - 1, pos.y, pos.z)) { AddLeftFace(blockData); } if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z + 1)) { AddBackFace(blockData); } if (blockData < 8 || !chunk.HasOpaqueBlock(pos.x, pos.y + 1, pos.z)) { AddTopFace(blockData); } if (blockData >= 8 || !chunk.HasOpaqueBlock(pos.x, pos.y - 1, pos.z)) { AddBottomFace(blockData); } }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int localPosition, NBTGameObject nbtGO) { ca.pos = localPosition; ca.worldPos = new Vector3Int(localPosition.x + chunk.x * 16, localPosition.y, localPosition.z + chunk.z * 16); ca.blockData = blockData; InitBlockAttributes(chunk, ref ca); chunk.GetLights(localPosition.x, localPosition.y, localPosition.z, out float skyLight, out float blockLight); FaceAttributes fa = new FaceAttributes(); fa.skyLight = new float[] { skyLight, skyLight, skyLight, skyLight }; fa.blockLight = new float[] { blockLight, blockLight, blockLight, blockLight }; fa.uv = uv_zero; fa.pos = frontVertices; fa.normal = Vector3.forward; fa.faceIndex = GetFrontIndexByData(chunk, ca.blockData); fa.color = GetFrontTintColorByData(chunk, localPosition, ca.blockData); AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = backVertices; fa.normal = Vector3.back; fa.faceIndex = GetBackIndexByData(chunk, ca.blockData); fa.color = GetBackTintColorByData(chunk, localPosition, ca.blockData); AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = topVertices; fa.normal = Vector3.up; fa.faceIndex = GetTopIndexByData(chunk, ca.blockData); fa.color = GetTopTintColorByData(chunk, localPosition, ca.blockData); AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = bottomVertices; fa.normal = Vector3.down; fa.faceIndex = GetBottomIndexByData(chunk, ca.blockData); fa.color = GetBottomTintColorByData(chunk, localPosition, ca.blockData); AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = leftVertices; fa.normal = Vector3.left; fa.faceIndex = GetLeftIndexByData(chunk, ca.blockData); fa.color = GetLeftTintColorByData(chunk, localPosition, ca.blockData); AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = rightVertices; fa.normal = Vector3.right; fa.faceIndex = GetRightIndexByData(chunk, ca.blockData); fa.color = GetRightTintColorByData(chunk, localPosition, ca.blockData); AddFace(nbtGO.nbtMesh, fa, ca); }
public override void AddCube(NBTChunk chunk, byte blockData, byte skyLight, Vector3Int pos, NBTGameObject nbtGO) { this.pos = pos; vertices = nbtGO.vertexList; triangles = nbtGO.triangles; plantIndex = GetPlantIndexByData(chunk, blockData); tintColor = GetTintColorByData(chunk, blockData); try { AddDiagonalFace(); AddAntiDiagonalFace(); } catch (System.Exception e) { Debug.Log(e.ToString() + "\n" + "pos=" + pos + ",data=" + blockData); } }
public override void AddCube(NBTChunk chunk, byte blockData, byte skyLight, Vector3Int pos, NBTGameObject nbtGO) { this.pos = pos; this.blockData = blockData; vertices = nbtGO.vertexList; triangles = nbtGO.triangles; Mesh mesh = GetMesh(); int faceIndex = TextureArrayManager.GetIndexByName(stairsName); int length = vertices.Count; for (int i = 0; i < mesh.vertices.Length; i++) { vertices.Add(new Vertex { pos = ToVector4(mesh.vertices[i] + pos, faceIndex), texcoord = mesh.uv[i], color = Color.white }); } foreach (int index in mesh.triangles) { triangles.Add(index + length); } }
public override void AddCube(NBTChunk chunk, byte blockData, byte skyLight, Vector3Int pos, NBTGameObject nbtGO) { this.pos = pos; vertices = nbtGO.vertexList; triangles = nbtGO.triangles; plantIndex = GetPlantIndexByData(chunk, blockData); tintColor = GetTintColorByData(chunk, blockData); try { AddFace(nearBottomLeft_1, nearTopLeft_1, nearTopRight_1, nearBottomRight_1, plantIndex, Color.white); AddFace(farBottomLeft_1, farTopLeft_1, farTopRight_1, farBottomRight_1, plantIndex, Color.white); AddFace(farBottomLeft_2, farTopLeft_2, nearTopLeft_2, nearBottomLeft_2, plantIndex, Color.white); AddFace(farBottomRight_2, farTopRight_2, nearTopRight_2, nearBottomRight_2, plantIndex, Color.white); } catch (System.Exception e) { Debug.Log(e.ToString() + "\n" + "pos=" + pos + ",data=" + blockData); } }