In Tomb Raider 4 the gunflashes are linked to a particular mesh number of the animating object’s skeleton (meshtree). For instance the SAS slot links the gunflash to mesh number 7 of the animating object in that slot. Mesh number 7 is the mesh of the gun.
See this post [link] for how to find which mesh the gunflash is linked to by adjusting the shooting animation using fragMOTION.
If, in the SAS slot, you replace the SAS animating object with a different enemy, the gunflash may appear at the wrong place because mesh 7 of the new enemy is not the gun mesh.
So one reason to change the mesh order is to have the gunflash appear in the correct position.
TRWad Reorganizer [link] is a program that can change the order of the meshes in an animating object’s meshtree.
Changing the order of the meshes usually ruins the existing animations but the magic of TRWad Reorganizer is that it adjusts the animation’s keyframes to match the new mesh order so the animations are not ruined.
Changing the meshtree is a feature of TRWad Reorganizer that is only available for a Single Moveable Object (or SMO) wad. That is, a wad file which contains only one object.
If your wad is not already an SMO use Wadmerger to create one.
To create an SMO open the wad in Wadmerger using the “Load” button on the right hand side. The objects in the wad should appear in the list on the right.
Make sure the left list is empty (press New wad button if not), find your object in the right list and copy it to the left list. Save the wad.
Once you have an SMO wad you need to check the animations in Wadmerger's Animation Editor.
Click on each animation for the object and make sure there is at least one keyframe.
TRWad Reorganizer requires every animation to have at least one keyframe.
Also find the mesh order by clicking on each mesh name in the Meshes list and make a diagram of the meshtree.
Draw each mesh separate with the mesh number written next to it and represent the meshtree connections with lines joining the meshes. Use Animation Editor’s Meshtree Editor to understand which meshes are connected to each other.
For the RigGuard3 object [link] I have the following diagram.
Now write the new mesh numbers next to each mesh.
Mesh0 must remain Mesh0 so write “0” next to it.
The gun mesh is Mesh9 but we need it to be Mesh7 so write “7” next to it.
The meshes in the guard’s left arm should be numbered consecutively with the lower numbers at the shoulder end and the higher numbers at the hand end.
So if the gun mesh is Mesh7 then the mesh after it must be Mesh8. The mesh before the gun mesh must be Mesh6. The mesh numbers from the gun mesh to the shoulder mesh decrease by 1 as we traverse the arm from the gun mesh to the shoulder mesh.
We end up with the following diagram.
Now we need to find if we can number three meshes with the numbers 1, 2, 3 by following the rule that each branch of meshes off a mesh is numbered consecutively with the lower numbers first. If we can do this then the left arm can start with Mesh4.
Sometimes it isn’t possible to make the numbering work, in which case, you may need to add some dummy invisible/hidden meshes to the object.
In this case we can number the chest as Mesh1, the neck as Mesh2 and the head as Mesh3. The neck-head branch is numbered consecutively as we want.
The right arm is now easy to number. Mesh9 is the next available number so number the right arm Mesh9 to Mesh11, shoulder to hand
Now we need to number the legs.
The next available number is 12. We can choose to start either the left or right leg with Mesh12 but if we use Mesh12 for the left leg it will mean the right leg uses the same mesh numbers and we won’t have to move them in TRWad Reorganizer.
The final mesh numbering is shown below.
It helps if we now write the old mesh numbers ordered in a list according to the new mesh numbers.
Open the wad in TRWad Reorganizer, right click and click “Mesh Tree Modification Tool” in the context menu.
In the Mesh Tree Modification Tool we move the meshes up or down until they are in the same order as our list. To move a mesh, right click on it and click “Up” or “Down” in the popup context menu or press the CTRL+UP keys or the CTRL+DOWN keys.
Before moving any meshes it can be helpful to remove the Pops and Pushes of all the meshes. We will need to change them anyway and removing them from all the meshes can make moving the meshes more straightforward.
Right click on each mesh and remove the tick/check mark next to Pop or Push or both in the popup context menu by clicking them or press CTRL+O to toggle a Pop and CTRL+U to toggle a Push.
The first number in the brackets next to the mesh number in the list indicates the Pops and Pushes. 0 means no Pop and no Push, 1 means Pop, 2 means Push and 3 means Pop and Push.
So the goal in this step is to have 0 as the first number in the brackets for each mesh but remember we do not have to move meshes 16 to 19 in this case so we will leave those meshes untouched.
The background colour of the Mesh Tree Modification Tool will change colour with the first modification to remind you that you have made a change. As you remove Pops and Pushes the tree display will change shape abruptly.
The meshtree with Pops and Pushes removed is shown in the screenshot below.
Because the Pops and Pushes are removed from the meshes we will move, the display won’t keep changing and make things more confusing when we move a mesh.
Move the meshes up or down the list until they are in the same order as our list.
With the meshes now ordered the way we want, we have to add the Pops and Pushes for the new structure.
There is a tutorial [link] for working out the Pops and Pushes at tombraiderforums (TRF) so I won’t repeat the steps here. Use the diagram we drew earlier in conjunction with the tutorial.
The new meshtree structure is shown in the screenshot below.
As a quick check for the Pops and Pushes, work from top to bottom of the meshtree and write an opening brace, {, for every “2” you see and a closing brace, }, for every “1” you see.
The structure is okay if you have the same number of opening braces as closing braces and the first brace is an opening brace and the last brace is a closing brace and you can pair each opening brace with a closing brace.
For our meshtree I get the following sequence of braces.
The following sequences indicate something is wrong with the Pops and Pushes.
When the new meshtree is finished, right click and click “Update Loaded Wad” in the popup context menu.
The “Update Loaded Wad” option is no longer available in the right click context menu until you make further changes.
Close the Mesh Tree Modification Tool window by clicking the window frame's “X” to return to TRWad Reorganizer.
Right click and save the wad.
Open the wad in Wadmerger and check that the object and animations look okay.
If you place the object in your project map and experience problems selecting other objects or many other objects rotate when you rotate this object it may mean the Pops and Pushes are incorrect.
If the gunflash is not approximately in the correct position in game it may mean the gun meshes for the two objects are not aligned in the same way. To check, export each gun mesh from StrPix as an *.mqo file and compare the two meshes in Metasequoia.
Is each gun’s vertical axis in the same plane? Does the barrel of both guns point in the same direction? Are the guns the same length?
Another reason for incorrect gunflash positioning is maybe we guessed the wrong mesh number linked to the gunflash.
Unfortunately for the Rig Guard3 object used in this example the gunflash was incorrectly positioned when shooting while standing or walking but was correctly positioned for the shooting when kneeling animation.
This means some other unknown factor is involved with the gunflash effect. Hopefully Lwmte at TRF can work it out some day.
Note that the rule about numbering meshes consecutively in a branch may not be a rule at all. This is the pattern I observed from studying original object’s meshtrees but I have never tested whether this is a requirement so feel to break it and see what happens.
No comments:
Post a Comment