示例#1
0
        public void SplineToDCurve()
        {
            Dictionary <DraggablePoint, DCurveBulb> bulbDict = new Dictionary <DraggablePoint, DCurveBulb>();

            foreach (DraggablePoint bulb in bulbs)
            {
                DCurveBulb dcBulb = bulb.ConvertToBulb();
                dBulbs.Add(dcBulb);
                bulbDict.Add(bulb, dcBulb);
            }

            foreach (CatmullRomSpline spline in splines)
            {
                DiscreteCurve dc = spline.ConvertToDCurve();

                if (spline.StartBulb)
                {
                    DCurveBulb parentOfSpline = bulbDict[spline.StartBulb];
                    dc.parentBulb = parentOfSpline;
                    parentOfSpline.childCurves.Add(dc);
                }
                if (spline.EndBulb)
                {
                    DCurveBulb endOfSpline = bulbDict[spline.EndBulb];
                    dc.childBulb            = endOfSpline;
                    endOfSpline.parentCurve = dc;
                }

                AddDCurve(dc);
            }

            stage = CanvasStage.DCurve;
        }
        public DCurveBulb Duplicate()
        {
            GameObject newBulbObj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            DCurveBulb newBulb    = newBulbObj.AddComponent <DCurveBulb>();

            newBulb.radius               = radius;
            newBulb.transform.position   = transform.position;
            newBulb.transform.localScale = transform.localScale;
            newBulb.transform.parent     = transform.parent;

            newBulb.childCurves = new List <IParameterizedCurve>();

            newBulb.originalType = originalType;

            return(newBulb);
        }
示例#3
0
        public void DCurveToTIC()
        {
            // Clear away the old stuff
            foreach (TorsionImpulseCurve tic in tiCurves)
            {
                Destroy(tic.gameObject);
            }
            tiCurves.Clear();

            foreach (DCurveBulb dcb in tiBulbs)
            {
                Destroy(dcb.gameObject);
            }
            tiBulbs.Clear();

            Dictionary <DCurveBulb, DCurveBulb> bulbDict = new Dictionary <DCurveBulb, DCurveBulb>();

            foreach (DCurveBulb origBulb in dBulbs)
            {
                DCurveBulb newBulb = origBulb.Duplicate();
                tiBulbs.Add(newBulb);
                bulbDict.Add(origBulb, newBulb);
            }

            foreach (DiscreteCurve dc in dCurves)
            {
                TorsionImpulseCurve impulseCurve = dc.MakeImpulseCurve();
                tiCurves.Add(impulseCurve);
                impulseCurve.transform.parent = transform;

                if (dc.parentBulb)
                {
                    DCurveBulb newParent = bulbDict[dc.parentBulb];
                    newParent.childCurves.Add(impulseCurve);
                    impulseCurve.StartJuncture = newParent;
                }

                if (dc.childBulb)
                {
                    DCurveBulb newChild = bulbDict[dc.childBulb];
                    newChild.parentCurve     = impulseCurve;
                    impulseCurve.EndJuncture = newChild;
                }
            }

            tiCreated = true;
        }
        public DCurveBulb ConvertToBulb()
        {
            if (Type != PointType.Spline)
            {
                GameObject bulbObj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                bulbObj.name = "discreteBulb";
                DCurveBulb bulb = bulbObj.AddComponent <DCurveBulb>();
                bulb.InitFromPoint(this);

                gameObject.SetActive(false);

                bulb.originalType = Type;

                return(bulb);
            }
            return(null);
        }
 public void CopyPrevs(DCurveBulb old)
 {
     previousParentPosition = old.previousParentPosition;
     previousParentTangent  = old.previousParentTangent;
 }
示例#6
0
 public void AddDBulb(DCurveBulb b)
 {
     dBulbs.Add(b);
 }