# Normal tag?

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 27/07/2011 at 08:23, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   9.6+
Platform:   Windows  ;   Mac OSX  ;
Language(s) :     C++  ;

---------
Howdy,

OK, I found this old thread about getting the normal data from a Normal tag:
https://plugincafe.maxon.net/topic/2732/2104_normal-tags&KW=Tnormal

... but it doesn't mention anything about how Ngons are handled.

Also, it doesn't mention anything about how to create a normal tag and fill it with the proper data.

Can anyone show any specific examples, including getting the normal data for both polygons and ngons and creating the normal data for both polygons and ngons?

Cactus Dan

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 31/07/2011 at 07:17, xxxxxxxx wrote:

This is how you to create a NormalTag in pre R12.  For simplicity I create random normals for each point normal. There are 12 WORDs for each polygon presenting the 12 vector components (x,y,z) of  the four points of an polygon, each multiplied by 32000.0.

``````
{

BaseObject *op = doc->GetActiveObject();
if (!op) return FALSE;
if (op->GetType() != Opolygon) return FALSE;

LONG polycnt = ToPoly(op)->GetPolygonCount();

VariableTag *ntag = VariableTag::Alloc(Tnormal, polycnt*12);
if (!ntag) return FALSE;

// elements are of type WORD (unsigned short)

Random rnd;
rnd.Init(56337);

Vector n;

for (LONG i=0; i<polycnt; i++)
{
// normal for point A
n = !Vector(rnd.Get11(), rnd.Get11(), rnd.Get11());

// normal for point B
n = !Vector(rnd.Get11(), rnd.Get11(), rnd.Get11());

// normal for point C
n = !Vector(rnd.Get11(), rnd.Get11(), rnd.Get11());

// normal for point D
n = !Vector(rnd.Get11(), rnd.Get11(), rnd.Get11());
}

op->InsertTag(ntag, NULL);

op->Message(MSG_UPDATE);

return TRUE;
}
``````

Since R12 it's much easier to use an the docs should explain it quite well.

cheers,
Matthias

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 31/07/2011 at 07:19, xxxxxxxx wrote:

I forgot, Ngons are not handled seperately. You set the point normals for each of their sub-polygons.

cheers,
Matthias

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 31/07/2011 at 07:26, xxxxxxxx wrote:

Howdy,

Thanks, Matthias.

When you say "pre R12", what's different in R12?

Edit:
Hehe, never mind. I just looked at the R12 SDK and I see there's a NormalStruct structure.

Cactus Dan

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 31/07/2011 at 07:31, xxxxxxxx wrote:

In R12 a dedicated NormalTag class was introduced which makes the handling much easier, e.g. you don't have to do the strange Vector to WORD converison anymore. It's very much like the UVWTag now.

cheers,
Matthias

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 31/07/2011 at 07:36, xxxxxxxx wrote:

Howdy,

Yes, I see. Nice improvement.