public static void GetModelAndDefinition(MyObjectBuilder_Character characterOb, out string characterModel, out MyCharacterDefinition characterDefinition, ref Vector3 colorMask)
        {
            characterModel = GetRealModel(characterOb.CharacterModel, ref colorMask);
            characterDefinition = null;

            if (!MyDefinitionManager.Static.Characters.TryGetValue(characterModel, out characterDefinition))
            {
                //System.Diagnostics.Debug.Fail("Character model " + m_characterModel + " not found!");
                characterDefinition = MyDefinitionManager.Static.Characters.First();

                characterModel = characterDefinition.Model;
            }
        }
Exemple #2
0
        private void SetCharacterReference(IMyEntity ent)
        {
            if(character == ent || !(ent is IMyCharacter))
                return;

            if(character != null)
                character.OnMovementStateChanged -= CharacterMovementStateChanged;

            character = ent as IMyCharacter;

            if(character == null)
                return;

            characterDefinition = GetCharacterDefinitionFrom(ent);
            character.OnMovementStateChanged += CharacterMovementStateChanged;
        }
        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;

            MyCharacterBone leftGlareBone = null;
            if (definition.LeftLightBone != String.Empty) leftGlareBone = m_character.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_character.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;
            }
        }
        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
                }
            }
        }
        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.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_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;
            }
        }