public Branch Generate(Branch parent, int depth, int i, int nMax, float angle, float length, Vec2 branchVec) { // var parentAngle = new Vec2(parent.X, parent.Y).GetAngle() * 180 / (float)Math.PI; var p1 = GetAngleVector(new Vec2(parent.X, parent.Y), angle, length); index++; var stroke = parent.Paint.StrokeWidth - 1; var particle = new Branch(_engine, p1.X, p1.Y, stroke, true, stroke / 5000, false, index); // particle.Paint.StrokeWidth -= 10 - nMax; particle.RigidBody.JointRevolute(parent.RigidBody, 0, 0, false, -0, 0, 0f); parent.AddNode(particle); if (i < nMax) { var a = Generate(particle, 0, i, nMax - 1, angle + 30, length - 10, new Vec2()); var b = Generate(particle, 0, i, nMax - 1, angle - 30, length - 10, new Vec2()); //a.RigidBody.JointRevolute(b.RigidBody, 0, 0, false, -1, 1, 0); // _engine.Physics.AddCircle(a.X, a.Y, 10, 0, 0.2f, 0.2f, 0.2f, 1); // _engine.Physics.AddCircle(b.X, b.Y, 10, 0, 0.2f, 0.2f, 0.2f, 1); } else { // var f = _engine.Physics.FactoryBody.CreateRigidVertex() // .CreateBox(0.2f, 0.2f, 10, 10, 0.2f, true) // .CreateBodyDef(particle.X, particle.Y, 0, true, false) // .Build(0.001f); // f.JointRevolute(particle.RigidBody, 0, 0, false, 0, 0, 0); Leaves.Add(particle.RigidBody); } return(particle); }
public MerkleTree AddLeaf(MerkleNode node) { Nodes.Add(node); Leaves.Add(node); SortedLeaves.Add(node.Hash, node); return(this); }
/// <summary> /// Removes current from leaves list and adds node there instead /// </summary> /// <param name="current"></param> /// <param name="node"></param> private void UpdateLeavesList(ActivationNode current, ActivationNode node) { if (!Leaves.Contains(node)) { Leaves.Add(node); } Leaves.Remove(current); }
private void RetrieveLeaves() { if (Leaves.Count != 0) { Leaves.Clear(); } var leavesData = _leaveService.GetAllLeaves(); foreach (var leave in leavesData) { Leaves.Add(leave); } }
private void RetrieveData() { var customPrincipal = Thread.CurrentPrincipal as CustomPrincipal; var leavesData = _leaveService.GetLeavesByLogin(customPrincipal.Identity.Name); foreach (var leave in leavesData) { Leaves.Add(leave); } var vacationsData = _vacationService.GetVacationsByLogin(customPrincipal.Identity.Name); foreach (var vacation in vacationsData) { Vacations.Add(vacation); } }
public override void Setup(Beast beast, GameObject holder) { base.Setup(beast, holder); GameObject leaf = GameObject.CreatePrimitive(PrimitiveType.Quad); leaf.transform.SetParent(Pivot.transform); leaf.name = this.GetType().Name; MeshRenderer r = leaf.GetComponent <MeshRenderer>(); byte[] bytes = System.IO.File.ReadAllBytes(Textures.First().FullName); Texture2D texture = new Texture2D(1, 1); texture.LoadImage(bytes); r.material = Resources.Load <Material>("BeastLeaf"); r.material.mainTexture = texture; leaf.transform.localScale = new Vector3((texture.width * 0.5f) * 0.01f, (texture.width * 0.5f) * 0.01f); leaf.transform.localPosition = new Vector3(0f, (texture.height * 0.25f) * 0.01f); //100 pixels per unit Leaves.Add(leaf); }
public void CalculateDuration(DateTime start, DateTime end) { if (Joins.Count == 0) { AtStart = true; Joins.Add(start); Joins.Sort(); } if (Leaves.Count == 0) { AtEnd = true; Leaves.Add(end); Leaves.Sort(); } if (IsLeaveFirst()) { AtStart = true; Joins.Add(start); Joins.Sort(); } if (IsJoinLast()) { AtEnd = true; Leaves.Add(end); Leaves.Sort(); } Joins.Sort(); Leaves.Sort(); Duration = MemberRaidDuration.Calculate(Joins, Leaves, AtStart, AtEnd); }
private void Read(BinaryReader br) { Header = new Header { Version = (Version)br.ReadInt32(), Lumps = new Lump[Lump.NumLumps] }; if (Header.Version != Version.Goldsource) { throw new NotSupportedException("Only Goldsource (v30) BSP files are supported."); } for (var i = 0; i < Header.Lumps.Length; i++) { Header.Lumps[i] = new Lump { Offset = br.ReadInt32(), Length = br.ReadInt32() }; } // Entities var lump = Header.Lumps[Lump.Entities]; br.BaseStream.Seek(lump.Offset, SeekOrigin.Begin); EntityBlock = Encoding.ASCII.GetString(br.ReadBytes(lump.Length)); // Planes lump = Header.Lumps[Lump.Planes]; br.BaseStream.Seek(lump.Offset, SeekOrigin.Begin); while (br.BaseStream.Position < lump.Offset + lump.Length) { Planes.Add(new Plane { Normal = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()), Distance = br.ReadSingle(), Type = br.ReadInt32() }); } // Textures lump = Header.Lumps[Lump.Textures]; br.BaseStream.Seek(lump.Offset, SeekOrigin.Begin); var numTextures = br.ReadUInt32(); var offsets = new int[numTextures]; for (var i = 0; i < numTextures; i++) { offsets[i] = br.ReadInt32(); } foreach (var offset in offsets) { br.BaseStream.Seek(lump.Offset + offset, SeekOrigin.Begin); var tex = Wad.WadFile.ReadMipTexture(br); Textures.Add(tex); } // Vertices lump = Header.Lumps[Lump.Vertices]; br.BaseStream.Seek(lump.Offset, SeekOrigin.Begin); while (br.BaseStream.Position < lump.Offset + lump.Length) { Vertices.Add(new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle())); } // Visibility lump = Header.Lumps[Lump.Visibility]; br.BaseStream.Seek(lump.Offset, SeekOrigin.Begin); VisData = br.ReadBytes(lump.Length); //TODO: decompress vis data // Nodes lump = Header.Lumps[Lump.Nodes]; br.BaseStream.Seek(lump.Offset, SeekOrigin.Begin); while (br.BaseStream.Position < lump.Offset + lump.Length) { var node = new Node { Plane = br.ReadUInt32(), Children = new short[2], Mins = new short[3], Maxs = new short[3] }; for (var i = 0; i < 2; i++) { node.Children[i] = br.ReadInt16(); } for (var i = 0; i < 3; i++) { node.Mins[i] = br.ReadInt16(); } for (var i = 0; i < 3; i++) { node.Maxs[i] = br.ReadInt16(); } node.FirstFace = br.ReadUInt16(); node.NumFaces = br.ReadUInt16(); Nodes.Add(node); } // Texinfo lump = Header.Lumps[Lump.Texinfo]; br.BaseStream.Seek(lump.Offset, SeekOrigin.Begin); while (br.BaseStream.Position < lump.Offset + lump.Length) { var info = new TextureInfo { S = new Vector4(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle()), T = new Vector4(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle()), MipTexture = br.ReadInt32(), Flags = br.ReadInt32() }; TextureInfos.Add(info); } // Faces lump = Header.Lumps[Lump.Faces]; br.BaseStream.Seek(lump.Offset, SeekOrigin.Begin); while (br.BaseStream.Position < lump.Offset + lump.Length) { var face = new Face { Plane = br.ReadInt16(), Side = br.ReadInt16(), FirstEdge = br.ReadInt32(), NumEdges = br.ReadInt16(), TextureInfo = br.ReadInt16(), Styles = br.ReadBytes(Face.MaxLightmaps), LightmapOffset = br.ReadInt32() }; Faces.Add(face); } // Lighting lump = Header.Lumps[Lump.Lighting]; br.BaseStream.Seek(lump.Offset, SeekOrigin.Begin); Lightmap = br.ReadBytes(lump.Length); // Clipnodes lump = Header.Lumps[Lump.Clipnodes]; br.BaseStream.Seek(lump.Offset, SeekOrigin.Begin); while (br.BaseStream.Position < lump.Offset + lump.Length) { var clip = new Clipnode { Plane = br.ReadInt32(), Children = new[] { br.ReadInt16(), br.ReadInt16() } }; Clipnodes.Add(clip); } // Leaves lump = Header.Lumps[Lump.Leaves]; br.BaseStream.Seek(lump.Offset, SeekOrigin.Begin); while (br.BaseStream.Position < lump.Offset + lump.Length) { var leaf = new Leaf { Contents = (Contents)br.ReadInt32(), VisOffset = br.ReadInt32(), Mins = new [] { br.ReadInt16(), br.ReadInt16(), br.ReadInt16() }, Maxs = new [] { br.ReadInt16(), br.ReadInt16(), br.ReadInt16() }, FirstMarkSurface = br.ReadUInt16(), NumMarkSurfaces = br.ReadUInt16(), AmbientLevels = br.ReadBytes(Leaf.MaxNumAmbientLevels) }; Leaves.Add(leaf); } // Marksurfaces lump = Header.Lumps[Lump.Marksurfaces]; br.BaseStream.Seek(lump.Offset, SeekOrigin.Begin); MarkSurfaces = new ushort[lump.Length / sizeof(ushort)]; for (var i = 0; i < MarkSurfaces.Length; i++) { MarkSurfaces[i] = br.ReadUInt16(); } // Edges lump = Header.Lumps[Lump.Edges]; br.BaseStream.Seek(lump.Offset, SeekOrigin.Begin); while (br.BaseStream.Position < lump.Offset + lump.Length) { var edge = new Edge { Start = br.ReadUInt16(), End = br.ReadUInt16() }; Edges.Add(edge); } // Surfedges lump = Header.Lumps[Lump.Surfedges]; br.BaseStream.Seek(lump.Offset, SeekOrigin.Begin); SurfaceEdges = new int[lump.Length / sizeof(int)]; for (var i = 0; i < SurfaceEdges.Length; i++) { SurfaceEdges[i] = br.ReadInt32(); } // Models lump = Header.Lumps[Lump.Models]; br.BaseStream.Seek(lump.Offset, SeekOrigin.Begin); while (br.BaseStream.Position < lump.Offset + lump.Length) { var model = new Model { Mins = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()), Maxs = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()), Origin = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()), HeadNodes = new [] { br.ReadInt32(), br.ReadInt32(), br.ReadInt32(), br.ReadInt32() }, VisLeaves = br.ReadInt32(), FirstFace = br.ReadInt32(), NumFaces = br.ReadInt32() }; Models.Add(model); } ParseEntities(); }
public void AddLeaf(MerkleNode node) { Nodes.Add(node); Leaves.Add(node); SortedLeaves.Add(node.Hash, node); }