My ingame solution is similar, but I use a circle rather than a box for the easiest. I handle vertical collisons (falling / jumping differently as this will be axis aligned - ie you dont tilt forwards and backwards)

What are you thoughts on dealing with non axis aligned collisions ....1, 2, 3 or another solution?

When rotation is nivolved it is no longer an AABB.What you need is an OBB with SAT.

This way you can already pick blocks to destroy them...But I honestly have no concrete Idea of how to do picking of single faces of a block...

I'd probably do that normal picking, and then construct a line out of the picking position, where the block was found and the camera position, and then test all the faces of the cube for intersection with the constructed line.

And you can easily cut down the faces that need checking down to 3 by not including the back faces.And if the camera position is equal to the block position on any axis then you can remove the faces on that axis too.

If you have the gradient of a line, then you can work out the x coords from the y coords and vice versa.In case you don't know linear algebra:

y = mx+c; x = (y-c)/m;

With that, you simply find which axis has the leastmost change (in this case x-axis), and interpolate along that line in ones, until you hit a block. Sometimes, you will have two y coords for one x coord. To avoid missing blocks that actually might be hit, you simply check for blocks on both sides of the intersected line. Once you hit a block, backtrack one space along the line to work out which face the ray intersected.

Of course it needs to be adjusted for 3D.

EDIT: I haven't actually tried this. I'm implementing it in my own game right now. It should work.

EDIT 2: Almost got it working. I just need to make it check for blocks on both sides of the line then it should be finished.

Hi, thanks for that. I have used Bresenhams line algorithm before in a 2.5D ray caster, also for Line of sight in a Tile based RPG game.

I have picking working fairly well now. I cast a ray from camera. I do it as you have outlined.

I do the vertical calculations first, and then from that I know the horizontal distance, which I just use trig to find the x and z distance. Like with Bresnenhams this can be optimised with similar triangles.

I don't know the usual resolution, but I'm casting 100 rays over 10 blocks. =0.1 block accuracy. I can improve this when I Find the individual face as you outline below.

The tricky part is if the line intersects exactly on the corner of 2 blocks, an thus traces through them. Mathamatically possible, but not what we want!

I'm having trouble with a texture on a cube as I want to texture my blocks now, they look too bland just using colours. I'm getting weird effects, I've textured just a cube which looks fine, if my texture is green (grass), then the rest of the blocks which aren't being textured by the way, will also take on this colour...have you seen anything like this before?...If the texture is brown/crate, then again all my colours on my blocks seemed to get 'tinted' with the texture colour?!

I'm using PNGDecoder, also used slick-util with same results.

Thanks and keep up this great work, it is inspiring!

*UPDATE - got it working, I was forgetting to disable the textures for blocks that don't need a texture!

Is it possible that we could get the source for the new version of your game? I've made my own block engine but it's not great on efficiency / performance, and I'd love to learn from someone better's code to see where it can be optimised and what methods I should be using.

Im going away for a few days so no work on this till monday. Someone is going to host the code for me, on my return I will make all the codeavailable. It's not fancy code, infact its probably a good example of not what to do. I't is not optimised, or organised. But I like to just get things working first.But if it helps solve any problems that people can build on then sure.

How about never disabling Texture2D?The only thing you have to do is, to put a white pixel in the top-left corner of the texture.And everytime you don't need texture's anymore, just set TexCoord to 0:0.

Stop being better at this than me :/ I almost deleted my project last night, I've been struggling lately. Do you use opengl's built in lighting to do your lighting right now? Or are you using vertex coloring?

Stop being better at this than me :/ I almost deleted my project last night, I've been struggling lately. Do you use opengl's built in lighting to do your lighting right now? Or are you using vertex coloring?

I face many problems with my project , too that I don't really see how to fix them.

My main issue is a vertex bug. At location 0, 0, 0 this little triangular shape set of vertices draw. I have come to conclude that they cause an issue where random vertices are drawn when my chunks update. I turn on wire frame mode and look in my chunk when it updates, and all of a sudden, close to 2,000 triangles draw and then delete themselves. My whole game slows down to 30 FPS, which is ridiculous seeing as when drawing 1 chunk, I get close to 2,000 FPS. I have come to call this bug the "0, 0, 0 update bug". I'm starting to think the issue is that I'm using quads and not triangles, and maybe the quads aren't being processed correctly. Fortunately, I bought a copy of the SuperBible, and it came today, so I'm going to learn modern OpenGL.

So while this guy is pretty good, and he obviously has been learning OpenGL more than me, I think my programs suffer mostly from my lack of OOP :/ I frequently have to re-design classes, and I hate it. Oh well...

Tests using vertex lighting for skylight shadows.When a block is placed, a search is made for blocks underneath that did have sky illumination. An area is then modified by around the block, decreasing the light level.So multiple connected blocks will decrease the level more and more.

Really nice work! I am looking forward to implementing lighting im my project too. This can create amtospheric highlights. But for now, I am still struggling with my collision detection, trying to make it better and more efficient.

Just a random Question again:Does anyone that makes a Voxel Engine make any plans?It seems like everyone just want's to clone Minecraft as fast as possible,ignoring all good programming principles while doing so.

As this goes to everyone building those engines I feel like answering:It sounds like an accusation. Even if it just was for copying the idea as fast as possible and getting it running, I don't see any problem in that as long as it is for fun.

As you can see in my thread, I am taking my time to optimize things. And I think others do aswell. For me it is a good thing to learn it by just copying the concept of minecraft, because these are my first steps in 3D programming and I am happy with my project. I love Minecraft and I would like to see if I can be able to get something similar working. Then, after that, I will go on making my own stuff with the things I have learned. This is my plan.

Just a random Question again:Does anyone that makes a Voxel Engine make any plans?It seems like everyone just want's to clone Minecraft as fast as possible,ignoring all good programming principles while doing so.

Does anyone here plan anything?

- Longor1996

Hi Longor

I do have a specific project in mind. It's nothing to do with a voxel game, but it does involve geometry created at runtime, and by working on this voxel project I have been developing the missing skills need to make the other project work. I will be posting the new project once its in a state to do so. I know others in this thread are also using this project to learn some new skills. As for ignoring programming principles, yes I am guilty - but like I say, it literally was just to test how something worked like VBO's, lighting etc.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org