THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/05/2009 at 02:03, xxxxxxxx wrote:
Cinema 4D Version: 11
Platform: Windows ; Mac OSX ;
Language(s) : C++ ;
I need to control that the points of an object are inside to another polygon!
The only way that I found to do this, is to verify the 6 directions for every points (X,-X,Y,-Y,Z,-Z) if there is a collision in every direction the point is inside!
This is my code, the strange thing is that seems that some points (that are inside perfectly) failed the collider procedure (usually in one direction).
I tried this with 2 simple polygons, HEXA outside and Sphere inside!
I don't understand why? Where I make mistake?
Bool find_ext_pts(BaseObject *objin,BaseObject *objout,BaseSelect* Asel)
const Vector* padr = ToPoint(objin)->GetPointR();
LONG pcnt = ToPoint(objin)->GetPointCount();
if (!pcnt) return FALSE;
v=mo2c*padr _;//fit outsideobj coordinate
for (k=0;k<6;k++)//six tests
On 29/05/2009 at 08:52, xxxxxxxx wrote:
the problem is with precission of
Intersect() and 100000 !
You should keep max_distance as smalls as possible, preferable only diameter of bounding sphere of you object.
> //something like this
> Real ray_length = Len(objin->GetRad()*2.01);
On 29/05/2009 at 08:57, xxxxxxxx wrote:
Start with a bounding volume test (a spherical center-radius calculated from the points of the object). This will be a VERY quick first test for point containment: any point whose distance from the center is greater than the radius is not contained in the object. You can also use an AABB but the spherical test is faster.
After that, there are many methods out there, but mostly dealing with polyhedra (closed, convex surfaces). BSP tress and Convex hulls are two ways for more generalized determination. Your method seems close to the Jordan Curve Theorem method. The best that I can do is suggest this link for ideas:
On 29/05/2009 at 09:29, xxxxxxxx wrote:
Thank's Remo verymuch!
I tried it and seems work well now!
I didn't know this, I was thinking that was a problem of C4d collision library!
On 29/05/2009 at 09:36, xxxxxxxx wrote:
The link is very interesting,
I'll read it carefully!