Crazy Minecart : 3d test

Continuing on 3d version of Crazy Minecart I started tests on the game itself.

Exporting models

To export models from Blender I use a small script to export all models with a name starting with “export_”, they are all exported in the “exports” folder, in collada (.dae file)

This script is based on this post, I’ve modified it to export only objects with a name starting with “export_”, to move objects to origin, and to export to collada (as collada supports armature/animations, that could be needed for future projects)

import bpy

# get the path where the blend file is located
path = bpy.path.abspath('//')

# deselect all objects
bpy.ops.object.select_all(action='DESELECT')    

# loop through all the objects in the scene
scene = bpy.context.scene
for ob in scene.objects:
    # make the current object active and select it
    scene.objects.active = ob
    ob.select = True

    # make sure that we only export meshes
    if ob.type == 'MESH' and ob.name.startswith('export_'):
        # export the currently selected object to its own file based on its name
        print(ob.name.replace('export_',''));
        px=ob.location.x;
        py=ob.location.y;
        pz=ob.location.z;
                
        ob.location.x=0.0;
        ob.location.y=0.0;
        ob.location.z=0.0;
        
        bpy.ops.wm.collada_export(filepath=str(path + 'exports/' + ob.name.replace('export_','') + '.dae'),selected=True,triangulate=True);
        
        ob.location.x=px;
        ob.location.y=py;
        ob.location.z=pz;
        
    # deselect the object and move on to another if any more are left
    ob.select = False

I’ve replaced the bottom timeline with the text editor in Blender, it makes running script easier (and I don’t know yet how timeline works). When executing script make sure you are in object mode, it won’t work in edit mode.

capture_2015-03-30_16-54-35_0320_Blender_home_jb_jbs_Projets_Microbasic_CrazyMinecr

 

First tests

As I suspected I had problems updating Crazy Minecart, it was using an old version of libgdx and other libraries. LibGdx was easy to update (create a new project, copy old files), but mopub was a pain, their documentation is outdated and incomplete, so that doesn’t help. But it finally worked (not tested on ios yet, and I haven’t tested game centers yet, I just know it compiles…)

I am currently working on the title screen, it is easier to test there, first adding models :

capture_2015-03-29_19-12-26_0295_crazy_minecart_

 

 

Then adding some basic lighting :

capture_2015-03-29_19-25-07_0840_crazy_minecart_

 

The trees seems off, it’s because of back face culling (front faces are invisible, back faces that should be invisible are visible), I have no idea why but the normals are inverted :

  • In blender normals are correct
  • If I export as wavefront object with Blender and re-import it, on import model will have normals inverted
  • If I export as collada object in Blender, it is correct on re-import
  • If I convert the collada object to LibGdx format then normals will be inverted
  • If I invert normals on model and export it, it will be visible in the game but normals will still be off (the face in shadow will receive light, but not the one in light)

So I ended up recreating the tree from scratch, and this time it worked, I have no idea why the other tree is such a mess…

I also increased gap between ties as it doesn’t look good at high speed and I scaled / rotated trees randomly :

capture_2015-03-29_20-44-51_0763_crazy_minecart_

 

Inverting grass/dirt, it feels better at high speed :

capture_2015-03-30_00-08-31_0957_crazy_minecart_

 

Tuning lighting a bit (I still need to tune light direction, specular and “shininess”) and changing trees colors :

capture_2015-03-30_00-37-00_0326_crazy_minecart_

 

Adding some shadows (using an orthographic camera, to simulate sun light / directional light) :

capture_2015-03-30_12-24-44_0605_crazy_minecart_

 

Moving the light source position a bit :

capture_2015-03-30_15-17-50_0853_crazy_minecart_

 

At this point I began testing on my Nexus 7, sadly it is running at around 25fps… It is because of shadow mapping, writing to a FBO seems to be really slow even with simple models such as the ones I use. And this game really needs a stable 60fps.

I am currently continuing testing shadow mapping, and trying to improve performances, if I can’t get anything good I’ll try something else.

Comments are closed.