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); }
// ------------------------------------------------------------------------------------------------ #region Light public void InitLight(bool isLightOn) { m_light = MyLights.AddLight(); m_light.Start(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 = "Textures\\Lights\\dual_reflector_2.dds"; m_light.Range = 2; m_light.ReflectorRange = MyCharacter.REFLECTOR_RANGE; m_light.ReflectorColor = MyCharacter.REFLECTOR_COLOR; m_light.ReflectorIntensity = MyCharacter.REFLECTOR_INTENSITY; 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.Intensity = MyCharacter.POINT_LIGHT_INTENSITY; // Reflector Range now very far m_light.UpdateReflectorRangeAndAngle(MyCharacter.REFLECTOR_CONE_ANGLE, MyCharacter.REFLECTOR_RANGE * REFLECTOR_RANGE_MULTIPLIER); m_light.LightOn = isLightOn; m_light.ReflectorOn = isLightOn; }
protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig) { m_prefabLightConfig = prefabConfig as MyPrefabConfigurationLight; MyMwcObjectBuilder_PrefabLight objectBuilderLight = objectBuilder as MyMwcObjectBuilder_PrefabLight; m_light = MyLights.AddLight(); m_light.LightType = (MyLight.LightTypeEnum)objectBuilderLight.LightType; m_light.Start(m_light.LightType, 1); m_light.UseInForwardRender = true; //grab first dummy and set it as point source //since we dont support yet more lights in one prefab. add just the first one MyModel model = MyModels.GetModelOnlyDummies(m_prefabLightConfig.ModelLod0Enum); m_pointLocalMatrix = Matrix.Identity; bool dummyFound = false; foreach (KeyValuePair <string, MyModelDummy> pair in model.Dummies) { if (pair.Key.StartsWith("Dummy", StringComparison.InvariantCultureIgnoreCase)) { m_pointLocalMatrix = pair.Value.Matrix; dummyFound = true; break; } } Debug.Assert(dummyFound, "Dummy 'POINT_LIGHT_POS' not found in light prefab model: " + model.AssetName); m_light.Color = objectBuilderLight.PointColor; m_light.ReflectorColor = objectBuilderLight.SpotColor; m_light.Falloff = objectBuilderLight.PointFalloff; m_light.ReflectorFalloff = objectBuilderLight.SpotFalloff; m_IntensityMax = m_light.Intensity = objectBuilderLight.PointIntensity; m_light.ReflectorIntensity = ReflectorIntensityMax = objectBuilderLight.SpotIntensity; m_light.ReflectorRange = MathHelper.Clamp(objectBuilderLight.SpotRange, 1, MyLightsConstants.MAX_SPOTLIGHT_RANGE); m_light.Range = MathHelper.Clamp(objectBuilderLight.PointRange, 1, MyLightsConstants.MAX_POINTLIGHT_RADIUS); m_light.PointLightOffset = objectBuilderLight.PointOffset; this.FlashOffset = objectBuilderLight.FlashOffset; //to add reflector range to builders m_light.SpecularColor = objectBuilderLight.PointSpecular; m_light.ReflectorConeDegrees = objectBuilderLight.SpotAgle; m_effect = objectBuilderLight.Effect; //m_light.LightOn = true; m_lastBlickChange = MyMinerGame.TotalGamePlayTimeInMilliseconds; // here set the properties of glare for the prefab light m_light.GlareOn = true; m_light.Glare.Type = MyLightGlare.GlareTypeEnum.Normal; m_light.Glare.QuerySize = .8f; m_light.ShadowDistance = objectBuilderLight.ShadowsDistance; m_light.Glare.Intensity = m_light.Intensity; UpdateEffect(); CastShadows = false; UpdateLightWorldMatrix(); }
public static void CreateOrUpdateLight(MyEntity entity, MyLight light, Color color, Vector3D?originPoint = null) { var lightPosition = originPoint ?? entity.WorldMatrix.Translation; var lightRange = 1.5f; //Range of light var lightIntensity = 5.0f; //Light intensity var lightFalloff = 1.5f; //Light falloff var lightOffset = 0.5f; //Light offset if (light == null) //Ignore - checks if there is a light and if not makes it. { light = MyLights.AddLight(); //Ignore - adds the light to the games lighting system light.Start(lightPosition, color.ToVector4(), lightRange, ""); // Ignore- Determines the lights position, initial color and initial range. light.Intensity = lightIntensity; //Ignore - sets light intensity from above values. light.Falloff = lightFalloff; //Ignore - sets light fall off from above values. light.PointLightOffset = lightOffset; //Ignore - sets light offset from above values. light.LightOn = true; //Ignore - turns light on } else { // Updates the lights position constantly. You'll need help if you want it somewhere else. light.Position = lightPosition; light.UpdateLight(); //Ignore - tells the game to update the light. } }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { base.Init(objectBuilder, cubeGrid); m_thrustDefinition = (MyThrustDefinition)BlockDefinition; var builder = (MyObjectBuilder_Thrust)objectBuilder; m_thrustColor = m_thrustDefinition.FlameIdleColor; ThrustOverride = builder.ThrustOverride; LoadDummies(); m_light = MyLights.AddLight(); m_light.ReflectorDirection = WorldMatrix.Forward; m_light.ReflectorUp = WorldMatrix.Up; m_light.ReflectorRange = 1; m_light.Color = m_thrustColor; m_light.GlareMaterial = m_thrustDefinition.FlameGlareMaterial; m_light.GlareQuerySize = m_thrustDefinition.FlameGlareQuerySize; m_glareSize = m_thrustDefinition.FlameGlareSize; m_maxBillboardDistanceSquared = m_thrustDefinition.FlameVisibilityDistance * m_thrustDefinition.FlameVisibilityDistance; m_maxLightDistanceSquared = m_maxBillboardDistanceSquared / 100; m_light.Start(MyLight.LightTypeEnum.PointLight, 1); SyncObject = new MySyncThruster(this); }
//public void LightingHandler(ref MyLight light, float positionOffset, float lightRange, Color color) void LightingHandler(ref MyLight light, Vector3D position, float lightRange, Color color, float falloff, float intensity, float mult) { if (light == null) { light = new MyLight(); //These control the light settings on spawn. //var lightRange = 2.5f; //Range of light var lightIntensity = 5.0f; //Light intensity //var lightFalloff = 0.5f; //Light falloff var lightFalloff = falloff; //Light falloff //var lightAdjustment = 0.0f; var lightPosition = position; //Sets the light to the center of the block you are spawning it on, if you need it elsehwere you will need help. light = MyLights.AddLight(); //Ignore - adds the light to the games lighting system light.Start(lightPosition, color, lightRange, ""); // Ignore- Determines the lights position, initial color and initial range. light.Intensity = lightIntensity; //Ignore - sets light intensity from above values. light.Falloff = lightFalloff; //Ignore - sets light fall off from above values. //_light.PointLightOffset = lightOffset; //Ignore - sets light offset from above values. light.LightOn = true; //Ignore - turns light on } else { light.Intensity = intensity * mult; light.Position = position; //Updates the lights position constantly. You'll need help if you want it somewhere else. light.UpdateLight(); //Ignore - tells the game to update the light. } }
void LightingHandler() { if (_light == null) { _light = new MyLight(); //These control the light settings on spawn. var lightRange = 2.5f; //Range of light var lightIntensity = 5.0f; //Light intensity var lightFalloff = 0.5f; //Light falloff //var lightAdjustment = 0.0f; var lightPosition = block.WorldMatrix.Translation + block.WorldMatrix.Forward * 0.2; //Sets the light to the center of the block you are spawning it on, if you need it elsehwere you will need help. _light = MyLights.AddLight(); //Ignore - adds the light to the games lighting system _light.Start(lightPosition, Color.Red, lightRange, ""); // Ignore- Determines the lights position, initial color and initial range. _light.Intensity = lightIntensity; //Ignore - sets light intensity from above values. _light.Falloff = lightFalloff; //Ignore - sets light fall off from above values. //_light.PointLightOffset = lightOffset; //Ignore - sets light offset from above values. _light.LightOn = true; //Ignore - turns light on } else { //_light.Intensity = 10 * ThrusterStrength; _light.Position = block.WorldMatrix.Translation + block.WorldMatrix.Forward; //Updates the lights position constantly. You'll need help if you want it somewhere else. _light.UpdateLight(); //Ignore - tells the game to update the light. } }
public NaniteBeaconEffect(MyCubeBlock owner, Vector3 localOffset, Vector4 color) { m_owner = owner as IMyFunctionalBlock; m_localOffset = localOffset; m_color = color; m_light = MyLights.AddLight(); //m_light.Start(color, 2f, 4f, "NaniteBeacon"); m_light.Start(color, 2f, "NaniteBeacon"); m_light.GlareType = VRageRender.Lights.MyGlareTypeEnum.Normal; m_light.GlareOn = true; m_light.GlareQuerySize = 1; m_light.GlareIntensity = 0.5f; var flareId = new MyDefinitionId(typeof(MyObjectBuilder_FlareDefinition), "BeaconSmall"); var flare = (MyFlareDefinition)MyDefinitionManager.Static.GetDefinition(flareId); m_light.GlareSize = flare.Size; m_light.SubGlares = flare.SubGlares; //m_light.GlareMaterial = "LightGlare"; //m_light.GlareType = VRageRender.Lights.MyGlareTypeEnum.Normal; m_updateCount = 0; }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { MyBeaconDefinition blockDefinition = base.BlockDefinition as MyBeaconDefinition; if (blockDefinition.EmissiveColorPreset == MyStringHash.NullOrEmpty) { blockDefinition.EmissiveColorPreset = MyStringHash.GetOrCompute("Beacon"); } MyResourceSinkComponent component = new MyResourceSinkComponent(1); component.Init(MyStringHash.GetOrCompute(blockDefinition.ResourceSinkGroup), 0.02f, new Func <float>(this.UpdatePowerInput)); base.ResourceSink = component; this.RadioBroadcaster = new MyRadioBroadcaster(blockDefinition.MaxBroadcastRadius / 10f); MyObjectBuilder_Beacon beacon = (MyObjectBuilder_Beacon)objectBuilder; if (beacon.BroadcastRadius > 0f) { this.RadioBroadcaster.BroadcastRadius = beacon.BroadcastRadius; } this.RadioBroadcaster.BroadcastRadius = MathHelper.Clamp(this.RadioBroadcaster.BroadcastRadius, 1f, blockDefinition.MaxBroadcastRadius); this.HudText.Clear(); if (beacon.HudText != null) { this.HudText.Append(beacon.HudText); } base.Init(objectBuilder, cubeGrid); component.IsPoweredChanged += new Action(this.Receiver_IsPoweredChanged); component.Update(); MyRadioBroadcaster radioBroadcaster = this.RadioBroadcaster; radioBroadcaster.OnBroadcastRadiusChanged = (Action)Delegate.Combine(radioBroadcaster.OnBroadcastRadiusChanged, new Action(this.OnBroadcastRadiusChanged)); this.m_largeLight = cubeGrid.GridSizeEnum == MyCubeSize.Large; this.m_light = MyLights.AddLight(); if (this.m_light != null) { this.m_light.Start(this.DisplayNameText); this.m_light.Range = this.m_largeLight ? 2f : 0.3f; this.m_light.GlareOn = false; this.m_light.GlareQuerySize = this.m_largeLight ? 1.5f : 0.3f; this.m_light.GlareQueryShift = this.m_largeLight ? 1f : 0.2f; this.m_light.GlareType = MyGlareTypeEnum.Normal; this.m_light.GlareMaxDistance = GLARE_MAX_DISTANCE; MyDefinitionId id = new MyDefinitionId(typeof(MyObjectBuilder_FlareDefinition), blockDefinition.Flare); MyFlareDefinition definition = MyDefinitionManager.Static.GetDefinition(id) as MyFlareDefinition; this.m_flare = definition ?? new MyFlareDefinition(); this.m_light.GlareIntensity = this.m_flare.Intensity; this.m_light.GlareSize = this.m_flare.Size; this.m_light.SubGlares = this.m_flare.SubGlares; } this.m_lightPositionOffset = this.m_largeLight ? new Vector3(0f, base.CubeGrid.GridSize * 0.3f, 0f) : Vector3.Zero; this.UpdateLightPosition(); this.m_restartTimeMeasure = false; this.AnimationRunning = true; base.SlimBlock.ComponentStack.IsFunctionalChanged += new Action(this.ComponentStack_IsFunctionalChanged); base.IsWorkingChanged += new Action <MyCubeBlock>(this.MyBeacon_IsWorkingChanged); base.ShowOnHUD = false; this.UpdateText(); }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { base.Init(objectBuilder, cubeGrid); m_radioBroadcaster = new MyRadioBroadcaster(this, 10000, IsWorking); if (((MyObjectBuilder_Beacon)objectBuilder).BroadcastRadius != 0) { m_radioBroadcaster.BroadcastRadius = ((MyObjectBuilder_Beacon)objectBuilder).BroadcastRadius; } m_radioBroadcaster.OnBroadcastRadiusChanged += OnBroadcastRadiusChanged; m_largeLight = cubeGrid.GridSizeEnum == MyCubeSize.Large; m_light = MyLights.AddLight(); m_light.Start(MyLight.LightTypeEnum.PointLight, 1.5f); m_light.LightOwner = MyLight.LightOwnerEnum.SmallShip; m_light.UseInForwardRender = true; m_light.Range = 1; m_light.GlareOn = true; m_light.GlareIntensity = m_largeLight ? 2 : 1; m_light.GlareQuerySize = m_largeLight ? 7.5f : 1.22f; m_light.GlareType = VRageRender.Lights.MyGlareTypeEnum.Distant; m_light.GlareMaterial = m_largeLight ? "GlareLsLight" : "GlareSsLight"; m_light.GlareMaxDistance = GLARE_MAX_DISTANCE; if (m_largeLight) { m_lightPositionOffset = new Vector3(0f, CubeGrid.GridSize * 0.5f, 0f); } else { m_lightPositionOffset = Vector3.Zero; } UpdateLightPosition(); PowerReceiver = new MyPowerReceiver( MyConsumerGroupEnum.Utility, false, MyEnergyConstants.MAX_REQUIRED_POWER_BEACON, UpdatePowerInput); PowerReceiver.IsPoweredChanged += Receiver_IsPoweredChanged; PowerReceiver.Update(); AddDebugRenderComponent(new MyDebugRenderComponentDrawPowerReciever(PowerReceiver, this)); AnimationRunning = true; SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; IsWorkingChanged += MyBeacon_IsWorkingChanged; ShowOnHUD = false; UpdateText(); }
private MyLight CreateEffectLight() { MyLight light = MyLights.AddLight(); light.Start(MyLight.LightTypeEnum.PointLight, Vector3.Zero, new Vector4(1.0f, 0.8f, 0.6f, 1.0f), 2.0f, 10.0f); light.GlareMaterial = "GlareWelder"; light.GlareOn = true; light.GlareQuerySize = 1; light.GlareType = VRageRender.Lights.MyGlareTypeEnum.Normal; return(light); }
protected virtual MyLight CreateSecondaryLight() { MyLight light = MyLights.AddLight(); light.Start(MyLight.LightTypeEnum.PointLight, Vector3.Zero, SecondaryLightColor, SecondaryLightFalloff, SecondaryLightRadius); light.GlareMaterial = "GlareWelder"; light.GlareOn = true; light.GlareQuerySize = 1; light.GlareType = VRageRender.Lights.MyGlareTypeEnum.Normal; return(light); }
public MyPrefabLamp(Vector3 position, float radiusMin, float radiusMax, int timerForBlic) { Position = position; RadiusMin = radiusMin; RadiusMax = radiusMax; TimerForBlic = timerForBlic; Light = MyLights.AddLight(); Light.Start(MyLight.LightTypeEnum.PointLight, position, Vector4.One, 1, radiusMin); Light.Intensity = 1; Light.LightOn = true; }
public void Start(float lightSize) { if (lightSize > 0) { Light = MyLights.AddLight(); Light.Color = Vector4.One; Light.Start(MyLight.LightTypeEnum.PointLight, 1.0f); Light.LightOn = lightSize > 0; Light.Intensity = 10; } }
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; } }
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); } }
void CreateLight(IMyEntity entity, string dummyName, Matrix dummyMatrix) { var light = MyLights.AddLight(); light.Start(dummyName); light.Color = Color.White; light.Range = Block.CubeGrid.GridSize; light.Falloff = 1f; light.Intensity = 2f; light.ParentID = Block.CubeGrid.Render.GetRenderObjectID(); light.Position = Vector3D.Transform(Vector3D.Transform(dummyMatrix.Translation, Block.WorldMatrix), Block.CubeGrid.WorldMatrixInvScaled); light.ReflectorDirection = Vector3D.TransformNormal(Vector3D.TransformNormal(dummyMatrix.Forward, Block.WorldMatrix), Block.CubeGrid.WorldMatrixInvScaled); light.ReflectorUp = Vector3D.TransformNormal(Vector3D.TransformNormal(dummyMatrix.Up, Block.WorldMatrix), Block.CubeGrid.WorldMatrixInvScaled); lights.Add(dummyName, light); configurator(dummyName, light, this); light.UpdateLight(); }
// This method realy initiates/starts the missile // IMPORTANT: Direction vector must be normalized! public void Start(Vector3 position, Vector3 initialVelocity, Vector3 direction, float impulseMultiplier, MyEntity owner) { base.Start(position, initialVelocity, direction, impulseMultiplier, owner, MyTextsWrapper.Get(MyTextsWrapperEnum.IlluminatingShellHud)); this.Physics.AddForce( MyPhysicsForceType.APPLY_WORLD_IMPULSE_AND_WORLD_ANGULAR_IMPULSE, initialVelocity * 2, position, null); // Setting a torque here make trouble for recycled mines... so for now we don't use it. Maybe in future in other physics engine than JLX. m_light = MyLights.AddLight(); if (m_light != null) { m_light.Start(MyLight.LightTypeEnum.PointLight, position, MyIlluminatingShellsConstants.LIGHT_COLOR, 1, MyIlluminatingShellsConstants.LIGHT_RADIUS); } m_particleEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.UniversalLauncher_IlluminatingShell); m_particleEffect.WorldMatrix = WorldMatrix; }
private void InitJetpackThrust(int bone, Vector3 forward, float offset, MyJetpackThrustDefinition thrustDefinition) { var thrust = new MyJetpackThrust() { Bone = bone, Forward = forward, Offset = offset, ThrustMaterial = thrustDefinition.ThrustMaterial, ThrustGlareSize = thrustDefinition.ThrustGlareSize }; thrust.Light = MyLights.AddLight(); thrust.Light.ReflectorDirection = Container.Entity.PositionComp.WorldMatrix.Forward; thrust.Light.ReflectorUp = Container.Entity.PositionComp.WorldMatrix.Up; thrust.Light.ReflectorRange = 1; thrust.Light.Color = thrustDefinition.ThrustColor; thrust.Light.Start(MyLight.LightTypeEnum.PointLight, 1); m_jetpackThrusts.Add(thrust); }
private MyLight CreateFlare(string debugName) { MyLight light = MyLights.AddLight(); if (light != null) { light.Start(base.Entity.DisplayName + " Reflector " + debugName + " Flare"); light.ReflectorOn = false; light.LightOn = false; light.Color = MyCharacter.POINT_COLOR; light.GlareOn = true; light.GlareIntensity = this.m_flareHeadlamp.Intensity; light.GlareSize = this.m_flareHeadlamp.Size; light.SubGlares = this.m_flareHeadlamp.SubGlares; light.GlareQuerySize = 0.05f; light.GlareMaxDistance = 40f; light.GlareType = MyGlareTypeEnum.Directional; } return(light); }
public void InitLight(bool isLightOn) { this.m_light = MyLights.AddLight(); if (this.m_light != null) { this.m_light.Start("SpectatorCameraController"); this.m_light.ReflectorOn = true; this.m_light.ReflectorTexture = @"Textures\Lights\dual_reflector_2.dds"; this.m_light.Range = 2f; this.m_light.ReflectorRange = 35f; this.m_light.ReflectorColor = MyCharacter.REFLECTOR_COLOR; this.m_light.ReflectorIntensity = MyCharacter.REFLECTOR_INTENSITY; this.m_light.ReflectorGlossFactor = MyCharacter.REFLECTOR_GLOSS_FACTOR; this.m_light.ReflectorDiffuseFactor = MyCharacter.REFLECTOR_DIFFUSE_FACTOR; this.m_light.Color = MyCharacter.POINT_COLOR; this.m_light.Intensity = MyCharacter.POINT_LIGHT_INTENSITY; this.m_light.UpdateReflectorRangeAndAngle(0.373f, 175f); this.m_light.LightOn = isLightOn; this.m_light.ReflectorOn = isLightOn; } }
public static void Draw() { if (MyFakes.TEST_MISSION_1_ENABLED) { if (m_remainingPrimaryTargetsCounter == 0) { if (m_russianDropZoneLight != null) { Vector3 dir = MyMwcUtils.Normalize(MyCamera.Position - RUSSIAN_DROP_ZONE_POSITION); float timeBlic = MyMinerGame.TotalGamePlayTimeInMilliseconds % 980; if (timeBlic > 250) { timeBlic = 980 - timeBlic; } timeBlic = MathHelper.Clamp(1 - timeBlic / 250, 0, 1); float alpha = MathHelper.Lerp(0.1f, 0.6f, timeBlic); m_dropZoneLightColor.W = alpha; m_russianDropZoneLight.Start(MyLight.LightTypeEnum.PointLight, RUSSIAN_DROP_ZONE_POSITION, m_dropZoneLightColor, 1, 200); float radius = MathHelper.Lerp(0.1f, 150f, timeBlic); MyTransparentGeometry.AddPointBillboard(MyTransparentMaterialEnum.ReflectorGlareAlphaBlended, m_dropZoneLightColor, RUSSIAN_DROP_ZONE_POSITION + dir * 5, radius, 0); } else { m_russianDropZoneLight = MyLights.AddLight(); if (m_russianDropZoneLight != null) { m_russianDropZoneLight.Start(MyLight.LightTypeEnum.PointLight, 1); } } } } }
private void InitLight() { m_pointLight = MyLights.AddLight(); m_pointLight.LightType = MyLight.LightTypeEnum.PointLight; m_pointLight.Start(m_pointLight.LightType, 1); m_pointLight.UseInForwardRender = true; //grab first dummy and set it as point source //since we dont support yet more lights in one prefab. add just the first one MyModel model = MyModels.GetModelOnlyDummies(ModelLod0.ModelEnum); m_pointLocalMatrix = Matrix.CreateTranslation(model.BoundingSphere.Center); m_pointLight.Color = new Vector4(1f, 0f, 0f, 1f); m_pointLight.ReflectorColor = Vector4.Zero; m_pointLight.Falloff = 0.1f; m_pointLight.ReflectorFalloff = 0.1f; m_intensityMax = m_pointLight.Intensity = 10f; m_pointLight.ReflectorIntensity = 1f; m_pointLight.ReflectorRange = 1f; m_pointLight.Range = 40f; m_pointLight.PointLightOffset = 0f; //to add reflector range to builders m_pointLight.SpecularColor = new Vector3(1f, 0f, 0f); m_pointLight.ReflectorConeDegrees = 0.1f; m_lastBlickChange = MyMinerGame.TotalGamePlayTimeInMilliseconds; // here set the properties of glare for the prefab light m_pointLight.GlareOn = true; m_pointLight.Glare.Type = MyLightGlare.GlareTypeEnum.Distant; m_pointLight.Glare.QuerySize = .8f; UpdateLightWorldMatrix(); }
// This method realy initiates/starts the missile // IMPORTANT: Direction vector must be normalized! public override void Start(Vector3D position, Vector3D initialVelocity, Vector3D direction, long owner) { m_collidedEntity = null; m_collisionPoint = null; m_maxTrajectory = m_missileAmmoDefinition.MaxTrajectory; m_owner = owner; m_isExploded = false; base.Start(position, initialVelocity, direction, owner); Physics.RigidBody.MaxLinearVelocity = m_missileAmmoDefinition.DesiredSpeed; m_explosionType = MyExplosionTypeEnum.MISSILE_EXPLOSION; MySoundPair shootSound = m_weaponDefinition.WeaponAmmoDatas[(int)MyAmmoType.Missile].ShootSound; if (shootSound != null) { // Plays cue (looping) m_soundEmitter.PlaySingleSound(shootSound, true); } m_light = MyLights.AddLight(); if (m_light != null) { m_light.Start(MyLight.LightTypeEnum.PointLight, (Vector3)PositionComp.GetPosition(), GetMissileLightColor(), 1, MyMissileConstants.MISSILE_LIGHT_RANGE); } if (MyParticlesManager.TryCreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_Missile, out m_smokeEffect)) { var matrix = PositionComp.WorldMatrix; matrix.Translation -= matrix.Forward * m_smokeEffectOffsetMultiplier; m_smokeEffect.WorldMatrix = matrix; m_smokeEffect.AutoDelete = false; m_smokeEffect.CalculateDeltaMatrix = true; } }
private void InitJetpackThrust(int bone, Vector3 forward, float offset, ref MyObjectBuilder_ThrustDefinition thrustProperties) { MyJetpackThrust thrust1 = new MyJetpackThrust(); thrust1.Bone = bone; thrust1.Forward = forward; thrust1.Offset = offset; thrust1.ThrustPointMaterial = MyStringId.GetOrCompute(thrustProperties.FlamePointMaterial); thrust1.ThrustLengthMaterial = MyStringId.GetOrCompute(thrustProperties.FlameLengthMaterial); thrust1.ThrustGlareSize = 1f; MyJetpackThrust item = thrust1; item.Light = MyLights.AddLight(); if (item.Light != null) { item.Light.ReflectorDirection = (Vector3)base.Container.Entity.PositionComp.WorldMatrix.Forward; item.Light.ReflectorUp = (Vector3)base.Container.Entity.PositionComp.WorldMatrix.Up; item.Light.ReflectorRange = 1f; item.Light.Color = thrustProperties.FlameIdleColor; item.Light.Start(base.Entity.DisplayName + " Jetpack " + this.m_jetpackThrusts.Count); item.Light.Falloff = 2f; this.m_jetpackThrusts.Add(item); } }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { base.Init(objectBuilder, cubeGrid); this.IsLargeLight = cubeGrid.GridSizeEnum == MyCubeSize.Large; this.SyncObject = new MySyncLightingBlock(this); var builder = (MyObjectBuilder_LightingBlock)objectBuilder; MyModel lightModel = MyModels.GetModelOnlyDummies(BlockDefinition.Model); foreach (var pair in lightModel.Dummies) { if (!pair.Key.ToLower().Contains("light")) { continue; } m_lightLocalPosition = pair.Value.Matrix.Translation; break; } Vector4 color = (builder.ColorAlpha == -1) ? LightColorDef : new Vector4(builder.ColorRed, builder.ColorGreen, builder.ColorBlue, builder.ColorAlpha); float radius = RadiusBounds.Clamp((builder.Radius == -1f) ? RadiusBounds.Default : builder.Radius); float falloff = FalloffBounds.Clamp(builder.Falloff); m_blinkIntervalSeconds = BlinkIntervalSecondsBounds.Clamp((builder.BlinkIntervalSeconds == -1f) ? BlinkIntervalSecondsBounds.Default : builder.BlinkIntervalSeconds); m_blinkLength = BlinkLenghtBounds.Clamp((builder.BlinkLenght == -1f) ? BlinkLenghtBounds.Default : builder.BlinkLenght); m_blinkOffset = BlinkOffsetBounds.Clamp((builder.BlinkOffset == -1f) ? BlinkOffsetBounds.Default : builder.BlinkOffset); m_intesity = IntensityBounds.Clamp((builder.Intensity == -1f) ? IntensityBounds.Default : builder.Intensity); m_positionDirty = true; m_light = MyLights.AddLight(); InitLight(m_light, color, radius, falloff); m_light.ReflectorRange = ShortReflectorRangeDef; m_light.Range = radius; m_light.PointLightOffset = 0.5f; m_light.ReflectorOn = false; m_light.LightOn = false; m_light.GlareOn = false; UpdateIntensity(); UpdateLightPosition(); NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME; Render.NeedsDrawFromParent = true; PowerReceiver = new MyPowerReceiver( MyConsumerGroupEnum.Utility, false, BlockDefinition.RequiredPowerInput, () => (Enabled && IsFunctional) ? PowerReceiver.MaxRequiredInput : 0f); PowerReceiver.Update(); AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawPowerReciever(PowerReceiver, this)); PowerReceiver.IsPoweredChanged += Receiver_IsPoweredChanged; SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { var beaconDefinition = BlockDefinition as MyBeaconDefinition; Debug.Assert(beaconDefinition != null); var sinkComp = new MyResourceSinkComponent(); sinkComp.Init( MyStringHash.GetOrCompute(beaconDefinition.ResourceSinkGroup), MyEnergyConstants.MAX_REQUIRED_POWER_BEACON, UpdatePowerInput); ResourceSink = sinkComp; RadioBroadcaster = new MyRadioBroadcaster(10000); if (((MyObjectBuilder_Beacon)objectBuilder).BroadcastRadius != 0) { RadioBroadcaster.BroadcastRadius = ((MyObjectBuilder_Beacon)objectBuilder).BroadcastRadius; } base.Init(objectBuilder, cubeGrid); sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged; sinkComp.Update(); RadioBroadcaster.OnBroadcastRadiusChanged += OnBroadcastRadiusChanged; m_largeLight = cubeGrid.GridSizeEnum == MyCubeSize.Large; m_light = MyLights.AddLight(); m_light.Start(MyLight.LightTypeEnum.PointLight, 1.5f); m_light.LightOwner = m_largeLight ? MyLight.LightOwnerEnum.LargeShip : MyLight.LightOwnerEnum.SmallShip; m_light.UseInForwardRender = true; m_light.Range = 1; m_light.GlareOn = true; m_light.GlareIntensity = m_largeLight ? 2 : 1; m_light.GlareQuerySize = m_largeLight ? 1.0f : 0.2f; m_light.GlareSize = 1.0f; m_light.GlareType = VRageRender.Lights.MyGlareTypeEnum.Distant; m_light.GlareMaterial = m_largeLight ? "GlareLsLight" : "GlareSsLight"; m_light.GlareMaxDistance = GLARE_MAX_DISTANCE; if (m_largeLight) { m_lightPositionOffset = new Vector3(0f, CubeGrid.GridSize * 0.5f, 0f); } else { m_lightPositionOffset = Vector3.Zero; } UpdateLightPosition(); AddDebugRenderComponent(new MyDebugRenderComponentDrawPowerReciever(ResourceSink, this)); AnimationRunning = true; SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; IsWorkingChanged += MyBeacon_IsWorkingChanged; ShowOnHUD = false; UpdateText(); }
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; } }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { var sinkComp = new MyResourceSinkComponent(); sinkComp.Init( BlockDefinition.ResourceSinkGroup, BlockDefinition.RequiredPowerInput, () => (Enabled && IsFunctional) ? ResourceSink.MaxRequiredInput : 0f); sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged; ResourceSink = sinkComp; base.Init(objectBuilder, cubeGrid); this.IsLargeLight = cubeGrid.GridSizeEnum == MyCubeSize.Large; var builder = (MyObjectBuilder_LightingBlock)objectBuilder; MyModel lightModel = VRage.Game.Models.MyModels.GetModelOnlyDummies(BlockDefinition.Model); foreach (var pair in lightModel.Dummies) { if (!pair.Key.ToLower().Contains("light")) { continue; } m_lightLocalPosition = pair.Value.Matrix.Translation; break; } Vector4 color = (builder.ColorAlpha == -1) ? LightColorDef : new Vector4(builder.ColorRed, builder.ColorGreen, builder.ColorBlue, builder.ColorAlpha); float radius = RadiusBounds.Clamp((builder.Radius == -1f) ? RadiusBounds.Default : builder.Radius); float reflectorRadius = ReflectorRadiusBounds.Clamp((builder.ReflectorRadius == -1f) ? ReflectorRadiusBounds.Default : builder.ReflectorRadius); float falloff = FalloffBounds.Clamp(builder.Falloff); m_blinkIntervalSeconds.Value = BlinkIntervalSecondsBounds.Clamp((builder.BlinkIntervalSeconds == -1f) ? BlinkIntervalSecondsBounds.Default : builder.BlinkIntervalSeconds); m_blinkLength.Value = BlinkLenghtBounds.Clamp((builder.BlinkLenght == -1f) ? BlinkLenghtBounds.Default : builder.BlinkLenght); m_blinkOffset.Value = BlinkOffsetBounds.Clamp((builder.BlinkOffset == -1f) ? BlinkOffsetBounds.Default : builder.BlinkOffset); m_intesity.Value = IntensityBounds.Clamp((builder.Intensity == -1f) ? IntensityBounds.Default : builder.Intensity); m_positionDirty = true; m_light = MyLights.AddLight(); InitLight(m_light, color, radius, falloff); m_light.ReflectorRange = reflectorRadius; m_light.Range = radius; m_light.ReflectorOn = false; m_light.LightOn = false; m_light.GlareOn = false; UpdateIntensity(); UpdateLightPosition(); NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.BEFORE_NEXT_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; Render.NeedsDrawFromParent = true; AddDebugRenderComponent(new MyDebugRenderComponentDrawPowerReciever(ResourceSink, this)); ResourceSink.Update(); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; IsWorkingChanged += CubeBlock_OnWorkingChanged; }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { MyEntityThrustComponent entityThrustComponent; if (!cubeGrid.Components.TryGet(out entityThrustComponent)) { entityThrustComponent = new MyThrusterBlockThrustComponent(); entityThrustComponent.Init(); cubeGrid.Components.Add <MyEntityThrustComponent>(entityThrustComponent); } m_thrustComponent = entityThrustComponent; BlockDefinition = (MyThrustDefinition)base.BlockDefinition; MyDefinitionId fuelId = new MyDefinitionId(); if (!BlockDefinition.FuelConverter.FuelId.IsNull()) { fuelId = BlockDefinition.FuelConverter.FuelId; } MyGasProperties fuelDef = null; if (MyFakes.ENABLE_HYDROGEN_FUEL) { MyDefinitionManager.Static.TryGetDefinition(fuelId, out fuelDef); } FuelDefinition = fuelDef ?? new MyGasProperties // Use electricity by default { Id = MyResourceDistributorComponent.ElectricityId, EnergyDensity = 1f, }; base.Init(objectBuilder, cubeGrid); var builder = (MyObjectBuilder_Thrust)objectBuilder; ThrustColor = BlockDefinition.FlameIdleColor; m_thrustOverride.Value = (builder.ThrustOverride * 100f) / BlockDefinition.ForceMagnitude; LoadDummies(); NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME; m_light = MyLights.AddLight(); m_light.ReflectorDirection = WorldMatrix.Forward; m_light.ReflectorUp = WorldMatrix.Up; m_light.ReflectorRange = CubeGrid.GridScale; m_light.Color = ThrustColor; m_light.GlareMaterial = BlockDefinition.FlameGlareMaterial; m_light.GlareQuerySize = BlockDefinition.FlameGlareQuerySize * CubeGrid.GridScale; m_glareSize = BlockDefinition.FlameGlareSize * CubeGrid.GridScale; m_maxBillboardDistanceSquared = BlockDefinition.FlameVisibilityDistance * BlockDefinition.FlameVisibilityDistance; m_maxLightDistanceSquared = m_maxBillboardDistanceSquared; m_light.Start(MyLight.LightTypeEnum.PointLight, 1); UpdateDetailedInfo(); FuelConverterDefinition = !MyFakes.ENABLE_HYDROGEN_FUEL ? new MyFuelConverterInfo { Efficiency = 1.0f } : BlockDefinition.FuelConverter; SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; }