public SFloor(DFloor dFloor) { Id = dFloor.Id; Name = dFloor.Name; Tag = dFloor.Tag; Height = dFloor.Height; LevelBottom = dFloor.LevelBottom; }
void Start() { domaManager = DomaManager.Instance; activeFloor = domaManager.currentStatusDoma.activeFloor; area3D = GameObject.Find("3DArea"); area2D = GameObject.Find("2DArea"); }
public void DrawWall() { activeFloor = domaManager.currentStatusDoma.activeFloor; if (domaManager.currentStatusDoma.GetFloorIndex(activeFloor.Id) > 0) { domaManager.currentStatusDoma.ShowWalls2dOnFloors(new Guid[] { activeFloor.Id, domaManager.currentStatusDoma.GetFloorBelow(activeFloor.Id).Id }); } else { domaManager.currentStatusDoma.ShowWalls2dOnFloors(new Guid[] { activeFloor.Id }); } if (activeFunction == drawWall) { DeactivateFunction(drawWall, activateButtonDrawWall); } else { ActivateFunction(drawWall, activateButtonDrawWall); } }
public void DrawCeiling() { domaManager.ResetDataFunctionNow = true; activeFloor = domaManager.currentStatusDoma.activeFloor; if (domaManager.currentStatusDoma.GetFloorIndex(activeFloor.Id) > 0) { domaManager.currentStatusDoma.ShowWalls2dOnFloors(new Guid[] { activeFloor.Id, domaManager.currentStatusDoma.GetFloorBelow(activeFloor.Id).Id }); } else { domaManager.currentStatusDoma.ShowWalls2dOnFloors(new Guid[] { activeFloor.Id }); } if (activeFunction == drawCeiling) { DeactivateFunction(drawCeiling, activateButtonDrawCeiling); } else { ActivateFunction(drawCeiling, activateButtonDrawCeiling); } }
void Start() { print("DrawWall Start()"); domaManager = DomaManager.Instance; activeFloor = currentStatusDoma.activeFloor; area3D = GameObject.Find("3DArea"); area2D = GameObject.Find("2DArea"); tempLineRenderer = new GameObject(); tempLineRenderer.name = "TempLineRender"; tempLineRenderer.AddComponent <LineRenderer>(); tempLineRenderer.GetComponent <LineRenderer>().startWidth = 0.2f; tempLineRenderer.GetComponent <LineRenderer>().endWidth = 0.2f; tempLineRenderer.transform.parent = area2D.transform; lastPoint = Vector3.zero; materialType1 = Resources.Load("Materials/concrete_block_material", typeof(Material)) as Material; materialType2 = Resources.Load("Materials/airblock_material", typeof(Material)) as Material; material = materialType1; }
public Tuple <GameObject, Solid> DrawMesh3D(Vector3 startPoint, Vector3 endPoint, float width, float height, string name) { activeFloor = currentStatusDoma.activeFloor; startPoint = new Vector3(startPoint.x, activeFloor.LevelBottom, startPoint.z); endPoint = new Vector3(endPoint.x, activeFloor.LevelBottom, endPoint.z); float h = height; GameObject gameObject = new GameObject(); gameObject.name = name; var between = endPoint - startPoint; var distance = Vector3.Distance(startPoint, endPoint); Vector3 vNormalized = endPoint - startPoint; Vector3 vPerpendicular = Vector3.Normalize(Vector3.Cross(vNormalized, Vector3.up)); var P1 = startPoint + vPerpendicular * width / 2; var P2 = startPoint - vPerpendicular * width / 2; var P3 = endPoint - vPerpendicular * width / 2; var P4 = endPoint + vPerpendicular * width / 2; Vector3[] vertices = { P1, P2, new Vector3(P2.x,P2.y + h, P2.z), new Vector3(P1.x,P1.y + h, P1.z), new Vector3(P4.x,P4.y + h, P4.z), new Vector3(P3.x,P3.y + h, P3.z), P3, P4, }; Point3d[] points3d = vertices.Select(v => new Point3d(v.x, v.y, v.z)).ToArray(); int[] triangles = { 0, 2, 1, //face front 0, 3, 2, 2, 3, 4, //face top 2, 4, 5, 1, 2, 5, //face right 1, 5, 6, 0, 7, 4, //face left 0, 4, 3, 5, 4, 7, //face back 5, 7, 6, 0, 6, 7, //face bottom 0, 1, 6 }; // UVs dla tekstury Vector2[] uvs = new Vector2[vertices.Length]; for (int i = 0; i < uvs.Length; i++) { uvs[i] = new Vector2(vertices[i].x, vertices[i].y); } var obj = new Net3dBool.Solid(points3d, triangles, getColorArray(8, Color.black)); MeshFilter mf = gameObject.AddComponent <MeshFilter>(); Mesh tmesh = new Mesh(); tmesh.vertices = GetVertices(obj); tmesh.triangles = obj.getIndices(); tmesh.uv = uvs; //tmesh.colors = GetColorsMesh(obj); tmesh.RecalculateNormals(); mf.mesh = tmesh; MeshRenderer mr = gameObject.AddComponent <MeshRenderer>(); gameObject.transform.Translate(new Vector3(2000, 0, 0), Space.World); gameObject.GetComponent <MeshRenderer>().material = material; gameObject.transform.parent = area3D.transform; // Doda Collider gdy ściana ma długość min. 20 cm if (Vector3.Distance(startPoint, endPoint) > 0.2f) { gameObject.AddComponent <MeshCollider>(); } gameObject.tag = "Wall"; gameObject.layer = LayerMask.NameToLayer("3DArea"); return(new Tuple <GameObject, Solid>(gameObject, obj)); }