View Full Version : Creating a rotating arm with pivot - ideas?
iblokh
10-17-2007, 05:49 AM
Hey guys - as I said in my other thread, I haven't written code for a long time and I'm new to Flash and AS. Decided to pick up AS3 by making a project, but going pretty slow so far. Basically trying to make a turntable and add functionality as I go.
So - any ideas on how to make pivoted arm that the user can rotate? Is there any way to give the user the ability to do free transform? Or do I need to make a function that detects a mouse_down, figures out how far from the pivot point the mouse has moved and rotates the arm as long as the new position is within the correct range of motion?
Anyway, just wanted to ask before I make things difficult for myself - haven't been able to find any examples of this through google yet.
hey,
I'm exactly in your position, I really want to make an interactive arm. Did you manage to make one? If so would you be kind enough to explain it to me...you could even be the first person (according to google) to write such a tutorial!
I've tried to look for a tutorial on this with no luck...you're my last hope :)
Bombdogs
01-12-2008, 10:55 PM
Or do I need to make a function that detects a mouse_down, figures out how far from the pivot point the mouse has moved and rotates the arm as long as the new position is within the correct range of motion?
You're doing better than you think, that's pretty much spot on.
This tutorial will point you in the right direction ..no pun intended...
http://www.actionscript.org/resources/articles/154/1/Mouse-Angle-Detection-II/Page1.html
Good luck.
PMF
iblokh
01-12-2008, 11:01 PM
Ah sorry - I need to start posting solutions to questions I ask on forums. I figured it out from these files:
http://www.senocular.com/flash/files/twoturningdials.fla
http://www.senocular.com/flash/files/twoturningdials.swf
There was an actual tutorial as well, but I can't find the link now. Let me know if you have any specific questions - it's been a little while, but I'll try to find my implementation.
Bombdogs
01-12-2008, 11:04 PM
lol, didn't spot the date of your post!!
PMF
lol thanks for replying so promptly. The thing I'm trying to achieve is just very slightly different to what you've done, but the principles should be the same.
I was wondering if it would be possible to have two lines connected by a string (representing a muscle) and when the user drags that string one of the lines moves up. I've sort of made a small diagram below.
If you can help that would be great :)
newblack
01-13-2008, 03:05 PM
i'll be able to help, but i'll need you to give me some more information first. and pls note that the difference in complexity between this and the original problem is enormous.
1. will this be dynamic or kinematic? dynamic being that the arm can undergo forces (like gravity) and its motion is effected by its mass; kinematic meaning just solving for position.
2. is the upper arm effected by the muscle contraction, or just the lower?
i don't want to scare you off, it's a fun problem to solve; and the implementation should be pretty simple once the concepts are understood.
whoops, really sorry for not realising the difference in complexity.
This will be a kinematic arm, only the muscle can raise or lower the lower arm. The upper arm will be stationary, just something the muscle is connected to.
Thanks for helping :)
newblack
01-13-2008, 07:21 PM
ah- well if the upper arm is stationary, it really is exactly the same situation as simply rotating it.
i see, so that should make things a lot easier. Is there any way you could guide me through this or show me how to get started.
iblokh
01-13-2008, 09:37 PM
I'll let better people than me handle this one - although a few questions; will the user be able to grab the "string" at any point and pull it in any direction? Are you going to animate the string bending with the pull? Just trying to really understand what you're trying to do.
hi,
I think I would probably allow the user to pull the string from any position, I'm not too sure about bending...if it's complicated then no, otherwise it should be ok.
iblokh
01-14-2008, 10:59 PM
hi,
I think I would probably allow the user to pull the string from any position, I'm not too sure about bending...if it's complicated then no, otherwise it should be ok.
Hm - I'm just trying to picture how it would work. I think the hard part would be dealing with the "string", rather than the "arm". If I were doing this, I'd implement spinning the arm the way the tutorial shows - just grabbig it with a mouse - then get the string to move correctly. Once it does, I'd back-up and add the functionality allowing you to move the arm with the string. Are you actually trying to build a bone/muscle model?
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.