protected override void InitLight(MyLight light, Vector4 color, float radius, float falloff) { light.Start(MyLight.LightTypeEnum.PointLight, color, falloff, radius); light.ReflectorDirection = WorldMatrix.Forward; light.ReflectorUp = WorldMatrix.Up; light.PointLightOffset = 0.5f; light.GlareOn = true; light.GlareIntensity = 0.4f; light.GlareQuerySize = 1; light.GlareMaterial = BlockDefinition.LightGlare; light.GlareType = VRageRender.Lights.MyGlareTypeEnum.Normal; light.GlareSize = 0.327f; }
protected override void InitLight(MyLight light, Vector4 color, float radius, float falloff) { light.Start(MyLight.LightTypeEnum.PointLight | MyLight.LightTypeEnum.Spotlight, color, falloff, radius); light.ShadowDistance = 20; light.LightOwner = MyLight.LightOwnerEnum.SmallShip; light.UseInForwardRender = true; light.ReflectorTexture = BlockDefinition.ReflectorTexture; light.ReflectorFalloff = 5; light.GlareOn = true; light.GlareIntensity = 1f; light.GlareQuerySize = GlareQuerySizeDef; light.GlareType = VRageRender.Lights.MyGlareTypeEnum.Normal; light.GlareMaterial = BlockDefinition.LightGlare; light.GlareSize = ReflectorGlareSizeDef; }
protected override void InitLight(MyLight light, Vector4 color, float radius, float falloff) { light.Start(MyLight.LightTypeEnum.PointLight | MyLight.LightTypeEnum.Spotlight, color, falloff, CubeGrid.GridScale * radius); /// todo: defaults should be supplied from Environemnt.sbc light.ShadowDistance = 20; light.LightOwner = MyLight.LightOwnerEnum.SmallShip; light.UseInForwardRender = true; light.ReflectorTexture = BlockDefinition.ReflectorTexture; light.Falloff = 0.3f; light.GlossFactor = 0; light.ReflectorGlossFactor = 0.65f; light.DiffuseFactor = 3.14f; light.PointLightOffset = 0.15f; light.GlareOn = true; light.GlareIntensity = 1f; light.GlareQuerySize = GlareQuerySizeDef; light.GlareType = VRageRender.Lights.MyGlareTypeEnum.Normal; light.GlareMaterial = BlockDefinition.LightGlare; light.GlareSize = ReflectorGlareSizeDef; }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { base.Init(objectBuilder, cubeGrid); BlockDefinition = (MyThrustDefinition)base.BlockDefinition; var builder = (MyObjectBuilder_Thrust)objectBuilder; ThrustColor = BlockDefinition.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 = ThrustColor; m_light.GlareMaterial = BlockDefinition.FlameGlareMaterial; m_light.GlareQuerySize = BlockDefinition.FlameGlareQuerySize; m_glareSize = BlockDefinition.FlameGlareSize; m_maxBillboardDistanceSquared = BlockDefinition.FlameVisibilityDistance*BlockDefinition.FlameVisibilityDistance; m_maxLightDistanceSquared = m_maxBillboardDistanceSquared / 100; m_light.Start(MyLight.LightTypeEnum.PointLight, 1); SyncObject = new MySyncThruster(this); UpdateDetailedInfo(); FuelConverterDefinition = !MyFakes.ENABLE_HYDROGEN_FUEL ? new MyFuelConverterInfo { Efficiency = 1.0f } : BlockDefinition.FuelConverter; 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, }; MyEntityThrustComponent entityThrustComponent; if (!cubeGrid.Components.TryGet(out entityThrustComponent)) { entityThrustComponent = new MyThrusterBlockThrustComponent(); entityThrustComponent.Init(); cubeGrid.Components.Add<MyEntityThrustComponent>(entityThrustComponent); } m_thrustComponent = entityThrustComponent; }
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 ? 15f : 0.2f; 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 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 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; } }
// 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; } }
// ------------------------------------------------------------------------------------------------ #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.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; }
void StartInternal() { VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyExplosion.StartInternal"); m_velocity = m_explosionInfo.Velocity; m_explosionSphere = m_explosionInfo.ExplosionSphere; if (m_explosionInfo.PlaySound) { // Play explosion sound VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Sound"); PlaySound(); VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); } // Light of explosion VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Light"); m_light = MyLights.AddLight(); if (m_light != null) { m_light.Start(MyLight.LightTypeEnum.PointLight, m_explosionSphere.Center, MyExplosionsConstants.EXPLOSION_LIGHT_COLOR, 1, Math.Min((float)m_explosionSphere.Radius * 8.0f, MyLightsConstants.MAX_POINTLIGHT_RADIUS)); m_light.Intensity = 2.0f; m_light.Range = Math.Min((float)m_explosionSphere.Radius * 3.0f, MyLightsConstants.MAX_POINTLIGHT_RADIUS); } VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); // Particles if (m_explosionInfo.CreateParticleEffect) { CreateParticleEffectInternal(); } m_explosionTriggered = false; VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); }
void StartInternal() { VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyExplosion.StartInternal"); if (m_soundEmitter == null) m_soundEmitter = new MyEntity3DSoundEmitter(null); m_velocity = m_explosionInfo.Velocity; m_explosionSphere = m_explosionInfo.ExplosionSphere; if (m_explosionInfo.PlaySound) { VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Sound"); // Play explosion sound PlaySound(); VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); } VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Light"); // Light of explosion m_light = MyLights.AddLight(); if (m_light != null) { m_light.Start(MyLight.LightTypeEnum.PointLight, m_explosionSphere.Center, MyExplosionsConstants.EXPLOSION_LIGHT_COLOR, 1, Math.Min((float)m_explosionSphere.Radius * 8.0f, MyLightsConstants.MAX_POINTLIGHT_RADIUS)); m_light.Intensity = 2.0f; m_light.Range = Math.Min((float)m_explosionSphere.Radius * 3.0f, MyLightsConstants.MAX_POINTLIGHT_RADIUS); } VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); MyParticleEffectsIDEnum newParticlesType; switch (m_explosionInfo.ExplosionType) { case MyExplosionTypeEnum.MISSILE_EXPLOSION: newParticlesType = MyParticleEffectsIDEnum.Explosion_Missile; break; case MyExplosionTypeEnum.BOMB_EXPLOSION: newParticlesType = MyParticleEffectsIDEnum.Explosion_Bomb; break; case MyExplosionTypeEnum.AMMO_EXPLOSION: newParticlesType = MyParticleEffectsIDEnum.Explosion_Ammo; break; case MyExplosionTypeEnum.GRID_DEFORMATION: newParticlesType = MyParticleEffectsIDEnum.Grid_Deformation; break; case MyExplosionTypeEnum.GRID_DESTRUCTION: newParticlesType = MyParticleEffectsIDEnum.Grid_Destruction; break; case MyExplosionTypeEnum.WARHEAD_EXPLOSION_02: newParticlesType = MyParticleEffectsIDEnum.Explosion_Warhead_02; break; case MyExplosionTypeEnum.WARHEAD_EXPLOSION_15: newParticlesType = MyParticleEffectsIDEnum.Explosion_Warhead_15; break; case MyExplosionTypeEnum.WARHEAD_EXPLOSION_30: newParticlesType = MyParticleEffectsIDEnum.Explosion_Warhead_30; break; case MyExplosionTypeEnum.WARHEAD_EXPLOSION_50: newParticlesType = MyParticleEffectsIDEnum.Explosion_Warhead_50; break; default: throw new System.NotImplementedException(); break; } if (m_explosionInfo.CreateParticleEffect) { VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Particles"); // Explosion particles GenerateExplosionParticles(newParticlesType, m_explosionSphere, m_explosionInfo.ParticleScale); VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); } m_explosionTriggered = false; VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); }
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; } }