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 / Scaling an object based on its size

Author
Message
Volund
20
Years of Service
User Offline
Joined: 21st Mar 2005
Location:
Posted: 22nd Mar 2005 12:41
Hey all, I'm trying to do a simple thing: make an object bigger or smaller than it is. The problem? I can't find any command that will tell me what the size/scale of an object is:

"object size x()" (or y or z) aren't any use because an object's size doesn't appear to change when I scale it... the object gets bigger, but the "object size *()" functions still return the same number

I thought there would be some command like "object scale()" that would return the object's scale, but there doesn't appear to be - and yet there has to be something, what am I missing here?

... and I said, it's alright.
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 22nd Mar 2005 12:53
i think the function works, but its returning an average size of all 3 dimensions perhaps dunno


If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself
robo cat
21
Years of Service
User Offline
Joined: 23rd Feb 2004
Location: In a cat litter tray, near you...
Posted: 22nd Mar 2005 15:26
In DBC when an object is scaled it is permanent, and the size will change. As this made it tricky to scale stuff depending on their initial size, since the initial size changes, in DBPro it was changed so that scaling an object doesn't actually effect its size - just its appearance. I think.

Simple... yet fun!
The Wendigo
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 22nd Mar 2005 16:31
robo is right about that. What you will need to do is simply record the new scale in a variable (or variables if you are doing it on multiple axis). Then, to get the true X Size, you would do Object Size X(myObject) * Scale. It's pretty simple there. If you are planning on doing this with a lot of objects with different scales, you might want to hold the information in an array (this is the easiest method). There is a more optimized way, but it requires some work and User Defined Types, so for the sake of this, do something like so:



Notice how I divided by 100. The reason for this is because DBP works with scale in percent. To change a percent to a normal scale, you would simply divide by 100.


Home of DOOP, Strata Works, and Height
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Mar 2005 16:33 Edited at: 22nd Mar 2005 16:33
Scale isn't retained. You need to save it yourself manually if you want to reference it later.

That's why Nuclear Glory Collision has it's own Scale Object command, so it can monitor it.

EDIT: Beaten to it!

BatVink
Qweeg
20
Years of Service
User Offline
Joined: 23rd Sep 2004
Location: Kent
Posted: 22nd Mar 2005 23:38
Apologies for being really thick, but when I run the code below the function returns the new scaled size of the object - in this case 20.

Am I just misunderstanding this (probably)?

RiiDii
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 22nd Mar 2005 23:38
Here's a quick snippet to show that in DBP the scale is based on the original size of the object. The object's would end up huge in this snippet otherwise (you change all the 100+i 's to 120 or something to validate). It also shows that size is different for spheres and cubes.


"Droids don't rip your arms off when they lose." -H. Solo

REALITY II
Qweeg
20
Years of Service
User Offline
Joined: 23rd Sep 2004
Location: Kent
Posted: 22nd Mar 2005 23:56
I understand that scaling is based on the original size of the object - like you said Riidii, in your demo code the object would soon be huge otherwise.

But in the original post Volund said he couldn't use object size x() because it returned the original size of the object not the scaled size.

Quote: "
"object size x()" (or y or z) aren't any use because an object's size doesn't appear to change when I scale it... the object gets bigger, but the "object size *()" functions still return the same number
"


But this isn't true - if you have a sphere of size 10 and scale it by 200 then object size x() returns 20 (roughly).
RiiDii
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 23rd Mar 2005 00:40
Qweeg, sorry, we posted at the same time, mine just a moment after yours I guess.
Object Size X/Y/Z changes as you change the scale. Try changing Object Size() to Object Size X/Y/Z() in the snippet.
I used Object Size X() and it's interesting to note that the Sphere and the Cube are identical, but not when using Object Size().

Quote: "I thought there would be some command like "object scale()" that would return the object's scale, but there doesn't appear to be - and yet there has to be something, what am I missing here?"

I think this was the main question: and it's been answered. There is nothing that returns the scale of the object, so there is no way to know the original size after it's been scaled, except to track it yourself. There is a nifty undocumented feature (bug?) where the object's collision box doesn't scale right when limb 0 is offset. I'll bet someone could write a function that would return an object's original size based on the collision box's offset size, but it ultimately would be easier (and faster) to track original object sizes in variables.

"Droids don't rip your arms off when they lose." -H. Solo

REALITY II
Qweeg
20
Years of Service
User Offline
Joined: 23rd Sep 2004
Location: Kent
Posted: 23rd Mar 2005 00:53
Thanks Riidii - I follow now. I think I was getting the wrong end of the stick as to what the actual problem was here.
Volund
20
Years of Service
User Offline
Joined: 21st Mar 2005
Location:
Posted: 23rd Mar 2005 16:29
Thanks everyone, your help is much appreciated!

I really didn't want to have to keep track of every object's scale (there are many of them, created dynamically and chosen at random - I'm writing a level editor), but now that I implemented it it isn't that bad - and scaling stuff is damn cool.

So what significant aspect of 3D graphics do I not understand? I mean, the engine keeps some sort of track of the size of an object, it renders it after all. Anyone knows why there's no command for this? It seems a bit inefficient.

... and I said, it's alright.

Login to post a reply

Server time is: 2025-06-04 17:29:08
Your offset time is: 2025-06-04 17:29:08