SFML community forums

General => SFML projects => Topic started by: Kalith on July 22, 2011, 02:44:39 am

Title: iCE³ - clone of Minecraft
Post by: Kalith on July 22, 2011, 02:44:39 am
From time to time, I see a game that is inspiring enough for me to either try to re-code them my way or create a new game that is very similar. It recently happened with Minecraft (http://www.minecraft.net/), the fabulous game by Mojang AB (or you could say just Notch).

The concept is simple : you begin the game in a wild cubic world, with a few animals around, mountains, trees and the see. The only tool you have is your bare hands, with which you can destroy most cubes in the world to collect them, and eventually place them wherever you want.
What is the point of the game ? Well, soon enough, the night starts to fall, and monsters appear... At first you can't fight them (unless you're willing to die after earing a *pshhhhh...*), so your only option is to build yourself a house and wait for the sun to return. Then, all monsters will catch on fire and die in a matter of seconds, leaving you alone again in this wide world (~4 times the surface of Earth !).

Very early in the game, you can build some tools using your inventory, torches for example, or a crafting table, which allows you to create many new things (pickaxes, swords, ...). These will help you to discover some new areas of the game, by allowing you to dig fast in the stone, of traveling the seas with a boat.

On top of that, you can play this game on a multi-player server, to build and discover with your friends.

I really like the simplicity of the game, and the vast opportunities it offers.
So I wanted to give it a shot : could I program such a game myself ?

My first priority was performances : currently, I only have a very crappy laptop at my disposal, on which Minecraft runs smoothly only with the lowest graphics options. But it is written in Java, and some even say it is badly written in Java. So that leaves some room for improvements.
On top of that, you can run into memory problems if you're not careful : improving performances implies most of the time to cache calculations to avoid running them on every frame. If you cache too much, you end up using enormous amounts of memory... To give you an idea, Minecraft can display the world up to a distance of 256 blocks, that means roughly 70 000 000 blocks... Assuming 5 bytes per block (which is quite a low number), it sums up to at least 300MB of memory.
As for CPU/GPU performances, I have at least 30 frames per second with a view distance of 250 blocks and smooth lighting enabled (per vertex lighting and ambient occlusion), while Minecraft runs terribly slow with the same parameters (about twice slower).
But again, I'm missing many features of Minecraft, so maybe I've done some optimizations that I won't be able to keep in the future.

I've used SFML for input handling, window and opengl context creation, and 2D drawing for the GUI. I also plan to use it for networking and sound/music later.
zlib is used to compress and decompress the world files to decrease disk usage and bandwidth.
The rest is done using OpenGL directly (not a big deal actually).

