This commit is contained in:
Frater 2017-09-24 01:45:36 +02:00
commit 43352ff262
1291 changed files with 220976 additions and 0 deletions

8
VISU/C/AMIGACIT Normal file
View file

@ -0,0 +1,8 @@
Amiga city: 90-140341
Elusive:
317 452 5897
317 452 1257
317 868 9465 55?
317 868 9454

BIN
VISU/C/C.EXE Normal file

Binary file not shown.

3
VISU/C/CALKU.BAT Normal file
View file

@ -0,0 +1,3 @@
cd scene
..\c -s10.0 u2a
cd ..

3
VISU/C/CCITY.BAT Normal file
View file

@ -0,0 +1,3 @@
cd scene
..\c -s10.0 u2e
cd ..

BIN
VISU/C/CITY.3DS Normal file

Binary file not shown.

368
VISU/C/CITY.C Normal file
View file

@ -0,0 +1,368 @@
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <malloc.h>
#include "..\cd.h"
#include "..\c.h"
#define noDEBUG
int indemo=0;
char scene[64]={"CITY"};
char tmpname[64];
char huge *scene0;
char huge *scenem;
int city=0;
#define LONGAT(zz) *((long huge *)(zz))
#define INTAT(zz) *((int huge *)(zz))
#define CHARAT(zz) *((char huge *)(zz))
#define MAXOBJ 256
struct s_co
{
object *o;
long dist;
int index;
int on;
} co[MAXOBJ];
int conum;
FILE *fr;
object camobject;
rmatrix cam;
int order[MAXOBJ],ordernum;
unsigned char huge *sp;
long lsget(unsigned char f)
{
long l;
switch(f&3)
{
case 0 : l=0;
break;
case 1 : l=(long)(char)(*sp++);
break;
case 2 : l=*sp++;
l|=(long)(char)(*sp++)<<8;
break;
case 3 : l=*sp++;
l|=(long)(*sp++)<<8;
l|=(long)(*sp++)<<16;
l|=(long)(char)(*sp++)<<24;
break;
}
return(l);
}
void resetscene(void)
{
int a;
sp=(unsigned char *)(scene0+16);
for(a=0;a<conum;a++)
{
memset(co[a].o->r,0,sizeof(rmatrix));
memset(co[a].o->r0,0,sizeof(rmatrix));
}
}
main(int argc,char *argv[])
{
char huge *sptemp;
int huge *ip;
char huge *cp;
int a,b,c,d,e,f,g;
#ifdef DEBUG
fr=fopen("tmp","wt");
#endif
indemo=1;
_asm int 3
sprintf(tmpname,"%s.00M",scene);
if(!indemo) printf("Loading materials %s...\n",tmpname);
scenem=readfile(tmpname);
sprintf(tmpname,"%s.00A",scene);
if(!indemo) printf("Loading animation %s...\n",tmpname);
scene0=readfile(tmpname);
if(scene0[15]=='C') city=1;
ip=(int huge *)(scene0+LONGAT(scene0+4));
conum=d=*ip++;
for(f=-1,c=1;c<d;c++)
{
e=*ip++;
if(e>f)
{
f=e;
sprintf(tmpname,"%s.%03i",scene,e);
if(!indemo) printf("Loading %s... ",tmpname);
co[c].o=vis_loadobject(tmpname);
memset(co[c].o->r,0,sizeof(rmatrix));
memset(co[c].o->r0,0,sizeof(rmatrix));
co[c].index=e;
co[c].on=0;
if(!indemo) printf("(co[%i]:%s)\n",c,co[c].o->name);
}
else
{
if(!indemo) printf("Copying %s.%03i... ",scene,e);
for(g=0;g<c;g++) if(co[g].index==e) break;
memcpy(co+c,co+g,sizeof(struct s_co));
co[c].o=getmem(sizeof(object));
memcpy(co[c].o,co[g].o,sizeof(object));
co[c].o->r=getmem(sizeof(rmatrix));
co[c].o->r0=getmem(sizeof(rmatrix));
memset(co[c].o->r,0,sizeof(rmatrix));
memset(co[c].o->r0,0,sizeof(rmatrix));
co[c].on=0;
if(!indemo) printf("(co[%i]:%s)\n",c,co[c].o->name);
}
}
co[0].o=&camobject;
camobject.r=&cam;
camobject.r0=&cam;
if(!indemo)
{
printf("Press any key to continue...");
getch();
}
vid_init(1);
cp=(char *)(scenem+16);
vid_setpal(cp);
_asm int 3
resetscene();
for(;;)
{
int fov;
int onum;
long pflag;
long dis;
long l;
object *o;
rmatrix *r;
_asm mov bx,2
_asm int 0fch // exit?
_asm mov a,ax
if(a) break;
vid_switch();
_asm mov bx,1
_asm int 0fch // waitb
vid_clear();
// parse animation stream
onum=0;
for(;;)
{
sptemp=sp;
_asm
{
mov ax,word ptr sptemp[0]
cmp ax,1000h
jb l1
sub word ptr sptemp[0],1000h
add word ptr sptemp[2],100h
l1:
}
sp=sptemp;
a=*sp++;
if(a==0xff)
{
a=*sp++;
if(a<=0x7f)
{
fov=a<<8;
break;
}
else if(a==0xff)
{
if(indemo) break;
resetscene();
continue;
}
}
if((a&0xc0)==0xc0)
{
onum=((a&0x3f)<<4);
a=*sp++;
}
onum=(onum&0xff0)|(a&0xf);
b=0;
switch(a&0xc0)
{
case 0x80 : b=1; co[onum].on=1; break;
case 0x40 : b=1; co[onum].on=0; break;
}
#ifdef DEBUG
if(b) fprintf(fr,"[%i (%s) ",onum,co[onum].on?"on":"off");
else fprintf(fr,"[%i (--) ",onum,co[onum].on?"on":"off");
#endif
if(onum>=conum) return(3);
r=co[onum].o->r0;
pflag=0;
switch(a&0x30)
{
case 0x00 : break;
case 0x10 : pflag|=*sp++; break;
case 0x20 : pflag|=sp[0];
pflag|=(long)sp[1]<<8;
sp+=2; break;
case 0x30 : pflag|=sp[0];
pflag|=(long)sp[1]<<8;
pflag|=(long)sp[2]<<16;
sp+=3; break;
}
#ifdef DEBUG
fprintf(fr,"pfl:%06lX",pflag);
#endif
l=lsget(pflag);
r->x+=l;
l=lsget(pflag>>2);
r->y+=l;
l=lsget(pflag>>4);
r->z+=l;
#ifdef DEBUG
fprintf(fr," XYZ:(%li,%li,%li)",r->x,r->y,r->z);
#endif
if(pflag&0x40)
{ // word matrix
for(b=0;b<9;b++) if(pflag&(0x80<<b))
{
r->m[b]+=lsget(2);
}
}
else
{ // byte matrix
for(b=0;b<9;b++) if(pflag&(0x80<<b))
{
r->m[b]+=lsget(1);
}
}
#ifdef DEBUG
fprintf(fr,"]\n");
#endif
}
// Field of vision
vid_cameraangle(fov);
// Calc matrices and add to order list (only enabled objects)
ordernum=0;
/* start at 1 to skip camera */
for(a=1;a<conum;a++) if(co[a].on)
{
order[ordernum++]=a;
o=co[a].o;
memcpy(o->r,o->r0,sizeof(rmatrix));
calc_applyrmatrix(o->r,&cam);
b=o->pl[0][1]; // center vertex
co[a].dist=calc_singlez(b,o->v0,o->r);
}
// Zsort
if(city)
{
co[2].dist=1000000000L; // for CITY scene, test
co[7].dist=1000000000L; // for CITY scene, test
co[13].dist=1000000000L; // for CITY scene, test
}
for(a=0;a<ordernum;a++)
{
dis=co[c=order[a]].dist;
for(b=a-1;b>=0 && dis>co[order[b]].dist;b--)
order[b+1]=order[b];
order[b+1]=c;
}
// Draw
for(a=0;a<ordernum;a++)
{
int x,y;
o=co[order[a]].o;
#ifdef DEBUG
fprintf(fr,"%s (i:%i Z:%li)\n",o->name,order[a],co[order[a]].dist);
#endif
vis_drawobject(o);
}
#ifdef DEBUG
fprintf(fr,"\n");
#endif
}
vid_deinit();
#ifdef DEBUG
fclose(fr);
#endif
return(0);
}
//////////////////////////////////////////////////////////////////////////////
void *getmem(long size)
{
void *p;
if(size>160000L)
{
printf("GETMEM: attempting to reserved >160K (%li byte block)\n",size);
exit(3);
}
p=halloc(size/16L+1,16);
if(!p)
{
printf("GETMEM: out of memory (%li byte block)\n",size);
exit(3);
}
return(p);
}
void freemem(void *p)
{
hfree(p);
}
char *readfile(char *name)
{
FILE *f1;
long size;
char huge *p,*p0;
f1=fopen(name,"rb");
if(!f1)
{
printf("File '%s' not found.",name);
exit(3);
}
fseek(f1,0L,SEEK_END);
p0=p=getmem(size=ftell(f1));
fseek(f1,0L,SEEK_SET);
if(size>64000)
{
fread(p,64000,1,f1);
size-=64000;
_asm
{
add word ptr p[2],4000
}
fread(p,(size_t)size,1,f1);
}
else fread(p,(size_t)size,1,f1);
fclose(f1);
return(p0);
}

BIN
VISU/C/CITY.EXE Normal file

Binary file not shown.

BIN
VISU/C/CITY.LBM Normal file

Binary file not shown.

11
VISU/C/CITY.MAT Normal file
View file

@ -0,0 +1,11 @@
;format: MATERIAL-NAME <parameters>
;parameters:
;#(number) first color in fade
;L# length of color fade (#=32/16/8/1=no fading)
;G gouraud
;X Two sided material
GRAYCEMENT 0 L32
GREENGRASS 32 L32 G
BLUEMETAL 64 L32 G
CYANMETAL 96 L32 G
GOLDMETAL 128 L32 G

198
VISU/C/CITY.NFO Normal file
View file

