Difference between revisions of "Apron lighting using effects and GMax"

From FSDeveloper Wiki
Jump to: navigation, search
 
Line 1: Line 1:
 
====== Using GMAX to Create Apron Lighting using Effects ======
 
====== Using GMAX to Create Apron Lighting using Effects ======
  
{{tutorials:gmax:apronlights.jpg}}
+
[[Image:apron.jpg]]
 
 
 
 
  
  

Revision as of 15:19, 28 September 2006

Using GMAX to Create Apron Lighting using Effects

Apron.jpg


Introduction

There has always been some confusion regarding the limitations of placing effects as ground lighting in Flight Simulator. This document gives you complete and correct information regarding these matters and should ensure better scenery from all of you! Detailed below are my and other peoples findings summarized into one document.

Should you have a suggestion for the document, I would appreciate if you could comment on the forum first before changing here.

Thanks

Nick Whittome




Previous requirements
 * Knowledge of GMAX
 * Knowledge of Creating Effects files
 * A lot of patience ;)
 * At least one beer per hour.













Creating an Effect

Before creating an effect, you have to undertand a problem that happens with effects. When you start Flight Simulator outside of the spawn area, you get to the airport and you have no effects. What's happening is that the model is spawning outside of the radius that the effects work, which means that the model spawns, the effects say "Oh I'm nowhere near the plane, I'm not going to draw" and then the effects don't respawn because they were a one-time effect with infinite lifetime.

You have two options.

Emitter Workaround

The first option is to set the lifetime of the emitter to 0 in your effect file. Look for:

[Emitter.0] Lifetime=0.00, 0.00

However, it should be noted that when you use this method if your **framerate drops** the **lights will get brighter** if the effect overlaps.

Controller Workaround

The second option is to use a controller file. There was a lot of discussion on this top on [thread]. I am now **certain** that the following instructions work, I have tested them a few times now.

What you want to do is create a static effect much like the plane navlights, use fx_navwhi.fx as a template. (This will eliminate the brightness problem with frame rate fluctuations) and then create a proximity controller that triggers the effect within the radius of the model instantiation.

So what happens is the controller tests proximity and creates the effect right after the model is created. In the sample below, I spawn the navwhih effect 10km out. I tested this by placing the effect in Westport (on the Washington coast) and then started my flight in Olympia (about 60 miles away). The effect was there when I got there. You could probably adjust the distance out even further as well. Here's the controller snippet to use:

[Library Effect] Lifetime=5 Version=1.00 Radius=200

Priority=0

[controller.0] lifetime=0.0, 0.0 type=3 distance=10000.00, 10000.00 delay=10000000.00, 10000000.00 x offset=0.00, 0.00 y offset=0.00, 0.00 z offset=0.00, 0.00 effect.0=fx_navwhih, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00

As you can see, **type 3** controller is proximity, which means the effect will trigger when you are within **[distance]** of the effect. In this case, 10,000 meters. The delay set to 10000000.00 means that the controller will not trigger the effect again until 10000000 seconds have passed (and who's going to fly that long really). Therefore it triggers a single instance of the effect when you are within 10,000 meters of the effect. The only possible problem with this solution is that if you go outside of the radius of the effect and unload it, you might not get it back again. But, if do that, the model will also unload, and then reload when you get within range.





Drawing your light boxes

After you have created your ground / apron in GMAX or another program, set that as your background in a **NEW** gmax file. Obviously, if you used GMAX this will be really easy as you simply copy your ground / apron file and place it in the same location in the scenery XML.

The reason for the new file is that you can export your lighting as a seperate MDL to your ground layout, and then you can use MDLTweaker to set display parameters for that MDL. This means that you do not need to create effects parameters because you can turn "on and off" your entire MDL. The other advantage of a seperate MDL file will be the fact that you can also create LOD files for you lights which we will get into later.

Now. Here is the time consuming part :)

 - Create a box, whatever size you want.
 - Do **not** rename the box OR attach anything yet!
 - Convert the box to an Editable Mesh, and then duplicate this box.
 - Everywhere you want to place a light, put a box.  (You may want to lift the box up a tad....)
 - **SAVE** your GMAX file and Archive this file as "Pre Effects attachment" or something simular.  Never touch this file again :)









Placing the Effect Methods

Using the Attachtool Script

You can use the attach tool that Microsoft kindly supplied. This can be a time consuming method as you **must** run the tool against every object separately. In fact, the more I think about it... you would be crazy to place this many lights using this method :) Forget I even wrote this.... unless you are a glutton for punishment.

Placing the Effect using a script for multiple objects

