How to get vertices data from mesh (imported fbx - 2.4.3)


I have two questions on the same topic

1 - How can I get vertices array or vertices count of mesh ? I’m importing .fbx files.

I want to change the vertices ARRT_UV0, so I need to know at least the amount of vertices on the object

(Mesh component allow me to ‘setVertices’, and I cant find a way to get the list of vertices or at least vertices count so I can change the uv position)

2 - Is there a way to get Vertices Groups from the imported model ?

Let me explain…

I’m creating a 3d model, and I’m trying to paint them by moving the vertices uv position to another point that match a color in my material.

If I know how many vertices there is on the model I can call ‘setVertices’ to the position of the color that I want and the object goes to that color.

I also would like to identify vertices groups so I can change the uv position only selected vertices

Hi, did you refer to this document first?

Hello @yufang.wu,

Yes, I looked into that document.
I got the example on this document to work, and I was able to change the uv position of the just created mesh.

But for that to work it needs to be initialized the mesh with vertice count on:

mesh.init(vfmtPosColor, **8**, true)

and when setting the vertices data I need to pass a array with size equals to vertices count or less.
if greater it just dont display the mesh.

mesh.setVertices(gfx.ATTR_UV0, [ cc.v2(0,0), cc.v2(0, 1), cc.v2(1, 0), cc.v2(1, 1), cc.v2(1,1), cc.v2(1, 0), cc.v2(0, 1), cc.v2(0, 0), ]);

But when I import a .fbx model to cocos, and move the prefab to the scene, it is just node3d with a meshRenderer and there is no method to get the vertices from the meshRenderer.mesh.

When I look the asset file,
that’s a Mesh object ? (I think it is)

I see the verts count and even Submesh array, with probably all vertices data that I want to access.
But I dont know how to read that.

You can use mesh._getAttrMeshData, please reference to ray_mesh

Thank you!

Edit: If you want to add subMesh to your mesh here’s how I did it

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.