@ -0,0 +1,198 @@
Mesh objects: Total vertices:764 Total faces:1204
Building01
Vertices:32 Faces:60
Materials:
GOLDMETAL
Smoothing:
1, 2, 3, 4, 5, 6, 10, 11, 12, 17
platform01
Vertices:64 Faces:96
Materials:
GRAYCEMENT
Building03
Vertices:16 Faces:24
Materials:
CYANMETAL
Building04
Vertices:8 Faces:12
Materials:
BLUEMETAL
Building06
Vertices:9 Faces:14
Materials:
BLUEMETAL
BuildingH
Vertices:40 Faces:60
Materials:
CYANMETAL
platform02
Vertices:120 Faces:178
Materials:
GRAYCEMENT
GREENGRASS
Building05
Vertices:8 Faces:12
Materials:
BLUEMETAL
Building08
Vertices:8 Faces:12
Materials:
BLUEMETAL
Building09
Vertices:9 Faces:14
Materials:
BLUEMETAL
Building10
Vertices:8 Faces:12
Materials:
BLUEMETAL
Building11
Vertices:16 Faces:24
Materials:
CYANMETAL
Building12
Vertices:16 Faces:24
Materials:
CYANMETAL
Car02
Vertices:12 Faces:20
Materials:
CYANMETAL
Page 1
platform03
Vertices:128 Faces:192
Materials:
GRAYCEMENT
GREENGRASS
Building02
Vertices:9 Faces:14
Materials:
BLUEMETAL
Building13
Vertices:9 Faces:14
Materials:
BLUEMETAL
Building14
Vertices:9 Faces:14
Materials:
BLUEMETAL
Building15
Vertices:8 Faces:12
Materials:
BLUEMETAL
Building16
Vertices:8 Faces:12
Materials:
BLUEMETAL
Building17
Vertices:8 Faces:12
Materials:
BLUEMETAL
Building18
Vertices:8 Faces:12
Materials:
BLUEMETAL
Building19
Vertices:8 Faces:12
Materials:
BLUEMETAL
BuildingC
Vertices:18 Faces:32
Materials:
CYANMETAL
Smoothing:
1, 2, 3, 10, 11, 12, 17
Building20
Vertices:14 Faces:24
Materials:
CYANMETAL
Building21
Vertices:19 Faces:34
Materials:
CYANMETAL
fclogo
Vertices:36 Faces:64
Smoothing:
1, 2, 3, 10, 11, 12, 17
Lamppost
Vertices:8 Faces:8
Materials:
GOLDMETAL
Helicopter
Vertices:72 Faces:140
Page 2
Materials:
GOLDMETAL
Smoothing:
1, 2, 3, 4, 5, 6, 10, 11, 12, 17
HeliRotor
Vertices:12 Faces:10
Materials:
GOLDMETAL
Smoothing:
17
Building07
Vertices:8 Faces:12
Materials:
BLUEMETAL
Building22
Vertices:8 Faces:12
Materials:
BLUEMETAL
Building23
Vertices:8 Faces:12
Materials:
BLUEMETAL
Materials summary:
GRAYCEMENT
GREENGRASS
BLUEMETAL
CYANMETAL
GOLDMETAL
Lights:
Light01
Cameras:
FlyCam (50.00mm)
Page 3

BIN
VISU/C/CITY.OBJ Normal file

Binary file not shown.

BIN
VISU/C/CITY.PAL Normal file

Binary file not shown.

BIN
VISU/C/CITY0A.OK Normal file

Binary file not shown.

BIN
VISU/C/CITYPAL.PAL Normal file

Binary file not shown.

407
VISU/C/CPLAY.C Normal file
View file

@ -0,0 +1,407 @@
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <malloc.h>
#include "..\cd.h"
#include "..\c.h"
#define DEBUG
int indemo=0;
char scene[64]={"CITY"};
char tmpname[64];
char huge *scene0;
char huge *scenem;
int city=0;
#define LONGAT(zz) *((long huge *)(zz))
#define INTAT(zz) *((int huge *)(zz))
#define CHARAT(zz) *((char huge *)(zz))
struct s_scl
{
char *data;
} scenelist[64];
int scl=0,sclp=0;
#define MAXOBJ 256
struct s_co
{
object *o;
long dist;
int index;
int on;
} co[MAXOBJ];
int conum;
FILE *fr;
object camobject;
rmatrix cam;
int order[MAXOBJ],ordernum;
unsigned char huge *sp;
long lsget(unsigned char f)
{
long l;
switch(f&3)
{
case 0 : l=0;
break;
case 1 : l=(long)(char)(*sp++);
break;
case 2 : l=*sp++;
l|=(long)(char)(*sp++)<<8;
break;
case 3 : l=*sp++;
l|=(long)(*sp++)<<8;
l|=(long)(*sp++)<<16;
l|=(long)(char)(*sp++)<<24;
break;
}
return(l);
}
void resetscene(void)
{
int a;
sp=(unsigned char *)(scenelist[sclp].data);
for(a=0;a<conum;a++)
{
memset(co[a].o->r,0,sizeof(rmatrix));
memset(co[a].o->r0,0,sizeof(rmatrix));
}
sclp++;
if(sclp>=scl)
{
sclp=0;
}
}
main(int argc,char *argv[])
{
char huge *sptemp;
int huge *ip;
char huge *cp;
int a,b,c,d,e,f,g;
#ifdef DEBUG
fr=fopen("tmp","wt");
#endif
if(argc>1)
{
strcpy(scene,argv[1]);
strupr(scene);
}
else indemo=1;
sprintf(tmpname,"%s.00M",scene);
if(!indemo) printf("Loading materials %s...\n",tmpname);
scene0=scenem=readfile(tmpname);
if(scene0[15]=='C') city=1;
if(scene0[15]=='R') city=2;
ip=(int huge *)(scene0+LONGAT(scene0+4));
conum=d=*ip++;
for(f=-1,c=1;c<d;c++)
{
e=*ip++;
if(e>f)
{
f=e;
sprintf(tmpname,"%s.%03i",scene,e);
if(!indemo) printf("Loading %s... ",tmpname);
co[c].o=vis_loadobject(tmpname);
memset(co[c].o->r,0,sizeof(rmatrix));
memset(co[c].o->r0,0,sizeof(rmatrix));
co[c].index=e;
co[c].on=0;
if(!indemo) printf("(co[%i]:%s)\n",c,co[c].o->name);
}
else
{
if(!indemo) printf("Copying %s.%03i... ",scene,e);
for(g=0;g<c;g++) if(co[g].index==e) break;
memcpy(co+c,co+g,sizeof(struct s_co));
co[c].o=getmem(sizeof(object));
memcpy(co[c].o,co[g].o,sizeof(object));
co[c].o->r=getmem(sizeof(rmatrix));
co[c].o->r0=getmem(sizeof(rmatrix));
memset(co[c].o->r,0,sizeof(rmatrix));
memset(co[c].o->r0,0,sizeof(rmatrix));
co[c].on=0;
if(!indemo) printf("(co[%i]:%s)\n",c,co[c].o->name);
}
}
co[0].o=&camobject;
camobject.r=&cam;
camobject.r0=&cam;
sprintf(tmpname,"%s.0AA",scene);
if(!indemo) printf("Loading animations...\n",tmpname);
ip=readfile(tmpname);
while(*ip)
{
a=*ip;
if(a==-1) break;
sprintf(tmpname,"%s.0%c%c",scene,a/10+'A',a%10+'A');
if(!indemo) printf("Scene: %s ",tmpname);
scenelist[scl].data=readfile(tmpname);
printf("(%i:@%Fp)\n",scl,scenelist[scl].data);
scl++;
ip+=2;
}
if(!indemo)
{
printf("Press any key to continue...");
getch();
}
resetscene();
vid_init(1); ////// oversample x 4
cp=(char *)(scenem+16);
vid_setpal(cp);
outp(0x3c8,0);
outp(0x3c9,0);
outp(0x3c9,0);
outp(0x3c9,0);
while(!kbhit())
{
int fov;
int onum;
long pflag;
long dis;
long l;
object *o;
rmatrix *r;
vid_switch();
vid_waitb();
vid_clear();
// parse animation stream
onum=0;
for(;;)
{
/*
sptemp=sp;
_asm
{
mov ax,word ptr sptemp[0]
cmp ax,1000h
jb l1
sub word ptr sptemp[0],1000h
add word ptr sptemp[2],100h
l1:
}
sp=sptemp;
*/
a=*sp++;
if(a==0xff)
{
a=*sp++;
if(a<=0x7f)
{
fov=a<<8;
break;
}
else if(a==0xff)
{
resetscene();
continue;
}
}
if((a&0xc0)==0xc0)
{
onum=((a&0x3f)<<4);
a=*sp++;
}
onum=(onum&0xff0)|(a&0xf);
b=0;
switch(a&0xc0)
{
case 0x80 : b=1; co[onum].on=1; break;
case 0x40 : b=1; co[onum].on=0; break;
}
#ifdef DEBUG
if(b) fprintf(fr,"[%i (%s) ",onum,co[onum].on?"on":"off");
else fprintf(fr,"[%i (--) ",onum,co[onum].on?"on":"off");
#endif
if(onum>=conum) return(3);
r=co[onum].o->r0;
pflag=0;
switch(a&0x30)
{
case 0x00 : break;
case 0x10 : pflag|=*sp++; break;
case 0x20 : pflag|=sp[0];
pflag|=(long)sp[1]<<8;
sp+=2; break;
case 0x30 : pflag|=sp[0];
pflag|=(long)sp[1]<<8;
pflag|=(long)sp[2]<<16;
sp+=3; break;
}
#ifdef DEBUG
fprintf(fr,"pfl:%06lX",pflag);
#endif
l=lsget(pflag);
r->x+=l;
l=lsget(pflag>>2);
r->y+=l;
l=lsget(pflag>>4);
r->z+=l;
#ifdef DEBUG
fprintf(fr," XYZ:(%li,%li,%li)",r->x,r->y,r->z);
#endif
if(pflag&0x40)
{ // word matrix
for(b=0;b<9;b++) if(pflag&(0x80<<b))
{
r->m[b]+=lsget(2);
}
}
else
{ // byte matrix
for(b=0;b<9;b++) if(pflag&(0x80<<b))
{
r->m[b]+=lsget(1);
}
}
#ifdef DEBUG
fprintf(fr,"]\n");
#endif
}
// Field of vision
vid_cameraangle(fov);
// Calc matrices and add to order list (only enabled objects)
ordernum=0;
/* start at 1 to skip camera */
for(a=1;a<conum;a++) if(co[a].on)
{
order[ordernum++]=a;
o=co[a].o;
memcpy(o->r,o->r0,sizeof(rmatrix));
calc_applyrmatrix(o->r,&cam);
b=o->pl[0][1]; // center vertex
if(co[a].o->name[1]=='_') co[a].dist=1000000000L;
else co[a].dist=calc_singlez(b,o->v0,o->r);
}
// Zsort
if(city==1)
{
co[2].dist=1000000000L; // for CITY scene, test
co[7].dist=1000000000L; // for CITY scene, test
co[13].dist=1000000000L; // for CITY scene, test
}
if(city==2)
{
co[14].dist=1000000000L; // for CITY scene, test
}
for(a=0;a<ordernum;a++)
{
dis=co[c=order[a]].dist;
for(b=a-1;b>=0 && dis>co[order[b]].dist;b--)
order[b+1]=order[b];
order[b+1]=c;
}
// Draw
for(a=0;a<ordernum;a++)
{
int x,y;
o=co[order[a]].o;
#ifdef DEBUG
fprintf(fr,"%s (i:%i Z:%li)\n",o->name,order[a],co[order[a]].dist);
#endif
vis_drawobject(o);
}
#ifdef DEBUG
fprintf(fr,"\n");
#endif
}
vid_deinit();
#ifdef DEBUG
fclose(fr);
#endif
return(0);
}
//////////////////////////////////////////////////////////////////////////////
void *getmem(long size)
{
void *p;
if(size>160000L)
{
printf("GETMEM: attempting to reserved >160K (%li byte block)\n",size);
exit(3);
}
p=halloc(size/16L+1,16);
if(!p)
{
printf("GETMEM: out of memory (%li byte block)\n",size);
exit(3);
}
return(p);
}
void freemem(void *p)
{
hfree(p);
}
char *readfile(char *name)
{
FILE *f1;
long size;
char huge *p,*p0;
f1=fopen(name,"rb");
if(!f1)
{
printf("File '%s' not found.",name);
exit(3);
}
fseek(f1,0L,SEEK_END);
p0=p=getmem(size=ftell(f1));
fseek(f1,0L,SEEK_SET);
if(size>128000)
{
fread(p,64000,1,f1);
size-=64000;
_asm add word ptr p[2],4000
fread(p,64000,1,f1);
size-=64000;
_asm add word ptr p[2],4000
fread(p,(size_t)size,1,f1);
}
else if(size>64000)
{
fread(p,64000,1,f1);
size-=64000;
_asm
{
add word ptr p[2],4000
}
fread(p,(size_t)size,1,f1);
}
else fread(p,(size_t)size,1,f1);
fclose(f1);
return(p0);
}