Thanks to a GMAX guru I know, the following script will take every object that is named **box_whatever** and will attach the effect of your choice with a little editing. When I get a chance I will get it to actually prompt you for the effect name and also ask you what the last box number was that you applied to (therefore you can run over and over again).

    • [this GMAX Script]** Then edit it as required. The information you will need to change is pretty obvious, but I shall explain.
 * The **strAttachNumber = 0** is a starting number that will count up as it applies to the boxes.   **IF YOU EVER NEED TO RUN THE SCRIPT TWICE YOU MUST CHANGE THIS NUMBER**.   The reason is simple, no attachpoint can have the same name otherwise it will not show in your scenery.   So, if you add more boxes, then need to run the tool again, you must set this number to the last attachpoint number to ensure a new set of unique numbers.  (Wow, that was a mouthful)
 * The ("attachpt_**MyEffectName** is the name the box will become.  Never change the attachpt_ part, only the **MyEffectName** part.
 * The next line is the data that will be written into the **User Properties** for the attachpoint.  You can edit as required.  You may want to add parameters, or simply change the **fx_MyeffectName** part to your **FX** file name

Simple eh ;)




Creating a bounding box

Once you have placed all of your lights and have attached your effects, you **must** create a transparent bounding box around the entire set of lights / boxes. To do this simply draw a box, and ensure that it encompasses all the boxes / lights, and then apply a standard texture. Once that is done, set the texture to "0" opacity, then convert the box to an Editable Mesh.


Exporting to Flight Simulator

Export the Boxes (now named attachpt_whatever) and the bounding box to a MDL file. Place this MDL file in the usual manner.

I would strongly suggest that the lights are placed a little above the ground as this will stop the flickering of the lights.

You may, of course, want to edit the MDL parameters using the MDLTweaker tool before compiling to your BGL library. You should now have ground lighting!


Oh No! I cannot see all my lights - Effect.cfg

Due to a limitation in the FS Game engine, you need to add a file called **effect.cfg** into your Effects folder to ensure that all your lighting shows up. (There is, of course, a MDL limitation of about 2000 objects - but this is not what I am referring to here).

The file must contain:

[Sprite Limit] Medium=500 High=9999999999 Low=100


Limitations that you may have to overcome

Scenery Excludes and Library Objects with Attached Effects

There is a "feature" of the Flight simulator Exclude XML that causes effects to dissapear if you exclude Library Objects. What this means is that the RefPoint of your excluded MDL must NOT have an exclude that includes Library Objects. The best method is to create small excludes around object you want to get rid of.

View Limitation of the Effects

There is a limitation on the view distance of an effect. For apron lighting this should not really matter, but if you are creating runway lights it may. The answer is to create LOD's of your placed effects and use a "brighter" effect on each LOD. The way you give this impression of brightness is to actully increase the size of the effect itself. This way, the lights show up at a distance.

Effects and how they affect framerates

Effects, IMHO, have very little effect on framerates.... but they DO have an effect. There has been a few threads on the forum regarding this subject.

//(Is it affect, effect or what? - the dictionary does not help here)//

It's indeed "effect". Affect is a verb, generally. Of course, so is effect sometimes. Gotta love English ;-)

Limitation of 2000 attachpoints per GMAX export

If you are creating a ground layout of lets say 1000 Effects, and then you lay down those effects again for night=1, again for dusk=1 and again for dawn=1 you now have 3000 attachpoints. You will get an error of "Too Many Objects" when exporting using MakeMDL.

Now... here is a "gotcha" as well... if you had this GMAX scene, with these 3000 objects and selected only 1000 of them for "Export Selected" **this will still fail!**. The reason is that MakeMDL will ALWAYS try to export any attachpoint in your scene, even if you did not select the object that those attachpoints were attached to. Get me? :)

The workaround is simple. Create 3 GMAX files, one for each set of 1000 attachpoints, and export them as seperate MDL files. Then, place all these MDL files in the same location. Problem sorted! :)






Document Version Information

20th October 2005 - Initial Headers added and initial section text. --- //Nick Whittome 2005/10/20 21:17//

20th October 2005 - Added more content. --- //Nick Whittome 2005/10/21 00:04//

20th October 2005 - Added GMAX Script and explaination of same, and more sections for future content. --- //Nick Whittome 2005/10/21 00:30//

21st October 2005 - Added limitation detail. Cannot figure out Affect / Effect... but from what I am reading in the dictionary I am right. --- //Nick Whittome 2005/10/21 13:58//

1st November 2005 - Added effect.cfg workaround and noted that the effects should not be placed directly on the ground. --- //Nick Whittome 2005/11/01 19:58//

6th November 2005 - Added "Limitation of 2000 attachpoints per GMAX export" section. --- //Nick Whittome 2005/11/06 16:32//