Gamestudio Links
Zorro Links
Newest Posts
bestwinsite
by winsite3. 05/30/24 04:10
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 852 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Precalculate an objects path and interaction #260060
04/08/09 18:14
04/08/09 18:14
Joined: May 2008
Posts: 150
Switzerland
Hitsch Offline OP
Member
Hitsch  Offline OP
Member

Joined: May 2008
Posts: 150
Switzerland
Hi,

I'm trying to precalculate where an object will be in the future, knowing it's speed, mass and direction, without the scene changing.
Essentially how it's often used in other games to show what path a hand grenade is going to take if it's being thrown with a certain speed and angle.
It would then follow exactly this path when it's released.

Since the present scene should not be changed, I would somehow have to precalculate the physics in the background and only the particles showing the path have to update when the variables change.
The way I'm going to use this the physics in the "present" would not change, so the game is actually paused and only the camera can move around, the variables can be changed and the particles adjust.

I've worked with Gamestudios native physics engine and looked into Newton a bit, but I don't see how I could get this to work. I think I'm going to go with Newton though, because the calculations would have to be very precise.
If two paths show that the two object will collide at a certain point in time and space, they would collide just like that afterwards.

Has anyone got a good suggestion where to start with this?

so long...

Re: Precalculate an objects path and interaction [Re: Hitsch] #260090
04/08/09 20:55
04/08/09 20:55
Joined: Jan 2004
Posts: 2,062
Hamburg, Germany
slacer Offline
Expert
slacer  Offline
Expert

Joined: Jan 2004
Posts: 2,062
Hamburg, Germany
Hi Hitsch,

if you throw an object you can calculate its expected path as you did at school ( google for Wurfparabel, schiefer Wurf, etc.)

If two player throw an object and you want to know if and where both object meet in space and when, you would have to decrease delta t if both objects gets closer. This way you would not miss the moment you are looking for.

But if you want to create a game where you have to throw objects and you only want to give the player a hint where his stone will hit the ground, you can work with a little trick.

I used a paint program to create a sprite with an rainbow like arc.
It was for a game with a catapult used to throw heavy objects around the area - to hit moving targets smile
Place the sprite in your 3D space in a way that one side of the arc meets your weapons starting point (the catapult).
If you rotate the weapon to left or right, you can rotate the sprite also.
If you want to put more energy into the impulse to throw the object, you scale the sprite along the X-direction.
Once I found the right scaling factor depending on the energy choosen by the player (hold the trigger longer, loads more energy into the catapult), it worked perfectly.

Well, it was too easy to aim then. So we decided to skip this feature...

You have to decide if you really need to show the path of several objects and to test if they might hit somewhere in the air, or if this would kill the fun part of your game if the player knows the result before the event happens.

-- slacer

Re: Precalculate an objects path and interaction [Re: slacer] #260097
04/08/09 21:24
04/08/09 21:24
Joined: May 2008
Posts: 150
Switzerland
Hitsch Offline OP
Member
Hitsch  Offline OP
Member

Joined: May 2008
Posts: 150
Switzerland
Thx for your ideas Slacer.

It sounds like a really good way to give the player a rough idea where the object is going to go. And this might be the way it's done in many games now that I think about it.
It's often not very accurate though.

Now my game mechanic is based on the players ability to make objects hit in midair and then bounce off the way he intends to.
Kind of like orchestrating a physics event beforehand and when everything is set and ready, it plays out just like the player intended.
For that he's able to stop time, move back and forward in time, move around in space to observe and organize collisions,. He can can then go back to where the path originates and change the variables there, resulting in a different outcome.


Quote:
or if this would kill the fun part of your game if the player knows the result before the event happens

I thought that too when I watched different physics game. Knowing that you are going to hit the target perfectly and then seeing it happening is not much fun. But if you could construct a very complex and very fast event that you could not create in real time, then I think it would be a nice moment when you see your creation play out.
Kind of like that Ati Demo from a few years back, where hundreds of balls fly all around the scene and hit different instruments and you totally lose track of whats happening. But it looks amazing.


