ArdorCraft API

Show off your Ardor3D skills - games, demos, videos, screen shots and other shiny.
Forum rules
Show off your Ardor3D skills - games, demos, videos, screen shots and other shiny. Don't tease... Your first post should show the shiny!

ArdorCraft API

Postby MrCoder » Tue May 17, 2011 8:31 am

Edit: The ArdorCraft API is a framework for you to use to build your own blockworld games...

So, I've finally made some decent progress on this project :)

First of all, it was quite a challange to transform ArdorCraft into a general API due to all the optimizations I had in that were game specific. It was also very intertwined with the game specific code (hello spagetti "I'm just gonna get this working" code). Anyways, after I got that done I discovered tons of things that could be improved, so I more or less rewrote most of it.

The project is hosted here: https://code.google.com/p/ardorcraft-api-examples/

If you are an Eclipse user it should be as easy as checking out the project, changing the lwjgl.jar native target (if not on windows), and then running the examples.
There are four examples included:
- SimpleGame, just the minimum code to generate a world and fly around in it.
- IntermediateGame, adds collision detection, block add/remove
- AdvancedGame, adds player physics (more to add here)
- RealGame, adds fly/walk switching, skydome, lighting changes, test on voxelizing a mesh into the world, blocktype changing, a marker that shows which block you are targeting etc

For ease of development, the api now works against the minecraft texture pack files (255 block textures packed into a single texture as a 16x16 grid).
Size of the world, map file, textures and such are all configurable.

There are possibly bugs introduced from the rewrite, so please add anything you find to the issue tracker!

Image

From here on it's a bit technical and boring, so only read if you are interested... :geek:
The biggest changes from the "old" ArdorCraft is:

Lighting
Lighting was built when the chunk meshes were built, and done by querying a lighting function for all faces of each cube to be lit. With this I could do some tracing and ambient occlusion calcs that looked pretty good.
But
- It was slow as hell
- Did not do well with things like getting complete darkness in closed spaces
- Since light had to be queried when rebuilding the mesh after adding/removing blocks, editing could feel slow. it was not possible to break up the building and lighting into separate threads.
- Adding local lights like torches would have been a mess
Due to that the lighting is now volumetric, in that all empty space blocks contain a light value. blocks get lit by the sun (and later on local lights), and then that light is propagaded into shadowed areas. This takes care of all the problems above. Also, I am now smoothing all the lighting and then applying the lighting to the vertices separately instead of a single light value per pace. So no light blockyness can be seen anymore. There is also added "crease" shading which looks great.
Oh, and its also possible to set the global lighting value now to simulate time of day.

Terrain generation
The user supplied terrain generation class was also queried at mesh building time, which was slow and ugly. Now the API always works against a map file, so everything that is generated or edited gets written to the chosen map file, and that mapfile is then queried when building the chunks. As an added bonus we now have a map file so that coming back into a map where you have been does not require any generating at all. Its also easy to create a stand-alone map viewer for it.
I have created my own format which compresses chunks as they are saved to the file so it should stay fairly small even for lots of data.

Well, lots more, but I'm in a bit of a hurry! :)
Last edited by MrCoder on Fri May 20, 2011 7:31 am, edited 4 times in total.
Destroy, Erase, Improve
User avatar
MrCoder
Site Admin
 
Posts: 755
Joined: Mon Nov 03, 2008 8:56 am
Location: Stockholm, Sweden

Re: ArdorCraft API

Postby MrCoder » Tue May 17, 2011 8:34 am

Destroy, Erase, Improve
User avatar
MrCoder
Site Admin
 
Posts: 755
Joined: Mon Nov 03, 2008 8:56 am
Location: Stockholm, Sweden

Re: ArdorCraft API

Postby renanse » Tue May 17, 2011 8:41 am

Awesome stuff! That single screen shot already looks way better than most other minecraft like games out there. :)
Gratitude is a mark of a noble soul and a refined character.
User avatar
renanse
Site Admin
 
Posts: 2955
Joined: Tue Oct 28, 2008 6:49 pm
Location: Austin, TX

