예제 #1
0
        public void InitJetpackThrusts(MyCharacterDefinition definition)
        {
            m_jetpackThrusts.Clear();

            if (definition.Jetpack == null)
            {
                return;
            }

            foreach (var thrustDefinition in definition.Jetpack.Thrusts)
            {
                int index;
                var thrustBone = m_skinnedEntity.AnimationController.FindBone(thrustDefinition.ThrustBone, out index);
                if (thrustBone == null)
                {
                    continue;
                }

                InitJetpackThrust(index, Vector3.Forward, thrustDefinition.SideFlameOffset, ref definition.Jetpack.ThrustProperties);     // UP is now in -Z
                InitJetpackThrust(index, Vector3.Left, thrustDefinition.SideFlameOffset, ref definition.Jetpack.ThrustProperties);
                InitJetpackThrust(index, Vector3.Right, thrustDefinition.SideFlameOffset, ref definition.Jetpack.ThrustProperties);
                InitJetpackThrust(index, Vector3.Backward, thrustDefinition.SideFlameOffset, ref definition.Jetpack.ThrustProperties); // DOWN is now in Z
                InitJetpackThrust(index, Vector3.Up, thrustDefinition.FrontFlameOffset, ref definition.Jetpack.ThrustProperties);      // FORWARD is now in Y
            }
        }
        public void InitLight(MyCharacterDefinition definition)
        {
            m_light = MyLights.AddLight();

            m_light.Start(MyLight.LightTypeEnum.PointLight | MyLight.LightTypeEnum.Spotlight, 0.5f);

            /// todo: defaults should be supplied from Environemnt.sbc
            m_light.GlossFactor        = 0;
            m_light.DiffuseFactor      = 3.14f;
            m_light.UseInForwardRender = true;
            m_light.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
            m_light.ShadowDistance     = 20;
            m_light.ReflectorFalloff   = 10;

            m_light.ReflectorTexture         = "Textures\\Lights\\dual_reflector_2.dds";
            m_light.ReflectorColor           = MyCharacter.REFLECTOR_COLOR;
            m_light.ReflectorConeMaxAngleCos = MyCharacter.REFLECTOR_CONE_ANGLE;
            m_light.ReflectorRange           = MyCharacter.REFLECTOR_RANGE;
            m_light.ReflectorGlossFactor     = MyCharacter.REFLECTOR_GLOSS_FACTOR;
            m_light.ReflectorDiffuseFactor   = MyCharacter.REFLECTOR_DIFFUSE_FACTOR;
            m_light.Color         = MyCharacter.POINT_COLOR;
            m_light.SpecularColor = new Vector3(MyCharacter.POINT_COLOR_SPECULAR);
            m_light.Range         = MyCharacter.POINT_LIGHT_RANGE;

            m_skinnedEntity.AnimationController.FindBone(definition.LeftLightBone, out m_leftLightIndex);

            m_skinnedEntity.AnimationController.FindBone(definition.RightLightBone, out m_rightLightIndex);
        }
예제 #3
0
        public void InitLight(MyCharacterDefinition definition)
        {
            m_light = MyLights.AddLight();

            m_lightGlareSize = definition.LightGlareSize;

            m_light.Start(MyLight.LightTypeEnum.PointLight | MyLight.LightTypeEnum.Spotlight, 1.5f);
            m_light.ShadowDistance     = 20;
            m_light.ReflectorFalloff   = 5;
            m_light.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
            m_light.UseInForwardRender = true;
            m_light.ReflectorTexture   = definition.ReflectorTexture;
            m_light.Range       = 1;
            m_light.GlossFactor = 0;

            MyCharacterBone leftGlareBone = null;

            if (definition.LeftLightBone != String.Empty)
            {
                leftGlareBone = m_skinnedEntity.AnimationController.FindBone(definition.LeftLightBone, out m_leftLightIndex);
            }
            if (leftGlareBone != null)
            {
                m_leftGlare = MyLights.AddLight();
                m_leftGlare.Start(MyLight.LightTypeEnum.None, 1.5f);
                m_leftGlare.LightOn            = false;
                m_leftGlare.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
                m_leftGlare.UseInForwardRender = false;
                m_leftGlare.GlareOn            = true;
                m_leftGlare.GlareQuerySize     = 0.2f;
                m_leftGlare.GlareType          = VRageRender.Lights.MyGlareTypeEnum.Directional;
                m_leftGlare.GlareMaterial      = definition.LeftGlare;
            }

            MyCharacterBone rightGlareBone = null;

            if (definition.RightLightBone != String.Empty)
            {
                rightGlareBone = m_skinnedEntity.AnimationController.FindBone(definition.RightLightBone, out m_rightLightIndex);
            }
            if (rightGlareBone != null)
            {
                m_rightGlare = MyLights.AddLight();
                m_rightGlare.Start(MyLight.LightTypeEnum.None, 1.5f);
                m_rightGlare.LightOn            = false;
                m_rightGlare.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
                m_rightGlare.UseInForwardRender = false;
                m_rightGlare.GlareOn            = true;
                m_rightGlare.GlareQuerySize     = 0.2f;
                m_rightGlare.GlareType          = VRageRender.Lights.MyGlareTypeEnum.Directional;
                m_rightGlare.GlareMaterial      = definition.RightGlare;
            }
        }
