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 / How to tell if a body is at rest?

Author
Message
Shando69
FPSC Reloaded TGC Backer
14
Years of Service
User Offline
Joined: 3rd Jan 2010
Location: Redland Bay, QLD, Australia
Posted: 23rd Jun 2011 00:40
Hi All,

I'm using DP to roll some dice, but I can't seem to work out how to tell if they have come to a total stop.

Any help would be greatly appreciated.

Regards

Shando

PS: I've tried testing for Angular & Linear Momentum/Velocity being less than 0.0005, but it still doesn't work (i.e. the dice are still moving when it tells me that these figures are less than 0.0005!)
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 23rd Jun 2011 16:06
set the damper value so that the will stop the rolling.



Dark Physics makes any hot drink go cold.
Shando69
FPSC Reloaded TGC Backer
14
Years of Service
User Offline
Joined: 3rd Jan 2010
Location: Redland Bay, QLD, Australia
Posted: 23rd Jun 2011 23:46
Hi HowDo,

Thanks, but maybe I didn't make myself quite clear...

The dice stop rolling fine, but I need to be able to work out when they have stopped rolling (i.e. when they are totally at rest)?

I've tried testing for Momentum & Velocity being below 0.0005, but this tells me the dice have stopped when I can see that they haven't (I've also tried testing with 0, but again the same thing!)

Regards

Shando
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 24th Jun 2011 17:55
check the doc on these commands one of them may be what you are look it for, plus I think I remember seeing a demo which would show 0.0000 when all movement had stopped. If I can find it will post which one it is.



Dark Physics makes any hot drink go cold.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 24th Jun 2011 18:08 Edited at: 24th Jun 2011 18:11
I think it this one, but I'm sure I seen a better one.



this was the one I was looking for.



Dark Physics makes any hot drink go cold.
Shando69
FPSC Reloaded TGC Backer
14
Years of Service
User Offline
Joined: 3rd Jan 2010
Location: Redland Bay, QLD, Australia
Posted: 25th Jun 2011 04:48
Thanks for the code HowDo, unfortunately I'm still having problems.....

My code is as follows, maybe I'm doing something very wrong????

Set up dice:



Main loop:



Finally, my call to rollDice():



As you can see, I'm only setting bIdle(x) to 1 IF the magnitudes of the Angular Velocity, the Linear Velocity, the Angular Momentum, the Linear Momentum & the Point Velocity are ALL zero!

Thanks

Shando
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 25th Jun 2011 15:42
try changing this

to this.


sometime floats and integer don't always check out.

Dark Physics makes any hot drink go cold.
Shando69
FPSC Reloaded TGC Backer
14
Years of Service
User Offline
Joined: 3rd Jan 2010
Location: Redland Bay, QLD, Australia
Posted: 27th Jun 2011 04:04
Hi HowDo,

Nope, still does the same

So basically I'm now stuck for ideas.

All I can think of is putting in some sort of delay between my code reporting that the Dice have come to rest, and actually getting the dice values (not ideal, but there seems to be no other way using DP!).

PS: I have implemented something similar in another piece of software that uses ODE physics, and it works fine. Maybe this is a "bug" in DP?????

PPS: Are there any good wrappers for ODE available for DarkBasic Pro?

Thanks

Shando

Love Hope Strength (Further details: http://www.lovehopestrength.co.uk/)

One Cancer Centre in every Country, One Concert at a Time
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 27th Jun 2011 15:18 Edited at: 27th Jun 2011 15:20
well I've just taken some of your code above and added the other bits needed to make it start to work.

Now I am wondering what are the dice landing on?


If want you could post what you have, minus the media, and I'll see if it would do as you wish.

Dark Physics makes any hot drink go cold.
Shando69
FPSC Reloaded TGC Backer
14
Years of Service
User Offline
Joined: 3rd Jan 2010
Location: Redland Bay, QLD, Australia
Posted: 28th Jun 2011 03:12
Hi HowDo,

My dba file is attached (all I did was create the "box" from Rigid Bodies).

You can ignore the code at the bottom of the "getDice" Function, as I imported it from another Game Engine that I had used to make this game previously.

Thanks for the help

Shando

Love Hope Strength (Further details: http://www.lovehopestrength.co.uk/)

One Cancer Centre in every Country, One Concert at a Time

Attachments

Login to view attachments
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 28th Jun 2011 20:04
changed a few bits, but I think it now does as it should, you just need to change the spacebar throw to some other way of starting the roll.



Dark Physics makes any hot drink go cold.
Shando69
FPSC Reloaded TGC Backer
14
Years of Service
User Offline
Joined: 3rd Jan 2010
Location: Redland Bay, QLD, Australia
Posted: 3rd Jul 2011 05:42
Hey HowDo,

Thanks for all the help

Unfortunately, it still doesn't quite work I can still tell that the blocks are moving when the relevant text has been displayed.

I'm going to give the Newton & ODE wrappers a try and see what happens

Thanks again

Shando

Love Hope Strength (Further details: http://www.lovehopestrength.co.uk/)

One Cancer Centre in every Country, One Concert at a Time
Shando69
FPSC Reloaded TGC Backer
14
Years of Service
User Offline
Joined: 3rd Jan 2010
Location: Redland Bay, QLD, Australia
Posted: 4th Jul 2011 10:29
Geez, don't you just hate it (and feel remarkably stupid as well) when it's a logic error

It's now working fine and all I had to do was move one line out of a loop!

Old code:



New code:



For those that may be interested, here is the complete code:



Many thanks to HowDo for all the assitance.

Regards

Shando

Love Hope Strength (Further details: http://www.lovehopestrength.co.uk/)

One Cancer Centre in every Country, One Concert at a Time
faria2159
12
Years of Service
User Offline
Joined: 6th Jul 2011
Location:
Posted: 6th Jul 2011 16:24
nice post indeed.
faria2159
12
Years of Service
User Offline
Joined: 6th Jul 2011
Location:
Posted: 6th Jul 2011 16:25
i have this kind of problem too. thanks all of them who answered the question. It helped me a lot.
Walter808
12
Years of Service
User Offline
Joined: 11th Aug 2011
Location:
Posted: 12th Aug 2011 01:55
Thx a lot, i had the same problem.

Login to post a reply

Server time is: 2024-03-28 17:39:19
Your offset time is: 2024-03-28 17:39:19