private List <ICollisionShape> BuildJenga()
        {
            List <ICollisionShape> objects = new List <ICollisionShape>();

            Vector3d position = new Vector3d(-8.0, 0.0, 0.0);

            string objName = "jenga.obj";

            GeometryProperties geom1 = GetObjectGeometry(objName, 1.0f);

            ShapeGeometry shapeGeometry = new ShapeGeometry(geom1.VertexPoint, geom1.TriagleIdx);

            ShapeFilename.Add(objName);
            ShapeScale.Add(1.0f);
            TextureFilename.Add("texture/woodbox.bmp");

            //var objects1 = new ConcaveShape(shapeGeometry, position, 1.0, false);
            //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
            //var objects1 = new ConvexShape(geom1.VertexPoint, position, 1.0);
            var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);

            objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 1.0));
            objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects1.SetRestitutionCoeff(0.1);
            objects1.SetDynamicFrictionCoeff(0.3);
            objects1.SetStaticFrictionCoeff(0.9);
            objects1.ExcludeFromCollisionDetection(false);
            objects1.SetErrorReductionParam(0.3);
            //position = position + shift;

            objects.Add(objects1);

            return(objects);
        }
        private List <ICollisionShape> BuildBridge()
        {
            List <ICollisionShape> objects = new List <ICollisionShape>();

            Vector3d position = new Vector3d(0.0, 0.0, 12.5);

            ShapeFilename.Add("cube.obj");
            ShapeScale.Add(1.5f);
            TextureFilename.Add("texture/woodbox.bmp");

            GeometryProperties geom1 = GetObjectGeometry("cube.obj", 1.5f);
            var objects_0            = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 0.0, true);

            objects_0.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 1.0));
            objects_0.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects_0.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects_0.SetRestitutionCoeff(0.1);
            objects_0.SetDynamicFrictionCoeff(0.4);
            objects_0.SetStaticFrictionCoeff(0.4);
            objects_0.ExcludeFromCollisionDetection(false);
            objects_0.SetErrorReductionParam(0.3);
            objects.Add(objects_0);

            position = new Vector3d(0.0, 1.2, 9.5);

            for (int i = 0; i < 9; i++)
            {
                ShapeFilename.Add("cube1.obj");
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");

                var geom      = GetObjectGeometry("cube1.obj", 1);
                var objects_1 = new ConvexShape(geom.VertexPoint, geom.TriagleIdx, position, 1.0, false);

                objects_1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
                objects_1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects_1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects_1.SetRestitutionCoeff(0.1);
                objects_1.SetDynamicFrictionCoeff(0.8);
                objects_1.SetStaticFrictionCoeff(0.9);
                objects_1.ExcludeFromCollisionDetection(false);
                objects_1.SetErrorReductionParam(0.3);
                objects.Add(objects_1);

                position = position - new Vector3d(0.0, 0.0, 2.5);
            }

            position = new Vector3d(0.0, 0.0, -13.5);
            ShapeFilename.Add("cube.obj");
            ShapeScale.Add(1.5f);
            TextureFilename.Add("texture/woodbox.bmp");

            geom1     = GetObjectGeometry("cube.obj", 1.5f);
            objects_0 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 0.0, true);

            objects_0.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 1.0));
            objects_0.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects_0.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects_0.SetRestitutionCoeff(0.1);
            objects_0.SetDynamicFrictionCoeff(0.4);
            objects_0.SetStaticFrictionCoeff(0.4);
            objects_0.ExcludeFromCollisionDetection(false);
            objects_0.SetErrorReductionParam(0.3);
            objects.Add(objects_0);


            return(objects);
        }
        private List <ICollisionShape> BuildBaseAndCarShapes()
        {
            List <ICollisionShape> objects = new List <ICollisionShape>();

            #region Terrain Base

            ShapeFilename.Add("cube1.obj");
            ShapeScale.Add(60);
            TextureFilename.Add("texture/woodbox.bmp");

            GeometryProperties geom0 = GetObjectGeometry(ShapeFilename[0], ShapeScale[0]);
            var objects0             = new ConvexShape(geom0.VertexPoint, geom0.TriagleIdx, new Vector3d(0.0, -4.0, 0.0), 0.0, true);
            objects0.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 1.0));
            objects0.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects0.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects0.SetRestitutionCoeff(0.1);
            objects0.SetDynamicFrictionCoeff(1.0);
            objects0.SetStaticFrictionCoeff(1.0);
            objects0.ExcludeFromCollisionDetection(false);
            objects0.SetErrorReductionParam(0.7);

            objects.Add(objects0);

            #endregion

            #region Dynamic Objects

            Vector3d position = new Vector3d(0.0, 5.6, 0.0);

            ShapeFilename.Add("cube2.obj");
            ShapeScale.Add(1);
            TextureFilename.Add("texture/woodbox.bmp");

            GeometryProperties geom1 = GetObjectGeometry("cube2.obj", 1);
            var objects_0            = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 100.0, false);

            objects_0.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
            objects_0.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects_0.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects_0.SetRestitutionCoeff(0.1);
            objects_0.SetDynamicFrictionCoeff(0.4);
            objects_0.SetStaticFrictionCoeff(0.3);
            objects_0.ExcludeFromCollisionDetection(false);
            objects_0.SetErrorReductionParam(0.5);
            objects.Add(objects_0);

            position = new Vector3d(-1.1, 5.1, -1.5);

            ShapeFilename.Add("wheel.obj");
            ShapeScale.Add(0.5f);
            TextureFilename.Add("texture/woodbox.bmp");

            geom1 = GetObjectGeometry("wheel.obj", 0.5f);
            var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);

            objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
            objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects1.SetRestitutionCoeff(0.1);
            objects1.SetDynamicFrictionCoeff(0.8);
            objects1.SetStaticFrictionCoeff(0.9);
            objects1.ExcludeFromCollisionDetection(false);
            objects1.SetErrorReductionParam(0.3);
            objects.Add(objects1);

            position = new Vector3d(1.1, 5.1, -1.5);

            ShapeFilename.Add("wheel.obj");
            ShapeScale.Add(0.5f);
            TextureFilename.Add("texture/woodbox.bmp");

            geom1    = GetObjectGeometry("wheel.obj", 0.5f);
            objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
            objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
            objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects1.SetRestitutionCoeff(0.1);
            objects1.SetDynamicFrictionCoeff(0.8);
            objects1.SetStaticFrictionCoeff(0.9);
            objects1.ExcludeFromCollisionDetection(false);
            objects1.SetErrorReductionParam(0.3);

            objects.Add(objects1);

            position = new Vector3d(1.1, 5.1, 1.5);

            ShapeFilename.Add("wheel.obj");
            ShapeScale.Add(0.5f);
            TextureFilename.Add("texture/woodbox.bmp");

            geom1    = GetObjectGeometry("wheel.obj", 0.5f);
            objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
            objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
            objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects1.SetRestitutionCoeff(0.1);
            objects1.SetDynamicFrictionCoeff(0.8);
            objects1.SetStaticFrictionCoeff(0.9);
            objects1.ExcludeFromCollisionDetection(false);
            objects1.SetErrorReductionParam(0.3);

            objects.Add(objects1);

            position = new Vector3d(-1.1, 5.1, 1.5);

            ShapeFilename.Add("wheel.obj");
            ShapeScale.Add(0.5f);
            TextureFilename.Add("texture/woodbox.bmp");

            geom1    = GetObjectGeometry("wheel.obj", 0.5f);
            objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
            objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
            objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects1.SetRestitutionCoeff(0.1);
            objects1.SetDynamicFrictionCoeff(0.8);
            objects1.SetStaticFrictionCoeff(0.9);
            objects1.ExcludeFromCollisionDetection(false);
            objects1.SetErrorReductionParam(0.3);

            objects.Add(objects1);

            #endregion

            return(objects);
        }
        private List <ICollisionShape> BuildStack()
        {
            List <ICollisionShape> objects = new List <ICollisionShape>();

            Vector3d shift = new Vector3d(0.0, 2.3, 0.0);

            Vector3d position = new Vector3d(8.0, 4.0, 0.0);
            string   objName  = "cube.obj";

            double[] mass = new double[] { 50, 20, 8, 3, 1 };

            GeometryProperties geom1 = GetObjectGeometry(objName, 1.0f);

            ShapeGeometry shapeGeometry = new ShapeGeometry(geom1.VertexPoint, geom1.TriagleIdx);

            //ShapeGeometry shapeGeometry = new ShapeGeometry(geom1.VertexPoint);

            for (int i = 0; i < 15; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1.0f);
                TextureFilename.Add("texture/woodbox.bmp");

                //var objects1 = new ConcaveShape(shapeGeometry, position, 1.0, false);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 1.0));
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }

            position = new Vector3d(11.0, 4.0, 0.0);

            for (int i = 0; i < 4; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");


                //GeometryProperties geom1 = GetObjectGeometry(objName, 1, 0.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
                //objects1.SetGeometry(geom1.VertexPoint, geom1.TriagleIdx);
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }

            position = new Vector3d(5.0, 1.7, 0.0);

            for (int i = 0; i < 4; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");


                //GeometryProperties geom1 = GetObjectGeometry(objName, 1, 0.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
                //objects1.SetGeometry(geom1.VertexPoint, geom1.TriagleIdx);
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }

            position = new Vector3d(5.0, 1.7, 3.0);

            for (int i = 0; i < 4; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");


                //GeometryProperties geom1 = GetObjectGeometry(objName, 1, 0.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
                //objects1.SetGeometry(geom1.VertexPoint, geom1.TriagleIdx);
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }

            position = new Vector3d(5.0, 1.7, -5.0);

            for (int i = 0; i < 4; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");


                //GeometryProperties geom1 = GetObjectGeometry(objName, 1, 0.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
                //objects1.SetGeometry(geom1.VertexPoint, geom1.TriagleIdx);
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }

            position = new Vector3d(5.0, 1.7, 8.0);

            for (int i = 0; i < 5; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");


                //GeometryProperties geom1 = GetObjectGeometry(objName, 1, 0.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
                //objects1.SetGeometry(geom1.VertexPoint, geom1.TriagleIdx);
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }


            position = new Vector3d(8.0, 1.7, -3.0);

            for (int i = 0; i < 10; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");


                //GeometryProperties geom1 = GetObjectGeometry(objName, 1, 0.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
                //objects1.SetGeometry(geom1.VertexPoint, geom1.TriagleIdx);
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }

            position = new Vector3d(8.0, 1.7, 3.0);

            for (int i = 0; i < 10; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");


                //GeometryProperties geom1 = GetObjectGeometry(objName, 1, 0.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
                //objects1.SetGeometry(geom1.VertexPoint, geom1.TriagleIdx);
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }

            return(objects);
        }
