I saved some FBX files (version 6.1, in ASCII format) in Blender, carrying Vertex Paint information.
I imported the FBX file into Cienam4D and it opened fine, ignoring all the Vertex Paint information, of course.
The number of vertices, correctly reported by Cinema4D is 984.
Opening the FBX in a text editor, I confirmed that the number of vertices is 984. I copied and pasted the vertices coordinates into a new document and searched for a comma. It reported that there were 2951. Since the last coordinate triple doesn’t include a comma, this means that there are 2952 coordinates in the list. Since each 3D point is made of three coordinates, the total number of vertices should be 2952/3 and that equals to 984. So, it confirms the number of vertices reported by Cinema4D.
Then I did the same for the ColorIndex list and it reported that it found 3775 commas. So, 3776 index values.
3776?!?!? Shouldn’t it be the same as the number of vertices? I mean, shouldn’t it have 984 index values?
What could be wrong?
If you unwrap an object, you are going to duplicate vertices. If you have a uv edge, each of the vertices on that edge needs two different uv coordinates. Applications like Blender just count them as one, while Unity counts them as two, which is actually correct.
That does not only happen for uv seams, but also for sharp edges. Sharp edges have at least two normal vectors pointing in different directions. That will also result in more than one vertex count.
OK, fair enough. Thank you for the information.
So, how do I extrapolate from a list of 3776 values to 984 vertices?
How do I know what color to assign to each vertex?
I mean, my model has 944 quadrangular faces. And, in fact, 3776/4 = 944.
So, the list of indexes tell me:
#1 - color index of the first point of polygon #1
#2 - color index of the second point of polygon #1
#3 - color index of the third point of polygon #1
#4 - color index of the forth point of polygon #1
#5 - color index of the first point of polygon #2
#6 - color index of the second point of polygon #2
#7 - color index of the third point of polygon #2
#8 - color index of the forth point of polygon #2
#9 - color index of the first point of polygon #3
#6 - color index of the second point of polygon #3
…
Or is it something different?
I also noticed that the PolygonVertexIndex list contains 1888 values (I counted the minus characters).
1888 / 2 = 944
This means that all faces are defined twice?
What is your actual goal?
I’m a Cinema 4D plugin developer and I’m writing a plugin to read FBX the information of the Vertex Painting.
I already have a fully functional plugin to read/write .obj files with Vertex Painting info. And the plugin also allows for in-app editing/rendering of Vertex Painting (something that Cinema 4D can’t natively do).
Now, I would also want to add the ability to read and write FBX files with that Vertex Painting information, so that users of Cinema 4D could model/paint in a known environment and also be able to export those assets to Unity (or whatever application that can open FBX files with Vertex Painting information).
What’s the reason for not using the official FBX SDK?
As the FBX format is closed and everything but easy to handle without the actual SDK, you should either try to use it or otherwise check the available resources. E.g. have a look how it is done in Blender. They have two FBX exporters and one importer. You are likely going to be far more successful if you get in touch with the Blender developers, than asking that kind of question in the Unity forum.
Thank you very much for the reply. I will asked then