Re: ArdorCraft API

Postby Valex » Tue May 17, 2011 2:19 pm

:shock: :shock: :shock: :shock:

And here I thought I was going to have a quiet week... must... read...

--V
User avatar
Valex
newcomer
 
Posts: 28
Joined: Fri Jul 24, 2009 1:42 pm
Location: Long Island, NY

Re: ArdorCraft API

Postby MrCoder » Thu May 19, 2011 9:30 am

Now has support for transparent blocks (windows, tree leaves etc). By default the blockId->texture mapping is the same as in minecraft (Minecraft block ids), ids 1-95.
I'm also doing automatic tinting of the grass(0,0) and leaves subtexture, like minecraft textures need...(can add configuration for that later)
Also added a small start of a minecraft->ardorcraft converter.
Destroy, Erase, Improve
User avatar
MrCoder
Site Admin
 
Posts: 755
Joined: Mon Nov 03, 2008 8:56 am
Location: Stockholm, Sweden

Re: ArdorCraft API

Postby MrCoder » Fri May 20, 2011 2:45 pm

Obis voxelization code which is included in the api can be a bit useful as a base for a complex block model (i need to find some better models though).
Image

It's as easy as this (after you get a collada model, from 3dwarehouse for example):
Code: Select all
            final ColladaImporter colladaImporter = new ColladaImporter();
            final ColladaStorage storage = colladaImporter.load(ResourceLocatorTool.locateResource(
                    ResourceLocatorTool.TYPE_MODEL, "com/ardorcraft/resources/model.dae"));
            final Node colladaNode = storage.getScene();
            final Mesh mesh = MeshCombiner.combine(colladaNode);

            final Voxelator voxelator = new Voxelator(blockWorld, 140, 140, 140); // max size of the model in blocks
            voxelator.voxelate(pos, mesh, 1.0f, 43); // 43 is blockId to use for the model, pos is where to place origo for the model


Maybe we can find a way to extract the texture/material at different parts to automatically set different block types.
Destroy, Erase, Improve
User avatar
MrCoder
Site Admin
 
Posts: 755
Joined: Mon Nov 03, 2008 8:56 am
Location: Stockholm, Sweden

Re: ArdorCraft API

Postby MrCoder » Fri May 20, 2011 5:51 pm

FYI, moving forward on local lights (hopefully commit to SVN tomorrow).

Scary dusk/night time:

Image
Image
Destroy, Erase, Improve
User avatar
MrCoder
Site Admin
 
Posts: 755
Joined: Mon Nov 03, 2008 8:56 am
Location: Stockholm, Sweden

Re: ArdorCraft API

Postby gouessej » Tue May 24, 2011 4:36 am

Good job :) It is really impressive. Does it require an high end machine to work?
gouessej
regular
 
Posts: 1186
Joined: Fri May 01, 2009 3:26 am
Location: France

Re: ArdorCraft API

Postby MrCoder » Tue May 24, 2011 6:06 am

Not at all, it's 100% fixed function (no shaders), and no special features (but next version will use VBOs if supported by the machine). i'm running it smoothly on my not so good laptops. It all depends on the view distance of course, so it can be adapted. Also depends on how complex your terrain is, so it's up to you folks to create terrain generators that generate beautiful but still not too complex scenes ;)
Destroy, Erase, Improve
User avatar
MrCoder
Site Admin
 
Posts: 755
Joined: Mon Nov 03, 2008 8:56 am
Location: Stockholm, Sweden

Re: ArdorCraft API

Postby MrCoder » Wed May 25, 2011 5:25 am

Local lights are in.

For you lazy people, a runnable version of one of the examples can be downloaded here: Example 1 (just edit run.bat to make sure the natives point to the right OS)
Destroy, Erase, Improve
User avatar
MrCoder
Site Admin
 
Posts: 755
Joined: Mon Nov 03, 2008 8:56 am
Location: Stockholm, Sweden

Next

Return to Show Case

Who is online

Users browsing this forum: No registered users and 0 guests

cron