











open Compatibility
open Types;;


(**************************************************************************)
(* $Id: default.ml,v 1.14 1997/05/01 17:59:09 doub Exp $                   *)
(* Default values for basic items                                         *)
(**************************************************************************)

(**************************************************************************)
(* Basic types                                                            *)
(**************************************************************************)

let default_frame =
{ height = 0.0 , 0.0 ;
  width  = 0.0 , 0.0 ;
  depth  = 0.0 , 0.0
} ;;

let default_clip =
    { clip_loop       = false ;
      clip_start_time = 0.0 ;
      clip_stop_time  = 0.0 ;
      clip_urls       = [] }
;;

let default_fontStyle =
    { family        = "SERIF" ;
      horizontal    = true ;
      justify       = [ "BEGIN" ] ;
      language      = "" ;
      left_to_right = true ;
      size          = 1.0 ;
      spacing       = 1.0 ;
      style         = "PLAIN" ;
      top_to_bottom = true }
;;

let default_image =
    { image_width      = 0 ;
      image_height     = 0 ;
      image_components = 0 ;
      image_pixels     = [] }
;;


(**************************************************************************)
(* vrml_object                                                            *)
(**************************************************************************)

let default_vrml_object =
    { objects   = [] ;
      children  = [] ;
      position  = 0.0 , 0.0 , 0.0 ;
      rotation  = (0.0 , 0.0 , 1.0) , 0.0 ;
      scale     = 1.0 , 1.0 , 1.0 ;
      frame     = default_frame ;
      unique    = false ;
      anchor    = NoAnchor ;
      billboard = NoBillboard ;
      collision = NoCollision }
;;


(**************************************************************************)
(* vrml_object properties : Anchor, Billboard and Collision               *)
(**************************************************************************)

let default_anchor =
    { anchor_description = "" ;
      anchor_parameters  = [] ;
      anchor_urls        = [] }
;;

let default_basic_anchor =
    Anchor default_anchor
;;

let default_billboard =
    { axis_of_rotation = 0.0 , 1.0 , 0.0 }
;;

let default_basic_billboard =
    Billboard default_billboard
;;

let default_collisionBox = 
    { collide     = true ;
      bbox_center = 0.0 , 0.0 , 0.0 ;
      bbox_size   = -1.0 , -1.0 , -1.0 }
;; 

let default_basic_collision =
    Collision default_collisionBox
;;


(**************************************************************************)
(* Material property                                                      *)
(**************************************************************************)

let default_material =
    { ambient_intensity = 0.2 ;
      diffuse_color     = 0.8 , 0.8 , 0.8 ;
      emissive_color    = 0.0 , 0.0 , 0.0 ;
      shininess         = 0.2 ;
      specular_color    = 0.0 , 0.0 , 0.0 ;
      transparency      = 0.0 }
;;

let default_basic_material =
    Material default_material
;;

(**************************************************************************)
(* Texture property                                                       *)
(**************************************************************************)

let default_textureCoordinate = [] ;;

let default_basic_imageTexture =
    ImageTexture ( [] )
;;

let default_movieTexture =
    { movieTexture_speed = 1.0 ;
      movieTexture_clip  = default_clip }
;;

let default_basic_movieTexture =
    MovieTexture default_movieTexture
;;

let default_basic_pixelTexture =
    PixelTexture ( default_image )
;;

let default_basic_texture texture_type =
    Texture
      ({ texture_repeatS     = true ;
         texture_repeatT     = true ;
         texture_type        = texture_type ;
         texture_center      = 0.0 , 0.0 ;
         texture_rotation    = 0.0 ;
         texture_scale       = 1.0 , 1.0 ;
         texture_translation = 0.0 , 0.0
      })
;;

let default_texture texture =
    { texture_repeatS     = true ;
      texture_repeatT     = true ;
      texture_type        = texture ;
      texture_center      = 0.0 , 0.0 ;
      texture_rotation    = 0.0 ;
      texture_scale       = 1.0 , 1.0 ;
      texture_translation = 0.0 , 0.0
   }
