예제 #1
0
        public XWPFTable(CT_Tbl table, IBody part)
        {
            this.part = part;
            this.ctTbl = table;

            tableRows = new List<XWPFTableRow>();
            // is an empty table: I add one row and one column as default
            if (table.SizeOfTrArray() == 0)
                CreateEmptyTable(table);

            foreach (CT_Row row in table.GetTrList()) {
                StringBuilder rowText = new StringBuilder();
                row.Table = table;
                XWPFTableRow tabRow = new XWPFTableRow(row, this);
                tableRows.Add(tabRow);
                foreach (CT_Tc cell in row.GetTcList()) {
                    cell.TableRow = row;
                    foreach (CT_P ctp in cell.GetPList()) {
                        XWPFParagraph p = new XWPFParagraph(ctp, part);
                        if (rowText.Length > 0) {
                            rowText.Append('\t');
                        }
                        rowText.Append(p.GetText());
                    }
                }
                if (rowText.Length > 0) {
                    this.text.Append(rowText);
                    this.text.Append('\n');
                }
            }
        }
예제 #2
0
파일: Side.cs 프로젝트: polly5315/NBump
 public Side(IBody body, Direction direction)
 {
     Body = body;
     NormalDirection = direction;
     Refresh();
     body.Changed += RectangleOnChanged;
 }
예제 #3
0
파일: XWPFSDT.cs 프로젝트: mdjasim/npoi
        public XWPFSDT(CT_SdtBlock block, IBody part)
        {
            this.part = part;
            this.content = new XWPFSDTContent(block.sdtContent, part, this);
            CT_SdtPr pr = block.sdtPr;
            List<CT_String> aliases = pr.GetObjectList<CT_String>(SdtPrElementType.alias);
            if (aliases != null && aliases.Count > 0)
            {
                title = aliases[0].val;
            }
            else
            {
                title = "";
            }
            CT_String[] array = pr.GetObjectList<CT_String>(SdtPrElementType.tag).ToArray();
            if (array != null && array.Length > 0)
            {
                tag = array[0].val;
            }
            else
            {
                tag = "";
            }

        }
예제 #4
0
 public XWPFSDTContent(CT_SdtContentBlock block, IBody part, IRunBody parent)
 {
     
     foreach (object o in block.Items)
     {
         if (o is CT_P)
         {
             XWPFParagraph p = new XWPFParagraph((CT_P)o, part);
             bodyElements.Add(p);
             paragraphs.Add(p);
         }
         else if (o is CT_Tbl)
         {
             XWPFTable t = new XWPFTable((CT_Tbl)o, part);
             bodyElements.Add(t);
             tables.Add(t);
         }
         else if (o is CT_SdtBlock)
         {
             XWPFSDT c = new XWPFSDT(((CT_SdtBlock)o), part);
             bodyElements.Add(c);
             contentControls.Add(c);
         }
         else if (o is CT_R)
         {
             XWPFRun run = new XWPFRun((CT_R)o, parent);
             runs.Add(run);
             bodyElements.Add(run);
         }
     }
 }
예제 #5
0
        public V2Body(IBody body)
        {
            _body = body;
            //_body = (IBody)Marshal. GetObjectForIUnknown(p);
            _initialized = true;

            IsTracked=_body.get_IsTracked();
        }
예제 #6
0
 public static bool Contains(this IBody body, IBody other)
 {
     return
         body.Position.X <= other.Position.X &&
         body.Position.X + body.Size.X >= other.Position.X + other.Size.X &&
         body.Position.Y <= other.Position.Y &&
         body.Position.Y + body.Size.Y >= other.Position.Y + other.Size.Y;
 }
예제 #7
0
 public static bool Intersects(this IBody body, IBody other)
 {
     return
         other.Position.X < body.Position.X + body.Size.X &&
         other.Position.Y < body.Position.Y + body.Size.Y &&
         other.Position.X + other.Size.X > body.Position.X &&
         other.Position.Y + other.Size.Y > body.Position.Y;
 }
예제 #8
0
        public Economy(GameState game, Id<Player> player, Id<IBody> body)
            : base(game)
        {
            this.player = game.Players[player];
            this.body = game.Bodies[body];

            this.listAs<Economy>();
        }
예제 #9
0
 public XWPFSDTContent(CT_SdtContentRun sdtRun, IBody part, IRunBody parent)
 {
     foreach (CT_R ctr in sdtRun.GetRList())
     {
         XWPFRun run = new XWPFRun((CT_R)ctr, parent);
         runs.Add(run);
         bodyElements.Add(run);
     }
 }
예제 #10
0
 public IEnumerable<Contact> FindContacts(IBody mainBody, IEnumerable<IBody> otherBodies)
 {
     return otherBodies
         .Where(otherBody => otherBody != mainBody) // cannot contact self
         .Where(otherBody => !OverlapStrats.HasStrategy(mainBody.BoundVolume, otherBody.BoundVolume) // where we dont have an overlap strategy
              || OverlapStrats.EnactStrategy(mainBody.BoundVolume, otherBody.BoundVolume, // or the overlap strategy passes (they are overlapping)
              new Transformation(mainBody.Dynamics.Transform, otherBody.Dynamics.Transform))) 
         .SelectMany(otherBody => ContactsOnFirst(otherBody, mainBody).Union(ContactsOnFirst(mainBody, otherBody))); // full collider intersection check   
 }
