flt14_1.h 23.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014
/*********************************************************************

	PROPRIETARY RIGHTS NOTICE: All rights reserved. This program
	contains proprietary information and trade secrets of Software
	Systems of San Jose, CA., and emodies substantial creative
	efforts and confidential information, ideas, and expressions.
	No part of this program may be reproduced in any form, or by
	any means electronic, mechanical, or otherwise, without the
	written permission of Software Systems.

	COPYRIGHT NOTICE: Copyright (C) 1986 to 1994, Software Systems,
	1884 The Alameda, San Jose, CA 95126.

**********************************************************************/

/*
 * Copyright (c) 1992 Silicon Graphics, Inc.
 *
 * Permission to use, copy, modify, distribute, and sell this software
 * and its documentation for any purpose is hereby granted without
 * fee, provided that (i) the above copyright notices and this
 * permission notice appear in all copies of the software and related
 * documentation, and (ii) the name of Silicon Graphics may not be
 * used in any advertising or publicity relating to the software
 * without the specific, prior written permission of Silicon Graphics.
 * 
 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
 * 
 * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL,
 * INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY
 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY
 * THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE
 * OR PERFORMANCE OF THIS SOFTWARE.
 * 
 */

/*
 * pfflt.h $Revision: 1.1.1.1 $
 */

#ifndef __MGPFFLT_H__
#define __MGPFFLT_H__

