• The forum has been updated. For an explanation of some of the changes, head over here.

Currently viewing this thread:

BladeofWar's

Sergeant at Arms
WB
Hello, I had to add new tableau_materials for my mod because the standard ones didn't work. And now I decided to do a lesson if you need it too. Required files module_scripts.py and module_tableau_materials.py. Let's start.

Firstly we'll create own tableau_material. For example:
Code:
    ("bw_troop_mesh", 0, "tableau_with_transparency", 1024, 1024, 0, 0, 350, 350,
   [
       (store_script_param, ":troop_no", 1),
       (cur_tableau_set_background_color, 0xFF888888),
       (cur_tableau_set_ambient_light, 10,11,15),
       (set_fixed_point_multiplier, 100),
       (cur_tableau_set_camera_parameters, 0, 40, 40, 0, 100000),

       (init_position, pos1),
       (position_set_z, pos1, 100),
       (position_set_x, pos1, -20),
       (position_set_y, pos1, -20),
       (cur_tableau_add_tableau_mesh, "tableau_troop_note_color", ":troop_no", pos1, 0, 0),
       (position_set_z, pos1, 200),
       (cur_tableau_add_tableau_mesh, "tableau_bw_troop_note_alpha_mask", ":troop_no", pos1, 0, 0),
       ]),

so what are these;

