Change object position based on displaced ground
-
On 03/03/2018 at 04:42, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R18.058
Platform: Windows ; Mac OSX ;
Language(s) : C++ ; XPRESSO ; PYTHON ;---------
Hello PluginCafe :),I am creating an Ocean kit for my client and my current setup is a custom created shader in an displacer (wish from client). The displacer is applied to a plane object which is the ocean surface.
What I want to do, is to let an object float ontop of that surface. I was thinking on creating a tag-plugin for this to modify the objects position (and maybe rotation) depending on the displaced surface.
My question(s) now is(are) :
Is it actually possible to get the new points of the displaced object an set my whole (floating) object's position to them? Since my plane is not a point object and maybe needs to be resized and re-segmented by the end-user.
What would be the best approach to do this?I hope everything is clear, and someone is able to help me
best regards and thanks in advance,
Florian -
On 05/03/2018 at 02:20, xxxxxxxx wrote:
Hi Florian, thanks for writing us.
Actually there are two options you can choose between:
- using the RayCollider library from our API you can sample the displaced ocean surface to identify real intersection on the surface and position your objects accordingly;
- given that you can access the displacing shader, if you convert the position of your floating object from the world space on the plane to UV space you have all the means to evaluate the shader at such UV; then the offset value obtained can be used to properly position the floating object on the displaced surface.
Best, Riccardo
-
On 07/03/2018 at 01:01, xxxxxxxx wrote:
Hello Riccardo,
thank you very much for your input!
About the second option you mentioned:
How would I be able to translate my objects coordinates to UV coordinates?Best, Florian