Game Development Community

dev|Pro Game Development Curriculum

Enviro-Torque

by Steven Peterson · 10/16/2005 (12:33 am) · 89 comments

---------------------------------------------------------------------------------------------------------
Authors Notes:
---------------------------------------------------------------------------------------------------------
This is my first patch. I did not have a lot of time to detour from my project to work
on it but I wanted to make a contribution. I hope you find this useful, and that
as you find improvements - you will submit them in return. It is good, but not perfect.

If you e-mail me (email in profile)
new patch files I will galdly add them to the resource. I hope to do another
maintenance release based on the comments below in a couple months,
but probably not till Q1-2006. (unless it's something HUGE ;-)

Enjoy!

(edit: June 28th, 2008 - Things got moved around on my website recently. This resource link has now been updated, to point to the correct location.)


-----------------------------------------------------------------------------------------------------------

Current Resource File:
----------------------------
envTorque-1.zip

Original Sources:
------------------------

GameManager Resource


Celestials Day/Night Cycles Resource

Dynamic Skies Forum Thread

Works With:
------------
This should patch to:
- TGE 1.3
- TGE+Lighting Pack (1.3.5)



Justification:
--------------

I'm new to Torque and found the above three resources incredibly
usefull. I also found them severely out of date. The mod was easy to
get working but the patches were a bear to merge by hand, bug-fix, and then
integrate into each other.

I figured that the three of these resources went together logically and
there was no reason for someone to go through the work I did all over again.
I was also afraid that if no one put out a maintenance release to any of them,
they would be lost to the sands of time when TGE 1.4 rolled around.

So here it is -


Included
------------
- Stand-alone "GameManager" mod - updated
- Enviro-Torque patch/mod


What Is Enviro-Torque
--------------------------------
Good Question.

Enviro-Torque has 3 components:
- Celestial day/night cycles with seasons
- Fractal Skies for dynamically generated sky patterns
- GameManager Date/Time and Weather system

I did not write any of them. I simply updated them to patch with the
current version of Torque, added in all the known bug-fixes and combined
them into one larger system. Some minor new features made it in too. :-)

You can read about the gameManager in detail in the (included)gameManager.txt file.
It's most important purpose is to bring dynamic weather into the mix.

The Celestial portion of the patch implements a sun that rises and sets
and moves with the seasons, as does the real sun. It also colors the sky,
terrain, and objects based on the time of day, and makes it get lighter/darker out.

The Fractal skies is a feature that creates a random sky pattern
using a fractal calculations. It is good for very light clouds. It can be turned
on/off with the:
FractalSky = true/false
at the top of sky.cc


Work In Progress
-----------------

One of this resources goals have yet to be accomplished: The GameManager
turns clouds on/off based on the weather. Unfortunately a "clear-blue" sky looks
fairly freakish in torque.

The FractalSkies is excellent for giving just a wisp of clouds.
With a little more tweaking, it should be perfect for texturing the sky on a
"clear" day without making it look overcast.

Then on a cloudy day we want to turn "on" or switch to our normal
.bmp storm clouds. This switch is what I'm currently stuck on.

For now you can select whether you want to use FractalSkies or
.bmp skies on a 'cloudy' day using the true/fals value listed above.

Last note, this is a living resource. If you submit fixes I will try to
update it from time to time. thx.




Current Status of Resource:
---------------------------

CRITICAL BUGS REMAINING:

- Need to finish dynamic weather integration with fractal-skies
- - Very Light clouds for "clear skies"
- - Big storm clouds for "story skies"
- - - (w/ or w/out fractal)

- If the weather is "clear" at game initialization, it mistakenly shows a
cloudy sky. It will abruptly fix itself when the sky changes to "cloudy".


NON-CRITICLE BUGS:
- Player and objects remain 'glowing' at night
- - Only a partial fix is available for this, and it's BAD.
- Terrain Shadows don't move - Apparently this has NEVER been an included feature...


OTHER-ISSUES:
- (?)

FIXED:

NOTES:
- Chances look good for a 1.4 if I release soon.
- - Any Takers?
- I don't believe this version has network support. sorry.
Page «Previous 1 2 3 4 5 Last »
#1
10/16/2005 (1:31 am)
Without network support I can't possibly use it, but you had me until then =0
Not to seem overly critical, this is an awesome resource.
#2
10/16/2005 (7:39 am)
URL link does not seem to work properly for me.
#3
10/16/2005 (12:57 pm)
Here's another link for envTorque. It works!
#4
10/16/2005 (4:23 pm)
There actually is a resource for moving the terrain shadows as well. At one time, I had it integrated with a few of the systems you've merged. The resource is one of the older day/nights, and probably I found it in the forums. It really just loaded/unloaded pre-made mission lighting files.
#5
10/16/2005 (6:08 pm)
I hope someone fixes this resource so that it works in multiplayer.
#6
10/18/2005 (8:11 am)
Just wanted to post, and say that I got this integrated with 1.4 RC2, it's a great resource, the only thing that I see as an issue is sometime the fractal clouds blow one direction and the precipitation is falling in random directions. It looks like you are trying to update the clouds direction, but it doesn't appear to be happening. Slowly changing cloud direction would be great, otherwise it should follow the clouds for now

