<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Modifiers in Unity3D</title>
	<atom:link href="http://www.everyday3d.com/blog/index.php/2009/11/10/porting-actionscript-to-unity3d/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.everyday3d.com/blog/index.php/2009/11/10/porting-actionscript-to-unity3d/</link>
	<description>3D user experience on the web. Design, technology news. A blog by Bartek Drozdz.</description>
	<lastBuildDate>Wed, 08 Sep 2010 08:42:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: marjan</title>
		<link>http://www.everyday3d.com/blog/index.php/2009/11/10/porting-actionscript-to-unity3d/comment-page-1/#comment-174515</link>
		<dc:creator>marjan</dc:creator>
		<pubDate>Fri, 05 Mar 2010 14:30:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=438#comment-174515</guid>
		<description>interesting...
Actually you can combine this with Ani.Mate, a tween class for Unity.

since my C is not very sharp, i took out some code from GUIManager, to achive the effekt. Of course you need Ani.Mate. Thats only 2 Scripts within the GuiManager Package.

I am using that one for iPhone Development.
so, Check it out:







using UnityEngine;
using System.Collections;

[RequireComponent (typeof(MeshFilter))]
public class Bend : MonoBehaviour {
	
	private Vector3[] original;
	private Mesh mesh;
	private Animator pAnimator;			//Animator script component
	
	public float force = 3.0f;

/*-------------------------------------Unity Methods-------------------------------------*/
	void Awake ()
	{
		
		pAnimator = (Animator) gameObject.GetComponent(typeof(Animator));
		
	}
	
	void Start() {	
		
		MeshFilter mfilter = GetComponent(typeof(MeshFilter)) as MeshFilter;
		mesh = mfilter.mesh;
		original = mesh.vertices;
		startUnwrap();
	}

	void startUnwrap() {
		AnimateTo(1f, null, null, null, &quot;force&quot;, -0.5f, &quot;easing&quot;, Ani.AnimationEasingType.SinusoidalEasing, &quot;direction&quot; , Ani.EasingType.InOut);
		AnimateTo(0.5f, null, null, null, &quot;force&quot;, 0.3f, &quot;easing&quot;, Ani.AnimationEasingType.SinusoidalEasing, &quot;direction&quot; , Ani.EasingType.InOut);
		AnimateTo(1.5f, null, null, null, &quot;force&quot;, 0f, &quot;easing&quot;, Ani.AnimationEasingType.ElasticEasing, &quot;direction&quot; , Ani.EasingType.Out);
		
		StartAnimation(Ani.Animate.OneShot, null, null, null);	
		
	}

	void Update() {	
		if(force == 0.0f) {
			mesh.vertices = original;
			mesh.RecalculateNormals();
			return;
		}
		
		Vector3[] vs = mesh.vertices;
		int vc = vs.Length;
			
		float radius = 1 / force;

		for (int i = 0; i &lt; vc; i++) {
			Vector3 v = copy(original[i]);
			
			float l = v.z;
			float d = v.x;

			float fa = (Mathf.PI / 2) + (force * l);
			
			float op = Mathf.Sin(fa) * (radius + d);
			float ow = Mathf.Cos(fa) * (radius + d);

			vs[i].z = -ow;
			vs[i].x = op - radius; 
		}
		
		mesh.vertices = vs;
		mesh.RecalculateNormals();
	}
	
	private Vector3 copy(Vector3 orig) {
		return new Vector3(orig.x, orig.y, orig.z);
	}
	
	//Mode To
	public void AnimateTo (float Duration, GameObject CallbackObj, string CallbackMsg, object CallbackParams, params object[] args)
	{
		//Wrapper function
		pAnimator.AnimateTo(this, Duration, CallbackObj, CallbackMsg, CallbackParams, args);
	}

	//Mode From
	public void AnimateFrom (float Duration, GameObject CallbackObj, string CallbackMsg, object CallbackParams, params object[] args)
	{
		//Wrapper function
		pAnimator.AnimateFrom(this, Duration, CallbackObj, CallbackMsg, CallbackParams, args);
	}
	
	//Mode By
	public void AnimateBy (float Duration, GameObject CallbackObj, string CallbackMsg, object CallbackParams, params object[] args)
	{
		//Wrapper function
		pAnimator.AnimateBy(this, Duration, CallbackObj, CallbackMsg, CallbackParams, args);
	}

