HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rtcore_geometry.h
Go to the documentation of this file.
1 // ======================================================================== //
2 // Copyright 2009-2018 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 
17 #pragma once
18 
19 #include "rtcore_buffer.h"
20 
22 
23 /* Opaque scene type */
24 typedef struct RTCSceneTy* RTCScene;
25 
26 /* Opaque geometry type */
27 typedef struct RTCGeometryTy* RTCGeometry;
28 
29 /* Types of geometries */
31 {
32  RTC_GEOMETRY_TYPE_TRIANGLE = 0, // triangle mesh
33  RTC_GEOMETRY_TYPE_QUAD = 1, // quad (triangle pair) mesh
34  RTC_GEOMETRY_TYPE_GRID = 2, // grid mesh
35 
36  RTC_GEOMETRY_TYPE_SUBDIVISION = 8, // Catmull-Clark subdivision surface
37 
38  RTC_GEOMETRY_TYPE_FLAT_LINEAR_CURVE = 17, // flat (ribbon-like) linear curves
39 
40  RTC_GEOMETRY_TYPE_ROUND_BEZIER_CURVE = 24, // round (tube-like) Bezier curves
41  RTC_GEOMETRY_TYPE_FLAT_BEZIER_CURVE = 25, // flat (ribbon-like) Bezier curves
42  RTC_GEOMETRY_TYPE_NORMAL_ORIENTED_BEZIER_CURVE = 26, // flat normal-oriented Bezier curves
43 
44  RTC_GEOMETRY_TYPE_ROUND_BSPLINE_CURVE = 32, // round (tube-like) B-spline curves
45  RTC_GEOMETRY_TYPE_FLAT_BSPLINE_CURVE = 33, // flat (ribbon-like) B-spline curves
46  RTC_GEOMETRY_TYPE_NORMAL_ORIENTED_BSPLINE_CURVE = 34, // flat normal-oriented B-spline curves
47 
48  RTC_GEOMETRY_TYPE_ROUND_HERMITE_CURVE = 40, // round (tube-like) Hermite curves
49  RTC_GEOMETRY_TYPE_FLAT_HERMITE_CURVE = 41, // flat (ribbon-like) Hermite curves
50  RTC_GEOMETRY_TYPE_NORMAL_ORIENTED_HERMITE_CURVE = 42, // flat normal-oriented Hermite curves
51 
55 
56  RTC_GEOMETRY_TYPE_ROUND_CATMULL_ROM_CURVE = 58, // round (tube-like) Catmull-Rom curves
57  RTC_GEOMETRY_TYPE_FLAT_CATMULL_ROM_CURVE = 59, // flat (ribbon-like) Catmull-Rom curves
58  RTC_GEOMETRY_TYPE_NORMAL_ORIENTED_CATMULL_ROM_CURVE = 60, // flat normal-oriented Catmull-Rom curves
59 
60  RTC_GEOMETRY_TYPE_USER = 120, // user-defined geometry
61  RTC_GEOMETRY_TYPE_INSTANCE = 121 // scene instance
62 };
63 
64 /* Interpolation modes for subdivision surfaces */
66 {
72 };
73 
74 /* Curve segment flags */
76 {
79 };
80 
81 /* Arguments for RTCBoundsFunction */
83 {
85  unsigned int primID;
86  unsigned int timeStep;
87  struct RTCBounds* bounds_o;
88 };
89 
90 /* Bounding callback function */
92 
93 /* Arguments for RTCIntersectFunctionN */
95 {
96  int* valid;
98  unsigned int primID;
100  struct RTCRayHitN* rayhit;
101  unsigned int N;
102 };
103 
104 /* Intersection callback function */
106 
107 /* Arguments for RTCOccludedFunctionN */
109 {
110  int* valid;
112  unsigned int primID;
114  struct RTCRayN* ray;
115  unsigned int N;
116 };
117 
118 /* Occlusion callback function */
120 
121 /* Arguments for RTCDisplacementFunctionN */
123 {
126  unsigned int primID;
127  unsigned int timeStep;
128  const float* u;
129  const float* v;
130  const float* Ng_x;
131  const float* Ng_y;
132  const float* Ng_z;
133  float* P_x;
134  float* P_y;
135  float* P_z;
136  unsigned int N;
137 };
138 
139 /* Displacement mapping callback function */
141 
142 /* Creates a new geometry of specified type. */
144 
145 /* Retains the geometry (increments the reference count). */
147 
148 /* Releases the geometry (decrements the reference count) */
150 
151 /* Commits the geometry. */
153 
154 
155 /* Enables the geometry. */
157 
158 /* Disables the geometry. */
160 
161 
162 /* Sets the number of motion blur time steps of the geometry. */
163 RTC_API void rtcSetGeometryTimeStepCount(RTCGeometry geometry, unsigned int timeStepCount);
164 
165 /* Sets the motion blur time range of the geometry. */
166 RTC_API void rtcSetGeometryTimeRange(RTCGeometry geometry, float startTime, float endTime);
167 
168 /* Sets the number of vertex attributes of the geometry. */
169 RTC_API void rtcSetGeometryVertexAttributeCount(RTCGeometry geometry, unsigned int vertexAttributeCount);
170 
171 /* Sets the ray mask of the geometry. */
173 
174 /* Sets the build quality of the geometry. */
176 
177 
178 /* Sets a geometry buffer. */
179 RTC_API void rtcSetGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot, enum RTCFormat format, RTCBuffer buffer, size_t byteOffset, size_t byteStride, size_t itemCount);
180 
181 /* Sets a shared geometry buffer. */
182 RTC_API void rtcSetSharedGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot, enum RTCFormat format, const void* ptr, size_t byteOffset, size_t byteStride, size_t itemCount);
183 
184 /* Creates and sets a new geometry buffer. */
185 RTC_API void* rtcSetNewGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot, enum RTCFormat format, size_t byteStride, size_t itemCount);
186 
187 /* Returns the pointer to the data of a buffer. */
189 
190 /* Updates a geometry buffer. */
192 
193 
194 /* Sets the intersection filter callback function of the geometry. */
196 
197 /* Sets the occlusion filter callback function of the geometry. */
199 
200 /* Sets the user-defined data pointer of the geometry. */
202 
203 /* Gets the user-defined data pointer of the geometry. */
205 
206 /* Set the point query callback function of a geometry. */
208 
209 /* Sets the number of primitives of a user geometry. */
210 RTC_API void rtcSetGeometryUserPrimitiveCount(RTCGeometry geometry, unsigned int userPrimitiveCount);
211 
212 /* Sets the bounding callback function to calculate bounding boxes for user primitives. */
214 
215 /* Set the intersect callback function of a user geometry. */
217 
218 /* Set the occlusion callback function of a user geometry. */
220 
221 /* Invokes the intersection filter from the intersection callback function. */
223 
224 /* Invokes the occlusion filter from the occlusion callback function. */
225 RTC_API void rtcFilterOcclusion(const struct RTCOccludedFunctionNArguments* args, const struct RTCFilterFunctionNArguments* filterArgs);
226 
227 
228 /* Sets the instanced scene of an instance geometry. */
230 
231 /* Sets the transformation of an instance for the specified time step. */
232 RTC_API void rtcSetGeometryTransform(RTCGeometry geometry, unsigned int timeStep, enum RTCFormat format, const void* xfm);
233 
234 /* Returns the interpolated transformation of an instance for the specified time. */
236 
237 
238 /* Sets the uniform tessellation rate of the geometry. */
239 RTC_API void rtcSetGeometryTessellationRate(RTCGeometry geometry, float tessellationRate);
240 
241 /* Sets the number of topologies of a subdivision surface. */
242 RTC_API void rtcSetGeometryTopologyCount(RTCGeometry geometry, unsigned int topologyCount);
243 
244 /* Sets the subdivision interpolation mode. */
246 
247 /* Binds a vertex attribute to a topology of the geometry. */
248 RTC_API void rtcSetGeometryVertexAttributeTopology(RTCGeometry geometry, unsigned int vertexAttributeID, unsigned int topologyID);
249 
250 /* Sets the displacement callback function of a subdivision surface. */
252 
253 /* Returns the first half edge of a face. */
254 RTC_API unsigned int rtcGetGeometryFirstHalfEdge(RTCGeometry geometry, unsigned int faceID);
255 
256 /* Returns the face the half edge belongs to. */
257 RTC_API unsigned int rtcGetGeometryFace(RTCGeometry geometry, unsigned int edgeID);
258 
259 /* Returns next half edge. */
260 RTC_API unsigned int rtcGetGeometryNextHalfEdge(RTCGeometry geometry, unsigned int edgeID);
261 
262 /* Returns previous half edge. */
263 RTC_API unsigned int rtcGetGeometryPreviousHalfEdge(RTCGeometry geometry, unsigned int edgeID);
264 
265 /* Returns opposite half edge. */
266 RTC_API unsigned int rtcGetGeometryOppositeHalfEdge(RTCGeometry geometry, unsigned int topologyID, unsigned int edgeID);
267 
268 
269 /* Arguments for rtcInterpolate */
271 {
273  unsigned int primID;
274  float u;
275  float v;
277  unsigned int bufferSlot;
278  float* P;
279  float* dPdu;
280  float* dPdv;
281  float* ddPdudu;
282  float* ddPdvdv;
283  float* ddPdudv;
284  unsigned int valueCount;
285 };
286 
287 /* Interpolates vertex data to some u/v location and optionally calculates all derivatives. */
289 
290 /* Interpolates vertex data to some u/v location. */
291 RTC_FORCEINLINE void rtcInterpolate0(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot, float* P, unsigned int valueCount)
292 {
293  struct RTCInterpolateArguments args;
294  args.geometry = geometry;
295  args.primID = primID;
296  args.u = u;
297  args.v = v;
298  args.bufferType = bufferType;
299  args.bufferSlot = bufferSlot;
300  args.P = P;
301  args.dPdu = NULL;
302  args.dPdv = NULL;
303  args.ddPdudu = NULL;
304  args.ddPdvdv = NULL;
305  args.ddPdudv = NULL;
306  args.valueCount = valueCount;
307  rtcInterpolate(&args);
308 }
309 
310 /* Interpolates vertex data to some u/v location and calculates first order derivatives. */
311 RTC_FORCEINLINE void rtcInterpolate1(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot,
312  float* P, float* dPdu, float* dPdv, unsigned int valueCount)
313 {
314  struct RTCInterpolateArguments args;
315  args.geometry = geometry;
316  args.primID = primID;
317  args.u = u;
318  args.v = v;
319  args.bufferType = bufferType;
320  args.bufferSlot = bufferSlot;
321  args.P = P;
322  args.dPdu = dPdu;
323  args.dPdv = dPdv;
324  args.ddPdudu = NULL;
325  args.ddPdvdv = NULL;
326  args.ddPdudv = NULL;
327  args.valueCount = valueCount;
328  rtcInterpolate(&args);
329 }
330 
331 /* Interpolates vertex data to some u/v location and calculates first and second order derivatives. */
332 RTC_FORCEINLINE void rtcInterpolate2(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot,
333  float* P, float* dPdu, float* dPdv, float* ddPdudu, float* ddPdvdv, float* ddPdudv, unsigned int valueCount)
334 {
335  struct RTCInterpolateArguments args;
336  args.geometry = geometry;
337  args.primID = primID;
338  args.u = u;
339  args.v = v;
340  args.bufferType = bufferType;
341  args.bufferSlot = bufferSlot;
342  args.P = P;
343  args.dPdu = dPdu;
344  args.dPdv = dPdv;
345  args.ddPdudu = ddPdudu;
346  args.ddPdvdv = ddPdvdv;
347  args.ddPdudv = ddPdudv;
348  args.valueCount = valueCount;
349  rtcInterpolate(&args);
350 }
351 
352 /* Arguments for rtcInterpolateN */
354 {
356  const void* valid;
357  const unsigned int* primIDs;
358  const float* u;
359  const float* v;
360  unsigned int N;
362  unsigned int bufferSlot;
363  float* P;
364  float* dPdu;
365  float* dPdv;
366  float* ddPdudu;
367  float* ddPdvdv;
368  float* ddPdudv;
369  unsigned int valueCount;
370 };
371 
372 /* Interpolates vertex data to an array of u/v locations. */
374 
375 /* RTCGrid primitive for grid mesh */
376 struct RTCGrid
377 {
378  unsigned int startVertexID;
379  unsigned int stride;
380  unsigned short width,height; // max is a 32k x 32k grid
381 };
382 
384 
385 
RTC_API void rtcSetGeometryOccludedFilterFunction(RTCGeometry geometry, RTCFilterFunctionN filter)
RTC_API void rtcFilterOcclusion(const struct RTCOccludedFunctionNArguments *args, const struct RTCFilterFunctionNArguments *filterArgs)
RTC_API void rtcDisableGeometry(RTCGeometry geometry)
RTC_API void rtcSetGeometryTimeRange(RTCGeometry geometry, float startTime, float endTime)
RTC_API void rtcEnableGeometry(RTCGeometry geometry)
RTC_API void rtcSetGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot, enum RTCFormat format, RTCBuffer buffer, size_t byteOffset, size_t byteStride, size_t itemCount)
void(* RTCOccludedFunctionN)(const struct RTCOccludedFunctionNArguments *args)
RTCCurveFlags
RTC_FORCEINLINE void rtcInterpolate1(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot, float *P, float *dPdu, float *dPdv, unsigned int valueCount)
struct RTCBounds * bounds_o
RTC_API void rtcSetGeometryUserData(RTCGeometry geometry, void *ptr)
GLenum mode
Definition: glew.h:2163
enum RTCBufferType bufferType
const Args & args
Definition: printf.h:628
GT_API const UT_StringHolder time
RTC_API void rtcSetGeometryIntersectFunction(RTCGeometry geometry, RTCIntersectFunctionN intersect)
RTC_API void * rtcSetNewGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot, enum RTCFormat format, size_t byteStride, size_t itemCount)
RTC_API void rtcSetGeometryTransform(RTCGeometry geometry, unsigned int timeStep, enum RTCFormat format, const void *xfm)
RTC_API unsigned int rtcGetGeometryFirstHalfEdge(RTCGeometry geometry, unsigned int faceID)
RTC_API void rtcSetGeometryUserPrimitiveCount(RTCGeometry geometry, unsigned int userPrimitiveCount)
RTC_API void rtcInterpolateN(const struct RTCInterpolateNArguments *args)
RTC_API void rtcSetGeometryIntersectFilterFunction(RTCGeometry geometry, RTCFilterFunctionN filter)
const GLdouble * v
Definition: glew.h:1391
#define RTC_FORCEINLINE
Definition: rtcore_common.h:54
GLenum GLint GLuint mask
Definition: glew.h:1845
RTC_API void * rtcGetGeometryBufferData(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot)
#define RTC_API
Definition: rtcore_config.h:65
typedefRTC_NAMESPACE_BEGIN struct RTCDeviceTy * RTCDevice
Definition: rtcore_device.h:24
RTC_API void rtcFilterIntersection(const struct RTCIntersectFunctionNArguments *args, const struct RTCFilterFunctionNArguments *filterArgs)
RTCBuildQuality
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glew.h:2981
RTC_API unsigned int rtcGetGeometryOppositeHalfEdge(RTCGeometry geometry, unsigned int topologyID, unsigned int edgeID)
struct RTCIntersectContext * context
unsigned short height
RTC_FORCEINLINE void rtcInterpolate0(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot, float *P, unsigned int valueCount)
struct RTCGeometryTy * RTCGeometry
RTC_API void rtcSetGeometryVertexAttributeCount(RTCGeometry geometry, unsigned int vertexAttributeCount)
bool intersect(const Line3< T > &line, const Vec3< T > &v0, const Vec3< T > &v1, const Vec3< T > &v2, Vec3< T > &pt, Vec3< T > &barycentric, bool &front)
RTC_API void rtcSetGeometrySubdivisionMode(RTCGeometry geometry, unsigned int topologyID, enum RTCSubdivisionMode mode)
enum RTCBufferType bufferType
RTC_API void rtcSetGeometryOccludedFunction(RTCGeometry geometry, RTCOccludedFunctionN occluded)
RTCSubdivisionMode
GLuint buffer
Definition: glew.h:1680
RTC_API void rtcSetGeometryDisplacementFunction(RTCGeometry geometry, RTCDisplacementFunctionN displacement)
void(* RTCFilterFunctionN)(const struct RTCFilterFunctionNArguments *args)
unsigned int startVertexID
RTC_API void rtcSetGeometryPointQueryFunction(RTCGeometry geometry, RTCPointQueryFunction pointQuery)
RTC_API void rtcCommitGeometry(RTCGeometry geometry)
void
Definition: png.h:1083
RTC_API void * rtcGetGeometryUserData(RTCGeometry geometry)
void(* RTCIntersectFunctionN)(const struct RTCIntersectFunctionNArguments *args)
RTC_API unsigned int rtcGetGeometryFace(RTCGeometry geometry, unsigned int edgeID)
const unsigned int * primIDs
struct RTCIntersectContext * context
RTC_API void rtcInterpolate(const struct RTCInterpolateArguments *args)
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
unsigned int stride
RTC_API void rtcRetainGeometry(RTCGeometry geometry)
RTC_API unsigned int rtcGetGeometryNextHalfEdge(RTCGeometry geometry, unsigned int edgeID)
void(* RTCDisplacementFunctionN)(const struct RTCDisplacementFunctionNArguments *args)
#define RTC_NAMESPACE_END
Definition: rtcore_config.h:33
const void * ptr(const T *p)
Definition: format.h:3292
void(* RTCBoundsFunction)(const struct RTCBoundsFunctionArguments *args)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: glew.h:1254
RTC_API void rtcReleaseGeometry(RTCGeometry geometry)
RTC_API void rtcSetGeometryMask(RTCGeometry geometry, unsigned int mask)
typedefRTC_NAMESPACE_BEGIN struct RTCSceneTy * RTCScene
RTC_API void rtcSetGeometryBuildQuality(RTCGeometry geometry, enum RTCBuildQuality quality)
RTC_API unsigned int rtcGetGeometryPreviousHalfEdge(RTCGeometry geometry, unsigned int edgeID)
RTC_API void rtcSetGeometryBoundsFunction(RTCGeometry geometry, RTCBoundsFunction bounds, void *userPtr)
RTC_API void rtcSetGeometryTopologyCount(RTCGeometry geometry, unsigned int topologyCount)
RTCFormat
Definition: rtcore_common.h:64
RTC_API void rtcSetGeometryVertexAttributeTopology(RTCGeometry geometry, unsigned int vertexAttributeID, unsigned int topologyID)
RTC_API RTCGeometry rtcNewGeometry(RTCDevice device, enum RTCGeometryType type)
struct RTCBufferTy * RTCBuffer
Definition: rtcore_buffer.h:47
RTC_API void rtcGetGeometryTransform(RTCGeometry geometry, float time, enum RTCFormat format, void *xfm)
RTC_API void rtcSetGeometryInstancedScene(RTCGeometry geometry, RTCScene scene)
RTC_API void rtcSetGeometryTessellationRate(RTCGeometry geometry, float tessellationRate)
bool(* RTCPointQueryFunction)(struct RTCPointQueryFunctionArguments *args)
RTC_API void rtcSetGeometryTimeStepCount(RTCGeometry geometry, unsigned int timeStepCount)
RTC_FORCEINLINE void rtcInterpolate2(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot, float *P, float *dPdu, float *dPdv, float *ddPdudu, float *ddPdvdv, float *ddPdudv, unsigned int valueCount)
RTC_API void rtcSetSharedGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot, enum RTCFormat format, const void *ptr, size_t byteOffset, size_t byteStride, size_t itemCount)
RTCGeometryType
unsigned short width
#define RTC_NAMESPACE_BEGIN
Definition: rtcore_config.h:32
RTCBufferType
Definition: rtcore_buffer.h:24
RTC_API void rtcUpdateGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot)