Wind simulator...UPDATED...9/29/03..

Posted By: Orange Brat

Wind simulator...UPDATED...9/29/03.. - 09/20/03 15:22

What exactly are the varying techniques, others have used, for creating wind? There isn't much talk about it and a search gives me 5000 hits because of the word "window".

I'm trying to develop a wind system that is totally random..somthing fast and somewhat simple that will affect models. Say I want a hanging light or a tree to sway in the breeze, but the sway should be totally random and dependent on the wind direction(and changes in direction). I suppose it could be coded for each entity as an action and assigned to the individual entity, but I like the idea of a global wind that is independent of the entities(or is it?) for whatever insane reason.

This almost sounds like a physics issue, though I haven't dove into that crazy place, yet.
Posted By: tesanders

Re: Creating wind... - 09/20/03 16:30

Interesting problem.

I've added wind effects to my script, but only to blow the player around the map, along with some debris. Both of those are, of course, relatively simple.

Speaking as someone who also hasn't touched the 3DGS physics package, it seems that that might be usable for rigid bodies such as your lanterns, (e.g., fix the top point and apply a changing force over time to the lantern's bottom point). As trees aren't rigid bodies, they may require a different approach.

As a simple trial, you could model a single reed using vec_for_mesh/vec_to_mesh to adjust the reed's vertices over time. Have it bend slightly in the direction of the wind by moving all the vertices in that direction to varying degrees. Move the vertices at the top of the reed farther than you move the ones towards the bottom, (i.e., make the lateral translation proportional to both the speed of the wind and the distance between a vertex and the model's base).



vec_for_mesh() gives you coordinates, so it's possible to calculate where a vertex is in relation to the model, (and thus, you can tell the tree which vertices to move). As things often bob back and forth in the wind, you could also add some sinusoidal factor in there.

Then there's always bones animation, which is probably handier than tweaking individual vertices. And finally, simply animating a tree's .mdl so that it rustles is the least computationally expensive. Of course, it's 3:30am, so I have no idea whether this makes any sense, but that never stopped me from talking.
Posted By: Orange Brat

Re: Creating wind... - 09/20/03 22:27

It all makes sense...it's just new found territory for me...I haven't messed with models very much and this wind thing is just on the to do list. I think all of the different methods are relevent for given situations and my global wind is probably too taxing(on lesser systems) to consider unless used sparingly.

I'm more interested in realistic motion, I suppose. I have two map entities(not models, not sure why I said models)...a sign that sways and a light that hangs from the ceiling that should move with the breeze coming though an open window.

I have one physics object to play with, since I have commercial, so I'll mess with that since these are rigid bodies. This should be a laugh riot.

EDIT: Got it to actually work...no wind but the entity moves exactly how I want it to visually. Of course it needs a bit of wind to make the motion random. I like the physics engine...nice stuff....I can see how someone could get carried away with it.
Posted By: PHeMoX

Re: Creating wind... - 09/21/03 00:34

hmmmm, I think that if you don't want it as an action to the stuff that is supossed to move in the wind, I'll guess the only way is to animate the models and add an interesting wind noise to give you the feeling that there is wind....
It's all about faking it, when you really want to program it, I think that it really WOULD slow things down much.... However it's an interesting thing; maybe just to mess around a bit someone could combinate clever coding for the wind with the tree-generating code.....(easy when you just animate the model.....)
mmmm I wonder how they do winds in games like Delta Force: Black hawk down .....................
Posted By: myrlyn68

Re: Creating wind... - 09/21/03 01:05

Most game systems don't animate the objects prior to being put into the game. They will use some form of mesh deformation in order to achieve the desired result. Take a look at GameDev.com's "Earth, Wind, Fire and Water" contest for a few different examples.

What it mostly comes down to is making sure your script can somehow identify an objects overall stiffness (perhaps using a skill), and its spring back. Then you apply a few different algorithms to it (there are a few choices on GameDev - I will look for the links again a bit later if needed), which take both of those factors into account. Most can be translated into c-script relatively easily. This than will dictate how far certain models will bend and sway with the wind force applied.

