# -*- mode: shell-script -*-
#
# Specification of Castle Game Engine X3D extensions.
# See https://castle-engine.io/x3d_extensions.php .
# This file is in the format understood by
# our ../x3d-nodes-to-pascal/x3d-nodes-to-pascal.lpr
# and by White Dune scripts.
#
# Note that we only list here *new* X3D nodes.
# Extensions (new fields) to existing nodes must be listed in other txt files
# (otherwse x3d-nodes-to-pascal would not be able to handle them).
# ----------------------------------------------------------------------------

# "KambiAppearance" is just a synonym for "Appearance" now.
#
# Now we just add all new fields to the standard "Appearance" node.
# Reasons: we describe in shadow_maps_x3d paper
# our propositions for Appearance (without introducing KambiAppearance,
# as (in the future) these should not be specific to our engine),
# also InstantReality already has Appearance.blendMode.
#
# You can however use KambiAppearance in your models, this allows you
# to declare KambiAppearance by EXTERNPROTO and fallback on standard
# Appearance.
KambiAppearance : Appearance {
}

GeneratedShadowMap : X3DSingleTextureNode {
  SFString   [in,out]      update           "NONE"
    range: ["NONE"|"NEXT_FRAME_ONLY"|"ALWAYS"]
    enumerated-type: TTextureUpdate TextureUpdateNames upNone
    doc: When to update the texture contents.
    # See GeneratedCubeMapTexture.change for reasoning why chRedisplay is good.
    change: chRedisplay
  SFInt32    []            size             128
    range: (0,Inf)
    change: chTextureRendererProperties
  SFNode     []            light            NULL
    range: X3DLightNode
    change: chGeneratedTextureUpdateNeeded
    weak-link
  SFFloat    [in,out]      scale            DefaultScale
    range: [0,Inf)
    change: chGeneratedTextureUpdateNeeded
  SFFloat    [in,out]      bias             DefaultBias
    range: [0,Inf)
    change: chGeneratedTextureUpdateNeeded
  SFString   []            compareMode      "COMPARE_R_LEQUAL"
    range: ["COMPARE_R_LEQUAL"|"COMPARE_R_GEQUAL"|"NONE"]
    enumerated-type: TShadowMapCompareMode CompareModeNames smCompareRLEqual
    change: chTextureRendererProperties
}

Text3D : Text {
  SFFloat    [in,out]      depth       0.1
    range: >= 0
    change: chGeometry
}

KambiInline : Inline {
  MFString   [in,out]      replaceNames  []
    change: chEverything
  MFNode     [in,out]      replaceNodes  []
    range: X3DNode
    change: chEverything
}

KambiNavigationInfo : NavigationInfo {
}

Teapot : X3DGeometryNode {
  SFVec3f    []            size        3 3 3
  SFBool     []            solid       TRUE
  SFBool     []            manifold    FALSE
  SFNode     [in,out]      texCoord    NULL
    range: TextureCoordinateGenerator, ProjectedTextureCoordinate, MultiGeneratedTextureCoordinate
}

RenderedTexture : X3DSingleTextureNode {
  SFNode     [in,out]      background       NULL
    range: X3DBackgroundNode
    change: chGeneratedTextureUpdateNeeded
  SFNode     [in,out]      fog              NULL
    range: Fog
    change: chGeneratedTextureUpdateNeeded
  SFNode     [in,out]      environment      NULL
    # range: EnvironmentBindable # this field is for compatibility with InstantReality, we don't support Environment node
    change: chGeneratedTextureUpdateNeeded
  SFNode     [in,out]      scene            NULL
    range: X3DNode
    change: chGeneratedTextureUpdateNeeded
  SFNode     [in,out]      foreground       NULL
    # range: ForegroundBindable # this field is for compatibility with InstantReality, we don't support Foreground node
    change: chGeneratedTextureUpdateNeeded
  MFInt32    [in,out]      dimensions            [DefaultRenderedTextureWidth, DefaultRenderedTextureHeight, 4, 1, 1]
    change: chTextureRendererProperties
  SFString   [in,out]      update                "NONE"
    range: ["NONE"|"NEXT_FRAME_ONLY"|"ALWAYS"]
    enumerated-type: TTextureUpdate TextureUpdateNames upNone
    doc: When to update the texture contents.
    # See GeneratedCubeMapTexture.change for reasoning why chRedisplay is good.
    change: chRedisplay
  # note that we allow even VRML 1.0 cameras by TAbstractViewpointNode
  SFNode     [in,out]      viewpoint             NULL
    range: X3DViewpointNode, ViewpointMirror
    change: chGeneratedTextureUpdateNeeded
  SFNode     []            textureProperties     NULL
    range: TextureProperties
    change: chTextureRendererProperties
  SFBool     []            repeatS               TRUE
    change: chTextureRendererProperties
  SFBool     []            repeatT               TRUE
    change: chTextureRendererProperties
  SFBool     []            repeatR               TRUE
    change: chTextureRendererProperties
  MFBool     [in,out]      depthMap              []
    change: chTextureRendererProperties
  MFInt32    [in,out]      zOffset               []
    change: chTextureRendererProperties
  MFNode     [in,out]      targets               []
    range: X3DTextureNode
    change: chTextureRendererProperties
  SFString   [in,out]      description           ""
    change: chNone
  SFMatrix4f [out]         viewing
  SFMatrix4f [out]         projection
  SFString   [in,out]      frameBufferMode       "AUTO"
    change: chTextureRendererProperties
  MFNode     []            excludeNodes          []
    change: chGeneratedTextureUpdateNeeded
  SFString   []            triggerName           "Render"
    change: chNone
  SFImage    [out]         image_changed
  SFBool     [out]         rendering
}

