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 / Reloading objects in the scene

Author
Message
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 1st Aug 2014 11:43
Hey guys,

I made possible for objects to save in a .dbo file but i want also to reload them. Here is the code for saving:



Alex Matei CEO
www.alexmatei.com
marialuiza
9
Years of Service
User Offline
Joined: 24th Jul 2014
Location:
Posted: 1st Aug 2014 13:29
how did you do that, that is really very curious to ask guys
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Aug 2014 19:00
Just use load object as in your snippet - and make sure you don't try to use an object ID which already exists. In your snippet, for example, if one of your objects already has ID = 1 then your load object will fail.



Powered by Free Banners
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 1st Aug 2014 19:16
Hey Green Gandalf,

Well, in my code snippet it loads one basic object. However, i want to load all the objects that had been saved in the folder.

Thank You!

Alex Matei CEO
www.alexmatei.com
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Aug 2014 19:19
What have you tried so far?



Powered by Free Banners
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 1st Aug 2014 19:38
Well basicly if i understand correctly from your question, i tried what i pasted in the code snippet, like that is the code to save the objects in the scene and after that trying to reload them, but in my code at keystate(3) it tells DBPRO to load one single object or else, i want to load ALL the objects that i saved in the keystate(2) process.

Alex Matei CEO
www.alexmatei.com
Derek Darkly
12
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 1st Aug 2014 19:39 Edited at: 1st Aug 2014 19:48
In your example you're using the number 1 for your load object when you should be using a variable.
Also, make sure you're deleting existing objects before trying to reload them.




666GO†O666
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 1st Aug 2014 20:24
Hey Derek Darkly,

The code works! Thank You very much, you made my day!

I have another question please don't be upset if i am bothering you very much... as a final thing i want to save and load saved object's positions i also have an example here:



Alex Matei CEO
www.alexmatei.com
Derek Darkly
12
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 1st Aug 2014 22:15 Edited at: 1st Aug 2014 22:17
Quote: "The code works! Thank You very much, you made my day!"


Great! I'd like to point out though that Green Gandalf said the same thing, minus the code snippet.


Your file writing code is wrong because you're doing:
write string 3, str$(object position x(objsave))
write string 4, str$(object position y(objsave))
write string 5, str$(object position x(objsave))


(i also noticed you used x twice instead of x,y,z)


If your file number is 3 then you'll want:
write string 3, str$(object position x(objsave))
write string 3, str$(object position y(objsave))
write string 3, str$(object position z(objsave))


666GO†O666
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 1st Aug 2014 22:23
Yeah sorry, i didn't noticed the last x.

So this part of the code is good to write the positions.
But how do i make the saved objects to be positioned with these saved values?

A huge Thank You!

Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 1st Aug 2014 22:26
Oh and sorry but i didn't noticed the meaning of Green Gandalf's question. Sorry

Alex Matei CEO
www.alexmatei.com
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 2nd Aug 2014 01:06 Edited at: 2nd Aug 2014 01:11
You could store the object position and orientation in a memblock. Then use Add Memblock To Object before saving the object as a DBO file. Then when loading each object use Get Memblock From Object to retrieve the position and orientation. After setting the variables you can use Delete Memblock From Object, if no longer needed.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Aug 2014 01:43
I didn't know about those commands. They look very useful, thanks.



Powered by Free Banners
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 2nd Aug 2014 02:21
Not a problem.

MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 2nd Aug 2014 11:55
Ok i understand... to i must also use write memblock?
Sorry but i never used memblocks...

Alex Matei CEO
www.alexmatei.com
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Aug 2014 12:23
Have you read the Help file for those commands?



Powered by Free Banners
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 2nd Aug 2014 13:28
Yes i did, but i don't know how to put the code together ...

Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Aug 2014 16:11 Edited at: 2nd Aug 2014 16:15
Hi there.

Long time from the last visit to the forum.

Why saving lots of object with an array , if we can save a big static level ?

We have the Gamefx Commands that can save a big level, and even we can add lights without external lightmapping program.

First we make static objects and then we build static portals & save map. If we want, we can add some lights around the level.



Cheers.

I'm not a grumpy grandpa

Attachments

Login to view attachments
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 2nd Aug 2014 16:28
Can you give me a basic example please?

Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 2nd Aug 2014 16:52
Hey Chafari, Good to see you again!
Their idea was good to save the objects as dbo the only thing that i want is to save their positions and reload the positions. Of course, your idea Chafari is also good.

Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Aug 2014 19:37 Edited at: 2nd Aug 2014 19:41
Hi MateiSoft Romania.

Quote: "
Their idea was good to save the objects as dbo the only thing that i want is to save their positions and reload the positions."


Well yes...somehow this is the way we save game positions when we are playing, but if we are creating the scenary would be better and easier to use gamefx commands

Here an example. Use your own textures to test



EDIT:
This is an example without lights. A complete example comes in gamefx commands. It comes include with Darkbasic Pro. I will show you more examples if you want

Cheers.

I'm not a grumpy grandpa
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 2nd Aug 2014 20:37
Hey Chafari,

You helped with the second thing that i wanted thank you very much!
You know, i am making an engine, this example is exactly what i wanted for the "final game" phase. However, i want an example on how to save simply some objects and reload them in the manner that i can re scale them, re position them and re manipulating them.(the codes for rescalling and manipulating i have them)

Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Aug 2014 23:21
Quote: "i want an example on how to save simply some objects and reload them in the manner that i can re scale them"


I'm not sure if what your are looking for is a browser where you select the object you need. If you have some code to re-scaling and manipulating objects, what do you really need? ....something like an imput where the user has to write down the file name ?

I'm not a grumpy grandpa
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 2nd Aug 2014 23:42
This is a little demo I worked up using the memblock idea. I got a little tired toward the end. So, I stopped commenting the code and the main loop could probably have been coded better. Notice the use of the dynamic type array. Hopefully you will be able to follow the code.



MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 3rd Aug 2014 00:02
Cafari, yes, i meant that the developer must enter the map's filename...the objects have been saved into the file with the states that the objects had before saving them. After that, if the developer wants to reload the file saved, the objects saved will reappear as it where before saving.

WickedX, i will definetly try your code! Appreciate it!

Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 3rd Aug 2014 00:19
The objects in the photo attached, can be selected, rotated etc.
When saving the objects with the static objects, after reloading them, i can't have control over them. However, if i am saving the objects themselves and their positions, i can reload the objects, and their positions and i will have the same control over them as before saving them to the disk.

Alex Matei CEO
www.alexmatei.com

Attachments

Login to view attachments
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Aug 2014 00:41
@WickedX Nice example .

@MateSoft Romania

Now I'm understanding what your are trying to achieve. Static objects, can't be manipulated once we make them static. We can make a trick to get the original position of all your objects when you save them. In our program, won't be to difficult to make some changes. Instead of moving and placing our object by any method, what we have to do is offset the limb zero position.

Example
This snippet has a reference center, and a ball that we save and load again. The new loaded ball won't be in the center ...it will be in the original position of the main one.



Cheers.

I'm not a grumpy grandpa
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 3rd Aug 2014 01:35
Quote: "@WickedX Nice example ."


Thank you. As always, enjoy your code as well. You definitely have talent.

MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 3rd Aug 2014 12:33
I will try later this day the examples and i will bring back a feedback thank you guys!

Alex Matei CEO
www.alexmatei.com

Login to post a reply

Server time is: 2024-04-25 07:11:32
Your offset time is: 2024-04-25 07:11:32