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.

Work in Progress / DBP Plugin - PROC_MAP - Procedural 3D Level Generator V4

Author
Message
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 15th May 2012 02:32 Edited at: 20th May 2012 00:09
Sometime ago I started working on this code - Original WIP - but after playing with it in different API's, including raw openGL, and after many improvements to generation speed I'm currently converting it to a Dark Basic Pro plugin.

Preview attached to this post... Now you can play around with it...

Almost ready for a DBP plugin...

I'm currently playing with the code in Dark GDK to get the main sections working, but for the DBP plugin it will have a lot of easy stuff to create decorations, collision, occlusion, etc.

. Collision will work with any polygon system, ie Sparkys.

. Occlusion will be based on viewing position and the sections will be hidden according to distance. It's low poly anyway but I've added it for future expansion.

. Decoration can easily be added by picking parts of the map whether it be a wall, ceiling or floor, retrieve the center coords and place your own object there.

. Zone placement/spawning also simple because of the map segment data.

There's a few ideas floating around in orbit about my brain cell for additions, such as adding different shaped rooms, adding the map to a terrain object and more. (That's for V5 though, for the procedural 3D world generation).

Anyway the plugin will consist of some functions as these (very likely to be changed):

. PROCMAP SETUP seed, segments (which will default to set values)
. PROCMAP SETUP CORRIDOR min_length, max_length, segments
. PROCMAP SETUP ROOM min_length, max_length, segments
. num = PROCMAP GET SEGMENT FLOOR COUNT( segment )
. x/y/z # = PROCMAP GET SEGMENT FLOOR X/Y/Z( segment, floor_edge )
. x/y/z # = PROCMAP GET SEGMENT ROOF X/Y/Z( segment, roof_edge )
... etc (This is a WIP and all the above can change)

A quick video to at least give some merit:



Now there's only two things to do:

1. Fix the walls UV's (I can do this by instead of the sort code searching for the vert index, it will check for the verts actual coordinates instead. This is because the segments copy a vert over and gets another index)

2. Tessellation for better lighting effects (By splitting each triangular into smaller segments)

HISTORY:

V1 - 2D array map to create simple blocks
V2 - 2D array map converted to a single object (still blocky)
V3 - 2D array map but using polygon map set up
V4 - 2D & 3D array map and segment addition

Currently at V4.3

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!

Attachments

