public ChildArranger(AbstractPoint startingOffset, int childrenPerWrappingLevel) { this._childrenPerWrappingLevel = childrenPerWrappingLevel; this._currentOffset = startingOffset; this._currentWrappingLevelChildrenCount = 0; this._currentWrappingLevelWidth = 0.0; this._biggestHeight = 0.0; }
private IEnumerator animatePoint(AbstractPoint point, Vector3 lineDir) { while (true) { point.Position3 += lineDir * Time.smoothDeltaTime * 2f; point.AddToRManager(); yield return(new WaitForEndOfFrame()); } }
private IEnumerator animatePoint(AbstractPoint point) { while (true) { Vector3 lineDir = line1.normalDir.normalized; if (!followLineDirection) { lineDir = -lineDir; } point.Position3 += lineDir * Time.smoothDeltaTime * 2f; point.AddToRManager(); yield return(new WaitForEndOfFrame()); } }
private void prevLine(AbstractPoint value) { if (value == null) { thisLR.enabled = false; updateLine = false; } else { thisLR.enabled = true; thisLR.SetPosition(0, value.transform.position); updateLine = true; thisLR.SetPosition(1, endofPin.position); } }
public AbstractPoint GetPositionOfNextChild(AbstractSize childSize) { if (this._currentWrappingLevelChildrenCount >= this._childrenPerWrappingLevel) { this.ShiftToNewWrappingLevel(); } AbstractPoint currentOffset = this._currentOffset; if (childSize.AbstractWidth > this._currentWrappingLevelWidth) { this._currentWrappingLevelWidth = childSize.AbstractWidth; } this.ShiftToBelowPreviousChild(childSize.AbstractHeight); return(currentOffset); }
protected override Size ArrangeOverride(Size finalSize) { int totalCount = this.NonCollapsedChildren.Count <UIElement>(); if (totalCount == 0) { return(finalSize); } GreedyWrapPanel.ChildArranger childArranger = new GreedyWrapPanel.ChildArranger(new AbstractPoint(Orientation.Vertical, this.Orientation, 0.0, 0.0), GreedyWrapPanel.CalculateCountPerWrappingLevel(totalCount, this.ActualWrappingLevels)); foreach (UIElement nonCollapsedChild in this.NonCollapsedChildren) { AbstractSize abstractSize = this.ConvertToAbstractSize(nonCollapsedChild.DesiredSize); AbstractPoint positionOfNextChild = childArranger.GetPositionOfNextChild(abstractSize); nonCollapsedChild.Arrange(new Rect(positionOfNextChild.RealPoint, nonCollapsedChild.DesiredSize)); } return(childArranger.TotalSize.RealSize); }
protected override Size ArrangeOverride(Size constraint) { UIElement[] array = this.NonCollapsedChildren.ToArray <UIElement>(); AbstractPoint abstractPoint = this.MakeAbstractPoint(); AbstractSize abstractSize1 = this.MakeAbstractSize(constraint); AbstractSize abstractItemSpacing = this.AbstractItemSpacing; double itemSpacing; double remainder; this.ComputeItemSpacing(this._measureInfo.RowCount, abstractSize1.AbstractHeight, this._measureInfo.AbstractSize.AbstractHeight, abstractItemSpacing.AbstractHeight, out itemSpacing, out remainder); int index1 = 0; for (int index2 = 0; index2 < this._measureInfo.RowCount; ++index2) { SpacingWrapPanel.RowInfo row = this._measureInfo.Rows[index2]; int childCount = row.ChildCount; double abstractWidth1 = abstractSize1.AbstractWidth; AbstractSize abstractSize2 = row.AbstractSize; double abstractWidth2 = abstractSize2.AbstractWidth; double abstractWidth3 = abstractItemSpacing.AbstractWidth; double num1; double num2; this.ComputeItemSpacing(childCount, abstractWidth1, abstractWidth2, abstractWidth3, out num1, out num2); int index3 = 0; while (index3 < row.ChildCount) { UIElement uiElement = array[index1]; AbstractSize childSize = row.ChildSizes[index3]; Rect finalRect = new Rect(abstractPoint.RealPoint, childSize.RealSize); uiElement.Arrange(finalRect); double num3 = num1 + ((double)index3 < num2 ? 1.0 : 0.0); abstractPoint.AbstractX += childSize.AbstractWidth + num3; ++index3; ++index1; } double num4 = itemSpacing + ((double)index2 < remainder ? 1.0 : 0.0); abstractPoint.AbstractX = 0.0; ref AbstractPoint local3 = ref abstractPoint; double abstractY = local3.AbstractY; abstractSize2 = row.AbstractSize; double num5 = abstractSize2.AbstractHeight + num4; local3.AbstractY = abstractY + num5; }
// Use this for initialization private void Start() { volumeLineRenderer = GetComponentInChildren <LineRenderer>(); TMPro = GetComponentInChildren <TextMeshPro>(); myAudioSource = GetComponent <AudioSource>(); xLen = .1f; controllPoint = GeoObjConstruction.iPoint(this.transform.position); prismBase.Add(controllPoint); prismBase.Add(GeoObjConstruction.dPoint(controllPoint.Position3 + Vector3.right * (sideLength1 - 2 * xLen))); prismBase.Add(GeoObjConstruction.dPoint(controllPoint.Position3 + Vector3.right * (sideLength1 - 2 * xLen) + Vector3.forward * (sideLength2 - 2 * xLen))); prismBase.Add(GeoObjConstruction.dPoint(controllPoint.Position3 + Vector3.forward * (sideLength2 - 2 * xLen))); List <AbstractLineSegment> prismBaseLines = new List <AbstractLineSegment>(); for (int i = 0; i < 3; i++) { prismBaseLines.Add(GeoObjConstruction.dLineSegment(prismBase[i], prismBase[i + 1])); } prismBaseLines.Add(GeoObjConstruction.dLineSegment(prismBase[prismBase.Count - 1], prismBase[0])); prismBasePoly = GeoObjConstruction.dPolygon(prismBaseLines, prismBase); prism = GeoObjConstruction.dPrism(prismBasePoly, prismBasePoly.center + Vector3.up * xLen); prismTopPoly = prism.bases[1]; cutoutRectangle.Add(prismBase[0]); cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[0].Position3 + Vector3.back * xLen)); cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[1].Position3 + Vector3.back * xLen)); cutoutRectangle.Add(prismBase[1]); cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[1].Position3 + Vector3.right * xLen)); cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[2].Position3 + Vector3.right * xLen)); cutoutRectangle.Add(prismBase[2]); cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[2].Position3 + Vector3.forward * xLen)); cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[3].Position3 + Vector3.forward * xLen)); cutoutRectangle.Add(prismBase[3]); cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[3].Position3 + Vector3.left * xLen)); cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[0].Position3 + Vector3.left * xLen)); List <AbstractLineSegment> cutoutLines = new List <AbstractLineSegment>(); for (int i = 0; i < cutoutRectangle.Count - 1; i++) { cutoutLines.Add(GeoObjConstruction.dLineSegment(cutoutRectangle[i], cutoutRectangle[i + 1])); } cutoutLines.Add(GeoObjConstruction.dLineSegment(cutoutRectangle[0], cutoutRectangle[cutoutRectangle.Count - 1])); cutoutRectanglePoly = GeoObjConstruction.dPolygon(cutoutLines, cutoutRectangle); foreach (MasterGeoObj mgo in prism.transform.parent.GetComponentsInChildren <MasterGeoObj>()) { if (mgo != controllPoint) { mgo.LeapInteraction = false; } } controllPoint.GetComponent <Leap.Unity.Interaction.InteractionBehaviour>().OnGraspedMovement += updateDiagram; controllPoint.GetComponent <Leap.Unity.Interaction.InteractionBehaviour>().OnGraspEnd += updateDiagram; volumeLineRenderer.useWorldSpace = false; Color tmp = Color.blue; tmp.a = .5f; cutoutRectanglePoly.figColor = tmp; foreach (AbstractPolygon poly in prism.allfaces) { tmp = Color.red; tmp.a = .5f; poly.figColor = tmp; } prism.bases[0].figColor = Color.clear; }
internal void addApexToList(AbstractPoint apex) { apexList.Add(apex); apexPos.Add(apex, apex.Position3); }
internal void Start() { shearingLabManager labMan = FindObjectOfType <shearingLabManager>(); labMan.measurementDisplays.Add(surfaceAreaModel.transform); labMan.measurementDisplays.Add(volumeModel.transform); //labMan.measurementDisplays.Add(crossSectionModel.transform); labMan.disableDisplays(); surfaceAreaModel.GetComponent <MeshRenderer>().materials[0].color = mgoColor; volumeModel.GetComponent <MeshRenderer>().materials[0].color = mgoColor; crossSectionModel.GetComponent <MeshRenderer>().materials[0].color = mgoColor; //copy into base scene on Load. //this.transform.parent = SceneManager.GetSceneByName("HandWaverBase").GetRootGameObjects()[0].transform.parent; //construct parallel planes flatface1 = flatlandSurface.Constructor(); flatface2 = flatlandSurface.Constructor(); flatface1.otherFlatlandSurface = flatface2; flatface2.otherFlatlandSurface = flatface1; flatface1.transform.localScale = new Vector3(3f, .0001f, 3f); flatface2.transform.localScale = new Vector3(3f, .0001f, 3f); AbstractPoint apexPoint = GeoObjConstruction.iPoint(Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height2); AbstractPolygon basePoly = GeoObjConstruction.rPoly(nSides, .3f, Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height1); myPyramid = GeoObjConstruction.dPyramid(basePoly, apexPoint); foreach (AbstractLineSegment line in myPyramid.allEdges) { line.LeapInteraction = false; } foreach (AbstractPoint point in basePoly.pointList) { point.LeapInteraction = false; flatface1.attachedObjs.Add(point); } foreach (AbstractPolygon face in myPyramid.allfaces) { face.LeapInteraction = false; } flatface2.attachedObjs.Add(apexPoint); flatface2.attachedObjs.Add(basePoly); myPyramid.GetComponent <InteractionBehaviour>().enabled = false; mf.transform.position = Vector3.zero; mf.transform.localScale = Vector3.one; mf.transform.rotation = Quaternion.identity; palmDetectors = GetComponentsInChildren <PalmDirectionDetector>(); //NATHAN HELP ME HERE for (int i = 0; i < palmDetectors.Length; i++) { PalmDirectionDetector palm = palmDetectors[i]; palm.OnActivate.AddListener(startUpdateMesh); palm.OnDeactivate.AddListener(endUpdateMesh); ExtendedFingerDetector finger = palm.GetComponent <ExtendedFingerDetector>(); finger.OnDeactivate.AddListener(endUpdateMesh); //the extended finger detectors are set to enable/disable the respective PalmDirectionDetectors. switch (i) { case 0: palm.HandModel = leapHandDataLogger.ins.currHands.Lhand_rigged; finger.HandModel = leapHandDataLogger.ins.currHands.Lhand_rigged; break; case 1: palm.HandModel = leapHandDataLogger.ins.currHands.RHand_rigged; finger.HandModel = leapHandDataLogger.ins.currHands.RHand_rigged; break; default: break; } } updateMesh = updateMeshRoutine(); if (overrideHandInput) { startUpdateMesh(); } foreach (AbstractPolygon face in myPyramid.allfaces) { face.figColor = mgoColor; } myPyramid.apex.GetComponent <InteractionBehaviour>().OnGraspEnd += constantVelOutOfRange; labMan.addApexToList(myPyramid.apex); }
internal void Start() { shearingLabManager labMan = FindObjectOfType <shearingLabManager>(); labMan.measurementDisplays.Add(areaModel.transform); labMan.measurementDisplays.Add(perimeterModel.transform); //labMan.measurementDisplays.Add(crossSectionModel.transform); labMan.disableDisplays(); areaModel.GetComponent <MeshRenderer>().materials[0].color = mgoColor; perimeterModel.GetComponent <LineRenderer>().materials[0].color = mgoColor; crossSectionModel.GetComponent <LineRenderer>().materials[0].color = mgoColor; line1 = parallelLines.Constructor(); parallelLines line2 = parallelLines.Constructor(); line1.Position3 = Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height2; line2.Position3 = Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height1; line1.otherLine = line2; line2.otherLine = line1; AbstractPoint p1 = GeoObjConstruction.iPoint(line1.Position3); AbstractPoint p2 = GeoObjConstruction.iPoint(line2.Position3); AbstractPoint p3 = GeoObjConstruction.iPoint(line2.Position3 + line2.normalDir * 0.3f); p1.GetComponent <InteractionBehaviour>().OnGraspedMovement += checkOutOfRange; p1.GetComponent <InteractionBehaviour>().OnGraspEnd += constantVelOutOfRange; labMan.addApexToList(p1); //line not on Parallel l1 = GeoObjConstruction.dLineSegment(p1, p2); //line not on parallel l2 = GeoObjConstruction.dLineSegment(p1, p3); //line on parallel AbstractLineSegment l3 = GeoObjConstruction.dLineSegment(p3, p2); line1.attachedObjs.Add(p1); line2.attachedObjs.Add(p2); line2.attachedObjs.Add(p3); points.Add(p1); points.Add(p2); points.Add(p3); lines.Add(l1); lines.Add(l2); lines.Add(l3); triangle = GeoObjConstruction.dPolygon(lines, points); foreach (AbstractLineSegment line in lines) { line.GetComponent <InteractionBehaviour>().enabled = false; } triangle.GetComponent <InteractionBehaviour>().enabled = false; myLR = GetComponent <LineRenderer>(); palmDetectors = GetComponentsInChildren <PalmDirectionDetector>(); for (int i = 0; i < palmDetectors.Length; i++) { PalmDirectionDetector palm = palmDetectors[i]; palm.OnActivate.AddListener(startUpdateMesh); palm.OnDeactivate.AddListener(endUpdateMesh); ExtendedFingerDetector finger = palm.GetComponent <ExtendedFingerDetector>(); finger.OnDeactivate.AddListener(endUpdateMesh); switch (i) { case 0: palm.HandModel = leapHandDataLogger.ins.currHands.Lhand_rigged; finger.HandModel = leapHandDataLogger.ins.currHands.Lhand_rigged; break; case 1: palm.HandModel = leapHandDataLogger.ins.currHands.RHand_rigged; finger.HandModel = leapHandDataLogger.ins.currHands.RHand_rigged; break; default: break; } //the extended finger detectors are set to enable/disable the respective PalmDirectionDetectors. } updateLR = updateLR_Routine(); if (overridePalmDetector) { startUpdateMesh(); } triangle.figColor = mgoColor; movePointOnLine = animatePoint(points[0]); }