00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef NVBLASTAUTHORINGTYPES_H
00030 #define NVBLASTAUTHORINGTYPES_H
00031
00032 #include <PxVec3.h>
00033 #include <PxVec2.h>
00034 #include <PxBounds3.h>
00035 #include "NvBlastTypes.h"
00036
00037 #define NOT_VALID_VERTEX INT32_MAX
00038
00039 namespace Nv
00040 {
00041 namespace Blast
00042 {
00043
00047 struct Edge
00048 {
00049 uint32_t s, e;
00050 Edge() : s(NOT_VALID_VERTEX), e(NOT_VALID_VERTEX){}
00051 Edge(int s, int e) : s(s), e(e) {}
00052 bool operator<(const Edge& b) const
00053 {
00054 if (s == b.s)
00055 return e < b.e;
00056 else
00057 return s < b.s;
00058 }
00059 };
00060
00064 struct Vertex
00065 {
00066 physx::PxVec3 p;
00067 physx::PxVec3 n;
00068 physx::PxVec2 uv[1];
00069 };
00070
00071
00072
00073 #define MATERIAL_INTERIOR 1000
00074 #define SMOOTHING_GROUP_INTERIOR 1000
00075
00076
00077
00081 struct Triangle
00082 {
00083 Triangle() {};
00084 Triangle(Vertex a, Vertex b, Vertex c) : a(a), b(b), c(c) {};
00085 Vertex a, b, c;
00086 int32_t userData;
00087 int32_t materialId;
00088 int32_t smoothingGroup;
00089 physx::PxVec3 getNormal() const
00090 {
00091 return ((b.p - a.p).cross(c.p - a.p));
00092 }
00093 inline Vertex& getVertex(uint32_t index)
00094 {
00095 return (&a)[index];
00096 }
00097 inline const Vertex& getVertex(uint32_t index) const
00098 {
00099 return (&a)[index];
00100 }
00101 };
00102
00103
00107 struct TriangleIndexed
00108 {
00109 TriangleIndexed() {};
00110 TriangleIndexed(uint32_t a, uint32_t b, uint32_t c) : ea(a), eb(b), ec(c) {};
00111
00112 uint32_t getOpposite(uint32_t a, uint32_t b)
00113 {
00114 if (ea != a && ea != b)
00115 return ea;
00116 if (eb != a && eb != b)
00117 return eb;
00118 if (ec != a && ec != b)
00119 return ec;
00120 return NOT_VALID_VERTEX;
00121 }
00122
00123 bool isContainEdge(uint32_t a, uint32_t b)
00124 {
00125 return (a == ea || a == eb || a == ec) && (b == ea || b == eb || b == ec);
00126 }
00127
00128 Triangle convertToTriangle(Vertex* vertices)
00129 {
00130 Triangle tr;
00131 tr.a = vertices[ea];
00132 tr.b = vertices[eb];
00133 tr.c = vertices[ec];
00134
00135 tr.userData = userData;
00136 tr.materialId = materialId;
00137 tr.smoothingGroup = smoothingGroup;
00138 return tr;
00139 }
00140
00141 uint32_t ea, eb, ec;
00142 int32_t materialId;
00143 int32_t smoothingGroup;
00144 int32_t userData;
00145 };
00146
00147
00148
00149
00153 struct Facet
00154 {
00155 int32_t firstEdgeNumber;
00156 uint32_t edgesCount;
00157 int64_t userData;
00158 int32_t materialId;
00159 int32_t smoothingGroup;
00160
00161 Facet(int32_t fEdge = 0, uint32_t eCount = 0, int32_t materialId = 0, int64_t userData = 0, int32_t smoothingGroup = 0) : firstEdgeNumber(fEdge), edgesCount(eCount), userData(userData), materialId(materialId), smoothingGroup(smoothingGroup) {}
00162 };
00163
00167 class RandomGeneratorBase
00168 {
00169 public:
00170
00171 virtual float getRandomValue() = 0;
00172
00173 virtual void seed(int32_t seed) = 0;
00174 virtual ~RandomGeneratorBase() {};
00175 };
00176
00180 struct CollisionHull
00181 {
00185 struct HullPolygon
00186 {
00187
00188 float mPlane[4];
00189
00190 uint16_t mNbVerts;
00191
00192 uint16_t mIndexBase;
00193 };
00195
00196 uint32_t pointsCount;
00197 uint32_t indicesCount;
00198 uint32_t polygonDataCount;
00199 physx::PxVec3* points;
00200 uint32_t* indices;
00201 HullPolygon* polygonData;
00202
00203 virtual ~CollisionHull() {}
00204
00205 virtual void release() = 0;
00206 };
00207
00211 struct AuthoringResult
00212 {
00213 uint32_t chunkCount;
00214
00215 uint32_t bondCount;
00216
00217 NvBlastAsset* asset;
00218
00223 uint32_t* assetToFractureChunkIdMap;
00224
00230 uint32_t* geometryOffset;
00231
00232 Triangle* geometry;
00233
00234 NvBlastChunkDesc* chunkDescs;
00235
00236 NvBlastBondDesc* bondDescs;
00237
00243 uint32_t* collisionHullOffset;
00244
00245 CollisionHull** collisionHull;
00246
00250 struct ExtPxChunk* physicsChunks;
00251
00256 struct ExtPxSubchunk* physicsSubchunks;
00257
00261 const char** materialNames;
00266 uint32_t materialCount;
00267
00269 virtual ~AuthoringResult() {}
00270
00274 virtual void releaseCollisionHulls() = 0;
00275
00279 virtual void release() = 0;
00280 };
00281
00282
00283 }
00284 }
00285
00286
00287 #endif // ifndef NVBLASTAUTHORINGTYPES_H