예제 #11
0
        public SmoothedGraphicalBody(IBody body, ImmutableArray<PrimitiveTriangle> tris, int framesToSmooth)
        {
            Body = body;
            Triangles = tris;
            FramesToSmooth = framesToSmooth;
            pastTransforms = new Queue<Transform>(FramesToSmooth);
            AddTransform(Body.Dynamics.Kinematics.Transform); // add starting transform to queue

            Body.FrameFinished += Body_FrameFinished;
        }
예제 #12
0
파일: Side.cs 프로젝트: polly5315/NBump
        private void RectangleOnChanged(object sender, IBody body)
        {
            if (Body != body)
                return;

            Refresh();

            if (Changed != null)
                Changed(this, this);
        }
예제 #13
0
        internal BestBodyArrivedToPopulationEventArgs(IPopulation population, IGroup group, IBody body)
        {
            Contract.Requires(population != null);
            Contract.Requires(group != null);
            Contract.Requires(body != null);

            Population = population;
            Group = group;
            Body = body;
        }
예제 #14
0
파일: World.cs 프로젝트: polly5315/NBump
 public void Remove(IBody body)
 {
     if (body == null)
         return;
     ISide[] sides;
     if (!_rectanglesSides.TryGetValue(body, out sides))
         return;
     foreach (var side in sides)
         _sideRepository.RemoveSide(side);
     body.Changed -= RectangleOnChanged;
 }
예제 #15
0
파일: World.cs 프로젝트: polly5315/NBump
        public void Add(IBody body)
        {
            if (body == null)
                throw new ArgumentNullException("body");
            if (_rectanglesSides.ContainsKey(body))
                return;

            var sides = _directions.Select(d => new Side(body, d)).ToArray();
            _rectanglesSides.Add(body, sides);
            foreach (var side in sides)
                _sideRepository.AddSide(side);
            body.Changed += RectangleOnChanged;
        }
예제 #16
0
        private bool RecordBody(IBody body, BinaryWriter dataWriter)
        {
            dataWriter.Write(body.IsTracked);

            // Skip the rest if it isn't tracked...is a waste since it isn't
            // materially different from a new body object
            if (!body.IsTracked)
                return false;

            dataWriter.Write((int)body.ClippedEdges);
            dataWriter.Write((int)body.HandLeftConfidence);
            dataWriter.Write((int)body.HandLeftState);
            dataWriter.Write((int)body.HandRightConfidence);
            dataWriter.Write((int)body.HandRightState);
            dataWriter.Write(body.IsRestricted);

            dataWriter.Write(body.JointOrientations.Count);
            foreach (var pair in body.JointOrientations)
            {
                dataWriter.Write((int)pair.Key);
                dataWriter.Write((int)pair.Value.JointType);
                dataWriter.Write(pair.Value.Orientation.W);
                dataWriter.Write(pair.Value.Orientation.X);
                dataWriter.Write(pair.Value.Orientation.Y);
                dataWriter.Write(pair.Value.Orientation.Z);
            }

            dataWriter.Write(body.Joints.Count);
            foreach (var pair in body.Joints)
            {
                dataWriter.Write((int)pair.Key);
                dataWriter.Write((int)pair.Value.JointType);
                dataWriter.Write(pair.Value.Position.X);
                dataWriter.Write(pair.Value.Position.Y);
                dataWriter.Write(pair.Value.Position.Z);
                dataWriter.Write(pair.Value.DepthPosition.X);
                dataWriter.Write(pair.Value.DepthPosition.Y);
                dataWriter.Write(pair.Value.ColorPosition.X);
                dataWriter.Write(pair.Value.ColorPosition.Y);
                dataWriter.Write((int)pair.Value.TrackingState);
            }

            dataWriter.Write((float)body.Lean.X);
            dataWriter.Write((float)body.Lean.Y);
            dataWriter.Write((int)body.LeanTrackingState);
            dataWriter.Write(body.TrackingId);
            dataWriter.Write(body.HasMappedDepthPositions);
            dataWriter.Write(body.HasMappedColorPositions);

            return true;
        }
        /// <summary>
        /// Updates the transform of an orbiting entity
        /// </summary>
        /// <param name="entity">Orbiting entity</param>
        /// <param name="updateTime">Update time, in ticks (<see cref="TinyTime"/>)</param>
        public void Update( IBody entity, long updateTime )
        {
            double angleIncrement = m_AnglePerSecond * TinyTime.ToSeconds( m_LastUpdate, updateTime );
            m_Angle = Utils.Wrap( m_Angle + angleIncrement, 0, Math.PI * 2.0 );

            double x = Math.Sin( m_Angle ) * m_Radius;
            double z = Math.Cos( m_Angle ) * m_Radius;

            entity.Transform.Position.X = m_Centre.Transform.Position.X + Units.Convert.MetresToUni( x );
            entity.Transform.Position.Y = m_Centre.Transform.Position.Y;
            entity.Transform.Position.Z = m_Centre.Transform.Position.Z + Units.Convert.MetresToUni( z );

            m_LastUpdate = updateTime;
        }