;;

let default_textureItem =
    { texture_repeatS     = true ;
      texture_repeatT     = true ;
      texture_type        = default_basic_imageTexture ;
      texture_center      = 0.0 , 0.0 ;
      texture_rotation    = 0.0 ;
      texture_scale       = 1.0 , 1.0 ;
      texture_translation = 0.0 , 0.0
   }
;;

(**************************************************************************)
(* Geometric                                                              *)
(**************************************************************************)

let default_basic_geometric shape =
    Geometric
      { shape    = shape ;
        material = NoMaterial ;
        texture  = NoTexture }
;;    


(*****************************************************************************)
(* Unlit geometric objects                                                   *)
(*****************************************************************************)

let default_point =
     { point_color      = -1.0 , -1.0 , -1.0 ;
       point_coordinate = 0.0 , 0.0 , 0.0 }
;;

let default_pointSet = [] ;;

let default_basic_pointSet =
    PointSet default_pointSet
;;

let  default_line =
{ line_point1 = 0.0 , 0.0 , 0.0 ;
  line_point2 = 0.0 , 0.0 , 0.0 ;
  line_color  = -1.0 , -1.0 , -1.0
} ;;

let default_lineSet = [] ;;

let default_basic_lineSet =
    LineSet default_lineSet
;;


(**************************************************************************)
(* Shapes                                                                 *)
(**************************************************************************)

let default_box =
    { box_size = 2.0 , 2.0 , 2.0 }
;;

let default_basic_box =
    Box default_box
;;

let default_cone =
    { cone_bottom_radius = 1.0 ;
      cone_height        = 2.0 ;
      cone_side          = true ;
      cone_bottom        = true }
;;

let default_basic_cone =
    Cone default_cone
;; 

let default_cylinder =
    { cylinder_bottom = true ;
      cylinder_height = 2.0 ;
      cylinder_radius = 1.0 ;
      cylinder_side   = true ;
      cylinder_top    = true }
;;

let default_basic_cylinder =
    Cylinder default_cylinder
;;

let default_elevationGrid =
    { grid_color              = [] ;
      grid_texture_coordinate = default_textureCoordinate ;
      grid_height             = [] ;
      grid_ccw                = true ;
      grid_color_per_vertex   = true ;
      grid_solid              = true ;
      grid_x_dimension        = 0 ;
      grid_x_spacing          = 0.0 ;
      grid_z_dimension        = 0 ;
      grid_z_spacing          = 0.0 }
;;

let default_basic_elevationGrid =
    ElevationGrid default_elevationGrid
;;

let default_extrusion =
    { extrusion_begin_cap     = true ;
      extrusion_ccw           = true ;
      extrusion_convex        = true ;
      extrusion_cross_section = [  1.0 ,  1.0 ;  1.0 , -1.0 ;
                                  -1.0 , -1.0 ; -1.0 ,  1.0 ;
                                   1.0 ,  1.0 ] ;   (* 2D shape *)
      extrusion_end_cap       = true ;
      extrusion_orientation   = [ (0.0 , 0.0 , 1.0) , 1.0 ] ;
      extrusion_scale         = [ 1.0 , 1.0 ] ;
      extrusion_solid         = true ;
      extrusion_spine         = [ 0.0 , 0.0 , 0.0 ; 0.0 , 1.0 , 0.0 ] }
;;

let default_basic_extrusion =
    Extrusion default_extrusion
;;

let default_sphere =
    { sphere_radius = 1.0 }
;;

let default_basic_sphere =
    Sphere default_sphere
;;


let default_text =
    { content    = [] ;
      font_style = default_fontStyle ;
      length     = [] ;
      max_extent = 0.0 }
;;

let default_basic_text =
    Text default_text
;;

let default_face = [] ;;

let default_faceSet =
    { faceSet_faces                    = [] ;
      faceSet_texture_coordinate       = default_textureCoordinate ;
      faceSet_ccw                      = true ;
      faceSet_convex                   = true ;
      faceSet_solid                    = true ;
      faceSet_texture_coordinate_index = [] }
