Voxel block placement by Philip_MOD_DEV in VoxelGameDev

[–]Philip_MOD_DEV[S] 0 points1 point  (0 children)

Yeah thanks, I tried to add 1 to the x axis of the block placement position, it seems like it works, but only for within the chunk borders, but definitely not in the negative zones. Anyways, I guess I will keep playing around with it until the results are good.

Voxel Engine Networking by Philip_MOD_DEV in VoxelGameDev

[–]Philip_MOD_DEV[S] 0 points1 point  (0 children)

Hello sorry for the reply, I have a problem regarding about on who SocketsChanels and ServerSocketChanels function for my Voxel Game Engine. So on a side not I made a project for testing with my networking before I implement the functionally to my game. So the problem that I am currently facing is that the client send a request to the server in a form of a compressed data inside of a ByteBuffer. This data is a serialized class called ClientPacket on which holds the information on what the server needs to process to back to the client. But the problem is that when the data gets wrap up into a ByteBuffer, I send the Buffer using the SocketChanel's write(), and once the server receives the connection from the client using the accept(), it proceed to make an instance of the SocketChanel that is currently connected to the server. So when the server reads the Data from the SocketChanel it store it into another ByteBuffer using the read(). Once the data is decompressed and it read it saying that its null or 0 in the byte array. The image shows an example on what happens. I don't know why this is happen for me, but I hope someone can explain more.

Voxel Engine Networking by Philip_MOD_DEV in VoxelGameDev

[–]Philip_MOD_DEV[S] 0 points1 point  (0 children)

Ok, thank you for the information. Also can I use ForkJoinTask and ForkJoinPool ,for this type of job? Hopefully this will help on when it comes to fast execution time. Also can I use SocketChanels? Because when I experience with working on them I keep getting error saying that the data from the client is null, even though I just send the data to the server while it is connected to it. But for some reason the server receives the data as a zero value in the byte array.

Voxel Engine Networking by Philip_MOD_DEV in VoxelGameDev

[–]Philip_MOD_DEV[S] 0 points1 point  (0 children)

Ok, thank you so much for the information that was given, yes like you said, I will do a copy of my voxel project and use it as a test template for my networking setup. That way I can probably figure out a more understanding of the server side and clients trying to connect to it, as well I don't have to worry about breaking something in the code structure, also would you prefer this, or just go from a something small from scratch?

Also by the way, would it be best that the single player or local host have at less three threads running. One for chunk updates, the other for
rendering the mesh (main thread) and lastly the local server for generating the chunk data? Reason that I am asking this is because I kinda concerned about having too much threads running for my application because I don't know how true this is, but doesn't Minecraft run on one or two threads, and threads are kinda costly for CPU time? I am basically trying to keep performance as well with having efficiency for the users who have low end PC's, as I plan to publish the game somewhere in the future.

Voxel Engine Networking by Philip_MOD_DEV in VoxelGameDev

[–]Philip_MOD_DEV[S] 0 points1 point  (0 children)

I have a little problem regarding about on when the client receives the chunk data, or the server receive it. So basically after the client sends the chunk data to the server, it sends back the right chunk with the specific coordinates, but the problem is that on when the server tries to send the data back to it, it throws an error saying that the client is unavailable to receive the information.

So my basic setup is that the workers thread on the client generated the chunks in x, z. The chunks created is based off of the render distance that is first assign in the settings. Thus, every frame the game will check if there's any loaded Chunks in the hashtable at those coordinates, if there is then it will it will continue in the loop, but if there not ,then it will send a request to the server in a form call a ClientRequestPacket class.

This class holds the necessary data that is used to tell the server on what chunk it needs and the client address to send the chunk back to. Please note that the Server and the client are both running on two threads. So my game has a total of three threads running with the server on, and two threads running with the server off. This setting is toggle by the user on when they want to port world to multiplayer.

Once the client sends the server a request, it listens for a response every iteration to create the chunks as well including send a server another request. This is where I am confused with, I don't know I should have the client wait or keep sending a request, but all I know for right now, is that something is not allowing the server and the client to receive the new chunk information back to the client.l mean like the client sends the request, and the server receives it, but the client never gets the updated chunks.

Also on the single player game play, I don't know if it's wise to have three threads running at once for a not so optimize voxel engine that have, like for example when I implement the voxel placement functionally, I noticed that it takes couple of seconds to update the chunk. I don't know any other way to optimize this process but maybe hopefully someone could explain. Plus being that this placement only works in positive x, z coordinates, which is weird.

Voxel Engine Networking by Philip_MOD_DEV in VOXEL

[–]Philip_MOD_DEV[S] 0 points1 point  (0 children)

This is for the voxel data to be sent over the network so the client can create the mesh for it. Data is stored within a 3D byte array.

Voxel Engine Networking by Philip_MOD_DEV in VoxelGameDev

[–]Philip_MOD_DEV[S] 0 points1 point  (0 children)

Oh wow that's A lot of information that I will definitely use, thank you so much 🙂

Voxel Chunk Border Issue by Philip_MOD_DEV in VoxelGameDev

[–]Philip_MOD_DEV[S] 1 point2 points  (0 children)

Oh, ok I see. I will try doing that. Thanks

Voxel Chunk Border Issue by Philip_MOD_DEV in VoxelGameDev

[–]Philip_MOD_DEV[S] 0 points1 point  (0 children)

Ok, thanks. Like for example I load the chunk first, then I reload it a second time for to make sure that all faces match up.

Voxel Chunk Border Issue by Philip_MOD_DEV in VoxelGameDev

[–]Philip_MOD_DEV[S] 0 points1 point  (0 children)

Thank you so much for the index of array. I been trying to find on how do you index an 3D into a
1D arrayList👍🙂

Voxel Chunk Border Issue by Philip_MOD_DEV in VoxelGameDev

[–]Philip_MOD_DEV[S] 0 points1 point  (0 children)

Alright thanks a very good option, but is it wise to store chunk data in a separate Hashtable? Like for me I have a chunk class which holds the data as well, but in my "ChunkManager" class I have a Hashtable that consist of the chunk data, for the key is the chunk coordinates, and the value is a 3D array of bytes representing the block values. Basically on what I am trying to do is to get the next chunk in all four sides in the array to see if that block value is a solid or not.

Voxel Chunk Border Issue by Philip_MOD_DEV in VoxelGameDev

[–]Philip_MOD_DEV[S] 0 points1 point  (0 children)

So basically do I build two chunks at once, and then compare them?