Login to view attachments
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 15th May 2012 02:41
Reserved for source code download...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
TheComet
11
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 15th May 2012 12:20 Edited at: 15th May 2012 12:21
Oh nice, I had the feeling I'd see this again! Looks like all NaGaCreMo'12 projects are still continuing (I'm also still working on LightShip).

Would it be possible to have destructable segments?

You might want to correct that UV data on the walls if you haven't already done so.

Hope to see more!

TheComet

Seppuku Arts
Moderator
14
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 15th May 2012 14:15 Edited at: 15th May 2012 14:16
Still looking awesome mate, it will be interesting to see the final result with this plugin. Good to see NaGaCreMo projects still going, speaking of which I should continue mine.

MrValentine
AGK Backer
8
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: Playing
Posted: 15th May 2012 14:40 Edited at: 15th May 2012 14:43
Me too... I have been looking at my NaGaCreMo project and intend to sprouse up the website then continue developing it...

Keeping my eyes on this

EDIT

Btw WLGfx... Where is that video hosted? I can not see it on my phone...

Duffer
16
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 15th May 2012 21:50
@ WLGfx,

This looks amazing.

Presume the final version of this would be a pay-for plugin? 'Procedural world generation'. LOL.

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 15th May 2012 22:24
@TheComet & Sepp - This code has been through the wars with openGL and has had a few improvements made along the way. I just thought I'd finally finish it off using the original API (GDK & DBP) that it was started with. The UV mapping on the walls has now been sorted but another slight bug has cropped up. Hopefully be ready in a few more days.

I've been constantly keeping an eye on your projects, although I don't make my own comments regularly. One day I might produce a full game.

@MrValentine - It'd be nice to see the final version of yours too. Been a while now.

@Duffer - No, I won't be making any money off this. It will be released for free and the source code will be available on request. I'll try my best to add as many features to it as possible as it's still being developed in GDK.

The next version, V5, will be likely on a planetary scale which will produce landscape, water, underground tunnels and hopefully city scapes. I've got stacks of notes written down for the next version and it will probably take a long time in development alongside other projects too.

Currently what this version does:

. The base class, PROC_MAP, generates the floor layout.
. The inherited class, GDK_MAP, splits the floor map into its segments, builds the floors, walls and ceiling, tessellates for better lighting, textures and sets the bounding boxes of each segment. All UV mapping is also automatic.
. The entire object is made into a single DBP/GDK object and each segment split into limbs which makes for better optimised rendering.
. Each section can be textured separately.
. A noise algorithm is added the the level to create a real sloping effect and not flat like most.
. All values used by the generation algorithm can be changed to produce billions of different levels although even changing the seed will do that anyway.
. I'm assuming the final object can be saved out as a DBO file.
. Automatic occlusion of far away segments.
. Generation is very fast as some functions have been dumped that were using pure STL and replaced with plain fast ANSI C.
. Decorating the level will be easy based on retrieving coords from any floor, wall or roof section in any segment. Just place objects at that point or at the midpoint between edges or faces.
. Doors can be placed between rooms as the algorithm does set the edge flag to a door type.

Over the time that I've been working on this, tons of code has been dumped and replaced or re-written as optimisations and other features get added. Whilst I'm still working with this, other additions are likely to be added along the way.

Pseudo code for it's use:



Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Duffer
16
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 15th May 2012 22:30
@ WLGfx,

Oh good grief. More strength to your arm then.

Quote: "The next version, V5, will be likely on a planetary scale which will produce landscape, water, underground tunnels and hopefully city scapes. I've got stacks of notes written down for the next version and it will probably take a long time in development alongside other projects too."


Can that actually be done??? Is that even possible as a plugin???

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 15th May 2012 23:45 Edited at: 15th May 2012 23:56
Yeah, it's all based on the coordinates of the surface, only the local area will be generated as the meshes and stuff. It's similar to having a map of 1,000,000 x 1,000,000 and only displaying a 20 x 20 segment of it.

Mixing it with an accurate noise algorithm you can use the seed values from it to generate anything on any scale.

By the time I'm developing that I'll hopefully have got my DBP & GDK licenses... It can be used for any type of game...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Matty H
10
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 16th May 2012 17:17
This looks awesome, good work indeed

Going from your other post(GDK section) I think you are making your own objects using code similar to what I posted?

You are probably aware that you could just draw all this stuff yourself using DX commands, this is what Dark Imposters and Blitz Terrain does, it still sits in nicely with the dark basic objects.

There is a command something like 'AddToRenderList()' which allows you to draw at any point inside the dbSync() command.

It's probably irrelevant as you have lots done already doing it with dark basic objects and it looks very good. The advantage of doing what I suggest is that you would use your own vertex structure and you could then easily render it in any DX engine or add other render functions to work with other engines.

I would think lots of the maths behind creating these cave structures is pretty independent to the few lines of code that draws it?

Good luck with this, I could definitely use it

WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 16th May 2012 19:37
@Matty H - I've made it as a single object (made up of multiple limbs) using the code you posted. Thanks man. Massive help that was too. Just like the IrrLicht engine, you can add your own rendering instead of creating an object, but in this case it is required so that Sparky's can pick up the information directly from the object. Most of the code is already done, even down to building up the internal mesh, so it's just a case of copying the vertices and faces over to which API is being used and DBP and GDK is quite convenient with it's limb system.

There is a lot of math behind those few functions, and a large map will take just a couple of seconds to return the final object. Most of the description of how it's done is in the original WIP.

Basically, start of with a rectangle, two triangles and then start attempting to add either a corridor or a room to one of the outer edges. When one has been successfully attached then carry on until all segments have been added. There are three lists, verts[], obvious, edges[] which tells me the type of edge (inner/outer/doorway/etc) and the segment it's in, faces[], obvious again.

If you're interested in the final code Matty I'll send it to you once it's done. The last thing to do once it's working is to make the code API independent. And I'll definitely look into the AddToRenderList(). Within the IrrLicht engine you can just attach your own openGL rendering functions to the drawing queue which is probably much the same.

Anyways, thanks man... Still ploughing through it when the house goes quiet...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 18th May 2012 18:22
Almost ready with this, I'm just missing a limb. Stranger things have happened though.



Hoping I can get a tad bit of help on the GDK forums with the missing limb.

The wall UVs have a smidgen glitch in them which I'm currently fixing but apart from that, the DBP plugin is almost ready.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Duffer
16
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 18th May 2012 21:45
Wasn't there a dbpro limit to number of limbs? or is it that this doesnt have to obey those rules as directly directx, if you see what I mean?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 18th May 2012 22:19
I'd probably have to hit the 20,000 map segments before I even touch the DBP limit on the limbs. And a 100 segment map is quite large. Not even the vertex count or index count will reach that unless my tessellation functions and map segments are high. For each map segment there are 3 limbs added, one for the floor, wall and roof section.

No, for some reason the very first limb added to the object is missing. All limbs added after that are there.

Got me flummoxed for the time being.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 19th May 2012 05:43 Edited at: 19th May 2012 05:45
Updated and fixed many silly bugs and almost completed...



Now there's only two things to do:

1. Fix the walls UV's (I can do this by instead of the sort code searching for the vert index, it will check for the verts actual coordinates instead. This is because the segments copy a vert over and gets another index)

2. Tessellation for better lighting effects (By splitting each triangular into smaller segments)

So far in C++ I do this to generate the map in the video: (takes less than 1 second to generate everything)



Note the:


Just a few commands (or the minimum of 2 commands) to generate any size level. It will also have the ability to change the textures of any segment, etc, etc...

Won't be long now folks!

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Duffer
16
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 19th May 2012 10:44
@ WLGfx,

Looking good.

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th May 2012 00:11
Just uploaded the preview to the first post for anyone wanting to try it out. Just enter the number of segments, the random seed value and the sloping height and it will generate a complete 3d level for you to explore...

Have fun with it and let me know any comments. Thank you...

The DBP plugin is likely to be ready by sometime during tomorrow.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 22nd May 2012 04:10
If anybody knows anything about plugins and may be able to help out then please have a look here - http://forum.thegamecreators.com/?m=forum_view&t=197032&b=18

It's not working! Other projects compile and run but anything that uses this plugin just freezes the compiler for some reason. Everything has been checked, doubled checked, re-installed, gone through with a fine tooth comb.

I'm almost at the point where I'll be dropping this permanently because I don't want to break my laptop.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Duffer
16
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 24th May 2012 09:56
@ WLGfx,

Hope you didn't give up. IanM is a bit of an authority on plugins for DBPro. I'll post in the dll section linking to here. Maybe he can help if not solved yet?>

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 24th May 2012 14:34 Edited at: 24th May 2012 14:37
@Duffer - Thanks buddy... (sent you an email)

I am hoping I can get it to work eventually because it would be a shame to see this dropped as there will be a few out there that would use this. If I can get it to work with DBP then my next procedural project is likely to be created as a plugin. I've only been visiting these forums over the last few days to see if there's been any posts about it.

It's on the side burner at the moment while I've started with teaching myself mySQL with Visual Basic and also teaching myself IrrLicht. I've found that having a few small projects and one large one helps me get past the writers block.

Accessing an SQL database stored online is one of my new projects, not just for gaming, such as MMO's and such, but for full databases with logins, passwords, ordering systems, etc. And as for learning IrrLicht, it's a free engine that is compatible with my slow laptop and most of the benchmarks work just fine on it too. Plus it's cross-platform.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 28th May 2012 18:56
Finished and downloadable from here: http://forum.thegamecreators.com/?m=forum_view&t=197247&b=18

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!

Login to post a reply

Server time is: 2019-02-20 18:38:05
Your offset time is: 2019-02-20 18:38:05