예제 #4
0
 public void InitLight(MyCharacterDefinition definition)
 {
     this.m_light = MyLights.AddLight();
     if (this.m_light != null)
     {
         this.m_light.Start(base.Entity.DisplayName + " Reflector");
         this.m_light.ReflectorOn      = true;
         this.m_light.ReflectorTexture = @"Textures\Lights\dual_reflector_2.tif";
         this.UpdateLightBasics();
         this.m_flareLeft  = this.CreateFlare("left");
         this.m_flareRight = this.CreateFlare("right");
         base.m_skinnedEntity.AnimationController.FindBone(definition.LeftLightBone, out this.m_leftLightIndex);
         base.m_skinnedEntity.AnimationController.FindBone(definition.RightLightBone, out this.m_rightLightIndex);
     }
 }
예제 #5
0
        public void InitJetpackThrusts(MyCharacterDefinition definition)
        {
            m_jetpackThrusts.Clear();

            foreach (var thrustDefinition in definition.Thrusts)
            {
                int index;
                var thrustBone = m_character.FindBone(thrustDefinition.ThrustBone, out index);
                if (thrustBone != null)
                {
                    InitJetpackThrust(index, Vector3.Forward, thrustDefinition.SideFlameOffset, thrustDefinition); // UP is now in -Z
                    InitJetpackThrust(index, Vector3.Left, thrustDefinition.SideFlameOffset, thrustDefinition);
                    InitJetpackThrust(index, Vector3.Right, thrustDefinition.SideFlameOffset, thrustDefinition);
                    InitJetpackThrust(index, Vector3.Backward, thrustDefinition.SideFlameOffset, thrustDefinition); // DOWN is now in Z
                    InitJetpackThrust(index, Vector3.Up, thrustDefinition.FrontFlameOffset, thrustDefinition);      // FORWARD is now in Y
                }
            }
        }
예제 #6
0
 public void InitJetpackThrusts(MyCharacterDefinition definition)
 {
     this.m_jetpackThrusts.Clear();
     if (definition.Jetpack != null)
     {
         foreach (MyJetpackThrustDefinition definition2 in definition.Jetpack.Thrusts)
         {
             int num;
             if (base.m_skinnedEntity.AnimationController.FindBone(definition2.ThrustBone, out num) != null)
             {
                 this.InitJetpackThrust(num, Vector3.Forward, definition2.SideFlameOffset, ref definition.Jetpack.ThrustProperties);
                 this.InitJetpackThrust(num, Vector3.Left, definition2.SideFlameOffset, ref definition.Jetpack.ThrustProperties);
                 this.InitJetpackThrust(num, Vector3.Right, definition2.SideFlameOffset, ref definition.Jetpack.ThrustProperties);
                 this.InitJetpackThrust(num, Vector3.Backward, definition2.SideFlameOffset, ref definition.Jetpack.ThrustProperties);
                 this.InitJetpackThrust(num, Vector3.Up, definition2.FrontFlameOffset, ref definition.Jetpack.ThrustProperties);
             }
         }
     }
 }
