banner
[面包]MrTwoC

[面包]MrTwoC

你好,欢迎来到这个基于区块链的个人博客 名字:面包 / MrTwoc 爱好:跑步(5/10KM)、咖啡、游戏(MMORPG、FPS、Minecraft、Warframe) 兴趣方向:Rust、区块链、网络安全、量子信息(量子计算)、游戏设计与开发
bilibili
steam
email
github

[Spiritual Realm] Project - Phase One Progress

Time Record: 2024-11-30
Currently implemented the function to remove internal invisible blocks.
Project Link and Introduction

Personal Thoughts#

At the same time as completing this phase, the project name was changed to:

bevy-Demo-Spirit-Realm (Spirit Realm)

Here, I borrowed from Qian Lao's insights on VR and the name for VR; I also feel that this name is very fitting (it seems like it should be called this), and I want to incorporate virtual reality technology into the game.

Personally, I believe that virtual reality technology is not just about simulating reality in a virtual environment, but should attempt to combine the virtual and the real, complementing each other.

Phase Code Explanation#

Block Culling:

Create a hashmap (chunk_blocks), traverse the xyz axes and store all blocks in the hashmap, then use another loop to traverse chunk_blocks, and directly use an if statement to check if the six faces of the current cube are adjacent to blocks, then negate it to generate the block.

        if !(
            chunk_blocks.contains_key(&[pos[0], pos[1] + 1, pos[2]]) &&
            chunk_blocks.contains_key(&[pos[0], pos[1] - 1, pos[2]]) &&
            chunk_blocks.contains_key(&[pos[0] + 1, pos[1], pos[2]]) &&
            chunk_blocks.contains_key(&[pos[0] - 1, pos[1], pos[2]]) &&
            chunk_blocks.contains_key(&[pos[0], pos[1], pos[2] + 1]) &&
            chunk_blocks.contains_key(&[pos[0], pos[1], pos[2] - 1])
        ){
            add_cube_to_mesh(&mut positions, &mut normals, &mut uvs, &mut indices, [pos[0] as f32, pos[1] as f32, pos[2] as f32]);
        }

Currently, this piece of code needs at least two more optimization iterations. One is to judge based on the block type; for example, if a block's face is adjacent to a water block, it does not need to be culled. Currently, there are only two block types: 1: solid block, 0: air, and there will be more block types in the future, like water blocks. (Currently, for optimization convenience, only a line of triangles is displayed.)

The other is that blocks exposed to air have not been fully optimized; a block can only see three faces from any angle, while the other three faces are not visible, which also needs to be culled.

The image shows a cube composed of 32x * 64y * 32z blocks.
image

Next Phase Plan#

1. Remove the other three invisible faces. 2. Implement chunk management, simulating the player's visual radius, loading and unloading chunks as the player moves. 3. Create a super flat world, similar to the (super flat world) in Minecraft.
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.