RUBE Loader Project

  ... the case you feel the need for a new feature or want to submit one.

Re: RUBE Loader Project

Postby baze » Tue Feb 25, 2014 8:25 am

I'm using RubeLoaderExtension (great work by the way) and I'm loading my levels in parts as described below. But now I have noticed a small bug in the loading I can't figure out.

nazgee wrote:
Syntax: [ Download ] [ Hide ]
  1. public class GameScene extends Scene() { 
  2.     private RubeDef mRubeWorld; 
  3.     private RubeDef mRubeVehicle; 
  4.  
  5.     public void load(ItemVehicle pVehicle, ItemLevel pLevel) { 
  6.         mRubeWorld = loadWorld(pLevel, loader, window); 
  7.         mRubeVehicle = loadVehicle(pVehicle, loader, window, mRubeDef.worldProvider); 
  8.     } 
  9.  
  10.     private RubeDef loadWorld(ItemLevel pLevel, final RubeLoader loader) { 
  11.         RubeDef rube = loader.load(GameResources.ACTIVITY.getResources(), this, GameResources.TEXTURES, GameResources.ENGINE.getVertexBufferObjectManager(), pLevel.getResourceID()); 
  12.         rube.worldProvider.getWorld().setContactListener(mContactListener); 
  13.  
  14.         // newly created physics world has to be created manually: 
  15.         registerUpdateHandler(rube.worldProvider.getWorld()); 
  16.         return rube; 
  17.     } 
  18.  
  19.     private RubeDef loadVehicle(ItemVehicle pVehicle, final RubeLoader loader, final IPhysicsWorldProvider pPhysicsWorldProvider) { 
  20.         RubeDef rube = loader.loadMoreToExistingWorld(GameResources.ACTIVITY.getResources(), this, GameResources.TEXTURES, GameResources.ENGINE.getVertexBufferObjectManager(), pVehicle.getResourceID(), pPhysicsWorldProvider); 
  21.  
  22.         return rube; 
  23.     } 


loadWorld creates a new RubeDef + PhysicsWorld. loadVehicle creates a new RubeDef, but reuses an exisiting PhysicsWorld. This means, that in a single PhysicsWorld, I can have level (ground, obstacles, background), as well as a vehicle (object that is driven by player), which is exactly what I wanted to have: two separate files, that form a common PhysicsWorld.


I'll try to explain:
In "level.json" file I'm defining "render order" to images to make some bodies appear front and some bodies appear back. Standard stuff and works like expected.

In my "vehicle.json" I'm defining "render order" and again vehicle parts are rendered correctly like like expected.

But render ordering seems to brake when level and vehicle are loaded into the same world. Looks like the vehicle will be always on top of the world even if "level.json" have images that have bigger "render order" than vehicles parts.

So should I call some method to reorder my images back to correct order after loading them in parts?

(btw.Big thanks to nazgee, RealMayo and Nicolas for making these tools available. )
baze
 
Posts: 2
Joined: Tue Feb 25, 2014 8:05 am

Re: RUBE Loader Project

Postby nazgee » Wed Feb 26, 2014 9:19 pm

Quick tip: you probably want to sort your scene after loading all the separate jsons. This should fix your ordering (given that you were consistent with image zindexes).

// load world to scene
// load vehicle to scene
scene.sortChildren();
Dirt Rider Mayhem is PUBLISHED now!
Image
User avatar
nazgee
 
Posts: 527
Joined: Fri Oct 21, 2011 10:31 pm
Location: Poland, Wrocław

Re: RUBE Loader Project

Postby baze » Wed Feb 26, 2014 11:31 pm

nazgee wrote:Quick tip: you probably want to sort your scene after loading all the separate jsons. This should fix your ordering (given that you were consistent with image zindexes).

// load world to scene
// load vehicle to scene
scene.sortChildren();


Great, that fixed it.
Thank you.


I'm also trying to extend RubeLoader to automatically load level graphics as it would make level creation and modifications smoother. I have been reading the RubeLoader but can't figure out why my modification doesn't work.

I have tried to simplified my problem below into example code that should auto-load textures but doesn't.
if I uncomment the "LoadAndStore"(lines 11-14) calls and move the "new RubeScene" (line 16) after line "this.mBitmapTextureAtlas.load()" then this example works.

Get-method has lazy-loading features that replaces those explicit "LoadAndStore" calls, but for some reason I must have the scene loading after building and loading textureAtlas.


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         protected void loadAndStore(final String pName) {
  2.                 ITextureRegion region = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mBitmapTextureAtlas, this, pName);
  3.                 mTexturesMap.put(pName, region);
  4.         }
  5.  
  6.         @Override
  7.         protected Scene onCreateScene() {              
  8.                 BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
  9.                 this.mBitmapTextureAtlas = new BuildableBitmapTextureAtlas(this.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR);             
  10. /*
  11.                 loadAndStore("ae.png");
  12.                 loadAndStore("wood.png");
  13.                 loadAndStore("star.png");
  14.                 loadAndStore("bg.png");
  15.    */
  16.                 RubeScene scene = new RubeScene(this, getResources(), getEngine().getVertexBufferObjectManager(), R.raw.rube_ae_example);              
  17.                
  18.                 try {
  19.                         this.mBitmapTextureAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 0, 1));
  20.                         this.mBitmapTextureAtlas.load();
  21.                 } catch (TextureAtlasBuilderException e) {
  22.                         Debug.e(e);
  23.                 }
  24.  
  25.                 return scene;
  26.         }
  27.  
  28.         @Override
  29.         public ITextureRegion get(String pFileName) {          
  30.                 if ( mTexturesMap.containsKey( pFileName ) ){
  31.                         Log.d("Texture", "Returning texture from cache["+pFileName+"]");
  32.                         return mTexturesMap.get(pFileName);
  33.                 } else {
  34.                         Log.d("Texture", "OnDemand loading texture["+pFileName+"]");
  35.                         loadAndStore(pFileName);
  36.                         return mTexturesMap.get(pFileName);
  37.                 }              
  38.                
  39.         }
  40.  
