my walking algorithm

   8397   7   0
User Avatar
Member
11 posts
Joined: July 2005
Offline
Thanks for people who have helped me
but my problem still remained

I have read the scripting and expression language help file in houdini 5.5
and I still do not know where to put the code in and how I should code.

Actually I know where I would put all my expressions, but how about scripting language? Do I just open the hip file with text editor and write the code directly in front of it?

I have came up with a algorithm for walking animation if I were to do it in c++
Can anyone give me a hint how to translate it to hscript
and….. WHERE WOULD I WRITE THE CODE ON :shock:

/* I do know houdini have IK solver and polynomial interpolation built in, but I should not use it for my project */

// define a datatype curve represents: c(t) = where x, y, z are (cubic) polynomials

// helpers
void initialize(curve& feetcurve){
// give some sample points to interpolate the motion of the feet that is not on the floor
feetcurve.interpolate(v1,v2,v3,v4);
}

void firstStep(){
// interpolate the motion of the first step, given the body is initially standing
// when first step finished, legs should be open, feet0 is in front, feet1 is in the back
}

void walk(int fixFeet, int startTime){
int otherFeet;
vector frontFeetPosition;

while(1){
otherFeet = abs(1-fixFeet);
// rotate the leg with the feet attatched to ground
….
// translate body corrospondingly
….

if (front feet is not straight yet and front feet have not reached the floor,
keep swinging it towards front)
{
frontFeetPosition = feetcurve.applyValue( (currentFrameNumber++) - startTime );
}

// if the front feet goes lower then the floor, adjust it
// note that frontFeetPostion is the position relative to body
if ( bodyPosition.y + frontFeetPostion.y < 0 ){
frontFeetPostion.y = -1*bodyPosition.y;

// also, it would be time to switch feet, proceed to next step
fixFeet = otherFeet;
startTime = currentFrameNumber;
}

// I implemented a IK solver, given the position of the feet
// the character would pose in the way such that his feet is exactly at that point
IKPose( feet, frontFeetPosition);

// posing is done, redraw this frame!
// finished drawing, idle for 0.03 seconds
}
}

// main function
main(){
curve feetcurve();
initialize(feetcurve, bodycurve);
firstSetp();
walk(0, currentFrameNumber);
}
User Avatar
Member
412 posts
Joined: July 2005
Offline
i don't know how exactly you wanting to “script” this, but it just seems unnecessary.. the only thing you would be scripting in hscript or the textport is: lay down this op node, put this value/expression in a parameter of that op, place down another op, wire that op to this op, etc, etc..

i mean yea, you can do that, but why really? i think this is a really great exercise to do if you wanting to learn hscript but if you wanting to teach yourself how to animate something procedurally rather than keyframes in a graph editor, then you wasting your time by taking on too many things.. especially if you are new to houdini, you really should go and investigate what each op is and what they are doing.. if you don't know that up front, then how will you be able to script those ops into your scene?

i would just throw down your ops in the gui and learn the expression language and put them in the appropriate parameters.. that is completely procedural, no keyframes whatsoever, and you will learn a lot from it..

as a kickstart example, i made this file for you of a *very* crude walk cycle.. (realize this is just a quick thing i made for you to begin with).. but it will show you some very simple expressions and how they are making my “legs” animate without keyframes.. compare the expressions i use in the docs and you will prob start to get the hang of it..

hth,
dave

example file:

http://studentpages.scad.edu/~dquiru20/walkcycle.hipnc [studentpages.scad.edu]
Dave Quirus
User Avatar
Member
11 posts
Joined: July 2005
Offline
thanks a lot…
I got your files
I am strating to understand a little about how to animate the objects in houdini!! 8)

yeah, by the way
for example, i see you map the x field of translate of sin($F), y field something else
is it possible to map the field into a expression that return a 3 dimension vector?

for example, let the translation of some object geo be mapped to a expression

vector foo(){
vector v;
vector=$F;
vector=$F+10;
vector=0;
return v;
}
User Avatar
Member
330 posts
Joined: July 2005
Offline
i think this will be useful for a lot of people, cheers
User Avatar
Member
2199 posts
Joined: July 2005
Online
Look in the expression help pdf under vector/matrix expressions.

Something like vector(ch(“../foo/tx”),ch(“../foo/ty”),ch(“../foo/tz”))
depends how and where you want to use it. The help will give you some more pointers.
The trick is finding just the right hammer for every screw
User Avatar
Member
4140 posts
Joined: July 2005
Offline
I'm starting to get the feeling that the teacher that assigned this has come from a Maya world, and things “scripting in Houdini” is identical to Mel. I may be wrong on this, xus, but if that's the thinking going into this, then you should know that this isn't really the case. It's been discussed before with some ex-Maya people who were having trouble grasping Houdini programming, but I'm unable to find that thread, unfortunately. I think the best analogy is that Houdini is actually “a Mel”, or a front end to a programming language like Mel. That's the whole idea behind it - it's a graphical interface to true proceduralism. Mel let's you do true proceduralism because Maya alone doesn't truly and fully support it. Houdini *is* the language. Scripting just lets you fiddle with those building blocks, but it isn't the building blocks themselves.

Ugh, I'm getting vague again, and I know english isn't your first language, sorry… Let me know if I make sense.

Cheers,

J.C.
John Coldrick
User Avatar
Member
11 posts
Joined: July 2005
Offline
I donno what my teacher use
this is more of a math course
what we use, they don't care
but we have to pick one in the beginning of semester and stick with it
and all algorithms, we have to come up myself
I came from openGL, so my algorithm is more like c++ algorithm
User Avatar
Member
639 posts
Joined: July 2005
Offline
Hi Xus,

Well, as John was saying, that Houdini itself is a “language”. There are couple of ways you can do to “plug” your own tools to control Houdini.

The first, and the easiest, is to use the HScript commands. You can pretty much use HScript to built an entire networks of operators and use it to automate certain tasks. Pipeline people generally do need to know HScript — depending on the production houses, I guess. So if all you want is to insert your own mathematical equations into a node's parameter, using HScript may be easier. What you probably want to do is to use your own C (or any other language) to feed in your parameters into a proper field of a proper operator. This approach is still just about the same as laying down operators and type the expressions by hand. Please look into the Scripting>“Scripting With Hscript and the c-shell” section of the documentation. While that's for C-Shell, the basic construct can still be applied to C.

Now, if you want more control, but don't want to use the Houdini Development Kit, you will have to understand Houdini's Geometry format. You can either have Houdini spit out a single geo file and use your own C program to process the geometry and write out a sequence of geo file (as you would with pic files). Or you can use the Unix SOP to pipe the geometry data from the operators out to your own program and then send the modified geometry back into Houdini to get the result. (Just make sure that the geometry's integrity is in tact.) This already is a very good feature of Houdini, I'd say.

Now, if you TRULY want to get to the guts of Houdini's operator, you can use HDK to do wantever you want it to do – be it your own fluid solver, etc. With the HDK, you'll truly understand why Houdini itself is a “language”.

Now, you can also use VEx (Vector EXpression) language to process your animation as well. With VEx, your limitation is that it won't allow you to add or delete point. (If you want to be able to add/del points, you'll most likely have to resort to HDK) Beware of the SIMD architecture, tho…

Well, hope that clears up a bit.
Alex
  • Quick Links