Another option is to use an invisible particle system and use those particles to be your wind force. This has a few advantages, as it is easier to represent calm areas on a level (behind buildings for example). Again though, it still requires a certain ammount of information to be stored within the meshes to be affected. Gets to be quite processor intensive though.
Posted By: BHoltzman

Re: Creating wind... - 09/21/03 14:07

I had this idea that may or may not work for wind effected objects. Vue 4 Pro is out and it will let you animate plants that you design and you can export the plants as 3d models. The idea is to take a couple of animated plant models and put them into WED so that we can fake a wind but make it look really good! Although the models are probably going to be too polygon heavy.

If anyone knows any more about whether vue 4 pro will work well in this situation, I'd love to hear from you.

From,

Ben
Posted By: Orange Brat

Re: Creating wind... - 09/21/03 14:25

Faked blowing via well done animations(different ones) are probably the way to go for us little people. The physics engine path has potential if I can get the thing to work(see physics section thread). I think I have it set up properly, but lack of coherent examples and good documentation are not in vast supply. This section of the manual needs a lot of attention.

I took a look at some of the Gamedev demos...some interesting stuff, though I have yet to find any with source code I can open. I'll search again when I find the time.
Posted By: myrlyn68

Re: Creating wind... - 09/21/03 14:33

I agree with you their - but animations come with a number of restrictions that brute force code can overcome. The biggest problem would be varying things from a small breeze to a brisk wind to a hurricane.

Also you have to be careful with your orientation of models, which will cause you to either create more models, or have a bunch of cookie cutter models.

One thing you might also look into as opposed to messing with all the vertexes (and I should have emntioned it before - since I am currently examining the feasibility between 20 or so other things ) is the use of bones. This will give you a hinge in your model already - then you just assign a few skills and a variable that gets set by the weather man, and you should be able to pull off swaying lanterns, trees, grass... Though bones require a bit of CPU time to calculate the position of the vertexes... Ah well - bump up those minimum requirements, and you are good to go.
Posted By: Orange Brat

Re: Creating wind... - 09/24/03 16:12

@myrlyn68:

Thanks for that link over in George's AUM29 thread. There's one really nice example with fairly easy to follow C++ source, and it reads like c-script. It's basically the guts of a simple wind system and can be integrated into the technique tesanders described above.

EDIT: <Code moved for clarity>
Posted By: myrlyn68

Re: Creating wind... - 09/24/03 21:41

Very good link if I don't say so myself. I'll take a closer look at the C++ after I have a bit more coffee this morning to see if I can't figure out the c-script translation for it.

In regards to the method above, don't forget using bones for more rigid bodies (the lantern in your physics example). It would require a bit more code, but should provide a nice effect.
Posted By: Orange Brat

Re: Creating wind... - 09/24/03 21:49

See below for latest iteration...it'll be the last since I've taken it as far as I can.

Quote:

In regards to the method above, don't forget using bones for more rigid bodies (the lantern in your physics example). It would require a bit more code, but should provide a nice effect.






The lantern is a map entity so it wouldn't have any bones anyway. I was going to have to figure out how to apply this "hack" to the physics force instructions....it would just involve doing some comparisons with values and if certain conditions were met then it does something.
Posted By: Orange Brat

Re: Creating wind... - 09/25/03 15:11

Code to return, in User Contributions, when it's finished!
Posted By: myrlyn68

Re: Creating wind... - 09/25/03 22:12

Currently without some pretty major changes to the way the code handles the trees (or other objects), or the 3DGS model format - it will not work straight away.

The biggest problem which I am running across is storing a relative value for the vertex movement based on a constraint which is determined by it's distance from the ground. While it is not impossible to have the vertex positions stored in an array and assign values like the weighting system used in that code, it seems to be a bit more difficult then what I initially anticipated.