Parsed in 0.025 seconds, using GeSHi 1.0.8.4
baze
 
Posts: 2
Joined: Tue Feb 25, 2014 8:05 am

Re: RUBE Loader Project

Postby Androidacct » Sun Mar 30, 2014 11:40 pm

Has anyone actually released a game using RUBE and Nazgee's loader? I was just wondering if there are any limitations? Is it noticeably slower to load compared to other games made using Andengine without rube? Cheers.
Zapper - A great game that tests your reflexes and concentration levels.
Image
https://play.google.com/store/apps/details?id=com.casualgames.zapper
Androidacct
 
Posts: 80
Joined: Wed Jan 29, 2014 12:29 am

Re: RUBE Loader Project

Postby nazgee » Mon Mar 31, 2014 9:35 am

My DRM uses RUBE. Candy roll saga by CoderForLife used to use RUBE before he was forced to remove game from the market.
I would say it is reasonably fast. What is slow for you?
Dirt Rider Mayhem is PUBLISHED now!
Image
User avatar
nazgee
 
Posts: 527
Joined: Fri Oct 21, 2011 10:31 pm
Location: Poland, Wrocław

Re: RUBE Loader Project

Postby Androidacct » Mon Mar 31, 2014 5:29 pm

It just felt like loading was slightly slower than scenes not created using Rube (this may be my inefficient textured mesh method). I was just curious if there are any limitations of the loader, but it must be good if several games have been released.

I've played your game, the features you use are very impressive from a developer point of view. I was watching my little brother play it tho and the lack of control in the air really frustrated him (after 3 goes he gave up), so maybe that is something to look in to. Also, I think there is too much clashing going on at times, sometimes I don't know which path my driver is going to take - is the driver going to go on the grass, go up the mountain or crash into bush. Finally I think the transition from finish to swinging sign is too abrupt. I'm not trying to hate in any way tho (rated 5 stars) I just think with some changes and maybe some decent graphics you could have a popular game.

