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.

DarkBASIC Professional Discussion / Assign an object number to each object imported.

Author
Message
General Jackson
User Banned
Posted: 16th Oct 2010 21:38 Edited at: 16th Oct 2010 21:39
What's a better way to import models? I want to automatically assign an object number to each object loaded. Is this doing it? or is it's object number lost each time a new model is loaded? (the openDialog command is from Blue GUI).



Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 16th Oct 2010 21:54
Arrays, and have a script for each model.

General Jackson
User Banned
Posted: 17th Oct 2010 01:56
I figured it had something to do with arrays.

Could you give just a little more information, though? Just to get me going (I dont need you to do it for me, though )

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 17th Oct 2010 02:37
Basically, I'd have an array with data for each object, including the object number, position etc.

In the script file i'd have the scale they have to be loaded in at, the location of the actual model, any textures, the likes, and instead of browsing for the model files, browse for these script files.

I guess it's kind of how the fpe files in fpsc work, if you've ever used fpsc.

gbark
20
Years of Service
User Offline
Joined: 14th Oct 2005
Location: US - Virginia
Posted: 17th Oct 2010 02:41
Your method does work for assigning object numbers, but as you said, they're lost afterwards.

In your particular example, you don't really need to keep track of the object numbers, however - You know that the first object number is 1, you have objectsinscene number of objects, and you know that they are numbered sequentially.

So you could just use a simple for loop from 1 to objectsinscene to loop through all the objects you've loaded, couldn't you?
General Jackson
User Banned
Posted: 17th Oct 2010 05:07
Quote: "Basically, I'd have an array with data for each object, including the object number, position etc."

I havent used an array before. So I have a quick question

dim objectsinscene(10000) would be what I would call it, correct? and how can I automatically load the first one into the array position 1, the second into array position 2, and so on?

gbark:
Quote: "So you could just use a simple for loop from 1 to objectsinscene to loop through all the objects you've loaded, couldn't you? "


Would this keep the numbers assigned to the objects? Because that is necessary for my engine.

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 17th Oct 2010 14:50
You may want to look at a tutorial on Arrays, I think TDK wrote one, in the db classic boards.

For example -



Then you would have your object load interface, assign the values from the script file into that array. Of course, this is just one way of doing it, if you think of a better way, you can do that, but this is how I would do it.

General Jackson
User Banned
Posted: 17th Oct 2010 21:47
Ahh ok, thanks!

Will let ya know if I get it.

General Jackson
User Banned
Posted: 19th Oct 2010 18:57 Edited at: 19th Oct 2010 18:58
Ok, so is this going to save my object numbers? I'm thinking yes.



General Jackson
User Banned
Posted: 20th Oct 2010 23:21
Bump.

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 20th Oct 2010 23:24
Sorry, I haven't been on in a while.

You should really look at a tutorial on arrays. You have to give an index to the array, not just the name.

objs = objectsinscene should be objs( 1 ) = objectinscene

Where 1 is the index of the array, you would have to make a function to find a free index, if that makes sense.

Login to post a reply

Server time is: 2026-07-22 03:51:48
Your offset time is: 2026-07-22 03:51:48