0
\$\begingroup\$

I am making a voxel game with OpenGl, I've got the major parts working, except the camera seems small compared to the the blocks. How do I make the camera bigger?
Do I do a scaling on the model matrix for each chunk? Or do I do something with the view matrix of the camera? When i tried these things, it messed up the coordinate system of my game, the blocks were not were they really were.I just want the player to be visually 2x bigger.

// the view matrix
glm::mat4 Camera::GetViewMatrix()
{
    glm::mat4 view = glm::lookAt(position, position + target, up);
    return view;
}


    // Where i do the chunk rendering
void WorldRenderer::RenderChunck(Chunk *c)
{
    glActiveTexture(GL_TEXTURE0);
    worldTexture->BindTexture();
    worldShader->Bind();
    worldVertexBuffer->BindVertexArrayBuffer();
    worldVertexBuffer->PutVertexData(c->meshData.verts, c->meshData.indices, c->meshData.textureCoords);

    glm::mat4 model = glm::mat4(1.0f); // model = local space to world space
    model = glm::translate(model, vec3(c->pos.x * Chunk::CHUNCK_SIZE, c->pos.y * Chunk::CHUNCK_SIZE, c->pos.z * Chunk::CHUNCK_SIZE));

    worldShader->setMat4f("model", model);
    glDrawElements(GL_TRIANGLES, c->meshData.indices.size(), GL_UNSIGNED_INT, 0);
}
void WorldRenderer::Render(glm::mat4 projectionMatrix, glm::mat4 viewMatrix)
{
    worldShader->setMat4f("view", viewMatrix);
    worldShader->setMat4f("projection", projectionMatrix);

    for (Chunk *c : renderedChunks)
    {
        this->RenderChunck(c);
    }
}

Image of the game

\$\endgroup\$
  • \$\begingroup\$ Try scaling geometry in view space in the shader \$\endgroup\$ – Ocelot Sep 6 at 0:21
2
\$\begingroup\$

Move the camera higher up. The human brain expects to be see from the normal human eye height above the ground, so about 150-170 cm. So your walls look about 4-6 metres high. Make the camera 10 times as high, and now they're 0.4-0.6 metres high.

Your current perspective is appropriate for a dungeon crawler where each wall is a voxel and the walls have traps and doors in them and so on. It's not appropriate for a Minecraft-style game. Minecraft intends to have 1-metre cubes, so it places the camera 1.6 cubes above the ground.

As HolyBlackCat said, don't forget to choose an appropriate movement speed as well.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

There's no such thing as "camera size". If you have a free-moving camera, the perceived "camera size" depends solely on the camera movement speed.

If you make your world N times larger and increase the movement speed N times, those two actions will cancel each other out, and the end result will be the same.

So instead of making the world larger, make the camera move faster. There's nothing more to it (except maybe changing the initial camera position to be higher above the ground).

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.