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


C# BulletSharp.CollisionObject类代码示例

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


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

示例1: OnInitializePhysics

        protected override void OnInitializePhysics()
        {
            BoxShape boxA = new BoxShape(new Vector3(1, 1, 1));
            boxA.Margin = 0;

            BoxShape boxB = new BoxShape(new Vector3(0.5f, 0.5f, 0.5f));
            boxB.Margin = 0;

            objects[0] = new CollisionObject();
            objects[1] = new CollisionObject();

            objects[0].CollisionShape = boxA;
            objects[1].CollisionShape = boxB;

            // collision configuration contains default setup for memory, collision setup
            CollisionConf = new DefaultCollisionConfiguration();
            Dispatcher = new CollisionDispatcher(CollisionConf);

            Broadphase = new AxisSweep3(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000));

            World = new DiscreteDynamicsWorld(Dispatcher, Broadphase, null, CollisionConf);
            World.Gravity = new Vector3(0, -10, 0);
            IsDebugDrawEnabled = true;

            //World.AddCollisionObject(objects[0]);
            World.AddCollisionObject(objects[1]);

            Quaternion rotA = new Quaternion(0.739f, -0.204f, 0.587f, 0.257f);
            rotA.Normalize();

            objects[0].WorldTransform = Matrix.RotationQuaternion(rotA) * Matrix.Translation(0, 3, 0);
            objects[1].WorldTransform = Matrix.Translation(0, 4.248f, 0);
        }
开发者ID:raiker,项目名称:BulletSharp,代码行数:33,代码来源:CollisionInterfaceDemo.cs

示例2: Render

 public void Render(CollisionObject body)
 {
     switch (body.CollisionShape.ShapeType)
     {
         case BroadphaseNativeType.SoftBodyShape:
             device.SetTransform(TransformState.World, Matrix.Identity);
             RenderSoftBody(body as SoftBody);
             break;
         case BroadphaseNativeType.CompoundShape:
             CompoundShape compoundShape = body.CollisionShape as CompoundShape;
             //if (compoundShape.NumChildShapes == 0)
             //    return;
             foreach (CompoundShapeChild child in compoundShape.ChildList)
             {
                 device.SetTransform(TransformState.World,
                     MathHelper.Convert(child.Transform) * MathHelper.Convert(body.WorldTransform));
                 Render(child.ChildShape);
             }
             break;
         default:
             device.SetTransform(TransformState.World, MathHelper.Convert(body.WorldTransform));
             Render(body.CollisionShape);
             break;
     }
 }
开发者ID:WebFreak001,项目名称:BulletSharp,代码行数:25,代码来源:MeshFactory.cs

