Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (483)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (550)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Rebirth - Game Resources Library  (Read 4582 times)
0 Members and 1 Guest are viewing this topic.
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Posted 2009-07-29 13:55:55 »

<a href="http://triangularpixels.net/games/tools/rebirth/">Rebirth</a> is a resource system designed for games, which makes it fast and easy to make your game data driven without having to write lots of tedious boilerplate parsing code. It's also a full resource manager, and handles object lifetimes and background loading in a seperate thread. And for maximum productivity it monitors your file system for file modifications and automatically reloads the affected resources while your game is still running.

<b>Current version</b>
<a href="http://www.triangularpixels.com/Rebirth/Latest/Rebirth.jar">Rebirth library jar</a>
<a href="http://www.triangularpixels.com/Rebirth/Latest/Api/index.html">Browsable Javadoc</a>
<a href="http://www.triangularpixels.com/Rebirth/Latest/Report/index.html">Test results</a>

<b>Getting started</b>
Check out the <a href="http://triangularpixels.net/games/tools/rebirth/quickstart1">quick start guide</a> and <a href="http://triangularpixels.net/games/tools/rebirth/quickstart2">quick start part two</a>.

<b>About</b>
The resource system is heavily inspired by Cas' resource system from SPGL, which I've been using for a while. The gist is to use copious amounts of reflection to convert from xml to a Java object based on the field names and types. Cas' system is pretty good, but it's starting to show it's age and there was a bunch of things I wanted to improve or add. The big improvements are:
 - background loading
 - cleaner xml syntax
 - pluggable decoders for user and 3rd party types
 - auto reload for modified files
 - resource inheritance

I'm pretty much calling this version 1.0, as it's complete and has all the core functionality you should need. Documentation is a little sparse but I'm working on that at the moment (feedback appreciated). Error handling should be robust but errors might be a little confusing to a beginner so suggestions for improvements there are appreciated too.

License is pending, but will probably be MIT or BSD unless anyone has any strong arguments against one of these.

So there you go. Smiley Comments and feedback of any kind greatly appreciated, and if you try it and hit any problems then post here or find me in #lwjgl.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #1 - Posted 2009-07-29 14:09:25 »

Shweeeet! I'll take a peek at it. Getting a bit sick of the foibles in my code.

Cas Smiley

Offline CommanderKeith
« Reply #2 - Posted 2009-08-01 03:59:50 »

Looks cool, great idea. That would make it a lot easier to change things for graphics and balancing.

It's such a pity that java's security is all or nothing, so reflection requires an 'all permissions' security dialog.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2009-08-01 06:49:00 »

Only access out of scope - the library could be tweaked to only work with public members. I suppose it'd be a bit less useful then.

Cas Smiley

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #4 - Posted 2009-08-01 09:30:17 »

Hmm, I always end up requesting all-permissions anyway, so I hadn't thought about that. Certainly accessing and setting private members is by design (because if you're obsessive like me you make your automatically parsed members private and write accessors for them so resources are properly immutable), but if you're careful to only read from them there's nothing stopping you working with all public fields.

I'll have to look into the reflection security stuff, it's entirely possible that it's usable without permissions in it's current state (although you might have to tag private members with @NonParsable so they get skipped).

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline CommanderKeith
« Reply #5 - Posted 2009-08-01 10:18:56 »

That's interesting, hadn't thought about just changing public members.

Don't go to any trouble trying to fix it, I was just thinking out loud about how annoying reflection is like that.

Cool library  Cool

Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #6 - Posted 2009-08-13 02:08:13 »

Seems neat! I like the idea of just putting stuff in a directory and then getting a reference to it and using it. Can it do more than parse XML? How about YAML? What if it could load images?

If you used something like XStream for XML or, even better Wink, YamlBeans for YAML, those libs serialize and deserialize object graphs without the need for a decoder, or even objects in the graph to extend a class.

