// This method is called when the fur objects is rendered. private Vector3 ComputeFurDisplacement(DelegateParameterBinding <Vector3> binding, RenderContext context) { // Animate the fur using a periodic animation. float p = (((float)_time.TotalSeconds) / 5.0f); float deltaX = (float)(Math.Pow(Math.Sin(p), 2) + Math.Cos(16 * p) + 1) * 0.001f; float deltaZ = (float)Math.Cos(2 * p) * 0.002f; Vector3F furDisplacement = new Vector3F(deltaX, -0.01f, deltaZ); // Add the current rigid body movement to the displacement. var meshNode = (MeshNode)context.SceneNode; var rigidBody = (RigidBody)meshNode.UserData; furDisplacement += -Vector3F.Clamp(rigidBody.LinearVelocity * 0.1f, -0.02f, 0.02f); return((Vector3)furDisplacement); }
private Vector3 GetSunDirection(DelegateParameterBinding<Vector3> binding, RenderContext context) { return (Vector3)DynamicSkyObject.SunDirection; }
// A callback for a DelegateParameterBinding which provides the shadow color. private Vector4 GetShadowColor(DelegateParameterBinding <Vector4> delegateParameterBinding, RenderContext renderContext) { return(_shadowColor); }
// A callback for a DelegateParameterBinding which provides the shadow matrix. private Matrix GetShadowMatrix(DelegateParameterBinding <Matrix> delegateParameterBinding, RenderContext renderContext) { return(_shadowMatrix); }
// This method is called when the fur objects is rendered. private Vector3 ComputeFurDisplacement(DelegateParameterBinding<Vector3> binding, RenderContext context) { // Animate the fur using a periodic animation. float p = (((float)_time.TotalSeconds) / 5.0f); float deltaX = (float)(Math.Pow(Math.Sin(p), 2) + Math.Cos(16 * p) + 1) * 0.001f; float deltaZ = (float)Math.Cos(2 * p) * 0.002f; Vector3F furDisplacement = new Vector3F(deltaX, -0.01f, deltaZ); // Add the current rigid body movement to the displacement. var meshNode = (MeshNode)context.SceneNode; var rigidBody = (RigidBody)meshNode.UserData; furDisplacement += -Vector3F.Clamp(rigidBody.LinearVelocity * 0.1f, -0.02f, 0.02f); return (Vector3)furDisplacement; }
private static Texture2D GetDetailClipmapTexture(DelegateParameterBinding<Texture2D> binding, RenderContext context) { var usage = binding.Description; int index = (usage != null) ? usage.Index : 0; var textures = GetTerrainNode(context).DetailClipmap.Textures; if (index < textures.Length) return textures[index]; return null; }
private Vector3 GetSunDirection(DelegateParameterBinding <Vector3> binding, RenderContext context) { return((Vector3)DynamicSkyObject.SunDirection); }
// A callback for a DelegateParameterBinding which provides the shadow matrix. private Matrix GetShadowMatrix(DelegateParameterBinding<Matrix> delegateParameterBinding, RenderContext renderContext) { return _shadowMatrix; }
private static Vector2 GetTerrainSize(DelegateParameterBinding<Vector2> binding, RenderContext context) { var terrainTile = GetTerrainTile(context); return new Vector2(terrainTile.WidthX, terrainTile.WidthZ); }
private static Vector2 GetTerrainOrigin(DelegateParameterBinding<Vector2> binding, RenderContext context) { var terrainTile = GetTerrainTile(context); return new Vector2(terrainTile.OriginX, terrainTile.OriginZ); }
private static Vector2 GetTerrainNormalTextureSize(DelegateParameterBinding<Vector2> binding, RenderContext context) { var texture = GetTerrainNormalTexture(null, context); return new Vector2(texture.Width, texture.Height); }
private static Texture2D GetTerrainNormalTexture(DelegateParameterBinding<Texture2D> binding, RenderContext context) { return GetTerrainTile(context).NormalTexture ?? context.GraphicsService.GetDefaultNormalTexture(); }
private static float GetHoleThreshold(DelegateParameterBinding<float> binding, RenderContext context) { return GetTerrainNode(context).HoleThreshold; }
private static float GetDetailFadeRange(DelegateParameterBinding<float> binding, RenderContext context) { return GetTerrainNode(context).DetailFadeRange; }
private static float GetDetailEnableAnisotropicFiltering(DelegateParameterBinding<float> binding, RenderContext context) { return GetTerrainNode(context).DetailClipmap.EnableAnisotropicFiltering ? 1 : 0; }
private Vector3 GetSkyLight(DelegateParameterBinding<Vector3> binding, RenderContext context) { return (Vector3)DynamicSkyObject.AmbientLight; }
private static float GetBaseClipmapCellsPerLevel(DelegateParameterBinding<float> binding, RenderContext context) { return GetTerrainNode(context).BaseClipmap.CellsPerLevel; }
private static float GetBaseClipmapLevelBias(DelegateParameterBinding<float> binding, RenderContext context) { return GetTerrainNode(context).BaseClipmap.LevelBias; }
// A callback for a DelegateParameterBinding which provides the shadow color. private Vector4 GetShadowColor(DelegateParameterBinding<Vector4> delegateParameterBinding, RenderContext renderContext) { return _shadowColor; }
private static float GetBaseClipmapNumberOfColumns(DelegateParameterBinding<float> binding, RenderContext context) { return GetTerrainNode(context).BaseClipmap.NumberOfTextureAtlasColumns; }
private Vector3 GetSkyLight(DelegateParameterBinding <Vector3> binding, RenderContext context) { return((Vector3)DynamicSkyObject.AmbientLight); }
private static float GetDetailClipmapNumberOfLevels(DelegateParameterBinding<float> binding, RenderContext context) { return GetTerrainNode(context).DetailClipmap.NumberOfLevels; }