THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/08/2011 at 05:54, xxxxxxxx wrote:
Cinema 4D Version:
i have a cube in object mode. i select a face polygon and i want to move the points ahead.
But how to understand what is ahead by getting vertexes information?
During a modelling i can see the cube and i can move ahead the selected vertexes for example in X direction, by selecting another face polygon the ahead is Z or -Z.
So how can i understand it by code?
Thanks in advance.
On 28/08/2011 at 07:00, xxxxxxxx wrote:
If you are attempting to move the vertices with respect to the polygon face, then you need to get the polygon face normal and use that as the direction vector for the direction to move the polygon's vertices. Since the polygon normal is 'normalized', you should be able to apply some scaling/delta factor to the direction vector by mouse movement.
On 28/08/2011 at 07:06, xxxxxxxx wrote:
A vertex in 3D space doesn't have a direction. When you move points in the editor, you're moving them with the mouse or by typing coordinates into the AM.
In code you can move the points in any direction you like. But since you can't "see" the face, one way would be to move them in the direction of the face normal. So you would need to get the face, get the points which make up that face, get the face normal, and move the points the desired distance along the normal.
There are classes/functions in the SDK which do most of that for you - look at PointObject, PolygonObject, and the function CalcFaceNormal().
On 28/08/2011 at 07:55, xxxxxxxx wrote:
Thanks to both, the problem is CalcFaceNormal() is not supported in c.o.f.f.e.e. but in c++.
No way to get it works in c.o.f.f.e.e.?
On 28/08/2011 at 08:07, xxxxxxxx wrote:
No, the function is not available in COFFEE. Try Python if you don't want to use C++.
On 28/08/2011 at 08:27, xxxxxxxx wrote:
The algorithm for calculating the normal of a polygon is easy (and ubiquitous). You can even look at the implementation in the C4D C++ SDK code and probably easily translate it to COFFEE. Google is your best friend in this situation.
On 30/08/2011 at 10:05, xxxxxxxx wrote:
This function will return the polygon's normal. Pass the polygon object and the polygon structure.
var a = op->GetPoint(poly->a);
var b = op->GetPoint(poly->b);
var c = op->GetPoint(poly->c);
if (poly->c == poly->d)
return vnorm(vcross(b-a, c-a));
var d = op->GetPoint(poly->d);
return vnorm(vcross(b-d, c-a));