コード例 #1
0
        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
        [TestCase(7, 2, 5f, 5f, 32, 0f)] /* default hull parameters */
        public void GeomHullConvexDecomp(int maxDepthSplit,
                                         int maxDepthSplitForSimpleShapes,
                                         float concavityThresholdPercent,
                                         float volumeConservationThresholdPercent,
                                         int maxVertices,
                                         float maxSkinWidth)
        {
            // Setup the physics engine to use the C# version of convex decomp
            Dictionary <string, string> engineParams = new Dictionary <string, string>();

            engineParams.Add("MeshSculptedPrim", "true");           // ShouldMeshSculptedPrim
            engineParams.Add("ForceSimplePrimMeshing", "false");    // ShouldForceSimplePrimMeshing
            engineParams.Add("UseHullsForPhysicalObjects", "true"); // ShouldUseHullsForPhysicalObjects
            engineParams.Add("ShouldRemoveZeroWidthTriangles", "true");
            engineParams.Add("ShouldUseBulletHACD", "false");
            engineParams.Add("ShouldUseSingleConvexHullForPrims", "true");
            engineParams.Add("ShouldUseGImpactShapeForPrims", "false");
            engineParams.Add("ShouldUseAssetHulls", "true");

            engineParams.Add("CSHullMaxDepthSplit", maxDepthSplit.ToString());
            engineParams.Add("CSHullMaxDepthSplitForSimpleShapes", maxDepthSplitForSimpleShapes.ToString());
            engineParams.Add("CSHullConcavityThresholdPercent", concavityThresholdPercent.ToString());
            engineParams.Add("CSHullVolumeConservationThresholdPercent", volumeConservationThresholdPercent.ToString());
            engineParams.Add("CSHullMaxVertices", maxVertices.ToString());
            engineParams.Add("CSHullMaxSkinWidth", maxSkinWidth.ToString());

            PhysicsScene = BulletSimTestsUtil.CreateBasicPhysicsEngine(engineParams);

            PrimitiveBaseShape pbs;
            Vector3            pos;
            Vector3            size;
            Quaternion         rot;
            bool isPhys;

            // Cylinder
            pbs   = PrimitiveBaseShape.CreateCylinder();
            pos   = new Vector3(100.0f, 100.0f, 0f);
            pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 10f;
            ObjectInitPosition = pos;
            size      = new Vector3(2f, 2f, 2f);
            pbs.Scale = size;
            rot       = Quaternion.Identity;
            isPhys    = true;
            uint cylinderLocalID = 123;

            PhysicsScene.AddPrimShape("testCylinder", pbs, pos, size, rot, isPhys, cylinderLocalID);
            BSPrim primTypeCylinder = (BSPrim)PhysicsScene.PhysObjects[cylinderLocalID];

            // Hollow Cylinder
            pbs = PrimitiveBaseShape.CreateCylinder();
            pbs.ProfileHollow = (ushort)(0.70f * 50000);
            pos   = new Vector3(110.0f, 110.0f, 0f);
            pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 10f;
            ObjectInitPosition = pos;
            size      = new Vector3(2f, 2f, 2f);
            pbs.Scale = size;
            rot       = Quaternion.Identity;
            isPhys    = true;
            uint hollowCylinderLocalID = 124;

            PhysicsScene.AddPrimShape("testHollowCylinder", pbs, pos, size, rot, isPhys, hollowCylinderLocalID);
            BSPrim primTypeHollowCylinder = (BSPrim)PhysicsScene.PhysObjects[hollowCylinderLocalID];

            // Torus
            // ProfileCurve = Circle, PathCurve = Curve1
            pbs = PrimitiveBaseShape.CreateSphere();
            pbs.ProfileShape = (byte)ProfileShape.Circle;
            pbs.PathCurve    = (byte)Extrusion.Curve1;
            pbs.PathScaleX   = 100; // default hollow info as set in the viewer
            pbs.PathScaleY   = (int)(.25f / 0.01f) + 200;
            pos   = new Vector3(120.0f, 120.0f, 0f);
            pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 10f;
            ObjectInitPosition = pos;
            size      = new Vector3(2f, 4f, 4f);
            pbs.Scale = size;
            rot       = Quaternion.Identity;
            isPhys    = true;
            uint torusLocalID = 125;

            PhysicsScene.AddPrimShape("testTorus", pbs, pos, size, rot, isPhys, torusLocalID);
            BSPrim primTypeTorus = (BSPrim)PhysicsScene.PhysObjects[torusLocalID];

            // The actual prim shape creation happens at taint time
            PhysicsScene.ProcessTaints();

            // Check out the created hull shapes and report their characteristics
            ReportShapeGeom(primTypeCylinder);
            ReportShapeGeom(primTypeHollowCylinder);
            ReportShapeGeom(primTypeTorus);
        }