Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any examples of pieced bodies?

Status
Not open for further replies.

WhiteTiger

Programmer
Jun 26, 2001
605
US
I have an idea for an intro to my page, but I was wondering if anyone knew of any place which had almost the same thing going on.

What I want to do, is take a picture of me running. I want to cut all the sections of my body, and animate them by moving the pieces. (the objects would be pictures from tip of fingers to wrist, wrist to elbow, elbow to shoulder)

Does anyone know where someone else has done this?...I want to see if anyone has done it before, and if I really like the look of it. Regards,
Anth:cool:ny
 
IMPRESSIVE
Do you have any tips on getting ends of limbs to stay connected when doing an animation?...or how to go about making this animation?

Remember, I'm not as good in math as you aparrently are.
Basically what I'm doing is just a few skits as intros, etc. Regards,
Anth:cool:ny
 
This is the actionscript I used for the arm (I've removed some other stuff like the strings etc that wasn't relevant).

Basically you're concentrating on two the joints between limbs - they're the important bits. They have to be kept the right distance apart so that the limbs don't stretch out of shape. Where it says "bit of trig" that's where that's being calculated - the elbow and shoulder always stay the same distance apart.

The rest is calculating the angles between the limbs then using the Math function atan2 to work out what rotation to apply to the limbs to make them line up with those angles.

Anything named "Hookes" is applying Hooke's Law which governs elasticity and that's creating the bouncing effects.

Anyway maybe you can cut and paste some of this or it might give you some ideas, most of it is just using simple arithmetic to work out distances.


Code:
onClipEvent (load) {
	_root.limbLength = 85;
	speed = 2;
	xHome = _root.wrist._x;
	yHome = _root.wrist._y;
	_root.wrist._x = xHome+30;
	_root.wrist._y = yHome-20;


	function resetHookes() {
		targetX = xHome;
		targetY = yHome;
		posX = _root.wrist._x;
		posY = _root.wrist._y;
		accelX = 0;
		accelY = 0;
		velocX = 0;
		velocY = 0;
		k = .3;
		m = 1;
		friction = .9;
	}

	function doHookes() {
		accelX = -(k/m)*(posX-targetX);
		accelY = -(k/m)*(posY-targetY);
		velocX += accelX;
		velocY += accelY;
		velocX *= friction;
		velocY *= friction;
		posX += velocX;
		_root.wrist._x = posX;
		posY += velocY;
		_root.wrist._y = posY;
	}

	function moveArm() {
		forearmDeltaX = _root.wrist._x-_root.elbow._x;
		forearmDeltaY = _root.wrist._y-_root.elbow._y;
		upperarmDeltaX = _root.elbow._x-_root.shoulder._x;
		upperarmDeltaY = _root.elbow._y-_root.shoulder._y;
		_root.forearm._rotation = Math.atan2(forearmDeltaY, forearmDeltaX)/Math.PI*180;
		_root.upperarm._rotation = Math.atan2(upperarmDeltaY, upperarmDeltaX)/Math.PI*180;
		_root.forearm._x = _root.wrist._x-forearmDeltaX;
		_root.forearm._y = _root.wrist._y-forearmDeltaY;
		_root.upperarm._x = _root.elbow._x-upperarmDeltaX;
		_root.upperarm._y = _root.elbow._y-upperarmDeltaY;
	}
}

onClipEvent (enterFrame) {
	xDiff = (_root.shoulder._x-_root._xmouse);
	yDiff = (_root.shoulder._y-_root._ymouse);
	distance = Math.sqrt(xDiff*xDiff+yDiff*yDiff);
	if (distance<_root.limbLength*2 && Math.abs(yDiff)<25 && _root._xmouse<(_root.shoulder._x-30)) {
		_root.wrist._x += (_root._xmouse-_root.wrist._x)/speed;
		_root.wrist._y += (_root._ymouse-_root.wrist._y)/speed;
		//reset hooke's
		resetHookes();
	} else {
		//doHookes
		doHookes();
	}
	distX = ((_parent.shoulder._x-_parent.wrist._x)/2);
	_parent.elbow._x = _parent.wrist._x+distX;
	bitOfTrig = Math.sqrt((_root.limbLength*_root.limbLength)-(distX*distX));
	_parent.elbow._y = _parent.shoulder._y+bitOfTrig;
	moveArm();
	
}[code] Slainte

[URL unfurl="true"]http://www.wangbar.co.uk[/URL]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top