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,72 @@
|
||||
/*
|
||||
* PROJECT: DVS
|
||||
* SUBSYSTEM: VL
|
||||
* MODULE: basictypes.def
|
||||
*
|
||||
* File: $RCSfile: basictypes.def,v $
|
||||
* Revision: $Revision: 0.4 $
|
||||
* Date: $Date: 1993/09/24 11:29:01 $
|
||||
* Author: $Author: jon $
|
||||
* RCS Ident: $Id: basictypes.def,v 0.4 1993/09/24 11:29:01 jon Exp $
|
||||
*
|
||||
* FUNCTION:
|
||||
* This module is used to hold the parameterised definitions of the basic
|
||||
* types used throughout the system for all the machines supported. When
|
||||
* porting to a new architecture all type stuff should be modified in
|
||||
* here. There should be no machine dependant code anywhere else!
|
||||
*
|
||||
* each of the basic type int8 uint8 etc, etc is defined in terms of
|
||||
* standard ansi 'C' types here, and given a enum name for conveniance.
|
||||
*
|
||||
* The format is DEF_TYPE ( <enum name>, <type name>, <ansi 'C' equiv> )
|
||||
*
|
||||
* $Log: basictypes.def,v $
|
||||
Revision 0.4 1993/09/24 11:29:01 jon
|
||||
Release 2.0.4
|
||||
|
||||
Revision 1.1 93/07/12 08:12:21 john
|
||||
Initial revision
|
||||
|
||||
# Revision 1.6 1993/03/19 15:24:22 john
|
||||
# added definition for system V release 4.2
|
||||
#
|
||||
# Revision 1.5 1992/09/28 17:19:58 mark
|
||||
# Added definitions for IRIS Indigo
|
||||
#
|
||||
# Revision 1.4 1992/09/15 13:47:54 jeff
|
||||
# now use _SYSV386 not SYSV386
|
||||
#
|
||||
# Revision 1.3 1992/09/15 13:10:32 jeff
|
||||
# added defs for SYSV386 targets.
|
||||
#
|
||||
# Revision 1.2 1992/09/14 13:18:53 jeff
|
||||
# progress, progreess....
|
||||
#
|
||||
# Revision 1.1 1992/07/27 12:24:20 jeff
|
||||
# Initial revision
|
||||
#
|
||||
*
|
||||
* Copyright (c) 1992 Division Ltd.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This Document may not, in whole or in part, be copied,
|
||||
* photocopied, reproduced, translated, or reduced to any
|
||||
* electronic medium or machine readable form without prior
|
||||
* written consent from Division Ltd.
|
||||
*/
|
||||
|
||||
|
||||
DEF_TYPE( INT8, int8, signed char )
|
||||
DEF_TYPE( UINT8, uint8, unsigned char )
|
||||
DEF_TYPE( INT16, int16, signed short )
|
||||
DEF_TYPE( UINT16, uint16, unsigned short )
|
||||
DEF_TYPE( INT32, int32, signed int )
|
||||
DEF_TYPE( UINT32, uint32, unsigned int )
|
||||
DEF_TYPE( FLOAT32, float32, float)
|
||||
DEF_TYPE( FLOAT64, float64, double)
|
||||
|
||||
/*
|
||||
* Note we may need to put ifdefs back in here for some machines IE 64Bit processors ?
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <conio.h>
|
||||
#include "dpltypes.h"
|
||||
#include "dpl.h"
|
||||
#include "matrix.h"
|
||||
#include "spline.h"
|
||||
|
||||
/*{{{ static float atan2deg ( float dz, float dx )*/
|
||||
static float _atan2deg ( float dz, float dx )
|
||||
{
|
||||
float angle;
|
||||
if ((dx*dx) < 0.0001f) {
|
||||
angle=(dz>0) ? 90.0f : -90.0f;
|
||||
return angle;
|
||||
}
|
||||
else {
|
||||
return (180.0f / 3.1415926535f) * atan2 ( dz, dx );
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ static void xformpoint ( POINT q, POINT p, MATRIX m )*/
|
||||
static void _xformpoint ( dpl_POINT q, dpl_POINT p, dpl_MATRIX m )
|
||||
{
|
||||
dpl_POINT r;
|
||||
int i;
|
||||
|
||||
for (i=0; i<4; i++ ) {
|
||||
r[i]=(p[0]*m[0][i])+
|
||||
(p[1]*m[1][i])+
|
||||
(p[2]*m[2][i])+
|
||||
(p[3]*m[3][i]);
|
||||
}
|
||||
memcpy ( q, r, sizeof(dpl_POINT));
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ void look_at ( VIEW *v, float *from, float *at, float z_spin )*/
|
||||
void look_at ( dpl_VIEW *v, float *from, float *at, float z_spin )
|
||||
{
|
||||
/* construct a view from 2 points */
|
||||
float dx, dy, dz;
|
||||
float px, py, pz;
|
||||
float thetax, thetay, thetaz;
|
||||
float yaw, roll;
|
||||
dpl_MATRIX m;
|
||||
dpl_POINT p, q;
|
||||
|
||||
/* put 'at' at origin, construct a vector from 'from' */
|
||||
px=from[0]; py=from[1]; pz=from[2];
|
||||
|
||||
dx=at[0]-px;
|
||||
dy=at[1]-py;
|
||||
dz=at[2]-pz;
|
||||
|
||||
thetaz=0.0f;
|
||||
thetay=0.0f;
|
||||
thetax=0.0f;
|
||||
|
||||
p[0]=dx;
|
||||
p[1]=dy;
|
||||
p[2]=dz;
|
||||
p[3]=1;
|
||||
|
||||
yaw=-_atan2deg ( dz, dx );
|
||||
dpl_IdMatrix ( m );
|
||||
dpl_Rotate ( m, -yaw, dpl_Y );
|
||||
_xformpoint ( q, p, m );
|
||||
|
||||
roll=_atan2deg(q[1], q[0] );
|
||||
|
||||
/* project onto x-z plane, assuming camera is initially looking down -z */
|
||||
dpl_IdMatrix ( v->matrix );
|
||||
|
||||
/* apply angles to matrix */
|
||||
|
||||
dpl_Rotate ( v->matrix, z_spin, dpl_Z );
|
||||
dpl_Rotate ( v->matrix, roll, dpl_X );
|
||||
dpl_Rotate ( v->matrix, yaw-90.0f, dpl_Y );
|
||||
|
||||
dpl_Translate( v->matrix, px, py, pz );
|
||||
dpl_Flush ( v );
|
||||
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
static int camera_inited=0;
|
||||
static float camera_t=0.0f;
|
||||
static cntl_point *camerahead=NULL;
|
||||
|
||||
/*{{{ void camera_move ( VIEW *eye,*/
|
||||
void camera_move ( dpl_VIEW *eye,
|
||||
char *spline_file,
|
||||
dpl_POINT look_at_point,
|
||||
float scale_fac,
|
||||
float dt )
|
||||
{
|
||||
cntl_point *p=camerahead;
|
||||
float t=camera_t;
|
||||
float px, py, pz, rx, ry, rz;
|
||||
dpl_POINT evalp;
|
||||
|
||||
if (camera_inited == 0) {
|
||||
camera_inited=1;
|
||||
p=init_splines(spline_file);
|
||||
t=0;
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
camerahead=walk_spline ( p, &t, dt );
|
||||
camera_t=t;
|
||||
|
||||
/* we have wobbled the spline according to the file - now build the
|
||||
view matrix */
|
||||
/*
|
||||
eye->matrix[3][0]=px+look_at_point[0];
|
||||
eye->matrix[3][1]=py+look_at_point[1];
|
||||
eye->matrix[3][2]=pz+look_at_point[2];
|
||||
|
||||
look_at ( eye, &eye->matrix[3][0], look_at_point, rz );
|
||||
*/
|
||||
|
||||
dpl_IdMatrix ( eye->matrix );
|
||||
|
||||
dpl_Rotate ( eye->matrix, rz, dpl_Z );
|
||||
dpl_Rotate ( eye->matrix, rx, dpl_X );
|
||||
dpl_Rotate ( eye->matrix, ry, dpl_Y );
|
||||
dpl_Translate ( eye->matrix, px, py, pz );
|
||||
|
||||
printf ("camera at %f %f %f\n",
|
||||
px, py, pz );
|
||||
|
||||
dpl_Flush(eye);
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ void camera_move_kbd ( VIEW *eye,*/
|
||||
|
||||
static float yaw=0.0f, pitch=0.0f, roll=0.0f,
|
||||
velocity=0.0f,
|
||||
px=0.0f, py=0.0f, pz=0.0f,
|
||||
pitch_velocity = 0.0f,
|
||||
yaw_velocity = 0.0f,
|
||||
roll_velocity = 0.0f,
|
||||
dspin=0.3f, dspeed=0.3f;
|
||||
|
||||
void camera_move_kbd ( dpl_VIEW *eye,
|
||||
char *spline_file,
|
||||
dpl_POINT look_at_point,
|
||||
float scale_fac,
|
||||
float dt )
|
||||
{
|
||||
dpl_POINT vel0, vel1;
|
||||
|
||||
/* compute roll, pitch, yaw from keyboard input */
|
||||
|
||||
if (kbhit()) {
|
||||
int ch;
|
||||
|
||||
ch=getch();
|
||||
switch (ch) {
|
||||
case '7' : /* roll left */
|
||||
roll_velocity += dspin;
|
||||
break;
|
||||
case '9': /* roll right */
|
||||
roll_velocity -= dspin;
|
||||
break;
|
||||
case '4' : /* swing left weeet chariot */
|
||||
yaw_velocity+=dspin;
|
||||
break;
|
||||
case '6' : /* right */
|
||||
yaw_velocity-=dspin;
|
||||
break;
|
||||
case '2' : /* upp */
|
||||
pitch_velocity+=dspin;
|
||||
break;
|
||||
case '8' : /* downnn */
|
||||
pitch_velocity-=dspin;
|
||||
break;
|
||||
case '5' : /* go faster */
|
||||
velocity+=dspeed;
|
||||
break;
|
||||
case '0' : /* decelerate */
|
||||
velocity-=dspeed;
|
||||
break;
|
||||
case '*' :
|
||||
pitch_velocity = 0.0;
|
||||
roll_velocity = 0.0;
|
||||
yaw_velocity = 0.0;
|
||||
break;
|
||||
case '-':
|
||||
pitch = 0.0;
|
||||
yaw = 0.0;
|
||||
roll = 0.0;
|
||||
break;
|
||||
case ' ' : /* set speed to 0 */
|
||||
velocity=0.0f;
|
||||
pitch_velocity = 0.0f;
|
||||
yaw_velocity = 0.0f;
|
||||
roll_velocity = 0.0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vel0[0]=0;
|
||||
vel0[1]=0;
|
||||
vel0[2]=-velocity;
|
||||
|
||||
dpl_IdMatrix ( eye->matrix );
|
||||
|
||||
roll += roll_velocity;
|
||||
pitch += pitch_velocity;
|
||||
yaw += yaw_velocity;
|
||||
|
||||
|
||||
dpl_Rotate ( eye->matrix, roll, dpl_Z );
|
||||
dpl_Rotate ( eye->matrix, pitch, dpl_X );
|
||||
dpl_Rotate ( eye->matrix, yaw, dpl_Y );
|
||||
|
||||
_xformpoint ( vel1, vel0, eye->matrix );
|
||||
|
||||
px+=vel1[0];
|
||||
py+=vel1[1];
|
||||
pz+=vel1[2];
|
||||
|
||||
dpl_Translate ( eye->matrix, px, py, pz );
|
||||
|
||||
dpl_Flush(eye);
|
||||
}
|
||||
/*}}} */
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef camera_h
|
||||
#define camera_h
|
||||
|
||||
#include "dpltypes.h"
|
||||
|
||||
extern void camera_move ( dpl_VIEW *eye,
|
||||
char *spline_file,
|
||||
dpl_POINT look_at_point,
|
||||
float scale_fac,
|
||||
float dt );
|
||||
|
||||
extern void camera_move_kbd ( dpl_VIEW *eye,
|
||||
char *spline_file,
|
||||
dpl_POINT look_at_point,
|
||||
float scale_fac,
|
||||
float dt );
|
||||
#endif
|
||||
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
23
|
||||
-134.2 73.1 0.0 0.0 0.0 0.0
|
||||
-134.2 73.1 0.0 0.0 0.0 0.0
|
||||
-134.2 73.1 0.0 0.0 0.0 0.0
|
||||
-134.2 73.1 0.0 0.0 0.0 0.0
|
||||
-134.2 73.1 0.0 0.0 0.0 0.0
|
||||
-134.2 -13.1 0.0 0.0 0.0 0.0
|
||||
-134.2 -23.1 0.0 0.0 0.0 0.0
|
||||
-134.2 -23.1 0.0 0.0 0.0 0.0
|
||||
-134.2 -23.1 0.0 0.0 0.0 0.0
|
||||
-134.2 -23.1 0.0 0.0 0.0 0.0
|
||||
-100.3 -2.4 109.1 5.0 4.0 5.0
|
||||
-40.3 -12.4 89.1 5.0 4.0 5.0
|
||||
109.1 -24.3 2.2 7.0 2.0 4.0
|
||||
-0.6 73.3 -101.1 0.0 -3.0 0.0
|
||||
-32.6 3.3 -81.1 0.0 -3.0 360.0
|
||||
119.1 -24.3 -140.2 7.0 2.0 0.0
|
||||
112.1 -20.3 -100.2 7.0 2.0 0.0
|
||||
0.6 0.3 140.1 0.0 -3.0 0.0
|
||||
30.6 53.3 30.1 0.0 -3.0 0.0
|
||||
0.6 73.3 101.1 0.0 -3.0 0.0
|
||||
32.6 3.3 91.1 0.0 -3.0 0.0
|
||||
-119.1 -24.3 140.2 7.0 2.0 0.0
|
||||
-112.1 -20.3 100.2 7.0 2.0 0.0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1 @@
|
||||
tanks 20 floor.v2z zilch
|
||||
@@ -0,0 +1,34 @@
|
||||
32
|
||||
0 0 0 0 0 0
|
||||
2000 0 0 0 0 0
|
||||
4000 0 0 0 0 0
|
||||
6000 0 0 0 0 0
|
||||
8000 0 20 0 90 0
|
||||
8000 0 40 0 90 0
|
||||
8000 0 60 0 90 0
|
||||
8000 0 80 0 90 0
|
||||
0 0 0 0 180 0
|
||||
0 0 0 0 180 0
|
||||
0 0 0 0 180 0
|
||||
0 0 0 0 180 0
|
||||
0 0 0 0 270 0
|
||||
0 0 0 0 270 0
|
||||
0 0 0 0 270 0
|
||||
0 0 0 0 270 0
|
||||
0 0 0 0 360 0
|
||||
0 0 0 0 360 0
|
||||
0 0 0 0 360 0
|
||||
0 0 0 0 360 0
|
||||
0 0 0 0 270 0
|
||||
0 0 0 0 270 0
|
||||
0 0 0 0 270 0
|
||||
0 0 0 0 270 0
|
||||
0 0 0 0 180 0
|
||||
0 0 0 0 180 0
|
||||
0 0 0 0 180 0
|
||||
0 0 0 0 180 0
|
||||
0 0 0 0 90 0
|
||||
0 0 0 0 90 0
|
||||
0 0 0 0 90 0
|
||||
0 0 0 0 90 0
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
float t;
|
||||
|
||||
sscanf ( argv[1], "%f", &t );
|
||||
printf ( "0x%x\n", *(int *) &t );
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
float.c(11): Warning! W107: Missing return value for function 'main'
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,504 @@
|
||||
/*
|
||||
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, "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);
|
||||
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[] )
|
||||
{
|
||||
progname=argv[0];
|
||||
|
||||
if (argc < 2) {
|
||||
printf ("usage %s: <scenefile>\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");
|
||||
exit(666);
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf ("failed to getenv dplarg\n");
|
||||
exit(666);
|
||||
}
|
||||
|
||||
near_clip=6.0;
|
||||
far_clip =12000.0f;
|
||||
|
||||
nain ( argc, argv );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*}}} */
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
goto total.c (Editing* C)
|
||||
goto fold.stp (Editing* Default)
|
||||
command "fold.cmd"
|
||||
foldmark "Occam" "--" ""
|
||||
foldmark "C" "/*" "*/"
|
||||
foldmark "Pascal" "(*" "*)"
|
||||
foldmark "Iterm" "#" ""
|
||||
foldmark "Latex" "%%" ""
|
||||
foldmark "Asm" ";" ""
|
||||
foldmark "As860" "\\" ""
|
||||
foldmark "C++" "//" ""
|
||||
|
||||
#{{{ 0 Macro key to type "--" at the beginning of a line
|
||||
209 45 45 202
|
||||
#}}}
|
||||
#{{{ 1 Macro key to say Hello World
|
||||
72 101 108 108 111 32 87 111 114 108 100
|
||||
#}}}
|
||||
#{{{ 3 Macro key to duplicate a fold marker
|
||||
221 212 211 222 209 246 249 202 211 209 205
|
||||
#}}}
|
||||
#{{{ 8 Macro key to search
|
||||
224
|
||||
#}}}
|
||||
#{{{ 9 Macro key to replace
|
||||
225
|
||||
#}}}
|
||||
@@ -0,0 +1,11 @@
|
||||
FOG 2000.0 12000.0 0.2 0.3 0.5
|
||||
BACKGND 0.4 0.6 0.8
|
||||
AMBIENT 0.4 0.4 0.6
|
||||
LIGHT 0.99 0.99 0.99 60 0 0
|
||||
|
||||
STATIC ocean 20.0 0 -190 0 0 0 0
|
||||
STATIC plant1 30.0 -500 -190 -600 0 -35 90
|
||||
STATIC plant2 32.0 0 -190 -500 0 70 90
|
||||
STATIC plant3 31.0 600 -190 -500 0 20 90
|
||||
STATIC plant4 27.0 -500 -190 0 0 0 90
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
16
|
||||
0.0 -4.0 0.0 0.01 -3.0 0.0
|
||||
0.0 -4.0 0.0 0.01 -3.0 0.0
|
||||
3.0 0.6 0.0 1.8 0.0 0.0
|
||||
4.0 0.9 0.0 1.6 0.0 0.0
|
||||
4.3 1.5 0.0 1.9 2.0 3.0
|
||||
3.9 1.00 -0.1 1.4 -3.0 0.0
|
||||
4.6 0.29 -0.1 1.2 -3.0 0.0
|
||||
5.0 0.4 -0.20 1.6 -3.0 0.0
|
||||
6.5 0.72 0.2 1.82 -3.0 0.0
|
||||
7.0 0.90 0.0 1.93 -3.0 0.0
|
||||
8.0 0.75 0.0 2.17 -3.0 0.0
|
||||
9.0 -0.37 0.1 2.6 -3.0 0.0
|
||||
10.0 -0.7 0.1 2.9 -3.0 0.0
|
||||
11.0 -1.5 0.1 3.3 -3.0 0.0
|
||||
12.0 -4.8 0.1 4.5 -3.0 0.0
|
||||
0.0 -4.0 0.0 0.01 -3.0 0.0
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
16
|
||||
0.0 -4.0 0.0 0.01 -3.0 0.0
|
||||
0.0 -1.6 0.2 0.8 0.0 0.0
|
||||
1.0 6.9 0.0 1.1 0.0 0.0
|
||||
1.3 19.5 0.1 1.9 2.0 3.0
|
||||
2.9 16.40 -0.1 2.2 -3.0 0.0
|
||||
6.8 14.9 -0.1 2.3 -3.0 0.0
|
||||
14.3 16.0 -0.20 2.1 -3.0 0.0
|
||||
12.8 14.9 0.2 2.4 -3.0 0.0
|
||||
11.3 14.0 0.0 2.2 -3.0 0.0
|
||||
12.8 15.1 0.0 2.047 -3.0 0.0
|
||||
14.3 16.0 0.1 2.3 -3.0 0.0
|
||||
12.8 15.0 0.0 2.2 -3.0 0.0
|
||||
11.0 13.7 -0.1 0.43 -3.0 0.0
|
||||
10.0 -0.3 0.1 0.0 -3.0 0.0
|
||||
0.0 -4.0 0.0 0.01 -3.0 0.0
|
||||
0.0 -4.0 0.0 0.01 -3.0 0.0
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <conio.h>
|
||||
#include "dpl.h"
|
||||
#include "matrix.h"
|
||||
#include "spline.h"
|
||||
|
||||
/*{{{ static float atan2deg ( float dz, float dx )*/
|
||||
static float _atan2deg ( float dz, float dx )
|
||||
{
|
||||
float angle;
|
||||
if ((dx*dx) < 0.0001f) {
|
||||
angle=(dz>0) ? 90.0f : -90.0f;
|
||||
return angle;
|
||||
}
|
||||
else {
|
||||
return (180.0f / 3.1415926535f) * atan2 ( dz, dx );
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ static void xformpoint ( POINT q, POINT p, MATRIX m )*/
|
||||
static void _xformpoint ( dpl_POINT q, dpl_POINT p, dpl_MATRIX m )
|
||||
{
|
||||
dpl_POINT r;
|
||||
int i;
|
||||
|
||||
for (i=0; i<4; i++ ) {
|
||||
r[i]=(p[0]*m[0][i])+
|
||||
(p[1]*m[1][i])+
|
||||
(p[2]*m[2][i])+
|
||||
(p[3]*m[3][i]);
|
||||
}
|
||||
memcpy ( q, r, sizeof(dpl_POINT));
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ void look_at ( VIEW *v, float *from, float *at, float z_spin )*/
|
||||
void look_at ( dpl_VIEW *v, float *from, float *at, float z_spin )
|
||||
{
|
||||
/* construct a view from 2 points */
|
||||
float dx, dy, dz;
|
||||
float px, py, pz;
|
||||
float thetax, thetay, thetaz;
|
||||
float yaw, roll;
|
||||
dpl_MATRIX m;
|
||||
dpl_POINT p, q;
|
||||
|
||||
/* put 'at' at origin, construct a vector from 'from' */
|
||||
px=from[0]; py=from[1]; pz=from[2];
|
||||
|
||||
dx=at[0]-px;
|
||||
dy=at[1]-py;
|
||||
dz=at[2]-pz;
|
||||
|
||||
thetaz=0.0f;
|
||||
thetay=0.0f;
|
||||
thetax=0.0f;
|
||||
|
||||
p[0]=dx;
|
||||
p[1]=dy;
|
||||
p[2]=dz;
|
||||
p[3]=1;
|
||||
|
||||
yaw=-_atan2deg ( dz, dx );
|
||||
dpl_IdMatrix ( m );
|
||||
dpl_Rotate ( m, -yaw, dpl_Y );
|
||||
_xformpoint ( q, p, m );
|
||||
|
||||
roll=_atan2deg(q[1], q[0] );
|
||||
|
||||
/* project onto x-z plane, assuming camera is initially looking down -z */
|
||||
dpl_IdMatrix ( v->matrix );
|
||||
|
||||
/* apply angles to matrix */
|
||||
|
||||
dpl_Rotate ( v->matrix, z_spin, dpl_Z );
|
||||
dpl_Rotate ( v->matrix, roll, dpl_X );
|
||||
dpl_Rotate ( v->matrix, yaw-90.0f, dpl_Y );
|
||||
|
||||
dpl_Translate( v->matrix, px, py, pz );
|
||||
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
static int camera_inited=0;
|
||||
static float camera_t=0.0f;
|
||||
static cntl_point *camerahead=NULL;
|
||||
|
||||
/*{{{ void camera_move ( VIEW *eye,*/
|
||||
void camera_move ( dpl_VIEW *eye,
|
||||
char *spline_file,
|
||||
dpl_POINT look_at_point,
|
||||
float scale_fac,
|
||||
float dt )
|
||||
{
|
||||
cntl_point *p=camerahead;
|
||||
float t=camera_t;
|
||||
float px, py, pz, rx, ry, rz;
|
||||
dpl_POINT evalp;
|
||||
|
||||
if (camera_inited == 0) {
|
||||
camera_inited=1;
|
||||
p=init_splines(spline_file);
|
||||
t=0;
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
camerahead=walk_spline ( p, &t, dt );
|
||||
camera_t=t;
|
||||
|
||||
/* we have wobbled the spline according to the file - now build the
|
||||
view matrix */
|
||||
/*
|
||||
eye->matrix[3][0]=px+look_at_point[0];
|
||||
eye->matrix[3][1]=py+look_at_point[1];
|
||||
eye->matrix[3][2]=pz+look_at_point[2];
|
||||
|
||||
look_at ( eye, &eye->matrix[3][0], look_at_point, rz );
|
||||
*/
|
||||
|
||||
dpl_IdMatrix ( eye->matrix );
|
||||
|
||||
dpl_Rotate ( eye->matrix, rz, dpl_Z );
|
||||
dpl_Rotate ( eye->matrix, rx, dpl_X );
|
||||
dpl_Rotate ( eye->matrix, ry, dpl_Y );
|
||||
dpl_Translate ( eye->matrix, px, py, pz );
|
||||
|
||||
dpl_Flush(eye);
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ void camera_move_kbd ( VIEW *eye,*/
|
||||
|
||||
static float
|
||||
yaw = 0.0f, pitch = 0.0f, roll = 0.0f,
|
||||
x_velocity = 0.0f,
|
||||
y_velocity = 0.0f,
|
||||
z_velocity = 0.0f,
|
||||
px = 0.0f, py = 5.0f, pz = 0.0f,
|
||||
pitch_velocity = 0.0f,
|
||||
yaw_velocity = 0.0f,
|
||||
roll_velocity = 0.0f,
|
||||
dspin = 0.3f, dspeed = 0.3f;
|
||||
|
||||
static int
|
||||
enhanced_key = 0; //Flag: True if next char is enhanced key.
|
||||
|
||||
void camera_move_kbd ( dpl_VIEW *eye,
|
||||
char *spline_file,
|
||||
dpl_POINT look_at_point,
|
||||
float scale_fac,
|
||||
float dt )
|
||||
{
|
||||
dpl_POINT vel0, vel1;
|
||||
|
||||
/* compute roll, pitch, yaw from keyboard input */
|
||||
|
||||
if (kbhit()) {
|
||||
int ch;
|
||||
|
||||
ch = getch();
|
||||
if (enhanced_key) {
|
||||
enhanced_key = 0; //False
|
||||
switch (ch) {
|
||||
case 'H': // 0,72 'H' up arrow
|
||||
y_velocity+=dspeed;
|
||||
break;
|
||||
case 'P': // 0,80 'P' down arrow
|
||||
y_velocity-=dspeed;
|
||||
break;
|
||||
case 'M': // 0,77 'M' left arrow
|
||||
x_velocity+=dspeed;
|
||||
break;
|
||||
case 'K': // 0,75 'K' right arrow
|
||||
x_velocity-=dspeed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ch == 0) {
|
||||
enhanced_key = -1; //True
|
||||
}
|
||||
else {
|
||||
switch (ch) {
|
||||
case '7' : /* roll left */
|
||||
roll_velocity += dspin;
|
||||
break;
|
||||
case '9': /* roll right */
|
||||
roll_velocity -= dspin;
|
||||
break;
|
||||
case '4' : /* swing left weeet chariot */
|
||||
yaw_velocity+=dspin;
|
||||
break;
|
||||
case '6' : /* right */
|
||||
yaw_velocity-=dspin;
|
||||
break;
|
||||
case '8' : /* upp */
|
||||
pitch_velocity-=dspin;
|
||||
break;
|
||||
case '2' : /* downnn */
|
||||
pitch_velocity+=dspin;
|
||||
break;
|
||||
case '5' : /* go faster */
|
||||
z_velocity+=(dspeed+dspeed);
|
||||
break;
|
||||
case '0' : /* decelerate */
|
||||
z_velocity-=(dspeed+dspeed);
|
||||
break;
|
||||
case '-':
|
||||
pitch = 0.0;
|
||||
yaw = 0.0;
|
||||
roll = 0.0;
|
||||
break;
|
||||
case ' ' : /* set speed to 0 */
|
||||
x_velocity=0.0f;
|
||||
y_velocity=0.0f;
|
||||
z_velocity=0.0f;
|
||||
// v--fall through--v //
|
||||
case '*' :
|
||||
pitch_velocity = 0.0f;
|
||||
yaw_velocity = 0.0f;
|
||||
roll_velocity = 0.0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vel0[0]=x_velocity;
|
||||
vel0[1]=y_velocity;
|
||||
vel0[2]=-z_velocity;
|
||||
|
||||
dpl_IdMatrix ( eye->matrix );
|
||||
|
||||
roll += roll_velocity;
|
||||
pitch += pitch_velocity;
|
||||
yaw += yaw_velocity;
|
||||
|
||||
dpl_Rotate ( eye->matrix, roll, dpl_Z );
|
||||
dpl_Rotate ( eye->matrix, pitch, dpl_X );
|
||||
dpl_Rotate ( eye->matrix, yaw, dpl_Y );
|
||||
|
||||
_xformpoint ( vel1, vel0, eye->matrix );
|
||||
|
||||
px+=vel1[0];
|
||||
py+=vel1[1];
|
||||
pz+=vel1[2];
|
||||
|
||||
dpl_Translate ( eye->matrix, px, py, pz );
|
||||
|
||||
dpl_Flush ( eye );
|
||||
}
|
||||
/*}}} */
|
||||
Binary file not shown.
@@ -0,0 +1,35 @@
|
||||
# ##############################################################
|
||||
#
|
||||
# makefile for WATCOM C to generate PC-interface dView example
|
||||
#
|
||||
#
|
||||
BIN=$(WATCOM)\bin
|
||||
DVINC=..\libdpl
|
||||
DVLIB=..\libdpl
|
||||
|
||||
CFLAGS= -zp4 -ei -7 -dDVIEW=1 -DMS_DOS=1 -i=$(WATCOM)\h;$(DVINC)
|
||||
|
||||
.c.obj:
|
||||
$(BIN)\wcc386 $(CFLAGS) $<
|
||||
|
||||
.obj.exe:
|
||||
$(BIN)b\wcl386 -l=386 $*.obj startdpl.obj kamera.obj spline.obj $(DVLIB)\libdpl.lib
|
||||
|
||||
O=.obj
|
||||
|
||||
testf15.exe: testf15.obj testf15.c startdpl.obj spline.obj $(DVLIB)\libdpl.lib
|
||||
|
||||
spin.exe: spin.obj spin.c spline.obj startdpl.obj $(DVLIB)\libdpl.lib
|
||||
|
||||
tanks.exe: tanks.obj tanks.c camera.obj spline.obj startdpl.obj $(DVLIB)\libdpl.lib
|
||||
|
||||
tankfog.exe: tankfog.obj tankfog.c camera.obj spline.obj startdpl.obj $(DVLIB)\libdpl.lib
|
||||
|
||||
flyk.exe: flyk.obj flyk.c kamera.obj spline.obj startdpl.obj $(DVLIB)\libdpl.lib
|
||||
|
||||
test.exe: test.obj test.c $(DVLIB)\libdpl.lib
|
||||
|
||||
glomm.exe: glomm.obj glomm.c
|
||||
$(BIN)b\wcl386 -l=386 $*.obj
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# ##############################################################
|
||||
#
|
||||
# makefile for WATCOM C to generate dpl interface
|
||||
#
|
||||
#
|
||||
|
||||
BIN=$(WATCOM)\bin
|
||||
|
||||
CFLAGS= -we -ox -ei -7 -DMS_DOS -i=$(WATCOM)\h;.
|
||||
|
||||
.c.obj:
|
||||
$(BIN)\wcc386 $(CFLAGS) $<
|
||||
|
||||
.asm.obj:
|
||||
386asm -80386P -COMPAT M1 $*.asm
|
||||
|
||||
test.obj : test.c dpl.h dpltypes.h
|
||||
|
||||
dpl.obj : dpl.c dpl.h dpl_host.h dpltypes.h vr_comms.h
|
||||
|
||||
dpl_host.obj : dpl_host.c dpl.h dpl_host.h dpltypes.h vr_comms.h
|
||||
|
||||
dpl_load.obj : dpl_load.c dpl.h dpl_host.h dpltypes.h vr_comms.h
|
||||
|
||||
vr_comms.obj : vr_comms.c vr_comms.h dpl.h dpl_host.h dpltypes.h
|
||||
|
||||
bizread.obj : bizread.c bizread.h dpl_host.h dpltypes.h
|
||||
|
||||
matrix.obj : matrix.c matrix.h dpl_host.h dpltypes.h
|
||||
|
||||
linkio.obj : linkio.c linkio.h
|
||||
|
||||
libdpl.lib: dpl.obj dpl_host.obj dpl_load.obj vr_comms.obj linkio.obj outfast.obj bizread.obj matrix.obj
|
||||
$(BIN)b\wlib libdpl.lib -+dpl.obj -+dpl_host.obj -+dpl_load.obj -+vr_comms.obj -+linkio.obj -+outfast.obj -+bizread.obj -+matrix.obj
|
||||
copy libdpl.lib libdpl
|
||||
copy dpl.h libdpl
|
||||
copy dpltypes.h libdpl
|
||||
copy basictyp.h libdpl
|
||||
|
||||
test.exe : test.c test.obj libdpl.lib
|
||||
$(BIN)b\wcl386 -l=386 $*.obj libdpl.lib
|
||||
|
||||
testla.exe : testla.c testla.obj vr_comms.c vr_comms.obj dpl_load.obj dpl_host.c dpl_host.obj dpl.c dpl.obj linkio.c linkio.obj outfast.obj
|
||||
$(BIN)b\wcl386 -l=386 $*.obj dpl_load.obj dpl_host.obj vr_comms.obj dpl.obj linkio.obj outfast.obj
|
||||
|
||||
testrand.exe : testrand.c testrand.obj
|
||||
$(BIN)b\wcl386 -l=386 $*.obj
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int my_malloced=0;
|
||||
|
||||
char *my_malloc ( int n )
|
||||
{
|
||||
char *c=malloc(n);
|
||||
|
||||
if (c) {
|
||||
my_malloced+=n;
|
||||
printf ( "malloced %d bytes, total %d\n", n, my_malloced );
|
||||
}
|
||||
else {
|
||||
printf ( "malloced FAILED on %d bytes, total %d\n", n, my_malloced );
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
void my_free ( char *c )
|
||||
{
|
||||
free(c);
|
||||
|
||||
printf ("free 0x%x\n", c );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
|
||||
Volume in drive U is VOL2
|
||||
Volume Serial Number is 0900-7C68
|
||||
Directory of U:\DEMOS\VR\MAZE\SAMPLE16
|
||||
|
||||
COLOUR PST 47632 07-24-92 7:19a
|
||||
FILE PST 72320 07-24-92 7:21a
|
||||
TWEET PST 52922 03-20-92 10:53p
|
||||
STOP PST 60000 03-20-92 10:53p
|
||||
LIGHT PST 40228 03-20-92 10:53p
|
||||
RESIZE PST 80212 03-20-92 10:53p
|
||||
FILER PST 62050 03-20-92 10:52p
|
||||
POP PST 21170 10-31-91 3:43p
|
||||
WINDOW PST 246962 03-20-92 10:51p
|
||||
DIRECT PST 63356 03-20-92 10:52p
|
||||
QUACK PST 37928 03-20-92 10:53p
|
||||
DOOR PST 133334 03-20-92 10:52p
|
||||
TOM1 PST 60000 03-20-92 10:51p
|
||||
PAINT PST 42336 07-24-92 7:18a
|
||||
GLOBE PST 60416 03-20-92 10:52p
|
||||
BREATH PST 205504 07-25-92 3:32p
|
||||
WALK PST 45872 07-24-92 9:23a
|
||||
WHOOSH PST 52922 03-20-92 10:52p
|
||||
START PST 88202 03-20-92 10:52p
|
||||
SURF PST 470992 06-05-92 4:46p
|
||||
CLANG PST 88202 03-20-92 10:51p
|
||||
ZZTOP PST 352800 04-25-93 1:36p
|
||||
RUNNING PST 44102 03-20-92 10:51p
|
||||
BUFFER PST 66624 03-20-92 10:53p
|
||||
GUN PST 66668 03-20-92 10:51p
|
||||
JAWS2 PST 207264 07-25-92 4:32p
|
||||
TOM2 PST 80000 03-20-92 10:51p
|
||||
PICK PST 35280 07-11-92 6:16p
|
||||
BLUEDRM PST 666800 07-23-92 11:33a
|
||||
BIGRUSH PST 492160 07-23-92 11:41a
|
||||
BLUES PST 696784 07-23-92 11:54a
|
||||
TROT PST 74960 07-26-92 3:24p
|
||||
TRIUMPH PST 335152 07-23-92 12:11p
|
||||
PICK2 PST 35280 07-24-92 8:34a
|
||||
BUMPH PST 335152 07-23-92 3:00p
|
||||
BIGUMPH PST 1229504 07-23-92 3:01p
|
||||
PING PST 62624 07-23-92 6:30p
|
||||
PING2 PST 89968 07-23-92 6:34p
|
||||
FLY PST 51152 07-24-92 7:17a
|
||||
WORLD PST 97024 07-24-92 7:20a
|
||||
SCALE PST 70560 07-24-92 7:20a
|
||||
TRASH PST 51152 07-24-92 7:22a
|
||||
GALLOP PST 86448 07-26-92 3:25p
|
||||
SPLASH PST 229328 07-23-92 12:18p
|
||||
DROP PST 26448 07-11-92 6:14p
|
||||
SATCH PST 500080 04-25-93 12:58p
|
||||
MOTOR PST 44096 08-26-92 1:50p
|
||||
JET PST 17632 08-26-92 1:47p
|
||||
BEETH6 PST 692368 04-25-93 1:41p
|
||||
ADD BAT 29 10-29-92 12:03a
|
||||
RENAULT PST 554784 04-25-93 1:48p
|
||||
HORN1 PST 70560 04-25-93 1:54p
|
||||
HORN2 PST 211680 04-25-93 1:55p
|
||||
HORN3 PST 52912 04-25-93 1:56p
|
||||
54 file(s) 9659935 bytes
|
||||
495288320 bytes free
|
||||
@@ -0,0 +1,79 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*{{{ void copy_image ( int *dest, int *src, in x0, int y0 )*/
|
||||
void copy_image ( int *dest, int *src, int x0, int y0 )
|
||||
{
|
||||
int i, s_index, d_index, j;
|
||||
|
||||
d_index=(y0*256)+x0;
|
||||
s_index=15;
|
||||
|
||||
for (j=0; j<64; j++ ) {
|
||||
for (i=0; i<32; i++) {
|
||||
int t;
|
||||
t=src[s_index+i];
|
||||
if (t==0) {
|
||||
dest[d_index+i]=0x0;
|
||||
}
|
||||
else {
|
||||
dest[d_index+i]=t | 256;
|
||||
}
|
||||
}
|
||||
|
||||
d_index+=256;
|
||||
s_index+=64;
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ int main ( int argc, char **argv )*/
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
FILE *s, *d;
|
||||
char fname[256];
|
||||
int *dest=malloc(256*256*sizeof(int));
|
||||
int *src =malloc(64*64*sizeof(int));
|
||||
int i, j, fix=1, index;
|
||||
|
||||
for (j=0; j<4; j++ ) {
|
||||
for (i=0; i<8; i++) {
|
||||
int ii, jj;
|
||||
int *srcp=src;
|
||||
|
||||
sprintf ( fname, "t:/usr/phil/f%d.tga", fix );
|
||||
fix++;
|
||||
printf ("read file %s\n", fname );
|
||||
s=fopen( fname, "rb" );
|
||||
fread ( src, 1, 18, s ); /* throw away tga header */
|
||||
|
||||
for (ii=0; ii<64; ii++ ) { /* read tga as 24-bit pixels */
|
||||
for (jj=0; jj<64; jj++ ) {
|
||||
char *csrcp=(char *) srcp;
|
||||
|
||||
*srcp=0;
|
||||
|
||||
fread ( csrcp+1, 1, 1, s );
|
||||
fread ( csrcp+2, 1, 1, s );
|
||||
fread ( csrcp+3, 1, 1, s );
|
||||
|
||||
srcp++;
|
||||
}
|
||||
}
|
||||
|
||||
fclose (s);
|
||||
index=(j*256*64)+(i*32);
|
||||
|
||||
printf ("extracting central portion\n" );
|
||||
|
||||
copy_image(dest, src, i*32, j*64 );
|
||||
}
|
||||
}
|
||||
|
||||
strcpy ( fname, "t:/usr/phil/allovem.svt" );
|
||||
d=fopen( fname, "wb" );
|
||||
fwrite ( dest, 1, 256*256*4, d );
|
||||
fclose (d);
|
||||
}
|
||||
/*}}} */
|
||||
@@ -0,0 +1 @@
|
||||
testf15 400 0
|
||||
@@ -0,0 +1,34 @@
|
||||
32
|
||||
-0.2 0.1 0.0 0.0 0.0 0.0
|
||||
0.3 -1.4 0.1 2.0 4.0 2.0
|
||||
0.2 -1.4 0.1 2.0 2.0 3.0
|
||||
0.3 -1.4 0.1 2.0 4.0 5.0
|
||||
0.2 0.3 1.7 3.0 2.0 3.0
|
||||
0.1 0.4 0.1 4.0 2.0 4.0
|
||||
-0.0 -0.1 -0.6 1.0 -3.0 0.0
|
||||
-0.0 -0.4 -0.1 1.0 -3.0 1.0
|
||||
-0.0 -0.3 -0.1 1.0 -3.0 0.0
|
||||
0.3 1.0 0.1 3.0 -1.0 -5.0
|
||||
0.1 1.31 1.8 -1.0 3.0 2.0
|
||||
0.1 1.41 -1.2 -1.0 3.0 4.0
|
||||
0.3 0.01 1.5 0.0 3.0 0.0
|
||||
0.0 0.01 0.2 0.0 0.0 360.0
|
||||
0.1 0.41 -0.2 1.0 0.0 360.0
|
||||
0.2 -0.21 -0.3 0.0 0.0 360.0
|
||||
0.1 -0.2 0.25 2.0 2.0 361.0
|
||||
-0.0 -0.3 -0.4 0.0 -3.0 359.0
|
||||
0.3 0.2 0.1 2.0 -1.0 360.0
|
||||
-0.2 0.01 0.2 0.0 0.0 360.0
|
||||
0.0 0.01 0.2 0.0 0.0 0.0
|
||||
0.4 0.31 0.0 2.0 0.0 0.0
|
||||
-0.2 1.8 0.1 2.0 0.0 0.0
|
||||
0.3 1.8 0.3 1.0 2.0 5.0
|
||||
-0.2 1.8 0.0 2.0 0.0 0.0
|
||||
-0.2 1.6 0.0 2.0 0.0 0.0
|
||||
0.2 1.7 0.2 2.0 0.0 0.0
|
||||
-0.2 1.8 0.0 2.0 0.0 0.0
|
||||
0.3 1.6 0.3 1.0 2.0 5.0
|
||||
0.3 -0.4 0.3 1.0 2.0 0.0
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,117 @@
|
||||
DIV-VIZ2
|
||||
HEADER
|
||||
(
|
||||
VERSION=2:01;
|
||||
DATE=28:2:94;
|
||||
TIME=17:55
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
TEXTURE(NAME=plant)
|
||||
{
|
||||
MAP {"funknoiz.svt"}
|
||||
MINIFY {POINT_SAMPLED}
|
||||
MAGNIFY {BILINEAR}
|
||||
}// End of texture
|
||||
|
||||
MATERIAL(NAME=robert)
|
||||
{
|
||||
TEXTURE {plant}
|
||||
AMBIENT {0.39, 0.99, 0.19}
|
||||
DIFFUSE {0.39, 0.99, 0.19}
|
||||
}// End of material
|
||||
|
||||
OBJECT
|
||||
(
|
||||
)
|
||||
{
|
||||
PATCH
|
||||
(
|
||||
F_MATERIAL=robert;
|
||||
B_MATERIAL=robert;
|
||||
VERTEX=RGB 2D_TEXTURE ;
|
||||
)
|
||||
{
|
||||
TRISTRIP {
|
||||
{-7.35181e-008, -3.02097, -320, 0.31453, 0.262108, 0.131054, 0, 0, 0}
|
||||
{-6.30152e-008, -2.58939, -318, 0.224363, 0.186969, 0.093484, 1, 0, 0.499975}
|
||||
{-2, -2.44554, -320, 0.334181, 0.278484, 0.139242, 0, 0.499975, 0}
|
||||
{-2, -2.02296, -318, 0.277538, 0.231282, 0.115641, 1, 0.499975, 0.499975}
|
||||
{-4, -2.01396, -320, 0.446312, 0.371927, 0.185963, 0, 0.99995, 0}
|
||||
{-4, -1.73526, -318, 0.368861, 0.307384, 0.153692, 1, 0.99995, 0.499975}
|
||||
{-6, -2.31069, -320, 0.312218, 0.260181, 0.130091, -1, 1.49993, 0}
|
||||
{-6, -1.72626, -318, 0.334181, 0.278484, 0.139242, 1, 1.49993, 0.499975}
|
||||
{-8, -1.87011, -320, 0.298346, 0.248621, 0.124311, -0.4, 1.9999, 0}
|
||||
{-8, -1.01598, -318, 0.498331, 0.415276, 0.207638, 1, 1.9999, 0.499975}
|
||||
{-10, -1.59141, -320, 0.349209, 0.291007, 0.145504, 0, 2.49988, 0}
|
||||
{-10, -1.00698, -318, 0.500643, 0.417203, 0.208601, 1, 2.49988, 0.499975}
|
||||
{-12, -1.43856, -320, 0.315686, 0.263072, 0.131536, 0, 2.99985, 0}
|
||||
{-12, -0.5844, -318, 0.664794, 0.553995, 0.276997, 1, 2.99985, 0.499975}
|
||||
{-14, -1.29468, -320, 0.520295, 0.433579, 0.21679, -1.1, 3.49983, 0}
|
||||
{-14, -1.01598, -318, 0.683289, 0.569407, 0.284704, 1, 3.49983, 0.499975}
|
||||
{-16, -2.16681, -320, 0.478679, 0.3989, 0.19945, -0.4, 3.9998, 0}
|
||||
{-16, -2.15784, -318, 0.42666, 0.35555, 0.177775, 1, 3.9998, 0.499975}
|
||||
}
|
||||
TRISTRIP {
|
||||
{-6.30152e-008, -2.58939, -318, 0.224363, 0.186969, 0.093484, 1, 0, 0.499975}
|
||||
{-3.5227e-008, -1.44753, -316, 0.294878, 0.245731, 0.122866, 1, 0, 0.99995}
|
||||
{-2, -2.02296, -318, 0.277538, 0.231282, 0.115641, 1, 0.499975, 0.499975}
|
||||
{-2, -1.01598, -316, 0.388512, 0.32376, 0.16188, 1, 0.499975, 0.99995}
|
||||
{-4, -1.73526, -318, 0.368861, 0.307384, 0.153692, 1, 0.99995, 0.499975}
|
||||
{-4, -1.15983, -316, 0.46134, 0.38445, 0.192225, 1, 0.99995, 0.99995}
|
||||
{-6, -1.72626, -318, 0.334181, 0.278484, 0.139242, 1, 1.49993, 0.499975}
|
||||
{-6, -1.58241, -316, 0.409321, 0.3411, 0.17055, 1, 1.49993, 0.99995}
|
||||
{-8, -1.01598, -318, 0.498331, 0.415276, 0.207638, 1, 1.9999, 0.499975}
|
||||
{-8, -1.44753, -316, 0.535323, 0.446102, 0.223051, 1, 1.9999, 0.99995}
|
||||
{-10, -1.00698, -318, 0.500643, 0.417203, 0.208601, 1, 2.49988, 0.499975}
|
||||
{-10, -1.87011, -316, 0.519139, 0.432616, 0.216308, 1, 2.49988, 0.99995}
|
||||
{-12, -0.5844, -318, 0.664794, 0.553995, 0.276997, 1, 2.99985, 0.499975}
|
||||
{-12, -1.87011, -316, 0.537634, 0.448029, 0.224014, 1, 2.99985, 0.99995}
|
||||
{-14, -1.01598, -318, 0.683289, 0.569407, 0.284704, 1, 3.49983, 0.499975}
|
||||
{-14, -1.73526, -316, 0.609306, 0.507755, 0.253878, 1, 3.49983, 0.99995}
|
||||
{-16, -2.15784, -318, 0.42666, 0.35555, 0.177775, 1, 3.9998, 0.499975}
|
||||
{-16, -2.15784, -316, 0.444, 0.37, 0.185, 1, 3.9998, 0.99995}
|
||||
}
|
||||
TRISTRIP {
|
||||
{-3.5227e-008, -1.44753, -316, 0.294878, 0.245731, 0.122866, 1, 0, 0.99995}
|
||||
{-1.75043e-008, -0.71928, -314, 0.315686, 0.263072, 0.131536, 1, 0, 1.49993}
|
||||
{-2, -1.01598, -316, 0.388512, 0.32376, 0.16188, 1, 0.499975, 0.99995}
|
||||
{-2, -0.44055, -314, 0.498331, 0.415276, 0.207638, 1, 0.499975, 1.49993}
|
||||
{-4, -1.15983, -316, 0.46134, 0.38445, 0.192225, 1, 0.99995, 0.99995}
|
||||
{-4, -0.8721, -314, 0.553819, 0.461516, 0.230758, 1, 0.99995, 1.49993}
|
||||
{-6, -1.58241, -316, 0.409321, 0.3411, 0.17055, 1, 1.49993, 0.99995}
|
||||
{-6, -1.44753, -314, 0.516827, 0.430689, 0.215345, 1, 1.49993, 1.49993}
|
||||
{-8, -1.44753, -316, 0.535323, 0.446102, 0.223051, 1, 1.9999, 0.99995}
|
||||
{-8, -1.73526, -314, 0.553819, 0.461516, 0.230758, 1, 1.9999, 1.49993}
|
||||
{-10, -1.87011, -316, 0.519139, 0.432616, 0.216308, 1, 2.49988, 0.99995}
|
||||
{-10, -2.45454, -314, 0.497176, 0.414313, 0.207156, 1, 2.49988, 1.49993}
|
||||
{-12, -1.87011, -316, 0.537634, 0.448029, 0.224014, 1, 2.99985, 0.99995}
|
||||
{-12, -2.73324, -314, 0.482148, 0.40179, 0.200895, 1, 2.99985, 1.49993}
|
||||
{-14, -1.73526, -316, 0.609306, 0.507755, 0.253878, 1, 3.49983, 0.99995}
|
||||
{-14, -2.59839, -314, 0.47868, 0.3989, 0.19945, 1, 3.49983, 1.49993}
|
||||
{-16, -2.15784, -316, 0.444, 0.37, 0.185, 1, 3.9998, 0.99995}
|
||||
{-16, -2.44554, -314, 0.463652, 0.386376, 0.193188, 1, 3.9998, 1.49993}
|
||||
}
|
||||
TRISTRIP {
|
||||
{-1.75043e-008, -0.71928, -314, 0.315686, 0.263072, 0.131536, 1, 0, 1.49993}
|
||||
{0, 0, -312, 0.494399, 0.414543, 0.205575, 0, 0, 1.9999}
|
||||
{-2, -0.44055, -314, 0.498331, 0.415276, 0.207638, 0.6, 0.499975, 1.49993}
|
||||
{-2, -0.43155, -312, 0.536479, 0.447066, 0.223533, 0, 0.499975, 1.9999}
|
||||
{-4, -0.8721, -314, 0.553819, 0.461516, 0.230758, 1, 0.99995, 1.49993}
|
||||
{-4, -1.15083, -312, 0.537635, 0.448029, 0.224014, -0.4, 0.99995, 1.9999}
|
||||
{-6, -1.44753, -314, 0.516827, 0.430689, 0.215345, 1, 1.49993, 1.49993}
|
||||
{-6, -1.72626, -312, 0.482148, 0.40179, 0.200895, 0, 1.49993, 1.9999}
|
||||
{-8, -1.73526, -314, 0.553819, 0.461516, 0.230758, 0.5, 1.9999, 1.49993}
|
||||
{-8, -1.87011, -312, 0.517983, 0.431652, 0.215826, 0.3, 1.9999, 1.9999}
|
||||
{-10, -2.45454, -314, 0.497176, 0.414313, 0.207156, 1, 2.49988, 1.49993}
|
||||
{-10, -2.58939, -312, 0.482147, 0.40179, 0.200895, -0.4, 2.49988, 1.9999}
|
||||
{-12, -2.73324, -314, 0.482148, 0.40179, 0.200895, 0.2, 2.99985, 1.49993}
|
||||
{-12, -3.16482, -312, 0.407009, 0.339174, 0.169587, 0, 2.99985, 1.9999}
|
||||
{-14, -2.59839, -314, 0.47868, 0.3989, 0.19945, 1, 3.49983, 1.49993}
|
||||
{-14, -3.02097, -312, 0.499487, 0.416239, 0.20812, -0.5, 3.49983, 1.9999}
|
||||
{-16, -2.44554, -314, 0.463652, 0.386376, 0.193188, 1, 3.9998, 1.49993}
|
||||
{-16, -3.02097, -312, 0.390825, 0.325687, 0.162844, -1, 3.9998, 1.9999}
|
||||
}
|
||||
}// End of patch
|
||||
}// End of object
|
||||
@@ -0,0 +1,5 @@
|
||||
FOG 900.0 12000.0 0.1 0.3 0.2
|
||||
BACKGND 0.4 0.6 0.8
|
||||
AMBIENT 0.3 0.6 0.4
|
||||
LIGHT 0.99 0.82 0.99 30 50 40
|
||||
STATIC ocean 20.0 0 -190 0 0 0 0
|
||||
@@ -0,0 +1,7 @@
|
||||
set dos4g=quiet
|
||||
set LEFTMAGIC=0x3281
|
||||
set RIGHTMAGIC=0x3281
|
||||
set vizpath=..\geometry\
|
||||
set dviewbin=..\dvwrgbin\
|
||||
set texture=..\texture\
|
||||
set transputer=200
|
||||
@@ -0,0 +1,7 @@
|
||||
set dos4g=quiet
|
||||
set LEFTMAGIC=0x3291
|
||||
set RIGHTMAGIC=0x3291
|
||||
set vizpath=..\geometry\
|
||||
set dviewbin=..\dvwrgbin\
|
||||
set texture=..\texture\
|
||||
set transputer=200
|
||||
@@ -0,0 +1,7 @@
|
||||
set dos4g=quiet
|
||||
set LEFTMAGIC=0x3209
|
||||
set RIGHTMAGIC=0x3209
|
||||
set vizpath=..\geometry\
|
||||
set dviewbin=..\dvwrgbin\
|
||||
set texture=..\texture\
|
||||
set transputer=200
|
||||
@@ -0,0 +1,7 @@
|
||||
set dos4g=quiet
|
||||
set LEFTMAGIC=0x32c1
|
||||
set RIGHTMAGIC=0x32c1
|
||||
set vizpath=..\geometry\
|
||||
set dviewbin=..\dvwrgbin\
|
||||
set texture=..\texture\
|
||||
set transputer=200
|
||||
@@ -0,0 +1,18 @@
|
||||
FOG 2000.0 12000.0 0.2 0.3 0.5
|
||||
BACKGND 0.4 0.6 0.8
|
||||
AMBIENT 0.3 0.6 0.4
|
||||
LIGHT 0.99 0.82 0.99 60 0 0
|
||||
STATIC ocean 20.0 0 -190 0 0 0 0
|
||||
STATIC butter 10.0 -485.0 410.0 -434.0 0 20 0
|
||||
STATIC golden 10.0 -510.0 420.0 -440.0 0 -70 0
|
||||
STATIC grouper 10.0 -518.0 400.0 -425.0 0 -10 0
|
||||
STATIC angel 10.0 -480.0 410.0 -430.0 0 -30 0
|
||||
STATIC butter 10.0 -460.0 350.0 -434.0 0 -10 0
|
||||
STATIC golden 10.0 -463.0 361.0 -440.0 0 -15 0
|
||||
STATIC grouper 10.0 -449.0 370.0 -432.0 0 -20 0
|
||||
STATIC angel 10.0 -453.0 354.0 -430.0 0 -31 0
|
||||
STATIC shark 8.0 0 230.0 -200.0 0 0 0
|
||||
STATIC shark 8.0 280.0 330.0 0 0 20 0
|
||||
STATIC shark 8.0 -480.0 410.0 -450.0 0 -40 0
|
||||
|
||||
STATIC flant 42.0 0 -190 500 0 15 90
|
||||
@@ -0,0 +1,10 @@
|
||||
8
|
||||
0 0.0 200.0 0.0 270.0 0.0
|
||||
100 0.0 100.0 0.0 180.0 0.0
|
||||
0 0.0 0.0 0.0 90.0 0.0
|
||||
-100 0.0 -100.0 0.0 0.0 0.0
|
||||
0 0.0 -200.0 0.0 90.0 0.0
|
||||
100 0.0 -100.0 0.0 180.0 0.0
|
||||
0 0.0 0.0 0.0 270.0 0.0
|
||||
-100 0.0 100.0 0.0 360.0 0.0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
flyk sharks.scn
|
||||
@@ -0,0 +1,28 @@
|
||||
FOG 2000.0 12000.0 0.2 0.3 0.5
|
||||
BACKGND 0.4 0.6 0.8
|
||||
AMBIENT 0.3 0.6 0.4
|
||||
LIGHT 0.99 0.82 0.99 60 0 0
|
||||
STATIC ocean 20.0 0 -190 0 0 0 0
|
||||
STATIC butter 10.0 -485.0 410.0 -434.0 0 20 0
|
||||
STATIC golden 10.0 -510.0 420.0 -440.0 0 -70 0
|
||||
STATIC grouper 10.0 -518.0 400.0 -425.0 0 -10 0
|
||||
STATIC angel 10.0 -480.0 410.0 -430.0 0 -30 0
|
||||
STATIC butter 10.0 -460.0 350.0 -434.0 0 -10 0
|
||||
STATIC golden 10.0 -463.0 361.0 -440.0 0 -15 0
|
||||
STATIC grouper 10.0 -449.0 370.0 -432.0 0 -20 0
|
||||
STATIC angel 10.0 -453.0 354.0 -430.0 0 -31 0
|
||||
STATIC shark 8.0 0 230.0 -200.0 0 0 0
|
||||
STATIC shark 8.0 280.0 330.0 0 0 20 0
|
||||
STATIC shark 8.0 -480.0 410.0 -450.0 0 -40 0
|
||||
|
||||
STATIC plant 30.0 -500 -190 -600 0 -35 90
|
||||
STATIC plant 32.0 0 -190 -500 0 70 90
|
||||
STATIC plant 31.0 600 -190 -500 0 20 90
|
||||
|
||||
STATIC plant 27.0 -500 -190 0 0 0 90
|
||||
STATIC plant 33.0 0 -190 0 0 -30 90
|
||||
STATIC plant 35.0 500 -190 0 0 90 90
|
||||
|
||||
STATIC plant 32.0 -500 -190 500 0 0 90
|
||||
STATIC plant 42.0 0 -190 600 0 15 90
|
||||
STATIC plant 49.0 600 -190 500 0 80 90
|
||||
@@ -0,0 +1,10 @@
|
||||
8
|
||||
0 0.0 400.0 0.0 0.0 0
|
||||
200 0.0 200.0 0.0 0.0 0
|
||||
0 0.0 0.0 0.0 0.0 0
|
||||
-200 0.0 -200.0 0.0 0.0 0
|
||||
0 0.0 -400.0 0.0 0.0 0
|
||||
200 0.0 -200.0 0.0 0.0 0
|
||||
0 0.0 0.0 0.0 0.0 0
|
||||
-200 0.0 200.0 0.0 0.0 0
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,274 @@
|
||||
/*
|
||||
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 "dpl5.h"
|
||||
#include "boot.h"
|
||||
#include "startup.h"
|
||||
|
||||
char *progname;
|
||||
|
||||
int860 link_A, link_B;
|
||||
extern int860 __acks_per_frame;
|
||||
extern int magicLeftVal,
|
||||
magicRightVal;
|
||||
|
||||
/*{{{ void eyeStuff ( VIEW *view )*/
|
||||
void eyeStuff ( VIEW *view, int left )
|
||||
{
|
||||
float scale=1.0;
|
||||
|
||||
PAZidMatrix(view->f);
|
||||
PAZidMatrix(view->b);
|
||||
if (left) scale *= -1.0f;
|
||||
|
||||
PAZtranslatePair (view->f, view->b, scale*1.275, 0, 0 );
|
||||
PAZrotatePair (view->f, view->b, 180, PAZ_Y );
|
||||
PAZtranslatePair (view->f, view->b, 0, 0, -48 );
|
||||
|
||||
if (left == (-1)) view->shift_x=0.0;
|
||||
else if (left) view->shift_x=0.2147;
|
||||
else view->shift_x=-0.2147;
|
||||
|
||||
/* view->shift_y = 0.0f; */
|
||||
|
||||
PAZwriteView ( view );
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ void spinning_jenny ( INSTANCE *inst, VIEW *view, char *scale_str )*/
|
||||
void spinning_jenny ( INSTANCE *inst, VIEW *eye, VIEW *rye, char *scale_str, int base, int times )
|
||||
{
|
||||
float theta, scale_fac=0.1;
|
||||
int i;
|
||||
float then, now;
|
||||
|
||||
if (rye == NULL)
|
||||
eyeStuff ( eye, -1 );
|
||||
else {
|
||||
eyeStuff ( eye, 0 );
|
||||
eyeStuff ( rye, 1 );
|
||||
}
|
||||
|
||||
sscanf(scale_str, "%f", &scale_fac );
|
||||
|
||||
printf ("spinning jenny, scale factor %f\n", scale_fac );
|
||||
|
||||
for (i=base; i<times; i++) {
|
||||
int nulls=0;
|
||||
|
||||
theta = (i+40)*0.43;
|
||||
|
||||
PAZidMatrix(inst->f);
|
||||
|
||||
PAZscale (inst->f, scale_fac, scale_fac, scale_fac, 1 );
|
||||
|
||||
PAZrotate (inst->f, theta*2.4, PAZ_X, 1 );
|
||||
PAZrotate (inst->f, theta*1.3, PAZ_Z, 1 );
|
||||
PAZrotate (inst->f, theta/2.5, PAZ_Y, 1 );
|
||||
|
||||
PAZwriteMatrix ( inst );
|
||||
|
||||
PAZrenderScene ();
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ 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 ( vizStr, root );
|
||||
strcat ( vizStr, name );
|
||||
return ( vizStr );
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ 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;
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ int nain ( int argc, char *argv[])*/
|
||||
int nain ( int argc, char *argv[])
|
||||
{
|
||||
LIGHTSOURCE *bulb1, *bulb2, *bulb3, *bulb4, *bulb5, *bulb6;
|
||||
INSTANCE *inst, *kiddy, *kiddy2;
|
||||
OBJECT *obj;
|
||||
SCENE *s;
|
||||
VIEW *eye, *rye;
|
||||
float t;
|
||||
char *objname;
|
||||
int i, made, ramp;
|
||||
MATERIAL *mtl;
|
||||
TEXTURE *tex;
|
||||
|
||||
|
||||
s = initialize_all ( 0, -1, &eye, &rye );
|
||||
|
||||
printf ( "PAZcreateInstance\n" );
|
||||
|
||||
inst = PAZcreateInstance ();
|
||||
printf ("returned 0x%x\n", inst );
|
||||
|
||||
obj=PAZcreateObject ( makeVizName(argv[2]), makeTexName );
|
||||
inst->obj=obj;
|
||||
|
||||
PAZidMatrixPair ( inst->f, inst->b );
|
||||
inst->enable=1;
|
||||
PAZwriteInstance ( inst );
|
||||
|
||||
printf ( "PAZcreateMaterial\n" );
|
||||
|
||||
mtl=PAZcreateMaterial();
|
||||
|
||||
{
|
||||
mtl->kd[0]=0.99;
|
||||
mtl->kd[1]=0.99;
|
||||
mtl->kd[2]=0.99;
|
||||
mtl->ks =0.7;
|
||||
mtl->power=7.3;
|
||||
mtl->opacity=1.0f;
|
||||
mtl->tex=tex;
|
||||
mtl->ramp_entry=0;
|
||||
strcpy ( mtl->texture_name, "default" );
|
||||
strcpy ( mtl->material_name, "viz_0001" );
|
||||
}
|
||||
|
||||
PAZwriteMaterial(mtl);
|
||||
|
||||
printf ("returned 0x%x\n", mtl );
|
||||
|
||||
/* create 3 light bulbs */
|
||||
|
||||
/*
|
||||
*/
|
||||
bulb1=PAZcreateLight ();
|
||||
PAZinitLight ( bulb1, 0, 0.9, 0.2, 0.9, 1, 0, 0 );
|
||||
PAZwriteLight ( bulb1 );
|
||||
|
||||
|
||||
bulb3=PAZcreateLight ();
|
||||
PAZinitLight ( bulb3, 0, 0.2, 0.9, 0.9, -1, 0, 0 );
|
||||
PAZwriteLight ( bulb3 );
|
||||
|
||||
bulb2=PAZcreateLight ();
|
||||
PAZinitLight ( bulb2, 2, 0.4, 0.4, 0.4, -0.577, 0.577, -0.577 );
|
||||
PAZwriteLight ( bulb2 );
|
||||
|
||||
PAZsetBackGND ( 0.5, 0.3, 0.2 );
|
||||
PAZfog ( 1, 200.0, 4000.0, 0.4f, 0.3f, 0.1f );
|
||||
|
||||
while (1) {
|
||||
inst->f_material=mtl->name;
|
||||
PAZwriteInstance ( inst );
|
||||
spinning_jenny ( inst, eye, rye, argv[1], 0, 1000 );
|
||||
inst->f_material=NULL;
|
||||
PAZwriteInstance ( inst );
|
||||
spinning_jenny ( inst, eye, rye, argv[1], 0, 1000 );
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ int main ( int argc, char *argv[] )*/
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
link_A= 1;
|
||||
link_B=-1;
|
||||
|
||||
progname=argv[0];
|
||||
|
||||
if (argc < 3) {
|
||||
printf ("usage %s: <scale> <v2zfile>\n", argv[0] );
|
||||
exit(666);
|
||||
}
|
||||
else {
|
||||
char dplStr1 [256];
|
||||
char dplStr2 [256];
|
||||
|
||||
magicLeftVal =env2hex("LEFTMAGIC", 0x3281);
|
||||
magicRightVal=env2hex("RIGHTMAGIC", 0x3281);
|
||||
|
||||
if (magicLeftVal & 0x8) {
|
||||
x_size=1024;
|
||||
y_size=768;
|
||||
}
|
||||
else if (magicLeftVal & 0x10) {
|
||||
x_size=640;
|
||||
y_size=480;
|
||||
}
|
||||
else if (magicLeftVal & 0x20) {
|
||||
x_size=832;
|
||||
y_size=512;
|
||||
}
|
||||
|
||||
start_dView ( makedplName ( dplStr1, "dv_skip.btl"),
|
||||
NULL,
|
||||
makedplName ( dplStr2, "pazpl5.mng"),
|
||||
env2hex("TRANSPUTER", 0x200), 1, -1 );
|
||||
|
||||
nain ( argc, argv );
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
@@ -0,0 +1,259 @@
|
||||
/*{{{ on cubic splining the cheesey way*/
|
||||
/*
|
||||
spline path follower - reads in a set of control points
|
||||
with x, y, z, rx, ry, rz
|
||||
|
||||
computes dx, dy, dz, drx, dry, drz per control point by cheesey
|
||||
difference - dx(n) = 0.5 * (x(n+1) - x(n-1))
|
||||
these differences are wrt t, the parametric, not time.
|
||||
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
/*}}} */
|
||||
|
||||
/*{{{ spline types*/
|
||||
typedef struct s_cntl_point {
|
||||
int knot_id; /* checking */
|
||||
float pos[3];
|
||||
float vel[3];
|
||||
float ang[3];
|
||||
float rot[3];
|
||||
float x_pos_cubic[4];
|
||||
float y_pos_cubic[4];
|
||||
float z_pos_cubic[4];
|
||||
float x_rot_cubic[4];
|
||||
float y_rot_cubic[4];
|
||||
float z_rot_cubic[4];
|
||||
struct s_cntl_point *next;
|
||||
struct s_cntl_point *prev;
|
||||
} cntl_point;
|
||||
/*}}} */
|
||||
|
||||
/*{{{ void solve_cubic ( float *coeffs, float v0, float v1, float d0, float d1 )*/
|
||||
static void solve_cubic ( float *coeffs, float v0, float v1, float d0, float d1 )
|
||||
{
|
||||
/*
|
||||
v = at^3 + bt^2 + ct + d
|
||||
dv = 3at^2 + 2bt + c
|
||||
|
||||
d = v0
|
||||
a+b+c+d = v1
|
||||
|
||||
c = d0
|
||||
3a + 2b + c = d1
|
||||
|
||||
2b + 3a = d1 - d0
|
||||
a + b = v1 - v0 - d0
|
||||
|
||||
3a + 2b - 2a - 2b = d1 - d0 - 2v1 + 2v0 + 2d0
|
||||
a = d1 - d0 - 2v1 + 2v0 + 2d0
|
||||
a = d1 + d0 - 2v1 + 2v0
|
||||
b = v1 - v0 - d0 - a
|
||||
|
||||
*/
|
||||
|
||||
coeffs[3] = v0;
|
||||
coeffs[2] = d0;
|
||||
coeffs[0] = d1 + d0 - (2.0f*v1) + (2.0f*v0);
|
||||
coeffs[1] = v1 - v0 - d0 - coeffs[0];
|
||||
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ static void solve_rot_cubic ( float *coeffs, float v0, float v1, float d0, float d1 )*/
|
||||
static void solve_rot_cubic ( float *coeffs, float v0, float v1, float d0, float d1 )
|
||||
{
|
||||
/*
|
||||
v = at^3 + bt^2 + ct + d
|
||||
dv = 3at^2 + 2bt + c
|
||||
|
||||
d = v0
|
||||
a+b+c+d = v1
|
||||
|
||||
c = d0
|
||||
3a + 2b + c = d1
|
||||
|
||||
2b + 3a = d1 - d0
|
||||
a + b = v1 - v0 - d0
|
||||
|
||||
3a + 2b - 2a - 2b = d1 - d0 - 2v1 + 2v0 + 2d0
|
||||
a = d1 - d0 - 2v1 + 2v0 + 2d0
|
||||
a = d1 + d0 - 2v1 + 2v0
|
||||
b = v1 - v0 - d0 - a
|
||||
|
||||
*/
|
||||
if (d0>360.0f) d0-=360.0f;
|
||||
if (d1>360.0f) d1-=360.0f;
|
||||
|
||||
coeffs[3] = v0;
|
||||
coeffs[2] = d0;
|
||||
coeffs[0] = d1 + d0 - (2.0f*v1) + (2.0f*v0);
|
||||
coeffs[1] = v1 - v0 - d0 - coeffs[0];
|
||||
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ void fill_knot ( cntl_point *knot )*/
|
||||
static void fill_knot ( cntl_point *knot )
|
||||
{
|
||||
cntl_point *next=knot->next;
|
||||
|
||||
/*{{{ x*/
|
||||
solve_cubic ( knot->x_pos_cubic,
|
||||
knot->pos[0], next->pos[0],
|
||||
knot->vel[0], next->vel[0] );
|
||||
/*}}} */
|
||||
/*{{{ y*/
|
||||
solve_cubic ( knot->y_pos_cubic,
|
||||
knot->pos[1], next->pos[1],
|
||||
knot->vel[1], next->vel[1] );
|
||||
/*}}} */
|
||||
/*{{{ z pos*/
|
||||
solve_cubic ( knot->z_pos_cubic,
|
||||
knot->pos[2], next->pos[2],
|
||||
knot->vel[2], next->vel[2] );
|
||||
/*}}} */
|
||||
|
||||
/*{{{ x*/
|
||||
solve_rot_cubic ( knot->x_rot_cubic,
|
||||
knot->ang[0], next->ang[0],
|
||||
knot->rot[0], next->rot[0] );
|
||||
/*}}} */
|
||||
/*{{{ y*/
|
||||
solve_rot_cubic ( knot->y_rot_cubic,
|
||||
knot->ang[1], next->ang[1],
|
||||
knot->rot[1], next->rot[1] );
|
||||
/*}}} */
|
||||
/*{{{ z rot*/
|
||||
solve_rot_cubic ( knot->z_rot_cubic,
|
||||
knot->ang[2], next->ang[2],
|
||||
knot->rot[2], next->rot[2] );
|
||||
/*}}} */
|
||||
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ void knot_velocity ( cntl_point *prev, cntl_point *this, cntl_point *next )*/
|
||||
static void knot_velocity ( cntl_point *prev, cntl_point *this, cntl_point *next )
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<3; i++ ) {
|
||||
float v1, v2, delta;
|
||||
|
||||
this->vel[i] = (next->pos[i] - prev->pos[i]) / 2.0f;
|
||||
|
||||
v1=this->ang[i];
|
||||
v2=next->ang[i];
|
||||
|
||||
delta=v2-v1;
|
||||
|
||||
while (delta>180) delta-=180;
|
||||
while (delta<-180) delta+=180;
|
||||
|
||||
this->rot[i] =delta / 2.0f;
|
||||
|
||||
/*
|
||||
if (v1<0) this->ang[i]+=360.0f;
|
||||
else
|
||||
*/
|
||||
while (this->ang[i]>360.0f) this->ang[i]-=360.0f;
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ float eval ( float *coeffs, float t )*/
|
||||
float eval ( float *coeffs, float t )
|
||||
{
|
||||
/* return a*t^3 + b*t^2 + c*t + d */
|
||||
return (coeffs[0]*t*t*t) + (coeffs[1]*t*t) + (coeffs[2]*t) + coeffs[3];
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ cntl_point *walk_spline ( cntl_point *v, float *t, float dt )*/
|
||||
cntl_point *walk_spline ( cntl_point *v, float *t, float dt )
|
||||
{
|
||||
float s=dt + (*t);
|
||||
int fix=1;
|
||||
|
||||
while (fix) {
|
||||
if (s < 0.0f) {
|
||||
s+=1.0f;
|
||||
v=v->prev;
|
||||
}
|
||||
else if (s > 1.0f) {
|
||||
s-=1.0f;
|
||||
v=v->next;
|
||||
}
|
||||
else fix=0;
|
||||
}
|
||||
|
||||
*t=s;
|
||||
return v;
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
cntl_point *init_splines ( char *fname )
|
||||
{
|
||||
FILE *fp=fopen(fname, "rt");
|
||||
if (fp==NULL) {
|
||||
printf ("Failed to open spline file %s\n", fname );
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
int n_pts, i;
|
||||
cntl_point *knots, *prev=NULL;
|
||||
|
||||
/* read in cntl points */
|
||||
fscanf ( fp, "%d\n", &n_pts );
|
||||
|
||||
printf ("%d cntl points\n", n_pts );
|
||||
|
||||
knots = (cntl_point *) malloc ( n_pts * sizeof (cntl_point));
|
||||
|
||||
printf ("malloced knots\n", n_pts );
|
||||
|
||||
for (i=0; i<n_pts; i++ ) {
|
||||
int n_read=0;
|
||||
|
||||
n_read= fscanf ( fp, "%f %f %f",
|
||||
&knots[i].pos[0],
|
||||
&knots[i].pos[1],
|
||||
&knots[i].pos[2] );
|
||||
n_read+=fscanf ( fp, "%f %f %f\n",
|
||||
&knots[i].ang[0],
|
||||
&knots[i].ang[1],
|
||||
&knots[i].ang[2] );
|
||||
|
||||
if (n_read == 6) {
|
||||
knots[i].knot_id = i;
|
||||
if (prev) {
|
||||
prev->next=&knots[i];
|
||||
knots[i].prev=prev;
|
||||
}
|
||||
prev=&knots[i];
|
||||
}
|
||||
else {
|
||||
n_pts=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf ("closing spline file\n" );
|
||||
fclose(fp);
|
||||
|
||||
knots[0].prev=&knots[n_pts-1];
|
||||
knots[n_pts-1].next=&knots[0];
|
||||
|
||||
printf ("patched up %d knots\n", n_pts );
|
||||
|
||||
printf ("approximating velocities\n" );
|
||||
/* approx velocities */
|
||||
for (i=0; i<n_pts; i++ )
|
||||
knot_velocity ( knots[i].prev, &knots[i], knots[i].next );
|
||||
|
||||
/* compute cubics */
|
||||
printf ("computing cubics\n" );
|
||||
for (i=0; i<n_pts; i++ )
|
||||
fill_knot ( &knots[i] );
|
||||
|
||||
return &knots[0];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*{{{ spline types*/
|
||||
typedef struct s_cntl_point {
|
||||
int knot_id; /* checking */
|
||||
float pos[3];
|
||||
float vel[3];
|
||||
float ang[3];
|
||||
float rot[3];
|
||||
float x_pos_cubic[4];
|
||||
float y_pos_cubic[4];
|
||||
float z_pos_cubic[4];
|
||||
float x_rot_cubic[4];
|
||||
float y_rot_cubic[4];
|
||||
float z_rot_cubic[4];
|
||||
struct s_cntl_point *next;
|
||||
struct s_cntl_point *prev;
|
||||
} cntl_point;
|
||||
|
||||
extern float eval ( float *coeffs, float t );
|
||||
extern cntl_point *walk_spline ( cntl_point *v, float *t, float dt );
|
||||
extern cntl_point *init_splines ( char *fname );
|
||||
/*}}} */
|
||||
Binary file not shown.
@@ -0,0 +1,202 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <dpltypes.h>
|
||||
#include <dpl.h>
|
||||
|
||||
int x_size=832,
|
||||
y_size=512;
|
||||
|
||||
float near_clip=4.0f, far_clip=2000.0f;
|
||||
|
||||
/*{{{ static char *find_dpl_arg ( char *dpl_arg, char *find_arg )*/
|
||||
static char *find_dpl_arg ( char *dpl_arg, char *find_arg )
|
||||
{
|
||||
char *check=dpl_arg, *ret=NULL;
|
||||
int len=strlen(find_arg);
|
||||
|
||||
while (*check) {
|
||||
/* printf ("checking %s with %s, %d chars\n", find_arg, check, len ); */
|
||||
if (strncmp (check, find_arg, len) == 0) {
|
||||
/* found it ? */
|
||||
/* printf ("preliminary match, on %s\n", check ); */
|
||||
while ((*check) != dpl_arg_sep) {
|
||||
if ((*check) == 0x0) return NULL;
|
||||
/* printf ("skipping %c\n", *check ); */
|
||||
check++;
|
||||
}
|
||||
check++;
|
||||
if ((*check) == 0x0) return NULL;
|
||||
else {
|
||||
/* printf ("match, returning %s!\n", check ); */
|
||||
return check;
|
||||
}
|
||||
}
|
||||
else check++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ int screen_resolution ( dpl_argv )*/
|
||||
int screen_resolution ( char *dpl_argv )
|
||||
{
|
||||
char *video=find_dpl_arg ( dpl_argv, "video" );
|
||||
|
||||
if (video == NULL) return 0;
|
||||
|
||||
if (strncmp ( video, "ntsc", 4 ) == 0) {
|
||||
x_size=704;
|
||||
y_size=480;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strncmp ( video, "vga", 3 ) == 0) {
|
||||
x_size=640;
|
||||
y_size=480;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strncmp ( video, "hires", 5 ) == 0) {
|
||||
x_size=1024;
|
||||
y_size=768;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strncmp ( video, "svga", 4 ) == 0) {
|
||||
x_size=832;
|
||||
y_size=512;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strncmp ( video, "nucolor", 7 ) == 0) {
|
||||
x_size=640;
|
||||
y_size=480;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strncmp ( video, "kaiser", 6 ) == 0) {
|
||||
x_size=640;
|
||||
y_size=480;
|
||||
return 1;
|
||||
}
|
||||
|
||||
else {
|
||||
printf ("Unknown video format %s\n", video );
|
||||
x_size=640;
|
||||
y_size=480;
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ dpl_ZONE *initialize_eyes ( char *dpl_args, int stereo,*/
|
||||
dpl_ZONE *initialize_eyes ( int stereo,
|
||||
dpl_VIEW **lye,
|
||||
dpl_VIEW **rye,
|
||||
float fog_near )
|
||||
{
|
||||
dpl_ZONE *z;
|
||||
dpl_VIEW *eye;
|
||||
float fog_far;
|
||||
|
||||
if (fog_near > far_clip)
|
||||
fog_far=fog_near+256;
|
||||
else
|
||||
fog_far=far_clip;
|
||||
|
||||
|
||||
printf ("initialize eyes\n" );
|
||||
|
||||
z=dpl_NewZone();
|
||||
|
||||
printf ("create 1st view\n" );
|
||||
|
||||
*lye = dpl_NewView();
|
||||
|
||||
if ((*lye) == NULL) {
|
||||
printf ("NULL eye\n" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
eye=*lye;
|
||||
|
||||
dpl_SetZoneEnable ( z, 1 );
|
||||
dpl_AddZoneToScene ( z );
|
||||
dpl_SetViewClipPlanes ( eye, near_clip, far_clip );
|
||||
dpl_SetViewBackGround ( eye, 0.4f, 0.6f, 0.9f );
|
||||
dpl_SetViewFog ( eye, 0, 0.5f, 0.5f, 0.6f, fog_near, fog_far );
|
||||
dpl_SetViewProjection ( eye, x_size, y_size,
|
||||
-1.0f, -1.0f, 1.0f, 1.0f,
|
||||
1.9f );
|
||||
dpl_AddViewToScene ( eye );
|
||||
|
||||
if (stereo == 0) {
|
||||
*rye=NULL;
|
||||
}
|
||||
else {
|
||||
printf ("create 2nd view\n" );
|
||||
*rye = dpl_NewView();
|
||||
if ((*rye) == NULL) {
|
||||
printf ("NULL rye\n" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
eye=*rye;
|
||||
|
||||
dpl_SetViewClipPlanes ( eye, near_clip, far_clip );
|
||||
dpl_SetViewBackGround ( eye, 0.4f, 0.6f, 0.9f );
|
||||
dpl_SetViewFog ( eye, 0, 0.5f, 0.5f, 0.6f, fog_near, fog_far );
|
||||
dpl_SetViewProjection ( eye, x_size, y_size,
|
||||
-1.0f, -1.0f, 1.0f, 1.0f,
|
||||
1.9f );
|
||||
dpl_AddViewToScene ( eye );
|
||||
}
|
||||
return z;
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ dpl_ZONE *initialize_all ( char *dpl_args,*/
|
||||
dpl_ZONE *initialize_all ( char *dpl_args,
|
||||
int stereo,
|
||||
dpl_VIEW **lye,
|
||||
dpl_VIEW **rye,
|
||||
float fog_near )
|
||||
{
|
||||
dpl_ZONE *z;
|
||||
dpl_PATHITEM *gpathitem, *tpathitem;
|
||||
dpl_EXTNITEM *gextnitem, *textnitem;
|
||||
dpl_FILEPATH *gpath, *tpath;
|
||||
|
||||
dpl_Init ( dpl_args );
|
||||
|
||||
gpath =dpl_NewFilePath();
|
||||
gpathitem=dpl_NewPathItem();
|
||||
gextnitem=dpl_NewExtnItem();
|
||||
|
||||
tpath =dpl_NewFilePath();
|
||||
tpathitem=dpl_NewPathItem();
|
||||
textnitem=dpl_NewExtnItem();
|
||||
|
||||
dpl_SetPathItemPath ( gpathitem, "..\\geometry" );
|
||||
dpl_SetExtnItemExtn ( gextnitem, "b2z" );
|
||||
|
||||
dpl_SetPathItemPath ( tpathitem, "..\\texture" );
|
||||
dpl_SetExtnItemExtn ( textnitem, "svt" );
|
||||
|
||||
dpl_AddPathToFilepath ( gpath, gpathitem );
|
||||
dpl_AddExtToFilepath ( gpath, gextnitem );
|
||||
|
||||
dpl_AddPathToFilepath ( tpath, tpathitem );
|
||||
dpl_AddExtToFilepath ( tpath, textnitem );
|
||||
|
||||
dpl_SetGeometryFilePath ( gpath );
|
||||
dpl_SetTextureFilePath ( tpath );
|
||||
|
||||
z = initialize_eyes ( stereo, lye, rye, fog_near );
|
||||
|
||||
return z;
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,10 @@
|
||||
#ifdef startup_h
|
||||
#else
|
||||
#define startup_h
|
||||
extern int x_size, y_size;
|
||||
extern float near_clip, far_clip;
|
||||
|
||||
extern dpl_ZONE *initialize_eyes ( int stereo, dpl_VIEW **eye, dpl_VIEW **rye, float fog );
|
||||
extern dpl_ZONE *initialize_all ( char *arg, int stereo, dpl_VIEW **eye, dpl_VIEW **rye, float fog );
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
[edit-]
|
||||
screen=80 50
|
||||
toggles=1 1 0 1 0 0
|
||||
srch=
|
||||
src=
|
||||
rpl=
|
||||
file=c:\dpl3\examples\sea.scn 1 1 1 1
|
||||
[brief]
|
||||
file=c:\dpl3\examples\sea.scn 1 1 1 1 1 47 78 1 c=0
|
||||
[shared-]
|
||||
pmark=c:\dpl3\examples\sea.scn 1 1
|
||||
|
||||
@@ -0,0 +1,472 @@
|
||||
|
||||
/*
|
||||
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 "dpl5.h"
|
||||
#include "boot.h"
|
||||
#include "startup.h"
|
||||
#include "camera.h"
|
||||
|
||||
char *progname;
|
||||
|
||||
int860 link_A, link_B;
|
||||
extern int860 __acks_per_frame;
|
||||
extern int magicLeftVal,
|
||||
magicRightVal;
|
||||
|
||||
/*{{{ reproducible random number support*/
|
||||
/* as always, this is CASIO calculator output */
|
||||
|
||||
static float sfx_random_numbers[67] = { 0.990f, 0.196f, 0.030f, 0.452f,
|
||||
0.165f, 0.663f, 0.737f, 0.774f,
|
||||
0.996f, 0.269f, 0.676f, 0.786f,
|
||||
0.123f, 0.474f, 0.755f, 0.919f,
|
||||
0.873f, 0.603f, 0.628f, 0.045f,
|
||||
0.089f, 0.509f, 0.413f, 0.416f,
|
||||
0.304f, 0.011f, 0.083f, 0.110f,
|
||||
0.177f, 0.602f, 0.810f, 0.181f,
|
||||
0.723f, 0.394f, 0.035f, 0.873f,
|
||||
0.678f, 0.331f, 0.407f, 0.499f,
|
||||
0.132f, 0.210f, 0.081f, 0.550f,
|
||||
0.344f, 0.894f, 0.469f, 0.307f,
|
||||
0.641f, 0.936f, 0.779f, 0.833f,
|
||||
0.373f, 0.915f, 0.972f, 0.887f,
|
||||
0.019f, 0.613f, 0.540f, 0.898f,
|
||||
0.755f, 0.689f, 0.076f, 0.173f,
|
||||
0.870f, 0.825f, 0.364f };
|
||||
|
||||
|
||||
static int sfx_random_ix = 0;
|
||||
static int sfx_random_base = 0;
|
||||
|
||||
static float float_0to1 ()
|
||||
{
|
||||
sfx_random_ix++;
|
||||
|
||||
if (sfx_random_ix >= 67)
|
||||
sfx_random_ix=0;
|
||||
|
||||
return sfx_random_numbers[sfx_random_ix];
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ void eyeStuff ( VIEW *view )*/
|
||||
void eyeStuff ( VIEW *view, int left )
|
||||
{
|
||||
float scale=1.0;
|
||||
|
||||
PAZidMatrix(view->f);
|
||||
PAZidMatrix(view->b);
|
||||
if (left) scale *= -1.0f;
|
||||
|
||||
PAZtranslatePair (view->f, view->b, scale*1.275, 0, 0 );
|
||||
PAZrotatePair (view->f, view->b, 180, PAZ_Y );
|
||||
PAZtranslatePair (view->f, view->b, 0, 0, -48 );
|
||||
|
||||
if (left == (-1)) view->shift_x=0.0;
|
||||
else if (left) view->shift_x=0.2147;
|
||||
else view->shift_x=-0.2147;
|
||||
|
||||
/* view->shift_y = 0.0f; */
|
||||
|
||||
PAZwriteView ( 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 );
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ static OBJECT *load_flames( char *fname )*/
|
||||
static OBJECT *load_flames( char *fname )
|
||||
{
|
||||
OBJECT *flame;
|
||||
|
||||
FILE *fp=fopen(makeTexName(fname), "rb" );
|
||||
int texels[32];
|
||||
int total_texels=0, n_read;
|
||||
|
||||
|
||||
if (fp) {
|
||||
printf ("load flames\n" );
|
||||
|
||||
for (n_read = fread ( texels, 1, 32*4, fp );
|
||||
n_read;
|
||||
n_read = fread ( texels, 1, 32*4, fp )) {
|
||||
PAZfxtexels ( texels, 32 );
|
||||
total_texels+=32;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
printf ( "%d texels read\n", total_texels );
|
||||
|
||||
flame=PAZcreateObject ( makeVizName("flame.v2z"), makeTexName );
|
||||
return flame;
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ 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;
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ int nain ( int argc, char *argv[])*/
|
||||
int nain ( int argc, char *argv[])
|
||||
{
|
||||
/*{{{ local variables*/
|
||||
LIGHTSOURCE *bulb1, *bulb2;
|
||||
LIGHTSOURCE *fires[2];
|
||||
INSTANCE *finst[2];
|
||||
int fireage[2];
|
||||
int polls=0;
|
||||
|
||||
INSTANCE *inst,
|
||||
*tanks[16];
|
||||
|
||||
OBJECT *obj;
|
||||
OBJECT *flame=NULL, *tank_obj=NULL;
|
||||
MATERIAL *mtl=NULL;
|
||||
MATERIAL *temp_mtl=NULL;
|
||||
TEXTURE *tex=NULL;
|
||||
TEXTURE *tank_tex=NULL;
|
||||
SCENE *s;
|
||||
VIEW *eye, *rye;
|
||||
float scale_fac, t,
|
||||
fogr, fogg, fogb;
|
||||
char *objname;
|
||||
|
||||
int frames=0, made, ramp,
|
||||
blowup =0,
|
||||
blowup0=0,
|
||||
blowup1=5;
|
||||
|
||||
int i, j;
|
||||
/*}}} */
|
||||
|
||||
s = initialize_all ( 0, -1, &eye, &rye );
|
||||
|
||||
sscanf(argv[1], "%f", &scale_fac );
|
||||
|
||||
/*{{{ build flames geometry*/
|
||||
flame=load_flames ( "allovem.svt" );
|
||||
|
||||
for (i=0; i<2; i++ ) {
|
||||
finst[i]=PAZcreateInstance();
|
||||
finst[i]->obj=flame;
|
||||
|
||||
PAZidMatrix ( finst[i]->f );
|
||||
PAZtranslate ( finst[i]->f, 0, 0.5, 0, 1 );
|
||||
PAZscale ( finst[i]->f, 80, 80, 80, 1 );
|
||||
PAZtranslate ( finst[i]->f, 0, 0, -6000, 1 );
|
||||
PAZinvert ( finst[i]->b, finst[i]->f );
|
||||
finst[i]->billboard=1;
|
||||
finst[i]->enable=0;
|
||||
PAZwriteInstance ( finst[i] );
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
tank_tex=PAZcreateTexture ( makeTexName ( "tank.svt" ), 0, "tank" );
|
||||
|
||||
/*{{{ create the tanks*/
|
||||
for (i=0; i<4; i++ ) {
|
||||
for (j=0; j<4; j++ ) {
|
||||
tanks[blowup] = PAZcreateInstance ();
|
||||
if (tank_obj==NULL)
|
||||
tank_obj=PAZcreateObject ( makeVizName ("tank_dea.b2z"), makeTexName );
|
||||
|
||||
tanks[blowup]->obj=tank_obj;
|
||||
PAZidMatrix ( tanks[blowup]->f );
|
||||
PAZrotate ( tanks[blowup]->f, 36.0f * float_0to1(), 1, 1 );
|
||||
PAZtranslate ( tanks[blowup]->f, (((float) i) - 1.5f)*530.0f, -40, (j-1)*530.0f, 1 );
|
||||
PAZinvert ( tanks[blowup]->b, tanks[blowup]->f );
|
||||
|
||||
tanks[blowup]->enable=1;
|
||||
|
||||
temp_mtl=PAZcreateMaterial();
|
||||
|
||||
temp_mtl->kd[0]=0.99f;
|
||||
temp_mtl->kd[1]=0.99f;
|
||||
temp_mtl->kd[2]=0.99f;
|
||||
temp_mtl->ks=0.0f;
|
||||
temp_mtl->tex=NULL;
|
||||
|
||||
PAZwriteMaterial(temp_mtl);
|
||||
|
||||
tanks[blowup]->f_material=temp_mtl->name;
|
||||
tanks[blowup]->f_texture =tank_tex->name;
|
||||
|
||||
PAZwriteInstance ( tanks[blowup] );
|
||||
|
||||
blowup++;
|
||||
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ create the floor*/
|
||||
|
||||
inst = PAZcreateInstance ();
|
||||
obj=PAZcreateObject ( makeVizName(argv[2]), makeTexName );
|
||||
inst->obj=obj;
|
||||
|
||||
PAZidMatrixPair ( inst->f, inst->b );
|
||||
PAZscalePair ( inst->f, inst->b, scale_fac, scale_fac, scale_fac );
|
||||
PAZtranslatePair ( inst->f, inst->b, 0, -40, 0 );
|
||||
inst->enable=1;
|
||||
|
||||
PAZwriteInstance ( inst );
|
||||
/*}}} */
|
||||
/*{{{ create the lights*/
|
||||
|
||||
/* create 2 light bulbs, 1 of which ambient */
|
||||
|
||||
bulb2=PAZcreateLight ();
|
||||
PAZinitLight ( bulb2, light_ambient, 0.2, 0.2, 0.3, -0.577, 0.577, -0.577 );
|
||||
PAZwriteLight ( bulb2 );
|
||||
|
||||
bulb1=PAZcreateLight ();
|
||||
PAZinitLight ( bulb1, light_directional, 0.65, 0.65, 0.43, 1, 1, -1 );
|
||||
PAZwriteLight ( bulb1 );
|
||||
|
||||
/* create the flame light sources */
|
||||
for (i=0; i<2; i++ ) {
|
||||
fires[i]=PAZcreateLight ();
|
||||
PAZinitLight ( fires[i], light_null, 0.99, 0.55, 0.2, -10000, -10000, -10000 );
|
||||
|
||||
fires[i]->min_rad=0.0f;
|
||||
fires[i]->max_rad=0.01f;
|
||||
|
||||
PAZwriteLight ( fires[i] );
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
fireage[0]=100;
|
||||
fireage[1]=100;
|
||||
|
||||
PAZsetBackGND ( 0.2, 0.3, 0.6 );
|
||||
|
||||
blowup =0;
|
||||
blowup0=0;
|
||||
blowup1=5;
|
||||
|
||||
PAZfog ( 1, 7000.0f, 12000.0f, 0.1f, 0.2f, 0.3f );
|
||||
|
||||
PAZrenderScene();
|
||||
|
||||
while (1) {
|
||||
frames++;
|
||||
{
|
||||
float ff=(float) frames;
|
||||
|
||||
ff/=200.0f;
|
||||
fogr=0.2f+0.3f*(1.0+sin(1.14f*ff));
|
||||
fogg=0.2f+0.3f*(1.0+sin(1.4f*ff));
|
||||
fogb=0.2f+0.3f*(1.0+cos(1.734f*ff));
|
||||
}
|
||||
camera_move_kbd ( eye, "tankview.spl",
|
||||
&inst->f[3][0], 1.0f, 0.0057f );
|
||||
|
||||
polls=0;
|
||||
|
||||
while (PAZpollAck() == 0) {
|
||||
polls++;
|
||||
if ((polls & 0xffff) == 0xffff)
|
||||
printf ("Waited %d times\n", polls );
|
||||
}
|
||||
if (polls==0) printf ("Polls 0 frame %d\n", frames );
|
||||
|
||||
PAZfog ( 1, 7000.0f, 12000.0f, fogr, fogg, fogb );
|
||||
PAZrenderScene();
|
||||
|
||||
if (frames == 100) {
|
||||
/*{{{ fire off a new explosion*/
|
||||
MATRIX m;
|
||||
|
||||
frames=0;
|
||||
i=blowup;
|
||||
blowup^=1;
|
||||
|
||||
PAZidMatrix (m);
|
||||
|
||||
if (i==0) {
|
||||
m[3][0]=tanks[blowup0]->f[3][0];
|
||||
m[3][1]=tanks[blowup0]->f[3][1];
|
||||
m[3][2]=tanks[blowup0]->f[3][2];
|
||||
blowup0++;
|
||||
blowup0&=15;
|
||||
}
|
||||
else {
|
||||
m[3][0]=tanks[blowup1]->f[3][0];
|
||||
m[3][1]=tanks[blowup1]->f[3][1];
|
||||
m[3][2]=tanks[blowup1]->f[3][2];
|
||||
blowup1++;
|
||||
blowup1&=15;
|
||||
}
|
||||
|
||||
PAZsfx ( 1, 0.0f, m );
|
||||
|
||||
PAZidMatrix ( finst[i]->f );
|
||||
PAZtranslate ( finst[i]->f, 0, 0.5, 0, 1 );
|
||||
PAZscale ( finst[i]->f, 80, 80, 80, 1 );
|
||||
PAZtranslate ( finst[i]->f, m[3][0], m[3][1], m[3][2], 1 );
|
||||
finst[i]->enable=1;
|
||||
PAZinvert ( finst[i]->b, finst[i]->f );
|
||||
PAZwriteInstance ( finst[i] );
|
||||
|
||||
fires[i]->position[0]=m[3][0];
|
||||
fires[i]->position[1]=180.0f + m[3][1];
|
||||
fires[i]->position[2]=m[3][2];
|
||||
fires[i]->positional=light_positional;
|
||||
|
||||
fires[i]->colour[0]=0.99f;
|
||||
fires[i]->colour[1]=0.99f;
|
||||
fires[i]->colour[2]=0.99f;
|
||||
|
||||
fires[i]->min_rad=480.0f;
|
||||
fires[i]->max_rad=1200.0f;
|
||||
|
||||
PAZwriteLight ( fires[i] );
|
||||
|
||||
/*}}} */
|
||||
}
|
||||
else {
|
||||
/*{{{ step current ones*/
|
||||
for (i=0; i<2; i++ ) {
|
||||
if (finst[i]->enable) {
|
||||
fireage[i]++;
|
||||
|
||||
if (fireage[i] > 170) {
|
||||
fireage[i]=0;
|
||||
finst[i]->enable=0;
|
||||
PAZwriteInstance ( finst[i] );
|
||||
|
||||
fires[i]->positional=light_null;
|
||||
fires[i]->min_rad=0.0f;
|
||||
fires[i]->max_rad=0.01f;
|
||||
|
||||
PAZwriteLight ( fires[i] );
|
||||
}
|
||||
else {
|
||||
PAZtranslate ( finst[i]->f, 0, -0.7, 0, 1 );
|
||||
PAZwriteMatrix ( finst[i] );
|
||||
|
||||
fires[i]->position[1]-=0.7f;
|
||||
fires[i]->min_rad*=0.976;
|
||||
fires[i]->max_rad*=0.976;
|
||||
|
||||
fires[i]->colour[1]*=0.984f;
|
||||
fires[i]->colour[2]*=0.976f;
|
||||
|
||||
PAZwriteLight ( fires[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ int main ( int argc, char *argv[] )*/
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
|
||||
link_A= 1;
|
||||
link_B=-1;
|
||||
|
||||
progname=argv[0];
|
||||
|
||||
if (argc < 4) {
|
||||
printf ("usage %s: <scale> <v2zfile> <texfile>\n", argv[0] );
|
||||
exit(666);
|
||||
}
|
||||
else {
|
||||
char dplStr1 [256];
|
||||
char dplStr2 [256];
|
||||
|
||||
magicLeftVal =env2hex("LEFTMAGIC", 0x3281);
|
||||
magicRightVal=env2hex("RIGHTMAGIC", 0x3281);
|
||||
|
||||
size_from_magic ( magicLeftVal );
|
||||
|
||||
near_clip=12.8;
|
||||
far_clip =12000.0f;
|
||||
|
||||
start_dView ( makedplName ( dplStr1, "pp5mon2.btl"),
|
||||
NULL,
|
||||
makedplName ( dplStr2, "pazpl5.mng"),
|
||||
env2hex("TRANSPUTER", 0x200), 1, -1 );
|
||||
|
||||
nain ( argc, argv );
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
@@ -0,0 +1,501 @@
|
||||
|
||||
/*
|
||||
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 "dpl5.h"
|
||||
#include "boot.h"
|
||||
#include "startup.h"
|
||||
#include "camera.h"
|
||||
|
||||
char *progname;
|
||||
|
||||
int860 link_A, link_B;
|
||||
extern int860 __acks_per_frame;
|
||||
extern int magicLeftVal,
|
||||
magicRightVal;
|
||||
|
||||
/*{{{ reproducible random number support*/
|
||||
/* as always, this is CASIO calculator output */
|
||||
|
||||
static float sfx_random_numbers[67] = { 0.990f, 0.196f, 0.030f, 0.452f,
|
||||
0.165f, 0.663f, 0.737f, 0.774f,
|
||||
0.996f, 0.269f, 0.676f, 0.786f,
|
||||
0.123f, 0.474f, 0.755f, 0.919f,
|
||||
0.873f, 0.603f, 0.628f, 0.045f,
|
||||
0.089f, 0.509f, 0.413f, 0.416f,
|
||||
0.304f, 0.011f, 0.083f, 0.110f,
|
||||
0.177f, 0.602f, 0.810f, 0.181f,
|
||||
0.723f, 0.394f, 0.035f, 0.873f,
|
||||
0.678f, 0.331f, 0.407f, 0.499f,
|
||||
0.132f, 0.210f, 0.081f, 0.550f,
|
||||
0.344f, 0.894f, 0.469f, 0.307f,
|
||||
0.641f, 0.936f, 0.779f, 0.833f,
|
||||
0.373f, 0.915f, 0.972f, 0.887f,
|
||||
0.019f, 0.613f, 0.540f, 0.898f,
|
||||
0.755f, 0.689f, 0.076f, 0.173f,
|
||||
0.870f, 0.825f, 0.364f };
|
||||
|
||||
|
||||
static int sfx_random_ix = 0;
|
||||
static int sfx_random_base = 0;
|
||||
|
||||
static float float_0to1 ()
|
||||
{
|
||||
sfx_random_ix++;
|
||||
|
||||
if (sfx_random_ix >= 67)
|
||||
sfx_random_ix=0;
|
||||
|
||||
return sfx_random_numbers[sfx_random_ix];
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ void eyeStuff ( VIEW *view )*/
|
||||
void eyeStuff ( VIEW *view, int left )
|
||||
{
|
||||
float scale=1.0;
|
||||
|
||||
PAZidMatrix(view->f);
|
||||
PAZidMatrix(view->b);
|
||||
if (left) scale *= -1.0f;
|
||||
|
||||
PAZtranslatePair (view->f, view->b, scale*1.275, 0, 0 );
|
||||
PAZrotatePair (view->f, view->b, 180, PAZ_Y );
|
||||
PAZtranslatePair (view->f, view->b, 0, 0, -48 );
|
||||
|
||||
if (left == (-1)) view->shift_x=0.0;
|
||||
else if (left) view->shift_x=0.2147;
|
||||
else view->shift_x=-0.2147;
|
||||
|
||||
/* view->shift_y = 0.0f; */
|
||||
|
||||
PAZwriteView ( view );
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ void spinning_jenny ( INSTANCE *inst, VIEW *view, char *scale_str )*/
|
||||
void spinning_jenny ( INSTANCE *inst, VIEW *eye, VIEW *rye, char *scale_str, int base, int times )
|
||||
{
|
||||
float theta, scale_fac=0.1;
|
||||
int i;
|
||||
float then, now;
|
||||
|
||||
if (rye == NULL)
|
||||
eyeStuff ( eye, -1 );
|
||||
else {
|
||||
eyeStuff ( eye, 0 );
|
||||
eyeStuff ( rye, 1 );
|
||||
}
|
||||
|
||||
sscanf(scale_str, "%f", &scale_fac );
|
||||
|
||||
printf ("spinning jenny, scale factor %f\n", scale_fac );
|
||||
|
||||
for (i=base; i<times; i++) {
|
||||
int nulls=0;
|
||||
|
||||
theta = (i+40)*0.43;
|
||||
|
||||
PAZidMatrix(inst->f);
|
||||
PAZidMatrix(inst->b);
|
||||
|
||||
PAZscalePair (inst->f, inst->b, scale_fac, scale_fac, scale_fac );
|
||||
|
||||
PAZrotatePair(inst->f, inst->b, theta*2.4, PAZ_X );
|
||||
PAZrotatePair(inst->f, inst->b, theta*1.3, PAZ_Z );
|
||||
PAZrotatePair(inst->f, inst->b, theta/2.5, PAZ_Y );
|
||||
|
||||
PAZwriteInstance ( inst );
|
||||
|
||||
PAZrenderScene ();
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ 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 );
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ static OBJECT *load_flames( char *fname )*/
|
||||
static OBJECT *load_flames( char *fname )
|
||||
{
|
||||
OBJECT *flame;
|
||||
|
||||
FILE *fp=fopen(makeTexName(fname), "rb" );
|
||||
int texels[32];
|
||||
int total_texels=0, n_read;
|
||||
|
||||
|
||||
if (fp) {
|
||||
printf ("load flames\n" );
|
||||
|
||||
for (n_read = fread ( texels, 1, 32*4, fp );
|
||||
n_read;
|
||||
n_read = fread ( texels, 1, 32*4, fp )) {
|
||||
PAZfxtexels ( texels, 32 );
|
||||
total_texels+=32;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
printf ( "%d texels read\n", total_texels );
|
||||
|
||||
flame=PAZcreateObject ( makeVizName("flame.v2z"), makeTexName );
|
||||
return flame;
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ 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;
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ int nain ( int argc, char *argv[])*/
|
||||
int nain ( int argc, char *argv[])
|
||||
{
|
||||
/*{{{ local variables*/
|
||||
LIGHTSOURCE *bulb1, *bulb2;
|
||||
LIGHTSOURCE *fires[2];
|
||||
INSTANCE *finst[2];
|
||||
int fireage[2];
|
||||
int polls=0;
|
||||
|
||||
INSTANCE *inst,
|
||||
*tanks[16];
|
||||
|
||||
OBJECT *obj;
|
||||
OBJECT *flame=NULL, *tank_obj=NULL;
|
||||
MATERIAL *mtl=NULL;
|
||||
MATERIAL *temp_mtl=NULL;
|
||||
TEXTURE *tex=NULL;
|
||||
TEXTURE *tank_tex=NULL;
|
||||
SCENE *s;
|
||||
VIEW *eye, *rye;
|
||||
float scale_fac, t;
|
||||
char *objname;
|
||||
|
||||
int frames=0, made, ramp,
|
||||
blowup =0,
|
||||
blowup0=0,
|
||||
blowup1=5;
|
||||
|
||||
int i, j;
|
||||
/*}}} */
|
||||
|
||||
s = initialize_all ( 0, -1, &eye, &rye );
|
||||
|
||||
sscanf(argv[1], "%f", &scale_fac );
|
||||
|
||||
/*{{{ build flames geometry*/
|
||||
flame=load_flames ( "allovem.svt" );
|
||||
|
||||
for (i=0; i<2; i++ ) {
|
||||
finst[i]=PAZcreateInstance();
|
||||
finst[i]->obj=flame;
|
||||
|
||||
PAZidMatrix ( finst[i]->f );
|
||||
PAZtranslate ( finst[i]->f, 0, 0.5, 0, 1 );
|
||||
PAZscale ( finst[i]->f, 80, 80, 80, 1 );
|
||||
PAZtranslate ( finst[i]->f, 0, 0, -6000, 1 );
|
||||
PAZinvert ( finst[i]->b, finst[i]->f );
|
||||
finst[i]->billboard=1;
|
||||
finst[i]->enable=0;
|
||||
PAZwriteInstance ( finst[i] );
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
tank_tex=PAZcreateTexture ( makeTexName ( "tank.svt" ), 0, "tank" );
|
||||
|
||||
/*{{{ create the tanks*/
|
||||
for (i=0; i<4; i++ ) {
|
||||
for (j=0; j<4; j++ ) {
|
||||
tanks[blowup] = PAZcreateInstance ();
|
||||
if (tank_obj==NULL)
|
||||
tank_obj=PAZcreateObject ( makeVizName ("tank_dea.b2z"), makeTexName );
|
||||
|
||||
tanks[blowup]->obj=tank_obj;
|
||||
PAZidMatrix ( tanks[blowup]->f );
|
||||
PAZrotate ( tanks[blowup]->f, 36.0f * float_0to1(), 1, 1 );
|
||||
PAZtranslate ( tanks[blowup]->f, (((float) i) - 1.5f)*530.0f, -40, (j-1)*530.0f, 1 );
|
||||
PAZinvert ( tanks[blowup]->b, tanks[blowup]->f );
|
||||
|
||||
tanks[blowup]->enable=1;
|
||||
|
||||
temp_mtl=PAZcreateMaterial();
|
||||
|
||||
temp_mtl->kd[0]=0.99f;
|
||||
temp_mtl->kd[1]=0.99f;
|
||||
temp_mtl->kd[2]=0.99f;
|
||||
temp_mtl->ks=0.0f;
|
||||
temp_mtl->tex=NULL;
|
||||
|
||||
PAZwriteMaterial(temp_mtl);
|
||||
|
||||
tanks[blowup]->f_material=temp_mtl->name;
|
||||
tanks[blowup]->f_texture =tank_tex->name;
|
||||
|
||||
PAZwriteInstance ( tanks[blowup] );
|
||||
|
||||
blowup++;
|
||||
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ create the floor*/
|
||||
|
||||
inst = PAZcreateInstance ();
|
||||
obj=PAZcreateObject ( makeVizName(argv[2]), makeTexName );
|
||||
inst->obj=obj;
|
||||
|
||||
PAZidMatrixPair ( inst->f, inst->b );
|
||||
PAZscalePair ( inst->f, inst->b, scale_fac, scale_fac, scale_fac );
|
||||
PAZtranslatePair ( inst->f, inst->b, 0, -40, 0 );
|
||||
inst->enable=1;
|
||||
|
||||
PAZwriteInstance ( inst );
|
||||
/*}}} */
|
||||
/*{{{ create the lights*/
|
||||
|
||||
/* create 2 light bulbs, 1 of which ambient */
|
||||
|
||||
bulb2=PAZcreateLight ();
|
||||
PAZinitLight ( bulb2, light_ambient, 0.2, 0.2, 0.3, -0.577, 0.577, -0.577 );
|
||||
PAZwriteLight ( bulb2 );
|
||||
|
||||
bulb1=PAZcreateLight ();
|
||||
PAZinitLight ( bulb1, light_directional, 0.65, 0.65, 0.43, 1, 1, -1 );
|
||||
PAZwriteLight ( bulb1 );
|
||||
|
||||
/* create the flame light sources */
|
||||
for (i=0; i<2; i++ ) {
|
||||
fires[i]=PAZcreateLight ();
|
||||
PAZinitLight ( fires[i], light_null, 0.99, 0.55, 0.2, -10000, -10000, -10000 );
|
||||
|
||||
fires[i]->min_rad=0.0f;
|
||||
fires[i]->max_rad=0.01f;
|
||||
|
||||
PAZwriteLight ( fires[i] );
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
fireage[0]=100;
|
||||
fireage[1]=100;
|
||||
|
||||
PAZsetBackGND ( 0.2, 0.3, 0.6 );
|
||||
|
||||
blowup =0;
|
||||
blowup0=0;
|
||||
blowup1=5;
|
||||
|
||||
PAZfog ( 1, 7000.0f, 12000.0f, 0.1f, 0.2f, 0.3f );
|
||||
|
||||
PAZrenderScene();
|
||||
|
||||
while (1) {
|
||||
frames++;
|
||||
|
||||
camera_move_kbd ( eye, "tankview.spl",
|
||||
&inst->f[3][0], 1.0f, 0.0057f );
|
||||
|
||||
polls=0;
|
||||
|
||||
while (PAZpollAck() == 0) {
|
||||
polls++;
|
||||
if ((polls & 0xffff) == 0xffff)
|
||||
printf ("Waited %d times\n", polls );
|
||||
}
|
||||
if (polls==0) printf ("Polls 0 frame %d\n", frames );
|
||||
|
||||
PAZrenderScene();
|
||||
|
||||
if (frames == 100) {
|
||||
/*{{{ fire off a new explosion*/
|
||||
MATRIX m;
|
||||
|
||||
frames=0;
|
||||
i=blowup;
|
||||
blowup^=1;
|
||||
|
||||
PAZidMatrix (m);
|
||||
|
||||
if (i==0) {
|
||||
m[3][0]=tanks[blowup0]->f[3][0];
|
||||
m[3][1]=tanks[blowup0]->f[3][1];
|
||||
m[3][2]=tanks[blowup0]->f[3][2];
|
||||
blowup0++;
|
||||
blowup0&=15;
|
||||
}
|
||||
else {
|
||||
m[3][0]=tanks[blowup1]->f[3][0];
|
||||
m[3][1]=tanks[blowup1]->f[3][1];
|
||||
m[3][2]=tanks[blowup1]->f[3][2];
|
||||
blowup1++;
|
||||
blowup1&=15;
|
||||
}
|
||||
|
||||
PAZsfx ( 1, 0.0f, m );
|
||||
|
||||
PAZidMatrix ( finst[i]->f );
|
||||
PAZtranslate ( finst[i]->f, 0, 0.5, 0, 1 );
|
||||
PAZscale ( finst[i]->f, 80, 80, 80, 1 );
|
||||
PAZtranslate ( finst[i]->f, m[3][0], m[3][1], m[3][2], 1 );
|
||||
finst[i]->enable=1;
|
||||
PAZinvert ( finst[i]->b, finst[i]->f );
|
||||
PAZwriteInstance ( finst[i] );
|
||||
|
||||
fires[i]->position[0]=m[3][0];
|
||||
fires[i]->position[1]=180.0f + m[3][1];
|
||||
fires[i]->position[2]=m[3][2];
|
||||
fires[i]->positional=light_positional;
|
||||
|
||||
fires[i]->colour[0]=0.99f;
|
||||
fires[i]->colour[1]=0.99f;
|
||||
fires[i]->colour[2]=0.99f;
|
||||
|
||||
fires[i]->min_rad=480.0f;
|
||||
fires[i]->max_rad=1200.0f;
|
||||
|
||||
PAZwriteLight ( fires[i] );
|
||||
|
||||
/*}}} */
|
||||
}
|
||||
else {
|
||||
/*{{{ step current ones*/
|
||||
for (i=0; i<2; i++ ) {
|
||||
if (finst[i]->enable) {
|
||||
fireage[i]++;
|
||||
|
||||
if (fireage[i] > 170) {
|
||||
fireage[i]=0;
|
||||
finst[i]->enable=0;
|
||||
PAZwriteInstance ( finst[i] );
|
||||
|
||||
fires[i]->positional=light_null;
|
||||
fires[i]->min_rad=0.0f;
|
||||
fires[i]->max_rad=0.01f;
|
||||
|
||||
PAZwriteLight ( fires[i] );
|
||||
}
|
||||
else {
|
||||
PAZtranslate ( finst[i]->f, 0, -0.7, 0, 1 );
|
||||
PAZwriteMatrix ( finst[i] );
|
||||
|
||||
fires[i]->position[1]-=0.7f;
|
||||
fires[i]->min_rad*=0.976;
|
||||
fires[i]->max_rad*=0.976;
|
||||
|
||||
fires[i]->colour[1]*=0.984f;
|
||||
fires[i]->colour[2]*=0.976f;
|
||||
|
||||
PAZwriteLight ( fires[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ int main ( int argc, char *argv[] )*/
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
|
||||
link_A= 1;
|
||||
link_B=-1;
|
||||
|
||||
progname=argv[0];
|
||||
|
||||
if (argc < 4) {
|
||||
printf ("usage %s: <scale> <v2zfile> <texfile>\n", argv[0] );
|
||||
exit(666);
|
||||
}
|
||||
else {
|
||||
char dplStr1 [256];
|
||||
char dplStr2 [256];
|
||||
|
||||
magicLeftVal =env2hex("LEFTMAGIC", 0x3281);
|
||||
magicRightVal=env2hex("RIGHTMAGIC", 0x3281);
|
||||
|
||||
size_from_magic ( magicLeftVal );
|
||||
|
||||
near_clip=12.8;
|
||||
far_clip =12000.0f;
|
||||
|
||||
start_dView ( makedplName ( dplStr1, "pp5mon2.btl"),
|
||||
NULL,
|
||||
makedplName ( dplStr2, "pazpl5.mng"),
|
||||
env2hex("TRANSPUTER", 0x200), 1, -1 );
|
||||
|
||||
nain ( argc, argv );
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
@@ -0,0 +1,5 @@
|
||||
4
|
||||
-550 148 0 0 0 0
|
||||
-0 58 550 0 0 0
|
||||
550 228 0 0 0 0
|
||||
0 52 -550 0 0 0
|
||||
@@ -0,0 +1,406 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <dpl.h>
|
||||
#include "matrix.h"
|
||||
#include <math.h>
|
||||
|
||||
char *dpl_arg;
|
||||
|
||||
/*{{{ static dpl_node * find ( char *s, int expect )*/
|
||||
static dpl_node * find ( char *s, int expect )
|
||||
{
|
||||
dpl_node *node;
|
||||
|
||||
if (node=dpl_FindNamedNode ( s )) {
|
||||
|
||||
if (expect == 0) {
|
||||
printf ("Unexpectedly found %s, 0x%x type 0x%x\n", s, node, node->type_check );
|
||||
}
|
||||
return node;
|
||||
}
|
||||
else {
|
||||
if (expect)
|
||||
printf ("Unexpectedly couldnt find %s\n", s );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ void dpl_test_1 ( void )*/
|
||||
void dpl_test_1 ( void )
|
||||
{
|
||||
dpl_ZONE *z;
|
||||
dpl_DCS *root;
|
||||
dpl_DCS *dcs1;
|
||||
dpl_DCS *chile;
|
||||
dpl_DCS *bro;
|
||||
|
||||
int i;
|
||||
dpl_LMODEL *lm;
|
||||
dpl_LIGHT *amb;
|
||||
dpl_LIGHT *direct;
|
||||
dpl_VIEW *eye;
|
||||
dpl_VERTEX_LIST *vl;
|
||||
dpl_INSTANCE *ins;
|
||||
dpl_OBJECT *obj;
|
||||
dpl_LOD *lod;
|
||||
dpl_MATRIX m;
|
||||
dpl_MATERIAL *frig, *firstpatch;
|
||||
float32 cx, cy, cz;
|
||||
|
||||
z=dpl_NewZone();
|
||||
|
||||
root = dpl_NewDcs();
|
||||
dcs1 = dpl_NewDcs();
|
||||
chile = dpl_NewDcs();
|
||||
bro = dpl_NewDcs();
|
||||
|
||||
dpl_NestDcs ( root, dcs1 );
|
||||
dpl_NestDcs ( dcs1, chile );
|
||||
dpl_LinkDcs ( chile, bro );
|
||||
|
||||
eye = dpl_NewView();
|
||||
|
||||
dpl_SetViewClipPlanes ( eye, 30.0f, 10000.0f );
|
||||
dpl_SetViewBackGround ( eye, 0.4f, 0.6f, 0.9f );
|
||||
dpl_SetViewFog ( eye, 1, 0.5f, 0.5f, 0.6f, 5000.0f, 10000.0f );
|
||||
dpl_SetViewProjection ( eye, 832.0f, 512.0f,
|
||||
-1.0f, -1.0f, 1.0f, 1.0f,
|
||||
2.0f );
|
||||
|
||||
dpl_IdMatrix ( m );
|
||||
dpl_Rotate ( m, 180.0f, dpl_Y );
|
||||
dpl_Translate ( m, 0.0f, 0.0f, -140.0f );
|
||||
dpl_SetViewMatrix ( eye, m );
|
||||
|
||||
lm = dpl_NewLmodel();
|
||||
|
||||
amb = dpl_NewLight();
|
||||
direct= dpl_NewLight();
|
||||
|
||||
dpl_SetLightType ( amb, dpl_light_type_ambient );
|
||||
dpl_SetLightColor ( amb, 0.2f, 0.3f, 0.5f );
|
||||
|
||||
dpl_SetLightType ( direct, dpl_light_type_directional );
|
||||
dpl_SetLightColor ( direct, 0.8f, 0.8f, 0.6f );
|
||||
dpl_SetDcsLight ( root, direct );
|
||||
|
||||
dpl_SetZoneLmodel ( z, lm );
|
||||
dpl_SetZoneRootDcs ( z, root );
|
||||
|
||||
dpl_AddLightToLmodel ( lm, amb );
|
||||
dpl_AddLightToLmodel ( lm, direct );
|
||||
|
||||
dpl_AddViewToScene ( eye );
|
||||
dpl_AddZoneToScene ( z );
|
||||
dpl_SetZoneEnable ( z, 1 );
|
||||
|
||||
ins=dpl_NewInstance ();
|
||||
/*
|
||||
obj=b2zread("globo.b2z" );
|
||||
obj=b2zread("grouper.b2z");
|
||||
obj=b2zread("terr46.b2z" );
|
||||
*/
|
||||
dpl_LoadObject ( obj=dpl_NewObject(), "little" );
|
||||
|
||||
lod=dpl_GetObjectFirstLod ( obj );
|
||||
|
||||
cx=(lod->bounds[0][0]+lod->bounds[1][0]) * 0.5f;
|
||||
cy=(lod->bounds[0][1]+lod->bounds[1][1]) * 0.5f;
|
||||
cz=(lod->bounds[0][2]+lod->bounds[1][2]) * 0.5f;
|
||||
|
||||
dpl_SetDcsInstance ( chile, ins);
|
||||
dpl_SetInstanceObject ( ins, obj );
|
||||
|
||||
/* first apply a scale to parent node */
|
||||
dpl_Scale ( dcs1->matrix, 5.0f, 5.0f, 5.0f );
|
||||
dpl_Flush ( dcs1 );
|
||||
|
||||
frig =dpl_NewMaterial();
|
||||
firstpatch=((dpl_GEOGROUP *) (lod->geogroup_list.head->item))->f_material;
|
||||
|
||||
frig->texture=firstpatch->texture;
|
||||
memcpy ( frig->emissive, firstpatch->emissive, 16*sizeof(float));
|
||||
frig->ramp=firstpatch->ramp;
|
||||
frig->texture->u0=0;
|
||||
frig->texture->v0=0;
|
||||
frig->texture->dv=0;
|
||||
frig->texture->du=0.43;
|
||||
|
||||
dpl_Flush(frig);
|
||||
dpl_Flush(frig->texture);
|
||||
|
||||
dpl_SetInstanceFrontMaterial ( ins, frig );
|
||||
dpl_SetInstanceBackMaterial ( ins, frig );
|
||||
/*
|
||||
*/
|
||||
{
|
||||
float alpha=0.0f;
|
||||
float alphacycle=0;
|
||||
int angle=0, clampcycle=0;
|
||||
|
||||
while (1) {
|
||||
float f;
|
||||
dpl_MATRIX m;
|
||||
angle++;
|
||||
|
||||
f=sin(alphacycle/22.0f);
|
||||
|
||||
if (f > 0.99f) {
|
||||
f=1.0f;
|
||||
clampcycle++;
|
||||
if (clampcycle==20) {
|
||||
alphacycle+=1.0f;
|
||||
clampcycle=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
alphacycle+=1.0f;
|
||||
|
||||
alpha=0.5f + 0.505f * f;
|
||||
|
||||
if (alpha < 0.0f)
|
||||
alpha=0.0f;
|
||||
else if (alpha > 1.0f)
|
||||
alpha=1.0f;
|
||||
|
||||
dpl_SetMaterialOpacity ( frig, alpha, alpha, alpha );
|
||||
|
||||
dpl_IdMatrix ( m );
|
||||
dpl_Translate ( m, -cx, -cy, -cz );
|
||||
dpl_Rotate ( m, angle*0.30f, dpl_Y );
|
||||
dpl_Rotate ( m, angle*0.437f, dpl_X );
|
||||
dpl_Rotate ( m, angle*0.1739f, dpl_Z );
|
||||
dpl_SetDcsMatrix ( chile, m );
|
||||
|
||||
dpl_DrawScene ( 1 );
|
||||
/* printf ("draw scene frame %d\n", angle ); */
|
||||
}
|
||||
}
|
||||
|
||||
dpl_RemoveViewFromScene ( eye );
|
||||
dpl_RemoveZoneFromScene ( z );
|
||||
|
||||
dpl_RemoveLightFromLmodel ( lm, amb );
|
||||
dpl_RemoveLightFromLmodel ( lm, direct );
|
||||
|
||||
dpl_DeleteLight ( amb );
|
||||
dpl_DeleteLight ( direct );
|
||||
|
||||
dpl_SetZoneLmodel ( z, NULL );
|
||||
dpl_DeleteLmodel ( lm );
|
||||
|
||||
dpl_PruneDcs ( bro );
|
||||
dpl_PruneDcs ( chile );
|
||||
dpl_PruneDcs ( dcs1 );
|
||||
|
||||
dpl_SetZoneRootDcs ( z, NULL );
|
||||
|
||||
dpl_DeleteDcs ( bro );
|
||||
dpl_DeleteDcs ( chile );
|
||||
dpl_DeleteDcs ( dcs1 );
|
||||
|
||||
dpl_DeleteView ( eye );
|
||||
|
||||
dpl_DeleteZone ( z );
|
||||
|
||||
printf ( dpl_Status() );
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ void dpl_test_2 ( void )*/
|
||||
void dpl_test_2 ( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
return;
|
||||
|
||||
for (i=0; i<2; i++ ) {
|
||||
dpl_ZONE *z;
|
||||
dpl_DCS *root;
|
||||
dpl_DCS *dcs1;
|
||||
dpl_DCS *chile;
|
||||
dpl_DCS *bro;
|
||||
|
||||
dpl_LMODEL *lm;
|
||||
dpl_LIGHT *amb;
|
||||
dpl_LIGHT *direct;
|
||||
|
||||
z=dpl_NewZone();
|
||||
|
||||
root = dpl_NewDcs();
|
||||
dcs1 = dpl_NewDcs();
|
||||
chile = dpl_NewDcs();
|
||||
bro = dpl_NewDcs();
|
||||
|
||||
dpl_NestDcs ( root, dcs1 );
|
||||
dpl_NestDcs ( dcs1, chile );
|
||||
dpl_LinkDcs ( chile, bro );
|
||||
|
||||
lm = dpl_NewLmodel();
|
||||
|
||||
amb = dpl_NewLight();
|
||||
direct= dpl_NewLight();
|
||||
|
||||
dpl_SetLightType ( amb, dpl_light_type_ambient );
|
||||
dpl_SetLightColor ( amb, 0.2f, 0.3f, 0.5f );
|
||||
|
||||
dpl_SetLightType ( direct, dpl_light_type_directional );
|
||||
dpl_SetLightColor ( direct, 0.8f, 0.8f, 0.6f );
|
||||
|
||||
dpl_SetZoneLmodel ( z, lm );
|
||||
dpl_SetZoneRootDcs ( z, root );
|
||||
|
||||
dpl_AddLightToLmodel ( lm, amb );
|
||||
dpl_AddLightToLmodel ( lm, direct );
|
||||
|
||||
dpl_NameNode ( &z->dplnode, "zone" );
|
||||
dpl_NameNode ( &lm->dplnode, "lighting model" );
|
||||
dpl_NameNode ( &amb->dplnode, "ambient" );
|
||||
dpl_NameNode ( &direct->dplnode, "direct light" );
|
||||
dpl_NameNode ( &root->dplnode, "root" );
|
||||
dpl_NameNode ( &dcs1->dplnode, "dcs1" );
|
||||
dpl_NameNode ( &chile->dplnode, "chile" );
|
||||
dpl_NameNode ( &bro->dplnode, "bro" );
|
||||
|
||||
find ( "lighting model", 1 );
|
||||
find ( "direct light", 1 );
|
||||
find ( "zone", 1 );
|
||||
find ( "root", 1 );
|
||||
find ( "dcs1", 1 );
|
||||
find ( "chile", 1 );
|
||||
find ( "bro", 1 );
|
||||
find ( "lighting module", 0 );
|
||||
find ( "roots", 0 );
|
||||
find ( "chile voodoo", 0 );
|
||||
find ( "bros", 0 );
|
||||
|
||||
dpl_ClearNameTable();
|
||||
|
||||
find ( "zone", 0 );
|
||||
find ( "lighting model", 0 );
|
||||
find ( "lighting module", 0 );
|
||||
find ( "direct light", 0 );
|
||||
find ( "root", 0 );
|
||||
find ( "roots", 0 );
|
||||
find ( "dcs1", 0 );
|
||||
find ( "chile", 0 );
|
||||
find ( "chile voodoo", 0 );
|
||||
find ( "bro", 0 );
|
||||
find ( "bros", 0 );
|
||||
|
||||
dpl_SetZoneRootDcs ( z, NULL );
|
||||
dpl_SetZoneLmodel ( z, NULL );
|
||||
|
||||
dpl_RemoveLightFromLmodel ( lm, amb );
|
||||
dpl_RemoveLightFromLmodel ( lm, direct );
|
||||
|
||||
dpl_DeleteLmodel ( lm );
|
||||
|
||||
dpl_DeleteLight ( amb );
|
||||
dpl_DeleteLight ( direct );
|
||||
|
||||
dpl_PruneDcs ( bro );
|
||||
dpl_PruneDcs ( chile );
|
||||
dpl_PruneDcs ( dcs1 );
|
||||
|
||||
dpl_DeleteDcs ( bro );
|
||||
dpl_DeleteDcs ( chile );
|
||||
dpl_DeleteDcs ( dcs1 );
|
||||
dpl_DeleteDcs ( root );
|
||||
|
||||
dpl_DeleteZone ( z );
|
||||
|
||||
printf ( dpl_Status() );
|
||||
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ void dpl_test_3 ( void )*/
|
||||
void dpl_test_3 ( void )
|
||||
{
|
||||
dpl_OBJECT *o;
|
||||
dpl_ZONE *z;
|
||||
clock_t then, now;
|
||||
|
||||
return;
|
||||
z=dpl_NewZone();
|
||||
|
||||
then=clock();
|
||||
|
||||
/*
|
||||
o=b2zread("ball.b2z");
|
||||
o=b2zread("ballo.b2z");
|
||||
o=b2zread("glob.b2z");
|
||||
o=b2zread("glob.b2z");
|
||||
o=b2zread("glob.b2z");
|
||||
*/
|
||||
|
||||
now=clock();
|
||||
|
||||
printf ("Done, read 3 globs (1.23 MBytes) in %f secs\n",
|
||||
(float) (now-then) / 100.0f) ;
|
||||
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ void dpl_test_4 ( void )*/
|
||||
void dpl_test_4 ( void )
|
||||
{
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
|
||||
/*{{{ int main ( int argc, char **argv )*/
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
dpl_PATHITEM *gpathitem, *tpathitem;
|
||||
dpl_EXTNITEM *gextnitem, *textnitem;
|
||||
dpl_FILEPATH *gpath, *tpath;
|
||||
|
||||
dpl_arg=getenv("dplarg");
|
||||
printf ("test is go\n" );
|
||||
|
||||
dpl_SetWarningLevel(0);
|
||||
dpl_Init ( dpl_arg );
|
||||
|
||||
gpath =dpl_NewFilePath();
|
||||
gpathitem=dpl_NewPathItem();
|
||||
gextnitem=dpl_NewExtnItem();
|
||||
|
||||
tpath =dpl_NewFilePath();
|
||||
tpathitem=dpl_NewPathItem();
|
||||
textnitem=dpl_NewExtnItem();
|
||||
|
||||
dpl_SetPathItemPath ( gpathitem, "..\\geometry" );
|
||||
dpl_SetExtnItemExtn ( gextnitem, "b2z" );
|
||||
|
||||
dpl_SetPathItemPath ( tpathitem, "..\\texture" );
|
||||
dpl_SetExtnItemExtn ( textnitem, "svt" );
|
||||
|
||||
dpl_AddPathToFilepath ( gpath, gpathitem );
|
||||
dpl_AddExtToFilepath ( gpath, gextnitem );
|
||||
|
||||
dpl_AddPathToFilepath ( tpath, tpathitem );
|
||||
dpl_AddExtToFilepath ( tpath, textnitem );
|
||||
|
||||
dpl_SetGeometryFilePath ( gpath );
|
||||
dpl_SetTextureFilePath ( tpath );
|
||||
|
||||
printf ("dpl_test_1\n" );
|
||||
dpl_test_1();
|
||||
return 0;
|
||||
|
||||
printf ("dpl_test_2\n" );
|
||||
dpl_test_2();
|
||||
|
||||
printf ("dpl_test_3\n" );
|
||||
dpl_test_3();
|
||||
|
||||
|
||||
printf ("dpl_test_4\n" );
|
||||
dpl_test_4();
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*}}} */
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,573 @@
|
||||
/*
|
||||
FILE : testf15.c
|
||||
PROJECT : pxpl5 renderer example - F15 squadron
|
||||
Author : Phil Atkin
|
||||
|
||||
|
||||
(C) Division Ltd 1994.
|
||||
|
||||
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include "dpl5.h"
|
||||
#include "boot.h"
|
||||
#include "startup.h"
|
||||
#include "spline.h"
|
||||
#include "camera.h"
|
||||
|
||||
char *progname;
|
||||
|
||||
int860 link_A, link_B;
|
||||
extern int magicLeftVal,
|
||||
magicRightVal;
|
||||
/*{{{ void eyeStuff ( VIEW *view )*/
|
||||
void eyeStuff ( VIEW *view, int left )
|
||||
{
|
||||
float scale=1.0;
|
||||
|
||||
PAZidMatrix(view->f);
|
||||
PAZidMatrix(view->b);
|
||||
if (left) scale *= -1.0f;
|
||||
|
||||
if (left != (-1))
|
||||
PAZtranslatePair (view->f, view->b, scale*1.275, 0, 0 );
|
||||
PAZrotatePair (view->f, view->b, 180, PAZ_Y );
|
||||
PAZtranslatePair (view->f, view->b, 0, 0, -102 );
|
||||
|
||||
if (left == (-1)) view->shift_x=0.0;
|
||||
else if (left) view->shift_x=0.2147;
|
||||
else view->shift_x=-0.2147;
|
||||
|
||||
/* view->shift_y = 0.0f; */
|
||||
|
||||
PAZwriteView ( view );
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
#define MAX_PLANES 5
|
||||
|
||||
static int planes_inited=0;
|
||||
static int camera_inited=0;
|
||||
cntl_point *splinehead=NULL;
|
||||
static float flight_t;
|
||||
static MATRIX flight_m;
|
||||
|
||||
typedef struct s_plane {
|
||||
cntl_point *cntl;
|
||||
float t;
|
||||
MATRIX orig;
|
||||
} plane_cntl_type;
|
||||
|
||||
plane_cntl_type plane_cntl[16];
|
||||
|
||||
static void check_matrix ( MATRIX m, char *s )
|
||||
{
|
||||
MATRIX tmp;
|
||||
MATRIX res;
|
||||
float hyp;
|
||||
int i, j;
|
||||
|
||||
PAZinvert ( tmp, m );
|
||||
PAZconcat ( res, m, tmp, 1 );
|
||||
|
||||
for (i=0; i<4; i++ ) {
|
||||
for (j=0; j<4; j++ ) {
|
||||
float t=res[i][j];
|
||||
hyp+=t*t;
|
||||
}
|
||||
}
|
||||
|
||||
if ((hyp < 3.99f) || (hyp > 4.01f)) {
|
||||
printf("MATRIX %s >>>>>\n", s );
|
||||
printf ( " [ %3.3f, %3.3f, %3.3f, %3.3f ]\n", m[0][0], m[0][1], m[0][2], m[0][3] );
|
||||
printf ( " [ %3.3f, %3.3f, %3.3f, %3.3f ]\n", m[1][0], m[1][1], m[1][2], m[1][3] );
|
||||
printf ( " [ %3.3f, %3.3f, %3.3f, %3.3f ]\n", m[2][0], m[2][1], m[2][2], m[2][3] );
|
||||
printf ( " [ %3.3f, %3.3f, %3.3f, %3.3f ]\n", m[3][0], m[3][1], m[3][2], m[3][3] );
|
||||
printf("concat with inverse %s >>>>>\n", s );
|
||||
printf ( " [ %3.3f, %3.3f, %3.3f, %3.3f ]\n", res[0][0], res[0][1], res[0][2], res[0][3] );
|
||||
printf ( " [ %3.3f, %3.3f, %3.3f, %3.3f ]\n", res[1][0], res[1][1], res[1][2], res[1][3] );
|
||||
printf ( " [ %3.3f, %3.3f, %3.3f, %3.3f ]\n", res[2][0], res[2][1], res[2][2], res[2][3] );
|
||||
printf ( " [ %3.3f, %3.3f, %3.3f, %3.3f ]\n", res[3][0], res[3][1], res[3][2], res[3][3] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static float atan2deg ( float dz, float dx )
|
||||
{
|
||||
float angle;
|
||||
if ((dx*dx) < 0.0001f) {
|
||||
angle=(dz>0) ? 90.0f : -90.0f;
|
||||
return angle;
|
||||
}
|
||||
else {
|
||||
return (180.0f / 3.1415926535f) * atan2 ( dz, dx );
|
||||
/*
|
||||
if (dx>0)
|
||||
return angle;
|
||||
else
|
||||
return 180.0f + angle;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
static void xformpoint ( POINT q, POINT p, MATRIX m )
|
||||
{
|
||||
POINT r;
|
||||
int i;
|
||||
|
||||
for (i=0; i<4; i++ ) {
|
||||
r[i]=(p[0]*m[0][i])+
|
||||
(p[1]*m[1][i])+
|
||||
(p[2]*m[2][i])+
|
||||
(p[3]*m[3][i]);
|
||||
}
|
||||
memcpy ( q, r, sizeof(POINT));
|
||||
}
|
||||
|
||||
void look_at ( VIEW *v, float *from, float *at, float z_spin )
|
||||
{
|
||||
/* construct a view from 2 points */
|
||||
float dx, dy, dz;
|
||||
float px, py, pz;
|
||||
float thetax, thetay, thetaz;
|
||||
float yaw, roll;
|
||||
MATRIX m;
|
||||
POINT p, q;
|
||||
|
||||
/* put 'at' at origin, construct a vector from 'from' */
|
||||
px=from[0]; py=from[1]; pz=from[2];
|
||||
|
||||
dx=at[0]-px;
|
||||
dy=at[1]-py;
|
||||
dz=at[2]-pz;
|
||||
|
||||
thetaz=0.0f;
|
||||
thetay=0.0f;
|
||||
thetax=0.0f;
|
||||
|
||||
p[0]=dx;
|
||||
p[1]=dy;
|
||||
p[2]=dz;
|
||||
p[3]=1;
|
||||
|
||||
yaw=-atan2deg ( dz, dx );
|
||||
PAZidMatrix ( m );
|
||||
PAZrotate ( m, -yaw, PAZ_Y, 1 );
|
||||
xformpoint ( q, p, m );
|
||||
|
||||
roll=atan2deg(q[1], q[0] );
|
||||
|
||||
/* project onto x-z plane, assuming camera is initially looking down -z */
|
||||
PAZidMatrix ( v->f );
|
||||
|
||||
/* apply angles to matrix */
|
||||
|
||||
PAZrotate ( v->f, z_spin, PAZ_Z, 1 );
|
||||
PAZrotate ( v->f, roll, PAZ_X, 1 );
|
||||
PAZrotate ( v->f, yaw-90.0f, PAZ_Y, 1 );
|
||||
|
||||
PAZtranslate( v->f, px, py, pz, 1 );
|
||||
|
||||
}
|
||||
|
||||
float evalx, evaly, evalz;
|
||||
float tx, ty, tz, theta=0, dtheta=0, flight_r;
|
||||
static float camera_t=0.0f;
|
||||
static cntl_point *camerahead=NULL;
|
||||
|
||||
|
||||
void cameradicking ( VIEW *eye,
|
||||
INSTANCE *look_at_me,
|
||||
float scale_fac,
|
||||
float dt )
|
||||
{
|
||||
cntl_point *p=camerahead;
|
||||
float t=camera_t;
|
||||
float px, py, pz, rx, ry, rz;
|
||||
POINT evalp;
|
||||
|
||||
if (camera_inited == 0) {
|
||||
camera_inited=1;
|
||||
p=init_splines("camera.spl");
|
||||
t=0;
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
camerahead=walk_spline ( p, &t, dt );
|
||||
camera_t=t;
|
||||
|
||||
/* we have wobbled the spline according to the file - now build the
|
||||
view matrix */
|
||||
|
||||
eye->f[3][0]=px+look_at_me->f[3][0];
|
||||
eye->f[3][1]=py+look_at_me->f[3][1];
|
||||
eye->f[3][2]=pz+look_at_me->f[3][2];
|
||||
|
||||
evalp[0]=evalx;
|
||||
evalp[1]=evaly;
|
||||
evalp[2]=evalz;
|
||||
|
||||
/*
|
||||
look_at ( eye, &eye->f[3][0], &look_at_me->f[3][0], rz );
|
||||
*/
|
||||
look_at ( eye, &eye->f[3][0], evalp, rz );
|
||||
PAZwriteViewMatrix ( eye );
|
||||
/* check_matrix ( eye->f, "view" ); */
|
||||
}
|
||||
|
||||
void planedicking ( INSTANCE *inst, int planeId,
|
||||
float scale, float dt, float dplane )
|
||||
{
|
||||
float px, py, pz, rx, ry, rz;
|
||||
cntl_point *p;
|
||||
float t;
|
||||
int i;
|
||||
MATRIX camera_target;
|
||||
|
||||
|
||||
if (planes_inited == 0) {
|
||||
planes_inited=1;
|
||||
splinehead=init_splines("planes.spl");
|
||||
|
||||
for (i=1; i<MAX_PLANES; i++) {
|
||||
float angle;
|
||||
float fi=(float) i;
|
||||
|
||||
angle=fi * (3.1415926f * 2.0f) / (MAX_PLANES-1);
|
||||
|
||||
plane_cntl[i].cntl=splinehead;
|
||||
plane_cntl[i].t=fi * dplane;
|
||||
|
||||
PAZidMatrix ( plane_cntl[i].orig );
|
||||
PAZtranslate ( plane_cntl[i].orig,
|
||||
10.3f*cos(angle), 0, 11.7f*sin(angle), 1 );
|
||||
}
|
||||
PAZidMatrix ( plane_cntl[0].orig );
|
||||
|
||||
plane_cntl[0].cntl=splinehead;
|
||||
plane_cntl[0].t=dplane;
|
||||
}
|
||||
|
||||
p=plane_cntl[planeId].cntl;
|
||||
t=plane_cntl[planeId].t;
|
||||
|
||||
PAZidMatrix ( inst->f );
|
||||
|
||||
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 );
|
||||
|
||||
|
||||
plane_cntl[planeId].cntl=walk_spline ( p, &plane_cntl[planeId].t, dt );
|
||||
|
||||
PAZscale ( inst->f, scale, scale, scale, 1 );
|
||||
if (planeId == 0) {
|
||||
PAZidMatrix ( camera_target );
|
||||
PAZscale ( camera_target, scale, scale, scale, 1 );
|
||||
}
|
||||
/* the above scale should have brought us up to 1.0 ish in plane space */
|
||||
/* now apply the spline */
|
||||
|
||||
PAZtranslate ( inst->f, px, py, pz, 1 );
|
||||
PAZrotate ( inst->f, rz, PAZ_Z, 1 );
|
||||
PAZrotate ( inst->f, rx, PAZ_X, 1 );
|
||||
PAZrotate ( inst->f, ry, PAZ_Y, 1 );
|
||||
PAZconcat ( inst->f, inst->f, plane_cntl[planeId].orig, 1 );
|
||||
|
||||
|
||||
if (planeId==0) {
|
||||
float rad=theta*3.1415926535f/180.0f;
|
||||
|
||||
theta+=dtheta;
|
||||
tx=flight_r*cos(rad);
|
||||
tz=flight_r*sin(rad);
|
||||
}
|
||||
|
||||
PAZrotate ( inst->f, 180.0f-theta, PAZ_Y, 1 );
|
||||
PAZtranslate ( inst->f, tx, 0, tz, 1 );
|
||||
PAZscale ( inst->f, 6, 6, 6, 1 );
|
||||
|
||||
if (planeId == 0) {
|
||||
PAZconcat ( camera_target, camera_target, plane_cntl[planeId].orig, 1 );
|
||||
PAZrotate ( camera_target, 180.0f-theta, PAZ_Y, 1 );
|
||||
PAZtranslate ( camera_target, tx, 0, tz, 1 );
|
||||
PAZscale ( camera_target, 6, 6, 6, 1 );
|
||||
evalx=camera_target[3][0];
|
||||
evaly=camera_target[3][1];
|
||||
evalz=camera_target[3][2];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void squadron_antics ( INSTANCE **planes, VIEW *eye, VIEW *rye, float scale_fac, int base, int times )
|
||||
{
|
||||
float theta;
|
||||
int i, j;
|
||||
float then, now;
|
||||
|
||||
if (rye == NULL)
|
||||
eyeStuff ( eye, -1 );
|
||||
else {
|
||||
eyeStuff ( eye, 0 );
|
||||
eyeStuff ( rye, 1 );
|
||||
}
|
||||
|
||||
|
||||
flight_r=26000;
|
||||
dtheta=0.13;
|
||||
|
||||
for (i=base; i<times; i++) {
|
||||
int nulls=0;
|
||||
|
||||
for (j=0; j<MAX_PLANES; j++) {
|
||||
planedicking ( planes[j], j,
|
||||
scale_fac, (j/392.0f)+0.034f, (j/283.0f)+0.007f );
|
||||
PAZwriteMatrix ( planes[j] );
|
||||
}
|
||||
cameradicking(eye, planes[0], scale_fac, 0.02f );
|
||||
PAZrenderScene();
|
||||
}
|
||||
}
|
||||
|
||||
/*{{{ 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 ( vizStr, root );
|
||||
strcat ( vizStr, name );
|
||||
if (strchr(vizStr, '.')==NULL) {
|
||||
strcat(vizStr, ".svt");
|
||||
}
|
||||
return ( vizStr );
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ 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;
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ static OBJECT *load_flames( char *fname )*/
|
||||
static OBJECT *load_flames( char *fname )
|
||||
{
|
||||
OBJECT *flame;
|
||||
|
||||
FILE *fp=fopen(makeTexName(fname), "rb" );
|
||||
int texels[32];
|
||||
int total_texels=0, n_read;
|
||||
|
||||
|
||||
if (fp) {
|
||||
printf ("load flames\n" );
|
||||
|
||||
for (n_read=fread ( texels, 1, 32*4, fp ); n_read; n_read=fread(texels,1,32*4,fp )) {
|
||||
PAZfxtexels ( texels, 32 );
|
||||
total_texels+=32;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
printf ( "%d texels read\n", total_texels );
|
||||
|
||||
flame=PAZcreateObject ( makeVizName("flame.v2z"), makeTexName );
|
||||
return flame;
|
||||
}
|
||||
/*}}} */
|
||||
/*{{{ int nain ( int argc, char *argv[])*/
|
||||
int nain ( int argc, char *argv[])
|
||||
{
|
||||
LIGHTSOURCE *bulb1, *bulb2, *bulb3, *bulb4, *bulb5, *bulb6;
|
||||
INSTANCE *planes[MAX_PLANES];
|
||||
INSTANCE *groundinst[25];
|
||||
OBJECT *obj;
|
||||
OBJECT *groundobj[25];
|
||||
SCENE *s;
|
||||
VIEW *eye, *rye;
|
||||
OBJECT *F15, *F16, *flames;
|
||||
float t, scale_fac=0.1;
|
||||
char *objname;
|
||||
int g, i, j, made, ramp;
|
||||
|
||||
|
||||
s = initialize_all ( 0, -1, &eye, &rye );
|
||||
|
||||
sscanf(argv[1], "%f", &scale_fac );
|
||||
|
||||
PAZfog ( 1, 15000.0f, 26244.0f, 0.4, 0.5, 0.6 );
|
||||
flames=load_flames("allovem.svt");
|
||||
|
||||
printf ("Making hills\n" );
|
||||
g=0;
|
||||
for (i=0; i<5; i++) {
|
||||
for (j=0; j<5; j++) {
|
||||
INSTANCE *terrinst;
|
||||
OBJECT *terrobj;
|
||||
|
||||
char hilly[256];
|
||||
sprintf(hilly, "terr%1d%1d.b2z", i*2, j*2 );
|
||||
|
||||
terrobj=PAZcreateObject(makeVizName(hilly), makeTexName);
|
||||
terrinst=PAZcreateInstance();
|
||||
terrinst->enable=1;
|
||||
terrinst->obj=terrobj;
|
||||
PAZwriteInstance ( terrinst );
|
||||
|
||||
PAZscale ( terrinst->f,
|
||||
10*scale_fac, 0.41*scale_fac, 10*scale_fac, 1 );
|
||||
PAZtranslate ( terrinst->f, 10.0, -14*scale_fac, 10.0, 1 );
|
||||
PAZwriteMatrix ( terrinst );
|
||||
groundobj[g]=terrobj;
|
||||
groundinst[g]=terrinst;
|
||||
g++;
|
||||
}
|
||||
}
|
||||
printf ("Made hills\n" );
|
||||
printf ("Making sky\n" );
|
||||
{
|
||||
OBJECT *skyobj;
|
||||
INSTANCE *skyinst;
|
||||
|
||||
skyobj=PAZcreateObject(makeVizName("mtl_frig.v2z"), makeTexName);
|
||||
skyinst=PAZcreateInstance();
|
||||
skyinst->obj=skyobj;
|
||||
skyinst->enable=1;
|
||||
PAZscalePair ( skyinst->f, skyinst->b,
|
||||
50*scale_fac, 50*scale_fac, 50*scale_fac );
|
||||
PAZtranslatePair ( skyinst->f, skyinst->b, 0, 8*scale_fac, 0 );
|
||||
PAZwriteInstance ( skyinst );
|
||||
}
|
||||
|
||||
F15=PAZcreateObject ( makeVizName("F15.v2z"), makeTexName );
|
||||
F16=PAZcreateObject ( makeVizName("F16.v2z"), makeTexName );
|
||||
|
||||
for (i=0; i< MAX_PLANES; i++) {
|
||||
INSTANCE *p=(planes[i]=PAZcreateInstance());
|
||||
if ((i&1) ==0)
|
||||
p->obj=F15;
|
||||
else
|
||||
p->obj=F16;
|
||||
p->enable=1;
|
||||
PAZidMatrixPair ( p->f, p->b );
|
||||
PAZwriteInstance ( p );
|
||||
}
|
||||
|
||||
/* create 3 light bulbs */
|
||||
|
||||
bulb1=PAZcreateLight ();
|
||||
PAZinitLight ( bulb1, light_directional, 0.99, 0.99, 0.79, 0, 1, 0 );
|
||||
PAZwriteLight ( bulb1 );
|
||||
|
||||
|
||||
bulb2=PAZcreateLight ();
|
||||
PAZinitLight ( bulb2, light_ambient, 0.2, 0.3, 0.4, 0, 0, 0 );
|
||||
PAZwriteLight ( bulb2 );
|
||||
|
||||
PAZsetBackGND ( 0.2, 0.3, 0.6 );
|
||||
|
||||
while (1) {
|
||||
squadron_antics ( planes, eye, rye, scale_fac, 0, 1000 );
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
|
||||
/*{{{ int main ( int argc, char *argv[] )*/
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
link_A= 1;
|
||||
link_B=-1;
|
||||
|
||||
progname=argv[0];
|
||||
|
||||
if (argc < 3) {
|
||||
printf ("usage %s: <scale> <v2zfile>\n", argv[0] );
|
||||
exit(666);
|
||||
}
|
||||
else {
|
||||
char dplStr1 [256];
|
||||
char dplStr2 [256];
|
||||
|
||||
magicLeftVal =env2hex("LEFTMAGIC", 0x3201);
|
||||
magicRightVal=env2hex("RIGHTMAGIC", 0x3201);
|
||||
|
||||
near_clip=25.6/2;
|
||||
far_clip =52428.8/2;
|
||||
|
||||
size_from_magic ( magicLeftVal );
|
||||
|
||||
start_dView ( makedplName ( dplStr1, "pp5mon2.btl"),
|
||||
NULL,
|
||||
makedplName ( dplStr2, "pazpl5.mng"),
|
||||
env2hex("TRANSPUTER", 0x150), 1, -1 );
|
||||
|
||||
nain ( argc, argv );
|
||||
}
|
||||
}
|
||||
/*}}} */
|
||||
@@ -0,0 +1 @@
|
||||
set DPLARG=/tranny~..\vrendmon.btl~/i860~..\vrend.mng~/link_A~3~/link_B~-1~/device~0x150~/video~svga~/n_860s~1
|
||||
@@ -0,0 +1,6 @@
|
||||
FOG 900.0 12000.0 0.1 0.3 0.2
|
||||
BACKGND 0.4 0.6 0.8
|
||||
AMBIENT 0.3 0.6 0.4
|
||||
LIGHT 0.99 0.82 0.99 30 50 40
|
||||
STATIC ocean 20.0 0 -190 0 0 0 0
|
||||
STATIC little 20.0 0.0 0.0 0.0 0 20 0
|
||||
Reference in New Issue
Block a user