using Godot;
using System.Reflection;
using System.Collections.Generic;

namespace Rokojori
{ 
  [Tool]
  [GlobalClass]
  public partial class GeometryShapeDeformer:GeometryModifier
  {   
    public enum Shape
    {
      Sphere,
      Capsule,
      Round_Cone
    }

    [Export]
    public Shape shape;

    
    public override List<ShaderCode> GetGeometryCode( ShaderGenerationContext context, int offsetIndex )
    {

      if ( ShaderPhase.Includes == context.phase )
      { 
        return IncludeFromLibrary( "Terrain" );
      }

      if ( ShaderPhase.Variables == context.phase )
      {        
        return AsUniformGroup( "Terrain",
          
        @"
        uniform sampler2D terrainHeightMap;
        uniform vec2 terrainCenterXZ = vec2( 0.0, 0.0 );
        uniform vec2 terrainSizeXZ = vec2( 100.0, 100.0 );
        uniform float terrainMinHeight = 0.0;
        uniform float terrainMaxHeight = 100.0;
        "
          
        );
           
      }

      if ( ShaderPhase.Vertex == context.phase )
      {

        return ToInnerBlock( "Terrain",
          
        @" 
        addTerrainOffset( 
          MODEL_MATRIX, 
          VERTEX, 
          terrainHeightMap,
          terrainCenterXZ,
          terrainSizeXZ,
          terrainMinHeight,
          terrainMaxHeight
        );
        
        "
                  
        );
      }

      return null;
    }
  }
}