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);
}
Let me know if I make sense.