3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1] 2 3 ... 5

Author Topic: RadSqLite Released.  (Read 9504 times)

jestermon

« on: June 04, 2010, 08:03:53 PM »
Ok guys, here are the toys, let's see what you can do with them.
Full manual included. Just add code.
I will add some examples to this thread, as I get the chance.

Happy databasing
« Reply #1 on: June 04, 2010, 09:02:15 PM »
1 minute ago I wrote 'I'm looking forward to it' and look. Here it is. 
« Reply #2 on: June 04, 2010, 10:47:27 PM »
Nice one. How fast can 3drad access elements from the database? Will using the database on a large scale create any kind of lag in comparison to using regular variables in a script.
« Reply #3 on: June 05, 2010, 03:29:03 AM »
Any database access is always slower than accessing variables in a script.
« Reply #4 on: June 05, 2010, 04:13:03 AM »
I've read through the manual...Serious tool.No doubt it's extremly handy for game-makers who need to parse plenty of data.So it came in handy.
« Reply #5 on: June 05, 2010, 05:05:59 AM »
Yes I realise an external data source will always be slower but will it be noticable?
« Reply #6 on: June 05, 2010, 10:07:46 AM »
I guess that will depend on the amount of data and the number of cycles you access it, like the polys... "will 3d rad run slow rendering a million polys object", probably, but it runs great a 10 one.  :D

btw, GREAT job Jestermon. thank you very much, I downloaded it and will test at the first oportunity to use it well I have.
Crashing Boxes - winner of the 3d games category at the 5th Uruguayan video game contest
get a copy for your iPad/iPhone!
« Reply #7 on: June 05, 2010, 10:45:24 AM »
Cool stuff! Thanx for sharing it jestermon  :)
« Reply #8 on: June 05, 2010, 12:16:05 PM »
Thanks alot, this is absolutely great :)

jestermon

« Reply #9 on: June 05, 2010, 03:02:10 PM »
Thanks for the feedback.

Quote
Yes I realise an external data source will always be slower but will it be noticable?

If you were to use it instead of local variables, it will drag the frame rate into the ground, for sure. Think of the database as a replacement for any text files that you would normally use, but with the power of sql behind it.
As far as speed goes, remember that for every call, there are many floats being loaded, manipulated and translated on both sides of the call (inside Rad, and inside the dll). so there will be a processing overhead, though not
noticeable to the human eye.

Let's use an imaginary game, as see what happens..
1.. You load pre-saved information from the database at initialization, this can be the entire layout of a battle field, the placement and strength values for each soldier. At init, you wont notice the (perhaps) quarter second load of tons of data.
2.. During the game events unfold that you wish to store. eg the base has been overrun, and half your forces wiped out... So as each even happens, a quick update call to the database is unnoticed, because they are small quick calls.
3.. A Major catastrophe hits your forward platoon, and they all get wiped out, and the 200 soldier lose valuable points, and this effects your strategy. A single update call, updates all the soldier's records, even of there are hundreds of them, the call is done in the thread, so you see no change in the frame rate of your game. Just one "sql update" call from you, a blink of and eye.
4.. You finally manage to win the level, and you want to save a lot of new info. so you push through maybe 30-40 sql calls (imaginary) .. and they are not all done together, so it does not effect your framerate, but it does a bit of disk access. It is a level change, so nothing is noticed.
5.. Next level starts, and you load a heap of info..
6.. Using triggers, an sql feature that will update other tables when there is a change made to another, is all internal to the sql engine, and run in a separate thread, you let the database worry about all the work.  So you can use complex logic even with your data, without it effecting frame rate
7.. The loop goes on, till you decide to save the game... Again, this is done when the game is idle, and frame rates are not an issue, so you can dump megabytes of save game info in a matter of seconds.

So in a nutshell, sql is perfect, as long as you don't use it to replace in game variables. But you can pump quick data from your variables to the database at any time, and retrieve them in another script, and use it as  bridge for complex data collections between scripts. But rather use in-game logic with your own variables, which get their values from the database.
Disk access is always slower than memory access, no matter how fast a database may be.

How fast.. Well with the level of games written with 3d Rad, you wont ever load a meg of data anyway (game data, not meshes, textures, etc.), but it takes about 0.07 seconds to do so in the dll. and about 0.23 seconds to transfer that to 3D Rad through the script interface.. so look at about 0.3 seconds per megabyte.. these are rough figures based on some tests. And string conversion based on these figures is extremely slow (0.07 compared to 0.23).. that's why I once asked Fernando if there was a possibility of using string interfaces to dll's  It is however negligible to the human eye.

Edit:
Quote
in comparison to using regular variables in a script

I've been thinking about your question...

Because the sql interface needs to extract the data from the string returned from RadSqLite.dll, this data is placed into a list. So you can use the data directly from the list, which is a local variable anyway. So you are going to use script variables to manage your own data. The sql inteface pushes and pulls text info to the dll; which you need to convert to numbers to use. So you cant really use the database to replace variables, which ever way you look at it.
example:

Code: [Select]
string [] myresults();    //to store your info from sql query into a SCRIPT VARIABLE LIST

