• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BulletSharp.CollisionShape类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



CollisionShape类属于BulletSharp命名空间,在下文中一共展示了CollisionShape类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: CreateShape

 public static Vector3[] CreateShape(CollisionShape shape, out uint[] indices)
 {
     switch (shape.ShapeType)
     {
         case BroadphaseNativeType.BoxShape:
             indices = null;
             return CreateBox(shape as BoxShape);
         case BroadphaseNativeType.Box2DShape:
             indices = null;
             return CreateBox2DShape(shape as Box2DShape);
         case BroadphaseNativeType.CapsuleShape:
             return CreateCapsule(shape as CapsuleShape, out indices);
         case BroadphaseNativeType.Convex2DShape:
             return CreateShape((shape as Convex2DShape).ChildShape, out indices);
         case BroadphaseNativeType.ConvexHullShape:
             indices = null;
             return CreateConvexHull(shape as ConvexHullShape);
         case BroadphaseNativeType.ConeShape:
             return CreateCone(shape as ConeShape, out indices);
         case BroadphaseNativeType.CylinderShape:
             return CreateCylinder(shape as CylinderShape, out indices);
         case BroadphaseNativeType.GImpactShape:
             indices = null;
             return CreateTriangleMesh((shape as GImpactMeshShape).MeshInterface);
         case BroadphaseNativeType.MultiSphereShape:
             return CreateMultiSphere(shape as MultiSphereShape, out indices);
         case BroadphaseNativeType.SphereShape:
             return CreateSphere(shape as SphereShape, out indices);
         case BroadphaseNativeType.StaticPlaneShape:
             return CreateStaticPlane(shape as StaticPlaneShape, out indices);
         case BroadphaseNativeType.TriangleMeshShape:
             indices = null;
             return CreateTriangleMesh((shape as TriangleMeshShape).MeshInterface);
     }
     if (shape is PolyhedralConvexShape)
     {
         return CreatePolyhedralConvexShape((shape as PolyhedralConvexShape), out indices);
     }
     throw new NotImplementedException();
 }
开发者ID:sinkingsugar,项目名称:BulletSharpPInvoke,代码行数:40,代码来源:MeshFactory.cs


示例17: CreateShape

        ShapeData CreateShape(CollisionShape shape)
        {
            ShapeData shapeData = new ShapeData();
            uint[] indices;
            Vector3[] vertices = CreateShape(shape, out indices);
            shapeData.VertexCount = vertices.Length / 2;
            shapeData.SetVertexBuffer(device, vertices);

            if (indices != null)
            {
                shapeData.IndexCount = indices.Length;
                ushort[] indices_s = CompactIndexBuffer(indices);
                if (indices_s != null)
                {
                    shapeData.SetIndexBuffer(device, indices_s);
                }
                else
                {
                    shapeData.SetIndexBuffer(device, indices);
                }
            }

            return shapeData;
        }
开发者ID:raiker,项目名称:BulletSharp,代码行数:24,代码来源:MeshFactory.cs


示例18: InitSoftBodyInstance

        void InitSoftBodyInstance(SoftBody softBody, CollisionShape shape)
        {
            var shapeData = InitShapeData(shape);
            shapeData.Instances.Add(new InstanceData()
            {
                WorldTransform = Matrix.Identity,
                Color = softBodyColor
            });

            UpdateSoftBody(softBody, shapeData);
        }
开发者ID:rhynodegreat,项目名称:BulletSharp,代码行数:11,代码来源:MeshFactory.cs


示例19: 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


示例20: InitShapeData

        ShapeData InitShapeData(CollisionShape shape)
        {
            ShapeData shapeData;

            if (shapes.TryGetValue(shape, out shapeData) == false)
            {
                if (shape.ShapeType == BroadphaseNativeType.SoftBodyShape)
                {
                    shapeData = new ShapeData();
                }
                else
                {
                    shapeData = CreateShape(shape);
                }

                // Create an initial instance data buffer for a single instance
                instanceDataDesc.SizeInBytes = InstanceData.SizeInBytes;
                shapeData.InstanceDataBuffer = new Buffer(device, instanceDataDesc);
                shapeData.BufferBindings[1] = new VertexBufferBinding(shapeData.InstanceDataBuffer, instanceDataDesc.SizeInBytes, 0);

                shapes.Add(shape, shapeData);
            }

            return shapeData;
        }
开发者ID:rhynodegreat,项目名称:BulletSharp,代码行数:25,代码来源:MeshFactory.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BulletSharp.DefaultCollisionConfiguration类代码示例发布时间:2022-05-24
下一篇:
C# BulletSharp.CollisionObjectWrapper类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap