COFFEE - Accessing UVW data / Texture coordinates
-
On 15/03/2015 at 17:25, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) : C.O.F.F.E.E ;---------
This article explains how to access a model's texture coordinates (this topic is quite poorly documented, and information is spread across code examples and forum threads).1. Finding the tag
To find an object's UVW tag, you should iterate through all the object's tag until you find an instance of UVWTag.
Tags are stored in a linked list. To iterate through the tags, call BaseObject::GetFirstTag() to get the first element, then call BaseList2D::GetNext() until it returns NULL.
For our purpose, we stop when we find an instance of UVWTag:for (tag = object->GetFirstTag(); tag != NULL && !instanceof(tag, UVWTag); tag = tag->GetNext());
Keep in mind that at the end of this loop, tag will be NULL if the object doesn't have a UVW tag, make sure it is not before you use it.
2. Reading UVW data
Start by getting a reference to the UVW buffer:var uvwData; uvwData = tag->GetData();
uvwData is an array of 3D vectors.
The UVW coordinates for the v th point of the p th polygon is stored at index p * 4 + v .
This is because all polygons are made up of four points. This is also true for triangles, two of their points are at the same position.
If you end up with backwards UVs, try mirroring them ( p * 4 + (3 - v ) ).
Keep in mind that polygons and points are indexed from 0.**3. Using UVW data
** As said above, the array returned by GetData() contains 3D vectors, you can access them in this fashion:var u = uvwData[poly * 4 + point].x; var v = uvwData[poly * 4 + point].y; var w = uvwData[poly * 4 + point].z;
-
On 16/03/2015 at 09:51, xxxxxxxx wrote:
Hello and welcome,
thanks for posting your findings. Please notice that the COFFEE programming language is outdated. You find more possibilities, better documentation and examples in the
Python
[URL-REMOVED] andC++
[URL-REMOVED] SDKs so you might want to take a look at them.Best wishes,
Sebastian
[URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.
-
On 16/03/2015 at 09:57, xxxxxxxx wrote:
This is quite a shame in my humble opinion. It offered a level of abstraction C++ doesn't have, and had a more 'universal'/'common' syntax than Python._<_mytubeelement_>_<mytubeelement =""loadBundle":true" ="relayPrefs" id="myTubeRelayElementToTa_<_mytubeelement_>_nt>
-
On 17/03/2015 at 08:01, xxxxxxxx wrote:
Howdy,
Originally posted by xxxxxxxx
...Please notice that the COFFEE programming language is outdated...
Will COFFEE ever be abandoned in the future? I hope not because I like the idea of being able to extend COFFEE and add COFFEE functions to my plugins so that users can write scripts to access certain data in my plugins.
Adios,
Cactus Dan -
On 19/03/2015 at 10:20, xxxxxxxx wrote:
Hello,
please understand that we cannot make any statements on future developments in this forum. But at least for the near future there will be no change for COFFEE developers.
Best wishes,
Sebastian