Search Unity

After playing minecraft...

Discussion in 'General Discussion' started by jc_lvngstn, Oct 8, 2010.

Thread Status:
Not open for further replies.
  1. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    I've played around with ThreadPool.QueueUserWorkItem a couple days ago and couldn't figure out one important thing. How do you make your function wait until the queued function is done?

    Code (csharp):
    1.  
    2. //Chunk function
    3. void GenerateMesh(){
    4.     //...set up some stuff before making mesh
    5.     WorldManager.generatedMeshData data = new GenerateMeshData(transform.position); //ChunkGeneration.GenerateMesh modifies this variable and you use it after the function is done //It is a static variable that belongs to WorldManager
    6.                                                                                     //It contains a list for vertices, triangles and uvs
    7.     ThreadPool.QueueUserWorkItem(new WaitCallBack(ChunkGeneration.GenerateMesh))//A function for calculating mesh
    8.     //How to wait?
    9.     //...Finish making mesh here
    10. }
    11.  
    Edit:
    Instead of QueueUserWorkItem I'm trying RegisterWaitForSingleObject because it "might" let me wait for the queued function to finish, I'm not sure. Does this look correct at all?
    Code (csharp):
    1.  
    2. void GenerateMesh(){
    3. //... code
    4.         GenerateMeshData generatedMeshData = new GenerateMeshData(transform.position);
    5.         AutoResetEvent arEvent = new AutoResetEvent(false);
    6.         RegisteredWaitHandle rwh = ThreadPool.RegisterWaitForSingleObject(arEvent, new WaitOrTimerCallback(ChunkGeneration.GenerateMesh), generatedMeshData, 2000, true);
    7.  
    8.         arEvent.WaitOne();
    9.         rwh.Unregister(arEvent);
    10. //... code
    11. }
    12.  
    It freezes the program so I guess I'm doing it wrong. I'm not sure what to do. I figured that by inputing the AutoResetEvent into RegisterWaitForSingleObject that it would let me know when the queued function is finished running by using arEvent.WaitOne(), but I guess not.
     
    Last edited: Dec 7, 2011
  2. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    The whole point of doing multithreading is so that you don't have to wait for the job to finish. If some processing takes 0.5 seconds in the main thread, it will still take 0.5 seconds in the background thread. If you wait for it, then the gui will still freeze for 0.5 seconds just like if you are doing single thread.

    Instead, what I do is queue up the job, and exit immediately. In essence, I do a fire and forget. The main thread continues and gui is smooth as silk, while the background thread is doing all the math.

    The problem is that creating the mesh needs to be done in the main thread, so how do you get the result of the job on the main thread?. One approach is to have a queue, the background thread when finishes enqueues an object with all the arrays necessary for creating the mesh. Then create a monobehaviour with an update function that constantly checks that queue, and when something is in there, it dequeues it and creates the mesh with the arrays.

    In my case I do something a little better: I have a queue, but I push jobs instead of objects to it. A monobehaviour with an update function constantly checks the queue for jobs and execute them as they arrive. That way my "ForegroundExecutor" does not have to know about arrays or meshes, but it is very generic and allows background threads to submit anything they want to be executed on the main thread. The jobs that I push to foreground do create the meshes and gameobjects and whatever else that needs to be executed on the main thread.
     
    Last edited: Dec 7, 2011
  3. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    Code (csharp):
    1.  
    2. GenerateMeshData generatedMeshData = new GenerateMeshData(transform.position);
    3. generatingMeshThread = true;
    4. ThreadPool.QueueUserWorkItem(new WaitCallback(GenerateMesh),  generatedMeshData); //sets generatingMeshThread to false when finished
    5.  
    6. while(generatingMeshThread) {
    7.       //Thread.Sleep(10); //Can't tell if I need this or not
    8. }
    9.  
    This seems to work ok. What I do is have a Coroutine in my WorldManager that acts as a queue. It only ever lets one thing generate at a time. First it tells chunks to generate blocks then after all chunks are finished calculating blocks it allows mesh to be generated.
     
  4. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    Hi!

    I am trying to create a Minecraft prototype in Unity, but I'm having problems with performance. So I have some questions for you guys :)

    1) If you use Perlin noise, how many octaves do you use? I use 5 octaves from wavelength 2 to 32 (I skip 1). If not, what other noise functions can be used to create similar minecraft terrain?

    2) After you have the heightmap in a 2D array, do you convert it to a 3D array, then add caves and stuff, or do you draw the mesh directly from the 2D array (and in the process add the other stuff) ?

    3) How do you sort out the borders of the chunks? I recalculate the chunks I need, but I don't think it's the best way. Do you keep info of the chunks in memory?

    On a side note, I think you can't have chunks of 16x128x16 cubes. The vertices array of Vector3 can hold 65536 elements (at least in JS). If you have 4 vertices per face and don't "recycle" them for other faces (which would mess up the UV), then the maximum vertices array for 16x128x16 cubes would hold 98,304 elements.
    The math is: Xsize * Ysize * Zsize * 6 faces * 4 vertices / 8
    And the chunk would look like a 3D chessboard (0,0,0 -> cube; 0,0,1 -> no cube; 0,0,2 -> cube; ... 0,1,0 -> no cube; 0,1,1 -> cube; ...)
    If you pay attention to how Minecraft 1.0.0 generates the chunks, you can see that it divides the 16x128x16 chunk in smaller vertical chunks (I think they are 16x16x16, I can't tell for sure).


    The video is very exaggerated. The real performance of the standalone is terrible.
     
    Last edited: Jan 10, 2012
  5. Rod-Galvao

    Rod-Galvao

    Joined:
    Dec 12, 2008
    Posts:
    210
    Does anyone know how to efficiently calculate ray tracing?
     
  6. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    If you are asking about ray tracing inside a minecraft style world this algorithm is extremely efficient. Here is an implementation in C# that you can pretty much cut paste. It is trivial to modify it to also tell you which face of the blocks you are hitting.

    I use it in my game on every frame to highlight the block you are pointing to.
     
  7. Creativita

    Creativita

    Joined:
    Dec 2, 2011
    Posts:
    180
    This is awesome. You should definitely expand on it
     
  8. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    Hey paulp, I've changed my code a bit more and made it so I'm not using a while loop after the ThreadPool.QueueUserWorkItem function. I'm now using a bool to let me know when it's done and then I finish what needed to be done in the Update function. Next up, changing my GenerateAmbientLight function so it can be threaded.
     
  9. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    How the heck are you planning on doing that? If you are running ambient light for 2 chunks that are next to each other, light might spill from one chunk to the next. If both of them are done in different threads, then you run into synchronization hell.
     
  10. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    Use Simplex noise instead, created by Perlin himself to fix some issues with Perlin noise. It is also faster, especially on 3d and 4d.


    You might want to read this. It gives you a basic idea of how to combine noise in interesting ways to generate a density functions. They just scratch the surface, you can do other stuff. For example, in 1.3.3, instead of using
    Code (csharp):
    1. float density = -ws.y
    use
    Code (csharp):
    1. float density = -heightmap[x,y]
    to have your terrain be generated with overhangs yet following the basic structure of a heightmap.

    I keep the chunks in memory for a radius around the player. A chunk has a reference to its neighbor chunks, so I can quickly examine it's neighbor to see if a block is covered or not.


    If you write your own shader, there are ways to share vertices between adjacent blocks, and even merge adjacent blocks. My chunks are 32x32x32 thanks to those optimizations.
     
  11. Creativita

    Creativita

    Joined:
    Dec 2, 2011
    Posts:
    180
    This is awesome. You should definitely expand on it
     
  12. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    I really need to rethink the timing of my chunk generation. I've made it so when the player moves to another chunk, the block array gets shifted too. But that creates a bunch of air blocks which is bad. Sometimes chunks think that there's nothing there when it's generating its mesh so you see a huge cube crater in the ground. So yea, timing... really hard (until I figure it out, then it'll be easy).

    Question: Do you shift your array of blocks when the player moves or just recalculate the block positions?
     
    Last edited: Dec 9, 2011
  13. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    My implementation is chunk based. So I have a master 3d array of chunks, where each chunk is an object with a 3d array of blocks. When the player moves, I move the chunks in the master array, which is very cheap, but the content of each chunk remains unchanged. As chunks fall out of the master array, they get discarded, and chunks that enter a smaller radius are loaded in a background thread.

    If I didn't have infinite Y, then my master array would be 2d instead.
     
    Last edited: Dec 9, 2011
  14. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    http://http.developer.nvidia.com/GPUGems3/gpugems3_ch01.html

    I'll look into this. Looks interesting. Thanks :)

    Also, one other question: Do you generate noise with a shader or via code?

    This is the worst case scenario chunk I mentioned before. As you can see there are no adjacent cubes, but it can be optimized by not rendering the inside of the chunk.
     
  15. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    Via code.

    Actually it isn't the worst case, because two blocks in diagonal can share one vertex. So the blocks in the center can share all vertices, Also the empty blocks don't require any rendering. An even worse case would be if the empty blocks were glass (or some other transparent block), and the blocks in diagonal were of different materials so no vertex could be shared.

    What I want to do is: as I am generating the mesh, if it becomes to big, then split it and create a second mesh. That way, I am highly optimized for the average case, yet support the worst case.

    If you can think of a way to avoid rendering the inside of a chunk, I am all ears.
     
  16. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    I hadn't thought about that. Replacing the empty blocks with transparent ones would make it worse.

    That's a great idea :)

    I think I'll be spending the weekend rewriting all of my code :) Thanks for your help!
     
  17. soulreafer

    soulreafer

    Joined:
    Nov 6, 2011
    Posts:
    28
    Is there a simple way to stop the randomness for the generation? like seeds or an fix math number.
    i search for some good levelgenaration tutorials/assets for a long time. its a shame that only two or three persons sharing there works.

    best regards
     
  18. soulreafer

    soulreafer

    Joined:
    Nov 6, 2011
    Posts:
    28
    can u explain me this snippet? i cant get it to work :/
    i think i need this, too becaus my chunk has one big mesh and i cant find the right position to place a block with raycast.hit + hit normal

    best regards
     
  19. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    The function is a generator, you can call it in infinity, and it will continue giving you cells that your ray is hitting. The first call will return the first cell you hit. Meaning the block right in front of you. The next call will give you the block after that, and so on. You stop when the distance is more than some threshold (how far can you reach), or when you hit a solid block.

    This is how I use it. My adaptation is inside RayTracer.trace:

    Code (csharp):
    1.  
    2. Vector3 pos = playerCamera.position;
    3.  
    4. // call the ray tracing generator,
    5. // and for each hit, check if it is
    6. // solid or if we got too far
    7. foreach (RayTracer.Hit hit in RayTracer.trace(pos, playerCamera.forward))
    8. {
    9.     double dx = hit.x +0.5 - pos.x;
    10.     double dy = hit.y +0.5 - pos.y;
    11.     double dz = hit.z +0.5 - pos.z;
    12.        
    13.     // how far is the hit from the player
    14.     double hitDistance2 = dx * dx + dy * dy + dz * dz;
    15.            
    16.     if (hitDistance2 > reach * reach)
    17.     {
    18.         // no hit, it is too far to reach
    19.         return;
    20.     }
    21.            
    22.     if (world[hit.x, hit.y, hit.z].type.solid)
    23.     {              
    24.         // we got a hit, highlight the block
    25.         return;
    26.     }
    27.            
    28. }
    29.  
     
    Last edited: Dec 10, 2011
  20. Rod-Galvao

    Rod-Galvao

    Joined:
    Dec 12, 2008
    Posts:
    210
    Same doubt here. I tried to implement it but I think I'm missing something...
    Do you mind to publish the Raytracer.trace method here?
     
  21. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    Here is my function:

    Code (csharp):
    1.  
    2.  
    3. using UnityEngine;
    4. using System.Collections.Generic;
    5. using System;
    6.  
    7. public class RayTracer {
    8.    
    9.     public struct Hit {
    10.         public int x, y,z, face;
    11.        
    12.     }
    13.     // This method is a *lot* faster than using (int)Math.floor(x)
    14.     private static int fastfloor(double x)
    15.     {
    16.         return x > 0 ? (int)x : (int)x - 1;
    17.     }
    18.        
    19.     /* traces a ray starting from a point to a direction
    20.      returns in order every block that intersects the ray
    21.      the return value is a x,y,z coordinate of the intersecting
    22.      voxel as well as a w which describes which face was intersected
    23.      
    24.      The algorithm is inspired by
    25.      "A Fast Voxel Traversal Algorithm for Ray Tracing"
    26.      by John Amanatides and Andrew Woo */
    27.    
    28.        
    29.     public static IEnumerable<Hit> trace(Vector3 pos, Vector3 direction)
    30.     {
    31.        
    32.         // what voxel are we on
    33.         int intX = fastfloor(pos.x);
    34.         int intY = fastfloor(pos.y);
    35.         int intZ = fastfloor(pos.z);
    36.        
    37.         // which way we go
    38.         int stepX = Math.Sign(direction.x);
    39.         int stepY = Math.Sign(direction.y);
    40.         int stepZ = Math.Sign(direction.z);
    41.        
    42.         // Calculate cell boundaries. when the step is positive, the
    43.         // next cell is after this one meening we add 1.
    44.         // If negative, cell is
    45.         // before this one in which case dont add to boundary
    46.         int boundaryX = intX + (stepX > 0 ? 1 : 0);
    47.         int boundaryY = intY + (stepY > 0 ? 1 : 0);
    48.         int boundaryZ = intZ + (stepZ > 0 ? 1 : 0);
    49.        
    50.         // how far do we have to walk before hitting a voxel boundary
    51.         // may be infinite
    52.         float tMaxX = (boundaryX - pos.x) / direction.x;
    53.         float tMaxY = (boundaryY - pos.y) / direction.y;
    54.         float tMaxZ = (boundaryZ - pos.z) / direction.z;
    55.        
    56.         // how far do we have to walk before crossing a cell
    57.         // may be infinite
    58.         float tDeltaX = stepX / direction.x;
    59.         float tDeltaY = stepY / direction.y;
    60.         float tDeltaZ = stepZ / direction.z;
    61.        
    62.         // which face was intersected
    63.         int facex = (stepX > 0 ? BlockType.WEST : BlockType.EAST);
    64.         int facey = (stepY > 0 ? BlockType.DOWN : BlockType.UP);
    65.         int facez = (stepZ > 0 ? BlockType.SOUTH : BlockType.NORTH);
    66.        
    67.         int face = facex;
    68.        
    69.        
    70.        
    71.         // start walking and returning the intersecting voxels
    72.         while (true)
    73.         {
    74.             yield return new Hit {
    75.                 x = intX,
    76.                 y = intY,
    77.                 z = intZ,
    78.                 face = face
    79.             };
    80.            
    81.             if (tMaxX < tMaxY  tMaxX < tMaxZ)
    82.             {
    83.                 intX += stepX;
    84.                 tMaxX += tDeltaX;
    85.                 face = facex;
    86.             }
    87.             else if (tMaxY < tMaxZ)
    88.             {
    89.                 intY += stepY;
    90.                 tMaxY += tDeltaY;
    91.                 face = facey;
    92.             }
    93.             else
    94.             {
    95.                 intZ += stepZ;
    96.                 tMaxZ += tDeltaZ;
    97.                 face = facez;
    98.             }
    99.         }
    100.        
    101.     }
    102.  
    103. }
    104.  
     
    Last edited: Dec 12, 2011
  22. Rod-Galvao

    Rod-Galvao

    Joined:
    Dec 12, 2008
    Posts:
    210
    Thanks man.
     
  23. recon

    recon

    Joined:
    Nov 28, 2009
    Posts:
    119
    This is a very interesting thread, I've been following it for quite a while now. So I was curios by the code posted, do you perform your math using double's? Isn't that usually overkill when a plain float would suffice instead?

    Also, have you considered doing some of your calculations using fixed point math? That can improve performance dramatically in some cases when you don't need "perfect" decimal resolution, it's typically used in culling for example.

    Don't know if that's helpful to you but I thought I chip in with my 2 cents anyway :p
     
  24. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,435
  25. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    Thank you for your feedback. It is overkill indeed. Changed it to float.

    Fixed point would not be that good though because none of the variables are bounded.
     
    Last edited: Dec 12, 2011
  26. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    Hey paulp, I tried changing my terrain generator to use one block array per chunk and it fails. The GenerateMesh function is threaded. I'm calling FindNeighborBlock which is required in GenerateMesh. In FindNeighborBlock if it it's at the edge of the Chunk's block array and it's trying to check the next chunk over, the thread gives me an error because I'm checking the Chunk. The Chunk is a MonoBehaviour and it doesn't like me checking whether it's null or equal to another chunk. So I don't know how you're doing it but it's certainly not going to go anywhere for me unless I just use what I was using before.
     
  27. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    @GIB3D

    As you discovered the hard way, chunks cannot be MonoBehaviours. You have to separate all the chunk generation from the unity libraries. My chunks are regular objects (not monobehaviours), and I keep them in the world (another regular object), which is the master array of chunks. When I want the neighbor of a chunk, I ask the world to give me the neighbor. I do all the loading/unloading, generation, lightning, and mesh generation (generating the arrays necessary for the mesh) without using a single class from Unity.

    Once I generate the arrays for the mesh, I hand it over to the main thread, where a gameobject will be allocated with a mesh. But the GameObject does very minimal work, and does not even keep the reference for the actual chunk object.
     
    Last edited: Dec 13, 2011
  28. soulreafer

    soulreafer

    Joined:
    Nov 6, 2011
    Posts:
    28
    i used gameobjects ( cubes ) to place new blocks. its the best way for my skill in unity atm and it´s simple to make more cubestyles without write meshs from scratch. but i read so much about meshcombine in this thread for better performance. so my question is there a way to combine every cubemesh to a big mesh if there is no space in each direction to another cube?
     
  29. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    Thanks paulp! By the way it's GIB3D (as lowercase it's gib3d). It's short for Green Ice Blitz3D. I used to use GIA_Green_Fire but it started getting annoying having to type such a long name. GIA is short for Green Ice Archer.

    Edit: I can tell this is going to take a bit of work to change how I'm generating things. Fun fun!
     
    Last edited: Dec 13, 2011
  30. soulreafer

    soulreafer

    Joined:
    Nov 6, 2011
    Posts:
    28
    I played arround with Bezir´s script and this is the result.
    Some nice Landscape so far but some water would be nice :/



    Fraps drops my FPS from +60 to 32 -.-
    Chunksize = 10x10
    Viewdistance = 60
     
  31. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    Hi guys!

    I'm having some trouble with multi-threading. My idea is to generate each independent chunk in a thread, but it doesn't seem to work very well. Are creating gameObjects, adding components(MeshFilter, MeshRenderer, MeshCollider, and scripts), and assigning vertices, uvs and triangles thread-safe functions?

    Also, I've been experimenting with big chunks, and I found out that an area of 9x9 Chunks (64x128x64) runs at 450-500fps and uses 1.5GB RAM and 400MB VRAM, versus what I had before: 15x15 chunks (16x128x16) ran at 200fps and used 3.0GB+ and 500MB VRAM.

    So having few big chunks is much much better than having lots of small chunks. Before I could hardly see an area of 240x240cubes before my computer crashed, and now I can render a ginormous map of 576x576cubes!! :)
     
  32. Manmax75

    Manmax75

    Joined:
    Jun 13, 2011
    Posts:
    88
    You cant call any Unity functions from a thread. You can do all your calculations, math, etc on the separate thread. But when it actually comes time to call the unity functions you MUST do this on the main thread.
     
  33. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Anything that is part of the UnityEngine library is pretty much off limits to a thread. There are a few exceptions but with what you are looking for creating objects and adding components it is a no go. What I did when playing with this was to offload all of the calculation stuff to a thread and then have that thread call back to a coroutine in Unity's main thread that would queue and process the creation of the objects, meshfilter, mesh, and meshcollider with the data that was just calculated when it was appropriate.
     
    Last edited: Dec 14, 2011
  34. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    That's a good idea. I'll try that. Thanks for your help!
     
  35. soulreafer

    soulreafer

    Joined:
    Nov 6, 2011
    Posts:
    28
    Last edited: Dec 14, 2011
  36. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    Me again :)

    I'm ready to move into lightmapping, but I don't know where to start. What functions should I look for? Or should I use shaders? I read about Beast lightmapper, but I'm not sure the maps can be created at run time. Any help will be appreciated!



    EDIT: I found mesh.colors. Now I need to find a shader that works with vertex colors.
     
    Last edited: Dec 16, 2011
  37. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    That looks beautiful Martin, makes you want to jump in that water. Speaking of which, has anyone worked on a swimming player controller script? I am sure this is something that could easily be shared among these multiple projects.
     
  38. HeadHunter

    HeadHunter

    Joined:
    Dec 17, 2011
    Posts:
    53
    Can some one help me add right clicking function for placing block in this script?
     
    Last edited: Jun 16, 2012
  39. soulreafer

    soulreafer

    Joined:
    Nov 6, 2011
    Posts:
    28
    search for this part:
    http://pastebin.com/xwfc6wGe

    and invert the funktion.
    u can use raycast for placement too.
    generate an new cube mesh at the hit positon and regenerate the chunk

    next time pls use an paste service for so long scripts.
     
    Last edited: Dec 17, 2011
  40. HeadHunter

    HeadHunter

    Joined:
    Dec 17, 2011
    Posts:
    53
    Sorry for the long script))
    Please, can you make this function for me?

    Tell please how to generate an new cube mesh?

    Please!!! help me with placing block function(((((((
     
    Last edited: Dec 18, 2011
  41. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    Finally got my terrain generator working again!

    $afd7bf43aff7b71c604195a14eccfbabc552dca085ab078422f887278d5aceaf6g.jpg

    Here's a link to the built version. I'd make a webplayer of it but my Perlin Instructions require reading from files, which the webplayer can't do.
    Terrain Generator
     
  42. TehWut

    TehWut

    Joined:
    Jun 18, 2011
    Posts:
    1,577
    Looks very Good!
     
  43. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    An updated version of my Free Terrain should be ready by tomorrow, I think I've figured out how to fix some Unity project bugs.
     
  44. martin32

    martin32

    Joined:
    Mar 30, 2011
    Posts:
    27
    Thanks :D
    I'm working on the dynamic sky. Will post some screens when I finish it.

    Looks great! I like the foggy atmosphere and the verticality of the map :)
     
  45. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    Here's the updated Free Terrain!
    Free Terrain 2.1

    One problem though is that it keeps saying the vertex and uv counts aren't right sometimes. It doesn't happen in the version with Bawl Physics so I'm not sure why it's doing it at the moment.
     
    Last edited: Jan 24, 2012
  46. _zeta

    _zeta

    Joined:
    Dec 24, 2011
    Posts:
    99
    when someone creates good blocky terrain with physics affected water drop me a pm with it please!
    thanks
     
  47. Tomo-Games

    Tomo-Games

    Joined:
    Sep 20, 2010
    Posts:
    223
    Hi guys.

    I just started reading the trail. Looks like some great work is coming out of this thread. Has anyone sticky'd these code posts? I would imagine Beezir's code has been through some updates? Also people have created their own spin offs like GIB3D's Free Terrain, it be cool to see a list thus far. Thanks.
     
  48. css_maya

    css_maya

    Joined:
    Nov 8, 2010
    Posts:
    12
    I second it, after 40 pages of forum reading I almost lost who is doing what ^^ so if you guys be kind and share project packages with us would be real nice :D
     
  49. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    I've finally got chunk saving/loading added in. It saves the chunks in folders like this..
    Code (csharp):
    1.  
    2. #MapName
    3. >Chunks
    4. >>#ChunkPosition
    5. >>>blocks.block
    6.  
    Where #MapName would be the name of the map and #ChunkPosition would be the position of the chunk. Easy!

    Loading -
    I've got it so when I create a chunk, it tries to load from the blocks.block file if there is one. If it doesn't find one, it'll do the normal perlin noise route.

    Saving -
    After the mesh is generated, the chunk is saved. From what I've been told though, I shouldn't save that often but for now it's good enough.

    Edit:
    Now it's time for some optimization. I'm going to change to using a single XML file for all the chunks instead of a bunch of folders and files.
     
    Last edited: Jan 1, 2012
  50. Tomo-Games

    Tomo-Games

    Joined:
    Sep 20, 2010
    Posts:
    223
    I get errors that crash the game when adding blocks in FT2

     
Thread Status:
Not open for further replies.