Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Correct way to specify per-vertex color in an FbxMesh

Correct way to specify per-vertex color in an FbxMesh

Anonymous
Not applicable
1,380 Views
1 Reply
Message 1 of 2

Correct way to specify per-vertex color in an FbxMesh

Anonymous
Not applicable

Hi all,

 

Does anybody know the best way of storing per-vertex diffuse color data in a mesh? I've seen the FbxGeometryElementVertexColor class and followed the code in the Layers SDK sample, but nothing seems to show up correctly when looking at the file in FBX Review.

 

Unless I'm mistaken, in the Layers sample code the colors that appear on each face of the cube are generated by creating a separate material on each face. If I change to code to  create a single material over the entire mesh then the FbxGeometryElementVertexColor element doesn't seem to do anything.

 

Is there really no way of creating a single material with per-vertex variation of the diffuse component?

 

Many thanks,

 

Simon

-

0 Likes
1,381 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

 

I had to define 3 colors per polygon in my model.

  
'-------------------------------------------------------------------------- If _group(id).header.Contains("iii") Then ' This model has vertexColors?
Dim colorLayer1 As FbxLayerElementVertexColor = Nothing colorLayer1 = FbxLayerElementVertexColor.Create(myMesh, "VertexColor") colorLayer1.Name = "VertexColor" colorLayer1.Mapping_Mode = FbxLayerElement.MappingMode.ByControlPoint colorLayer1.Reference_Mode = FbxLayerElement.ReferenceMode.Direct Dim color As New FbxColor For I = 1 To _group(id).nPrimitives_ Dim indi = _group(id).indicies(I) color.Red = CDbl(_group(id).vertices(indi.v1).index_1 / 255) 'convert to double color.Green = CDbl(_group(id).vertices(indi.v1).index_2 / 255) color.Blue = CDbl(_group(id).vertices(indi.v1).index_3 / 255) color.Alpha = 1.0 'CDbl(_group(id).vertices(I).index_4 / 255) colorLayer1.DirectArray.Add(color) ' add color to layer color.Red = CDbl(_group(id).vertices(indi.v2).index_1 / 255) color.Green = CDbl(_group(id).vertices(indi.v2).index_2 / 255) color.Blue = CDbl(_group(id).vertices(indi.v2).index_3 / 255) color.Alpha = 1.0 'CDbl(_group(id).vertices(I).index_4 / 255) colorLayer1.DirectArray.Add(color) color.Red = CDbl(_group(id).vertices(indi.v3).index_1 / 255) color.Green = CDbl(_group(id).vertices(indi.v3).index_2 / 255) color.Blue = CDbl(_group(id).vertices(indi.v3).index_3 / 255) color.Alpha = 1.0 'CDbl(_group(id).vertices(I).index_4 / 255) colorLayer1.DirectArray.Add(color) Next layer.VertexColors = colorLayer1 End If
'--------------------------------------------------------------------------

 

0 Likes