Edge Points
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/11/2002 at 17:02, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.012
Platform: Windows ;
Language(s) : C++ ;---------
Hi,
I am about to make a Tool Plugin and need the position on an edge when the mouse pointer gets over it. So when the mouse pointer is over a certain edge (position) these Coordinates should be returned. What would be the best way? Could somebody point me into the right direction?
Thanks in advance
Samir -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/11/2002 at 01:18, xxxxxxxx wrote:
Quote: Originally posted by 3D Designer on 10 November 2002
>
> * * *
>
> Hi,
>
> I am about to make a Tool Plugin and need the position on an edge when the mouse pointer gets over it. So when the mouse pointer is over a certain edge (position) these Coordinates should be returned. What would be the best way? Could somebody point me into the right direction?
This should be done in ToolData::GetCursorInfo() then. An easy way is to use the collider library. I don't know if it's the fastest way. Either you can use GeRayCollider and look for barrycentric coordinates close to zero (this cannot detect when you're close to an edge outside the object) :BaseObject* obj = doc->GetActiveObject(); if (!obj) return FALSE; AutoAlloc<GeRayCollider> rc; if (!rc) return FALSE; rc->Init(obj, TRUE); Vector wtail = bd->SW(Vector(x,y,0)); Vector whead = bd->SW(Vector(x,y,10000.0)); Vector otail = (!obj->GetMg()) * wtail; Vector oray = (whead - wtail) ^ (!obj->GetMg()); rc->Intersect(otail, !oray, 10000.0); GeRayColResult res; if (rc->GetNearestIntersection(&res)) { // look at res.barrycoords }
You could probably also use GeColliderEngine with a probe triangle as second collision object to overcome the outside limitiation.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/11/2002 at 02:25, xxxxxxxx wrote:
Quote: Originally posted by Mikael Sterner on 11 November 2002
>
> * * *
>
>> Quote: Originally posted by 3D Designer on 10 November 2002
>>
>> * * *
>>
>> Hi,
>>
>> I am about to make a Tool Plugin and need the position on an edge when the mouse pointer gets over it. So when the mouse pointer is over a certain edge (position) these Coordinates should be returned. What would be the best way? Could somebody point me into the right direction?
>
> This should be done in ToolData::GetCursorInfo() then. An easy way is to use the collider library. I don't know if it's the fastest way. Either you can use GeRayCollider and look for barrycentric coordinates close to zero (this cannot detect when you're close to an edge outside the object) :
>
>\> \> \> BaseObject* obj = doc->GetActiveObject(); \> > if (!obj) return FALSE; \> \> \> \> \> AutoAlloc<GeRayCollider> rc; \> > if (!rc) return FALSE; \> > rc->Init(obj, TRUE); \> \> \> \> \> Vector wtail = bd->SW(Vector(x,y,0)); \> > Vector whead = bd->SW(Vector(x,y,10000.0)); \> > Vector otail = (!obj->GetMg()) * wtail; \> > Vector oray = (whead - wtail) ^ (!obj->GetMg()); \> \> \> \> \> rc->Intersect(otail, !oray, 10000.0); \> \> \> \> \> GeRayColResult res; \> > if (rc->GetNearestIntersection(&res)) \> > { \> > // look at res.barrycoords \> > } \> \>
>
> You could probably also use GeColliderEngine with a probe triangle as second collision object to overcome the outside limitiation.
>
> * * *
Hi Mikael,
thanks very much for the quick response. That looks fine. I will try that.
Best
Samir -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/11/2002 at 07:05, xxxxxxxx wrote:
Hmm, I got the coords of any intersection stored in GeRayColResult res but I always get Barrycentric Coordinates of (0,0,0)? I tried to look up some information on Barycentric Coords but couldn´t find the answer why it is like that.
Could you please elaborate that? Thanks in advance...
Anybody any ideas how to filter only ray intersections of edges and take faces out of intersection?
Thank you very much
Samir -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/11/2002 at 08:37, xxxxxxxx wrote:
Hi Sorry, my fault. I printed LONG values. *ashamed*
Thanks again. Hope I can make it.
Best
Samir -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/11/2002 at 09:55, xxxxxxxx wrote:
Quote: Originally posted by 3D Designer on 11 November 2002
>
> * * *
>
> Hmm, I got the coords of any intersection stored in GeRayColResult res but I always get Barrycentric Coordinates of (0,0,0)? I tried to look up some information on Barycentric Coords but couldn´t find the answer why it is like that.
>
> Could you please elaborate that? Thanks in advance...
I saw your posts about LONG, but perhaps I still was a bit unclear. First, barrycentric coordinates (sort of) measure the distance to the edges in a triangle. So what I should have said was that when one of the components of the barrycentric coordinates is close to zero you're close to an edge. (For example [0.7, 0.3, 0.0]. Good luck!