Building Comanche 3D in less than 100 lines of code (UPDATE)

Amazing, Thomas! Your Script doesn’t seem so far from what I tried, only mine was lame and yours is fun! Wonder how you did that. More to dig into …

@Tomas Jakobs Hahahah, nice one! Manhattan city with Voxels. Love it!

Thomas, mind if I ask you some more? From what I‘ve seen so far, the biggest difference in my version is I left the image data in the main window part and declared the main window to be the Script‘s context. You set up a complete independent context and therefore seem to be able to access the voxelheight array and other stuff directly without any bottleneck that I used to encounter.

Is setting up a separate context the way to go or does the magic live elsewhere? I wash‘t aware that XojoScript could be that useful – thanks a lot! Even with profiling on it is still very playable.

@Ulrich: Thank Alain, he’s the one behind this VoxelEngine Masterpiece in Xojo… I’ve only added some eye candy left and right… :slight_smile:

… ehm… better don’t ask me why something is done in this or that fashion… it works!
Guess I am a typical developer forgetting everything as soon as it is typed :wink:

Ha! OK! :smiley:
Thanks for pointing me towards that, whatever may be the fact anyway.
And of course to Alain! Fascinating stuff he uses to come up with!

Alright mates, this evening I could not keep my hands off the copper, again.
THere are some Tweaks everywhere but the biggest improvement is, that the size of maps is unlimited.

I’ve put a really huge Map (10800x10800px) and it works perfectly, only the loading time takes approx 1-2 Minutes.
So I’ve added a Loading Window each time you switch the map.

The map I’ve taken is really huge and represents Europe, North Africa and Middle East.
It’s taken from NASA’s Blue Marple Project is Public Domain as far as I understood the legal terms.

Heck it’s nice to fly across the Alps :wink:

@Sam: Have you found a little time? You are the expert for graphics. We need you! :wink:

Download link:

https://dl.dropboxusercontent.com/u/30535865/xojo/XOJOComancheWithScript.zip

argh… chopper not copper… forgive me please my typos… and I cannot correct my last post… arrgh…

I think some sort of ‘chunk’ system would need to be build for big maps. I don’t know how the FPS is on mac, but your last version compiled only get 2 to 3 FPS. I understand you’re all Apple fans, but don’t forget we want to promote Xojo as a cross compile language :slight_smile:

on windows 2-3 FPS (damn, edit not possible for me too). Maybe our OpenGL master @Alwyn Bester could come up with some of his magic :wink:

Please Check out Var FieldOfDepth, it is still Set to -500 and can be reduced to -400.
yes at this Point 3D accerlation is needed, perhaps DirectX on Win and OpenGL on Mac/Linux? I am Not familiar with this… Time for somebody else…

Yes I think OpenGL would be the best choice, as it can be used on all three platforms. However, this is also out of my scope. It is nice to see all the people intersted in this project. I didn’t expect so many liked old school engines like me. So maybe I’ll tackle BSP trees (binary space partition) engines like in Doom for a next article :slight_smile:

As a fellow developer once said to me, if you’re not willing to write specific code for each platform, how can you consider yourself a cross-platform developer.

Xojo does a lot for us, but sometimes to get the performance needed you gotta go lower.

I’m really busy at the moment with several projects and just moved home. I really want to participate in this project as it looks so much fun.

I also think it would be awesome if the Xojo community could publicly release this, and of course the App Store is where I’m thinking. I’m not thinking to charge for this, just to put it out there and say it’s made with Xojo by everyone who’s contributed.

Let me see what optimisations I might be able to make without platform specific code.

Oh, I’m no expert, just have some experience s’all.

Good Morning Alain you’re famous :slight_smile:
Xojo Inc. posted your Blog on Facebook yesterday, Congrats!

I humbly have to decline the title OpenGL “Master”… and would rather call it OpenGL “enthusiast with lots to learn”. :wink:

OpenGL is possibly a good next step to increase rendering speeds, especially in a cross platform environment.

Currently I’m working on polygon triangulation. Breaking polygons into triangles is one of those problems that sounds so easy and trivial to do, until you start writing the code (been kept busy for days now on this problem). This will still keep me busy for a while, and I also have another tutorial queued thereafter on how to navigate cameras in your 3D scenes with OpenGL.

Once all this is in done, I will definitely come back to these voxel algorithms to take an in depth look at how this could possible be integrated with OpenGL into the X3 engine, in a way to make them (the algorithms) easily re-usable in different projects.

Yes please… you already have a devoted fan waiting to read the article :wink:

Alain, you’re right on windows. The framerate is far from being acceptable, the sounds either and Xojo made an EXE of 158 MB!!!

But as good news: Framerate seems not to be affected by the graphics nor the huge map. It’s the sound only. As first aid I am now checking if sound is still playing before “play” is fired continuously. But I am still not happy about Performance on Windows. I will lay my hands on it later. Maybe I am putting the whole SFX stuff in another thread.

On Mac this doesn’t make any problems and executable file size is much smaller either. :frowning:

I’m in the process of rewriting the originale engine in pure Xojo (not even using Xojoscript) and are getting a huge speed improvement (at least in Windows, not tested in Xojo yet). Update in the next hour.

Here is a new version where I use some techniques of ABXVision to do some fast picture manipulations, not using Xojoscript again but pure Xojo! On windows at least its a huge performance boost. I would even say, playable :slight_smile: The big trick was using memory blocks and pointers.

I’ve used the original project with the ascyn keys and speed options of Tomas included ( @Tomas Jakobs I think it’s probably easier for you to add your neat graphs and HUD updates yourself).

Let me know how it goes on OSX. In my VMWare OSX it want well, but a real one should be better.

P.S. the binaries are also included in the download for those who do not have Xojo available.

http://gorgeousapps.com/ABComancheMB.zip

This is very interesting, mostly because I don’t understand how the voxel algorithm works :slight_smile: I ran several profiles thinking graphics would be the bottleneck but it looks like the voxel math is at least 75% of the time. I only profiled the original project though, maybe the others change this ratio.

So using OpenGL for drawing I don’t think will help much and the voxel math looks fairly tight. There’s a few ways I think will streamline it (only step on the 'i’s within bounds, precompute constant values, use the same number type so there’s less conversion) but those are marginal improvements I think. (oooh, will need to check your new version)

I cracked open an old project for downloading and drawing google elevation data and hacked in your maps. It draws the height field with triangles stored in a display list, haven’t checked fps but it’s very smooth, even with all 102410242 triangles. This completely sidesteps the voxel algorithm though defeating the purpose!

http://home.comcast.net/~trochoid/elev.zip
Run, make fullscreen, click the “init” button and wait.
Camera control is wonky for this…
Mouse drag to swing the camera about the look at point.
Mouse wheel to dolly towards look at point
Option+Mouse drag to slide look at point in current direction
Control+Mouse drag to look around from camera point
Shift+Mouse drag to move in the XZ plane (not adjusted for current heading = confusing)

I like the look of the voxel algorithm and would like to understand it better and make it run faster. There may be a way to do the vxdl math in an OpenGL fragment shader which would be really fast but requires declares to OpenGL.

Wow, impressive stuff Will!