当前位置: 首页>>代码示例>>C#>>正文


C# CollisionObject.GetCollisionGroup方法代码示例

本文整理汇总了C#中BulletSharp.CollisionObject.GetCollisionGroup方法的典型用法代码示例。如果您正苦于以下问题:C# CollisionObject.GetCollisionGroup方法的具体用法?C# CollisionObject.GetCollisionGroup怎么用?C# CollisionObject.GetCollisionGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BulletSharp.CollisionObject的用法示例。


在下文中一共展示了CollisionObject.GetCollisionGroup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetupAndFireEvent

        /// <summary>
        /// Sets up a contact event and then invokes it.
        /// </summary>
        private void SetupAndFireEvent(CollisionObject objectA, CollisionObject objectB, Vector3? position, Vector3? normal, ObjectTouchingFlags flags)
        {
            PonykartCollisionGroups groupA = objectA.GetCollisionGroup();
            PonykartCollisionGroups groupB = objectB.GetCollisionGroup();
            //int groupIDA = (int) groupA;
            //int groupIDB = (int) groupB;

            CollisionReportInfo info = new CollisionReportInfo {
                FirstGroup = groupA,
                SecondGroup = groupB,
                FirstObject = objectA,
                SecondObject = objectB,
                Position = position,
                Normal = normal,
                Flags = flags
            };

            FireEvent(info);
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:22,代码来源:CollisionReporter.cs

示例2: GetCollisionGroup

 public static PonykartCollisionGroups GetCollisionGroup(CollisionObject obj)
 {
     return obj.GetCollisionGroup();
 }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:4,代码来源:PhysicsWrapper.cs

示例3: ContactAdded

        /// <summary>
        /// Fired every frame when an object is inside another object.
        /// </summary>
        bool ContactAdded(ManifoldPoint point, CollisionObject objectA, int partId0, int index0, CollisionObject objectB, int partId1, int index1)
        {
            // if one of the two objects is deactivated, we don't care
            if (!objectA.IsActive && !objectB.IsActive)
                return false;

            int objectACollisionGroup = (int) objectA.GetCollisionGroup();
            int objectBCollisionGroup = (int) objectB.GetCollisionGroup();

            // do we have any events that care about these groups? if not, then skip this collision pair
            if (reporters[objectACollisionGroup, objectBCollisionGroup] == null
                    && reporters[objectBCollisionGroup, objectACollisionGroup] == null)
                return false;

            // when the actual bodies are touching and not just their AABB's
            if (point.Distance <= 0.05) {
                // get the lists
                HashSet<CollisionObject> objectAList = GetCollisionListForObject(objectA, CurrentlyCollidingWith),
                                         newObjectAList = GetCollisionListForObject(objectA, NewCollidingWith),
                                         objectBList = GetCollisionListForObject(objectB, CurrentlyCollidingWith),
                                         newObjectBList = GetCollisionListForObject(objectB, NewCollidingWith);

                // see if the other object is in there
                if (!objectAList.Contains(objectB) || !objectBList.Contains(objectA)) {
                    /*
                     * if it isn't, add it! this means we have a new collision and need to fire off an event!
                     * okay now we need to get the point where it contacted!
                     * Limitation with this system: if we're already colliding with B and then collide with it in a different place without
                     * leaving the original place, we won't get another event. Why? Well because what if something's sliding along?
                     * Don't need loads of events for that
                     */
                    // make sure we add it to our collections! The hashset means we don't have to worry about duplicates
                    objectAList.Add(objectB);
                    objectBList.Add(objectA);
                    newObjectAList.Add(objectB);
                    newObjectBList.Add(objectA);

                    // update the dictionaries (is this necessary?)
                    CurrentlyCollidingWith[objectA] = objectAList;
                    CurrentlyCollidingWith[objectB] = objectBList;
                    NewCollidingWith[objectA] = newObjectAList;
                    NewCollidingWith[objectB] = newObjectBList;

                    Vector3 pos = point.PositionWorldOnA.MidPoint(point.PositionWorldOnB);
                    Vector3 normal = point.NormalWorldOnB;

                    // woop woop they started touching, so we fire off an event!
                    SetupAndFireEvent(objectA, objectB, pos, normal, ObjectTouchingFlags.StartedTouching);
                }
                else {
                    // already in the dictionary, no new collisions. Add it to the new dictionary anyway though, because if we don't then it thinks
                    // they stopped colliding. Which we don't want!
                    newObjectAList.Add(objectB);
                    newObjectBList.Add(objectA);

                    NewCollidingWith[objectA] = newObjectAList;
                    NewCollidingWith[objectB] = newObjectBList;
                }
            }
            // This means they're still inside each other's AABB's, but they aren't actually touching
            //else {

            //}

            return false;
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:69,代码来源:CollisionReporter.cs


注:本文中的BulletSharp.CollisionObject.GetCollisionGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。