Exemple #1
0
        //--------------------Constructors--------------------//
        public Bullet(Vector3 startingPosition, Vector3 velocity, Vector3 normal) :
            base(startingPosition, Vector3.Zero, velocity, 0)
        {
            this.position = startingPosition;
            this.velocity = velocity * SHOOTING_POWER;

            Forward = -Vector3.Normalize(velocity);
            Up      = normal;
            Right   = Vector3.Cross(Up, Forward);

            this.rotationMatrix.Forward = Forward;
            this.rotationMatrix.Up      = Up;
            this.rotationMatrix.Right   = Right;

            boundingBox = OBB.CreateFromSphere(bulletModel.Meshes[0].BoundingSphere, startingPosition, BULLET_SCALE, rotationMatrix);
        }
Exemple #2
0
        //--------------------Functions--------------------//

        //Loads
        internal void LoadModelBones(ContentManager content, Material material, Light light)
        {
            shootSoundFX         = content.Load <SoundEffect>("pimba").CreateInstance();
            shootSoundFX.Volume  = 0.5f;
            turnSoundFX          = content.Load <SoundEffect>("girar_torres").CreateInstance();
            turnSoundFX.IsLooped = true;
            turnSoundFX.Volume   = 1f;

            leftDirt  = new ParticleSystem(ParticleType.Smoke, this.position + leftDirtOffset, new ParticleSpawner(0.01f, true), content, 250, 500, 5);
            rightDirt = new ParticleSystem(ParticleType.Smoke, this.position + rightDirtOffset, new ParticleSpawner(0.01f, true), content, 250, 500, 5);

            leftSmoke  = new ParticleSystem(ParticleType.Smoke, this.position + leftSmokeOffset, new ParticleSpawner(0.01f, true), content, 250, 400, 5);
            rightSmoke = new ParticleSystem(ParticleType.Smoke, this.position + rightSmokeOffset, new ParticleSpawner(0.01f, true), content, 250, 400, 5);

            tankModel   = content.Load <Model>("tank");
            boundingBox = OBB.CreateFromSphere(tankModel.Root.Meshes[0].BoundingSphere, this.position, modelScale, this.rotationMatrix);

            this.cannonBone    = tankModel.Bones["canon_geo"];
            cannon             = new Bone(cannonBone.Transform, this.position, Vector3.Zero, modelScale);
            cannon.boundingBox = OBB.CreateFromSphere(cannonBone.Meshes[0].BoundingSphere, cannon.position, modelScale, this.rotationMatrix);
            //TODO: FIX CANNON's BOUNDING BOX

            this.turretBone    = tankModel.Bones["turret_geo"];
            turret             = new Bone(turretBone.Transform, this.position, Vector3.Zero, modelScale);
            turret.boundingBox = OBB.CreateFromSphere(turretBone.Meshes[0].BoundingSphere, turret.position, modelScale, this.rotationMatrix);

            this.hatchBone      = tankModel.Bones["hatch_geo"];
            this.hatchTransform = hatchBone.Transform;

            this.rightSteerBone      = tankModel.Bones["r_steer_geo"];
            this.rightSteerTransform = rightSteerBone.Transform;

            this.leftSteerBone      = tankModel.Bones["l_steer_geo"];
            this.leftSteerTransform = leftSteerBone.Transform;

            this.rightFrontWheelBone      = tankModel.Bones["r_front_wheel_geo"];
            this.rightFrontWheelTransform = rightFrontWheelBone.Transform;

            this.leftFrontWheelBone      = tankModel.Bones["l_front_wheel_geo"];
            this.leftFrontWheelTransform = leftFrontWheelBone.Transform;

            this.rightBackWheelBone      = tankModel.Bones["r_back_wheel_geo"];
            this.rightBackWheelTransform = rightBackWheelBone.Transform;

            this.leftBackWheelBone      = tankModel.Bones["l_back_wheel_geo"];
            this.leftBackWheelTransform = leftBackWheelBone.Transform;

            this.boneTransformations = new Matrix[tankModel.Bones.Count];

            foreach (ModelMesh mesh in tankModel.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    //Material
                    effect.AmbientLightColor      = material.AmbientColor;
                    effect.DiffuseColor           = material.DiffuseColor;
                    effect.SpecularColor          = material.SpecularColor;
                    effect.SpecularPower          = material.SpecularPower;
                    effect.PreferPerPixelLighting = true;

                    //Light
                    effect.LightingEnabled                 = true;
                    effect.DirectionalLight0.Enabled       = true;
                    effect.DirectionalLight0.DiffuseColor  = light.DiffuseColor;
                    effect.DirectionalLight0.SpecularColor = light.SpecularColor;
                    effect.DirectionalLight0.Direction     = light.Direction;
                }
            }
        }