[Closed] Number of CPV verts of specific vert ooooh ive gone crosseyed 😀
Hi
The numbcer of colour per vetex verts (CPV) is possible to get using
getNumCPVVerts <mesh>
I cant see a way of getting the number of CPV verts for a specific vertex, ie if a plane has 1 division and each quad on either side is colour differently then there are 8 CPV verts and 6 geo verts.
Is there a way of determining the number of CPV verts per geo vert.
Thanks for any help
from the maxscript help
In order to find out which texture vertex corresponds to a mesh vertex, you have to do the following:
[ol]
[li] Take the index of the mesh vertex.[/li]> [li] Find out which faces reference the index of the face.[/li]> [li] Note the number of the vertex (1 st , 2 nd or 3 rd – .x, .y or .z) inside each face.[/li]> [li] For each face referencing the vertex, get the texture face with the same index.[/li]> [li] Get the index of the respective texture vertex from the face – 1 st , 2 nd or 3 rd / .x, .y or .z[/li]> [li] The vertex you got corresonds to the mesh vertex we started with.[/li]> [li] Repeat steps 3 to 6 for all faces found. [/li]>
Same applies to color vertices.
[/ol]
which would boil down to something like this
fn GetCPVertsUsingVert mObj vert =
(
-- get the faces using this vert
faces = meshop.getFacesUsingVert mObj vert as array;
-- collect the all the corners used by our vert in each face
facecorners = for f in faces collect
(
face = getFace mObj f;
finditem #(face.x,face.y,face.z) vert
)
-- collect the all the cpverts used by the same face and corner, removing all the duplicates
makeUniqueArray (for f = 1 in faces.count collect (getVCFace mObj faces[f])[facecorners[f]] as integer);
)
err how did i miss that
And what page was this on? the meshops page?
Thanks for the reply
returning a bitarray is marginally quicker
fn GetCPVertsUsingVert mObj vert =
(
-- get the faces using this vert
faces = meshop.getFacesUsingVert mObj vert as array;
-- collect the all the corners used by our vert in each face
facecorners = for f in faces collect
(
local face = getFace mObj f;
finditem #(face.x,face.y,face.z) vert
)
-- collect the all the cpverts used by the same face and corner
cpverts = #{};
cpverts.count = getNumCPVVerts mObj;
for f = 1 to faces.count do cpverts[(getVCFace mObj faces[f])[facecorners[f]]] = true;
cpverts;
)
shaves a bit more time off.
fn GetCPVertsUsingVert mObj vert =
(
-- get the faces using this vert
faces = meshop.getFacesUsingVert mObj vert as array;
-- collect the all the corners used by our vert in each face
facecorners = for f in faces collect
(
local face = getFace mObj f;
local corner = 1;
if face.y == vert then corner = 2;
else if face.z == vert then corner = 3;
corner;
)
-- collect the all the cpverts used by the same face and corner
cpverts = #{};
cpverts.count = getNumCPVVerts mObj;
for f = 1 to faces.count do cpverts[(getVCFace mObj faces[f])[facecorners[f]]] = true;
cpverts;
)