Archived

This topic is now archived and is closed to further replies.

MENTAL

Ripples over a terrain

Recommended Posts

I''ve been designing a C&C-esque game for some time, but have hit a milestone. one of the weapons (called the sonic-noise-blaster) sends ripples across the landscape (polygon not voxel based) in a waves. The algerithm to make the verticies in the terrain bounce up and down works fine, but i''m trying to work out which verticies will be affected. This ascii drawing my help portray the situation x = vertex ! = affected vertex o = weapon start - = wave --!----!-!- x x x x -x---!---x x x x x -!----- x x x x !--!- x x x x -!- x x x x x -x o each vertex of the terrain has 3 xyz values - a set for the current posistion, another set for the normal posistion (when nothing is affecting it), and the last set for the destination. each wave is defined by 2 xys coordinates and a value for it''s life (decreased each frame). there will be a total of 6 waves going across the landscape from each weapon. each wave is a straight line (not curved, like a proper wave) to make the calcuations easier. The waves will also be moving forward (whichever direction that may be), increasing constantly until their "life" value runs out. I also need help calcuating the co-ords for the line, depending on the angle(0-360 depeding on the direction of the user). any help would be greatly appreciated Sami Hamlaoui PS, more than one weapon could be fired at the same vertex, but i''ll worry about that later

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hmm, the BBS made a hash of your post.

So you already know how to achieve a sinusoidal ripple per vertex, but just need to tell which vertii to efect?

Without the graphic to tell what you want to do its tough to know if this will help, but lemme know if this is what you''re asking about.

A couple questions first : One, why create six waves when the wavs will be moving across the ground? or do you mean the gun makes six waves one after another after its fired? I''ll assume the latter for the moment.

You have the weapon startlocation and a direction in degrees, say.

First of all, create a vector in the direction of propagation of the wave. That would be :

wx = cos(angle) * wavespeed
wy = sin(angle) * wavespeed

this is also the normal for the entire wave. Now, you want the waves to spread out as they travel away from the gun (or at least thats what it looks like from the gibbled diagram).

So lets have a wave be a line segment centered on the normal vector. The length of the line segment at any stage in its life will be (life /life_max)* max_line_length.

You can change this to an iterative version by making it :

length = length + [(1/life_max) * max_line_length]. You can store the value in the [] in your wave, saving you those calculations as you go. Note that the TOTAl length you want should be 2x this, this length is referring to from the midpoint to an end.

the vector to an endpoint of the line _from_ the midpoint of the line would be :

(using math notation, NOT C)

endP1 = (wy,-wx) * length(t) / wavespeed
endP2 = (-wy,wx) * length(t) / wavespeed

where length(t) is the formula given a couple paragraphs above

the location of the endpoints at any time T of your waveline would then be :

wp1_x(t) = (initialwavepointX + wx*t + wy*length(t) / wavespeed)
wp1_y(t) = (ititialwavepointY + wy*t - wx*length(t) / wavespeed)
wp2_x(t) = (initialwavepointX + wx*t - wy*length(t) / wavespeed)
wp2_y(t) = (ititialwavepointY + wy*t + wx*length(t) / wavespeed)

Changing this to an iterative version, and also changing into a 3d representation, is left as an exercise to the reader (meaning I''m tired of typing). 3d in particular has some unlooked for effects. A waveline becomes a plane, complicating things.

So, what this will do :

at time t=0 you start firing. A wave is produced. A time later, the wave has moved along the vector of propagation. The line of the wavefront has widened perpendicular to its direction of travel. As it goes farther along, it gets wider and wider. Finally it reaches the end of its life, and you kill it.

Note that you still have to pick out individual vertexes to move up and down from the line given. This is non-trivial, I''m not sure of the best way to do this. Perhaps a linear interpolation considering the max height of the wave (at the line itself) to however far away the vertex is from the actual wave crest.

Maybe someone else could help you there, I haven''t committed any thought to 3d and terrain systems yet.

I think those should work, but I''m writing this from the computer lab here at the uni, so I don''t have any materials to test this idea with.

(Can you tell I just got out of my class in vector calculus?)

-- Remnant

Share this post


Link to post
Share on other sites
Thanks a lot for the info (at least 1 person replied ).

I''ve managed to find a way of calculating which verticies are affected (and in the process severly sped up my collision detection algarithms), and you help now means i can complete the code. Thanks!

MENTAL

PS: next time you reply to any of my postings, could you please use a slightly simplified language - i''m only 15 years old and i had to read your post about 4 or 5 times to get the jist of it

Share this post


Link to post
Share on other sites
Heh, sorry. I''ve finally learned all the correct names and concepts that I''ve known about for along time now, and now that they''ve been drilled into my head from taking collegiate math and physics classes, I use em.


- Remnant
- (Steve Schmitt)

Share this post


Link to post
Share on other sites