home *** CD-ROM | disk | FTP | other *** search
- /***********************************************************/
- /* */
- /* Amiga C Manual (ACM) V3.0 Amiga C Club (ACC) */
- /* ------------------------- ------------------ */
- /* */
- /* Chapter: 3D Amiga C Club */
- /* File: 3D.h Tulevagen 22 */
- /* Author: Mats & Anders Bjerin 181 41 LIDINGO */
- /* Date: 92-04-02 SWEDEN */
- /* Version: 1.00 */
- /* */
- /* Copyright 1992, Anders Bjerin - Amiga C Club (ACC) */
- /* */
- /* Registered members may use this program freely in their */
- /* own commercial/noncommercial programs/articles. */
- /* */
- /***********************************************************/
-
-
- #include <exec/types.h>
-
-
- /* Factor to multiply with to reach specfloat format. */
- /* This gives 5 decimal places and an integer part */
- /* of 16 bits i.e. numbers between -32768 and 32767. */
- #define FFACTOR 65536L
-
-
- /* No steps to shift a number to make it into specfloat format. */
- /* Must remain 16 for function LongFloatMultiply() to work. */
- #define FSHIFT 16
-
-
- /* A very small value used when something almost zero. */
- #define EPSILON 4
-
-
- /* So we do not have to calculate this: */
- #define HALF_PI 1.57080 /* 0.5 * PI */
- #define ONE_AND_A_HALF_PI 4.71239 /* 1.5 * PI */
-
- /* Number of index positions in the plane data from TOTAL_NUMBER_OF_VECTORS */
- /* that the x-axis is found. */
- #define XAXISPOS 3
-
- /* Number of index positions in the plane data from TOTAL_NUMBER_OF_VECTORS */
- /* that the y-axis is found. */
- #define YAXISPOS 2
-
- /* Number of index positions in the plane data from TOTAL_NUMBER_OF_VECTORS */
- /* that the z-axis is found. */
- #define ZAXISPOS 1
-
- /* Number of index positions in the plane data from TOTAL_NUMBER_OF_VECTORS */
- /* that the 0-point (rotation) is found. */
- #define ZEROPOINTPOS 4
-
-
-
- /* Typedeclarations. */
- struct Coord3D
- {
- long x;
- long y;
- long z;
- };
-
- /* Useful macros to convert between radians (0-2PI) */
- /* and ordinary degrees (0-360): */
- #define DEG2RAD(d) ((d)/180*PI)
- #define RAD2DEG(r) ((r)*180/PI)
-
-
-
-
- /*********************************************/
- /* Declare all functions in the main module: */
- /*********************************************/
-
- void draw_vectors
- (
- struct RastPort *rp,
- struct Coord3D data[],
- WORD colour
- );
-
- void Play( void );
-
- void main();
-
- void clean_up( STRPTR message );
-
-
-
-
- /*******************************************/
- /* Declare all functions in the 3D module: */
- /*******************************************/
-
- long LongFloatMultiply( long x, long y );
-
- long Dot3DProduct( struct Coord3D point1, struct Coord3D point2 );
-
- void VectorProduct
- (
- struct Coord3D a,
- struct Coord3D b,
- struct Coord3D *v
- );
-
- int SurfaceDirection
- (
- struct Coord3D point1,
- struct Coord3D point2,
- struct Coord3D point3,
- struct Coord3D e
- );
-
- float Angle
- (
- long x,
- long y
- );
-
- void Calc3DTranslation
- (
- long tx,
- long ty,
- long tz,
- long a[][4]
- );
-
- void Calc3DRot
- (
- int m,
- float fan,
- long a[][4]
- );
-
- void Calc3DMult
- (
- long a[][4],
- long b[][4],
- long c[][4]
- );
-
- void Generat3DRotation
- (
- float an,
- struct Coord3D b,
- struct Coord3D d,
- long a[][4]
- );
-
- void Transform
- (
- struct Coord3D v,
- long a[][4],
- struct Coord3D *w
- );
-
- void CalcObserverPosition
- (
- struct Coord3D eye,
- struct Coord3D direction,
- long q[][4]
- );
-
- void ProjectInPerspective
- (
- struct Coord3D v,
- struct Coord3D *w,
- int half_display_width,
- int half_display_height
- );
-
- void CalcDirection
- (
- struct Coord3D b1,
- struct Coord3D b2,
- struct Coord3D *d
- );
-
- void InitializeGlobalData( void );
-
- void Prepare3DData
- (
- int total_nr_vectors,
- int zero_point_pos
- );
-
- void Startup3D
- (
- int total_nr_vectors,
- int zero_point_pos
- );
-