rtcore_geometry.h 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. // ======================================================================== //
  2. // Copyright 2009-2017 Intel Corporation //
  3. // //
  4. // Licensed under the Apache License, Version 2.0 (the "License"); //
  5. // you may not use this file except in compliance with the License. //
  6. // You may obtain a copy of the License at //
  7. // //
  8. // http://www.apache.org/licenses/LICENSE-2.0 //
  9. // //
  10. // Unless required by applicable law or agreed to in writing, software //
  11. // distributed under the License is distributed on an "AS IS" BASIS, //
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
  13. // See the License for the specific language governing permissions and //
  14. // limitations under the License. //
  15. // ======================================================================== //
  16. #ifndef __EMBREE_GEOMETRY_H__
  17. #define __EMBREE_GEOMETRY_H__
  18. /*! \ingroup embree_kernel_api */
  19. /*! \{ */
  20. /*! invalid geometry ID */
  21. #define RTC_INVALID_GEOMETRY_ID ((unsigned)-1)
  22. /*! maximal number of time steps */
  23. #define RTC_MAX_TIME_STEPS 129
  24. /*! maximal number of user vertex buffers */
  25. #define RTC_MAX_USER_VERTEX_BUFFERS 16
  26. /*! maximal number of index buffers for subdivision surfaces */
  27. #define RTC_MAX_INDEX_BUFFERS 16
  28. /*! \brief Specifies the type of buffers when mapping buffers */
  29. enum RTCBufferType
  30. {
  31. RTC_INDEX_BUFFER = 0x01000000,
  32. RTC_INDEX_BUFFER0 = 0x01000000,
  33. RTC_INDEX_BUFFER1 = 0x01000001,
  34. RTC_VERTEX_BUFFER = 0x02000000,
  35. RTC_VERTEX_BUFFER0 = 0x02000000,
  36. RTC_VERTEX_BUFFER1 = 0x02000001,
  37. RTC_USER_VERTEX_BUFFER = 0x02100000,
  38. RTC_USER_VERTEX_BUFFER0 = 0x02100000,
  39. RTC_USER_VERTEX_BUFFER1 = 0x02100001,
  40. RTC_FACE_BUFFER = 0x03000000,
  41. RTC_LEVEL_BUFFER = 0x04000001,
  42. RTC_EDGE_CREASE_INDEX_BUFFER = 0x05000000,
  43. RTC_EDGE_CREASE_WEIGHT_BUFFER = 0x06000000,
  44. RTC_VERTEX_CREASE_INDEX_BUFFER = 0x07000000,
  45. RTC_VERTEX_CREASE_WEIGHT_BUFFER = 0x08000000,
  46. RTC_HOLE_BUFFER = 0x09000001,
  47. };
  48. /*! \brief Supported types of matrix layout for functions involving matrices */
  49. enum RTCMatrixType {
  50. RTC_MATRIX_ROW_MAJOR = 0,
  51. RTC_MATRIX_COLUMN_MAJOR = 1,
  52. RTC_MATRIX_COLUMN_MAJOR_ALIGNED16 = 2,
  53. };
  54. /*! \brief Supported geometry flags to specify handling in dynamic scenes. */
  55. enum RTCGeometryFlags
  56. {
  57. RTC_GEOMETRY_STATIC = 0, //!< specifies static geometry that will change rarely
  58. RTC_GEOMETRY_DEFORMABLE = 1, //!< specifies dynamic geometry with deformable motion (BVH refit possible)
  59. RTC_GEOMETRY_DYNAMIC = 2, //!< specifies dynamic geometry with arbitrary motion (BVH refit not possible)
  60. };
  61. /*! \brief Boundary interpolation mode for subdivision surfaces.
  62. WARNING: This enum is deprecated, use RTCSubdivisionMode instead.
  63. */
  64. enum RTCBoundaryMode
  65. {
  66. RTC_BOUNDARY_NONE = 0, //!< ignores border patches
  67. RTC_BOUNDARY_SMOOTH = 1, //!< smooth border (default)
  68. RTC_BOUNDARY_EDGE_ONLY = 1, //!< soft boundary (default)
  69. RTC_BOUNDARY_EDGE_AND_CORNER = 2 //!< boundary corner vertices are sharp vertices
  70. };
  71. /*! \brief Interpolation mode for subdivision surfaces. The modes are
  72. * ordered to interpolate successively more linear. */
  73. enum RTCSubdivisionMode
  74. {
  75. RTC_SUBDIV_NO_BOUNDARY = 0, //!< ignores border patches
  76. RTC_SUBDIV_SMOOTH_BOUNDARY = 1, //!< smooth border (default)
  77. RTC_SUBDIV_PIN_CORNERS = 2, //!< smooth border with fixed corners
  78. RTC_SUBDIV_PIN_BOUNDARY = 3, //!< linearly interpolation along border
  79. RTC_SUBDIV_PIN_ALL = 4, //!< pin every vertex (interpolates every patch linearly)
  80. };
  81. /*! Intersection filter function for single rays. */
  82. typedef void (*RTCFilterFunc)(void* ptr, /*!< pointer to user data */
  83. RTCRay& ray /*!< intersection to filter */);
  84. /*! Intersection filter function for ray packets of size 4. */
  85. typedef void (*RTCFilterFunc4)(const void* valid, /*!< pointer to valid mask */
  86. void* ptr, /*!< pointer to user data */
  87. RTCRay4& ray /*!< intersection to filter */);
  88. /*! Intersection filter function for ray packets of size 8. */
  89. typedef void (*RTCFilterFunc8)(const void* valid, /*!< pointer to valid mask */
  90. void* ptr, /*!< pointer to user data */
  91. RTCRay8& ray /*!< intersection to filter */);
  92. /*! Intersection filter function for ray packets of size 16. */
  93. typedef void (*RTCFilterFunc16)(const void* valid, /*!< pointer to valid mask */
  94. void* ptr, /*!< pointer to user data */
  95. RTCRay16& ray /*!< intersection to filter */);
  96. /*! Intersection filter function for ray packets of size N. */
  97. typedef void (*RTCFilterFuncN)(int* valid, /*!< pointer to valid mask */
  98. void* userPtr, /*!< pointer to geometry user data */
  99. const RTCIntersectContext* context, /*!< intersection context as passed to rtcIntersect/rtcOccluded */
  100. struct RTCRayN* ray, /*!< ray and previous hit */
  101. const struct RTCHitN* potentialHit, /*!< potential new hit */
  102. const size_t N /*!< size of ray packet */);
  103. /*! Displacement mapping function.
  104. WARNING: This callback is deprecated, use RTCDisplacementFunc2 instead.
  105. */
  106. typedef void (*RTCDisplacementFunc)(void* ptr, /*!< pointer to user data of geometry */
  107. unsigned geomID, /*!< ID of geometry to displace */
  108. unsigned primID, /*!< ID of primitive of geometry to displace */
  109. const float* u, /*!< u coordinates (source) */
  110. const float* v, /*!< v coordinates (source) */
  111. const float* nx, /*!< x coordinates of normalized normal at point to displace (source) */
  112. const float* ny, /*!< y coordinates of normalized normal at point to displace (source) */
  113. const float* nz, /*!< z coordinates of normalized normal at point to displace (source) */
  114. float* px, /*!< x coordinates of points to displace (source and target) */
  115. float* py, /*!< y coordinates of points to displace (source and target) */
  116. float* pz, /*!< z coordinates of points to displace (source and target) */
  117. size_t N /*!< number of points to displace */ );
  118. /*! Displacement mapping function. */
  119. typedef void (*RTCDisplacementFunc2)(void* ptr, /*!< pointer to user data of geometry */
  120. unsigned geomID, /*!< ID of geometry to displace */
  121. unsigned primID, /*!< ID of primitive of geometry to displace */
  122. unsigned time, /*!< time step to calculate displacement for */
  123. const float* u, /*!< u coordinates (source) */
  124. const float* v, /*!< v coordinates (source) */
  125. const float* nx, /*!< x coordinates of normalized normal at point to displace (source) */
  126. const float* ny, /*!< y coordinates of normalized normal at point to displace (source) */
  127. const float* nz, /*!< z coordinates of normalized normal at point to displace (source) */
  128. float* px, /*!< x coordinates of points to displace (source and target) */
  129. float* py, /*!< y coordinates of points to displace (source and target) */
  130. float* pz, /*!< z coordinates of points to displace (source and target) */
  131. size_t N /*!< number of points to displace */ );
  132. /*! \brief Creates a new scene instance.
  133. WARNING: This function is deprecated, use rtcNewInstance2 instead.
  134. A scene instance contains a reference to a scene to instantiate and
  135. the transformation to instantiate the scene with. An implementation
  136. will typically transform the ray with the inverse of the provided
  137. transformation and continue traversing the ray through the provided
  138. scene. If any geometry is hit, the instance ID (instID) member of
  139. the ray will get set to the geometry ID of the instance. */
  140. RTCORE_API RTCORE_DEPRECATED unsigned rtcNewInstance (RTCScene target, //!< the scene the instance belongs to
  141. RTCScene source //!< the scene to instantiate
  142. );
  143. /*! \brief Creates a new scene instance.
  144. A scene instance contains a reference to a scene to instantiate and
  145. the transformation to instantiate the scene with. For motion blurred
  146. instances, a number of timesteps can get specified. An
  147. implementation will typically transform the ray with the inverse of
  148. the provided transformation (or inverse of linearly interpolated
  149. transformation in case of multi-segment motion blur) and continue
  150. traversing the ray through the provided scene. If any geometry is
  151. hit, the instance ID (instID) member of the ray will get set to the
  152. geometry ID of the instance. */
  153. RTCORE_API unsigned rtcNewInstance2 (RTCScene target, //!< the scene the instance belongs to
  154. RTCScene source, //!< the scene to instantiate
  155. size_t numTimeSteps = 1); //!< number of timesteps, one matrix per timestep
  156. /*! \brief Sets transformation of the instance.
  157. WARNING: This function is deprecated, use rtcSetTransform2 instead.
  158. */
  159. RTCORE_API RTCORE_DEPRECATED void rtcSetTransform (RTCScene scene, //!< scene handle
  160. unsigned geomID, //!< ID of geometry
  161. RTCMatrixType layout, //!< layout of transformation matrix
  162. const float* xfm //!< pointer to transformation matrix
  163. );
  164. /*! \brief Sets transformation of the instance for specified timestep */
  165. RTCORE_API void rtcSetTransform2 (RTCScene scene, //!< scene handle
  166. unsigned int geomID, //!< ID of geometry
  167. RTCMatrixType layout, //!< layout of transformation matrix
  168. const float* xfm, //!< pointer to transformation matrix
  169. size_t timeStep = 0 //!< timestep to set the matrix for
  170. );
  171. /*! \brief Creates a new triangle mesh. The number of triangles
  172. (numTriangles), number of vertices (numVertices), and number of time
  173. steps (1 for normal meshes, and up to RTC_MAX_TIME_STEPS for multi
  174. segment motion blur), have to get specified. The triangle indices
  175. can be set be mapping and writing to the index buffer
  176. (RTC_INDEX_BUFFER) and the triangle vertices can be set by mapping
  177. and writing into the vertex buffer (RTC_VERTEX_BUFFER). In case of
  178. multi-segment motion blur, multiple vertex buffers have to get filled
  179. (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for each time
  180. step. The index buffer has the default layout of three 32 bit
  181. integer indices for each triangle. An index points to the ith
  182. vertex. The vertex buffer stores single precision x,y,z floating
  183. point coordinates aligned to 16 bytes. The value of the 4th float
  184. used for alignment can be arbitrary. */
  185. RTCORE_API unsigned rtcNewTriangleMesh (RTCScene scene, //!< the scene the mesh belongs to
  186. RTCGeometryFlags flags, //!< geometry flags
  187. size_t numTriangles, //!< number of triangles
  188. size_t numVertices, //!< number of vertices
  189. size_t numTimeSteps = 1 //!< number of motion blur time steps
  190. );
  191. /*! \brief Creates a new quad mesh. The number of quads (numQuads),
  192. number of vertices (numVertices), and number of time steps (1 for
  193. normal meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
  194. blur), have to get specified. The quad indices can be set be mapping
  195. and writing to the index buffer (RTC_INDEX_BUFFER) and the quad
  196. vertices can be set by mapping and writing into the vertex buffer
  197. (RTC_VERTEX_BUFFER). In case of multi-segment motion blur, multiple
  198. vertex buffers have to get filled (RTC_VERTEX_BUFFER0,
  199. RTC_VERTEX_BUFFER1, etc.), one for each time step. The index buffer has
  200. the default layout of three 32 bit integer indices for each quad. An
  201. index points to the ith vertex. The vertex buffer stores single
  202. precision x,y,z floating point coordinates aligned to 16 bytes. The
  203. value of the 4th float used for alignment can be arbitrary. */
  204. RTCORE_API unsigned rtcNewQuadMesh (RTCScene scene, //!< the scene the mesh belongs to
  205. RTCGeometryFlags flags, //!< geometry flags
  206. size_t numQuads, //!< number of quads
  207. size_t numVertices, //!< number of vertices
  208. size_t numTimeSteps = 1 //!< number of motion blur time steps
  209. );
  210. /*! \brief Creates a new subdivision mesh. The number of faces
  211. (numFaces), edges/indices (numEdges), vertices (numVertices), edge
  212. creases (numEdgeCreases), vertex creases (numVertexCreases), holes
  213. (numHoles), and time steps (numTimeSteps) have to get speficied at
  214. construction time.
  215. The following buffers have to get filled by the application: the face
  216. buffer (RTC_FACE_BUFFER) contains the number edges/indices (3 or 4)
  217. of each of the numFaces faces, the index buffer (RTC_INDEX_BUFFER)
  218. contains multiple (3 or 4) 32bit vertex indices for each face and
  219. numEdges indices in total, the vertex buffer (RTC_VERTEX_BUFFER)
  220. stores numVertices vertices as single precision x,y,z floating point
  221. coordinates aligned to 16 bytes. The value of the 4th float used for
  222. alignment can be arbitrary. In case of multi-segment motion blur,
  223. multiple vertex buffers have to get filled (RTC_VERTEX_BUFFER0,
  224. RTC_VERTEX_BUFFER1, etc.), one for each time step.
  225. Optionally, the application can fill the hole buffer
  226. (RTC_HOLE_BUFFER) with numHoles many 32 bit indices of faces that
  227. should be considered non-existing.
  228. Optionally, the application can fill the level buffer
  229. (RTC_LEVEL_BUFFER) with a tessellation level for each of the numEdges
  230. edges. The subdivision level is a positive floating point value, that
  231. specifies how many quads along the edge should get generated during
  232. tessellation. The tessellation level is a lower bound, thus the
  233. implementation is free to choose a larger level. If no level buffer
  234. is specified a level of 1 is used.
  235. Optionally, the application can fill the sparse edge crease buffers
  236. to make some edges appear sharper. The edge crease index buffer
  237. (RTC_EDGE_CREASE_INDEX_BUFFER) contains numEdgeCreases many pairs of
  238. 32 bit vertex indices that specify unoriented edges. The edge crease
  239. weight buffer (RTC_EDGE_CREASE_WEIGHT_BUFFER) stores for each of
  240. theses crease edges a positive floating point weight. The larger this
  241. weight, the sharper the edge. Specifying a weight of infinify is
  242. supported and marks an edge as infinitely sharp. Storing an edge
  243. multiple times with the same crease weight is allowed, but has lower
  244. performance. Storing the an edge multiple times with different
  245. crease weights results in undefined behaviour. For a stored edge
  246. (i,j), the reverse direction edges (j,i) does not have to get stored,
  247. as both are considered the same edge.
  248. Optionally, the application can fill the sparse vertex crease buffers
  249. to make some vertices appear sharper. The vertex crease index buffer
  250. (RTC_VERTEX_CREASE_INDEX_BUFFER), contains numVertexCreases many 32
  251. bit vertex indices to speficy a set of vertices. The vertex crease
  252. weight buffer (RTC_VERTEX_CREASE_WEIGHT_BUFFER) specifies for each of
  253. these vertices a positive floating point weight. The larger this
  254. weight, the sharper the vertex. Specifying a weight of infinity is
  255. supported and makes the vertex infinitely sharp. Storing a vertex
  256. multiple times with the same crease weight is allowed, but has lower
  257. performance. Storing a vertex multiple times with different crease
  258. weights results in undefined behaviour.
  259. */
  260. RTCORE_API unsigned rtcNewSubdivisionMesh (RTCScene scene, //!< the scene the mesh belongs to
  261. RTCGeometryFlags flags, //!< geometry flags
  262. size_t numFaces, //!< number of faces
  263. size_t numEdges, //!< number of edges
  264. size_t numVertices, //!< number of vertices
  265. size_t numEdgeCreases, //!< number of edge creases
  266. size_t numVertexCreases, //!< number of vertex creases
  267. size_t numHoles, //!< number of holes
  268. size_t numTimeSteps = 1 //!< number of motion blur time steps
  269. );
  270. /*! \brief Creates a new hair geometry consisting of multiple hairs
  271. represented as cubic bezier curves with varying radii.
  272. WARNING: This function is deprecated, use rtcNewBezierHairGeometry instead.
  273. The number of curves (numCurves), number of vertices (numVertices),
  274. and number of time steps (1 for normal meshes, and up to
  275. RTC_MAX_TIME_STEPS for multi-segment motion blur), have to get
  276. specified at construction time. Further, the curve index buffer
  277. (RTC_INDEX_BUFFER) and the curve vertex buffer (RTC_VERTEX_BUFFER)
  278. have to get set by mapping and writing to the appropiate buffers. In
  279. case of multi-segment motion blur, multiple vertex buffers have to
  280. get filled (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for
  281. each time step. The index buffer has the default layout of a single
  282. 32 bit integer index for each curve, that references the start
  283. vertex of the curve. The vertex buffer stores 4 control points per
  284. curve, each such control point consists of a single precision
  285. (x,y,z) position and radius, stored in that order in
  286. memory. Individual hairs are considered to be subpixel sized which
  287. allows the implementation to approximate the intersection
  288. calculation. This in particular means that zooming onto one hair
  289. might show geometric artefacts. */
  290. RTCORE_API RTCORE_DEPRECATED unsigned rtcNewHairGeometry (RTCScene scene, //!< the scene the curves belong to
  291. RTCGeometryFlags flags, //!< geometry flags
  292. size_t numCurves, //!< number of curves
  293. size_t numVertices, //!< number of vertices
  294. size_t numTimeSteps = 1 //!< number of motion blur time steps
  295. );
  296. /*! \brief Creates a new hair geometry, consisting of multiple hairs
  297. represented as cubic bezier curves with varying radii. The number of
  298. curves (numCurves), number of vertices (numVertices), and number of
  299. time steps have to get specified at construction time (1 for normal
  300. meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
  301. blur). Further, the curve index buffer (RTC_INDEX_BUFFER) and the
  302. curve vertex buffer (RTC_VERTEX_BUFFER) have to get set by mapping
  303. and writing to the appropiate buffers. In case of multi-segment
  304. motion blur multiple vertex buffers have to get filled
  305. (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for each time
  306. step. The index buffer has the default layout of a single 32 bit
  307. integer index for each curve, that references the start vertex of
  308. the curve. The vertex buffer stores 4 control points per curve, each
  309. such control point consists of a single precision (x,y,z) position
  310. and radius, stored in that order in memory. Individual hairs are
  311. considered to be subpixel sized which allows the implementation to
  312. approximate the intersection calculation. This in particular means
  313. that zooming onto one hair might show geometric artefacts. */
  314. RTCORE_API unsigned rtcNewBezierHairGeometry (RTCScene scene, //!< the scene the curves belong to
  315. RTCGeometryFlags flags, //!< geometry flags
  316. unsigned int numCurves, //!< number of curves
  317. unsigned int numVertices, //!< number of vertices
  318. unsigned int numTimeSteps = 1 //!< number of motion blur time steps
  319. );
  320. /*! \brief Creates a new hair geometry, consisting of multiple hairs
  321. represented as cubic bspline curves with varying radii. The number
  322. of curves (numCurves), number of vertices (numVertices), and number
  323. of time steps have to get specified at construction time (1 for
  324. normal meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
  325. blur). Further, the curve index buffer (RTC_INDEX_BUFFER) and the
  326. curve vertex buffer (RTC_VERTEX_BUFFER) have to get set by mapping
  327. and writing to the appropiate buffers. In case of multi-segment
  328. motion blur multiple vertex buffers have to get filled
  329. (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for each time
  330. step. The index buffer has the default layout of a single 32 bit
  331. integer index for each curve, that references the start vertex of
  332. the curve. The vertex buffer stores 4 control points per curve, each
  333. such control point consists of a single precision (x,y,z) position
  334. and radius, stored in that order in memory. Individual hairs are
  335. considered to be subpixel sized which allows the implementation to
  336. approximate the intersection calculation. This in particular means
  337. that zooming onto one hair might show geometric artefacts. */
  338. RTCORE_API unsigned rtcNewBSplineHairGeometry (RTCScene scene, //!< the scene the curves belong to
  339. RTCGeometryFlags flags, //!< geometry flags
  340. unsigned int numCurves, //!< number of curves
  341. unsigned int numVertices, //!< number of vertices
  342. unsigned int numTimeSteps = 1 //!< number of motion blur time steps
  343. );
  344. /*! \brief Creates a new curve geometry, consisting of multiple curves
  345. represented as cubic bezier curves with varying radii.
  346. WARNING: This function is deprecated, use rtcNewBezierCurveGeometry instead.
  347. The intersected surface is defined as the sweep of a varying radius
  348. circle perpendicular along the curve. The number of curves
  349. (numCurves), number of vertices (numVertices), and number of time
  350. steps have to get specified at construction time (1 for normal
  351. meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
  352. blur). Further, the curve index buffer (RTC_INDEX_BUFFER) and the
  353. curve vertex buffer (RTC_VERTEX_BUFFER) have to get set by mapping
  354. and writing to the appropiate buffers. In case of multi-segment
  355. motion blur, multiple vertex buffers have to get filled
  356. (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for each time
  357. step. The index buffer has the default layout of a single 32 bit
  358. integer index for each curve, that references the start vertex of
  359. the curve. The vertex buffer stores 4 control points per curve, each
  360. such control point consists of a single precision (x,y,z) position
  361. and radius, stored in that order in memory. */
  362. RTCORE_API RTCORE_DEPRECATED unsigned rtcNewCurveGeometry (RTCScene scene, //!< the scene the curves belong to
  363. RTCGeometryFlags flags, //!< geometry flags
  364. size_t numCurves, //!< number of curves
  365. size_t numVertices, //!< number of vertices
  366. size_t numTimeSteps = 1 //!< number of motion blur time steps
  367. );
  368. /*! \brief Creates a new curve geometry, consisting of multiple curves
  369. represented as cubic bezier curves with varying radii. The
  370. intersected surface is defined as the sweep of a varying radius
  371. circle perpendicular along the curve. The number of curves
  372. (numCurves), number of vertices (numVertices), and number of time
  373. steps have to get specified at construction time (1 for normal
  374. meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
  375. blur). Further, the curve index buffer (RTC_INDEX_BUFFER) and the
  376. curve vertex buffer (RTC_VERTEX_BUFFER) have to get set by mapping
  377. and writing to the appropiate buffers. In case of multi-segment
  378. motion blur, multiple vertex buffers have to get filled
  379. (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for each time
  380. step. The index buffer has the default layout of a single 32 bit
  381. integer index for each curve, that references the start vertex of
  382. the curve. The vertex buffer stores 4 control points per curve, each
  383. such control point consists of a single precision (x,y,z) position
  384. and radius, stored in that order in memory. */
  385. RTCORE_API unsigned rtcNewBezierCurveGeometry (RTCScene scene, //!< the scene the curves belong to
  386. RTCGeometryFlags flags, //!< geometry flags
  387. unsigned int numCurves, //!< number of curves
  388. unsigned int numVertices, //!< number of vertices
  389. unsigned int numTimeSteps = 1 //!< number of motion blur time steps
  390. );
  391. /*! \brief Creates a new curve geometry, consisting of multiple curves
  392. represented as cubic bspline curves with varying radii. The
  393. intersected surface is defined as the sweep of a varying radius
  394. circle perpendicular along the curve. The number of curves
  395. (numCurves), number of vertices (numVertices), and number of time
  396. steps have to get specified at construction time (1 for normal
  397. meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
  398. blur). Further, the curve index buffer (RTC_INDEX_BUFFER) and the
  399. curve vertex buffer (RTC_VERTEX_BUFFER) have to get set by mapping
  400. and writing to the appropiate buffers. In case of multi-segment
  401. motion blur, multiple vertex buffers have to get filled
  402. (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for each time
  403. step. The index buffer has the default layout of a single 32 bit
  404. integer index for each curve, that references the start vertex of
  405. the curve. The vertex buffer stores 4 control points per curve, each
  406. such control point consists of a single precision (x,y,z) position
  407. and radius, stored in that order in memory. */
  408. RTCORE_API unsigned rtcNewBSplineCurveGeometry (RTCScene scene, //!< the scene the curves belong to
  409. RTCGeometryFlags flags, //!< geometry flags
  410. unsigned int numCurves, //!< number of curves
  411. unsigned int numVertices, //!< number of vertices
  412. unsigned int numTimeSteps = 1 //!< number of motion blur time steps
  413. );
  414. /*! \brief Creates a new line segment geometry, consisting of multiple
  415. segments with varying radii. The number of line segments
  416. (numSegments), number of vertices (numVertices), and number of time
  417. steps have to get specified at construction time (1 for normal
  418. meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
  419. blur). Further, the segment index buffer (RTC_INDEX_BUFFER) and the
  420. segment vertex buffer (RTC_VERTEX_BUFFER) have to get set by mapping
  421. and writing to the appropiate buffers. In case of multi-segment
  422. motion blur, multiple vertex buffers have to get filled
  423. (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for each time
  424. step. The index buffer has the default layout of a single 32 bit
  425. integer index for each line segment, that references the start
  426. vertex of the segment. The vertex buffer stores 2 end points per
  427. line segment, each such point consists of a single precision (x,y,z)
  428. position and radius, stored in that order in memory. Individual
  429. segments are considered to be subpixel sized which allows the
  430. implementation to approximate the intersection calculation. This in
  431. particular means that zooming onto one line segment might show
  432. geometric artefacts. */
  433. RTCORE_API unsigned rtcNewLineSegments (RTCScene scene, //!< the scene the line segments belong to
  434. RTCGeometryFlags flags, //!< geometry flags
  435. size_t numSegments, //!< number of line segments
  436. size_t numVertices, //!< number of vertices
  437. size_t numTimeSteps = 1 //!< number of motion blur time steps
  438. );
  439. /*! Sets a uniform tessellation rate for subdiv meshes and hair
  440. * geometry. For subdivision meshes the RTC_LEVEL_BUFFER can also be used
  441. * optionally to set a different tessellation rate per edge.*/
  442. RTCORE_API void rtcSetTessellationRate (RTCScene scene, unsigned geomID, float tessellationRate);
  443. /*! \brief Sets 32 bit ray mask. */
  444. RTCORE_API void rtcSetMask (RTCScene scene, unsigned geomID, int mask);
  445. /*! \brief Sets boundary interpolation mode for default subdivision surface topology.
  446. WARNING: This function is deprecated, use rtcSetSubdivisionMode instead.
  447. */
  448. RTCORE_API RTCORE_DEPRECATED void rtcSetBoundaryMode(RTCScene scene, unsigned geomID, RTCBoundaryMode mode);
  449. /*! \brief Sets subdivision interpolation mode for specified subdivision surface topology */
  450. RTCORE_API void rtcSetSubdivisionMode(RTCScene scene, unsigned geomID, unsigned topologyID, RTCSubdivisionMode mode);
  451. /*! \brief Binds a user vertex buffer to some index buffer topology. */
  452. RTCORE_API void rtcSetIndexBuffer(RTCScene scene, unsigned geomID, RTCBufferType vertexBuffer, RTCBufferType indexBuffer);
  453. /*! \brief Maps specified buffer. This function can be used to set index and
  454. * vertex buffers of geometries. */
  455. RTCORE_API void* rtcMapBuffer(RTCScene scene, unsigned geomID, RTCBufferType type);
  456. /*! \brief Unmaps specified buffer.
  457. A buffer has to be unmapped before the rtcEnable, rtcDisable,
  458. rtcUpdate, or rtcDeleteGeometry calls are executed. */
  459. RTCORE_API void rtcUnmapBuffer(RTCScene scene, unsigned geomID, RTCBufferType type);
  460. /*! \brief Shares a data buffer between the application and
  461. * Embree.
  462. WARNING: This function is deprecated, use rtcSetBuffer2 instead.
  463. * The passed buffer is used by Embree to store index and vertex
  464. * data. It has to remain valid as long as the mesh exists, and the
  465. * user is responsible to free the data when the mesh gets
  466. * deleted. One can optionally speficy a byte offset and byte stride
  467. * of the elements stored inside the buffer. The addresses
  468. * ptr+offset+i*stride have to be aligned to 4 bytes on Xeon CPUs and
  469. * 16 bytes on Xeon Phi accelerators. For vertex buffers, the 4 bytes
  470. * after the z-coordinate of the last vertex have to be readable
  471. * memory, thus padding is required for some layouts. If this
  472. * function is not called, Embree will allocate and manage buffers of
  473. * the default layout. */
  474. RTCORE_API void rtcSetBuffer(RTCScene scene, unsigned geomID, RTCBufferType type,
  475. const void* ptr, size_t byteOffset, size_t byteStride);
  476. /*! \brief Shares a data buffer between the application and
  477. * Embree. The data has to remain valid as long as the mesh exists,
  478. * and the user is responsible to free the data when the mesh gets
  479. * deleted. For sharing the buffer, one has to specify the number of
  480. * elements of the buffer, a byte offset to the first element, and
  481. * byte stride of elements stored inside the buffer. The addresses
  482. * ptr+offset+i*stride have to be aligned to 4 bytes. For vertex
  483. * buffers and user vertex buffers the buffer has to be padded with 0
  484. * to a size of a multiple of 16 bytes, as Embree always accesses
  485. * vertex buffers and user vertex buffers using SSE instructions. If
  486. * this function is not called, Embree will allocate and manage
  487. * buffers of the default layout. */
  488. RTCORE_API void rtcSetBuffer2(RTCScene scene, unsigned geomID, RTCBufferType type,
  489. const void* ptr, size_t byteOffset, size_t byteStride, size_t size = -1);
  490. /*! \brief Enable geometry. Enabled geometry can be hit by a ray. */
  491. RTCORE_API void rtcEnable (RTCScene scene, unsigned geomID);
  492. /*! \brief Update all geometry buffers.
  493. Each time geometry buffers got modified, the user has to call some
  494. update function to tell the ray tracing engine which buffers got
  495. modified. The rtcUpdate function taggs each geometry buffer of the
  496. specified geometry as modified. */
  497. RTCORE_API void rtcUpdate (RTCScene scene, unsigned geomID);
  498. /*! \brief Update spefific geometry buffer.
  499. Each time geometry buffers got modified, the user has to call some
  500. update function to tell the ray tracing engine which buffers got
  501. modified. The rtcUpdateBuffer function taggs a specific buffer of
  502. some geometry as modified. */
  503. RTCORE_API void rtcUpdateBuffer (RTCScene scene, unsigned geomID, RTCBufferType type);
  504. /*! \brief Disable geometry.
  505. Disabled geometry is not hit by any ray. Disabling and enabling
  506. geometry gives higher performance than deleting and recreating
  507. geometry. */
  508. RTCORE_API void rtcDisable (RTCScene scene, unsigned geomID);
  509. /*! \brief Sets the displacement function. */
  510. RTCORE_API void rtcSetDisplacementFunction (RTCScene scene, unsigned geomID, RTCDisplacementFunc func, RTCBounds* bounds);
  511. /*! \brief Sets the displacement function. */
  512. RTCORE_API void rtcSetDisplacementFunction2 (RTCScene scene, unsigned geomID, RTCDisplacementFunc2 func, RTCBounds* bounds);
  513. /*! \brief Sets the intersection filter function for single rays. */
  514. RTCORE_API void rtcSetIntersectionFilterFunction (RTCScene scene, unsigned geomID, RTCFilterFunc func);
  515. /*! \brief Sets the intersection filter function for ray packets of size 4. */
  516. RTCORE_API void rtcSetIntersectionFilterFunction4 (RTCScene scene, unsigned geomID, RTCFilterFunc4 func);
  517. /*! \brief Sets the intersection filter function for ray packets of size 8. */
  518. RTCORE_API void rtcSetIntersectionFilterFunction8 (RTCScene scene, unsigned geomID, RTCFilterFunc8 func);
  519. /*! \brief Sets the intersection filter function for ray packets of size 16. */
  520. RTCORE_API void rtcSetIntersectionFilterFunction16 (RTCScene scene, unsigned geomID, RTCFilterFunc16 func);
  521. /*! \brief Sets the intersection filter function for ray packets of size N. */
  522. RTCORE_API void rtcSetIntersectionFilterFunctionN (RTCScene scene, unsigned geomID, RTCFilterFuncN func);
  523. /*! \brief Sets the occlusion filter function for single rays. */
  524. RTCORE_API void rtcSetOcclusionFilterFunction (RTCScene scene, unsigned geomID, RTCFilterFunc func);
  525. /*! \brief Sets the occlusion filter function for ray packets of size 4. */
  526. RTCORE_API void rtcSetOcclusionFilterFunction4 (RTCScene scene, unsigned geomID, RTCFilterFunc4 func);
  527. /*! \brief Sets the occlusion filter function for ray packets of size 8. */
  528. RTCORE_API void rtcSetOcclusionFilterFunction8 (RTCScene scene, unsigned geomID, RTCFilterFunc8 func);
  529. /*! \brief Sets the occlusion filter function for ray packets of size 16. */
  530. RTCORE_API void rtcSetOcclusionFilterFunction16 (RTCScene scene, unsigned geomID, RTCFilterFunc16 func);
  531. /*! \brief Sets the occlusion filter function for ray packets of size N. */
  532. RTCORE_API void rtcSetOcclusionFilterFunctionN (RTCScene scene, unsigned geomID, RTCFilterFuncN func);
  533. /*! Set pointer for user defined data per geometry. Invokations
  534. * of the various user intersect and occluded functions get passed
  535. * this data pointer when called. */
  536. RTCORE_API void rtcSetUserData (RTCScene scene, unsigned geomID, void* ptr);
  537. /*! Get pointer for user defined data per geometry based on geomID. */
  538. RTCORE_API void* rtcGetUserData (RTCScene scene, unsigned geomID);
  539. /*! Interpolates user data to some u/v location. The data buffer
  540. * specifies per vertex data to interpolate and can be one of the
  541. * RTC_VERTEX_BUFFER0/1 or RTC_USER_VERTEX_BUFFER0/1 and has to
  542. * contain numFloats floating point values to interpolate for each
  543. * vertex of the geometry. The dP array will get filled with the
  544. * interpolated data and the dPdu and dPdv arrays with the u and v
  545. * derivative of the interpolation. If the pointers dP is NULL, the
  546. * value will not get calculated. If dPdu and dPdv are NULL the
  547. * derivatives will not get calculated. Both dPdu and dPdv have to be
  548. * either valid or NULL. The buffer has to be padded at the end such
  549. * that the last element can be read safely using SSE
  550. * instructions. */
  551. RTCORE_API void rtcInterpolate(RTCScene scene, unsigned geomID, unsigned primID, float u, float v, RTCBufferType buffer,
  552. float* P, float* dPdu, float* dPdv, size_t numFloats);
  553. /*! Interpolates user data to some u/v location. The data buffer
  554. * specifies per vertex data to interpolate and can be one of the
  555. * RTC_VERTEX_BUFFER0/1 or RTC_USER_VERTEX_BUFFER0/1 and has to
  556. * contain numFloats floating point values to interpolate for each
  557. * vertex of the geometry. The P array will get filled with the
  558. * interpolated datam the dPdu and dPdv arrays with the u and v
  559. * derivative of the interpolation, and the ddPdudu, ddPdvdv, and
  560. * ddPdudv arrays with the respective second derivatives. One can
  561. * disable 1) the calculation of the interpolated value by setting P
  562. * to NULL, 2) the calculation of the 1st order derivatives by
  563. * setting dPdu and dPdv to NULL, 3) the calculation of the second
  564. * order derivatives by setting ddPdudu, ddPdvdv, and ddPdudv to
  565. * NULL. The buffers have to be padded at the end such that the last
  566. * element can be read or written safely using SSE instructions. */
  567. RTCORE_API void rtcInterpolate2(RTCScene scene, unsigned geomID, unsigned primID, float u, float v, RTCBufferType buffer,
  568. float* P, float* dPdu, float* dPdv, float* ddPdudu, float* ddPdvdv, float* ddPdudv, size_t numFloats);
  569. /*! Interpolates user data to an array of u/v locations. The valid
  570. * pointer points to an integer array that specified which entries in
  571. * the u/v arrays are valid (-1 denotes valid, and 0 invalid). If the
  572. * valid pointer is NULL all elements are considers valid. The data
  573. * buffer specifies per vertex data to interpolate and can be one of
  574. * the RTC_VERTEX_BUFFER0/1 or RTC_USER_VERTEX_BUFFER0/1 and has to
  575. * contain numFloats floating point values to interpolate for each
  576. * vertex of the geometry. The P array will get filled with the
  577. * interpolated data, and the dPdu and dPdv arrays with the u and v
  578. * derivative of the interpolation. If the pointers P is NULL, the
  579. * value will not get calculated. If dPdu and dPdv are NULL the
  580. * derivatives will not get calculated. Both dPdu and dPdv have to be
  581. * either valid or NULL. These destination arrays are filled in
  582. * structure of array (SoA) layout. The buffer has to be padded at
  583. * the end such that the last element can be read safely using SSE
  584. * instructions.*/
  585. RTCORE_API void rtcInterpolateN(RTCScene scene, unsigned geomID,
  586. const void* valid, const unsigned* primIDs, const float* u, const float* v, size_t numUVs,
  587. RTCBufferType buffer,
  588. float* P, float* dPdu, float* dPdv, size_t numFloats);
  589. /*! Interpolates user data to an array of u/v locations. The valid
  590. * pointer points to an integer array that specified which entries in
  591. * the u/v arrays are valid (-1 denotes valid, and 0 invalid). If the
  592. * valid pointer is NULL all elements are considers valid. The data
  593. * buffer specifies per vertex data to interpolate and can be one of
  594. * the RTC_VERTEX_BUFFER0/1 or RTC_USER_VERTEX_BUFFER0/1 and has to
  595. * contain numFloats floating point values to interpolate for each
  596. * vertex of the geometry. The P array will get filled with the
  597. * interpolated datam the dPdu and dPdv arrays with the u and v
  598. * derivative of the interpolation, and the ddPdudu, ddPdvdv, and
  599. * ddPdudv arrays with the respective second derivatives. One can
  600. * disable 1) the calculation of the interpolated value by setting P
  601. * to NULL, 2) the calculation of the 1st order derivatives by
  602. * setting dPdu and dPdv to NULL, 3) the calculation of the second
  603. * order derivatives by setting ddPdudu, ddPdvdv, and ddPdudv to
  604. * NULL. These destination arrays are filled in structure of array
  605. * (SoA) layout. The buffer has to be padded at the end such that
  606. * the last element can be read safely using SSE
  607. * instructions. */
  608. RTCORE_API void rtcInterpolateN2(RTCScene scene, unsigned geomID,
  609. const void* valid, const unsigned* primIDs, const float* u, const float* v, size_t numUVs,
  610. RTCBufferType buffer,
  611. float* P, float* dPdu, float* dPdv, float* ddPdudu, float* ddPdvdv, float* ddPdudv, size_t numFloats);
  612. /*! \brief Deletes the geometry. */
  613. RTCORE_API void rtcDeleteGeometry (RTCScene scene, unsigned geomID);
  614. /*! @} */
  615. #endif