CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 01-17-2008, 09:02 PM   #1
devoy
New Member
 
Join Date: Aug 2004
Posts: 9
world point position from poly uv's

Is it possible to get the point position from a uv coord on a poly?

You can do this on a nurbs surface
i.e

pointPosition nurbsCylinder1.uv[1.79693196412904][4.79288262919124];
// Result: -0.811743 0.796932 -0.583178 //

any help appreciated
thanks
devoy
(also posted in dynamics forum)
 
Old 01-17-2008, 10:16 PM   #2
Gravedigger
Know-it-All
Patrik Hadorn
Switzerland
 
Join Date: Apr 2005
Posts: 344
well just change .uv with .map then it should work:
Code:
pointPosition pSphere1.map[0]
 
Old 01-17-2008, 10:39 PM   #3
devoy
New Member
 
Join Date: Aug 2004
Posts: 9
using the .map coords doesn't give me what I want...
it does not interpolate across the uv space as the nurbs .uv's do,
and how do I know which uv coord map[$n] corresponds to?

for instance
I have particles with goalU and goalV if my goal object was nurbs I could easily
fing out where the particles were being attracted to by

float $pos[]=`pointPosition nurbs.uv[goalU][goalV]`;

unfortunately I am not using nurbs so I want to find a way of doing the same thing with
a poly object

thanks
 
Old 01-17-2008, 10:40 PM   #4
devoy
New Member
 
Join Date: Aug 2004
Posts: 9
oops posted twice

Last edited by devoy : 01-17-2008 at 10:47 PM. Reason: posted twice by mistake
 
Old 01-21-2008, 02:27 AM   #5
ashishdantu
CG talk crawler...
 
ashishdantu's Avatar
portfolio
ashishdantu
3D Tech Artist
Singapore, India
 
Join Date: Apr 2002
Posts: 603
Send a message via Yahoo to ashishdantu
hi

just a quick try i did - with a sphere which is parented to world..

xform -q -ws -t pSphere1.map[253] - returns a value which does give you usable values..

but when the pSphere is under a group, now the command is NOT returning world space values ???

sory this might be fully usable but just wanted to try..
__________________
|| Loka samastaa sukhino bhavantu ||
ash
 
Old 01-21-2008, 09:21 PM   #6
trancor
Script Monkey
 
trancor's Avatar
portfolio
Kevin Edzenga
Character Simulation Technical Director
Blue Sky Studios
USA
 
Join Date: May 2007
Posts: 1,127
Send a message via AIM to trancor
if I understand correctly, you're trying to find a point ANYWHERE on the poly object. I've made a script in the past that did this sorta (it was for a company so I can't post the script). Buttttt, the script involved some math to find an exact location on a plane, the math is basic algebraic math. Basically finding locations between verts based on percentages.

is/of * x/100 = %

soo basically, I'd find the 4 vert locations of the face the object is currently in. And if you take two vectors of two verts in that face, and subtract each other, you'll have a difference that you can move the object through ----

x1=3
y1=5
z1=7

x2=5
y2=10
z2=10

so the possible movement area between these two verts is

<<(x2-x1), (y2-y1), (z2-z1)>>
<<2,5,3>> --- This is your "Of" value in the equation I wrote above.

so to pull the percentage, this would be an already existing attribute on the particles themself of object itself. For particles, just make another general per particle array.
but lets say the object is 70 % between both of those verts

Soo for this --- is/of * x/100 = %
You'd look for the "Is"

And just plug in your vector you found

X/2 * 70/100 = 1.4
X/5 * 70/100 = 3.5
X/3 * 70/100 = 2.1


So, the vector 70% between point 1 and point 2 is -
<<1.4, 3.5, 2.1>>

You'd write these in scripting like this --

$Is = Of * x /100;
float $X = 2*70 / 100;

Then add the found values for point 1 -

x3=x1+1.4
y3=y1+3.5
z3=z1+2.1

x3=4.4
y3=8.5
z3=9.1


And just do it for your x y and z, but this is a bit of work. SOOOO I dunno if you feel like writing out the math for this.

----------------------

Seeing how polygon objects have UVs, and are set points in space, it's hardder to find specific points on the object. Nurbs are all math, so the mesh uses the logitude and latitude as U and V values, but you know that.


Here is something I wrote up real fast, but pretty much all it does is find the selected UV on the poly object's UV Map and converts it to a vert and finds the point in space of the vert.

Code:
string $selUV[]=`ls -sl -flatten`; //Convert selection to Verts PolySelectConvert 3; string $selected[]=`ls -sl -flatten`; //World Space Point Position vector $pointPos=`pointPosition $selected[0]`; print $pointPos; //Select the original UV again select $selUV[0];




Thats the best I can do without writing a bit larger of a code for you.

But, if you are doing this for a particle system, it's easy to just run through the verts as a goal value, and the particle will like float to the next point, you just need to lower the goal weight. That way the particles will move to the next particle. You can find the next vert to move to by finding the connected edges to the vert and find the verts on one of those edges and the vert that you arn't currently at would be the only other vert listed.

DAMN, that was long

Last edited by trancor : 01-22-2008 at 02:37 AM.
 
Old 01-21-2008, 11:09 PM   #7
trancor
Script Monkey
 
trancor's Avatar
portfolio
Kevin Edzenga
Character Simulation Technical Director
Blue Sky Studios
USA
 
Join Date: May 2007
Posts: 1,127
Send a message via AIM to trancor
didn't update in the server that I posted anything on this thread ---
 
Old 01-21-2008, 11:09 PM   #8
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 10:24 AM.


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