(store_script_param, ":troop_no", 1), = #A method used to determine troop
(cur_tableau_set_background_color, 0xFF88888:cool:, #Background color
(cur_tableau_set_ambient_light, 10,11,15), #Ambient Light
(set_fixed_point_multiplier, 100), #this put in order to prevent slippage etc ... for positions
(cur_tableau_set_camera_parameters, 0, 40, 40, 0, 100000), #for camera angle
these are not important,
Now these are important;

(init_position, pos1),
(position_set_z, pos1, 100),
(position_set_x, pos1, -20),
(position_set_y, pos1, -20),
You can set the tableau_material's positions in this section.

(cur_tableau_add_tableau_mesh, "tableau_troop_note_color", ":troop_no", pos1, 0, 0), #an essential element to color our tableau material we explained below.
(cur_tableau_add_tableau_mesh, "tableau_bw_troop_note_alpha_mask", ":troop_no", pos1, 0, 0), # this provides an alpha view of the tableau

Now let's examine these two in detail.
Code:
  ("troop_note_color", 0, "mat_troop_portrait_color", 1024, 1024, 0, 0, 400, 400,
   [
       (store_script_param, ":troop_no", 1),
       (cur_tableau_set_background_color, 0xFFC6BB94),
       (cur_tableau_set_ambient_light, 10,11,15),
       (call_script, "script_bw_add_troop_to_cur_tableau", ":troop_no"),
       ]),

important code is
Code:
(call_script, "script_add_troop_to_cur_tableau", ":troop_no"),
let's examine this script;

Code:
  #script_bw_add_troop_to_cur_tableau
  # INPUT: troop_no
  # OUTPUT: none
  ("bw_add_troop_to_cur_tableau",
    [
       (store_script_param, ":troop_no",1),

       (set_fixed_point_multiplier, 100),

       (cur_tableau_clear_override_items),

#       (cur_tableau_set_override_flags, af_override_fullhelm),
       (cur_tableau_set_override_flags, af_override_head|af_override_weapons),

       (init_position, pos2),
       (cur_tableau_set_camera_parameters, 1, 6, 6, 10, 10000),

       (init_position, pos5),
       (assign, ":eye_height", 162),
       (store_mul, ":camera_distance", ":troop_no", 87323),
#       (val_mod, ":camera_distance", 5),
       (assign, ":camera_distance", 139),
       (store_mul, ":camera_yaw", ":troop_no", 124337),
       (val_mod, ":camera_yaw", 50),
       (val_add, ":camera_yaw", -25),
       (store_mul, ":camera_pitch", ":troop_no", 98123),
       (val_mod, ":camera_pitch", 20),
       (val_add, ":camera_pitch", -14),
       (assign, ":animation", "anim_stand_man"),


       (position_set_z, pos5, ":eye_height"),

       # camera looks towards -z axis
       (position_rotate_x, pos5, -90),
       (position_rotate_z, pos5, 180),

       # now apply yaw and pitch
       (position_rotate_y, pos5, ":camera_yaw"),
       (position_rotate_x, pos5, ":camera_pitch"),
       (position_move_z, pos5, ":camera_distance", 0),
       (position_move_x, pos5, 5, 0),

       (cur_tableau_add_troop, ":troop_no", pos2, ":animation" , 0),

       (cur_tableau_set_camera_position, pos5),

       (copy_position, pos8, pos5),
       (position_rotate_x, pos8, -90), #y axis aligned with camera now. z is up
       (position_rotate_z, pos8, 30),
       (position_rotate_x, pos8, -60),
       (cur_tableau_add_sun_light, pos8, 175,150,125),
     ]),

the important part is the look of the troop so we will set it with the override flags

Code:
       (cur_tableau_clear_override_items),

       (cur_tableau_set_override_flags, af_override_head|af_override_weapons),

(cur_tableau_clear_override_items), = this deletes explicitly overridden items.
(cur_tableau_set_override_flags, af_override_head|af_override_weapons), = this indicates the items to be overridden.


override flags;
Code:
af_override_weapons         = 0x0000000f          =not show weapon
af_override_weapon_0        = 0x00000001        =not show weapon0
af_override_weapon_1        = 0x00000002        =not show weapon1
af_override_weapon_2        = 0x00000004        =not show weapon2
af_override_weapon_3        = 0x00000008        =not show weapon3
af_override_head            = 0x00000010        =not show head
af_override_body            = 0x00000020        =not show body
#af_override_leg             = 0x00000040
af_override_foot            = 0x00000040        =not show foot
af_override_gloves          = 0x00000080        =not show gloves
af_override_horse           = 0x00000100        =not show horse
af_override_fullhelm        = 0x00000200         =not show fullhelm


af_override_all_but_horse   = af_override_weapons | af_override_head | af_override_body |af_override_gloves        =not show all but show horse
af_override_all             = af_override_horse | af_override_all_but_horse        =not show all itmes
af_override_everything      = af_override_all | af_override_foot                        =not show anythings

Is it okey? let's examine alpha mask;

Code:
  ("bw_troop_note_alpha_mask", 0, "mat_troop_portrait_mask", 1024, 1024, 0, 0, 400, 400,
   [
       (store_script_param, ":troop_no", 1),
       (cur_tableau_set_background_color, 0x00888888),
       (cur_tableau_set_ambient_light, 10,11,15),
       (cur_tableau_render_as_alpha_mask),
       (call_script, "script_bw_add_troop_to_cur_tableau", ":troop_no"),
       ]),
Important code is
Code:
 (call_script, "script_bw_add_troop_to_cur_tableau", ":troop_no"),
let's examine this script;

Code:
#script_bw_add_troop_to_cur_tableau
  # INPUT: troop_no
  # OUTPUT: none
  ("bw_add_troop_to_cur_tableau",
    [
       (store_script_param, ":troop_no",1),

       (set_fixed_point_multiplier, 100),

       (cur_tableau_clear_override_items),

#       (cur_tableau_set_override_flags, af_override_fullhelm),
       (cur_tableau_set_override_flags, af_override_head|af_override_weapons),


       (init_position, pos2),
       (cur_tableau_set_camera_parameters, 1, 6, 6, 10, 10000),

       (init_position, pos5),
       (assign, ":eye_height", 162),
       (store_mul, ":camera_distance", ":troop_no", 87323),
#       (val_mod, ":camera_distance", 5),
       (assign, ":camera_distance", 139),
       (store_mul, ":camera_yaw", ":troop_no", 124337),
       (val_mod, ":camera_yaw", 50),
       (val_add, ":camera_yaw", -25),
       (store_mul, ":camera_pitch", ":troop_no", 98123),
       (val_mod, ":camera_pitch", 20),
       (val_add, ":camera_pitch", -14),
       (assign, ":animation", "anim_stand_man"),


       (position_set_z, pos5, ":eye_height"),

       # camera looks towards -z axis
       (position_rotate_x, pos5, -90),
       (position_rotate_z, pos5, 180),

       # now apply yaw and pitch
       (position_rotate_y, pos5, ":camera_yaw"),
       (position_rotate_x, pos5, ":camera_pitch"),
       (position_move_z, pos5, ":camera_distance", 0),
       (position_move_x, pos5, 5, 0),


       (cur_tableau_add_troop, ":troop_no", pos2, ":animation" , 0),

       (cur_tableau_set_camera_position, pos5),

       (copy_position, pos8, pos5),
       (position_rotate_x, pos8, -90), #y axis aligned with camera now. z is up
       (position_rotate_z, pos8, 30),
       (position_rotate_x, pos8, -60),
       (cur_tableau_add_sun_light, pos8, 175,150,125),
     ]),
Important codes are these;

Code:
       (cur_tableau_clear_override_items),

       (cur_tableau_set_override_flags, af_override_head|af_override_weapons),

I explained this

Code:
(assign, ":animation", "anim_stand_man"),
This determines the animation of the troop to be displayed.

I hope it helped. If you have any questions, you can ask here.
Good forums...
 
Top Bottom