Now Calculating a simple path with simple math as you described sounds nice but would be way to complicated and I'm not sure if the engine would calculate exactly the same or be less (or more) accurate.

Is it possible to speed up time in general? So the physics could play out and I could record the paths and then move frame by frame, back and forward?



Last edited by Hitsch; 04/08/09 21:33.
Re: Precalculate an objects path and interaction [Re: Hitsch] #260104
04/08/09 22:09
04/08/09 22:09
Joined: Jan 2004
Posts: 2,062
Hamburg, Germany
slacer Offline
Expert
slacer  Offline
Expert

Joined: Jan 2004
Posts: 2,062
Hamburg, Germany
Quote:
Is it possible to speed up time in general? So the physics could play out and I could record the paths and then move frame by frame, back and forward?


You can create a bunch of arrays and store each objects position and angle at a rate of 20 fps and use these arrays to show the objects trails or to show the situation at frame 200 and rotate the camera around the center of action.

This way your get something like the bullet time effect smile

You could use motion blur for sequences of the past and only render outlines of objects from the future.


But it is not easy to speed things up.
Why?
If you have an object with a mass of 1 kg and you want to apply a force to it, a single frame of energy would not be enough.
You would have to apply the force for several frames until the friction, etc. does not hold back the object from moving.

If you increase the energy of that impulse to shorten the time needed to get your object into the air, your object might launch like a bullet from a gun or like a rocket but is not similar to a thrown stone.

It is a realtime physics engine.

But I think there was a time variable which has an effect on the physics engine, maybe you can play around with it and prerecord the sequence without even rendering a single frame.

Just check the manual if there is a reference to physic simulation and time, fps, fps_max, etc.
There was a time related bug some years ago with ODE and it was fixed with such a time correcting variable... maybe it could help you now, too.

-- slacer

Re: Precalculate an objects path and interaction [Re: slacer] #260408
04/10/09 15:31
04/10/09 15:31
Joined: May 2008
Posts: 150
Switzerland
Hitsch Offline OP
Member
Hitsch  Offline OP
Member

Joined: May 2008
Posts: 150
Switzerland
I have a working scene now with ODE. I'm throwing an object and tracing it's steps with particles. When I then launch an other object of exactly the same masses, it follows that path remarkably well. The first few objects follow exactly, then they slowly tend to leave the path. As expected I guess...

And yes, that's all because of the frame rate that is dropping.
So like this it's impossible to get the same result from a calculation as the last time. They will always be slightly different eek

So what I would need is to have the physics engine do its calculations not in real time, but take as long as it needs for my desired amount of accuracy.
So far I couldn't find a way to do this in ODE, since "ph_fps_max_lock = 60" restricts the engine only for higher frame rates, but not if they drop below the fps_min.

Could this be possible with Newton?
So that I can give it a bunch of variables and only get the update when the whole scene has played out. Or have regular updates, but just not dependent on the frame rate?

Re: Precalculate an objects path and interaction [Re: Hitsch] #260503
04/11/09 14:24
04/11/09 14:24
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
Limit the frame rate in the other direction would be nice... Well,if this would be possible, there were no problems with low frame rates anymore, right? So I'm afraid this is not possible with any engine.

Re: Precalculate an objects path and interaction [Re: the_clown] #260508
04/11/09 15:02
04/11/09 15:02
Joined: May 2008
Posts: 150
Switzerland
Hitsch Offline OP
Member
Hitsch  Offline OP
Member

Joined: May 2008
Posts: 150
Switzerland
True, it sounds impossible because there can't be a minimal limitation for frames rates. I can see that.

Except if the physics engine doesn't have to do real time calculations and then synchronize it with the graphics.
Or am I wrong here?

What I want to do is simply calculate the outcome of a scene with multiple objects and some variables. Then the calculations can happen a lot faster then real time and with it's own clock. Not the frame rate clock. So if I start the exact same calculations right after the last one, the result would have to be exactly the same, because nothing has changed! The only thing that changes in real time is the time it takes to finish a cycle, right?


Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1