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 / Saving and reloading an object filled scene

Author
Message
Cyber 1
18
Years of Service
User Offline
Joined: 11th Feb 2008
Location:
Posted: 20th Jan 2011 10:22
Hello all,

I have created a program that creates a scene using basic shapes
loaded as X files and then multiplied using `Clone object`.
I have programmed certain keys to clone,scale,rotate and
move each object manually rather than in a program run.
It`s sort of a 3D construction program. Problem is that I
do not know how to save and reload the created scene so that
when reloaded all the cloned objects can remember their
position, scale, rotation and texture data.
Each scene can be made up of hundreds of objects and I would
like to know if their is a way to save all together as a scene,
allowing for future reloading whilst remembering positions,sizes,
rotation and texture data as originally created.
Thanks in advance for any help you can give. ( Code supplied ).

The Creator
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 20th Jan 2011 14:50
Yes, it's absolutely possible!

You can look at this : http://forum.thegamecreators.com/?m=forum_view&t=173880&b=1

It's an old abandoned project, but if you look at the code.It's fairly simple written.Good example of save and load routines.

I think you can make the same approach.Make an array with all your objects, their properties as scale, position, texture used and so on.Save it to a file, then load it in similar way.

I gtg to work but when go back i'm gonna look at your code and try to do it work that way if you are unable to do it yourself.It's a good challenge for me, because i lack of determination to start a project for some reason.It's frustrating.I get rusty, but that's not the main reason i can't code...

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 20th Jan 2011 18:01
It should be as simple as,

- open a file
- write the model's filename
- write the x, y, and z position as floats
- write the x, y, and z rotation as floats

When loading, just loop through reading the data and load and position each object. Store the data in a UDT array and when you come across duplicate models just clone the new one from the first one you loaded.

Cyber 1
18
Years of Service
User Offline
Joined: 11th Feb 2008
Location:
Posted: 22nd Jan 2011 11:32
Thanks for the advice given here.
Sadly my experience with arrays is nil.
Luskos, I would like your help to develop the code
necessary for making my project work.
Any progress that you make I would be interested in seeing.
My email address is: [email protected]
As you have not left an email address for me to contact you
I would appreciate it if you could email me directly,
so that I can work in with you.
Thanks again to all for helping me.

The Creator
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 22nd Jan 2011 13:58
Arrays - get to know arrays and love them...
They will be your best friend when programming games!
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 22nd Jan 2011 17:48
An example UDT array might be,



Hope that helps.

luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 23rd Jan 2011 12:02
KISTech example explained it very well.Looking at your code you are gonna need UDT like this:


It covers every object type, but spheres.

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
Cyber 1
18
Years of Service
User Offline
Joined: 11th Feb 2008
Location:
Posted: 24th Jan 2011 09:42
Thanks very much to all.
I shall do my best to learn arrays.
If I run into trouble then I will once again
turn to this forum for the best help.
You blokes are the greatest.

The Creator

Login to post a reply

Server time is: 2026-07-16 12:20:05
Your offset time is: 2026-07-16 12:20:05