3D Game Programming All in One (Course Technology PTR Game Development Series)
You probably noticed when you were editing the Emaga6 MIS file that there was an object defined in there called "Sky". There are lots of goodies in that object for us sky worshipers.
Here it is:
new Sky(Sky) { position = "-1088 -928 0"; rotation = "1 0 0 0"; scale = "1 1 1"; materialList = "./sky_book.dml"; cloudHeightPer[0] = "0.349971"; cloudHeightPer[1] = "0.25"; cloudHeightPer[2] = "0.199973"; cloudSpeed1 = "0.0002"; cloudSpeed2 = "0.0004"; cloudSpeed3 = "0.0006"; visibleDistance = "1100"; fogDistance = "1000"; fogColor = "0.820000 0.828000 0.844000 1.000000"; fogStorm1 = "0"; fogStorm2 = "0"; fogStorm3 = "0"; fogVolume1 = "500 0 100"; fogVolume2 = "0 0 0"; fogVolume3 = "0 0 0"; windVelocity = "0.1 0.1 0"; windEffectPrecipitation = "1"; SkySolidColor = "0.547000 0.641000 0.789000 0.000000"; useSkyTextures = "1"; renderBottomTexture = "0"; noRenderBans = "0"; locked = "true"; };
We have already encountered the MaterialList property and have seen that it is used to point to a file that contains the names of the images that will be displayed on the interior faces of our skybox.
Not all of the properties in the skybox are particularly interesting; they owe their presence to Torque's beginnings as the code that drives the Tribes 2 game. The position, scale, and rotation properties don't accomplish much when you use them—they are there because all objects have those properties whether or not they are meaningful.
The cloudHeight properties are useful, and we will cover them in the next section. The same applies to the properties for fog.
One of the most useful properties is visibleDistance. This property specifies the distance, in world units, beyond which the terrain and all game objects will not be rendered. This is a useful, though rather ham-handed, method for increasing frame rates in game worlds that have many objects present. In conjunction with the fogDistance property, this sort of simulates the concept that all landscape artists are familiar with that objects become hazier and harder to see at a distance. This is because there is simply more atmosphere between you and the objects you are viewing in the distance, and the greater the distance, the more the air obscures your view. This effect is a well-known one called atmospheric perspective. The great Leonardo Da Vinci studied this effect quite a bit back in the 15th and 16th centuries—he called it aerial perspective.
By exaggerating this effect we have a useful mechanism to reduce the number of objects that the video card needs to render, and this improves your frame rate.
The fogDistance property specifies the distance from you that the haziness we just talked about begins. The distant fogginess starts at this point and gets thicker as the distance increases, until the visibleDistance is reached, after which nothing is rendered. By using these two properties, you can prepare a game world where there is a natural-appearing haziness that slowly obscures distant objects until they disappear completely.
Note | You should always make sure that visibleDistance is a bigger number than fogDistance, otherwise you risk crashing the game engine in clients in certain situations. In fact, for the sake of safety, always make sure that visibleDistance is at least 50 units larger than fogDistance. Less than that is not really useful anyway. |
If you don't want to use a skybox, there is the SkySolidColor property, which you can set. Then you will get a uniformly colored sky all around with a band of changing color near the horizon to simulate the lightening effect we see—something like the gradient we made for our skybox. In this case, to disable the skybox, set useSkyTextures to 0 or False. Set noRenderBans to 0 or False to enable the simulated horizon coloring, and set it to True to disable the coloring.
You can also just prevent the bottom image in the skybox from being rendered, or considered for rendering, by setting renderBottomTexture to 0 or False. This might eke out a frame or two of frame rate for you.
The windVelocity and windEffectPrecipitation precipitation properties have no effect on their own. They are used in conjunction with the storm effects we will cover later.
Категории