object/poly behind mouse cursor
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/07/2008 at 01:58, xxxxxxxx wrote:
ok nevermind, meanwhile i found the solution in another post here..
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/07/2008 at 02:48, xxxxxxxx wrote:
It would be maybe interesting for the other forum members to know how you solved the problem. Maybe you can share what you have found out.
cheers,
Matthias
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/07/2008 at 03:01, xxxxxxxx wrote:
of course, forgot about tat sry ;-)
im using GeRayCollider to shoot rays from my eye through the mouse cursor, just like superman would do ;-)
in the code below im checking if the ray hits the currently active object:
>
\> AutoAlloc<GeRayCollider> rc; \> if (!rc) return FALSE; \> // the object i want to know if it was hit \> BaseObject\* obj = doc->GetActiveObject(); \> \> Vector wtail = bd->SW(Vector(mx,my,0)); \> Vector whead = bd->SW(Vector(mx,my,10000.0)); \> Vector otail = (!obj->GetMg()) \* wtail; \> Vector oray = (whead - wtail) ^ (!obj->GetMg()); \> \> // init rayCollider with object to check ray collisions on \> rc->Init(obj,TRUE); \> // check for intersection, 10000 is the length of the ray \> rc->Intersect(otail, !oray, 10000.0); \> \> // if a ray has hit the object \> if(rc->GetNearestIntersection(&res;)){ \> . \> . \> // res.hitpos has the hit position \> // and res.f_normal is the normal vec of the hit polygon \> . \> . \> } \>
the stuff with the computation on the right vector, i found using the forum search here.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/07/2008 at 03:03, xxxxxxxx wrote:
Thanks for sharing
cheers,
Matthias
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/04/2011 at 05:25, xxxxxxxx wrote:
Hi,
I am trying this exact thing and am not getting any results.
Here's the code I am using.
BaseObject* pObj = doc->GetActiveObject(); if(!pObj) return FALSE; AutoAlloc<GeRayCollider> cRay; if (!cRay) return FALSE; GeRayColResult res; // Make sure RayCollider is there if (!cRay) { GePrint("ERROR - RayCollider not Initialized"); return FALSE; } Vector wtail = bd->SW(Vector(x, y, UM_START)); Vector whead = bd->SW(Vector(x, y, UM_END)) - wtail; Vector otail = (!pObj->GetMg()) * wtail; Vector oray = (whead - wtail) ^ (!pObj->GetMg()); cRay->Init(pObj, TRUE); cRay->Intersect(otail, !oray, 10000.0); if (cRay->GetNearestIntersection(&res)) { GePrint("A COLLISION HAS OCCURED"); return TRUE; } return TRUE;
I am not seeing anything in the console that says "A COLLISION HAS OCCURED" when I put my mouse over the active object... Does anyone see a reason why my code wouldn't work?
Thanks,
Shawn
EDIT: DOH! I figured it out. My collider was too short. :) Remember size does matter. ;)
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/04/2011 at 11:44, xxxxxxxx wrote:
Is there a more complete example of this?
I'm assuming that bd is a parameter used with this class method:
virtual DRAWRESULT Draw (BaseObject *op, DRAWPASS type, BaseDraw *bd, BaseDrawHelp *bh);So I'm also assuming that the DRAWRESULT method needs to also be used.
But what goes inside of it?Can anyone provide a more complete example of this?
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/04/2011 at 11:51, xxxxxxxx wrote:
what specifically would you like to achieve with it? I could be more specific if I knew what you were looking to do. :)
To answer your first question, bd is the BaseDraw that is allocated in my function. In my case I am calling my function from the Draw() function which also allocates a BaseBraw so I just use the bd from that function and pass it to my own.
If you'd like I can repost the code I posted above with more comments to explain what each thing does. :)
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/04/2011 at 12:21, xxxxxxxx wrote:
Hi Shawn,
I'm just trying to learn how to do basic ray collision that prints a message to the console when the mouse is over an object.I think I understand the code that's been posted so far. But it's only a small portion of the entire .cpp file. And I'm having trouble building the stuff that's not been listed to make it work.
Namely the classes and the methods.-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/04/2011 at 12:32, xxxxxxxx wrote:
The code above is coming from a ToolData plugin. You could put the following code in the Draw() function of a tooldata plugin,
TOOLDRAW MyClass::Draw(BaseDocument* doc, BaseContainer& data, BaseDraw* bd, BaseDrawHelp* bh, BaseThread* bt, TOOLDRAWFLAGS flags){ BaseObject* pObj = doc->GetActiveObject(); if(!pObj) return TOOLDRAW_0; AutoAlloc<GeRayCollider> cRay; if (!cRay) return TOOLDRAW_0; GeRayColResult res; // Make sure RayCollider is there if (!cRay) { GePrint("ERROR - RayCollider not Initialized"); return TOOLDRAW_0; } Vector wtail = bd->SW(Vector(mouseX, mouseY, 0)); Vector whead = bd->SW(Vector(mouseX, mouseY, 100000)); Vector otail = (!pObj->GetMg()) * wtail; Vector oray = (whead - wtail) ^ (!pObj->GetMg()); cRay->Init(pObj, TRUE); cRay->Intersect(otail, !oray, 10000.0); if (cRay->GetNearestIntersection(&res)) { GePrint("A COLLISION HAS OCCURED"); } return TOOLDRAW_0; }
mouseX and mouseY are global Reals. Both declared as global variables. Then in the GetCursorInfo() you would simply put
Bool MyClass::GetCursorInfo(BaseDocument* doc, BaseContainer& data, BaseDraw* bd, Real x, Real y, BaseContainer& bc){ mouseX = x; mouseY = y; if (x > -1.0f) SpecialEventAdd(EVMSG_UPDATEHIGHLIGHT); return TRUE; }
This should give you a working model to learn from. :) Hope that helps. ~Shawn
_<_h4_>__<_h4_>_/h4>
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/04/2011 at 13:06, xxxxxxxx wrote:
Thanks Shawn.
Got it working now.BTW: Did you ever figure out how to merge documents?
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/04/2011 at 13:11, xxxxxxxx wrote:
I did. I don't have the code here though because i am not home.. send me a PM at c4d cafe to remind me and i will send it to you when i get home. I keep forgetting to send it to you cuz when i get outa work i get focused on other things lol
sorry about that. :)
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/04/2011 at 14:07, xxxxxxxx wrote:
I'm not a member there.
My e-mail is: scottasba@hotmail.com
Thanks,
-ScottA