/// <summary> /// 生成一组[四角锥(菱形)]单元信息 /// </summary> /// <param name="x_Size"></param> /// <param name="y_Size"></param> /// <param name="height"></param> /// <returns></returns> internal static WFData QuadDiamondSpaceGrid_Unit(float x_Size, float y_Size, float height) { var wfData = new WFData(); var node1 = new WFNode(new Vector3(0, 0, 0), NodePosType.taperedBottom); var node2 = new WFNode(new Vector3(x_Size * 0.5f, 0, -y_Size * 0.5f), NodePosType.taperedBottom); var node3 = new WFNode(new Vector3(x_Size, 0, 0), NodePosType.taperedBottom); var node4 = new WFNode(new Vector3(x_Size * 0.5f, 0, y_Size * 0.5f), NodePosType.taperedBottom); var node5 = new WFNode(new Vector3(x_Size * 0.5f, -height, 0), NodePosType.taperedTop); wfData.wfNodes.Add(node1); wfData.wfNodes.Add(node2); wfData.wfNodes.Add(node3); wfData.wfNodes.Add(node4); wfData.wfNodes.Add(node5); wfData.wfBars.Add(new WFBar(node1.m_id, node2.m_id, BarPosType.upBar)); //1-2 wfData.wfBars.Add(new WFBar(node1.m_id, node4.m_id, BarPosType.upBar)); //1-4 wfData.wfBars.Add(new WFBar(node1.m_id, node5.m_id, BarPosType.centerBar)); //1-5 wfData.wfBars.Add(new WFBar(node2.m_id, node3.m_id, BarPosType.upBar)); //2-3 wfData.wfBars.Add(new WFBar(node2.m_id, node5.m_id, BarPosType.centerBar)); //2-5 wfData.wfBars.Add(new WFBar(node3.m_id, node4.m_id, BarPosType.upBar)); //3-4 wfData.wfBars.Add(new WFBar(node3.m_id, node5.m_id, BarPosType.centerBar)); //3-5 wfData.wfBars.Add(new WFBar(node4.m_id, node5.m_id, BarPosType.centerBar)); //4-5 return(wfData); }
protected override WFData GenerateWFData(FrameRule clamp) { var startPos = -new Vector3(clamp.size1, -clamp.height, clamp.size2) * 0.5f; WFData wfData = new WFData(); float x_Size = clamp.size1 / clamp.num1; float y_Size = clamp.size2 / clamp.num2; WFNode[,] topNodes = new WFNode[clamp.num1, clamp.num2]; for (int i = 0; i < clamp.num1; i++) { for (int j = 0; j < clamp.num2; j++) { if (i > 0 && i < clamp.num1 - 1 && j > 0 && j < clamp.num2 - 1 && i % 2 != 0 && j % 2 != 0) { continue; } WFData data = CalcuteUtility.QuadrangularSpaceGrid_Unit(x_Size, y_Size, clamp.height); data.AppendPosition(startPos + i * x_Size * Vector3.right + j * y_Size * Vector3.forward); topNodes[i, j] = data.wfNodes.Find(x => x.type == NodePosType.taperedTop); wfData.InsertData(data); } } var downData = CalcuteUtility.ConnectNeerBy(topNodes, BarPosType.downBar); wfData.InsertData(downData); return(wfData); }
/// <summary> /// 生成一组[桁架型(菱形)]单元信息 /// 左下前角为原点 /// </summary> /// <param name="clamp"></param> /// <returns></returns> internal static WFData TrussTypeDiamondSpaceGrid_Unit(float x_Size, float y_Size, float height) { var wfData = new WFData(); var node1 = new WFNode(new Vector3(0, 0, 0)); //1 var node2 = new WFNode(new Vector3(x_Size * 0.5f, 0, -y_Size * 0.5f)); //2 var node3 = new WFNode(new Vector3(x_Size * 0.5f, height, -y_Size * 0.5f)); //3 var node4 = new WFNode(new Vector3(0, height, 0)); //4 var node5 = new WFNode(new Vector3(x_Size * 0.5f, 0, y_Size * 0.5f)); //5 var node6 = new WFNode(new Vector3(x_Size, 0, 0)); //6 var node7 = new WFNode(new Vector3(x_Size, height, 0)); //7 var node8 = new WFNode(new Vector3(x_Size * 0.5f, height, y_Size * 0.5f)); //8 wfData.wfNodes.Add(node1); wfData.wfNodes.Add(node2); wfData.wfNodes.Add(node3); wfData.wfNodes.Add(node4); wfData.wfNodes.Add(node5); wfData.wfNodes.Add(node6); wfData.wfNodes.Add(node7); wfData.wfNodes.Add(node8); //wfData.wfBars.Add(new WFBar(node1.m_id, node2.m_id));//1-2 //wfData.wfBars.Add(new WFBar(node1.m_id, node4.m_id));//1-4 //wfData.wfBars.Add(new WFBar(node1.m_id, node5.m_id));//1-5 //wfData.wfBars.Add(new WFBar(node1.m_id, node8.m_id));//1-8 //wfData.wfBars.Add(new WFBar(node2.m_id, node3.m_id));//2-3 //wfData.wfBars.Add(new WFBar(node2.m_id, node4.m_id));//2-4 //wfData.wfBars.Add(new WFBar(node2.m_id, node6.m_id));//2-6 //wfData.wfBars.Add(new WFBar(node2.m_id, node7.m_id));//2-7 //wfData.wfBars.Add(new WFBar(node3.m_id, node4.m_id));//3-4 //wfData.wfBars.Add(new WFBar(node3.m_id, node7.m_id));//3-7 //wfData.wfBars.Add(new WFBar(node4.m_id, node8.m_id));//4-8 //wfData.wfBars.Add(new WFBar(node5.m_id, node6.m_id));//5-6 //wfData.wfBars.Add(new WFBar(node5.m_id, node8.m_id));//5-8 //wfData.wfBars.Add(new WFBar(node6.m_id, node7.m_id));//6-7 //wfData.wfBars.Add(new WFBar(node6.m_id, node8.m_id));//6-8 //wfData.wfBars.Add(new WFBar(node7.m_id, node8.m_id));//7-8 wfData.wfBars.Add(new WFBar(node1.m_id, node2.m_id, BarPosType.downBar)); //1-2 wfData.wfBars.Add(new WFBar(node1.m_id, node4.m_id, BarPosType.centerBar)); //1-4 wfData.wfBars.Add(new WFBar(node1.m_id, node5.m_id, BarPosType.downBar)); //1-5 wfData.wfBars.Add(new WFBar(node1.m_id, node8.m_id, BarPosType.centerBar)); //1-8 wfData.wfBars.Add(new WFBar(node2.m_id, node3.m_id, BarPosType.centerBar)); //2-3 wfData.wfBars.Add(new WFBar(node2.m_id, node4.m_id, BarPosType.centerBar)); //2-4 wfData.wfBars.Add(new WFBar(node2.m_id, node6.m_id, BarPosType.downBar)); //2-6 wfData.wfBars.Add(new WFBar(node2.m_id, node7.m_id, BarPosType.centerBar)); //2-7 wfData.wfBars.Add(new WFBar(node3.m_id, node4.m_id, BarPosType.upBar)); //3-4 wfData.wfBars.Add(new WFBar(node3.m_id, node7.m_id, BarPosType.upBar)); //3-7 wfData.wfBars.Add(new WFBar(node4.m_id, node8.m_id, BarPosType.upBar)); //4-8 wfData.wfBars.Add(new WFBar(node5.m_id, node6.m_id, BarPosType.downBar)); //5-6 wfData.wfBars.Add(new WFBar(node5.m_id, node8.m_id, BarPosType.centerBar)); //5-8 wfData.wfBars.Add(new WFBar(node6.m_id, node7.m_id, BarPosType.centerBar)); //6-7 wfData.wfBars.Add(new WFBar(node6.m_id, node8.m_id, BarPosType.centerBar)); //6-8 wfData.wfBars.Add(new WFBar(node7.m_id, node8.m_id, BarPosType.upBar)); //7-8 return(wfData); }
protected override WFData GenerateWFData(FrameRule clamp) { float x_Size = clamp.size1 / clamp.num1; float y_Size = clamp.size2 / clamp.num2; var startPos = -new Vector3(clamp.size1, -clamp.height, clamp.size2 - y_Size) * 0.5f; WFData wfData = new WFData(); WFNode[,] topNodes = new WFNode[clamp.num1, clamp.num2]; List <WFNode> bundNodes = new List <WFNode>(); for (int i = 0; i < clamp.num1; i++) { for (int j = 0; j < clamp.num2; j++) { WFData data = CalcuteUtility.QuadDiamondSpaceGrid_Unit(x_Size, y_Size, clamp.height); var position = startPos + i * x_Size * Vector3.right + j * y_Size * Vector3.forward; data.AppendPosition(position); topNodes[i, j] = data.wfNodes.Find(x => x.type == NodePosType.taperedTop); wfData.InsertData(data); if (i == 0)//左 { var node = data.wfNodes.Find(x => Vector3.Distance(x.position, position) < 0.1f); bundNodes.Add(node); } if (j == 0) {//下 var downPos = position + x_Size * Vector3.right * 0.5f - y_Size * Vector3.forward * 0.5f; var node = data.wfNodes.Find(x => Vector3.Distance(x.position, downPos) < 0.1f); bundNodes.Add(node); } if (i == clamp.num1 - 1)//右 { var rightPos = position + x_Size * Vector3.right; var node = data.wfNodes.Find(x => Vector3.Distance(x.position, rightPos) < 0.1f); bundNodes.Add(node); } if (j == clamp.num2 - 1)//上 { var upPos = position + x_Size * Vector3.right * 0.5f + y_Size * Vector3.forward * 0.5f; var node = data.wfNodes.Find(x => Vector3.Distance(x.position, upPos) < 0.1f); bundNodes.Add(node); } } } var downData = CalcuteUtility.ConnectNeerBy(topNodes, BarPosType.downBar); wfData.InsertData(downData); var bundData = CalcuteUtility.ConnectNeerBy(bundNodes, Mathf.Sqrt(Mathf.Pow(x_Size, 2) + Mathf.Pow(y_Size, 2)), BarPosType.upBar); wfData.InsertData(bundData); return(wfData); }
public static WFData GetTestData() { var data = new WFData(); data.wfNodes = new List <WFNode>(); var node1 = new WFNode(Vector3.zero); data.wfNodes.Add(node1); var node2 = new WFNode(Vector3.one); data.wfNodes.Add(node2); data.wfBars = new List <WFBar>(); var bar = new WFBar(node1.m_id, node2.m_id, BarPosType.upBar); data.wfBars.Add(bar); return(data); }
/// <summary> /// 生成一组[桁架型(三向交叉)]单元信息 /// 左下前角为原点 /// </summary> /// <param name="clamp"></param> /// <returns></returns> internal static WFData TrussTypeThreeDirectionSpaceGrid_Unit(float x_Size, float y_Size, float height) { var wfData = new WFData(); var node1 = new WFNode(new Vector3(0, 0, 0)); var node2 = new WFNode(new Vector3(x_Size, 0, 0)); var node3 = new WFNode(new Vector3(x_Size, height, 0)); var node4 = new WFNode(new Vector3(0, height, 0)); var node5 = new WFNode(new Vector3(0, 0, y_Size)); var node6 = new WFNode(new Vector3(x_Size, 0, y_Size)); var node7 = new WFNode(new Vector3(x_Size, height, y_Size)); var node8 = new WFNode(new Vector3(0, height, y_Size)); wfData.wfNodes.Add(node1); wfData.wfNodes.Add(node2); wfData.wfNodes.Add(node3); wfData.wfNodes.Add(node4); wfData.wfNodes.Add(node5); wfData.wfNodes.Add(node6); wfData.wfNodes.Add(node7); wfData.wfNodes.Add(node8); wfData.wfBars.Add(new WFBar(node1.m_id, node2.m_id, BarPosType.downBar)); //1-2 wfData.wfBars.Add(new WFBar(node1.m_id, node4.m_id, BarPosType.centerBar)); //1-4 wfData.wfBars.Add(new WFBar(node1.m_id, node5.m_id, BarPosType.downBar)); //1-5 wfData.wfBars.Add(new WFBar(node1.m_id, node6.m_id, BarPosType.downBar)); //1-6 wfData.wfBars.Add(new WFBar(node1.m_id, node8.m_id, BarPosType.centerBar)); //1-8 wfData.wfBars.Add(new WFBar(node2.m_id, node3.m_id, BarPosType.centerBar)); //2-3 wfData.wfBars.Add(new WFBar(node2.m_id, node4.m_id, BarPosType.centerBar)); //2-4 wfData.wfBars.Add(new WFBar(node2.m_id, node6.m_id, BarPosType.downBar)); //2-6 wfData.wfBars.Add(new WFBar(node2.m_id, node7.m_id, BarPosType.centerBar)); //2-7 wfData.wfBars.Add(new WFBar(node3.m_id, node4.m_id, BarPosType.upBar)); //3-4 wfData.wfBars.Add(new WFBar(node3.m_id, node7.m_id, BarPosType.upBar)); //3-7 wfData.wfBars.Add(new WFBar(node4.m_id, node6.m_id, BarPosType.centerBar)); //4-6 wfData.wfBars.Add(new WFBar(node4.m_id, node7.m_id, BarPosType.upBar)); //4-7 wfData.wfBars.Add(new WFBar(node4.m_id, node8.m_id, BarPosType.upBar)); //4-8 wfData.wfBars.Add(new WFBar(node5.m_id, node6.m_id, BarPosType.downBar)); //5-6 wfData.wfBars.Add(new WFBar(node5.m_id, node8.m_id, BarPosType.centerBar)); //5-8 wfData.wfBars.Add(new WFBar(node6.m_id, node7.m_id, BarPosType.centerBar)); //6-7 wfData.wfBars.Add(new WFBar(node6.m_id, node8.m_id, BarPosType.centerBar)); //6-8 wfData.wfBars.Add(new WFBar(node7.m_id, node8.m_id, BarPosType.upBar)); //7-8 return(wfData); }
/// <summary> /// 生成一组[三角锥]单元信息 /// 上面下角为原点 /// </summary> /// <param name="x_Size"></param> /// <param name="y_Size"></param> /// <param name="height"></param> /// <returns></returns> internal static WFData TrigonumSpaceGrid_Unit(float edge, float height) { var wfData = new WFData(); var edgeHeight = edge * 0.5f * Mathf.Tan(Mathf.Deg2Rad * 60); var centr1 = edge * 0.5f / Mathf.Cos(Mathf.Deg2Rad * 30); var node1 = new WFNode(new Vector3(0, 0, 0), NodePosType.taperedBottom); var node2 = new WFNode(new Vector3(edge * 0.5f, 0, edgeHeight), NodePosType.taperedBottom); var node3 = new WFNode(new Vector3(-edge * 0.5f, 0, edgeHeight), NodePosType.taperedBottom); var node4 = new WFNode(new Vector3(0, -height, centr1), NodePosType.taperedTop); wfData.wfNodes.Add(node1); wfData.wfNodes.Add(node2); wfData.wfNodes.Add(node3); wfData.wfNodes.Add(node4); wfData.wfBars.Add(new WFBar(node1.m_id, node2.m_id, BarPosType.upBar)); //1-2 wfData.wfBars.Add(new WFBar(node1.m_id, node3.m_id, BarPosType.upBar)); //1-3 wfData.wfBars.Add(new WFBar(node1.m_id, node4.m_id, BarPosType.centerBar)); //1-4 wfData.wfBars.Add(new WFBar(node2.m_id, node3.m_id, BarPosType.upBar)); //2-3 wfData.wfBars.Add(new WFBar(node2.m_id, node4.m_id, BarPosType.centerBar)); //2-4 wfData.wfBars.Add(new WFBar(node3.m_id, node4.m_id, BarPosType.centerBar)); //3-4 return(wfData); }
internal void OnInitialized(WFNode node) { this.Info = node; transform.position = Info.position; CreateCollider(); }