Anyway, enough talking, here are the pretty screenshots :
(http://darkdragon1.free.fr/mycraft/Mycraft_001_th.jpg) (http://darkdragon1.free.fr/mycraft/Mycraft_001.jpg)
(don't mind the 8FPS, I had to Alt+Tab to take a screen shot without the mouse on Ubuntu...)
(http://darkdragon1.free.fr/mycraft/Mycraft_002_th.jpg) (http://darkdragon1.free.fr/mycraft/Mycraft_002.jpg)(http://darkdragon1.free.fr/mycraft/Mycraft_003_th.jpg) (http://darkdragon1.free.fr/mycraft/Mycraft_003.jpg)
Smooth lighting and normal lighting comparison (I erased the mouse with Gimp here... damn thing). Normal lighting is the raw result of light propagation per block. Lighting is done per cube face. With smooth lighting, each vertex takes the average light amount of the surrounding blocs and lighting is done per vertex instead. There is also an ambient occlusion effect, which is very simply implemented (~ number of occupied blocks around the vertex).
(http://darkdragon1.free.fr/mycraft/Mycraft_004_th.jpg) (http://darkdragon1.free.fr/mycraft/Mycraft_004.jpg)(http://darkdragon1.free.fr/ice3/ice3_005_th.jpg) (http://darkdragon1.free.fr/ice3/ice3_005.jpg)
(http://darkdragon1.free.fr/ice3/ice3_006_th.jpg) (http://darkdragon1.free.fr/ice3/ice3_006.jpg)(http://darkdragon1.free.fr/ice3/ice3_007_th.jpg) (http://darkdragon1.free.fr/ice3/ice3_007.jpg)
Basic procedural terrain generation.
All pictures were taken on my laptop with an integrated Intel chip, except the last one which was taken on my gaming rig that is ~2-3 years old (with GUI caching on).

What is done :
Known issues :
Current controls :
You can download the sources and binaries (win32 and linux32) from the project's sourceforge page : [download] (http://sourceforge.net/projects/ice3/files/ice3/), or using the following links (I may forget to update this post for every release, so don't hesitate to visite the sourceforge page). It is released under the GNU General Public License (GPL).
Although I'm much less used to distributing linux programs, it should work out of the box provided that you have the following packages installed :
Please tell me if the program requires a shared object that is not covered by this list. All other dependencies are linked as static libraries, except some very common ones like libc, libX11, ...

If you decide to compile the program yourself, I warn you : it may be a little difficult... I use several libraries written by myself for other projects, which depends among others on lua5.1 (to which I've made some modifications) and freetype2. I've also modified SFML a little ;). Latest Win32 builds also require boost::thread (until MinGW supports std::thread).
The project (and the utility libraries) needs to be compiled with GCC 4.4 at least (using C++0x). Project files for Code::Blocks are provided in each package.

You can download most dependencies from here : [download] (https://sourceforge.net/projects/wowrl/files/frost%20utils/) (source only, not always updated to the last svn version), and the modified versions of Lua5.1 and SFML2.0 here : [zip] (http://darkdragon1.free.fr/ice3/dependencies.zip), [7z] (http://darkdragon1.free.fr/ice3/dependencies.7z) (again, source only).
Title: iCE³ - clone of Minecraft
Post by: AngelHoof on July 22, 2011, 01:06:08 pm
Very interesting, and great work to you, good sir.
Title: iCE³ - clone of Minecraft
Post by: Zinlibs on July 22, 2011, 04:04:11 pm
Oh my God ! I just dreamed to make a minecraft-clone too !
I'm gonna test It ! Congrats !
Title: iCE³ - clone of Minecraft
Post by: Kalith on July 22, 2011, 04:11:41 pm
Compiling instructions are in readme.txt from the dependency archive.
Good luck :P
Title: iCE³ - clone of Minecraft
Post by: Groogy on July 22, 2011, 05:38:04 pm
Gah damn you, seems like pretty many want to make infiniminer/minecraft clones. Though I want to go more in the Dwarf fortress direction but have the FPS perspective of Minecraft. Also you confirmed everything I thought about Notch. I meet Jens(Back-end programmer at Mojang) on NGC and asked him about the performance and his answers were that Markus had prioritized functionality over performance. But if you got so much done in 10 days it feels like he should have been able to at least make something.

Anymway looks nice. Are you thinking about completing it or your just experimenting so you'll only work with it as long as it entertains you? Will you try and make something of your own or just copy Minecraft?
Title: iCE³ - clone of Minecraft
Post by: Kalith on July 22, 2011, 05:53:58 pm
Well it only took me 10 days because I didn't have to invent anything except some algorithms. I know where I'm going, and it helps a lot.

I don't have any plans for now. As you say, I'm doing it because I enjoy it. If I ever make a truly playable version (that is, with random map generation, crafting, block drops and probably multiplayer), I won't stop here and I'll surely try to add new things ! Elevators, more entertaining enemies, etc.

If you're interested in this kind of project, there are far more advanced ones such as Minetest (http://celeron.55.lt/~celeron55/minetest/index), which is also written in C++ and open source (but uses Irrlicht).
Title: iCE³ - clone of Minecraft
Post by: Groogy on July 22, 2011, 06:31:00 pm
I'm not interested in Minecraft directly it's more sand-box games overall. As I said I come from Dwarf Fortress which is a lot more story guided even if it's a sand-box game. So I'm actually not interested in any minecraft implementations.

Though if you want to discuss things then I wouldn't mind ^^
Title: iCE³ - clone of Minecraft
Post by: Kalith on July 26, 2011, 05:50:54 pm
I've released a new version, here is the changelog :
I've also tried to cross compile some Win32 binaries from Ubuntu using Wine and MinGW. I managed to build everything and run, but there are some very strange Z-buffer issues (seems to be caused by Wine, runs fine natively on Windows). Plus I had to disable VBO rendering, else the program wouldn't run (now fixed).
Anyway, here is the resulting binary (along with all the files needed to play), please tell me if it works better for you :
Title: iCE³ - clone of Minecraft
Post by: Zinlibs on July 26, 2011, 09:33:05 pm
On Windows 7, I don't have Z-buffer issues at all. :D
Title: iCE³ - clone of Minecraft
Post by: Nexus on July 26, 2011, 09:49:00 pm
Very nice :)

The Windows version works well so far. I think the default controls are quite strange (ZQSD, although WASD would be more meaningful). And the game crashes when I dig too deep ;)
Title: iCE³ - clone of Minecraft
Post by: Kalith on July 26, 2011, 10:10:36 pm
Great !

The crash when you dig too much is expected, and should vanish in the end. It happens because the unit you control gets out of the playable world, and ends up associated to a NULL block chunk. It can be fixed, but this crash should never appear in a full featured version with procedural generation of chunks, as there would always be a chunk to be in.

And about the controls, that's because I use a french keyboard layout, on which A/Q and W/Z are reversed...
I don't know if SFML has a way to figure out what the keyboard layout of the user is ? I could allow a simple switch in the configuration file, but that'd be much less pretty...

By the way, might I ask how performances are in full screen ?
You can switch to fullscreen by editing DefaultConfig.lua in the root directory, setting "Fullscreen" to true and modifying "ScreenWidth" and "ScreenHeight" to match your display's native resolution. That should disable the vertical synchronization and allow unlimited FPS count.
Title: iCE³ - clone of Minecraft
Post by: Nexus on July 26, 2011, 10:47:50 pm
Quote from: "Kalith"
By the way, might I ask how performances are in full screen ?
You can switch to fullscreen by editing DefaultConfig.lua in the root directory, setting "Fullscreen" to true and modifying "ScreenWidth" and "ScreenHeight" to match your display's native resolution. That should disable the vertical synchronization and allow unlimited FPS count.
Usually, I get 170-230 FPS. When looking at the clear sky, the framerate goes up to 370 FPS, during the day/night change it sinks to 70 FPS.

I used fullscreen mode with a resolution of 1680x1050.
Title: iCE³ - clone of Minecraft
Post by: Kalith on July 26, 2011, 10:59:30 pm
With VBOs disabled, performances should be strictly identical during day/night and transition periods. Have you pressed the V key (which toggles VBO rendering) ?
Title: iCE³ - clone of Minecraft
Post by: Nexus on July 26, 2011, 11:17:54 pm
Quote from: "Kalith"
Have you pressed the V key (which toggles VBO rendering) ?
No. When I press the V key, only the glass and tree leaf blocks are rendered, and as soon as a day/night transition ends, the game crashes.
Title: iCE³ - clone of Minecraft
Post by: Kalith on July 27, 2011, 02:35:09 am
Yes I think I've done something wrong with the Glew library when cross compiling... I'll try to fix this.

About the FPS drop, you're right : I see it too on my machine. And I think I've found the reason. I didn't think it'd matter so much though.

Each block has two lighting values, "sunlight" and "light". When rendered, and depending on the day time, the resulting lighting color of each face is calculated using these two values. Because they are clamped to the [0,255] range, I can make a "lighting array" that contains all possible final lighting of a block, indexed by the two lighting parameters "sunlight" and "light", to avoid recalculating them every time.
This lighting array is only updated on day/night transitions.
The same thing is done for ambient occlusion.

The actual calculation is not that expensive (it's a rather simple 256x256 double loop), but I've optimized it as much as I could, and now I don't have any FPS drop... it even runs better during day/night transitions :( For such a small optimization (a priori), I find it really hard to believe.
I've tried to understand why for an hour, profiling the rendering code, but I have absolutely no clue : rendering takes twice less time to execute when the lighting array is updated... Maybe a CPU/GPU synchronization thing ?

Anyway, I've updated the previous binaries, please tell me what is the result on your side.

Edit : I've fixed the VBO problem : wasn't calling glewInit. Strange it didn't matter on Linux though. Anyway, they are now enabled by default.
Title: iCE³ - clone of Minecraft
Post by: Nexus on July 27, 2011, 02:00:29 pm
The new binaries don't contain an exe file ;)

And I think you should name the versions differently to avoid confusion.
Title: iCE³ - clone of Minecraft
Post by: danman on July 27, 2011, 02:31:44 pm
Kalith : i think GLEW use the OpenGL3 headers on linux ;)
Title: iCE³ - clone of Minecraft
Post by: Kalith on July 27, 2011, 04:43:45 pm
@Nexus : Oops sorry ! I've updated the latest links with the missing .exe.
And about the version number, you're right. I'm so much used to SVN for my other projects that I forget it's not enabled here... I'll change version names for the next releases.

@danman : What difference does it make ?
Title: iCE³ - clone of Minecraft
Post by: Kalith on July 28, 2011, 02:39:45 pm
I've released a new version which supports shaders. It improves performance during day/night transitions when using VBOs, try it :)

Lighting information is stored as a texture coordinate, and then used in the shader to compute the final lighting, by sampling a lighting texture.
That way, VBOs are only updated locally when the geometry or lighting changes.
The shader involved is extremely simple and should be available on most graphics card. Else, the option is simply disabled and the game uses the software version.

I first tried to do the lighting calculation in the vertex shader, but only recent graphics cards support textures in vertex shaders (my integrated Intel GMA doesn't seem to), and with additional limitations, so I had to do it in the fragment shader, which is obviously slower.

Shaders can be enabled/disabled dynamically using the F3 key.
Title: iCE³ - clone of Minecraft
Post by: Kalith on July 28, 2011, 09:29:17 pm
Updating the lighting array/texture was still too costly.
I've changed it to be more like Minecraft : update between day and night is not continuous but is done by steps. Minecraft uses ~16 steps (their lighting system, much like mine, only has 16 different shades). I've set it to 32 steps because it looks almost continuous and doesn't consume much more resources.
The value can be adjusted in the DefaultConfig.lua file, by adding :
Code: [Select]
["LightingUpdateRate"] = 16,

To further reduce the time it takes to build the lighting texture, I've also resized it from 256x256 to 64x64, which makes absolutely no difference to the final result.
Title: iCE³ - clone of Minecraft
Post by: Kalith on July 29, 2011, 12:58:13 am
Sorry I forgot to address this issue before...
I've implemented a quick way to change key bindings : a GUI shows up the first time you launch the game, allowing you to set your key bindings in a (hopefully) user friendly way.
Tell me if it's ok for you.

Controls now also default to WSAD.

Finally, I've moved all the technical keys (toggle VBO, toggle wireframe, ...) to the F1-F12 keys. So the W is now free :)

Edit : fixed damaged block texture (0.017b).

Edit 2 : I'll be away for 2 weeks and without any internet access starting from tomorrow, August 1rst.
I'm currently working on a real infinite world, where the program generates new block chunks as you walk by. I've re-written the world file format for this purpose, using a Minecraft-like region system : regions contain 9x9x9 chunks, and instead of storing the whole world into a single file, there is a file per region. This new file system is also ready for data compression (per chunk) to use less space on the disk, and in the future reduce bandwidth between the server and the client (ex : the current demo world weights 4MB, and only 4kB when compressed by 7zip...).
I'm still not using threads, so there is a little hang when the program generates new chunks. Fortunately, this part is (at least should be) easily implemented using threads, so that won't be a problem later.
Hopefully I'll come back to you in two weeks with everything working :)
Title: iCE³ - clone of Minecraft
Post by: keyforge on July 31, 2011, 04:05:11 am
I found a typo in the KeyBindings.lua file, moving right won't work because you put StrageRight instead of StrafeRight. I fixed it and it worked! It's always one little character that messes things up, XD!
Title: iCE³ - clone of Minecraft
Post by: Haikarainen on August 01, 2011, 06:28:15 pm
Quote from: "keyforge"
I found a typo in the KeyBindings.lua file, moving right won't work because you put StrageRight instead of StrafeRight. I fixed it and it worked! It's always one little character that messes things up, XD!


Yep, wont work for me neither.

Found a bug; Probably some overflow when trying to go to the edge of the map. It crashes.
Title: iCE³ - clone of Minecraft
Post by: TehSeph on August 02, 2011, 11:11:55 am
Offtopic: First post! :D

Ontopic: Great work! A suggestion, if you will? (I know this sounds lame, but...) I'm the type of person who learns by copying others and tweaking, or even more simply by seeing what someone did to change their code. Is there any chance you could create a subversion of the source? Preferably, through "Sourceforge" or "Google Code" as they have the most user-friendly change logs. I'm sure that would be of great help for people like myself to learn from. :oops:

Real curious to see where this goes in the future. Look out Notch! :lol:
Title: iCE³ - clone of Minecraft
Post by: danman on August 04, 2011, 07:58:22 pm
Ooops, i forgot to answer you Kalith  :lol: .

if you use the opengl3 header file provided by openGL for linux, it defines all the openGL 3 functions, so you don't have to load anythings :D although windows need GLEW because he only has a openGL1 header file. I don't know if it works on windows, but the siteduzero.com's new openGL tutorial say it doesn't.

Just a question, i've read your code, but i'm not sure. Are you rendering 1 VBO per chunk ?
Title: iCE³ - clone of Minecraft
Post by: Kalith on August 13, 2011, 02:53:24 pm
@keyforge : You're right, I fixed it (will be available in the next version).

@Haikarainen : Yes, that's a known bug that will be addressed in the next version as well.

@TehSeph : As soon as the current version is ready, I'll settle a sourceforge repository for the project. It won't contain all the changes since the very first releases though, only the future ones.

@danman : Ok I see :) Thank you for clarifying this point !
About VBOs, yes : I use a VBO per chunk. As far as I can tell, it offers an interesting performance boost (unfortunately I'm V-Sync limited so I can't tell how much exactly), and is extremely simple to manage.
I could pack several chunks into a single VBO, but that's be harder to implement, and the performance gain may not be worth the effort.

The next version is almost ready to be released, featuring basic procedural terrain generation, multi-threaded loading and updating of chunks, saving world on disk (during run time, in a thread too) with zlib compression.
I still need to fix a few things though (ambient occlusion bugs, among others).

Edit : Here it is !
(http://darkdragon1.free.fr/mycraft/Mycraft_004_th.jpg) (http://darkdragon1.free.fr/mycraft/Mycraft_004.jpg)
The original Linux version uses the C++0x threading capabilities (std::thread, std::mutex, std::unique_lock and std::condition_variable), while the Win32 port relies on Boost (MinGW being a bit late regarding std::thread support).
I'll update the first post with the new files as soon as they are available.
Title: iCE³ - clone of Minecraft
Post by: TehSeph on August 14, 2011, 06:04:43 am
Awesome.
Technically, you could start from r13 since you still have the src zipped on the OP.
Also, new version looks great.
I'm working on a somewhat similar project in which I plan to use a 3rd person Diablo-style perspective.
Reviewing the original minecraft java source and your c++ source in comparison has helped me a lot.
Can't wait to see that svn! :D
Title: iCE³ - clone of Minecraft
Post by: Kalith on August 14, 2011, 03:51:23 pm
Thank you !
Actually, I'm in trouble with the SVN : there is already a 'Mycraft' project (https://sourceforge.net/projects/mycraft/) on sourceforge... I'll have to find another name, and I'm terrible at it :)

Do you have a web page / forum post describing your project ? I'm curious too !
Title: iCE³ - clone of Minecraft
Post by: TehSeph on August 14, 2011, 09:02:25 pm
@Kalith: Currently, no. It's in the VERY EARLY stages of being worked on by myself and a group of net-friends.
We're building a GUI at the moment, and so far only have very basic OpenGL rendering for the actual 3d because none of us know graphics programming too terribly well. :?
I can get a screenshot posted for you, though... Give me a bit...
Title: iCE³ - clone of Minecraft
Post by: Kalith on August 15, 2011, 12:44:44 am
Name of the project has changed.
Took me several hours to realize that all "****craft" names were already taken by some random company... I had to find something more original (hem...), and came up with "icecube", or with the cool typography : iCE³. The "cube" part is obviously related to the nature of the project, and for the "ice" part : I use a custom framework that I created 3 years ago and called "Frost", so here you go...

Anyway, I've created a sourceforge page for the project that you can reach here (http://sourceforge.net/projects/ice3/). It contains all the files that were available in the first post, plus some older versions (starting from v0.001).
As soon as I'll have all the file uploaded, I'll create and fill the SVN repository.
Edit : SVN is ready, with code from v0.001 to the latest v0.019 :) Enjoy !
Title: iCE³ - clone of Minecraft
Post by: Kalith on August 20, 2011, 04:40:41 pm
I've released a new binary version (svn0027) which mostly contains bug fixes. Terrain generation has been tweaked a little to provide more interesting results, and lighting has been temporarily disabled because of serious performances issues : somehow, if the terrain gets too complex (nothing fancy though), the lighting system fails miserably and the world takes ages to generate completely.
Lighting will come back when I find a better algorithm.

(http://darkdragon1.free.fr/ice3/ice3_005_th.jpg) (http://darkdragon1.free.fr/ice3/ice3_005.jpg)

Edit : now providing linux 32bit binaries. Although I'm much less used to distributing linux programs, it should work out of the box provided that you have the following packages installed :
Please tell me if the program requires a shared object that is not covered by this list. All other dependencies are linked as static libraries, except some very common ones like libc, libX11, ...
Title: iCE³ - clone of Minecraft
Post by: easy on August 21, 2011, 01:09:52 pm
Thanks! It's a very nice work!

I've just tested it on Linux Mint Debian, the linux package worked out-of-the-box. However, on quitting it has frozen. Also, it seemed to me that no new chunks were loaded, that is I only had a certain area to play inside.

Cheers,
easy
Title: iCE³ - clone of Minecraft
Post by: Kalith on August 21, 2011, 09:47:38 pm
Hi, and thank you for your feedback !

Freezing on exit never happened to me on release mode. The only reason I can think of would be a deadlock issue between the different threads (LoaderThread (loading/saving), UpdaterThread, and main thread). When you shutdown the program, the main thread sends a "shutdown" signal to the two others, then waits for them to end :
The two other threads only communicate with the main thread, not between themselves, so I don't really know how a deadlock could happen...
Is it a systematic issue, or is it just random ?

About chunks not loading, that's weird. Can you reach the "edge" of the world without new chunks to appear ?
More precisely, can you tell me what are the numbers shown on the bottom right corner of the screen, after ~10sec ?
Title: iCE³ - clone of Minecraft
Post by: easy on August 22, 2011, 12:13:10 am
Freezing is not random, see my complete bug report below.

Yes, chunks on the edge stop loading and no more gets loaded. At least I can see no new chunks apprearing.

I took some screenshots for you about everything, read on:

Code: [Select]
Froze on startup again -- I had to kill the process. Log:

[00:00:00:000] : Starting iCE3...
[00:00:00:001] : # Warning # : Application : Lua::State : DoFile : can't open "Saves/Config.lua".
[00:00:00:056] : Done.
[00:00:00:056] :
[00:00:00:057] : New state : TestState.
[00:00:00:235] : Minimum memory size of a block : 5
[00:00:00:235] : Minimum memory size of a chunk : 276 + 5 * 3375 = 17151
[00:00:00:235] :
[00:00:00:252] : Terrain generation info :
[00:00:00:252] : World seed  : 3140
[00:00:00:252] : Persistence : 0.5
[00:00:00:252] : Frequency   : 0.01 (period : 100)
[00:00:00:252] : Amplitude   : 50
[00:00:00:252] : Octaves     : 5
[00:00:00:252] :
[00:00:00:252] :
[00:00:00:252] : Loading world 'Saves/Worlds/NewWorld001/NewWorld001.wrld'...
[00:00:00:252] : Clearing old world...
[00:00:00:272] : Done.
[00:00:00:272] :

So I've tried it again, but it has frozen on startup:

[00:00:00:000] : Starting iCE3...
[00:00:00:001] : # Warning # : Application : Lua::State : DoFile : can't open "Saves/Config.lua".
[00:00:00:049] : Done.
[00:00:00:049] :
[00:00:00:049] : New state : TestState.
[00:00:00:228] : Minimum memory size of a block : 5
[00:00:00:229] : Minimum memory size of a chunk : 276 + 5 * 3375 = 17151
[00:00:00:229] :
[00:00:00:245] : Terrain generation info :
[00:00:00:245] : World seed  : 3140
[00:00:00:245] : Persistence : 0.5
[00:00:00:245] : Frequency   : 0.01 (period : 100)
[00:00:00:245] : Amplitude   : 50
[00:00:00:245] : Octaves     : 5
[00:00:00:245] :
[00:00:00:245] :
[00:00:00:245] : Loading world 'Saves/Worlds/NewWorld001/NewWorld001.wrld'...
[00:00:00:245] : Clearing old world...
[00:00:00:266] : Done.
[00:00:00:266] :

So I've cheated a bit and renamed "NewWorld001" to "aaaaaaaa_NewWorld001" in Saves/Worlds. And yes it started up again! I'm gonna take some screenshots for you right now of the edges... (A bit annoying that I have to ALT-TAB out of the window to get back my mouse pointer, otherwise it's not shown!)

I've made 3 screenshots: "ice3-1.jpg" and "ice3-2.jpg" in on a border of the map, and then I've walked to the other end and took "ice3-3.jpg". After a couple of minutes I'm gonna take another screenshot for you of about 10 minutes playing.

Oops.. I'm creating an underground tunnel (ice3-4.jpg) and if I jump up, I can jump through the ceiling and see the world from below. I'm gonna try to capture it... success (ice3-5.jpg).

Okay, 10 minutes is over, here goes my last screenshot: "ice3-6.jpg".

I've tried to press the close button an it froze again:

[00:00:00:000] : Starting iCE3...
[00:00:00:001] : # Warning # : Application : Lua::State : DoFile : can't open "Saves/Config.lua".
[00:00:00:052] : Done.
[00:00:00:052] :
[00:00:00:053] : New state : TestState.
[00:00:00:232] : Minimum memory size of a block : 5
[00:00:00:232] : Minimum memory size of a chunk : 276 + 5 * 3375 = 17151
[00:00:00:232] :
[00:00:00:248] : Terrain generation info :
[00:00:00:249] : World seed  : 3140
[00:00:00:249] : Persistence : 0.5
[00:00:00:249] : Frequency   : 0.01 (period : 100)
[00:00:00:249] : Amplitude   : 50
[00:00:00:249] : Octaves     : 5
[00:00:00:249] :
[00:12:02:281] :
[00:12:02:281] : Closing state : TestState.


(http://kepfeltoltes.hu/thumb/110822/ice3-1_www.kepfeltoltes.hu_.jpg) (http://kepfeltoltes.hu/view/110822/ice3-1_www.kepfeltoltes.hu_.jpg)

(http://kepfeltoltes.hu/thumb/110822/ice3-2_www.kepfeltoltes.hu_.jpg) (http://kepfeltoltes.hu/view/110822/ice3-2_www.kepfeltoltes.hu_.jpg)

(http://kepfeltoltes.hu/thumb/110822/ice3-3_www.kepfeltoltes.hu_.jpg) (http://kepfeltoltes.hu/view/110822/ice3-3_www.kepfeltoltes.hu_.jpg)

(http://kepfeltoltes.hu/thumb/110822/ice3-4_www.kepfeltoltes.hu_.jpg) (http://kepfeltoltes.hu/view/110822/ice3-4_www.kepfeltoltes.hu_.jpg)

(http://kepfeltoltes.hu/thumb/110822/ice4-5_www.kepfeltoltes.hu_.jpg) (http://kepfeltoltes.hu/view/110822/ice4-5_www.kepfeltoltes.hu_.jpg)

(http://kepfeltoltes.hu/thumb/110822/ice3-6_www.kepfeltoltes.hu_.jpg) (http://kepfeltoltes.hu/view/110822/ice3-6_www.kepfeltoltes.hu_.jpg)

I hope all these can help you!
Cheers,
easy
Title: iCE³ - clone of Minecraft
Post by: Kalith on August 22, 2011, 12:47:29 am
Wow, that's a hell of a bug report :D
Thank you !

Quote from: "easy"
Yes, chunks on the edge stop loading and no more gets loaded. At least I can see no new chunks apprearing.

Ok, from the screenshots you posted, I can see that both the Loader and the Updater threads are doing their job as there is no pending chunks in their respective queues.
You have too little chunks loaded though : 1000 instead of 4000 (if you didn't change the view distance).

That said, I can see that occlusion works for border blocks (it shouldn't if the neighboring chunk has not been loaded yet). I'm sorry to involve you any further, but can you dig in the "empty" space ? For example, if you see something like in third screenshot : the block that is at the very bottom of the mountain (near the edge of the map) has some occlusion on it that suggest that another block is present nearby. If you can, try to dig there :)

Anyway, that bug is really strange. It's so obvious, and doesn't happen on my machine, with the same binaries : there must be something wrong with dependencies (or with the hardware, but that's improbable)...
I wonder : to use my own version of SFML, I provided the .so files in the same directory as the binary, and compiled it with "-rpath ./" so it can search for shared objects in its directory.
Maybe for some reason the program loads another version of SFML that you have in standard directories (/usr/lib for example).
I don't think so, because it would most likely crash if it was the case, but if you "cd" to the "ice3" directory and run "ldd iCE3" in the terminal, what does it say about SFML shared objects ?

Quote
So I've cheated a bit and renamed "NewWorld001" to "aaaaaaaa_NewWorld001" in Saves/Worlds. And yes it started up again!

Yes, by default the program tries to load "NewWorld001", and if it doesn't exist, generate a new one. That's a temporary behavior, but it's good enough for testing purposes :) You can safely delete the "Worlds" or "NewWorld001" directories when you want to start anew (my dustbin is full of it...).

Quote
Oops.. I'm creating an underground tunnel (ice3-4.jpg) and if I jump up, I can jump through the ceiling and see the world from below. I'm gonna try to capture it... success (ice3-5.jpg).

There are some rare problems with the collision detection algorithm. It works perfectly most of the time, but sometimes fails for no apparent reason.
Do you still have that world on your hard drive ? If so, can you still see through the ground when you go there ?
If that's the case, then I'd be very grateful if you could upload this world file somewhere ! I still have no reproducible case of the collision detection failing...

Thank you very much for all this feedback anyway :)
Title: iCE³ - clone of Minecraft
Post by: easy on August 22, 2011, 09:57:39 am
Yes I've thought too that maybe we have different versions of SFML, so I've opened the ice3 directory and seen that you've provided yours. To ensure that it loads these libraries, I've added a line to your startup script:

Code: [Select]
iCE3.sh:

#!/bin/bash

cd `dirname $0`
export LD_LIBRARY_PATH=.
./iCE3


By the way, after this I've also tried "ldd iCE3", and it seems to be fine:

Code: [Select]

linux-gate.so.1 =>  (0xb77f7000)
libfreetype.so.6 => /usr/lib/i386-linux-gnu/libfreetype.so.6 (0xb7741000)
libdl.so.2 => /lib/i386-linux-gnu/i686/cmov/libdl.so.2 (0xb773d000)
libsfml-window.so => ./libsfml-window.so (0xb7729000)
libsfml-graphics.so => ./libsfml-graphics.so (0xb768c000)
libsfml-system.so => ./libsfml-system.so (0xb7682000)
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb7594000)
libm.so.6 => /lib/i386-linux-gnu/i686/cmov/libm.so.6 (0xb756e000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb7550000)
libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xb73f6000)
libz.so.1 => /usr/lib/libz.so.1 (0xb73e2000)
libGL.so.1 => /usr/lib/i386-linux-gnu/libGL.so.1 (0xb7310000)
libGLEW.so.1.5 => /usr/lib/libGLEW.so.1.5 (0xb72b9000)
libpthread.so.0 => /lib/i386-linux-gnu/i686/cmov/libpthread.so.0 (0xb729f000)
/lib/ld-linux.so.2 (0xb77f8000)
libX11.so.6 => /usr/lib/i386-linux-gnu/libX11.so.6 (0xb7165000)
libGLU.so.1 => /usr/lib/i386-linux-gnu/libGLU.so.1 (0xb70f3000)
libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0xb70cf000)
libXrandr.so.2 => /usr/lib/i386-linux-gnu/libXrandr.so.2 (0xb70c7000)
libnvidia-tls.so.280.13 => /usr/lib/i386-linux-gnu/tls/libnvidia-tls.so.280.13 (0xb70c3000)
libnvidia-glcore.so.280.13 => /usr/lib/i386-linux-gnu/libnvidia-glcore.so.280.13 (0xb57b2000)
libXext.so.6 => /usr/lib/i386-linux-gnu/libXext.so.6 (0xb57a0000)
librt.so.1 => /lib/i386-linux-gnu/i686/cmov/librt.so.1 (0xb5797000)
libXmu.so.6 => /usr/lib/libXmu.so.6 (0xb5781000)
libXi.so.6 => /usr/lib/i386-linux-gnu/libXi.so.6 (0xb5771000)
libxcb.so.1 => /usr/lib/i386-linux-gnu/libxcb.so.1 (0xb5752000)
libXrender.so.1 => /usr/lib/i386-linux-gnu/libXrender.so.1 (0xb5748000)
libXt.so.6 => /usr/lib/i386-linux-gnu/libXt.so.6 (0xb56eb000)
libXau.so.6 => /usr/lib/i386-linux-gnu/libXau.so.6 (0xb56e8000)
libXdmcp.so.6 => /usr/lib/i386-linux-gnu/libXdmcp.so.6 (0xb56e1000)
libSM.so.6 => /usr/lib/i386-linux-gnu/libSM.so.6 (0xb56d9000)
libICE.so.6 => /usr/lib/i386-linux-gnu/libICE.so.6 (0xb56c0000)
libuuid.so.1 => /lib/libuuid.so.1 (0xb56bb000)


This time, it loaded up without a freeze, and actuall when I've started goind off the hill I've seen a new chunk appearing, but then it stopped loading. So I've tried what you've said, to dig into the empty space (ice3-7.jpg) but as you can see, I only could dig into the loaded chunks. I've also tried to dig *and* go into the empty space, but it keeps blocking my character movement, so the collision works fine :)

(http://kepfeltoltes.hu/thumb/110822/ice3-7_www.kepfeltoltes.hu_.jpg) (http://kepfeltoltes.hu/view/110822/ice3-7_www.kepfeltoltes.hu_.jpg)

What Linux distro are you using (or used, when compiled your game and SFML)? This is Linux Mint, the debian-based version, 32bits. I've got 4Gb of RAM, Intel Core 2 Duo T6670 2.20Ghz CPU, nVidia GeForce 310M with 512Mb VRAM.

I've started a system monitor and the game pretty much uses both my CPUs at 100% (ice3-8.jpg) and you can see the graph after I've killed the process (yeah, it has frozen again) on "ice3-9.jpg".

(http://kepfeltoltes.hu/thumb/110822/ice3-8_www.kepfeltoltes.hu_.jpg) (http://kepfeltoltes.hu/view/110822/ice3-8_www.kepfeltoltes.hu_.jpg)

(http://kepfeltoltes.hu/thumb/110822/ice3-9_www.kepfeltoltes.hu_.jpg) (http://kepfeltoltes.hu/view/110822/ice3-9_www.kepfeltoltes.hu_.jpg)

Log:

Code: [Select]
[00:00:00:000] : Starting iCE3...
[00:00:00:001] : # Warning # : Application : Lua::State : DoFile : can't open "Saves/Config.lua".
[00:00:00:055] : Done.
[00:00:00:055] :
[00:00:00:055] : New state : TestState.
[00:00:00:234] : Minimum memory size of a block : 5
[00:00:00:234] : Minimum memory size of a chunk : 276 + 5 * 3375 = 17151
[00:00:00:234] :
[00:00:00:250] : Terrain generation info :
[00:00:00:250] : World seed  : 3140
[00:00:00:250] : Persistence : 0.5
[00:00:00:250] : Frequency   : 0.01 (period : 100)
[00:00:00:250] : Amplitude   : 50
[00:00:00:250] : Octaves     : 5
[00:00:00:250] :
[00:01:00:978] :
[00:01:00:978] : Closing state : TestState.


Quote
Yes, by default the program tries to load "NewWorld001", and if it doesn't exist, generate a new one. That's a temporary behavior, but it's good enough for testing purposes  You can safely delete the "Worlds" or "NewWorld001" directories when you want to start anew (my dustbin is full of it...).


Note that it did exist, but it has crashed when loading it!

Trying to start the game, and it just don't. Log:

Code: [Select]
[00:00:00:000] : Starting iCE3...
[00:00:00:044] : Done.
[00:00:00:044] :
[00:00:00:044] : New state : TestState.
[00:00:00:233] : Minimum memory size of a block : 5
[00:00:00:233] : Minimum memory size of a chunk : 276 + 5 * 3375 = 17151
[00:00:00:233] :
[00:00:00:249] : Terrain generation info :
[00:00:00:249] : World seed  : 3140
[00:00:00:249] : Persistence : 0.5
[00:00:00:249] : Frequency   : 0.01 (period : 100)
[00:00:00:249] : Amplitude   : 50
[00:00:00:249] : Octaves     : 5
[00:00:00:249] :
[00:00:00:249] :
[00:00:00:249] : Loading world 'Saves/Worlds/NewWorld001/NewWorld001.wrld'...
[00:00:00:249] : Clearing old world...
[00:00:00:270] : Done.
[00:00:00:270] :
[00:00:00:358] : # Error # : Main : World : Unit lookup list is outdated.
[00:00:00:358] :
[00:00:00:358] : Closing iCE3...
[00:00:00:358] : Average FPS : nan
[00:00:00:358] : Best FPS : 0
[00:00:00:358] : Worst FPS : inf
[00:00:00:358] :
[00:00:00:359] : Done.


Sigh... deleted the saved world, started again. Ok. Trying to remake a collision-fail example... Ok. It seems when you've got 3 empty cubes above and you jump, you can see through the ceiling. I've digged a tunnel for you, when startup just go forward to the bottom of the next hill and you'll find it there. Go until the glass cubes and jump! Ok I've made an asphalt arrow to show where the tunnel starts. So I was climbing up to the start mounting when I've literally fallen through the whole map, see "ice3-10.jpg"! :)

(http://kepfeltoltes.hu/thumb/110822/ice3-10_www.kepfeltoltes.hu_.jpg) (http://kepfeltoltes.hu/view/110822/ice3-10_www.kepfeltoltes.hu_.jpg)

And here's the saved world:

http://data.hu/get/4156681/Saves.zip

Scroll down, use the big gray "Lassú letöltés" button under the red signs!

I don't know how long these sreenshots and this .zip is available, so you might consider saving them to you hdd.

See if all these help you,
Regards,
easy
Title: iCE³ - clone of Minecraft
Post by: Kalith on August 22, 2011, 02:53:01 pm
Code: [Select]
#!/bin/bash

cd `dirname $0`
export LD_LIBRARY_PATH=.
./iCE3

... that's what the compilation flag "-rpath ./" does actually, so you don't have to make that kind of script :) The original script is only needed when you want to run the game through a symlink (launcher, ...) : "rpath" tells the program to look in the current directory for shared objects, so you first have to "cd" to the game's directory, and not the launcher/symlink one.
Anyway, it seems that it's not the root of the problem.

Quote
What Linux distro are you using (or used, when compiled your game and SFML)?

I compiled the program on a 32bit Ubuntu distribution (11.04), using an Intel Core i3 (2 cores, but Ubuntu sees 4 thanks to hyper threading) with 2.4GHz per core, 2Gb of RAM, and an integrated Intel GMA graphics card (uses system RAM as VRAM), with GCC 4.5.2.

Quote
This time, it loaded up without a freeze, and actuall when I've started goind off the hill I've seen a new chunk appearing, but then it stopped loading. So I've tried what you've said, to dig into the empty space (ice3-7.jpg) but as you can see, I only could dig into the loaded chunks. I've also tried to dig *and* go into the empty space, but it keeps blocking my character movement, so the collision works fine :)

There is a safeguard in the code to prevent the player from stepping into an unloaded chunk, so the collision you see doesn't necessarily comes from the chunk blocks. If you had been able to dig, then the chunk would have been loaded but it's Quad cache wouldn't have been updated...

Quote
I've started a system monitor and the game pretty much uses both my CPUs at 100% (ice3-8.jpg) and you can see the graph after I've killed the process (yeah, it has frozen again) on "ice3-9.jpg".

That's an expected behavior if you took the first screen shot only after several seconds of gameplay. Is it still the same after ~20-30secs ?

Quote
Note that it did exist, but it has crashed when loading it!

Yes that's not really a crash but an unhandled exception :)
It happens when the game crashes (or hangs) on exit : the game saves the NewWorld0001.wrld file, which contains a unit lookup list that keeps a list of all units in the world, and information about which chunk it lies in : all the other informations about a unit is stored along with the chunk data. So if the game crashes before saving all chunks, then the unit lookup list may tell the world that a unit "X" is located in chunk "Y", and when the world loads chunk "Y", it may not find unit "X" inside... So it considers the unit lookup list as outdated, and throws an exception.
For now, this exception is not handled, and it kills the progam. Later on, I may try to rebuild the unit list so you can still load "half saved" world.


Quote
It seems when you've got 3 empty cubes above and you jump, you can see through the ceiling. I've digged a tunnel for you, when startup just go forward to the bottom of the next hill and you'll find it there. Go until the glass cubes and jump! Ok I've made an asphalt arrow to show where the tunnel starts. So I was climbing up to the start mounting when I've literally fallen through the whole map, see "ice3-10.jpg"! :)

I'm sorry, the world you provided is missing the *.wrld file, so I can't load it :( But I'm being dumb here : since the game crashes on exit for you, you won't be able to save it all...
That said, I managed to reproduce your bug and I confirm it.
Actually the camera is positioned at the very top of the unit's collision mesh (which is a simple cylinder), so there are some rare occasions when the camera is exactly "in" a block face. I'll fix it by moving the camera down a little in the next version, thanks ;)

The rare collision detection bugs I was thinking about are more like the one you experienced when climbing the mountain and fell through it.

Back on the original problem, can you try the Win32 version with wine ? It should work out of the box as well.
Title: iCE³ - clone of Minecraft
Post by: easy on August 22, 2011, 07:38:47 pm
Quote
... that's what the compilation flag "-rpath ./" does actually, so you don't have to make that kind of script  


Ok! I'm not that experienced with coding on Linux, I've been a Windows guy for many years...

Quote
That's an expected behavior if you took the first screen shot only after several seconds of gameplay. Is it still the same after ~20-30secs ?


Yes, it didn't go lower.

Quote
Back on the original problem, can you try the Win32 version with wine ? It should work out of the box as well.


I don't have Wine installed, sorry. :)
Title: iCE³ - clone of Minecraft
Post by: Kalith on August 22, 2011, 10:01:34 pm
Quote from: "easy"
Ok! I'm not that experienced with coding on Linux, I've been a Windows guy for many years...

Me neither :\

Quote
Yes, it didn't go lower.

That's not good then. One or both the additional threads are busy, but their queues are empty... They are meant to sleep for 10ms in that case, so they shouldn't use all the CPU. Or maybe 10ms is too small, I'll try to increase this number for future releases just to be sure.

Quote
I don't have Wine installed, sorry. :)

Ah, too bad.
When I have the time, I'll make a special release for you, which will output some more information in the log file. That should help to track down the issue.

Thank you very much for your help though !
Title: iCE³ - clone of Minecraft
Post by: easy on August 23, 2011, 10:41:48 am
Quote
When I have the time, I'll make a special release for you, which will output some more information in the log file. That should help to track down the issue.


Okay, but I think you should leave most of the debug-log info in your game after! You'll never know when you'll need a logfile from a user, I always write out debug info to the console and into a file if the project is bigger.
Title: iCE³ - clone of Minecraft
Post by: Kalith on August 23, 2011, 12:09:21 pm
Quote from: "easy"
Okay, but I think you should leave most of the debug-log info in your game after! You'll never know when you'll need a logfile from a user, I always write out debug info to the console and into a file if the project is bigger.

Yes, but the output will be huge here, and it will affect performances. I can't afford to keep it in a release build :)
Furthermore, I like my log file to only print critical informations. I remember Ogre printing tons of lines in the log file (about supported OpenGL extensions etc), hiding important notices such as shader compilation failure.
Title: iCE³ - clone of Minecraft
Post by: Kalith on August 23, 2011, 02:24:41 pm
Here you are : [download] (http://darkdragon1.free.fr/ice3/ice3_easy_test.zip).
Can you try this new binary ? No need for extensive testing, just run it once and wait for ~20sec, then exit.
If everything runs fine, the log file should be approximately ~700Kb (each thread describes what it's doing, so with 4000 chunks it gets quite verbose). Then please upload it somewhere so I can take a look at it ;)
Title: iCE³ - clone of Minecraft
Post by: Kalith on August 24, 2011, 12:52:31 am
Playing with terrain generation :
(http://darkdragon1.free.fr/ice3/ice3_006_th.jpg) (http://darkdragon1.free.fr/ice3/ice3_006.jpg)

Binaries have been updated to svn v0036.
Now supporting alpha blended blocks (water blocks mainly, but no water physics yet).
Lighting is back also :)
Title: iCE³ - clone of Minecraft
Post by: easy on August 24, 2011, 02:32:48 pm
Quote from: "Kalith"
Can you try this new binary ? No need for extensive testing, just run it once and wait for ~20sec, then exit.
If everything runs fine, the log file should be approximately ~700Kb (each thread describes what it's doing, so with 4000 chunks it gets quite verbose). Then please upload it somewhere so I can take a look at it ;)


I did try it yesterday evening, I just didn't have time to upload it until now.

Here's the log file. (http://data.hu/get/4163345/iCE3.log) It looks quite all right for me...

I've played a longer period because I've been building a house. :D
I still have the freeze-on-exit bug.
Title: iCE³ - clone of Minecraft
Post by: N1ghtly on August 24, 2011, 10:45:46 pm
a-m-a-z-i-n-g

Damn man, nice work!
How did you draw the graphics? OpenGL in an SFML context?
Title: iCE³ - clone of Minecraft
Post by: Kalith on August 25, 2011, 03:09:43 am
Quote from: "easy"
Here's the log file. (http://data.hu/get/4163345/iCE3.log) It looks quite all right for me...

Thank you. It look fine to me as well... Chunks are appropriately loaded and updated, so there must be something wrong in the way they are displayed. Have you tried to disable VBOs (by pressing the F4 key), and does that change anything ?

Quote from: "easy"
I've played a longer period because I've been building a house. :D
I still have the freeze-on-exit bug.

Glad to hear you have fun with it anyway :)
About the freeze, I can see from the log file that the LoaderThread is doing nothing when the world closes, and that's not a good thing.
I've uploaded the last svn version (0037) for you [here] (http://darkdragon1.free.fr/ice3/ice3_linux32_svn0037.zip) : there is more output written in the log file when the world closes. It could help narrow down the problem.

Quote from: "N1ghtly"
Damn man, nice work!
How did you draw the graphics? OpenGL in an SFML context?

Thank you !
Yes, exactly. I let SFML handle the context, and draw the world using OpenGL calls (either in immediate mode or using vertex buffer objects, depending on the user's preference).
Title: iCE³ - clone of Minecraft
Post by: easy on August 25, 2011, 08:09:46 pm
I've tried the new SVN version you've provided, and it started even worse: I could not move my character 1 step further than the start position, because the game just crashed and the window has disappeared!

A couple of tried to disable VBOs, as you've suggested, but before I've deleted the previous saved world. This time it has started, but there were missing chunks:
(https://legacy.sfmluploads.org/cache/pics/93_ice3-11.jpg)

Then I've made a tunnel through the mountain, looked back, and found a visibility bug:
(https://legacy.sfmluploads.org/cache/pics/94_ice3-12.jpg)

On the other side of the mountain:
(https://legacy.sfmluploads.org/cache/pics/95_ice3-13.jpg)

CPU usage:
(https://legacy.sfmluploads.org/cache/pics/96_ice3-14.jpg)

Freeze on exit, log goes here:
https://legacy.sfmluploads.org/code/73

The mountains and the water also looks great! Congrats! :P

I'm using SFML Uploads this time. Really nice! :)
Title: iCE³ - clone of Minecraft
Post by: Kalith on August 25, 2011, 09:31:55 pm
I can confirm the visibility bug on my side as well. I thought I fixed it, but apparently no... I'll investigate this, thank you for the feedback.

About the freeze, the log file definitely confirms that there is something wrong with the loader thread. Along with the previous log file you posted, I now know that the main thread waits for it to end... doing nothing :\ Great !
When I find the time, I'll upload another verbose binary that will print informations about the loader thread's main loop instead of simply reporting which tasks are being executed.

Currently I'm working on improving the interface a little, by giving control of the mouse pointer using the Shift key as a toggle. The world menu is being rewritten to allow creation of a new world with a different name and a different seed, as well as loading previous worlds. The "save" menu item has been removed because saving is automatic now (I may provide a "safety save" option though, in case the user fears a crash).

When it's done, I may try to remove the custom code I've added to SFML, so I don't need to ship the modified version anymore. I hope that it'll help fixing your problems.

Glad you like the new terrain though :)
Title: iCE³ - clone of Minecraft
Post by: bronddy on August 28, 2011, 08:21:51 am
How do you control who can build in your minecraft server? I've just made a minecraft server , but i don't know how i can control who can build and who cant? How can i give and take building rights?
____________________
affiliateelite (http://www.keywordspy.com/overview/domain.aspx?q=affiliateelite.com) ~ affiliateelite.com (http://www.keywordspy.com/overview/domain.aspx?q=affiliateelite.com) ~ adgooroo (http://www.keywordspy.com/overview/keyword.aspx?q=adgooroo) ~ adgooroo.com (http://www.keywordspy.com/overview/domain.aspx?q=adgooroo.com)
Title: iCE³ - clone of Minecraft
Post by: Kalith on August 28, 2011, 12:49:47 pm
You'd better ask your question at the official Minecraft forums, [here] (http://www.minecraftforum.net/).
That's out of topic here.
Title: iCE³ - clone of Minecraft
Post by: Kalith on September 10, 2011, 12:13:35 pm
New binary release, with the following change log (svn0041).
It contains several bug fixes and a reworked feature : the "world menu", from which you can create a new world or open a previous one.
This menu is clickable, so you have to free the mouse cursor to access it. This can be done by pressing the Shift key for now (I may change the default in the future though, and allow it to be customizable).
Also, I now have access to a native Win32 computer with a real graphics card (ATi), so I discovered a few bugs that wouldn't appear on my linux laptop.

Changelog :
Code: [Select]
- Fixed the ShowMouseCursor Lua function not blocking world events.
 - Native Win32 build targets updated.
 - Fixed VBO being destroyed in the LoaderThread, where there is no OpenGL context.
 - Texture filtering disabled for lighting texture to fix bad values at texture borders (ATI cards only ?).
 - Rewritten ZoneManager UI addon to WorldMenu : can now create a new world with a new seed and reacts to mouse clicks instead of key presses.
 - Pressing the Shift key toggles mouse grab (hide/show pointer) so the user can interact with the GUI.
 - Removed unnecessary code from Block.
 - Improved log file look and added more ouput regarding world clearing.


Finally, please note that from now on, I have much less time at my disposal as I need to work for my last year of Master degree.

@easy : "Fixed VBO being destroyed in the LoaderThread" may address your chunk loading problem (even though I doubt it).

Edit : The visibility bug mentioned in the previous post has been fixed in svn0042, so it will be available in the next release.
Title: iCE³ - clone of Minecraft
Post by: easy on September 10, 2011, 03:12:32 pm
Cool! Thanks! I'm gonna try it later, because acually now I'm working... :D
Title: iCE³ - clone of Minecraft
Post by: Kalith on September 10, 2011, 08:39:54 pm
You can now try the latest binary, from svn0050.
As said in my previous post, it contains the fix for the "visibility bug" along with many others (collision detection, player spawning, ...).

I've also reworked the terrain generation a little. I felt the world was too flat between the sea and the mountain, so I adjusted it a bit :
(http://darkdragon1.free.fr/ice3/ice3_007_th.jpg) (http://darkdragon1.free.fr/ice3/ice3_007.jpg)
Screenshot took on my gaming rig & Windows XP, with a much better graphics card (HD4770, a few years old) and a worse processor (2.5GHz dual core from AMD).
As you can see, it runs fairly well with a large view distance (set to 256 here).
I also have Ubuntu installed on this machine, so I tested the precompiled binary and it works ok, no loading or freeze problem.
Your problem is either related to your distro or your hardware. I'm sorry I can't do more... (cool game by the way :))
Title: iCE³ - clone of Minecraft
Post by: Kalith on September 14, 2011, 10:58:34 pm
Bah, from Minecraft's 1.8 update patch :
Quote
New improved lighting — day/night cycles no longer require chunk updates. Lighting is updated via a texture, whose coordinates are the block's sky light and block light levels.


That's exactly the technique I used for light rendering so far.
Do you read this Notch ? :)
Title: iCE³ - clone of Minecraft
Post by: OniLinkPlus on September 15, 2011, 02:39:24 am
Quote from: "Kalith"
Bah, from Minecraft's 1.8 update patch :
Quote
New improved lighting — day/night cycles no longer require chunk updates. Lighting is updated via a texture, whose coordinates are the block's sky light and block light levels.


That's exactly the technique I used for light rendering so far.
Do you read this Notch ? :)
He actually mentioned that update long before you even started this project. He just kept holding it off until the Adventure.
Title: iCE³ - clone of Minecraft
Post by: Kalith on September 15, 2011, 06:45:20 pm
Oh really ? I read most of his blog posts but can't remember any reference to something in that taste. Could you point me to where you read that ?
Hehe, I was feeling a bit proud of myself, then you just killed it :) Thank you for pointing that out anyway !
Title: iCE³ - clone of Minecraft
Post by: Sylmael on September 16, 2011, 09:23:55 am
Hi Kalith, can you tell me how this texture lighting works? Nice work btw ;).
Title: iCE³ - clone of Minecraft
Post by: Kalith on September 16, 2011, 03:49:34 pm
Sure ! It's a technique that is very specific to the pre-calculated lighting system that this kind of game uses (the different lighting values of each block is updated only when the surrounding geometry changes or when lights move).

When you build your vertex data (or vertex buffer object), you specify three additional texture coordinates, along with the usual 2 coordinates used for actual texturing.
In the first one, you store the amount of sunlight, in the second one, the amount of block light, and in the third one, the occlusion value (this last one is not necessary, but you can improve a little the look of the occlusion that way). Then, in your program, you create a lighting texture that contains pre-calculated blended lighting :
Code: [Select]
// uiLightingArraySize_ : defines the quality of the lighting, I use 64 pixels, then :
//     uiLightingArrayRatio_ = 256u/uiLightingArraySize_
// Light::INTENSITY_TABLE : table containing light intensity, indexed by block raw lighting
//     (~distance from nearest lit block), I use an inverse exponential law : exp[-a*(255-i)]
for (uint s = 0; s < uiLightingArraySize_; ++s)
{
    Color mSun = mSunColor_*Light::INTENSITY_TABLE[s*uiLightingArrayRatio_];
    for (uint l = 0; l < uiLightingArraySize_; ++l)
    {
        float fLight = Light::INTENSITY_TABLE[l*uiLightingArrayRatio_];
        Color mLight = mSun + Color(fLight, fLight, fLight);
        mLight.Saturate();

        // Store additional information in the alpha component for occlusion
        mLight.a = Light::OCCLUSION_TABLE2[std::max(s, l)*uiLightingArrayRatio_];

        lLightingArray_->SetPixel(s, l, mLight);
    }
}


Here is the resulting texture (I increased the texture size to 128 pixels for you to see better, and added different colors for sunlight (blueish) and block light (yellowish)). On the left you have the texture in the middle of the day, and on the right the same texture at night :
(http://darkdragon1.free.fr/ice3/light.png)(http://darkdragon1.free.fr/ice3/light2.png)(http://darkdragon1.free.fr/ice3/light3.png)(http://darkdragon1.free.fr/ice3/light4.png)
Basically, you can see that, at night, only the block light remains, and sunlight vanishes.

Then, when I render the blocks, I bind this manual texture and use it in a shader to produce per pixel lighting :

vertex shader, extremely simple, just sends everything to the fragment shader properly :
Code: [Select]
void main()
{
    gl_TexCoord[0] = gl_MultiTexCoord0;
    gl_TexCoord[1] = gl_MultiTexCoord1;
    gl_FrontColor  = gl_Color;
    gl_Position    = gl_ModelViewProjectionMatrix*gl_Vertex;
}


fragment shader :
Code: [Select]
uniform sampler2D light;
uniform sampler2D texture;

void main()
{
    vec4 cLight = texture2D(light, gl_TexCoord[1].xy);
    vec4 cTexture = texture2D(texture, gl_TexCoord[0].xy)*gl_Color;
    float fOcclusion = 1.0 - cLight.a*0.75*gl_TexCoord[1].z;
    gl_FragColor.rgb = cTexture.rgb*cLight.rgb*fOcclusion;
    gl_FragColor.a = cTexture.a;
}


The most important advantage is that you don't have to touch your vertex data when the sunlight changes. You only need to update the lighting texture with the modified "mSunColor_", which is much less intensive than re-updating each VBO of your scene, and allows for cheap continuous transitions.
Title: iCE³ - clone of Minecraft
Post by: Sylmael on September 16, 2011, 07:36:01 pm
Interesting, thanks for sharing. So when i have a chunk 16x128x16 blocks (xyz) i need only 16x16 pixels lighting texture? And how this technique deals with sun light that enters a cave. When this is a 2D texture it can describe light brightness for one block per pixel.. sorry but i am little confused here. :) But this topic is very interesting for programmer like me.
Title: iCE³ - clone of Minecraft
Post by: Kalith on September 16, 2011, 07:47:11 pm
Yes you got it wrong :) I'll try to be more clear :

For each block in the world, you have two lighting values :
These two values have to be calculated in the CPU using some spreading algorithm, and stored in memory, every time a light moves or a block is destroyed/created.

The first approach I used (and so did Notch), was to use these two values to compute a "final light color", and store it in the vertex data.
The big problem comes when the sun color changes, when going from day to night for example : you have to re-update all your vertex caches to use the new sun color. And this is costly (only if you use a vertex caching mechanism though, like VBOs. If you render the world in immediate mode then it makes almost no difference).

So the trick is :
When you want to render your block, you create a vertex list, and to each vertex from that block, you associate two additional texture coordinates : (sunlight, light).
In the shader, you use these coordinates to sample a "lighting texture". In pseudo code, if the lighting texture is called 'texture', you have :
Code: [Select]
texture[sunlight][light]
... which is the resulting light value of your vertex (the "final light color" I was reffering to earlier).
Actually, you can do it without a light texture, and do all the calculations in the fragment shader. The texture is just a cache that contains already calculated values, that you built in the CPU before.

Edit : I've submitted a new commit to the SVN repository. You can now change the color of the sky and sunlight for the different times of the day. Here is a sample screenshot of the game at night with the modified colors :
(http://darkdragon1.free.fr/ice3/ice3_008_th.jpg) (http://darkdragon1.free.fr/ice3/ice3_008.jpg)

Contrary to what one could think, the sun color at night is plain black. The blueish tint comes from the contrast with the warm color of the torch light down the cave.
Title: iCE³ - clone of Minecraft
Post by: Sylmael on September 16, 2011, 09:12:54 pm
:idea:
Oh thanks, i understand now perfectly. Well I work on a minecraft clone myself too. (first tried coding it in c++ but then moved to java and lwjgl). Maybe i can help you with my pearls of wisdom and knowledge somehow. ;)
Title: iCE³ - clone of Minecraft
Post by: Kalith on September 16, 2011, 09:16:50 pm
That would be greatly appreciated :)
Do you have a website or some other place where we can take a look at what you've done ?
And also, what made you switch to Java ?
Title: iCE³ - clone of Minecraft
Post by: Groogy on September 16, 2011, 09:22:00 pm
Actually Kal I have to say your lighting looks way better. You also seem to be one with some understanding to the whole thing. (Lighting and 3D Graphics) Which is more than you can say for Notch.

I would hope you soon end up with a more complete version with maybe survival? Maybe even do better and realistic water instead of that annoying fake algorithm in Minecraft.
Title: iCE³ - clone of Minecraft
Post by: Kalith on September 16, 2011, 10:05:11 pm
Quote from: "Groogy"
Actually Kal I have to say your lighting looks way better. You also seem to be one with some understanding to the whole thing. (Lighting and 3D Graphics) Which is more than you can say for Notch.

Thanks ! I still think that his lighting is better than mine though : [sample from Minecraft 1.8.1] (http://darkdragon1.free.fr/ice3/minecraft.jpg).
Although, I'd say that Notch has learned many things since he started Minecraft. True, the very first versions of his game were full of possible optimizations, unexpectedly slow etc. But the community, and - I guess - his co-workers, helped him a lot in improving the whole thing.
I don't know his previous works, but to me Minecraft looks like his first project. We all start somewhere : I for example am not proud of the very first lines of code of my life...
And you have to admit that he has a good sense of what a proper gameplay is ;)

Quote from: "Groogy"
I would hope you soon end up with a more complete version with maybe survival? Maybe even do better and realistic water instead of that annoying fake algorithm in Minecraft.

It depends on what you mean by "soon". As I said in a previous post, I worked on this project during my summer holidays, and now I'm back to work, serious work (http://www.amazon.com/Quantum-Theory-Fields-1/dp/0521550017), so I have very little time to spare.
I still feel the current version is buggy : there are some remaining collision bugs, chunk generation is not very pleasant performance wise (although chunk loading from disk is), and I miss several important features (like different light attenuation per block type and, as you said, proper water physics*).
Before thinking about a "survival mode" (for non Minecraft players : it's the game mode that contains monsters etc, to be compared to "creative mode" where you cannot die and have an infinite inventory), I'd first need to settle all this.
Then, and only then, I'd have to implement drops, a real inventory, monsters, weapons, a really interesting terrain generation algorithm, and on top of that : networking...
That's huge.

So I'm sorry but to be realistic, it won't be ready before 2012 (and we'll all be dead then... no ?).

* : Note that, in a blocky world of that kind, you can't do everything you want. Minecraft's water physics is probably the simplest ok-looking implementation, but it works and allows for interesting gameplay. Better water physics (like in Terraria for example) has a cost, but I still haven't thought deeply about it.
Title: iCE³ - clone of Minecraft
Post by: Sylmael on September 16, 2011, 10:43:21 pm
Saddly i don't have a website or blog for shoving my project. But i can share some screenshots. Sorry for the image quality. It's night here and i start to feel very sleepy.

About the project :
* currently there is a big bug after refactoring chunk class so the framerate is pretty bad
* working sliding collision
* working animated models
* sun & block lighting but only per face
* terrain and cave generator
* block placing, removing
* sky with sun (sunrise/sunset), moon, stars and clouds
* raining and snowing

(http://www.ulozisko.sk/obrazky/small-440025/demo01.jpg) (http://www.ulozisko.sk/440025/demo01.jpg)

(http://www.ulozisko.sk/obrazky/small-440030/demo02.jpg) (http://www.ulozisko.sk/440030/demo02.jpg)

(http://www.ulozisko.sk/obrazky/small-440031/demo03.jpg) (http://www.ulozisko.sk/440031/demo03.jpg)

And sorry if i spam your topic with pictures. I can delete them, or you can,  after watching.

Yes and why i switched to java. Simple reason : portability, faster developing and flexible code. Who knows, maybe i port it back to c++ someday. :)
Title: iCE³ - clone of Minecraft
Post by: Kalith on September 17, 2011, 11:14:46 am
Looking great !

I have a question then : how do you perform frustum culling ? Do you test each chunk against the camera's frustum on each frame ?
For now, I only perform culling when the camera moves. When the camera is still, performances are good of course, but not when moving... (it costs  5ms on my computer).
Do you have a special technique to improve that ?
Title: iCE³ - clone of Minecraft
Post by: Groogy on September 17, 2011, 11:34:09 am
I can actually propose something. Use a octree for the chunks. Should be perfect and let you cut down on the amount of checks you have to do. The only problem would be that you have to be able to extend the octree somehow which would either require you to reconstruct it or add a new root level ontop of the previous one which increases the depth. Though I think if you implement a 2D grid ontop of the octree you should be able to have it extendable efficiently as well.

Wha I'm thinking is that you make it so that a octtree have 5-10 chunks in it each. So testing would first be "Find what octree to test against" and since the grid cells are so big it should be very fast( more or less, what is my position and take the cells surrounding it) and then you test against the octree's in selected cells to find what chunks.

Might even be able to get away with using Quadtree since if I remember correctly, chunks don't grow in one direction right? You don't generate more chunks when going up and down.
Title: iCE³ - clone of Minecraft
Post by: Sylmael on September 17, 2011, 11:37:14 am
Thanks :)
This is the part i am trying to optimize now. I recalculate frustrum every frame even if the camera doesn't move (pretty hardcore i know).

Here is how it works :

* i have an array of big chunks 16x128x16 blocks (data) + bbox
* then i make 8 mini chunks (16x16x16 blocks) from each big chunk (8 display lists) and calculate their bbox as well

Render loop :
* looping through array of big chunks and testing against frustum : if in frustum then check which one from 8 mini chunks are in frustum too and add them to render array

It looks like simple octree algorythm.
Title: iCE³ - clone of Minecraft
Post by: Kalith on September 17, 2011, 11:42:47 am
Yes, using octrees is a possible solution I've been thinking of.
I've never implemented such a system but that shouldn't be too hard, I'll think about it more, thanks !

Quote from: "Groogy"
Might even be able to get away with using Quadtree since if I remember correctly, chunks don't grow in one direction right? You don't generate more chunks when going up and down.

Actually no. That's the way Minecraft works, but I decided to allow unlimited depth and height (as Minetest does). It complicates things a little, but I think it is worth it.
You loose some performance, as you have much more chunks to deal with (10 times more approximately), but you can also use that at your advantage to perform more culling (Minecraft renders everything that is below your feets, even if you can't see it). For example, in the current version, every chunk (15x15x15) that is surrounded by non empty chunks is not rendered if all its faces are hidden. That helps a little.

Edit : cross posting !
Yes that's more or less the philosophy of the octree... I'll try to see what I can come up with, thanks ;)
Title: iCE³ - clone of Minecraft
Post by: Groogy on September 17, 2011, 12:35:02 pm
I you need help with the octree just let me know.

I was thinking first that kD-tree's might be something because the cubes are more or less static. But then I remembered that if you remove a block then you have to recalculate the whole kD-tree and you would be VERY limited by what is possible to do.

I think Octree is the way to go. Just doing a single octree over the whole map won't cut it of course but I think you should start out with it and see the improvement. I can give you the code for finding a node fast for an object at aPosition with a size of aRadius:
Code: [Select]
Node *FindNode( const Vector3f aPosition, const float aRadius ) const
{
        Node *currentNode = myRootNode;
        while( currentNode != NULL )
        {
                bool straddle = false;
                int index = 0;
                float deltaX = 0;
                float deltaY = 0;
                float deltaZ = 0;

                deltaX = aPosition.x - currentNode->center.x;
                straddle = !( deltaX - aRadius > -currentNode->halfWidth && deltaX + aRadius < currentNode->halfWidth );
                if( deltaX > 0.0f )
                {
                        index = 1;
                }

                if( straddle == false )
                {
                        deltaY = aPosition.y - currentNode->center.y;
                        straddle = !( deltaY - aRadius > -currentNode->halfWidth && deltaY + aRadius < currentNode->halfWidth );
                        if( deltaY > 0.0f )
                        {
                                index += 2;
                        }

                        if( straddle == false )
                        {
                                deltaZ = aPosition.z - currentNode->center.z;
                                straddle = !( deltaZ - aRadius > -currentNode->halfWidth && deltaZ + aRadius < currentNode->halfWidth );
                                if( deltaZ > 0.0f )
                                {
                                        index += 4;
                                }
                        }
                }

                if( straddle == false )
                {
                        if( currentNode->children[ index ] != NULL )
                        {
                                currentNode = currentNode->children[ index ];
                        }
                        else
                        {
                                float step = currentNode->halfWidth * 0.5f;
                                Vector3f newCenter = Vector3f::Zero;
                                newCenter.x = currentNode->center.x + ( ( index & 1 ) ? step : -step );
                                newCenter.y = currentNode->center.y + ( ( index & 2 ) ? step : -step );
                                newCenter.z = currentNode->center.z + ( ( index & 4 ) ? step : -step );
                                currentNode->children[ index ] = new Node( newCenter, step, currentNode );
                                currentNode = currentNode->children[ index ];
                        }
                }
                else
                {
                        break;
                }
        }
        return currentNode;
}


There might be faster or better ways to do it. My class mates octree's check for straddle is a bit different. But they don't handle dynamically allocating new nodes. Anyway this is the basis for insertion. The rest is just collision checking with sphere against AABB and frustum vs AABB for each node as you traverse the tree. Removing an object from the tree should be the fastest(objects should remember what node they exist in)
Title: iCE³ - clone of Minecraft
Post by: Sylmael on September 19, 2011, 05:08:40 pm
One more question for you Kalith. Can you please explain me, which faces do you use when you calculate smooth - per vertex lighting?
Title: iCE³ - clone of Minecraft
Post by: Kalith on September 19, 2011, 07:41:29 pm
Quote from: "Groogy"
I you need help with the octree just let me know.

Thank you ! I'll keep you in touch ;)

Quote from: "Sylmael"
Can you please explain me, which faces do you use when you calculate smooth - per vertex lighting?

Sure ! Here is a little drawing, that will most likely be clearer than my words :
(http://darkdragon1.free.fr/ice3/smoothlighting.png)

The exact same algorithm is used for LEFT, RIGHT, FRONT, BACK and BOTTOM faces (of course, except the fact that the drawing is rotated), and for any of their 4 vertices.
Title: iCE³ - clone of Minecraft
Post by: Sylmael on September 19, 2011, 08:23:02 pm
Wow, this sure will help me further. Thank you very much. :)
Title: iCE³ - clone of Minecraft
Post by: easy on September 23, 2011, 01:54:26 pm
Check this out! (http://www.sfml-dev.org/forum/viewtopic.php?t=5932)
Title: iCE³ - clone of Minecraft
Post by: Kalith on September 23, 2011, 06:51:30 pm
Nice initiative ! And thank you for picking up a picture of iCE3 :)
Title: iCE³ - clone of Minecraft
Post by: easy on September 24, 2011, 12:16:01 pm
I've chosen this image:
(http://darkdragon1.free.fr/ice3/ice3_006.jpg)

Is it okay?
Title: iCE³ - clone of Minecraft
Post by: Kalith on September 24, 2011, 03:28:37 pm
That's up to you to decide ;)
I think the latest one is less cluttered with text : [click] (http://darkdragon1.free.fr/ice3/ice3_007.jpg).
Title: iCE³ - clone of Minecraft
Post by: easy on September 26, 2011, 02:09:01 pm
I've downloaded this last one you've suggested, but unfortunately I couldn't add it as a screenshot, yet... Sooner or later it should work!
Title: iCE³ - clone of Minecraft
Post by: meissner61 on October 05, 2011, 09:27:18 am
i tried playing the game. Unfortunetly at the start up screen it sais press escape and it doesn't work for me :(
Title: iCE³ - clone of Minecraft
Post by: Kalith on October 05, 2011, 07:08:45 pm
It works well for me on Windows. Are you playing on linux ?
Title: iCE³ - clone of Minecraft
Post by: meissner61 on October 05, 2011, 07:10:13 pm
no i am under windows 7 64 , its clearly running in the background as fps is changing and stuff.. but i am just stuck on opening screen telling me to press escape (Checked my escape button and it works) - any way to disable that start screen?
Title: iCE³ - clone of Minecraft
Post by: Kalith on October 05, 2011, 07:16:45 pm
That's strange. As a temporary workaround, you can go to the Save folder, and create a new file called KeyBindings.lua, in which you'll have to copy the following :
Code: [Select]
KeyBindings = {
    ["MoveForward"] = 17,
    ["Jump"] = 57,
    ["StrafeLeft"] = 30,
    ["MoveBackward"] = 31,
    ["StrafeRight"] = 32,
}


This is the standard WSAD layout for QWERTY keyboards. If you're not comfortable with it, you can adjust the numbers above using the KeyCodes.lua file, located at the root directory of the game.

This will prevent the start screen from popping the next time you start the game.
Title: iCE³ - clone of Minecraft
Post by: meissner61 on October 05, 2011, 07:19:07 pm
Very good worked! I am playing it now. You seem to have a very developed and thought out project, you are planning on doing a lot more?
Title: iCE³ - clone of Minecraft
Post by: Kalith on October 05, 2011, 07:28:34 pm
To me, it's more a tech demo than anything else right now. And as I've said in previous posts, I won't be able to work seriously on this for a while because of my studies. But nothing prevents me from coming back to it later, and who knows how far it'll go !
Anyway, thank you. Glad you like it :)