Ejemplo n.º 5
0
        private List <ICollisionShape> GetSimulationObjects()
        {
            List <ICollisionShape> objects = new List <ICollisionShape>();

            #region Terrain Base

            ShapeFilename.Add("cube1.obj");
            ShapeScale.Add(60);
            TextureFilename.Add("texture/woodbox.bmp");

            GeometryProperties geom0 = GetObjectGeometry(ShapeFilename[0], ShapeScale[0], 0.0);
            var objects0             = new ConvexShape(geom0.VertexPoint, geom0.TriagleIdx, new Vector3d(0.0, -2.0, 0.0), 0.0, true);
            objects0.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 1.0));
            objects0.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects0.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects0.SetRestitutionCoeff(0.1);
            objects0.SetDynamicFrictionCoeff(1.0);
            objects0.SetStaticFrictionCoeff(1.0);
            objects0.ExcludeFromCollisionDetection(false);
            objects0.SetErrorReductionParam(0.3);

            objects.Add(objects0);

            #endregion

            #region Dynamic Objects

            Vector3d shift    = new Vector3d(3.0, 0.0, 0.0);
            Vector3d position = new Vector3d(0.0, 7.0, 0.0);

            double[] mass = new double[] { 50, 20, 8, 3, 1 };


            ShapeFilename.Add("cube1.obj");
            ShapeScale.Add(10.0f);
            TextureFilename.Add("texture/woodbox.bmp");

            GeometryProperties geom1 = GetObjectGeometry("cube1.obj", 10.0f, 0.75);
            //var objects1 = new ConcaveShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0, true);
            var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 0.0, true);
            //var objects1 = new ConvexShape(geom1.VertexPoint, position, 1.0);
            objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 1.0));
            objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects1.SetRestitutionCoeff(0.01);
            objects1.SetDynamicFrictionCoeff(0.3);
            objects1.SetStaticFrictionCoeff(1.0);
            objects1.ExcludeFromCollisionDetection(false);
            objects1.SetErrorReductionParam(0.3);

            objects.Add(objects1);

            double[] friction = new double[] { 0.8, 0.6, 0.4, 0.2 };

            position = new Vector3d(-3.0, 13.50, -5.0);

            for (int i = 0; i < 4; i++)
            {
                ShapeFilename.Add("cube.obj");
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");


                geom1    = GetObjectGeometry("cube.obj", 1, 0.75);
                objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 1.0));
                //objects1.SetGeometry(geom1.VertexPoint, geom1.TriagleIdx);
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(friction[i]);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.5);
                position = position + shift;

                objects.Add(objects1);
            }



            #endregion

            return(objects);
        }
