Beispiel #1
0
        public override void InitData(SimulatorData data)
        {
            base.InitData(data);

            // Create ODE world.
            //world = new World();
            world = Tao.Ode.Ode.dWorldCreate();

            // Set default gravity.
            Gravity = Defaults.Gravity;

            // Create the root ODE space.
            if (data.UseOctreeInsteadHash)
            {
                //space = new QuadTreeSpace(data.worldCenter, data.worldSize, data.octreeDepth);
                space = Tao.Ode.Ode.dQuadTreeSpaceCreate(IntPtr.Zero, OdeHelper.ToOdeVector3(data.WorldCenter), OdeHelper.ToOdeVector3(data.WorldSize), data.OctreeDepth);
            }
            else
            {
                space = Tao.Ode.Ode.dHashSpaceCreate(IntPtr.Zero);
                Tao.Ode.Ode.dHashSpaceSetLevels(space, data.HashMinLevel, data.HashMaxLevel);                 // (KleMiX) ...
            }

            //space.Collider = OdeHelper.CollisionCallback;

            rootSpace = new OdeSpace(space);

            // Create the ODE contact joint group.
            //contactJointGroup = new ODE.Joints.JointGroup();
            contactJointGroup = Tao.Ode.Ode.dJointGroupCreate(0);

            // Set the ODE global CFM value that will be used by all Joints
            // (including contacts).  This affects normal Joint constraint
            // operation and Joint limits.  The user cannot adjust CFM, but
            // they can adjust ERP (a.k.a. bounciness/restitution) for materials
            // (i.e. contact settings) and Joint limits.
            //dWorldSetCFM( mWorldID, Defaults.Ode.globalCFM );
            //world.CFM = Defaults.Ode.globalCFM;
            Tao.Ode.Ode.dWorldSetCFM(world, Defaults.Ode.GlobalCFM);

            // Set the ODE global ERP value.  This will only be used for Joints
            // under normal conditions, not at their limits.  Also, it will not
            // affect contacts at all since they use material properties to
            // calculate ERP.
            //dWorldSetERP( mWorldID, ( real ) 0.5 * ( defaults::ode::maxERP +defaults::ode::minERP ) );
            //world.ERP = 0.5f * (Defaults.Ode.maxERP + Defaults.Ode.minERP);
            Tao.Ode.Ode.dWorldSetERP(world, 0.5f * (Defaults.Ode.MaxERP + Defaults.Ode.MinERP));
            Tao.Ode.Ode.dWorldSetContactSurfaceLayer(world, Defaults.Ode.SurfaceLayer);

            SolverAccuracy = Defaults.SolverAccuracy;
            collisionCount = 0;
            // "mRaycastResult" is initialized in its own constructor.
            sensorSolid     = null;
            rayContactGroup = Defaults.Shape.ContactGroup;
        }
Beispiel #2
0
        public override SpaceBase CreateSpace()
        {
            OdeSpace newSpace = new OdeSpace();

            // Add this new Space as a child of the Simulator's root Space.
            //space.Add((ODE.Geoms.Geom)newSpace.InternalGetSpaceID());
            Tao.Ode.Ode.dSpaceAdd(space, newSpace.InternalGetSpaceID());

            AddSpace(newSpace);
            return(newSpace);
        }