#ifdef __cplusplus
extern "C" {
#endif


/* Floating point epsilon comparisons */
#define MGFEPS	(1e-7)

#define FEPS_EQUAL2(v0, v1)						\
       ((v0)[0] >= (v1)[0] - MGFEPS && (v0)[0] <= (v1)[0] + MGFEPS &&	\
        (v0)[1] >= (v1)[1] - MGFEPS && (v0)[1] <= (v1)[1] + MGFEPS)

#define FEPS_EQUAL3(v0, v1)						\
      ((v0)[0] >= (v1)[0] - MGFEPS && (v0)[0] <= (v1)[0] + MGFEPS &&	\
       (v0)[1] >= (v1)[1] - MGFEPS && (v0)[1] <= (v1)[1] + MGFEPS &&	\
       (v0)[2] >= (v1)[2] - MGFEPS && (v0)[2] <= (v1)[2] + MGFEPS)

#define FEPS_EQUAL4(v0, v1)						\
      ((v0)[0] >= (v1)[0] - MGFEPS && (v0)[0] <= (v1)[0] + MGFEPS &&	\
       (v0)[1] >= (v1)[1] - MGFEPS && (v0)[1] <= (v1)[1] + MGFEPS &&	\
       (v0)[2] >= (v1)[2] - MGFEPS && (v0)[2] <= (v1)[2] + MGFEPS &&	\
       (v0)[3] >= (v1)[3] - MGFEPS && (v0)[3] <= (v1)[3] + MGFEPS)
    
#define FTOL_EQUAL3(v0, v1, tol)						\
      ((v0)[0] >= (v1)[0] - tol && (v0)[0] <= (v1)[0] + tol &&	\
       (v0)[1] >= (v1)[1] - tol && (v0)[1] <= (v1)[1] + tol &&	\
       (v0)[2] >= (v1)[2] - tol && (v0)[2] <= (v1)[2] + tol)

#define MG_MAX_TEXTURES		4096
#define LISTSIZE	2048
#define MAXBLEND	128
#define MAXBCOLORS	128

/*
 *  multigen opcodes
 */
#define MG_HEADER		1
#define MG_GROUP		2
#define MG_LOD			3
#define MG_OBJECT		4
#define MG_POLYGON		5
#define MG_VERT_ABS		7
#define MG_VERT_SHAD		8
#define MG_VERT_NORM		9
#define MG_PUSH			10
#define MG_POP			11
#define MG_DOF			13
#define MG_DOFFLOAT		14
#define MG_PUSH_SF		19
#define MG_POP_SF		20
#define MG_COMMENT		31
#define MG_COLOR_TABLE		32
#define MG_LONGID		33

/* opcodes 40-48 are other transformation record types */
#define MG_MATRIX		49
#define MG_VECTOR		50
#define MG_BBOX			51
#define MG_REPLICATE		60
#define MG_INSTANCE_REF		61
#define MG_INSTANCE_DEF		62
#define MG_EXTERNAL_REF		63
#define MG_TEXTURE_REF		64
#define MG_EYEPOINTS		65
#define MG_MATERIAL_TABLE	66
#define MG_VTXTABLE		67	
#define MG_DVERT_ABS		68	
#define MG_DVERT_NORM		69	
#define MG_DVERT_NORM_TEX	70	
#define MG_DVERT_ABS_TEX	71	
#define MG_VTXLIST		72
#define MG_LODFLOAT		73
#define MG_BOXFLOAT		74

// Texture defines
// Minification filters
#define TX_POINT		0
#define TX_BILINEAR		1
#define TX_MIPMAP		2
#define TX_MIPMAP_POINT		3
#define TX_MIPMAP_LINEAR	4
#define TX_MIPMAP_BILINEAR	5
#define TX_MIPMAP_TRILINEAR	6

// Magnification filters
#define TX_POINT		0
#define TX_BILINEAR		1

#define TX_PACK_8		1
#define TX_PACK_16		2

#define TX_REPEAT		0
#define TX_CLAMP		1

/* opcodes 76-82 are other transformation record types */
#define MG_DEYEPOINTS		83

/* opcodes for road record types */
#define MG_ROAD			87
#define MG_ZONE_REF		88

/* opcode for sub vertex record type */
#define MG_VTXLISTS		89

/* opcode for linkage record type */
#define MG_LINK			90

/* opcode for sound record type */
#define MG_SOUND		91

/* opcode for road record type */
#define MG_PATH			92

/* opcode for sound record type */
#define MG_SOUNDS		93

/* opcode 94 is transformation record type */

/* opcode for switch record type */
#define MG_SWITCH		96

/* last opcode defined in opcodeNames[] */
#define MG_OPCODENAMES_MAX	97

#define MG_DVERT_SHAD		200	/* performer use only */
#define MG_DVERT_SHAD_TEX	201	/* performer use only */


#define MG_IMPOSSIBLE		-100000000

#define MG_VERT_TEX		0x1000

/* Conversion macros */
#define MG_COORD2VEC3(v, mgv)		\
    (v)[0] = (float)mgv[0];    		\
    (v)[1] = (float)mgv[1];   		\
    (v)[2] = (float)mgv[2]

/* color */
#define MG_CONVCOLOR(c,color)			\
    (c)[0] = CurMgFile->colorTable[color][0];	\
    (c)[1] = CurMgFile->colorTable[color][1];	\
    (c)[2] = CurMgFile->colorTable[color][2]

/* monochrome */
/*
#define MG_CONVCOLOR(c,color) \
    do  \
    { \
	float r = CurMgFile->colorTable[color][0]; \
	float g = CurMgFile->colorTable[color][1]; \
	float b = CurMgFile->colorTable[color][2]; \
	float y = 0.30*r + 0.59*g + 0.11*b; \
	(c)[0] = y; \
	(c)[1] = y; \
	(c)[2] = y; \
    } while (0)
*/

#define MG_CONVCOORD(v,mgv)			\
    (v)[0] = mgv[0] * CurMgFile->vertMult;	\
    (v)[1] = mgv[1] * CurMgFile->vertMult;	\
    (v)[2] = mgv[2] * CurMgFile->vertMult

#define NORMMULT    (1./(1<<30))
#define MG_CONVNORM(n,mgn)			\
    (n)[0] = mgn[0] * NORMMULT;		\
    (n)[1] = mgn[1] * NORMMULT;		\
    (n)[2] = mgn[2] * NORMMULT

/*
 *  on disk object structures
 */

/* MPG */
typedef unsigned short ushort;

typedef struct {
    short	opcode;
    ushort	length;
} mgBead;


typedef struct {
    short	opcode;	/* 1 */
    ushort	length;
    char	id[8];
    long	frev;
    long	dbrev;
    char	revDate[32];
    short	nextGroupId;
    short	nextLodId;
    short	nextObjId;
    short	nextPolyId;
    short	unitMulDiv;
    char	unitType;
    char	texWhite;		
    long	flags;
    long	SWLat;
    long	SWLong;
    long	NELat;
    long	NELong;
    long	latOrig;
    long	longOrig;
    long	projType;
    long	oswIfmt[2];
    long	oterTrans[2];
    long	upperLat;		
    long	lowerLat;		
    long	nlHash;			
    short	nextDofId;		
    short	vtxFormat;	
    long	dblOrig;
    double	swIfmt[2];
    double	terTrans[2];
    /*
     * These fields are new in OpenFlight R14.0 (frev == 14)
     */
    unsigned short soundId;
    unsigned short pathId;
    int reserved[2];
    unsigned short clipId;
    unsigned short textId;
    unsigned short switchId;
    double SWLat1;
    double SWLong1;
    double NELat1;
    double NELong1;
    double latOrig1;
    double longOrig1;
    double upperLat1;
    double lowerLat1;
} mgHeader;


/*
 *  shared vertex structures
 */

typedef struct {	
    short	opcode; /* 67 */
    ushort	length;
    int		vtxlen;
} mgVertTable;


typedef struct {		
    short	opcode; /* 68 */
    ushort	length;
    short	vcolor;
    short	flags;
    double	p [ 3 ];				
} mgVertSharedAbs;


typedef struct {		
    short	opcode; /* 69 */
    ushort	length;
    short	vcolor;
    short	flags;
    double	p [ 3 ];				
    float	n [ 3 ];					
    int			spare;									
} mgVertSharedNorm;


typedef struct {		
    short	opcode; /* 70 */
    ushort	length;
    short	vcolor;
    short	flags;
    double	p [ 3 ];				
    float	n [ 3 ];					
    float	t [ 2 ];					
    int		spare;				
} mgVertSharedNormTex;


typedef struct {		
    short	opcode; /* 71 */
    ushort	length;
    short	vcolor;
    short	flags;
    double	p [ 3 ];				
    float	t [ 2 ];					
} mgVertSharedAbsTex;


typedef struct {
    short 	opcode; /* 72 */
    ushort 	length;
} mgVertList;


typedef struct {
    int	vtxoffset;
} mgVertOffset;

typedef struct {
    short 	opcode; /* 89 */
    ushort 	length;
} mgVertsList;

typedef struct {
    int	vtxoffset;
    int	vtxsoffset;
} mgVertsOffset;

typedef struct {		/* ten for each view window */
    long rotcenter[3];		/* center of rotation for window */
    float yaw, pitch, roll;
    float rotmatrix[4][4];	/* cumulative rotation matrix */
    float fov, scale;
    float nearclip, farclip;
    float flymatrix[4][4];	/* matrix for rotating eye within data base */
    float lookfrom[3];		/* current position of eye in db */
    float flyyaw;		/* current yaw of eye in flythrough */
    float flypitch;		/* current pitch of eye in flythrough */
    float eyedir[3];		/* current direction of eye */
    long nofly;			/* whether eye positioned by fly thru or not */
    long orthoflag;		/* TRUE for ortho display */
    long active;			/* flags whether this structure has been used */
    long imageoffset[2];	/* location of background image */
    long imagezoom;		/* scale of background image */
    long spare[8];		/* spares to make up 256 bytes */
} mgEyeSave;


typedef struct {		/* ten for each view window */
    double rotcenter[3];	/* center of rotation for window */
    float yaw, pitch, roll;
    float rotmatrix[4][4];	/* cumulative rotation matrix */
    float fov, scale;
    float nearclip, farclip;
    float flymatrix[4][4];	/* matrix for rotating eye within data base */
    float lookfrom[3];		/* current position of eye in db */
    float flyyaw;		/* current yaw of eye in flythrough */
    float flypitch;		/* current pitch of eye in flythrough */
    float eyedir[3];		/* current direction of eye */
    long nofly;			/* whether eye positioned by fly thru or not */
    long orthoflag;		/* TRUE for ortho display */
    long active;		/* flags whether this structure has been used */
    long imageoffset[2];	/* location of background image */
    long imagezoom;		/* scale of background image */
    long spare[8];		/* spares to make up 256 bytes */
} mgDEyeSave;


typedef struct {
    short	opcode; /* 65 */
    ushort	length;
    mgEyeSave	eyepos [ 10 ];	/* eyepoint positions */
} mgEyePoint;


typedef struct {
    short	opcode; /* 83 */
    ushort	length;
    mgDEyeSave	eyepos [ 10 ];	/* eyepoint positions */
} mgDEyePoint;

/*
 *  defines for unitType
 */
#define MGU_METERS	0
#define MGU_KILOMETERS	1
#define MGU_FEET	4
#define MGU_INCHES	5
#define MGU_NAUT_MILES	8

/*
 *  defines for vtxType
 */
#define MGV_INTEGER	0
#define MGV_FLOAT	1
#define MGV_DOUBLE	2

	/* road attribute record: */
typedef struct {		
    short	opcode;	/* 87 */
    ushort	length;
    char	id[8];
/* sorry, road data still changing */ 
} mgRoad;

	/* sound attribute record: */
typedef struct {		
    short	opcode;	/* 91 */
    ushort	length;
    char	id[8];
    struct {			/* MCB: required for alignment */
	int	index;
	double 	offset[3];
	float 	normal[3];
	float 	amplitude;
	float 	pitchbend;
	float 	priority;
	float 	falloff;
	float 	width;
	struct {
	    unsigned doppler: 1;	
	    unsigned absorption: 1;
	    unsigned delay: 1;
	    unsigned direction:2;
	    unsigned active:1;
	} flags;
    } sound;
} mgSound;

	/* path attribute record: */
typedef struct {		
    short	opcode;	/* 92 */
    ushort	length;
    char	id[8];
    char	pathname[120];
    double	speedlimit;
    int		nopass;
    int		spare[121];
} mgPath;

#define MG_BITS_PER_SWITCH	(sizeof( int ) * 8)

	/* switch attribute record: */
typedef struct {		
    short	opcode;	/* 96 */
    ushort	length;
    char	id[ 8 ];
    int		flags;
    int		curmask;
    int		maxmask;
    int		count;
    unsigned	aSwitches[ 1 ];	/* really maxmask * count elements */
} mgSwitch;

typedef struct {
    short	opcode;	/* 2 */
    ushort	length;
    char	id[8];
    short	relPri;
    short	spare1;
    long	flags;
    short	fxId1;
    short	fxId2;
    short	signif;
    char	layer;
    char	spare2;
} mgGroup;


	/* integer dof attribute record: */
typedef struct {
    short	opcode;	/* 13 */
    ushort	length;
    char	id [8];
    long	putanchor [3];	
    long	putalign [3];	
    long	puttrack [3];	
    int minz, maxz, curz, incrementz;
    int miny, maxy, cury, incrementy;
    int minx, maxx, curx, incrementx;
    long minazim, maxazim, curazim, incrementazim;
    long minincl, maxincl, curincl, incrementincl;
    long mintwist, maxtwist, curtwist, incrementtwist;	
    long minzscale, maxzscale, curzscale, incrementzscale; 
    long minyscale, maxyscale, curyscale, incrementyscale; 
    long minxscale, maxxscale, curxscale, incrementxscale; 
} mgDof;


	/* floating pt dof attribute record: */
typedef struct {	
    short	opcode;	/* 14 */
    ushort	length;
    char	id [8];
    double putanchor [ 3 ];
    double putalign [ 3 ];
    double puttrack [ 3 ];
    double minz, maxz, curz, incrementz;
    double miny, maxy, cury, incrementy;
    double minx, maxx, curx, incrementx;
    double minazim, maxazim, curazim, incrementazim;
    double minincl, maxincl, curincl, incrementincl;
    double mintwist, maxtwist, curtwist, incrementtwist;	
    double minzscale, maxzscale, curzscale, incrementzscale; 
    double minyscale, maxyscale, curyscale, incrementyscale; 
    double minxscale, maxxscale, curxscale, incrementxscale; 
} mgDDof;


typedef struct {
    short	opcode;	/* 3 */
    ushort	length;
    char	id[8];
    long	inDist;
    long	outDist;
    short	fxId1;
    short	fxId2;
    long	flags;
    long	center[3];
    long	spare1[11];
} mgLod;


typedef struct {
    short	opcode;	/* 73 */
    ushort	length;
    char	id[8];
    double	inDist;
    double	outDist;
    short	fxId1;
    short	fxId2;
    long	flags;
    double	center[3];
} mgFLod;


typedef struct {
    short	opcode;	/* 4 */
    ushort	length;
    char	id[8];
    long	flags;
    short	relPri;
    ushort	transp;
    short	fxId1;
    short	fxId2;
    short	signif;
// MPG 3/2/95 - this doesn't agree with the docs for version 14.1
//    short	spare1[31];
    short	spare1;
} mgObject;


typedef struct {
    short	opcode;	/* 5 */
    ushort	length;
    char	id[8];
    int		IRCode;		/* infrared color code */
    short	relPri;
    char	drawType;
    char	spare1;
    short	color1;
    short	color2;
    char	spare2;
    char	textureTemplate;
    short	detail;
    short	texture;
    short	material;
    short	surfaceMaterialCode;
    short	featureId;
    int		IRMaterial;	/* infrared material code */
    ushort	transp;		/* 0 = solid, ffff = clear */
    short	spare4[1];
} mgPolygon;


typedef struct {
    short	opcode;	/* 7 */
    ushort	length;
    long	v[3];
    float	t[2];
} mgVertAbs;


typedef struct {
    short	opcode;	/* 8 */
    ushort	length;
    long	v[3];
    short	unused;
    short	color;
    float	t[2];
} mgVertShad;


typedef struct {
    short	opcode;	/* 9 */
    ushort	length;
    long	v[3];
    short	unused;
    short	color;
    long	n[3];
    float	t[2];
} mgVertNorm;


typedef struct {
    short	opcode;	/* 10, 11, 19, or 20 */
    ushort	length;
} mgControl;


typedef struct {
    short	opcode;	/* 31 */
    ushort	length;
    char	text[256];	/* really variable sized */
} mgComment;


#define MG_CT_SHADED	28
#define MG_CT_NO_SHADE	128
#define MG_CT_FIXED	56

typedef struct {
    short	opcode;	/* 32 */
    ushort	length;
    short	color[MG_CT_SHADED][3];
    short	spare[4][3];
    short	fixedColor[MG_CT_FIXED][3];
} mgColorTable;

typedef struct mgLongID {
    short	opcode;	/* 33 */
    ushort	length;
    char	text[ 256 ];	/* really variable sized */
} mgLongID;

typedef struct {
    short	opcode;	/* 49 */
    ushort	length;
    float	matrix[4][4];
} mgMatrix;


typedef struct {
    short	opcode;	/* 50 */
    ushort	length;
    float	vec[3];
} mgVect;


typedef struct {
    short	opcode;	/* 51 */
    ushort	length;
    long	low[3];
    long	hi[3];
} mgBbox;


typedef struct {
    short	opcode;	/* 60 */
    ushort	length;
    short	count;
    short	spare;
} mgReplicate;


typedef struct {
    short	opcode;	/* 61 */
    ushort	length;
    short	spare;
    short	defNumber;
} mgInstanceRef;


typedef struct {
    short	opcode;	/* 62 */
    ushort	length;
    short	spare;
    short	defNumber;
} mgInstanceDef;


typedef struct {
    short	opcode;	/* 63 */
    ushort	length;
    char	file[80];
} mgExternalRef;


typedef struct {
    short	opcode;	/* 64 */
    ushort	length;
    char	file[80];
    long	index;
    long	x;		/* palette location */
    long	y;		/* palette location */
} mgTextureRef;

#define TV_MODULATE	0
#define TV_BLEND	1
#define TV_DECAL	2
#define TV_COLOR	3

typedef struct {
    long	    width;	/* the number of pixels in u direction */
    long	    height;	/* the number of pixels in v direction */
    long	    rwsizeu;	/* real world sizeu */
    long	    rwsizev;	/* real world sizev */
    long	    iup, jup;       /* the i and j of the direction considered to be up */
    long	    type;       /* -1 = Not used, 
                                    0 = texture - 8 bit color lookup, 
                                    1 = Template - 8 bit color lookup, 
                                    2 = Intensity,
                                    3 = Intensity-Alpha,
                                    4 = RGB, 
                                    5 = RGBAlpha */
    long	    minfilter;      /* TX_POINT, TX_BILINEAR, TX_MIPMAP, 
                                TX_MIPMAP_POINT, TX_MIPMAP_LINEAR, 
                                TX_MIPMAP_BILINEAR, TX_MIPMAP_TRILINEAR */
    long	    magfilter;   /*    TX_POINT, TX_BILINEAR */
    long	    wrap;        /* TX_REPEAT, TX_CLAMP, TX_SELECT */
    long	    wrapu;       /* same as wrap for U only */
    long	    wrapv;       /* same as wrap for V only */
    long	    changed;     /* file has been changed */
    long	    i1, j1;	 /* pivot point for template/stamps */
    long	    envtype;     /* texture environment 0 = TV_MODULATE
                                                        1 = TV_BLEND
                                                        2 = TV_DECAL
                                                        3 = TV_COLOR */
    long spareia;    /* spare words for future expansion */

    long user1;			/* 8 misc fields for DBL's */
    long user2;
    long user3;
    long user4;
    long user5;
    long user6;
    long user7;
    long user8;

    double rwsizeuf;	/* floating point real world sizeu */
    double rwsizevf;	/* floating point real world sizev */

    long dbl_orig;	/* originator of texture */
    long formatrev;	/* kernel version number */

    long internalformat;		/* 0 = default
	1 = TX_I_12A_4		   1-comp 	2-comp	full speed
	2 = TX_IA_8		   2-comp	full speed
	3 = TX_RGB_5		   3-comp	full speed
	4 = TX_RGBA_4		   4-comp	full speed
	5 = TX_IA_12		   2-comp	half speed
	6 = TX_RGBA_8		   4-comp	half speed
	7 = TX_RGBA_12		   3-comp 	4-comp	quarter speed
	8 = TX_I_16 		   SHADOW MODE ONLY
	9 = TX_RGB_12 		   3-comp 	4-comp	third speed */

    long externalformat;		/* 0 = default
				   1 = TX_PACK_8
				   2 = TX_PACK_16 */
    long usefilter;		/* if TRUE send 8 floats as kernel */
    float kernel [ 8 ];		/* 8 floats of symmetric separable filter */

    long controlpoint;

    float lod0, scale0;
    float lod1, scale1;
    float lod2, scale2;
    float lod3, scale3;
    float lod4, scale4;
    float lod5, scale5;
    float lod6, scale6;
    float lod7, scale7;
    float clamp;

    long magfilteralpha;	/* TX_POINT, TX_BILINEAR */
    long magfiltercolor;	/* TX_POINT, TX_BILINEAR */

    float spare1 [ 22 ];

    int detail;
    int j, k, m, n, scramble;
    int tile;
    float lowerleftu, lowerleftv, upperrightu, upperrightv;

    int spare    [ 160 ];	/* spare words for future expansion */
    char comment [ 512 ];	/* user specified text comment */
} mgTextureAttr;

typedef struct {
    float	ambient[3];
    float	diffuse[3];
    float	specular[3];
    float	emission[3];
    float	shininess;
    float	alpha;
    long	spare1[32];
} mgMaterial;

typedef struct {
    short	opcode;	/* 66 */
    ushort	length;
    mgMaterial mat[64];
} mgMaterialTable;

#ifndef TRUE
#define TRUE	1
#endif
#ifndef FALSE
#define FALSE	0
#endif

/* MPG */
#define pfVec2 float*
#define pfVec3 float*
#define pfVec4 float*

typedef struct _absVert {
    pfVec3		coord;
} AbsVert;

typedef struct _absTexVert {
    pfVec3		coord;
    pfVec2		texCoord;
} AbsTexVert;

typedef struct _shadedVert {
    pfVec3		coord;
    pfVec3		color;
} ShadedVert;

typedef struct _shadedTexVert {
    pfVec3		coord;
    pfVec3		color;
    pfVec2		texCoord;
} ShadedTexVert;

typedef struct _normVert {
    pfVec3		coord;
    pfVec3		norm;
} NormVert;

typedef struct _normTexVert {
    pfVec3		coord;
    pfVec3		norm;
    pfVec2		texCoord;
} NormTexVert;

#define TRI	1001
#define QUAD	1002
#define BIG	1003

#define POLYDEF			\
    long	type;		\
    long 	numVerts;	\
    pfVec3	color;		\
    pfVec3	color2;		\
    pfVec3	norm;		\
    struct _poly *next

typedef struct _poly {
    POLYDEF;
    long	indexList[1];
 } Poly;

typedef struct {
    POLYDEF;
    long	indexList[3];	/* Variable length list MUST come last in struct */
} Tri;

typedef struct {
    POLYDEF;
    long	indexList[4];	/* Variable length list MUST come last in struct */
} Quad;

typedef struct {
    POLYDEF;
    long	indexList[256];	/* Variable length list MUST come last in struct */
} BigPoly;

typedef struct _lightPoint {
    char 	name[80];
    long	numPoints;
    long	set;
    long 	*indexList;
    long 	liteType;
    pfVec3	vector;
    pfVec4	frontColor;
    pfVec4	backColor;
    struct _lightPoint *next;
} LightPoint;

typedef struct _GeoSet {
    char 	drawType;
    short 	vertType;
    short	billboard;
    long 	numPrims;
    Poly 	*primList;
    struct _GeoSet *next;
} GeoSet;

/* MPG
typedef struct _GeoState {
    short 	texture;
    short 	detail;
    short 	material;
    short	color;
    short	bcolor;
    short	backFace;
    GeoSet	*gtList;
    pfGeoState	*pfgs;
    struct _GeoState *next;
} GeoState;
*/

/* MPG
typedef struct _InstDef {
    pfNode    *inst;
    long      id;
} InstDef;
*/

/* MPG
typedef struct _RepRef {
    pfNode	*node;
    pfNode	*parent;
    pfMatrix	matrix;
    long	repcnt;
} RepRef;
*/

/* MPG
typedef struct _MgFile
{
    long	    vtxFormat;
    long	    formatRev;
    char	    file[80];
    char	    *mgVertexTable;
    pfGroup	    *root;
    GeoState	    *gsList;
    InstDef	    mgInstList[LISTSIZE];
    mgTextureRef    *mgTexList[MG_MAX_TEXTURES];
    pfTexture	    *pfTexList[MG_MAX_TEXTURES];
    pfTexEnv	    *pfTEnvList[MG_MAX_TEXTURES];
    long	    blendIndex[MG_MAX_TEXTURES];
    long	    TBlendTex[MAXBLEND][MAXBCOLORS];
    long	    pfTexIndex[MG_MAX_TEXTURES];
    long	    mgTexCount, mgInstCount, pfTexCount, blendCount;
    mgMaterial	    *mgMtlList;
    pfMaterial	    *pfMtlList[MG_MAX_TEXTURES];
    float	    vertMult;
    pfVec3	    *colorTable;
    mgColorTable    *mgCTab;
    RepRef   rep [LISTSIZE];
    long	    lastrep;
    struct _MgFile  *next;
} MgFile;
*/

/* geom.c */
extern char*	    addPoly(mgPolygon *);
// MPG
// extern pfNode*	    makeGeometry(void);
extern void	    geomInit(void);
extern void	    geomExit(void);
// MPG
// extern void	    countGSet(pfGeoSet *);

/* hier.c */
extern void	    diag(char *fmt, ...);
extern void	    diagEnable(int s);

/* tmesher.c */
// MPG
// extern pfGeoSet*   tstripGSet(pfGeoSet *);
extern void	    mesherInit(void);
extern void	    mesherExit(void);

/* hier.c */
// MPG 
// extern MgFile	    *CurMgFile, *RootMgFile;
extern long	    FlatFlag, ComputeNormals, ShowTStrips, FoundLPoints;

#ifdef __cplusplus
}
#endif

#endif /* __MGPFFLT_H__ */