Great resource by the way.

I've also added snow, and debris start and stop functions and they seem to work pretty well. I need to tweak them a bit, and I must say with the rain, lightning, and the debris flying it makes quite a cool effect. :)
#7
10/18/2005 (8:21 pm)
I think I fixed the issue with static shapes

Pic

At around line 762
void TSMesh::setMaterial(S32 matIndex, TSMaterialList* materials)
{
	if(gCelestials)
	{
		//make mesh darker at night
		ColorF dn = gCelestials->mCurrentColor;
		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
		glColor4f(dn.red, dn.green, dn.blue, 1);
	}

Okay now the only issue is the tree itself doesn't actually darken it appears, and if it does it is very slight. Any thoughts on this would be great. Oh this is a replace of the code that had the snapping effect, and I believe you still have to apply the fxFoliageReplicator code section as well.

I don't have the lighting pack so maybe this looks better with it.
#8
10/19/2005 (8:31 am)
Hey all,

First sorry for the bad link. From resource-submission to approval there was about a 2 week lag, in which the link changed... Should be fixed now.

If anyone want the full history paritularly regarding lighting/shadow problems and multiplayer be sure to read the original resource threads - specifically:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5417

I'm doing a 1-semester senior project, by myself, so no time to worry about multiplayer network issues. If someone gets it working I'll be glad to update the resource.

@Beasley - I'll drop in this code and try it - this week or next. I don't actually have static shapes OR trees in my game yet so it was hard to test. Best thing I can say now is find a middle ground to the tree's ambient light so it looks ok under both settings.

I'm going to be taking another look at that code eventually, so maybe between the two of us we can track down the problem. If anything the lightingpack will exaggerate the problem :-(
#9
10/19/2005 (3:40 pm)
@Beasley:

In your shot it looks like theres ferns on the ground. I noticed a similar effect of no-collision grass off to the right side of the lake in the original TGE-1.3 demo.

Are you doing the same thing? and what's it called or where can I read up on it?
#10
10/19/2005 (3:53 pm)
RE: clouds/wind

It's written to randomly update the wind velocity(speed + direction) on rain-start. This should shift the clouds, rain and other particle effects consistantly. I know it works with the bmp clouds, I'll look at fractal clouds again.

On my latest itteration I set the wind randomly in "initWeather()" and then shift it '0' or '1' points on '0' or '1' axies as a part of "updateWeather()";

It's not release ready yet, but when I'm happy I'll update the resource.
#11
10/19/2005 (6:55 pm)
It is just a simple fxFoliageReplicator, and yes it highlighted and dimmed appropriately. It appears that all the billboard stuff is now working correctly.
#12
10/19/2005 (7:30 pm)
Okay I've figured it out. meshes like trees now get dark when it gets dark out, and the lighting follows the sun correctly as well.
Drop this bit of code in and you are set with the meshes.

in sun.h add the line in bold
class Sun : public NetObject
{
   private:
      typedef NetObject Parent;

      LightInfo      mLight;
      [b]LightInfo      mbLight;[/b]

      void conformLight();

in sun.cc basically replace the guts of registerLights with
void Sun::registerLights(LightManager * lightManager, bool)
{
	[b]if(gCelestials)
	{
		F32 i = gCelestials->GetIntensity();
		mbLight.mDirection.set(-gCelestials->mSunVector.x, -gCelestials->mSunVector.y, gCelestials->mSunVector.z);
		mbLight.mColor = gCelestials->mCurrentColor;
		mbLight.mAmbient.set(mLight.mAmbient.red * i, mLight.mAmbient.green * i, mLight.mAmbient.blue * i);
	}
	else
		mbLight = mLight;
	lightManager->addLight(&mbLight);[/b]
}
#13
10/20/2005 (1:31 am)
Hmmm - this all works for you? I'm not getting the expected results at all. I added in your 3 pieces of code and turned on the thing in fxFoligeReplicator but no change for folige or static shapes. Could be the LightingPack I suppose.

The LightingPack patches registereLights also, but if we use their variables and put the Celestials first they shouldn't conflict. This is what I thought it should look like.

Guess I'll play more tomarrow.

void Sun::registerLights(LightManager * lightManager, bool)
{

   //--- Celestial Patch Changes ---//
   if(gCelestials)
   {
      F32 i = gCelestials->GetIntensity() * .5;
      mbLight.mDirection.set(gCelestials->mSunVector.x, gCelestials->mSunVector.y, 
gCelestials->mSunVector.z);
      mbLight.mColor = gCelestials->mCurrentColor;
      mbLight.mAmbient.set(mLight.mAmbient.red * i, mLight.mAmbient.green * i, mLight.mAmbient.blue * i);
	  mRegisteredLight = mbLight;   
   }
   else
      mRegisteredLight = mLight;   
 
   	//----- End Celestial Patch -----//
	
	
   //-----------------------------------------------
   // Lighting Pack code block
   //-----------------------------------------------
   mRegisteredLight = mLight;   
   sgLightManager::sgGetFilteredLightColor(mRegisteredLight.mColor, mRegisteredLight.mAmbient, 0);
   lightManager->addLight(&mRegisteredLight);
   //-----------------------------------------------
   // Lighting Pack code block
   //-----------------------------------------------

}
#14
10/20/2005 (3:36 am)
You are overriding your changes, because you are setting the mRegisteredLight = mbLight;, which is good, then then next code execution is to override it with mregisteredLight = mLight;

you will want to comment out that next bit of code.
//-----------------------------------------------
   // Lighting Pack code block
   //-----------------------------------------------
   [b]//mRegisteredLight = mLight;   [/b]
   sgLightManager::sgGetFilteredLightColor(mRegisteredLight.mColor, mRegisteredLight.
mAmbient, 0);
   lightManager->addLight(&mRegisteredLight);
   //-----------------------------------------------
   // Lighting Pack code block
   //-----------------------------------------------

Also atleast the way I have mine set up, and I followed yours to the T the suns reflection on the trees was backwards, maybe this is the difference between 1.3 and 1.4 or maybe the TLK fixes it I don't know, but to get the light to show up on the tree correctly I had to make sure I negated the x and y values in mSunVector.

I do plan on getting the TLK soon, especially for the Night Cycles. Ahh they make me druel.
#15
10/20/2005 (6:46 am)
Has anyone had any luck getting this to work with TGE 1.4? I replaced the sky.cc/.h in 1.4 with the one in the Enviro-Torque resource, and added the Celestial.cc/.h files. Everything compiled fine, but I received an error message and a crash when starting my mission. I tracked down the crash to the Celestial::onAdd function, which was missing this bit of code which I added:
if (Parent::onAdd() == false)
         return false;

// The rest of the function goes here!

This fixed the crash and after that it seems to run. At least, weather/time is updated correctly. However, my sun doesn't move in the sky, my clouds don't seem to dynamically change, and I get no darkness at night. I think the cloud issue MIGHT be my own issue, as I noticed a few days ago I no longer have cloud layers, even though they are turned on. When I start a new mission, though, I have layers. So it seems to be mission related. Very strange.

Anyways, this resource now somewhat works with my mission in TGE 1.4, but if I try starting a new mission (so I could see if the clouds dynamically change in that) TGE crashes without any error messages or console messages (I guess I need to debug this to try and figure it out). This happened both with the Celestial section in my .mis file and without.

I guess perhaps the sun not updating position issue might be that TGE 1.4 modified sky.cc/.h and I replaced that version with with a modified 1.3 version, and thus broke something in 1.4.

I'm also curious as to whether I should be seeing darkness if I don't have TLK, or is TLK required for this to work?

Update:
I just noticed your post, Steven. Can you share what you needed to do to get this to work in 1.4?

BTW, snow was one thing I was going to add to this resource. Did you actually implement temperatures based on latitude along with the current season, and current time (ie, it gets colder at night)? I'd LOVE to get the modifications you made. =)
#16
10/20/2005 (3:42 pm)
Doesn't work for me. Also tried replacing all the mbLight with mLight - use one variable, and elimiate the need for an "else".

Either way it either everything is black, or what is facing the sun (when rendered) looks 100% and whats away from it is black. Different results each time.. Nothing was changing. Although sunposition would update it'self if i kept hitting the re-light button.

Tested different things for several hours but nadda. I'm glad you got it working though, mabye they fixed somthing in 1.4 that lets this work.
#17
10/20/2005 (5:26 pm)
@Raven:Do you have a Sun in your mission file, if now put this in

new Sun() {
	azimuth = "45";
	elevation = "35";
	color = "0.888000 0.885000 0.780000 1.000000";
	ambient = "0.400000 0.400000 0.400000 1.000000";	
	rotation = "1 0 0 0";
	position = "0 0 0";
	scale = "1 1 1";
	direction = "0 0 0";
};

Also if you eliminate the mbLight, then you loose your reference point and things get out of whack in my experience.

@Robert Geiman: I'm working on the latest 1.4, and what you want to do it do a merge between the 1.4 source and the enviro pack. A good tool to use if you are on a win platform is an open source program called WinMerge.
#18
10/20/2005 (10:48 pm)
@Beasley
I see what you mean about the reference point. I'll try it again later, by setting mbLight = mLight right before I use it. I think I missed that combination.. In fact I might go back and try to get the "Light-Snapping" working again, and then build up from there.

Yeah I got a sun, lol. Thanks though :)



BTW:
I just noticed today that celestial takes in the datablock values for tilt, lat. and long. in degrees and then converts to radians and it gets saved back to the datablock that way. It doesn't SEEM to be causing any problems though, as i've been using this for 6 weeks and just noticed it now... Thought i'd point it out though.
#19
10/21/2005 (11:30 am)
Steven, thanks for the tip. I'll give that a shot when I get some more time!
#20
10/27/2005 (9:11 pm)
Has anyone noticed problems with celestials and water-specularity? I think it might be part of my known lighting issue, but i'm not seeing any..
Page «Previous 1 2 3 4 5 Last »