Hi;
In Rhinocommon I can use this funtion : Intersection.MeshRay Method (Mesh, Ray3d,Int32 ), find the faces which intersect with the Ray, but I search the Rhino c++ sdk along time, I was not found the funtion like it, how cant I solve it?
dale
(Dale Fugier)
October 3, 2018, 1:09am
2
Hi @suc_kiet ,
Use the ON_RayShooter
class. See opennurbs_plus.h for itβs declaration.
β Dale
Hi@dale;
I have see it, in ON_RayShooter class, just have the funtion abaut surface.
So I must change the mesh to surface first?
dale
(Dale Fugier)
October 31, 2018, 7:20pm
4
Hi @suc_kiet ,
Let me know if this sample code helps.
#include "stdafx.h"
/*
Description:
Finds the first intersection of a ray with a mesh.
Parameters:
mesh - [in] - A mesh to intersect.
ray - [in] - A ray to be casted.
face_indices - [out] - Faces on mesh that ray intersects (can be nullptr).
Returns:
>= 0.0 parameter along ray if successful. < 0.0 if no intersection found.
Remarks:
The ray may intersect more than one face in cases where the ray hits the edge
between two faces or the vertex corner shared by multiple faces.
*/
double SampleIntersectMeshRay(const ON_Mesh* mesh, ON_3dRay* ray, ON_SimpleArray<int>* face_indices)
{
double rc = -1.0;
if (mesh && ray)
{
This file has been truncated. show original
β Dale
1 Like