View Full Version : get coordinates of each vertex on plane
cgforliving 10-24-2006, 07:55 PM I have a ground plane which is uneven and I want to get world coordinates of each vertex in the plane. Can someone show me some example scripts to do that!
Thanks
|
|
HalfVector
10-24-2006, 08:04 PM
Hi.
This function will return an array with the world-space vertex positions for the object "obj".
fn getVertexPositions obj = (
local vPositions = #()
local triMesh = snapshotAsMesh obj
for v = 1 to triMesh.numVerts do (
append vPositions (getVert triMesh v)
)
delete triMesh
return vPositions
)
Did you mean that?
cgforliving
10-24-2006, 09:03 PM
Looks like it, but I am not able to run this; it gives a runtime error "snapshotAsMesh requires a node".
Thanks for the quick reply
Light
10-24-2006, 09:16 PM
Try getVertexPositions $
Light
cgforliving
10-24-2006, 09:30 PM
If I try
getVertexPositions $Plane01
it Works!
(Plane01 is the name of the object in my scene.)
But
when I try
getVertexPositions ($+objName)
OR
$objname
Doesn't Work!
(obName is the name of object in my script)
Any help on this.
jonlauf
10-24-2006, 10:14 PM
if you mean you assigned a variable objname to the object in your scene like this:
objname = $Plane01
then you call the function with just the variable name as the argument like this:
getVertexPositions objname
cgforliving
10-24-2006, 10:31 PM
Thats what I tried for the first time
Did not work
jonlauf
10-24-2006, 11:09 PM
I have one object in my scene named "Plane01" and this works fine for me:
fn getVertexPositions obj = (
local vPositions = #()
local triMesh = snapshotAsMesh obj
for v = 1 to triMesh.numVerts do (
append vPositions (getVert triMesh v)
)
delete triMesh
return vPositions
)
objname = $Plane01
getVertexPositions objname
What are you doing differently?
cgforliving
10-24-2006, 11:33 PM
Say I have a list of object names in an array; Plane01, Plane02 etc
This way I do not have "$" in front. I tried adding that to the name and it still gives problems.
fn getVertexPositions obj = (
::::::::::::
::::::::::::
)
newName = "$"+objName
getVertexPositions newName
HalfVector
10-24-2006, 11:38 PM
newName = "$"+objName
getVertexPositions newName
No, the function expect a node not a string. So if you have the name of the node (Plane01, Plane02, etc) do:
obj = getNodeByName objName
getVertexPositions obj
cgforliving
10-25-2006, 12:00 AM
Thank you for your reply
CGTalk Moderation
10-25-2006, 12:00 AM
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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.