<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5110923420068612029</id><updated>2025-07-24T17:57:32.232-07:00</updated><category term="c#"/><category term="raytracer"/><category term="3d"/><category term="raytracing"/><category term="realistic graphics"/><category term=".Net"/><category term="xna"/><category term="2012"/><category term="C++"/><category term="PI"/><category term="Vectors"/><category term="c++/cli"/><category term="efficiency"/><category term="efficient"/><category term="from scratch"/><category term="number"/><category term="operator"/><category term="overloading"/><category term="perfect"/><category term="perfect number"/><category term="perfect numbers"/><category term="sphere"/><category term="vector"/><category term="website"/><category term="windows phone"/><category term="winodws"/><category term="x"/><category term="xbox"/><category term="xna 4.0"/><category term="y"/><category term="z"/><title type='text'>Belal&#39;s Blog</title><subtitle type='html'>3D design, 3D games, and game programming.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://thver.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5110923420068612029/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://thver.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Belal</name><uri>http://www.blogger.com/profile/09157670058713428098</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5110923420068612029.post-8806557252058725227</id><published>2016-04-30T16:52:00.000-07:00</published><updated>2016-05-02T16:57:23.705-07:00</updated><title type='text'>How to break out of a nested for-loop in Java</title><content type='html'>You&#39;d normally think that it&#39;s impossible to break out of a double, triple or n-times nest loops in Java without using some convoluted piece of code that &amp;nbsp;involves some kind of boolean checking &amp;nbsp;but &lt;b&gt;it is possible&lt;/b&gt;, and it&#39;s pretty darn simple. It&#39;s just one of those things that you never learned about in your high school or college java class.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Anyway, here it is, with all its beauty:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
outerloop: &lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; 20; i++) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; j = 0; j &amp;lt; 10; j++) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;(i == 10) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;break&lt;/span&gt; outerloop;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Yes, it&#39;s &lt;b&gt;that simple.&lt;/b&gt;&amp;nbsp;Who knew you could label loops in Java.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://thver.blogspot.com/feeds/8806557252058725227/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thver.blogspot.com/2016/04/how-to-break-out-of-nested-for-loop-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5110923420068612029/posts/default/8806557252058725227'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5110923420068612029/posts/default/8806557252058725227'/><link rel='alternate' type='text/html' href='http://thver.blogspot.com/2016/04/how-to-break-out-of-nested-for-loop-in.html' title='How to break out of a nested for-loop in Java'/><author><name>Belal</name><uri>http://www.blogger.com/profile/09157670058713428098</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5110923420068612029.post-5384152751922525848</id><published>2013-03-02T10:02:00.000-08:00</published><updated>2013-03-03T11:08:13.328-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="efficiency"/><category scheme="http://www.blogger.com/atom/ns#" term="efficient"/><category scheme="http://www.blogger.com/atom/ns#" term="operator"/><category scheme="http://www.blogger.com/atom/ns#" term="overloading"/><category scheme="http://www.blogger.com/atom/ns#" term="PI"/><category scheme="http://www.blogger.com/atom/ns#" term="raytracer"/><category scheme="http://www.blogger.com/atom/ns#" term="vector"/><category scheme="http://www.blogger.com/atom/ns#" term="Vectors"/><category scheme="http://www.blogger.com/atom/ns#" term="x"/><category scheme="http://www.blogger.com/atom/ns#" term="y"/><category scheme="http://www.blogger.com/atom/ns#" term="z"/><title type='text'>Efficient Vectors in C#</title><content type='html'>Making the raytracing made me in an efficiency craze. I had to think about the efficiency for everything. One of the basic things to think about is vectors! Consider the following &lt;a href=&quot;https://gist.github.com/JointJBA/9bbfc6059cbd696db62e&quot; target=&quot;_blank&quot;&gt;vectors&lt;/a&gt;.&amp;nbsp;I&lt;span style=&quot;font-family: inherit;&quot;&gt;n this code, there are three vector structs, each with different x, y, z implementations. The three vectors overload the multiplication, addition, and subtraction operators to apply them to x, y, and z. I created a simple test to see the efficiency of the 3 implementations. The test was very simple it involved two vectors one with the x, y, and z equal to PI and vector with the x, y, and z values set to 1. The vector with the 1 value is multiplied, added, and subtracted with a PI vector in a for loop that goes 1,000,000 times. Here are the results:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; style=&quot;width: 400px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;Struct
&lt;/th&gt;
&lt;th&gt;*&lt;/th&gt;
&lt;th&gt;+&lt;/th&gt;
&lt;th&gt;-&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;div style=&quot;text-align: center;&quot;&gt;
Vec&lt;/div&gt;
&lt;/td&gt;
&lt;td&gt;&lt;div style=&quot;text-align: center;&quot;&gt;
1665&lt;/div&gt;
&lt;/td&gt;
&lt;td&gt;&lt;div style=&quot;text-align: center;&quot;&gt;
255&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;div style=&quot;text-align: center;&quot;&gt;
316&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;div style=&quot;text-align: center;&quot;&gt;
Vec2&lt;/div&gt;
&lt;/td&gt;
&lt;td&gt;&lt;div style=&quot;text-align: center;&quot;&gt;
2104&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;div style=&quot;text-align: center;&quot;&gt;
569&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;div style=&quot;text-align: center;&quot;&gt;
781&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;div style=&quot;text-align: center;&quot;&gt;
Vec3&lt;/div&gt;
&lt;/td&gt;
&lt;td&gt;&lt;div style=&quot;text-align: center;&quot;&gt;
1603&lt;/div&gt;
&lt;/td&gt;
&lt;td&gt;&lt;div style=&quot;text-align: center;&quot;&gt;
224&lt;/div&gt;
&lt;/td&gt;
&lt;td&gt;&lt;div style=&quot;text-align: center;&quot;&gt;
346&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
The result show that properties are the least efficient way, taking 100% more time.</content><link rel='replies' type='application/atom+xml' href='http://thver.blogspot.com/feeds/5384152751922525848/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thver.blogspot.com/2013/03/efficient-vectors-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5110923420068612029/posts/default/5384152751922525848'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5110923420068612029/posts/default/5384152751922525848'/><link rel='alternate' type='text/html' href='http://thver.blogspot.com/2013/03/efficient-vectors-in-c.html' title='Efficient Vectors in C#'/><author><name>Belal</name><uri>http://www.blogger.com/profile/09157670058713428098</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5110923420068612029.post-359719753883368245</id><published>2012-12-24T17:48:00.001-08:00</published><updated>2012-12-24T18:13:03.039-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="2012"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="raytracer"/><category scheme="http://www.blogger.com/atom/ns#" term="raytracing"/><category scheme="http://www.blogger.com/atom/ns#" term="realistic graphics"/><category scheme="http://www.blogger.com/atom/ns#" term="website"/><category scheme="http://www.blogger.com/atom/ns#" term="xna"/><title type='text'>Online Raytracer</title><content type='html'>I have finished 95% percent of the raytracer, and since it is written in C# and doesn&#39;t use unsafe code, I could use it with asp.net. A parser interprets XML for the raytracer and produces a final image at the bottom of the page. The online sample lacks textures and meshes, which I plan to add later. Also the documentation of the markup language is not complete, but you can get the hang of it by taking a look at the samples. Everyday I will update the raytracer and parser for the bugs. Please use the report page to report any bug or exception that comes up! You can find the website &lt;a href=&quot;http://csraytracer.somee.com/&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhq1JaMyLdW-9i0NZwo6Fq1HQMqIXlczZ5XEGPIJuN6tEPHqiLjXxy6vI6QSvnoLToYzb7YM7wRLGfjLHacNvBVOjKnNbBc2NfM0Rpp4NeROtVbOS2PXXr4YvW4sqbOEKOPurDUbWcN11w/s1600/website.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;492&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhq1JaMyLdW-9i0NZwo6Fq1HQMqIXlczZ5XEGPIJuN6tEPHqiLjXxy6vI6QSvnoLToYzb7YM7wRLGfjLHacNvBVOjKnNbBc2NfM0Rpp4NeROtVbOS2PXXr4YvW4sqbOEKOPurDUbWcN11w/s640/website.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://thver.blogspot.com/feeds/359719753883368245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thver.blogspot.com/2012/12/online-raytracer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5110923420068612029/posts/default/359719753883368245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5110923420068612029/posts/default/359719753883368245'/><link rel='alternate' type='text/html' href='http://thver.blogspot.com/2012/12/online-raytracer.html' title='Online Raytracer'/><author><name>Belal</name><uri>http://www.blogger.com/profile/09157670058713428098</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhq1JaMyLdW-9i0NZwo6Fq1HQMqIXlczZ5XEGPIJuN6tEPHqiLjXxy6vI6QSvnoLToYzb7YM7wRLGfjLHacNvBVOjKnNbBc2NfM0Rpp4NeROtVbOS2PXXr4YvW4sqbOEKOPurDUbWcN11w/s72-c/website.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5110923420068612029.post-6740324487225659296</id><published>2012-09-17T15:50:00.000-07:00</published><updated>2012-10-05T16:18:14.479-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="3d"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="raytracer"/><category scheme="http://www.blogger.com/atom/ns#" term="raytracing"/><category scheme="http://www.blogger.com/atom/ns#" term="realistic graphics"/><title type='text'>Update: More raytracer images</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I haven&#39;t posted in a while. Today I will not post much except some more of images of my C# raytracer. I have added reflection, transparency, and textures.&lt;br /&gt;
Here are the images:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcAkO9ZmgjWVSnDloOfcmg2VFiZn75MTKTsauWJssY_re_mHSQfC9cdMSq8XmZSwB02CW3bqrlEFI0iAVJ3-mF4ihvSvFQQ-txmQnaRBf8XlyqdCt32QYtlS_J4hikavUow_YuiLmkuEs/s1600/all_large.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcAkO9ZmgjWVSnDloOfcmg2VFiZn75MTKTsauWJssY_re_mHSQfC9cdMSq8XmZSwB02CW3bqrlEFI0iAVJ3-mF4ihvSvFQQ-txmQnaRBf8XlyqdCt32QYtlS_J4hikavUow_YuiLmkuEs/s400/all_large.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEik5HZCLyxNGUrp7emzIETjHieRF3Cntv7EQj6KqQA2jLL746HR7MEPIcK9tVKbg2QwjOcZ-f2sCKSb41SVTNclJyFisphNeKjJaS3AEib9eZX1nRF3YPJRXHB-5xbEC3R31RicdMaiMmo/s1600/glossy_reflection.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;347&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEik5HZCLyxNGUrp7emzIETjHieRF3Cntv7EQj6KqQA2jLL746HR7MEPIcK9tVKbg2QwjOcZ-f2sCKSb41SVTNclJyFisphNeKjJaS3AEib9eZX1nRF3YPJRXHB-5xbEC3R31RicdMaiMmo/s400/glossy_reflection.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPdFFiwFKpg1RG8SBGqRK9NLTRbmoeqs40AHF1sXy3lCAy6T972k1Y7j9V64XSCTgKiyXuS57HOsqb2BeNcyrtrqg4U4ZEwt1LlUB_LT2Bq55kxVQMdeQWIKLyFt8-9gNMVcsNEmHzlmk/s1600/reflection_spheres.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;393&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPdFFiwFKpg1RG8SBGqRK9NLTRbmoeqs40AHF1sXy3lCAy6T972k1Y7j9V64XSCTgKiyXuS57HOsqb2BeNcyrtrqg4U4ZEwt1LlUB_LT2Bq55kxVQMdeQWIKLyFt8-9gNMVcsNEmHzlmk/s400/reflection_spheres.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8H1NASS6jqMKDs0F4b3-lQ5M6LxJ818zkNCxAHyE0toRFB_tXv1lAiUpuTxS1uXKn_YAXjzOOyHcy0h1KWOFbdKEZcGAC4hE7oPpS9dO5zTxL2hJAOS0zlAFq7hOZqgvidWOpV193bYM/s1600/regular.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;326&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8H1NASS6jqMKDs0F4b3-lQ5M6LxJ818zkNCxAHyE0toRFB_tXv1lAiUpuTxS1uXKn_YAXjzOOyHcy0h1KWOFbdKEZcGAC4hE7oPpS9dO5zTxL2hJAOS0zlAFq7hOZqgvidWOpV193bYM/s400/regular.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnVMscoL1HjMIiZcIDMSI4ugWgBPJDjKwEMcttceGsWJ_3U5rCw-gSgCzdIVHOuE-vHkhcTgqlTwQ3TAXWRU1JKs0enyvi8i3grAIHPyZ6gwS4x9ea0w5COcforg1gyrWyU1VEjQhFrJ8/s1600/texture+test.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;297&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnVMscoL1HjMIiZcIDMSI4ugWgBPJDjKwEMcttceGsWJ_3U5rCw-gSgCzdIVHOuE-vHkhcTgqlTwQ3TAXWRU1JKs0enyvi8i3grAIHPyZ6gwS4x9ea0w5COcforg1gyrWyU1VEjQhFrJ8/s400/texture+test.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio6OqfSgouErd8e7lLUMvVdRQxlOuR5zEpxcjGeHmGWhPIyiJyWo8i_3gANyKqBNP0fImp8GjPS0v2XuhPug9hrqlHoD9XOwM_URnThrQtgDOeV1QoakMbhpouzWhayYO29bkTjCYdMT4/s1600/tspheres.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;297&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio6OqfSgouErd8e7lLUMvVdRQxlOuR5zEpxcjGeHmGWhPIyiJyWo8i_3gANyKqBNP0fImp8GjPS0v2XuhPug9hrqlHoD9XOwM_URnThrQtgDOeV1QoakMbhpouzWhayYO29bkTjCYdMT4/s400/tspheres.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://thver.blogspot.com/feeds/6740324487225659296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thver.blogspot.com/2012/09/update-more-raytracer-images.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5110923420068612029/posts/default/6740324487225659296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5110923420068612029/posts/default/6740324487225659296'/><link rel='alternate' type='text/html' href='http://thver.blogspot.com/2012/09/update-more-raytracer-images.html' title='Update: More raytracer images'/><author><name>Belal</name><uri>http://www.blogger.com/profile/09157670058713428098</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcAkO9ZmgjWVSnDloOfcmg2VFiZn75MTKTsauWJssY_re_mHSQfC9cdMSq8XmZSwB02CW3bqrlEFI0iAVJ3-mF4ihvSvFQQ-txmQnaRBf8XlyqdCt32QYtlS_J4hikavUow_YuiLmkuEs/s72-c/all_large.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5110923420068612029.post-9002586137037497713</id><published>2012-09-07T18:03:00.000-07:00</published><updated>2012-09-16T16:34:10.718-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="c++/cli"/><category scheme="http://www.blogger.com/atom/ns#" term="number"/><category scheme="http://www.blogger.com/atom/ns#" term="perfect"/><category scheme="http://www.blogger.com/atom/ns#" term="perfect number"/><category scheme="http://www.blogger.com/atom/ns#" term="perfect numbers"/><title type='text'>Break: Calculating perfect numbers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Till now there have been 4 perfect numbers discovered, but it would be also nice to know how to calculate them. The logic is very simple. I will write the logic and code in C++/CLI.&lt;br /&gt;
First lets define perfect numbers. Perfect numbers are numbers that are equal to their divisors. For example number 6, its divisors are 1,2,3 (excluding the number itself). 1 + 2 + 3 = 6. There are about 47 perfect numbers discovered till now, the first 4 are very easy to get; the rest go from 8 digits to millions of digits. The logic is very simple, Here is the code:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;long&lt;/span&gt; count = 1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;( ; ;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;long&lt;/span&gt; current = 0;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;long&lt;/span&gt; i = count - 1; i &amp;nbsp;&amp;gt; 0; i--)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;(count % i == 0) &lt;span style=&quot;color: #38761d;&quot;&gt;// make sure the current number is divisble with the numbers smaller than it&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;current += i;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;(current == count)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Console::WriteLine(count);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;count++;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://thver.blogspot.com/feeds/9002586137037497713/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thver.blogspot.com/2012/09/break-calculating-perfect-numbers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5110923420068612029/posts/default/9002586137037497713'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5110923420068612029/posts/default/9002586137037497713'/><link rel='alternate' type='text/html' href='http://thver.blogspot.com/2012/09/break-calculating-perfect-numbers.html' title='Break: Calculating perfect numbers'/><author><name>Belal</name><uri>http://www.blogger.com/profile/09157670058713428098</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5110923420068612029.post-5199464298398628771</id><published>2012-08-27T12:25:00.001-07:00</published><updated>2012-08-27T13:50:21.753-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="3d"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="from scratch"/><category scheme="http://www.blogger.com/atom/ns#" term="raytracer"/><category scheme="http://www.blogger.com/atom/ns#" term="raytracing"/><category scheme="http://www.blogger.com/atom/ns#" term="realistic graphics"/><title type='text'>C# raytracer from scratch</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I am building a complete C# raytracer. It uses my own math library and it will be part of the Disque Engine. The raytracer is close to completion. Right now it can render the basic shapes such as spheres, cubes, cones, cylinders, disks, rectangles, and triangles. I am also trying to implement a ply file reader so that I can render the&amp;nbsp;Stanford&amp;nbsp;bunny or other standard models. After I finish the raytracer I will post tutorials on how to build your own.&lt;br /&gt;
&lt;br /&gt;
Here are some samples(time format is h:m:s.ms) :&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghVxmQb2w1LW1MaoRlplKfks3jr8Yb07b-vD92dwTKICCt8sT-tftKCiYT9XZHHPtZGiK_-elbyQ3Fwitv2HATBU1IvW4EkbbldBWRYnMoCjNDjNFhCBgpUGp2EptJPcGyQYUZh4Qr4NQ/s1600/background.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;393&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghVxmQb2w1LW1MaoRlplKfks3jr8Yb07b-vD92dwTKICCt8sT-tftKCiYT9XZHHPtZGiK_-elbyQ3Fwitv2HATBU1IvW4EkbbldBWRYnMoCjNDjNFhCBgpUGp2EptJPcGyQYUZh4Qr4NQ/s640/background.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Simple image rendered at 256 samples per pixel, total render time: 00:09:43.838&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZnfBZWWga0TAX_zqRQwOfNkNG8PG7MpksR0__XPwKy1QShoUiNm4ooc4zWVM7o6S9SQ74m4ax4GyYb8G9FoPD05AUlgu7dWJS8rxbk9e-HwpuRPWfApVJBAeIYESo9YbMrefKlEeRa6Q/s1600/spheres.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZnfBZWWga0TAX_zqRQwOfNkNG8PG7MpksR0__XPwKy1QShoUiNm4ooc4zWVM7o6S9SQ74m4ax4GyYb8G9FoPD05AUlgu7dWJS8rxbk9e-HwpuRPWfApVJBAeIYESo9YbMrefKlEeRa6Q/s1600/spheres.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
An image of 1000 random spheres rendered at 121 samples per pixel, total render time: 02:13:45.002&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
I will provide more samples as the raytracer advances.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://thver.blogspot.com/feeds/5199464298398628771/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thver.blogspot.com/2012/08/c-raytracer-from-scratch.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5110923420068612029/posts/default/5199464298398628771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5110923420068612029/posts/default/5199464298398628771'/><link rel='alternate' type='text/html' href='http://thver.blogspot.com/2012/08/c-raytracer-from-scratch.html' title='C# raytracer from scratch'/><author><name>Belal</name><uri>http://www.blogger.com/profile/09157670058713428098</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghVxmQb2w1LW1MaoRlplKfks3jr8Yb07b-vD92dwTKICCt8sT-tftKCiYT9XZHHPtZGiK_-elbyQ3Fwitv2HATBU1IvW4EkbbldBWRYnMoCjNDjNFhCBgpUGp2EptJPcGyQYUZh4Qr4NQ/s72-c/background.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5110923420068612029.post-6747759030066306048</id><published>2012-07-12T09:14:00.001-07:00</published><updated>2012-12-15T14:30:04.756-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="3d"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="sphere"/><category scheme="http://www.blogger.com/atom/ns#" term="windows phone"/><category scheme="http://www.blogger.com/atom/ns#" term="winodws"/><category scheme="http://www.blogger.com/atom/ns#" term="xbox"/><category scheme="http://www.blogger.com/atom/ns#" term="xna"/><category scheme="http://www.blogger.com/atom/ns#" term="xna 4.0"/><title type='text'>How to create a sphere programmatically in XNA</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I &quot;discovered&quot; an easy but silly way to create a sphere programmatically in XNA, it is very simple. The idea came to me when I wanted to create huge planets in XNA to make an endless map. Any way the method is very simple, I don&#39;t know If someone knows it or it was used before, but till now it is working and efficient. You can control the resolution or how &quot;round&quot; the sphere is.&lt;br /&gt;
&lt;div&gt;
The code is written in C# with microsoft&#39;s XNA 4.0.&lt;/div&gt;
&lt;div&gt;
Here is a high resolution sphere in wire frame:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxNjKO7sGCMe544TPpVeRDoNN5EdyzmI_9MQRaEpywI4Aa5MZWeEtUKrqbvBBbpd7CQVOGtnrfZOP7KNtt5rxSYV1CnVW0iqHEBMLmzm7IJNh2c7g4nPO0wS68A6zoKFisI_c_Prds5P8/s1600/spherexna.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;381&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxNjKO7sGCMe544TPpVeRDoNN5EdyzmI_9MQRaEpywI4Aa5MZWeEtUKrqbvBBbpd7CQVOGtnrfZOP7KNtt5rxSYV1CnVW0iqHEBMLmzm7IJNh2c7g4nPO0wS68A6zoKFisI_c_Prds5P8/s400/spherexna.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The sphere contains 8100 vertices and 48600 indices.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Code:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;    &lt;span class=&quot;kwrd&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot; style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; Sphere
    {
        VertexPositionColor[] vertices; //later, I will provide another example with VertexPositionNormalTexture
        VertexBuffer vbuffer;
        &lt;span class=&quot;kwrd&quot; style=&quot;color: blue;&quot;&gt;short&lt;/span&gt;[] indices; //my laptop can only afford Reach, no HiDef :(
        IndexBuffer ibuffer;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
        &lt;span class=&quot;kwrd&quot; style=&quot;color: blue;&quot;&gt;float&lt;/span&gt; radius;
        &lt;span class=&quot;kwrd&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; nvertices, nindices;
        BasicEffect effect;
        GraphicsDevice graphicd;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; Sphere(&lt;span class=&quot;kwrd&quot;&gt;float&lt;/span&gt; Radius, GraphicsDevice graphics)
        {
            radius = Radius;
            graphicd = graphics;
            effect = &lt;span class=&quot;kwrd&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; BasicEffect(graphicd);
            nvertices = 90 * 90; // 90 vertices in a circle, 90 circles in a sphere
            nindices = 90 * 90 * 6;
            vbuffer = &lt;span class=&quot;kwrd&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; VertexBuffer(graphics, &lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(VertexPositionNormalTexture), nvertices, BufferUsage.WriteOnly);
            ibuffer = &lt;span class=&quot;kwrd&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; IndexBuffer(graphics, IndexElementSize.SixteenBits, nindices, BufferUsage.WriteOnly);
            createspherevertices();
            createindices();
            vbuffer.SetData&amp;lt;VertexPositionColor&amp;gt;(vertices);
            ibuffer.SetData&amp;lt;&lt;span class=&quot;kwrd&quot; style=&quot;color: blue;&quot;&gt;short&lt;/span&gt;&amp;gt;(indices);
            effect.VertexColorEnabled = &lt;span class=&quot;kwrd&quot; style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;
        }
        &lt;span class=&quot;kwrd&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; createspherevertices()
        {
            vertices = &lt;span class=&quot;kwrd&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; VertexPositionColor[nvertices];
            Vector3 center = &lt;span class=&quot;kwrd&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; Vector3(0, 0, 0);
            Vector3 rad = &lt;span class=&quot;kwrd&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; Vector3((&lt;span style=&quot;color: blue;&quot;&gt;float&lt;/span&gt;)Math.Abs(radius), 0, 0);
            &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; x = 0; x &amp;lt; 90; x++) //90 circles, difference between each is 4 degrees
            {
                &lt;span class=&quot;kwrd&quot;&gt;float&lt;/span&gt; difx = 360.0f / 90.0f;
                &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; y = 0; y &amp;lt; 90; y++) //90 veritces, difference between each is 4 degrees 
                {
                    &lt;span class=&quot;kwrd&quot;&gt;float&lt;/span&gt; dify = 360.0f / 90.0f;
                    Matrix zrot = Matrix.CreateRotationZ(MathHelper.ToRadians(y * dify)); rotate vertex around z
                    Matrix yrot = Matrix.CreateRotationY(MathHelper.ToRadians(x * difx)); rotate circle around y
                    Vector3 point = Vector3.Transform(Vector3.Transform(rad, zrot), yrot);//transformation

                    vertices[x + y * 90] = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; VertexPositionColor(point, Color.Black);
                }
            }
        }
        &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; createindices()
        {
            indices = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;short&lt;/span&gt;[nindices];
            &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; i = 0;
            &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; x = 0; x &amp;lt; 90; x++)
            {
                &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; y = 0; y &amp;lt; 90; y++)
                {
                    &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; s1 = x == 89 ? 0 : x + 1;
                    &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; s2 = y == 89 ? 0 : y + 1;
                    &lt;span class=&quot;kwrd&quot;&gt;short&lt;/span&gt; upperLeft = (&lt;span class=&quot;kwrd&quot;&gt;short&lt;/span&gt;)(x * 90 + y);
                    &lt;span class=&quot;kwrd&quot;&gt;short&lt;/span&gt; upperRight = (&lt;span class=&quot;kwrd&quot;&gt;short&lt;/span&gt;)(s1 * 90 + y);
                    &lt;span class=&quot;kwrd&quot;&gt;short&lt;/span&gt; lowerLeft = (&lt;span class=&quot;kwrd&quot;&gt;short&lt;/span&gt;)(x * 90 + s2);
                    &lt;span class=&quot;kwrd&quot;&gt;short&lt;/span&gt; lowerRight = (&lt;span class=&quot;kwrd&quot;&gt;short&lt;/span&gt;)(s1 * 90 + s2);
                    indices[i++] = upperLeft;
                    indices[i++] = upperRight;
                    indices[i++] = lowerLeft;
                    indices[i++] = lowerLeft;
                    indices[i++] = upperRight;
                    indices[i++] = lowerRight;
                }
            }
        }
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Draw(Camera cam) // the camera class contains the View and Projection Matrices
        {
            effect.View = cam.View;
            effect.Projection =  cam.Projection;
            graphicd.RasterizerState = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; RasterizerState() { FillMode = FillMode.WireFrame }; // Wireframe as in the picture
            &lt;span class=&quot;kwrd&quot;&gt;foreach&lt;/span&gt; (EffectPass pass &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicd.DrawUserIndexedPrimitives&amp;lt;VertexPositionColor&amp;gt;(PrimitiveType.TriangleList, vertices, 0, nvertices, indices, 0, indices.Length / 3);
            }
        }
    }
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://thver.blogspot.com/feeds/6747759030066306048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thver.blogspot.com/2012/07/how-to-create-sphere-programmatically.html#comment-form' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5110923420068612029/posts/default/6747759030066306048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5110923420068612029/posts/default/6747759030066306048'/><link rel='alternate' type='text/html' href='http://thver.blogspot.com/2012/07/how-to-create-sphere-programmatically.html' title='How to create a sphere programmatically in XNA'/><author><name>Belal</name><uri>http://www.blogger.com/profile/09157670058713428098</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxNjKO7sGCMe544TPpVeRDoNN5EdyzmI_9MQRaEpywI4Aa5MZWeEtUKrqbvBBbpd7CQVOGtnrfZOP7KNtt5rxSYV1CnVW0iqHEBMLmzm7IJNh2c7g4nPO0wS68A6zoKFisI_c_Prds5P8/s72-c/spherexna.jpg" height="72" width="72"/><thr:total>11</thr:total></entry></feed>