當前位置: 首頁>>代碼示例>>C#>>正文


C# BulletSharp.CollisionShape類代碼示例

本文整理匯總了C#中BulletSharp.CollisionShape的典型用法代碼示例。如果您正苦於以下問題:C# CollisionShape類的具體用法?C# CollisionShape怎麽用?C# CollisionShape使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CollisionShape類屬於BulletSharp命名空間,在下文中一共展示了CollisionShape類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RigidBodyConstructionInfo

 public RigidBodyConstructionInfo(float mass, MotionState motionState, CollisionShape collisionShape)
 {
     _native = btRigidBody_btRigidBodyConstructionInfo_new(mass, (motionState != null) ? motionState._native : IntPtr.Zero,
         (collisionShape != null) ? collisionShape._native : IntPtr.Zero);
     _collisionShape = collisionShape;
     _motionState = motionState;
 }
開發者ID:Cyberbanan,項目名稱:BulletSharpUnity3d,代碼行數:7,代碼來源:RigidBodyConstructionInfo.cs

示例2: AddChildShape

		public unsafe static void AddChildShape(this CompoundShape obj, ref OpenTK.Matrix4 localTransform, CollisionShape shape)
		{
			fixed (OpenTK.Matrix4* localTransformPtr = &localTransform)
			{
				obj.AddChildShape(ref *(BulletSharp.Math.Matrix*)localTransformPtr, shape);
			}
		}
開發者ID:sinkingsugar,項目名稱:BulletSharpPInvoke,代碼行數:7,代碼來源:CompoundShapeExtensions.cs

示例3: PhysicalBody

 public PhysicalBody(RigidBody rigidBody, CollisionShape shape, TransformationManager manager)
 {
     Body = rigidBody;
     Shape = shape;
     Transformation = manager;
     Enabled = false;
 }
開發者ID:whztt07,項目名稱:vengine,代碼行數:7,代碼來源:PhysicalBody.cs

示例4: RemoveShape

 public override void RemoveShape(CollisionShape shape)
 {
     if (shapes.ContainsKey(shape))
     {
         shapes[shape].Dispose();
         shapes.Remove(shape);
     }
 }
開發者ID:WebFreak001,項目名稱:BulletSharp,代碼行數:8,代碼來源:MeshFactory.cs

示例5: BulletPhysicObject

        public BulletPhysicObject(CollisionShape CollisionShape, Vector3 translation, Matrix rotation, Vector3 Scale, float mass, CollisionFilterGroups CollisionFilterGroup = CollisionFilterGroups.DefaultFilter,CollisionFilterGroups collisionFilterMask = CollisionFilterGroups.DefaultFilter)
        {
            shape  = CollisionShape;
            this.scale = Scale;
            this.mass = mass;
            shape.LocalScaling = Scale;
            obj = LocalCreateRigidBody(mass, Matrix.CreateTranslation(translation) * rotation, CollisionShape);            

        }
開發者ID:brunoduartec,項目名稱:port-ploobsengine,代碼行數:9,代碼來源:BulletPhysicObject.cs

示例6: CreateShape

        Mesh CreateShape(CollisionShape shape)
        {
            uint[] indices;
            BulletSharp.Math.Vector3[] vertices = CreateShape(shape, out indices);

            int vertexCount = vertices.Length / 2;
            int indexCount = (indices != null) ? indices.Length : vertexCount;
            bool index32 = indexCount > 65536;

            Mesh mesh = new Mesh(device, indexCount / 3, vertexCount,
                MeshFlags.SystemMemory | (index32 ? MeshFlags.Use32Bit : 0), VertexFormat.Position | VertexFormat.Normal);

            DataStream vertexBuffer = mesh.LockVertexBuffer(LockFlags.Discard);
            vertexBuffer.WriteRange(vertices);
            mesh.UnlockVertexBuffer();

            DataStream indexBuffer = mesh.LockIndexBuffer(LockFlags.Discard);
            if (index32)
            {
                if (indices == null)
                {
                    indices = new uint[indexCount];
                    uint i = 0;
                    while (i < indexCount)
                    {
                        indices[i] = i;
                        i++;
                    }
                }
                indexBuffer.WriteRange(indices);
            }
            else
            {
                ushort[] indices_s;
                if (indices == null)
                {
                    indices_s = new ushort[indexCount];
                    ushort i = 0;
                    while (i < indexCount)
                    {
                        indices_s[i] = i;
                        i++;
                    }
                }
                else
                {
                    indices_s = CompactIndexBuffer(indices);
                }
                indexBuffer.WriteRange(indices_s);
            }
            mesh.UnlockIndexBuffer();

            shapes.Add(shape, mesh);
            return mesh;
        }
