Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / MEL point light help
  RSS 2.0 ATOM  

MEL point light help
Rate this thread
 
62445
 
Permlink of this thread  
avatar
  • goose
  • Posted: 01 December 2011 03:21 PM
  • Total Posts: 15
  • Joined: 22 August 2006 02:49 AM

I’ve saved a shelf button for my own poinlight, raised from the grid, with the right
quadratic settings, raytrace ,etc....it’s a time saver, however when I click the saved shelf button command again it goes back to default settings....unless I rename the light before creating another one.
What sort of a mel line could I add to that mel to stop from resetting to default?
Also same thing with a blinn, I made one for the shelf with 0 reflectivity and on the first
creation of the node is right but once I create a second blinn, goes back to 500 reflectivity.
...again, unless I rename the blinn.
thanks for any pointers.



Replies: 0
avatar
  • ldunham1
  • Posted: 01 December 2011 08:42 PM

It does kinda depend on what you already have, instead of adding mel, sounds like you just need to adjust what you have. If you post up i’ll take a look and should be able to sort it.

If not you could have a look at the rename command to rename your object after it’s created to a unique name tn ensure the next instance of the script doesn’t just adjust the node you already have.



Lee Dunham | Character TD
ldunham.blogspot.com

Replies: 1
/userdata/avatar/rc3q4nie4.jpg

Thanks Idunham, here’s the simple script...yeah, I just new to add an flag, variable or something at the end of this script but
I’m just starting to learn more about scripting, I named the light at the end of the script “Point_A” , but it goes back to deafult settings one I hit the shelf button to create another light....see if you can help.....thanks.......

defaultPointLight(55, 0.8820000291,0.866271019,0.7876260281, 2, 1, 0,0,0, 1);
setAttr “pointLightShape1.useRayTraceShadows” 1;
setAttr “pointLightShape1.lightRadius” 0.1;
setAttr “pointLightShape1.shadowRays” 2;
setAttr “pointLightShape1.rayDepthLimit” 4;
move -r -os -wd 0 4.662165 0 ;
select -r pointLight1 ;
rename “pointLight1” “Point_A”;
// Result: Point_A //

Author: goose

Replied: 02 December 2011 09:15 AM  
avatar

defaultPointLight is actually a maya script, rather than a base MEL command. I would think you got the script you are using by copying from the script editor… which is OK, but you might have better results using the pointLight command directly.

Your problem is that you are overwriting the default name pointLight1 each time you run the script. Only the first time you run it will the button be named pointLight1 when created.

I will attempt to make a script for you, and while the placement values may not be exactly what you want for each new light, you can probably modify this yourself to get it right.

string $pLightName = `pointLight -intensity 55.0 -rgb 0.8820000291 0.866271019 0.7876260281 -decayRate 2 -useRayTraceShadows 1 -shadowColor 0.0 0.0 0.0 -shadowSamples 2 -discRadius 0.1 -name "Point_A"`;
setAttr ($pLightName+".rayDepthLimit"4;
move --os -wd 0 4.662165 0;

This will create a new light every time, starting with Point_A, then Point_A1, Point_A2 and so on. Edit the name in the script if you want to start with Point1 or something else, Maya will always add a digit on the end so each light has a unique name.

Note how I did this… I created a variable $pLightName which receives the name of the newly created light after the pointLight command makes it (and that name is passed as the -name parameter, so the rename is not needed. The setAttr command uses the actual new light name instead of pointLightShape1 name (so you don’t have your command overwriting a different light every time). Several of the parameter you were using setAttr on can be included in the pointLight command, so I put them there. Since the light is selected when it is made, there was no need to use the select command to select it again.

I tested it here and it makes and moves the lights where the code specifies. That is always the same place, you can edit the script to move it somewhere else, I just copied your code location.

You can find the documentation on the pointLight command in the technical documentation section of the Maya docs if you want to adjust some of the parameters, but I used the long names in teh command so it would be more obvious what everything does.

<* Wes *>



Replies: 0
avatar
  • goose
  • Posted: 02 December 2011 07:33 PM

Priceless Wesley! thanks a lot ,I’ll adjust the scriptomorrow following your notes.
Best.



Replies: 0