Saturday, August 22, 2009

nice solution to rounding float in MEL

though I use MEL less and less this day, it's still nice to have some solution for some problem, like the one below.

If you want to round a float to nearest integer in python, just use round(4.33) . But we don't have round function in MEL. so we need to do some workaround. I found below technique in Maya Station blog :


float $float = 3.14159265;

floor ( $float + 0.5 );

// Result: 3

Wednesday, April 08, 2009

add something like [code][/code] in blogger

When you need to post multiple-line source codes(mel,C,python,whatever)..you need the exact format as in your code editor because it'll look much tidier. But if you paste the code here in the standard blogger post editor, it'd look as ugly as you can imagine. So I search the net the found this site (also a blogger site):

http://formatmysourcecode.blogspot.com/


Basically you just need to paste the codes there, and it'll return the "correct" formatting for you. And then you can paste them back to your post editor.

Here's an example of it:
{
polySelectConstraint -m 3 -t 0x8000 -w 1 ;
polySelectConstraint -dis;
$selection = `ls -sl -fl -l` ;

string $borderShell[];
int $borderSize[];
int $currSize=0;
for($currID= 0;$currID<size($selection);$currID++)
{

if($selection[$currID]=="")
continue;

$borderShell[$currSize] = $selection[$currID];


string $tmp[]=`polyListComponentConversion -fe -tv $selection[$currID]`;
string $verts[]=`ls -fl $tmp`;

int $found=0;
int $iter=0;
int $maxIter = 20000;
do
{
$found=0;

for($nID = 0;$nID<size($selection);$nID++)
{
if($selection[$nID]=="")
continue;

if($selection[$nID] == $selection[$currID])
continue;

$tmp=`polyListComponentConversion -fe -tv $selection[$nID]`;
string $nVerts[] = `ls -fl $tmp`;


for($i=0;$i<size($verts);$i++)
{

for($j=0;$j<size($nVerts);$j++)
{
if($verts[$i] == $nVerts[$j])
{
$borderShell[$currSize] = $borderShell[$currSize] + " " + $selection[$nID];
$selection[$currID]="";
$selection[$nID] = "";
$j =!$j;
$verts[$i] = $nVerts[$j];

$found=1;
break;

}
}

if($found)
break;
}
if($found)
break;
}
$iter+=1;
}while($found && $iter<$maxIter);

$currSize+=1;
}
print $borderShell;
}


The example codes above are mel codes. The usage is to organize border edges into each separate border shells.

Saturday, March 14, 2009

Funny mind...


About six years ago, just graduated from high school, I was deeply obsessed with Kiyosaki's words. The most important thing seemed to be making quick money, then retire early and enjoy the "free life". But at that time, I had no idea and clear plan of how to quickly become rich and financial independent, aside from the abstract idea like "investing","leverage","ma
ke the money multiplies itself", etc.

Today, I still had no idea and clear plan :). But toward these years,my focus and main goals slowly shifted to become a "creative and inventive" person. By that I mean a man who possess technical and artistic skills to create astounding works,which in turn will generate money "enough" for my living needs. My interest in duplicating the income (for example by investing in stocks or real estate or whatever the investor teaches ^ ^ ) has been diminished, or more correctly, postponed.

Of course I'm still aware that I need to do some investing in order to "live easier" instead of counting on the "not so great" monthly income. But I think the first and foremost thing to do is to educate myself with the skills mentioned above so that I'm at least as competent as any others in my field, since it's a flat world now (thanks to Mr Friedman for the term). As long as you're competent, the demand for your skill will always exist, and the reward may increase exponentially when you're the 'A' list.

This may not be the best route to be financially independent (it's still my important consideration, I mean, who isn't?), but I think it's the most suitable and satisfying one for me, because basically I'm a person who's quite hungry for knowledge and information,and admittedly, recognition from others. For me it's quite satisfying when people recognize my work or appreciate my technical support/help. So hopefully I could contribute more and more in the future , and get satisfying reward in the process.

I wonder though, what will my 10 years older mind think about in this matter, will it dismiss my current thought as I'm doing now with my adolescence idea? :)

Sunday, February 01, 2009

fallen, and forgotten...

This is the rendered image of my latest personal works, mainly to practice my modeling, texturing, and rendering skills. No fancy stuff, I'm just trying to create a realistic image.

Description : A mask accidentally dropped on the street. He's not considered a valuable item, so nobody cared about him, and he gradually became dirty, and useless, ready to be thrown into trashcan..




software used : Maya as main platform, Photoshop for texturing, and 3Delight for rendering.

large image link :
http://r4inm4ker.frihost.net/works/images/mask-render1.jpg