Creating your first Airplane by Brsseb
Preparing for the lesson
Yes, now im back and its finally time for airplanes! First things first..you need these skills and programs to do this tutorial:
There is already a good Airplane tutorial on the net (Building the Piper Cheyenne). Its not done yet and it focuses on modeling an airplane from start to finish (from blueprint setup to final model). In my tut, which will be a abit shorter, I will focus just on the LOD (and config) setup needed to get an airplane model working properly in OFP.
Ok, lets move to next page and have a look at the tutorial model…(drumroll…)
Ok, i know that if you have followed the other tutorials, you know that I don't make proper models for my tuts. I make them as simple as possible so that its easier to see i.e important vertex placements on my screen shots (hard to understand a 3d mesh view with 2000+faces in the background…) and for the fact that I don't want to use too much time on simple example models. So here it is, in all its glory:
The model we will we working with in this tutorial
First thing you must do is download the model.You can get the ZIP Brsseb_lesson6_start.rar.
As usual, extract the ZIP and put the folder you get in your bulldozer directory just as any other addon project. The folder is called “firstplane”. The p3d is also called “firstplane”, then there is a config.cpp file and some basic textures.
Fire Geometry and Geometry LOD looks like this
Since we have learned many things by now, I have made the most obvious things on the model. Here Fire Geo and Geo are the same (just that Geo has wheight, of course). On a real project, Fire geometry would usually be mode detailed.
Landcontact contains just 3 vertices making up the trycycle landinggear
The landContact LOD contains just 3 vertices, each repersenting the though point for the wheels. We will have to change this one later for the gear to work properly, though.
Nothing new in memory LOD yet, just the basics of any vehicle
And then the Memory LOD, containing things that you learned ages ago, right? Hope so.
So, so lets not go into o2 just yet. I want to show you what we need to do. The easiest way to explain the work needed; I want to you to compile the firsplane now. Yes, test it ingame and see what we need to do! Start your PBO program, compile the firstplane folder and put the resulting pbo in your addons folder. Yes it will fly! (but dont use the firstperson view for the pilot/cargo, since the View Pilot/Cargo LODs are not made yet, we`ll do that last (since we will be editing the original “0.00” LOD all the way).
The plane it its current state. Not very plane-ish, am I right? Note that the landinggear dont retract, the rotors dont spin and there are no control surfaces (flaps, rudder, ailerons) present. Dont worry, we`ll fix all that!
Ok, so not much to brag about is it? No working gear animation, the rotors don't spin or anything. And there are no working flaps, rudder or ailerons to see. But it can take off, land, and it flies very well. That's due to the config file, and we can make ANYTHING fly with just the right configfile. So no magic really.
Ready to fix the plane? Then start up o2 and bulldozer and move to the next step.
Lets fix the landing gear first. If you tested the model ingame, you will notice that the Raise/Lower landing gear at the action menu works. Trying to land the plane without gear down, you will crash. So that's not the problem, that's all defined in the config. What we need to do is make the animation for our gear work so that the gear in the plane retracts and lowers when the user uses the aciton menu.
How do we do that, you say? If you have followed my tuts you know it by now: we set up a bunch of wacky named (in czech) selections and let the ofp engine do the rest. We have a tricycle landing gear (one nose gear and two at the rear), just like the ofp A10 got. So ofp will have no problem with this.
Ok, now ofp know what the gears are and will use these selection when doing the rotation. But we still have work to do, we need to define an axis for each wheel, so that ofp can rotate each wheel around. Lets go to memory lod for that:
Ok, so now OFP can do the gear animation with no problems. One thing remains though:
This way the LandContact points follow the gear animation
Guess what, if you have checked that all selections are named right and you have followed this page to the point, the gear should work now. So compile and lets test the gear ingame. If some of the gears don't work, its probably because a bad named selection. Make sure you got no typos on the plane. And should some animation work the wrong way, try rotating the axis 180 degrees in Memory LOD.
Note that we cant seem to control the direction the gear retracts. They always retract forward, like the A10 does, and sometimes that's not what we want (e.i. most ww2 fighter retracted their gear inwards). So if we want to have a different gear animation, we can (from v1.85+ at least). But this is out of scope for this simple tutorial.
ok, now lets see if we can do anything about the static rotors. Lets make them spin!
Lets make the rotors turn. The LOD setup for that is similar to the one from lesson 4, where we made teh rotor blades spin. We need some selections in 0.00 lod and some axises in Memory lod. Note that we have two engines on this plane, so if you just have one engine, you just use the first set of selections.
Note that both engines has a rotor structure and a face with a rotor blur on it. Lets begin.
Ok, done with the rotors in model lod. Lets head for Memory LOD and make the axises for the spinning rotors.
And that's that. Compile and see how it looks ingame. Make sure you got all the selections correct or you might get some strange results.
Plane with working rotors. Nice!
If you only had like 1 rotor, you simply do the same setup without the one engine included, and that way you could also leave out the “0” in all selections that have that.
Now, how about fixing those control surfaces, eh?
Lets make one type of control surface at a time and then compile and test to see if it works.
We`ll start with the rudder. As you can see we need only one rudder surface, since we have only one vertical tailfin. We must make the surface, give it a selection name and an axis.
Go to memory LOD and create an axis for the rudder. Name it “osa leve smerovky” (axis left rudder)
Now lets compile and see if it works. I assume you know how rudder should work (which way it turns when you turn the plane). If not, consult any flight simulator or check out the official planes. The problem when making axises for plane surfaces, is that the order the vertices in the axis is created matters! So sometimes you might end up with a surface, like the rudder, going the wrong way or spinning around like crazy. If the rudder is reversed when you compile now, simply swap the axis vertices position to fix it (that way you have rotated the axis 180* and it should now work). The axis swapping need is a common problem with plane makers, so be prepared to swap some axis points if the problem occurs.
How the rudder should work. If it is reversed, try swapping the two axis points
The most common problem with plane surfaces is Typos, its so damn easy to make a mistake when typing the selection names (much due to the words left and right in Czech has different forms; levy (left); leve, leva, and pravy; (right) prave, prava, etc. So make sure you get all of the selection names right!
Go to 0.00 lod and make the two missing elevator surfaces. (place a box-structure, resize and make them black like before). Then select each of them and name them “leva vejskovka” (left) and “prava vejskovka” (right). Note that its “pravA/levA”, with A instead of “Y” on the end. That's the most common Typos there is in plane making, thrust me! Make sure to get the right form on all words!
Now compile and test it ingame. Remember to swap (switch places) on axis vertices if one of the elevators go the wrong way when testing. If you are unsure, compare to another plane or try thinking of what happens when a surface moves.
The next surfaces are the ailerons, they make the plane roll to the side. Also, in ofp, ailerons is also used for air brakes. We want air brakes too, so these surfaces are somewhat different.
Go to 0.00 lod and make the ailerons. But this time, make a total of 4 structures, not just one pair as before. Remember the air brake on the A10? Of not, test it now and try to imagine how they did it. Basically, they have slitted each aileron surface in two, so that when normal flying it works just as a normal ailerons, but when you brake (holding the back-key long enough), they split parts, with one part going up and one down to form the air brakes. Pretty neat, really.
Here is a setup for air brakes from another model of mine. Just to show you how it all works. Don't worry, I`ll walk you trough the whole selection naming
So lets do this:
Now you have two ailerons, one right and one left both split on two halves. Now we must create proper selections for them.
Phew, now that was a bit hard, now wasn't it? Test it and correct with axis swapping or typo hunt if you screwed up. Make sure you get it right: When a plane bank (roll) to the left, the one on your left goes up and the one on the right goes down (seen from the back). And vice versa. Also, test the air brake feature: when you hold down the back-button for some time, the ailerons should split and the top pair goes up (+90 degrees up) and the bottom pair goes down (-90 degrees down). Compare with the A10 if you are still unsure.
One surface type left: the flaps, used for either giving the plane extra lift at takeoffs of for reducing airspeed at landings. Dead easy for you to make now if you have made it so far.
Now test the flaps ingame. Operate them using the action menu and make sure they move the right way. if not, you know what to do don't you ;)?
Flaps in the up and down positions
Ok, still alive? Good, because we are all done with control surfaces! So now they work, the propeller spins and the gear retracts. Great job! On the next page we`ll add some more detail, and then its all done!
We got a nice plane right now, but we can still add some minor details to spice it up a bit. So lets add some features: If you did lesson 5, the boat tutorial, you know that lights are easy to make. We just add some named vertices in Memory lOD. So lets have red and green position lights on the wingtips and a flashing white one at the top of the tail, like most planes do (Or go mad and decorate the plane with lights like a crazy christmas three, your choice ;) ). And a bunch of other smaller details.
OK, that's enough detail for now, isn't it? One last thing…
As usual, I give a short overview of the configfile. Im not teaching C++, so don't ask me about what classes are or such questions. If you don't have a CLUE on what this config does, you need to hook up with someone who knows if you want your addon in the game.
In the first part, we have the usual declarations, the CfgPatches class and where out model is introduced to the game for the first time, and the CfgModel class where we specify which type of addon this will be and what subclasses we need.
The last part is the interesting one. Here, the usual stuff about any vehicles are defined. Many of the values in here should be familiar to you now (model, side, displayname). Note the value “gearRetracting=true” indicating that this plane has retracting gear, like the A10 does. The Cessna haven't. Then there is a lot of physics values that can be tweaked for the plane, like brake distance and control surface sensitivity. Note that no weapons are on board the plane right now (that's for another tutorial, for sure ;) ).
OK, bored now? Me too, lets compile and get this thing over with!
OK lets get this over with quickly. The last thing to do is to make the “View Pilot” and “View Cargo” LODs, just like you did in lesson 4 and lesson 5. Easy, just right click “0.00” LOD, select duplicate twice. Change the two new LOD copies to View Pilot and View Cargo. Now the messed up 1st person view for the pilot is no more!. See lesson 4 (helitut) for more in deep info about view-lods.
The plane ingame! Pretty nice, huh?
Get final PBO Brsseb_lesson6_end.rar.
So compile the plane for the last time, and check it out ingame. If all works as planned, feel proud. If not, try again, make yourself 200% sure that you don't have any typos or anything. If everything fails (or you spotted a bug in this tutorial, mail me at email@example.com).
Thanks for all nice feedback Ive gotten so far since Ive started this tutorial series! I`ll try to write as often as I can. Cheers!
This tutorial was written by Brsseb in ofp.gamepark.cz/_hosted/brsseb/, it was posted here with his permissions, thank you Brsseb!