예제 #18
0
        public XWPFTable(CT_Tbl table, IBody part, int row, int col)
            : this(table, part)
        {

            for (int i = 0; i < row; i++)
            {
                XWPFTableRow tabRow = (GetRow(i) == null) ? CreateRow() : GetRow(i);
                for (int k = 0; k < col; k++)
                {
                    XWPFTableCell tabCell = (tabRow.GetCell(k) == null) ? tabRow
                            .CreateCell() : null;
                }
            }
        }
예제 #19
0
파일: World.cs 프로젝트: polly5315/NBump
        public ICollection<MulticollisionEvent> GetCollisions(IBody body, Vector2 path)
        {
            if (body == null)
                throw new ArgumentNullException("body");

            //todo: do not use LINQ, iterate all four enumerables in parallel to one lazy result!!!
            return _directions
                .SelectMany(direction => GetSideCollisions(body, direction, path))
                .GroupBy(te => te.Traversed)
                .OrderBy(teg => teg.Key)
                .Select(teg => new MulticollisionEvent
                {
                    Traversed = teg.Key,
                    Collisions = teg.Select(ce => ce.Collision).ToArray()
                })
                .ToArray();
        }
예제 #20
0
 /**
  * If a table cell does not include at least one block-level element, then this document shall be considered corrupt
  */
 public XWPFTableCell(CT_Tc cell, XWPFTableRow tableRow, IBody part)
 {
     this.ctTc = cell;
     this.part = part;
     this.tableRow = tableRow;
     // NB: If a table cell does not include at least one block-level element, then this document shall be considered corrupt.
     if(cell.GetPList().Count<1)
         cell.AddNewP();
     bodyElements = new List<IBodyElement>();
     paragraphs = new List<XWPFParagraph>();
     tables = new List<XWPFTable>();
     foreach (object o in ctTc.Items)
     {
         if (o is CT_P)
         {
             XWPFParagraph p = new XWPFParagraph((CT_P)o, this);
             paragraphs.Add(p);
             bodyElements.Add(p);
         }
         if (o is CT_Tbl)
         {
             XWPFTable t = new XWPFTable((CT_Tbl)o, this);
             tables.Add(t);
             bodyElements.Add(t);
         }
     }
 /*
     XmlCursor cursor = ctTc.NewCursor();
     cursor.SelectPath("./*");
     while (cursor.ToNextSelection()) {
         XmlObject o = cursor.Object;
         if (o is CTP) {
             XWPFParagraph p = new XWPFParagraph((CTP)o, this);
             paragraphs.Add(p);
             bodyElements.Add(p);
         }
         if (o is CTTbl) {
             XWPFTable t = new XWPFTable((CTTbl)o, this);
             tables.Add(t);
             bodyElements.Add(t);
         }
     }
     cursor.Dispose();*/
 }
예제 #21
0
        // all of the contacts where second's edges intersect first's body
        // handles all cordinate transformation from each body to the world
        private IEnumerable<Contact> ContactsOnFirst(IBody first, IBody second)
        {
            IEdgeIntersector firstShape = first.CollisionShape;
            IEdgeIntersector secondShape = second.CollisionShape;
            Transform firstTransform = first.Dynamics.Transform;
            Transform secondTransform = second.Dynamics.Transform;
            var secondToFirst = new Transformation(secondTransform, firstTransform);

            if (IntersectStrats.HasStrategy(firstShape, secondShape))
            {
                return IntersectStrats.EnactStrategy(firstShape, secondShape, secondToFirst.Reverse()).Select(i => new Contact(i, first, second));
            }

            // general case             
            return
                // everything is converted to the firsts local transform coords
                secondShape.Edges.SelectMany(secondEdge => firstShape.FindIntersections(secondToFirst.TransformEdge(secondEdge)) 
                .Select(i => new Contact(firstTransform.ToWorldSpace(i), first, second))); // then to world coords
        }
예제 #22
0
파일: Leg3DOF.cs 프로젝트: veggielane/Robot
 public void Inverse(IBody body)
 {
     /*
     * Todo:
     * - Elbow Up + Elbow Down
     * - Reduce Calcs
     *
     * Jazar Pg. 331
     */
     var LtoF = (FootPosition + FootOffset) - BasePosition.ToVector3();
     var relative = (BasePosition.RotationComponent * LtoF.ToMatrix4());
     var angle1 = MathsHelper.Atan2(relative.Y, relative.X);
     var a = (Matrix4.RotateZ(angle1) * Matrix4.Translate(CoxaLength, 0, 0)).ToVector3();
     var c = relative.ToVector3();
     var atoc = c - a;
     var angle3 = 2 * MathsHelper.Atan2(((FemurLength + TibiaLength).Pow(2) - (atoc.X.Pow(2) + atoc.Z.Pow(2))).Sqrt(), (atoc.X.Pow(2) + atoc.Z.Pow(2) - (FemurLength - TibiaLength).Pow(2)).Sqrt());
     var angle2 = MathsHelper.Atan2(atoc.Z, atoc.X) + MathsHelper.Atan2(TibiaLength * Angle.FromRadians(angle3).Sin(), FemurLength + TibiaLength * Angle.FromRadians(angle3).Cos());
     CoxaServo.Angle = Angle.FromRadians((CoxaInvert ? -1 : 1) * (angle1 + CoxaOffset));
     FemurServo.Angle = Angle.FromRadians((FemurInvert ? -1 : 1) * (angle2 + FemurOffset));
     TibiaServo.Angle = Angle.FromRadians((TibiaInvert ? -1 : 1) * (angle3 + TibiaOffset));
 }
