[1378] | 1 | #ifndef NX_FLUIDS_NXMESHDATA
|
---|
| 2 | #define NX_FLUIDS_NXMESHDATA
|
---|
| 3 | /** \addtogroup fluids
|
---|
| 4 | @{
|
---|
| 5 | */
|
---|
| 6 | /*----------------------------------------------------------------------------*\
|
---|
| 7 | |
|
---|
| 8 | | Public Interface to NovodeX Technology
|
---|
| 9 | |
|
---|
| 10 | | www.novodex.com
|
---|
| 11 | |
|
---|
| 12 | \*----------------------------------------------------------------------------*/
|
---|
| 13 |
|
---|
| 14 | /**
|
---|
| 15 | \brief Very similar to #NxMeshFlags used for the #NxSimpleTriangleMesh type.
|
---|
| 16 |
|
---|
| 17 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 18 | */
|
---|
| 19 | enum NxMeshDataFlags
|
---|
| 20 | {
|
---|
| 21 | /**
|
---|
| 22 | \brief Denotes the use of 16-bit vertex indices.
|
---|
| 23 | */
|
---|
| 24 | NX_MDF_16_BIT_INDICES = 1 << 0,
|
---|
| 25 |
|
---|
| 26 | /**
|
---|
| 27 | \brief Specifies that all floats are written compressed to 16 bit.
|
---|
| 28 | */
|
---|
| 29 | NX_MDF_16_BIT_COMPRESSED_FLOATS = 1 << 1,
|
---|
| 30 |
|
---|
| 31 | /**
|
---|
| 32 | \brief Specifies that triangle indices are generated and adjacent triangles share common vertices.
|
---|
| 33 |
|
---|
| 34 | If this flag is not set, all triangles are described as vertex triplets in the vertex array.
|
---|
| 35 | */
|
---|
| 36 | NX_MDF_INDEXED_MESH = 1 << 2,
|
---|
| 37 |
|
---|
| 38 | };
|
---|
| 39 |
|
---|
| 40 | /**
|
---|
| 41 | \brief Descriptor-like user-side class for describing fluid mesh data.
|
---|
| 42 |
|
---|
| 43 | This data type is used for specifying how the SDK is supposed to pass generated mesh data. This is used for
|
---|
| 44 | implicit mesh generation (see NxImplicitMesh) which is used to render a fluid simulated
|
---|
| 45 | by the NxFluid instance.
|
---|
| 46 |
|
---|
| 47 | The usual way to render a fluid is to create a vertex buffer containing
|
---|
| 48 | data for vertex positions and normals, then defining where this data is supposed to be written to
|
---|
| 49 | in memory by creating an NxMeshData object and using this instance to create an NxImplicitMesh
|
---|
| 50 | from a fluid. After each simulation step, the user can send the buffer data to the graphics card.
|
---|
| 51 | Vertex data elements (positions and normals) can be specified as being written to an interleaved
|
---|
| 52 | vertex buffer or into separate buffers.
|
---|
| 53 |
|
---|
| 54 | This class is very similar to NxSimpleTriangleMesh, with the difference that this user buffer
|
---|
| 55 | wrapper is used to let the SDK write to user buffers instead of reading from them.
|
---|
| 56 |
|
---|
| 57 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 58 | */
|
---|
| 59 | class NxMeshData
|
---|
| 60 | {
|
---|
| 61 | public:
|
---|
| 62 |
|
---|
| 63 | /**
|
---|
| 64 | \brief The pointer to the user specified buffer for vertex positions.
|
---|
| 65 |
|
---|
| 66 | A vertex position consists of three consequent 32 or 16 bit floats,
|
---|
| 67 | depending on whether NX_MDF_16_BIT_COMPRESSED_FLOATS has been set.
|
---|
| 68 |
|
---|
| 69 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 70 | */
|
---|
| 71 | void* verticesPosBegin;
|
---|
| 72 |
|
---|
| 73 | /**
|
---|
| 74 | \brief The pointer to the user specified buffer for vertex normals.
|
---|
| 75 |
|
---|
| 76 | A vertex normal consists of three consequent 32/16 bit floats.
|
---|
| 77 |
|
---|
| 78 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 79 | */
|
---|
| 80 | void* verticesNormalBegin;
|
---|
| 81 |
|
---|
| 82 | /**
|
---|
| 83 | \brief Specifies the distance of two vertex position start addresses in bytes.
|
---|
| 84 |
|
---|
| 85 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 86 | */
|
---|
| 87 | NxI32 verticesPosByteStride;
|
---|
| 88 |
|
---|
| 89 | /**
|
---|
| 90 | \brief Same as veticesPosByteStride for vertex normals.
|
---|
| 91 |
|
---|
| 92 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 93 | */
|
---|
| 94 | NxI32 verticesNormalByteStride;
|
---|
| 95 |
|
---|
| 96 | /**
|
---|
| 97 | \brief The maximal number of vertices which can be stored in the user vertex buffers.
|
---|
| 98 |
|
---|
| 99 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 100 | */
|
---|
| 101 | NxU32 maxVertices;
|
---|
| 102 |
|
---|
| 103 | /**
|
---|
| 104 | \brief Must point to the user allocated memory holding the number of vertices stored in the user vertex
|
---|
| 105 | buffers.
|
---|
| 106 |
|
---|
| 107 | If the SDK writes to a given vertex buffer, it also sets the numbers of elements written.
|
---|
| 108 |
|
---|
| 109 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 110 | */
|
---|
| 111 | NxU32* numVerticesPtr;
|
---|
| 112 |
|
---|
| 113 | /**
|
---|
| 114 | \brief The pointer to the user specified buffer for vertex indices.
|
---|
| 115 |
|
---|
| 116 | An index consist of one 32 or 16 bit integer, depending on whether NX_MDF_16_BIT_INDICES has been set.
|
---|
| 117 |
|
---|
| 118 | This is only used when the flag NX_MDF_INDEXED_MESH has been set.
|
---|
| 119 |
|
---|
| 120 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 121 | */
|
---|
| 122 | void* indicesBegin;
|
---|
| 123 |
|
---|
| 124 | /**
|
---|
| 125 | \brief Specifies the distance of two vertex indices start addresses in bytes.
|
---|
| 126 |
|
---|
| 127 | This is only used when the flag NX_MDF_INDEXED_MESH has been set.
|
---|
| 128 |
|
---|
| 129 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 130 | */
|
---|
| 131 | NxI32 indicesByteStride;
|
---|
| 132 |
|
---|
| 133 | /**
|
---|
| 134 | \brief The maximal number of indices which can be stored in the user index buffer.
|
---|
| 135 |
|
---|
| 136 | This is only used when the flag NX_MDF_INDEXED_MESH has been set.
|
---|
| 137 |
|
---|
| 138 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 139 | */
|
---|
| 140 | NxU32 maxIndices;
|
---|
| 141 |
|
---|
| 142 | /**
|
---|
| 143 | \brief Must point to the user allocated memory holding the number of vertex triplets used to define
|
---|
| 144 | triangles.
|
---|
| 145 |
|
---|
| 146 | If the SDK writes to a given triangle index buffer, it also sets the number of
|
---|
| 147 | triangles written. If the flag NX_MDF_INDEXED_MESH has not been set, the triangle number is
|
---|
| 148 | equal to the number of vertices divided by 3.
|
---|
| 149 |
|
---|
| 150 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 151 | */
|
---|
| 152 | NxU32* numTrianglesPtr;
|
---|
| 153 |
|
---|
| 154 | /**
|
---|
| 155 | \brief Flags of type NxMeshDataFlags
|
---|
| 156 |
|
---|
| 157 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 158 | */
|
---|
| 159 | NxU32 flags;
|
---|
| 160 |
|
---|
| 161 |
|
---|
| 162 |
|
---|
| 163 |
|
---|
| 164 | const char* name; //!< Possible debug name. The string is not copied by the SDK, only the pointer is stored.
|
---|
| 165 |
|
---|
| 166 | NX_INLINE ~NxMeshData();
|
---|
| 167 | /**
|
---|
| 168 | \brief (Re)sets the structure to the default.
|
---|
| 169 |
|
---|
| 170 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 171 | */
|
---|
| 172 |
|
---|
| 173 | NX_INLINE void setToDefault();
|
---|
| 174 | /**
|
---|
| 175 | \brief Returns true if the current settings are valid
|
---|
| 176 |
|
---|
| 177 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 178 | */
|
---|
| 179 | NX_INLINE bool isValid() const;
|
---|
| 180 |
|
---|
| 181 | /**
|
---|
| 182 | \brief Constructor sets to default.
|
---|
| 183 |
|
---|
| 184 | \warning <b>Preliminary API, subject to change</b>
|
---|
| 185 | */
|
---|
| 186 | NX_INLINE NxMeshData();
|
---|
| 187 | };
|
---|
| 188 |
|
---|
| 189 | NX_INLINE NxMeshData::NxMeshData()
|
---|
| 190 | {
|
---|
| 191 | setToDefault();
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 | NX_INLINE NxMeshData::~NxMeshData()
|
---|
| 195 | {
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | NX_INLINE void NxMeshData::setToDefault()
|
---|
| 199 | {
|
---|
| 200 | verticesPosBegin = NULL;
|
---|
| 201 | verticesNormalBegin = NULL;
|
---|
| 202 | verticesPosByteStride = 0;
|
---|
| 203 | verticesNormalByteStride = 0;
|
---|
| 204 | maxVertices = 0;
|
---|
| 205 | numVerticesPtr = NULL;
|
---|
| 206 | indicesBegin = NULL;
|
---|
| 207 | indicesByteStride = 0;
|
---|
| 208 | maxIndices = 0;
|
---|
| 209 | numTrianglesPtr = NULL;
|
---|
| 210 | flags = NX_MDF_INDEXED_MESH;
|
---|
| 211 |
|
---|
| 212 | name = NULL;
|
---|
| 213 | }
|
---|
| 214 |
|
---|
| 215 | NX_INLINE bool NxMeshData::isValid() const
|
---|
| 216 | {
|
---|
| 217 | if (numVerticesPtr && !(verticesPosBegin && verticesNormalBegin)) return false;
|
---|
| 218 | if (!numVerticesPtr && (verticesPosBegin || verticesNormalBegin)) return false;
|
---|
| 219 |
|
---|
| 220 | if (verticesPosBegin && !verticesPosByteStride) return false;
|
---|
| 221 | if (verticesNormalBegin && !verticesNormalByteStride) return false;
|
---|
| 222 |
|
---|
| 223 | if (!numVerticesPtr && numTrianglesPtr) return false;
|
---|
| 224 | if (numVerticesPtr && flags & NX_MDF_INDEXED_MESH && !numTrianglesPtr) return false;
|
---|
| 225 | if (numVerticesPtr && !(flags & NX_MDF_INDEXED_MESH) && numTrianglesPtr) return false;
|
---|
| 226 |
|
---|
| 227 | if (!numTrianglesPtr && indicesBegin) return false;
|
---|
| 228 | if (numTrianglesPtr && !indicesBegin) return false;
|
---|
| 229 |
|
---|
| 230 | if (indicesBegin && !indicesByteStride) return false;
|
---|
| 231 |
|
---|
| 232 | return true;
|
---|
| 233 | }
|
---|
| 234 |
|
---|
| 235 | /** @} */
|
---|
| 236 | #endif
|
---|
| 237 |
|
---|
| 238 |
|
---|
| 239 | //AGCOPYRIGHTBEGIN
|
---|
| 240 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 241 | // Copyright © 2005 AGEIA Technologies.
|
---|
| 242 | // All rights reserved. www.ageia.com
|
---|
| 243 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 244 | //AGCOPYRIGHTEND
|
---|
| 245 |
|
---|