BIN
VISU/C/CPLAY.EXE Normal file

Binary file not shown.

BIN
VISU/C/CPLAY.OBJ Normal file

Binary file not shown.

165
VISU/C/DEBUG.1 Normal file
View file

@ -0,0 +1,165 @@
face 2: 0 1 2 3
face 16: 0 4 5 1
face 30: 2 6 3
face 42: 3 6 4 0
face 56: 8 7 9
face 68: 11 10 12
30 56 2 16
compare f1(56) with f4(42)
camera at -68915832, d1=0, d2=4037, d1a=0 d2a=4037
returns -1
30 56 2 16
compare f1(56) with f3(16)
camera at -68915832, d1=0, d2=39093, d1a=0 d2a=39093
returns -1
2 30 16 42
compare f0(2) with f1(30)
camera at 82536286, d1=-22283, d2=0, d1a=22283 d2a=0
returns -1
30 2 16 42
compare f0(30) with f2(16)
camera at -128617788, d1=-61200, d2=0, d1a=61200 d2a=0
returns 1
30 2 16 42
compare f0(30) with f3(42)
camera at -128617788, d1=-40798, d2=0, d1a=40798 d2a=0
returns 1
30 2 16 42
compare f0(30) with f4(68)
camera at -128617788, d1=-28494, d2=0, d1a=28494 d2a=0
returns 1
30 2 16 42
compare f0(30) with f5(56)
camera at -128617788, d1=-29454, d2=0, d1a=29454 d2a=0
returns 1
30 2 16 42
compare f0(30) with f1(2)
camera at -128617788, d1=-30602, d2=0, d1a=30602 d2a=0
returns 1
30 2 16 42
compare f0(30) with f2(16)
camera at -128617788, d1=-61200, d2=0, d1a=61200 d2a=0
returns 1
30 2 16 42
compare f0(30) with f3(42)
camera at -128617788, d1=-40798, d2=0, d1a=40798 d2a=0
returns 1
30 2 16 42
compare f0(30) with f4(68)
camera at -128617788, d1=-28494, d2=0, d1a=28494 d2a=0
returns 1
30 2 16 42
compare f0(30) with f5(56)
camera at -128617788, d1=-29454, d2=0, d1a=29454 d2a=0
returns 1
30 2 16 42
compare f1(2) with f2(16)
camera at 82536286, d1=-22287, d2=0, d1a=22287 d2a=0
returns -1
30 16 2 42
compare f1(16) with f3(42)
camera at 67413648, d1=-30605, d2=0, d1a=30605 d2a=0
returns -1
30 42 2 16
compare f1(42) with f4(68)
camera at 72956014, d1=-37256, d2=0, d1a=37256 d2a=0
returns -1
30 68 2 16
compare f1(68) with f5(56)
camera at 80004026, d1=-25569, d2=0, d1a=25569 d2a=0
returns -1
30 56 2 16
compare f1(56) with f2(2)
camera at -68915832, d1=0, d2=39091, d1a=0 d2a=39091
returns -1
30 56 2 16
compare f1(56) with f3(16)
camera at -68915832, d1=0, d2=39093, d1a=0 d2a=39093
returns -1
30 56 2 16
compare f1(56) with f5(68)
camera at -68915832, d1=0, d2=41296, d1a=0 d2a=41296
returns -1
30 56 2 16
compare f2(2) with f3(16)
camera at 82536286, d1=-22287, d2=0, d1a=22287 d2a=0
returns -1
30 56 16 2
compare f2(16) with f4(42)
camera at 67413648, d1=-30605, d2=0, d1a=30605 d2a=0
returns -1
30 56 42 2
compare f2(42) with f5(68)
camera at 72956014, d1=-37256, d2=0, d1a=37256 d2a=0
returns -1
30 56 68 2
compare f2(68) with f3(2)
camera at 80004026, d1=-2539, d2=0, d1a=2539 d2a=0
returns -1
30 56 68 2
compare f2(68) with f4(16)
camera at 80004026, d1=-24819, d2=0, d1a=24819 d2a=0
returns -1
30 56 68 2
compare f2(68) with f5(42)
camera at 80004026, d1=-24819, d2=0, d1a=24819 d2a=0
returns -1
30 56 68 2
compare f3(2) with f4(16)
camera at 82536286, d1=-22287, d2=0, d1a=22287 d2a=0
returns -1
30 56 68 16
compare f3(16) with f5(42)
camera at 67413648, d1=-30605, d2=0, d1a=30605 d2a=0
returns -1
30 56 68 42
compare f3(42) with f4(2)
camera at 72956014, d1=-46736, d2=5, d1a=46736 d2a=5
returns -1
30 56 68 42
compare f3(42) with f5(16)
camera at 72956014, d1=-46738, d2=0, d1a=46738 d2a=0
returns -1
30 56 68 42
compare f4(2) with f5(16)
camera at 82536286, d1=-22287, d2=0, d1a=22287 d2a=0
returns -1
30 56 68 42
compare f4(16) with f5(2)
camera at 67413648, d1=-40801, d2=1, d1a=40801 d2a=1
returns -1

BIN
VISU/C/DIS.EXE Normal file

Binary file not shown.

45
VISU/C/DOC Normal file
View file

@ -0,0 +1,45 @@
Files in general:
*.00A Animation
*.00M Materials (palette)
*.### Object ### (###=number prefixed with zeros)
OBJECT FILE:
SCENE.00A FILE:
word: number of objects
word: file number for object 0
word: file number for object 1
...
word: file number for object N
Stream of frame data starts.
word X
x&0xfff = number of object
bits:
0x0F Low 4 bits of the object to modify
0x30 Bytes of flags to read (0..3)
0xC0 Command:
0x00 0=Leave to list
0x40 1=Remove from list
0x80 2=Add to list
0xC0 3=Hi change. X&0x3F=Object number/16. (high bits)
Hi change 0x3F (X=0xFF) means special. Next byte Y:
<0x80=next frame, Y=hi byte of camera angle (field of vision)
0=next frame
0xFF=end of anim
Position: 3 x DWORD
Rotation: 9 x WORD
###
Flags:
bits:
0..1 0=X coordinate same, 1=byte change, 2=word change, 3=dword chnage (all start out zero)
2..3 -"- for Y coordinate
4..5 -"- for Z coordinate
6 1=Matrix stored with word changes (0=bytes)
7..15 1=This entry in matrix changed
All objects start hidden (except camera)

BIN
VISU/C/DOOBJ.EXE Normal file

Binary file not shown.

BIN
VISU/C/DP_PREFS Normal file

Binary file not shown.

BIN
VISU/C/FAKE.EXE Normal file

Binary file not shown.

BIN
VISU/C/FLY.3DS Normal file

Binary file not shown.

BIN
VISU/C/GLVP.EXE Normal file

Binary file not shown.

569
VISU/C/MAIN.C Normal file
View file

