Monday, October 26, 2009
Smash Bros. Brawl Texture Hack
So I did this a while back for fun. It's a texture hack for Zero Suit Samus in Smash Bros. The figure and build seemed a good fit for Kid from Chrono Cross. The UV topology was kind of a mess, and there was no good way to test it in Maya at the time. Just looking at the original textures in Photoshop, it was hard to tell what was what. So the the work flow was pretty tedious. Paint a bit in Photoshop, compile texture, write out to SD card, play Smash Bros. After trying to pinpoint bad areas in the texture (stretching and scale issues), I'd go back to Photoshop for more guess work and then repeat the process. This is the result. The compiled textures can be downloaded here if you have an interest in trying them out. It was a interesting experience, but too much trial and error to really get creative. I'd like to do a Starky hack of Olimar, but until I find a way to preview textures and models in Maya, I'll stay away from that.
Monday, October 19, 2009
Maya Geometry Exporter
Maya object exporter I wrote. Getting the vertex order right for components was frustrating. Maya's a little inconsistent in this regard. Some MEL functions list vertex translation correctly but then the adjacent function for vertex normals lists them arbitrarily and so on. Oh well. Currently I'm using this to get models into an OpenGL game. If you'd like to use the code feel free. It's a little hacky and slow writing large models. I'll clean it up a bit later and add bones for articulated models.
// ******** global proc AOF() ******** //
// Simply opens export dialog box //
// //
/////////////////////////////////////////
global proc AOF()
{
fileBrowserDialog -m 1 -fc "ExportAOF" -an "Save AOF" -om "SaveAs";
}
// ***** global proc ExportAOF() ***** //
// Handles object parsing //
// //
/////////////////////////////////////////
global proc ExportAOF(string $filename, string $fileType)
{
//Setup file name
$fileType = "\.aof";
string $filename = $filename + $fileType;
//Open file for writing
$fileHandle = `fopen $filename "w"`;
//Setup Variables
string $selection[] = `ls -sl`;
int $m, $n;
//Process geometry
fwrite $fileHandle "#Vertex Data Format: [Position X 3] [Normal X 3] [UV X 2]\n";
PolySelectConvert 1;//convert selection to faces
string $faces[] = `ls -sl -fl`;
fwrite $fileHandle (`size $faces`+"\n");
for($m = 0; $m < `size $faces`; $m++)
{
select -r $faces[$m];
string $faceToVertex[]=`polyInfo -faceToVertex`;
string $tokens[];
tokenize $faceToVertex[0] " :\n\r" $tokens;
int $vertexOrder[];
clear $vertexOrder;
int $t;
for ($t = 2; $t < `size $tokens`; $t++)
{
$vertexOrder[`size $vertexOrder`] = $tokens[$t];
}
string $fverts[]={($selection[0]+"\.vtx["+$vertexOrder[0]+"]"),
($selection[0]+"\.vtx["+$vertexOrder[1]+"]"),
($selection[0]+"\.vtx["+$vertexOrder[2]+"]")
};
PolySelectConvert 1;
select -r $faces[$m];
for($j = 0; $j < `size $fverts`; $j++)
{
//vertex position
float $vpos[] = `xform -q -ws -t $fverts[$j]`;
//normal position
float $normal[3];
string $vertexFace[]= `polyListComponentConversion -fv -tvf $fverts[$j]`;
$vertexFace= `filterExpand -sm 70 -ex true $vertexFace`;
//check to see which face the vertex is associated with
//and retrieve that normal
for($n = 0; $n < `size $vertexFace`; $n++)
{
string $token[];
tokenize $vertexFace[$n] " []\r\n" $token;
if($token[2] == $m)
{
$normal=`polyNormalPerVertex -q -xyz $vertexFace[$n]`;
}
}
//UV position
select -r $faces[$m];
PolySelectConvert 4;
string $uvs[]=`ls -sl -fl`;
string $testUV;
float $UV[];
for($testUV in $uvs)
{
string $test[]=`polyListComponentConversion -fuv -tv $testUV`;
if($test[0]==$fverts[$j])
{
$UV=`polyEditUV -q $testUV`;
}
}
//Write out data
fwrite $fileHandle ($vpos[0]+" "+$vpos[1]+" "+$vpos[2]+" "+
$normal[0]+" "+$normal[1]+" "+$normal[2]+" "+
$UV[0]+" "+$UV[1]+"\n");
}
}
fclose $fileHandle;
}
// ******** global proc AOF() ******** //
// Simply opens export dialog box //
// //
/////////////////////////////////////////
global proc AOF()
{
fileBrowserDialog -m 1 -fc "ExportAOF" -an "Save AOF" -om "SaveAs";
}
// ***** global proc ExportAOF() ***** //
// Handles object parsing //
// //
/////////////////////////////////////////
global proc ExportAOF(string $filename, string $fileType)
{
//Setup file name
$fileType = "\.aof";
string $filename = $filename + $fileType;
//Open file for writing
$fileHandle = `fopen $filename "w"`;
//Setup Variables
string $selection[] = `ls -sl`;
int $m, $n;
//Process geometry
fwrite $fileHandle "#Vertex Data Format: [Position X 3] [Normal X 3] [UV X 2]\n";
PolySelectConvert 1;//convert selection to faces
string $faces[] = `ls -sl -fl`;
fwrite $fileHandle (`size $faces`+"\n");
for($m = 0; $m < `size $faces`; $m++)
{
select -r $faces[$m];
string $faceToVertex[]=`polyInfo -faceToVertex`;
string $tokens[];
tokenize $faceToVertex[0] " :\n\r" $tokens;
int $vertexOrder[];
clear $vertexOrder;
int $t;
for ($t = 2; $t < `size $tokens`; $t++)
{
$vertexOrder[`size $vertexOrder`] = $tokens[$t];
}
string $fverts[]={($selection[0]+"\.vtx["+$vertexOrder[0]+"]"),
($selection[0]+"\.vtx["+$vertexOrder[1]+"]"),
($selection[0]+"\.vtx["+$vertexOrder[2]+"]")
};
PolySelectConvert 1;
select -r $faces[$m];
for($j = 0; $j < `size $fverts`; $j++)
{
//vertex position
float $vpos[] = `xform -q -ws -t $fverts[$j]`;
//normal position
float $normal[3];
string $vertexFace[]= `polyListComponentConversion -fv -tvf $fverts[$j]`;
$vertexFace= `filterExpand -sm 70 -ex true $vertexFace`;
//check to see which face the vertex is associated with
//and retrieve that normal
for($n = 0; $n < `size $vertexFace`; $n++)
{
string $token[];
tokenize $vertexFace[$n] " []\r\n" $token;
if($token[2] == $m)
{
$normal=`polyNormalPerVertex -q -xyz $vertexFace[$n]`;
}
}
//UV position
select -r $faces[$m];
PolySelectConvert 4;
string $uvs[]=`ls -sl -fl`;
string $testUV;
float $UV[];
for($testUV in $uvs)
{
string $test[]=`polyListComponentConversion -fuv -tv $testUV`;
if($test[0]==$fverts[$j])
{
$UV=`polyEditUV -q $testUV`;
}
}
//Write out data
fwrite $fileHandle ($vpos[0]+" "+$vpos[1]+" "+$vpos[2]+" "+
$normal[0]+" "+$normal[1]+" "+$normal[2]+" "+
$UV[0]+" "+$UV[1]+"\n");
}
}
fclose $fileHandle;
}
Saturday, October 17, 2009
It's about time
Man, you would think for someone who's supposed to be somewhat tech savvy I'd have one of these by now. It's shameful, but I hope to redeem myself. I'll be oozing bits of my 3D projects and code every now an again. Stay tuned, meat bags.
Subscribe to:
Posts (Atom)