Also, I have no idea how Mattias managed to get away with Candy racer... Google play is so inconsistent lol
Zapper - A great game that tests your reflexes and concentration levels.
Image
https://play.google.com/store/apps/details?id=com.casualgames.zapper
Androidacct
 
Posts: 80
Joined: Wed Jan 29, 2014 12:29 am

Re: RUBE Loader Project

Postby nazgee » Mon Mar 31, 2014 8:40 pm

DRM sucks. It might be decently coded, but it fails as a FUN game. I know it, so I don't mind hating. I started it as a project to validate that RUBE has all required feature, and accidentaly made a game of it :) Anyway: thanks for the rating!

If you create physics directly from code (e.g. you have very simple or random levels), than it will be blazing fast. If you need to load a level, than there is parsing involved and it will always be a bit slower.
Loading levels from binary formats will be faster, but it's not portable. To be portable RUBE uses JSON which is a bit faster than XML is, but still requires parsing.

Original implementation of RUBE loader extension was ~250% slower, so believe me- I already did some optimizations of it, though I am sure that getting better performance is still needed.

If you want to know what is taking your time, do a simple profiling: measure time it takes for RUBE loader to load your level (I think that RUBE loader used to print out loading times in logcat... maybe it still does it?).

If it's indeed RUBE loader to be blamed, you can try "packing" your json files (there is an option for it somewhere in editor). RUBE loader should handle it correctly, and be a little bit faster (this kind of files do not contain whitespaces, which makes it easier/faster to parse, but hard/impossible to edit manually for human).
Dirt Rider Mayhem is PUBLISHED now!
Image
User avatar
nazgee
 
Posts: 527
Joined: Fri Oct 21, 2011 10:31 pm
Location: Poland, Wrocław

Re: RUBE Loader Project

Postby nazgee » Tue Apr 01, 2014 10:44 pm

RUBE loader displays load times:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Debug.w("RubeLoaderExtension LOAD_TIME=" + elapseTime/1000.f);
Parsed in 0.020 seconds, using GeSHi 1.0.8.4

Just have a look at your logcat, and make sure that your loading delay comes from RUBE loader or sth else.
Dirt Rider Mayhem is PUBLISHED now!
Image
User avatar
nazgee
 
Posts: 527
Joined: Fri Oct 21, 2011 10:31 pm
Location: Poland, Wrocław

Re: RUBE Loader Project

Postby Androidacct » Wed Apr 02, 2014 1:36 am

Ooh that's useful, I'll check it out. Cheers.
Zapper - A great game that tests your reflexes and concentration levels.
Image
https://play.google.com/store/apps/details?id=com.casualgames.zapper
Androidacct
 
Posts: 80
Joined: Wed Jan 29, 2014 12:29 am

Re: RUBE Loader Project

Postby Yotamanga » Fri May 02, 2014 11:21 am

Hey,

First at all, big thanks to nazgee for his work and exampes.

I'm a newbie in android' developpement ^^.
i was making a platform game when i needed to take care about the specific texture U_U
So i tried to undertand how it works whith rube and nazgee's example.
I guess i succeed in modify the exemple but when i try to implement the solution into my game i have some troubles...

Some questions :
- Does the rube loader works for project base on "baseactivity" instead of "simpleBaseActivity" ?
- How work the ITextureProvider type and how can i set value into ?

EDIT : got it \o/
it iissss workinnngg !
(i forgot to implements ITextureProvider on one of my class U_U)


thanks in advance.
Sorry for my english :(
User avatar
Yotamanga
 
Posts: 1
Joined: Sat Apr 26, 2014 7:41 pm

PreviousNext

Return to Features

Who is online

Users browsing this forum: No registered users and 5 guests