@ -0,0 +1,569 @@
// 3DS converter V2.0
#include <stdio.h>
#include <stdarg.h>
#include <conio.h>
#include <ctype.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include <math.h>
#include "..\cd.h"
#include "..\c.h"
void vDraw(void);
void vDeinit(void);
void vClear(void);
void vNext(void);
void vInit(void);
void vPalette(void);
int drawpass=0;
void doscene(int scene);
int addvx(long x,long y,long z);
int addnr(long x,long y,long z);
char far *vram=(char far *)0xa0000000L;
char fill_color[64000];
char fill_object[64000];
char fill_curobj;
//----------------------------------------------------------------
// filenames
char *inname="NoName";
char ascname[64];
char vuename[64];
char tmpname[64];
char scenename[64];
// flags
int cityflag=0;
int debug=0;
int printon=0;
int reporton=1;
int playloop=0;
int materials=0;
int vuedone=0;
// variables
float fxadd,fxmul;
float fyadd,fymul;
float fzadd,fzmul;
float scale=100.0F;
#define BIGLONG 2000000000L
#define MAXMAT 32
#define MAXFACE 16 // in a polygon
#define MAXOBJ 256
#define MAXVX 500
#define MAXNR 500
#define MAXFC 500
#define NORMALSIZE UNIT // length of normals
//----------------------------------------------------------------
// globals
rmatrix camera;
FILE *in,*in2;
FILE *outb,*outb2,*outb3;
FILE *freport=NULL;
FILE *fdeb;
int debcount=0;
char palette[768];
// prototypes
void readvue(void);
void readasc(void);
// world structs
struct s_cobject
{
char name[18];
int index;
int duplicate;
int original;
int lastused;
int f1,f2,n1,n2,v1,v2,ng;
long size;
char fname[16];
object *o;
long dist;
int on;
int last_on;
long last_x,last_y,last_z;
long last_m[9];
} co[MAXOBJ];
int conum=0;
struct s_material
{
char name[32];
int flags;
int color;
int colorlen;
} mat[MAXMAT];
int matnum=0;
char matpal[768];
int matpalenabled=0;
int usefov;
object camobject;
// other c code included
#include "save.c"
#include "util.c"
#include "osort.c"
#include "readasc.c"
#include "readvue.c"
#include "readmat.c"
#include "readinf.c"
// main
main(int argc,char *argv[])
{
char tmpfname[64];
int pause=0;
int a;
int totalfaces=0,totalvertices=0,totalnormals=0;
fdeb=fopen("debug.tmp","wt");
if(argc==1)
{
printf("\n"
"usage: C [options] <scenename(no extensions)>\n"
"-c Set Cityflag\n"
"-w Set Runflag\n"
"-r Generate report (to file REPORT)\n"
"-p Print report to screen as well\n"
"-l Loop the animation phase until key pressed\n"
"-s### Specify scale factor (default 100.0)\n"
);
return(0);
}
reporton=0;
for(a=1;a<argc;a++) if(argv[a][0]=='-') switch(argv[a][1])
{
case 'c' :
case 'C' : cityflag=1; break;
case 'w' :
case 'W' : cityflag=2; break;
case 'r' :
case 'R' : reporton=1; break;
case 'p' :
case 'P' : reporton=printon=1; break;
case 's' :
case 'S' : sscanf(argv[a]+2,"%f",&scale); break;
case 'l' :
case 'L' : playloop=1; break;
}
else strcpy(inname,argv[a]);
// defaults
strupr(inname);
strcpy(ascname,inname);
strcat(ascname,".ASC");
strcpy(vuename,inname);
strcat(vuename,".VUE");
strcpy(scenename,inname);
fxmul=scale; fxadd=0.0F;
fymul=scale; fyadd=0.0F;
fzmul=scale; fzadd=0.0F;
in=fopen(ascname,"rt");
if(!in)
{
printf("%s not found!\n",ascname);
exit(3);
}
fclose(in);
if(reporton) freport=fopen("report","wt");
// blue screen
printf( "\n");
printf( "Analyzing and converting (while screen is blue)\n");
printf( " Scene name: %s\n",inname);
printf( "Scale factor: %f\n",scale);
if(pause)
{
printf("Press any key to start.\n");
getch();
}
else printf("\n");
outp(0x3c8,0); outp(0x3c9,0); outp(0x3c9,0); outp(0x3c9,32);
strcpy(co[0].name,"CAMERA");
co[0].on=1; // camera is always on
co[0].index=-1;
co[0].duplicate=1; // let's lie
co[0].original=0;
co[0].lastused=0;
co[0].o=&camobject;
camobject.r=&camera;
camobject.r0=&camera;
conum=1;
strcpy(tmpname,inname);
strcat(tmpname,".INF");
in=fopen(tmpname,"rt");
if(in) fclose(in);
else
{
printf("%s.INF file not found!\n",inname);
exit(3);
}
strcpy(tmpname,inname);
strcat(tmpname,".MAT");
in=fopen(tmpname,"rt");
if(in)
{
readmat();
fclose(in);
}
strcpy(tmpname,inname);
strcat(tmpname,".PAL");
in=fopen(tmpname,"rb");
if(in)
{
matpalenabled=1;
fread(matpal,768,1,in);
fclose(in);
}
else
{
for(a=0;a<32;a++)
{
matpal[a*3+0]=a*2;
matpal[a*3+1]=a*2;
matpal[a*3+2]=a*2;
}
}
sprintf(tmpfname,"%s.00M",scenename);
outb3=fopen(tmpfname,"wb");
putw(0,outb3);
putw(0,outb3);
putw(0,outb3);
putw(0,outb3);
putw(0,outb3);
putw(0,outb3);
putw(0,outb3);
putw(0,outb3);
fwrite(matpal,768,1,outb3);
in=fopen(ascname,"rt");
if(!in)
{
printf("%s not found!\n",ascname);
exit(3);
}
readasc();
fclose(in);
vInit();
printon=0;
for(a=1;a<conum;a++)
{
objectsort(co[a].o);
}
_asm mov ax,13h
_asm int 10h
vPalette();
sprintf(tmpfname,"%s.0AA",scenename);
outb2=fopen(tmpfname,"wb");
strcpy(tmpname,inname);
strcat(tmpname,".INF");
in=fopen(tmpname,"rt");
readinf();
fclose(in);
putw(0xffff,outb2);
putw(0xffff,outb2);
fclose(outb2);
{ // init stuff for script
int coi;
long l,l2;
struct s_cobject *cop;
l=ftell(outb3);
putw(conum,outb3);
for(coi=1;coi<conum;coi++)
{
cop=co+coi;
putw(cop->index,outb3);
}
fseek(outb3,0L,SEEK_SET);
putc('F',outb3);
putc('C',outb3);
putc(0xfc,outb3);
putc(0x1a,outb3);
putl(l,outb3);
putw(0,outb3);
putw(0,outb3);
putw(0,outb3);
putc(0,outb3);
if(cityflag==1) putc('C',outb3);
else if(cityflag==2) putc('R',outb3);
else putc(0,outb3);
}
if(!kbhit()) vuedone=1;
if(kbhit()) getch();
vDeinit();
{
if(vuedone) printf("Saving scenery: (%s.00O,%s.00M,%s.0$$)\n\n",scenename,scenename,scenename);
else printf("Saving objects: (%s.00M)\n\n",scenename);
for(a=1;a<conum;a++)
{
if(!co[a].duplicate)
{
printf("Object: %s",co[a].name);
saveobject(co+a); // save object to disk
printf(" File: %s Size:%li\n",co[a].fname,co[a].size);
printf(" Faces:%i=>%i Vertices:%i=>%i Normals:%i Gouraudnormals:%i\n",
co[a].f1,co[a].f2,
co[a].v1,co[a].v2,
co[a].n2,co[a].ng-co[a].n2);
}
totalfaces+=co[co[a].index].f1;
totalvertices+=co[co[a].index].v1;
totalnormals+=co[co[a].index].n2;
}
}
print("Conversion finished (or escaped)!\n");
printf("Total sum of stuff in animation:\n"
" faces: %i\n"
"vertices: %i\n"
" normals: %i\n",
totalfaces,
totalvertices,
totalnormals);
if(freport) fclose(freport);
fclose(fdeb);
return(0);
}
void doscene(int scene)
{
int a;
char tmpfname[64];
sprintf(tmpfname,"%s-%i.vue",inname,scene);
in=fopen(tmpfname,"rt");
if(!in)
{
print("Scene %s not found.\n",tmpfname);
return;
}
vuedone=1;
putw(scene,outb2);
putw(0,outb2);
sprintf(tmpfname,"%s.0%c%c",inname,scene/10+'A',scene%10+'A');
outb=fopen(tmpfname,"wb");
readvue();
fclose(in);
fclose(outb);
}
void vPalette(void)
{
int a,b;
if(matpalenabled)
{
vid_setpal(matpal);
return;
}
for(a=0;a<256;a++)
{
palette[a*3+0]=(char)((a&15)*3+((a/16)&3)*0);
palette[a*3+1]=(char)((a&15)*3+((a/16)&3)*2);
palette[a*3+2]=(char)((a&15)*3+((a/16)&3)*4);
}
for(a=0;a<32;a++)
{
palette[16*3+a*3+0]=(char)(63-a*2);
palette[16*3+a*3+1]=(char)(63-a*2);
palette[16*3+a*3+2]=(char)(63-a*2);
}
palette[2]=32;
palette[255*3+0]=63;
palette[255*3+1]=32;
palette[255*3+2]=16;
vid_setpal(palette);
}
void vInit(void)
{
vid_init(1);
vPalette();
}
void vDeinit(void)
{
vid_deinit();
}
void vNext(void)
{
vid_switch();
vid_waitb();
vid_clear();
}
void vClear(void)
{
vid_clear();
}
#pragma check_stack(off)
void _loadds cfill(int *fd)
{
int color,y,a,x,cnt;
long lx,la,rx,ra;
char *p,*pp;
a=*fd++;
if(a!=0) return; // not flat shading!
color=*fd++;
y=*fd++;
for(;;)
{
a=*fd++;
if(a<0) break;
if(a)
{
lx=(unsigned)(*fd++);
lx|=(long)(*fd++)<<16;
la=(unsigned)(*fd++);
la|=(long)(*fd++)<<16;
}
a=*fd++;
if(a<0) break;
if(a)
{
rx=(unsigned)(*fd++);
rx|=(long)(*fd++)<<16;
ra=(unsigned)(*fd++);
ra|=(long)(*fd++)<<16;
}
a=*fd++;
while(a--)
{
lx+=la;
rx+=ra;
if(lx<rx)
{
x=lx>>16;
cnt=(rx>>16)-x;
}
else
{
x=rx>>16;
cnt=(lx>>16)-x;
}
p=fill_color+x+y*320;
pp=fill_object+x+y*320;
#if 0
p[0]=color;
p[cnt-1]=color;
#else
while(cnt--)
{
*p++=color;
*pp++=fill_curobj;
}
#endif
y++;
}
}
}
#pragma check_stack(on)
int order[MAXOBJ],ordernum;
void vDraw(void)
{
rmatrix cam;
rmatrix tmp;
object *o;
long dis;
int a,b,c;
if(!drawpass)
{
vid_waitb();
memcpy(vram,fill_color,64000);
memset(fill_color,0,64000);
memset(fill_object,0,64000);
draw_setfillroutine(cfill);
}
else
{
vNext();
draw_setfillroutine(NULL);
}
memcpy(&cam,&camera,sizeof(rmatrix));
{
ordernum=0;
for(a=1;a<conum;a++)
{
order[ordernum++]=a;
o=co[a].o;
memcpy(o->r,o->r0,sizeof(rmatrix));
calc_applyrmatrix(o->r,&cam);
b=o->pl[0][1]; // center vertex
if(co[a].name[1]=='_') co[a].dist=100000000L;
else co[a].dist=calc_singlez(b,o->v0,o->r);
}
for(a=0;a<ordernum;a++)
{
dis=co[c=order[a]].dist;
for(b=a-1;b>=0 && dis>co[order[b]].dist;b--)
order[b+1]=order[b];
order[b+1]=c;
}
if(!drawpass)
{
print("[Zsort order: (conum=%i)]\n",conum);
}
for(a=0;a<ordernum;a++)
{
int x,y;
o=co[order[a]].o;
fill_curobj=order[a];
vis_drawobject(o);
co[order[a]].on=!o->vf;
if(!drawpass)
{
print("[%s(%i): %li (v%i)]\n",co[order[a]].name,order[a],co[order[a]].dist,o->pl[0][1]);
if(!o->vf)
{
x=o->pv[o->pl[0][1]].x;
y=o->pv[o->pl[0][1]].y;
x=x+y*320;
vram[x]=255;
vram[x-1]=255;
vram[x+1]=255;
vram[x-320]=255;
vram[x+320]=255;
}
}
}
if(!drawpass)
{
print("\n");
}
}
}

BIN
VISU/C/MAIN.OBJ Normal file

Binary file not shown.

4
VISU/C/MAK.BAT Normal file
View file

@ -0,0 +1,4 @@
cd ..
nmake
cd c
nmake c.exe

46
VISU/C/MAKEFILE Normal file
View file

@ -0,0 +1,46 @@
all : c.exe cplay.exe city.exe srvec.exe u2a.exe u2e.exe
#all : u2e.exe
# objects
objs=main.obj
main.c : readvue.c readinf.c readmat.c readasc.c util.c opt.c save.c osort.c
# option flags
asm_f = /ML /m9 /s /JJUMPS
cdeb_f = /AL /c /W2 /Zi
c_f = /AL /Oxaz /W2 /c
# general compile orders
.asm.obj :
tasm $(asm_f) $<
.c.obj :
cl /qc $(c_f) $<
c.exe : $(objs) ..\visu.lib
link /CO /E /ST:8192 $(objs),c.exe,nul,..\visu.lib;
cplay.obj : cplay.c
cl $(c_f) cplay.c
cplay.exe : cplay.obj ..\visu.lib
link /CO /E /ST:2048 cplay.obj,cplay.exe,nul,..\visu.lib;
city.exe : city.obj ..\visu.lib
link /CO /E /ST:2048 city.obj,city.exe,nul,..\visu.lib;
srvec.exe : srvec.obj ..\visu.lib
link /CO /E /ST:2048 srvec.obj,srvec.exe,nul,..\visu.lib;
u2a.exe : u2a.obj ..\visu.lib
link /E /ST:2048 u2a.obj+_bg.obk+..\..\dis\disc.obj,u2a.exe,nul,..\visu.lib;
copy u2a.exe ..\..\main\data
u2e.exe : u2e.obj ..\visu.lib
link /E /ST:2048 u2e.obj ..\..\dis\disc.obj,u2e.exe,nul,..\visu.lib;
copy u2e.exe ..\..\main\data

132
VISU/C/OPT.C Normal file
View file

