FORUMS: list search recent posts

Create billbaords script?

COW Forums : Autodesk Maya

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
James Peres
Create billbaords script?
on Apr 5, 2014 at 1:21:18 am

So I'm going to need to make a lot of poly planes to make a billboard and assign them image sequences or static images for textures. It's a little tedious duplicating materials and adding file nodes etc just to add a billboard, let alone add a control to control the frame extension. Is there any script to do this or help out in making 2d animation with this?

(Going to plan to use this to make some cool transitions in Unity so that's why I don't want to use another animation tool)

Thanks!

-
James

Mac Pro 4,1 Quad Core 2.66


Return to posts index

James Peres
Re: Create billbaords script?
on Apr 9, 2014 at 10:41:47 pm

I ended up making one, posting here to help anyone else.

/*

makeBillboard() by Brian Perez
Creates an poly plane with a new shading group, asks for
texture to be used. Creates a control curve surrounding the plane
and creates a set driven key on the control node if is an image sequence

Based heavily off of jgMakeSimpleSDK by Jay Grenier (jay@jaygrenier.com),
imageloop by Bjorn Klaassen (http://www.highend3d.com/maya/mel/?section=rendering#3636), and
f_ref by Filippo Maccari (http://www.creativecrash.com/script/40618/)

v1 : Basic functionality implemented
*/

global proc makeBillboard()
{
if ( `window -exists makeBillboard`)
{
deleteUI -window makeBillboard;
}
else
{
string $makeBillboard_window = `window -title "makeBillboard"
-s false
-mnb false
-mxb false
-w 100
-h 600 makeBillboard`;

columnLayout -adj true;

button -l "Make"
-h 50
-w 100
-rs true
-c ( "exe_makeBillboard" );

separator -h 10 -st "none";

checkBox -label "image sequence?"
-v 1 image_seq;
checkBox -label "normalize size"
-v 1 normalize_size;
checkBox -label "filter texture"
-v 1 filter_texture;

showWindow $makeBillboard_window;;
}
}

