Introduction to Maya - Modeling Fundamentals Vol 2
This course will look in the fundamentals of modeling in Maya with an emphasis on creating good topology. It's aimed at people that have some modeling experience in Maya but are having trouble with complex objects.
# 1 29-02-2012 , 06:22 AM
Acid44
Guest
Posts: n/a

Game Modeling Button?

When the cars I model for work go to the game engine all the normals are set to 90 degrees. This is freaking exhausting when modeling as I have to set to 90 and unlock normals every time I bevel anything, or create a new panel/part to make sure it looks decent.

Is there a way I could make a shelf button to freeze transformations, set normal angle to 90, and unlock normals all at once? Keep in mind I have no idea about anything to do with mel script, so if you could write/tell me what to do with it in simple terms it would help a lot user added image

Thanks

# 2 29-02-2012 , 09:12 AM
daverave's Avatar
The thin red line
Join Date: Aug 2009
Location: England
Posts: 4,472
I dont write script but what you could do open your script editor and move to the side select your model now take note of what is added to the script edit as you do your actions (freeze transformation ec) after you have finished high light the add script middle mouse button and drag up to the shelf, that should work.............dave




Avatar Challenge Winner 2010
# 3 29-02-2012 , 11:02 AM
Registered User
Join Date: Mar 2007
Posts: 1,055
Yup Dave is correct, I don't script at all but have used this tactic before,

# 4 29-02-2012 , 11:41 AM
ctbram's Avatar
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,998
NextDesign would probably be your best bet to answer this.

The problem is for unlocking the vertex normals and to set the normal angle per vertex for a selected object you are going to need a vertex or vertex face selection. so you will have to write mel code to do that.

Freezing transforms and setting the edge normals to 90 can be done per object selection and so can be copied from the scrpt editor directly. Here is the mel for that...

FreezeTransformations;
polySoftEdge -angle 90;

For setting per vertex or vertex face normals and to unlock the them for a selected polygon object you'll need code that looks kinda like this...

string $selection[] `ls -sl`;
int $count1[] = `polyEvaluate -v $selection[0]`;
select -r ($selection[0] + ".vtx[0:" + ($count1[0] - 1) + "]");
polyNormalPerVertex -ufn 1; -xyz (float) (float) (float)
select -r $selection;

The first line, saves the current selection.

The next two lines look at only the first object selected and selects all the vertex components. Note - for all objects in the selection you will need a foreach loop over all the objects in the $selection. I can't help you there.

The -xyz sets the per vertex normal angle in the x y and z directions but I am not sure what the float value for 90 degree in x, y, and z is though. The -ufn 1 says unlock all the vertex or vertex faces selected.

The last line restores the original selection and for this is probebly not needed but rather a way to unselect all the vertexes that will now be selected.


"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675

Last edited by ctbram; 29-02-2012 at 11:44 AM.
# 5 29-02-2012 , 11:45 AM
Acid44
Guest
Posts: n/a
Thanks, works decently ;D

Is there any way to then export that button so I can pass it to a few people?

EDIT: CT, you posted as I was posting, just trying to make sense of that before replying properly :p

E2: Get what you mean now, sort of. Most of it anyway... The rest is kind of over my head at the moment, guess I'll just wait for ND to see this thread and see if he can be of assistance :p


Last edited by Acid44; 29-02-2012 at 01:31 PM.
# 6 29-02-2012 , 11:57 AM
daverave's Avatar
The thin red line
Join Date: Aug 2009
Location: England
Posts: 4,472
Not sure if that last bit will help Rick..........dave

FreezeTransformations;
polySoftEdge -angle 90;
ConvertSelectionToVertexFaces;
polyNormalPerVertex -ufn true




Avatar Challenge Winner 2010

Last edited by daverave; 29-02-2012 at 12:03 PM.
# 7 29-02-2012 , 12:32 PM
ctbram's Avatar
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,998
Well my point Dave is he cannot simply copy and paste from the script editor for setting the per vertex angle and unlocking them because that requires a component selection and will have the specific object embedded in the selection so he is not going to be able to make a generalized button for that and will need to write mel.

I am not a mel writer so I just gave an over view of the kind of code he will need for that part of the problem.

NextDesign is probably his best hope of getting properly written code.


"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675
# 8 29-02-2012 , 02:08 PM
daverave's Avatar
The thin red line
Join Date: Aug 2009
Location: England
Posts: 4,472
Rick I have been doing this sort of stuff for years not in maya but excel and access, I was a team leader of a parts department and the manager thought he was pulling a fast one when he gave me 15,000 lines of engineer orders to put on the system but he did not know that I found a way to put a order on the system with a macro and spread sheet, I just pressed play then went for a fag......LOL......dave




Avatar Challenge Winner 2010
# 9 29-02-2012 , 03:38 PM
ctbram's Avatar
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,998
Sorry Dave, I thought unlock normals had to have an object specific vertex or vertex face component selection. Apparently they do not. When I went in and tried it earlier I got a message that the unliock normals only worked on a component selection. I just went in again and it lets me do it and set vertex normals now on an object selection. Sorry for the error.

Remember to turn on echo all commands or the polyNormalPerVertex -ufn true; and polyNormalPerVertex -xyz 1 0 0; commands. The freezeTransformations does seem to echo even if the echo all commands checkbox is unchecked.


"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675

Last edited by ctbram; 29-02-2012 at 03:40 PM.
# 10 29-02-2012 , 04:52 PM
daverave's Avatar
The thin red line
Join Date: Aug 2009
Location: England
Posts: 4,472
Rick I used the ConvertSelectionToVertexFaces; command to change the selection I do not know if it works because I dont know how to see if the the norms are unlocked.........dave




Avatar Challenge Winner 2010
# 11 29-02-2012 , 06:53 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Usually a PM is the best way to get my attention user added image

So has this been solved, or should I take a look into it?


Imagination is more important than knowledge.
# 12 29-02-2012 , 08:24 PM
Acid44
Guest
Posts: n/a
Still needs to be looked at, as I need it to preferably work for dozens of objects at a time

@Dave - You can check if the normals are unlocked by selecting an object and then going to the Vertex Normal Edit Tool, yellow lines are locked, green is unlocked

Also, the snippet you've posted works without the line that converts selection to vertex, but with that line in it doesn't seem to do anything


Last edited by Acid44; 29-02-2012 at 08:26 PM.
# 13 29-02-2012 , 09:05 PM
ctbram's Avatar
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,998
@acid when you say set the normals to 90 are you referring to vertex normals or edge normals?


"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675
# 14 29-02-2012 , 09:25 PM
ctbram's Avatar
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,998
Here you go Acid try this....

Code:
string $selection[] = `ls -sl`;
for ($node in $selection)
{
    FreezeTransformations $node;            // freeze xforms
    polyNormalPerVertex -ufn true $node;    // unlock normals
    polySoftEdge -angle 90 $node;           // set normal angle to 90
}

Note: I am not a mel guy. I just hacked this up. There is no error checking. But if you select all polyobjects this should do exactly what you want. 1. freeze all the transforms, unlock all the normals, set the normal angle to 90 for every object in the selection.


"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675

Last edited by ctbram; 29-02-2012 at 09:29 PM.
# 15 29-02-2012 , 09:41 PM
Acid44
Guest
Posts: n/a
I'm guessing edge normals, the polysoftedge tool one user added image

And that worked perfectly, thanks user added image

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads