Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Loading an object over time?

Author
Message
Qqite
14
Years of Service
User Offline
Joined: 28th Feb 2010
Location: Florida, U.S.
Posted: 4th Aug 2012 23:47
So I have an idea that one could setup a thread to load objects that runs parallel to the main thread. This thread would, when fed info on what to load in a message queue, that it would load objects (dbLoadObject(...)) in that thread and blacklist that object number (maybe dbHide that object until it is finished loading so that it is not drawn) so that nothing else flips out.

So my question is, is this possible? Or will DGDk still throw an error if it has an object loading in another thread when called to sync?

Is there another way to do this? I notice that dbLoadObject has a third parameter that I have yet to understand?

P.S. The reason I want this is because in my game new players/npcs are going to be coming in and out of view very commonly, and loading every since game object before the game starts is not possible. So I'm trying to have the client load things on the fly but to load things over time so that the client can keep a somewhat consistant framerate to work with as to not completely stop the game while the object loads.

Ventures of the worlds around us are limited only by our imagination.
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 4th Aug 2012 23:59
It's not possible without completely rewriting the "load object" command. You can load one of each type of object at the start and then simply clone/instance them as required. That should be very fast.

[b]
Qqite
14
Years of Service
User Offline
Joined: 28th Feb 2010
Location: Florida, U.S.
Posted: 5th Aug 2012 00:59
So is there any way of making a memblock and tjen turning imto an object? I really want to avoid loading EVERYTHING at the beginning :\

Ventures of the worlds around us are limited only by our imagination.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th Aug 2012 01:36
I was under the impression this should be possible with DarkGDK 2 (refering to how it's advertised to support multi threading).
Although .... it might be that it just queues all functions so that they will be run sequentially all the same if called from different threads. I haven't looked into this yet but was meaning to one of these days.


"Why do programmers get Halloween and Christmas mixed up?"
FireIndy
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 5th Aug 2012 02:07
DarkGDK 1.0 isn't thread-safe. 2.0 is supposed to be. You may have to get just sort of clever. If you are writing a client/server game, in which players join the server, why not just create a full list of "dummy" players for each client initially and then hide/show them if they join/leave respectively. If you have some sort of load screen, you can put some loading of objects/data there to off put some of the loading later.

Otherwise, it's kind of hard to load things so that they don't interfere with framerate.

Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 5th Aug 2012 04:45
Thread-safe means it won't crash, but it also won't have the desired effect of loading everying asynchronously.

If you save all your objects as .dbo files then most of the time will be spent doing file access, the rest is very fast. Since the code for DBPro is open source, it should be a simple matter to modify it to load from memory rather than a file. You can do the loading from the file into memory yourself in another thread, and when it is ready make it into an object.

[b]
Dar13
15
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 5th Aug 2012 05:20
Quote: "Thread-safe means it won't crash, but it also won't have the desired effect of loading everying asynchronously"

So DarkGDK 2.0 supports multithreading but DarkGDK 2.0 isn't multithreaded itself? I suppose that makes sense in a way.

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th Aug 2012 13:24
Quote: "Since the code for DBPro is open source, it should be a simple matter to modify it to load from memory rather than a file."

Is it described how to recompile these dll's anywhere?
I guess trial and error would work, but since there are people around that knows it already...


"Why do programmers get Halloween and Christmas mixed up?"
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 5th Aug 2012 15:11
I didn't mean you should recompile them, just copy the relevent functions into your own code. By all means request it as a feature, I was just suggesting how it could be done without waiting.

[b]
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th Aug 2012 15:28
That would work with DGDK 1, but since there is no access to the internal classes etc. from DGDK 2 one would have to recompile the plugins to achieve such :\

(And yes, I realise this thread might be about DGDK 1 anyway )


"Why do programmers get Halloween and Christmas mixed up?"
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 5th Aug 2012 16:07
You can still access the sObject structure in GDK 2 just like you could in GDK 1.

[b]
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 8th Aug 2012 03:07
Quote: "You can still access the sObject structure in GDK 2 just like you could in GDK 1."

Really? I was not aware, care to share how? (I browsed through the documentation for 3D objects / meshes but didn't find anything appropriate).


"Why do programmers get Halloween and Christmas mixed up?"
Dar13
15
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 8th Aug 2012 14:17
Aha, I see. Thanks


"Why do programmers get Halloween and Christmas mixed up?"
Qqite
14
Years of Service
User Offline
Joined: 28th Feb 2010
Location: Florida, U.S.
Posted: 8th Aug 2012 23:42
Ok so I bought DarkGDK2 and I have to say that I'm super excited that someone cleaned up v1.

So on this thread's topic. How would I use sObject to manually load an object? The thread you linked doesn't go into how you would use this class.

Ventures of the worlds around us are limited only by our imagination.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 9th Aug 2012 02:04 Edited at: 9th Aug 2012 02:05
The loading function is likely somewhere in here.
Unfortunately I always found that SVN very hard to navigate but it should be there.

Basically you'll just have to copy, paste and make some changes to the LoadObject function.

EDIT:The url didn't work (probably due to some special character(s); here it is anyway: http://code.google.com/p/darkbasicpro/source/browse/trunk/%20darkbasicpro%20--username%20LeeBamberTGC/DarkGDK/Code/Source/DarkSDKBasic3D.cpp


"Why do programmers get Halloween and Christmas mixed up?"
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 10th Aug 2012 17:24
There was also a tutorial for GDK 1 which shows how to load an object of a different file format. It's not quite what you want but it may help you understand how it works.

[b]

Login to post a reply

Server time is: 2024-04-23 15:20:03
Your offset time is: 2024-04-23 15:20:03