Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (575)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Voxel-Based Engine Using Game  (Read 2283 times)
0 Members and 1 Guest are viewing this topic.
Offline Kyrluckechuck

Senior Newbie





« Posted 2014-05-27 18:02:28 »

So, basically we're trying to make this very basic Voxel-based engine to use for a school project. We seem to be having great difficulty getting our physics engine to interact with the world that we have it generating... Could anyone enlighten us at all?

The main issue is getting the 'playerBody' to go inside the 'air' gaps, like the code to use seems full proof...

That's about all, if you guys need more info I don't know what to post but I'll gladly post it up!


https://github.com/Kyrluckechuck/EndOfYearProj

And yes, don't worry, we know there's code from other people that's been incorporated. If anyone has any issue at all feel free to give us your name and we'll mention you, but this isn't for profit, purely for educational purposes!

Continue down \|/
Offline Bearded Cow
« Reply #1 - Posted 2014-05-28 10:34:15 »

I can't find any code where you are checking if on ground or not.
Offline theagentd
« Reply #2 - Posted 2014-05-28 10:43:58 »

This shouldn't be any different compared to basic AABB collision detection since your voxels are essentially AABBs.

Myomyomyo.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Kyrluckechuck

Senior Newbie





« Reply #3 - Posted 2014-05-28 11:52:47 »

The code is inside the PhysicsWorld class technically. We create a world of blocks and every time one is committed to the world that's actually going to be rendered, if it's not air, the block is made according to its XYZ coordinates (this is in the Chunk class)
Offline Bearded Cow
« Reply #4 - Posted 2014-05-28 12:44:02 »

The code is inside the PhysicsWorld class technically. We create a world of blocks and every time one is committed to the world that's actually going to be rendered, if it's not air, the block is made according to its XYZ coordinates (this is in the Chunk class)

I understood that, I can't find (Maybe because I've never used bulletphysics before) the bit of code that is something a long the lines of,

  • move player
  • collision sideways/can move to new position
  • collision below/should be affected by gravity?
Offline Kyrluckechuck

Senior Newbie





« Reply #5 - Posted 2014-05-28 12:47:59 »

I'm not 100% sure as right now loading Eclipse, but I'm almost positive it's under the Camera class that the checking is done for movement

Okay ignore that. After rereading our code I realized our basic implementation of collisions had been removed and put in with a version of Jbullet collision, but ours is for sure broken. Ours actually says it's colliding with everything, and so we have it being looped through to check manually if it collided with the player. (which doesn't work to be completely honest)

So new question, does anyone have any idea of how we could fix our collision detection to work properly?
Offline opiop65

JGO Kernel


Medals: 156
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #6 - Posted 2014-05-28 14:28:43 »

Wow. This is really weird!

The library you're using, GLUtils, is the library I created. Much of the code is based off of my voxel engine series (link in my signature). That's just... Wow that's so weird that you're using my tutorials and code! I'm pancakesimone on YouTube!

I honestly would not recommend my tutorials as they weren't coded very well. I also am not planning on putting out any more tutorials.

Offline Kyrluckechuck

Senior Newbie





« Reply #7 - Posted 2014-05-28 14:55:30 »

Ahahah that's actually really weird! Man it would have been awesome if you'd continued that series, but I understand. Do you happen to have any ideas on how we could remake our collision detection? I'm still trying to wrap my head around the idea of AABB and stuff  Undecided
Offline opiop65

JGO Kernel


Medals: 156
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #8 - Posted 2014-05-28 16:46:47 »

Well what are you having issues with?

Easiest way I can think of:

Keep a list of some sort of bounding boxes in the world class. AABBs are quite easy to implement so I won't go in to detail if you don't need me to.

Every entity will also have a bounding box. Entity to entity collision detection is fairly easy, just loop through the lost of entities and see if the bounding boxes collide.

Block to entity collision detection is a little more involved. You will need to grab the bounding boxes of the blocks around the entity and then test for collision.

I would personally just do a simple check every tick in the entity class to see if there is a block below it. If there is, the entity is obviously on the ground and you will not need to perform collision responses in the downward z direction. All other axis must be tested and collision responses must be handled accordingly.

