I don't know how much you know about (vertex & fragment) shader but you might want to look into setting positions via a shader uniform rather than modifying the vertex data itself (which is much more expensive). Since you're already useing OpenGL 3.1+ (VBOs) you might as well use shaders as well - if you are not using them already.

The loop would look something like that:1. use shader program (glUseProgram) and upload the uniform offset (glUseUniform)2. render the vbo3. get the next vbo and continue

Of course this only works as described if all vertices share the same offset which should be the case with chunks.

Don't you mean OpenGL 2.1? Pretty sure vbos and shaders are standard in that.But I agree completely, shaders are the way forward. I used to try and find "smart" ways of doing things without using shaders but it's just pointless. It's inefficient for you and your computer. Shaders are just simple. As soon as I read the first tutorial, I realized that and cursed for all the time I'd wasted avoiding them.

This does the whole chunk in one go, does this seem correct?Before I was create a display list just for one cube, not a whole chunk, now just have one call todraw a chunk, not 4096 (which is 4096 glTranslatef calls too!).

I guess I need to have an array of display lists for each chunk? How many display listscan you have? PS - I'm doing it this way before eventually moving onto VBO's, want to walkbefore I can run, and hey, Notch used display lists :-)

glBegin(GL11.GL_QUADS);renderBlock();glEnd();iBlockCount++; // total of blocks that can be seen }elseiHidden++; // amount of blocks that are surrounded } } }System.out.println("Block amount hidden by neighbours:" + iHidden +" and Block total rendered:" + iBlockCount);returniBlockCount;

}

Next will be to add some FrustumCulling.

Anybody any tips on when to set blocks to certain types...i.e.dirt, grass...would this be dependanton the height value?

That's looking good, I like the lighting and the skybox. Thanks for posting that. I started with immediate mode. And I'm trying VBO but its quite a learning curve. Though it does draw much faster for me.

Display lists seem to be performing fine for me, I've put some stuff into VBO's and tested, doesn't seem too bad to do, although it looks like it depends on the version of OpenGL you are using with some of the methods as they do change a lot?!

Think if I put in frustum culling, will need to partition the space up, octree comes to mind, have you implemented one in your project?

What do you mean by your space is partitioned into 16^3 chunks? I guess you meanyou re using chunks of 16x16x16, this is the same as me.

What would be needed is to use an octree structure to partition the world into smaller spaces, thus when doing frustum culling there isn't as many checks to do - I can't really see the point of doing frustum culling without space partitioning unless somebody tells me otherwise?

I'm also doing neighbouring checks on the blocks so blocks that are hidden by other blocks aren't rendered.

Wanting to add a player to the voxel engine now. I've basically just centred a cube as the playerin the centre of the screen. I'm just applying the camera's pitch to the player, something like this:

1

glRotatef(-yRot, 0.0f, 1.0f, 0.0f);

Where yRot is the camera's pitch, now I'm presuming I don't move the player about, just the world as I am doing with my camera? I did try to make the player cube rotate on the X-axis, but it looks silly as the cube goes out of alignment with the world:

1

glRotatef(-xRot, 1.0f, 0.0f, 0.0f);

My question is, how do you add a player and move it around the world correctly - i.e. so it 'angles' with the land so to speak...

Just added in block detection - basically detect if block you are on is active or not, need check if block in front, back etc are active also and then need to stop you moving when you are!

How is yours going?

The way I did that is when u press to move it adds on you x and z vectors to your position, then if that block is solid at you height, then you can't move, otherwise you go ahead and apply those vectors.

I got camera moving up and down, my player always stays in same place, don't know if this is correct?

I'm trying to put collision detection in, can detect when player has a block in front, underneath etc, but if player turns (camera turns) and then move's forwards my collision is all messed up. Think I need to know which way the camera is facing, thought I had this with some trig:

direction = atan(camerapos.x / camerapos.z );

How are you doing the player movement, collision detection?

Anybody else got any tips on collision detection with block - and how would I implement a vector slide?

Maps will be larger, just messing around at the moment, just want to get the collision stuff working, thought this would be simple.

piover180 = 0.0174532925f to convert to radiens xpos, zpos are my float player positions. yrot, y axis rotation.0.35 is the distanced moved (notice its more than the actual movment, this is so you cannot get too close to a block) (ie the camera has a size)There is an issue with this and diagonally placed blocks. This will be sorted later.

the player updates are only applied if there is not a block.

1 2 3 4 5 6 7 8 9 10 11 12

privatebooleanisBlock(floatx, floatz) {

intc = getChunk(x, z); //get the chunk of the block

x=x%16; //this will find the block within the chunk z=z%16;

if(chunks[c].getblockID(x, (int)playerheight,z)>0)returntrue;

returnfalse; }

This is a simplified version of my isBlock code. (ther is some stuff in there to sort out negativate coordinates)The Chunk getBlockID just returns a value. 0 is Air, all other blocks are solid at the moment.This assumes the player is 1 block high!

If you want any more code Ill pop it on. It works for me, but more experience programmers may have better solutions.

//3d vector to store the camera's position inprivateVector3fposition = null;//the rotation around the Y axis of the cameraprivatefloatyaw = 0.0f;//the rotation around the X axis of the cameraprivatefloatpitch = 0.0f;

//translates and rotate the matrix so that it looks through the camera//this does basically what gluLookAt() doespublicvoidlookThrough() {//rotate the pitch around the X axisGL11.glRotatef(pitch, 1.0f, 0.0f, 0.0f);//rotate the yaw around the Y axis// remove line below for third personGL11.glRotatef(yaw, 0.0f, 1.0f, 0.0f);//translate to the position vector's locationGL11.glTranslatef(position.x, position.y, position.z);

}

}

How do you initialise your camera position at the start and your floor?

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