Sauerworld Forum

Sauerbraten Talk => General Chat => Topic started by: Salatiel on September 18, 2019, 08:08:47 PM

Title: How to generate 3D geometry based on a heightmap image
Post by: Salatiel on September 18, 2019, 08:08:47 PM
Hello, a few months ago I posted here a tool called IMTOC ( ), which lets you convert images into .cfg files and run them ingame, and recently I tried to create "3D" images using the pixel brightness to determine the height of the cube, and it ended up working very well:


This is really simple to do, as long as you have the movesel command installed on your client, below are the steps you can follow:

First you need to modify your client with a new function (movesel), and then add another common script to your autoexec.cfg (autodraw.cfg).

Things you only need to do once:
1- add the movesel command to your sauerbraten/src/engine/octaedit.cpp file

2- run the autodraw.cfg script: (you can paste it on your autoexec or something like that).

Things you need to do for each image:
1- resize your (heightmap) image to a less exaggerated size, if your image resolution is too good, the process can take minutes, and you don't want it. I usually use 100 pixels (100 cubes).

2- upload your image to IMTOC


3- once the conversion is complete, download the .cfg file that IMTOC sent you, and place it in your sauerbraten root folder.

4- ingame, run your image's cfg file /exec imagename.cfg

5- go to the middle of the map, or an area that you think your image will fit, and run the command /autodraw.


And that's it, your "3D image" will start to be drawn. The autodraw command has 2 extra arguments to turn alpha on/off and to define which color will be considered alpha.

/autodraw <bool> <string>
for example: /autodraw 1 "0xFF0000", the red color will be ignored.

This is all possible thanks to the movesel command, be sure to ask eihrul to add this function (movesel) to sauerbraten's SVN, so in the future we won't need to modify the client to achieve this result.  ::)

I know this would be extremely faster to do using some other C++ function and some magical lib for image processing, but I have no experience to put this into practice, so I am sharing the alternative and simpler way to do it.

Have fun and let me know what you think!
Title: Re: How to generate 3D geometry based on a heightmap image
Post by: TristamK on November 02, 2019, 09:04:32 AM
Damn. Pretty interesting thing. But there a few reasons why i can't use it
1) I don't know how to use it for race (pekaface.jpg) . Atleast i  don't have ideas except for something which can me merged with arC's colorful scripts.
2) And? which is more important, i need to compile it and i didn't want to do it. ¯\_(ツ)_/¯  At Least i don't know when i compiled something last time. Isn't there any clients which have this function build in?