Collision response should be easy for blocks, just repel the player backwards in the direction that the player is colliding. The same could work for blocks. You could save the last location the entity was and then revert back to it after the collision occurred, but you will want to add some "padding" push back so that the collision will not happen again within a small period of time because of course this will cause a rapid "jerking" movement along the collision vector.

I'm sure I could post some solid math equations later! Just give me a few hours, today is the last day of school and I'm going to hang out with friends to celebrate Smiley

Offline Kyrluckechuck

Senior Newbie





« Reply #9 - Posted 2014-05-28 17:00:57 »

Ahahah okay thanks so much for the info! I'll see what I can do and definitely take a look at the math if you post some :p

Enjoy! 
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Kyrluckechuck

Senior Newbie





« Reply #10 - Posted 2014-05-28 23:20:39 »

Okay, I've now added AABB-style collision with spheres for the player, just actually implementing it now. How big of a deal is it that I made the Y-axis my height? Just you said your Z-axis was so just wondering Tongue
Offline opiop65

JGO Kernel


Medals: 156
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #11 - Posted 2014-05-28 23:29:52 »

Ah sorry yes, its the y axis not the z. Got that confused.

Offline Kyrluckechuck

Senior Newbie





« Reply #12 - Posted 2014-05-29 11:10:28 »

Okay so I've added the AABB style collision with a sphere for the player, however my grid for the AABB seems to be different than that of the blocks... meaning that for some reason with a chunksize of 8 (8x8x8), the only blocks it recognizes are from 3 to -3 in all axis... I'm so confused :/
Oh and currently the only movement being collision checked is the downward movement using the 'shift' key

EDIT
Also, would an array of true/false be more efficient for block collisions than AABB? So not really a collision system, but just when you want to move to the block in front of you, you check the coordinates of that block for being true/false instead. Just wondering since mine seems to be broken :p
EDIT #2
Revised code to check in ALL directions, not just the downwards


Found a silly little issue in the code.. realized the AABB guide I followed didn't do it properly for if the object was created not from the origin. Fixed and now the code works. Not seamless, now I need to add momentum and stuff so gravity works properly.

Now, my question is which would be better:
two playersphere's with camera set on the center of the top sphere, or an oval with the camera offset upwards? (I want a little less than two blocks total height.
OR is there a better alternative?
Offline Kyrluckechuck

Senior Newbie





« Reply #13 - Posted 2014-05-30 03:37:53 »

Okay whole new issue, I know you said I shouldn't use your GLUtils class, but unfortunately I'm not good enough at knowing my own code to completely remove it altogether.
How could I go about creating a main menu and a 'pause game' state?
Looking at your code, the original Main() statement is:
1  
2  
3  
4  
5  
6  
   public Main(){
      gameLoop = new GameLoop();
      gameLoop.setScreen(this);
      gameLoop.start(30);
     
   }

