using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using MikuMikuDance.XNA.Stages;
using Microsoft.Xna.Framework.Graphics;
using BulletX.BulletCollision.CollisionShapes;
using BulletX.LinerMath;
using BulletX.BulletDynamics.Dynamics;
using BulletX.BulletCollision.BroadphaseCollision;

namespace BulletTest
{
    class BoxObj : PhysicsObj
    {
        public BoxObj(Game game, IMMDCamera camera, Model model, btVector3 sideLengths,
            btTransform startTransform, DiscreteDynamicsWorld world)
            : base(game, camera, model)
        {
            //1. 衝突スキン作成
            collision = new BoxShape(sideLengths * 0.5f);
            // 2.	初期の位置と姿勢。
            IMotionState motionState = new DefaultMotionState(startTransform);
            //3.イナーシャの作成
            btVector3 localInertia;
            collision.calculateLocalInertia(1.0f, out localInertia);
            //4.剛体の作成
            RigidBodyConstructionInfo info = new RigidBodyConstructionInfo(1.0f, motionState, collision, localInertia);

            body = new RigidBody(info);
            body.setDamping(0.5f, 0.5f);
            body.Friction = 0.5f;
            //body.UserData = objCount++;
            body.Restitution = 0.5f;
            //5.ボディを有効化する
            world.addRigidBody(body, (short)CollisionFilterGroups.AllFilter, (short)CollisionFilterGroups.AllFilter);

            color = Vector3.One;
        }
    }
}