hey guys, I would really like to be able to use Alembic to pass vertex cache data in between maya and houdini. Unfortunately, the maya plug in for this is incredibly limiting (it only passes position, normals, and a single UV set.. maybe color… but I really need control on what kind of mesh data I pass)
I was thinking to make my own abcExporter and I wanted to see if anyone could point me in any direction? Ideally it would be nice if I could use the python API to avoid having to write a plug in
thank you in advance!
Alembic export from maya to houdini
11368 4 3-
- grayOlorin
- Member
- 1814 posts
- Joined: Oct. 2010
- Offline
-
- Sadjad Rabiee
- Member
- 1391 posts
- Joined: Dec. 2010
- Offline
-
- jparker
- Member
- 321 posts
- Joined:
- Offline
I wrote this MEL script in Maya 2013 to get rest position data into Houdini. You can use colorSets in Maya to get your vector data across. The most useful info for you is probably in the comments on top. Note that it also is saving out a “abcMaterial” and “abcMaterialTextures” attribute that you probably don't need.
/*
To save color information into the alembic file the flag “-wcs” is needed.
Example:
AbcExport -verbose -j “ -wcs -frameRange 1 1 -attr abcMaterial -attr abcMaterialTextures -ro -uvWrite -wholeFrameGeo -worldSpace -writeVisibility -root |model_GRP -file /tmp/test.abc”;
*/
global proc storeRestPosition(string $sel)
{
string $colorSet = “rest”;
int $undoState = `undoInfo -q -state`;
undoInfo -state false;
constructionHistory -toggle false;
string $nodes = `listRelatives -ad -f $sel`;
for ($node in $nodes)
{
if (`nodeType $node` == “mesh”)
{
print (“Setting vertex colors on node ”+$node+“\n”);
string $cmd = “”;
if (!stringArrayContains($colorSet, `polyColorSet -q -allColorSets`))
{
polyColorSet -create -clamped 0 -rpt RGB -colorSet $colorSet $node;
}
polyColorSet -currentColorSet -colorSet $colorSet $node;
int $nverts = `polyEvaluate -v $node`;
int $i;
for ($i = 0; $i < $nverts; $i++)
{
string $currentVtx = ($node+".vtx");
float $pos = `xform -q -ws -t $currentVtx`;
$cmd += (“polyColorPerVertex -nun -rgb ”+$pos+“ ”+$pos+“ ”+$pos+“ ”+$currentVtx+“;\n”);
}
eval($cmd);
clearCache -all;
setAttr ($node+“.displayColors”) 1;
}
}
undoInfo -state $undoState;
constructionHistory -toggle true;
}
That said, I haven't attempted going back out of Houdini into Maya.
/*
To save color information into the alembic file the flag “-wcs” is needed.
Example:
AbcExport -verbose -j “ -wcs -frameRange 1 1 -attr abcMaterial -attr abcMaterialTextures -ro -uvWrite -wholeFrameGeo -worldSpace -writeVisibility -root |model_GRP -file /tmp/test.abc”;
*/
global proc storeRestPosition(string $sel)
{
string $colorSet = “rest”;
int $undoState = `undoInfo -q -state`;
undoInfo -state false;
constructionHistory -toggle false;
string $nodes = `listRelatives -ad -f $sel`;
for ($node in $nodes)
{
if (`nodeType $node` == “mesh”)
{
print (“Setting vertex colors on node ”+$node+“\n”);
string $cmd = “”;
if (!stringArrayContains($colorSet, `polyColorSet -q -allColorSets`))
{
polyColorSet -create -clamped 0 -rpt RGB -colorSet $colorSet $node;
}
polyColorSet -currentColorSet -colorSet $colorSet $node;
int $nverts = `polyEvaluate -v $node`;
int $i;
for ($i = 0; $i < $nverts; $i++)
{
string $currentVtx = ($node+".vtx");
float $pos = `xform -q -ws -t $currentVtx`;
$cmd += (“polyColorPerVertex -nun -rgb ”+$pos+“ ”+$pos+“ ”+$pos+“ ”+$currentVtx+“;\n”);
}
eval($cmd);
clearCache -all;
setAttr ($node+“.displayColors”) 1;
}
}
undoInfo -state $undoState;
constructionHistory -toggle true;
}
That said, I haven't attempted going back out of Houdini into Maya.
-
- grayOlorin
- Member
- 1814 posts
- Joined: Oct. 2010
- Offline
hey guys, thank you for the reply! jparker, the route to remap to color beforehand is not a terrible idea. it could be a“preprocess” script to exporting an alembic cache. Will have to dig in into how to make it work with moving geometry in maya from a previous cache (I have never parsed multiple geo frames in maya
)
)
-G
-
- Sadjad Rabiee
- Member
- 1391 posts
- Joined: Dec. 2010
- Offline
jparker
I wrote this MEL script in Maya 2013 to get rest position data into Houdini. You can use colorSets in Maya to get your vector data across. The most useful info for you is probably in the comments on top. Note that it also is saving out a “abcMaterial” and “abcMaterialTextures” attribute that you probably don't need.
/*
To save color information into the alembic file the flag “-wcs” is needed.
Example:
AbcExport -verbose -j “ -wcs -frameRange 1 1 -attr abcMaterial -attr abcMaterialTextures -ro -uvWrite -wholeFrameGeo -worldSpace -writeVisibility -root |model_GRP -file /tmp/test.abc”;
*/
global proc storeRestPosition(string $sel)
{
string $colorSet = “rest”;
int $undoState = `undoInfo -q -state`;
undoInfo -state false;
constructionHistory -toggle false;
string $nodes = `listRelatives -ad -f $sel`;
for ($node in $nodes)
{
if (`nodeType $node` == “mesh”)
{
print (“Setting vertex colors on node ”+$node+“\n”);
string $cmd = “”;
if (!stringArrayContains($colorSet, `polyColorSet -q -allColorSets`))
{
polyColorSet -create -clamped 0 -rpt RGB -colorSet $colorSet $node;
}
polyColorSet -currentColorSet -colorSet $colorSet $node;
int $nverts = `polyEvaluate -v $node`;
int $i;
for ($i = 0; $i < $nverts; $i++)
{
string $currentVtx = ($node+".vtx");
float $pos = `xform -q -ws -t $currentVtx`;
$cmd += (“polyColorPerVertex -nun -rgb ”+$pos+“ ”+$pos+“ ”+$pos+“ ”+$currentVtx+“;\n”);
}
eval($cmd);
clearCache -all;
setAttr ($node+“.displayColors”) 1;
}
}
undoInfo -state $undoState;
constructionHistory -toggle true;
}
That said, I haven't attempted going back out of Houdini into Maya.
That's good idea for starting ,really thanks
-
- Quick Links

