NOTE: This page was automatically converted from the original Serious Editor 2 help file, using http://labs.seapine.com/htmltowiki.cgi .
Door tutorial (Simple skeleton and animation, mechanism and door setup)
In this tutorial we'll make a door by making a skeleton and a door animation followed by setting up the mechanism so that our door can actually have collision.
Open 'Door.mdl' saved in Content/SDK/Models directory.
The first thing to do when making an animation is to create weight maps. A weight map gives information on how much influence the skeleton bone will have on each vertex.
Go to the mesh editor and select the door frame (select any polygon of the frame and press ']' to add the connected polygons to the selection). Now select the 'weight map' type (W) in the 'vertex map (VM)' mode in the lower right corner of the work panel. Now right click where it says <none> and choose New.
Creating new weight map for selected polygons
Now the weighting tool dialog will open. As the name of our Weight map enter 'Frame' (mechanism parts and skeleton bones must have the same name as the weight map that they apply to). Leave the weight value at 1. This means that this weightmap will have a 100% influence on the vertices belonging to this weightmap. Now repeat this process for each door wing and give their weight maps the names 'Left' and 'Right'.
If you have done everything right, we can proceed with creating a skeleton. Open the Skeleton editor (shift E and then S). First we must create a new skeleton LOD. Right click in the box next to 'Skeleton' in the lower right corner. A menu will open, choose New. Now press Shift X (create bone tool). A dialog will open for entering the new bone's name. We need only two bones since our frame won't be animated. Name the new bone 'Left' (it will influence vertices belonging to the 'Left' weight map). A new bone is created at the model's origin. We can leave it here and create another bone called 'Right'. The new bone is automatically set as a child of the previously created bone. To fix that we need to reparent it. Press Shift S and delete the value in the reparent bone dialog and hit enter. It is not important, but for the sake of neatness we'll correct its z axis position and bring it to the origin. Open the Tools panel (Q) and set the Z value in Position and rotation to 0. This part is done and we can move to the animation.
Open the Animation Editor. The first thing we must do is create a new anim set and a new animation. Choose new from the menu's that are opened when you right click on the first two boxes next to the play control in the lower right corner of the work panel. Your new animation is named Default by default. Rename it to Open by choosing the Rename action from the menu which you get when you right click on the name. In the third box's menu select New All. It will create new envelopes for each bone that you have in your skeleton and will name them accordingly. You can see that bones have appeared in the work panel.
|Everything is set to begin animating, but we'll adjust a few things before that. Open the Animation panel (alt 1). It displays the properties of the selected animation (the selected animation is displayed in the middle box in the right lower corner of the work panel). Your default animation has 31 frames and since this is a simple movement, we need just two. So set 'First frame' to 1 and 'Last frame' to 2. 'SecPerFrame' defines how long the animation will last for each frame, in seconds. Set it to 1. That means that the door will open in 1 second.||
Now select the envelope that you want to animate in the third box in the lower right corner of the work panel. We can start with 'Left' envelope (bone). The time bar is located below the work panel. The first frame is indicated on the far left and the last one is indicated on the far right. If the space between them is clear (not blue), it means that the animation is in the first frame (if not press left or right arrow once). Now create a motion key for the selected envelope in the first frame. Simply hit enter to open a dialog and once again to confirm it. There is no need to adjust anything. Now press the right arrow key to advance to the next frame in the animation. You will notice that the frame bar became colored blue. The blue line indicates active frame(s). Now it is extended across the screen because we have only two frames. When you have more than 2, you will see that only the active frames are colored blue in the time bar.
|Now we will set a new position for the bone in the second frame. Open the Tools panel and edit the Channel values/Left.Pos.X. Set it to -2. Your left door wing should've moved to the side. Create another motion key in the second frame (just hit enter twice). Press the left arrow key to return to frame one and repeat the process for the Right envelope. However this time, in Right.Pos.X enter value 2 to move the wing to the other side.||
If you have done everything right you should see something like this:
Finished animation in second frame
You can test your animation in the Model editor. In the List panel (shift alt 4) double click on the animation name (Open). It will play that animation in the work panel.
This mechanism is bit more complex than one we have already done. It will have a Main part that won't animate, and two child parts. To begin, create a new mechanism, and set the Material to Stone. Now create a new mechanism template and name it Main (that's the name we gave to the door frame weight map). Since this part will be neither animated nor have physics, it doesn't need a body, but it does need a shape. Add a new shape with a primitive hull and use these values:
You may notice we're only doing an aproximation of the collision. It may seem imprecise but its sufficient, especially for the purpose of this tutorial. We'll need two more shapes for the entire door frame, so add another shape. Since the second shape will be the same as the one we already have, we can copy all of its properties and change the Rel. placement X value to -3.3 on the new shape. To copy property values simply mark shape 0 (which will be colored blue) and press ctrl C (copy), then mark shape 1 and press ctrl V (paste). Now change its X axis placement. One more shape is left so add the final shape and use these values:
The first part of the mechanism is done! On to the next part! Fold back the Shapes properties and add a new Child parts member. Unfold it. It has the same properties (almost, at least those we are interested in) as the Root part. Give it the name 'Left' (as the bone it will animate with). Since this part will be animated, but we don't want it to be moved except by the animation, we'll use a KinematicBodyTemplate. Add a Kinematic body and move on to shapes (remember that the part must have same position as the bone with the same name, but since all of our bones are on 0,0,0 coordinates and that this is the position of our new part, we don't have to make any adjustments). Now add a new shape with these values:
To create the Right part, we'll use the copy/paste trick again. Fold back the Left part properties and add new a Root part child (under Left part). Mark the Left part properties (0), press ctrl C, mark the new part properties (1) and press ctrl V. Notice that the new part has the same name. Change it to Right and change its Rel. placement on the X axis to 1.5. That's it! Our door is ready to be used in our world. It may seem complicated at first glance, but the system is very powerful and once you get used to it, it becomes like a second nature.
Let's place it in a world and put it to use. You can continue with the world from the previous tutorial(s). Open it and drop a Door entity into it. In the entity panel, browse for your door model in the Door model property. First we'll align it to the center of the doorway. Select any of the two rooms and then the Door. Now press ctrl A (Align). Set the equal (=) option for Align x section in the dialog that opened. Leave the rest as they are. Deactivate the tool by pressing D. You may now notice that you have aligned the Door to the Room model on the x axis so now they are placed exactly in center of the Room. To align the Door exactly in between two rooms select the door and make sure that you can see bounding box edge where two rooms connect. Press alt and set the Drag/Align switches like in the picture:
This means that your Door will be aligned, only on the Z axis using the Door's (Src - source) bounding box plane (B) to the Room's (Dst - destination) bounding box edge (E). This will place the Door exactly in between the two rooms. You can always place them manually, but if you want to keep everything neat, you should use Drag/Align. Move your mouse pointer to the top bounding box edge of the Door.
Move your mouse pointer to the top bounding box edge of the Door.
Dragging Door bounding box plane...
And drag it to the Room's bounding box edge.
... to Room bounding box edge.
Now we need to enable our door by placing detectors in front of it and behind it. Simply set the Detector in front and the Detector behind the door to true in the Entity panel. Detectors take the size of the whole model into account (with door frame) and we need just the door. Set the Extra area value to -2 and that should do it. Note that the Opening animation is Open by default. That's the name we used, but if your door uses a different opening animation, set it here. Also, if you have a special closing animation enter it under the Closing animation value. If no closing animation is defined, the opening animation will be played backwards.
If you test the game now, you'll notice there is something missing. The doors make no sound... To correct this we'll need to open the animation editor. In the animset panel add a new sound event member to Events. 'Sound' in the scheme defines the name of the sound scheme in the model. We'll set it up in the model editor under the name Door. So enter that name in the value. As the frame (animation frame) we'll set frame 1 which means that the sound will start playing in first frame. As the Event rules, set Forward only which will disable playing the sound when the doors return to the first frame when closing. Add a new sound event member for closing. The scheme is the same (we'll use the same sound), the frame will be 2 (the animation will play backwards from frame 2 to 1) and event rules, of course, Reverse only. Now open the Model editor (shift E and then D) and in the Instance panel (shift alt 2) unfold the Model properties. Add new Schemes and then a new Sound scheme. Now add a new sounds member and name it Door. Add a new Variations member and browse for Stone_Door_1sec.wav from the Content/SDK/Sounds folder. You should have everything set like this:
Door scheme setup
This concludes the door tutorial which covered some aspects usable for other purposes. Setting up skeletons, animations and mechanisms can be used for other purposes, too. The Drag/Align and Align tools will often be used in level editing, so keep note of them. It is also recommended to follow the links to those tool description in this documentation. At this point you can practise a bit with creating new rooms, architecture, lighting them and connecting them with doors...