PDA

View Full Version : Cleaning up a biped function


Rick Stirling
12-12-2007, 10:44 AM
I've got a function that gives me the x,y,z position of a Biped/CS bone, but it's UGLY. It works, but it's always annoyed me that it felt so hacky.

It basically converts the biped information into a string, parses it, then rebuilds the x, y and z components into a point3.

Can anyone suggest a way to clean it up?



fn getbipedpos bipbone = (
-- taking in a bone, convert it to a string, parse the position
print bipbone
bbs = bipbone as string
t = filterstring bbs "["
co = filterstring t[2] ",]"
xc = co[1] as float
yc = co[2] as float
zc = co[3] as float

p3 = [xc,yc,zc]

return p3
)

shibumenon
12-12-2007, 01:05 PM
$.transform.pos
will give you the world pos of the selected object, be it a biped object or any other.

if bipBone is a variable storing a biped node, then
bipBone.transform.pos
will give you its world pos

Rick Stirling
12-12-2007, 01:23 PM
Fantastic! I only discovered the $.transform.WHATEVER a few weeks ago when trying to get rotation information. I'd not even considered that'd work.

Rick Stirling
12-15-2007, 10:06 AM
Thanks again for this - I realised that it made even more sense to make it in a generic find position script, so that it works with any object and not just biped (it already does simply by using your OBJECT_HERE.transform.pos , so I'm changing the name of the function to make it more obvious that it's not just about biped now.

In fact, I've decided to update it so that it will be used in my bone creation, so I'll pass every start and end point to it. To make it more generic, I'll allow it to accept point3 values as input and simply return them unchanged.

LoneRobot
12-17-2007, 01:36 PM
or you could just use

biped.gettransform $ #pos

there are a load of biped methods exposed to MXS in the "Biped Transform Methods" topic.

CGTalk Moderation
12-17-2007, 01:36 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.