示例#1
0
    //public static Bounds GetActiveConduitBounds()
    //{
    //    return m_activeConduit.mesh.bounds;
    //}

    public static void LinkActiveConduit(Bend bend)
    {
        Debug.Log("ConduitManager: LinkActiveConduit()");
        // Remove any current Decorator component objects from Active Conduit
        AConduitDecorator decorator = m_activeConduit.GetComponentInChildren <AConduitDecorator>();

        if (decorator != null)
        {
            decorator.OnRemove();
            //Destroy( decorator.gameObject );
            m_activeConduit.transform.DestroyChildren();
        }

        m_activeConduit.Link(bend);

        // Set Decorator (if available)
        decorator = ConduitDecoratorFactory.Get(bend.type);
        if (decorator != null)
        {
            m_activeDecorator = Instantiate(decorator);
            m_activeDecorator.transform.SetParent(m_activeConduit.transform, false);
            m_activeDecorator.transform.localPosition = Vector3.zero; // @TODO - Redundant?
            m_activeDecorator.Set(m_activeConduit);
        }
        else
        {
            m_activeDecorator = null;
        }
    }
示例#2
0
    public float EAngle(int order, bool suppress = false)
    {
        Bend param = GetParameter();

        if (param == null)
        {
            if (!suppress)
            {
                Debug.LogError(string.Format("No parameter for Angle: {0}-{1}-{2}", this.atom0.amberName, this.atom1.amberName, this.atom2.amberName));
            }
            return(0f);
        }

        float angle = this.atoms.getAngle(this.a0, this.a1, this.a2);

        if (order == 0)
        {
            return(param.keq * Mathf.Pow(angle - param.req, 2f));
        }
        else if (order == 1)
        {
            return(2f * param.keq * (angle - param.req));
        }
        else if (order == 2)
        {
            return(2f * param.keq);
        }
        else
        {
            return(0f);
        }
    }
        public IActionResult SacuvajModifikovanBend(string bendID, string Ime, string Brclanova, string Brojtel)
        {
            Bend bb = new Bend();

            bb.BendID    = bendID;
            bb.Ime       = Ime;
            bb.Brclanova = Brclanova;
            bb.Brojtel   = Brojtel;

            if (proveriUneto(bb) == false) //proverava da li su sva polja uneta
                                           // return RedirectToAction("ModifikujBend");
            {
                return(RedirectToAction("ModifikujBend", new { bendID = bendID }));
            }


            try
            {
                session.Execute(" INSERT INTO \"Bend\"(\"bendID\", brclanova, brojtel, ime)" +
                                "  VALUES(\'" + bendID + "\',\'" + bb.Brclanova + "\' ,\'" + bb.Brojtel + "\' ,\'" + bb.Ime + "\' );");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(RedirectToAction("PrikaziBendove"));
        }
示例#4
0
        public IActionResult Snimi(MuzikaEvidentirajBendoveVM x)
        {
            Bend bendovi = new Bend();

            x.PutanjaDoSlike = UploadFile(x);
            if (x.BendID == 0)
            {
                _dbContext.Add(bendovi);
            }
            else
            {
                bendovi = _dbContext.Bendovi.Find(x.BendID);
            }

            bendovi.BendID          = x.BendID;
            bendovi.SatnicaSviranja = x.SatnicaSviranja;
            if (!string.IsNullOrEmpty(x.PutanjaDoSlike))
            {
                bendovi.PutanjaDoSlikeBenda = x.PutanjaDoSlike;
            }

            bendovi.OpisBenda  = x.OpisBenda;
            bendovi.NazivBenda = x.NazivBenda;



            _dbContext.SaveChanges();
            return(Redirect("PrikazBendova?KorisnikID=" + x.KorisnikID));
        }
示例#5
0
    public void AddControlPoint(Vector3 Pt, int segCount, BendType bendType, Bend bend)
    {
        if (segCount != 0)
        {
            segCount = bend.EndSegIdx - bend.StartSegIdx;
        }
        RLPt BCP = new RLPt(this, Pt);

        BCP.BendType = bendType;
        BCP.Bend     = bend;
        CtrlPts[CtrlPts.Count - 2].SegCount = segCount;     //set the SegCount of the previous CtrlPt
        CtrlPts.Insert(CtrlPts.Count - 1, BCP);

        SetCtrlPtIds();
        SetSegStartIds();
        CtrlPts[CtrlPts.Count - 1].Pos = Pt;        //cos the last control point is a dummy and is in the same place
        if (BCP.CtrlPtId == 1)
        {
            if (Rd.IsCircular)
            {
                CtrlPts[0].Pos = CtrlPts[CtrlPts.Count - 2].Pos;
            }
        }
        else
        {
            CtrlPts[0].Pos = Pt;                    //cos the first one is a dummy too
        }
        if (BCP.CtrlPtId > 1)
        {
            AddPathPoints(segCount);
        }
    }
    public override void Decorate()
    {
        Bend bend = m_Conduit.bend;
        // Get Segmented Radius
        float radiusM    = (float)bend.GetInputParameter(EBendParameterName.SegmentedRadius).value;
        float angleDeg   = (float)bend.GetInputParameter(EBendParameterName.SegmentedAngle).value;
        var   centerline = m_Conduit.centerline;
        var   indices    = m_Conduit.centerlineBendIndices;

        if (radiusM == 0f || angleDeg == 0f || indices.Count == 0 || bend.alert != null)
        {
            EnableSector(false);
            return;
        }
        if (!m_SectorEnabled)
        {
            EnableSector(true);
        }

        // Get Bend Start Positions
        int start_i = indices[0].index;

        // Generate Circle Sector Mesh
        ConduitGenerator.GenerateSector(sectorMesh, radiusM, angleDeg, 5f);

        // Set Position

        Vector3 center = centerline[start_i].point + centerline[start_i].radialDir * radiusM;

        sectorObject.localPosition = center;
    }
示例#7
0
 public void Link(Bend model)
 {
     if (m_Bend != null)
     {
         m_Bend.onEvent.RemoveListener(ListenerBend);
     }
     m_Bend = model;
     m_Bend.onEvent.AddListener(ListenerBend);
 }
示例#8
0
    /*##################################
     *
     *      Public Functions
     *
     ###################################*/
    /// <summary>
    /// Links this Bend Input Screen to a Bend and Sets up Screen Appropriately
    /// </summary>
    public override void Link(IModel model)
    {
        if (!m_HasInitialized)
        {
            Debug.LogError("BendInputScreen: Link() Screen must first be Initialized.");
            return;
        }
        if (m_Bend != null)
        {
            // Unregister Listeners on Previous Bend
            m_Bend.onEvent.RemoveListener(ListenerBend);
        }
        Bend bend = (Bend)model;

        m_Bend = bend;
        m_Bend.onEvent.AddListener(ListenerBend);

        // Initialize Output View
        InitializeOutput();

        RectTransform   scrollerContent = bendParameterScroller.content;
        RectTransform   bendParamPrefab;
        UIBendParameter uiBendParam;
        BendParameter   bendParam;

        bendParameterScroller.ClearContent();

        // Set up Bend Input Parameter View
        for (int i = 0; i < bend.inputParameters.Count; ++i)
        {
            bendParam       = bend.inputParameters[i];
            bendParamPrefab = Instantiate(bendParameterPrefab);
            bendParamPrefab.SetParent(scrollerContent, false);

            uiBendParam = bendParamPrefab.GetComponent <UIBendParameter>();
            uiBendParam.Set(bendParam.type, BendParameter.GetStringValue(bendParam.name), i);
            uiBendParam.onClick = DisplayWidget;
            if (i == 0)
            {
                // Set 1st Parameter as Selected
                uiBendParam.button.Select();
            }
        }

        bendParameterScroller.Layout();

        // Set up Help Widget
        bendParamPrefab = Instantiate(bendParameterPrefab);
        bendParamPrefab.SetParent(scrollerContent, false);
        uiBendParam = bendParamPrefab.GetComponent <UIBendParameter>();
        uiBendParam.SetAsHelp();
        uiBendParam.onClick = DisplayHelpWidget;

        // Display 1st Parameter Widget
        m_ActiveParameter = -1;
        DisplayWidget(0);
    }
示例#9
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        Bend bend = (Bend)target;

        if (GUILayout.Button("Bend Mesh"))
        {
            bend.BendMesh();
        }
    }
