Weather System (21 posts)

  • Profile picture of t0neg0d t0neg0d135p said 3 months, 2 weeks ago:

    Sooooo…

    I added a weather system that is server based. Each zone is responsible for forecasting it’s own weather and delivering information to the client(s). Storm duration, intensity, type and so forth. Lighting is handled by the server as well so placement is congruent from client to client. Clouds in the skybox with roll in/out with the storm info.

    Why would I bother?

    Well… I know that the graphics for this game will never be insanely awesome, so I am opting for atmosphere instead. Make it “feel” a certain way, and you the users brain will fill in the blanks.

    Anyways… here is a sample. Not complete by any stretch of the imagination, but the basics are there.

  • Profile picture of Tumaini Tumaini79p said 3 months, 2 weeks ago:

    Very nice!
    I’ve always preferred atmosphere and immersion in a game over super-brilliant graphics (I think your graphics look good already, as well).
    Will the weather affect the character or the surrounding? E.g. will the character get slower reaction if they are cold or will some terrain get slower to walk in if it has been raining?

  • Profile picture of staugaard staugaard38p said 3 months, 2 weeks ago:

    Very nice, indeed… May I ask how you did those clouds?? Looks great.

  • Profile picture of normen normen1291p said 3 months, 2 weeks ago:

    Yeah, it looks really cool. I think this will do a _lot_ to the feel of the game. Do you add any buffs/debuffs on the player based on the weather too? Like make them a bit slower in the rain and idk, a bit better at hitting the enemy when its sunny?

  • Profile picture of iamcreasy iamcreasy62p said 3 months, 2 weeks ago:

    wow, that looks really nice. How did you do the rain, cloud and lightning?

  • Profile picture of pspeed pspeed822p said 3 months, 2 weeks ago:

    @t0neg0d said:
    Well… I know that the graphics for this game will never be insanely awesome, so I am opting for atmosphere instead. Make it “feel” a certain way, and you the users brain will fill in the blanks.

    Yes, atmosphere is everything… and good job on putting some thought into the system so that it’s not just “hah! it’s raining” then “Hah! now it’s not” randomness. :)

    My weather system is still only on paper… so I envy others. :)

  • Profile picture of t0neg0d t0neg0d135p said 3 months, 2 weeks ago:

    Hmm… let me see if I can answer all the questions. If I miss one… smack me, I’ll answer it eventually.

    Will it effect players. All stats are based off the following code, so apply modifiers via spells, weather, etc are extremely easy to handle.

    public class cStat implements Serializable {
    	String name;
    	float base = 0, altered = 0, equip = 0, effect = 0, factored = 0, current = 0;
    
    	public cStat() {  }
    	public void initStat(String name) {
    		this.name = name;
    	}
    	public void setBase(float value) { base = value; totalFactored(); }
    	public void addBase(float value) { base += value; totalFactored(); }
    	public void subBase(float value) { base -= value; totalFactored(); }
    	public float getBase() { return base; }
    	public void setAltered(float value) { altered = value; totalFactored(); }
    	public void addAltered(float value) { altered += value; totalFactored(); }
    	public void subAltered(float value) { altered -= value; totalFactored(); }
    	public float getAltered() { return altered; }
    	public void setEquip(float value) { equip = value; totalFactored(); }
    	public void addEquip(float value) { equip += value; totalFactored(); }
    	public void subEquip(float value) { equip -= value; totalFactored(); }
    	public float getEquip() { return equip; }
    	public void setEffect(float value) { effect = value; totalFactored(); }
    	public void addEffect(float value) { effect += value; totalFactored(); }
    	public void subEffect(float value) { effect -= value; totalFactored(); }
    	public float getEffect() { return effect; }
    	public void setFactored(float value) { factored = value; }
    	public void addFactored(float value) { factored += value; }
    	public void subFactored(float value) { factored -= value; }
    	public float getFactored() { return factored; }
    	public void setCurrent(float value) { current = value; }
    	public void addCurrent(float value) { current += value; }
    	public void subCurrent(float value) { current -= value; }
    	public float getCurrent() { return current; }
    	public void resetCurrent() { current = factored; }
    	private void totalFactored() {
    		factored = base+altered+equip+effect;
    		if (factored < current) current = factored;
    	}
    }

    All objects are derived of a collect of stats (among other things). A stat can be anything (obviously), so effecting the players attack speed, movement speed, overall weight, etc, etc, etc is as easy as calling addEffect… or subEffect. If these are timer based, that expire automatically–or in the case of weather changes received from the server (also considering player skills that would counter the effect)… could potentially effect any number of attributes.

    As for how I did the lightning (This worked for a really great looking torch effect as well):

    Lightning—lighting effect

    // for the dureation of the lightning effect
    float lColor = (float)(Math.random()*.3f)+.7f;
    lLight.setColor(new ColorRGBA(lColor, lColor, lColor, 1));
    // otherwise, set the light to Black
    

    Torch—lighting effect

    if (!skyBox.getIsDay()){
    	float red = ((float)Math.random()*.2f)+.6f;
    	float green = red-.2f;//((float)Math.random()*.2f)+.4f;
    	float radius = ((float)Math.random()*2)+6;
    	torch.setColor(new ColorRGBA(red,green,.0f,.8f));
    	torch.setRadius(radius);
    }
    

    As for the lightning & rain display—
    A billboarded quad set to Bucket.Sky – for the lightning
    A particle emitter — for the rain
    the code in the update of the control is fairly straight forward:

    public void update(float tpf) {
    	int pos;
    	float x, y;
    
    	pos = (int)Math.round(Math.random());
    	x = (float)(Math.random()*(size*3));
    	if (pos == 0) x = -x;
    	pos = (int)Math.round(Math.random());
    	y = (float)(Math.random()*(size*3));
    	if (pos == 0) y = -y;
    
    	weather.setLocalTranslation(x, size, y);
    
    	if (showLightning) {
    		lShowCount += tpf;
    		if (lShowCount > 1.5) {
    			// Set material to notta after lightning ends
    			effectNode.setMaterial(mat_LTrans);
    			showLightning = false;
    			lShowCount = 0;
    			lLight.setColor(ColorRGBA.Black);
    		} else {
    			if (lBegin) {
    				// Position quad & set material.. need to update to image defined by server
    				effectNode.setLocalTranslation(lV);
    				effectNode.setMaterial(mat_L);
    				lBegin = false;
    			}
    			// Flicker lightning light
    			float lColor = (float)(Math.random()*.3f)+.7f;
    			lLight.setColor(new ColorRGBA(lColor, lColor, lColor, 1));
    		}
    	}
    }
    
    public void showLightning(float[] position, int imageIndex) {
    	lV = new Vector3f(position[0], position[1], position[2]);
    	lBegin = true;
    	showLightning = true;
    }
  • Profile picture of staugaard staugaard38p said 3 months, 2 weeks ago:

    I like it… How about your clouds?

  • Profile picture of t0neg0d t0neg0d135p said 3 months, 2 weeks ago:

    Oh yeah…

    The skybox (or hemispheres is an ugly monster atm. But, here is the general idea:

    I have have an outter hemisphere with the night star material. Another slightly inside of it with the day material, that is alpha’d out or in depending on the game time. These are static, though if I had ambition, I would expand the star map to another hemisphere and position them accord to seasons (not going there personally, but the seasons and season changes are defined in game)

    Inside of there are two hemispheres, creating a sphere. Each is texture with alpha mapped clouds (more than likely rendered in photoshop… with some minor alterations). The bottom hemisphere is a mirror image of the top. Now, to cycle heavier clouds in, I do texture swapping on the hemisphere that is out of view to make it appear to be a seamless transition.

    This all works, but… here is what I would like to do:

    Create a single static grid that is mostly flat and eventually curves out of view towards the edges. I’m desperately trying to create a shader that I can set the x, y coords of the texture… so in repeat mode… as long as it is tile-able, the shader will move the clouds for me… but I am relatively shader illiterate and my attempts so far just produce a non-moving texture =(

  • Profile picture of t0neg0d t0neg0d135p said 3 months, 2 weeks ago:

    Almost forgot… the fairly hemispheres are small, rendered to the sky and follow the player.

    I tried to get them to follow the chasecam… but this did some ugly things, so eventually I’ll have to figure this out, or things get weird when you zoom out from the player.

  • Profile picture of t0neg0d t0neg0d135p said 3 months, 2 weeks ago:

    Another quick update…. shows the skybox night to day fade…. and also uses a shader for cloud movement now. Allowed me to flatten the mesh used the cloud layer to give a more linear look to the cloud movement. The final will use 2 separate cloud layers and allow for overall alpha manipulation… movement speeds/direction changes… and applying a varying color overlay to change clouds from white to gray… etc, etc, Really happy with the overall effect of the shader movement. Thanks @pspeed for the tips!

  • Profile picture of staugaard staugaard38p said 3 months, 2 weeks ago:

    Excellent ideas. Im going to work on the same in the next (or next) milestone in our project, so im trying to get all the inspriration i can get. If I think of something genius, i’ll let you know. Thanks a bunch for the ideas!

  • Profile picture of enum enum20p said 3 months, 2 weeks ago:

    As I said already I like even your normal graphics very much and now it’s really great.
    And thank you for sharing your ideas.

  • Profile picture of androlo androlo329p said 1 month ago:

    I find that your clouds look very good. As does your whole project. Looking forward to more reports like this.

    I just want to ask about the cloud perspective (or lack thereof). What made you choose that particular method? It just seems very hard to get multiple cloud levels etc. to work well. Have you tried a skydome instead? And in that case, why did you choose a sky box instead?

    If you haven’t seen it, here is an example of typical skydome clouds with proper perspective. I just made a hemisphere with blue background and a low res noise texture for clouds (so they look flat and awful), but you can at least see how it works.

  • Profile picture of androlo androlo329p said 1 month ago:

    Here, two layers. Super easy.