View Full Version : UV Planar placement/orientation by selecting a face ?

11 November 2005, 11:18 AM
I search an UV tool mel , that can be used simply and fast.

for exemple.. I want to Select many face.. and select the last face qho define the orientation of the Uv planar tool to create fast lightmap UV for a bunch of buildings.

As I want:

Select an object ( building polymesh )
Go to Face selection
Select multiple face
select the last face ( who will define the orientation of the planar UV tool )
launch the script.
wait and dada !!! it's done..
I want to define the Width and Height of the UV planar tool and that it works for the Second UVSet.

11 November 2005, 02:09 PM
I've find a beginning of solution trues this Mel Script created by Dru Abrams from ( :

Maybe I need to add that line in the script:

global proc spFaceCam_Work_Proc()
if (`objExists faceCam`)
delete faceCam;
string $current[]=`ls -sl`;
string $object[]=`ls -hl`;
string $locator[]=`spaceLocator`;
select $current;
string $cluster[]=`cluster`;
pointConstraint $cluster[1] $locator[0];
string $camera[]=`camera`;
string $camConstraint[]=`pointConstraint $locator[0] $camera[0]`;
delete $camConstraint;
parent $camera[0] $locator[0];
select $object[0];
select -add $locator[0];
normalConstraint -aimVector 0 0 1 -upVector 0 1 0 -worldUpType "vector" -worldUpVector 0 1 0;
setAttr ($camera[0]+".tz") 5;
parent -w $camera[0];
rename $camera[0] faceCam;
delete $locator;
delete $cluster;
//floatSliderGrp -e -v 5 spFaceCam_zoomSlider;
//connectControl spFaceCam_zoomSlider ("faceCam.translateZ");
select $current;
hilite -r $object;
lookThroughModelPanel faceCam (`getPanel -wf`);

global proc spFaceCam_drawUIcontrols()
frameLayout -l "spFaceCam" -cll 1 -cl 0 spFaceCam_frameLayout;
formLayout spFaceCamForm;
button -l "make cam!" -c ("spFaceCam_Work_Proc()") spFaceCamButton;
// floatSliderGrp -f 1 -l "camZoom" -cat 1 "right" 0 -cw3 50 35 80 -adj 3 spFaceCam_zoomSlider;
setParent ..;
formLayout -e
-af spFaceCamButton "right" 0
-af spFaceCamButton "left" 0
// -af spFaceCam_zoomSlider "right" 0
// -af spFaceCam_zoomSlider "left" 0
// -af spFaceCam_zoomSlider "bottom" 0

global proc spFaceCam()
if (`window -ex spFaceCam`)
deleteUI -wnd spFaceCam;
window spFaceCam;
tabLayout spFaceCamTab;
tabLayout -e -tl spFaceCam_frameLayout "spFaceCam" spFaceCamTab;
showWindow spFaceCam;

Should I have to add this line:

setAttr "faceCamShape.orthographic" 1;
setAttr "faceCamShape.orthographicWidth" 50;

11 November 2005, 02:33 PM
as I use this script.. I think about that I need to specify the Y position of the UV planar projection to O by this command:

-projectionCenterY (-pcy) 0

And With that Script.. composed a new script who can position a camera on a selection of face, and aplly an UV Poly Planarby camera projection but with altitude define at 0.

So I define that mel script line:

polyProjection -ch 1 -type Planar -ibd on -icx 0.5 -icy 0.5 -ra 0 -isu 1 -isv 1 -kir -md c -pcy 0

//but The Projection Center still doesn't want to be modify. So I have to return that line to modify it again to O in Y axe. and modify the Width and Height to 100 for UV unwrap convenience.

setAttr "polyPlanarProj10.projectionHeight" 100;
setAttr "polyPlanarProj10.projectionWidth" 100;
setAttr "polyPlanarProj10.projectionCenterY" 0;

11 November 2005, 03:10 PM
should I have to do that ?

polyProjection -ch 1 -type Planar -ibd on -icx 0.5 -icy 0.5 -ra 0 -isu 1 -isv 1 -kir -md c

string $UVHeight= `projectionHeight`;

string $UVWidth= `projectionWidth`;

string $AltitudeY= `projectionCenterY`;

//setAttr "polyPlanarProj10.projectionHeight" 100;

$UVHeight = 100;

//setAttr "polyPlanarProj10.projectionWidth" 100;

$UVWidth = 100;

//setAttr "polyPlanarProj10.projectionCenterY" 0;

$AltitudeY = 100;

Please Help I'm a Newbie.. in mel scripting !

11 November 2005, 08:10 AM
Nobody can help me on that problem... I want to byPass the manual change of the width, heigth , and Projectioncenter Y, by using a script... Please Help, that repetitive process so I will lost to many hours.. or maybe 1 day !

11 November 2005, 10:31 AM
ah yes, i wrote that first script (spFaceCam) a few years ago (it's just hosted on dru's site). i shudder to remember my coding from then :eek:

the help for polyProjection will tell you that using mapDirection will override your placement flags. so if you want to set the placement again, you'll need to store the projection node in a variable (here the help is actually wrong - you can store the projectionNode in a string[] variable).

float $value = 100;
string $proj[] = `polyProjection -ch 1 -type Planar -ibd on -icx 0.5 -icy 0.5 -ra 0 -isu 1 -isv 1 -kir -md c`;
setAttr ($proj[0]+".projectionCenter") $value $value $value;

in this case, the command (polyProjection) returns a string array (string[]). We just need the first index of this array (string[0]).


11 November 2005, 10:07 AM
can you explain a little bit more... I want to see the organization of the script with spDaceCamera, with polyprojection tweak !

11 November 2005, 11:45 AM
the problem is that the "ls" command will return the selection in alphabetical order, so it will be hard to define the last select face without clearly naming an Ui for exemple, it could be possible.

I'll have a look sometime, but i'm very busy at the moment


CGTalk Moderation
11 November 2005, 11:45 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.