As soon as I finish up a couple other projects I am working on, I'm going to see about rewriting the handling procedures to see if I can't get something to work a bit better. The code for generating the force (wind) itself seems to work fine when implemented in a level though.
Posted By: JayG

Re: Creating wind... - 09/26/03 00:43

This looks like some nice work..

just a few comments

why not use vec_lerp in c-script to replace the D3DXVec2Lerp(w_CurrentDirection, w_CurrentDirection, w_DirectionGoal, w_DirectionChangePct);


I don't know I saw the lerp and thought it might help.


You are correct about

w_strWindInfo.Format("Wind speed %.2f Dir %s", w_CurrentSpeed,GetWindDirectionString(degrees));


It is formating the data (Current Speend and WindDirection)into a string representation and will be saved in w_strWindInfo.



Posted By: Orange Brat

Re: Creating wind... - 09/26/03 05:58

Quote:

why not use vec_lerp in c-script to replace the D3DXVec2Lerp




Because I didn't realize it was a new feature. Thanks for the heads up.

@mrylyn68:

I'm glad to hear the wind force is actually working for you...I finally got it working, since discovering a careless error("==" was being used instead of a "=" in one line).

I changed the "fatan" to a "ftan", near the bottom of "wind()" and changed the "*" to a "/" in the f_Degrees function(made a couple of checks there, too). After doing this, the cardinal directions shift indicator seems to work, though I have no idea if it is accurate, though I think it is. This is a slightly different way that the original, but that version did not work at all.

Anyway, if you have any luck with the vertex movement, keep us posted, and see above for my semi-final script(unless you have any suggestions/contributions for improvement) and revised explanations/bugs/etc.
Posted By: MarkMcFear

Re: Creating wind... - 09/28/03 10:43

First off, wow nice stuff you guys.

Second off, am I to understand that potentially a person could animate their environmental models (leaves, trees, clumps of grass etc.) and use the wind direction from this function to actually animate the models during gameplay to accomplish a direcitonal "wind force" in the animations? That would certainly add a seriously unique touch to alot of games.

I wish you guys luck in this. I'll definitely stay tuned.

Mark

Posted By: myrlyn68

Re: Creating wind... - 09/28/03 10:56

Yes, you could potentially apply a "wind force" to everything in your game, granted your game would tick along at a smooth 2 or 3 FPS.

Like any physics calculations, they tend to get pretty intensive the more of them you run. While this is pretty mild as far as the processor requirements go, when you begin applying it to everything - it adds up quickly.

It isn't really that unique anymore though. Most games that can afford the CPU time have wind effects now, and if you really wanted to get crazy you can add the effects to various character model parts to have them move with the wind (hair, capes).
Posted By: Orange Brat

Re: Creating wind... - 09/28/03 11:10

@MarkMcFear:

It would probably be best to use it in moderation...if we all had 5 GHz Pentium VI PCs you might be able to get away with everything Perhaps a mixture of some objects that move via wind effects(to add the random touch) and models with looping animations would work best. Anyway, I'm still hammering away at it, so what is above will change a bit, most likely. Check back since I won't post a new reply..I'll just edit the code above.
Posted By: MarkMcFear

Re: Creating wind... - 09/28/03 11:19

Heh yes, everything in moderation I guess what I am most excited about is teh possibility to put in random grass clumps that "wave" in the wind. These clumps would all be client side generated and the wind process would jsut be client side fluff. It oculd be turned off or on to boost performance or reality and would really add a touch of eye candy to my somewhat bland attempts at level creation.

My current screenshots for the game are pretty old now. I'm working the first "zone" which I am using in the video trailer next month. I've got some actual 3D modeled grass MDLs that I would love to try this with. I'm buried knee deep in an inventory re-write at the moment so I really can't attack this at the moment.

Still, you guys are really making some great strides in tapping the potential of the 3DGS engine. I'll stay tuned =)

Mark

© 2024 lite-C Forums