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.

Dark Physics & Dark A.I. & Dark Dynamix / [DP] Scaling objects...

Author
Message
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Jan 2008 16:28
Hi all,

Trying to make a sphere grow in DP, object is scaling just fine, but then I'm stuck on what to do with DP to update the size of the sphere. The only way I can find to do this is recreate the rigid body, but I'm sure there must be a way to scale in DP, I'm sure someone mentioned using scaling as an explosion, like scaling an object to double the size before hiding it when it explodes so that it forces other objects away.

I thought that the explosion examples might have scaling, but they just step through each object and apply force to suit the explosion, no scaling stunts to be found.

So I would like to know how to update the scale of an object in DP, a rigid dynamic but also, hopefully a static mesh as well.

Any help or ideas for this DP noob?


less is more, but if less is more how you keeping score?
Hayer
18
Years of Service
User Offline
Joined: 4th Nov 2005
Location: Norway
Posted: 17th Jan 2008 17:52
Quote: "I'm sure someone mentioned using scaling as an explosion,"


Yea, I think it was Benjamin..

Currently tryin' the same for my RTS tank, but it just won't work..

Kendor
21
Years of Service
User Offline
Joined: 31st Jan 2003
Location: Malta
Posted: 17th Jan 2008 20:32 Edited at: 17th Jan 2008 20:33
Unfortunately, scaling is not possible on either dynamic or static meshes. Even if it was possible, scaling could not be applied to a static mesh, since static rigid bodies cannot be modified once initialised.

Your only option is to continously delete and re-create the rigid body. It works correctly for spheres/boxes, but maybe impractical in case of meshes since they take longer to initiliase. Here is an example:



Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why.
Programmers combine theory and practice: Nothing works and they don't know why.
thebulk71
18
Years of Service
User Offline
Joined: 2nd Jan 2006
Location: takin a poop
Posted: 17th Jan 2008 21:26
I am actually stuck on the same problem!

To scale the object, currently I am deleting the rigid body, scaling the object and recreating the rigid body (primitives only).

It works well but I can't re-apply linear or angular velocity to the object!... I am still experimenting here, and I'll post results if I manage.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Jan 2008 23:35 Edited at: 17th Jan 2008 23:36
I have something working with deleting and recreating the physics object, I store some properties first, like the linear and angular speeds, in fact here's the code I'm using now:

mas#=phy get rigid body mass(4)
xls#=phy get rigid body linear velocity x(4)
yls#=phy get rigid body linear velocity y(4)
zls#=phy get rigid body linear velocity z(4)
xas#=phy get rigid body angular velocity x(4)
yas#=phy get rigid body angular velocity y(4)
zas#=phy get rigid body angular velocity z(4)

phy delete rigid body 4
phy make rigid body dynamic sphere 4
phy set rigid body max angular velocity 4,ANG_MAX#
phy set rigid body angular damping 4, ANG_DAMP#
phy set rigid body linear damping 4, LINEAR_DAMP#
phy set rigid body mass 4,mas#
phy set rigid body linear velocity 4,xls#,yls#,zls#
phy set rigid body angular velocity 4,xas#,yas#,zas#


It seems smooth enough for now, I think I could get away with using it - but it seems daft, there should be a way to update a physics object size.


less is more, but if less is more how you keeping score?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Jan 2008 23:38
You don't need scaling spheres to create explosions. The latest update has force fields...

http://www.thegamecreators.com/data/newsletter/newsletter_issue_60.html#4

Kendor
21
Years of Service
User Offline
Joined: 31st Jan 2003
Location: Malta
Posted: 18th Jan 2008 07:18 Edited at: 18th Jan 2008 07:19
@Batvink: I think Van mentioned explosions because he thought they use scaling, not because he actually needs to create explosions.

@Van B: The problem with scaling, as opposed to position/rotation, is that it actually modifies the rigid body in the physics simulation, thus requiring a new rigid body. Another problem is if there are any objects "trapped" between the old size and the new one, especially if large scaling factor are used.

@thebulk71: Take a look at my example, it has linear/angular velocity applied with scaling.

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why.
Programmers combine theory and practice: Nothing works and they don't know why.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd Jan 2008 13:35
Yeah, I mean I plan to have explosions but will be using those new force commands for that.

I'm reasonably happy with it at the mo, haven't heard back from my team mate yet but I quite like it. Perhaps there's some safety code I can add to prevent lockups - like maybe check the linear velocity, if the linear velocity is nothing, then don't scale, maybe even shrink a little. The other option is just to kill the player if they get stuck when scaling up, we could work that into the gameplay somehow.


Anyhoo, thanks all for your appreciated input on this, good to know I'm not alone.


less is more, but if less is more how you keeping score?

Login to post a reply

Server time is: 2024-05-20 02:28:21
Your offset time is: 2024-05-20 02:28:21