Obtaining texture UV coordinates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I have an issue where I have coded a Revit plugin which renders a scene - and calculates the UV coordinates for each vertex. Unfortunately there are a number of situations where UV mapping is wrong - even with planar mapping.
For example, the attached image images shows the results from UV mapping (on the right), verses the "Realistic" viewport setting.
As you can see, the horizontal surface is uncorrectly mapped. MR does not have this issue.
The code to calculate the UV is:
foreach (Face face in solid.Faces) { PlanarFace planarFace = face as PlanarFace; CylindricalFace cylindricalFace = face as CylindricalFace; ConicalFace conicalFace = face as ConicalFace; RevolvedFace revolvedFace = face as RevolvedFace; HermiteFace hermiteFace = face as HermiteFace; RuledFace ruledFace = face as RuledFace; for (int v = 0; v < 3; ++v) { XYZ pointXYZ = triangle.get_Vertex(v); IntersectionResult ir = face.Project(pointXYZ); // Calculate the UV's if the face is planar if (planarFace != null) { if (ir != null) { m_Uvws[uvIndex].U = ir.UVPoint.U; m_Uvws[uvIndex].V = ir.UVPoint.V; } } else if (cylindricalFace != null) { if (ir != null) { ....
So my question is, how can I get correct UV's?
(EDIT: I have invested a significant amount of time trying to implement the approach outlined in http://thebuildingcoder.typepad.com/blog/2010/02/texture-data-uv-coordinates-and-fbx.html and it is simply not viable. It is not possible to match the UV's indexs from the FBX with the vertex indexs obtained via the Revit API. Also, FBX assigns each polygon to a RenderAppearance, rather than a Revit Material - so it is not possible to determine what the material is for a given polygon in the FBX.]
Thanks in advance.