1
0
Fork 0

Assembling triangles and building a new .node file with the proper shared

vertices now works.  Now we just have to use the shared normals and we'll
be all set.
This commit is contained in:
curt 1998-01-15 21:33:32 +00:00
parent 9557133729
commit 8e59b3debd
3 changed files with 67 additions and 20 deletions

View file

@ -372,25 +372,31 @@ void build_node_list(char *basename, char *basepath) {
/* dump in WaveFront .obj format */
void dump_nodes(char *basename, char *basepath) {
void dump_nodes(char *basename) {
char file[256];
FILE *fp;
int i;
int i, len;
/* generate output file name */
strcpy(file, basename);
len = strlen(file);
file[len-2] = '\0';
strcat(file, ".node");
/* dump vertices */
printf(" writing vertices in .node format\n");
/* printf("Creating node file: %s\n", file);
fd = fopen(file, "w"); */
printf("Creating node file: %s\n", file);
printf(" writing vertices in .node format.\n");
fp = fopen(file, "w");
printf("%d 2 1 0\n", nodecount);
fprintf(fp, "%d 2 1 0\n", nodecount);
/* now write out actual node data */
for ( i = 0; i < nodecount; i++ ) {
printf("%d %.2f %.2f %.2f 0\n", i + 1,
fprintf(fp, "%d %.2f %.2f %.2f 0\n", i + 1,
nodes[i][0], nodes[i][1], nodes[i][2]);
}
/* fclose(fd); */
fclose(fp);
}
@ -441,14 +447,19 @@ int main(int argc, char **argv) {
build_node_list(basename, basepath);
/* dump in WaveFront .obj format */
dump_nodes(basename, basepath);
dump_nodes(basename);
return(0);
}
/* $Log$
/* Revision 1.1 1998/01/15 02:45:26 curt
/* Initial revision.
/* Revision 1.2 1998/01/15 21:33:36 curt
/* Assembling triangles and building a new .node file with the proper shared
/* vertices now works. Now we just have to use the shared normals and we'll
/* be all set.
/*
* Revision 1.1 1998/01/15 02:45:26 curt
* Initial revision.
*
*/

View file

@ -6,13 +6,16 @@
1/14/98 - Don't create shared corners or edges if one already exists.
1/14/98 - Reassemble triangles using only body, shared corners, and
shared edges.
--------------------------------------------------------------------------
| Todo
--------------------------------------------------------------------------
1/14/98 - Reassemble triangles using only body, shared corners, and
shared edges.
1/15/98 - Retro-fit tri2obj to use shared normals rather than regenerating
normals for shared vertices.
1/12/98 - Try reversing cw-wound strips rather than calling glFrontFace()
in the display list.

View file

@ -32,9 +32,10 @@ $do_demfit = 0;
$do_triangle_1 = 0;
$do_fixnode = 0;
$do_splittris = 0;
$do_assemtris = 1;
$do_assemtris = 0;
$do_triangle_2 = 0;
$do_tri2obj = 0;
$do_tri2obj = 1;
$do_strips = 0;
$do_fixobj = 0;
@ -202,12 +203,39 @@ if ( $do_assemtris ) {
}
# 4.3 Retriangulate fixed up files (without -q option)
# 4.3 Retriangulate reassembled files (without -q option) so no new
# nodes are generated.
if ( $do_triangle_2 ) {
@FILES = `ls $subdir`;
foreach $file ( @FILES ) {
print $file;
chop($file);
if ( ($file =~ m/\.node$/) && ($file !~ m/\.\d\.node$/) ) {
$command = "./Triangle/triangle $subdir/$file";
print "Running '$command'\n";
open(OUT, "$command |");
while ( <OUT> ) {
print $_;
}
close(OUT);
# remove input file.node
unlink("$subdir/$file");
}
}
}
# 5. tri2obj file (.1.node) (.1.ele)
#
# Take the file.1.node and file.1.ele and produce file.1.obj
#
# Extracts normals out of the shared edge/vertex files, and uses
# the precalcuated normals for these nodes instead of calculating
# new ones. By sharing normals as well as vertices, not only are
# the gaps between tiles eliminated, but the colors and lighting
# transition smoothly across tile boundaries.
if ( $do_tri2obj ) {
@FILES = `ls $subdir`;
@ -224,9 +252,9 @@ if ( $do_tri2obj ) {
}
close(OUT);
unlink("$subdir/$file.node");
unlink("$subdir/$file.node.orig");
unlink("$subdir/$file.ele");
# unlink("$subdir/$file.node");
# unlink("$subdir/$file.node.orig");
# unlink("$subdir/$file.ele");
}
}
}
@ -299,6 +327,11 @@ if ( $do_fixobj ) {
#---------------------------------------------------------------------------
# $Log$
# Revision 1.6 1998/01/15 21:33:33 curt
# Assembling triangles and building a new .node file with the proper shared
# vertices now works. Now we just have to use the shared normals and we'll
# be all set.
#
# Revision 1.5 1998/01/15 02:50:08 curt
# Tweaked to add next stage.
#