However, I'm unsure of how I would be able to implement the changing of screens as i can't figure out what your screen is called (I'm not sure what 'this' is referring to! X_X)

Might be a really obvious answer or I may be going about solving this wrong, but your help will be much appreciated X_X

*I removed your GLUtils.jar package and instead added your source code from your repo in order to be able to read the source properly and make minor tweaks


**********************
EDIT
**********************
Seriously noone uses different screens for their games/menus? :/
Offline Kyrluckechuck

Senior Newbie





« Reply #14 - Posted 2014-06-11 18:33:24 »

Okay whole new set of issues.
What would the best way of altering our rendering system be?
We seem to have hit a brick wall in regards to rendering only blocks in sight(not blocks that are behind other blocks).
The current way we're doing it is checking for all blocks see if they're next to air, and rendering only those, which is good for small maps.
As soon as we have the larger maps with the randomly generated terrain, this is too resource consuming and is killing the rendering from 30fps to 2-10 fps...
Offline LaakeS-G

Junior Newbie


Exp: 5 years



« Reply #15 - Posted 2014-06-11 18:48:36 »

30FPS :O why so low are you running on a vintage computer?

And why is it dropping while loading? I just finished my async chunk loading system a few minutes ago and im not losing a single frame at all untill i reach like 60+ chunks loaded then its just because its hard on my mac with INTEL HD 3000


Offline Kyrluckechuck

Senior Newbie





« Reply #16 - Posted 2014-06-11 18:51:23 »

Ahahaha, it basically is! Max I can reliably do on the computer is 30fps, and the computer itself has about 512MB ram with a Intel graphics chipset from the late '90s (reallllyyy old cpu dual core running at ~2 GHz)
These are the school computers as this is for a school project :p
Offline LaakeS-G

Junior Newbie


Exp: 5 years



« Reply #17 - Posted 2014-06-11 18:57:19 »

Ahhh makes sense, but even at my school (Sac State University) we have at least intel 4000's and around 4gb dual core i believe. Have you tried calculating everything async before rendering? would probably boost the fps while loading the chunks
Offline Kyrluckechuck

Senior Newbie





« Reply #18 - Posted 2014-06-11 19:00:17 »

To be completely honest with you, I'm not too sure what that even means lol

Offline LaakeS-G

Junior Newbie


Exp: 5 years



« Reply #19 - Posted 2014-06-11 19:04:11 »

Calculating the Mesh A.K.A. the sides to render in a thread seperate from the thread where you update the display and tell it what to render.

You can either use futures with a executor service or just a seperate thread.


(Note: I do not mean multithreaded rendering.)


Example(just a clip of what it would look like.):
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
SubThread Calculate
MainThread Render
SubThread Calculate
SubThread Calculate
SubThread Calculate
MainThread Render
SubThread Calculate
MainThread Render
MainThread Render
MainThread Render
SubThread Calculate
SubThread Calculate
SubThread Calculate
MainThread Render
MainThread Render
SubThread Calculate
MainThread Render
SubThread Calculate
MainThread Render
SubThread Calculate
SubThread Calculate


Sub thread just checks where you are and finds the chunks it needs to calculate, once calculated it tells the main thread its ready to render those chunks. main thread then renders them.
Offline Kyrluckechuck

Senior Newbie





« Reply #20 - Posted 2014-06-11 19:06:58 »

Okay, I think I caught a little of that from your thread that you posted earlier, not 100% sure the best way to implement that, did you follow any tutorials at all or any examples? 
Offline LaakeS-G

Junior Newbie


Exp: 5 years



« Reply #21 - Posted 2014-06-11 19:12:47 »

Nope, just used my experience from past projects ive done that required async to be used. Ill post more of my code later, i have to go on a ENVS 10 trip to a nature center.
Offline Kyrluckechuck

Senior Newbie





« Reply #22 - Posted 2014-06-11 19:16:38 »

Much appreciated sir, we're starting to hit deadlines on this project and not entirely sure our best way to go about this part.  

We're hoping to finish up the render to be efficient enough that you can blockpick (which I'm going to throw my hand at implementing tonight) and delete /add blocks in

Thanks, look forward to seeing what you mean!
----------
EDIT: also just figured I'd back up why we have such bad computers, it's a high school, though next week I'll be outta there after I finish at least a basic version of this game. Actually plan on continuing it after Tongue
----------
EDIT #2: Attempted our hand at implementing Threading.. God that did not end well..
If you want to see our miserable attempt you can just uncomment a couple things but to be honest most of it was so bad we just didn't even save it commented
I'm really curious to see how you went about doing the "toRemove" and "toAdd" Queue's and such! Tongue
Offline Kyrluckechuck

Senior Newbie





« Reply #23 - Posted 2014-06-13 03:48:09 »

Okay so I've now tried my attempt at threading again, this time with a little more success.

I got so far as to realize that I'm having issues with doing the rebuilding of the chunks inside the subthread. The issue however is that if I queue the loading to be in the main thread, that defeats the purpose of even having the subthread as all of that loading will just end of being done in the main thread anyway...

If you want to see my code, I'm not sure what would be best to post:

https://github.com/Kyrluckechuck/EndOfYearProj/tree/ThreadedBranch

The outside loading is being done insdie of the BackgroundProcessing class for reference, the rest of the chunkupdating is being done in the ChunkManager class.

