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


C# Vector3.ToBullet方法代码示例

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


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

示例1: lua_SetGravity

 public static void lua_SetGravity(float x, float y = 0, float z = 0)
 {
     var g = new Vector3(x, y, z);
     BtEngineDynamicsWorld.Gravity = g.ToBullet();
     ConsoleInfo.Instance.Printf("gravity = {0}", g.ToStringEx(round: 3));
 }
开发者ID:zdimension,项目名称:FreeRaider,代码行数:6,代码来源:Script.cs

示例2: lua_PushEntityBody

        public static void lua_PushEntityBody(int id, int bodyNumber, float hForce, float vForce, bool resetFlag)
        {
            var ent = EngineWorld.GetEntityByID((uint)id);
            // TODO: Add warning if null
            // TODO: Check bodyNumber > 0
            if (ent != null && bodyNumber < ent.Bf.BoneTags.Count && ent.Bt.BtBody[bodyNumber] != null &&
                ent.TypeFlags.HasFlag(ENTITY_TYPE.Dynamic))
            {
                var t = ent.Angles.X * RadPerDeg;

                var ang1 = (float) Math.Sin(t);
                var ang2 = (float) Math.Cos(t);

                var angle = new Vector3(-ang1 * hForce, ang2 * hForce, vForce);

                if (resetFlag)
                    ent.Bt.BtBody[bodyNumber].ClearForces();

                ent.Bt.BtBody[bodyNumber].LinearVelocity = angle.ToBullet();
                ent.Bt.BtBody[bodyNumber].AngularVelocity = (angle / 1024.0f).ToBullet();
            }
            else
            {
                ConsoleInfo.Instance.Warning(SYSWARN_CANT_APPLY_FORCE, id);
            }
        }
开发者ID:zdimension,项目名称:FreeRaider,代码行数:26,代码来源:Script.cs

示例3: Sector_AllowTraverse

        public static int Sector_AllowTraverse(RoomSector rs, float floor, EngineContainer container)
        {
            var f0 = rs.FloorCorners[0][2];
            if (rs.FloorCorners[1][2] != f0 || rs.FloorCorners[2][2] != f0 || rs.FloorCorners[3][2] != f0)
            {
                return 0x00;
            }

            if (Math.Abs(floor - f0) < 1.1f && rs.Ceiling - rs.Floor >= TR_METERING_SECTORSIZE)
            {
                return 0x01;
            }

            var cb = new BtEngineClosestRayResultCallback(container);
            var from = new Vector3(rs.Position.X, rs.Position.Y, floor + TR_METERING_SECTORSIZE * 0.5f);
            var to = new Vector3(rs.Position.X, rs.Position.Y, floor - TR_METERING_SECTORSIZE * 0.5f);
            BtEngineDynamicsWorld.RayTest(from.ToBullet(), to.ToBullet(), cb);
            if (cb.HasHit)
            {
                Vector3 v;
                Helper.SetInterpolate3(out v, from, to, cb.ClosestHitFraction);
                if (Math.Abs(v.Z - floor) < 1.1f)
                {
                    var cont = (EngineContainer) cb.CollisionObject.UserObject;
                    if (cont != null && cont.ObjectType == OBJECT_TYPE.Entity &&
                        ((Entity) cont.Object).TypeFlags.HasFlag(ENTITY_TYPE.TraverseFloor))
                    {
                        return 0x01;
                    }
                }
            }

            return 0x00;
        }
开发者ID:zdimension,项目名称:FreeRaider,代码行数:34,代码来源:CharacterController.cs

示例4: SetPosition

 public virtual void SetPosition(Vector3 position)
 {
     if (isInWorld)
     {
         BulletSharp.Math.Matrix newTrans = m_collisionObject.WorldTransform;
         newTrans.Origin = position.ToBullet();
         m_collisionObject.WorldTransform = newTrans;
         transform.position = position;
     } else
     {
         transform.position = position;
     }
 }
开发者ID:Cyberbanan,项目名称:BulletSharpUnity3d,代码行数:13,代码来源:BCollisionObject.cs

示例5: CreateFramesA_B

 // Object A has the constraint compontent and is constrainted to object B
 // The constraint frame is defined relative to A by three vectors.
 // This method calculates the frames A and B that need to be passed to bullet
 public bool CreateFramesA_B(UnityEngine.Vector3 forwardInA, UnityEngine.Vector3 upInA, UnityEngine.Vector3 constraintPivotInA, out BM.Matrix frameInA, out BM.Matrix frameInB, ref string errorMsg)
 {
     frameInA = BM.Matrix.Identity;
     if (!CreateFrame(forwardInA, upInA, constraintPivotInA, ref frameInA, ref errorMsg))
     {
         frameInB = BM.Matrix.Identity;
         return false;
     }
     BM.Vector4 x = frameInA.Row1;
     BM.Vector4 y = frameInA.Row2;
     BM.Vector4 z = frameInA.Row3;
     Vector3 xx = new Vector3(x.X, x.Y, x.Z);
     Vector3 yy = new Vector3(y.X, y.Y, y.Z);
     Vector3 zz = new Vector3(z.X, z.Y, z.Z);
     Quaternion q = transform.localRotation * Quaternion.Inverse(m_otherRigidBody.transform.localRotation);
     xx = q * xx;
     yy = q * yy;
     zz = q * zz;
     frameInB = BM.Matrix.Identity;
     frameInB.Row1 = new BM.Vector4(xx.ToBullet(), 0f);
     frameInB.Row2 = new BM.Vector4(yy.ToBullet(), 0f);
     frameInB.Row3 = new BM.Vector4(zz.ToBullet(), 0f);
     frameInB.Origin = m_otherRigidBody.transform.InverseTransformPoint(transform.TransformPoint(constraintPivotInA)).ToBullet();
     return true;
 }
开发者ID:Cyberbanan,项目名称:BulletSharpUnity3d,代码行数:28,代码来源:BTypedConstraint.cs


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