|
|
In article <3f192104$1@news.povray.org>, tim### [at] gmxde says...
> It does sound interesting, but also a little above
> my head at the moment... Nontheless, thanks
> for link, perhaps I can make something of it when
> having more time to spend on it...
>
Simplest definition is that Inverse Kinematics uses some sort of nesting
of objects. In SDL this is easy:
union {
Object1
Object {
Object2
rotate <x2,y2,z2>
}
rotate <x1,y1,z1>
}
Rotating by x1, y1, z1 will automatically move both objects, while x2,
y2, z2 only move the nested one. The trick here is positioning. Each
objects rotation 'must' be at the origin (or specifically the point
around which you want to rotate it). Thus for a cylinder you want to
position the end you want to be the 'center' so it is at <0,0,0>. Example
(ignoring any syntax errors I made... lol):
#declare x1 = 0; //Segment 1 (upper arm perhaps?)
#declare y1 = 0;
#declare z1 = 0;
#declare x2 = 0; //Segment 2 and joint (lower arm)
#declare y2 = 90;
#declare z2 = 0;
union {
cylinder{<0,0,0>,<1,1,1>,2} //First segment.
union {
sphere {<0,0,0),2} //Joint
cylinder {<0,0,0>,<1,1,1>,2} //Second Segment.
rotate <x2 ,y2, z2> //Rotate them around 0,0,0 'first' to position.
translate <1,1,1> //Move them to the end of the first segment.
}
rotate <x1,y1,z1> //Rotate the first 'and' linked second segment.
translate ... //Move to where ever you need the entire chain.
}
For a complex object like a robot you would start with some the fingers
and work backward toward the body, attaching each new part to it in this
way, by first rotating it to the direction you want it pointed, then
moving it to the correct place in relation to the next object. As long as
all objects are properly nested, moving the torso of the robot will also
move the arms and legs, but rotating the left arm will only effect the
lower arm, the hand, fingers and what ever else is attached to that chain
of objects. The critical thing is as I said, to make sure that the point
you want the object to move around 'starts' at the center of the
rendering world, before you move it. Then it is just a matter of changing
the rotation of each of these objects to put them where you need them.
Then all you do is change the values of the variable you used and
everything will move properly.
It is really quite simple, but definitely easier in the SDL than other
programs. Trying to do the same thing in a modeller is a pain, since
unless it specifically supports Inverse Kinematics or 'IK chains' getting
all the objects tied together properly and working can be a pain. It is
much easier to fix something when you can specifically define the order
rotation and translation happen, than to fiddle with a modeller that may
force a specific order on those actions.
The Raytracing Worlds book on POV-Ray had an explanation of how all this
worked, going through the process step by step. However, I think it was a
tutorial on using Moray to construct it. Moray has built in features to
limit the amount and direction you can rotate stuff, so you won't rotate
the arm into the middle of the body and stuff like that. In the SDL you
have to be a bit more careful.
--
void main () {
call functional_code()
else
call crash_windows();
}
Post a reply to this message
|
|