@ -0,0 +1,132 @@
/* ASC optimization from:
char oname[64];
struct s_tmpvx *vx;
struct s_tmpfc *fc;
int vxnum,fcnum,vxleft,fcleft;
to:
int facedata[32767],facedatalen;
int faceoff[MAXFC],facenum;
*/
int currentface;
int connects[256],connectp;
int pvnum;
int pv[MAXFACE];
void padd(int v) // add vertex to pv
{
if(pvnum && pv[pvnum-1]==v) return;
pv[pvnum++]=v;
if(pvnum>=MAXFACE)
{
int a;
printf("FATAL ERROR: FACE OVERFLOW (SEE REPORT)");
print("FATAL: FACE %i OVERFLOWS (max %i sides) [",currentface,MAXFACE);
for(a=0;a<connectp;a++) print("%i ",connects[a]);
print("]");
exit(3);
}
}
void pexpand(struct s_tmpfc *f,int i,int cntn) // add face to pv
{
int k,l,v1,v2,cnt;
if(f->used) return;
f->used=1;
for(cnt=0;cnt<cntn;cnt++)
{
if(f->vv[i]) padd(f->v[i]);
else
{ // find the polygon on side and recurse
l=-1; // nothing found
v1=f->v[(i==2)?0:i+1];
v2=f->v[i];
for(k=0;k<fcnum;k++) if(!fc[k].used)
{
if(fc[k].v[0]==v1 && fc[k].v[1]==v2)
{
l=1; break;
}
if(fc[k].v[1]==v1 && fc[k].v[2]==v2)
{
l=2; break;
}
if(fc[k].v[2]==v1 && fc[k].v[0]==v2)
{
l=0; break;
}
}
if(l==-1)
{ // failed to find
padd(f->v[i]);
}
else
{
connects[connectp++]=k;
pexpand(fc+k,l,2);
}
}
i=(i==2)?0:i+1;
}
}
void optimize(void)
{
int nrm,i,j,flags,a;
facedatalen=facenum=0;
facedata[facedatalen++]=0; // 'null' face
for(j=0;j<vxnum;j++)
{
gvx[j].x=gvx[j].y=gvx[j].z=gvx[j].power=0;
}
for(i=0;i<fcnum;i++)
{
currentface=i;
connectp=0;
pvnum=0;
connects[connectp++]=i;
pexpand(fc+i,0,3);
if(pvnum)
{
long x=0,y=0,z=0;
// calc normal
{
struct s_tmpvx *v;
struct s_tmpvx *w;
int a,b;
double dl;
for(a=0;a<pvnum;a++)
{
v=vx+pv[a];
w=vx+pv[a?(a-1):(pvnum-1)];
x+=(v->y-w->y)*(v->z+w->z);
y+=(v->z-w->z)*(v->x+w->x);
z+=(v->x-w->x)*(v->y+w->y);
}
dl=sqrt((double)x*(double)x+(double)y*(double)y+(double)z*(double)z);
if(dl<-1 || dl>1)
{
x=-(long)((double)x*NORMALSIZE/dl);
y=-(long)((double)y*NORMALSIZE/dl);
z=-(long)((double)z*NORMALSIZE/dl);
}
nrm=addnr(x,y,z);
}
// write stuff
flags=mat[fc[i].material].flags;
faceoff[facenum++]=facedatalen*2; // char offset
facedata[facedatalen++]=pvnum|flags; // sides | flags
facedata[facedatalen++]=mat[fc[i].material].color; // color
facedata[facedatalen++]=nrm; // normal
for(j=0;j<pvnum;j++)
{
a=pv[j];
gvx[a].x+=x;
gvx[a].y+=y;
gvx[a].z+=z;
gvx[a].power++;
facedata[facedatalen++]=a;
}
}
}
}

271
VISU/C/OSORT.BBK Normal file
View file

@ -0,0 +1,271 @@
// object sorting
long osx,osy,osz; // sorting eye
long aosx,aosy,aosz; // sorting eye
long bosx,bosy,bosz; // sorting eye
static long osd=0;
void osetup(object *o,int flag)
{ // sets up camera distance etc for good viewing
long cx,cy,cz;
long ox,oy,oz;
long d=osd;
int a,c;
vlist *v;
for(c=0;c<64;c++)
{
ox=osx*d/256L;
oy=osy*d/256L;
oz=osz*d/256L;
v=o->v0+o->pl[0][1];
cx=v->x;
cy=v->y;
cz=v->z;
calc_setrmatrix_camera(o->r,ox+cx,oy+cy,oz+cz,cx,cy,cz);
calc_nrotate(o->nnum1,o->n,o->n0,o->r);
calc_rotate(o->vnum,o->v,o->v0,o->r);
calc_project(o->vnum,o->pv,o->v);
if(!flag) break;
for(a=0;a<o->vnum;a++) if(o->pv[a].vf) break;
if(a==o->vnum) break;
d=d*4/3;
}
if(osd<d) osd=d;
}
void sortdir(int d,long *osx,long *osy,long *osz)
{
switch(d)
{
case 0 : *osx=-256; *osy=-256; *osz=-256; break;
case 1 : *osx=256; *osy=-256; *osz=-256; break;
case 2 : *osx=256; *osy=256; *osz=-256; break;
case 3 : *osx=-256; *osy=256; *osz=-256; break;
case 4 : *osx=-256; *osy=-256; *osz=256; break;
case 5 : *osx=256; *osy=-256; *osz=256; break;
case 6 : *osx=256; *osy=256; *osz=256; break;
case 7 : *osx=-256; *osy=256; *osz=256; break;
default : *osx=*osy=*osz=0; break;
}
}
struct s_osp
{
long dis; // distance maximum
long dismin; // distance minimum
long a,b,c,d; // plane equation
int o; // offset
int swapped;
} osp[MAXFC];
struct s_osp osptmp;
int qcmp(struct s_osp *a,struct s_osp *b)
{
if(a->dis>b->dis) return(-1);
if(a->dis<b->dis) return(1);
return(0);
}
// -1=j farther than i (swap)
// 0==indetermined
// 1==i farther than j (ok)
// 2==i farther than j.. (next)}
int planecompare(struct s_osp *i,struct s_osp *j,object *o)
{
int *ip,*pp;
long d1=0,d2=0,dc=0,d,d1a,d2a;
int d1c=0,d2c=0;
int a,c;
if(i->dismin>j->dis) return(2);
pp=(int *)(j->o+(char *)(o->pd));
c=*pp++; // sides
c&=0xff;
pp++; // skip color
pp++; // skip normal
while(c--)
{
a=*pp++;
d=(long)(((double)o->v[a].x*(double)i->a+(double)o->v[a].y*(double)i->b+(double)o->v[a].z*(double)i->c+(double)i->d)/10000.0);
if(debcount<100)
{
fprintf(fdeb,"%id:%li\n",c,d);
debcount++;
}
if(d<0) { d1+=d; d1c++; }
else { d2+=d; d2c++; }
}
if(d1c) d1/=d1c;
if(d2c) d2/=d2c;
// camera at zero, so dc=i->d;
dc=i->d;
if(d1<0) d1a=-d1; else d1a=d1;
if(d2<0) d2a=-d2; else d2a=d2;
if(d1a>d2a)
{
if(d1>0 && dc>0) return(1);
return(-1);
}
else
{
if(d2>0 && dc>0) return(1);
return(-1);
}
}
void objectsort(object *o)
{
static int skipw=0;
long z,z1,z2;
long px,py,pz,pa,pb,pc,pd,td;
int fbak,i,j;
int d,a,c,b,n,onum;
int changed;
int *ip,*pp;
osd=256;
for(d=0;d<8;d++)
{
sortdir(d,&osx,&osy,&osz);
osetup(o,1);
}
for(d=0;d<8;d++)
{
aosx=osx;
aosy=osy;
aosz=osz;
sortdir(d,&osx,&osy,&osz);
bosx=osx;
bosy=osy;
bosz=osz;
if(d && !skipw)
{
for(a=0;a<=64;a+=2)
{
b=64-a;
osx=(aosx*(long)b+bosx*(long)a)>>6;
osy=(aosy*(long)b+bosy*(long)a)>>6;
osz=(aosz*(long)b+bosz*(long)a)>>6;
osetup(o,0);
fbak=o->flags;
o->flags&=~(F_GOURAUD);
vNext();
vis_drawobject(o);
o->flags=fbak;
}
}
osx=bosx;
osy=bosy;
osz=bosz;
osetup(o,0);
ip=o->pl[0]+2;
onum=0;
while(*ip)
{
osp[onum].o=*ip++;
pp=(int *)(osp[onum].o+(char *)o->pd);
c=*pp++; // sides
c&=0xff;
pp++; // skip color
n=*pp++; // skip normal
z=0; z2=0x7fffffff;
while(c--)
{
a=*pp++;
if(c==1)
{
px=o->v[a].x;
py=o->v[a].y;
pz=o->v[a].z;
}
z1=o->v[a].z;
if(z1>z) z=z1;
if(z1<z2) z2=z1;
}
osp[onum].a=pa=o->n[n].x;
osp[onum].b=pb=o->n[n].y;
osp[onum].c=pc=o->n[n].z;
osp[onum].d=pd=-px*pa-py*pb-pz*pc;
osp[onum].dis=z;
osp[onum].dismin=z2;
pp=(int *)(osp[onum].o+(char *)o->pd);
c=*pp++; // sides
c&=0xff;
pp++; // skip color
pp++; // skip normal
while(c--)
{
a=*pp++;
td=o->v[a].x*pa+o->v[a].y*pb+o->v[a].z*pc+pd;
/*
if(debcount<100)
{
fprintf(fdeb,"%id:%li\n",c,td);
debcount++;
}
*/
}
onum++;
}
qsort(osp,onum,sizeof(osp[0]),qcmp);
//resort by planes
#if 1
for(j=0;j<onum;j++) osp[j].swapped=0;
for(i=0;i<onum;i++)
{
changed=0;
for(j=i+1;j<onum;j++)
{
a=planecompare(osp+i,osp+j,o);
// -1=j farther than i (swap)
// 0==indetermined
// 1==i farther than j (ok)
// 2==i farther than j.. (next)
if(a==2) break;
else if(a==-1)
{
if(osp[j].swapped) continue; // no double swap
changed=1;
memcpy(&osptmp,osp+j,sizeof(osptmp));
memcpy(osp+j,osp+i,sizeof(osptmp));
memcpy(osp+i,&osptmp,sizeof(osptmp));
osp[j].swapped=1;
j=-1;
}
}
if(changed) i--;
else for(j=i+1;j<onum;j++) osp[j].swapped=0;
}
#endif
o->plnum=d+2;
ip=o->pl[d+1];
*ip++=onum+3;
ip++; // skip center vertex id
for(a=0;a<onum;a++)
{
*ip++=osp[a].o;
}
*ip++=0;
fbak=o->flags;
o->flags&=~(F_GOURAUD);
vNext();
vis_drawobject(o);
if(!skipw)
{
vNext();
vis_drawobject(o);
vNext();
vis_drawobject(o);
vNext();
vis_drawobject(o);
a=getch();
if(a==13) skipw=1;
}
o->flags=fbak;
}
}

322
VISU/C/OSORT.C Normal file
View file

