public void Init()
        {
            Dictionary <string, string> engineParams = new Dictionary <string, string>();

            engineParams.Add("VehicleEnableAngularVerticalAttraction", "true");
            engineParams.Add("VehicleAngularVerticalAttractionAlgorithm", "1");
            PhysicsScene = BulletSimTestsUtil.CreateBasicPhysicsEngine(engineParams);

            PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateSphere();
            Vector3            pos = new Vector3(100.0f, 100.0f, 0f);

            pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 2f;
            TestVehicleInitPosition = pos;
            Vector3 size = new Vector3(1f, 1f, 1f);

            pbs.Scale = size;
            Quaternion rot     = Quaternion.Identity;
            bool       isPhys  = false;
            uint       localID = 123;

            PhysicsScene.AddPrimShape("testPrim", pbs, pos, size, rot, isPhys, localID);
            TestVehicle = (BSPrim)PhysicsScene.PhysObjects[localID];
            // The actual prim shape creation happens at taint time
            PhysicsScene.ProcessTaints();
        }
示例#2
0
        public void CreateAndDropPhysicalCube()
        {
            PrimitiveBaseShape newcube  = PrimitiveBaseShape.CreateBox();
            Vector3            position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f);
            Vector3            size     = new Vector3(0.5f, 0.5f, 0.5f);
            Quaternion         rot      = Quaternion.Identity;
            PhysicsActor       prim     = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true);
            OdePrim            oprim    = (OdePrim)prim;
            OdeScene           pscene   = (OdeScene)ps;

            Assert.That(oprim.m_taintadd);

            prim.LocalID = 5;

            for (int i = 0; i < 58; i++)
            {
                ps.Simulate(0.133f);

                Assert.That(oprim.prim_geom != (IntPtr)0);

                Assert.That(oprim.m_targetSpace != (IntPtr)0);

                //Assert.That(oprim.m_targetSpace == pscene.space);
                m_log.Info("TargetSpace: " + oprim.m_targetSpace + " - SceneMainSpace: " + pscene.space);

                Assert.That(!oprim.m_taintadd);
                m_log.Info("Prim Position (" + oprim.m_localID + "): " + prim.Position.ToString());

                // Make sure we're above the ground
                //Assert.That(prim.Position.Z > 20f);
                //m_log.Info("PrimCollisionScore (" + oprim.m_localID + "): " + oprim.m_collisionscore);

                // Make sure we've got a Body
                Assert.That(oprim.Body != (IntPtr)0);
                //m_log.Info(
            }

            // Make sure we're not somewhere above the ground
            Assert.That(prim.Position.Z < 21.5f);

            ps.RemovePrim(prim);
            Assert.That(oprim.m_taintremove);
            ps.Simulate(0.133f);
            Assert.That(oprim.Body == (IntPtr)0);
        }