global proc exe_makeBillboard()
{
string $filepath[] = `fileDialog2 -fileMode 1 -caption "Import Image"`;

if (`exists $filepath[0]`)
{
string $extensionremove[];
tokenize $filepath [0] "." $extensionremove;
string $pathremoved = $extensionremove[size($extensionremove)-2];

string $pathremove[];
tokenize $pathremoved "/" $pathremove;
string $filedumbname = $pathremove[size($pathremove)-1];

string $tempgrp = `group -em -name ("TEMPGRP_"+$filedumbname)`;

string $tempgrpname[];
tokenize $tempgrp "TEMPGRP_" $tempgrpname;
string $filename = $tempgrpname[size($tempgrpname)-1];

delete $tempgrp;

if (`objExists ("IP_"+$filename+"_PLANE")`)
{
print "Texture filename already present, too long or too messy, please rename your texture file";
}
else
{
shadingNode -asShader lambert
-n ("IP_"+$filename+"_MAT");
shadingNode -asTexture file
-n ("IP_"+$filename+"_TXT");

setAttr -type "string" ("IP_"+$filename+"_TXT.fileTextureName") $filepath;

int $checkbox_imageSequence=`checkBox -q -value image_seq`;
if ( $checkbox_imageSequence == 1 )
{
setAttr ("IP_"+$filename+"_TXT.useFrameExtension") 1;
}
connectAttr -f ("IP_"+$filename+"_TXT.outColor") ("IP_"+$filename+"_MAT.color");
setAttr ("IP_"+$filename+"_MAT.ambientColor") -type double3 1 1 1 ;
setAttr ("IP_"+$filename+"_MAT.diffuse") 0;

if (`getAttr ("IP_"+$filename+"_TXT.fileHasAlpha")` == 1)
{
connectAttr -f ("IP_"+$filename+"_TXT.outTransparency") ("IP_"+$filename+"_MAT.transparency");
}

polyPlane -sx 1
-sy 1
-w 1
-h 1
-n ("IP_"+$filename+"_PLANE")
-ch 0;

setAttr ("IP_"+$filename+"_PLANE.rotateX") 90;
addAttr -ln "resolution" -k true -at double ("IP_"+$filename+"_TXT");
addAttr -ln "resolution" -k true -at double ("IP_"+$filename+"_PLANE");

setAttr ("IP_"+$filename+"_PLANE.resolution") 512;
connectAttr -f ("IP_"+$filename+"_PLANE.resolution") ("IP_"+$filename+"_TXT.resolution");
addAttr -ln "filter_intensity" -k true -at double -min 0 -max 10 -dv 2 ("IP_"+$filename+"_PLANE");

setAttr ("IP_"+$filename+"_TXT.filterType") 1;
setAttr ("IP_"+$filename+"_TXT.preFilter") 1;
connectAttr -f ("IP_"+$filename+"_PLANE.filter_intensity") ("IP_"+$filename+"_TXT.preFilterRadius");

int $checkbox_filter =`checkBox -q -value filter_texture`;
if ($checkbox_filter == 0)
{
setAttr ("IP_"+$filename+"_PLANE.filter_intensity") 0;
}
if ($checkbox_filter == 1)
{
setAttr ("IP_"+$filename+"_PLANE.filter_intensity") 2;
}

$width = `getAttr ("IP_"+$filename+"_TXT.outSizeX")`;
$height = `getAttr ("IP_"+$filename+"_TXT.outSizeY")`;
$ratio = ($width / $height);

int $checkbox_normalize =`checkBox -q -value normalize_size`;

if ($checkbox_normalize == 0)
{
setAttr ("IP_"+$filename+"_PLANE.scaleX") $width;
setAttr ("IP_"+$filename+"_PLANE.scaleZ") $height;
}

if ($checkbox_normalize == 1)
{
if ($width < $height)
{
setAttr ("IP_"+$filename+"_PLANE.scaleX") (24 * $ratio);
setAttr ("IP_"+$filename+"_PLANE.scaleZ") 24;
}
else
{
setAttr ("IP_"+$filename+"_PLANE.scaleX") 24;
setAttr ("IP_"+$filename+"_PLANE.scaleZ") (24 / $ratio);
}
}

select -r ("IP_"+$filename+"_PLANE") ;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;
hyperShade -assign ("IP_"+$filename+"_MAT");
select -cl;

string $control_curve = `curve -d 1 -p -13 13 0 -p 13 13 0 -p 13 -13 0 -p -13 -13 0 -p -13 13 0 -k 0 -k 1 -k 2 -k 3 -k 4 `;
string $frameSelText = "frameSel";
addAttr -ln $frameSelText -at long $control_curve;
setAttr -keyable true ($control_curve+"."+$frameSelText);
makeIdentity -apply true -translate 1 -rotate 1 -scale 1 -normal 0;

parent ("IP_"+$filename+"_PLANE") ($control_curve);
scale 0.2 0.2 0.2 $control_curve;

if ( $checkbox_imageSequence == 1 )
{
// Get info
string $driver = ($control_curve+"."+$frameSelText) ;
string $driven = ("IP_"+$filename+"_TXT.frameExtension") ;

// Check if objects exists, if not die
if(!`objExists $driver`) error ($driver+" - Driver object doesn't exist.") ;
if(!`objExists $driven`) error ($driven+" - Driven object doesn't exist.") ;

// Create Set Driven Keys
setDrivenKeyframe -itt "linear" -ott "linear" -dv 0 -v 0 -cd $driver $driven ;
setDrivenKeyframe -itt "linear" -ott "linear" -dv 50 -v 50 -cd $driver $driven ;
}

setAttr -lock true ("IP_"+$filename+"_PLANE.tx");
setAttr -lock true ("IP_"+$filename+"_PLANE.ty");
setAttr -lock true ("IP_"+$filename+"_PLANE.tz");
setAttr -lock true ("IP_"+$filename+"_PLANE.rx");
setAttr -lock true ("IP_"+$filename+"_PLANE.ry");
setAttr -lock true ("IP_"+$filename+"_PLANE.rz");
setAttr -lock true ("IP_"+$filename+"_PLANE.sx");
setAttr -lock true ("IP_"+$filename+"_PLANE.sy");
setAttr -lock true ("IP_"+$filename+"_PLANE.sz");
setAttr -lock true ("IP_"+$filename+"_PLANE.v");
setAttr -lock true ("IP_"+$filename+"_PLANE.resolution");
setAttr -lock true ("IP_"+$filename+"_PLANE.filter_intensity");

rename $control_curve ("CNTRL_"+$filename);
select ("CNTRL_"+$filename);
}
}
}


-
James

Mac Pro 4,1 Quad Core 2.66


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]