Home » MODDING HQ 1.13 » v1.13 Features How-Tos & Discussions » LOBOT tutorials (Tutorials focused on creating new animations and equipment for LOBOT)
LOBOT tutorials[message #364117]
|
Sun, 02 January 2022 01:38
|
|
Asdow |
|
Messages:134
Registered:August 2010 |
|
|
Here is the first in a set of tutorials aimed at helping others create new content for JA 2 using LOBOT and the blender framework made for it. In order to not overwhelm with information, importing a rifle into the file might be a good starting point. I'll write an overview of the blender file and its inner workings later.
Due to 10 image limit, I can't embed all the images, so click on the links when going through this.
Tutorial to rig and render a rifle for JA 2
Here is a step-by-step tutorial on how to add a rifle 3d model into the blender framework, and how to render it and eventually turn it into sti files for JA 2.
You can get the framework from github from this link: https://github.com/Asdow/JA2-Character-Animation-Photobooth
Just click the green 'code' button and select 'download ZIP' and extract it somewhere. Be sure to also extract the make_script.7z and JA2 2.9_033.blend.7z that are inside it to the project folder.
The first file contains programs needed for converting rendered images to .sti files and the second one contains the actual Blender file.
SETTING UP THE RIFLE FOR RENDERS
The H&K G11 3d model I'm using can be downloaded from here: https://sketchfab.com/3d-models/low-poly-hk-g11-f3b4895aa54946e089069ac664a36ae5
Download the original format (.FBX) and extract the file somewhere
After that's done, let's open up the file in Blender and let's get to it.
This is how it looks after opening the files, notice in the right corner that there are a total of 16 scenes, 8 camera scenes and 8 cryptomatte scenes for the cameras.
We'll primarily just stay on scene 'Camera 1' and its layer 'View Layer' throughout the tutorial, but it's good to know that they are there. We'll also mostly stay on the "Animation" tab and "Object Mode" as seen in the screenshot.
Next, let's import the G11 into Blender. Go to top left, File -> Import -> FBX and browse to the file
https://i.imgur.com/7HiN96A.jpg
After importing, it should look something like this.
Notice, that the rifle model brought a Lamp, Camera and an Armature with it to the scene. We will only need the actual rifle mesh, so in the outliner select those three objects and press 'x' to delete them.
You should end up with this.
https://i.imgur.com/tLih4J3.jpg
Next, let's rename the Cube.001 to something more reasonable, such as 'Weapon - G11'. The "Weapon" part in the name will be important but I'll explain why further on.
Then we have to rotate and scale the 3d model to be more in proportion to the body. It's usually helpful to also change the 3d model's origin location. Some 3d models have it in an odd location which makes especially rotations a bit awkward.
With the rifle model selected, press 'F3' and search for 'origin', then select for example 'Origin to Geometry' to move the object's origin to be in the middle of it.
https://i.imgur.com/gASzkU4.jpg
To help moving and scaling the rifle model, you can use the "Weapon - FAL" object as a reference. In the outliner, click on the checkbox next to "Prop 1" collection to enable it and then enable the object to be shown in the viewport.
Scale, move and rotate the rifle so its handle is about where the FAL's is. Don't worry about exact size or location just yet. We can always go back and tweak the position if need be.
This is how it looks after I was done with it.
https://i.imgur.com/yOuHmNw.jpg
Next, we'll need to setup the model so it follows the body and arm movements during animations. With the rifle selected, click the 'modifier' tab, select 'Add Modifier' and click on 'Armature'
Then, click on the 'Object' selection and select 'weapon holder Right'
Go to 'Vertex Groups' tab for the object, add a Vertex Group to the model and rename it to "Weapon.R". The exact name is important here.
Then hit 'tab' to enter edit mode for the rifle, select all the vertices/faces and with the "Weapon.R" vertex group active, click 'Assign' to assign everything to it.
Hit 'tab' to exit edit mode and notice that the rifle suddenly disappears from where it used to be. It's now following the armature and the weapon holder rig that is attached to the right hand.
https://i.imgur.com/F8dHaHC.jpg
Next up, let's change the gun's color to something better. With the rifle selected, click on the 'materials' tab, set the first material to "Material.009" and delete all the other materials from the object.
The rifle is now almost ready to be rendered. Currently, it's only visible in Camera 1 so we need to link the object to the other scenes and move it to one of the "Prop" collections.
Go to "Scripting" tab, and select the "Link Object to scenes.py" script.
With *only* the G11 rifle selected, press the 'run script' button and the gun will be linked to all the other scenes.
Next, switch to the "Move to collection.py" script and again, with *only* the G11 rifle selected, press the 'run script' button and the object will be automatically moved to a Prop collection in all 16 scenes.
You can change which collection it is moved to by changing the 'collName' variable in the script. Don't worry if you accidentally moved it to a different collection than you intended. You can just modify the collName and run the script again. It will always unlink the object from any current collections it is in.
I've adjusted the collName so it is moved to "Prop 1" collection. After running the script, notice how the object is now inside the "Prop 1" collection where the "Weapon - FAL" is as well.
https://i.imgur.com/d7REnUH.jpg
https://i.imgur.com/wXWnsOs.jpg
Now, we're pretty much done with adding the rifle to the file. Let's switch back to "Animation" tab, disable the "Prop 1" collection and select the rig so that a list of animations is visible in the action editor as seen in the next screenshot, save the file and exit Blender.
We still have a little bit of setup needed to do outside blender before we can actually render the gun. Open the "batchrender-unified.py" file, located in "renderScriptBodies" folder.
This python script file is responsible for setting up the blender file when we call it with different animations and render them. There are mainly two things here that we need to change occasionally.
1. Which body, and 2. what equipment we want to show in the renders.
https://i.imgur.com/h5Zv9rg.jpg
The bodytype can be selected by changing the 'true' and 'false' values in lines 84...86 as seen here. The way it is in the screenshot, means we would be rendering the big male body and hiding the regular male and female from the renders.
The second part is on line 104, and it decides which props we want to show in the renders. This is also why we wanted that "Weapon" part in the 3d model's name. In the beginning of this script, it goes through all the objects in the file and if they have a certain word in their name, they are first hidden from the render, and then we display only certain props here. This is so we don't have to worry about which state we left the objects in inside blender and we don't accidentally end up with extra objects in our render.
Notice, that we can only render 25 props simultaneously. For the purpose of this tutorial, I'll add an extra set just for the G11 rifle alone. Set the 'renderSet' to 7 and then go to the end of the file and modify it to look like this. Disabling the unused prop layers (lines 366..367) is not strictly necessary but it will make rendering just one prop faster and won't output empty .png files into "output" folder
https://i.imgur.com/1N7jk4w.jpg
Save and close the file and that's it, the gun can now be rendered!
RENDERING
So, because of the amount of animations and setup needed for them, rendering is done via commandline by calling batchscripts that call blender.exe with the blendfile and a pythonscript.
There are two small programs I wrote to make this more convenient, JA2-BatchRenderCreator.exe and JA2-BatchRender.exe.
The source codes for them can be found in here if you're interested.
https://github.com/Asdow/JA2-BatchRenderCreator
https://github.com/Asdow/JA2-BatchRender
I will have to explain a bit here so bear with me. Normally you don't have to touch any files besides the python script, but I feel it's good to know this so one could for example add a new animation they would want to render for a certain body.
In "batchSriptData" folder there are several text files named something like "Animations - bodytype - type of weapon", for example "Animations - Big male - Rifle.txt"
The files contain a list of tuples that have four components. First one is the animation name inside the blender file, second one is how many frames the animation has, third one is what will its filename be when it's converted to .sti and last one is the amount of view directions the animation has. Most have 8 directions but there are a few special cases of 4 and 1 view directions.
An example of one tuple would be
("Standing - Rifle - Idle",8,"M_R_STD",8),
You can comment an animation out with ';', so this next line would not be used for renders
;("Standing - Rifle - Idle",8,"M_R_STD",8),
So, the way this works is that we use JA2-BatchRenderCreator.exe to generate complete python scripts that we can use with blender. We give the program a value of how many script files we want to divide the list of animations to, file to read the animations from, and the python script to use for generating the complete python scripts.
To help out, there is already a batch script named "createBatchRenderScripts.bat" which does it for all three bodytypes. You can open the .bat file in a text editor to see how it is. It simply deletes any files in "renderGeneratedScripts" folder and then creates new ones to the same folder.
So anytime you switch either the bodytype you want to render, or the set of equipment that's visible in the pythonscript. Run this .bat file to update the actual scripts that are then fed to blender.exe.
Let's do that then and double-click the "createBatchRenderScripts.bat" to update the script files. You can open one of the generated script files from "renderGeneratedScripts" folder and compare how it differs from the batchrender-unified.py file in "renderScriptBodies" if you want to.
After that's done, we can render the animations by double clicking one of the multiple batchrender .bat files such as "batchrender - Big male - Rifles.bat"
These batchscript files simply call JA2-BatchRender.exe with 3 arguments; 1. a path to where blender.exe is located, 2. the name of the .blend file we want to use, and 3. the name of the generated python scripts we want to use, omitting the number from the end.
You'll need to change the path to where Blender is installed on your machine in all these .bat files.
What JA2-BatchRender.exe does, is simply, it counts how many python scripts there are that it should use, and calls blender multiple times using the .blend file we gave it and the python scripts so several animations can be rendered in parallel and waits for them to finish rendering.
This way there is no need to manually define how many blender instances you want to run. If you want to render all the animations in one instance, simply change the number in "createBatchRenderScripts.bat" to "1", run it and then call the rendering .bat file for those animations.
It can also deal with the case of having less animations than the amount of files they need to be split into. Say you want to render only 1 animation this time, but normally you render everything and want them to be divided into 4 lists. No problem, first three generated python scripts will have an empty list and those instances won't render anything and the 1 animation is put into the last script which then renders normally.
I recommend starting by rendering just one animation, so let's open up Animations - Big male - Rifle.txt and comment out all other animations except ("Standing - Rifle - Idle",8,"M_R_STD",8)
Save the file, run "createBatchRenderScripts.bat" and then run the "batchrender - Big male - Rifles.bat" and wait for rendering to finish.
CREATING STI FILES
After the renders are done, the outputted .png files are saved into "output/animation name" folder with names specifying which prop, camera and frame it is. Creating sti files are done with JA2-MakeSTI.exe.
Its source code can be found here: https://github.com/Asdow/JA2-MakeSTI
There are again a couple of files in "batchScriptData" that I need to explain now. Namely, sticonfig.ini, animationFiles.txt and propFiles.txt.
sticonfig.ini has global settings for both JA2-makeSTI and sticom.exe written by bio, which is eventually responsible for the conversion. Normally you don't need to change anything in this file, but again, good to know that it exists. You can for example change where the finished .sti files are saved.
Then, animationFiles.txt contains a list of text file names that JA2-MakeSTI can use for the animations. The program first reads the names of the files from here, and then reads the actual animation data from said files and prints a dialog where you can select which animations you want to convert into sti files.
https://i.imgur.com/g0f8T1a.jpg
After selecting one, it'll then print out a list of found animations and gives another dialog where you can select which props you want to create. This is where the propFiles.txt comes in. It works similarly to animationFiles.txt, where it contains a list of filenames where the actual data resides, as well as a description that is shown in the selection dialog.
https://i.imgur.com/Gw2tksL.jpg
I'll use prop-weapons-1.txt as an example of the actual prop data. What it contains is this:
; :: separator, palette filename, prefix, suffix
;------------------------------------------------------
guns_universal_v2.stp :: Prop1 :: _FAL
guns_universal_v2.stp :: Prop2 :: _AR
guns_universal_v2.stp :: Prop3 :: _AK47
guns_universal_v2.stp :: Prop4 :: _famas
guns_universal_v2.stp :: Prop5 :: _SCARH
guns_universal_v2.stp :: Prop6 :: _M82
guns_universal_v2.stp :: Prop7 :: _dragunov
guns_universal_v2.stp :: Prop8 :: _PSG1
guns_universal_v2.stp :: Prop9 :: _TRG42
guns_universal_v2.stp :: Prop10 :: _Patriot
;------------------------------------------------------
guns_universal_v2.stp :: Prop11 :: _P90
guns_universal_v2.stp :: Prop12 :: _M1A1
guns_universal_v2.stp :: Prop13 :: _PPSH41
guns_universal_v2.stp :: Prop14 :: _MP5
guns_universal_v2.stp :: Prop15 :: _shotgun
guns_universal_v2.stp :: Prop16 :: _Saiga
guns_universal_v2.stp :: Prop17 :: _spas12
guns_universal_v2.stp :: Prop18 :: _uzi
guns_universal_v2.stp :: Prop19 :: _RPK
guns_universal_v2.stp :: Prop20 :: _SAW
;------------------------------------------------------
guns_universal_v2.stp :: Prop21 :: _PKM
guns_universal_v2.stp :: Prop22 :: _mosin
guns_universal_v2.stp :: Prop23 :: _M14
guns_universal_v2.stp :: Prop24 :: _MKL
guns_universal_v2.stp :: Prop25 :: _RR
Entries are separated by :: and there are 3 entries; palette, prop number and the suffix we want that prop to have.
Palette is the palette file we want to apply to the images to convert them into limited color .sti files. The files reside in make_script/Palettes folder.
Prop filename tells the program which .png files to grab from "output/animation" folders and the suffix is added to the end of the .sti filename.
As an example, let's say we have rendered all those weapons for this ("Standing - Rifle - Idle",8,"M_R_STD",8), animation, and we then run ja2-makesti. The .sti files we create will be M_R_STD_FAL.sti, M_R_STD_AR.sti and so on
So now that we know how the prop definitions work, we can create a new file and add a definition for our G11 rifle. Let's create a new text file into "batchScriptData" and name it "Prop-Weapons-tutorial.txt". Open it and paste this inside it
guns_universal_v2.stp :: Prop1 :: _G11
Remember to adjust the prop number if you didn't move it to the first collection in Blender. Then save and close the file.
Now let's add it to the propFiles.txt file, so open that and paste this to the end of it
Prop-Weapons-tutorial.txt :: Weapon Tutorial ( G11 )
Save and close the file.
Assuming we've rendered a set of animations already, we can now call JA2-MakeSTI.exe, select the animation set we rendered, and the G11 prop and it'll create the .sti files. I'll explain in a later tutorial on how to add the required definitions so we can get the gun to show up ingame. You can open the created .sti file with sti-edit which is inside make_script/sti-edit folder and see how it looks.
[Updated on: Sun, 02 January 2022 02:17] Report message to a moderator
|
Sergeant
|
|
|
Goto Forum:
Current Time: Fri Sep 13 00:56:44 GMT+3 2024
Total time taken to generate the page: 0.00695 seconds
|