<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Join My Conversation &#187; Lingo</title>
	<atom:link href="http://www.jmckell.com/category/lingo/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jmckell.com</link>
	<description>Conversation and news topics</description>
	<lastBuildDate>Thu, 02 Sep 2010 23:53:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Collision Using Spring Force</title>
		<link>http://www.jmckell.com/collision-using-spring-force-2/</link>
		<comments>http://www.jmckell.com/collision-using-spring-force-2/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 18:49:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Animation]]></category>
		<category><![CDATA[Lingo]]></category>
		<category><![CDATA[collision spring force]]></category>

		<guid isPermaLink="false">http://www.heathersych.com/?p=91</guid>
		<description><![CDATA[Collision Using Spring Force
When two objects rebound after colliding with each other,          it is due to a spring force, even though it may not look          like it. When two billiard balls collide, the compression of the ball [...]]]></description>
			<content:encoded><![CDATA[<p>Collision Using Spring Force</p>
<p>When two objects rebound after colliding with each other,          it is due to a <strong>spring force</strong>, even though it may not look          like it. When two billiard balls collide, the compression of the ball          is limited to a miniscule fraction of its width but it still happens.</p>
<p>Using a spring force requires <strong>higher model rates</strong> to realistically collide faster, harder objects. The <strong>fps</strong> display in the demo shows the <strong>actual frame rate</strong>. The          <a name="demo"></a> movie itself is set to 999 fps. On a 1.3 GHz P3 it          averages about 980 actual fps.</p>
<p><span>repeat with </span>s = <span>1</span> <span>to</span> <span>4</span><br />
<span>if</span> s &lt;&gt; <span>me</span>.spritenum          <span>then</span><br />
spOther = <span>sprite</span>(s)</p>
<p><span>&#8211;distance components</span><br />
distX = (spOther.x) &#8211; x<br />
distY = (spOther.y) &#8211; y</p>
<p><span>&#8211;pythagorean theorem          to get distance</span><br />
dist = <span>sqrt</span>(<span>power</span>(distX,<span>2</span>)          + <span>power</span>(distY,<span>2</span>))</p>
<p><span>&#8211;spring force</span><br />
xSpring = <span>0</span><br />
ySpring = <span>0</span><br />
minDist = (sp.<span>width</span> + spOther.<span>width</span>) / <span>2.0</span> -<span> 10</span><br />
<span>if</span> dist &lt;          minDist <span>then</span><br />
springF = (minDist &#8211; dist) * <span>.02</span><br />
xSpring = springF * -(distX/dist)<br />
ySpring = springF * -(distY/dist)<br />
<span>end if</span></p>
<p>xTotalForce = xTotalForce + xSpring<br />
yTotalForce = yTotalForce + ySpring<br />
<span> end if<br />
end repeat </span></p>
<p>The algorithm is <strong>almost identical to <a href="http://www.jmckell.com/generalgravity.html#demo2">general          gravity</a></strong>, so only the repeat loop is shown. Instead of calculating          gravity, it calculates spring force. Spring force only acts when the objects          are within a certain distance of each other, expressed as <strong>dist          &lt; minDist</strong>.</p>
<p>The magnitude of the spring force is given by <strong>minDist          &#8211; dist</strong>. This is the <strong>restPosition &#8211; position </strong>equation          from the <a href="http://www.jmckell.com/springforces.html">Spring Forces</a> section. <strong>Scaling          by .02</strong> puts the force into proportion with other values in the          animation. It can be considered the <strong>stiffness of the object</strong>,          the higher it is the stiffer the object.</p>
<p>This demo gives each object a <strong><a href="http://www.jmckell.com/mass.html">mass</a></strong>,          and uses the mass in the<br />
<strong>accel = force / mass</strong> equation. The behavior of the large          object shows how mass affects acceleration. When two objects collide,          each experiences the same amount of force, acting in opposite directions.          This force translates into a <strong>smaller acceleration for more massive          objects</strong>.</p>
<p>Mass can be set however you&#8217;d like. In this demo it is          set to the cube of the sprite width, which would roughly correspond to          its mass if it was a<br />
3-dimensional sphere.</p>
<p>The type of collision modelled in this demo is for <strong>round          objects with no friction</strong> between them. Friction or non-round          shape would cause part of the energy in the collision to go into rotational          velocity, making the objects spin.</p>
<p>For comments on the rest of the script, see <a href="http://www.jmckell.com/generalgravity.html">General                Gravity</a>.</p>
<img src="http://www.jmckell.com/?ak_action=api_record_view&id=91&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.jmckell.com/collision-using-spring-force-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Quad Property</title>
		<link>http://www.jmckell.com/the-quad-property/</link>
		<comments>http://www.jmckell.com/the-quad-property/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 01:03:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Lingo]]></category>
		<category><![CDATA[lingo help]]></category>
		<category><![CDATA[math animation]]></category>
		<category><![CDATA[quad property]]></category>

		<guid isPermaLink="false">http://www.jmckell.com/?p=125</guid>
		<description><![CDATA[The sprite.quad property is a list of four  points that specify the screen coordinates of the corners of a  sprite.          If the quad property is set in Lingo, Director will distort the  sprite          accordingly. [...]]]></description>
			<content:encoded><![CDATA[<p>The sprite.quad property is a <strong>list of four  points</strong> that specify the screen coordinates of the <strong>corners of a  sprite</strong>.          If the quad property is set in Lingo, Director will distort the  sprite          accordingly. This allows the rendering of 3D rotation of a  sprite.</p>
<p>Drag on the screen to spin the object<br />
<object classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" width="512" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0"><param name="src" value="dir/quad.dcr" /><param name="swRemote" value="swSaveEnabled='true'  swVolume='true' swRestart='true' swPausePlay='true' swFastForward='true'  swContextMenu='true' " /><param name="swStretchStyle" value="none" /><param name="bgColor" value="#000000" /><embed type="application/x-director" width="512" height="300" src="http://www.jmckell.com/dir/quad.dcr" bgcolor="#000000" swremote="swSaveEnabled='true' swVolume='true'  swRestart='true' swPausePlay='true' swFastForward='true'  swContextMenu='true' " swstretchstyle="none" pluginspage="http://www.macromedia.com/shockwave/download/"></embed></object> <strong>Quad property</strong> &#8211; <a href="http://www.jmckell.com/zip/quad.zip">source         movie</a></p>
<p>property sp<br />
property verts<br />
property trans<br />
property rotVelo</p>
<p>on beginsprite(me)<br />
sp = sprite(me.spritenum)<br />
verts = []<br />
verts[1] = vector(-1,1,0)<br />
verts[2] = vector(1,1,0)<br />
verts[3] = vector(1,-1,0)<br />
verts[4] = vector(-1,-1,0)<br />
trans = transform()<br />
trans.scale = vector(150,150,1)<br />
rotVelo = vector(.3,.2,0)<br />
end</p>
<p>on exitframe()<br />
modelFrame()<br />
render()<br />
end</p>
<p>on modelFrame()<br />
trans.rotate(rotVelo)<br />
end</p>
<p>on render()<br />
eyez = 500<br />
ptList = []<br />
repeat with v = 1 to          4<br />
vec = trans * verts[v]<br />
persp = eyez / (vec.z + eyez)<br />
pt = point(vec.x          * persp, vec.y * persp) +  stageCenter<br />
ptList.add(pt)<br />
end repeat<br />
sp.quad = ptList<br />
end</p>
<p>The Model<br />
The animation model in this demo consists of four vectors, a  transform,          and a rotational velocity. The <strong>four vectors</strong> specify the          corners of the object, and are analogous to a &#8220;model resource&#8221;.          The <strong>transform</strong> is used to specify the scale,  translation,          and rotation of the object. Each model frame, the transform is  rotated          by a vector that specifies <strong>rotational velocity</strong>.</p>
<p>The model could have been stored in four vectors  that specify          3D world coordinates, without using a transform. But keeping the  <strong>resource          information and transform separate</strong> makes transforming  easier,          and makes it easier to animate the corners with respect to each  other.</p>
<p>•How would you change the &#8220;registration point&#8221;          of the plane?</p>
<p>Rendering<br />
Multiplying each resource vector by the transform gives the 3D  world coordinates          of the corners. The <a href="http://www.jmckell.com/3Dcues.html">perspective  equation</a> is          then used to map the 3D points to 2D. The 2D points are put in a  list          which is used to set the sprite&#8217;s quad property. The order of  the points          is <strong>clockwise from upper-left</strong> for right side up  facing          the viewer, which is the reason for the order of the resource  vectors.</p>
<p>The next section shows how to combine quads to  make 3D          objects.</p>
<img src="http://www.jmckell.com/?ak_action=api_record_view&id=125&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.jmckell.com/the-quad-property/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Space Viewport 2.0</title>
		<link>http://www.jmckell.com/space-viewport-2-0/</link>
		<comments>http://www.jmckell.com/space-viewport-2-0/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 00:57:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Lingo]]></category>
		<category><![CDATA[Marketing]]></category>

		<guid isPermaLink="false">http://www.heathersych.com/?p=81</guid>
		<description><![CDATA[Case Study: Space Viewport 2.0
Related Topics:
Space Viewport
Perspective &#38; Other Depth Cues 
Data Structures and Recursion 



View controls:
Drag in viewport to pan
Drag on &#8216;radar&#8217; to pan
Alt-drag in viewport to zoom
Click &#8216;follow&#8217; to follow ship
Ship controls:
left/right arrows to turn
ctrl to thrust



 Space Viewport 2.0 &#8211; source        movie
This demo builds on [...]]]></description>
			<content:encoded><![CDATA[<p>Case Study: Space Viewport 2.0</p>
<p><strong>Related Topics:</strong><br />
<a href="http://www.jmckell.com/spaceView.html">Space Viewport</a><br />
<a href="http://www.jmckell.com/3Dcues.html">Perspective &amp; Other Depth Cues </a><br />
<a href="http://www.jmckell.com/directionaccel.html">Data Structures and Recursion </a><a name="demo"></a></p>
<table border="0" width="100%">
<tbody>
<tr valign="top">
<td width="32%"><span><strong>View controls:</strong><br />
Drag in viewport to pan<br />
Drag on &#8216;radar&#8217; to pan<br />
Alt-drag in viewport to zoom<br />
</span><span>Click &#8216;follow&#8217; to follow ship</span></td>
<td width="68%"><strong>Ship controls:</strong><br />
left/right arrows to turn<br />
ctrl to thrust</td>
</tr>
</tbody>
</table>
<p><object classid="clsid:166b1bca-3f9c-11cf-8075-444553540000" width="512" height="255" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0"><param name="src" value="dir/spaceView2.dcr" /><param name="swRemote" value="swSaveEnabled='true' swVolume='true' swRestart='true' swPausePlay='true' swFastForward='true' swContextMenu='true' " /><param name="swStretchStyle" value="none" /><param name="bgColor" value="#000000" /><param name="progress" value="FALSE" /><param name="logo" value="FALSE" /><param name="bgcolor" value="#000000" /><embed type="application/x-director" width="512" height="255" src="dir/spaceView2.dcr" logo="FALSE" progress="FALSE" bgcolor="#000000" swstretchstyle="none" swremote="swSaveEnabled='true' swVolume='true' swRestart='true' swPausePlay='true' swFastForward='true' swContextMenu='true' "></embed></object> <span><strong>Space Viewport 2.0</strong> &#8211; <a href="http://www.jmckell.com/zip/spaceView2.zip">source        movie</a></span></p>
<p>This demo builds on the first version by giving universe elements a depth and rendering with some <a href="http://www.jmckell.com/3Dcues.html">depth cues, </a>and also storing the universe model in a <a href="http://www.jmckell.com/datastruc.html#trees">tree</a> rather than a list.</p>
<p><span>Depth &amp; Perspective</span><br />
The field of action is still two dimensional, but adding depth makes the visuals more interesting. It&#8217;s pretty simple to do. Each element is given a <strong>z coordinate</strong> which is used for <a href="http://www.jmckell.com/3Dcues.html#perspective"><strong>perspective</strong></a> and for <strong>blendlevel (haze)</strong> and <strong>locz (z-axis blocking)</strong>.</p>
<p>Notice how the method <strong>uniToView()</strong> which maps universe to screen coordinates now makes use of the perspective value. First the <strong>offset</strong> from the camera is found (vec &#8211; camVec), then <strong>perspective</strong> is applied, then <strong>zoom and shifting</strong>:</p>
<p><span>on</span> uniToView(vec)<br />
vec = (vec &#8211; camVec) * persp<br />
<span>loch</span> = vec.<span>x</span> * zoomLevel + viewRect.<span>left</span> + viewRect.<span>width</span>/<span>2</span><br />
<span>locv</span> = vec.<span>y</span> * zoomLevel + viewRect.<span>top</span> + viewRect.<span>height</span>/<span>2</span><br />
<span>return</span> <span>point</span>(<span>loch</span>, <span>locv</span>)<br />
<span>end</span></p>
<p><span>Tree Structure for the Model</span><br />
Instead of being stored in a list, the objects of the universe are now stored as a <a href="http://www.jmckell.com/datastruc.html#trees">tree</a>. The universe object is the tree <strong>root</strong>, and each object&#8217;s position is relative to its parent. The circling planets show how the <strong>tree structure simplifies the programming</strong>—the planet script doesn&#8217;t need to take into account how the sun fits into the rest of the scene. For more on using a tree and transforms in animation see <a href="http://www.jmckell.com/3Dworld.html">3D World</a> and the other 3D quad demos.</p>
<p>Migrating to a tree structure was made much easier by <strong>inheritance</strong>. Simply making the treeNode script the ancestor of universeElement gave all the model objects the <strong>properties and methods of a tree node</strong>.</p>
<p>This demo is a relatively rare example of the use in Lingo of a series of inheritance, where a <strong>script&#8217;s ancestor itself has an ancestor</strong>. For example, ship inherits universeElement which inherits treeNode. Does it make a difference if universeElement and treeNode are <strong>reversed in the order</strong>? It wouldn&#8217;t to the ship script, but there are reasons to arrange it the way it is. <strong>Abstractly</strong>, according to the <strong>&#8220;is a&#8221;</strong> relationship of inheritance, universeElement is a treeNode but treeNode is not a universeElement. <strong>Practically</strong>, if you wanted a node just for <strong>grouping</strong> in the model you can now just use a universeElement object (because it inherits from treeNode).</p>
<img src="http://www.jmckell.com/?ak_action=api_record_view&id=81&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.jmckell.com/space-viewport-2-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
