/**************************************************************************** * * Copyright 1995 Division Limited. * All Rights Reserved * * * System : * Module : * Object Name : $RCSfile: ptool.h,v $ * Revision : $Revision: 1.18 $ * Date : $Date: 95/05/16 13:47:00 $ * Author : $Author: bill $ * Last Modified : <150595.1203> * * Description * * Notes * * History * * $Log: ptool.h,v $ * Revision 1.18 95/05/16 13:47:00 bill * Added 1) dos. 2) STRIP_LIST. 3) POINTLIST. 4) biz->bgf * * Revision 1.17 95/04/27 23:01:16 bill * Major ci for 3.0 Alpha (new: pgeneral, dm) * * **************************************************************************** * * Copyright (c) 1995 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. ****************************************************************************/ #ifndef __PTOOL_H__ #define __PTOOL_H__ #ifdef _PF_LOCAL #include "pfile.h" #else #include #endif /*****************************************************************************/ /* pfile error numbers */ #define dptENO_NOTIMP 0x8001 #define dptENO_FORM 0x8002 #define dptENO_VALUE 0x8003 #define dptENO_USAGE 0x8004 #define dptENO_NULL 0x8005 #define dptENO_INTER 0x8006 #define dptENO_GRAPH 0x8007 /*****************************************************************************/ /* ptool monitor flags */ #define dptMON_ALL 0x01000000 void dptGetLibraryVersion(uint8 *M, uint8 *m) ; /* returns 0 if the triangle is small, 1 and the normal otherwise */ int32 dptCalcVTriNorm(dmVector pnt1, dmVector pnt2, dmVector pnt3, dmVector normal) ; int32 dptCalcTriNorm(dpfVERTEXPTR vert1, dpfVERTEXPTR vert2, dpfVERTEXPTR vert3, dmVector normal) ; void dptMatMultVector(dmVector OutVec, dmVector vec, dmMatrix mat) ; /* * FILE __ptmesh.c * Creates and saves meshes */ #define dpt_OPT_PMESH 0x010000 #define dpt_OPT_PSTRIP 0x020000 dptMESHPTR dptCreateMesh(int32 hash_size, int32 normals) ; void dptFreeMesh(dptMESHPTR mesh) ; void dptGetMeshStats(dptMESHPTR mesh) ; int32 dptGetMeshNoTriangles(dptMESHPTR mesh) ; int32 dptGetMeshNoVertices(dptMESHPTR mesh) ; int32 dptGetMeshNoDropTri(dptMESHPTR mesh) ; int32 dptMeshLoadFile(dptMESHPTR mesh, dpfFILEPTR file) ; int32 dptMeshLoadObject(dptMESHPTR mesh, dpfOBJECTPTR object) ; int32 dptMeshLoadLOD(dptMESHPTR mesh, dpfLODPTR LOD) ; int32 dptMeshLoadPatch(dptMESHPTR mesh, dpfPATCHPTR patch) ; int32 dptMeshLoadGeometry(dptMESHPTR mesh, dpfGEOMETRYPTR geom) ; int32 dptMeshLoadTriangle(dptMESHPTR mesh, dpfVERTEXPTR vert1, dpfVERTEXPTR vert2, dpfVERTEXPTR vert3) ; int32 dptMeshCalcFaceNormals(dptMESHPTR mesh) ; void dptMeshSetVertexPoint(dptMESHPTR mesh, dpfVERTEXPTR vert, dmVector point) ; int32 dptMeshUnloadPatch(dpfPATCHPTR patch, dptMESHPTR mesh, int32 usePmesh) ; int32 dptMeshUnloadLOD(dpfLODPTR LOD, dptMESHPTR mesh, int32 usePmesh) ; int32 dptMeshUnloadMesh(dptMESHPTR mesh, int32 usePmesh) ; /* ** Octize utilitises ** ** must load the file into a mesh using dptMeshLoadFile etc. ** Then use dptOctizeMesh to octize followed by ** dptUnloadOctizedMeshSingle or dptUnloadOctizedMeshMulti ** for single and All file outputs. */ int32 dptOctizeMesh(dptMESHPTR mesh, dpfIVECTOR div, dmVector Min, dmVector Dif) ; int32 dptSpatialiseMesh(dptMESHPTR mesh) ; int32 dptUnloadDividedMeshSingle(dptMESHPTR mesh, int32 octPos, int32 usePmesh, int32 *noTriangles) ; int32 dptUnloadOctizedMeshSingle(dptMESHPTR mesh, dpfIVECTOR pos, int32 usePmesh, int32 *noTriangles) ; int32 dptUnloadDividedMeshAll(dptMESHPTR mesh, int32 usePmesh) ; /* * File ptbbox * Gets bounding box of files, objects, patches & geoms * * dpfBbox??? must have the MaxVec and MinVec initialized by the user * before it is first called. * dpfGetbbox??? Initializes itself, and gets the bounding box and * difference vector for the structure. */ int32 dptGetBBoxGeometry(dpfGEOMETRYPTR geom, dmVector MaxVec, dmVector MinVec, dmVector differ) ; int32 dptGetBBoxPatch(dpfPATCHPTR patch, dmVector MaxVec, dmVector MinVec, dmVector differ) ; int32 dptGetBBoxLOD(dpfLODPTR LOD, dmVector MaxVec, dmVector MinVec, dmVector differ) ; int32 dptGetBBoxFile(dpfFILEPTR file, dmVector MaxVec, dmVector MinVec, dmVector differ) ; /* * File ptscale * scales files, objects, patches & geoms */ /* NOTE! :- If dptScaleGeometry or Patch is used it is up to the USER to ** scale all LOD reference points !!! DON'T FORGET. */ int32 dptScaleGeometry(dpfGEOMETRYPTR geom, int32 normals, dmVector scale) ; int32 dptScalePatch(dpfPATCHPTR patch, dmVector scale) ; int32 dptScaleObject(dpfOBJECTPTR object, dmVector scale) ; int32 dptScaleFile(dpfFILEPTR file, dmVector scale) ; int32 dptChangeFileUnit(dpfFILEPTR file, dpfUNIT unit) ; int32 dptScaleNPGeometry(dpfGEOMETRYPTR geom, dmVector scale, dpfIVECTOR NP) ; int32 dptScaleNPPatch(dpfPATCHPTR patch, dmVector scale, dpfIVECTOR NP) ; int32 dptScaleNPObject(dpfOBJECTPTR object, dmVector scale, dpfIVECTOR NP) ; int32 dptScaleNPFile(dpfFILEPTR file, dmVector scale, dpfIVECTOR NP) ; /* * File ptxlate * translates files, objects, patches & geoms */ /* NOTE! :- If dptTranslateGeometry or Patch is used it is up to the USER to ** scale all LOD reference points !!! DON'T FORGET. */ int32 dptTranslateGeometry(dpfGEOMETRYPTR geom, dmVector trn) ; int32 dptTranslatePatch(dpfPATCHPTR patch, dmVector trn) ; int32 dptTranslateLOD(dpfLODPTR LOD, dmVector trn) ; int32 dptTranslateObject(dpfOBJECTPTR object, dmVector trn) ; int32 dptTranslateFile(dpfFILEPTR file, dmVector trn) ; /* * File ptcentre * Centre's given file */ int32 dptCentreFile(dpfFILEPTR file) ; /* * File ptcoales * coalesces short patches into longer ones * reduces file size, execution time */ int32 dptCoalesceLOD(dpfLODPTR LOD) ; int32 dptCoalesceObject(dpfOBJECTPTR obj, int32 coalesceLODs, int32 coalesceGEOMs) ; int32 dptCoalesceFile(dpfFILEPTR file, int32 coalesceLODs, int32 coalesceGEOMs) ; /* * File pttextur * Places planar texture co-ordinates on given file */ #define dpt_TEXTURE_PLANE 0 #define dpt_TEXTURE_AXIAL 1 #define dpt_TEXTURE_CYLINDER 2 typedef struct { int32 method ; int32 noWraps ; int32 gotSize, gotRef ; int32 Cswap ; int32 Uco, Vco ; int32 axes[3] ; float32 Usize, Vsize ; float32 Cangle, Coffset ; dmVector reference ; int32 distort ; } dptTEXTURE, *dptTEXTUREPTR ; void dptCorrectTriangleTexture(dptMESHPTR mesh, dpfPATCHPTR patch, dpfVERTEXPTR vert1, dpfVERTEXPTR vert2, dpfVERTEXPTR vert3, int32 noWraps, int32 *distort) ; dpfGEOMETRYPTR dptCorrectGeometryTexture(dpfGEOMETRYPTR geom, int32 noWraps, int32 *distort) ; int32 dptTextureInit(dptTEXTUREPTR txt, int32 method, int32 NoWraps, int32 gotSize, int32 gotRef, dmVector MinVec, dmVector differ, float32 Usize, float32 Vsize, dmVector reference, int32 Uco, int32 Vco, int32 *axes, int32 Cswap, float32 Cangle) ; int32 dptTextureFileInit(dpfFILEPTR file, dptTEXTUREPTR txt, int32 method, int32 NoWraps, int32 gotSize, int32 gotRef, float32 Usize, float32 Vsize, dmVector reference, int32 Uco, int32 Vco, int32 *axes, int32 Cswap, float32 Cangle) ; dpfGEOMETRYPTR dptTextureGeometry(dpfGEOMETRYPTR geom, dptTEXTUREPTR txt) ; int32 dptTexturePatch(dpfPATCHPTR ptch, dptTEXTUREPTR txt) ; int32 dptTextureLOD(dpfLODPTR LOD, dptTEXTUREPTR txt) ; int32 dptTextureFile(dpfFILEPTR file, dptTEXTUREPTR txt) ; /* * File __ptrot.c * rotates files, objects, patches & geoms * Order the rotations are performed are the same as MAZ * ie Z, X then Y */ /* Matrix point transformers. * Transforms (Xforms) files using a 4x4 homogeneous matrix, * Note that translations are performed, hence the use of dmPntXformMat * * Used directly by the dptRotate functions. */ #define dptVectorXformMat(OutVec,vec,mat) dmPointXformMat(OutVec,vec,mat) extern void (dptVectorXformMat)(dmVector OutVec, dmVector vec, dmMatrix mat) ; int32 dptXformGeometry(dpfGEOMETRYPTR geom, int32 Normals, dmMatrix rotate) ; int32 dptXformPatch(dpfPATCHPTR patch, dmMatrix rotate) ; int32 dptXformObject(dpfOBJECTPTR object, dmMatrix rotate) ; int32 dptXformFile(dpfFILEPTR file, dmMatrix rotate) ; /***************************************************************************** * NOTE! :- If dptRotateGeometry or Patch is used it is up to the USER to * * scale all LOD reference points !!! DON'T FORGET. * *****************************************************************************/ /* * Rotation functions use the Xform functions directly, so error messages * will be dptXform's. */ extern void dptRotateSetup(dmMatrix outMat, dmVector inRot) ; #define dptRotateGeometry(geom,Normals,rotate) \ dptXformGeometry(geom,Normals,rotate) #define dptRotatePatch(patch,rotate) \ dptXformPatch(patch,rotate) #define dptRotateObject(object,rotate) \ dptXformObject(object,rotate) #define dptRotateFile(file,rotate) \ dptXformFile(file,rotate) /* * File __pticon.h * Centre's and scales a given file to produce an icon */ #define dpt_ICONSIZE 1.0 int32 dptIconizeFile(dpfFILEPTR file, float32 size) ; /* * File __ptrond.h * Rounds given file to the given number of sig. figures * if the given number is <= 0 then default is used. */ #define dpt_DEFAULTSIGFIG 6 #define dpt_DEFAULTDPS 4 #define dpt_DEFAULTWRAP 1 int32 dptRoundFvertex(dpfFILEPTR file, int32 SigFig, int32 dps) ; int32 dptFuzzyJoinFile(dpfFILEPTR file, float32 Dist, int32 WarnDis) ; int32 dptJoinMeshTriangles(dptMESHPTR mesh, float32 distTol, float32 angTol, int32 *joinCount, int32 Verbose) ; int32 dptJoinPatchTriangles(dpfPATCHPTR patch, int32 hash_size, int32 usePmesh, float32 distTol, float32 angTol, int32 *joinCount, int32 Verbose) ; typedef struct { /* Check setup parameters */ int32 dps ; /* decimal places to check to */ int32 NoWraps ; /* maximum no. of texture wraps */ int32 autoFix ; /* autoFix on if non-zero */ int32 disableText ; /* don't fix textures if non-zero */ int32 splitGeom ; /* if non-zero the split triangle */ /* rather than distort texture */ int32 Verbose ; /* run with verbose */ /* Things calculated on setup */ float32 MulFac ; /* Normal modulus accuracy mul factor*/ /* No. things found empty */ int32 emptyLod ; int32 emptyPatch ; int32 emptyGeom ; /* LOD error report */ int32 badDummy ; /* got a dummy with other lods */ int32 badOrder ; /* lods in wrong order - flag only */ int32 distSame ; /* switch-in == out count */ int32 distSwap ; /* switch-in > out count */ int32 overLap ; /* lod switch in overlaps others out */ /* geometry bad report */ int32 badPmeshT ; /* No of bad pmesh triangle connects */ int32 badSphere ; /* No of spheres with bad radii */ int32 badLine ; /* No of 0 length lines */ int32 badPoint ; /* No. points with nans, inc. lod ref*/ int32 badNorm ; /* No. normals with bad mod */ int32 badCook ; /* No. rgb's out of range */ int32 badText ; /* no. nan | text co-ords out of wrap*/ float32 maxText ; /* the maximum range of a texture */ /* boundary report */ int32 badBBox ; int32 badBSphere ; int32 badBPmesh ; int32 isBad ; /* Summary flag - if true then error found */ /* auto-fix output */ int32 dropLod ; /* No dropped lods as empty */ int32 dropPatch ; /* No dropped patches as empty */ int32 dropGeom ; /* No dropped geometries as empty */ int32 dropTri ; /* No tri's dropped because duff */ /* duff cos nan's or pmesh connect */ int32 dropLine ; /* No lines's dropped cos len = 0 */ int32 dropSphere ; /* No tri's dropped cos radius = 0 */ int32 dropBPart ; /* No B box, sphere and pmeshes drop */ int32 dropBound ; /* No bounds dropped */ int32 normDistort ; /* No normal 0 or nan mods */ int32 textDistort ; /* No texture distorts (0 if split) */ int32 newTriCnt ; /* No new tris created from splitting*/ int32 isAwful ; /* Summary flag - if true then Distortion */ } dptCHECK, *dptCHECKPTR ; int32 dptCheckLODs(dpfFILEPTR file, dptCHECKPTR check) ; int32 dptCheckPatch(dpfPATCHPTR patch, dptCHECKPTR check) ; void dptCheckSetup(dptCHECKPTR check, int32 dps, int32 NoWraps, int32 autoFix, int32 disableText, int32 verbose) ; int32 dptCheckFile(dpfFILEPTR file, dptCHECKPTR check, int32 dps, int32 NoWraps, int32 autoFix, int32 disableText, int32 verbose) ; int32 dptNormalizeMesh(dptMESHPTR mesh, float32 Tolerence, int32 Verbose) ; int32 dptNormalPatch(dpfPATCHPTR patch, int32 hash_size, float32 Tolerence, int32 usePmesh, int32 *DropTri, int32 Verbose) ; /* reduce a patch * NOTE :- * Method is a bit field using the following #defines * verbose is a bit field 0x02=Prompt, 0x04=GL, non-zero=% */ #define dptRDC_DUPS 0x0001 #define dptRDC_DUPD 0x0002 #define dptRDC_SQUR 0x0004 #define dptRDC_180 0x0008 #define dptRDC_360 0x0010 int32 dptReducePatch(dpfPATCHPTR patch, int32 hash_size, float32 Cook_Tol, float32 Norm_Tol, float32 Tri_Tol, float32 Edge_Tol, int32 *DropTri, int32 NoIter, int32 usePmesh, int32 Method, int32 Verbose, float32 WarmInc) ; /* ** Reduces the number of faces in a cylinder. ** Tolerences :- ** MaxRadiusTol ** RatioTol - The maximum ratio between the largest and ** smallest end edges. ** NormTol - How correctly shaped the pairs are. ** MaxNoFaces - Max faces in a cylinder -> 2* no of trian. ** MinNoFaces - Min faces in a cylinder ** FinNoFaces - Final no faces. */ /* The cylinder structure * The following rules must be adhered to if blast is to correctly re-create * them. * 1) there are 2 different types of cylinders, flat (disks and ring) and * non-flat (cones and tubes). * 2) flat cylinders must have a length of 0.0, the larger ring must be * stored in slot 0 and inner ring or centre in slot 1. PlnNorm and * CenLine must be the same and point in the direction it is facing. * Flipping the centLine direction and facing bit in flags (bit 1) * can be used to change its orientation * 3) Non-flat tubes have a non-zero length, the CentLine is the direct * needed to go for the centre point of ring in slot 0 to the centre * of ring in slot 1. Bit 1 of flags indicates where the cylinder is * in or outwardly facing, set if in. * 4) flat disk cylinders are automatically converted to cylinder ends if * an apropriate cylinder is found. * 5) Bit 2 of flags gives the orientation of the cylinder in the pipe, if * set then it is facing the other way. * 6) Bit 3-5 of flags indicates the part got of a cylinder * 7) the plane normals must point outwards of a tube if inwardly facing, * or inwardly if inwardly facing. With a ring, the large radius ring must * point in the direction the ring faces and it will join that way, the * smaller must point the oposite way. */ #define dptBLAST_FACE 0x0001 #define dptBLAST_DIR 0x0002 #define dptBLAST_BODY 0x0004 #define dptBLAST_END1 0x0008 #define dptBLAST_END2 0x0010 #define dptBLAST_DISK 0x0020 #define dptBLAST_CONE 0x0040 #define dptBLAST_RING 0x0080 #define dptBLAST_TUBE 0x0100 typedef struct dptCYLINDER_str { int32 noFaces ; int32 flags ; float32 Length ; dmVector CentLine ; float32 Radius[2] ; dmVector Centre[2] ; dmVector PlnNorm[2] ; struct dptCYLINDER_str *next ; } dptCYLINDER, *dptCYLINDER_ptr ; typedef struct dptCYLLIST_str { int32 flags[2] ; int32 NoVert ; float32 maxRadius ; float32 minRadius ; float32 Radius[2] ; dmVector Centre[2] ; dmVector PlnNorm[2] ; dptCYLINDER_ptr EndCyl[2] ; struct dptCYLLIST_str *next ; } dptCYLLIST, *dptCYLLIST_ptr ; typedef struct { dptMESHPTR curMesh ; dpfPATCHPTR curPatch ; int32 BBlast ; float32 BMaxSideTol ; float32 BRatioTol ; float32 BEdgeTol ; float32 BNormTol ; int32 CBlast ; int32 CStats ; int32 CMinFcs ; int32 CMaxFcs ; int32 CNoRanges ; float32 *CMinRad ; float32 *CMaxRad ; int32 *CFinFcs ; /* to be filled */ int32 KeepParts ; float32 CRatioTol ; float32 CNormTol ; float32 CCentDif ; float32 CRadDif ; float32 CTurnTol ; /* to be left alone */ float32 TurnTol ; float32 cNorm0Tol ; float32 cNorm90Tol ; dptCYLLIST_ptr CList_hd, CList_tl ; dpfVERTEXPTR *TopVerts, *BotVerts ; } dptBLAST, *dptBLASTPTR ; int32 dptBlastPatch(dpfPATCHPTR patch, int32 hash_size, dptBLASTPTR blast, int32 usePmesh, int32 *DropTri, int32 Verbose) ; int32 dptTinyKillMesh(dptMESHPTR mesh,float32 Angl_Tol, int32 Verbose, int32 *SmallTri) ; int32 dptTinyKillPatch(dpfPATCHPTR patch, int32 hash_size, float32 Angl_Tol, int32 usePmesh, int32 *DropTri, int32 Verbose) ; /* ** ptflip - module to flip the trangle direction face */ int32 dptFlipAllGeometry(dpfGEOMETRYPTR geom, int32 flipNormals) ; int32 dptFlipAllPatch(dpfPATCHPTR patch, int32 flipNormals) ; int32 dptFlipAllObject(dpfOBJECTPTR object, int32 flipNormals) ; int32 dptFlipAllFile(dpfFILEPTR file, int32 flipNormals) ; int32 dptFlipRightMesh(dptMESHPTR mesh, int32 *flipCount, int32 Verbose) ; int32 dptFlipRightPatch(dpfPATCHPTR patch, int32 hash_size, int32 usePmesh, int32 *DropTri, int32 *flipCount, int32 Verbose) ; /* ** hedgehog a given file */ int32 dptCreateVisualMaterials(dpfFILEPTR file) ; int32 dptAddVertexNormalVisual(dpfFILEPTR file, char *matLib, float32 Pscale, float32 Bscale) ; int32 dptAddBoundBoxVisual(dpfFILEPTR file, char *matLib) ; int32 dptAddBoundSphereVisual(dpfFILEPTR file, char *matLib, int32 udice, int32 vdice) ; int32 dptAddBoundPmeshVisual(dpfFILEPTR file, char *matLib) ; int32 dptRmvVertexNormalVisual(dpfFILEPTR file) ; int32 dptRmvBoundBoxVisual(dpfFILEPTR file) ; int32 dptRmvBoundSphereVisual(dpfFILEPTR file) ; int32 dptRmvBoundPmeshVisual(dpfFILEPTR file) ; int32 dptCookGeometry(dpfGEOMETRYPTR geom, dpfRGBA col) ; int32 dptCookFile(dpfFILEPTR file) ; /* Boundary stuff */ int32 dptCalcMinBBox(dpfFILEPTR file, int32 res, dpfBOUNDPTR bound) ; int32 dptCreateBoundary(dpfFILEPTR file, int32 minBBoxRes, int32 doHierarchy, int32 keepPmesh, int32 hashSize) ; /* Tessellate a polygon, allowing for concavity. * * The pmesh must already contain all the required vertices, noPnts is * a count of the number of points in the polygon (doesnt have to be the * number of vertices), and vrtlst is an int array of size noPnts giving * the pmesh vert numbr for the nth point. * Assumes that the polygon is closed, so vrtlst[0] != vrtLst[noPnts-1] * should be true. */ int32 dptPolyTessellate(dpfGEOMETRYPTR pmesh, int32 noPnts, int32 *vrtLst) ; /* graphics routines */ int32 dptInitGraphics(char *name) ; int32 dptInitView(dmVector boxMin, dmVector boxDif) ; int32 dptEndView(void) ; #endif /* __PTOOL_H__ */