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 / Object Position Problem

Author
Message
Black Chaos
15
Years of Service
User Offline
Joined: 20th Apr 2011
Location:
Posted: 20th Apr 2011 16:07
//This is a re-post, simply because i need a solution quick.
In one program I save two objects positions to file.
Example:
Quote: "
//Object One
ObjOnePositionX = 432
ObjOnePositionY = 1051
ObjOnePositionZ = 2333

//Object One
ObjOnePositionX = 432
ObjOnePositionY = 1024
ObjOnePositionZ = 2333
"

Another program loads these setings(Just the X,Y and Z positions).
Create two object of the same size and shape and then use the exact positions loaded from file.

But!

When the objects are positioned in the second program, using the same positions!; the two objects have much more space in between(Visually),mainly on the y-axis i think.

Please help!

bconline
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 20th Apr 2011 18:06
Show your code in one of these:



and we can troubleshoot for you.

Black Chaos
15
Years of Service
User Offline
Joined: 20th Apr 2011
Location:
Posted: 20th Apr 2011 18:27
The first program saves the position of two objects that exist in the program e.g. a cube and a cylinder.
The program then writes these positions to file.



The second program then creates an array to store these positions, reads the file saves the x,y and z positions into the array.

Two objects are then created; the same shape and size.
The same positions are used.
But the objects are in different places from the original program.

bconline
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 20th Apr 2011 22:37 Edited at: 20th Apr 2011 22:47
Well, that's not all your code, I'm sure, but a couple of things to think about...

Your x,y, and z positions need to be floats instead of integers.

Do you have AUTOCAM on or off?

Are you trying to write to a file that already exists? (This will fail)

You should write floats instead of strings.

Does the same thing happen without the file save? I.E. if you just make the objects, save the positions, destroy the objects, then re-create them?

If you are able to post all your code, I could see what you mean.

EDIT: Also, IanM's matrix utils will let you save a UDT array, which would be much easier than saving each position.

Black Chaos
15
Years of Service
User Offline
Joined: 20th Apr 2011
Location:
Posted: 20th Apr 2011 23:51 Edited at: 21st Apr 2011 01:32
Here's my code:

First program


//The second program


My point is that, regardless of the fact that the objects are made and positioned with the same values, they still endup in diffeent places (Visually!).



bconline
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 21st Apr 2011 05:25 Edited at: 21st Apr 2011 06:43
Your first program will not compile, and throws many errors while refusing to compile, possibly related to the definition of SON in your UDT. Also, you gotta have a space between the code and the // for comments.

After those two things are fixed, it hangs on lib0(n)

Does the code you posted actually run for you?

My advice is to take a few steps backward, do a simple save and load of one object and figure out what's not working. THEN add in all the fancy stuff.

One thing to check... your first program does not show the objects, so how do you know they aren't VISUALLY in the same place after you load them? If you use the CONTROL CAMERA USING ARROWKEYS command it can change what you see vs. a positioned and still camera.

EDIT: Here is a REALLY simple version of saving and loading four datum about an object.



I see what you are trying to do, saving all the info to recreate a scene, my example is just to illustrate that the object does indeed load with the same coords and angle, and looks exactly like it did when saved. So, maybe the camera changes between the programs?

I had this other thought... suppose you saved two files for each setup. One is a "scene" file that contains the camera position, the number of objects in the scene, the names of all textures used in the scene, etc. Then you could have an "objects" file that is the saved UDT of all data for each object. That way you could use IanM's save array command to save the objects, and the scene file could tell you how big to dimension the object UDT array. Just a thought.

Black Chaos
15
Years of Service
User Offline
Joined: 20th Apr 2011
Location:
Posted: 21st Apr 2011 13:15
Hey, thanks for your help.

Even though what your saying is true; the camera angle and position does play a large role in how the distance between two objects are perceived.

Note: In my first program, I have a function that allows camera rotation and movement using the mouse; same in the second.

Corrections: I'm going to save the cameras position and angle so that the scene can be loaded the exact same way it was saved.

I will test a little more, but this time i'll save some evidence of my testing. I'm probably going to run the tests and post images in this thread as soon as possible.



As for IanM's save array command; I would prefer right now to use JUST! the default DBPro's lib, functions and commands(Just to keep things simple and on track), nothing personal, just apart of my planned completion date.

Keep and eye on this post

bconline

Login to post a reply

Server time is: 2026-07-18 06:41:23
Your offset time is: 2026-07-18 06:41:23