WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   How to fixing unpredictable physics with manual intervention? (https://forum.worldviz.com/showthread.php?t=4956)

performlabrit 02-18-2014 06:03 AM

How to fixing unpredictable physics with manual intervention?
 
Hello all,

I'm trying to run an experiment in which I need very predictable physical interactions between a bouncing ball and the ground. For example, if the ball is dropped from a known height, the ball should return to that height (no energy should be lost upon collision). This isn't the case if using the physics engine, no matter the bounce/density/hardness settings, energy is lost. This is because Vizard does not give full access to some of the physics sim parameters (CFM).

So I must come up with my own solution:

* When the ball is about to collide with the ground (on the next frame), turn off physics

* Manually simulate ball movement as it hits the ground and reflects.
There is no friction, so this is a simple 2 step process. Using pre-bounce position, velocity, and acceleration, I calc the ball's position when it reaches a height of 1 ball radius. Then, I reverse the vertical component of velocity and calculate the ball's new height after reflection, at the start of the next frame (a total of 16.7 ms later at 60 hz).

* On the next frame, turn physics back on. I wait a frame to avoid issues with prioritization.

Unfortunately, energy is still lost upon a bounce! I've had a second pair of eyes check my equations, and there don't seem to be any mistakes.

Any ideas?

- gD


All times are GMT -7. The time now is 02:27 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC