home *** CD-ROM | disk | FTP | other *** search
- *** old\showdxf.c Tue Sep 7 16:48:38 1993
- --- showdxf.c Sat Jan 8 18:27:40 1994
- ***************
- *** 235,240 ****
- --- 235,241 ----
- fprintf(stderr, " 9 PLG format for use with rend386\n");
- fprintf(stderr, " 10 Raw triangle output\n");
- fprintf(stderr, " 11 art 2.3\n");
- + fprintf(stderr, " 12 Rayce 2.7\n");
-
- #endif
- } /* showdxf_usage */
- *** old\lib.h Mon Sep 6 19:13:42 1993
- --- lib.h Fri Jan 7 10:10:08 1994
- ***************
- *** 26,31 ****
- --- 26,36 ----
- * Eduard [esp] Schwan
- * Copied comments from lib.c into here for "documenting"
- * the calls a little better.
- + *
- + * Modified: 6 January 1994
- + * Shawn McHorse
- + * Added support for Rayce 2.7
- + *
- */
- #ifndef LIB_H
- #define LIB_H
- ***************
- *** 39,45 ****
-
- /* ------- The version of this Library, see lib_get_version_str() -------- */
-
- ! #define LIB_VERSION "3.1a"
-
- /* Raytracers supported by this package (default OUTPUT_POVRAY): */
-
- --- 44,50 ----
-
- /* ------- The version of this Library, see lib_get_version_str() -------- */
-
- ! #define LIB_VERSION "3.1b"
-
- /* Raytracers supported by this package (default OUTPUT_POVRAY): */
-
- ***************
- *** 58,64 ****
- #define OUTPUT_PLG 9 /* PLG format for use with "rend386" */
- #define OUTPUT_RAWTRI 10 /* Raw triangle output */
- #define OUTPUT_ART 11 /* Art 2.3 */
- ! #define OUTPUT_DELAYED 12 /* Needed for RTRACE/PLG output.
- When this is used, all definitions will be
- stored rather than immediately dumped. When
- all definitions are complete, use the call
- --- 63,70 ----
- #define OUTPUT_PLG 9 /* PLG format for use with "rend386" */
- #define OUTPUT_RAWTRI 10 /* Raw triangle output */
- #define OUTPUT_ART 11 /* Art 2.3 */
- ! #define OUTPUT_RAYCE 12 /* Rayce 2.7 */
- ! #define OUTPUT_DELAYED 13 /* Needed for RTRACE/PLG output.
- When this is used, all definitions will be
- stored rather than immediately dumped. When
- all definitions are complete, use the call
- ***************
- *** 65,71 ****
- "lib_flush_definitions" to spit them all out. */
-
- /* Default setting of output RT type - change to your favorite & recompile */
- ! #define OUTPUT_RT_DEFAULT OUTPUT_NFF
-
- /* Sets raw triangle output format to include texture */
- #define RAWTRI_WITH_TEXTURES 0 /* set to 1 to include texture */
- --- 71,77 ----
- "lib_flush_definitions" to spit them all out. */
-
- /* Default setting of output RT type - change to your favorite & recompile */
- ! #define OUTPUT_RT_DEFAULT OUTPUT_RAYCE
-
- /* Sets raw triangle output format to include texture */
- #define RAWTRI_WITH_TEXTURES 0 /* set to 1 to include texture */
- ***************
- *** 216,221 ****
- --- 222,228 ----
- * 9 PLG format for use with "rend386"
- * 10 Raw triangle output
- * 11 art 2.3
- + * 12 Rayce 2.7
- * -c - output true curved descriptions
- * -t - output tessellated triangle descriptions
- * -f file - output filename (used for showdxf.c only)
- *** old\lib.c Tue Sep 7 16:42:16 1993
- --- lib.c Sun Jan 9 07:16:12 1994
- ***************
- *** 74,79 ****
- --- 74,84 ----
- * Eric Haines
- * Created standardized lib_open/lib_close functions
- * Renamed lib_initialize/lib_shutdown to lib_storage_*
- + *
- + * Modified: 6 January 1994
- + * Shawn McHorse
- + * Added support for Rayce 2.7
- + *
- */
-
- /*-----------------------------------------------------------------*/
- ***************
- *** 166,171 ****
- --- 171,177 ----
- fprintf(stderr, " 9 PLG format for use with rend386\n");
- fprintf(stderr, " 10 Raw triangle output\n");
- fprintf(stderr, " 11 art 2.3\n");
- + fprintf(stderr, " 12 Rayce 2.7\n");
- fprintf(stderr, "-c - output true curved descriptions\n");
- fprintf(stderr, "-t - output tessellated triangle descriptions\n");
-
- ***************
- *** 191,196 ****
- --- 197,203 ----
- * 9 PLG format for use with "rend386"
- * 10 Raw triangle output
- * 11 art 2.3
- + * 12 Rayce 2.7
- * -c - output true curved descriptions
- * -t - output tessellated triangle descriptions
- * -f file - DXF file to convert/display (used for showdxf.c only)
- ***************
- *** 694,699 ****
- --- 701,726 ----
- fprintf(outfile, "\n");
- break;
-
- + case OUTPUT_RAYCE:
- + tab_indent();
- + fprintf(outfile, "camera {\n");
- + tab_inc();
- + tab_indent();
- + fprintf(outfile, "location <%g, %g, %g>\n",
- + from[X], from[Y], from[Z]);
- + tab_indent();
- + fprintf(outfile, "look_at <%g, %g, %g>\n", at[X], at[Y], at[Z]);
- + tab_indent();
- + fprintf(outfile, "sky <%g, %g, %g>\n", up[X], up[Y], up[Z]);
- + tab_indent();
- + fprintf(outfile, "aspect %g\n", aspect_ratio);
- + tab_indent();
- + fprintf(outfile, "fov %g\n", fov_angle);
- + tab_dec();
- + tab_indent();
- + fprintf(outfile, "} /* camera */\n\n");
- + break;
- +
- case OUTPUT_RAWTRI:
- break;
- }
- ***************
- *** 834,839 ****
- --- 861,872 ----
- fprintf(outfile, "\n");
- break;
-
- + case OUTPUT_RAYCE:
- + tab_indent();
- + fprintf(outfile, "light_source { <%g, %g, %g> color rgb <%g, %g, %g> }\n\n",
- + center_pt[X], center_pt[Y], center_pt[Z], lscale, lscale, lscale);
- + break;
- +
- case OUTPUT_RAWTRI:
- break;
- }
- ***************
- *** 922,930 ****
- fprintf(outfile, "0 0 0\n");
- break;
-
- - case OUTPUT_RAWTRI:
- - break;
- -
- case OUTPUT_ART:
- tab_indent();
- fprintf(outfile, "background %g, %g, %g\n",
- --- 955,960 ----
- ***************
- *** 931,936 ****
- --- 961,975 ----
- color[X], color[Y], color[Z]);
- fprintf(outfile, "\n");
- break;
- +
- + case OUTPUT_RAYCE:
- + tab_indent();
- + fprintf(outfile, "options { background color rgb <%g, %g, %g> }\n\n",
- + color[X], color[Y], color[Z]);
- + break;
- +
- + case OUTPUT_RAWTRI:
- + break;
- }
- }
-
- ***************
- *** 1327,1332 ****
- --- 1366,1410 ----
- fprintf(outfile, "transparency %f\n", kt);
- fprintf(outfile, "\n");
- break;
- +
- + case OUTPUT_RAYCE:
- + txname = create_surface_name(name, texture_count);
- + tab_indent();
- + fprintf(outfile, "#declare %s = texture {\n", txname);
- + tab_inc();
- + if (ka != 0) {
- + tab_indent();
- + fprintf(outfile, "ambient color rgb <%g, %g, %g>\n",
- + ka*color[X], ka*color[Y], ka*color[Z]);
- + }
- + if (kd != 0) {
- + tab_indent();
- + fprintf(outfile, "diffuse color rgb <%g, %g, %g>\n",
- + kd*color[X], kd*color[Y], kd*color[Z]);
- + }
- + if (shine != 0) {
- + tab_indent();
- + if (shine > 1.0) shine = 1.0;
- + fprintf(outfile, "specular color rgb <%g, %g, %g>\n",
- + shine*color[X], shine*color[Y], shine*color[Z]);
- + }
- + if (ks != 0) {
- + tab_indent();
- + fprintf(outfile, "reflection color rgb <%g, %g, %g>\n",
- + ks*color[X], ks*color[Y], ks*color[Z]);
- + }
- + if (kt != 0) {
- + tab_indent();
- + fprintf(outfile, "refraction color rgb <%g, %g, %g>\n",
- + kt*color[X], kt*color[Y], kt*color[Z]);
- + tab_indent();
- + fprintf(outfile, "ior %g\n", i_of_r);
- + }
- + tab_dec();
- + tab_indent();
- + fprintf(outfile, "} /* texture %s */\n\n", txname);
- + break;
- +
- }
-
- /* Stash away the current texture name */
- ***************
- *** 1680,1685 ****
- --- 1758,1838 ----
- fprintf(outfile, "\n");
- break;
-
- + case OUTPUT_RAYCE:
- + if (apex_pt[W] < base_pt[W]) {
- + /* Put the bigger end at the top */
- + COPY_COORD4(axis, base_pt);
- + COPY_COORD4(base_pt, apex_pt);
- + COPY_COORD4(apex_pt, axis);
- + }
- + /* Find the axis and axis length */
- + SUB3_COORD3(axis, apex_pt, base_pt);
- + len = lib_normalize_vector(axis);
- + if (len < EPSILON) {
- + /* Degenerate cone/cylinder */
- + fprintf(outfile, "/* degenerate cone/cylinder! Ignored... */\n");
- + break;
- + }
- + if (ABSOLUTE(apex_pt[W] - base_pt[W]) < EPSILON) {
- + /* Treat this thing as a cylinder */
- + tab_indent();
- + fprintf(outfile, "object { cylinder { <%g, %g, %g>, <%g, %g, %g>, %g } ",
- + base_pt[X], base_pt[Y], base_pt[Z],
- + apex_pt[X], apex_pt[Y], apex_pt[Z], base_pt[W]);
- + if (texture_name != NULL)
- + fprintf(outfile, "texture { %s } ", texture_name);
- + fprintf(outfile, "}\n\n");
- + } else {
- + /* Determine alignment */
- + cottheta = len / (apex_pt[W] - base_pt[W]);
- + tab_indent();
- + fprintf(outfile, "object {\n");
- + tab_inc();
- + tab_indent();
- + fprintf(outfile, "quadric{ <1, 1, -1>, <0, 0, 0>, <0, 0, 0>, 0 } /* cone */\n");
- + if (texture_name != NULL) {
- + tab_indent();
- + fprintf(outfile, "texture { %s }\n", texture_name);
- + }
- + tab_indent();
- + fprintf(outfile, "clipped_by {\n");
- + tab_inc();
- + tab_indent();
- + fprintf(outfile, "intersection {\n");
- + tab_inc();
- + tab_indent();
- + fprintf(outfile, "plane { <0, 0, -1>, %g}\n", -base_pt[W]);
- + tab_indent();
- + fprintf(outfile, "plane { <0, 0, 1>, %g}\n", apex_pt[W]);
- + tab_dec();
- + tab_indent();
- + fprintf(outfile, "} /* intersection */\n");
- + tab_dec();
- + tab_indent();
- + fprintf(outfile, "} /* clip */\n");
- + tab_indent();
- + fprintf(outfile, "translate <0, 0, %g>\n", -base_pt[W]);
- + tab_indent();
- + fprintf(outfile, "scale <1, 1, %g>\n", cottheta);
- + len = sqrt(axis[X] * axis[X] + axis[Z] * axis[Z]);
- + xang = -180.0 * asin(axis[Y]) / PI;
- + if (len < EPSILON)
- + yang = 0.0;
- + else
- + yang = 180.0 * acos(axis[Z] / len) / PI;
- + if (axis[X] < 0)
- + yang = -yang;
- + tab_indent();
- + fprintf(outfile, "rotate <%g, %g, 0>\n", xang, yang);
- + tab_indent();
- + fprintf(outfile, "translate <%g, %g, %g>\n",
- + base_pt[X], base_pt[Y], base_pt[Z]);
- + tab_dec();
- + tab_indent();
- + fprintf(outfile, "} /* cone */\n\n");
- + }
- + break;
- +
- case OUTPUT_RAWTRI:
- lib_output_polygon_cylcone(base_pt, apex_pt);
- break;
- ***************
- *** 1885,1890 ****
- --- 2038,2098 ----
- apex[W] = oradius;
- lib_output_cylcone(base, apex, curve_format);
- break;
- +
- + case OUTPUT_RAYCE:
- + /* A disc is a plane intersected with either one or two
- + * spheres
- + */
- + COPY_COORD3(axis, normal);
- + len = lib_normalize_vector(axis);
- + tab_indent();
- + fprintf(outfile, "object {\n");
- + tab_inc();
- + tab_indent();
- + fprintf(outfile, "plane { <0, 0, 1>, 1 }\n");
- + if (texture_name != NULL) {
- + tab_indent();
- + fprintf(outfile, "texture { %s }", texture_name);
- + }
- + tab_indent();
- + fprintf(outfile, "clipped_by {\n");
- + tab_inc();
- + if (iradius > 0.0) {
- + tab_indent();
- + fprintf(outfile, "intersection {\n");
- + tab_inc();
- + tab_indent();
- + fprintf(outfile, "sphere { <0, 0, 0>, %g inverse }\n",
- + iradius);
- + tab_indent();
- + fprintf(outfile, "sphere { <0, 0, 1>, %g }\n", oradius);
- + tab_dec();
- + tab_indent();
- + fprintf(outfile, "} /* intersection */\n");
- + }
- + else {
- + tab_indent();
- + fprintf(outfile, "object { sphere { <0, 0, 0>, %g } }\n",
- + oradius);
- + }
- + tab_dec();
- + tab_indent();
- + fprintf(outfile, "} /* clip */\n");
- + len = sqrt(axis[X] * axis[X] + axis[Z] * axis[Z]);
- + xang = -180.0 * asin(axis[Y]) / PI;
- + yang = 180.0 * acos(axis[Z] / len) / PI;
- + if (axis[X] < 0)
- + yang = -yang;
- + tab_indent();
- + fprintf(outfile, "rotate <%g, %g, 0>\n", xang, yang);
- + tab_indent();
- + fprintf(outfile, "translate <%g, %g, %g>\n",
- + center[X], center[Y], center[Z]);
- + tab_dec();
- + tab_indent();
- + fprintf(outfile, "} /* object - disc */\n\n");
- + break;
- +
- }
- } else {
- lib_output_polygon_disc(center, normal, iradius, oradius);
- ***************
- *** 2258,2263 ****
- --- 2466,2480 ----
- fprintf(outfile, "\n");
- break;
-
- + case OUTPUT_RAYCE:
- + tab_indent();
- + fprintf(outfile, "object { sphere { <%g, %g, %g>, %g }",
- + center_pt[X], center_pt[Y], center_pt[Z], center_pt[W]);
- + if (texture_name != NULL)
- + fprintf(outfile, " texture { %s }", texture_name);
- + fprintf(outfile, " }\n\n");
- + break;
- +
- case OUTPUT_RAWTRI:
- lib_output_polygon_sphere(center_pt);
- break;
- ***************
- *** 2415,2420 ****
- --- 2632,2638 ----
- case OUTPUT_QRT:
- case OUTPUT_RTRACE:
- case OUTPUT_VIVID:
- + case OUTPUT_RAYCE:
- case OUTPUT_RAWTRI:
- lib_output_polygon_height(height, width, data,
- x0, x1, y0, y1, z0, z1);
- ***************
- *** 2696,2701 ****
- --- 2914,2960 ----
- fprintf(outfile, "}\n");
- fprintf(outfile, "\n");
- break;
- +
- + case OUTPUT_RAYCE:
- + /*
- + A torus object lies in the x-y plane. We need to determine
- + the angles of rotation to get it lined up with "normal".
- + */
- + tab_indent();
- + fprintf(outfile, "object {\n");
- + tab_inc();
- + tab_indent();
- + fprintf(outfile, "torus { %g, %g }\n", iradius, oradius);
- + (void)lib_normalize_vector(normal);
- + len = sqrt(normal[X] * normal[X] + normal[Y] * normal[Y]);
- + xang = 180.0 * asin(normal[Z]) / PI + 90.0;
- + if (len < EPSILON)
- + zang = 0.0;
- + else
- + zang = -180.0 * acos(normal[Y] / len) / PI;
- + if (normal[X] < 0)
- + zang = -zang;
- + if (ABSOLUTE(xang) > EPSILON || ABSOLUTE(zang) > EPSILON) {
- + tab_indent();
- + fprintf(outfile, "rotate <%g, 0, %g>\n", xang, zang);
- + }
- + if (ABSOLUTE(center[X]) > EPSILON ||
- + ABSOLUTE(center[Y]) > EPSILON ||
- + ABSOLUTE(center[Z]) > EPSILON) {
- + tab_indent();
- + fprintf(outfile, "translate <%g, %g, %g>\n",
- + center[X], center[Y], center[Z]);
- + }
- + if (texture_name != NULL) {
- + tab_indent();
- + fprintf(outfile, "texture { %s }", texture_name);
- + }
- + fprintf(outfile, "\n");
- + tab_dec();
- + tab_indent();
- + fprintf(outfile, "} // torus\n");
- + fprintf(outfile, "\n");
- + break;
- }
- } else {
- lib_output_polygon_torus(center, normal, iradius, oradius);
- ***************
- *** 2846,2851 ****
- --- 3105,3120 ----
- (p1[Z] + p2[Z]) / 2.0,
- p2[X] - p1[X], p2[Y] - p1[Y], p2[Z] - p1[Z]);
- break;
- +
- + case OUTPUT_RAYCE:
- + tab_indent();
- + fprintf(outfile, "object { box { <%g, %g, %g>, <%g, %g, %g> }",
- + p1[X], p1[Y], p1[Z], p2[X], p2[Y], p2[Z]);
- + if (texture_name != NULL)
- + fprintf(outfile, " texture { %s }", texture_name);
- + fprintf(outfile, " }\n\n");
- + break;
- +
- }
- }
- }
- ***************
- *** 3379,3384 ****
- --- 3648,3691 ----
- fprintf(outfile, "\n");
- break;
-
- + case OUTPUT_RAYCE:
- + tab_indent();
- + fprintf(outfile, "object {\n");
- + tab_inc();
- + tab_indent();
- + if (norm == NULL)
- + fprintf(outfile, "triangle {\n");
- + else
- + fprintf(outfile, "smooth_triangle {\n");
- + tab_inc();
- + for (i=0;i<3;++i) {
- + tab_indent();
- + fprintf(outfile, "<%g, %g, %g>",
- + out_verts[t][i][X],
- + out_verts[t][i][Y],
- + out_verts[t][i][Z]);
- + if (norm != NULL)
- + fprintf(outfile, ", <%g, %g, %g>",
- + out_norms[t][i][X],
- + out_norms[t][i][Y],
- + out_norms[t][i][Z]);
- + if (i < 2)
- + fprintf(outfile, ",");
- + fprintf(outfile, "\n");
- + } /*for*/
- + tab_dec();
- + tab_indent();
- + fprintf(outfile, "} /* smooth triangle */\n");
- + if (texture_name != NULL) {
- + tab_indent();
- + fprintf(outfile, "texture { %s }\n", texture_name);
- + }
- + tab_dec();
- + tab_indent();
- + fprintf(outfile, "} /* object */\n\n");
- + break;
- +
- +
- case OUTPUT_RAWTRI:
- for (i=0;i<3;++i) {
- fprintf(outfile, "%-10.5g %-10.5g %-10.5g ",
- ***************
- *** 3604,3609 ****
- --- 3911,3944 ----
- fprintf(outfile, "\n");
- break;
-
- + case OUTPUT_RAYCE:
- + tab_indent();
- + fprintf(outfile, "object {\n");
- + tab_inc();
- + tab_indent();
- + fprintf(outfile, "polygon {\n");
- + tab_inc();
- + for (num_vert = 0; num_vert < tot_vert; num_vert++) {
- + tab_indent();
- + fprintf(outfile, " <%g, %g, %g>",
- + vert[num_vert][X],
- + vert[num_vert][Y],
- + vert[num_vert][Z]);
- + if (num_vert < tot_vert-1)
- + fprintf(outfile, ",");
- + fprintf(outfile, "\n");
- + }
- + tab_dec();
- + tab_indent();
- + fprintf(outfile, "} /* polygon */\n");
- + if (texture_name != NULL) {
- + tab_indent();
- + fprintf(outfile, "texture { %s }\n", texture_name);
- + }
- + tab_dec();
- + tab_indent();
- + fprintf(outfile, "}\n\n");
- + break;
- } /* switch */
- } /* else !OUTPUT_DELAYED */
- }
- ***************
- *** 3890,3895 ****
- --- 4225,4231 ----
- case OUTPUT_POVRAY_20:
- case OUTPUT_PLG:
- case OUTPUT_RAWTRI:
- + case OUTPUT_RAYCE:
- lib_output_viewpoint(view.from, view.at, view.up, view.angle,
- view.aspect, view.hither, view.resx, view.resy);
-
-