예제 #23
0
        public XWPFTable(CT_Tbl table, IBody part, int row, int col)
            : this(table, part)
        {

            CT_TblGrid ctTblGrid = table.AddNewTblGrid();
            for (int j = 0; j < col; j++)
            {
                CT_TblGridCol ctGridCol= ctTblGrid.AddNewGridCol();
                ctGridCol.w = 300;
            }
            for (int i = 0; i < row; i++)
            {
                XWPFTableRow tabRow = (GetRow(i) == null) ? CreateRow() : GetRow(i);
                for (int k = 0; k < col; k++)
                {
                    if (tabRow.GetCell(k) == null)
                    {
                        tabRow.CreateCell();
                    }
                }
            }
        }
예제 #24
0
 /**
  * If a table cell does not include at least one block-level element, then this document shall be considered corrupt
  */
 public XWPFTableCell(CT_Tc cell, XWPFTableRow tableRow, IBody part)
 {
     this.ctTc = cell;
     this.part = part;
     this.tableRow = tableRow;
     // NB: If a table cell does not include at least one block-level element, then this document shall be considered corrupt.
     if(cell.GetPList().Count<1)
         cell.AddNewP();
     bodyElements = new List<IBodyElement>();
     paragraphs = new List<XWPFParagraph>();
     tables = new List<XWPFTable>();
     foreach (object o in ctTc.Items)
     {
         if (o is CT_P)
         {
             XWPFParagraph p = new XWPFParagraph((CT_P)o, this);
             paragraphs.Add(p);
             bodyElements.Add(p);
         }
         if (o is CT_Tbl)
         {
             XWPFTable t = new XWPFTable((CT_Tbl)o, this);
             tables.Add(t);
             bodyElements.Add(t);
         }
         if (o is CT_SdtBlock)
         {
             XWPFSDT c = new XWPFSDT((CT_SdtBlock)o, this);
             bodyElements.Add(c);
         }
         if (o is CT_SdtRun)
         {
             XWPFSDT c = new XWPFSDT((CT_SdtRun)o, this);
             bodyElements.Add(c);
         }
     }
 }
예제 #25
0
        public AbstractXWPFSDT(CT_SdtPr pr, IBody part)
        {

            CT_String[] aliases = pr.GetAliasArray();
            if (aliases != null && aliases.Length > 0)
            {
                title = aliases[0].val;
            }
            else
            {
                title = "";
            }
            CT_String[] tags = pr.GetAliasArray();
            if (tags != null && tags.Length > 0)
            {
                tag = tags[0].val;
            }
            else
            {
                tag = "";
            }
            this.part = part;

        }
        public EconomyController(GameState game, Id<Player> player, PlayerGameView view)
            : base(game)
        {
            this.view = view;
            this.player = game.Players[player];
            this.economy = game.Economies.First(e => e.Player == this.player);
            this.body = this.economy.Body;

            view.FocusOnBody(this.body);

            this.controls = new PlayerControls();

            this.stats = new[]
            {
                new EcoStatController(this.game, this, this.economy, EcoValue.Income,
                    KeyboardAction.FromKey(Key.Number1),KeyboardAction.FromKey(Key.Number2), "1<>2"),
                new EcoStatController(this.game, this, this.economy, EcoValue.Projectiles,
                    KeyboardAction.FromKey(Key.Q),KeyboardAction.FromKey(Key.W), "Q<>W"),
                new EcoStatController(this.game, this, this.economy, EcoValue.FireRate,
                    KeyboardAction.FromKey(Key.A),KeyboardAction.FromKey(Key.S), "A<>S"),
                new EcoStatController(this.game, this, this.economy, EcoValue.Defenses,
                    KeyboardAction.FromKey(Key.Z),KeyboardAction.FromKey(Key.X), "Z<>X"),
            };
        }
예제 #27
0
 public void FocusOnBody(IBody body)
 {
     this.body = body;
 }
예제 #28
0
 public Exit(ISelect <_, Store <T> > origin, IBody <T> body) : this(origin, body, Return)
 {
 }