Anyone with any ideas in regards to doing the asynchronous chunk loading or if they have a way of doing chunkloading in a way that it won't slow down my game (in another thread is the only way I can think of) please post! Help would be much appreciated as I only have a couple days left!

Thank you in advance!
Offline LaakeS-G

Junior Newbie


Exp: 5 years



« Reply #24 - Posted 2014-06-13 04:29:13 »

Okay so i removed my ready queue completely, just pooped it out of my code.
I am keeping the remove queue though.

Here is my chunk loading based on camera position thread. (dont mind the slopiness, i always clean up my code after i finalize it.)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
      Thread th = new Thread(new Runnable(){
         public void run(){
            while (Camera.instance == null){
               try {
                  Thread.sleep(100);
               } catch (InterruptedException e) {
               }
            }
            while (Game.isRunning()){
               List<Chunkv2> chss = new ArrayList<>();
               int camx = (int)Camera.instance.getPosition().x;
               int camz = (int)Camera.instance.getPosition().z;
               for (int[] point : MathUtil.getRadialCoords(radius)){
                  int tx = (camx < 0 ? ((camx + 1) / Chunkv2.X_MAX) - 1 : camx / Chunkv2.X_MAX)+point[0];
                  int tz = (camz < 0 ? ((camz + 1) / Chunkv2.Z_MAX) - 1 : camz / Chunkv2.Z_MAX)+point[1];
                  chss.add(getChunk2(tx, tz, true).build());
               }
               for (Chunkv2 old : getChunks()){
                  if (!chss.contains(old)){
                     delete.add(old);
                  }
               }
               try {
                  Thread.sleep(300);
               } catch (InterruptedException e) {
               }
            }
         }
      });
      th.start();

then i recently switched to only local face render checks, and ended up speeding up my calculations of faces to render by around 23ms. This is the face calcualation, like i said before its messy and i dont give a hoot about it being messy atm. Too busy with physics summer class to spend too much time making it look neat when i just want it working atm.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
   public static int X_MAX = 16, Z_MAX = 16;
   public static int Y_MAX = 120;


   private short[][][] ids = new short[Y_MAX][X_MAX][Z_MAX];

//LATER in a method...


      List<float[]> vertexs = new ArrayList<>();
      List<float[]> norms = new ArrayList<>();
      List<float[]> texs = new ArrayList<>();
      for (short y = 0; y < Y_MAX; y++)
         for (short xx = 0; xx < X_MAX; xx++)
            for (short zz = 0; zz < Z_MAX; zz++) {
               //TODO: just check internal faces.
               if (y == 0 || ids[y-1][xx][zz] == 0)
                  Cuboidv2.generate(ids[y][xx][zz], (x * X_MAX) + xx, y, (z * Z_MAX) + zz, vertexs, norms, texs, BlockFace.DOWN);
               if (y == this.Y_MAX-1 || ids[y+1][xx][zz] == 0)
                  Cuboidv2.generate(ids[y][xx][zz], (x * X_MAX) + xx, y, (z * Z_MAX) + zz, vertexs, norms, texs, BlockFace.UP);
               if (xx == 0 || ids[y][xx-1][zz] == 0)
                  Cuboidv2.generate(ids[y][xx][zz], (x * X_MAX) + xx, y, (z * Z_MAX) + zz, vertexs, norms, texs, BlockFace.WEST);
               if (xx == this.X_MAX-1 || ids[y][xx+1][zz] == 0)
                  Cuboidv2.generate(ids[y][xx][zz], (x * X_MAX) + xx, y, (z * Z_MAX) + zz, vertexs, norms, texs, BlockFace.EAST);
               if (zz == 0 || ids[y][xx][zz-1] == 0)
                  Cuboidv2.generate(ids[y][xx][zz], (x * X_MAX) + xx, y, (z * Z_MAX) + zz, vertexs, norms, texs, BlockFace.SOUTH);
               if (zz == this.Z_MAX-1 || ids[y][xx][zz+1] == 0)
                  Cuboidv2.generate(ids[y][xx][zz], (x * X_MAX) + xx, y, (z * Z_MAX) + zz, vertexs, norms, texs, BlockFace.NORTH);
               
            }
   }


