  | | | Dir3d-l Digest, Vol 8, Issue 9 | Dir3d-l Digest, Vol 8, Issue 9 2004-01-08 - By dir3d-l-request@(protected)
Back Send Dir3d-l mailing list submissions to dir3d-l@(protected)
To subscribe or unsubscribe via the World Wide Web, visit http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l or, via email, send a message with subject or body 'help' to dir3d-l-request@(protected)
You can reach the person managing the list at dir3d-l-owner@(protected)
When replying, please edit your Subject line so it is more specific than "Re: Contents of Dir3d-l digest..."
Today's Topics:
1. Re: Finding the landing point (Kevan Dettelbach) 2. Re: Finding the landing point (Don Relyea) 3. RE: Finding the landing point (Allen Partridge) 4. Re: Finding the landing point (Lucas Meijer) 5. Re: Camera following (Roger Jones) 6. Re: Finding the landing point (noisecrime) 7. explicit me (Thomas Williams) 8. Re: explicit me (Neto) 9. Re: Finding the landing point (James Newton)
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Message: 1 Date: Thu, 8 Jan 2004 09:22:19 -0800 From: "Kevan Dettelbach" <kevan@(protected)> Subject: Re: [Dir3d-l] Finding the landing point To: <dir3d-l@(protected)> Message-ID: <015701c3d60b$fae48350$1904a8c0@(protected)> Content-Type: text/plain; charset="iso-8859 (See http://iso-8859.ora-code.com)-1"
What I would do is calculate where the ball would land on an imaginary horizontal plane Then do a modelunderray aimed from the imaginary landing point pointed at the angled plane.
Kevan -- -- Original Message -- -- From: "Allen Partridge" <partridge@(protected)> To: <dir3d-l@(protected)> Sent: Thursday, January 08, 2004 7:31 AM Subject: [Dir3d-l] Finding the landing point
> Okay - my head hurts. > > Has anyone got an efficient way to find the landing point of a > projectile (imagine target image at landing point of a ball arcing > according to force / gravity.)? > > Without running all of the frames= I'd like to know where that ball will > hit. This is further complicated by the fact that it's hitting a ground > that is rotated on the x, so the ground is sort of uphill as we go. > > So I guess what I'm asking is ... given a constant velocity, a constant > gravity and drag and a dynamic launch trajectory is there a shortcut way > to find the point at which a projectile will intersect with an angled > plane - rather than repeating through all of its steps. > > Things that you might need to know; -- > > I calculate the gravitational force like this; > > pInitTime is created earlier = just the start time in milliseconds when > the projectile is launched. > pDir is the initial launch trajectory, also passed in when launched > > pTimeLapsed = ((the milliseconds - pInitTime) * 0.001) > pGravity = vector(0, -(9.8/pTimeLapsed*pTimeLapsed),0) > pMomentum = ((pDir*(pVelocity*pDrag))+(pGravity*0.0333)) > tSpeed = pMomentum.magnitude > pDir = pMomentum.getnormalized() > pModel.translate(pMomentum) > > > I of course do some other stuff, but this is the basic motion section. > Obviously I don't want to have to repeat through this to figure out > where it will end up, I have plenty of stuff to draw on screen without > all of that and there are potentially 40 - 50 projectiles in the virtual > air at once so I need a much faster targeting solution. > > Thoughts??? > > --al > > > > > > > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ > Dir3d-l mailing list > Dir3d-l@(protected) > http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l
-- ---- ---- ---- ---- ---- --
Message: 2 Date: Thu, 8 Jan 2004 12:36:44 -0500 From: Don Relyea <don@(protected)> Subject: Re: [Dir3d-l] Finding the landing point To: dir3d-l@(protected) Message-ID: <v04220802bc23445dbd88@[67.65.75.234]> Content-Type: text/plain; charset="us-ascii" ; format="flowed"
This site has a formula to calculate exact landing place of a golf ball but doesn't take into effect drag, may help though. It also runs through Eulers method etc.
http://www.kopernekus.com/physics/3dprojectile.asp
>Okay - my head hurts. > >Has anyone got an efficient way to find the landing point of a >projectile (imagine target image at landing point of a ball arcing >according to force / gravity.)?
Don Relyea don@(protected) 214-340-9284 http://www.donrelyea.com -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ BUGLORD RTS game for Windows, Pocket PC, Palm OS Check it out! http://www.buglord.com -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
-- ---- ---- ---- ---- ---- --
Message: 3 Date: Thu, 8 Jan 2004 12:43:58 -0500 From: "Allen Partridge" <partridge@(protected)> Subject: RE: [Dir3d-l] Finding the landing point To: <dir3d-l@(protected)> Message-ID: <000a01c3d60e$fee3bd10$d1fea8c0@(protected)> Content-Type: text/plain; charset="us-ascii"
Yes,
But how would you calculate where the ball was going to land? I mean without running the gravity sim.
--tia,
al
-- --Original Message-- -- From: dir3d-l-bounces@(protected) [mailto:dir3d-l-bounces@(protected)] On Behalf Of Kevan Dettelbach Sent: Thursday, January 08, 2004 12:22 PM To: dir3d-l@(protected) Subject: Re: [Dir3d-l] Finding the landing point
What I would do is calculate where the ball would land on an imaginary horizontal plane Then do a modelunderray aimed from the imaginary landing point pointed at the angled plane.
Kevan -- -- Original Message -- -- From: "Allen Partridge" <partridge@(protected)> To: <dir3d-l@(protected)> Sent: Thursday, January 08, 2004 7:31 AM Subject: [Dir3d-l] Finding the landing point
> Okay - my head hurts. > > Has anyone got an efficient way to find the landing point of a > projectile (imagine target image at landing point of a ball arcing > according to force / gravity.)? > > Without running all of the frames= I'd like to know where that ball will > hit. This is further complicated by the fact that it's hitting a ground > that is rotated on the x, so the ground is sort of uphill as we go. > > So I guess what I'm asking is ... given a constant velocity, a constant > gravity and drag and a dynamic launch trajectory is there a shortcut way > to find the point at which a projectile will intersect with an angled > plane - rather than repeating through all of its steps. > > Things that you might need to know; -- > > I calculate the gravitational force like this; > > pInitTime is created earlier = just the start time in milliseconds when > the projectile is launched. > pDir is the initial launch trajectory, also passed in when launched > > pTimeLapsed = ((the milliseconds - pInitTime) * 0.001) > pGravity = vector(0, -(9.8/pTimeLapsed*pTimeLapsed),0) > pMomentum = ((pDir*(pVelocity*pDrag))+(pGravity*0.0333)) > tSpeed = pMomentum.magnitude > pDir = pMomentum.getnormalized() > pModel.translate(pMomentum) > > > I of course do some other stuff, but this is the basic motion section. > Obviously I don't want to have to repeat through this to figure out > where it will end up, I have plenty of stuff to draw on screen without > all of that and there are potentially 40 - 50 projectiles in the virtual > air at once so I need a much faster targeting solution. > > Thoughts??? > > --al > > > > > > > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ > Dir3d-l mailing list > Dir3d-l@(protected) > http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ Dir3d-l mailing list Dir3d-l@(protected) http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l
-- ---- ---- ---- ---- ---- --
Message: 4 Date: Thu, 08 Jan 2004 18:51:40 +0100 From: Lucas Meijer <lucas@(protected)> Subject: Re: [Dir3d-l] Finding the landing point To: dir3d-l@(protected) Message-ID: <3FFD98AC.1030300@(protected)> Content-Type: text/plain; charset=us-ascii; format=flowed
> I of course do some other stuff, but this is the basic motion section. > Obviously I don't want to have to repeat through this to figure out > where it will end up, I have plenty of stuff to draw on screen without > all of that and there are potentially 40 - 50 projectiles in the virtual > air at once so I need a much faster targeting solution.
Hey Allen,
It might be better (at least easier, but I think also better), to use an iterative solution: just quickly simulate your timesteps, and see where it lands.
You could also solve it mathematically, (you can simplify the problem by looking at it from the ground's point of view.. the ground isn't tilted, the cannon shooting the ball is!, the ground is flat).
However the mathmetical solution will give you the 'right' solution, while your simulation will be off. Wether the difference is too much in your case, depends on what you're using it for, but since you're using euler integration, chances are you'll be off by quite an amount, depending on the size of your timestep.
So if you take the mathematical route, chances are good you'll have to upgrade your simulation to a better integration routine, like midpoint, or ranga-kuppa, runga kappa, (sorry dyslexic :-), or at least something better than euler.
Good luck, Lucas
-- ---- ---- ---- ---- ---- --
Message: 5 Date: Thu, 8 Jan 2004 10:12:11 -0800 From: Roger Jones <roger@(protected)> Subject: Re: [Dir3d-l] Camera following To: dir3d-l@(protected) Message-ID: <2E06BD26-4206-11D8-B498-000393C60948@(protected)> Content-Type: text/plain; charset=US-ASCII; format=flowed
On Jan 8, 2004, at 7:51 AM, Colin Holgate wrote:
> You normally would interpolate transforms (duplicate the current > transform, apply the full change to the duplicate, then interpolate > the actual transform part of the way towards the adjusted duplicate). > If there's something in the camera transform that can't be controlled, > you can work around that by having a model as the camera's parent, and > do all the transforms to the model instead of the camera.
I tried something like that recently and found that when I made the camera a child of a dummy that reflection maps no longer updated when the camera was no at the top of the hierarchy. YMMV
-- ---- ---- ---- ---- ---- --
Message: 6 Date: Thu, 8 Jan 2004 18:14:07 -0000 From: "noisecrime" <noise@(protected)> Subject: Re: [Dir3d-l] Finding the landing point To: <dir3d-l@(protected)> Message-ID: <006101c3d613$34a5a720$0100a8c0@(protected)> Content-Type: text/plain; charset="iso-8859 (See http://iso-8859.ora-code.com)-1"
-- -- Original Message -- -- From: "Allen Partridge" <partridge@(protected)>
> Has anyone got an efficient way to find the landing point of a > projectile (imagine target image at landing point of a ball arcing > according to force / gravity.)? > > Without running all of the frames= I'd like to know where that ball will > hit. This is further complicated by the fact that it's hitting a ground > that is rotated on the x, so the ground is sort of uphill as we go.
> Thoughts???
First off do you need to know the impact point before it happens? If so how accurate should it be?
I think i'd tackle it by running through the projectile motion (exactly as you wanted to avoid ;) ) However as this isn't to be displayed we can use much larger time steps than you would normally.
So each frame we have a starting point and an end point, simply raycast between the two. If there is an intersection then go back to the start position and this time only advance by half the step. Do the raycast again if it fails to hit anything, use the end point as the new start point and repeat the above procedure. If the raycast hits something repeat dividing up the timestep by 2 each time, until either the interception point is the same as the previous one or when the step time is below some threshold. The final interception you calculate is the impact point.
Other optimsiations Can the projectile hit anything during its upward segement of the arc? If not then use the standard projectile motion eqs to calculate the highest point on the arc, and start the step time checking from there.
If this is for some AI, then the recursive time division can be exited at different times based on their 'accuracy setting' As the earlier you come out of the loop, the higher the time step and thus less accurate the impact point prediciton is likely to be.
For a large number of simulatanious impact queires - stagger them. Its highly unlikely a user would be any the wiser to you calcualting the impact point for say 10 projectiles in one frame as opposed to you taking ten frames doing one per frame (as long as you've got a decent framerate that is). For example if we ignore the time it takes to find an impact point and your game is running at 30 fps, then it would take 333ms (10 frames) to calculate the impact points for ten projectiles, thats a third of a second. So as long as you display all the impact points at once, no-one will notice the short delay.
The intersect tests may be quite expensive using raycasting, but if you're using something like a hieght map (evenly spaced grid) you should be able to come up with a much fast alternative as you can build a bounding box (figurativly) around the start and end points, and from that determine a smaller subsection of triangles to check against.
I'm pretty sure you can use some good old projectile motion equations for this if you need a refresher perhaps take a look at this http://www.physicsclassroom.com/Class/vectors/U3L2a.html
hope this helps
Noisecrime 2004
-- ---- ---- ---- ---- ---- --
Message: 7 Date: Thu, 8 Jan 2004 13:07:05 -0800 From: "Thomas Williams" <t@(protected)> Subject: [Dir3d-l] explicit me To: <dir3d-l@(protected)> Message-ID: <KOEHJJFDCKOPOJDPCONBMEABCMAA.t@(protected)> Content-Type: text/plain; charset="iso-8859 (See http://iso-8859.ora-code.com)-1"
I just ran into a strange situation using regarding the use of (me). I've got a parent script that uses several methods. At one point, from inside one of these methods, I make a call to another method (that is inside the same parent script) and pass arguments along. The problem is that the arguments don't get passed (their value turns up as void) if I use (me) as the initial argument in the opening line of the method that is being called.
eg:
on doStuff (me) -- do the stuff quantity = 3 makeNewThing(quantity) end doStuff
on makeNewThing (me, quantity) put "quantity",quantity end makeNewThing
-- ---- ---- ---- "quantity" <void> -- ---- ---- ----
but if I take out the me, the argument gets passed fine. eg
on makeNewThing (quantity) put "quantity",quantity end makeNewThing
-- ---- ---- ---- "quantity" 3 -- ---- ---- ----
I am mystified as to why this happens. But more to the point, is it necessary or even a good idea to use (me) as the initial argument in methods.
This brings me to the other use of explicit me as a predicate for methods. Unlike "this" in AS, it seems that lingo does not like to use (me) as a predicate for calling methods _unless_ the method is in an ancestor.
eg this is wrong:
on doStuff (me) -- do the stuff quantity = 3 me.makeNewThing(quantity) <--- explicit use of me end doStuff
unless we are calling a method that exists only in an ancestor. Do I have this right?
can someone clarify the rules for when (me) must be used and when not to use it? sorry, I know this is basic stuff, but when it acts erratically, I wonder what the rules _really_ are.
I'm also wondering if the new DirMX2004 is going to adopt a syntax that resembles "this" in AS.
thanks
Thomas
-- ---- ---- ---- ---- ---- --
Message: 8 Date: Thu, 8 Jan 2004 19:08:24 -0300 From: "Neto" <neto@(protected)> Subject: Re: [Dir3d-l] explicit me To: <dir3d-l@(protected)> Message-ID: <000501c3d633$efd22a30$1501b2aa@(protected)> Content-Type: text/plain; charset="iso-8859 (See http://iso-8859.ora-code.com)-1"
AFAIK, the 'me' keyword in Director is just a convention. You could call it whatever you wanted, even 'this'. It's just that the new() handler inside a parent script receives a parameter that is a reference to that script. After that parameter is stored somewhere, you can do whatever you want with it.
-- ---- ---- --- on new (foo)
return foo end -- ---- ---- ---
That works as well.
As for the explicit me in handlers, there is a difference between:
me.doSomething()
and ...
doSomething(me)
In the first case you are explicitely calling the 'doSomething' handler inside the 'me' object (remember 'me' has no special powers - it's just a variable like any other). Since 'me' often happens to be the same script, it'll call a handler in itself (or in the ancestor, if the handler is not found in the object). The 'doSomething' handler will receive an automatic parameter - a reference to the script where it lies at (NOT the script that called it).
The second case makes Director look around for a handler. First it checks if there is such handler in the script where the handler was called. If so, it's called, but it will NOT receive the automatic 'me' as the first parameter. It'll work *exactly* like a global handler, with the difference that the instance properties are avaliable to it. It's up to you or not to pass a 'me' along.
-- -- Original Message -- -- From: "Thomas Williams" <t@(protected)> To: <dir3d-l@(protected)> Sent: Thursday, January 08, 2004 6:07 PM Subject: [Dir3d-l] explicit me
> I just ran into a strange situation using regarding the use of (me). > I've got a parent script that uses several methods. > At one point, from inside one of these methods, I make a call to another > method (that is inside the same parent script) and pass arguments along. The > problem is that the arguments don't get passed (their value turns up as > void) if I use (me) as the initial argument in the opening line of the > method that is being called. > > eg: > > on doStuff (me) > -- do the stuff > quantity = 3 > makeNewThing(quantity) > end doStuff > > on makeNewThing (me, quantity) > put "quantity",quantity > end makeNewThing > > -- ---- ---- ---- > "quantity" <void> > -- ---- ---- ---- > > > but if I take out the me, the argument gets passed fine. > eg > > on makeNewThing (quantity) > put "quantity",quantity > end makeNewThing > > -- ---- ---- ---- > "quantity" 3 > -- ---- ---- ---- > > I am mystified as to why this happens. But more to the point, is it > necessary or even a good idea to use (me) as the initial argument in > methods. > > This brings me to the other use of explicit me as a predicate for methods. > Unlike "this" in AS, it seems that lingo does not like to use (me) as a > predicate for calling methods _unless_ the method is in an ancestor. > > eg this is wrong: > > on doStuff (me) > -- do the stuff > quantity = 3 > me.makeNewThing(quantity) <--- explicit use of me > end doStuff > > unless we are calling a method that exists only in an ancestor. Do I have > this right? > > can someone clarify the rules for when (me) must be used and when not to use > it? > sorry, I know this is basic stuff, but when it acts erratically, I wonder > what the rules _really_ are. > > I'm also wondering if the new DirMX2004 is going to adopt a syntax that > resembles "this" in AS. > > > thanks > > Thomas > > > > > > > > > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ > Dir3d-l mailing list > Dir3d-l@(protected) > http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l >
-- ---- ---- ---- ---- ---- --
Message: 9 Date: Thu, 08 Jan 2004 22:15:02 +0000 From: James Newton <james.newton@(protected)> Subject: Re: [Dir3d-l] Finding the landing point To: "dir3d-l@(protected)" <dir3d-l@(protected)> Message-ID: <BC2386E6.348F%james.newton@(protected)> Content-Type: text/plain; charset="ISO-8859 (See http://ISO-8859.ora-code.com)-1"
On 8/1/04 3:31 pm, "Allen Partridge" <partridge@(protected)> wrote: > Has anyone got an efficient way to find the landing point of a > projectile (imagine target image at landing point of a ball arcing > according to force / gravity.)? > > Without running all of the frames= I'd like to know where that ball will > hit. This is further complicated by the fact that it's hitting a ground > that is rotated on the x, so the ground is sort of uphill as we go.
Hi Allen,
Your projectile will follow a parabolic curve in a 2D plane. The sloping ground can be expressed as a straight line in the same plane. Finding the intersection of the two requires you to solve a quadratic equation:
on LineCutsParabola(a, b, c, m, n) -- ---- ---- ---- ---- ---- ---- --- -- INPUT: <a>, <b>, <c>, <m> and <n> must all be floats -- The parabola is expressed as y = ax^2 + bx + c -- The line is expressed as y = mx + n -- NOTE: This method does not handle the special cases where a = 0 -- and where the line is vertical. -- OUTPUT: Returns a list of points. The list may contain 0, 1 or 2 -- points where the line intersects the parabola. The -- coordinates will be floats. -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
tResult = []
-- Express the parabola and the line as equations -- y = ax^2 + bx + c .... (1) -- y = mx + n -- -- Replace y with (mx + n) in (1) -- -- => mx + n = ax^2 + bx + c ... (2) -- => ax^2 +(b - m)x + (c - n) = 0 -- -- Replacing (b - m) and (c - n) with B and C, we have a standard -- quadratic equation: -- -- y = ax^2 + Bx + C ........................... (3) -- -- Using the quadratic formula: -- -- x = (-B � sqrt(B*B - 4 * a * C)) / (2 * a)
if a = 0 then -- Special case: there is no parabola return tResult end if
-- Convert to a single quadratic equation in x B = b - m C = c - n
determinant = B * B - 4 * a * C
if determinant < 0 then -- There are no real roots to the quadratic: the line does not -- cross the parabola
else if determinant = 0 then -- There is only one root, at the tip of the parabola
x = -B / (2 * a) y = m * x + n
tPoint = point(x, y) tResult.append(tPoint)
else -- There are two distinct roots root = sqrt(determinant)
-- First root x = (-B + root) / (2 * a) y = m * x + n tPoint = point(x, y) tResult.append(tPoint)
-- Second root x = (-B - root) / (2 * a) y = m * x + n tPoint = point(x, y) tResult.append(tPoint) end if
return tResult end LineIntersectsParabola
Your work now is to determine the input values. Use a negative value of <a> to represent gravity. Work out what vertical plane the projectile is being fired in. If you consider the firing point to be at [0, 0] in that plane, <c> will become 0. Increasing the value of <b> will increase the range of the projectile. You will then have to work out the equation for the line where the ground cuts your 2D projectile plane.
The method above should return two values, one near the firing point (if this is not on the same slope of ground) and one more distant, where the projectile lands. You will now have to convert the landing point in the 2D projectile plane into a point in your 3D world.
Does this help you get started? How's your matrix math for the 2D <=> 3D conversions?
Cheers,
James
-- ---- ---- ---- ---- ---- --
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ Dir3d-l mailing list Dir3d-l@(protected) http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l
End of Dir3d-l Digest, Vol 8, Issue 9 *************************************
|
|
 |