LWJGL - Voxel Engine


	glLoadIdentity();  

	GL11.glRotatef(10, 0, 0, 1);
	GL11.glTranslatef(-0.05f, (walkbias / 2.3f) + 0.9f, 0.4f);

       // draw cube

What walkbias is?

It’s just a value that is calculated to get a bobbing effect - I got the idea from Vermeer who I believe got it from one of nehe’s tuts.

You can just do:

GL11.glTranslatef(-0.05f, 0.9f, 0.4f);

You may have to play around with the values dependant on your camera position.

I found some time and started working on the engine again, but I still cannot get the holding cube right. Can someone send me a working piece of code about the holding cube?

Some of the strangle results:

VFrsQmG3zQw

Paul.

Yes walkbias is from NEHE’s tutorial. I have scaled it down by 2.3 as the motion does not need to be as pronounced as the full bias of the character.

Draw it last and don’t do any depth testing.

Mike

I looks like you are not translating and rotating it properly.

this is from a page on my blockworld page

you can also download my code, its on there somewhere. This part is halfway down the render method

I don’t translate the position - just set identity and position the cube after.

I just do:


	glLoadIdentity();  

	GL11.glRotatef(10, 0, 0, 1);
	GL11.glTranslatef(-0.05f, (walkbias / 2.3f) + 0.9f, 0.4f);

       // draw cube

The above is called after my camera has been translated.


	glLoadIdentity();  

	GL11.glRotatef(10, 0, 0, 1);
	GL11.glTranslatef(-0.05f, (walkbias / 2.3f) + 0.9f, 0.4f);

       // draw cube

What walkbias is?

It’s just a value that is calculated to get a bobbing effect - I got the idea from Vermeer who I believe got it from one of nehe’s tuts.

You can just do:

GL11.glTranslatef(-0.05f, 0.9f, 0.4f);

You may have to play around with the values dependant on your camera position.

Yes walkbias is from NEHE’s tutorial. I have scaled it down by 2.3 as the motion does not need to be as pronounced as the full bias of the character.

Thank you all for your help. I used steg90’s method, and it worked. I was expecting something more compilicated with usage of trigonometry to tell you the truth.

My current problem is that from some angles, players cannot see the rest of the blocks through a transparent block. At some points it seems like there are no other blocks behind the transparent ones like water. I don’t know if my explanation is good enough to understand. I am not sure what causes that.

Paul.

To fix this problem (almost):


			GL11.glEnable(GL11.GL_BLEND);
			GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
			GL11.glAlphaFunc(GL11.GL_GREATER, (float) 0.1);

And then you will also have to do depth-sort your chunks.
Then render opaque things front-to-back, and then render back-to-front transparent things.

Example:


List<?> visibleChunks = ???;
Collections.sort(visibleChunks,frontBackDistanceSort);

for(int n = 0; n < visibleChunks.size(); n++)
    visibleChunks.get(n).renderCall(OPAQUE);
for(int n = visibleChunks.size()-1; n >= 0; n--)
    visibleChunks.get(n).renderCall(TRANSPARENT);

  • Longor1996

Thank you all for your help. I used steg90’s method, and it worked. I was expecting something more compilicated with usage of trigonometry to tell you the truth.

My current problem is that from some angles, players cannot see the rest of the blocks through a transparent block. At some points it seems like there are no other blocks behind the transparent ones like water. I don’t know if my explanation is good enough to understand. I am not sure what causes that.

Paul.

To fix this problem (almost):


			GL11.glEnable(GL11.GL_BLEND);
			GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
			GL11.glAlphaFunc(GL11.GL_GREATER, (float) 0.1);

And then you will also have to do depth-sort your chunks.
Then render opaque things front-to-back, and then render back-to-front transparent things.

Example:


List<?> visibleChunks = ???;
Collections.sort(visibleChunks,frontBackDistanceSort);

for(int n = 0; n < visibleChunks.size(); n++)
    visibleChunks.get(n).renderCall(OPAQUE);
for(int n = visibleChunks.size()-1; n >= 0; n--)
    visibleChunks.get(n).renderCall(TRANSPARENT);

  • Longor1996

The creator of Dysis (Arktos) got around that problem by rendering chunks in 2 passes.

The first pass is all the normal blocks.
The second is water and all the other semi-transparent blocks

(Make sure all chunks are rendered by the first pass before going onto the second pass.)

Wow, after adding some simple checks to try your solution the game crashes everytime I try to spawn water and this is the error log.

I googled it and some people had this error at minecraft. The possible reason was the graphics card driver, but it is the first time I get this. (Also, first time I use transparency.)

http://pastebin.java-gaming.org/d6d37427e58

Paul.

I used 2 render passes for transparent water etc…

Just tried that and it worked.

Thank you, HeroesGraveDev.

The creator of Dysis (Arktos) got around that problem by rendering chunks in 2 passes.

The first pass is all the normal blocks.
The second is water and all the other semi-transparent blocks

(Make sure all chunks are rendered by the first pass before going onto the second pass.)

Wow, after adding some simple checks to try your solution the game crashes everytime I try to spawn water and this is the error log.

I googled it and some people had this error at minecraft. The possible reason was the graphics card driver, but it is the first time I get this. (Also, first time I use transparency.)

http://pastebin.java-gaming.org/d6d37427e58

Paul.