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.
#21
10/29/2005 (11:16 pm)
So has anyone got the multiplayer working with this resource?
#22
10/31/2005 (4:21 am)
Stephen, I don't think any of us have had the time or intrest as we're all on single-player projects, and working on other bugs/features with this resource.

If you want networking/muliplayer, then why don't you figure it out and then submit it back so others can benifit?
#23
10/31/2005 (11:37 am)
Hrm.. well because I dont know any C++. Well I guess I wont use this resource.
#24
10/31/2005 (3:25 pm)
@ Stephan (and anyone else intrested in networking):

I supose thats as good a reason as any, though if you have any interest in learning I would HIGHLY reccomend "C++ How to Program" by Deitel & Deitel. This is what I keep by my side.:

http://www.amazon.com/exec/obidos/tg/detail/-/0130384747/qid=1130799853/sr=8-9/ref=pd_bbs_9/103-1495105-7138206?v=glance&s=books&n=507846


My last comment, I wasn't saying to be mean, I'm just pointing out that thats how these resources evolve. It'd be great if this resource DID support mulitplayer. If someone sends me an update, I will happily post it, but no one's contacted me as of yet.

Unfotunetly I know nothing about TGE networking, and the only time I intend to touch it, if at all, is to take it OUT of my engine. Therefore I can guarantee I personally won't be doing anything in that area for this resource, even though there's other things like weather effects and lighting I'm continueing to working on.

Again not trying to be mean, just being bluntly honest, so take it at face-value. I don't want to see you wasting your time waiting for a feature that is not in development. I heard a rummor about another upcoming resource called Night Cycles that is supposed to be good. Try checking into that.
#25
11/01/2005 (10:10 pm)
Hmm, it shouldn't be too hard to put the timekeeping code in the server. Then have the client update it's time from the server to determine where to put everything....
#26
11/03/2005 (7:05 pm)
I would be really glad if someone will add multiplayer with this resource. I have been waiting for a resource like this but with multiplayer.
#27
11/06/2005 (8:38 am)
Ahhh I just wrote out a big post and the site erased it when I clicked on "notify when new comments..."

Anyway. This looks like an awesome resource but I'm having problems getting it to work properly. I'm running TGE 1.3 and successfully got the time/weather system (GameManager) to work. However I can't get the dynamic sun to work. I followed the installation instructions to the letter (twice!) but whenever I run the game I always have a static sun that's high in the sky and doesn't move, even though the time and weather change.

I tried to automatically apply the patch but was getting a ton of errors, so I did it manually, and it all compiled fine, just no dynamic sun, it's as though I didn't add any dynamic sun code at all. Has anyone ever run into this kind of problem before? I'm new to Torque and fairly new to c++ but still, according to the instructions I did everything right, just no go. Can anyone help? :) I'm really looking forward to getting this to work properly.

Thanks!
#28
11/09/2005 (8:16 pm)
@Jamie - just saw this post. I feel like I know the answer to this but it's not coming to me right now. Let me think on it.

In the mean time, make sure you have the correct type of sun datablock in your .mis file. I know i put it in the docs somewhere, it's a long one.

I'm sorry the 1.3 patch didn't apply cleanly automatically. It was supposed to be backwards compatiable to 1.3 but I couldn't test it. Did you see alot of conflicts when you did it by hand?
#29
11/09/2005 (9:40 pm)
wrong forum - disregard please.
#30
11/10/2005 (7:17 pm)
Hi RavenSlay3r, I'm heading away for the long weekend but will go through it in more detail and post about it on Sunday night. When I did the patch by hand it seemed to go through fine... but I may be remembering wrong, I'm quite tired atm.. :)
#31
11/12/2005 (12:01 pm)
@S.Beasley - Did you ever get anywhere with the fractal sky integration?

@Jamie - Check to make sure you did the changes to fxSunLight.cc correctly - it's around line 1400 and goes like this:

// Adjust Azimuth/Elevations.
		mTempElevation = 90.0f - (mTempElevation - 90.0f);
		mTempAzimuth += (mTempAzimuth >= 180.0f) ? -180.0f : 180.0f;
	}

	//--- Celestial Patch Changes ---//
	// Consult celesial management <sami>
	F32 Yaw, Pitch;
	if(gCelestials != NULL)
	{
		gCelestials->UpdateSunPosition();		
		mSunAzimuth = gCelestials->getAzimuthDegrees();
		mSunElevation = gCelestials->getElevationDegrees();
		Yaw = gCelestials->getAzimuthRads();
		Pitch = gCelestials->getElevationRads();
	}
	else
	{
		Yaw = mDegToRad(mClampF(mTempAzimuth,0,359));
		Pitch = mDegToRad(mClampF(mTempElevation,-360,+360));
	}
	// end <sami>
	//----- End Celestial Patch -----//

	// Create clamped Yaw/Patch and calculate sun direction.
//	F32		Yaw = mDegToRad(mClampF(mTempAzimuth,0,359));
//	F32		Pitch = mDegToRad(mClampF(mTempElevation,-360,+360));
	MathUtils::getVectorFromAngles(SunlightOffset, Yaw, Pitch);

	// Get Control Camera Eye Position.
	Point3F eyePos;
	MatrixF eye;
	GameConnection* conn = GameConnection::getServerConnection();
	conn->getControlCameraTransform(0, &eye);
	eye.getColumn(3, &eyePos);

Coincidently I've been playing with the central paragraph there, trying to force it to use the mSunAzimuth and mSunElevation from the fxSunLight datablock as an offset to the info it gets from gCelestials.

