<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>true isometric projection with opengl</title>
		<link>http://www.allegro.cc/forums/view/600737</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 30 Jun 2009 18:48:42 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello,</p><p>I am a newbie in OpenGL programming and not very good at mathematics. Is there a simple way to have isometric projection? </p><p>I mean the true isometric projection, not the general orthogonal projection.</p><p>(<a href="http://en.wikipedia.org/wiki/Isometric_projection">http://en.wikipedia.org/wiki/Isometric_projection</a>)</p><p>Isometric projection happens only when projections of unit X, Y and Z vectors are equally long and angles between them are exactly 120 degrees. </p><p>(Also this is kind of a follow up for the thread: <a href="http://www.allegro.cc/forums/thread/592722">http://www.allegro.cc/forums/thread/592722</a>)</p><p>Code snippets are highly appreciated..</p><p>Thanks in advance..
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (999999)</author>
		<pubDate>Mon, 29 Jun 2009 21:15:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Definitely possible. It&#39;ll be a job of twizzling the projection matrix after you&#39;ve set up whatever you&#39;d like as an orthogonal projection (for example, to set up what proportion of the screen 1 unit is), then something like:</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span>GLfloat isoMatrix<span class="k2">[</span><span class="n">16</span><span class="k2">]</span> <span class="k3">=</span>
<span class="number">  2</span><span class="k2">{</span>
<span class="number">  3</span>   sinf<span class="k2">(</span><span class="n">2</span><span class="k3">*</span>M_PI<span class="k3">/</span><span class="n">3</span><span class="k2">)</span>, cosf<span class="k2">(</span><span class="n">2</span><span class="k3">*</span>M_PI<span class="k3">/</span><span class="n">3</span><span class="k2">)</span>, <span class="n">0</span>, <span class="n">0</span>,
<span class="number">  4</span>   sinf<span class="k2">(</span><span class="n">4</span><span class="k3">*</span>M_PI<span class="k3">/</span><span class="n">3</span><span class="k2">)</span>, cosf<span class="k2">(</span><span class="n">4</span><span class="k3">*</span>M_PI<span class="k3">/</span><span class="n">3</span><span class="k2">)</span>, <span class="n">0</span>, <span class="n">0</span>,
<span class="number">  5</span>   <span class="n">0</span>, <span class="n">1</span>, <span class="n">1</span>, <span class="n">0</span>,
<span class="number">  6</span>   <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">1</span>
<span class="number">  7</span><span class="k2">}</span><span class="k2">;</span>
<span class="number">  8</span>
<span class="number">  9</span>isoMatrix<span class="k2">[</span><span class="n">0</span><span class="k2">]</span> <span class="k3">=</span> 
<span class="number"> 10</span>
<span class="number"> 11</span>glMatrixMode<span class="k2">(</span>GL_PROJECTION<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 12</span>glMultMatrixf<span class="k2">(</span>isoMatrix<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 13</span>
<span class="number"> 14</span>glMatrixMode<span class="k2">(</span>GL_MODELVIEW<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 15</span>...
</div></div><p>

Might not be right, but is intended to map the x axis to an angle 1/3 of the way around a circle, the y axis to an angle 2/3 of the way around a circle and the z axis to straight up, with &#39;distance&#39; preserved (but still ignored) so that depth buffering works. This is really dashed off very quickly, without much thought at all. I&#39;m sure someone smarter or with time to actually fire up a compiler will be able to fix it up almost immediately.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Mon, 29 Jun 2009 21:43:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Err... why not just use a camera matrix to apply those rotations to the model matrix while using standard orthogonal projection? I was told that touching the projection matrix is a bad idea.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Tue, 30 Jun 2009 05:16:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600737/818934#target">SiegeLord</a> said:</div><div class="quote"><p>I was told that touching the projection matrix is a bad idea. </p></div></div><p>

Could you elaborate on that?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Indeterminatus)</author>
		<pubDate>Tue, 30 Jun 2009 11:37:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600737/818854#target">999999</a> said:</div><div class="quote"><p>
I mean the true isometric projection, not the general orthogonal projection.
</p></div></div><p>
1. Set ortho projection<br />2. Rotate the scene 45 degrees about the up axis<br />3. Rotate the scene 60 degrees about the x axis</p><p>The actual angles are a wild guess, so you might have to check them... the 45 degrees should be correct though.<br />If axis orientations don&#39;t match with what you want, you need to throw in the appropriate 90 or 180 degree rotations.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Tue, 30 Jun 2009 14:19:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600737/818982#target">Indeterminatus</a> said:</div><div class="quote"><p>Could you elaborate on that?</p></div></div><p>
Yep, same question from me. The request is to set up a particular type of projection — I can&#39;t see any reason why it would be a bad idea to put it on the projection stack, since that&#39;s what it&#39;s there for.</p><p>Quite probably my maths is broken though; I&#39;m free this evening so will try to fix it then.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Tue, 30 Jun 2009 15:32:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m not exactly sure, but I think some implementations may rely on certain characteristics (axis orientation and such) of the projection transform in order to correctly do things like clipping, z-buffering, etc.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Tue, 30 Jun 2009 15:53:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I had played with this some time ago, seems that glOrtho does what you need: It sets up an orthogonal projection, which gives you the isometric view of your choice.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Tue, 30 Jun 2009 17:20:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600737/818999#target">Tobias Dammers</a> said:</div><div class="quote"><p>I&#39;m not exactly sure, but I think some implementations may rely on certain characteristics (axis orientation and such) of the projection transform in order to correctly do things like clipping, z-buffering, etc.</p></div></div><p>
I don&#39;t think that is compatible with the OpenGL specification, which provides this diagram of the transform pipeline:</p><p><span class="remote-thumbnail"><span class="json">{"name":"img55.gif","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/8\/584dba8bc5248e49c8f723667da994e0.gif","w":519,"h":217,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/8\/584dba8bc5248e49c8f723667da994e0"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/5/8/584dba8bc5248e49c8f723667da994e0-240.jpg" alt="img55.gif" width="240" height="100" /></span></p><p>Per the spec:
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>Figure 2.6 diagrams the sequence of transformations that are applied to vertices. The vertex coordinates that are presented to the GL are termed object coordinates. The model-view matrix is applied to these coordinates to yield eye coordinates. Then another matrix, called the projection matrix, is applied to eye coordinates to yield clip coordinates. A perspective division is carried out on clip coordinates to yield normalized device coordinates. A final viewport transformation is applied to convert these coordinates into window coordinates.</p></div></div><p>

Obviously if you collapse the z coordinates down to a single point then z-buffering isn&#39;t going to work, but it should be impossible to break clipping. It&#39;s just one more matrix stage. The main functional reason that modelview and projection are separate is that the lighting model includes specular lighting, which is a function of light position, object position and camera position — so the latter two need to be distinguishable.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Tue, 30 Jun 2009 17:20:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hm, yes, lighting. That makes more sense. Still a good reason for using the projection matrix for just that, projection, and nothing else.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Tue, 30 Jun 2009 18:05:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That sounds in line with what I remember being told. That must be what I have meant then.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Tue, 30 Jun 2009 18:29:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600737/819029#target">Tobias Dammers</a> said:</div><div class="quote"><p>Still a good reason for using the projection matrix for just that, projection, and nothing else.</p></div></div><p>
But this is using it for projection. Modelview to align objects with each other and with the camera, projection to map from the camera to the screen.</p><p>It&#39;s all slightly academic if the code I posted doesn&#39;t work however — must check that out...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Tue, 30 Jun 2009 18:48:42 +0000</pubDate>
	</item>
</rss>