예제 #29
0
        public async Task BuckledDyingDropItemsTest()
        {
            var options = new ServerIntegrationOptions {
                ExtraPrototypes = PROTOTYPES
            };
            var server = StartServer(options);

            IEntity         human  = null;
            BuckleComponent buckle = null;
            HandsComponent  hands  = null;
            IBody           body   = null;

            await server.WaitIdleAsync();

            await server.WaitAssertion(() =>
            {
                var mapManager    = IoCManager.Resolve <IMapManager>();
                var entityManager = IoCManager.Resolve <IEntityManager>();

                var gridId      = new GridId(1);
                var grid        = mapManager.GetGrid(gridId);
                var coordinates = grid.GridEntityId.ToCoordinates();

                human         = entityManager.SpawnEntity("BuckleDummy", coordinates);
                IEntity chair = entityManager.SpawnEntity("StrapDummy", coordinates);

                // Component sanity check
                Assert.True(human.TryGetComponent(out buckle));
                Assert.True(chair.HasComponent <StrapComponent>());
                Assert.True(human.TryGetComponent(out hands));
                Assert.True(human.TryGetComponent(out body));

                // Buckle
                Assert.True(buckle.TryBuckle(human, chair));
                Assert.NotNull(buckle.BuckledTo);
                Assert.True(buckle.Buckled);

                // Put an item into every hand
                for (var i = 0; i < hands.Count; i++)
                {
                    var akms = entityManager.SpawnEntity("RifleAk", coordinates);

                    // Equip items
                    Assert.True(akms.TryGetComponent(out ItemComponent item));
                    Assert.True(hands.PutInHand(item));
                }
            });

            await server.WaitRunTicks(10);

            await server.WaitAssertion(() =>
            {
                // Still buckled
                Assert.True(buckle.Buckled);

                // With items in all hands
                foreach (var slot in hands.Hands)
                {
                    Assert.NotNull(hands.GetItem(slot));
                }

                var legs = body.GetPartsOfType(BodyPartType.Leg);

                // Break our guy's kneecaps
                foreach (var leg in legs)
                {
                    body.RemovePart(leg);
                }
            });

            await server.WaitRunTicks(10);

            await server.WaitAssertion(() =>
            {
                // Still buckled
                Assert.True(buckle.Buckled);

                // Now with no item in any hand
                foreach (var slot in hands.Hands)
                {
                    Assert.Null(hands.GetItem(slot));
                }

                buckle.TryUnbuckle(human, true);
            });
        }
예제 #30
0
 public void RemoveBody(IBody iBody)
 {
     world.RemoveBody((TrueSync.Physics2D.Body)iBody);
     world.ProcessRemovedBodies();
 }
예제 #31
0
 public void setParent(IBody parent, float distanceFromParent)
 {
     this.Parent             = parent;
     this.distanceFromParent = distanceFromParent;
 }
예제 #32
0
 protected virtual void OnRemovedFromPartInBody(IBody oldBody, IBodyPart oldPart)
 {
 }
예제 #33
0
 protected virtual void OnAddedToPartInBody(IBody body, IBodyPart part)
 {
 }
예제 #34
0
 /**
  * @brief The related GameObject is firstly set to be inactive then in a safe moment it will be destroyed.
  *
  * @param rigidBody Instance of a {@link TSRigidBody}
  **/
 private static void DestroyTSRigidBody(GameObject tsColliderGO, IBody body)
 {
     tsColliderGO.gameObject.SetActive(false);
     instance.lockstep.Destroy(body);
 }
예제 #35
0
 public Content(IBody <T> body) : this(body, Leases <T> .Default)
 {
 }
예제 #36
0
 public Particle(IBody body, string particleTexture)
 {
     Body = body;
     Color = new Color(1f, 1f, 1f);
     ParticleTexture = particleTexture;
 }
예제 #37
0
 /// <summary>
 /// Gets the <c>IJointOrientation</c> of the joint that mirrors the specified
 /// <c>JointTypeEx</c> (e.g., the left wrist mirrors the right wrist).
 /// </summary>
 public static IJointOrientation GetMirroredJointOrientation(this IBody body, JointTypeEx jointType)
 {
     return(body.JointOrientations[_mirroredJoints[jointType]]);
 }
예제 #38
0
 public static ICommand Command(GameState game, FreeObject particle, IBody body)
 {
     return(new CommandImplementation(game, particle, body));
 }
예제 #39
0
 /// <summary>
 /// Returns the distance (in meters) between the two specified joints.
 /// </summary>
 public static double GetDistanceBetween(this IBody body, JointTypeEx jointTypeA, JointTypeEx jointTypeB)
 {
     return(body.GetVector(jointTypeA, jointTypeB).Length());
 }
예제 #40
0
 public BodyContentWriteStream(IBody body) : base(new TemporaryDataStorage())
 {
     this.body = body;
 }
예제 #41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Request"/> class.
 /// </summary>
 /// <param name="method">HTTP method.</param>
 /// <param name="url">Request URL.</param>
 /// <param name="body">HTTP body.</param>
 public Request(string method, string url, IBody body)
 {
     Method = method;
     Url    = url;
     Body   = body;
 }
예제 #42
0
파일: Class156.cs 프로젝트: jollitycn/JGNet
 public Class156(IHeader1 class146_1, IBody interface47_0)
 {
     this.class146_0 = class146_1;
     this.class147_0 = interface47_0 ?? new Body();
 }
예제 #43
0
 protected virtual void OnAddedToBody(IBody body)
 {
 }