Ejemplo n.º 6
0
        private List <ICollisionShape> GetSimulationObjects()
        {
            List <ICollisionShape> objects = new List <ICollisionShape>();

            #region Terrain Base

            ShapeFilename.Add("cube1.obj");
            ShapeScale.Add(60);
            TextureFilename.Add("texture/woodbox.bmp");

            GeometryProperties geom0 = GetObjectGeometry(ShapeFilename[0], ShapeScale[0], 0.0);
            var objects0             = new ConvexShape(geom0.VertexPoint, geom0.TriagleIdx, new Vector3d(0.0, -2.0, 0.0), 0.0, true);
            objects0.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 1.0));
            objects0.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects0.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
            objects0.SetRestitutionCoeff(0.1);
            objects0.SetDynamicFrictionCoeff(1.0);
            objects0.SetStaticFrictionCoeff(1.0);
            objects0.ExcludeFromCollisionDetection(false);
            objects0.SetErrorReductionParam(0.3);

            objects.Add(objects0);

            #endregion

            #region Dynamic Objects

            Vector3d shift = new Vector3d(0.0, 2.3, 0.0);

            Vector3d position = new Vector3d(0.0, 4.0, 0.0);
            string   objName  = "cube.obj";

            double[] mass = new double[] { 50, 20, 8, 3, 1 };

            GeometryProperties geom1 = GetObjectGeometry(objName, 1.0f, 0.0);

            ShapeGeometry shapeGeometry = new ShapeGeometry(geom1.VertexPoint, geom1.TriagleIdx);
            //ShapeGeometry shapeGeometry = new ShapeGeometry(geom1.VertexPoint);

            for (int i = 0; i < 15; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1.0f);
                TextureFilename.Add("texture/woodbox.bmp");

                //var objects1 = new ConcaveShape(shapeGeometry, position, 1.0, false);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 1.0));
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }

            position = new Vector3d(3.0, 4.0, 0.0);

            for (int i = 0; i < 4; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");


                //GeometryProperties geom1 = GetObjectGeometry(objName, 1, 0.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
                //objects1.SetGeometry(geom1.VertexPoint, geom1.TriagleIdx);
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }

            position = new Vector3d(-3.0, 1.7, 0.0);

            for (int i = 0; i < 4; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");


                //GeometryProperties geom1 = GetObjectGeometry(objName, 1, 0.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
                //objects1.SetGeometry(geom1.VertexPoint, geom1.TriagleIdx);
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }

            position = new Vector3d(-3.0, 1.7, 3.0);

            for (int i = 0; i < 4; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");


                //GeometryProperties geom1 = GetObjectGeometry(objName, 1, 0.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
                //objects1.SetGeometry(geom1.VertexPoint, geom1.TriagleIdx);
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }

            position = new Vector3d(-3.0, 1.7, -5.0);

            for (int i = 0; i < 4; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");


                //GeometryProperties geom1 = GetObjectGeometry(objName, 1, 0.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
                //objects1.SetGeometry(geom1.VertexPoint, geom1.TriagleIdx);
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }

            position = new Vector3d(-3.0, 1.7, 8.0);

            for (int i = 0; i < 5; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");


                //GeometryProperties geom1 = GetObjectGeometry(objName, 1, 0.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
                //objects1.SetGeometry(geom1.VertexPoint, geom1.TriagleIdx);
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }


            position = new Vector3d(0.0, 1.7, -3.0);

            for (int i = 0; i < 10; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");


                //GeometryProperties geom1 = GetObjectGeometry(objName, 1, 0.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
                //objects1.SetGeometry(geom1.VertexPoint, geom1.TriagleIdx);
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }

            position = new Vector3d(0.0, 1.7, 3.0);

            for (int i = 0; i < 10; i++)
            {
                ShapeFilename.Add(objName);
                ShapeScale.Add(1);
                TextureFilename.Add("texture/woodbox.bmp");


                //GeometryProperties geom1 = GetObjectGeometry(objName, 1, 0.0);
                //var objects1 = new ConvexShape(geom1.VertexPoint, geom1.TriagleIdx, position, 1.0);
                var objects1 = new ConvexShape(shapeGeometry, position, 1.0, false);
                objects1.SetRotationStatus(new Quaternion(new Vector3d(0.0, 0.0, 0.0), 0.0));
                //objects1.SetGeometry(geom1.VertexPoint, geom1.TriagleIdx);
                objects1.SetLinearVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetAngularVelocity(new Vector3d(0.0, 0.0, 0.0));
                objects1.SetRestitutionCoeff(0.1);
                objects1.SetDynamicFrictionCoeff(0.3);
                objects1.SetStaticFrictionCoeff(0.9);
                objects1.ExcludeFromCollisionDetection(false);
                objects1.SetErrorReductionParam(0.3);
                position = position + shift;

                objects.Add(objects1);
            }


            //TextureFilename[3] = new string[1] { "texture/woodbox.bmp" };
            //TODO rimuovere
            //<ShapeFilename[3] = new string[1] { "torus.obj" };
            //ShapeScale[3] = new float[1] { 1 };

            //var objects3 = BuildSoftBody("torus.obj", 1, new Vector3(0.0, -1.5, 0.0));
            //         objects3.SetStaticFrictionCoeff(0.5);
            //         objects3.SetDynamicFrictionCoeff(0.5);
            //         objects3.SetRestitutionCoeff(0.5);
            //         objects3.SetRestoreCoeff(60.0);

            //         objects.Add(objects3);

            #endregion

            return(objects);
        }