예제 #7
0
        private MySoundPair SelectSound()
        {
            MySoundPair           soundPair        = EmptySoundPair;
            MyCharacterDefinition myCharDefinition = m_character.Definition;
            MyStringHash          physMaterial     = MyStringHash.GetOrCompute(myCharDefinition.PhysicalMaterial);

            m_isWalking = false;

            bool updateEmitterSounds = false;
            MyCharacterMovementEnum movementState = m_character.GetCurrentMovementState();

            switch (movementState)
            {
            case MyCharacterMovementEnum.Walking:
            case MyCharacterMovementEnum.BackWalking:
            case MyCharacterMovementEnum.WalkingLeftFront:
            case MyCharacterMovementEnum.WalkingRightFront:
            case MyCharacterMovementEnum.WalkingLeftBack:
            case MyCharacterMovementEnum.WalkingRightBack:
            case MyCharacterMovementEnum.WalkStrafingLeft:
            case MyCharacterMovementEnum.WalkStrafingRight:
            {
                if (m_character.Breath != null)
                {
                    m_character.Breath.CurrentState = MyCharacterBreath.State.Calm;
                }
                soundPair   = MyMaterialPropertiesHelper.Static.GetCollisionCue(MovementSoundType.Walk, physMaterial, RayCastGround());
                m_isWalking = true;
            }
            break;

            case MyCharacterMovementEnum.Running:
            case MyCharacterMovementEnum.Backrunning:
            case MyCharacterMovementEnum.RunStrafingLeft:
            case MyCharacterMovementEnum.RunStrafingRight:
            case MyCharacterMovementEnum.RunningRightFront:
            case MyCharacterMovementEnum.RunningRightBack:
            case MyCharacterMovementEnum.RunningLeftFront:
            case MyCharacterMovementEnum.RunningLeftBack:
            {
                if (m_character.Breath != null)
                {
                    m_character.Breath.CurrentState = MyCharacterBreath.State.Heated;
                }
                soundPair   = MyMaterialPropertiesHelper.Static.GetCollisionCue(MovementSoundType.Run, physMaterial, RayCastGround());
                m_isWalking = true;
            }
            break;

            case MyCharacterMovementEnum.CrouchWalking:
            case MyCharacterMovementEnum.CrouchBackWalking:
            case MyCharacterMovementEnum.CrouchWalkingLeftFront:
            case MyCharacterMovementEnum.CrouchWalkingRightFront:
            case MyCharacterMovementEnum.CrouchWalkingLeftBack:
            case MyCharacterMovementEnum.CrouchWalkingRightBack:
            case MyCharacterMovementEnum.CrouchStrafingLeft:
            case MyCharacterMovementEnum.CrouchStrafingRight:
            {
                if (m_character.Breath != null)
                {
                    m_character.Breath.CurrentState = MyCharacterBreath.State.Calm;
                }
                soundPair   = MyMaterialPropertiesHelper.Static.GetCollisionCue(MovementSoundType.CrouchWalk, physMaterial, RayCastGround());
                m_isWalking = true;
            }
            break;

            case MyCharacterMovementEnum.Crouching:
            case MyCharacterMovementEnum.Standing:
            {
                if (m_character.Breath != null)
                {
                    m_character.Breath.CurrentState = MyCharacterBreath.State.Calm;
                }
                var previousMovementState = m_character.GetPreviousMovementState();
                var currentMovementState  = m_character.GetCurrentMovementState();
                if (previousMovementState != currentMovementState &&
                    (previousMovementState == MyCharacterMovementEnum.Standing || previousMovementState == MyCharacterMovementEnum.Crouching))
                {
                    soundPair = (currentMovementState == MyCharacterMovementEnum.Standing) ? CharacterSounds[(int)CharacterSoundsEnum.CROUCH_UP_SOUND] : CharacterSounds[(int)CharacterSoundsEnum.CROUCH_DOWN_SOUND];
                }
            }
            break;

            case MyCharacterMovementEnum.Sprinting:
            {
                if (m_character.Breath != null)
                {
                    m_character.Breath.CurrentState = MyCharacterBreath.State.VeryHeated;
                }
                soundPair   = MyMaterialPropertiesHelper.Static.GetCollisionCue(MovementSoundType.Sprint, physMaterial, RayCastGround());
                m_isWalking = true;
            }
            break;

            case MyCharacterMovementEnum.Jump:
            {
                if (!m_jumpReady)
                {
                    break;
                }
                m_jumpReady = false;
                m_character.SetPreviousMovementState(m_character.GetCurrentMovementState());
                var emitter = MyAudioComponent.TryGetSoundEmitter();                                 // We need to use another emitter otherwise the sound would be cut by silence next frame
                if (emitter != null)
                {
                    emitter.Entity = m_character;
                    emitter.PlaySingleSound(CharacterSounds[(int)CharacterSoundsEnum.JUMP_SOUND]);
                }

                if ((m_standingOnGrid != null || m_standingOnVoxel != null) && ShouldUpdateSoundEmitters)
                {
                    updateEmitterSounds = true;
                }
                m_standingOnGrid  = null;
                m_standingOnVoxel = null;
            }
            break;

            case MyCharacterMovementEnum.Flying:
            {
                if (m_character.Breath != null)
                {
                    m_character.Breath.CurrentState = MyCharacterBreath.State.Calm;
                }
                if (m_character.JetpackComp != null && m_jetpackMinIdleTime <= 0f && m_character.JetpackComp.FinalThrust.LengthSquared() >= 50000f)
                {
                    soundPair             = CharacterSounds[(int)CharacterSoundsEnum.JETPACK_RUN_SOUND];
                    m_jetpackSustainTimer = Math.Min(JETPACK_TIME_BETWEEN_SOUNDS, m_jetpackSustainTimer + MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS);
                }
                else
                {
                    soundPair             = CharacterSounds[(int)CharacterSoundsEnum.JETPACK_IDLE_SOUND];
                    m_jetpackSustainTimer = Math.Max(0f, m_jetpackSustainTimer - MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS);
                }
                m_jetpackMinIdleTime -= MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;

                if ((m_standingOnGrid != null || m_standingOnVoxel != null) && ShouldUpdateSoundEmitters)
                {
                    updateEmitterSounds = true;
                }
                m_standingOnGrid  = null;
                m_standingOnVoxel = null;
            }
            break;

            case MyCharacterMovementEnum.Falling:
            {
                if (m_character.Breath != null)
                {
                    m_character.Breath.CurrentState = MyCharacterBreath.State.Calm;
                }

                if ((m_standingOnGrid != null || m_standingOnVoxel != null) && ShouldUpdateSoundEmitters)
                {
                    updateEmitterSounds = true;
                }
                m_standingOnGrid  = null;
                m_standingOnVoxel = null;
            }
            break;

            default:
            {
            }
            break;
            }

            //MyRenderProxy.DebugDrawText2D(Vector2.Zero, movementState.ToString(), Color.Red, 1.0f);

            if (movementState != MyCharacterMovementEnum.Flying)
            {
                m_jetpackSustainTimer = 0f;
                m_jetpackMinIdleTime  = 0.5f;
            }
            if (updateEmitterSounds)
            {
                MyEntity3DSoundEmitter.UpdateEntityEmitters(true, true, false);
            }
            return(soundPair);
        }
        public void InitLight(MyCharacterDefinition definition)
        {
            m_light = MyLights.AddLight();

            m_lightGlareSize = definition.LightGlareSize;

            m_light.Start(MyLight.LightTypeEnum.PointLight | MyLight.LightTypeEnum.Spotlight, 0.5f);

            /// todo: defaults should be supplied from Environemnt.sbc
            m_light.GlossFactor        = 0;
            m_light.DiffuseFactor      = 3.14f;
            m_light.UseInForwardRender = true;
            m_light.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
            m_light.ShadowDistance     = 20;
            m_light.ReflectorFalloff   = 10;

            m_light.ReflectorTexture         = "Textures\\Lights\\dual_reflector_2.dds";
            m_light.ReflectorColor           = MyCharacter.REFLECTOR_COLOR;
            m_light.ReflectorConeMaxAngleCos = MyCharacter.REFLECTOR_CONE_ANGLE;
            m_light.ReflectorRange           = MyCharacter.REFLECTOR_RANGE;
            m_light.ReflectorGlossFactor     = MyCharacter.REFLECTOR_GLOSS_FACTOR;
            m_light.ReflectorDiffuseFactor   = MyCharacter.REFLECTOR_DIFFUSE_FACTOR;
            m_light.Color         = MyCharacter.POINT_COLOR;
            m_light.SpecularColor = new Vector3(MyCharacter.POINT_COLOR_SPECULAR);
            m_light.Range         = MyCharacter.POINT_LIGHT_RANGE;

            MyCharacterBone leftGlareBone = null;

            if (definition.LeftLightBone != String.Empty)
            {
                leftGlareBone = m_skinnedEntity.AnimationController.FindBone(definition.LeftLightBone, out m_leftLightIndex);
            }
            if (leftGlareBone != null)
            {
                m_leftGlare = MyLights.AddLight();
                m_leftGlare.Start(MyLight.LightTypeEnum.None, 1.5f);
                m_leftGlare.LightOn            = false;
                m_leftGlare.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
                m_leftGlare.UseInForwardRender = false;
                m_leftGlare.GlareOn            = true;
                m_leftGlare.GlareQuerySize     = 0.2f;
                m_leftGlare.GlareType          = VRageRender.Lights.MyGlareTypeEnum.Directional;
                m_leftGlare.GlareMaterial      = definition.LeftGlare;
            }

            MyCharacterBone rightGlareBone = null;

            if (definition.RightLightBone != String.Empty)
            {
                rightGlareBone = m_skinnedEntity.AnimationController.FindBone(definition.RightLightBone, out m_rightLightIndex);
            }
            if (rightGlareBone != null)
            {
                m_rightGlare = MyLights.AddLight();
                m_rightGlare.Start(MyLight.LightTypeEnum.None, 1.5f);
                m_rightGlare.LightOn            = false;
                m_rightGlare.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
                m_rightGlare.UseInForwardRender = false;
                m_rightGlare.GlareOn            = true;
                m_rightGlare.GlareQuerySize     = 0.2f;
                m_rightGlare.GlareType          = VRageRender.Lights.MyGlareTypeEnum.Directional;
                m_rightGlare.GlareMaterial      = definition.RightGlare;
            }
        }