public void UpdateLightProperties(float currentLightPower) { if (m_light != null) { m_light.ReflectorRange = MyCharacter.REFLECTOR_RANGE; m_light.ReflectorColor = MyCharacter.REFLECTOR_COLOR; m_light.ReflectorIntensity = MyCharacter.REFLECTOR_INTENSITY * currentLightPower; m_light.Color = MyCharacter.POINT_COLOR; m_light.SpecularColor = new Vector3(MyCharacter.POINT_COLOR_SPECULAR); m_light.Range = MyCharacter.POINT_LIGHT_RANGE; m_light.Intensity = MyCharacter.POINT_LIGHT_INTENSITY * currentLightPower; //MyTrace.Send(TraceWindow.Default, m_currentLightPower.ToString()); m_light.UpdateLight(); if (m_leftGlare != null) { m_leftGlare.GlareIntensity = m_light.Intensity; m_leftGlare.UpdateLight(); } if (m_rightGlare != null) { m_rightGlare.GlareIntensity = m_light.Intensity; m_rightGlare.UpdateLight(); } } }
public override void UpdateAfterSimulation() { base.UpdateAfterSimulation(); float oldPower = m_currentLightPower; float timeDeltaInSeconds = (MySandboxGame.TotalGamePlayTimeInMilliseconds - m_lastAnimationUpdateTime) / 1000f; float sign = (IsWorking) ? 1f : -1f; m_currentLightPower = MathHelper.Clamp(m_currentLightPower + sign * timeDeltaInSeconds / LIGHT_TURNING_ON_TIME_IN_SECONDS, 0, 1); m_lastAnimationUpdateTime = MySandboxGame.TotalGamePlayTimeInMilliseconds; if (m_currentLightPower <= 0) { m_light.LightOn = false; m_light.GlareOn = false; } else { m_light.LightOn = true; m_light.GlareOn = true; } if (oldPower != m_currentLightPower) { UpdateLightPosition(); m_light.UpdateLight(); UpdateEmissivity(); UpdateLightProperties(); } if (m_currentLightPower == (sign * 0.5f + 0.5f)) { AnimationRunning = false; } }
public override void ActiveUpdate() { float emissive = MathExtensions.TrianglePulse(m_updateCount, 1f, 150); //MyCubeBlockEmissive.SetEmissiveParts((MyEntity)m_owner, emissive, Color.FromNonPremultiplied(m_color) * 0f, Color.White); m_owner.SetEmissiveParts("Emissive-Beacon", Color.FromNonPremultiplied(m_color) * emissive, 1f); m_owner.SetEmissiveParts("Emissive0", Color.FromNonPremultiplied(m_color) * emissive, emissive); MyCubeBlockEmissive.SetEmissiveParts((MyEntity)m_owner, emissive, Color.FromNonPremultiplied(m_color) * emissive, Color.White); if (!m_owner.IsFunctional || !m_owner.Enabled) { if (m_soundEmitter != null) { if (m_soundEmitter.IsPlaying) { m_soundEmitter.StopSound(true); } } m_light.Intensity = 0f; m_light.GlareIntensity = 0f; m_light.UpdateLight(); return; } if (m_soundEmitter == null) { m_soundPair = new MySoundPair("NaniteBeacon"); m_soundEmitter = new MyEntity3DSoundEmitter((MyEntity)m_owner, true); m_soundEmitter.PlaySound(m_soundPair, true); } else if (!m_soundEmitter.IsPlaying) { m_soundEmitter.PlaySound(m_soundPair, true); } m_light.Intensity = MathExtensions.TrianglePulse(m_updateCount, 0.8f, 150); m_light.GlareIntensity = MathExtensions.TrianglePulse(m_updateCount, 0.8f, 150); //m_light.GlareSize = 0.098f; Vector3D position = m_owner.GetPosition(); if (m_owner.CubeGrid.GridSizeEnum == VRage.Game.MyCubeSize.Small) { Vector3D localPosition = new Vector3D(0f, 0.30f, 0f); position = Vector3D.Transform(localPosition + m_localOffset, m_owner.WorldMatrix); } else { Vector3D localPosition = new Vector3D(0f, -0.05f, 0f); position = Vector3D.Transform(localPosition + m_localOffset, m_owner.WorldMatrix); } m_light.Position = position; m_light.UpdateLight(); m_updateCount++; }
private void UpdateLightProperties() { if (m_light == null) { return; } ProfilerShort.Begin("UpdateLightProperties"); m_light.UpdateLight(); ProfilerShort.End(); }
public void UpdateLightPosition() { if (m_light != null) { MatrixD specMatrix = MatrixD.CreateWorld(Position, m_orientation.Forward, m_orientation.Up); m_reflectorAngleMatrix = MatrixD.CreateFromAxisAngle(specMatrix.Backward, MathHelper.ToRadians(MyCharacter.REFLECTOR_DIRECTION)); m_light.ReflectorDirection = Vector3.Transform(specMatrix.Forward, m_reflectorAngleMatrix); m_light.ReflectorUp = specMatrix.Up; m_light.Position = Position; m_light.UpdateLight(); } }
public void UpdateLightProperties(float currentLightPower) { if (m_light != null) { m_light.ReflectorIntensity = MyCharacter.REFLECTOR_INTENSITY * currentLightPower; m_light.Intensity = MyCharacter.POINT_LIGHT_INTENSITY * currentLightPower; //MyTrace.Send(TraceWindow.Default, m_currentLightPower.ToString()); m_light.UpdateLight(); } }
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. } }
private void UpdateEffect() { // Disable active effect when tool is too far (this is so that effects of other players in MP look better) if (CurrentEffect == 1 && m_raycastComponent.HitCubeGrid == null) { CurrentEffect = 2; } if (CurrentEffect == 2 && m_raycastComponent.HitCharacter != null) { CurrentEffect = 1; } //MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, 0.0f), "Updating effect!", Color.Red, 1.0f); switch (CurrentEffect) { case 0: StopLoopSound(); break; case 1: //MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, 30.0f), "Primary", Color.Red, 1.0f); StartLoopSound(true); break; case 2: //MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, 60.0f), "Secondary", Color.Red, 1.0f); StartLoopSound(false); break; } const float lightMuzzleOffset = 0.0f; const float particleMuzzleOffset = 1.0f; if (m_toolEffect != null) { m_toolEffect.WorldMatrix = GetEffectMatrix(particleMuzzleOffset); } if (m_toolSecondaryEffect != null) { m_toolSecondaryEffect.WorldMatrix = GetEffectMatrix(particleMuzzleOffset); } if (m_toolEffectLight != null) { m_toolEffectLight.Position = GetEffectMatrix(lightMuzzleOffset).Translation; if (CurrentEffect == 1) { m_toolEffectLight.Intensity = MyUtils.GetRandomFloat(m_handItemDef.LightIntensityLower, m_handItemDef.LightIntensityUpper); m_toolEffectLight.GlareIntensity = m_toolEffectLight.Intensity; m_toolEffectLight.GlareSize = m_toolEffectLight.Intensity * m_handItemDef.LightGlareSize; } else { m_toolEffectLight.Intensity = MyUtils.GetRandomFloat(SecondaryLightIntensityLower, SecondaryLightIntensityUpper); m_toolEffectLight.GlareIntensity = m_toolEffectLight.Intensity; m_toolEffectLight.GlareSize = m_toolEffectLight.Intensity * SecondaryLightGlareSize; } m_toolEffectLight.UpdateLight(); } }
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 void UpdateLight() { bool shouldLit = (float)Vector3D.DistanceSquared(MySector.MainCamera.Position, PositionComp.GetPosition()) < m_maxLightDistanceSquared;; if (ThrustRadiusRand > 0 && shouldLit && m_flames.Count > 0) { var f = m_flames[0]; var position = Vector3D.Transform(f.Position, PositionComp.WorldMatrix); float radius = ThrustRadiusRand * f.Radius; float length = ThrustLengthRand * f.Radius; float thickness = ThrustThicknessRand * f.Radius; Light.LightOn = true; Light.Intensity = 1.3f + length; Light.Range = radius * 2 + length / 10; Light.Position = Vector3D.Transform(position, MatrixD.Invert(CubeGrid.PositionComp.WorldMatrix)); Light.ParentID = CubeGrid.Render.GetRenderObjectID(); Light.GlareOn = true; if (((MyCubeGrid)Parent).GridSizeEnum == MyCubeSize.Large) { Light.GlareIntensity = 0.5f + length * 2; } else { Light.GlareIntensity = 0.5f + length * 2; } Light.GlareType = VRageRender.Lights.MyGlareTypeEnum.Normal; Light.GlareSize = (radius * 0.8f + length * 0.05f) * m_glareSize; Light.UpdateLight(); } else { if (Light.GlareOn || Light.LightOn) { Light.GlareOn = false; Light.LightOn = false; Light.UpdateLight(); } } }
public static void ToggleLight(MyLight light) { if (light != null) { light.LightOn = !light.LightOn; light.UpdateLight(); } }
protected override void UpdateEffects() { UpdateParticleMatrices(); if (m_effectLight != null) { m_effectLight.Position = GetLightPosition(); m_effectLight.UpdateLight(); } }
public void UpdateLight() { bool shouldLit = (float)Vector3D.DistanceSquared(MySector.MainCamera.Position, PositionComp.GetPosition()) < m_maxLightDistanceSquared;; if (ThrustRadiusRand > 0 && shouldLit && m_flames.Count > 0) { var f = m_flames[0]; var position = Vector3D.Transform(f.Position, PositionComp.WorldMatrix); float radius = ThrustRadiusRand * f.Radius * CubeGrid.GridScale; float length = ThrustLengthRand * f.Radius * CubeGrid.GridScale; Light.LightOn = true; Light.Intensity = LIGHT_INTENSITY_BASE + length * LIGHT_INTENSITY_LENGTH; Light.Range = radius * LIGHT_RANGE_RADIUS + length * LIGHT_RANGE_LENGTH; Light.Position = Vector3D.Transform(position, MatrixD.Invert(CubeGrid.PositionComp.WorldMatrix)); Light.ParentID = CubeGrid.Render.GetRenderObjectID(); Light.GlareOn = true; Light.GlareIntensity = GLARE_INTENSITY_BASE + length * GLARE_INTENSITY_LENGTH; Light.GlareType = VRageRender.Lights.MyGlareTypeEnum.Normal; Light.GlareSize = (radius * GLARE_SIZE_RADIUS + length * GLARE_SIZE_LENGTH) * m_glareSize * CubeGrid.GridScale; Light.UpdateLight(); } else { if (Light.GlareOn || Light.LightOn) { Light.GlareOn = false; Light.LightOn = false; Light.UpdateLight(); } } }
private void OnModelPositionChanged(MyPositionComponentBase pos) { // save turret position GetTurretOrientation(); //Logger.Instance.LogMessage("Forward:" + pos.GetOrientation().Forward.ToString()); // update light m_light_emmitter.ReflectorDirection = pos.GetOrientation().Forward; m_light_emmitter.ReflectorUp = pos.GetOrientation().Up; m_light_emmitter.Position = pos.GetPosition() + pos.GetOrientation().Forward *Light_Offset; m_light_emmitter.UpdateLight(); }
protected override void UpdateEffects() { if ((m_particleEffect1 != null || m_particleEffect2 != null) && m_sparks == false) { StopSparks(); } else if ((m_particleEffect1 == null || m_particleEffect2 == null) && m_sparks && m_wantsToGrind) { StartEffects(); } else { UpdateParticleMatrices(); } if (m_effectLight != null) { m_effectLight.Position = GetLightPosition(); m_effectLight.UpdateLight(); } }
private void MakeLight() { // light setup m_light_emmitter = new MyLight(); m_light_emmitter.Start(m_light_model.PositionComp.GetPosition(), Light_Color, 0, m_turret.DisplayNameText); m_light_emmitter.CastShadows = true; m_light_emmitter.LightType = MyLightType.SPOTLIGHT; m_light_emmitter.LightType = MyLightType.SPOTLIGHT; m_light_emmitter.Position = m_light_model.PositionComp.GetPosition() + m_light_model.PositionComp.GetOrientation().Forward *Light_Offset; /*m_light_emmitter.Falloff = 0.3f; * m_light_emmitter.GlossFactor = 1f;*/ m_light_emmitter.ParentID = m_light_model.Render.GetRenderObjectID(); /*m_light_emmitter.GlareOn = m_light_emmitter.LightOn; * m_light_emmitter.GlareQuerySize = GlareQuerySizeDef; * m_light_emmitter.GlareType = MyGlareTypeEnum.Directional; * m_light_emmitter.GlareSize = m_light_flare.Size; * m_light_emmitter.SubGlares = m_light_flare.SubGlares;*/ //m_light_flare = MyDefinitionManager.Static.GetDefinition(new MyDefinitionId((MyObjectBuilderType)typeof(MyObjectBuilder_FlareDefinition), "NoFlare")) as MyFlareDefinition ?? new MyFlareDefinition(); //m_light_emmitter.ReflectorTexture = m_light_cone_texture_path; m_light_emmitter.ReflectorGlossFactor = 1f; m_light_emmitter.ReflectorFalloff = 0.3f; m_light_emmitter.ReflectorColor = Light_Color; m_light_emmitter.ReflectorIntensity = Light_Intensity; m_light_emmitter.ReflectorDirection = m_light_model.PositionComp.GetOrientation().Forward; m_light_emmitter.ReflectorUp = m_light_model.PositionComp.GetOrientation().Up; m_light_emmitter.ReflectorRange = Light_Radius; m_light_emmitter.ReflectorOn = m_turret.IsWorking; m_light_emmitter.LightOn = false; m_light_emmitter.UpdateLight(); //m_light_model.Render.NeedsDrawFromParent = true; }
public void Update100() { if (m_beaconLight != null && m_beaconLight.Intensity != 0f) { m_beaconLight.GlareIntensity = 0f; m_beaconLight.Intensity = 0f; m_beaconLight.ReflectorIntensity = 0f; m_beaconLight.UpdateLight(); } if (myLock.TryAcquireExclusive()) { if (m_node == null) { if (!Registrar.TryGetValue(Entity, out m_node)) { Log.DebugLog("failed to get node"); return; } } if (m_node.Storage == null) { Log.DebugLog("no storage"); return; } // actions on main thread CheckCustomInfo(); //if (myLastSeen.Count > 0) //{ // Log.DebugLog("sending to storage: " + myLastSeen.Count); // m_node.Storage.Receive(myLastSeen); //} myThread.EnqueueAction(Update_OnThread); } }
public bool Draw() { if (thrust.MarkedForClose || thrust.Closed) { return(false); // remove from list } MatrixD cm = MyAPIGateway.Session.Camera.WorldMatrix; if (thrust.IsWorking && Vector3D.DistanceSquared(cm.Translation, thrust.WorldMatrix.Translation) <= maxViewDistSq) { if (firstFunctional) { firstFunctional = false; GetFlameInfo(); // needed here because it relies on getting dummies from the main model } float ClosedMultiplier = 1f; if (Reverser != null) { if (Reverser.MarkedForClose || Reverser.Closed) { Reverser = null; } else { ClosedMultiplier = 1 - Reverser.ReflectedThrust; } } bool paused = MyParticlesManager.Paused; Sandbox.Definitions.MyThrustDefinition def = thrust.BlockDefinition; float amount = Math.Min(thrust.CurrentStrength * 2, 1); if (!paused) { float lengthTarget = Math.Max(amount, 0.25f) * length * 3f * MyUtils.GetRandomFloat(0.9f, 1.1f) * ClosedMultiplier; thrustLerpLength = lengthTarget; // MathHelper.Lerp(thrustLerpLength, lengthTarget, 0.3f); float thickTarget = thickness * MyUtils.GetRandomFloat(0.9f, 1.1f); thrustLerpThick = thickTarget; // MathHelper.Lerp(thrustLerpThick, thickTarget, 0.2f); thurstLerpColor = MathHelper.Lerp(thurstLerpColor, amount, 0.25f); } //var trailColor = Vector4.Lerp(new Vector4(1f, 0.3f, 0f, 1f) * 0.25f, new Vector4(0.5f, 0.6f, 1f, 1f) * 0.75f, thurstLerpColor); Vector4 trailColor = Vector4.Lerp(new Vector4(0.5f, 0.6f, 1f, 1f) * 0.25f, new Vector4(1f, 0.3f, 0f, 1f), thurstLerpColor); Vector4 insideColor = trailColor; // Vector4.Lerp(new Vector4(1f, 0.3f, 0f, 1f) * 0.5f, new Vector4(1f, 1f, 0.9f, 1f), thurstLerpColor); Vector4 lightColor = insideColor; // Vector4.Lerp(new Vector4(1f, 0.3f, 0f, 1f), new Vector4(1f, 0.5f, 0.25f, 1f), thurstLerpColor); MatrixD m = thrust.WorldMatrix; float gridScale = thrust.CubeGrid.GridScale; MyStringId material = ThrustReversersMod.Instance.THRUST_MATERIAL; for (int i = 0; i < flames.Count; ++i) { FlameInfo flame = flames[i]; Vector3D direction = Vector3D.TransformNormal((Vector3D)flame.Direction, m); Vector3D position = Vector3D.Transform((Vector3D)flame.LocalFrom, m); Vector3D trailPos = position + (direction * trailOffset); Vector3 dirToCam = Vector3.Normalize(cm.Translation - position); float dot = Vector3.Dot(dirToCam, direction); float trailAlpha = 0.5f; float pointsAlpha = 2f; const float TRAIL_ANGLE_LIMIT = 0.95f; const float POINTS_ANGLE_START = 0.9f; const float POINTS_ANGLE_END = 0.35f; if (dot > TRAIL_ANGLE_LIMIT) { trailAlpha *= 1 - ((dot - TRAIL_ANGLE_LIMIT) / (1 - TRAIL_ANGLE_LIMIT)); } if (dot < POINTS_ANGLE_END) { pointsAlpha = 0; } else if (dot < POINTS_ANGLE_START) { pointsAlpha *= (dot - POINTS_ANGLE_END) / (POINTS_ANGLE_START - POINTS_ANGLE_END); } if (trailAlpha > 0) { MyTransparentGeometry.AddLineBillboard(material, trailColor * trailAlpha, trailPos, direction, thrustLerpLength, JET_FLAME_SCALE_MUL * thrustLerpThick, blendType: BLEND_TYPE); } if (pointsAlpha > 0) { MyTransparentGeometry.AddBillboardOriented(ThrustReversersMod.Instance.POINT_MATERIAL, trailColor * pointsAlpha, position + (direction * pointOffset), m.Left, m.Up, (thickness * pointScaleMul), blendType: BLEND_TYPE); } float coneHeightFinal = coneHeight * (paused ? 1 : MyUtils.GetRandomFloat(0.9f, 1.1f)); MatrixD coneMatrix = MatrixD.CreateWorld(position + (direction * (coneOffset + coneHeightFinal)), -direction, m.Up); Color coneColor = new Color(insideColor); DrawTransparentCone(ref coneMatrix, coneRadius, coneHeightFinal, ref coneColor, 16, ThrustReversersMod.Instance.CONE_MATERIAL, blendType: BLEND_TYPE); } // TODO reflected flames //if(ClosedMultiplier < 1 && amount > 0) //{ // float reflectedTrailOffset = -0.25f; // float reflectedTrailHeight = 1.5f; // // var door = (MyAdvancedDoor)Reverser.Entity; // // foreach(var part in door.Subparts.Values) // { // var pm = part.WorldMatrix; // // MyTransparentGeometry.AddBillboardOriented(ThrustReversersMod.Instance.THRUST_MATERIAL, trailColor * (1 - ClosedMultiplier), pm.Translation + (pm.Forward * reflectedTrailOffset) + pm.Up * (reflectedTrailHeight * 0.5), pm.Left, pm.Down, 0.5f, reflectedTrailHeight); // } //} light.LightOn = true; light.Position = m.Translation + (m.Forward * lightOffset); light.Color = lightColor; light.Intensity = 100 * Math.Max(trailColor.W * 2, 0.5f); light.Falloff = 3f; light.Range = thrustLerpThick * 2f; light.UpdateLight(); lightJet.LightOn = true; lightJet.Position = m.Translation + (m.Forward * lightJetOffset); lightJet.Color = trailColor; lightJet.Falloff = 1f; lightJet.Range = thrustLerpLength * 0.75f; lightJet.Intensity = 10 * trailColor.W; lightJet.UpdateLight(); } else { if (light.LightOn) { light.LightOn = false; light.UpdateLight(); } if (lightJet.LightOn) { lightJet.LightOn = false; lightJet.UpdateLight(); } } return(true); // keep in list }
public override void Draw() { base.Draw(); UpdateCharacterSkeleton(); VRageRender.MyRenderProxy.SetCharacterTransforms(RenderObjectIDs[0], m_character.BoneRelativeTransforms); Matrix headMatrix = m_character.GetHeadMatrix(false); Vector3 position = m_light.Position; Vector3 forwardVector = m_light.ReflectorDirection; Vector3 leftVector = headMatrix.Left; Vector3 upVector = headMatrix.Up; float reflectorLength = MyCharacter.REFLECTOR_BILLBOARD_LENGTH * 0.4f * 0.16f; float reflectorThickness = MyCharacter.REFLECTOR_BILLBOARD_THICKNESS * 0.08f; //float reflectorRadiusForAdditive = 0.25f;//0.65f; Vector3 color = new Vector3(m_light.ReflectorColor); Vector3 glarePosition = position + forwardVector * 0.28f; var dot = Vector3.Dot(Vector3.Normalize(MySector.MainCamera.Position - glarePosition), forwardVector); float angle = 1 - Math.Abs(dot); float alphaGlareAlphaBlended = (float)Math.Pow(1 - angle, 2); float alphaGlareAdditive = (float)Math.Pow(1 - angle, 2); float alphaCone = (1 - (float)Math.Pow(1 - angle, 30)) * 0.5f; float reflectorRadiusForAlphaBlended = MathHelper.Lerp(0.1f, 0.5f, alphaGlareAlphaBlended); //3.5f; // Multiply alpha by reflector level (and not the color), because if we multiply the color and let alpha unchanged, reflector cune will be drawn as very dark cone, but still visible var reflectorLevel = m_character.CurrentLightPower; m_light.ReflectorIntensity = reflectorLevel; alphaCone *= reflectorLevel * 0.2f; alphaGlareAlphaBlended *= reflectorLevel * 0.1f; alphaGlareAdditive *= reflectorLevel * 0.8f; float distance = Vector3.Distance(m_character.PositionComp.GetPosition(), MySector.MainCamera.Position); if (!m_character.IsInFirstPersonView && distance < MyCharacter.LIGHT_GLARE_MAX_DISTANCE && reflectorLevel > 0) { float alpha = MathHelper.Clamp((MyCharacter.LIGHT_GLARE_MAX_DISTANCE - 10.0f) / distance, 0, 1); if (reflectorLength > 0 && reflectorThickness > 0) { if (m_leftGlare != null) { MyTransparentGeometry.AddLineBillboard("ReflectorConeCharacter", new Vector4(color, 1.0f) * alphaCone * alpha, m_leftGlare.Position, m_leftGlare.ReflectorDirection, reflectorLength, reflectorThickness); } if (m_rightGlare != null) { MyTransparentGeometry.AddLineBillboard("ReflectorConeCharacter", new Vector4(color, 1.0f) * alphaCone * alpha, m_rightGlare.Position, m_rightGlare.ReflectorDirection, reflectorLength, reflectorThickness); } } if (m_leftGlare != null) { MyTransparentGeometry.AddPointBillboard("ReflectorGlareAlphaBlended", new Vector4(color, 1.0f) * alphaGlareAlphaBlended * alpha, m_leftGlare.Position, reflectorRadiusForAlphaBlended * 0.3f, 0); } if (m_rightGlare != null) { MyTransparentGeometry.AddPointBillboard("ReflectorGlareAlphaBlended", new Vector4(color, 1.0f) * alphaGlareAlphaBlended * alpha, m_rightGlare.Position, reflectorRadiusForAlphaBlended * 0.3f, 0); } } DrawJetpackThrusts(m_character.UpdateCalled()); if (m_character.Hierarchy.Parent != null) { if (m_leftGlare != null && m_leftGlare.LightOn == true) { m_leftGlare.LightOn = false; m_leftGlare.GlareOn = false; m_leftGlare.UpdateLight(); } if (m_rightGlare != null && m_rightGlare.LightOn == true) { m_rightGlare.LightOn = false; m_rightGlare.GlareOn = false; m_rightGlare.UpdateLight(); } } else { if (m_leftGlare != null && m_leftGlare.LightOn == false) { m_leftGlare.LightOn = true; m_leftGlare.GlareOn = true; m_leftGlare.UpdateLight(); } if (m_rightGlare != null && m_rightGlare.LightOn == true) { m_rightGlare.LightOn = true; m_rightGlare.GlareOn = true; m_rightGlare.UpdateLight(); } } if (MySession.ControlledEntity == m_character) { if (m_character.IsDead && m_character.CurrentRespawnCounter > 0) { DrawBlood(1); } if (!m_character.IsDead && m_currentHitIndicatorCounter > 0) { m_currentHitIndicatorCounter -= MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS; if (m_currentHitIndicatorCounter < 0) { m_currentHitIndicatorCounter = 0; } float alpha = m_currentHitIndicatorCounter / HIT_INDICATOR_LENGTH; DrawBlood(alpha); } if (m_character.StatComp != null) { var healthRatio = m_character.StatComp.HealthRatio; if (healthRatio <= MyCharacterStatComponent.LOW_HEALTH_RATIO && !m_character.IsDead) { float alpha = MathHelper.Clamp(MyCharacterStatComponent.LOW_HEALTH_RATIO - healthRatio, 0, 1) / MyCharacterStatComponent.LOW_HEALTH_RATIO + 0.3f; DrawBlood(alpha); } } } //DebugDraw(); }