THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/03/2003 at 23:40, xxxxxxxx wrote:
Cinema 4D Version: 7.3
Platform: Mac ; Mac OSX ;
Language(s) : C.O.F.F.E.E ;
Ok, I'm writing a COFFEE plugin to dump vertex coordinates, normals, and texture uv coordinates into a custom format for use in an opengl app I'm writing.
My problem is with the UVWTag being sort of unreliable. When I'm writing the four UV coordinate sets for each poly to a text file, I get incorrect mapping when it loads in my opengl app. However, this ONLY seems to happen when I use a UVW tag that was generated by the "Generate UVW Coordinates" menu command in C4D (i.e. not the one that just shows up when I make an object editable).
So specifically my question is this:
How should I access the UVWTag data to best get global UV texture coordinates for each polygon vertex? Currently I'm retrieving them something like this:
var uvw_tag = current_object->GetFirstTag(); //or whatever, but I make sure 'uvw_tag' is a UVWTag. var uvw_data = uvw_tag->GetData(); //and to access uvw's for a polygon number 'n': uvw_data[ 3*n + 0 ] //for first vertex uvw_data[ 3*n + 1 ] //for second vertex uvw_data[ 3*n + 2 ] //for third vertex uvw_data[ 3*n + 3 ] //for fourth vertex //this code is sort of based off of an example in the COFFEE docs
So somehow I'm thinking its not quite that straightforward? If there's a better way I'm all ears. Could the problem perhaps lie with polygons that are triangles? Like would the UVW tag not store duplicate UVW coordinates for a poly that has verts 3 and 4 identical? I tried a workaround to correct for that, but it made things even worse. Feel free to explain things to me in language that you might use with a dim, hearing impaired child: I'm experienced with OpenGL but very new to COFFEE.
BTW - I hope this isn't a really dumb question, but what is the 'W' in UVW mapping? I understand the implication of U and V (taking a 2d object, like a texture, and applying it to a 3d surface) but what on earth is the W there for? When I access it in coffee, its always 0... so as of the moment I just ignore W and only use U and V in my opengl app, since opengl just wants 2d texture coordinates for 2d textures (makes sense...). I have looked breifly online, and there is a shocking silence about this 'W' parameter... I once read someone casually say something about converting UVW to UV... please tell me this is simple, or better yet uneccessary.