void DrawCeil() { if (!capMode) { Vector3 offset, a, b, c, d; offset = new Vector3(-0.5f, 0, -0.5f) * scale; a = new Vector3(0, height * scale, 0); b = new Vector3(scale * size, height * scale, 0); c = new Vector3(0, height * scale, scale * size); d = new Vector3(scale * size, height * scale, scale * size); a += offset; b += offset; c += offset; d += offset; ceilMeshObject = new MeshObject(4 + 4 * 4, 2 * 3 + 3 * 2 * 4); ceilMeshObject.AddQuad(a, b, c, d); //ceilMeshObject.AddQuad(new Vector3(0, height, 0), new Vector3(1, height, 0), new Vector3(0, height, 1), new Vector3(1, height, scale)); } else { grounds = new List <HallInfo>(); GetGroundFromMap(true); ceilMeshObject = new MeshObject((grounds.Count * 4 + 4 * 4), grounds.Count * 2 * 3 + 3 * 2 * 4); AddCeilBorders(); DrawGround(ref ceilMeshObject, height * scale); } }
void DrawGround(ref MeshObject meshObject, float groundHeight) { Vector2 bottomOffset, topOffset, rightOffset, leftOffset; bottomOffset = Vector2.down * 0.5f; topOffset = Vector2.up * 0.5f; leftOffset = Vector2.left * 0.5f; rightOffset = Vector2.right * 0.5f; foreach (HallInfo groundTile in grounds) { Vector2 beginningPoint = groundTile.GetBeginning; Vector2 endPoint = groundTile.GetEnd; Vector2 direction = groundTile.GetDirection; Vector2 a, b, c, d; a = beginningPoint + bottomOffset + leftOffset; d = endPoint + topOffset + rightOffset; if (direction == Vector2.up) { b = beginningPoint + bottomOffset + rightOffset; c = endPoint + topOffset + leftOffset; } else { b = endPoint + bottomOffset + rightOffset; c = beginningPoint + topOffset + leftOffset; } a *= scale; b *= scale; c *= scale; d *= scale; meshObject.AddQuad(new Vector3(c.x, groundHeight, c.y), new Vector3(d.x, groundHeight, d.y), new Vector3(a.x, groundHeight, a.y), new Vector3(b.x, groundHeight, b.y)); } }