Example #1
0
        /// <summary>
        /// set all effect parameters and process the model's effect.
        /// </summary>
        void OnEffectProcess(object sender, GameModel.RenderingCustomEffectEventArgs e) 
        {
            RenderLighting lighting = e.RenderTracer.Lighting;

            e.Effect.Parameters["LightColor"].SetValue(
                                            lighting.diffuseColor.ToVector4());

            e.Effect.Parameters["AmbientLightColor"].SetValue(
                                            lighting.ambientColor.ToVector4());

            e.Effect.Parameters["Shininess"].SetValue(1.0f);

            e.Effect.Parameters["SpecularPower"].SetValue(12.0f);

            e.Effect.Parameters["EnvironmentMap"].SetValue(
                RobotGameGame.CurrentGameLevel.GameWorld.TextureCubeMap);

            e.Effect.Parameters["World"].SetValue(e.World);

            e.Effect.Parameters["View"].SetValue(e.RenderTracer.View);

            e.Effect.Parameters["Projection"].SetValue(e.RenderTracer.Projection);

            e.Effect.Parameters["LightPosition"].SetValue(
                                    Vector3.Negate(lighting.direction) * 1000);
        }
Example #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public GameWeapon(GameWeaponSpec spec)
        {
            this.specData = spec;

            //  model
            if (spec.ModelAlone )
            {
                modelWeapon = new GameModel[spec.ModelCount];
                indexWeaponFireDummy = new int[spec.ModelCount];
                indexWeaponAttachDummy = new int[spec.ModelCount];

                //  Find bones
                for (int i = 0; i < spec.ModelCount; i++ )
                {
                    modelWeapon[i] = new GameModel(spec.ModelFilePath);
                    modelWeapon[i].Name = spec.ModelFilePath;

                    for (int j = 0; j < modelWeapon[i].ModelData.model.Bones.Count; j++)
                    {
                        ModelBone bone = modelWeapon[i].ModelData.model.Bones[j];

                        //  Gun muzzule bone
                        if (bone.Name == spec.MuzzleBone)
                            indexWeaponFireDummy[i] = bone.Index;

                        //  Gun attach bone to character
                        if (bone.Name == spec.AttachBone)
                            indexWeaponAttachDummy[i] = bone.Index;
                    }
                }

                //  Apply NormalMap and SpeculaMap to only player's machine gun
                if (this.WeaponType == WeaponType.PlayerMachineGun)
                {
                    for (int i = 0; i < spec.ModelCount; i++)
                    {
                        modelWeapon[i].RenderingCustomEffect +=
                            new EventHandler<GameModel.RenderingCustomEffectEventArgs>(
                            OnEffectProcess);
                    }
                }
            }

            Reset();
        }