then this is for drawing, note that it only runs the draw method whence the chunk has been built by the above method. Im using display lists with va's inside, might switch to vao's with attrib pointers though.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
      this.drawID = GL11.glGenLists(1);
      GL11.glNewList(drawID, GL11.GL_COMPILE);
      /* BUILD */

      /* ENABLE */
       glEnableClientState(GL_NORMAL_ARRAY);
       glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
       glEnableClientState(GL_VERTEX_ARRAY);


      /* ADD BUFFERS */
       glNormalPointer(0, normals);
       GL11.glTexCoordPointer(2, 0, texcoords);//(3, GL_FLOAT, 0, colors1);
       glVertexPointer(3, 0, verticies);
       
       /* DRAW */
       glDrawArrays(GL11.GL_QUADS, 0, this.drawcount);

        /* DISABLE */
       glDisableClientState(GL_VERTEX_ARRAY);
       glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
       glDisableClientState(GL_NORMAL_ARRAY);
      GL11.glEndList();



Then to render i just call the draw list. quite simple, all relies on the "do only when done" system now.

This below is what i have in my chunk manager when calling renderchunks.
1  
2  
3  
4  
5  
6  
7  
8  
   Chunkv2 remove;
      while ((remove = delete.poll()) != null){
         loaded.remove(remove);
      }
      for (Chunkv2 chun : getChunks()) {
         chun.draw();
         chun.render();
      }



And my MathUtils class which i use for calculating radial chunks near camera,(horrid way of doing what im doing but hell it works atm.)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
public static int[][] getRadialCoords(int radius){
      /*
         LOGIC
         (x*x) + (y*y) = radius*radius
         x = radius * cos(theta)
         y = radius * sin(theta)

       */

      List<int[]> points = new ArrayList<>();
      for (int r = 0; r <= radius; r++){
         for (int theta = 0; theta < 360; theta++){
            int x = (int) (r * Math.cos( theta ));
            int y = (int) (r * Math.sin( theta ));
            if (!isPointInList(points, new int[]{x,y})){
               points.add(new int[]{x,y});
            }
         }
      }
      return points.toArray(new int[points.size()][]);
   }
   
   private static boolean isPointInList(List<int[]> list, int[] point){
      for (int[] si : list){
         if (si[0] == point[0] && si[1] == point[1]){
            return true;
         }
      }
      return false;
   }



All in all loads up new chunks near instantly(37ms max from finding chunk doesnt exist to having it rendered), i cant move the camera fast enough to get past the loading chunks anymore. Longest part in my code atm is generating the values in the chunk. I really need to clean this code up badly the more i look at it. but i'm super busy, so if anyone is going to come on here and just be like face to the desk to the max then just please don't waste your time! -.-


Main thing here thats good is the simplex algo i'm using for the different values but it takes roughly 78ms to generate a chunk terrain caves and all the other goodies, roughly 20,000 cuboids.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
   protected static short[][][] generateSolid(int x, int z){
      short[][][] solidBlocks = new short[Chunkv2.Y_MAX][Chunkv2.X_MAX][Chunkv2.Z_MAX];
      for (short xx = 0; xx < Chunkv2.X_MAX; xx++) {
         for (short zz = 0; zz < Chunkv2.X_MAX; zz++) {
            short maxHeight = (short) (85 + (int) ((World.terrain.getNoise(xx + (x * Chunkv2.X_MAX), (z * Chunkv2.X_MAX) + zz) * 25)));
            for (short y = 0; y < maxHeight; y++) {
               if (y == 0)
                  solidBlocks[Math.min(y, Chunkv2.Y_MAX)][xx][zz] = 5;
               else if (y == maxHeight-1)
                  solidBlocks[Math.min(y, Chunkv2.Y_MAX)][xx][zz] = 1;
               else if (World.cavePossibility.getNoise((xx + (x * Chunkv2.X_MAX))/100, ((z * Chunkv2.X_MAX) + zz)/100) >= 0 && y < maxHeight-13){
                  if (World.caves.getNoise(xx + (x * Chunkv2.X_MAX), (z * Chunkv2.X_MAX) + zz, y) >= 0)
                     solidBlocks[Math.min(y, Chunkv2.Y_MAX)][xx][zz] = 3;
                  else
                     solidBlocks[Math.min(y, Chunkv2.Y_MAX)][xx][zz] = 0;
               } else {
                  solidBlocks[Math.min(y, Chunkv2.Y_MAX)][xx][zz] = 2;
               }
         }
         }
      }
      return solidBlocks;
   }




