math: project point on a poly

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 10/06/2004 at 10:07, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   8.100 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------

Hi all,

i need to find the closest point p1 in a poly
to point p2 outside of the poly.

It should be possible to get p1 by projecting p2 along the normal of the poly, but unfortunately i dont know how to do it! (cos im quite bad at maths)

Is there maybe a function in the sdk that can
project a point on a plane along the planes normal?

thanks,
devel

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 11/06/2004 at 09:43, xxxxxxxx wrote:

the solution of your problem is very difficult:
it is ease to do this with a Plain and a Point, because a plane has infinite extension. but in your case you have to check the bounds (edges) of your poly. Another problem is that that a poly can also be nonplanar, so you have to do this with triangles, they are always planar!

btw: I don´t know any function in the sdk that does your thing!

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 11/06/2004 at 10:34, xxxxxxxx wrote:

well,thanks for your answer..

your probably right, especially about the poly vs triangle thing..
..didnt think of that before x-|

what i am actually trying to do with my plugin
is make a multispline stick to a deformable mesh..

like when i make a spline-beard around a poly selection
and then make some facial expression morphing with the head, the beard stays attached to the poly-selection..

well maybe there's another solution somewhere..
or somebody else already did it!

thanks anyway,
and have a good time all,

devel

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 11/06/2004 at 11:24, xxxxxxxx wrote:

Don't 100% understand the question, but maybe you could use the GeRayCollider class.
 
Its a class used to check if a ray has intersected a polygon, and it returns a whole great deal of information, the point of intersection, the polygons normal, etc
 
The xpresso ray collider node is very useful to experiment with

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 11/06/2004 at 12:03, xxxxxxxx wrote:

thanks ill read it up in the manual and play around some,
but it looks like it can only check collision between ray(line) and object and i need to check collision ray/poly..

--edit---

..should have read the manual BEFORE posting...

looks like the node can return the poly that was hit by the ray...

so thanks again, looks like this might work! 😄

cheers,
devel

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 11/06/2004 at 12:18, xxxxxxxx wrote:

Yes its for object, but objects are made out of polygons right?
 
Its also not that hard to check if a point is inside a polygon, there are many ways to do it.
 
http://www.gametutorials.com/Tutorials/opengl/OpenGL_Pg3.htm
 
I learn't all I know about polygon detection from that site
 
1. Line Segment and Plane Collision
2. Line Segment and Polygon Collision
 
The source code contains a very good explaination on what is happening. Its easy to convert into c4d too, because sdk already has great vector operations 🙂

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 11/06/2004 at 14:00, xxxxxxxx wrote:

thanks, i'll check it out..

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 12/06/2004 at 01:57, xxxxxxxx wrote:

Quote: Originally posted by devel on 11 June 2004
>
> * * *
>
> what i am actually trying to do with my plugin
> is make a multispline stick to a deformable mesh..
>
> like when i make a spline-beard around a poly selection
> and then make some facial expression morphing with the head, the beard stays attached to the poly-selection..
>
>
> * * *

what i understood is that you need something that always stays at the same place on top of a (deformable) surface, right? In my opinion you should do this with the uv-coordinates of the poly. else you are getting problems with the right position when the shape of the poly is changing! I don´t know if there is any function in the sdk that extracts you the 3d-coordinates with the input of a poly and the uv-coordinates!

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 12/06/2004 at 02:07, xxxxxxxx wrote:

hmm, sounds like a good idea..

i'm not quite sure how to do it right now,
but im im just gonna play around with uv now, might
turn out to be easier than what i had in mind first..

thanks for the hint,
devel

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 12/06/2004 at 02:46, xxxxxxxx wrote:

bad idea. This would require the object to always have accurate UV coords which is not always the case (some don´t even have any UVs assigned)

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 12/06/2004 at 02:55, xxxxxxxx wrote:

yeah thats right,
but i actually need this plugin for my fully textured head (with complete uvw's), so that shouldnt be a problem..

on the other hand, that wouldnt make it very handy in terms of general usefulness (e.g. for other people) i guess...

well, so how'd you do it?

the problem is indeed to get the right coordinate on the poly, when the mesh has deformed..

greetings,
devel

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 12/06/2004 at 03:05, xxxxxxxx wrote:

Well, actually I already did this ;o) I am using this for my own plugin DPInstantTree (for it now has hair support) and so I wrote such a plugin some days ago. I am triangulating the object and then calculate the initial position on the triangle (as written a tri is always planar) and stick it to this position. Actually not that complicated. Do a google search for the position in a triangle. It´s more than easy.
Good luck

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 12/06/2004 at 03:06, xxxxxxxx wrote:

when deforming the barrycentric coords of the poly do change too (maybe maxx meant these coords by uv coords) so it works here too.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 12/06/2004 at 03:21, xxxxxxxx wrote:

alright thanks Samir,
gonna check it out..

greetings,
devel