開發者ID:rhynodegreat,項目名稱:BulletSharpPInvoke,代碼行數:55,代碼來源:MeshFactory.cs

示例7: CreateRigidBody

        public override RigidBody CreateRigidBody(bool isDynamic, float mass, Matrix startTransform, CollisionShape shape, string bodyName)
        {
            RigidBody body = base.CreateRigidBody(isDynamic, mass, startTransform, shape, bodyName);

            if (bodyName != null && bodyName.Equals("GroundName"))
                body.UserObject = "Ground";

            if (shape.ShapeType == BroadphaseNativeType.StaticPlaneShape)
                body.UserObject = "Ground";

            return body;
        }
開發者ID:rhynodegreat,項目名稱:BulletSharp,代碼行數:12,代碼來源:SerializeDemo.cs

示例8: Prop

        public Prop(CollisionShape shape, float mass, Matrix4 start)
        {
            Physics physics = Game.Instance.Physics;

            Shape = shape;
            IsDynamic = (mass != 0.0f);
            physics.Props.Add(this);
            Vector3 inertia = Vector3.Zero;
            if (IsDynamic) shape.CalculateLocalInertia(mass, out inertia);
            DefaultMotionState motionState = new DefaultMotionState(start);
            RigidBody.RigidBodyConstructionInfo info = new RigidBody.RigidBodyConstructionInfo(mass, motionState, shape, inertia);
            Body = new RigidBody(info);
            physics.World.AddRigidBody(Body);
        }
開發者ID:copygirl,項目名稱:Blocky,代碼行數:14,代碼來源:Prop.cs

示例9: CreateBody

 RigidBody CreateBody(float mass, CollisionShape shape, Vector3 offset)
 {
     using (var info = new RigidBodyConstructionInfo(mass, new DefaultMotionState(), shape, Vector3.Zero))
     {
         if (mass != 0.0f)
         {
             info.LocalInertia = info.CollisionShape.CalculateLocalInertia(mass);
         }
         var collisionObject = new RigidBody(info);
         collisionObject.Translate(offset);
         world.AddRigidBody(collisionObject);
         return collisionObject;
     }
 }
開發者ID:ruisebastiao,項目名稱:BulletSharp,代碼行數:14,代碼來源:TriangleMeshTest.cs

示例10: LocalCreateRigidBody

        protected RigidBody LocalCreateRigidBody(float mass, Matrix startTransform, CollisionShape shape)
        {
            bool isDynamic = (mass != 0.0f);

            Vector3 localInertia = Vector3.Zero;
            if (isDynamic)
                shape.CalculateLocalInertia(mass, out localInertia);

            DefaultMotionState myMotionState = new DefaultMotionState(startTransform);

            RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia);
            body = new RigidBody(rbInfo);
            
            return body;
        }
開發者ID:brunoduartec,項目名稱:port-ploobsengine,代碼行數:15,代碼來源:BulletPhysicObject.cs

示例11: CreateBody

        static RigidBody CreateBody(float mass, CollisionShape shape, Vector3 offset)
        {
            var constInfo = new RigidBodyConstructionInfo(mass, new DefaultMotionState(), shape, Vector3.Zero);
            if (mass != 0.0f)
            {
                constInfo.LocalInertia = constInfo.CollisionShape.CalculateLocalInertia(mass);
            }
            var collisionObject = new RigidBody(constInfo);
            collisionObject.Translate(offset);
            world.AddRigidBody(collisionObject);

            AddToDisposeQueue(constInfo);
            AddToDisposeQueue(constInfo.MotionState);
            AddToDisposeQueue(collisionObject);
            AddToDisposeQueue(shape);

            return collisionObject;
        }
開發者ID:sinkingsugar,項目名稱:BulletSharpPInvoke,代碼行數:18,代碼來源:Program.cs

