Anonymous user
Catmull–Clark subdivision surface/Tcl Test Code: Difference between revisions
Catmull–Clark subdivision surface/Tcl Test Code (view source)
Revision as of 01:26, 18 January 2010
, 14 years ago→Demonstration
Line 42:
(Using the utility functions from above, plus the code from the main solution page.)
<lang tcl># Make a display surface
pack [canvas .c -width 400 -height 400 -background #7f7f7f]
# Points to define the unit cube
set points {
Line 55:
{0.0 1.0 1.0}
}
foreach pt $points {
# Try removing one of the faces to demonstrate holes.▼
lassign $pt x y z
lappend points [list [expr {0.25 + 0.5*$x}] [expr {0.25 + 0.5*$y}] $z]
}
set faces {
{0
{
{2 10 11 3}
{3 11 8 0}
{0 1 5 4}
{
{
{
{4 5 13 12}
{5 6 14 13}
{6 7 15 14}
{7 4 12 15}
{8 9 13 12}
{9 10 14 13}
{10 11 15 14}
{11 8 12 15}
}
# Show the initial layout
visualizeNet .c $points $faces -outline
# Apply the Catmull-Clark algorithm to generate a new surface
lassign [CatmullClark $points $faces] points2 faces2
## Uncomment the next line to get the second level of subdivision
lassign [CatmullClark $points2 $faces2] points2 faces2
# Visualize the new surface
visualizeNet .c $points2 $faces2 -outline
|