@ -0,0 +1,322 @@
// object sorting
//#define SORTDIRS 6
#define SORTDIRS 8
long osx,osy,osz; // sorting eye
long aosx,aosy,aosz; // sorting eye
long bosx,bosy,bosz; // sorting eye
static long osd=0;
void osetup(object *o,int flag)
{ // sets up camera distance etc for good viewing
long cx,cy,cz;
long ox,oy,oz;
long d=osd;
int a,c;
vlist *v;
for(c=0;c<64;c++)
{
ox=osx*d/256L;
oy=osy*d/256L;
oz=osz*d/256L;
v=o->v0+o->pl[0][1];
cx=v->x;
cy=v->y;
cz=v->z;
calc_setrmatrix_camera(o->r,ox+cx,oy+cy,oz+cz,cx,cy,cz,0);
calc_nrotate(o->nnum1,o->n,o->n0,o->r);
calc_rotate(o->vnum,o->v,o->v0,o->r);
calc_project(o->vnum,o->pv,o->v);
if(!flag) break;
for(a=0;a<o->vnum;a++) if(o->pv[a].vf) break;
if(a==o->vnum) break;
d=d*4/3;
}
if(osd<d) osd=d;
}
void sortdir(int d,long *osx,long *osy,long *osz)
{
switch(d)
{
/*
case 0 : *osx=-256; *osy=0; *osz=0; break;
case 1 : *osy=-256; *osz=0; *osx=0; break;
case 2 : *osz=-256; *osx=30; *osy=30; break;
case 3 : *osx=256; *osy=0; *osz=0; break;
case 4 : *osy=256; *osz=0; *osx=0; break;
case 5 : *osz=256; *osx=30; *osy=30; break;
*/
case 0 : *osx=-256; *osy=-256; *osz=-256; break;
case 1 : *osx=256; *osy=-256; *osz=-256; break;
case 2 : *osx=256; *osy=256; *osz=-256; break;
case 3 : *osx=-256; *osy=256; *osz=-256; break;
case 4 : *osx=-256; *osy=-256; *osz=256; break;
case 5 : *osx=256; *osy=-256; *osz=256; break;
case 6 : *osx=256; *osy=256; *osz=256; break;
case 7 : *osx=-256; *osy=256; *osz=256; break;
case 8 : *osx=-366; *osy=0; *osz=0; break;
/*
case 0 : *osx=-256; *osy=-256; *osz=-256; break;
case 1 : *osx=256; *osy=-256; *osz=-256; break;
case 2 : *osx=256; *osy=256; *osz=-256; break;
case 3 : *osx=-256; *osy=256; *osz=-256; break;
case 4 : *osx=-256; *osy=-256; *osz=256; break;
case 5 : *osx=0; *osy=366; *osz=0; break;
case 6 : *osx=256; *osy=-256; *osz=256; break;
case 7 : *osx=0; *osy=-366; *osz=0; break;
case 8 : *osx=256; *osy=256; *osz=256; break;
case 9 : *osx=-366; *osy=0; *osz=0; break;
case 10 : *osx=-256; *osy=256; *osz=256; break;
case 11 : *osx=366; *osy=0; *osz=0; break;
case 12 : *osx=30; *osy=30; *osz=-366; break;
case 13 : *osx=30; *osy=30; *osz=366; break;
*/
default : *osx=*osy=*osz=0; break;
}
}
struct s_osp
{
long dis; // distance maximum
long dismin; // distance minimum
long a,b,c,d; // plane equation
int o; // offset
int swapped;
} osp[MAXFC];
struct s_osp osptmp;
int qcmp(struct s_osp *a,struct s_osp *b)
{
if(a->dis>b->dis) return(-1);
if(a->dis<b->dis) return(1);
return(0);
}
// -1=j farther than i (swap)
// 0==indetermined
// 1==i farther than j (ok)
// 2==i farther than j.. (next)}
int planecompare(struct s_osp *i,struct s_osp *j,object *o,int flag)
{
int *ip,*pp;
long d1=0,d2=0,dc=0,d,d1a,d2a,dd;
int d1c=0,d2c=0;
int a,c,r;
if(i->dismin>j->dis) return(2);
pp=(int *)(j->o+(char *)(o->pd));
c=*pp++; // sides
c&=0xff;
pp++; // skip color
pp++; // skip normal
//fprintf(fdeb,"compare i=f%i(%i) with j=f%i(%i)\n",i-osp,i->o,j-osp,j->o);
while(c--)
{
a=*pp++;
d=(long)(((double)o->v[a].x*(double)i->a+(double)o->v[a].y*(double)i->b+(double)o->v[a].z*(double)i->c+(double)i->d)/1000.0);
if(debcount<1000)
{
//fprintf(fdeb,"v%i:%li ",a,d);
debcount++;
}
if(d<0) { d1+=d; d1c++; }
else { d2+=d; d2c++; }
}
if(d1c) d1/=d1c;
if(d2c) d2/=d2c;
// camera at zero, so dc=i->d;
dc=i->d;
if(d1<0) d1a=-d1; else d1a=d1;
if(d2<0) d2a=-d2; else d2a=d2;
d=d1a-d2a; if(d<0) d=-d;
dd=(d1a+d2a)/8;
if(d<dd) return(0); // comaparator face cuts this one in middle
//fprintf(fdeb,"\ncamera at %li, d1=%li, d1c=%i, d2=%li, d2c=%i, d1a=%li d2a=%li\n",dc,d1,d1c,d2,d2c,d1a,d2a);
if(d1a>d2a)
{
if(d1>0 && dc>0) r=1;
else if(d1<0 && dc<0) r=1;
else r=-1;
}
else
{
if(d2>0 && dc>0) r=1;
else if(d2<0 && dc<0) r=1;
else r=-1;
}
if(flag)
{
a=planecompare(j,i,o,0);
if(a==r) r=0;
//fprintf(fdeb,"returns %i\n\n",r);
}
return(r);
}
void objectsort(object *o)
{
static int skipw=0;
long z,z1,z2;
long px,py,pz,pa,pb,pc,pd,td;
int fbak,i,j,k;
int d,a,c,b,n,onum;
int changed;
int *ip,*pp;
osd=256;
for(d=0;d<SORTDIRS;d++)
{
sortdir(d,&osx,&osy,&osz);
osetup(o,1);
}
for(d=0;d<SORTDIRS;d++)
{
aosx=osx;
aosy=osy;
aosz=osz;
sortdir(d,&osx,&osy,&osz);
bosx=osx;
bosy=osy;
bosz=osz;
if(d && !skipw)
{
for(a=0;a<=64;a+=2)
{
b=64-a;
osx=(aosx*(long)b+bosx*(long)a)>>6;
osy=(aosy*(long)b+bosy*(long)a)>>6;
osz=(aosz*(long)b+bosz*(long)a)>>6;
osetup(o,0);
fbak=o->flags;
o->flags&=~(F_GOURAUD);
vNext();
vis_drawobject(o);
o->flags=fbak;
}
}
osx=bosx;
osy=bosy;
osz=bosz;
osetup(o,0);
ip=o->pl[0]+2;
onum=0;
while(*ip)
{
a=osp[onum].o=*ip++;
pp=(int *)(osp[onum].o+(char *)o->pd);
c=*pp++; // sides
c&=0xff;
if(a!=68 && a!=56)
{
// *pp=-1;
}
pp++; // skip color
n=*pp++; // skip normal
z=0; z2=0x7fffffff;
//fprintf(fdeb,"face %i: ",osp[onum].o);
while(c--)
{
a=*pp++;
//fprintf(fdeb,"%i ",a);
if(c==1)
{
px=o->v[a].x;
py=o->v[a].y;
pz=o->v[a].z;
}
z1=o->v[a].z;
if(z1>z) z=z1;
if(z1<z2) z2=z1;
}
//fprintf(fdeb,"\n");
osp[onum].a=pa=o->n[n].x/4;
osp[onum].b=pb=o->n[n].y/4;
osp[onum].c=pc=o->n[n].z/4;
osp[onum].d=pd=-px*pa-py*pb-pz*pc;
osp[onum].dis=z;
osp[onum].dismin=z2;
pp=(int *)(osp[onum].o+(char *)o->pd);
c=*pp++; // sides
c&=0xff;
pp++; // skip color
pp++; // skip normal
while(c--)
{
a=*pp++;
td=o->v[a].x*pa+o->v[a].y*pb+o->v[a].z*pc+pd;
}
onum++;
}
qsort(osp,onum,sizeof(osp[0]),qcmp);
//resort by planes
#if 0
for(i=0;i<onum;i++)
{
for(k=i+1;k<onum;k++)
{
for(j=k;j<onum;j++)
{
for(a=0;a<8;a++)
{
//fprintf(fdeb,"%i%c ",osp[a].o,osp[a].swapped?'*':'.');
}
//fprintf(fdeb,"\n");
a=planecompare(osp+i,osp+j,o,1);
// -1=j farther than i (swap)
// 0==indetermined
// 1==i farther than j (ok)
// 2==i farther than j.. (next)
/*
if(a==2)
{
j=onum;
break;
}
else */
if(a==-1)
{
break;
}
}
if(j==onum) break; //all faces after i were before it
memcpy(&osptmp,osp+k,sizeof(osptmp));
memcpy(osp+k,osp+i,sizeof(osptmp));
memcpy(osp+i,&osptmp,sizeof(osptmp));
}
}
#endif
o->plnum=d+2;
ip=o->pl[d+1];
*ip++=onum+3;
ip++; // skip center vertex id
for(a=0;a<onum;a++)
{
*ip++=osp[a].o;
}
*ip++=0;
fbak=o->flags;
o->flags&=~(F_GOURAUD);
vNext();
vis_drawobject(o);
if(!skipw)
{
vNext();
vis_drawobject(o);
vNext();
vis_drawobject(o);
vNext();
vis_drawobject(o);
a=getch();
if(a==27) break;
if(a==13) skipw=1;
}
o->flags=fbak;
}
}

BIN
VISU/C/PIC003.UH Normal file

Binary file not shown.

2
VISU/C/PLAY.BAT Normal file
View file

@ -0,0 +1,2 @@
fake " "
plays3m -xplaycity musa.s3m

1
VISU/C/PLAYCITY.BAT Normal file
View file

@ -0,0 +1 @@
cplay city

BIN
VISU/C/PLAYS3M.EXE Normal file

Binary file not shown.

396
VISU/C/READASC.C Normal file
View file

