View Full Version : script controller
I was hoping someone here could help me with a problem I have.
I would like to pick up the angle of a protractor and use that to move an object along a path.
I attach the protractor to my bone system pivot point and select the 2 bones to create the angle but I can't seem to extract that angle information. As I move my Ik bones around the angle changes as expected but I can't wire this or seem to use it.
So I figured that I might be able to use controller scripts to convert the angle from the protractor (approx range 10-180 degrees) and link that into a percentage along path.
My scripting is almost non existent - ie I can read scripts (generally) but struggle to write them...... come to think of it, its a bit like my french. ;)
Any help would be greatly appreciated.
10-15-2003, 09:53 PM
Hi El-d, as far as i know, it is not possible to get or set any information from a protractor. i ran into the same problem some days ago and didn't found a solution. it isn't accessable in maxscript, and wireing doesnt work either. maybe you should look for an alternative for the protractor, i finally came up with a z-downscaled sphere, where the sliceFrom/To parameters represent the angle (i wanted to create a visual feedback for ik limits, and the spheres look way cooler than the ugly protractor ;))
Thanks for the response, and unfortuneately I thought as much with regards the protractor.
Its good to hear you found a solution using the slice from /to parameters.
I assume that you link the sphere to the upper arm bone (elbow joint) with the slice from aligned with the bone. What I am not sure about is how do you go about linking the slice to angle to the forearm bone so that as the arm bends the slice to angle follows it?
Could you please explain how to do thius as its been driving me crazy
Many thanks in advance
10-21-2003, 02:05 PM
hi, sorry for the long delay, i have been pretty busy..
yes, you link the sphere to the first bone and then wire the sliceTo parameter to the proper rotationaxis of the second bone, you might have to apply some offset to the wiring, if the bone has already rotation.
i can sent you an example scene later, i don't have access to my webspace right now.. hope this helps!
This is what I assumed and tried after your first explanation. The trouble is that it doesn't work as soon as IK Hi Solver is applied to the bones.
If you have managed to do it with the Ik solver then the test file would be gratefully received.
10-21-2003, 09:43 PM
Since IK doesn't use the bones' rotation controllers, you have to extract the angle the hard way. Here's an example of how to extract the angle between two bones:
q_rot = ($bone02.transform * (inverse $bone01.transform)).rotation
This will return a quat result, so you will want to convert it to euler in order to make sensible use of it:
e_rot = q_rot as eulerangles
If you're using IK, you can then just use e_rot.z to get the angle.
I finally got the time to try your script and it works perfectly. A great multitude of thanks for that as it was really starting to irritate me.
01-16-2006, 09: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-2015, Jelsoft Enterprises Ltd.