PDA

View Full Version : Get vertex alpha channel values?


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.

Bobo
02-02-2004, 11:43 PM
Please read the topic "Accessing the Viewport Vertex Alpha Values" in the MAXScript 6 Online Reference (I think I wrote it for the PFlow Extension update to 5.1, so you could download the MAXScript Help 5.1.1 from discreet's support site if you are still using Max 5)

It shows an example of accessing the viewport alpha channel (-2) and discusses related questions...

Please let me know if you cannot find it.
(In the 6th version, there is also a topic called "How do I access the Alpha values shown in the viewport?" in the "Frequently Asked Questions" chapter which links to the actual page)

Hope this helps.

Bobo


Originally posted by ed-it
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.

CGTalk Moderation
01-17-2006, 08:00 AM
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.