(***********************************************************************) (* *) (* JoCamls'R Us - a not so simple ray tracer in JoCaml *) (* *) (* Luc Maranget, projet Moscova, INRIA Rocquencourt *) (* *) (* Copyright 2007 Institut National de Recherche en Informatique et *) (* en Automatique. This file is distributed under the terms of the *) (* GNU Public License version 2, http://www.gnu.org/licenses/gpl.txt *) (* *) (* Important: based upon the ray tracer of the Camls'R'Us team *) (* written at the occasion of the ICFP programming contest 2000 *) (* Copyright 2000 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* *) (***********************************************************************) open Point type antialias = Super of int | Adapt type t_opt = { mutable fudge_factor : float ; mutable graphic : bool ; mutable dump_tree : bool ; mutable antialias : antialias ; mutable no_bs : bool ; mutable start_xv : bool ; mutable inside_object_color : Point.t ; mutable horizon_color : Point.t ; mutable no_dl : bool ; mutable progress : bool ; mutable no_sort : bool ; mutable client : bool ; mutable host : string ; mutable port : int ; mutable nclients : int ; } let opt = { fudge_factor = 0.0 ; graphic = false ; dump_tree = false ; antialias = Super 1 ; no_bs = false ; start_xv = false ; inside_object_color = {x = 0.0; y = 0.0; z = 0.0} (* black *) ; horizon_color = {x = 0.0; y = 0.0; z = 0.0} (* black *) ; no_dl = false ; progress = false ; no_sort = false ; client = false ; host = "localhost" ; port = 12345 ; nclients = 0 ; } let set_fudge_factor x = opt.fudge_factor <- x let fudge x = if opt.fudge_factor = 0.0 then x else x *. (1. -. Random.float opt.fudge_factor) let parse_host_port s = try let colon = String.index s ':' in let h = String.sub s 0 colon and p = String.sub s (colon+1) (String.length s - colon -1) in if h <> "" then opt.host <- h ; if p <> "" then opt.port <- int_of_string p ; with | Not_found -> opt.host <- s | Failure _ -> raise (Arg.Bad ("bad port specification " ^ s)) let pgm = Sys.argv.(0) let ext = let base = Filename.basename pgm in try let dot = String.index base '.' in String.sub base dot (String.length base-dot) ; with Not_found -> "" let dir = Filename.dirname pgm