Ejemplo n.º 1
0
        public virtual void InitializePhysics()
        {
#if BULLETSHARP
            BulletSharpPhysicsComponent bulletPys = new BulletSharpPhysicsComponent(this);
#endif
#if BULLETXNA
            BulletXNAPhysicsComponent bulletPysXNA = new BulletXNAPhysicsComponent(this);
#endif
#if JITTER
            JitterPhysicsComponent jitterPhysics = new JitterPhysicsComponent(this);
#endif
        }
        public virtual void InitializePhysics()
        {
#if BULLETSHARP
            BulletSharpPhysicsComponent bulletPys = new BulletSharpPhysicsComponent(this);
#endif
#if BULLETXNA
            BulletXNAPhysicsComponent bulletPysXNA = new BulletXNAPhysicsComponent(this);
#endif
#if JITTER
            JitterPhysicsComponent jitterPhysics = new JitterPhysicsComponent(this);  
#endif
        
        }
Ejemplo n.º 3
0
        public void InitializePhysicsJitter()
        {
#if JITTER
            if (jitterPhysics == null)
            {
                JitterPhysicsComponent jitterPhysics2 = new JitterPhysicsComponent(this);
            }


            JitterObject ball = new JitterObject(this, "Models/Sphere");
            ball.Shape = new Jitter.Collision.Shapes.SphereShape(1f);
            ball.SetUpBulletPhysicsBody();
            ball.TranslateAA(camera.Position + new Vector3(0, 10, -5));
            ball.TextureMaterials.Add("Textures/core1");
            ball.NormalMaterials.Add("Textures/core1Normal");
            Components.Add(ball);

            // create a few dynamic rigidbodies
            float mass = 1.0f;

            Jitter.Collision.Shapes.BoxShape colShape = new Jitter.Collision.Shapes.BoxShape(Jitter.LinearMath.JVector.One);


            float start_x = StartPosX - ArraySizeX / 2;
            float start_y = StartPosY;
            float start_z = StartPosZ - ArraySizeZ / 2;

            start_z -= 8;
            Random rnd = new Random();

            int k, i, j;
            for (k = 0; k < ArraySizeY; k++)
            {
                for (i = 0; i < ArraySizeX; i++)
                {
                    for (j = 0; j < ArraySizeZ; j++)
                    {
                        Matrix startTransform = Matrix.CreateTranslation(
                            2 * i + start_x,
                            2 * k + start_y,
                            2 * j + start_z
                        );

                        // using motionstate is recommended, it provides interpolation capabilities
                        // and only synchronizes 'active' objects
                        JitterObject box = new JitterObject(this, "Models/Box");
                        box.Shape = new Jitter.Collision.Shapes.BoxShape(Jitter.LinearMath.JVector.One);
                        box.SetUpBulletPhysicsBody();
                        box.Position = startTransform.Translation;

                        box.TextureMaterials.Add("Textures/BoxColor");
                        box.NormalMaterials.Add("Textures/BoxNormal");
                        
                        box.TranslateAA(new Vector3(0, 7, 0));
                        Components.Add(box);
                    }
                }
            }

            start_x -= 8;

            for (k = 0; k < 2; k++)
            {
                for (i = 0; i < 2; i++)
                {
                    for (j = 0; j < 2; j++)
                    {
                        Matrix startTransform = Matrix.CreateTranslation(
                            2 * i + start_x,
                            2 * k + start_y,
                            2 * j + start_z
                        );

                        // using motionstate is recommended, it provides interpolation capabilities
                        // and only synchronizes 'active' objects
                        JitterObject box = new JitterObject(this, "Models/Box");
                        box.Shape = new Jitter.Collision.Shapes.BoxShape(Jitter.LinearMath.JVector.One);
                        box.SetUpBulletPhysicsBody();
                        box.Position = startTransform.Translation;
                        box.TextureMaterials.Add("Textures/BoxColor01");
                        box.NormalMaterials.Add("Textures/BoxNormal01");
                        
                        box.TranslateAA(new Vector3(0, 7, 0));
                        Components.Add(box);
                    }
                }
            }
            IsPhysicsEnabled = false;
#endif
        }