DHART
|
Classes | |
struct | RayResult |
The result of casting a ray at an object. Contains distance to the hitpoint and the ID of the mesh. More... | |
Functions | |
C_INTERFACE | CreateRaytracer (HF::Geometry::MeshInfo< float > *mesh, HF::RayTracer::EmbreeRayTracer **out_raytracer, bool use_precise) |
Create a new raytracer using several meshes. More... | |
C_INTERFACE | CreateRaytracerMultiMesh (HF::Geometry::MeshInfo< float > **meshes, int num_meshes, HF::RayTracer::EmbreeRayTracer **out_raytracer, bool use_precise) |
Create a new raytracer using several meshes. More... | |
C_INTERFACE | AddMesh (HF::RayTracer::EmbreeRayTracer *ERT, HF::Geometry::MeshInfo< float > *MI) |
Add a new mesh to a raytracer. More... | |
C_INTERFACE | AddMeshes (HF::RayTracer::EmbreeRayTracer *ERT, HF::Geometry::MeshInfo< float > **MI, int number_of_meshes) |
Add a new mesh to a raytracer. More... | |
C_INTERFACE | DestroyRayTracer (HF::RayTracer::EmbreeRayTracer *rt_to_destroy) |
Delete an existing raytracer. More... | |
C_INTERFACE | CastRaysDistance (HF::RayTracer::EmbreeRayTracer *ert, float *origins, int num_origins, float *directions, int num_directions, std::vector< RayResult > **out_results, RayResult **results_data) |
Cast rays for each node in origins/directions as ordered pairs and get distance back as a result. More... | |
C_INTERFACE | CastSingleRayDistance (HF::RayTracer::EmbreeRayTracer *ert, const float *origin, const float *direction, const float max_distance, float *out_distance, int *out_meshid) |
Cast a single ray and get the distance to its hit and the mesh ID if it hit anything. If it missed, then distance and meshid will both be -1. More... | |
C_INTERFACE | CastRay (HF::RayTracer::EmbreeRayTracer *ert, float &x, float &y, float &z, float dx, float dy, float dz, float max_distance, bool &result) |
Cast a single ray from the raytracer and receive a point in return. More... | |
C_INTERFACE | CastMultipleRays (HF::RayTracer::EmbreeRayTracer *ert, float *origins, const float *directions, int size, float max_distance, bool *result_array) |
Cast multiple rays at once in parallel and receive their hitpoints in return. The number of directions must be equal to the number of origins. More... | |
C_INTERFACE | CastMultipleOriginsOneDirection (HF::RayTracer::EmbreeRayTracer *ert, float *origins, const float *direction, int size, float max_distance, bool *result_array) |
Cast rays from each origin point in the given direction. More... | |
C_INTERFACE | CastMultipleDirectionsOneOrigin (HF::RayTracer::EmbreeRayTracer *ert, const float *origin, float *directions, int size, float max_distance, bool *result_array) |
Cast rays from a single origin point in multiple directions and get a the points where they intersected the geometry. More... | |
C_INTERFACE | CastOcclusionRays (HF::RayTracer::EmbreeRayTracer *ert, const float *origins, const float *directions, int origin_size, int direction_size, float max_distance, bool *result_array) |
Cast one or more occlusion rays in parallel. More... | |
C_INTERFACE | DestroyRayResultVector (std::vector< RayResult > *analysis) |
Destroy a vector of rayresults. More... | |
C_INTERFACE | PreciseIntersection (HF::RayTracer::EmbreeRayTracer *RT, double x, double y, double z, double dx, double dy, double dz, double *out_distance) |
Perform efficient ray intersections using Intel's Embree Library.
Every example below will be assumed to begin with this body of code;
we will call it the 'setup':
First, begin by loading the .OBJ file:
Mesh setup (from objloader_C.h)
Then, create the BVH:
At this point, you are ready to use your BVH.
All examples below will assume you have already created a BVH from the .OBJ file provided.
(all examples below begin with the setup code described above)
When you are finished with the BVH, you must then release its memory resources:
After destroying the BVH,
you must also do the same for the (vector<HF::Geometry::MeshInfo> *) used by LoadOBJ.
Mesh teardown (from objloader_C.h)
>>> LoadOBJ loaded mesh successfully into loaded_obj at address 0000019C4EA752E0, code: 1
>>> CreateRaytracer created EmbreeRayTracer successfully into bvh at address 0000019C4EA12820, code: 1
The client is responsible for releasing the memory for
the mesh (vector<HF::Geometry::MeshInfo> *) and the BVH (HF::RayTracer::EmbreeRayTracer *).
Every example for each function should be followed up by the 'teardown' code described above.
C_INTERFACE AddMesh | ( | HF::RayTracer::EmbreeRayTracer * | ERT, |
HF::Geometry::MeshInfo< float > * | MI | ||
) |
#include <Cinterface/raytracer_C.h>
Add a new mesh to a raytracer.
ERT | raytracer to add the mesh to |
MI | MeshInfo to add to the raytracer. Will try to maintain IDs, however if there is a collision, then the MeshInfo will be updated to contain the ID assigned to it by the raytracer. |
Definition at line 84 of file raytracer_C.cpp.
References HF::RayTracer::EmbreeRayTracer::AddMesh().
C_INTERFACE AddMeshes | ( | HF::RayTracer::EmbreeRayTracer * | ERT, |
HF::Geometry::MeshInfo< float > ** | MI, | ||
int | number_of_meshes | ||
) |
#include <Cinterface/raytracer_C.h>
Add a new mesh to a raytracer.
ERT | raytracer toa dd the mesh to |
MI | MeshInfo to add to the raytracer. Will try to maintain IDs, however if there is a collision, then each MeshInfo will be updated to contain the ID assigned to it by the raytracer. |
number_of_meshes | Number of meshes in MI . |
Definition at line 71 of file raytracer_C.cpp.
References HF::RayTracer::EmbreeRayTracer::AddMesh().
C_INTERFACE CastMultipleDirectionsOneOrigin | ( | HF::RayTracer::EmbreeRayTracer * | ert, |
const float * | origin, | ||
float * | directions, | ||
int | size, | ||
float | max_distance, | ||
bool * | result_array | ||
) |
#include <Cinterface/raytracer_C.h>
Cast rays from a single origin point in multiple directions and get a the points where they intersected the geometry.
ert | A pointer to a valid embree raytracer. |
origin | An array of 3 floats representing the X, Y, and Z coordinates of the origin to cast from respectively |
directions | A list of floats representing directions, with each 3 floats representing one direction. If a ray cast in a direction resulted in a hit, that direction will be overwritten to the hitpoint. |
size | Number of points and directions, equal to the total number of floats in one array / 3 |
max_distance | Maximum distance a ray can travel and still hit a target |
result_array | Output parameter conatining an ordered list of booleans set to true if the their rays hit, and false if their rays did not. |
returns | HF_STATUS::OK on completion. |
Begin by loading an .obj file (Mesh setup).
Then, create a BVH (Raytracer setup) using the mesh.
Define the starting points from where the ray will cast.
Define the vector components of the ray(s) that will be cast.
Define a maximum distance value, and a container to store the ray collision results.
We can review the results by outputting the contents of the results container:
From here, please review the example at Raytracer teardown for instructions
on how to free the remainder of the resources used in this example –
which are the (vector<HF::Geometry::MeshInfo> *) and (HF::RayTracer::EmbreeRayTracer *) instances.
>>> LoadOBJ loaded mesh successfully into loaded_obj at address 0000019E906587A0, code: 1
>>> CreateRaytracer created EmbreeRayTracer successfully into bvh at address 0000019E86D22500, code: 1
>>> result[0]: hit
>>> [0, 0, 0], direction [0, 0, 0]
>>> result[1]: hit
>>> [0, 0, 0], direction [0, 0, 0]
>>> result[2]: hit
>>> [0, 0, 0], direction [0, 0, 1.19209e-07]
Definition at line 249 of file raytracer_C.cpp.
References ConvertRawFloatArrayToPoints(), HF::Exceptions::OK, and HF::RayTracer::EmbreeRayTracer::PointIntersections().
C_INTERFACE CastMultipleOriginsOneDirection | ( | HF::RayTracer::EmbreeRayTracer * | ert, |
float * | origins, | ||
const float * | direction, | ||
int | size, | ||
float | max_distance, | ||
bool * | result_array | ||
) |
#include <Cinterface/raytracer_C.h>
Cast rays from each origin point in the given direction.
ert | The raytracer to cast each ray from. |
origins | A list of floats representing origin points, with each 3 floats representing one point. |
direction | An array of 3 floats representing the X, Y, and Z coordinates respectively. |
size | Number of points and directions, equal to the total number of floats in one array / 3. |
max_distance | Maximum distance a ray can travel and still hit a target. |
result_array | Output parameter conatining an ordered list of booleans set to true if the their rays hit, and false if their rays did not. |
Begin by loading an .obj file (Mesh setup).
Then, create a BVH (Raytracer setup) using the mesh.
Define the starting points from where the ray will cast.
Define the vector components of the ray that will be cast.
Define a maximum distance value, and a container to store the ray collision results.
We can review the results by outputting the contents of the results container:
From here, please review the example at Raytracer teardown for instructions
on how to free the remainder of the resources used in this example –
which are the (vector<HF::Geometry::MeshInfo> *) and (HF::RayTracer::EmbreeRayTracer *) instances.
>>> LoadOBJ loaded mesh successfully into loaded_obj at address 0000019E90659220, code: 1
>>> CreateRaytracer created EmbreeRayTracer successfully into bvh at address 0000019E86D22BE0, code: 1
>>> result[0]: hit
>>> [0, 0, -1], from point [0, 0, 0]
>>> result[1]: hit
>>> [0, 0, -1], from point [0, 0, -2.38419e-07]
>>> result[2]: hit
>>> [0, 0, -1], from point [0, 0, 0]
Definition at line 227 of file raytracer_C.cpp.
References ConvertRawFloatArrayToPoints(), HF::Exceptions::OK, and HF::RayTracer::EmbreeRayTracer::PointIntersections().
C_INTERFACE CastMultipleRays | ( | HF::RayTracer::EmbreeRayTracer * | ert, |
float * | origins, | ||
const float * | directions, | ||
int | size, | ||
float | max_distance, | ||
bool * | result_array | ||
) |
#include <Cinterface/raytracer_C.h>
Cast multiple rays at once in parallel and receive their hitpoints in return. The number of directions must be equal to the number of origins.
ert | Raytracer to cast each ray from. |
origins | A list of floats representing origin points, with each 3 floats representing one point. If the ray cast from a point is successful, said point will be overwritten with the place it hit. |
directions | A list of floats representing ray directions, with each 3 floats representing one direction. |
size | Number of points and directions, equal to the total number of floats in one array / 3. |
max_distance | Maximum distance a ray can travel and still hit a target. Any hits beyond this point will not be recorded. |
result_array | Output parameter containing an ordered list of booleans set to true if the their rays hit, and false if their rays did not. |
Begin by loading an .obj file (Mesh setup).
Then, create a BVH (Raytracer setup) using the mesh.
Define the starting points from where the ray will cast.
Define the vector components of the ray that will be cast.
Define a maximum distance value, and a container to store the ray collision results.
We can review the results by outputting the contents of the results container:
From here, please review the example at Raytracer teardown for instructions
on how to free the remainder of the resources used in this example –
which are the (vector<HF::Geometry::MeshInfo> *) and (HF::RayTracer::EmbreeRayTracer *) instances.
>>> LoadOBJ loaded mesh successfully into loaded_obj at address 0000019E906596A0, code: 1
>>> CreateRaytracer created EmbreeRayTracer successfully into bvh at address 0000019E86D22500, code: 1
>>> result[0]: hit
>>> [0, 0, 0], direction [0, 0, -1]
>>> result[1]: hit
>>> [0, 0, -2.38419e-07], direction [0, 0, -2]
>>> result[2]: hit
>>> [0, 0, 2.38419e-07], direction [0, 0, -3]
Definition at line 199 of file raytracer_C.cpp.
References ConvertRawFloatArrayToPoints(), HF::Exceptions::OK, and HF::RayTracer::EmbreeRayTracer::PointIntersections().
C_INTERFACE CastOcclusionRays | ( | HF::RayTracer::EmbreeRayTracer * | ert, |
const float * | origins, | ||
const float * | directions, | ||
int | origin_size, | ||
int | direction_size, | ||
float | max_distance, | ||
bool * | result_array | ||
) |
#include <Cinterface/raytracer_C.h>
Cast one or more occlusion rays in parallel.
ert | A pointer to a valid embree raytracer |
origins | A list of floats representing origin points, with each 3 floats representing one point |
directions | A list of floats representing ray directions, with each 3 floats representing one direction |
origin_size | How many origins points are included are included. Note that a single origin point is 3 floats, so this should equal the length of the origin array/3. This must match direction_size or be equal to one. |
direction_size | How many directions are included. Note that a single direction is 3 floats, so this should equal the length of the origin array / 3. This must match origin_size or be equal to one. |
max_distance | Maximum distance a ray can travel and still hit a target. |
result_array | Output array booleans |
Begin by loading an .obj file (Mesh setup).
Then, create a BVH (Raytracer setup) using the mesh.
Define the starting points from where the ray will cast.
Define the vector components of the ray(s) that will be cast.
Define a maximum distance value, and a container to store the ray occlusion results.
If does_occlude is true, the ray connects.
From here, please review the example at Raytracer teardown for instructions
on how to free the remainder of the resources used in this example –
which are the (vector<HF::Geometry::MeshInfo> *) and (HF::RayTracer::EmbreeRayTracer *) instances.
>>> LoadOBJ loaded mesh successfully into loaded_obj at address 0000019E90658440, code: 1
>>> CreateRaytracer created EmbreeRayTracer successfully into bvh at address 0000019E86D22BE0, code: 1
>>> Using multidirection, single origin
>>> Does the ray connect? True
Definition at line 271 of file raytracer_C.cpp.
References ConvertRawFloatArrayToPoints(), HF::RayTracer::EmbreeRayTracer::Occlusions(), and HF::Exceptions::OK.
C_INTERFACE CastRay | ( | HF::RayTracer::EmbreeRayTracer * | ert, |
float & | x, | ||
float & | y, | ||
float & | z, | ||
float | dx, | ||
float | dy, | ||
float | dz, | ||
float | max_distance, | ||
bool & | result | ||
) |
#include <Cinterface/raytracer_C.h>
Cast a single ray from the raytracer and receive a point in return.
ert | Raytracer to cast each ray from. |
x | x coordinate of the ray's origin. Will be set to the hit point's x coordinate if the ray something. |
y | y coordinate of the ray's origin. Will be set to the hit point's y coordinate if the ray something. |
z | z coordinate of the ray's origin. Will be set to the hit point's z coordinate if the ray something. |
dx | x coordinate of the ray's direction. |
dy | y coordinate of the ray's direction. |
dz | z coordinate of the ray's direction. |
max_distance | Maximum distance to record a hit within. Any hits beyond this distance will not be counted. |
result | Set to true if the ray hits, false otherwise |
Begin by loading an .obj file (Mesh setup).
Then, create a BVH (Raytracer setup) using the mesh.
Define the starting points from where the ray will cast.
Define the vector components of the ray that will be cast.
Define a maximum distance value, and a hit point that determines the ray's intended destination..
Invoke PointIntersection . did_hit will be set true if a hit occurred.
From here, please review the example at Raytracer teardown for instructions
on how to free the remainder of the resources used in this example –
which are the (vector<HF::Geometry::MeshInfo> *) and (HF::RayTracer::EmbreeRayTracer *) instances.
>>> LoadOBJ loaded mesh successfully into loaded_obj at address 0000019E906599A0, code: 1
>>> CreateRaytracer created EmbreeRayTracer successfully into bvh at address 0000019E86D22BE0, code: 1
>>> Hit point: [0, 0, 0]
Definition at line 193 of file raytracer_C.cpp.
References HF::Exceptions::OK, and HF::RayTracer::EmbreeRayTracer::PointIntersection().
C_INTERFACE CastRaysDistance | ( | HF::RayTracer::EmbreeRayTracer * | ert, |
float * | origins, | ||
int | num_origins, | ||
float * | directions, | ||
int | num_directions, | ||
std::vector< RayResult > ** | out_results, | ||
RayResult ** | results_data | ||
) |
#include <Cinterface/raytracer_C.h>
Cast rays for each node in origins/directions as ordered pairs and get distance back as a result.
ert | The raytracer to use for casting every ray. |
origins | An array of origin points to cast rays from. Should be an array of floats with every 3 floats representing a new origin point. |
num_origins | The number of points in origins. NOTE: This should be equal to the length of origins / 3, since every 3 floats in origins equals a single point. |
directions | An array of directions points to cast rays from. Should be an array of floats with every 3 floats representing a new direction. |
num_directions | The number of directions in directions. NOTE: This should be equal to the length of directions / 3, since every 3 floats in directions equals a single direction. |
out_results | Output parameter for ray results. |
results_data | Output parameter for the data of the array held by out_results |
Equal amount of directions/origins: Cast a ray for every pair of origin/direction in order. i.e. (origin[0], direction[0]), (origin[1], direction[1]).
One direction, multiple origins: Cast a ray in the given direction from each origin point in origins.
One origin, multiple directions: Cast a ray from the origin point in each direction in directions.
Begin by loading an .obj file (Mesh setup).
Then, create a BVH (Raytracer setup) using the mesh.
Define the starting points from where the ray will cast.
Define the vector components of the ray that will be cast.
Prepare a pointer to std::vector<RayResult>, and a pointer to a RayResult .
Then, invoke CastRaysDistance .
We can review the results by outputting the contents of the results container:
From here, please review the example at Raytracer teardown for instructions
on how to free the remainder of the resources used in this example –
which are the (vector<HF::Geometry::MeshInfo> *) and (HF::RayTracer::EmbreeRayTracer *) instances.
>>> LoadOBJ loaded mesh successfully into loaded_obj at address 0000019C4EA752E0, code: 1
>>> CreateRaytracer created EmbreeRayTracer successfully into bvh at address 0000019C4EA12280, code: 1
>>> Ray result: [{Distance: 2
>>> Mesh ID: 0}, {Distance: 1.5
>>> Mesh ID: 0}, {Distance: 1.33333
>>> Mesh ID: 0}]
Definition at line 111 of file raytracer_C.cpp.
References ConvertRawFloatArrayToPoints(), HF::Exceptions::GENERIC_ERROR, HF::RayTracer::EmbreeRayTracer::IntersectOutputArguments(), and HF::Exceptions::OK.
C_INTERFACE CastSingleRayDistance | ( | HF::RayTracer::EmbreeRayTracer * | ert, |
const float * | origin, | ||
const float * | direction, | ||
const float | max_distance, | ||
float * | out_distance, | ||
int * | out_meshid | ||
) |
#include <Cinterface/raytracer_C.h>
Cast a single ray and get the distance to its hit and the mesh ID if it hit anything. If it missed, then distance and meshid will both be -1.
ert | The ray tracer to cast from. |
origin | The origin point to cast from. |
direction | The direction to cast the ray in. |
max_distance | Maximum distance to record a hit within. Any hits beyond this distance will not be counted. |
out_distance | Out parameter for Distance to the hitpoint. Will be set to -1 if the ray didn't hit anything. |
out_meshid | Out parameter for the ID of the hit mesh. Will be set to -1 if the ray didn't hit anything. |
Begin by loading an .obj file (Mesh setup).
Then, create a BVH (Raytracer setup) using the mesh.
Define the starting points from where the ray will cast.
Define the vector components of the ray that will be cast.
Define a max_distance.
Also create variables distance and mesh_id and initialize them as shown.
They will be mutated if a hit occurs.
Then, invoke CastSingleRayDistance
If mesh_id is not -1, and distance is not -1, a hit was made.
From here, please review the example at Raytracer teardown for instructions
on how to free the remainder of the resources used in this example –
which are the (vector<HF::Geometry::MeshInfo> *) and (HF::RayTracer::EmbreeRayTracer *) instances.
>>> LoadOBJ loaded mesh successfully into loaded_obj at address 0000019C4EA3FCB0, code: 1
>>> CreateRaytracer created EmbreeRayTracer successfully into bvh at address 0000019C4EA12820, code: 1
>>> Distance is 2, meshid is 0
Definition at line 98 of file raytracer_C.cpp.
References HF::RayTracer::EmbreeRayTracer::IntersectOutputArguments(), and HF::Exceptions::OK.
C_INTERFACE CreateRaytracer | ( | HF::Geometry::MeshInfo< float > * | mesh, |
HF::RayTracer::EmbreeRayTracer ** | out_raytracer, | ||
bool | use_precise | ||
) |
#include <Cinterface/raytracer_C.h>
Create a new raytracer using several meshes.
mesh | The meshes to add to raytracer's BVH. |
out_raytracer | Output parameter for the new raytracer. |
use_precise | If true, use a more precise but slower method of triangle intersections |
Definition at line 15 of file raytracer_C.cpp.
References HF::Exceptions::GENERIC_ERROR, HF::Exceptions::INVALID_OBJ, HF::Exceptions::MISSING_DEPEND, and HF::Exceptions::OK.
C_INTERFACE CreateRaytracerMultiMesh | ( | HF::Geometry::MeshInfo< float > ** | meshes, |
int | num_meshes, | ||
HF::RayTracer::EmbreeRayTracer ** | out_raytracer, | ||
bool | use_precise | ||
) |
#include <Cinterface/raytracer_C.h>
Create a new raytracer using several meshes.
mesh | The meshes to add to raytracer's BVH. |
num_meshes | Number of meshes in meshes |
out_raytracer | Output parameter for the new raytracer. |
mesh
is null. Definition at line 39 of file raytracer_C.cpp.
References HF::Exceptions::GENERIC_ERROR, HF::Exceptions::INVALID_OBJ, HF::Exceptions::MISSING_DEPEND, and HF::Exceptions::OK.
C_INTERFACE DestroyRayResultVector | ( | std::vector< RayResult > * | analysis | ) |
#include <Cinterface/raytracer_C.h>
Destroy a vector of rayresults.
analysis | The ray results to destroy |
Definition at line 281 of file raytracer_C.cpp.
References DeleteRawPtr(), and HF::Exceptions::OK.
C_INTERFACE DestroyRayTracer | ( | HF::RayTracer::EmbreeRayTracer * | rt_to_destroy | ) |
#include <Cinterface/raytracer_C.h>
Delete an existing raytracer.
rt_to_destroy | Raytracer to destroy |
Definition at line 91 of file raytracer_C.cpp.
References HF::Exceptions::OK.
C_INTERFACE PreciseIntersection | ( | HF::RayTracer::EmbreeRayTracer * | RT, |
double | x, | ||
double | y, | ||
double | z, | ||
double | dx, | ||
double | dy, | ||
double | dz, | ||
double * | out_distance | ||
) |
#include <Cinterface/raytracer_C.h>
Definition at line 286 of file raytracer_C.cpp.
References HF::RayTracer::HitStruct< numeric_type >::distance, HF::RayTracer::EmbreeRayTracer::Intersect(), and HF::Exceptions::OK.