Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Voxel Terrain Engine

Author
Message
NoviceNate333
11
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 26th Feb 2016 17:11
Hi you all. I am posting again to "show off" the voxel terrain ive been messing around with. thought i would post my code for any possible optimizations. im loading a 64x64 bmp to generate the terrain so there are 4096 blocks being generated, Im currently getting 60fps with exclude based on the distance.

also i am having trouble deleting the vector of cubes it gives me a conversion error any help with that would be cool as well.

Chunk.h


Block.h


main.h


and heres a nice little picture XD
Hotline
16
Years of Service
User Offline
Joined: 22nd Aug 2008
Location:
Posted: 27th Feb 2016 02:04 Edited at: 27th Feb 2016 02:58
Now this code looks way way better !

"also i am having trouble deleting the vector of cubes it gives me a conversion error any help with that would be cool as well."

If you mean this : int CHUNK_DATA[4096] = {0};. You can't delete it because it is not dynamically allocated.It's allocated on the stack and it will be deleted once goes out of scope.Since you declared CHUNK_DATA in global scope , it means it will be deleted when you close your application.

Also you could get a lot higher fps sorting your blocks in a octree .You can get even higher if GDK had a scene manager with a parent-child system so you can check the root bounding box of blocks and if it's not in the view simply not draw it's children.In GDK you have to exclude all blocks one by one
[href=forum.thegamecreators.com/?m=forum_view&t=191567&b=5]Spark Particle engine[/href]
[href=forum.thegamecreators.com/?m=forum_view&t=199163&b=5]Transform gizmo plugin[/href]
NoviceNate333
11
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 28th Feb 2016 01:20
Could you provide an octree example. I though about trying to add them as limbs to one object per chunk. I dont know if that is sort of the same concept or not. Im not quit sure how the limb commands work in gdk.
also here in this code when i try to generate more than 4 chunks i get an out of bounds error do you know why that could be?

Hotline
16
Years of Service
User Offline
Joined: 22nd Aug 2008
Location:
Posted: 28th Feb 2016 06:46 Edited at: 28th Feb 2016 18:16
Well i can't help you with GDK commands because i can't remember them,But regading to octree it's quite simple to implement in c++. Octree = recursion.There are 4 steps in building an octree

1 Add : add objects to your root octree chunk
2. Split if you reached the maximum allowed number of objects per chunk split this current chunk into 8 sub chunks
3. Sort : Resort all your nodes in this chunk to fit into newly created sub chunks (check chunk AABB vs Object AABB if fully fits into one of the 8 chunks insert there.If doesn't fit in any of the new chunks , leave it where it is)
4. Repeat

Here's a very basic example.Please note this is only a pseudo code and probably has some issues but it perfectly demonstrates how can you implement your octree.
TODO : perform recursive spliting (i am a bit sleepy now so i can't do that )

OctreeChunk.h




OctreeChunk.cpp





Octree.h



Octree.cpp

[href=forum.thegamecreators.com/?m=forum_view&t=191567&b=5]Spark Particle engine[/href]
[href=forum.thegamecreators.com/?m=forum_view&t=199163&b=5]Transform gizmo plugin[/href]

Login to post a reply

Server time is: 2024-11-18 19:27:32
Your offset time is: 2024-11-18 19:27:32