Question on setting up a multi-texcoord GeomVertexFormat.

I have some vertices that have 2 sets of texcoords per vertex. I’m trying to setup the vertex format but I’m not sure how to add the 2nd set of texcoords. The manual says something about not re-using the same name in an array. I assume that means I can’t just add another column called C_texcoord. What is the proper way to add multiple tex coords per vertex? Thanks.

I assume this is incorrect?

array->addColumn(InternalName::make(‘vertex’), 3,
GeomEnums::NT_float32, GeomEnums::C_point );
array->addColumn(InternalName::make(‘normal’), 3,
GeomEnums::NT_float32, GeomEnums::C_point );
array->addColumn(InternalName::make(‘texcoord’), 2,
GeomEnums::NT_float32, GeomEnums::C_texcoord );
array->addColumn(InternalName::make(‘texcoord’), 2,
GeomEnums::NT_float32, GeomEnums::C_texcoord );

C_texcoord is not the name, that’s the contents type. You can have many columns with the same contents, but only one with the name: InternalName::make(‘texcoord’).

The name ‘texcoord’ is the name of the default texture coordinate set. If you want to create additional texture coordinate sets, each one will have its own name. These names will be of the form InternalName::get_texcoord_name(‘myTexcoordName’).

So this is correct:

array->add_column(InternalName::make('vertex'), 3,
                  GeomEnums::NT_float32, GeomEnums::C_point );
array->add_column(InternalName::make('normal'), 3,
                  GeomEnums::NT_float32, GeomEnums::C_vector );
array->add_column(InternalName::make('texcoord'), 2,
                  GeomEnums::NT_float32, GeomEnums::C_texcoord );
array->add_column(InternalName::get_texcoord_name('foo'), 2,
                  GeomEnums::NT_float32, GeomEnums::C_texcoord );

Note for those reading this post: the above syntax is for C++. The equivalent Python syntax is similar, but not identical.

Also note that your normals should be contents type C_vector, or they may get transformed funny when you call NodePath::flatten_light() or related methods.

Incidentally, there are convenience methods for all the common column names. You can replace the above with the equivalent:

array->add_column(InternalName::get_vertex(), 3,
                  GeomEnums::NT_float32, GeomEnums::C_point );
array->add_column(InternalName::get_normal(), 3,
                  GeomEnums::NT_float32, GeomEnums::C_vector );
array->add_column(InternalName::get_texcoord(), 2,
                  GeomEnums::NT_float32, GeomEnums::C_texcoord );
array->add_column(InternalName::get_texcoord_name('foo'), 2,
                  GeomEnums::NT_float32, GeomEnums::C_texcoord );

David

Yes, my mistake it was a late night.

Thanks for your help, this should get me started.
-X