예제 #44
0
        private void _bodyReader_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {
            if (!_bodyFrameEnable)
            {
                return;
            }
            IEnumerable <IBody> bodies = null; // to make the GetBitmap call a little cleaner

            using (var frame = e.FrameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    frame.GetAndRefreshBodyData(_bodies);
                    bodies = _bodies;
                }
            }

            if (bodies != null)
            {
                int i = 0;
                foreach (IBody body1 in bodies)
                {
                    if (Scene.Instance != null && Kinect.Instance.Recorder.IsRecording)
                    {
                        if (body1.TrackingId != 0)
                        {
                            Person person1 = Scene.Instance.Persons.FirstOrDefault(p => p.TrackingId == (long)body1.TrackingId);
                            if (person1 == null)
                            {
                                person1 = new Person(
                                    body1.TrackingId,
                                    Scene.Instance.Persons.Count
                                    );
                                Scene.Instance.Persons.Add(person1);
                            }

                            IJoint center = body1.Joints[JointType.SpineShoulder];
                            for (int j = i + 1; j < bodies.Count(); j++)
                            {
                                IBody body2 = bodies.ElementAt(j);

                                if (body2.TrackingId != 0)
                                {
                                    Person person2 = Scene.Instance.Persons.FirstOrDefault(p => p.TrackingId == (long)body2.TrackingId);
                                    if (person2 == null)
                                    {
                                        person2 = new Person(
                                            body2.TrackingId,
                                            Scene.Instance.Persons.Count
                                            );
                                        Scene.Instance.Persons.Add(person2);
                                    }
                                    IJoint center2 = body2.Joints[JointType.SpineShoulder];
                                    //double d = Relacion.distance();
                                    Relation rel = new Relation(person1, person2, center, center2, Kinect.Instance.Recorder.getCurrentLocation());
                                    if (rel.HasInteraction())
                                    {
                                        Interaction.Instance.Relations.Add(rel);
                                    }
                                }
                            }
                        }


                        //if the current body TrackingId changed, update the corresponding gesture detector with the new value
                        if (body1.TrackingId != Kinect.Instance.gestureDetectorList[i].TrackingId)
                        {
                            Kinect.Instance.gestureDetectorList[i].TrackingId = body1.TrackingId;

                            // if the current body is tracked, unpause its detector to get VisualGestureBuilderFrameArrived events
                            // if the current body is not tracked, pause its detector so we don't waste resources trying to get invalid gesture results
                            Kinect.Instance.gestureDetectorList[i].IsPaused = body1.TrackingId == 0;
                        }
                    }
                    i++;
                }

                bodies.MapDepthPositions();
                //bodies.MapColorPositions();
                MainWindow.Instance().bodyImageControl.Source = bodies.GetBitmap(Colors.LightGreen, Colors.Yellow);
                //OutputImage = bodies.GetBitmap(Colors.LightGreen, Colors.Yellow);
            }
            else
            {
                MainWindow.Instance().bodyImageControl.Source = null;
                //OutputImage = null;
            }
        }
예제 #45
0
 protected virtual void OnRemovedFromBody(IBody old)
 {
 }
예제 #46
0
 public Car(ICarFactory factory)
 {
     _body  = factory.CreateBody();
     _motor = factory.CreateMotor();
     _cabin = factory.CreateCabin();
 }
예제 #47
0
 public static bool HasMechanismBehavior <T>(this IBody body)
 {
     return(body.Parts.Values.Any(p => p.HasMechanismBehavior <T>()));
 }
예제 #48
0
        public async Task BuckledDyingDropItemsTest()
        {
            var server = StartServer();

            IEntity         human  = null;
            IEntity         chair  = null;
            BuckleComponent buckle = null;
            StrapComponent  strap  = null;
            HandsComponent  hands  = null;
            IBody           body   = null;

            server.Assert(() =>
            {
                var mapManager = IoCManager.Resolve <IMapManager>();

                var mapId = new MapId(1);
                mapManager.CreateNewMapEntity(mapId);

                var entityManager = IoCManager.Resolve <IEntityManager>();
                var gridId        = new GridId(1);
                var grid          = mapManager.CreateGrid(mapId, gridId);
                var coordinates   = grid.GridEntityId.ToCoordinates();
                var tileManager   = IoCManager.Resolve <ITileDefinitionManager>();
                var tileId        = tileManager["underplating"].TileId;
                var tile          = new Tile(tileId);

                grid.SetTile(coordinates, tile);

                human = entityManager.SpawnEntity("HumanMob_Content", coordinates);
                chair = entityManager.SpawnEntity("ChairWood", coordinates);

                // Component sanity check
                Assert.True(human.TryGetComponent(out buckle));
                Assert.True(chair.TryGetComponent(out strap));
                Assert.True(human.TryGetComponent(out hands));
                Assert.True(human.TryGetComponent(out body));

                // Buckle
                Assert.True(buckle.TryBuckle(human, chair));
                Assert.NotNull(buckle.BuckledTo);
                Assert.True(buckle.Buckled);

                // Put an item into every hand
                for (var i = 0; i < hands.Count; i++)
                {
                    var akms = entityManager.SpawnEntity("RifleAk", coordinates);

                    // Equip items
                    Assert.True(akms.TryGetComponent(out ItemComponent item));
                    Assert.True(hands.PutInHand(item));
                }
            });

            server.RunTicks(10);

            server.Assert(() =>
            {
                // Still buckled
                Assert.True(buckle.Buckled);

                // With items in all hands
                foreach (var slot in hands.Hands)
                {
                    Assert.NotNull(hands.GetItem(slot));
                }

                var legs = body.GetPartsOfType(BodyPartType.Leg);

                // Break our guy's kneecaps
                foreach (var leg in legs)
                {
                    body.RemovePart(leg);
                }
            });

            server.RunTicks(10);

            server.Assert(() =>
            {
                // Still buckled
                Assert.True(buckle.Buckled);

                // Now with no item in any hand
                foreach (var slot in hands.Hands)
                {
                    Assert.Null(hands.GetItem(slot));
                }
            });

            await server.WaitIdleAsync();
        }