;;


(**************************************************************************)
(* Lights                                                                 *)
(**************************************************************************)

let default_directionalLight =
    { directionalLight_direction = 0.0 , 0.0 , -1.0 }
;;

let default_basic_directionalLight =
    DirectionalLight default_directionalLight
;;

let default_pointLight =
    { pointLight_attenuation = 1.0 , 0.0 , 0.0 ;
      pointLight_radius      = 100.0 }
;;

let default_basic_pointLight =
    PointLight default_pointLight
;;

let default_spotLight =
    { spotLight_attenuation   = 1.0 , 0.0 , 0.0 ;
      spotLight_beam_width    = 1.570796 ;
      spotLight_cut_off_angle = 0.785398 ;
      spotLight_direction     = 0.0 , 0.0 , -1.0 ;
      spotLight_radius        = 100.0 }
;;

let default_basic_spotLight =
    SpotLight default_spotLight
;;

let default_basic_light light =
    Light
      ({ light_ambient_intensity = 0.0 ;
         light_color             = 1.0 , 1.0 , 1.0 ;
         light_intensity         = 1.0 ;
         light_type              = light
      })
;;

let default_light =
{ light_ambient_intensity = 0.0 ;
  light_color = 1.0 , 0.0 , 0.0 ;
  light_intensity = 1.0 ;
  light_type = PointLight (default_pointLight) 
};;


(**************************************************************************)
(* Sound                                                                  *)
(**************************************************************************)

let default_sound =
    { sound_direction   = 0.0 , 0.0 , 1.0 ;
      sound_intensity   = 1.0 ;
      sound_max_back    = 10.0 ;
      sound_max_front   = 10.0 ;
      sound_min_back    = 1.0 ;
      sound_min_front   = 1.0 ;
      sound_priority    = 0.0 ;
      sound_spatialize  = true ;
      sound_description = "" ;
      sound_pitch       = 1.0 ;
      sound_clip        = default_clip }
;;

let default_basic_sound =
    Sound default_sound
;;


(**************************************************************************)
(* LOD                                                                    *)
(**************************************************************************)

let default_lod =
    { lod_levels = [] ;
      (* lod_center = 0.0 , 0.0 , 0.0 ; *)
      lod_ranges = [] }
;;

let default_basic_lod =
    LOD default_lod
;;


(**************************************************************************)
(* ViewPoint                                                              *)
(**************************************************************************)

let default_viewPoint =
    { viewPoint_field_of_view     = 0.785398 ;
      viewPoint_jump              = true ;
      viewPoint_description       = "" ;
      navigation_avatar_size      = [ 0.25 ; 1.6 ; 0.75 ] ;
      navigation_headlight        = true ;
      navigation_speed            = 1.0 ;
      navigation_type             = [ "WALK" ] ; 
      navigation_visibility_limit = 0.0 }
;;

let default_basic_viewPoint =
   ViewPoint default_viewPoint
;;


(*****************************************************************************)
(* Non-positionable objects : background and fog                             *)
(*****************************************************************************)

(* Background *)

let default_background =
    { ground_angle = [] ;
      ground_color = [] ;
      back_url     = [] ;
      bottom_url   = [] ;
      front_url    = [] ;
      left_url     = [] ;
      right_url    = [] ;
      top_url      = [] ;
      sky_angle    = [] ;
      sky_color    = [ 0.0 , 0.0 , 0.0 ] }
;;

let default_basic_background =
    Background default_background
;;


(* Fog *)

let default_fog =
    { fog_color            = 1.0 , 1.0 , 1.0 ;
      fog_type             = "LINEAR" ;
      fog_visibility_range = 0.0 }
;;

let default_basic_fog =
    Fog default_fog
;;


(**************************************************************************)
(* vrml_world                                                             *)
(**************************************************************************)
let default_vrml_world =
    { info       = [] ;
      title      = "" ;
      tree       = default_vrml_object ;
      specials   = [] ;
      animations = [] }
;;

