Catmull–Clark subdivision surface: Difference between revisions

Content added Content deleted
Line 457: Line 457:
(print_string "surface {\n"; List.iter pr_face fl; print_string "}\n")
(print_string "surface {\n"; List.iter pr_face fl; print_string "}\n")


let c000 = { x=(-1.0); y=(-1.0); z=(-1.0) }
let c p q r = let s i = if i = 0 then -1.0 else 1.0 in { x = s p; y = s q; z = s r } ;;
let c001 = { x=(-1.0); y=(-1.0); z= 1.0 }
let c010 = { x=(-1.0); y= 1.0 ; z=(-1.0) }
let c011 = { x=(-1.0); y= 1.0 ; z= 1.0 }
let c100 = { x= 1.0 ; y=(-1.0); z=(-1.0) }
let c101 = { x= 1.0 ; y=(-1.0); z= 1.0 }
let c110 = { x= 1.0 ; y= 1.0 ; z=(-1.0) }
let c111 = { x= 1.0 ; y= 1.0 ; z= 1.0 }
let cube = [
let cube = [
(Face [c000;c001;c011;c010]); (Face [c100;c101;c111;c110]);
(Face [c 0 0 0; c 0 0 1; c 0 1 1; c 0 1 0]); (Face [c 1 0 0; c 1 0 1; c 1 1 1; c 1 1 0]);
(Face [c000;c100;c101;c001]); (Face [c010;c110;c111;c011]);
(Face [c 0 0 0; c 1 0 0; c 1 0 1; c 0 0 1]); (Face [c 0 1 0; c 1 1 0; c 1 1 1; c 0 1 1]);
(Face [c000;c010;c110;c100]); (Face [c001;c011;c111;c101]) ];;
(Face [c 0 0 0; c 0 1 0; c 1 1 0; c 1 0 0]); (Face [c 0 0 1; c 0 1 1; c 1 1 1; c 1 0 1]) ] in
show_faces cube;

show_faces cube;;
show_faces (catmull_clark cube)</lang>
show_faces (catmull_clark cube);;</lang>
with output:
with output:
<pre>surface {
<pre>surface {