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).
On 22/02/2017 at 04:41, xxxxxxxx wrote:
User Information: Cinema 4D Version: R18 Platform: Windows ; Language(s) : C++ ;
--------- Hello.
I have a tooldata plugin. I need to click on any object, get the normal vector from the polygon I clicked and create in a position based on the direction of the normal.
Here is what I do:
I need to find the clicked position in World space. I feel that GeRayCollider's Intersect is the way to go, but it requires position and direction of the ray.
Here is how I get screen-to-world position (is it correct ?) :
Vector cam_pos = base_draw->GetSceneCamera(doc)->GetAbsPos(); Vector world_pos = base_draw->SW(Vector(mouse_x, mouse_x, cam_pos.z));
How do I find the direction to the clicked point ?
Thank you.
On 23/02/2017 at 04:54, xxxxxxxx wrote:
Hello, BaseView::SW() requires a vector with three components: the X and Y coordinate in screen space and the orthogonal distance from that screen space point to the desired world space point.
ViewportSelect::PickObject() fills a C4DObjectList. For a given object in that list the distance to the hit point can be obtained with C4DObjectList::GetZ(). This distance can be used with BaseView::SW().
It is not needed to use GeRayCollider.
best wishes, Sebastian
On 24/02/2017 at 02:08, xxxxxxxx wrote:
Hello.
What I need to so is click an object in the viewport and get the 3D point that I clicked (and of course belongs in the surface of the object). I suppose to do that you need to cast a ray from camera position to the clicked point of the object.
SW is a value related to Camera's position. So, how can I cast a ray from the camera to the clicked point? The intersection with that object will be the 3D point that I need to retrieve.
On 24/02/2017 at 07:02, xxxxxxxx wrote:
I posted a plugin example with the source code a long time ago called "GeRayCollider_13" that shows how to do this sort of thing: https://sites.google.com/site/scottayersmedia/plugins
Maybe that will be useful to you.
-ScottA
On 24/02/2017 at 08:35, xxxxxxxx wrote:
Hello,
you can "click" in the viewport using ViewportSelect::PickObject(). The filled C4DObjectList contains the distance needed to use BaseView::SW() to create the desired world space point. It is not needed to cast any rays.