示例#10
0
        public Bend CreateNew()
        {
            var item = new Bend
            {
                Id = MockDatabase.Bendovi.Max(x => x.Id) + 1
            };

            MockDatabase.Bendovi.Add(item);
            return(item);
        }
示例#11
0
 public void AddBend(Bend newBend)
 {
     foreach (Bend bend in bends)
     {
         if (bend.TypeEquivalent(newBend))
         {
             throw new System.Exception("Bend already exists in Parameters set");
         }
     }
     bends.Add(newBend);
 }
示例#12
0
 //Find index of type equivalent bend
 //Return -1 if no type equivalent bends are in this parameters set
 public int IndexBend(Bend otherBend)
 {
     for (int index = 0; index < bends.Count; index++)
     {
         if (bends[index].TypeEquivalent(otherBend))
         {
             return(index);
         }
     }
     return(-1);
 }
 public bool proveriUneto(Bend k)
 {
     if (k.BendID != null & k.Brclanova != null & k.Brojtel != null & k.Ime != null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#14
0
 public bool ContainsBend(Bend otherBend)
 {
     foreach (Bend thisBend in bends)
     {
         if (thisBend.TypeEquivalent(otherBend))
         {
             return(true);
         }
     }
     return(false);
 }
        // ! Elimina tutti i fillet
        public static List <string> deleteFillet_(PartDocument oDoc)
        {
            SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition;

            List <string> faceCollToKeep = new List <string>();

            if (oCompDef.Bends.Count > 0)
            {
                Bend oBend = oCompDef.Bends[1];

                FaceCollection oFaceColl = oBend.FrontFaces[1].TangentiallyConnectedFaces;
                oFaceColl.Add(oBend.FrontFaces[1]);

                foreach (Face oFace in oFaceColl)
                {
                    faceCollToKeep.Add(oFace.InternalName);
                }

                NonParametricBaseFeature oBaseFeature = oCompDef.Features.NonParametricBaseFeatures[1];

                oBaseFeature.Edit();

                SurfaceBody basebody = oBaseFeature.BaseSolidBody;

                ObjectCollection oColl = iApp.TransientObjects.CreateObjectCollection();

                foreach (Face f in basebody.Faces)
                {
                    if (faceCollToKeep.Contains(f.InternalName))
                    {
                        if (f.SurfaceType == SurfaceTypeEnum.kCylinderSurface)
                        {
                            oColl.Add(f);
                        }
                    }
                }
                try
                {
                    oBaseFeature.DeleteFaces(oColl);
                    oBaseFeature.ExitEdit();
                }
                catch
                {
                    oBaseFeature.ExitEdit();
                    return(null);
                }
            }

            return(faceCollToKeep);
        }
示例#16
0
        public IActionResult ObrisiBend(string KorisnikID, int BendID)
        {
            Bend bend = _dbContext.Bendovi.Find(BendID);

            foreach (var x in _dbContext.MuzikaBendovi.Where(a => a.BendID == BendID))
            {
                _dbContext.MuzikaBendovi.Remove(x);
            }

            _dbContext.Remove(bend);

            _dbContext.SaveChanges();

            return(Redirect("PrikazBendova?KorisnikID=" + KorisnikID));
        }
示例#17
0
 public bool TypeEquivalent(Bend other)
 {
     if (this.t1 != other.t1)
     {
         return(false);
     }
     if (this.t0 == other.t0 && this.t2 == other.t2)
     {
         return(true);
     }
     if (this.t0 == other.t2 && this.t2 == other.t0)
     {
         return(true);
     }
     return(false);
 }
        protected Bend ReadBend()
        {
            Bend bend = new Bend();

            bend.Type  = ReadEnum <BendType>();
            bend.Value = ReadInt();

            int pointsNumber = ReadInt();

            bend.Points = new BendPoint[pointsNumber];
            for (int i = 0; i < pointsNumber; i++)
            {
                bend.Points[i] = ReadBendPoint();
            }

            return(bend);
        }
        public IActionResult sacuvajBenduBazi(string BendID, string Brclanova, string Brojtel, string Ime)
        {
            Bend k = null;

            var r = session.Execute("SELECT * FROM \"Bend\"  WHERE " + "\"bendID\" =" + "\'" + BendID + "\'" + " ; ");

            foreach (var result in r)
            {
                k = new Bend();

                k.BendID    = result.GetValue <string>("bendID");
                k.Ime       = result.GetValue <string>("ime");
                k.Brclanova = result.GetValue <string>("brclanova");
                k.Brojtel   = result.GetValue <string>("brojtel");
            }
            if (k != null)
            {
                return(RedirectToAction("kreirajBend")); //posotji bend sa ovim id
            }
            Bend kk = new Bend();

            kk.BendID    = BendID;
            kk.Brclanova = Brclanova;
            kk.Brojtel   = Brojtel;
            kk.Ime       = Ime;



            if (proveriUneto(kk) == false)//proverava da li su sva polja uneta
            {
                return(RedirectToAction("kreirajBend"));
            }

            try
            {
                session.Execute(" INSERT INTO \"Bend\"(\"bendID\", brclanova, brojtel, ime)" +
                                "  VALUES(\'" + BendID + "\',\'" + kk.Brclanova + "\' ,\'" + kk.Brojtel + "\' ,\'" + kk.Ime + "\' );");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(RedirectToAction("PrikaziBendove"));
        }
        public IActionResult ModifikujBend(string bendID)
        {
            Bend k = null;

            var r = session.Execute("SELECT * FROM \"Bend\"  WHERE " + "\"bendID\" =" + "\'" + bendID + "\'" + " ; ");

            foreach (var result in r)
            {
                k = new Bend();

                k.BendID    = result.GetValue <string>("bendID");
                k.Ime       = result.GetValue <string>("ime");
                k.Brclanova = result.GetValue <string>("brclanova");
                k.Brojtel   = result.GetValue <string>("brojtel");
            }

            return(View(k));
        }
    public override void Decorate()
    {
        Bend bend = m_Conduit.bend;

        // Get Roll Angle
        float rollAngleDeg = (float)bend.GetOutputParameter(EBendParameterName.RollAngleDegrees).value;
        float riseM        = (float)bend.GetInputParameter(EBendParameterName.Rise).value;
        float rollM        = (float)bend.GetInputParameter(EBendParameterName.Roll).value;
        var   centerline   = m_Conduit.centerline;
        var   indices      = m_Conduit.centerlineBendIndices;

        if (rollAngleDeg == 0f || indices.Count == 0 || bend.alert != null)
        {
            // Disable Lines
            EnableLines(false);
            return;
        }
        if (!m_LinesEnabled)
        {
            EnableLines(true);
        }

        // Get Points
        //Vector3 csFirst = centerline[ indices[0].index ].point;
        //Vector3 ceSecond = centerline[ indices[3].index ].point;
        Vector3 cEnd = centerline[centerline.Count - 1].point;

        Vector3 origin = Vector3.zero;

        origin.z = cEnd.z;
        Vector3 riseOrigin = origin;

        riseOrigin.y -= m_LineWidth * 0.5f;
        // Generate Circle Sector Mesh
        //ConduitGenerator.GenerateSector( sectorMesh, riseM, rollAngleDeg, 5f );
        m_RiseLine.Draw(riseOrigin, riseOrigin + Vector3.up * riseM);
        m_RollLine.Draw(origin, origin + Vector3.left * rollM);

        // Positions
        //sectorObject.localPosition = origin;
        m_Conduit.transform.rotation = Quaternion.Euler(0f, 0f, rollAngleDeg);
        transform.localRotation      = Quaternion.Euler(0f, 0f, 360f - rollAngleDeg); // Undo Rotation (since we're child of Conduit)
    }
示例#22
0
        private BandDto MapBand(Bend foundedBand)
        {
            var responseDto = new BandDto();

            responseDto.City          = foundedBand.mjesto;
            responseDto.Contact       = foundedBand.kontakt;
            responseDto.FacebookPage  = foundedBand.facebook;
            responseDto.Founded       = foundedBand.datum_osnivanja;
            responseDto.Id            = foundedBand.id_bend;
            responseDto.Image         = foundedBand.slika;
            responseDto.InstagramPage = foundedBand.instagram;
            responseDto.Mail          = foundedBand.e_mail;
            responseDto.MemberCount   = foundedBand.broj_clanova;
            responseDto.Name          = foundedBand.naziv;
            responseDto.WebPage       = foundedBand.web_stranica;
            responseDto.AccountType   = foundedBand.tip_korisnika;
            responseDto.BandFounded   = true;

            return(responseDto);
        }
    /*
     * kind of an expensive method, but for my purposes we dont need a dynamic constraint generator, so be it
     */
    void GenerateConstraints()
    {
        vertex     firstVertex = vertices[0];
        FixedPoint fp          = new FixedPoint(0, firstVertex);

        firstVertex.GetComponent <Renderer>().material.color = Color.black;
        constraints.Add(fp);

        for (int i = 0; i < vertices.Length; i++)
        {
            for (int j = 0; j < vertices.Length; j++)
            {
                if (i != j)
                {
                    if ((vertices[i].transform.position - vertices[j].transform.position).magnitude < 1.2f)
                    {
                        Stretch s = new Stretch(i, j, vertices[i], vertices[j]);
                        constraints.Add(s);
                    }
                }
            }
        }
        //diagonal edges
        for (int i = 0; i < (rows - 1) * (columns - 1) + 6; i++)
        {
            if (i % columns == (columns - 1))
            {
                continue;
            }
            Stretch s = new Stretch(i, i + columns + 1, vertices[i], vertices[i + columns + 1]);
            Bend    b = new Bend(i, i + columns + 1, i + 1, i + columns,
                                 vertices[i], vertices[i + columns + 1], vertices[i + 1], vertices[i + columns]);
            constraints.Add(s);
            constraints.Add(b);
            //create triangle t1
            //triangles.Add(vertices[i]); triangles.Add(vertices[i + columns+ 1]); triangles.Add(vertices[i+1]);
            //create triangle t2
            //triangles.Add(vertices[i + columns+ 1]); triangles.Add(vertices[i]); triangles.Add(vertices[i + columns]);
        }
    }
示例#24
0
 private void PopulateXSecCurrBends()
 {
     foreach (Bend _bend in Bends)
     {
         //These two saved a massive performance hit
         Bend _nb = Bends.Next(_bend);
         for (XSec x = _bend.TurninXSec; x != _bend.ExitXSec; x = XSecs.Next(x))
         {
             x.CurrBend = _bend;
         }
         if (_nb.TurninXSec == null)
         {
             Debug.Log("BendId" + _bend.BendId + " no turnin");
         }
         else
         {
             for (XSec x = _bend.TurninXSec; x != _nb.TurninXSec; x = XSecs.Next(x))
             {
                 x.NextBend = _nb;
             }
         }
     }
 }
示例#25
0
        public void KojtoCAD_3D_ExtrudeRatioByBend()
        {
            Database db = HostApplicationServices.WorkingDatabase;
            Editor   ed = Application.DocumentManager.MdiActiveDocument.Editor;

            Matrix3d old = ed.CurrentUserCoordinateSystem;

            ed.CurrentUserCoordinateSystem = Matrix3d.Identity;

            try
            {
                if ((container != null) && (container.Bends.Count > 0) && (container.Triangles.Count > 0))
                {
                    do
                    {
                        PromptPointResult  pPtRes;
                        PromptPointOptions pPtOpts = new PromptPointOptions("");

                        // Prompt for the first point
                        pPtOpts.Message = "\nEnter the first Point of the Bend: ";
                        pPtRes          = Application.DocumentManager.MdiActiveDocument.Editor.GetPoint(pPtOpts);
                        if (pPtRes.Status == PromptStatus.OK)
                        {
                            Point3d ptFirst = pPtRes.Value;

                            // Prompt for the second point
                            pPtOpts.Message      = "\nEnter the second Point of the Bend: ";
                            pPtOpts.UseBasePoint = true;
                            pPtOpts.BasePoint    = ptFirst;
                            pPtRes = Application.DocumentManager.MdiActiveDocument.Editor.GetPoint(pPtOpts);
                            if (pPtRes.Status == PromptStatus.OK)
                            {
                                Point3d ptSecond = pPtRes.Value;

                                if (ptSecond.DistanceTo(ptFirst) >= ConstantsAndSettings.MinBendLength)
                                {
                                    Pair <quaternion, quaternion> pb = new Pair <quaternion, quaternion>(new quaternion(0, ptFirst.X, ptFirst.Y, ptFirst.Z), new quaternion(0, ptSecond.X, ptSecond.Y, ptSecond.Z));
                                    Bend Bend = null;
                                    foreach (Bend bend in container.Bends)
                                    {
                                        if (bend == pb)
                                        {
                                            Bend = bend;
                                            break;
                                        }
                                    }
                                    if ((object)Bend != null)
                                    {
                                        if (!Bend.IsFictive())
                                        {
                                            int kT = 0;//first
                                            #region select triangle side
                                            if (Bend.SecondTriangleNumer >= 0)
                                            {
                                                //------ prompt for triangle
                                                PromptPointResult  tPtRes;
                                                PromptPointOptions tPtOpts = new PromptPointOptions("");
                                                tPtOpts.Message = "\nEnter the third Point of the Triangle: ";
                                                tPtRes          = Application.DocumentManager.MdiActiveDocument.Editor.GetPoint(tPtOpts);
                                                if (tPtRes.Status == PromptStatus.OK)
                                                {
                                                    Triplet <quaternion, quaternion, quaternion> pTR = new Triplet <quaternion, quaternion, quaternion>(new quaternion(0, ptFirst.X, ptFirst.Y, ptFirst.Z),
                                                                                                                                                        new quaternion(0, ptSecond.X, ptSecond.Y, ptSecond.Z),
                                                                                                                                                        new quaternion(0, tPtRes.Value.X, tPtRes.Value.Y, tPtRes.Value.Z));
                                                    Triangle TR = null;
                                                    foreach (Triangle tr in container.Triangles)
                                                    {
                                                        if (tr == pTR)
                                                        {
                                                            TR = tr;
                                                            break;
                                                        }
                                                    }
                                                    if ((object)TR != null)
                                                    {
                                                        if (Bend.FirstTriangleNumer != TR.Numer)
                                                        {
                                                            kT = 1;//second
                                                        }
                                                    }
                                                    else
                                                    {
                                                        MessageBox.Show("\nTriangle not found - E R R O R  !", "E R R O R - Selection Triangle", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                        ed.WriteMessage("\nTriangle not found - E R R O R  !");
                                                    }
                                                }
                                            }
                                            #endregion

                                            double extrudeRatio = (kT == 0) ? Bend.explicit_first_cutExtrudeRatio : Bend.explicit_second_cutExtrudeRatio;

                                            PromptDoubleOptions pDoubleOpts = new PromptDoubleOptions("");
                                            pDoubleOpts.Message = "\nEnter the Distance : ";

                                            pDoubleOpts.AllowZero     = true;
                                            pDoubleOpts.AllowNegative = true;
                                            pDoubleOpts.DefaultValue  = extrudeRatio;
                                            PromptDoubleResult pDoubleRes = Application.DocumentManager.MdiActiveDocument.Editor.GetDouble(pDoubleOpts);
                                            if (pDoubleRes.Status == PromptStatus.OK)
                                            {
                                                // double newRatio = pDoubleRes.Value;
                                                if (kT == 0)
                                                {
                                                    Bend.explicit_first_cutExtrudeRatio = pDoubleRes.Value;
                                                }
                                                else
                                                {
                                                    Bend.explicit_second_cutExtrudeRatio = pDoubleRes.Value;
                                                };
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }while (MessageBox.Show("Select next ?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes);
                }
                else
                {
                    MessageBox.Show("\nData Base Empty !\n\nMissing Bends !", "Range Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch { }
            finally { ed.CurrentUserCoordinateSystem = old; }
        }
示例#26
0
    void Update()
    {
        if (CR_Running)
        {
            return;
        }
        if (Timer == 0)
        {
            Timer = 10;
        }
        Timer--;
        if (Timer != 0)
        {
            return;
        }
        Accel      = 0.9f;
        BrakeForce = 0;
        Steer      = 0;
        SegIdx     = _gps.CurrSegIdx;
        _currXSec  = _gps.CurrXSec;
        _nextBend  = _gps.NextBend;
        _currBend  = _gps.CurrBend;
        bool FirstHalfOfBend = _currBend != null && _currXSec.IsBefore(_currBend.ApexXSec);
        //Vector3 B = Road.Instance.Segments[SegIdx].verts[4];
        Vector3 SegFwdDir = Road.Instance.XSecs[SegIdx].Forward;
        Vector3 Heading   = transform.forward;

        HeadingAngle = Vector3.Angle(Heading, SegFwdDir);
        Vector3 cross = Vector3.Cross(Heading, SegFwdDir);

        if (cross.y > 0)
        {
            HeadingAngle = -HeadingAngle;
        }
        //Postition across the cross sec
        Vector3 L             = Road.Instance.XSecs[SegIdx].KerbL;
        Vector3 R             = Road.Instance.XSecs[SegIdx].KerbR;
        float   DistFromLKerb = Vector3.Distance(L, transform.position);
        float   DistFromRKerb = Vector3.Distance(R, transform.position);
        //Calculate entry speed for next bend
        float _entrySpeed = Mathf.Abs(50 / _nextBend.AnglePerSeg);

        //Coming into a sharp bend too fast slow down
        if (_gps.SegsPerSec - _entrySpeed > (_nextBend.StartSegIdx > _gps.CurrSegIdx?_nextBend.StartSegIdx - _gps.CurrSegIdx: _nextBend.StartSegIdx + Rd.Segments.Count - _gps.CurrSegIdx))
        {
            Accel = 0; BrakeForce = 1f;
        }
        else
        {
            Accel = 1; BrakeForce = 0;
        }


        //Aim for the middle of the 10th segment in front
        XSec    AimSec   = Road.Instance.XSecCircular(SegIdx + 20);
        Vector3 AimPoint = AimSec.MidPt;

        if (FirstHalfOfBend)
        {
            if (_currBend.AnglePerSeg > 1)
            {
                if (_currBend.Type == BendType.Left)
                {
                    AimPoint = AimSec.MidLeft;
                }
                if (_currBend.Type == BendType.Right)
                {
                    AimPoint = AimSec.MidRight;
                }
            }
        }
        Vector3 LongAimPoint = Road.Instance.XSecCircular(SegIdx + 40).MidPt;

        //steer round the car in front
        Vector3 FrontOfCar = transform.position + transform.up * 0.5f + transform.forward * 2.5f;

        _collisionRay = new Ray(FrontOfCar, AimPoint + Vector3.up - FrontOfCar);
        int layerMask = (1 << 8);

        if (Physics.Raycast(_collisionRay, out CollisionHit, 50, layerMask))
        {
            if (CollisionHit.collider.name != this.name)
            {
                if (CollisionHit.rigidbody.velocity.sqrMagnitude < 1)
                {
                    StartCoroutine(ThreePointTurn("R"));
                }
                else
                {
                    AimPoint = (Road.Instance.XSecCircular(SegIdx + 10).MidPt + Road.Instance.XSecCircular(SegIdx + 10).KerbR) / 2;
                }
            }
        }
        //Debug.DrawRay(FrontOfCar, AimPoint + Vector3.up - FrontOfCar, Color.red);

        //***********************************************************************************
        //Steer towards the aim point
        float   DesiredHeadingAngle = Vector3.Angle(AimPoint - transform.position, SegFwdDir);
        Vector3 crossDes            = Vector3.Cross(AimPoint - transform.position, SegFwdDir);

        if (crossDes.y > 0)
        {
            DesiredHeadingAngle = -DesiredHeadingAngle;
        }

        // Pointing towards kerb - do a 3 point turn
        if (HeadingAngle > -100 && HeadingAngle < -80 && DistFromLKerb < 3)
        {
            StartCoroutine(ThreePointTurn("L"));
            return;
        }
        if (HeadingAngle < 100 && HeadingAngle > 80 && DistFromRKerb < 3)
        {
            StartCoroutine(ThreePointTurn("R"));
            return;
        }

        //Coming up to a hill, put your foot down
        if (LongAimPoint.y - SegFwdDir.y > 0)
        {
            Accel = ((LongAimPoint.y - SegFwdDir.y) * 0.005f) + 0.9f;
        }


        //coming up to a hill bend slow down
        if (Mathf.Abs(_nextBend.Angle) > 10 && _gps.NextHill > 2 && _gps.Speed > 10)
        {
            Accel = 0; BrakeForce = 0.5f;
        }

        //Positive steer = right
        Steer = (DesiredHeadingAngle - HeadingAngle);

        //Start of bend - flick the wheel
        //copied from CarAIInput

        /*
         * //Slide the Adjusted turnin point along the gate
         * SlideFrac = Mathf.Sqrt(Mathf.Clamp01(TurnInSpeed / _nextBend.Speed)); // - Mathf.Abs(Mathf.Sin(DriftAngle)) * 1.5f); //SlideFrac=1 for a big swingout
         * //Debug.Log("SlideFrac=" + TurnInSpeed  + "/" + _nextBend.Speed + "=" + SlideFrac);
         * AdjustedTurninPt = Vector3.Lerp(_nextBend.MinTurninPos, _nextBend.TurninPos, SlideFrac);
         * AdjustedTurninXSec = Rd.XSecs[Mathf.RoundToInt(Mathf.Lerp(_nextBend.StartSegIdx, _nextBend.TurninSegIdx, SlideFrac))];
         */

        if (_opponentCollisionDirec == CollisionDirection.Left && Steer < 10)
        {
            Steer = 10;
        }
        if (_opponentCollisionDirec == CollisionDirection.Right && Steer > -10)
        {
            Steer = -10;
        }
    }
示例#27
0
    public void CalculateBends()
    {
        if (!IsCircular)
        {
            return;
        }
        Bends = new CircleList <Bend>();
        Bend           _bend      = new Bend();
        int            BendId     = 0;
        MovingAvgFloat AngleQueue = new MovingAvgFloat(5);

        _bez = BezierLine.Instance;
        int      XSecCount = XSecs.Count();
        Vector3  PrevMid;
        Vector3  ThisMid;
        Vector3  NextMid;
        BendType _bt            = BendType.Unknown;
        BendType _prevbt        = BendType.Unknown;
        int      Incr           = 1;
        float    AngleThreshold = 1.34f;

        foreach (XSec X in XSecs)
        {
            PrevMid = XSecs.Prev(X).MidPt;
            ThisMid = X.MidPt;
            NextMid = XSecs.Next(X).MidPt;
            float Angle    = VectGeom.SignedAngle(ThisMid + ThisMid - PrevMid, ThisMid, NextMid, Vector3.up);
            float _segDist = Vector3.Distance(ThisMid, NextMid);
            AngleQueue.Push(Angle);
            if (Mathf.Abs(AngleQueue.Avg) < AngleThreshold)
            {
                _bt = BendType.Straight;
            }
            else
            {
                _bt = AngleQueue.Avg > 0 ? BendType.Right : BendType.Left;
            }

            if (_prevbt == _bt)
            {
                _bend.Angle += Angle;
            }
            else
            {
                if (_prevbt == BendType.Left || _prevbt == BendType.Right)
                {  //Finish off the previous bend
                    if (Mathf.Abs(_bend.Angle) < 15)
                    {
                        //ignore small bends
                        Bends.Remove(_bend);
                        BendId--;
                    }
                    else
                    {
                        //take 2 off cos of moving avg
                        _bend.EndXSec    = XSecs[X.Idx - 2];
                        _bend.EndSegIdx  = _bend.EndXSec.Idx;
                        _bend.ApexXSec   = XSecs[_bend.StartSegIdx + Mathf.RoundToInt(XSecs.Diff(_bend.StartXSec, _bend.EndXSec) / 2)];
                        _bend.ApexSegIdx = _bend.ApexXSec.Idx;
                        if (_bend.Type == BendType.Right)
                        {
                            _bend.ApexPos = _bend.ApexXSec.KerbR + (_bend.ApexXSec.KerbL - _bend.ApexXSec.KerbR).normalized; _bend.MinTurninPos = _bend.StartXSec.KerbR + (_bend.StartXSec.KerbL - _bend.StartXSec.KerbR).normalized * (_bend.Concatenated ? 4 : 2);
                        }
                        if (_bend.Type == BendType.Left)
                        {
                            _bend.ApexPos = _bend.ApexXSec.KerbL + (_bend.ApexXSec.KerbR - _bend.ApexXSec.KerbL).normalized; _bend.MinTurninPos = _bend.StartXSec.KerbL + (_bend.StartXSec.KerbR - _bend.StartXSec.KerbL).normalized * (_bend.Concatenated ? 4 : 2);
                        }
                        //Fmax = mv^2/r
                        float c = (_bend.EndSegIdx - _bend.StartSegIdx) * 360 / _bend.Angle;
                        float r = Mathf.Abs(c) / Mathf.PI / 2f;
                        //Debug.Log("Bend" + _bend.BendId + " radius = " + r);
                        _bend.SqrtRad = Mathf.Sqrt(r);
                    }
                }
                else
                {   //We might be starting a new bend or carrying n the previous one
                    if (_bt == BendType.Left || _bt == BendType.Right)
                    {
                        bool StartNewBend = true;

                        if (BendId > 0 && X.Idx - Bends[BendId - 1].EndSegIdx < 15 && Bends[BendId - 1].Type == _bt) ///bugbugbug circle bug
                        {                                                                                            //if the bend we've just finished is close to and the same sign as one before
                          //We just carry on with this bend and dont create a new one
                            StartNewBend       = false;
                            _bend.Concatenated = true;
                            GameObject.Destroy(GameObject.Find("Turnin" + _bend.BendId));
                            GameObject.Destroy(GameObject.Find("Apex" + _bend.BendId));
                            GameObject.Destroy(GameObject.Find("BendStart" + _bend.BendId));
                        }

                        if (StartNewBend)
                        {
                            //Create a new Bend
                            _bend             = new Bend();
                            _bend.Type        = _bt;
                            _bend.Sign        = _bt == BendType.Right ? (Int16)1 : (Int16)(-1);
                            _bend.StartXSec   = XSecs[X.Idx - 2];//-2 cos of moving avg
                            _bend.StartSegIdx = _bend.StartXSec.Idx;
                            _bend.Angle       = Angle;
                            _bend.BendId      = BendId;
                            Bends.Add(_bend);
                            BendId++;
                        }
                    }
                }
                //******************************************************************************************
            }
            _prevbt = _bt;
        }
        //This is the last bend. NOt a brilliant bit but it doesn't crash
        if (_bt == BendType.Straight)
        {
            goto Finalise;
        }
        _bend.EndSegIdx = XSecs.Count - 1;
        _bend.EndXSec   = XSecs[_bend.EndSegIdx];
        if (_bend.EndSegIdx <= _bend.StartSegIdx && Bends.Count() > 0)
        {
            Bends.Remove(_bend); Bends.Last().EndSegIdx = XSecs.Count;
        }
        else
        {
            _bend.ApexSegIdx = Mathf.RoundToInt((_bend.EndSegIdx + _bend.StartSegIdx) / 2);
            _bend.ApexXSec   = XSecs[_bend.ApexSegIdx];
            if (_bend.Type == BendType.Right)
            {
                _bend.ApexPos = _bend.ApexXSec.KerbR + (_bend.ApexXSec.KerbL - _bend.ApexXSec.KerbR).normalized;
            }
            if (_bend.Type == BendType.Left)
            {
                _bend.ApexPos = _bend.ApexXSec.KerbL + (_bend.ApexXSec.KerbR - _bend.ApexXSec.KerbL).normalized;
            }
        }
Finalise:
        CalculateTurninAndExitPoints();
        PopulateXSecCurrBends();
    }
示例#28
0
 /**************************************************************
 *	Create Geometries Helpers
 **************************************************************/
 /// Generate geometry from path points (for Line or ParticleSystem objects)
 //
 //        public Geometry createPointsGeometry (float divisions)
 //        {
 //            //List<Vector3> pts = this.getPoints( divisions, true );
 //            List<Vector3> pts = this.getPoints (divisions, true);
 //            return this.createGeometry (pts);
 //        }
 //    
 //        // Generate geometry from equidistance sampling along the path
 //    
 //        public Geometry createSpacedPointsGeometry (float divisions)
 //        {
 //        
 //            //List<Vector3> pts = this.getSpacedPoints( divisions, true );
 //            List<Vector3> pts = this.getSpacedPoints (divisions);
 //            return this.createGeometry (pts);
 //        
 //        }
 //    
 //        Geometry createGeometry (List<Vector3> points)
 //        {
 //        
 //            Geometry geometry = new Geometry ();
 //        
 //            for (int i = 0; i < points.Count; i ++) {
 //                geometry.vertices.Add (new Vector3 (points [i].x, points [i].y, points [i].z));
 //            }
 //        
 //            return geometry;
 //        
 //        }
 /**************************************************************
  *	Bend / Wrap Helper Methods
  **************************************************************/
 // Wrap path / Bend modifiers?
 // TODO: ///////// Check Bend TYPE
 void addWrapPath(Bend bendpath)
 {
     this.bends.Add (bendpath);
 }
示例#29
0
    public Parameters ParametersFromFRCMODFile(string filename)
    {
        Parameters parameters = Instantiate <Parameters>(parametersPrefab);

        string[] lines    = FileIO.Readlines(filename);
        int      maxLines = lines.Length;

        List <string> sections = new List <string> {
            "MASS",
            "BOND",
            "ANGL",
            "DIHE",
            "IMPR",
            "NONB",
            "IPOL",
            "CMAP",
            "%"
        };
        string sectionName;
        int    sectionNum  = 0;
        int    numSections = sections.Count;

        string section = "";

        lineNumber = 0;

        string restOfLine;

        string[] splitLine;


        Stretch         newStretchParam;
        Bend            newBendParam;
        Torsion         newTorsionParam;
        ImproperTorsion newImproperTorsionParam;
        VdW             newVdWParam;

        Torsion existingTorsionParam;
        int     existingTorsionNum;
        bool    torsionModified;

        int offset;

        while (lineNumber < maxLines)
        {
            line = lines [lineNumber];

            if (line == "")
            {
                continue;
            }

            for (sectionNum = 0; sectionNum < numSections; sectionNum++)
            {
                sectionName = sections [sectionNum];
                if (line.StartsWith(sectionName))
                {
                    section = sectionName;
                    goto SKIP;
                }
            }

            //Ignore MASS section

            //Parse Bond
            if (section == "BOND")
            {
                t0 = GetAmberFromString(line, 0);
                t1 = GetAmberFromString(line, 3);

                restOfLine = line.Substring(5, line.Length - 6);
                splitLine  = restOfLine.Split(new [] { " " }, System.StringSplitOptions.RemoveEmptyEntries);

                keq = float.Parse(splitLine [0]);
                req = float.Parse(splitLine [1]);

                newStretchParam = new Stretch(t0, t1, req, keq);
                parameters.stretches.Add(newStretchParam);
            }
            else if (section == "ANGL")
            {
                t0 = GetAmberFromString(line, 0);
                t1 = GetAmberFromString(line, 3);
                t2 = GetAmberFromString(line, 6);

                restOfLine = line.Substring(8, line.Length - 9);
                splitLine  = restOfLine.Split(new [] { " " }, System.StringSplitOptions.RemoveEmptyEntries);

                keq = float.Parse(splitLine [0]);
                req = float.Parse(splitLine [1]);

                newBendParam = new Bend(t0, t1, t2, req, keq);
                parameters.bends.Add(newBendParam);
            }
            else if (section == "DIHE")
            {
                t0 = GetAmberFromString(line, 0);
                t1 = GetAmberFromString(line, 3);
                t2 = GetAmberFromString(line, 6);
                t3 = GetAmberFromString(line, 9);

                newTorsionParam = new Torsion(t0, t1, t2, t3);

                restOfLine = line.Substring(11, line.Length - 12);
                splitLine  = restOfLine.Split(new [] { " " }, System.StringSplitOptions.RemoveEmptyEntries);

                npaths      = int.Parse(splitLine [0]);
                v           = float.Parse(splitLine [1]);
                gamma       = float.Parse(splitLine [2]);
                periodicity = (int)Mathf.Abs(float.Parse(splitLine [3]));

                //The same param can be defined on multiple lines
                torsionModified = false;

                for (existingTorsionNum = 0; existingTorsionNum < parameters.torsions.Count; existingTorsionNum++)
                {
                    existingTorsionParam = parameters.torsions [existingTorsionNum];
                    if (existingTorsionParam.TypeEquivalent(newTorsionParam))
                    {
                        existingTorsionParam.Modify(periodicity, v, gamma);
                        torsionModified = true;
                    }
                }


                if (!torsionModified)
                {
                    newTorsionParam.npaths = npaths;
                    if (periodicity == 1)
                    {
                        newTorsionParam.v0     = v;
                        newTorsionParam.gamma0 = gamma;
                    }
                    else if (periodicity == 2)
                    {
                        newTorsionParam.v1     = v;
                        newTorsionParam.gamma1 = gamma;
                    }
                    else if (periodicity == 3)
                    {
                        newTorsionParam.v2     = v;
                        newTorsionParam.gamma2 = gamma;
                    }
                    else if (periodicity == 4)
                    {
                        newTorsionParam.v3     = v;
                        newTorsionParam.gamma3 = gamma;
                    }

                    parameters.torsions.Add(newTorsionParam);
                }
            }
            else if (section == "IMPR")
            {
                t0 = GetAmberFromString(line, 0);
                t1 = GetAmberFromString(line, 3);
                t2 = GetAmberFromString(line, 6);
                t3 = GetAmberFromString(line, 9);

                restOfLine = line.Substring(11, line.Length - 12);
                splitLine  = restOfLine.Split(new [] { " " }, System.StringSplitOptions.RemoveEmptyEntries);

                offset = 1;

                //Sometimes npaths is included here, even though ignored. Sometimes it's not.
                if (splitLine [0].Contains("."))
                {
                    offset = 0;
                }

                v           = float.Parse(splitLine [offset]);
                gamma       = float.Parse(splitLine [offset + 1]);
                periodicity = (int)Mathf.Abs(float.Parse(splitLine [offset + 2]));

                newImproperTorsionParam = new ImproperTorsion(t0, t1, t2, t3, v, gamma, periodicity);

                parameters.improperTorsions.Add(newImproperTorsionParam);
            }
            else if (section == "NONB")
            {
                splitLine = line.Split(new [] { " " }, System.StringSplitOptions.RemoveEmptyEntries);

                t      = splitLine [0];
                radius = float.Parse(splitLine [1]);
                v      = float.Parse(splitLine [2]);

                newVdWParam = new VdW(t, radius, v);

                parameters.vdws.Add(newVdWParam);
            }

SKIP:
            ;
        }

        return(parameters);
    }
示例#30
0
 public void Delete(Bend item)
 {
     MockDatabase.Bendovi.Remove(item);
 }
示例#31
0
        static MockDatabase()
        {
            var b1 = new Bend {
                Id = 1, Naziv = "The Smiths", GodinaOsnutka = 1981, BrojClanova = 4
            };
            var b2 = new Bend {
                Id = 2, Naziv = "Arcade Fire", GodinaOsnutka = 2001, BrojClanova = 6
            };

            var a1 = new Album {
                Id = 1, Naziv = "The Smiths", GodinaIzdanja = 1984, OsnovnaCijena = 99.99m, BendId = 1, Bend = b1
            };
            var a2 = new Album {
                Id = 2, Naziv = "The Queen is Dead", GodinaIzdanja = 1986, OsnovnaCijena = 99.99m, BendId = 1, Bend = b1
            };

            var a3 = new Album {
                Id = 3, Naziv = "Neon Bible", GodinaIzdanja = 2007, OsnovnaCijena = 99.99m, BendId = 2, Bend = b2
            };

            var p1 = new Pjesma {
                Id = 1, Naziv = "Reel Around the Fountain", RedniBroj = 1, TrajanjeSekundi = 404, Album = a1, AlbumId = 1
            };
            var p2 = new Pjesma {
                Id = 2, Naziv = "Miserable Lie", RedniBroj = 2, TrajanjeSekundi = 321, Album = a1, AlbumId = 1
            };
            var p3 = new Pjesma {
                Id = 3, Naziv = "Pretty Girls Make Graves", RedniBroj = 3, TrajanjeSekundi = 516, Album = a1, AlbumId = 1
            };
            var p4 = new Pjesma {
                Id = 4, Naziv = "The Hand That Rocks the Cradle", RedniBroj = 4, TrajanjeSekundi = 368, Album = a1, AlbumId = 1
            };
            var p5 = new Pjesma {
                Id = 5, Naziv = "Still Ill", RedniBroj = 5, TrajanjeSekundi = 602, Album = a1, AlbumId = 1
            };
            var p6 = new Pjesma {
                Id = 6, Naziv = "Hand in Glove", RedniBroj = 6, TrajanjeSekundi = 258, Album = a1, AlbumId = 1
            };
            var p7 = new Pjesma {
                Id = 7, Naziv = "What Difference Does It Make?", RedniBroj = 7, TrajanjeSekundi = 344, Album = a1, AlbumId = 1
            };
            var p8 = new Pjesma {
                Id = 8, Naziv = "I Don't Owe You Anything", RedniBroj = 8, TrajanjeSekundi = 441, Album = a1, AlbumId = 1
            };
            var p9 = new Pjesma {
                Id = 9, Naziv = "Suffer Little Children", RedniBroj = 9, TrajanjeSekundi = 289, Album = a1, AlbumId = 1
            };
            var p10 = new Pjesma {
                Id = 10, Naziv = "You've Got Everything Now", RedniBroj = 10, TrajanjeSekundi = 375, Album = a1, AlbumId = 1
            };

            var p11 = new Pjesma {
                Id = 11, Naziv = "The Queen Is Dead", RedniBroj = 1, TrajanjeSekundi = 404, Album = a2, AlbumId = 2
            };
            var p12 = new Pjesma {
                Id = 12, Naziv = "Frankly, Mr. Shankly", RedniBroj = 2, TrajanjeSekundi = 321, Album = a2, AlbumId = 2
            };
            var p13 = new Pjesma {
                Id = 13, Naziv = "I Know It's Over", RedniBroj = 3, TrajanjeSekundi = 516, Album = a2, AlbumId = 2
            };
            var p14 = new Pjesma {
                Id = 14, Naziv = "Never Had No One Ever", RedniBroj = 4, TrajanjeSekundi = 368, Album = a2, AlbumId = 2
            };
            var p15 = new Pjesma {
                Id = 15, Naziv = "Cemetry Gates", RedniBroj = 5, TrajanjeSekundi = 602, Album = a2, AlbumId = 2
            };
            var p16 = new Pjesma {
                Id = 16, Naziv = "Bigmouth Strikes Again", RedniBroj = 6, TrajanjeSekundi = 258, Album = a2, AlbumId = 2
            };
            var p17 = new Pjesma {
                Id = 17, Naziv = "The Boy with the Thorn in His Side", RedniBroj = 7, TrajanjeSekundi = 344, Album = a2, AlbumId = 2
            };
            var p18 = new Pjesma {
                Id = 18, Naziv = "Vicar in a Tutu", RedniBroj = 8, TrajanjeSekundi = 441, Album = a2, AlbumId = 2
            };
            var p19 = new Pjesma {
                Id = 19, Naziv = "There Is a Light That Never Goes Out", RedniBroj = 9, TrajanjeSekundi = 289, Album = a2, AlbumId = 2
            };
            var p20 = new Pjesma {
                Id = 20, Naziv = "Some Girls Are Bigger Than Others", RedniBroj = 10, TrajanjeSekundi = 375, Album = a2, AlbumId = 2
            };

            var p21 = new Pjesma {
                Id = 21, Naziv = "Black Mirror", RedniBroj = 1, TrajanjeSekundi = 404, Album = a3, AlbumId = 3
            };
            var p22 = new Pjesma {
                Id = 22, Naziv = "Keep the Car Running", RedniBroj = 2, TrajanjeSekundi = 321, Album = a3, AlbumId = 3
            };
            var p23 = new Pjesma {
                Id = 23, Naziv = "Neon Bible", RedniBroj = 3, TrajanjeSekundi = 516, Album = a3, AlbumId = 3
            };
            var p24 = new Pjesma {
                Id = 24, Naziv = "Intervention", RedniBroj = 4, TrajanjeSekundi = 368, Album = a3, AlbumId = 3
            };
            var p25 = new Pjesma {
                Id = 25, Naziv = "Black Wave/Bad Vibrations", RedniBroj = 5, TrajanjeSekundi = 602, Album = a3, AlbumId = 3
            };
            var p26 = new Pjesma {
                Id = 26, Naziv = "Ocean of Noise", RedniBroj = 6, TrajanjeSekundi = 258, Album = a3, AlbumId = 3
            };
            var p27 = new Pjesma {
                Id = 27, Naziv = "The Well and the Lighthouse", RedniBroj = 7, TrajanjeSekundi = 344, Album = a3, AlbumId = 3
            };
            var p28 = new Pjesma {
                Id = 28, Naziv = "(Antichrist Television Blues)", RedniBroj = 8, TrajanjeSekundi = 441, Album = a3, AlbumId = 3
            };
            var p29 = new Pjesma {
                Id = 29, Naziv = "Windowsill", RedniBroj = 9, TrajanjeSekundi = 289, Album = a3, AlbumId = 3
            };
            var p30 = new Pjesma {
                Id = 30, Naziv = "No Cars Go", RedniBroj = 10, TrajanjeSekundi = 375, Album = a3, AlbumId = 3
            };
            var p31 = new Pjesma {
                Id = 31, Naziv = "My Body Is a Cage", RedniBroj = 11, TrajanjeSekundi = 375, Album = a3, AlbumId = 3
            };

            b1.Albumi.Add(a1);
            b1.Albumi.Add(a2);
            b2.Albumi.Add(a3);

            a1.Pjesme.AddRange(new List <Pjesma> {
                p1, p2, p3, p4, p5, p6, p7, p8, p9, p10
            });
            a2.Pjesme.AddRange(new List <Pjesma> {
                p11, p12, p13, p14, p15, p16, p17, p18, p19, p20
            });
            a3.Pjesme.AddRange(new List <Pjesma> {
                p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31
            });

            Bendovi = new List <Bend> {
                b1, b2
            };
            Albumi = new List <Album> {
                a1, a2, a3
            };
            Pjesme = new List <Pjesma> {
                p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31
            };
        }
        protected Bend ReadBend()
        {
            Bend bend = new Bend();
            bend.Type = ReadEnum<BendType>();
            bend.Value = ReadInt();

            int pointsNumber = ReadInt();
            bend.Points = new BendPoint[pointsNumber];
            for (int i = 0; i < pointsNumber; i++)
                bend.Points[i] = ReadBendPoint();

            return bend;
        }