ed-it
02-02-2004, 05:06 AM
Hi there,
I'm writing a script to export the vertex color and alpha values from a selected mesh to a text file. I can get the color values fine, but can't find a way to get the alpha values.
The code is currently:
-- Pick the mesh to export colors from
target_mesh = pickObject message:"Pick Target Surface:" filter:g_filter
if isValidNode target_mesh then
(
-- Snapshot mesh
tmesh = snapshotAsMesh target_mesh
-- Save file dialog
out_name = getSaveFileName \
caption:"Save vertex color text file" \
types:"Text(*.txt)"
if out_name != undefined then
(
out_file = createfile out_name
num_verts = tmesh.numverts
for v = 1 to num_verts do
(
-- Get vertex color
vc = getVertColor tmesh v
format "%\t%\t%\t%\n" v vc.r vc.g vc.b to:out_file
)
-- Close file
close out_file
)
)
I'm guessing I need a line similar to the vc = getVertColor, but for the vertex alphas. In the import script (opposite of this one), I use "meshOp.setVertAlpha target_mesh -2 vert alpha" to set the vertex alpha, which works fine. It uses channel -2 which is Max's built in vertex alpha channel.
If anyone could help, that would be great. Thanks.
I'm writing a script to export the vertex color and alpha values from a selected mesh to a text file. I can get the color values fine, but can't find a way to get the alpha values.
The code is currently:
-- Pick the mesh to export colors from
target_mesh = pickObject message:"Pick Target Surface:" filter:g_filter
if isValidNode target_mesh then
(
-- Snapshot mesh
tmesh = snapshotAsMesh target_mesh
-- Save file dialog
out_name = getSaveFileName \
caption:"Save vertex color text file" \
types:"Text(*.txt)"
if out_name != undefined then
(
out_file = createfile out_name
num_verts = tmesh.numverts
for v = 1 to num_verts do
(
-- Get vertex color
vc = getVertColor tmesh v
format "%\t%\t%\t%\n" v vc.r vc.g vc.b to:out_file
)
-- Close file
close out_file
)
)
I'm guessing I need a line similar to the vc = getVertColor, but for the vertex alphas. In the import script (opposite of this one), I use "meshOp.setVertAlpha target_mesh -2 vert alpha" to set the vertex alpha, which works fine. It uses channel -2 which is Max's built in vertex alpha channel.
If anyone could help, that would be great. Thanks.