@ -0,0 +1,396 @@
// temporary structs for loading
struct s_tmpvx
{
long x;
long y;
long z;
int power; // for center
};
struct s_tmpnr
{
long x;
long y;
long z;
};
struct s_tmpgnr // gouraud normal
{
long x;
long y;
long z;
int power;
};
struct s_tmpfc
{
int v[3]; // vertex number
char vv[3]; // vertex (edge) visible
char used;
char material;
};
// buffers for reading objects from asc
char oname[64];
int vxleft,fcleft;
int vxmap[MAXVX];
struct s_tmpvx vxdata[MAXVX];
struct s_tmpnr nrdata[MAXNR];
struct s_tmpgnr gvxdata[MAXVX];
struct s_tmpfc fcdata[MAXFC];
struct s_tmpvx *vx=vxdata;
struct s_tmpnr *nr=nrdata;
struct s_tmpfc *fc=fcdata;
struct s_tmpgnr *gvx=gvxdata;
int vxnum,fcnum,nrnum,nrnum1;
int vxcount,fccount; // original in 3DS
int facedata[16384],facedatalen; // len=words
int faceoff[MAXFC],facenum;
#include "opt.c"
int addvx(long x,long y,long z)
{
int i;
for(i=0;i<vxnum;i++)
{
if(vx[i].x==x && vx[i].y==y && vx[i].z==z)
{
vx[i].power++;
return(i);
}
}
vx[vxnum].power=1;
gvx[vxnum].power=0;
vx[vxnum].x=x;
vx[vxnum].y=y;
vx[vxnum].z=z;
return(vxnum++);
}
int addnr(long x,long y,long z)
{
int i;
for(i=0;i<nrnum;i++)
{
if(nr[i].x==x && nr[i].y==y && nr[i].z==z)
{
return(i);
}
}
nr[nrnum].x=x;
nr[nrnum].y=y;
nr[nrnum].z=z;
return(nrnum++);
}
void resetscene(void)
{
struct s_cobject *co1;
int i,a;
co1=co;
for(i=0;i<conum;i++)
{
co1->last_on=0;
co1->last_x=0;
co1->last_y=0;
co1->last_z=0;
for(a=0;a<9;a++) co1->last_m[a]=0;
co1++;
}
}
int duplicate(struct s_cobject *co0)
{
int a;
struct s_cobject *co1;
co1=co+conum;
co1->index=co0->index;
strcpy(co1->name,co0->name);
co1->last_on=0;
co1->last_x=0;
co1->last_y=0;
co1->last_z=0;
for(a=0;a<9;a++) co1->last_m[a]=0;
co1->lastused=-1;
co1->duplicate=1;
co1->original=co0-co;
co1->size=co0->size;
strcpy(co1->fname,co0->fname);
co1->o=getmem(sizeof(object));
memcpy(co1->o,co0->o,sizeof(object));
// new object needs new matrices
co1->o->r=getmem(sizeof(rmatrix));
co1->o->r0=getmem(sizeof(rmatrix));
memset(co1->o->r,0,sizeof(rmatrix));
memset(co1->o->r0,0,sizeof(rmatrix));
return(conum++);
}
struct s_cobject *create(void)
{
int a;
object *o;
co[conum].o=o=getmem(sizeof(object));
memcpy(co[conum].name,oname,17);
co[conum].name[17]=0;
co[conum].index=conum;
co[conum].last_on=0;
co[conum].last_x=0;
co[conum].last_y=0;
co[conum].last_z=0;
for(a=0;a<9;a++) co[conum].last_m[a]=0;
o->flags=F_DEFAULT;
o->r=getmem(sizeof(rmatrix));
o->r0=getmem(sizeof(rmatrix));
calc_setrmatrix_ident(o->r0);
o->r0->x=o->r0->y=o->r0->z=0;
o->pd=getmem(facedatalen*2);
o->pdlen=facedatalen*2;
o->plnum=1;
for(a=0;a<SORTDIRS+1;a++)
{
o->pl[a]=getmem((3+facenum)*2);
}
o->nnum=nrnum;
o->nnum1=nrnum1;
o->vnum=vxnum;
o->v0=getmem(vxnum*sizeof(vlist));
o->n0=getmem(nrnum*sizeof(nlist));
o->v=getmem(vxnum*sizeof(vlist));
o->n=getmem(nrnum*sizeof(nlist));
o->pv=getmem(vxnum*sizeof(pvlist));
o->vf=0;
// copy vertices etc to just allocated object
for(a=0;a<vxnum;a++)
{
o->v0[a].x=vx[a].x;
o->v0[a].y=vx[a].y;
o->v0[a].z=vx[a].z;
o->v0[a].normal=vx[a].power; // power=normal
o->v0[a].RESERVED=0xfc;
}
for(a=0;a<nrnum;a++)
{
o->n0[a].x=(int)nr[a].x;
o->n0[a].y=(int)nr[a].y;
o->n0[a].z=(int)nr[a].z;
o->n0[a].RESERVED=0xfc;
}
memcpy(o->pd,facedata,facedatalen*2);
memcpy(o->pl[0]+2,faceoff,2*facenum);
o->pl[0][0]=facenum+3; // words in list
o->pl[0][1]=0; // closest=center in list 0 (set later)
o->pl[0][facenum+2]=0; // end
return(co+(conum++));
}
int calccenter(void)
{
long x,y,z,p;
int a;
for(x=y=z=0,a=1;a<vxnum;a++)
{
p=vx[a].power;
x+=vx[a].x*p; y+=vx[a].y*p; z+=vx[a].z*p;
}
if(vxnum>1)
{
x/=vxnum-1; y/=vxnum-1; z/=vxnum-1;
}
print("Centerxyz: %li,%li,%li\n",x,y,z);
return(addvx(x,y,z));
}
void unify(long *x,long *y,long *z)
{
double d;
d=sqrt((double)*x*(double)*x+(double)*y*(double)*y+(double)*z*(double)*z);
if(!d) return;
d=1/d;
*x=(long)(NORMALSIZE*(double)*x*d);
*y=(long)(NORMALSIZE*(double)*y*d);
*z=(long)(NORMALSIZE*(double)*z*d);
}
void objectdone(void)
{
long x,y,z;
long cx,cy,cz;
int svx[SORTDIRS+1];
int a,center;
struct s_cobject *co;
if(vxleft || fcleft) error("Not all vertices (%i missing) or faces (%i missing) found!",vxleft,fcleft);
optimize(); // combines triangles to larger faces and creates polydata
center=calccenter(); // calculate center
cx=vx[center].x;
cy=vx[center].y;
cz=vx[center].z;
for(a=0;a<SORTDIRS;a++) // calculate box for Z sort
{
sortdir(a,&x,&y,&z);
svx[a]=addvx(x+cx,y+cy,z+cz);
}
nrnum1=nrnum;
// add gouraud normals
for(a=0;a<vxnum;a++) if(gvx[a].power)
{
x=gvx[a].x/gvx[a].power;
y=gvx[a].y/gvx[a].power;
z=gvx[a].z/gvx[a].power;
unify(&x,&y,&z);
vx[a].power=addnr(x,y,z);
}
else vx[a].power=-1;
// all vertices & normals should be in tmp structs now!
co=create(); // allocate memory for object and copy data to it
co->duplicate=0;
co->original=conum-1;
co->lastused=-1;
co->o->pl[0][1]=center; // sortlist0's closest vertex should be center
for(a=0;a<SORTDIRS;a++) co->o->pl[a+1][1]=svx[a];
print(" Faces: %i => %i\n",fccount,facenum);
print(" Normals: %i => %i (%i)\n",fccount,nrnum1,nrnum);
print("Vertices: %i => %i\n",vxcount,vxnum);
co->f1=fccount; co->f2=facenum;
co->n1=fccount; co->n2=nrnum1; co->ng=nrnum;
co->v1=vxcount; co->v2=vxnum;
*oname=0;
}
void readasc(void)
{
char tmp[256];
int a,b,i1,i2,i3;
int i1v,i2v,i3v;
long x,y,z;
float f,fx,fy,fz;
char *p,*p0,*t;
print("\n");
print(">>>>>>>>>>>>>>>> ASC file <<<<<<<<<<<<<<<<\n");
print("\n");
while(!feof(in))
{
p0=p=getline();
if(emptyline(p)) continue;
// process line
t=getfirsttoken(&p);
IFT("Named")
{
if(*oname)
{
objectdone();
print("}\n");
print("\n");
}
gettoken(&p); // 'object:'
t=gettoken(&p);
strcpy(tmp,t);
do
{
p0=p=getline();
}
while(emptyline(p));
IFS(p,"Tri-mesh")
{
print("TRIMESH %s\n",tmp);
strcpy(oname,tmp);
p=p0;
getseek(&p,"Vertices:");
i1=getint(&p);
p=p0;
getseek(&p,"Faces:");
i2=getint(&p);
print("vertices:%i faces:%i\n",i1,i2);
print("{\n");
//
vxnum=0;
nrnum=0;
fcnum=0;
vxcount=vxleft=i1;
fccount=fcleft=i2;
//
}
else
{
print("SKIPPING OBJECT %s (%s)\n",tmp,p);
}
continue;
}
if(!*oname) continue; // no object being processed!
IFT("Vertex")
{
t=gettoken(&p);
IFT("list:") continue;
i1=atoi(t);
//if(i1!=vxnum) error("Vertex indices out of order");
getxxyyzz(&p,&x,&y,&z);
vxmap[i1]=addvx(x,y,z);
print("vertex %i (%li,%li,%li)\n",i1,x,y,z);
vxleft--;
}
else IFT("Smoothing:")
{
// skip smoothing groups for now
}
else IFT("Material:")
{
t=p0+10;
for(a=0;a<strlen(t);a++) if(t[a]=='\"')
{
t[a]=0;
break;
}
b=strlen(t);
for(a=0;a<matnum;a++)
{
if(!memcmp(t,mat[a].name,b))
{
fc[fcnum-1].material=a;
break;
}
}
}
else IFT("Face")
{
t=gettoken(&p);
IFT("list:") continue;
a=atoi(t);
if(a!=fcnum) error("Face indices out of order");
t=gettoken(&p);
i1=atoi(t+2);
t=gettoken(&p);
i2=atoi(t+2);
t=gettoken(&p);
i3=atoi(t+2);
t=gettoken(&p);
i1v=t[3]-'0';
t=gettoken(&p);
i2v=t[3]-'0';
t=gettoken(&p);
i3v=t[3]-'0';
fc[fcnum].v[0]=vxmap[i1];
fc[fcnum].v[1]=vxmap[i2];
fc[fcnum].v[2]=vxmap[i3];
fc[fcnum].vv[0]=(char)i1v;
fc[fcnum].vv[1]=(char)i2v;
fc[fcnum].vv[2]=(char)i3v;
fc[fcnum].used=0;
fc[fcnum].material=0;
print("face %i (%c%i,%c%i,%c%i)\n",a,
i1v?'+':'-',i1,
i2v?'+':'-',i2,
i3v?'+':'-',i3);
fcnum++;
fcleft--;
}
else print("Unknown: %s\n",t);
if(debug) print(" (%s)\n",p0);
}
if(*oname)
{
objectdone();
print("}\n");
print("\n");
}
}

43
VISU/C/READINF.C Normal file
View file

@ -0,0 +1,43 @@
void readinf(void)
{
char tmp[256];
int a,b,c,d;
object *o;
char *p,*p0,*t;
matnum=0;
while(!feof(in))
{
p0=p=getline();
if(*p==';') continue;
t=gettoken(&p);
IFT("scene")
{
t=gettoken(&p);
a=atoi(t);
in2=in;
resetscene();
doscene(a);
in=in2;
}
else IFT("hide")
{
t=gettoken(&p);
o=findobject(t,-9);
o->flags&=~(F_VISIBLE);
}
else IFT("show")
{
t=gettoken(&p);
o=findobject(t,-9);
o->flags|=(F_VISIBLE);
}
else IFT("fov")
{
t=gettoken(&p);
a=atoi(t);
usefov=a;
}
}
printf("\n\n");
}

61
VISU/C/READMAT.C Normal file
View file

@ -0,0 +1,61 @@
void readmat(void)
{
char tmp[256];
int a,b,c,d;
char *p,*p0,*t;
matnum=0;
printf("Materials:\n");
while(!feof(in))
{
p0=p=getline();
if(*p==';') continue;
if(*p)
{
t=gettoken(&p);
for(a=0;a<strlen(t);a++) if(t[a]=='#') t[a]=' ';
strcpy(mat[matnum].name,t);
mat[matnum].color=0;
mat[matnum].flags=0;
mat[matnum].colorlen=1;
while(*p)
{
t=gettoken(&p);
a=toupper(*t);
switch(a)
{
case 'X' :
mat[matnum].flags|=F_2SIDE;
break;
case 'L' :
mat[matnum].colorlen=atoi(t+1);
break;
case 'G' :
mat[matnum].flags|=F_GOURAUD;
break;
default :
if(a>='0' && a<='9')
{
mat[matnum].color=atoi(t);
}
break;
}
}
switch(mat[matnum].colorlen)
{
case 32 : mat[matnum].flags|=F_SHADE32; break;
case 16 : mat[matnum].flags|=F_SHADE16; break;
case 8 : mat[matnum].flags|=F_SHADE8; break;
case 1 : break;
default : printf("ILLEGAL COLOR LENGTH>> "); break;
}
sscanf(p,"%s %i %i",mat[matnum].name,&mat[matnum].color,&mat[matnum].colorlen);
printf("%s colors:%i..%i ",mat[matnum].name,mat[matnum].color,
mat[matnum].color+mat[matnum].colorlen-1);
if(mat[matnum].flags&F_GOURAUD) printf("Gouraud ");
if(mat[matnum].flags&F_TEXTURE) printf("Texture ");
printf("\n");
matnum++;
}
}
}

255
VISU/C/READVUE.C Normal file
View file