示例3: CollisionObjectDataHolder

        /// <summary>
        /// Create a data holder without a LThing object.
        /// </summary>
        /// <param name="collisionGroup">The collision group of the object</param>
        /// <param name="name">The name of the object, excluding an ID</param>
        /// <param name="owner">The collision object this data holder is attached to</param>
        public CollisionObjectDataHolder(CollisionObject owner, PonykartCollisionGroups collisionGroup, string name)
        {
            this.Owner = owner;
            this.CollisionGroup = collisionGroup;
            this.Name = name;

            this.ID = IDs.Random;
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:14,代码来源:CollisionObjectDataHolder.cs

示例4: AddSingleResult

 public override float AddSingleResult(ManifoldPoint cp, CollisionObject colObj0, int partId0, int index0, CollisionObject colObj1, int partId1, int index1)
 {
     if (colObj0.UserObject != null && colObj0.UserObject is IPhysicObject)
     {
         objs.Add(colObj0.UserObject as IPhysicObject);
     }
     return 0;
 }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:8,代码来源:BulletPhysicWorld.cs

示例5: Render

 public void Render(CollisionObject body)
 {
     if (body.CollisionShape.ShapeType == BroadphaseNativeType.SoftBodyShape)
     {
         RenderSoftBody(body as SoftBody);
     }
     else
     {
         Render(body.CollisionShape);
     }
 }
开发者ID:raiker,项目名称:BulletSharp,代码行数:11,代码来源:GraphicObjectFactory.cs

示例6: _BuildCollisionObject

        //called by Physics World just before rigid body is added to world.
        //the current rigid body properties are used to rebuild the rigid body.
        internal virtual bool _BuildCollisionObject()
        {
            BPhysicsWorld world = BPhysicsWorld.Get();
            if (m_collisionObject != null)
            {
                if (isInWorld && world != null)
                {
                    world.RemoveCollisionObject(m_collisionObject);
                }
            }

            if (transform.localScale != UnityEngine.Vector3.one)
            {
                Debug.LogError("The local scale on this collision shape is not one. Bullet physics does not support scaling on a rigid body world transform. Instead alter the dimensions of the CollisionShape.");
            }

            m_collisionShape = GetComponent<BCollisionShape>();
            if (m_collisionShape == null)
            {
                Debug.LogError("There was no collision shape component attached to this BRigidBody. " + name);
                return false;
            }

            CollisionShape cs = m_collisionShape.GetCollisionShape();
            //rigidbody is dynamic if and only if mass is non zero, otherwise static

            if (m_collisionObject == null)
            {
                m_collisionObject = new CollisionObject();
                m_collisionObject.CollisionShape = cs;
                m_collisionObject.UserObject = this;

                BulletSharp.Math.Matrix worldTrans;
                BulletSharp.Math.Quaternion q = transform.rotation.ToBullet();
                BulletSharp.Math.Matrix.RotationQuaternion(ref q, out worldTrans);
                worldTrans.Origin = transform.position.ToBullet();
                m_collisionObject.WorldTransform = worldTrans;
                m_collisionObject.CollisionFlags = m_collisionFlags;
            }
            else {
                m_collisionObject.CollisionShape = cs;
                BulletSharp.Math.Matrix worldTrans;
                BulletSharp.Math.Quaternion q = transform.rotation.ToBullet();
                BulletSharp.Math.Matrix.RotationQuaternion(ref q, out worldTrans);
                worldTrans.Origin = transform.position.ToBullet();
                m_collisionObject.WorldTransform = worldTrans;
                m_collisionObject.CollisionFlags = m_collisionFlags;
            }
            return true;
        }
开发者ID:Cyberbanan,项目名称:BulletSharpUnity3d,代码行数:52,代码来源:BCollisionObject.cs

示例7: KinematicClosestNotMeConvexResultCallback

 public KinematicClosestNotMeConvexResultCallback(CollisionObject me, Vector3 up, float minSlopeDot)
     : base(ref zero, ref zero)
 {
     _me = me;
     _up = up;
     _minSlopeDot = minSlopeDot;
 }
开发者ID:sinkingsugar,项目名称:BulletSharpPInvoke,代码行数:7,代码来源:KinematicCharacterController.cs

示例8: KinematicClosestNotMeRayResultCallback

 public KinematicClosestNotMeRayResultCallback(CollisionObject me)
     : base(ref zero, ref zero)
 {
     _me = me;
 }
开发者ID:sinkingsugar,项目名称:BulletSharpPInvoke,代码行数:5,代码来源:KinematicCharacterController.cs

示例9: ContactTest

		public void ContactTest(CollisionObject colObj, ContactResultCallback resultCallback)
		{
			btCollisionWorld_contactTest(_native, colObj._native, resultCallback._native);
		}
开发者ID:rhynodegreat,项目名称:BulletSharpPInvoke,代码行数:4,代码来源:CollisionWorld.cs

示例10: TestRayCast

        static void TestRayCast(CollisionObject testObject)
        {
            Vector3 rayFromWorld = testObject.WorldTransform.Origin + new Vector3(0, 0, -2);
            Vector3 rayToWorld = testObject.WorldTransform.Origin + new Vector3(0, 0, 2);
            var rayCallback = new CustomRayCallback(ref rayFromWorld, ref rayToWorld);
            world.RayTestRef(ref rayFromWorld, ref rayToWorld, rayCallback);
            if (rayCallback.CollisionObject != testObject)
            {
                Console.WriteLine("Raycast FAILED!");
            }

            AddToDisposeQueue(rayCallback);
        }
开发者ID:sinkingsugar,项目名称:BulletSharpPInvoke,代码行数:13,代码来源:Program.cs

示例11: InitRigidBodyInstance

 void InitRigidBodyInstance(CollisionObject colObj, CollisionShape shape, ref Matrix transform)
 {
     if (shape.ShapeType == BroadphaseNativeType.CompoundShape)
     {
         foreach (var child in (shape as CompoundShape).ChildList)
         {
             Matrix childTransform = child.Transform * transform;
             InitRigidBodyInstance(colObj, child.ChildShape, ref childTransform);
         }
     }
     else
     {
         var shapeData = InitShapeData(shape);
         shapeData.Instances.Add(new InstanceData()
         {
             WorldTransform = transform,
             Color = "Ground".Equals(colObj.UserObject) ? groundColor :
                 colObj.ActivationState == ActivationState.ActiveTag ? activeColor : passiveColor
         });
     }
 }
开发者ID:rhynodegreat,项目名称:BulletSharp,代码行数:21,代码来源:MeshFactory.cs

示例12: NeedsResponse

 public bool NeedsResponse(CollisionObject body0, CollisionObject body1)
 {
     return btDispatcher_needsResponse(_native, body0._native, body1._native);
 }
开发者ID:Cyberbanan,项目名称:BulletSharpUnity3d,代码行数:4,代码来源:Dispatcher.cs

示例13: CheckCollideWithOverride

 public bool CheckCollideWithOverride(CollisionObject co)
 {
     return btCollisionObject_checkCollideWithOverride(_native, co._native);
 }
开发者ID:Cyberbanan,项目名称:BulletSharpUnity3d,代码行数:4,代码来源:CollisionObject.cs

示例14: OnContactProcessed

 void OnContactProcessed(ManifoldPoint cp, CollisionObject body0, CollisionObject body1)
 {
     // Debug.WriteLine("OnContactProcessed");
     cp.UserPersistentData = 1;
 }
开发者ID:GameProduction,项目名称:ScharfschiessenGame,代码行数:5,代码来源:DynamicWorldImp.cs

示例15: UpdateSingleAabb

		public void UpdateSingleAabb(CollisionObject colObj)
		{
			btCollisionWorld_updateSingleAabb(_native, colObj._native);
		}
开发者ID:rhynodegreat,项目名称:BulletSharpPInvoke,代码行数:4,代码来源:CollisionWorld.cs


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