ANOTHER Minecraft clone

Community Forums/Showcase/ANOTHER Minecraft clone

Kittomer(Posted 2011) [#1]
EDIT: Aw, damn. I wanted to post this to the showcase. Sorry. Can a mod move this?

Yes, yes, I know.
But, it seemed like a fun way to learn 3D programming, and it worked well enough, I learned a lot, some of which I would have preferred not to learn, though.

I am thinking about making some sort of dragon sim city with lair building.
Hunting cows, killing knights for hoard, that sort of thing.



Left click REMOVES blocks, and right click ADDS blocks. It will add the same type of block that was removed last, so for now you pick blocks to place by removing one of the same type.

TAB or ESCAPE opens the menu when in the game.

W,A,S,D is movement.
Space is jump or when pressed repeatedly flying by "flapping" wings.

There is a bug that sometimes causes some (and sometimes huge amounts of) chunks not to render/calculate/get queued. I don't even know WHAT excatly isn't happening, need to write a debug function that can trace this when I identify a missing chunk. I don't know what happens, I couldn't find the culprit in the code so far.

Next on my list is still fake ambient occlusion, but I really need to finish the saving function. It's already in there, but slow, makes huge files, and EXTREMELY buggy. No reason to save when it asks you, just say no.

Download:
http://www.kittomer.com/temp/dragoncraftwip5.zip (2,3 MB)

Last edited 2011


slenkar(Posted 2011) [#2]
it gives me an exception access violation


Kittomer(Posted 2011) [#3]
You mean, right at the start? Huh, weird, it hasn't given that on any of my computers yet.

Maybe you haven't extracted the zip with folders intact? I don't think I put in any checks for missing files.


BlitzSupport(Posted 2011) [#4]
Worked well here, very smooth considering how much it's drawing!

I noticed that the player's collision radius seems to be way too large -- you can't easily go inside caves/tunnels that you build.

@Slenkar, maybe try running the config utility and setting everything to known good values for your system.


GW(Posted 2011) [#5]
ya, just throws an exception..


ando(Posted 2011) [#6]
I tested on 2 pc's.

First, older xp with low to medium stats. After about a minute of loading a black screen started to appear then vanished. No error message, just gone.

Second, new laptop running win7 64 bit 4gig ram, 1gig vid, AMD A4-3300M APU with Radeon HD graphics twin cpu about 1.9 GHz DX11.
It ran quite well and looks good. When I walk around, for the first second it's smooth and fast before going jumpy and slow. If I walk for a second at a time, it stays in smooth mode.

EDIT
I just played with the config and got it running pretty good......my bad. : )

The config also got it working on the xp, but only just.....(BTW, I wasn't blaming XP, it's the old hardware I've got it in ).....

Ando.

Last edited 2011


Yahfree(Posted 2011) [#7]
Written in?

How does it work?


Kittomer(Posted 2011) [#8]
I tried to optimize it as much as I could, even though I still feel it's slower than what minecraft does.
Well, until you visit an area for the second time, then the terrain data is cached and it only has to build the mesh, which goes pretty fast.

Blitzsupport: Well, the big collision radius is due to the fact that in the game you're supposed to be a dragon, when its finished later on. Also, I made some mistakes in planning, since this was my first minib3d venture. I assumed that the world Z axis was "up/down" and since minb3d seems to be built around the idea that it's more like Z is in or out of the screen, I'm suffering some problems now.

GW: Try using the config tool and make sure the directories have been extracted properly. I didn't put in any checks for proper video config and file location yet, so, if other blitzmax/minib3d games work for you, this one SHOULD too.

ando: I am glad you got it working after all! Your laptop must be pretty dusty. ;) I've 4 computers at home to test it on, and the oldest is a first generation pentium 4 with a Radeon X800, and even that one runs it respectably, if I ignore the speed penalty from the aging harddrive.

Yahfree: It's written in Blitzmax with MiniB3D. And it works pretty much like Minecraft does. At least I think so, I couldn't find out that terribly much about its inner workings.
It's using chunks of 16x16x128 blocks to build the world, based on perlin noise. I love perlin noise. I'm only building the faces of blocks that are exposed to air, and later water, when I make the fluids working.
There's lots of visibility checks to make sure as little as possible overhead in rendering and keeping the meshes is in there. I store all the calculated voxel data in an array, so that I only have to rebuild the mesh when a chunk is in visible range again.

I'll probably need help with saving that voxel data though, saving it raw is not an option, since it's about 260 MB of data for a 1024x1024 map. I tried to use Gman's zip mod to compress it, but it crashes when I try to add big files to the zip. I haven't yet tried to stream the data into the compression, because I'm not quite understanding yet how it works, and I want to be sure It can still handle big files that way. I guess I could try saving it in chunks, but that is just opening another can of worms.
Does anyone have experience with zipping large amounts of data out of blitzmax?

I'll probably have to go down the route of saving chunks, since saving all the data at once also takes a while.

This whole chunk thing is nice for optimizing, but a nightmare to program, in my opinion. :P


Tachyon(Posted 2011) [#9]
Very cool. Any thought about sharing the source code and perhaps turn it in to a community project?


skn3(Posted 2011) [#10]
Considering you will have large spaces that consist of the same block type, could you perhaps compress it similar to how you would do simple image compression by pixel Color? http://en.m.wikipedia.org/wiki/Run-length_encoding


John Cage(Posted 2011) [#11]
How to run this? It gives an 'access violation' in my XP.


Kittomer(Posted 2011) [#12]
Tachyon: I'm not really intending on making this open, I already work with a couple of people on this, and it probably will stay private, without any sort of big public release.

Someone else here already made a Minecraft clone, with the source being public and probably a lot cleaner and more efficient than mine anyway. XD

skn3: Well, for the moment, I'd just be happy if I could get it into a zip file, until I have hammered out all the data I would need to keep and save. Then I will think about something more efficient/specialized.

John Cage: It seems to be from all the reports I got so far, that it crashes on Windows XP computers at the start. Seems to work fine on Vista machines. I have to look into this, I have old XP machines I will test my code on.


FBEpyon(Posted 2011) [#13]
Hello Kittomer,

How are you doing your culling on your engine, I have been trying to get mine to work, and not very successful on it.. Do you have any suggestions..?

William Mc.


Kittomer(Posted 2011) [#14]
What exactly is the problem for you?

I don't really do any actual culling of the faces, outside of whatever the graphics card does.

I only check for two things:

- Is the chunk in visible range?
- Is the chunk visible on screen currently?

That really is enough.

I'd say most modern graphics cards, even low end ones, usually don't have a problem pushing a lot of simple textured polygons on the screen, as long as you keep the draw calls down.

Try to get as many faces as possible in one mesh/entity.

Only create faces that can actually be visible, i.e. only mesh faces that are exposed/adjacent to air or transparent liquid.


FBEpyon(Posted 2011) [#15]
Well; this is what Im currently doing for the faces, but what about all the faces that are not facing you or have a <0 normal you wouldn't want to light these until the transformation matrix has changed it to >0, and I'm having to modify the minib3d to help with depth testing and adding in shaders to help with lighting, as using Createlight() function is out of date, and most people use shaders to control the lighting.

Anyways... ***I was just seeing if you were taking away the <0 normal faces and only drawing anything that is needed that is >0 to the camera..***

*** This statement might cause slow rendering so I'm only playing with it for now. I'm just starting to work with OpenGL more bought the super bible and trying to convert a lot into OpenGL 3.3 >

William Mc.

Last edited 2011


Kittomer(Posted 2011) [#16]
You mean the backface culling? Usually minib3d should be doing that by default, unless you disabled it with "EntityFX Mesh, 16". Or modified minib3d so much that you broke it. ;)

I'm using an unmodified (well, except of course the changes I did to get nearest filtering.) miniB3D version, and I didn't have any trouble with lighting so far. I use vertex colors for static lighting and a normal direct light for the sun, and that seems to work just fine to me.

I don't really intend to modify mB3D any more, unless I hit some big problem somewhere.


FBEpyon(Posted 2011) [#17]
No; I was talking about removing any blocks that are behind another one.. by doing this you are removing unwanted rendering and hopefully speeding up the program, but at the same time, doing this real time cause major slowing of the program, so I'm hoping there is a way to do this another way.. :(

MiniB3d has depth buffers, but there current depth buffer is still messed up..

William Mc.

Last edited 2011


Kittomer(Posted 2011) [#18]
Oh, now I get it.
You are generating every cube in a chunk? All 6 faces maybe? Maybe even as a seperate mesh?
No wonder it's too slow. You don't have to do that, use chunks.
I am using 16*16*128 blocks sized chunks. (Splitting chunks into smaller chunks along the depth axis didn't add any speed gains I could

detect, and just added complexity.)
When you create the geometry for the chunk, don't create every face for every cube, or god forbid, even use createcube.
Every chunk should have a single mesh, which contains all the faces for that chunk.
Calculate all the 3D noise data for that chunk, then mesh it face by face, based on that data.
Simply only create the faces that are in contact with air blocks (or anything else that is transparent)

If I'm still not talking about what you mean, then I'm stumped. XD

Anyway.

I've created a new version that fixes two serious bugs and adds a feature:

- No more missing chunks!
- Crashing on startup issue on Windows XP (and maybe others) SHOULD be fixed.
- Simple sun light system added.
- Also some smaller crash fixes that should have been unlikely to happen anyway.
- Quite possibly some speedups. Maybe.
- Saving and Loading is a bit less of a mess, but still slow, large and loading causes massive corruption. No idea yet why.





Download:
http://www.kittomer.com/temp/dragoncraftwip6.zip (2,3 MB)

Last edited 2011


FBEpyon(Posted 2011) [#19]
Hello Kittomer,

I'm building every chunk into one mesh, then adding faces based on if there is AIR need to that block, then going through the mesh and remove any extra un-needed vertices and rebuilding the mesh.

I have been playing with this kind of block system for a few months now, and I'm very OCD about my code an how things work, so I have re-written the code 6 times.

But I'm just trying to see if other might be doing something different and should be releasing an alpha in about a month or so, once I know for a fact that this is running correctly..

William Mc.


Luke111(Posted 2011) [#20]
Based On The Screenshots:
I take it you are using 3D Perlin Noise and scaling the chunks up to, say, 6 or 8 times? It looks better than mine! Good job!

Is that real water physics?

Also, I am just curious if you are using the same algorithm I am using for building blocks:
(example is we just picked the left side)

1. Figure out that X mod 1 = 0
2. Check if there is a block on X,Ceil(Y-1),Ceil(Z-1)
3. if there is, we just picked the left side. Otherwise, right side.
4. We picked the left side, so make a block at x-1,Ceil(Y-1),Ceil(Z-1)

Chunking makes it more complex, but you can have a look at Engine.bmx in the zip Lukeminer 0026 at http://experimental.thegamerboard.com if you are curious on how I did it, but you probably don't need any help; I think you implemented this already, right?

Oh, also, What I would do is make an array of the block types' images and show that on the screen, and use 2 keys to change left and right the block type in the array. Use a variable to determine what type is selected in the array, and reflect that in the UV coordinates of the texture on the vertices. That's how I did it, I am sure you can come up with a better way.

One last thing: Nice shadowing!


Kittomer(Posted 2011) [#21]
Yep, it's 3D Perlin noise.

I haven't implemented any liquid effects yet, should be fun to figure that one out.

And no, to figure out which side of the block I picked, I use the difference between the picked coordinates and the camera coordinates.
To place my cursor:

CameraPick (_DefaultCamera, (GraphicsWidth() / 2), (GraphicsHeight() / 2))
_PickCacheX = PickedX() ;_PickCacheY = PickedY() ;_PickCacheZ = PickedZ()
		
If _DefaultCamera.px > _PickCacheX _XDelta = -0.01
If _DefaultCamera.px < _PickCacheX _XDelta = 0.01
If _DefaultCamera.pz * -1 > _PickCacheZ _ZDelta = -0.01
If _DefaultCamera.pz * -1 < _PickCacheZ _ZDelta = 0.01
If _DefaultCamera.py > _PickCacheY _YDelta = -0.01
If _DefaultCamera.py < _PickCacheY _YDelta = 0.01
							
PositionEntity (_3DCursor, Int(_PickCacheX + _XDelta) + 0.5, Int(_PickCacheY + _YDelta) - 0.5, Int(_PickCacheZ + _ZDelta) + 0.5)

Not very impressive, but works, mostly. :P
Add/Remove blocks uses pretty much the same code.

Chunks are already implemented, and works fine so far.

One of my next things on the list is a user interface for the blocks, yes.

I tried your version and it looks good so far!


Luke111(Posted 2011) [#22]
The problem that my version gets with my picking algorithm, is that often the picked x, y, or z that is supposed to be "Mod 1 = 0" is really about X.999987
Instead of X.0

I like your concept for picking and placing the blocks, along with the cursor.

Thank you for the support with my version!


Kittomer(Posted 2011) [#23]
Well, glad I could help you. :)

An update to the current version:

-A small inventory hot-bar. Can be scrolled with the mouse wheel, later hot-keys, too.
-Water is now transparent and can be entered all water-like
-Water flows!
-Trees now have a transparent, leafy crown
-Some bug-fixes
-Some speedups, unfortunately the new features ate them, probably is even a bit slower now.

Download:
http://dragoncraft.kittomer.com/?page_id=43