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.

Author
Message
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 17th Feb 2014 12:06
Hello guyz...I want to save a map that i made from importing objects.But i can't seem to make it work...

I tried by saving objects as dbo...no result....and with arrays but i don't really know how to work with arrays....If you can please help me with this subject.

Thank You very much!

Alex Matei CEO
www.alexmatei.com
Flamertor
14
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 17th Feb 2014 13:04
if this map is made of several object you can put it into a txt file like so



I think this will work, I haven't tested it and if you don't understand any part just ask.
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 17th Feb 2014 14:01 Edited at: 17th Feb 2014 14:16
Flamertor is on the right track! You basically need to decide in what form you wish to save the 'map'. I usually work with a packed files, with encrypted data files, but to keep it simple, use a simple text file, like Flamertor showed.

You need to save the objects, positions, angles and all other relevant data in that text file, so that it can be loaded/read again and the (loading)actions, according to the saved data, can be performed again.

Here is a basic create and write text file example:


Just try to write your own process from this!

Regards Sph!nx
www.mental-image.net
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 17th Feb 2014 16:10
Just a small correction, this:



will not work, because "open to write" requires the file to not exist. So this is the way to go:



Also, file# would be a float variable. While this probably works, it's certainly a good idea to use an integer instead.

Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 17th Feb 2014 18:06
Woops, mr ShellfishGames is right... I should test code I post, even the ridiculously easy ones, it seems.

Regards Sph!nx
www.mental-image.net
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 17th Feb 2014 18:57
Quote: "I tried by saving objects as dbo...no result...."


Hi there.
We can save as .Dbo, but we have to prepare first the scene. Let say that we want to make a house with several rooms , windows , doors and what not. We can make the floor as the main object, and then instead of adding objects to room, we add limb...we need to make a function of course....so every time we make a box there will be a funtion that makes the box, converted to mesh and delete box. We load textures as in normal case, but instead of texturin objects, we texture limbs. In the final object, we have to save as Dbo, so next time we open our object "Dbo", will have a room with every limb correctly positioned with correct scale, texture and so on.

I'm not a grumpy grandpa
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 17th Feb 2014 19:10
Hey guyz! Thank you so much for the replies!

I hope that my code isn't messed up. I tryed the .txt method but after save it always says(the object's coordinates) 0,0,0

Here is my import code:


So first of all the opendialog command from blue gui is initialized and after that if the file exists the object is loaded and ready for placing by user and after click, it places on the respective position.


Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 17th Feb 2014 19:42
Hey Chafari i tryed your way by saving to dbo file and it worked. Just the simple object not limb though. But the problems is i see in that code i think for my import.

Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 17th Feb 2014 20:10 Edited at: 17th Feb 2014 20:12
If you finally decide to use this method of saving a Dbo file, you just load the object with LOAD OBJECT command, and you don't need any spacial code

Edited. Remember, that we can make object from limb and save the limb required as Dbo file

I'm not a grumpy grandpa
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 17th Feb 2014 20:32
well yes i did that but it says that the object could not be found.

I have a variable named obj
Global obj = 1

then the obj is incremented to add more objects

i made a save map button and i programmed it like so :

save object "map.dbo",obj

Again file does not exists...i am assuming that it must save all the numbers 1,2,3 as many objects as i added

Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 17th Feb 2014 20:36
Quote: ".i am assuming that it must save all the numbers 1,2,3 as many objects as i added"


No, we have just one big object with lots of limbs, that we save in a unique object.

I'm not a grumpy grandpa
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 17th Feb 2014 20:40
So you are saying that i must make a ground as an object and then when i import the objects i must add the objects as limbs not simple objects.

Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 17th Feb 2014 20:45
and the one that i save as dbo is the ground that will also automatically save the limbs from it that i added

Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 17th Feb 2014 20:46 Edited at: 17th Feb 2014 21:02
What I meant, is that we can make a floor , then add a box as a room, but instead of making a box, we make the box, then we convert object to mesh, then we add this mesh to the main object. Once we make mesh from any object, we don't need it, and we can delete it and add that mesh to the main object, so if we have added let say 10 object to the main one, we can save the final object as Dbo, and load it again as Dbo. I you want, I can make an example for you.

An example for you.


I'm not a grumpy grandpa
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 17th Feb 2014 21:02
Please if you want make an example...i am trying something right now but it has weird rotation with no textures etc.... I can learn easy from some examples.

Here's a bit of my code:





Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 17th Feb 2014 21:03
Oh good sorry i didn't saw the example ill test it now

Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 17th Feb 2014 21:09 Edited at: 17th Feb 2014 21:25
Example above, notice that we convert to mesh all objects that we want to add to the main object. We need a function to make this easier.
If we need to add a complete Dbo to our Dbo and this object has more than one limb, we have first to separate every limb of the new object and make object from limb, and finally convert object to mesh


If we save our dbo, and when we load it again and we don't know how many limb has the object we can do somthing like:
Quote: "`cheking how many limbs has our object
for i= 1 to 1000
if limb exist(100,i) then lm=lm+1
next i"