示例12: LocalCreateRigidBody

        public virtual RigidBody LocalCreateRigidBody(float mass, Matrix startTransform, CollisionShape shape)
        {
            //rigidbody is dynamic if and only if mass is non zero, otherwise static
            bool isDynamic = (mass != 0.0f);

            Vector3 localInertia = Vector3.Zero;
            if (isDynamic)
                shape.CalculateLocalInertia(mass, out localInertia);

            //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
            DefaultMotionState myMotionState = new DefaultMotionState(startTransform);

            RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia);
            RigidBody body = new RigidBody(rbInfo);

            World.AddRigidBody(body);

            return body;
        }
開發者ID:rhynodegreat,項目名稱:BulletSharp,代碼行數:19,代碼來源:PhysicsContext.cs

示例13: CreateCube

        public static void CreateCube(CollisionShape cs, Mesh mesh)
        {
            BulletSharp.Math.Vector3 ext = ((BoxShape)cs).HalfExtentsWithMargin;
            float length = ext.X * 2f;
            float width = ext.Y * 2f;
            float height = ext.Z * 2f;

            UnityEngine.Vector3 p0 = new UnityEngine.Vector3(-length * .5f, -width * .5f, height * .5f);
            UnityEngine.Vector3 p1 = new UnityEngine.Vector3(length * .5f, -width * .5f, height * .5f);
            UnityEngine.Vector3 p2 = new UnityEngine.Vector3(length * .5f, -width * .5f, -height * .5f);
            UnityEngine.Vector3 p3 = new UnityEngine.Vector3(-length * .5f, -width * .5f, -height * .5f);

            UnityEngine.Vector3 p4 = new UnityEngine.Vector3(-length * .5f, width * .5f, height * .5f);
            UnityEngine.Vector3 p5 = new UnityEngine.Vector3(length * .5f, width * .5f, height * .5f);
            UnityEngine.Vector3 p6 = new UnityEngine.Vector3(length * .5f, width * .5f, -height * .5f);
            UnityEngine.Vector3 p7 = new UnityEngine.Vector3(-length * .5f, width * .5f, -height * .5f);

            MakeUnityCubeMesh(p0, p1, p2, p3, p4, p5, p6, p7, mesh);
        }
開發者ID:Cyberbanan,項目名稱:BulletSharpUnity3d,代碼行數:19,代碼來源:MeshFactory2.cs

示例14: LocalCreateRigidBody

        public override RigidBody LocalCreateRigidBody(float mass, Matrix startTransform, CollisionShape shape)
        {
            //rigidbody is dynamic if and only if mass is non zero, otherwise static
            bool isDynamic = (mass != 0.0f);

            Vector3 localInertia = Vector3.Zero;
            if (isDynamic)
                shape.CalculateLocalInertia(mass, out localInertia);

            //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects

            RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, null, shape, localInertia);
            RigidBody body = new RigidBody(rbInfo);
            rbInfo.Dispose();
            body.ContactProcessingThreshold = defaultContactProcessingThreshold;
            body.WorldTransform = startTransform;

            World.AddRigidBody(body);

            return body;
        }
開發者ID:RainsSoft,項目名稱:BulletSharpPInvoke,代碼行數:21,代碼來源:BenchmarkDemo.cs

示例15: CreateStack

        void CreateStack(CollisionShape boxShape, int size, float zPos)
        {
            Matrix trans;
            float mass = 1.0f;

            for (int i = 0; i < size; i++)
            {
                // This constructs a row, from left to right
                int rowSize = size - i;
                for (int j = 0; j < rowSize; j++)
                {
                    trans = Matrix.Translation(
                        -rowSize * CubeHalfExtents + CubeHalfExtents + j * 2.0f * CubeHalfExtents,
                        CubeHalfExtents + i * CubeHalfExtents * 2.0f,
                        zPos);

                    RigidBody body = LocalCreateRigidBody(mass, trans, boxShape);
                    body.ActivationState = ActivationState.IslandSleeping;
                }
            }
        }
開發者ID:rhynodegreat,項目名稱:BulletSharp,代碼行數:21,代碼來源:Physics.cs


注:本文中的BulletSharp.CollisionShape類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。