예제 #49
0
        public XWPFParagraph(CT_P prgrph, IBody part)
        {
            this.paragraph = prgrph;
            this.part      = part;

            this.document = part.GetXWPFDocument();

            if (document == null)
            {
                throw new NullReferenceException();
            }
            // Build up the character runs
            runs  = new List <XWPFRun>();
            iRuns = new List <IRunElement>();

            BuildRunsInOrderFromXml(paragraph.Items);
            // Look for bits associated with the runs
            foreach (XWPFRun run in runs)
            {
                CT_R r = run.GetCTR();
                if (document != null)
                {
                    for (int i = 0; i < r.Items.Count; i++)
                    {
                        object o = r.Items[i];
                        if (o is CT_FtnEdnRef)
                        {
                            CT_FtnEdnRef ftn = (CT_FtnEdnRef)o;
                            footnoteText.Append("[").Append(ftn.id).Append(": ");

                            XWPFFootnote footnote = null;

                            if (r.ItemsElementName.Count > i && r.ItemsElementName[i] == RunItemsChoiceType.endnoteReference)
                            {
                                footnote = document.GetEndnoteByID(int.Parse(ftn.id));
                                if (footnote == null)
                                {
                                    footnote = document.GetFootnoteByID(int.Parse(ftn.id));
                                }
                            }
                            else
                            {
                                footnote = document.GetFootnoteByID(int.Parse(ftn.id));
                                if (footnote == null)
                                {
                                    footnote = document.GetEndnoteByID(int.Parse(ftn.id));
                                }
                            }

                            if (footnote != null)
                            {
                                bool first = true;
                                foreach (XWPFParagraph p in footnote.Paragraphs)
                                {
                                    if (!first)
                                    {
                                        footnoteText.Append("\n");
                                        first = false;
                                    }
                                    footnoteText.Append(p.Text);
                                }
                            }

                            footnoteText.Append("]");
                        }
                    }
                }
            }
        }
 /**
  *  @brief Check if the collision between two RigidBodies is enabled.
  *
  *  @param rigidBody1 First {@link RigidBody}
  *  @param rigidBody2 Second {@link RigidBody}
  **/
 public bool IsCollisionEnabled(IBody rigidBody1, IBody rigidBody2)
 {
     return(LayerCollisionMatrix.CollisionEnabled(gameObjectMap[rigidBody1], gameObjectMap[rigidBody2]));
 }
예제 #51
0
 public Exit(ISelect <_, Store <T> > origin, IBody <T> body, Action <T[]> @return)
 {
     _origin = origin;
     _body   = body;
     _return = @return;
 }
        public bool Raycast(TSVector rayOrigin, TSVector rayDirection, RaycastCallback raycast, out IBody body, out TSVector normal, out FP fraction)
        {
            RigidBody rb;
            bool      result = world.CollisionSystem.Raycast(rayOrigin, rayDirection, raycast, out rb, out normal, out fraction);

            body = rb;

            return(result);
        }
예제 #53
0
 public Exit(ISelect <_, T[]> origin, IBody <T> body, Action <T[]> @return)
     : this(new Origin <_, T>(origin), body, @return)
 {
 }
 public void RemoveBody(IBody iBody)
 {
     world.RemoveBody((RigidBody)iBody);
 }
예제 #55
0
 public Parameters(FreeObject particle, IBody body)
 {
     this.particleId = particle.Id.Simple;
     this.bodyId     = body.Id.Simple;
 }
예제 #56
0
 /// <summary>
 /// Gets a <c>Bone</c> structure containing the two <c>IJoint</c> values
 /// that constitute the start and end of the specified <c>BoneTypeEx</c>.
 /// </summary>
 public static Bone GetBone(this IBody body, BoneTypeEx boneType)
 {
     return(new Bone(boneType, body.Joints[boneType.StartJoint], body.Joints[boneType.EndJoint]));
 }