@ -0,0 +1,255 @@
int findobject_co;
object *findobject(char *t,int frame)
{
int i,l=strlen(t);
int found1=-1;
for(i=1;i<conum;i++)
{
if(!memcmp(co[i].name,t,l))
{
if(found1==-1) found1=i;
if(co[i].lastused!=frame)
{
findobject_co=i;
co[i].lastused=frame;
return(co[i].o);
}
}
}
if(found1!=-1)
{
print("^ Object %s duplicated.\n",t);
i=duplicate(co+found1);
co[i].lastused=frame;
findobject_co=i;
return(co[i].o);
}
print("ERROR: object %s not found!\n",t);
return(co[0].o);
}
int lsize(long l)
{
if(!l) return(0);
if(l>=-127 && l<=127) return(1);
if(l>=-32767 && l<=32767) return(2);
return(3);
}
void putl(long l,FILE *f)
{
putw(l&0xffff,f);
putw(l>>16,f);
}
void lwrite(int f,long l)
{
switch(f&3)
{
case 0 : break;
case 1 : putc(l,outb); break;
case 2 : putw(l,outb); break;
case 3 : putl(l,outb); break;
}
}
void readvue(void)
{
static int lastobject_co=0;
int a,ix,iy,visfield;
int frame;
long x,y,z,x2,y2,z2,ll;
float f,fx,fy,fz;
rmatrix tmpm;
rmatrix tmpm2;
char *p,*p0,*t;
object *o;
print("\n");
print(">>>>>>>>>>>>>>>> VUE file <<<<<<<<<<<<<<<<\n");
print("\n");
while(!feof(in))
{
p0=p=getline();
if(emptyline(p)) continue;
// process line
t=gettoken(&p);
IFT("frame")
{
t=gettoken(&p);
frame=a=atoi(t);
if(!drawpass)
{ // init stuff for script
lastobject_co=0;
}
print("FRAME %i\n",a);
if(kbhit()) break;
}
else IFT("transform")
{
t=gettoken(&p);
print("TRANSFORM %s",t);
o=findobject(t,frame);
o->r0->m[0]=(long)(UNIT*getfloat(&p));
o->r0->m[3]=(long)(UNIT*getfloat(&p));
o->r0->m[6]=(long)(UNIT*getfloat(&p));
o->r0->m[1]=(long)(UNIT*getfloat(&p));
o->r0->m[4]=(long)(UNIT*getfloat(&p));
o->r0->m[7]=(long)(UNIT*getfloat(&p));
o->r0->m[2]=(long)(UNIT*getfloat(&p));
o->r0->m[5]=(long)(UNIT*getfloat(&p));
o->r0->m[8]=(long)(UNIT*getfloat(&p));
getxyz(&p,&x,&y,&z);
o->r0->x=x;
o->r0->y=y;
o->r0->z=z;
print(" (xyz: %li %li %li)\n",x,y,z);
o->flags&=~(F_GOURAUD);
}
else IFT("camera")
{
getxyz(&p,&x2,&y2,&z2);
print("CAMERA (%li,%li,%li)->",x2,y2,z2);
getxyz(&p,&x,&y,&z);
print("(%li,%li,%li) ",x,y,z);
f=getfloat(&p); // roll
print("Roll:%f ",f);
a=(angle)f*65536L/360L;
calc_setrmatrix_camera(&camera,x2,y2,z2,x,y,z,a);
f=getfloat(&p); // field of vision
f=(float)usefov;
print("FOV:%f \n",f);
f=f*65536.0/360.0;
visfield=(angle)f;
visfield&=0xff00;
vid_cameraangle(visfield);
vDraw();
if(!drawpass)
{
int coi,coilast=0;
unsigned int u;
struct s_cobject *cop;
object *o;
for(coi=1;coi<conum;coi++)
{
co[coi].on=0;
}
// scan fill_object for truely visible objects
for(u=0;u<64000;u++)
{
a=fill_object[u];
if(a) co[a].on=1;
}
// camera always on!
co[0].on=1;
co[0].last_on=1;
fprintf(fdeb,"%i\n",conum);
for(coi=0;coi<conum;coi++)
{
int flag,a,b,pflaglen;
long pflag,mbytes;
long wx,wy,wz;
long l;
flag=pflag=pflaglen=0;
cop=co+coi;
o=cop->o;
fprintf(fdeb,"%s:%i\n",cop->name,cop->on);
if(!cop->on)
{ // object hidden
if(cop->last_on)
{
flag=0x40;
cop->last_on=0;
}
}
else
{ // visible
if(!cop->last_on)
{
flag=0x80;
cop->last_on=1;
}
l=o->r0->z - cop->last_z;
a=lsize(l); wz=l;
pflag<<=2; pflag|=a;
l=o->r0->y - cop->last_y;
a=lsize(l); wy=l;
pflag<<=2; pflag|=a;
l=o->r0->x - cop->last_x;
a=lsize(l); wx=l;
pflag<<=2; pflag|=a;
mbytes=1;
print("[pfl:%06lX]",pflag);
for(a=0;a<9;a++)
{
b=o->r0->m[a] - cop->last_m[a];
if(b<-127 || b>127) mbytes=0;
if(b) pflag|=0x80L<<a;
}
print("[pfl:%06lX]",pflag);
if(!mbytes) pflag|=0x40;
if(!pflag) pflaglen=0;
else if(!(pflag&0xffffff00L)) pflaglen=1;
else if(!(pflag&0xffff0000L)) pflaglen=2;
else pflaglen=3;
flag|=0x10*pflaglen;
}
if(flag)
{
if( (coi&0xff0)!=(coilast&0xff0) )
{
putc(0xC0|(coi>>4),outb);
putc((coi&0x0f)|flag,outb);
}
else
{
putc((coi&0x0f)|flag,outb);
}
coilast=coi;
if(pflaglen)
{
l=pflag;
while(pflaglen--)
{
putc(l,outb);
l>>=8;
}
print("[pfl:%06lX wxyz:%li,%li,%li]\n",pflag,wx,wy,wz);
lwrite(pflag,wx);
lwrite(pflag>>2,wy);
lwrite(pflag>>4,wz);
for(a=0;a<9;a++) if(pflag&(0x80<<a))
{
b=o->r0->m[a] - cop->last_m[a];
if(mbytes) putc(b,outb);
else putw(b,outb);
}
}
for(a=0;a<9;a++) cop->last_m[a]=o->r0->m[a];
cop->last_x=o->r0->x;
cop->last_y=o->r0->y;
cop->last_z=o->r0->z;
}
}
putc(0xff,outb);
putc(visfield>>8,outb);
}
}
else print("Unknown: %s\n",t);
if(debug) print(" (%s)\n",p0);
}
putc(0xff,outb);
putc(0xff,outb);
}

92
VISU/C/REPORT Normal file
View file

@ -0,0 +1,92 @@
Norton Disk Doctor II
Norton Utilities, 5.0
Sunday, 25 July 1993 23.38
*************************
* Report for Drive C: *
*************************
DISK TOTALS
-----------------------------------------
62 181 376 bytes Total Disk Space
60 704 768 bytes in 3 119 User Files
555 008 bytes in 263 Directories
337 920 bytes in 19 Hidden Files
583 680 bytes Available on the Disk
LOGICAL DISK INFORMATION
-----------------------------------------
Media Descriptor: F8
Large Partition: Yes
FAT Type: 16-bit
Total Sectors: 121 720
Total Clusters: 30 362
Bytes Per Sector: 512
Sectors Per Cluster: 4
Bytes Per Cluster: 2 048
Number of FATs: 2
First Sector of FAT: 1
Number of Sectors Per FAT: 119
First Sector of Root Dir: 239
Number of Sectors in Root Dir: 32
Maximum Root Dir File Entries: 512
First Sector of Data Area: 271
PHYSICAL DISK INFORMATION
-----------------------------------------
Drive Number: 80
Heads: 7
Cylinders: 1 023
Sectors Per Track: 17
Starting Head: 1
Starting Cylinder: 0
Starting Sector: 1
Ending Head: 6
Ending Cylinder: 1 022
Ending Sector: 17
SYSTEM AREA STATUS
-----------------------------------------
No Errors in the System Area
FILE STRUCTURE STATUS
-----------------------------------------
******************** Entries with an Invalid Cluster *******************
\MINCODE\VISU\C\c.exe
Status: Truncated
****************************** Lost Chains *****************************
Lost cluster chain at cluster 30 174
Status: Deleted
Lost cluster chain at cluster 30 175
Status: Deleted
Lost cluster chain at cluster 30 363
Status: Deleted
SURFACE TEST STATUS
-----------------------------------------
Test Settings
-----------------------
Test: Disk Test
Test Type: Daily
Repair Setting: Prompt before Repairing
Passes Requested: 1
Passes Completed: 1
Elapsed Time: 1 minute; 58 seconds
No Errors encountered in Surface Test

90
VISU/C/SAVE.C Normal file
View file

@ -0,0 +1,90 @@
long blockstack[16];
int blockstackp=0;
void beginblock(char *label)
{
blockstack[blockstackp]=ftell(outb);
blockstackp++;
putc(label[0],outb);
putc(label[1],outb);
putc(label[2],outb);
putc(label[3],outb);
putc(0xff,outb);
putc(0xff,outb);
putc(0xff,outb);
putc(0xff,outb);
}
void endblock(void)
{
long op,l;
op=ftell(outb);
while(op&3)
{
op++;
putc(0,outb);
}
blockstackp--;
l=blockstack[blockstackp];
fseek(outb,l+4,SEEK_SET);
l=op-l-8;
putc((int)l&255,outb); l>>=8;
putc((int)l&255,outb); l>>=8;
putc((int)l&255,outb); l>>=8;
putc((int)l&255,outb);
fseek(outb,op,SEEK_SET);
}
void saveobject(struct s_cobject *co)
{
object *o;
char fname[32];
long l;
int a,b;
o=co->o;
sprintf(fname,"%s.%03i",scenename,co->index);
outb=fopen(fname,"wb");
strcpy(co->fname,fname);
beginblock("VERS");
putw(0x0100,outb);
endblock();
beginblock("NAME");
fprintf(outb,co->name);
putc(0,outb);
endblock();
beginblock("VERT");
putw(o->vnum,outb);
putw(0,outb);
fwrite(o->v0,sizeof(vlist),o->vnum,outb);
endblock();
beginblock("NORM");
putw(o->nnum,outb);
putw(o->nnum1,outb);
fwrite(o->n0,sizeof(nlist),o->nnum,outb);
endblock();
beginblock("POLY");
fwrite(o->pd,1,o->pdlen,outb);
endblock();
for(b=0;b<o->plnum;b++)
{
if(!b) beginblock("ORD0");
else beginblock("ORDE");
fwrite(o->pl[b],2,o->pl[b][0],outb);
endblock();
}
beginblock("END ");
endblock();
co->size=ftell(outb);
fclose(outb);
}

BIN
VISU/C/SCENE.3DS Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2A.001 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2A.002 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2A.003 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2A.00M Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2A.0AA Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2A.0AB Normal file

Binary file not shown.

3
VISU/C/SCENE/U2A.INF Normal file
View file

@ -0,0 +1,3 @@
fov 48
scene 1

BIN
VISU/C/SCENE/U2A.LBM Normal file

Binary file not shown.

15
VISU/C/SCENE/U2A.MAT Normal file
View file

@ -0,0 +1,15 @@
;format: MATERIAL-NAME <parameters>
;parameters:
;#(number) first color in fade
;L# length of color fade (#=32/16/8/1=no fading)
;G gouraud
;X Two sided material
DEFAULT 96 L32
LIGHT_BLUE 32 L32 G
BLACK 0 L16 G
ORANGE 64 L32
GREY 128 L32 G
MOTOR 64 L32 G
POHJA 4 L16
COLOR00 0 L16

BIN
VISU/C/SCENE/U2A.PAL Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2A.PRJ Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2AOLD.PRJ Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.001 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.002 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.003 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.004 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.005 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.006 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.007 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.008 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.009 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.00M Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.010 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.011 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.012 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.013 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.014 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.015 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.016 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.017 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.018 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.019 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.020 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.021 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.022 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.023 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.024 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.025 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.026 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.027 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.028 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.029 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.030 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.031 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.032 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.033 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.034 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.035 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.036 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.037 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.038 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.039 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.040 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.041 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.042 Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.0AA Normal file

Binary file not shown.

BIN
VISU/C/SCENE/U2E.0AB Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more