示例#1
0
        // 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);
        }
示例#2
0
 private Vector3 GetSunDirection(DelegateParameterBinding<Vector3> binding, RenderContext context)
 {
   return (Vector3)DynamicSkyObject.SunDirection;
 }
示例#3
0
 // A callback for a DelegateParameterBinding which provides the shadow color.
 private Vector4 GetShadowColor(DelegateParameterBinding <Vector4> delegateParameterBinding, RenderContext renderContext)
 {
     return(_shadowColor);
 }
示例#4
0
 // A callback for a DelegateParameterBinding which provides the shadow matrix.
 private Matrix GetShadowMatrix(DelegateParameterBinding <Matrix> delegateParameterBinding, RenderContext renderContext)
 {
     return(_shadowMatrix);
 }
示例#5
0
    // 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;
    }
示例#6
0
        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;
        }
示例#7
0
 private Vector3 GetSunDirection(DelegateParameterBinding <Vector3> binding, RenderContext context)
 {
     return((Vector3)DynamicSkyObject.SunDirection);
 }
示例#8
0
 // A callback for a DelegateParameterBinding which provides the shadow matrix.
 private Matrix GetShadowMatrix(DelegateParameterBinding<Matrix> delegateParameterBinding, RenderContext renderContext)
 {
   return _shadowMatrix;
 }
示例#9
0
 private static Vector2 GetTerrainSize(DelegateParameterBinding<Vector2> binding, RenderContext context)
 {
     var terrainTile = GetTerrainTile(context);
       return new Vector2(terrainTile.WidthX, terrainTile.WidthZ);
 }
示例#10
0
 private static Vector2 GetTerrainOrigin(DelegateParameterBinding<Vector2> binding, RenderContext context)
 {
     var terrainTile = GetTerrainTile(context);
       return new Vector2(terrainTile.OriginX, terrainTile.OriginZ);
 }
示例#11
0
 private static Vector2 GetTerrainNormalTextureSize(DelegateParameterBinding<Vector2> binding, RenderContext context)
 {
     var texture = GetTerrainNormalTexture(null, context);
       return new Vector2(texture.Width, texture.Height);
 }
示例#12
0
 private static Texture2D GetTerrainNormalTexture(DelegateParameterBinding<Texture2D> binding, RenderContext context)
 {
     return GetTerrainTile(context).NormalTexture ?? context.GraphicsService.GetDefaultNormalTexture();
 }
示例#13
0
 private static float GetHoleThreshold(DelegateParameterBinding<float> binding, RenderContext context)
 {
     return GetTerrainNode(context).HoleThreshold;
 }
示例#14
0
 private static float GetDetailFadeRange(DelegateParameterBinding<float> binding, RenderContext context)
 {
     return GetTerrainNode(context).DetailFadeRange;
 }
示例#15
0
 private static float GetDetailEnableAnisotropicFiltering(DelegateParameterBinding<float> binding, RenderContext context)
 {
     return GetTerrainNode(context).DetailClipmap.EnableAnisotropicFiltering ? 1 : 0;
 }
示例#16
0
 private Vector3 GetSkyLight(DelegateParameterBinding<Vector3> binding, RenderContext context)
 {
   return (Vector3)DynamicSkyObject.AmbientLight;
 }
示例#17
0
 private static float GetBaseClipmapCellsPerLevel(DelegateParameterBinding<float> binding, RenderContext context)
 {
     return GetTerrainNode(context).BaseClipmap.CellsPerLevel;
 }
示例#18
0
 private static float GetBaseClipmapLevelBias(DelegateParameterBinding<float> binding, RenderContext context)
 {
     return GetTerrainNode(context).BaseClipmap.LevelBias;
 }
示例#19
0
 // A callback for a DelegateParameterBinding which provides the shadow color.
 private Vector4 GetShadowColor(DelegateParameterBinding<Vector4> delegateParameterBinding, RenderContext renderContext)
 {
   return _shadowColor;
 }
示例#20
0
 private static float GetBaseClipmapNumberOfColumns(DelegateParameterBinding<float> binding, RenderContext context)
 {
     return GetTerrainNode(context).BaseClipmap.NumberOfTextureAtlasColumns;
 }
示例#21
0
 private Vector3 GetSkyLight(DelegateParameterBinding <Vector3> binding, RenderContext context)
 {
     return((Vector3)DynamicSkyObject.AmbientLight);
 }
示例#22
0
 private static float GetDetailClipmapNumberOfLevels(DelegateParameterBinding<float> binding, RenderContext context)
 {
     return GetTerrainNode(context).DetailClipmap.NumberOfLevels;
 }