sql = "select soldier,battalion,allegiance,lifepoints from battlesquads where battalion = 'red team';";
doSql();
int count = getRecordcount();
for(int i=0;i<count;i++)
{
   getRecord(i);    //reads the data from the dll results buffer in dll memory
                         //always available till the next "select" query

  //the data will  look something like this:   general;red team;player3;120;
  //not very usable in this format.

   myresults = split((sqlResult,";"); //extracts the data to your list
   
   //Now you get the data out of the list into another list for internal use
   soldier[i] =  myresults[0];        //1st column from query
   //battalion[i] =  myresults[1];     // we don't need this data, but used for sql search
   allegiance[i] =   myresults[2];     //3rd column from query
   lifepoints[i] =   iStringVal(myresults[3]);  //convert to internal numeric (4th col)

}

OR if you use a class

Code: [Select]
class SOLDIER
{
   string rank;
   string allegiance;
   float lifepoints;
}

SOLDIER [] soldier(200);  // .. or dynamic if you prefer

for(int i=0;i<count;i++)
   soldier[i].rank =  myresults[0];
   soldier[i].allegiance =  myresults[1];
   soldier[i].lifepoints =  iStringVal(myresults[3]);
}

As you see above, the data is returned as a single string, the split function breaks it into a string list, but you have to take it out of the list to your own variables to use it logically in the game.

If you were using a text file, you would also have a little layer of data conversion in between. sql just gives you control of the the data you select.

Hope this all makes more sense.
« Last Edit: June 05, 2010, 06:21:50 PM by jestermon »

jestermon

« Reply #10 on: June 07, 2010, 02:45:03 AM »
Demo 1 - RadSqLite in action.

This demo shows that with a few sql statements, you can update the database with the click of the mouse, and store location information for later retrieval.

How this works:
There are 2 Andro's... One which you can walk around with, so that you can move the camera location to other parts of the map. Another Andro which walks to waypoints that you define with mouse clicks on the ground.

As the demo starts, there are a few locations that already stored in the database table, that are loaded at startup. Andro2 walks from waypoint to waypoint, until you add another waypoint to the list by left-clicking on the ground.

To start afresh, click with the right mouse button on the ground, which clears all waypoints in memory, as well as in the database.  Then simply click at different locations on the ground to define new waypoints, and Andro2 starts walking to the waypoints in sequence. As you click, each waypoint is saved to the database, for later retrieval.

To see your recorded waypoints load into action, simply stop the demo and restart it. Your saved waypoints will be loaded into memory, and Adro2 will start walking using your saved data.

This interacrive method can be used for recording locations in your game at run-time, or to preset locations, for trees, gems, buildings or any other object or prop that you wish to use in your game. The waypoints are just location x,y,z coordinates that are saved, and are simply used for waypoints in this demo.

The zip file contains the directory structure of where everything should go. Included are the .3dr project file, the RadSqLite dll and the radtestdb.db database file.

Happy databasing.
« Last Edit: June 07, 2010, 02:49:24 AM by jestermon »

jestermon

« Reply #11 on: June 08, 2010, 10:37:54 PM »
SqRadLite V2 release
And another demo

This version has 2 new functions, namely debugOn and debugOff, which allows you to view debug information in the RadSqLite.debug file which gets created in the 3D Rad or game root directory. The manual has been updated.

This demo is a simple Trivia fun, showing another possible use for the database and how to do it.
« Reply #12 on: June 10, 2010, 12:22:00 AM »
 :D I don't get it?? Can I just access these new functions using any script in the project or does it have to be in the "RadSqLiteSQL client" script. Could I request a really simple example? I think that would really help me get started. I'm probably going to end up with a pretty huge database in my game, consisting of times, scores enabled cheats, selected cars, rims, colors, upgrades, levels, hmmm... the list goes on. I'm guessing this tool would have advantages over writing txt files? Or is this even the right tool for this purpose?

jestermon

« Reply #13 on: June 10, 2010, 12:49:23 AM »
You caught me as I took a last peek at the forum before going to sleep after a 12 hour stretch with shaders.. Ok back to reality.

What I do, is I put together my general project objects first, so that I have everything in place. I then merge the RadSqLite project, and then do my scripting directly in there.
1.. I put all my global declarations between the last comment of the RadSqLite block and Main, also any functions that I use. you can structure it your own way.
2.. I add the database name in the iInitialize() block, because I know that I'm not going to change it. but you can set it from anywhere
3.. I then open up SqLite Administrator http://sqliteadmin.orbmu2k.de/
4.. I work directly with sql statements there, to test them fix any syntax errors.
5.. I then create empty function blocks, the name determined by its functionality.
6.. I paste the sql text i need in the block as a comment, and then proceed from there.

For examples, I suggest you look at the resources (they have resource somewhere in their name) I posted with Demo1 and Demo2, since they are simple woriking examples. They have the databases as well as the uncompiled .3dr in them. I suggest you use 3DRadLiteV2, since it had debug switches, which allow you to see debug info in a dump file.. Refer to the manual released with RadSqLite V2

Text files are a thing of the past with sql. you have the full power of sql at your finger tips. The database is cross-script, cross-level, cross-project, and totally portable. Your database read and write is instantaneous, and unless you are reading hundreds of records within every keyframe, you may notice a 1 to 2 frame drop in your framerate. It's that fast. you can store your entire life history, and then some in a database, and select up to the minute reports throughout your game ... (imaginary scenario, but factual availablity from megabytes of data in a flash).

PS: I use another tool Sql Browser (i prefer the Admin tool above for live testing) which has the ability to import and export csv files http://sqlitebrowser.sourceforge.net/
I use a standard Excel spreadsheet to create and fill a complex database, and then export that as a csv comma ssperated file with names in the top column. this I import into sqlite with the sqlitebrowser.

Edit: I'll post a simple example when I wake up and get back to my 3D playing later :)
« Last Edit: June 10, 2010, 01:15:24 AM by jestermon »
« Reply #14 on: June 10, 2010, 10:16:39 AM »
Ok, thanks. That really helps.. And sorry to bother you so late. I was pretty much the same. I modeled for around ten hours yesterday and 9 hours tuesday and monday. So I'm about ready to get some fresh air today. ;D
Pages: [1] 2 3 ... 5