I’m using GeomVertexReaders in order to examine the vertices of a model. To this end, I have three such readers: one for vertex-positions (attached to the “vertex” column), one for vertex-normals (attached to the “normal” column), and one for vertex-colours (attached to the “color” column).
I haven’t yet tested the reader that examines normals, but the one that examines positions seems to work as expected.
The one that examines colours, however, doesn’t. Specifically, I seem to only get black (i.e. (0, 0, 0, 1)) when I call “getData4()” on it.
I’ve examined the model, and it does appear to have vertex-colours. (Indeed, those colours show up on the original, visible model as shown in the scene, I believe.)
I’ve also checked that the vertex-data does have a “color” column, and it seems that it does.
This–somewhat abbreviated–is what I’m doing:
for geom in node.modifyGeoms():
newGeom = geom.decompose()
newGeom.makeNonindexed(False)
vData = newGeom.getVertexData()
rowCount = vData.getNumRows()
reader = GeomVertexReader(vData, "vertex")
if dataCallback is not None:
polys = []
readerColours = GeomVertexReader(vData, "color")
readerNormals = GeomVertexReader(vData, "normal")
for i in range(0, rowCount, 3):
# ... vertex-position stuff here ...
if dataCallback is not None:
if vData.hasColumn("normal"):
normal1 = readerNormals.getData3()
normal2 = readerNormals.getData3()
normal3 = readerNormals.getData3()
else:
normal1 = normal2 = normal3 = Vec3(0, 0, 1)
if vData.hasColumn("color"):
colour1 = readerColours.getData4()
colour2 = readerColours.getData4()
colour3 = readerColours.getData4()
else:
# Note here that the fourth component of this
# is zero, while the fourth component that I'm
# getting in my results is one. Further, I think
# that I've checked that the code is in fact
# getting into the if-statement above.
colour1 = colour2 = colour3 = Vec4(0, 0, 0, 0)