PDA

View Full Version : world coord of a UV ona nurbs object


twidup
07-14-2003, 12:29 PM
ok, how would one go about getting this info?

I have done it before, but I cant remember for some reason.

I have tried xform, but it is not giving me any results, which is just wierd.

-Todd

Duncan
07-14-2003, 11:50 PM
pointOnSurface

Duncan

twidup
07-15-2003, 05:05 AM
Sweet, that helps for when I do know where the uv coord is, but what if I need to get it for a surface point set by a user?

basically, if a user selects a surface point I need to get teh world coord of it.

pointOnSurface will work, but the other way I learned was fast, few lines.

any other suggestions?

mark_wilkins
07-15-2003, 10:21 AM
What, you mean like selecting a CV?

If you do an ls -sl when a user has picked a CV in component mode you'll get back something like


nurbsSphere1.cv[10]


so you just do something like this:


float $coords[] = `xform -ws nurbsSphere1.cv[10]`;


-- Mark

dunkel3d
07-15-2003, 05:13 PM
Hi Mark,
I'm trying something similar.

I'm trying to loop through a poly object's vertices, capturing their tx ty tz ws values and storing them in variables.

first, How can I query an object's total number of vertices?

second, Would it be logical to then store them in an array in order to loop through each one?

third, how could I query each vtx's world space coords?

I tried:
select -r pSphere1.vtx[11] ;
move -r 1.226199 0 0 ;
vector $Vcoords = `xform -ws pSphere1.vtx[11]`;
// Result: <<0, 0, 0>> //
print($Vcoords);
0 0 0


S

mark_wilkins
07-15-2003, 06:24 PM
Originally posted by dunkel3d

first, How can I query an object's total number of vertices?



int $numVerts = `polyEvaluate -v pSphere1`;



second, Would it be logical to then store them in an array in order to loop through each one?

You can loop over their indices and refer to them as pSphere1.vtx[$index] or whatever.


third, how could I query each vtx's world space coords?

I left a few important flags out before because I was rushing. Here's the corrected code. Incidentally, I strongly recommend becoming very familiar with the xform command -- it's one of the most useful in Maya.

xform returns an array of floats, not a vector, so you'll have to stuff the values into a vector by hand:


select -r pSphere1.vtx[11] ;
move -r 1.226199 0 0 ;
float $Vcoords_array[] = `xform -q -translation -ws pSphere1.vtx[11]`;
vector $Vcoords = <<$Vcoords_array[0], $Vcoords_array[1], $Vcoords_array[2]>>;



-- Mark

dunkel3d
07-15-2003, 06:46 PM
Thanks Mark. You're the best!:thumbsup:

S

BTW I am waiting for the day when your Greenspan has a huge grin on his face.

Duncan
07-15-2003, 10:58 PM
Twidup.. if you want to know the uv values for a point on surface( as opposed to a cv ) then when you select the surface point it is displayed in the titlebar something like:
nurbsSphere1.uv[2.37093410513308][1.79919306987827] ;
where the two numbers are the uv value. Doing ls -sl will also return this string. If you want to use it in an expression, you could parse the string to get the uv values( using tokenize ).

Duncan

twidup
07-15-2003, 11:03 PM
Duncan,

yeah, thats what I am looking at. Hmmm, I thought there was a way to grab the world coord with xform on that UV local. I know other than that, that I can use pointOnsurface and a couple tokeniize strings to get the data.

Thanks for everything
-Todd

twidup
07-15-2003, 11:15 PM
so, I select a point on the nurbsSphere and then put this into a float. like below; the problem then is that the results are nothing. not even 0 0 0

is this just a linux thing or windows as well, or is this not possible with a value in UV space on a nurbs object?


float $test[] =`xform -ws nurbsSphere1.uv[2.49415013553028][7.62181351334038]`;
// Result: //

Duncan
07-15-2003, 11:22 PM
Ahh.. I see. You want:
pointPosition

Duncan

mark_wilkins
07-15-2003, 11:52 PM
hehe

sorry, I got confused because you started talking about "selected points" and I thought CVs.

Point position is the best way, but xform should work -- you're having trouble because you've left off (as I did) the -q and the -translation flags. Look at my second example.

-- Mark

twidup
07-16-2003, 12:01 AM
hmmm, when I have tried the -q -t -ws flags, I get 0 0 0, which is not correct. I would get the same with -q -t

I will try the pointPosition and see how it work ;)

Thanks guys.

twidup
07-16-2003, 04:28 AM
sweet as.

pointPosition works great, thanks guys.

-Todd

mark_wilkins
07-16-2003, 07:05 PM
ok so I've finally had time to play around with this...

so umm... what good is actually selecting a UV point in this way, particularly if xform just ignores queries about it? Am I missing something clever? :D

-- Mark

twidup
07-16-2003, 09:33 PM
I am using for auto creation scripts, as for using xform, I just seem to recall using it originally for it, but I may not have when I was proofing the script out. unfortunately, I cant find my notes or scenes for it so I have to start over and pointPosition does make a lot more sense ;)

-Todd

mark_wilkins
07-16-2003, 09:35 PM
BTW I wasn't asking that last question to question what you're doing, I was just trying to inform myself about why selecting a UV point is generally a useful thing to do in Maya...

-- Mark

CGTalk Moderation
01-15-2006, 03:00 PM
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.