PDA

View Full Version : setNumCPVVerts


PEN
07-22-2009, 09:39 PM
I'm not sure that I get this fully or at all. I want to set vertex colors on an object so I gather I need to use setNumCPVVerts and then buildVCFaces, but buildVCFaces tells me "Runtime error: BuildVCFaces - mesh has no color-per-vertex vertices: TriMesh"

When I check GetNumCPVVerts it returns 0. I get what it is wanting but don't understand just how to set it.

Any one have any ideas on this?

denisT
07-23-2009, 12:48 AM
I'm not sure that I get this fully or at all. I want to set vertex colors on an object so I gather I need to use setNumCPVVerts and then buildVCFaces, but buildVCFaces tells me "Runtime error: BuildVCFaces - mesh has no color-per-vertex vertices: TriMesh"

When I check GetNumCPVVerts it returns 0. I get what it is wanting but don't understand just how to set it.

Any one have any ideas on this?


call "defaultVCFaces" first. it will create vertex color channel. after that you will be able to set the number of cpv verts.

PEN
07-23-2009, 12:59 PM
Doesn't work, how about a working example as what I have isn't going any where and I have tried all sorts of things.

Here is what I just tried..

defaultVCFaces $.mesh
setNumCPVVerts $.mesh 100 true
buildVCFaces $.mesh true

phoelix
07-23-2009, 02:49 PM
those vertex color commands only works if the object is an Editable Mesh

convertto $ Editable_mesh
defaultVCFaces $.mesh
setNumCPVVerts $.mesh 100 true
buildVCFaces $.mesh true

phoelix
07-23-2009, 02:53 PM
you should use polyOp methods if you have an Editable Poly

Vertex Colors
polyOp.getVertsByColor <Poly poly> <Color color> <Float red_thresh> \

<Float green_thresh> <Float blue_thresh> \

channel:<int=0>

Returns the vertices whose vertex color is within the color range as a <bitarray>. The range values should be in the range of 0 to 255.

polyOp.getVertsByColor <Poly poly> <Point3 uvw> <Float u_thresh> \

<Float v_thresh> <Float w_thresh> channel:<int=0>

Returns the vertices whose UVW is within the UVW range as a <bitarray>. The range values should be in the range of 0 to 1.

polyOp.setVertColor <Poly poly> <int mapChannel> <vertlist> <Color color>

Sets the vertex color for the specified vertices in the specified <mapChannel>.

polyOp.SetFaceColor <Poly poly> <int mapChannel> <facelist> <Color color>

Sets the vertex color for the vertices used by the specified faces in the specified <mapChannel>.

Rick Stirling
07-23-2009, 03:18 PM
Paul, here's a section of a script I wrote that we use on a daily basis:




obj=$ -- added this here to make it obvious

-- Go to polygon mode and select all
subobjectLevel = 1


-- get numver of verts in the object
nv=0
nv= obj.numverts

-- since we don't know if the artist has used Epoly or Emesh, try both.
for i = 1 to nv do
(
try (polyop.setvertcolor $ 0 i (color 190 190 190)) catch ()
try (meshop.setvertcolor $ 0 i (color 190 190 190)) catch ()
)





I shouldn't have mixed up $ and obj, but it works.

Bobo
07-23-2009, 03:22 PM
Doesn't work, how about a working example as what I have isn't going any where and I have tried all sorts of things.

Here is what I just tried..

defaultVCFaces $.mesh
setNumCPVVerts $.mesh 100 true
buildVCFaces $.mesh true


You are trying to operate live on the $.mesh. I *think* what happens is $.mesh grabs the mesh from the object into a TriMesh value. Then you modify that in memory. Then you calll the next function and it grabs a NEW TriMesh (not the one already in memory you modified) and of course it was not changed yet, so you get an error and so on.

$.mesh makes sense if you are READING data from an object. It gives you the TOP OF THE STACK TriMesh representation of the object even if it is not an Editable Mesh.

As mentioned by others, these methods are designed to operate on Editable Meshes so you will have to collapse the stack and remove the .mesh from your code.
They CAN operate on a TriMesh, but then you wouldn't be able to feed the changes back to your object unless it was an EdiableMesh to start with.

So if you do either myMesh = $.mesh or myMesh = snapshotAsMesh $ (this gives you world space state of the mesh), then the methods will operate on the TriMesh value correctly, but it would only make sense if you would assign that myMesh value back to some object, for example to a fresh EditableMesh's .mesh property. Otherwise the changes will remain on the memory copy of the mesh and not appear in the scene which is of course not what your want...

PEN
07-24-2009, 07:36 PM
Hmm, what I have is a scripted plugin object and I don't want to collapse it. I have been able to set the number of color verts to the same as the triMesh using defaultVCFaces on the triMesh that is being stored in a variable and it works. So the other functions don't work the same way as this one? and I need to do it on the baseObject?

CGTalk Moderation
07-24-2009, 07:36 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.