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.

Work in Progress / Loading objects in the background (threaded)

Author
Message
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 18th Jan 2007 21:56
This little app loads objects in a separate thread. That means while a cube rotates happily on your screen, the program loads a model (~3 MB) 15 times and shows them after the process is finished. Normally you'd notice a serious delay/halt during the loading of each object. But since this process is threaded in this demo, the impact isn't so much obvious anymore.
Well we've tested it on several machines now and it appears to work quite well. "Quite well" means that we did experience the one or other odd crash occasionally . However, it's important to test this on as many systems as possible.

On a side note: The INTERVAL routines in STYX were never intended for doing stuff like this. But since it's there, well...

Attachments

Login to view attachments
Steve J
18
Years of Service
User Offline
Joined: 22nd Apr 2006
Location: Vancouver, Washington
Posted: 18th Jan 2007 23:28
holy crap! I need styx! This would work wonders on a lod system...

Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 19th Jan 2007 00:01
very nice!

This could also be useful for starting to load media while you are still in the main menu

One man, one lawnmower, plenty of angry groundhogs.
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 19th Jan 2007 02:47
Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 19th Jan 2007 02:54
Very cool stuff Empty

The app worked for me. That might be a good way to handle deleting object too since object deletion is painfully slow.

If I ever get back into actually making games instead of tools for other people to make games, STYX will be one of the first things that I buy.

EZrotate! TextureMax! Enhanced Animations! (coming soon....) 3D Character Maker! (coming soon....)
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 19th Jan 2007 03:04
Thank you.

Quote: "If I ever get back into actually making games instead of tools for other people to make games."

Oh yes, same here, same here.

Bongadoo
18
Years of Service
User Offline
Joined: 4th May 2006
Location:
Posted: 19th Jan 2007 11:38
This is exactly what I've wanted for a long time, I didn't even realise you could get access to another thread with DB.

I've reached a bit of an end with being able to add additional features to my RPG, but I shall rebuild the engine with this involved and it will allow me much more flexibility.

This will allow me to seperate the content streaming to the other thread and allow me to have much more complex scenes and objects. Currently I am doing small chunk loading for the streaming, but this will allow me to load large DBO objects and parse through them no problem at all. Genius!
Sergey K
20
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 19th Jan 2007 11:52
wich reminds me my old object load system loong loong time ago

v. nice.. but does dbp supports now loading models while using the SYNC command? (thread safe)

MyNewSite:http://gogetax.com
Forums(About BLO and more):http://gogetax.com/forum
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 19th Jan 2007 12:55
Quote: "v. nice.. but does dbp supports now loading models while using the SYNC command? (thread safe)"