The thinking being, that would allow me to "customize" the position of each sunlight-datablock allowing for multiple suns/moons/planets etc. So far have had less than NO luck!.

Open to ideas...
#32
11/21/2005 (11:30 pm)
@Jamie, did you ever fix your issue? I saw in the original celestial thread Don Bates had a similiar issue.

His problem was he had this line in the wrong spot:
MathUtils::getVectorFromAngles(SunlightOffset, Yaw, Pitch);
#33
11/22/2005 (6:04 pm)
Hi there, sorry for not posting about this for a while, I wasn't meeting with success so took a few days' break from it until coming back to it tonight. Thanks for the link to the original celestial thread, it seems I haven't been able to resolve the issue yet though. I started out again from scratch, from a brand new install, and it's the same thing. Specifically, this is what happens:

After I make the changes to the files in Eclipse as outlined in the patch file (I use the included sky.cc and sky.h files), I rebuild the project (I'm using the default starter fps game), and these are the last few lines of the output when it's finished compiling:


--> Linking buildWad.exe
--> Compiling texture2bm8/main.cc
--> Compiling texture2bm8/svector.cc
--> Assembling texture2bm8/vector.asm
--> Linking texture2bm8.exe
make[1]: Target `all' not remade because of errors.
make: *** [tools] Error 2
make: Target `all' not remade because of errors.


The torqueDemo.exe is in fact created, and when I go to run it, the splash screen and the main screen come up, but when I click on "launch mission" I immediately get the "please tell microsoft about this problem" error:


torqueDemo.exe has encountered a problem and needs to close. We are sorry for the inconvenience.


When I debug it in visual c++, this is what comes up:


Unhandled exception at 0x0040d2f2 in torqueDemo.exe: 0xC0000095: Integer overflow.


Being fairly new to c++ I have no idea what this means besides the fact that there's an error :/ When I click on "view dissasembly" the following line is arrowed:


0040D2F2 div eax,dword ptr [ecx*4+645A74h]


I noticed that the line: "MathUtils::getVectorFromAngles(SunlightOffset, Yaw, Pitch);" doesn't have to change location though, since the patch file indicates:


// Create clamped Yaw/Patch and calculate sun direction.
- F32 Yaw = mDegToRad(mClampF(mTempAzimuth,0,359));
- F32 Pitch = mDegToRad(mClampF(mTempElevation,-360,+360));
+// F32 Yaw = mDegToRad(mClampF(mTempAzimuth,0,359));
+// F32 Pitch = mDegToRad(mClampF(mTempElevation,-360,+360));
MathUtils::getVectorFromAngles(SunlightOffset, Yaw, Pitch);


The only other thing I can think of is the line: "exec("./gm_KeyBinds.cs");". It didn't say specifically into which section of default.bind.cs to include it so I first tried it in the misc section, then tried it in a few other locations. I don't think it actually makes a difference but perhaps I'm wrong :)

I'm running version 1.3 without the lighting pack. I'll have to rack my brain at work tomorrow... :)
Thanks,
Jamie
#34
11/24/2005 (12:28 pm)
tried to apply this on TGE 1.4 - no luck... on mission load get "Object did not call SimObject::onAdd()" in console\simmanager.cc @ 420

Any ideas?
#35
11/30/2005 (8:15 pm)
Anyone done any work on porting this over to TSE?
#36
12/07/2005 (1:43 am)
i try to implemet this but i am getting Integer Overflow error when game load
i check console and i get this error

starter.fps/server/scripts/weather.cs (427): Unknown command setPercentage.

but i don't think problem ie boz of this.
When i try to run the program without GameManager it is working fine
#37
12/07/2005 (1:52 am)
Vishal, try searching for "setPercentange" in sources (file: engine/game/fx/precipitation.cc) and change it to "setPercentage". Rebuild.
#38
12/07/2005 (2:30 am)
The sun is put, but the moon is not born, why?
#39
12/09/2005 (4:43 am)
how i can darken my interiror and tree in night mode
#40
12/19/2005 (3:27 pm)
@Vishal: I haven't been able to fix the interiors and trees either yet. Supposedly Steven Beasly got it in 1.4, try following his instructions above.

@Juan: I tried adding a moon myself by adding a new fxSunLight object. Turns out you can only have one celestial body object.

@bank: sorry no ideas, don't think i've seen that before.

@all: Forget if i mentioned it above but if you check my .plans and my website I'm starting work on Enviro-Torque 2.0 for next year. It's going to be a ground-up rewrite targeted for TGE-1.4. Hopefully it will address most of these issues including various day/night bugs, multiple celestial bodies, network support, easiser installation, etc.

@Nathan: Once I nail down 2.0 and am really happy with it, there's a strong possibility for a TSE version. But I wouldn't expect it before summer or fall at this point. It's somthing I would really like to do, but I have alot of stuff that has to get done first.

For TSE: I know some stuff would have to be completely re-written to adapt to (and take advantage of) the shader technology. In the case of shadows this would be a huge gain. I don't know how extensive or difficult these changes would be - but I'm not expecting it to be a trivial port.

@Whoever asked - I don't think in the current verison of this resource you can offset the sun's starting position, aside from changing the long., lat. and axis-tilt.

@all:
Sorry I can't be more helpfull, but alot of the problems with this resource seem to be design issues that I inherited from the dependencies. So the answer to just-about-everything is going to be "wait for the next version"... :-(