/// <summary> /// Setzt die Farbe des Sonnenlichts /// </summary> /// <param name="red">Rotanteil</param> /// <param name="green">Grünanteil</param> /// <param name="blue">Blauanteil</param> /// <param name="intensity">Helligkeitsanteil</param> public void SetSunColor(float red, float green, float blue, float intensity) { _sunColor.X = HelperGL.Clamp(red, 0, 1); _sunColor.Y = HelperGL.Clamp(green, 0, 1); _sunColor.Z = HelperGL.Clamp(blue, 0, 1); _sunColor.W = HelperGL.Clamp(intensity, 0, 1); }
/// <summary> /// Setzt die Partikelfärbung /// </summary> /// <param name="red">Rot</param> /// <param name="green">Grün</param> /// <param name="blue">Blau</param> /// <param name="intensity">Helligkeit</param> public void SetColor(float red, float green, float blue, float intensity) { _tint.X = HelperGL.Clamp(red, 0, 1); _tint.Y = HelperGL.Clamp(green, 0, 1); _tint.Z = HelperGL.Clamp(blue, 0, 1); _tint.W = HelperGL.Clamp(intensity, 0, 1); }
internal void SetTextureBackgroundInternal(string filename, float repeatX = 1, float repeatY = 1, float red = 1, float green = 1, float blue = 1, float intensity = 1, bool isFile = true) { if (filename == null || filename.Length < 1) { _textureBackground = -1; _textureBackgroundTint = Vector4.Zero; } else { if (KWEngine.CustomTextures[this].ContainsKey(filename)) { _textureBackground = KWEngine.CustomTextures[this][filename]; } else { _textureBackground = isFile ? HelperTexture.LoadTextureForBackgroundExternal(filename) : HelperTexture.LoadTextureForBackgroundInternal(filename); KWEngine.CustomTextures[this].Add(filename, _textureBackground); } _textureBackgroundTint.X = HelperGL.Clamp(red, 0, 1); _textureBackgroundTint.Y = HelperGL.Clamp(green, 0, 1); _textureBackgroundTint.Z = HelperGL.Clamp(blue, 0, 1); _textureBackgroundTint.W = HelperGL.Clamp(intensity, 0, 1); _textureBackgroundTransform.X = HelperGL.Clamp(repeatX, 0.001f, 8192); _textureBackgroundTransform.Y = HelperGL.Clamp(repeatY, 0.001f, 8192); _textureSkybox = -1; } }
/// <summary> /// Glow-Effekt des Objekts /// </summary> /// <param name="red">Rot</param> /// <param name="green">Grün</param> /// <param name="blue">Blau</param> /// <param name="intensity">Intensität</param> public void SetGlow(float red, float green, float blue, float intensity) { _glow.X = HelperGL.Clamp(red, 0, 1); _glow.Y = HelperGL.Clamp(green, 0, 1); _glow.Z = HelperGL.Clamp(blue, 0, 1); _glow.W = HelperGL.Clamp(intensity, 0, 1); }
public void SetBloom(float red, float green, float blue, float intensity) { _bloom.X = HelperGL.Clamp(red, 0, 1); _bloom.Y = HelperGL.Clamp(green, 0, 1); _bloom.Z = HelperGL.Clamp(blue, 0, 1); _bloom.W = HelperGL.Clamp(intensity, 0, 1); }
/// <summary> /// Setzt die Größe /// </summary> /// <param name="width">Breite</param> /// <param name="height">Höhe</param> public void SetScale(float width, float height) { _scale.X = HelperGL.Clamp(width, 0.001f, float.MaxValue); _scale.Y = HelperGL.Clamp(height, 0.001f, float.MaxValue); _scale.Z = 1; _scaleMatrix = Matrix4.CreateScale(_scale); UpdatePositions(); }
private void SetFOVShadowPrivate(float fov) { FOVShadow2 = HelperGL.Clamp(fov, 60, 179); if (KWEngine.CurrentWorld != null) { _projectionMatrixShadow2 = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(FOVShadow2 / 2), KWEngine.ShadowMapSize / (float)KWEngine.ShadowMapSize, 1f, CurrentWorld != null ? CurrentWorld.ZFar / 10 : 100f); UpdateMatrices(); } }
public static void SoundChangeGain(int sourceId, float gain) { if (mAudioOn) { gain = HelperGL.Clamp(gain, 0, 8); if (mSources[sourceId] != null && mSources[sourceId].IsPlaying) { AL.Source(mSources[sourceId].GetSourceId(), ALSourcef.Gain, gain); } } }
/// <summary> /// Setzt den Koeffizienten für die Berechnung der Schatten der LightObject-Instanz /// </summary> /// <param name="bias">Biaswert (Standard: 0.005f; Bereich: 0.00001f bis 1f)</param> public void SetFOVShadowBiasCoefficient(float bias = 0.005f) { if (Type != LightType.DirectionalShadow) { throw new Exception("Cannot set FOV for a LightObject that is not of Type 'DirectionalShadow'."); } else { ShadowMapBiasCoefficient = HelperGL.Clamp(bias, 0.00001f, 1); } }
/// <summary> /// Konstruktormethode für Partikel /// </summary> /// <param name="position">Position</param> /// <param name="scale">Größe in x-, y- und z-Richtung</param> /// <param name="type">Art</param> public ParticleObject(Vector3 position, Vector3 scale, ParticleType type) { _scale.X = HelperGL.Clamp(scale.X, 0.001f, float.MaxValue); _scale.Y = HelperGL.Clamp(scale.Y, 0.001f, float.MaxValue); _scale.Z = HelperGL.Clamp(scale.Z, 0.001f, float.MaxValue); _scaleCurrent.X = HelperGL.Clamp(scale.X, 0.001f, float.MaxValue); _scaleCurrent.Y = HelperGL.Clamp(scale.Y, 0.001f, float.MaxValue); _scaleCurrent.Z = HelperGL.Clamp(scale.Z, 0.001f, float.MaxValue); Position = position; _type = type; _info = KWEngine.ParticleDictionary[_type]; }
/// <summary> /// Setzt das Field of View (in Grad) für das schattenwerfende Licht (DirectionalShadow) /// </summary> /// <param name="fov">Blickfeld nach links und rechts in Grad (Minimum: 60, Maximum: 180)</param> public void SetFOVShadow(float fov) { if (Type != LightType.DirectionalShadow) { throw new Exception("Cannot set FOV for a LightObject that is not of Type 'DirectionalShadow'."); } else { FOVShadow2 = HelperGL.Clamp(fov, 60, 179); if (KWEngine.CurrentWorld != null) { _projectionMatrixShadow2 = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(FOVShadow2 / 2), KWEngine.ShadowMapSize / (float)KWEngine.ShadowMapSize, 1f, CurrentWorld != null ? CurrentWorld.ZFar / 10 : 100f); UpdateMatrices(); } } }
internal void SetTextureSkyboxInternal(string filename, float red = 1, float green = 1, float blue = 1, float intensity = 1, bool isFile = true) { if (filename == null || filename.Length < 1) { _textureSkybox = -1; } else { if (KWEngine.CustomTextures[this].ContainsKey(filename)) { _textureSkybox = KWEngine.CustomTextures[this][filename]; } else { _textureSkybox = HelperTexture.LoadTextureSkybox(filename, !isFile); } _textureBackgroundTint.X = HelperGL.Clamp(red, 0, 1); _textureBackgroundTint.Y = HelperGL.Clamp(green, 0, 1); _textureBackgroundTint.Z = HelperGL.Clamp(blue, 0, 1); _textureBackgroundTint.W = HelperGL.Clamp(intensity, 0, 1); _textureBackground = -1; } }
internal void Draw(Explosion e, ref Matrix4 viewProjection) { if (e == null || e._model == null || e._currentWorld == null) { return; } GL.UseProgram(mProgramId); lock (e) { int type = (int)e._type; GL.Uniform4(mUniform_Glow, e.Glow.X, e.Glow.Y, e.Glow.Z, e.Glow.W); GL.Uniform1(mUniform_SunAmbient, HelperGL.Clamp(e._currentWorld.SunAmbientFactor * 2f, 0, 1)); GL.Uniform1(mUniform_Number, (float)e._amount); GL.Uniform1(mUniform_Spread, e._spread); GL.Uniform3(mUniform_Position, e.Position); GL.Uniform1(mUniform_Time, e._secondsAlive / e._duration); GL.Uniform1(mUniform_Size, e._particleSize); GL.Uniform1(mUniform_Algorithm, e._algorithm); GL.Uniform3(mUniform_TintColor, e.Color); if (type < 100) { GL.Uniform1(mUniform_Towards, 0); } else if (type >= 100 && type < 1000) { GL.Uniform1(mUniform_Towards, 1); } else { GL.Uniform1(mUniform_Towards, 2); } GL.Uniform4(mUniform_Axes, e._amount, e._directions); GL.UniformMatrix4(mUniform_VP, false, ref viewProjection); GL.Uniform2(mUniform_TextureTransform, e._textureTransform.X, e._textureTransform.Y); if (e._textureId > 0) { GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, e._textureId); GL.Uniform1(mUniform_Texture, 0); GL.Uniform1(mUniform_TextureUse, 1); } else { GL.Uniform1(mUniform_TextureUse, 0); } GeoMesh mesh = e._model.Meshes.ElementAt(0).Value; GL.BindVertexArray(mesh.VAO); GL.BindBuffer(BufferTarget.ElementArrayBuffer, mesh.VBOIndex); GL.DrawElementsInstanced(mesh.Primitive, mesh.IndexCount, DrawElementsType.UnsignedInt, IntPtr.Zero, e._amount); GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0); GL.BindVertexArray(0); } GL.UseProgram(0); }