sda4: commit the Glaze developer hard-drive dump
Un-ignored: the dev drive is the ground truth the restoration and emulator work constantly reference (DPL3/LIBDPL + VRENDER i860 renderer source, BT/RP live+dev game trees, VGL_LABS pod boot, scene/audio content). Kept in-repo for the pod-owner community. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,548 @@
|
||||
/*
|
||||
FILE : testpp5.c
|
||||
PROJECT : pxpl5 renderer test
|
||||
Author : Phil Atkin
|
||||
|
||||
|
||||
(C) Division Ltd 1993.
|
||||
|
||||
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include "dpl.h"
|
||||
#include "matrix.h"
|
||||
#include "startup.h"
|
||||
#include "spline.h"
|
||||
#include "camera.h"
|
||||
|
||||
char *progname;
|
||||
static char *dpl_arg;
|
||||
|
||||
/* a few static dpltypes */
|
||||
static dpl_ZONE *zone=NULL;
|
||||
static dpl_LMODEL *lmodel=NULL;
|
||||
static dpl_LIGHT *direct=NULL;
|
||||
static dpl_LIGHT *ambient=NULL;
|
||||
static dpl_VIEW *eye, *rye;
|
||||
|
||||
/*{{{ void eyeStuff ( VIEW *view )*/
|
||||
void eyeStuff ( dpl_VIEW *view, int left )
|
||||
{
|
||||
float scale=1.0;
|
||||
|
||||
dpl_IdMatrix(view->matrix);
|
||||
|
||||
dpl_Translate (view->matrix, scale*1.275, 0, 0 );
|
||||
dpl_Rotate (view->matrix, 180, dpl_Y );
|
||||
dpl_Translate (view->matrix, 0, 0, -48 );
|
||||
|
||||
dpl_Flush (view);
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ char *makeVizName ( char *name )*/
|
||||
char vizStr [256];
|
||||
|
||||
char *makeVizName ( char *name )
|
||||
{
|
||||
char *root;
|
||||
|
||||
if ((root=getenv("VIZPATH")) == NULL)
|
||||
return(name);
|
||||
else {
|
||||
strcpy ( vizStr, root );
|
||||
strcat ( vizStr, name );
|
||||
return ( vizStr );
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ char *makeTexName ( char *name )*/
|
||||
char texStr [256];
|
||||
|
||||
char *makeTexName ( char *name )
|
||||
{
|
||||
char *root;
|
||||
|
||||
if ((root=getenv("TEXTURE")) == NULL)
|
||||
return(name);
|
||||
else {
|
||||
strcpy ( texStr, root );
|
||||
strcat ( texStr, name );
|
||||
|
||||
return ( texStr );
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ char *makedplName ( char *name )*/
|
||||
char *makedplName ( char *dplstr, char *name )
|
||||
{
|
||||
char *root;
|
||||
|
||||
if ((root=getenv("DVIEWBIN")) == NULL)
|
||||
return(name);
|
||||
else {
|
||||
strcpy ( dplstr, root );
|
||||
strcat ( dplstr, name );
|
||||
|
||||
return ( dplstr );
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ int env2hex ()*/
|
||||
int env2hex ( char *env_str, int default_v )
|
||||
{
|
||||
char *s;
|
||||
int v;
|
||||
|
||||
if (s = getenv(env_str)) {
|
||||
if (sscanf(s, "%x", &v) == 1) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
printf ("Defaulting on %s to 0x%x\n", env_str, default_v );
|
||||
|
||||
return default_v;
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ cheesy scene file support*/
|
||||
/*{{{ about the cheesy file format*/
|
||||
/*
|
||||
this is a DEAD quick and dirty 'get-your-geometry-executing' thing,
|
||||
which loads up a scene, and constantly executes it, allowing the
|
||||
user to wander round by keyboard flight.
|
||||
|
||||
it only took 30 minutes to write so is not supported.
|
||||
|
||||
cheesy scene format is
|
||||
|
||||
FOG z0 z1 r g b
|
||||
BACKGND r g b
|
||||
AMBIENT r g b
|
||||
LIGHT r g b dx dy dz
|
||||
STATIC name scale px py pz rx ry rz
|
||||
DYNAMIC name scale splinefile t0 dt
|
||||
*/
|
||||
|
||||
|
||||
/*}}} */
|
||||
|
||||
/*{{{ cheesy structure*/
|
||||
typedef struct s_cheesy {
|
||||
dpl_DCS *dcs;
|
||||
cntl_point *p;
|
||||
float scale;
|
||||
float t, dt;
|
||||
struct s_cheesy *next;
|
||||
} cheesy_scene;
|
||||
|
||||
cheesy_scene *camembert=NULL;
|
||||
/*}}} */
|
||||
|
||||
/*{{{ static cheesy_scene *load_cheesy_scene ( char *s )*/
|
||||
static cheesy_scene *load_cheesy_scene ( char *s )
|
||||
{
|
||||
cheesy_scene *cheesy_head=NULL;
|
||||
FILE *fp=fopen(s, "rt" );
|
||||
int read;
|
||||
dpl_DCS *zone_root;
|
||||
dpl_DCS *geom_root,
|
||||
*geom_tail=NULL;
|
||||
dpl_DCS *light_root,
|
||||
*light_tail=NULL;
|
||||
char *str=malloc(256);
|
||||
|
||||
if (fp==NULL) {
|
||||
printf ("couldnt open scene file\n" );
|
||||
exit(666);
|
||||
}
|
||||
|
||||
zone_root =dpl_NewDcs();
|
||||
light_root=dpl_NewDcs();
|
||||
geom_root =dpl_NewDcs();
|
||||
light_tail=light_root;
|
||||
geom_tail =geom_root;
|
||||
|
||||
lmodel=dpl_NewLmodel ();
|
||||
|
||||
dpl_SetZoneRootDcs ( zone, zone_root );
|
||||
dpl_SetZoneLmodel ( zone, lmodel );
|
||||
dpl_LinkDcs ( zone_root, light_root );
|
||||
dpl_NestDcs ( zone_root, geom_root );
|
||||
|
||||
read=fscanf( fp, "%s ", str );
|
||||
|
||||
while (read == 1) {
|
||||
float neer, phar, r, g, b;
|
||||
|
||||
if (strncmp ( str, "//", 2) == 0) {
|
||||
// read=fscanf( fp, "%s\n", str ); // throw away
|
||||
str=fgets( str, 256, fp ); // throw away
|
||||
}
|
||||
else if (strncmp ( str, "CLIP", 4) == 0) {
|
||||
read=fscanf( fp, "%f %f\n", &neer, &phar ); // throw away
|
||||
/* see main() below */
|
||||
}
|
||||
else if (strncmp ( str, "FOG", 3) == 0) {
|
||||
/*{{{ */
|
||||
|
||||
read=fscanf( fp, "%f %f %f %f %f\n", &neer, &phar, &r, &g, &b );
|
||||
|
||||
printf ("fog %f, %f %f, %f, %f\n", neer, phar, r, g, b );
|
||||
|
||||
dpl_SetViewFog ( eye, 1, r, g, b, neer, phar );
|
||||
if (rye)
|
||||
dpl_SetViewFog ( rye, 1, r, g, b, neer, phar );
|
||||
/*}}} */
|
||||
}
|
||||
else if (strncmp ( str, "BACKGND", 7) == 0) {
|
||||
/*{{{ */
|
||||
|
||||
read=fscanf( fp, "%f %f %f\n", &r, &g, &b );
|
||||
|
||||
printf ("set background %f, %f, %f\n", r, g, b );
|
||||
|
||||
dpl_SetViewBackGround ( eye, r, g, b );
|
||||
if (rye) dpl_SetViewBackGround ( rye, r, g, b );
|
||||
/*}}} */
|
||||
}
|
||||
else if (strncmp ( str, "STATIC", 5) == 0) {
|
||||
/*{{{ */
|
||||
dpl_DCS *d;
|
||||
dpl_INSTANCE *i;
|
||||
dpl_OBJECT *o;
|
||||
|
||||
read=fscanf( fp, "%s ", str );
|
||||
|
||||
printf ("create static object %s\n", str );
|
||||
|
||||
d=geom_tail;
|
||||
|
||||
o=dpl_NewObject();
|
||||
|
||||
if (o) {
|
||||
float scale, tx, ty, tz, rx, ry, rz;
|
||||
|
||||
dpl_LoadObject ( o, str );
|
||||
|
||||
printf ("loaded object\n" );
|
||||
|
||||
read=fscanf( fp, "%f %f %f %f %f %f %f\n",
|
||||
&scale, &tx, &ty, &tz, &rx, &ry, &rz );
|
||||
|
||||
printf ("translate %f %f %f\n", tx, ty, tz );
|
||||
|
||||
i=dpl_NewInstance();
|
||||
|
||||
dpl_SetInstanceObject ( i, o );
|
||||
|
||||
dpl_IdMatrix ( d->matrix );
|
||||
|
||||
dpl_Rotate ( d->matrix, rz, dpl_Z );
|
||||
dpl_Rotate ( d->matrix, rx, dpl_X );
|
||||
dpl_Rotate ( d->matrix, ry, dpl_Y );
|
||||
|
||||
dpl_Scale ( d->matrix, scale, scale, scale );
|
||||
dpl_Translate ( d->matrix, tx, ty, tz );
|
||||
d->identity=0;
|
||||
|
||||
dpl_SetDcsInstance ( d, i );
|
||||
|
||||
d=dpl_NewDcs ();
|
||||
dpl_LinkDcs ( geom_tail, d );
|
||||
geom_tail=d;
|
||||
|
||||
dpl_Hide(o);
|
||||
}
|
||||
else {
|
||||
printf ("Failed to load object from file %s\n", str );
|
||||
exit(666);
|
||||
}
|
||||
/*}}} */
|
||||
}
|
||||
else if (strncmp ( str, "DYNAMIC", 7) == 0) {
|
||||
/*{{{ */
|
||||
cheesy_scene *edam=malloc(sizeof(cheesy_scene));
|
||||
dpl_DCS *d;
|
||||
dpl_INSTANCE *i;
|
||||
dpl_OBJECT *o;
|
||||
|
||||
read=fscanf( fp, "%s ", str );
|
||||
|
||||
printf ("create dynamic object %s\n", str );
|
||||
|
||||
o=dpl_NewObject();
|
||||
|
||||
if (o) {
|
||||
float scale, t0, dt;
|
||||
|
||||
dpl_LoadObject ( o, str );
|
||||
|
||||
read=fscanf( fp, "%f %s %f %f\n",
|
||||
&scale, str, &t0, &dt );
|
||||
|
||||
printf ("spline file %s\n", str );
|
||||
|
||||
i=dpl_NewInstance();
|
||||
dpl_SetInstanceObject ( i, o );
|
||||
|
||||
d=geom_tail;
|
||||
|
||||
edam->p=init_splines ( str );
|
||||
|
||||
edam->scale = scale;
|
||||
edam->t =t0;
|
||||
edam->dt=dt;
|
||||
|
||||
edam->dcs=geom_tail;
|
||||
edam->next=cheesy_head;
|
||||
cheesy_head=edam;
|
||||
|
||||
dpl_SetDcsInstance ( d, i );
|
||||
d=dpl_NewDcs ();
|
||||
dpl_LinkDcs ( geom_tail, d );
|
||||
geom_tail=d;
|
||||
|
||||
dpl_Hide(o);
|
||||
|
||||
}
|
||||
else {
|
||||
printf ("Failed to load object from file %s\n", str );
|
||||
exit(666);
|
||||
}
|
||||
/*}}} */
|
||||
}
|
||||
else if (strncmp ( str, "AMBIENT", 6) == 0) {
|
||||
/*{{{ */
|
||||
dpl_LIGHT *light;
|
||||
float r, g, b;
|
||||
|
||||
read=fscanf( fp, "%f %f %f\n", &r, &g, &b );
|
||||
|
||||
light=dpl_NewLight();
|
||||
dpl_SetLightType ( light, dpl_light_type_ambient );
|
||||
dpl_SetLightColor ( light, r, g, b );
|
||||
dpl_AddLightToLmodel ( lmodel, light );
|
||||
|
||||
/*}}} */
|
||||
}
|
||||
else if (strncmp ( str, "LIGHT", 5) == 0) {
|
||||
/*{{{ */
|
||||
dpl_DCS *d;
|
||||
dpl_LIGHT *light;
|
||||
float r, g, b, x, y, z;
|
||||
|
||||
read=fscanf( fp, "%f %f %f %f %f %f\n", &r, &g, &b, &x, &y, &z );
|
||||
|
||||
d=light_tail;
|
||||
light=dpl_NewLight();
|
||||
dpl_SetLightType ( light, dpl_light_type_directional );
|
||||
dpl_SetLightColor ( light, r, g, b );
|
||||
dpl_AddLightToLmodel ( lmodel, light );
|
||||
|
||||
d=light_tail;
|
||||
dpl_SetDcsLight ( d, light );
|
||||
dpl_IdMatrix ( d->matrix );
|
||||
dpl_Rotate ( d->matrix, z, dpl_Z );
|
||||
dpl_Rotate ( d->matrix, x, dpl_X );
|
||||
dpl_Rotate ( d->matrix, y, dpl_Y );
|
||||
d->identity=0;
|
||||
dpl_Flush(d);
|
||||
|
||||
d=dpl_NewDcs ();
|
||||
dpl_LinkDcs ( light_tail, d );
|
||||
light_tail=d;
|
||||
|
||||
/*}}} */
|
||||
}
|
||||
else {
|
||||
printf ("Huh, dont understand %s\n", str );
|
||||
exit(666);
|
||||
}
|
||||
read=fscanf( fp, "%s ", str );
|
||||
}
|
||||
fclose(fp);
|
||||
printf ("hey, read the scene\n" );
|
||||
fflush(stdout);
|
||||
free(str);
|
||||
return cheesy_head;
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ static execute ( cheesy_scene *s )*/
|
||||
static execute ( cheesy_scene *s )
|
||||
{
|
||||
while (s) {
|
||||
cntl_point *p=s->p;
|
||||
|
||||
if (p) {
|
||||
dpl_DCS *d=s->dcs;
|
||||
float t, px, py, pz, rx, ry, rz;
|
||||
|
||||
t=s->t;
|
||||
|
||||
px=eval(p->x_pos_cubic, t );
|
||||
py=eval(p->y_pos_cubic, t );
|
||||
pz=eval(p->z_pos_cubic, t );
|
||||
|
||||
rx=eval(p->x_rot_cubic, t );
|
||||
ry=eval(p->y_rot_cubic, t );
|
||||
rz=eval(p->z_rot_cubic, t );
|
||||
|
||||
p = walk_spline ( p, &s->t, s->dt );
|
||||
s->p = p;
|
||||
|
||||
dpl_IdMatrix ( d->matrix );
|
||||
|
||||
dpl_Rotate ( d->matrix, rz, dpl_Z );
|
||||
dpl_Rotate ( d->matrix, rx, dpl_X );
|
||||
dpl_Rotate ( d->matrix, ry, dpl_Y );
|
||||
|
||||
dpl_Scale ( d->matrix, s->scale, s->scale, s->scale );
|
||||
dpl_Translate ( d->matrix, px, py, pz );
|
||||
|
||||
dpl_Flush(d);
|
||||
}
|
||||
|
||||
s=s->next;
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*}}} */
|
||||
|
||||
/*{{{ int nain ( int argc, char *argv[])*/
|
||||
int nain ( int argc, char *argv[])
|
||||
{
|
||||
dpl_node *sky;
|
||||
|
||||
zone=initialize_all ( dpl_arg,
|
||||
0,
|
||||
&eye, &rye, far_clip / 2.0f );
|
||||
|
||||
camembert=load_cheesy_scene ( argv[1] );
|
||||
/*{{{ make sky move*/
|
||||
if (sky=dpl_FindNamedTypedNode ( dpl_type_texture, "sky_tex")) {
|
||||
dpl_TEXTURE *tex=(dpl_TEXTURE *) sky;
|
||||
|
||||
tex->u0=0;
|
||||
tex->v0=0;
|
||||
tex->dv=0.13f;
|
||||
tex->du=0.0373f;
|
||||
dpl_Flush(tex);
|
||||
}
|
||||
/*
|
||||
*/
|
||||
/*}}} */
|
||||
/*{{{ make plant move*/
|
||||
if (sky=dpl_FindNamedTypedNode ( dpl_type_texture, "plant")) {
|
||||
dpl_TEXTURE *tex=(dpl_TEXTURE *) sky;
|
||||
|
||||
tex->u0=0;
|
||||
tex->v0=0;
|
||||
tex->dv=0.1;
|
||||
tex->du=0.913f;
|
||||
dpl_Flush(tex);
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ make fish move*/
|
||||
if (sky=dpl_FindNamedTypedNode ( dpl_type_texture, "plant4")) {
|
||||
dpl_TEXTURE *tex=(dpl_TEXTURE *) sky;
|
||||
|
||||
tex->u0=0;
|
||||
tex->v0=0;
|
||||
tex->dv=0.6;
|
||||
tex->du=0.0f;
|
||||
dpl_Flush(tex);
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
while (1) {
|
||||
if (argc > 2)
|
||||
camera_move ( eye, argv[2],
|
||||
NULL, 0.0f, 0.0132f );
|
||||
else
|
||||
camera_move_kbd ( eye, "dontneed.one",
|
||||
NULL, 1.0f, 0.0057f );
|
||||
dpl_DrawScene (1);
|
||||
|
||||
execute ( camembert );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ int main ( int argc, char *argv[] )*/
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
FILE *fp;
|
||||
int read;
|
||||
char *str;
|
||||
|
||||
progname=argv[0];
|
||||
|
||||
if (argc < 2) {
|
||||
printf ("usage %s: <scenefile> [camera_spline_file]\n", argv[0] );
|
||||
exit(666);
|
||||
}
|
||||
else {
|
||||
dpl_arg=getenv("dplarg");
|
||||
|
||||
/* dpl_SetWarningLevel ( 100 ); */
|
||||
|
||||
if (dpl_arg) {
|
||||
if (screen_resolution ( dpl_arg ) == 0) {
|
||||
printf ("failed to understand video format\n"); //(redundant message)
|
||||
exit(666);
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf ("failed to getenv dplarg\n");
|
||||
exit(666);
|
||||
}
|
||||
|
||||
near_clip=6.0;
|
||||
far_clip =12000.0f;
|
||||
|
||||
fp = fopen( argv[1], "rt" );
|
||||
if (fp==NULL) {
|
||||
printf ("couldnt open scene file\n" );
|
||||
exit(666);
|
||||
}
|
||||
str=malloc(256);
|
||||
read=fscanf( fp, "%s ", str );
|
||||
|
||||
while (read == 1) {
|
||||
float neer, phar;
|
||||
|
||||
if (strncmp ( str, "CLIP", 4) == 0) {
|
||||
/*{{{ */
|
||||
|
||||
read=fscanf( fp, "%f %f\n", &neer, &phar );
|
||||
|
||||
printf ("clip %f, %f\n", neer, phar );
|
||||
|
||||
near_clip = neer;
|
||||
far_clip = phar;
|
||||
break;
|
||||
|
||||
/*}}} */
|
||||
}
|
||||
|
||||
read=fscanf( fp, "%s ", str );
|
||||
}
|
||||
fclose(fp);
|
||||
fflush(stdout);
|
||||
free(str);
|
||||
|
||||
nain ( argc, argv );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*}}} */
|
||||
Reference in New Issue
Block a user