so when we know how many limbs has our object , we can add a new limb:

ADD LIMB 100,LM+1,1



I'm not a grumpy grandpa
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 17th Feb 2014 21:54
Chafari i am very sorry for my missunderstoodnment, really....but can you update this code with what you tried to explain to me please? I will understand much better....The fact is that i don't know how to corelate with my code. This code makes the following : when pressing the import button it pops up the openfiledialog...i import the file, the file appears for positioning with the camera, after clicking the screen it positions on the spot where the camera is/was. I also made a mesh from it and added the limb but it turned out horrible...no textures, no proper position...I didn't used for loop...Again really sorry! But if you can update this code please...



Alex Matei CEO
www.alexmatei.com
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Feb 2014 03:11
Quote: "will not work, because "open to write" requires the file to not exist. So this is the way to go:"


I'd like to make a small suggestion. Instead of immediately deleting the file, if it already exist, save the new one to a temp file first. Once it's been created and all write operations have finished, then delete the other old file and rename the temp. It's technically safer this way because if something happens while creating/saving the file, you'd risk losing the original file too.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th Feb 2014 11:52 Edited at: 18th Feb 2014 11:53
@MateiSoft Romania

When we open an object to add as limb, we first have to position where we decide it to go, so we need a position system such as the arrowkeys and then position the object in te correct place . When the new object, is correctly positioned, we have to convert it to mesh, pressing other key or with buttons on the screen and mouseclick or whatever we decide. Then of course, the new limb, will have no texture until we give a texture to the new limb. Take a look to this piece of code, and imagine that the box in the midle of the floor, is the one that you have loaded to add as a new limb. Go with little box where you want into the floor, place and rotate as you want the limb to be, then press spacekey to add the new limb.



In the same way, you can add as many limbs as you need , taking into acount that you have to increase variable limb every time you add new limb to the main object.

I'm not a grumpy grandpa
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 18th Feb 2014 13:43
Quote: "I'd like to make a small suggestion. Instead of immediately deleting the file, if it already exist, save the new one to a temp file first. Once it's been created and all write operations have finished, then delete the other old file and rename the temp. It's technically safer this way because if something happens while creating/saving the file, you'd risk losing the original file too."


Absolutely.

MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 19th Feb 2014 09:28
Thank You chafari i managed to understand whats the problem with the limbs. Regarding with texturing the limbs, i don't have one single texture for the objects i can add multiple objects in my scene. How can i retrieve those different textures from different objects to texture different limbs?

Thank You again for your patience!

Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 19th Feb 2014 11:21
Quote: "How can i retrieve those different textures from different objects to texture different limbs?"


In the case that the new object has more than one limb, we have to check how many limb has the new object:

Quote: "
for i= 1 to 500
if limb exist(1000,i) then lm=lm+1
next i
"


Once we know how many limbs has the new object we find out how is it textured:

Quote: "
for i= 1 to lm
name$= limb texture name(1000,i)
load image name$,i
texture limb 1000,i+lm,i
next i
"


I have to say, that this method is only if you want to save your 3D object from your 3D program, but not for saving position in save/load game.
If what you need is just save every position of all objects in a game you had better to make an array and save:
position
angle
scale.

Something like this:




To load saved data could be like this:



I'm not a grumpy grandpa
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 19th Feb 2014 15:05
I did this with saving the array though it says cuz the object cannot be found after placing multiple objects in the scene. So the better way is through limbs. But have a look here :





[img]null[/img]

Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 19th Feb 2014 15:50 Edited at: 19th Feb 2014 15:51
Quote: " So the better way is through limbs. But have a look here :"


I have already read your piece of code. It says:

if the file exist, and you press Left Mouse Button your variable =1 then I suppose you will load the object , then you make a mesh from it and add it as limb. That is correct.
But I can't see where you place the object acording to the scene. We need somehow a method to place the new limb in the correct position. Once we make a mesh from an object, we don't need it any longer. I can't see where could be your problem with just little parts of your code, but you could do a small project where you load/place/and succes doing this ,before trying a big project. Don't worry, I will help you if I can

I'm not a grumpy grandpa
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 20th Feb 2014 20:02
Hey chafari sorry for the delay, i tried your code its really what i needed i will now try to update it for my code. Yes i also do "temporary" projects for some parts that i need to implement in my engine and to test those parts. I also want to thank you very much for your having time to help me. I really learned a lot from you and from people like you from the forum. I will program this part and test it and i will come back with a message!

Thank You again!

Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 21st Feb 2014 20:41
Hey chafari i tried of course with a sepparate program to test this out i tried to update but it gives me that the limbs must be chained or something...



Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 24th Feb 2014 14:03
Quote: "it gives me that the limbs must be chained or something..."


Sorry for the delay. This use to happens when we add limbs with wrong order...for example, if our object has 10 limbs and we try to add again limb number 10. I know that you have your variable to inc 1 every call, but sometimes occur that it call twice.

I'm not a grumpy grandpa

Login to post a reply

Server time is: 2026-07-07 00:50:30
Your offset time is: 2026-07-07 00:50:30