Exporting polys.. normals?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/02/2003 at 21:18, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.012
Platform: Mac ;
Language(s) : C.O.F.F.E.E ; C++ ;---------
Does Cinema 4D API have support for generating or accessing normals on polys/verts?here's some code snippets that i'm trying to adapt to the Cinema4D API
// theFaces[theFaceIndex].m_MaterialID = reinterpret_cast<long>( polyObject->GetFaceMaterial( theFaceIndex ) );theFaces[theFaceIndex].m_Vert1.m_PositionIndex = polyMeshArray[ theFaceIndex ].a;
theNormalIndex = polyMeshArray[ theFaceIndex ].a;
// theFaces[theFaceIndex].m_Norm1.m_X = polyObject->normals[theNormalIndex].x;
// theFaces[theFaceIndex].m_Norm1.m_Y = -polyObject->normals[theNormalIndex].y;
// theFaces[theFaceIndex].m_Norm1.m_Z = polyObject->normals[theNormalIndex].z;//Assign Vert1
theFaces[theFaceIndex].m_Vert3.m_PositionIndex = polyMeshArray[ theFaceIndex ].b;
theNormalIndex = polyMeshArray[ theFaceIndex ].b;
// theFaces[theFaceIndex].m_Norm3.m_X = polyObject->normals[theNormalIndex].x;
// theFaces[theFaceIndex].m_Norm3.m_Y = -polyObject->normals[theNormalIndex].y;
// theFaces[theFaceIndex].m_Norm3.m_Z = polyObject->normals[theNormalIndex].z;theFaces[theFaceIndex].m_Vert2.m_PositionIndex = polyMeshArray[ theFaceIndex ].c;
theNormalIndex = polyMeshArray[ theFaceIndex ].c;
// theFaces[theFaceIndex].m_Norm2.m_X = polyObject->normals[theNormalIndex].x;
// theFaces[theFaceIndex].m_Norm2.m_Y = -polyObject->normals[theNormalIndex].y;
// theFaces[theFaceIndex].m_Norm2.m_Z = polyObject->normals[theNormalIndex].z; -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/02/2003 at 00:09, xxxxxxxx wrote:
You can use the CalcFaceNormal() function to find a polygons normal:
Vector CalcFaceNormal(Vector* padr, const Polygon& v)
A material can be restricted to a polygon selection, the information is in the TextureTag, this also contains which material is assigned to an object.
Polygons are accessed from Polygon array pointer returned by GetPolygon(), verts from GetPoint() function, look at the members of the PolygonObject in the docs. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/02/2003 at 14:15, xxxxxxxx wrote:
Thanks Dave,
that worked great..
do you know a way to get texture corodinates for verts/points?
my guess isn't not cut and dry-eric
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/02/2003 at 16:00, xxxxxxxx wrote:
ok i missed what you were saying.. i;ll do some research..
is there a way to get point normals vs. face normals? I am needing vert normals to calcalate smoothing.
Thanks, eric
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/02/2003 at 16:56, xxxxxxxx wrote:
you can calculate them yourself. Just get the sourrounding polygons of the point and divide thru the count of sourrounding polygons, then normalize the result. Or you could also use the Neigbhor class to get the pointPolygons and then do the same as described.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/02/2003 at 11:38, xxxxxxxx wrote:
OUCH!
that can be really painful. that should be provided by the API.I'm really not that much of a Cinema4D user myself. new to programming in it.. you know why C4D doesn't provide access to all that? seems like to me, the vertex normals need to be in the software to display them anyway...
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/02/2003 at 13:24, xxxxxxxx wrote:
the smoothed normals are supplied when you are likely to need them (during render), but in no other places does CINEMA use them, supplying them at other times would increase data storage, probably also add extra overhead that is generally not needed. It is unusual for an export to need the normal per vertex, it is either the face normal, or just the point order, in cases, as with yours, it is better that the exporter or whatever plugin, does its own smoothing, you can then choose how to do it, and it is very easy using the Neighbor class, you can use that to find all polygons around a point, then get the face normals of each, sum and normalise them, not really painful
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/02/2003 at 13:51, xxxxxxxx wrote:
... Because the "point normals" don't really exist. The point normal you calculate is always an interpolation (or plain said: an estimation). The surface of a polygon mesh is not differentiatable (the right word) at the polygon edges and thus you can't calculate an normal vector of an edge (or a point on the edge).
All you can do is to interpolate the normals of the neighbouring polygons. And there are different ways for that. Samir's approach ist the most simple one. One modification of that would be to calculate the average by weighting the normals by the area of the corresponding polygon.
I guess the calculation of the vertx normals is done by the 3D hardware on-the-fly so the vertex normals wouldn't be stored.
BTW: If you you have to calculate all "point normals" of your mesh then it would be better not to search for every point its neighbouring polygons. Instead you create a sum-table with an entry for each point, loop through all polygons and add each polygon normal vector (must be normalized) to the sums of its points.
Ciao,
Marcus -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/02/2003 at 11:54, xxxxxxxx wrote:
I guess my point was that many 3d packages I've used and have a real-time display/render or API, there is access to them in order to get smooth shading onscreen for the program itself to display them, thus exposing it out is more easily accessible..
But I see your point.