<?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: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-7823330869601911934</id><updated>2011-08-08T16:34:19.214+03:00</updated><category term='LoD'/><category term='performance'/><category term='quadtree'/><category term='algorithm'/><category term='texture coordinates'/><category term='texture buffer'/><category term='schema'/><title type='text'>Yet another galaxy</title><subtitle type='html'>This blog is dedicated to my project. It's goal to make a game, i nice game that a lot of person is waiting for. A game that has changed the way of a space flight simulator you know. It was Elite.
In future I want to make something even more. Endless universe, planetary flights, bargaining, salvaging, mining and etc.
Wish me luck :)</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>17</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-7896115961928467453</id><published>2010-11-11T11:42:00.001+02:00</published><updated>2010-11-11T11:42:14.121+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='LoD'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><title type='text'>Quad isn't the best?</title><content type='html'>&lt;p&gt;While reading some articles over the internet I am deeply starting to thing, that the quad-based LoD algorithm wasn't the best idea. I think so mainly because using such technique on a rather flat surfaces I still will have a lot of unneeded detail.&lt;/p&gt;&lt;p&gt;To demonstrate what I mean, I have found some pictures on the internet.&lt;/p&gt;&lt;p&gt;&lt;img style="float: left;" title="turner_05a.gif" src="http://lh3.ggpht.com/_PZ1vnwKATzs/TNu6b_gE-nI/AAAAAAAAAG8/bU5xwkqPLTA/turner_05a.gif?imgmax=800" border="0" alt="turner_05a.gif" width="130" height="119" /&gt; The picture to the left illustrates something like a hill near the flat ground. The hill itself is more "extruded" from the surface, and it needs more vertexes to represent all it's slopes and caves. It's more logical to add extra detail to the hills, and do not extra detail where the area is completely flat. This is the algorithm I need to implement if I want more complex terrain look more natural. This algorithm is called Optimally Adapted Meshes (OAM).&lt;/p&gt;&lt;p&gt;&lt;img style="float: left;" title="turner_05c.gif" src="http://lh5.ggpht.com/_PZ1vnwKATzs/TNu6c8S-10I/AAAAAAAAAHA/MskIjbXWX94/turner_05c.gif?imgmax=800" border="0" alt="turner_05c.gif" width="130" height="117" /&gt;Unlike previous picture, this one exactly represents the technique I use at the moment. It can be seen with naked eyes that there are way more vertexes used on the areas, where you actually do not need them.&lt;/p&gt;&lt;p&gt;The OAM algorithm, or it's implementation to visualize terrains in realtime (Real-time Optimally Adapted Meshes, or ROAM) uses a height map to determine for each vertex it's error value - the heights around it so see if the area around it is flat or it needs more detail. Based on error value it determines where the extra detail should be added and where it's ok to leave the same amount of vertexes at the moment.&lt;/p&gt;&lt;p&gt;I also need to think in parallel the scaling problem, and implement it inside.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Roam info &amp;amp; papers: &lt;a href="http://www.gamasutra.com/view/feature/3188/realtime_dynamic_level_of_detail_.php?page=1"&gt;1&lt;/a&gt;, &lt;a href="http://www.flipcode.com/archives/ROAM_Implementation_Optimizations.shtml"&gt;2&lt;/a&gt;, &lt;a href="http://www.cognigraph.com/ROAM_homepage/"&gt;3&lt;/a&gt;, &lt;a href="http://vterrain.org/LOD/"&gt;4&lt;/a&gt;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-7896115961928467453?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/7896115961928467453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2010/11/quad-isn-best.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/7896115961928467453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/7896115961928467453'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2010/11/quad-isn-best.html' title='Quad isn&amp;#39;t the best?'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_PZ1vnwKATzs/TNu6b_gE-nI/AAAAAAAAAG8/bU5xwkqPLTA/s72-c/turner_05a.gif?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-8142694992417486540</id><published>2010-11-11T09:42:00.001+02:00</published><updated>2010-11-11T09:43:43.493+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><title type='text'>Glitches</title><content type='html'>&lt;p&gt;I have realized, that something needs to be changed in my code. I did some tests trying to see how program responses to big numbers. I have created a planet with the size exact to Earth's, and tried to fly here and there to see the performance, and then I ran to some unpleasant glitches.&lt;/p&gt;&lt;p&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" title="glitches.png" src="http://lh6.ggpht.com/_PZ1vnwKATzs/TNuerLvqjtI/AAAAAAAAAG0/f2BK-EH0Uk0/glitches.png?imgmax=800" border="0" alt="glitches.png" width="500" height="281" /&gt;&lt;/p&gt;&lt;p&gt;This is taken from the stationary orbit at 1100 km from the surface of the virtual Earth. Strange thing that this artifacts not always appears (maybe I should call them UFO? :) ). It seems that this happens when some other processes run in background and use CPU resources a lot. I haven't tested it on other computers, maybe it's hardware specific.&lt;/p&gt;&lt;p&gt;I also noticed, that memory allocation and garbage collection isn't quite good, because the project constantly drains memory while runs. The problem is in LoD code, definitely.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-8142694992417486540?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/8142694992417486540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2010/11/glitches.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/8142694992417486540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/8142694992417486540'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2010/11/glitches.html' title='Glitches'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_PZ1vnwKATzs/TNuerLvqjtI/AAAAAAAAAG0/f2BK-EH0Uk0/s72-c/glitches.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-7507102598897722099</id><published>2010-10-29T12:51:00.000+03:00</published><updated>2010-10-29T12:51:23.730+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><title type='text'>Scales again</title><content type='html'>I've been thinking a lot about scales recently, once again, and those thoughts driving me nuts slowly.&lt;br /&gt;&lt;br /&gt;Space is a very very very large thing. Our planet is about 6'300 km in radius, that is 12'600 km in diameter, and that is 12'600'000 meters, 8 digits. Assuming one world unit in the close distance is 1 meter of the planet, I have only 100 more sized object to be able to handle in close distance. So if I will be crazy enough to fly close to the sun (so that is should be rendered in real scale), I would have an float overflow because the radius of the sun is abou 110 times bigger, that the Earth's radius. We can ask why do we need such big numbers to store if we are 10 meters from the surface? Well, even if the part of a surface if 10 meters from you, you still have to take in mind that the center point of an asteroidal body is way far away from you and it is needed to make a proper curvature of a planet. To solve this somehow I have only 3 options in my mind:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Store vertex coordinates in doubles and apply exponential space transformations before converting them to floats.&lt;/li&gt;&lt;li&gt;Store vertex coordinates in doubles and cull vertexes that are very far away.&lt;/li&gt;&lt;li&gt;Make up something else.&lt;/li&gt;&lt;/ol&gt;And in my opinion, the only reasonable option is the last one..&lt;br /&gt;&lt;br /&gt;There are couple of planetary engine demos around the web, I wonder how they solve this problem.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-7507102598897722099?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/7507102598897722099/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2010/10/scales-again.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/7507102598897722099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/7507102598897722099'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2010/10/scales-again.html' title='Scales again'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-2083527578688355188</id><published>2010-09-02T19:49:00.000+03:00</published><updated>2010-09-02T19:49:26.501+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LoD'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><title type='text'>When to split &amp; when to combine</title><content type='html'>Today I have almost finished my LoD algorithm. For now I just use simple "divide to 4" technique, and later I will probably use some other, more efficient one, like true ROAM, but for now it's ok.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the heart of it lies one big question - when to split node to add more detail, and when to combine 4 nodes to one, so to remove unneeded detail. My first thoughts were to make some kind of table with the dependency of distance to node to necessary LoD level, but it was rejected soon because of planet sizes, which varies a lot. For example, using this approach my big planets will be less detailed, rather than small ones because of node's size - it will be bigger for big planets.. like the side of a big cube is bigger that the side of a small one.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Then I tried to calculate the ratio between the distance to node and node's size, and this gave a better result.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The idea is simple. First I calculate the factor (F) which equals to distance to node (actually the it's the distance to closest vertex of a node) divided by node's size. Then I analyze this like so:&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;If F is less than some number (Kmin), which means that camera is close to node, then extra detail should be added (the node should be split on 4 smaller nodes).&amp;nbsp;Of course here the check should be added if the detail level is at it's maximum.&lt;/li&gt;&lt;li&gt;If F i greater than some number (Kmax), which means, that camera is far enough from the node, then extra detail should be removed. And of course here the check should be added if the detail level is at it's minimum.&lt;/li&gt;&lt;li&gt;And finally, if F is between Kmin and Kmax - do nothing.&lt;/li&gt;&lt;/ol&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_PZ1vnwKATzs/TH_UQDOutuI/AAAAAAAAAGE/DpevOoPcTJY/s1600/Distance+to+LoD.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_PZ1vnwKATzs/TH_UQDOutuI/AAAAAAAAAGE/DpevOoPcTJY/s320/Distance+to+LoD.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Something like this. In this picture I have chosen Kmin to be 2, and Kmax to be 3, but it's obvious, that this is the place to experiment.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This logic needs to be integrated in the procedure that scans all the quadtree, and decides if the leaf should just be rendered, or divided/combined.&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-2083527578688355188?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/2083527578688355188/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2010/09/when-to-split-when-to-combine.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/2083527578688355188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/2083527578688355188'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2010/09/when-to-split-when-to-combine.html' title='When to split &amp; when to combine'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_PZ1vnwKATzs/TH_UQDOutuI/AAAAAAAAAGE/DpevOoPcTJY/s72-c/Distance+to+LoD.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-3786344158837514700</id><published>2010-08-31T13:58:00.000+03:00</published><updated>2010-08-31T13:58:34.215+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='schema'/><category scheme='http://www.blogger.com/atom/ns#' term='quadtree'/><title type='text'>Deciding what to render</title><content type='html'>For the last two days I was thinking about my quadtree of nodes. Quadtree-based structure is used to store terrain nodes at different level of detail, based on the camera distance to them - more closely is the camera, then more detailed should be terrain. I will later write some text about my quadtree implementation, but for now I want to be detailed in explaining the scheme, which is essential to selecting the quadtree nodes, that needs to be rendered.&lt;br /&gt;&lt;br /&gt;The quadtree consists of 2 core elements - node(s) and leaf(s). As I mentoned before, if a node have no child node(s), then this node is a leaf, and it should be rendered (if visible, but for now I do not make any checks on visibility). Each node may be only in two states: a leaf, or a node with 4 children (in that case such node is called a branch). This is the basics of quadtrees.&lt;br /&gt;&lt;br /&gt;So, the core problem is to decide what quadtree elements needs to be rendered. This means that &amp;nbsp;there should be some kind of procedure, that runs via quadtree's nodes, and decides what to render and what to not.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_PZ1vnwKATzs/THzRcj0YwSI/AAAAAAAAAFc/8V62PL4hLIs/s1600/quadtree+(branches+and+leafes).png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_PZ1vnwKATzs/THzRcj0YwSI/AAAAAAAAAFc/8V62PL4hLIs/s320/quadtree+(branches+and+leafes).png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Lets assume we have a quadtree like this. This quadtree have 3 "level of detail" levels (LoD levels, to be more shortly), and a lot of branches and leaves. Green circles are leaves, and brown ones are branches. Despite the visibility factor it's logical, that every leaf should be rendered, so that we could see the final terrain.&lt;br /&gt;&lt;br /&gt;No matter how deep is the quadtree, the procedure, that finds all leaves in the quadtree so to render them later should scan all the quadtree's levels, and choose only those nodes, that are leaves. It should start from the very top of the quadtree, see if this node has any children. If it has, then "descent" down by one level until it finds the leaf. After the leaf is found it should "ascend" up to check other branches by going down. It should repeat this steps until all elements of quadtree are examined. It is clear, that if we have a rather big quadtree, it will take a lot of time to scan all its elements. Assuming that in this procedure we do not check for leaf's visibility, then yes, it will take some time to scan all the quadtree. Later on, when visibility check will be performed, the amount of nodes, that needs to be checked will decrease a lot. It can be easily understood if we assume that on the picture above, the third node from the left if no visible - then there's no need to scan its children.&lt;br /&gt;&lt;br /&gt;Without visibility checks, the block scheme of such procedure can be the following.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_PZ1vnwKATzs/THzeNzN2avI/AAAAAAAAAF0/7vbcwZq_tTI/s1600/Quadtree+scan+scheme.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" src="http://4.bp.blogspot.com/_PZ1vnwKATzs/THzeNzN2avI/AAAAAAAAAF0/7vbcwZq_tTI/s400/Quadtree+scan+scheme.png" width="347" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Each node have the levelCheck variable, that is by default equals to 0 and is used to store in quadtree the child node number that has been scanned already. If it is equal to 4, that means that on this level we have scanned all children, so we should go up a level. And the lines "this.levelCheck=0" is used to reset the counter after all children of current node are scanned, so that next time when we will need to scan the quadtree, all nodes have this number reset back to zero.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-3786344158837514700?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/3786344158837514700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2010/08/deciding-what-to-render.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/3786344158837514700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/3786344158837514700'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2010/08/deciding-what-to-render.html' title='Deciding what to render'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_PZ1vnwKATzs/THzRcj0YwSI/AAAAAAAAAFc/8V62PL4hLIs/s72-c/quadtree+(branches+and+leafes).png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-2439722092168577071</id><published>2010-08-30T12:33:00.000+03:00</published><updated>2010-08-30T12:33:52.824+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='texture buffer'/><category scheme='http://www.blogger.com/atom/ns#' term='texture coordinates'/><title type='text'>Texture coordinates</title><content type='html'>Last two days I was trying to figure out what are texture coordinates. It's name sounds pretty obvious, but in real code it was confusing for me what exactly are texture coordinates and texture buffer, and how they should be properly defined.&lt;br /&gt;&lt;br /&gt;I have found a nice picture, that have everything to understand once and for all what they are.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_PZ1vnwKATzs/THt6lASGDBI/AAAAAAAAAFE/FehqAEM3v6E/s1600/textCoord.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_PZ1vnwKATzs/THt6lASGDBI/AAAAAAAAAFE/FehqAEM3v6E/s320/textCoord.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;According to OpenGL documentation each texture must have like 2Nx2N for  better memory allocation and computation. Each object's vertex should be “bound”  to some point on the texture so that when the texture is applied to the object,  the graphics card will know how to “wrap” an object with a texture. To do it  properly, the corresponding position of each vertex on a 2d texture should be  defined. This is called texture coordinates, and they should be defined as [0;1]  numbers.&lt;br /&gt;&lt;br /&gt;For example, if we have a 3x3 square mesh, that consists from&amp;nbsp;9 vertices with  any dimensions in 3d&amp;nbsp;(lets say 10 by 10), the scheme of defining texture  coordinates (and texture buffer lately) should be like this (texture coordinates  are always 2d and in range of [0;1] for each vertex):&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_PZ1vnwKATzs/THt6vDsly7I/AAAAAAAAAFM/t5gEQ_QGIzo/s1600/textCoord2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_PZ1vnwKATzs/THt6vDsly7I/AAAAAAAAAFM/t5gEQ_QGIzo/s320/textCoord2.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Black text represent 3d vertex coordinates, and red text - 2d texture coordinates.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-2439722092168577071?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/2439722092168577071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2010/08/texture-coordinates.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/2439722092168577071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/2439722092168577071'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2010/08/texture-coordinates.html' title='Texture coordinates'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_PZ1vnwKATzs/THt6lASGDBI/AAAAAAAAAFE/FehqAEM3v6E/s72-c/textCoord.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-6406644268603247317</id><published>2010-03-10T09:19:00.003+02:00</published><updated>2010-08-30T20:43:33.634+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><title type='text'>Wierd things</title><content type='html'>Last night at about 1 a.m. I was trying to put some tests to reveal the difference in calculating floats and doubles. The idea was simple - fix a time when the test stars, put in a loop for 1 million times some equations like multiplying and finding a square root of the number, and then fix the end time so do subtract it from the start time.&lt;br /&gt;&lt;br /&gt;In first test floats were used. The number like 123456.78 was multiplied, divided, square rooted and etc. for fixed amount of iterations. And then, using doubles (big numbers from previous post) the same type of test was performed.&lt;br /&gt;&lt;br /&gt;I was shocked that rather small float numbers had a higher results than doubles!&lt;br /&gt;&lt;br /&gt;This is truly the result that let me think more closely to use doubles instead of floats without any doubts regarding performance.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-6406644268603247317?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/6406644268603247317/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2010/03/wierd-things.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/6406644268603247317'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/6406644268603247317'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2010/03/wierd-things.html' title='Wierd things'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-8309842527684011210</id><published>2010-03-09T16:05:00.001+02:00</published><updated>2010-03-09T16:07:42.759+02:00</updated><title type='text'>Matter of scale</title><content type='html'>Yesterday I was thinking more closely about numbers to understand the scales of the star system(s), and ways to deal with them.&lt;br /&gt;&lt;br /&gt;I started from understanding how far is the distance from our Sun to the last planet. According to Wikipedia, the Neptune is about 30 AU (astronomical units. 1AU = 149’597’871 kilometers, or 92’960’000 miles). Objects of &lt;a href="http://en.wikipedia.org/wiki/Kuiper_belt"&gt;Kuiper belt&lt;/a&gt;, or so called trans-Neptunian objects, may be placed at the distance not far from 55 AU in their average radius, and it consists mostly from small objects, like asteroid belt. The biggest body of Kuiper belt is Eris, which has 97 AU in aphelion and 37 AU in perihelion. Beyond Kuiper belt lies &lt;a href="http://en.wikipedia.org/wiki/Oort_cloud"&gt;The Oort cloud&lt;/a&gt; - a hypothesized spherical cloud of comets which may lie roughly 50’000 AU, or nearly a light-year, from the Sun. Oort cloud consists from asteroids, space dust and comets.&lt;br /&gt;&lt;br /&gt;So, for the star like our Sun (G2 star), which has a mass of 1.9+E30kg. the distance from its center to the farthest object could be around 1’000 AU, or about 1.49+E11km. A thousand AU came from the idea that if I want to make project close to reality, I may close my eyes on every and very far object in the star system, but, never the less, make enough space to model some really far objects. My guess is that this number can easily be divided even 10 times, and it will be more than enough, and later I will use the number of 100 AU for the stars like our Sun.&lt;br /&gt;&lt;br /&gt;But! According to &lt;a href="http://en.wikipedia.org/wiki/O-type_main_sequence_star"&gt;this&lt;/a&gt; nice article, O-class stars may have mass from 15 to 90 times more, than the mass of the Sun. Taking in account the dependency of gravity force from objects mass by Newton’s law, such big stars will have the same about of gravitational force at the distance of square root of mass. So, if the mass is 90 times bigger, then the distance will be a bit more less than 10 times.&lt;br /&gt;&lt;br /&gt;With all that in mind, I need to be able to operate with the distances of 1’000 AU for a single star. &lt;br /&gt;&lt;br /&gt;According to &lt;a href="http://en.wikipedia.org/wiki/Binary_star"&gt;Wikipedia&lt;/a&gt;, almost half of the stars in our galaxy are systems of two stars, or  binary star systems, where 2 stars floats around their center of mass. It is written there that some binary systems may have more suitable conditions for planet formation, rather than single stars may have. &lt;br /&gt;&lt;br /&gt;But let’s fantasize a bit and assume that even star systems with 3 or 4 stars may have a condition to form planets (stable or not), and to be able to make and fly around such star system I will need, let’s say the double space I have calculated.&lt;br /&gt;&lt;br /&gt;So, 2’000 AU will be enough for any condition and any star in my virtual galaxy. And it is equal to 299’195’742’000 km, in every direction from the star system center. That is a HUGE space. By the way, if I move with the speed of light (which is equal to 299’792 km/sec.) I will need about 693 days, or almost 2 years to travel from the center of star system to its boundaries. But why should I worry? I have a hyperspace drive, haven’t I? :)&lt;br /&gt;&lt;br /&gt;If I want to have a precision of 1 meter in my project, I will need to be able to operate with the numbers from -2.99+E14  to +2.99+E14, which can perfectly be held by double precision floating points. But dealing with doubles every time with every object may significally decrease the performance.&lt;br /&gt;&lt;br /&gt;I came up with idea of so called local space and global space to, probably, solve performance issues I might have, if I use doubles everywhere. The idea is to render/calculate everything using global scale units when player’s cam isn’t near any global object of star system (global units have a precision of, let’s say 10000 km), and switch to local (coordinates), when player’s cam enters some certain region near any global space object, for example planet. If we assume that each space body has its global coordinates, then local space would be bounded and centered to the current position of the body.&lt;br /&gt;&lt;br /&gt;Switching back and forth from global to local coordinates should probably spare some CPU power and give me necessary precision.&lt;br /&gt;&lt;br /&gt;I should post some more thoughts on this idea later.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-8309842527684011210?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/8309842527684011210/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2010/03/matter-of-scale.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/8309842527684011210'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/8309842527684011210'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2010/03/matter-of-scale.html' title='Matter of scale'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-7661836484152389658</id><published>2010-03-08T16:07:00.002+02:00</published><updated>2010-03-08T16:35:49.311+02:00</updated><title type='text'>Core object scheme and hierarchy</title><content type='html'>Today I was thinking more closely to the overall object hierarchy of the entire project. As well as the bodies in our solar system “attached” to theirs “parent” bodies (like the moon is a “child” of our Earth, it goes around the Earth, and Earth goes around the Sun), and all the space bodies goes around the Sun, my structure tries to stay closer the same hierarchy.&lt;br /&gt;&lt;br /&gt;The scheme of object hierarchy can be seen below. Of course, I believe I will modify it in time due to some new ideas, but the core idea should look that way.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_PZ1vnwKATzs/S5UK6_KgIuI/AAAAAAAAAE8/iKFma23gn9I/s1600-h/scheme_big.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 275px;" src="http://3.bp.blogspot.com/_PZ1vnwKATzs/S5UK6_KgIuI/AAAAAAAAAE8/iKFma23gn9I/s320/scheme_big.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5446271332878656226" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Basically almost every entity on this scheme has a name of “factory”, and it’s pretty self-explanatory. Each this entity handles the generation of the named object in the space, stores it’s parameters and handles some object routines.&lt;br /&gt;&lt;br /&gt;For example, PlanetFactory is responsible for generating the planet body with all the stuff, that planet consists of, like surface (that’s been generated by PlanetSurfaceFactory), water (PlanetWaterFactory) or whatever liquid the planet may have, sky (PlanetSkyFactory), and maybe some more later (RiverFactory, CityFactory, etc.). Therefore PlanetFactory is a child to PlanetarySystemFactory – class, that is responsible for processing all the bodies, including the planet itself, that orbits around, let’s say, the center of mass of the planet – Planet itself, planet moons, celestial bodies like Saturn rings, asteroids, debris… If we go higher, there is a SolarSystemFactory, and, as you can guess already, stores and processes all space bodies of the star system, including the star itself, planets, asteroids and asteroid belts, comets and all others.&lt;br /&gt;&lt;br /&gt;The scheme looks good and logical for me, and I will definitely try to follow it. Next step will be to define common variables and procedures for each node of the scheme.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-7661836484152389658?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/7661836484152389658/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2010/03/core-object-scheme-and-hierarchy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/7661836484152389658'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/7661836484152389658'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2010/03/core-object-scheme-and-hierarchy.html' title='Core object scheme and hierarchy'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_PZ1vnwKATzs/S5UK6_KgIuI/AAAAAAAAAE8/iKFma23gn9I/s72-c/scheme_big.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-4498329821285884215</id><published>2010-03-08T09:54:00.003+02:00</published><updated>2010-03-08T16:37:20.584+02:00</updated><title type='text'>Long-awaited update</title><content type='html'>It’s been a while since I have posted the last message. A lot of thing have changed and a lot of has been redone. It’s a pity that it is now 4th rework on the simple node tree flow, but because I find it essential to the whole project, I think it’s best to find the right solution first, and then continue to make other things.&lt;br /&gt;&lt;br /&gt;I have now switched back to Java Monkey Engine due to simplicity of coding from all my platforms that I work on every day. The experience with Ogre3d engine in that area wasn’t very good from the perspective of switching the development platform each day due to the fact that in my work time, I like to put the work away and return to the project, if I have some ideas I want to try. And in that time I work under windows. And at home I have my beautiful iMac with MacOS X in it, of course. Switching back to jME took away the problem of reconfiguring the project settings for each platform each time I put the code written form windows to mac, and vice versa. I know that it’s solvable and my lack of knowledge in that area gives me pain, but for now, it’s better for me to stay with jME to avoid them. Anyway, if you understand the problem completely (and for now, understanding the routines to handle trees for planet surface rendering is the problem), it isn’t very hard to switch to another engine in future.&lt;br /&gt;&lt;br /&gt;At the moment I have completely decided what scheme is better for my needs of creating and handling the planet surface, and it’s ROAM. I do not remember whether I posted the link to the ROAM PDF paper or not, but I will do it now anyway. So, here’s the &lt;a href="https://graphics.llnl.gov/ROAM/roam.pdf"&gt;link&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Why ROAM is good? Well, the best way to see it is to define how I want the planet surface to be born and handled. I have found the following scheme the best:&lt;br /&gt;&lt;br /&gt;1. Using complex procedural algorithms generate a planetary map (the vision of what the planet will look like with all the coasts, mountains, valleys, etc.) that later can be modified to add crates, rivers, cliffs, and many more.&lt;br /&gt;2. Using the same algorithm make a height map.&lt;br /&gt;3. Make a spherical planet body and apply map to it.&lt;br /&gt;4. Using altitude as the parameter, adjust the height of the planet mesh, and add extra geometry when we approach closer to surface. This means that form space you will see a bump mapped sphere, and as you get closer to surface, the surface will slowly and smoothly change to reveal all the “heights”.&lt;br /&gt;&lt;br /&gt;For that scheme I find ROAM is a perfect choice. Later on I will post some updates on the node and tree routines.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-4498329821285884215?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/4498329821285884215/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2010/03/its-been-while-since-i-have-posted-last.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/4498329821285884215'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/4498329821285884215'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2010/03/its-been-while-since-i-have-posted-last.html' title='Long-awaited update'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-6521356765645180963</id><published>2009-10-08T22:21:00.001+03:00</published><updated>2009-10-08T22:21:45.974+03:00</updated><title type='text'>Completely new node class</title><content type='html'>During my last days I've been working on implementing new class for my nodes. I took the conception to make each node not 1 by 1 quad, by n by n quads. This means that each my node will consist of n by n nodes (16x16 for example). After the node is being created, it's transformed into a single mesh and then attacked to the scene. The reason for this was bad frame-per-second rate with previous ways, because each frame each my quad was send to GPU for rendering. And because of huge amount of quads, each sending  slowed down the performance. GPU can handle complex meshes very fast if sent to GPU as a single mesh.&lt;br /&gt;&lt;br /&gt;So, by rewriting the Node class to this new approach, the fps increased more than 100 times! Now that's what I call HUGE :)&lt;br /&gt;&lt;br /&gt;Also, the node's constructor allows now to set the desired amount of quads on each side. The example below shows the cube with 128x128 quads on each cube's face.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align:center;"&gt;&lt;img src="http://lh6.ggpht.com/_PZ1vnwKATzs/Ss47n8twk4I/AAAAAAAAAEo/f273EdR6YeA/SimpleGameScreenShot.png?imgmax=800" alt="SimpleGameScreenShot.png" border="0" width="436" height="327" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;And with this one it's still over 150 frames per second.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-6521356765645180963?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/6521356765645180963/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2009/10/completely-new-node-class.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/6521356765645180963'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/6521356765645180963'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2009/10/completely-new-node-class.html' title='Completely new node class'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_PZ1vnwKATzs/Ss47n8twk4I/AAAAAAAAAEo/f273EdR6YeA/s72-c/SimpleGameScreenShot.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-8128617693919589753</id><published>2009-10-05T13:11:00.001+03:00</published><updated>2009-10-05T13:11:07.190+03:00</updated><title type='text'>Performance issues and ideas</title><content type='html'>It seems that performance issues are caused by too many nodes attached to the rootNode manager (the one that handles all the geometry in the scene). I  have asked the question on the forum (&lt;a href="http://www.jmonkeyengine.com/forum/index.php?topic=12224.0" target="_blank"&gt;here&lt;/a&gt;) and there were some solutions gives, as well as some ideas made up in my mind.&lt;br /&gt;&lt;br /&gt;Well, one way is to somehow lower the amount of custom nodes while saving the same amount of triangles in the scene. This can be done if I make a constant mesh from many nodes and only then add it to the rootNode manager. So I have to write a procedure that reads all my quad tree, finds all nodes that have to be rendered (i.e. are leafs) that are on the same level in my quad tree, and makes a constant mesh (TriMesh to be exact by java terminology) and then pass it to the scene manager. And that for all tree levels.&lt;br /&gt;&lt;br /&gt;Another thought that I had was related with splitting. In my previous posts I mentioned that according to my splitting procedure the quad splits on 4 smaller. In future the idea was to split the quad if camera is close o it so to add more detail. But splitting only one segment each time won't add much of a nice picture, imho. I think I need to "split" quads for some segment bigger than one parent quad. That way adding more detail won't be so.. mmm... so rude, maybe. Somehow like &lt;a href="http://www.youtube.com/watch?v=jUfkH7pvV9U&amp;NR=1" target="_blank"&gt;this&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;So, I believe I will focus on this.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-8128617693919589753?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/8128617693919589753/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2009/10/performance-issues-and-ideas.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/8128617693919589753'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/8128617693919589753'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2009/10/performance-issues-and-ideas.html' title='Performance issues and ideas'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-1486406917148076515</id><published>2009-10-01T23:35:00.001+03:00</published><updated>2009-10-01T23:35:57.889+03:00</updated><title type='text'>Cube to Sphere mapping</title><content type='html'>Whooah...&lt;br /&gt;&lt;br /&gt;Finaly I have managed to solve all bugs in my way to map coordinates for each vertex from primary cube so to form a sphere. Planet should look like a sphere, because nobody likes cubic planets :)&lt;br /&gt;&lt;br /&gt;The main equations for transforming coordinates of cube to spherical are the following:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align:center;"&gt;&lt;img src="http://lh6.ggpht.com/_PZ1vnwKATzs/SsUO-iYCiwI/AAAAAAAAAEc/a2bfrsguEjQ/9C401787-51AE-4B7D-BDD8-0D5BD4B522FE.jpg?imgmax=800" alt="9C401787-51AE-4B7D-BDD8-0D5BD4B522FE.jpg" border="0" width="280" height="124" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;For that reasons I have made a "final" class called c_MyMath for keeping all the future equation functions there.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align:center;"&gt;&lt;img src="http://lh5.ggpht.com/_PZ1vnwKATzs/SsURxbCi1vI/AAAAAAAAAEg/SSNAnvwBB_c/HelloWorld.png?imgmax=800" alt="HelloWorld.png" border="0" width="356" height="368" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;After a bit of testing I found that it was a bad idea to store spherical coordinates of each vertex multiplied by planetary scale factor (the radius of the planet) because while doing scaling in the node's constructor, I needed to take care of scaling during quad splitting also. I thought it's whatever if I do the scaling for each vertex in the constructor and in splitting procedure, and doing it just before the prerender function, which finds all the quads that should be rendered and then apply the scaling. I understand that it's better to handle everything from the start (not just before th rendering) but for now I have decided to leave things as they were.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align:center;"&gt;&lt;img src="http://lh6.ggpht.com/_PZ1vnwKATzs/SsUSHWd_jOI/AAAAAAAAAEk/Y4RqXfxLBcE/HelloWorld-1.png?imgmax=800" alt="HelloWorld-1.png" border="0" width="328" height="323" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now the protoplanet looks finally like a sphere!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-1486406917148076515?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/1486406917148076515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2009/10/cube-to-sphere-mapping.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/1486406917148076515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/1486406917148076515'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2009/10/cube-to-sphere-mapping.html' title='Cube to Sphere mapping'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_PZ1vnwKATzs/SsUO-iYCiwI/AAAAAAAAAEc/a2bfrsguEjQ/s72-c/9C401787-51AE-4B7D-BDD8-0D5BD4B522FE.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-4738533672367540659</id><published>2009-10-01T14:58:00.001+03:00</published><updated>2009-10-01T14:58:14.035+03:00</updated><title type='text'>Dealing with quadtrees 3: The cube</title><content type='html'>I have managed to draw a single quad on the window, and make split algorithm work properly. It uses parent quad's vertex coordinates and makes new 4 quads and calculates it's vertex coordinates.&lt;br /&gt;&lt;br /&gt;I have realized, that basically I need to store in some king of list all my new quads, and later on I also need to make a procedure (at the moment just a simple one) that looks through this lists and makes another one, containing only leafs - quads that have to be rendered.&lt;br /&gt;&lt;br /&gt;To store it I used LinkedList class. Very useful.&lt;br /&gt;&lt;br /&gt;I needed to make a cube that consist of 6 quads (6 sides) at the moment of creation. The problem was that by defining a tree (as it should be defined) it should have only one root (quad, or whatever). By making 6 sides, I basically create 6 roots, and I was afraid that I will have problems later when I will have to make some kind of procedure, that will need to find all quads that have to be rendered, because that way I will need to call it for each 6 primary quads. The solution with lists I found quite resultive.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align:center;"&gt;&lt;img src="http://lh6.ggpht.com/_PZ1vnwKATzs/SsSWNhjfazI/AAAAAAAAAEU/-FeXIdpyuQM/HelloWorld.png?imgmax=800" alt="HelloWorld.png" border="0" width="340" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This is the result of primary cube. At the moment I have decided to draw cube so that it's center is in the (0;0;0) and vertexes have by default +1 or -1 in all direction, multiplied by scale factor. Later on I will have to add algorithm that could place the cube in any coordinates so that all formulas stay consistant and correct. But that will be later.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align:center;"&gt;&lt;img src="http://lh4.ggpht.com/_PZ1vnwKATzs/SsSXqkgZqKI/AAAAAAAAAEY/IaB1VDyD1so/HelloWorld-1.png?imgmax=800" alt="HelloWorld-1.png" border="0" width="340" height="347" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This is the result of splitting the primary cube 3 times (6 sides times 4^3 gives 384 quads).&lt;br /&gt;&lt;br /&gt;By now it works, by the framerate results doesn't make me happy, because by dividing the prime cube 5 times gives only 20 fps and that's odd.&lt;br /&gt;&lt;br /&gt;Next step will be finding out why the hell fps are so small :) and second make a sphere out of cube - it should be spherical planet, not cube like :)&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-4738533672367540659?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/4738533672367540659/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2009/10/dealing-with-quadtrees-3-cube.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/4738533672367540659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/4738533672367540659'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2009/10/dealing-with-quadtrees-3-cube.html' title='Dealing with quadtrees 3: The cube'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_PZ1vnwKATzs/SsSWNhjfazI/AAAAAAAAAEU/-FeXIdpyuQM/s72-c/HelloWorld.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-7938764853774906282</id><published>2009-09-29T13:49:00.002+03:00</published><updated>2009-09-29T13:54:35.534+03:00</updated><title type='text'>Dealing with quadtrees 2: Points</title><content type='html'>&lt;p&gt;Continuing to make a quadtree. Next step is to understand the splitting process. In simple words I need to split a parent quad on to 4 small quads with proper coordinate for each vertex of the each child node.&lt;/p&gt; &lt;a href="http://lh3.ggpht.com/_PZ1vnwKATzs/SsHmP60e7SI/AAAAAAAAADM/NXb7XbK2KKk/s1600-h/LOD%5B20%5D.png"&gt;&lt;img title="LOD" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="300" alt="LOD" src="http://lh3.ggpht.com/_PZ1vnwKATzs/SsHmQJn10aI/AAAAAAAAADU/e76MFtZVXgg/LOD_thumb%5B18%5D.png?imgmax=800" width="420" border="0" /&gt;&lt;/a&gt;   &lt;p&gt;To understand the concept I took a very simple quad with coordinates from (0;0;0) to (1;1;0). It’s frame and numbers are black on the screenshot. It has 4 points:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Point 0 - (0;0;0) &lt;/li&gt;    &lt;li&gt;Point 1 - (0;1;0) &lt;/li&gt;    &lt;li&gt;Point 2 - (1;0;0) &lt;/li&gt;    &lt;li&gt;Point 3 - (1;1;0) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Because of jME &lt;a href="http://www.jmonkeyengine.com/wiki/doku.php?id=trimesh&amp;amp;s[]=trimesh" target="_blank"&gt;tutorial page&lt;/a&gt; about drawing vertices has algorithm, that draws quad as two triangles exactly the same way (coordinates) as I mentioned before (like from point 0 to 3) I used the same concept here, but later on I have found that in my draft papers I have mistaken X coordinate with Y. That gave me that the point #1 is under point #0, but in reality it point #1 should be from the right from point #0. But actualy that was not important :) &lt;/p&gt;  &lt;p&gt;As it can be seen from the picture, 4 child quads are numbered the same way as points (although as I have mentioned that isn't quite right, but it works), and in the table I wrote coordinates for each point of each child just as I see them.&lt;/p&gt; &lt;a href="http://lh3.ggpht.com/_PZ1vnwKATzs/SsHnPRnk9PI/AAAAAAAAADw/4f3FvpagnXI/s1600-h/coords%5B4%5D.png"&gt;&lt;img title="coords" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="351" alt="coords" src="http://lh6.ggpht.com/_PZ1vnwKATzs/SsHnP6UB-_I/AAAAAAAAAD0/mmiIFi3D5Fs/coords_thumb%5B1%5D.png?imgmax=800" width="404" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-7938764853774906282?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/7938764853774906282/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2009/09/dealing-with-quadtrees-2-points.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/7938764853774906282'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/7938764853774906282'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2009/09/dealing-with-quadtrees-2-points.html' title='Dealing with quadtrees 2: Points'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_PZ1vnwKATzs/SsHmQJn10aI/AAAAAAAAADU/e76MFtZVXgg/s72-c/LOD_thumb%5B18%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-4674173744144050189</id><published>2009-09-28T15:03:00.004+03:00</published><updated>2009-09-28T15:25:23.166+03:00</updated><title type='text'>Dealing with quadtrees (part 1)</title><content type='html'>&lt;div&gt;My next step is to deal with quadtrees.&lt;/div&gt;&lt;div&gt;Best described in wiki, quadtree is:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;..is a tree data structure in which each internal node has up to four children.&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Imagine a plane, that consist of a single quad only. If we move closer to it, and we want to add more detail, we need to split this quad (so it become more detailed). Because the name of quad speaks for itself, the best way to split is to divide it on 4 small quads. If we had one quad before (called root or branch), these 4 new quads will become children (or leafs) of the previous quad.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, the quadtree is a structure, that holds "branches" and their leafs (if any). Each branch may have 4 children or 0 children. The node that do not have any children called "leaf", all others are branches. Quite simple, isn't it? You may look also &lt;a href="http://www.gamedev.net/reference/articles/article1303.asp"&gt;here&lt;/a&gt; for more detailed explanation if you haven't caught something.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So my first task is to "make" a test quad and then try to split it. The main problem that anyone can encounter is to calculate all points of child nodes correctly.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-4674173744144050189?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/4674173744144050189/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2009/09/dealing-with-quadtrees-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/4674173744144050189'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/4674173744144050189'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2009/09/dealing-with-quadtrees-part-1.html' title='Dealing with quadtrees (part 1)'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7823330869601911934.post-5542360192221873387</id><published>2009-09-25T12:34:00.003+03:00</published><updated>2009-09-25T13:09:52.352+03:00</updated><title type='text'>Blog to keep everything in mind</title><content type='html'>This is the first post.&lt;div&gt;I have opened this blog for 2 reasons.&lt;/div&gt;&lt;div&gt;First, somebody might find the info described here useful.&lt;/div&gt;&lt;div&gt;Second, I will try to put this information for myself to remember everything and practice a bit in writing useful information.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now, it's time to tell what exactly I am planning to achieve. Some may remember the game called Elite. One feature of this game that truly inspired me is that it has almost unlimited space to fly to. The universe has number of stars almost the same as real universe, and all of them are created using pseudo random sequence of data.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Next feature is that player have an ability to fly not only in space, but fly close to planet surface, and even land on it. The way how space body can be seen with quite a rich resolution when you approach closer to it is done, using techniques called "Level of Detail", or LOD. LOD algorithms add on the fly more detail to the mesh as you approach closer to it. You might want to &lt;a href="http://en.wikipedia.org/wiki/Level_of_detail"&gt;read more&lt;/a&gt; about it on the wiki.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, my start point is to make an LOD algorithm. As to the engine itself, I have chosen &lt;a href="http://jmonkeyengine.com/"&gt;jME&lt;/a&gt; engine so to be really cross-platform, but maybe I will have to switch to &lt;a href="http://www.ogre3d.org/"&gt;OGRE&lt;/a&gt; rendering engine in the future. There are several issues why maybe I will have to switch to OGRE, and main of them are that OGRE have already some nice addons to handle water and sky. We'll see.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7823330869601911934-5542360192221873387?l=yagsteps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yagsteps.blogspot.com/feeds/5542360192221873387/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yagsteps.blogspot.com/2009/09/blog-to-keep-everything-in-ming.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/5542360192221873387'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7823330869601911934/posts/default/5542360192221873387'/><link rel='alternate' type='text/html' href='http://yagsteps.blogspot.com/2009/09/blog-to-keep-everything-in-ming.html' title='Blog to keep everything in mind'/><author><name>Vadim</name><uri>http://www.blogger.com/profile/01120900142800447591</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
