Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/10/2010 at 15:52, xxxxxxxx wrote:
User Information: Cinema 4D Version: 12 Platform: Windows ; Language(s) : C++ ;
--------- Hey everyone,
I am trying to determine where the mouse cursor is relative to the center of a polygon. If the mouse cursor is in the upper half of a polygon I would like one thing to happen, if the cursor is in the bottom half of the polygon I would like another thing to happen. Does anyone know how I would determine the location of the mouse cursor relative to the center of a polygon. Is ViewportSelect() what I will use to do this? Can someone help me out with this?
Thanks,
Shawn
On 11/10/2010 at 23:19, xxxxxxxx wrote:
One option is to use raytracing (GeRayCollider in the collider library) to shoot a ray from the viewplane along the viewing direction. From this you can get the barycentric coordinates (i.e., relative coordinates within the polygon) of the intersection point.
Best regards /Filip
On 12/10/2010 at 13:40, xxxxxxxx wrote:
Is there a sample of this somewhere?
On 12/10/2010 at 16:07, xxxxxxxx wrote:
Okay so I am able to get the barycentric coordinates with the following code.
AutoAlloc<GeRayCollider> rc; if (!rc) return FALSE; rc->Init(objPoly, TRUE); Vector wtail = bd->SW(Vector(mousex,mousey,0)); Vector whead = bd->SW(Vector(mousex,mousey,10000.0)); Vector otail = (!objPoly->GetMg()) * wtail; Vector oray = (whead - wtail) ^ (!objPoly->GetMg()); rc->Intersect(otail, !oray, 10000.0); GeRayColResult res; if (rc->GetNearestIntersection(&res)) { Real x = res.barrycoords.x; Real y = res.barrycoords.x; Real z = res.barrycoords.x; if ( (x > 0 && x < .300) || (y > 0 && y < .300) || (z > 0 && z < .300)) { GePrint("VERTICAL"); } if ( (x > .300 && x < .700) || (y > .300 && y < .700) || (z > .300 && z < .700)) { GePrint("HORIZONTAL"); } GePrint("Barry Coords: Vector(" + RealToString(x) + "," + RealToString(y) + "," \+ RealToString(z) + ")");
So from what I am seeing, the barrycoords are different depending on the mode you are in. Is there an explaination somewhere of how those coordinates are represented for each mode (Points, polygons, and edges)
On 12/10/2010 at 16:08, xxxxxxxx wrote:
DOH! I used all x's ... sorry .. my mistake.
On 12/10/2010 at 23:44, xxxxxxxx wrote:
And here's some background on barycentric coordinates:
http://en.wikipedia.org/wiki/Barycentric_coordinate_system_(mathematics)
On 13/10/2010 at 14:16, xxxxxxxx wrote:
Thanks for the info and link FilipM