diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-10-20 19:08:05 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-10-20 19:08:05 -0400 |
commit | 0cb8dcce563a36dd2adb8e4d941cbac4adcb8561 (patch) | |
tree | f88e290a73fa863488960f4142eae57a6cffbdfc /dimension/realize.c | |
parent | 59481d4e4421cc7d0610d49c6dbec720de1f11ea (diff) | |
download | dimension-0cb8dcce563a36dd2adb8e4d941cbac4adcb8561.tar.xz |
Add cones to dimension.
Diffstat (limited to 'dimension/realize.c')
-rw-r--r-- | dimension/realize.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/dimension/realize.c b/dimension/realize.c index dc315d8..b5f6e50 100644 --- a/dimension/realize.c +++ b/dimension/realize.c @@ -845,17 +845,28 @@ dmnsn_realize_box(dmnsn_astnode astnode) static dmnsn_object * dmnsn_realize_cylinder(dmnsn_astnode astnode) { - dmnsn_assert(astnode.type == DMNSN_AST_CYLINDER, "Expected a cylinder."); - - dmnsn_astnode pnode1, pnode2, radius, open; - dmnsn_array_get(astnode.children, 0, &pnode1); - dmnsn_array_get(astnode.children, 1, &pnode2); - dmnsn_array_get(astnode.children, 2, &radius); - dmnsn_array_get(astnode.children, 3, &open); + dmnsn_astnode pnode1, rnode1, pnode2, rnode2, open; + + if (astnode.type == DMNSN_AST_CONE) { + dmnsn_array_get(astnode.children, 0, &pnode1); + dmnsn_array_get(astnode.children, 1, &rnode1); + dmnsn_array_get(astnode.children, 2, &pnode2); + dmnsn_array_get(astnode.children, 3, &rnode2); + dmnsn_array_get(astnode.children, 4, &open); + } else if (astnode.type == DMNSN_AST_CYLINDER) { + dmnsn_array_get(astnode.children, 0, &pnode1); + dmnsn_array_get(astnode.children, 1, &pnode2); + dmnsn_array_get(astnode.children, 2, &rnode1); + dmnsn_array_get(astnode.children, 2, &rnode2); + dmnsn_array_get(astnode.children, 3, &open); + } else { + dmnsn_assert(false, "Expected a cone or cylinder."); + } dmnsn_vector p1 = dmnsn_realize_vector(pnode1); dmnsn_vector p2 = dmnsn_realize_vector(pnode2); - double r = dmnsn_realize_float(radius); + double r1 = dmnsn_realize_float(rnode1); + double r2 = dmnsn_realize_float(rnode2); dmnsn_vector dir = dmnsn_vector_sub(p2, p1); double l = dmnsn_vector_norm(dir); @@ -864,7 +875,7 @@ dmnsn_realize_cylinder(dmnsn_astnode astnode) double theta2 = dmnsn_vector_axis_angle(dmnsn_y, dir, dmnsn_z); dmnsn_object *cylinder - = dmnsn_new_cylinder(r, r, dmnsn_realize_integer(open)); + = dmnsn_new_cylinder(r1, r2, dmnsn_realize_integer(open)); /* Transformations: lift the cylinder to start at the origin, scale, rotate, and translate properly */ cylinder->trans = dmnsn_translation_matrix(dmnsn_new_vector(0.0, 1.0, 0.0)); @@ -1034,6 +1045,7 @@ dmnsn_realize_object(dmnsn_astnode astnode, dmnsn_array *lights) case DMNSN_AST_BOX: object = dmnsn_realize_box(onode); break; + case DMNSN_AST_CONE: case DMNSN_AST_CYLINDER: object = dmnsn_realize_cylinder(onode); break; |