On 25/05/2013 at 21:30, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 14
Platform: Windows ;
Language(s) : C++ ;
---------
Hi everybody.
I am currently writing on a small application which exports some 3D Game Models to Cinema 4D. For writing the file I am using the current SDK (Melange 6). In my original structure I have a list of edges. A edge consists of a verticle (3D Point Structure in absolute coordinates) and UV Information (2D Point Structure in floating point values from 0-1). 3 edges represent a triangle polygon.
Generating the 3D Model was quite a simple task: Create the polygon object, resize it, write the verticles and polygons to GetPointW() / GetPolygonW() arrays.
But now I want to generate the UVW Tags to generate the textures later on. I also thought it would be quite easy but for some unknown reason, the mesh isn't placed well.
Here is a simplified code of my implementation:
Vector* verticles = c4dPolygon->GetPointW();
CPolygon* polygons = c4dPolygon->GetPolygonW();
UVWTag* uvw = (UVWTag* )baseObject->addTag(Tuvw);
UVWHandle uvwptr = uvw->GetDataAddressW();
for(int i = 0; i < polygonCount * 3; i++)
{
Edge* e = edges[i];
verticles[v++] = Vector(e->Position.X, e->Position.Y, e->Position.Z);
if( (i+1) % 3 == 0 && i >= 2)
{
Edge* e1 = edges[v-3];
Edge* e2 = edges[v-2];
Edge* e3 = edges[v-1];
polygons[p++] = CPolygon(v-1, v-2, v-3);
uvw->Set(uvwptr, p-1,
UVWStruct(
Vector(e1->UV.X, e1->UV.Y,0)
Vector(e2->UV.X, e2->UV.Y,0)
Vector(e3->UV.X, e3->UV.Y,0)
);
}
}
If I inspect the UV in Cinema 4D I can only see dots instead of the full polygons. The dots seem to be positioned well along the texture, but the polygons are simply not unfolded and the texture is misplaced because of that. Can somebody of you explain me why the UV is not unfolded well? Maybe it's a setting when creating the UVW.
Here a screenshot of the result:
Greetings