MAIN TODO ON ALL MY CODE IS OPTIMIZE IT AND CLEAN IT UP THANKS!
Offline Kyrluckechuck

Senior Newbie





« Reply #25 - Posted 2014-06-13 11:27:59 »

Thanks! Uber helpful, I'll take a look at your face rendering method in an hour! Tongue

Do you mind if I ask how you implemented threading? 
Offline LaakeS-G

Junior Newbie


Exp: 5 years



« Reply #26 - Posted 2014-06-13 13:44:56 »

Well for simple tasks i use http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ExecutorService.html but for main threads like RenderingThread and MeshCalculationThread and PhysicsEngineThread i just use Threads. Everyonce in a while ill make my own sub thread async task system.
Offline Kyrluckechuck

Senior Newbie





« Reply #27 - Posted 2014-06-19 03:05:47 »

Okay so starting to realize I'm way over my head here.

After talking with a couple people in the tech industry, I've come across the realization that it's never good to have multiple classes accessing the OpenGL stream. So in short, the rendering must be done in the main class or only in one class.

At first I attempted to use the Executor Service style, but that didn't turn out well. All I ended up doing there was implementing a way for chunks to save ASYNC when you make block changes (previously it didn't save your changes to the world).

So, now realizing I very likely won't be able to offset my calculations needed for rendering, it brings up a new question I'm unable to answer and was hoping someone might have an idea: How could I render ONLY the blocks I am able to see? Or just render enough blocks, not excess. (Currently I'm rendering all blocks next to air within the 9 chunk's square around me. (my current chunk and the 8 surrounding chunks, which is about 4000 blocks rendered per chunk in a 16x16x64 world (generated using a SimplexNoise))

The second question then;
And what would be a good method of implementing the loading of the new chunks as I move into another chunk (assuming it always has the 9 square chunks in memory)?

Sorry if I'm too vague, but this is really starting to drive me nuts, everything I try is just making the game run even slower!
Offline gouessej
« Reply #28 - Posted 2014-09-09 11:33:29 »

Hi

After talking with a couple people in the tech industry, I've come across the realization that it's never good to have multiple classes accessing the OpenGL stream. So in short, the rendering must be done in the main class or only in one class.
Accessing OpenGL from multiple threads is possible but there is no guarantee that it works reliably everywhere. The rendering can be done in multiple classes as long as they don't try to make the OpenGL context current on several threads. Call all your rendering methods directly or indirectly in GameLoop.render() or Screen.worldRender() and it will work.

At first I attempted to use the Executor Service style, but that didn't turn out well. All I ended up doing there was implementing a way for chunks to save ASYNC when you make block changes (previously it didn't save your changes to the world).

So, now realizing I very likely won't be able to offset my calculations needed for rendering, it brings up a new question I'm unable to answer and was hoping someone might have an idea: How could I render ONLY the blocks I am able to see? Or just render enough blocks, not excess. (Currently I'm rendering all blocks next to air within the 9 chunk's square around me. (my current chunk and the 8 surrounding chunks, which is about 4000 blocks rendered per chunk in a 16x16x64 world (generated using a SimplexNoise))

The second question then;
And what would be a good method of implementing the loading of the new chunks as I move into another chunk (assuming it always has the 9 square chunks in memory)?

Sorry if I'm too vague, but this is really starting to drive me nuts, everything I try is just making the game run even slower!
Are you sure that the bottlenecks are those computations? Do you plan to use view frustum culling in order to render only the blocks you have a chance to see?

Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (35 views)
2014-10-17 03:59:02

Norakomi (25 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (26 views)
2014-10-15 16:18:58

TehJavaDev (50 views)
2014-10-14 00:39:48

TehJavaDev (50 views)
2014-10-14 00:35:47

TehJavaDev (40 views)
2014-10-14 00:32:37

BurntPizza (63 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (74 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!