How aim polyNormal to an Object center ?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  10 October 2005
Question How aim polyNormal to an Object center ?

Look at this little sketch who explain What I want to do .. with a mel command.



I have created several yellow polyplane, and it around the sphere shape with the MakeLive function. I doesn't search to orient the plane // to the surface of the blue sphere ! So I want to modify all the face normal of the Yellow shape to get it look at the outer space of the Blue sphere center. As you can see the blue sphere was correctly smooth, and all the normal face of the sphere look perfectly at the opposite of the Center pivot of the sphere.

I want to do that Because .. I want to get a correct light effect on the shape of the yellow plane,as if he look like a sphere.. for good illumination.

How can I do this process in a mel script ?
__________________
Freelance 3D CG Environement Artist
at F & K Studio
in South Korea
 
  10 October 2005
nobody can help me .... or maybe you work hard to resolve tha problem...
__________________
Freelance 3D CG Environement Artist
at F & K Studio
in South Korea
 
  10 October 2005
have you try constraint normal?

should work to fit your plane to the sphere, then delete the constraint if you don't want it anymore..done.

cheers
 
  10 October 2005
Smile

The sphere shape is just here to explain what I want to do with the Normal of the yellow shape..

I would like to orient ( aim ) every normal of the yellow shape to look out of the center of the Yellow shape ( as well as the center of the Blue sphere ). the sphere is just a notice, to understand how I would ike to turn all the normal of the Yellow shape
__________________
Freelance 3D CG Environement Artist
at F & K Studio
in South Korea
 
  10 October 2005
Will the polyPlanes and the sphere be animated?
__________________
D
 
  10 October 2005
Thumbs up Howdyy

Here's a quick script I wrote to orient the normals to have a common
intersection point (sphere's center point in this case).

The usage is as follows:
1) Create a locator and move it to mark the given center point.
(Move the locator's transform-node, not the locator's "Local position" etc. attributes)
2) Select the locator and the geometry to apply the effect on to.
3) Execute the script.

Here's a picture to illustrate the resulting normals.
The individual planes no longer have a faceted look, but
are smoothly Gouraud-shaded to better model the shading
on a sphere.




And the code...


   global proc savingSmoluck() {
  
  	string $transforms[] = `ls -sl -type "transform"`;
  	if(size($transforms) < 1) error "Please select a locator!";
  
  	int $locatorFound = false;
  	vector $locator;
  	for($transform in $transforms) {
  		string $shapes[] = `listRelatives -children $transform`;
  		for($shape in $shapes)
  			if (`nodeType $shape` == "locator")
  			{
  				$locatorFound = true;
 				$locator = `xform -q -ws -t $transform`;
  				break;
  			}
  
  		if($locatorFound) break;
  	}
  	if(!$locatorFound) error "Please select a locator!";
  
  	print ("Locator with coordinates: ("+$locator+")\n");
  
  	string $objects[] = `filterExpand -sm 12`;
  	if(size($objects) < 1) error "Please select at least one poly object!";
  	for($object in $objects) {
  
  		int $i; int $numVs[] = `polyEvaluate -vertex $object`;
  		for($i=0; $i<$numVs[0]; $i++) {
  
  			string $V = $object+".vtx["+$i+"]";
  			vector $point = `xform -q -ws -t $V`;
  
  			vector $normal = $point - $locator;
  			if(normalize($normal) != 1) continue;
  
 			polyNormalPerVertex -xyz ($normal.x) ($normal.y) ($normal.z) $V;
  		}
  	}
  }
  
 
  10 October 2005
Talking I send you my scene because.. your script won't work for me ;-)

Here the mb file With the locator and one shape. I have tested with Maya 6 and 7 , and the script seems to have a problem.. Or it's my mistake..

http://skeeter.mot.free.fr/cgtalkup...ormal/import.mb

Please help...And Many Thanks you can resolve that.
__________________
Freelance 3D CG Environement Artist
at F & K Studio
in South Korea
 
  10 October 2005
but if you just want the plane to orient in a specific direction then just create a locator and aimConstraint your plane to it..what's the probleme with that?.

Or maybe i don't get it.

cheers

Edit:
Ok my bad didn't really understand what you where doing.
I guess the above script sould work then.

Last edited by thematt : 10 October 2005 at 07:59 AM.
 
  10 October 2005
Arrow

To Thematt:

I explain what I want not fairly well as I need maybe.. but I doesn't want to Aim the different plane Shape.. But the "Normal" of the different plane shape. That the Big Difference !

Migugi understood my question, but it seems that the script dosen't work for me. Should I have missed something ?
__________________
Freelance 3D CG Environement Artist
at F & K Studio
in South Korea
 
  10 October 2005
Smile

The thing is, a polygonal face has face normals and vertex normals.
Now if you apply the script straight ahead to the scene you posted
there are a few faces that have a face normal pointing towards the
locator (highlighted red in the picture 1) and cause shading errors when
the script applies the vertex normals to them (in picture 2 the faces are
rendered black). This is because the face normals are facing the opposite
direction than the vertex normals.

What you have to do before executing the script is to flip the direction of the
problematic face normals to point away from the locator.
(Using just the Maya's Edit Polygons -> Normals -> Reverse).

Once all the face normals are facing away from the locator, you can apply the
script, which works on the vertex-normal level. The resulting geometry can then be seen in
picture 3. There are a few faces that are rendered black, but that is due to the
cameras point of view. If you rotate the camera, some other faces are facing the
other way. You can use the Shading -> Back face culling, to toggle the rendering
of back faced polygons. In picture 4 the shading should be fine.

Also, you might want to check out a MEL-tool collection I've written for
manipulating vertex normals
http://migugi.wellfish.org/mel/normalTools/



 
  10 October 2005
So I will really thing That I'm from another planet... Test that corrected maya binary file. I've reverse some of the face who in the past looked into the locator.

So now .. if I follow you procedure, I'll have to:

1. Verify if there is quads who look into the locator, and correct it by a reverse command on these face.
2. Select the locator first and the polyshape finally.
3. Execute the mel script... and it's done.

But for me nothing appens...

Take that new .mb file to test it. I have put the mel Script in comment window of the Locator.


And Thanks a lot for your MEL-tool collection , it's very usefull for Lowpoly modeling especialy for gaming. I will show you later why I want to InvertOrient Normal To Locator.

You will see that very usefull in most case, like in a lowpoly tree modeling/rendering ...oups !
__________________
Freelance 3D CG Environement Artist
at F & K Studio
in South Korea

Last edited by smoluck : 10 October 2005 at 08:58 AM.
 
  10 October 2005
Originally Posted by smoluck: 3. Execute the mel script... and it's done.

But for me nothing appens...


Ahh, so you have trouble executing the script. Here's a few ways you can do it:

1)
Save the whole script as
Documents and Settings\[user name]\My Documents\maya\[version]\scripts\savingSmoluck.mel
Now you can write
savingSmoluck();
in your script editor and execute it. (hilight the script and press Ctrl+Enter)
Or highlight the code and drag it to your shelf with the middle mouse button
to make a shelf button.

2)
Copy the whole script to your script editor and add the line
savingSmoluck();
to the end of the script and execute the whole thing.


See, you can't just execute the script as I pasted it, but you must call the
function defined in the script. Sorry for the inconvenience.
 
  10 October 2005
Yes Thanks... I've forget that Point ....Crazy !

So Now , you can Add that little script to your Normal Tool Component You've done all the devellopement...I'm just the Dady of the idea...
__________________
Freelance 3D CG Environement Artist
at F & K Studio
in South Korea
 
  10 October 2005
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:00 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.