No, that was the tricky part...

Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 19th Jan 2007 20:09 Edited at: 19th Jan 2007 20:10
Yes it ran fine for me... though when i minimized it to do something else and came back it crashed of course. (but that is DBPro's fault)

One man, one lawnmower, plenty of angry groundhogs.
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 19th Jan 2007 21:10 Edited at: 19th Jan 2007 21:11
Cool.

For those who are interested: the cleaned up yet undocumented source code (Styx commands in UPPERCASE):



valleyman86
17
Years of Service
User Offline
Joined: 15th Dec 2006
Location:
Posted: 19th Jan 2007 22:36 Edited at: 19th Jan 2007 22:41
Quote: "very nice!

This could also be useful for starting to load media while you are still in the main menu "


This can be done without using this plugin. Which btw I don't even know where to find. Ive been using this in my game for the comp. Its called multi-threading. Here is a link to torreys multithreading dll. It works great. Just make sure to turn off autocam because during the loading of object dbpro moves the camera temorarily. Doesn't styx cost money? I dont know but here you go. Works great. If you want to do it yourself lookup create thread functions in the winapi. Btew about the crashes. I had some witht this dll too and it was because I was not using them correctly. make sure the thread is closed properly and putting a sleep timer may help. I have one of 0 right now because I was using it to prevent a crash but it never helped so I set it to 0. I no longer get crashes as all. It seemed pretty random before. I believe the problem was with syncing. Make sure that you do not sync twice at the same time. Thats where the random crashes come in. If one thread is syncing at the same time as your main thread. This is why I had the sleep command. So that the main thread would give the second thread time to close before syncing. Hope I was not too confusing. I was trying to remember what I did as I typed.

http://forum.thegamecreators.com/?m=forum_view&t=68623&b=1
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 19th Jan 2007 22:48
Quote: "Which btw I don't even know where to find"

Erm, here?


Yep, Torrey's plugin has been out for a while, altough we use a slightly different approach in Styx (that has already been discussed in another forum thread).

SageTech
19
Years of Service
User Offline
Joined: 3rd Dec 2004
Location: Orlando, Florida
Posted: 20th Jan 2007 03:34
Well, Gotta start saving up, as soon as I get WOLF's enhanced animation Styx is definitely next on my list. Cheers, and great work.

Kenjar, yet another victim of NRS (N00b Relapse Syndrome) May he code in peace...

Juso
22
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: Finland
Posted: 20th Jan 2007 13:44
It works fine even on win98.

There is about 200 commands in STYX, is there somewhere a list of them?
headcrab 53
19
Years of Service
User Offline
Joined: 14th Jul 2005
Location:
Posted: 20th Jan 2007 21:52 Edited at: 20th Jan 2007 22:10
Using this plug in, are you able to use things like Physics or Sparky's Collision DLL? The free plugin that valleyman86 pointed out crashed doing those things. Sparky's Collision DLL worked with it sometimes, but I tried seting up terrain collision from within one of the threads and it crashed. (Unless I did something wrong)
Alquerian
18
Years of Service
User Offline
Joined: 29th Mar 2006
Location: Reno Nevada
Posted: 21st Jan 2007 08:00
empty - this is exactly what I needed! I can think of a million applications for this! Great work indeed!

Quote: "If I ever get back into actually making games instead of tools for other people to make games"

heh, you and me both buddy. I finish one, then I am on to another. I should take the advice found in my sig

Quit planning to make a game and make a game.
JosephB
18
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 21st Jan 2007 11:25
Very, very nice. The first time I ran the file after downloading and then extracting, it locked up without loading any of the models. The cube spun a few times and then locked up. I closed it through task manager and then tried it again a couple of times and all seemed to work well.
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 21st Jan 2007 16:11
Thanks all for testing. Under certain circumstances it could cause trouble on Multicore and Hyper-Threading systems (which will probably also be the case for other threading methods). This should be solved now.



Quote: "There is about 200 commands in STYX, is there somewhere a list of them?"

Here's a preliminary list of commands in STYX 1.10 (now more than 250):

COM, ActiveX, .NET


Dialogs


Error Trapping


Filenames & Filepaths


Flash Movies


INI Files


Intervals, References and Callbacks


Memory Access


MIDI Out


Number Operations


String Operations


Window Commands


Window Shaper and Splash Screen


XML Files


SageTech
19
Years of Service
User Offline
Joined: 3rd Dec 2004
Location: Orlando, Florida
Posted: 22nd Jan 2007 04:53
Hey empty, I tried the other multithreading dll valleyman86 suggested, but it was causing me a significant problem, so I'm back to Styx. When will the multithreading be implemented into Styx? As that is when I intend to buy it.

Kenjar, yet another victim of NRS (N00b Relapse Syndrome) May he code in peace...

dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 22nd Jan 2007 08:38
I tried the demo, but it seemed to freeze when I assume it was loading a cube, as it spins for a second or two then stops, no cpu activity. I have a Athlon 64 X2 4400+ is that changes anything.

empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 22nd Jan 2007 14:09
@SageTech
Quote: "Hey empty, I tried the other multithreading dll valleyman86 suggested, but it was causing me a significant problem, so I'm back to Styx. When will the multithreading be implemented into Styx? As that is when I intend to buy it."

The update is done so far, just needs more examples for the new commands. So it'll be end of January, early February.


@dark coder
Quote: "I tried the demo, but it seemed to freeze when I assume it was loading a cube, as it spins for a second or two then stops, no cpu activity. I have a Athlon 64 X2 4400+ is that changes anything."

Yes, HT and multicore CPUs can have trouble with the uploaded version under certain circumstances. I'll upload another one later today/tomorrow.

valleyman86
17
Years of Service
User Offline
Joined: 15th Dec 2006
Location:
Posted: 24th Jan 2007 10:15
Wasn't trying to persuade people from styx btw. I'm not sure all of what it does. I seems to add a lot of neat functions (provided you do need them heh) but I was merely pointing to that dll. The dll I suggested did give me crash issues at first but once I figured out what not to do it was fine. Mainly crashed when syncing at same time. But that dll does not implement any handy error prevention features which yours may. I'm not sure how yours works. But good luck and keep up the good work. 200 new commands is a lot heh.
SageTech
19
Years of Service
User Offline
Joined: 3rd Dec 2004
Location: Orlando, Florida
Posted: 28th Jan 2007 19:27
Hey empty, another question. Exactly what is the syntax to get this working? Also, Can I open up multiple threads (or however its done) to load multiple objects simultaneously? Thanks again, and as soon as its implemented, you have my money. cheers.

Kenjar, yet another victim of NRS (N00b Relapse Syndrome) May he code in peace...

empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 29th Jan 2007 01:43
I posted the code for the example program above, but here it is again :




Basically you need to register a function you want to run periodically (threaded or not threaded). This is called INTERVAL.
The syntax to register a function is:
REGISTER FUNCTION : MyFunction() : INTERVAL Interval Number
where interval number can be a number between 1 and 256.
BTW, this syntax is the same for CALLBACKs (functions that can be called from WinAPI for example) and REFERENCEs (to obtain function pointers etc.). Note that in all cases the functions cannot have any arguments. Also note that the function will be called upon registering. However you can exit early by putting this line at the top of your function:
If REGISTER CALL() Then ExitFunction

Quote: "Also, Can I open up multiple threads (or however its done) to load multiple objects simultaneously?"

Yes, however the more threads are running the more does it affect the FPS.

I've been distracted by other things recently (IDE bug hunting ) so I haven't written much examples yet, but I'm positive that it'll be done by the end of this week.

SageTech
19
Years of Service
User Offline
Joined: 3rd Dec 2004
Location: Orlando, Florida
Posted: 29th Jan 2007 01:59
Sorry, didn't bother to check this thread for the code. That looks rather straightforward, and painless to implement. However, I'm kind of confused as to what the results will be. While I'm in the function, will my main loop continue on as well?

Kenjar, yet another victim of NRS (N00b Relapse Syndrome) May he code in peace...

empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 29th Jan 2007 10:45
Juso
22
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: Finland
Posted: 14th Mar 2007 10:02
@empty

I just bought Styx and experimented with your above code, but it doesnt work

Compiler stops at line "REGISTER FUNCTION..."

and there is too many parametres at line "START INTERVAL 1, 0, 0, 1"

So is this example Styx 1.1 ? I have Styx 1.0
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 14th Mar 2007 11:09 Edited at: 14th Mar 2007 11:10
Is this actually properly thread-safe? If so, how exactly?

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Soty
18
Years of Service
User Offline
Joined: 18th Aug 2006
Location:
Posted: 5th Jun 2007 18:24
Hi,

I have the same problem how Juso...

@empty
When did the update commes ?

A programmer is a tool to convert coffe into code !!!

Login to post a reply

Server time is: 2024-09-29 20:35:44
Your offset time is: 2024-09-29 20:35:44