I want to get some knowledge for fixing up my issue, which is I cannot import second vertex color. I'm using add-on to do so but it has not this feature. So what I am asking for is to make comments with informations about what specific line of code is doing or just tell me how to create a loop for this a piece of code to import more than one vertex color. I tried but it's not even import the first one.
You can ask me for variables so I could bring declarations and linked wwith it codes.
Original contains variable
## Set VCOLs
if ( dff_props.read_vcol and ( geom.flags & GEOMETRY_PRELIT ) ):
vcf = get_vertex_colors( m ).new()
vcs = [[], [], []]
if dff_props.use_remdbls:
for fi, f in enumerate( get_faces( m ) ):
vcs[0] += geom.vcols[ ( geom.faces_org[fi*4 ] )*4 : ( geom.faces_org[fi*4 ] )*4 +3 ]
vcs[1] += geom.vcols[ ( geom.faces_org[fi*4+1] )*4 : ( geom.faces_org[fi*4+1] )*4 +3 ]
vcs[2] += geom.vcols[ ( geom.faces_org[fi*4+2] )*4 : ( geom.faces_org[fi*4+2] )*4 +3 ]
else:
for fi, f in enumerate( get_faces( m ) ):
vcs[0] += geom.vcols[ ( f.vertices[0] )*4 : ( f.vertices[0] )*4 +3 ]
vcs[1] += geom.vcols[ ( f.vertices[1] )*4 : ( f.vertices[1] )*4 +3 ]
vcs[2] += geom.vcols[ ( f.vertices[2] )*4 : ( f.vertices[2] )*4 +3 ]
vcf.data.foreach_set( "color1", vcs[0] )
vcf.data.foreach_set( "color2", vcs[1] )
vcf.data.foreach_set( "color3", vcs[2] )
m.update()
m.vertices.foreach_set( "normal", geom.norms ) # Vert NORs seem to be recalculated by "mesh.update()"
#if( geom.flags & GEOMETRY_NORMALS ): m.vertices.foreach_set( "normal", geom.norms ) # Vert NORs seem to be recalculated by "mesh.update()"
Edited by myself
## Set VCOLs
for poly in m.polygons:
for idx in poly.loop_indices:
if ( dff_props.read_vcol and ( geom.flags & GEOMETRY_PRELIT ) ):
vcf = get_vertex_colors( m ).new()
vcs = [[], [], []]
if dff_props.use_remdbls:
for fi, f in enumerate( get_faces( m ) ):
vcs[0] += geom.vcols[ ( geom.faces_org[fi*4 ] )*4 : ( geom.faces_org[fi*4 ] )*4 +3 ]
vcs[1] += geom.vcols[ ( geom.faces_org[fi*4+1] )*4 : ( geom.faces_org[fi*4+1] )*4 +3 ]
vcs[2] += geom.vcols[ ( geom.faces_org[fi*4+2] )*4 : ( geom.faces_org[fi*4+2] )*4 +3 ]
else:
for fi, f in enumerate( get_faces( m ) ):
vcs[0] += geom.vcols[ ( f.vertices[0] )*4 : ( f.vertices[0] )*4 +3 ]
vcs[1] += geom.vcols[ ( f.vertices[1] )*4 : ( f.vertices[1] )*4 +3 ]
vcs[2] += geom.vcols[ ( f.vertices[2] )*4 : ( f.vertices[2] )*4 +3 ]
vcf.data.foreach_set( "color1", vcs[0] )
vcf.data.foreach_set( "color2", vcs[1] )
vcf.data.foreach_set( "color3", vcs[2] )
m.update()
m.vertices.foreach_set( "normal", geom.norms ) # Vert NORs seem to be recalculated by "mesh.update()"
#if( geom.flags & GEOMETRY_NORMALS ): m.vertices.foreach_set( "normal", geom.norms ) # Vert NORs seem to be recalculated by "mesh.update()"
Rest of code if really needed. It contains every important informations about declarations etc.
Source ( init) - https://pastebin.com/4hUBJrxV
Source ( utils ) -https://pastebin.com/ze1q4vYw
Source ( import ) - https://pastebin.com/nEsSJj4v
Thank you in advance for your time.