	//Start animation sequence
	public void StartAnimation (Ani.Animate AnimateMode, GameObject CallbackObj, object CallbackMsg, object CallbackParams)
	{
		//Wrapper function
		switch (AnimateMode)
		{
			case Ani.Animate.OneShot:
				pAnimator.StartAnimation(Ani.Animate.OneShot, CallbackObj, CallbackMsg, CallbackParams);
				break;
			case Ani.Animate.Loop:
				pAnimator.StartAnimation(Ani.Animate.Loop, CallbackObj, CallbackMsg, CallbackParams);
				break;
		}	
	}
	
	//Stop animation sequence
	public void StopAnimation ()
	{
		//Wrapper function
		pAnimator.StopAnimation();
	}
	
	//Clear animation queue
	public void ClearAnimation ()
	{
		//Wrapper function
		pAnimator.ClearAnimation();
	}

	
}</description>
		<content:encoded><![CDATA[<p>interesting&#8230;<br />
Actually you can combine this with Ani.Mate, a tween class for Unity.</p>
<p>since my C is not very sharp, i took out some code from GUIManager, to achive the effekt. Of course you need Ani.Mate. Thats only 2 Scripts within the GuiManager Package.</p>
<p>I am using that one for iPhone Development.<br />
so, Check it out:</p>
<p>using UnityEngine;<br />
using System.Collections;</p>
<p>[RequireComponent (typeof(MeshFilter))]<br />
public class Bend : MonoBehaviour {</p>
<p>	private Vector3[] original;<br />
	private Mesh mesh;<br />
	private Animator pAnimator;			//Animator script component</p>
<p>	public float force = 3.0f;</p>
<p>/*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-Unity Methods&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-*/<br />
	void Awake ()<br />
	{</p>
<p>		pAnimator = (Animator) gameObject.GetComponent(typeof(Animator));</p>
<p>	}</p>
<p>	void Start() {	</p>
<p>		MeshFilter mfilter = GetComponent(typeof(MeshFilter)) as MeshFilter;<br />
		mesh = mfilter.mesh;<br />
		original = mesh.vertices;<br />
		startUnwrap();<br />
	}</p>
<p>	void startUnwrap() {<br />
		AnimateTo(1f, null, null, null, &#8220;force&#8221;, -0.5f, &#8220;easing&#8221;, Ani.AnimationEasingType.SinusoidalEasing, &#8220;direction&#8221; , Ani.EasingType.InOut);<br />
		AnimateTo(0.5f, null, null, null, &#8220;force&#8221;, 0.3f, &#8220;easing&#8221;, Ani.AnimationEasingType.SinusoidalEasing, &#8220;direction&#8221; , Ani.EasingType.InOut);<br />
		AnimateTo(1.5f, null, null, null, &#8220;force&#8221;, 0f, &#8220;easing&#8221;, Ani.AnimationEasingType.ElasticEasing, &#8220;direction&#8221; , Ani.EasingType.Out);</p>
<p>		StartAnimation(Ani.Animate.OneShot, null, null, null);	</p>
<p>	}</p>
<p>	void Update() {<br />
		if(force == 0.0f) {<br />
			mesh.vertices = original;<br />
			mesh.RecalculateNormals();<br />
			return;<br />
		}</p>
<p>		Vector3[] vs = mesh.vertices;<br />
		int vc = vs.Length;</p>
<p>		float radius = 1 / force;</p>
<p>		for (int i = 0; i &lt; vc; i++) {<br />
			Vector3 v = copy(original[i]);</p>
<p>			float l = v.z;<br />
			float d = v.x;</p>
<p>			float fa = (Mathf.PI / 2) + (force * l);</p>
<p>			float op = Mathf.Sin(fa) * (radius + d);<br />
			float ow = Mathf.Cos(fa) * (radius + d);</p>
<p>			vs[i].z = -ow;<br />
			vs[i].x = op &#8211; radius;<br />
		}</p>
<p>		mesh.vertices = vs;<br />
		mesh.RecalculateNormals();<br />
	}</p>
<p>	private Vector3 copy(Vector3 orig) {<br />
		return new Vector3(orig.x, orig.y, orig.z);<br />
	}</p>
<p>	//Mode To<br />
	public void AnimateTo (float Duration, GameObject CallbackObj, string CallbackMsg, object CallbackParams, params object[] args)<br />
	{<br />
		//Wrapper function<br />
		pAnimator.AnimateTo(this, Duration, CallbackObj, CallbackMsg, CallbackParams, args);<br />
	}</p>
<p>	//Mode From<br />
	public void AnimateFrom (float Duration, GameObject CallbackObj, string CallbackMsg, object CallbackParams, params object[] args)<br />
	{<br />
		//Wrapper function<br />
		pAnimator.AnimateFrom(this, Duration, CallbackObj, CallbackMsg, CallbackParams, args);<br />
	}</p>
<p>	//Mode By<br />
	public void AnimateBy (float Duration, GameObject CallbackObj, string CallbackMsg, object CallbackParams, params object[] args)<br />
	{<br />
		//Wrapper function<br />
		pAnimator.AnimateBy(this, Duration, CallbackObj, CallbackMsg, CallbackParams, args);<br />
	}</p>
<p>	//Start animation sequence<br />
	public void StartAnimation (Ani.Animate AnimateMode, GameObject CallbackObj, object CallbackMsg, object CallbackParams)<br />
	{<br />
		//Wrapper function<br />
		switch (AnimateMode)<br />
		{<br />
			case Ani.Animate.OneShot:<br />
				pAnimator.StartAnimation(Ani.Animate.OneShot, CallbackObj, CallbackMsg, CallbackParams);<br />
				break;<br />
			case Ani.Animate.Loop:<br />
				pAnimator.StartAnimation(Ani.Animate.Loop, CallbackObj, CallbackMsg, CallbackParams);<br />
				break;<br />
		}<br />
	}</p>
<p>	//Stop animation sequence<br />
	public void StopAnimation ()<br />
	{<br />
		//Wrapper function<br />
		pAnimator.StopAnimation();<br />
	}</p>
<p>	//Clear animation queue<br />
	public void ClearAnimation ()<br />
	{<br />
		//Wrapper function<br />
		pAnimator.ClearAnimation();<br />
	}</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blenderificus</title>
		<link>http://www.everyday3d.com/blog/index.php/2009/11/10/porting-actionscript-to-unity3d/comment-page-1/#comment-119448</link>
		<dc:creator>Blenderificus</dc:creator>
		<pubDate>Thu, 31 Dec 2009 21:41:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=438#comment-119448</guid>
		<description>thank you soooo very much for porting some of your modifiers to unity from flash.  If you ever get the time, I truly look forward to you porting the rest over :-) thanks again!</description>
		<content:encoded><![CDATA[<p>thank you soooo very much for porting some of your modifiers to unity from flash.  If you ever get the time, I truly look forward to you porting the rest over :-) thanks again!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bartek drozdz</title>
		<link>http://www.everyday3d.com/blog/index.php/2009/11/10/porting-actionscript-to-unity3d/comment-page-1/#comment-79603</link>
		<dc:creator>bartek drozdz</dc:creator>
		<pubDate>Tue, 10 Nov 2009 17:56:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=438#comment-79603</guid>
		<description>@AngryAnt Thanks for the tip! So far I didn&#039;t have time to check the new animation editor, but this is a great idea.

UPDATE Nov 17 2009. I checked it with the animation editor and it works great (no code changes needed) Thanks for the tip!</description>
		<content:encoded><![CDATA[<p>@AngryAnt Thanks for the tip! So far I didn&#8217;t have time to check the new animation editor, but this is a great idea.</p>
<p>UPDATE Nov 17 2009. I checked it with the animation editor and it works great (no code changes needed) Thanks for the tip!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AngryAnt</title>
		<link>http://www.everyday3d.com/blog/index.php/2009/11/10/porting-actionscript-to-unity3d/comment-page-1/#comment-79598</link>
		<dc:creator>AngryAnt</dc:creator>
		<pubDate>Tue, 10 Nov 2009 17:48:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=438#comment-79598</guid>
		<description>Nice post. For full animation control - what about animating via the animation view in stead of scripted animation? Expose relevant properties in your script and curves away!</description>
		<content:encoded><![CDATA[<p>Nice post. For full animation control &#8211; what about animating via the animation view in stead of scripted animation? Expose relevant properties in your script and curves away!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Tondeur</title>
		<link>http://www.everyday3d.com/blog/index.php/2009/11/10/porting-actionscript-to-unity3d/comment-page-1/#comment-79573</link>
		<dc:creator>Paul Tondeur</dc:creator>
		<pubDate>Tue, 10 Nov 2009 16:32:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.everydayflash.com/blog/?p=438#comment-79573</guid>
		<description>Nice work Bartek! Excellent to see you&#039;ve been able to port some code from AS3 to C# for use in Unity.</description>
		<content:encoded><![CDATA[<p>Nice work Bartek! Excellent to see you&#8217;ve been able to port some code from AS3 to C# for use in Unity.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