예제 #57
0
        public XWPFSDTContentCell(CT_SdtContentCell sdtContentCell,
                                  XWPFTableRow xwpfTableRow, IBody part)
        {
            StringBuilder sb = new StringBuilder();
            

            //keep track of the following,
            //and add "\n" only before the start of a body
            //element if it is not the first body element.

            //index of cell in row
            int tcCnt = 0;
            //count of body objects
            int iBodyCnt = 0;
            int depth = 1;
            string sdtXml = sdtContentCell.ToString();
            using (StringReader sr = new StringReader(sdtXml))
            {
                XmlParserContext context = new XmlParserContext(null, POIXMLDocumentPart.NamespaceManager,
                    null, XmlSpace.Preserve);
                using (XmlReader cursor = XmlReader.Create(sr, null, context))
                {
                    while (cursor.Read() && depth > 0)
                    {
                        if (cursor.NodeType == XmlNodeType.Text)
                        {
                            sb.Append(cursor.ReadContentAsString());
                        }
                        else if (IsStartToken(cursor, "tr"))
                        {
                            tcCnt = 0;
                            iBodyCnt = 0;
                        }
                        else if (IsStartToken(cursor, "tc"))
                        {
                            if (tcCnt++ > 0)
                            {
                                sb.Append("\t");
                            }
                            iBodyCnt = 0;
                        }
                        else if (IsStartToken(cursor, "p") ||
                              IsStartToken(cursor, "tbl") ||
                              IsStartToken(cursor, "sdt"))
                        {
                            if (iBodyCnt > 0)
                            {
                                sb.Append("\n");
                            }
                            iBodyCnt++;
                        }

                    }
                }
            }
            //IEnumerator cursor = sdtContentCell.Items.GetEnumerator();
            //while (cursor.MoveNext() && depth > 0)
            //{
            //    //TokenType t = cursor.ToNextToken();
            //    object t = cursor.Current;
            //    if (t is CT_Text)//??
            //    {
            //        //sb.Append(cursor.TextValue);
            //    }
            //    else if (IsStartToken(cursor, "tr"))
            //    {
            //        tcCnt = 0;
            //        iBodyCnt = 0;
            //    }
            //    else if (IsStartToken(cursor, "tc"))
            //    {
            //        if (tcCnt++ > 0)
            //        {
            //            sb.Append("\t");
            //        }
            //        iBodyCnt = 0;
            //    }
            //    else if (IsStartToken(cursor, "p") ||
            //          IsStartToken(cursor, "tbl") ||
            //          IsStartToken(cursor, "sdt"))
            //    {
            //        if (iBodyCnt > 0)
            //        {
            //            sb.Append("\n");
            //        }
            //        iBodyCnt++;
            //    }
            //    //if (cursor.IsStart())
            //    //{
            //    //    depth++;
            //    //}
            //    //else if (cursor.IsEnd())
            //    //{
            //    //    depth--;
            //    //}
            //}
            text = sb.ToString();
        }
예제 #58
0
 public CommandImplementation(GameState game, FreeObject particle, IBody body)
     : base(CommandType.ParticlePlanetCollision, game)
 {
     this.particle = particle;
     this.body     = body;
 }
예제 #59
0
        public XWPFParagraph(CT_P prgrph, IBody part)
        {
            this.paragraph = prgrph;
            this.part = part;

            this.document = part.GetXWPFDocument();

            if (document == null)
            {
                throw new NullReferenceException();
            }
            // Build up the character runs
            runs = new List<XWPFRun>();

            BuildRunsInOrderFromXml(paragraph.Items);
            // Look for bits associated with the runs
            foreach (XWPFRun run in runs)
            {
                CT_R r = run.GetCTR();
                if (document != null)
                {
                    foreach (object o in r.Items)
                    {
                        if (o is CT_FtnEdnRef)
                        {
                            CT_FtnEdnRef ftn = (CT_FtnEdnRef)o;
                            footnoteText.Append("[").Append(ftn.id).Append(": ");
                            
                            XWPFFootnote footnote = document.GetFootnoteByID(int.Parse(ftn.id));
                            if (footnote == null)
                                footnote = document.GetEndnoteByID(int.Parse(ftn.id));
                               //ftn.DomNode.LocalName.Equals("footnoteReference") ?
                               //      document.GetFootnoteByID(ftn.Id.IntValue()) :
                               //      document.GetEndnoteByID(ftn.Id.IntValue());

                            bool first = true;
                            foreach (XWPFParagraph p in footnote.Paragraphs)
                            {
                                if (!first)
                                {
                                    footnoteText.Append("\n");
                                    first = false;
                                }
                                footnoteText.Append(p.Text);
                            }

                            footnoteText.Append("]");
                        }
                    }
                }
            }

            // Get all our child nodes in order, and process them
            //  into XWPFRuns where we can
            /*XmlCursor c = paragraph.NewCursor();
            c.SelectPath("child::*");
            while (c.ToNextSelection()) {
               XmlObject o = c.Object;
               if(o is CT_R) {
                  Runs.Add(new XWPFRun((CT_R)o, this));
               }
               if(o is CT_Hyperlink) {
                  CT_Hyperlink link = (CT_Hyperlink)o;
                  foreach(CTR r in link.RList) {
                     Runs.Add(new XWPFHyperlinkRun(link, r, this));
                  }
               }
               if(o is CT_SdtRun) {
                  CT_SdtContentRun run = ((CT_SdtRun)o).SdtContent;
                  foreach(CTR r in Run.RList) {
                     Runs.Add(new XWPFRun(r, this));
                  }
               }
               if(o is CT_RunTrackChange) {
                  foreach(CTR r in ((CT_RunTrackChange)o).RList) {
                     Runs.Add(new XWPFRun(r, this));
                  }
               }
               if(o is CT_SimpleField) {
                  foreach(CTR r in ((CT_SimpleField)o).RList) {
                     Runs.Add(new XWPFRun(r, this));
                  }
               }
            }*/
        }
예제 #60
0
 public Content(IBody <T> body, IStores <T> stores)
 {
     _body   = body;
     _stores = stores;
 }