コード例 #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;
 }