예제 #1
0
        protected override void OnInitializePhysics()
        {
            // collision configuration contains default setup for memory, collision setup
            CollisionConf = new SoftBodyRigidBodyCollisionConfiguration();
            Dispatcher    = new CollisionDispatcher(CollisionConf);

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

            // the default constraint solver.
            Solver = new SequentialImpulseConstraintSolver();

            softBodyWorldInfo = new SoftBodyWorldInfo
            {
                AirDensity   = 1.2f,
                WaterDensity = 0,
                WaterOffset  = 0,
                WaterNormal  = Vector3.Zero,
                Gravity      = new Vector3(0, -10, 0),
                Dispatcher   = Dispatcher,
                Broadphase   = Broadphase
            };
            softBodyWorldInfo.SparseSdf.Initialize();

            World         = new SoftRigidDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf);
            World.Gravity = new Vector3(0, -10, 0);
            World.DispatchInfo.EnableSpu = true;

            World.SetInternalTickCallback(PickingPreTickCallback, this, true);

            InitializeDemo();
        }
예제 #2
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public Physics()
        {
            DantzigSolver mlcp = new DantzigSolver();

            collisionConf = new SoftBodyRigidBodyCollisionConfiguration();
            dispatcher    = new CollisionDispatcher(new DefaultCollisionConfiguration());
            solver        = new DefaultSoftBodySolver();
            ConstraintSolver cSolver = new MultiBodyConstraintSolver();

            broadphase = new DbvtBroadphase();
            World      = new SoftRigidDynamicsWorld(dispatcher, broadphase, cSolver, collisionConf, solver);

            //Actual scaling is unknown, this gravity is probably not right
            World.Gravity = new Vector3(0, -98.1f, 0);
            World.SetInternalTickCallback(new DynamicsWorld.InternalTickCallback((w, f) => DriveJoints.UpdateAllMotors(Skeleton, cachedArgs)));

            //Roobit
            RigidNode_Base.NODE_FACTORY = (Guid guid) => new BulletRigidNode(guid);
            string RobotPath = @"C:\Program Files (x86)\Autodesk\Synthesis\Synthesis\Robots\";
            string dir       = RobotPath;

            GetFromDirectory(RobotPath, s => { Skeleton = (BulletRigidNode)BXDJSkeleton.ReadSkeleton(s + "skeleton.bxdj"); dir = s; });
            List <RigidNode_Base> nodes = Skeleton.ListAllNodes();

            for (int i = 0; i < nodes.Count; i++)
            {
                BulletRigidNode bNode = (BulletRigidNode)nodes[i];
                bNode.CreateRigidBody(dir + bNode.ModelFileName);
                bNode.CreateJoint();

                if (bNode.joint != null)
                {
                    World.AddConstraint(bNode.joint, true);
                }
                World.AddCollisionObject(bNode.BulletObject);
                collisionShapes.Add(bNode.BulletObject.CollisionShape);
            }

            //Field
            string fieldPath = @"C:\Program Files (x86)\Autodesk\Synthesis\Synthesis\Fields\";

            GetFromDirectory(fieldPath, s => f = BulletFieldDefinition.FromFile(s));

            foreach (RigidBody b in f.Bodies)
            {
                World.AddRigidBody(b);
                collisionShapes.Add(b.CollisionShape);
            }
        }