P-152: Virtual World Concept Update 119: MS1 Complete!
I have finally finished MileStone 1 of the spherical terrain project.
I fixed the texturing issue by simply making the minimum and maximum height ranges relative to the distance between the origin of the planet and the X,Y and Z position of each point in the render list, this worked for each of the six faces of the terrain.
I also found, and fixed, a major bug with the generation of vertices for the initial heightfield. This bug was causing ugly graphical effects at the seams between the six faces of the terrain, and was caused by modification that I made previously to the algorithm that generates those points.
I also did extensive work to optimise the code. At one point, I had 14,000 lines of code in the main sphericalterrain.cpp file! This was mostly redundant code from attempts that didn’t work, and debugging information, which I had left in the file. I removed all of this some time ago, and got down to about 2,500 lines of code. I am now at 1,754 lines, which is a huge reduction. I have removed a lot of redundant and unnecessary code from the codebase, which resulted in this reduction. I probably haven’t increased the execution time very much, since most of the unoptimised code was in the setup and initialisation functions, not the render loop, but I definitely made things a lot cleaner.
There is still a lot of work to be done in future milestones, including some fairly fundamental changes to the structure of how the code actually works. Currently, I am generating a low resolution heightfield, and storing it as a list of points. This is done at load time. In the render loop, each tick, I am filling a quadtree with that heightfield, and then subdividing it if necessary. This means that the low-resolution heightfield is being added to the quad tree each tick, which isn’t needed. A smarter way would be to load the heightfield into a quadtree (of whatever depth was necessary to store the heightfield), and then simply copy this quadtree in the render loop, to form a new quadtree which can be subdivided as I am currently doing. This should make the all-important render loop faster, although probably not all that much, the heightfield is of very low resolution, and even populating a tree with it every tick wouldn’t take very long.
The main goals for MS2 will the the SkySphere, The Collision system upgrades (support for precipitation, ground cover, AI and environment objects, etc) and the WaterSphere. I will probably leave the scaling of the terrain to a realistic planet size to MS3. I expect to start working on MS2 as early as the end of next month, after I finish P-167.
This picture is one of my favourites from the final day of testing MS1. I think it sums up what I have achieved quite well. The reason the skybox is upside down is because the player is standing “upside down”. The modification that I made to the gravity in T3D allow the player to walk all around the surface of the spherical terrain without issue.

01/05/2016 , 01:21:20 AM
Torque 3D MIT – P152
The images below show the results of MS1 in greater detail. I think the resolution is quite good, but the terrain can be optimised easily for high detail or fast rendering, so I could have gone for even better looking terrain if I wanted to take a performance hit, or I could have reduced the quality (for a flight sim, for example) and sped up the rendering.

01/05/2016 , 01:29:44 AM
Torque 3D MIT – P152

01/05/2016 , 01:29:49 AM
Torque 3D MIT – P152

30/04/2016 , 11:59:35 PM
Torque 3D MIT – P152

01/05/2016 , 12:48:11 AM
Torque 3D MIT – P152

30/04/2016 , 12:17:32 AM
Torque 3D MIT – P152

30/04/2016 , 12:18:47 AM
Torque 3D MIT – P152

30/04/2016 , 12:19:05 AM
Torque 3D MIT – P152
P152_DEBUG
30/04/2016 , 12:13:45 AM
Torque 3D MIT – P152

30/04/2016 , 12:19:56 AM
Torque 3D MIT – P152

30/04/2016 , 12:20:29 AM
Torque 3D MIT – P152

30/04/2016 , 12:20:36 AM
Torque 3D MIT – P152

30/04/2016 , 12:20:46 AM
Torque 3D MIT – P152

30/04/2016 , 12:21:04 AM
Torque 3D MIT – P152

30/04/2016 , 12:21:25 AM
Torque 3D MIT – P152

30/04/2016 , 12:22:04 AM
Torque 3D MIT – P152

