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 / Learning UDT"S Have Question

Author
Message
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 11th Nov 2012 17:48 Edited at: 11th Nov 2012 17:53
I am pretty sure I know the answer here but want to make sure so here goes!

If I set up a type as maps and have 25 variables in that type and then set up a map such as city map which may only use 10 of those variables defined in type (map) this is ok right? I don't have to use all 25 variables in my city map if I don't need them right?

I am pretty sure this is how this works if this is true I am really starting to see the power here. I can set up type map, include every possible thing for every map in my game then make up my different maps using only what I need from the type for that specific map.

Also if this is the way it works out can I just define the type now with just what I need for now then add to the type as I go along?

Thanks
Dragonslayer
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Nov 2012 19:20
No you don't have to use all the variables specified in a UDT, but then why put them there? Their memory is still allocated and it would be wasteful.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 11th Nov 2012 19:48
So then I can add as I go along right?
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 11th Nov 2012 19:56
No, I'm afraid UDTs are not dynamic, as is generally the case with structs/classes in compiled languages. You would need to add all the properties you want to the UDT right from the start. If you don't know what components there will be until run time then you probably want to make a "dictionary" or "associative array" kind of a set-up.


Previously TEH_CODERER.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Nov 2012 22:02
Did he mean that? I assumed he was asking whether he could simply change the type definition as he went along. For example, version 1 of the program might have:



whereas version 2 could have



All you have to do is add the extra line in the definition when you need it.

But then he might not have meant that.
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 11th Nov 2012 22:11
Ah, I may have misunderstood then, sorry. I assumed that by 'So then I can add as I go along right?' he meant at run-time. Ignore my post then!


Previously TEH_CODERER.
Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 11th Nov 2012 23:18
Phaelax, shouldn't hobbiest programmers be more concerned with over catering the infrastructure needed for their game, rather than worrying about wasted memory?

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Nov 2012 00:34
Quote: "Ignore my post then!"


Not necessarily. Let's wait till he clarifies what he meant.
GregA
15
Years of Service
User Offline
Joined: 21st Jun 2011
Location:
Posted: 12th Nov 2012 03:37
Heh, I am doing the same thing, only I am working at the level of individual walls, doors, floors, and bits of room decoration. Also, instead of using UDT's, I am just using the global object list.

Wow, I'm going to have about 30 different types of objects to rename... A finished game is going to have thousands of objects...

My Connect 4 game had over 70 objects right there at the beginning.

I wish someone would write a tutorial on how to modify Blenders .x exporter to enhance the property list.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 12th Nov 2012 11:00
Well we don't really know what's in your UDT. If we did then we could suggests some refinements. Though, when it comes to this sort of thing people usually create 2 versions of the type, for different map type.

Personally if it's big UDT's say for like my particle system which in all has like 600 variables, I split it up and turned it into a parent child structure using arrays. Say for instance I have 100 particles systems but none of them use rotation, the few vectors and other variable under rotation are taking up memory, so I split them off in there own sub sections and array and created a hook (index id of the rotations array) for rotation in the main UDT. The advantage of this is if the hook returns -1 (not allocated) then processing rotation doesn't need to be done, and you save a lot of computations.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 12th Nov 2012 19:33
Quote: "Phaelax, shouldn't hobbiest programmers be more concerned with over catering the infrastructure needed for their game, rather than worrying about wasted memory?"

Maybe, but it shouldn't be ignored either. But when I first started programming, RAM was a luxury that I never got out of the habit of ignoring.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 13th Nov 2012 05:10
Quote: "I wish someone would write a tutorial on how to modify Blenders .x exporter to enhance the property list."


Blender can set custom properties directly in the ui, The exporter is just a script written in python and having it write a few extra lines of data wouldn't be hard, the API is well documented and should give all the needed info for accessing those property fields via the script. I may misunderstand what you mean by property list as it relates to the .x format, but still any mod of the export comes down to python and changing what it reads from the API and writes to file.

GregA
15
Years of Service
User Offline
Joined: 21st Jun 2011
Location:
Posted: 13th Nov 2012 17:06
Ortu,

Right now I am using Blender as a level editor... I enumerate the whole data file then based on the name of a limb I do something with it.

The problem I am having at the moment is that I am packing data into the name of the object, and it is starting to make my head hurt...

For example, I have an Object, lets call it Cube.001

If I want it to be a physics object, I prepend to the name either PS or PD.

Therefore the name would become PSCube.001 for a physic cube static, and PDCube.001 for a physic cube dynamic.

Which is an ok way to do this for now, but... Well just launch Blender and rename an object, and you will quickly see why, when I get to the complexity of an entire level, why this will be hard to sort out.

As I move on in this project I am working on at the moment, I can see all 1000 or so objects in my level having names like PSXTR_Cube.001 and the potential debuging nightmare that this will be later on, that could be simplified if there was a easy way to modify the .x file format, AND make the those changes right in DBPro.

I think ideally I would just write a custom exporter from right in Blender that just writes my level file with all the properties, but in my mind that adds a whole stupid level of complexity (and about six weeks programming and debugging) when really all I want is to load my level.... Rather than just load a file...

The main reasoning here is I am bad at multi tasking... As I am going through my ~creative~ process my head is either in gamer mode or programmer mode, and it takes me a couple of hours to switch between the two.

Also, my head ~never~ goes into secretarial assistant mode to look forward to clicking on all 1k or so objects in my level and fastidiously renaming all of them...


/aside

There is this gal at the office who takes care of the product database, she is really great at it. She makes sure every last field is filled in exactly as she wants, and so that everything works in the various PO and invoice software. I wish I could afford to hire her to work through and rename my Blender files...
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 13th Nov 2012 21:02
Ive been planning to use it for a level editor myself, my plan is to write an exporter to send the scene data to an XML file, which could then be parsed to load and manipulate the objects in dbpro.

It really needs a separate export from the .x, as the format doesn't support such custom properties in anyway which could be auto handled by load object. You could append them to the file, but would need to open to read and parse the info out manually anyways.

Possibly an almost ready made solution: You might look at exporting the overall scene with the .x3d format. Dbpro can't load from it directly, but it is based in XML which can be handled with plugins and it includes more scene centric info than the .x it does also include a collision enabled tag if physics are set to an object in blender, though it does not seem to include custom user defined properties atm.

Anyways I guess my point is different exporters will best serve different jobs object vs scene, and it's going to need a specialized map loader within dbpro to import the scene however it gets out of blender

Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 15th Nov 2012 05:06
Green Gandalf
That is how I ment that.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Nov 2012 18:48
Quote: "Green Gandalf
That is how I ment that."


Which? What I said or what Andrew said?
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 16th Nov 2012 03:39
The way you said it. Know I can't add into a type at runtime but I can come back and add to it at a later time right?
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Nov 2012 14:10
Quote: "but I can come back and add to it at a later time right?"


Yes.

Login to post a reply

Server time is: 2026-07-12 08:56:02
Your offset time is: 2026-07-12 08:56:02