Logger : X3DChildNode {
  SFInt32    [in,out]      level       1
  SFString   []            logFile     ""
  SFBool     [in,out]      enabled     TRUE
  XFAny      [in]          write
}

# MultiGeneratedTextureCoordinate : X3DTextureCoordinateNode {
# #
#   MFNode [in,out] texCoord NULL
#     range: TextureCoordinateGenerator, ProjectedTextureCoordinate
# }
#
# Implementation detail: instead of being a new class
# derived from abstract X3DTextureCoordinateNode,
# MultiGeneratedTextureCoordinate now descends from MultiTextureCoordinate.
# See TMultiGeneratedTextureCoordinateNode comments for reasons.
MultiGeneratedTextureCoordinate : MultiTextureCoordinate {
}

ProjectedTextureCoordinate : X3DSingleTextureCoordinateNode {
  SFNode     [in,out]      projector   NULL
    range: SpotLight, DirectionalLight, X3DViewpointNode, TSpotLightNode_1, TDirectionalLightNode_1
    change: chTextureCoordinate
    doc: Viewpoint or light that determine how is the texture projected.
}

# See https://castle-engine.io/x3d_extensions_screen_effects.php
ScreenEffect : X3DChildNode {
  SFBool     [in,out]      enabled     TRUE
    change: chScreenEffectEnabled
  SFBool     [in,out]      needsDepth  FALSE
    change: chRedisplay
  MFNode     [in,out]      shaders     []
    range: X3DShaderNode
    change: chEverything
}

# See https://castle-engine.io/compositing_shaders.php
Effect : X3DChildNode {

  SFString   []            language    ""
    range: ["CG"|"GLSL"|"HLSL"|...]
    enumerated-type: TShaderLanguage ShaderLanguageNames slDefault
    change: chEverything
    doc: Shading language. Only the GLSL (OpenGL Shading Language) is actually supported. The default value, empty string, is equivalent to GLSL.
  SFBool     [in,out]      enabled     TRUE
    change: chVisibleNonGeometry
  MFNode     []            parts       []
    range: EffectPart
    change: chEverything
  SFString   []            uniformMissing    "WARNING"
    range: ["WARNING", "IGNORE"]
    enumerated-type: TUniformMissing UniformMissingNames umWarning
    change: chEverything
    doc: Should we report a missing uniform value. Setting this to umWarning (default) is useful to spot simple mistakes in naming uniforms. On the other hand, OpenGL aggressively removes unused uniforms from code, and it may cause spurious messages that some uniform is missing -- even though the shader is correct, is just doesn't use some uniform value e.g. because no lights are present on the current scene.
}

# See https://castle-engine.io/compositing_shaders.php
EffectPart : X3DNode, X3DUrlObject {
  default-container-field: parts

  MFString [in,out] url      []
    change: chEverything
  SFString []       type     "VERTEX"
    range: ["VERTEX"|"FRAGMENT"]
    enumerated-type: TShaderType ShaderTypeNameX3D stVertex
    change: chEverything
}

# See https://castle-engine.io/compositing_shaders.php
ShaderTexture : X3DSingleTextureNode {
  SFString []       defaultTexCoord "BOUNDS2D"
    #range: ["BOUNDS2D"|"BOUNDS3D"]
    change: chEverything
    # TODO: use enumerated-type:....
}

# See https://castle-engine.io/x3d_extensions.php#section_ext_blending
BlendMode {
  default-container-field: blendMode
  SFString   [in,out]      srcFactor   "src_alpha"
    range: ["zero", ..., "one_minus_constant_alpha"]
    enumerated-type: TBlendingSourceFactor BlendingSourceFactorNames bsSrcAlpha
  SFString   [in,out]      destFactor  "one_minus_src_alpha"
    range: ["zero", ..., "one_minus_constant_alpha"]
    enumerated-type: TBlendingDestinationFactor BlendingDestinationFactorNames bdOneMinusSrcAlpha
  SFColor    [in,out]      color       1 1 1
  SFFloat    [in,out]      colorTransparency  0
}

ViewpointMirror {
  default-container-field: viewpoint
  SFFloat   [in,out]      distanceFromShape 0.01
}

OrientationInterpolator2D : X3DInterpolatorNode {
  MFFloat    [in,out] keyValue      []
    change: chNone
  SFVec3f    [in,out] axis          0 0 1
  SFRotation [out]    value_changed
}