Stepping back from Rebirth a bit and just thinking about what I'd like to see in a resource management system:

  • Progress is important. Probably less so with configuration files, since they probably parse quickly, but loading images, maybe building a database, etc. Should be a nice way to get a percentage of progress. If the framework has many tasks and some of them don't have an idea of completion percentage, then the progress percentage would be indeterminate. However, and this is the clever bit Wink, what if it remembered the time it took, so next time the app runs it will show progress percentage based on time.
  • Easy of use. Serialized objects shouldn't have to extend a class. The framework shouldn't require any setup, just files in a directory and some Java code to create a resource pool.
  • Adding resource types should be easy. Eg, what if I wanted .sql files to be run in an in-memory database using the resource system in order to gain progress status and file watching? What if I wanted to do image loading via LWJGL? Via Slick? Audio loading?
  • What happens if all my resources are in JARs? Might be neat to work from the file system, classpath, JAR, ZIP, URL, etc. Might want to make how the resources are found and loaded very flexible to support this sort of thing.
  • Might be nice to clear a resource pool. Imagine you had separate game screens that were very resource intensive. When you leave a screen you could clear its resources and when you show a screen you would load them again. Would be sweet if this were just a method call or two. Resources could be treated generically and have a lifecycle, so different resource types would have hooks to init/destroy/whatever.
  • How about a way to save resources? My config files can usually be changed in-game and are written back to disk. Maybe resources could even be added to a resource pool programmatically and it would create new files.
  • Background loading should be cancelable. Eg, if something is loading in the background and the user leaves that screen, the loading should stop.

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #7 - Posted 2009-08-13 09:47:30 »

(with apologies about the length...)

Seems neat! I like the idea of just putting stuff in a directory and then getting a reference to it and using it. Can it do more than parse XML? How about YAML? What if it could load images?
XML only at the moment - I've never actually seen YAML used "in the wild" myself, I suppose it could be added but I see it making the API more complicated and harder to use with little benifit.

Quote
If you used something like XStream for XML or, even better Wink, YamlBeans for YAML, those libs serialize and deserialize object graphs without the need for a decoder, or even objects in the graph to extend a class.
I looked at using XStream but it wasn't a great fit. XStream aims to just convert to/from xml with as little effort as possible - Rebirth is about making your own xml syntax for resources and converting that into a set of objects with minimal parsing code. Obviously I've pinched the handy bits (like auto decoding of primative and array types) anyway so adding XStream as well doesn't make sense.



Quote
Progress is important. Probably less so with configuration files, since they probably parse quickly, but loading images, maybe building a database, etc. Should be a nice way to get a percentage of progress. If the framework has many tasks and some of them don't have an idea of completion percentage, then the progress percentage would be indeterminate. However, and this is the clever bit Wink, what if it remembered the time it took, so next time the app runs it will show progress percentage based on time.
It's already possible to determine loading progress over the top of the current system by looking at resource states. I plan on writing a better 'resource phase' system over the top for typical per-level style resource management which will have progress tracking.

Quote
Easy of use. Serialized objects shouldn't have to extend a class. The framework shouldn't require any setup, just files in a directory and some Java code to create a resource pool.
Rebirth resources don't have to extend a base class, but they do need to implement an interface so they can have their lifecycle managed. Trivial resources (which just use auto parsing) can extend a base class to get that behaviour 'for free'. For classes you can't control or implement an interface then Decoders let you use these easily.

Quote
Adding resource types should be easy. Eg, what if I wanted .sql files to be run in an in-memory database using the resource system in order to gain progress status and file watching? What if I wanted to do image loading via LWJGL? Via Slick? Audio loading?
The Rebirth approach to this is that you use your regular image/db/audio resources, and have a Resource which creates them in the create() callback. Main-thread callbacks let you do any initialisation which has to happen in the main thread (like texture uploads).

Quote
What happens if all my resources are in JARs? Might be neat to work from the file system, classpath, JAR, ZIP, URL, etc. Might want to make how the resources are found and loaded very flexible to support this sort of thing.
Native file system (for development) and jars (for deployment) are supported out-of-the-box. If you want to support additional locations like zip or over the internet then the ResourceIO interface lets you do that.

Quote
Might be nice to clear a resource pool. Imagine you had separate game screens that were very resource intensive. When you leave a screen you could clear its resources and when you show a screen you would load them again. Would be sweet if this were just a method call or two. Resources could be treated generically and have a lifecycle, so different resource types would have hooks to init/destroy/whatever.
See above comments on progress tracking.

Quote
How about a way to save resources? My config files can usually be changed in-game and are written back to disk. Maybe resources could even be added to a resource pool programmatically and it would create new files.
Config files and any savable state/progress isn't part of a resource system IMHO. Resources are very deliberately immutable, intended to be in a jar or on read-only media (CD/DVD). More of a job for something like XStream IMHO.


I think I should emphasise that Rebirth is not XStream. They solve different problems in entirely different ways. I really would suggest giving it a try rather than picking apart the feature list - it's only a couple of function calls to get started and you'll quickly see easy it is to add and tweek resources. Plus, I'm much more likely to add/change things if you're using it rather than armchair debating it. Wink

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline cylab

JGO Ninja


Medals: 43



« Reply #8 - Posted 2009-08-13 10:23:01 »

Did you take a look at JAXB? If so, why did you abadon it (for your XML->Object conversion part). I am just curious.

Mathias - I Know What [you] Did Last Summer!
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #9 - Posted 2009-08-13 10:46:43 »

I had a look at quite a few xml apis when I started writing this, but I can't remember if I looked at jaxb specifically. Personally I'm really not a fan of xml schema files (big, verbose, tedious) and the whole idea of the library is that it's easy to use - requiring people know how to create valid schema files and generate code via the jaxb schema compiler is significant extra work I think for minimal added benefit.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #10 - Posted 2009-08-13 10:48:19 »

Rebirth resources don't have to extend a base class, but they do need to implement an interface so they can have their lifecycle managed. Trivial resources (which just use auto parsing) can extend a base class to get that behaviour 'for free'. For classes you can't control or implement an interface then Decoders let you use these easily.
My point was, an interface doesn't seem necessary for POJOs/beans, and Decoders don't seem necessary for 3rd party POJOs/beans.

Quote
The Rebirth approach to this is that you use your regular image/db/audio resources, and have a Resource which creates them in the create() callback. Main-thread callbacks let you do any initialisation which has to happen in the main thread (like texture uploads).
I liked the idea of automating it, of only needing to ask for a reference.

Quote
I really would suggest giving it a try rather than picking apart the feature list - it's only a couple of function calls to get started and you'll quickly see easy it is to add and tweek resources. Plus, I'm much more likely to add/change things if you're using it rather than armchair debating it. Wink
Well, you asked for feedback and comments. Smiley I have a strong distaste for hand editing XML, but mostly I don't currently have any projects with enough configuration to warrant Rebirth.

Offline cylab

JGO Ninja


Medals: 43



« Reply #11 - Posted 2009-08-13 10:52:01 »

I had a look at quite a few xml apis when I started writing this, but I can't remember if I looked at jaxb specifically. Personally I'm really not a fan of xml schema files (big, verbose, tedious) and the whole idea of the library is that it's easy to use - requiring people know how to create valid schema files and generate code via the jaxb schema compiler is significant extra work I think for minimal added benefit.

You can just annotate a java class and you are done. Unfortunately that's exactly the part of JAXB that isn't well visible in the myriads of schema centric articles about it :/ You can even do the opposite and generate a schema from the annotated classes to get code-completion in xml editors / ides.

Mathias - I Know What [you] Did Last Summer!
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #12 - Posted 2009-08-13 10:57:49 »

You can just annotate a java class and you are done. Unfortunately that's exactly the part of JAXB that isn't well visible in the myriads of schema centric articles about it :/ You can even do the opposite and generate a schema from the annotated classes to get code-completion in xml editors / ides.
Sounds promising. I'll look into it but I'm not convinced it's not too "enterprisey" for my usage.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #13 - Posted 2009-08-13 11:06:25 »

My point was, an interface doesn't seem necessary for POJOs/beans, and Decoders don't seem necessary for 3rd party POJOs/beans.
I liked the idea of automating it, of only needing to ask for a reference.

Decoders allow you to do a lot more though - like defining custom syntax instead of a straight one to one mapping of attributes to members. For example a Color decoder could let you define one as "red=10 blue=20 green=30", or "light blue" or "0xAA99DD", or "(0.4, 0.6, 0.1)". And if you provide a decoder for your native texture/image/etc. then it will be automated in your resource class.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #14 - Posted 2009-08-29 12:32:26 »

There's a new version up (same urls as before). You can now use it in 'restrictive' mode, for use in applets and other sandboxed environments. This works as before with the caveat that resources need to have public members rather than private ones.

Also fixed a few embarassing resource creation and threading bugs, plus added the ability to do a background create of all resources in one go.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (15 views)
2014-08-22 19:31:30

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (38 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!