[help] (partly solved) [SCharacterInstance::Init] Could not get Ptr to model

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

User avatar
Xkuka
Posts: 245
Joined: Sun, 14. Mar 10, 19:25
x4

[help] (partly solved) [SCharacterInstance::Init] Could not get Ptr to model

Post by Xkuka »

So i am playing around with character assets, but i cant get it to work replacing uniform diffuse maps. I have some success with hairs, but when i do my changes to more variants i get these errors.

So for example i started with changing the PIO female uniforms, simple enough since all PIO characters use the same two meshes (xac),

I have created copies of the original diffusion maps, changed the colour, exported them back as dds, removed the extension, packed as gz.
Files are located like this
extensions\MYMOD\assets\characters\terran\textures\char_pio_f_pilot_suit_01_diff (of course packed as .gz)

Now added a new materials to the material_library.xml, basically a copy of the originals, only changed the number of the material ID and the path of the diffuse map

Code: Select all

<add sel="/materiallibrary/collection[@name='terrancharacters']"> 
<material name="ter_p1_char_pio_f_pilot_suit_06" shader="P1_character.fx" blendmode="NONE" preview="none">
  <properties>
    <property type="Float" name="AnisoX" value="0.5" />
   <property type="Float" name="AnisoY" value="0.5" />
   <property type="BitMap" name="smooth_map" value="extensions\ego_dlc_terran\assets\characters\terran\textures\char_pio_f_pilot_suit_01_smooth" />
   <property type="BitMap" name="metal_map" value="extensions\ego_dlc_terran\assets\characters\terran\textures\char_pio_f_pilot_suit_01_metal" />
   <property type="BitMap" name="diffuse_map" value="extensions\MYMOD\assets\characters\terran\textures\char_pio_f_pilot_suit_01_diff" />
   <property type="BitMap" name="normal_map" value="extensions\ego_dlc_terran\assets\characters\terran\textures\char_ter_f_pilot_suit_01_normal" />
   <property type="Float" name="diffuseStr" value="1.0" />
   <property type="Float" name="normalStr" value="1.0" />
   <property type="Float" name="specularStr" value="1.0" />
   <property type="Float" name="Smoothness" value="1.0" />
   <property type="Float" name="Metallness" value="1.0" />
   <property type="Float" name="environmentStr" value="1.0" />
  </properties>
</material>
Now i copied the original xac files to my mod folder, edited the material references simply by changing the number to the one i use for my material version with a hex editor without changing the number of characters.
Files are located in the same way as in the dlc.

Now i made a diff patch to the character_macro.xml changing the path of the torso model like this:

Code: Select all

  <replace sel="//macro[@name='character_pioneers_female_cau_civilian_01_macro']/properties/models/model[@type='torso']">
    <model type="torso" selection="random">
      <select index="1" weight="25" ref="extensions/MYMOD/assets/characters/terran/bodies/char_pio_f_pilot_suit_01" />
      <select index="2" weight="25" ref="extensions/MYMOD/assets/characters/terran/bodies/char_pio_f_crew_uniform_01" />
    </model>
  </replace>
...to all 15 variants.

I start the game, i am located in a neighbor sector, a ship docked at a PIO ED, so i can get fresh instantiated characters. But most of them are simply invisible, some have heads but no bodies.

I have the assumption it has something to do with the path, and that for example the terran character_macro.xml is a merge, but the material_library.xml a diff patch. But i don't understand really how that might affect the way i need to patch over these files while my material diff patch nothing replaces. Usually, a merge can be patched by a diff in the root of the mod folder, but patching another patch might require following the same folder structure again inside of the mod folder. But i am not sure, it has worked this way in another case where i patched some dlc files, but here it doesn't. The character_macro is a merge, so it should be fine being in the root of the mod, where i already made some other changes to terran characters that do work.
I have also set the dlc as dependency.

What am i missing here? :gruebel:

Do i need to set this up as another mod since i already made some changes to the character_macro.xml? Or is there a specific order necessary inside of a diff patch that changes multiple different child elements?

And what exactly is this "Ptr" (pointer)?
Last edited by Xkuka on Wed, 19. Apr 23, 19:12, edited 1 time in total.
***Never not modified***
Specs: I9 9900k, 32GB DDR4, ASUS RTX2060 12GB, Sys drive: 1TB Nvme SSD, Games drive: 1TB Nvme SSD, Win10 pro 21H2
User avatar
Xkuka
Posts: 245
Joined: Sun, 14. Mar 10, 19:25
x4

Re: [help] [SCharacterInstance::Init] Could not get Ptr to model

Post by Xkuka »

Ok i got it. My attempt to be less intrusive failed. I did not want to overwrite the original files and change nodes that don't need changing, in case they could be useful and for compatibility.
But in the end i had to do that. Not picking specific nodes and trying to duplicate the assets, but rolling over it replacing complete macros and replacing the the path that leads to the original texture file works.

And in the meantime i also managed for the first time crashing the game with my edits. Perhaps meddling with a hex editor in mesh files isn't as recommendable as i read in a tutorial^^ Or i did something wrong. Sadly there isn't any reference for that purpose and no other mod that actually did what i just did, at least not in that way as far as i know.
That confirms that in order to change a surface texture it is not necessary to touch any mesh directly. Everything is in the materials_library.xml.
But i still would like to be able to duplicate stuff in order to create more variety. If anyone knows more how to properly deal with meshes and only changing the material references in them i would be delighted to learn about it.
***Never not modified***
Specs: I9 9900k, 32GB DDR4, ASUS RTX2060 12GB, Sys drive: 1TB Nvme SSD, Games drive: 1TB Nvme SSD, Win10 pro 21H2
User avatar
Dj_FRedy
Posts: 245
Joined: Mon, 27. Jun 11, 05:58
x4

Re: [help] (partly solved) [SCharacterInstance::Init] Could not get Ptr to model

Post by Dj_FRedy »

I was curious to see if I could make this work, my steps for testing:

Code: Select all

└───z_df_template_mod
    ├───extensions
    │   └───ego_dlc_terran
    │       └───assets
    │           └───characters
    │               └───terran
    │                   ├───bodies
    │                   └───textures
    └───libraries
└───libraries
character_macros.xml

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff>
    <!-- character pio female: crew & marines -->
    <replace sel="//macro[@name='character_pioneers_female_cau_crew_01_macro']/properties/models/model[@type='torso']">
        <model type="torso" selection="random">
            <select index="1" weight="25" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_pilot_suit_01"/>
            <select index="2" weight="25" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_crew_uniform_01"/>
            <select index="3" weight="25" ref="extensions/z_df_template_mod/extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_pilot_suit_02"/>
            <select index="4" weight="25" ref="extensions/z_df_template_mod/extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_crew_uniform_02"/>
        </model>
    </replace>

    <replace sel="//macro[@name='character_pioneers_female_afr_crew_01_macro']/properties/models/model[@type='torso']">
        <model type="torso" selection="random">
            <select index="1" weight="25" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_pilot_suit_01"/>
            <select index="2" weight="25" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_crew_uniform_01"/>
            <select index="3" weight="25" ref="extensions/z_df_template_mod/extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_pilot_suit_02"/>
            <select index="4" weight="25" ref="extensions/z_df_template_mod/extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_crew_uniform_02"/>
        </model>
    </replace>

    <replace sel="//macro[@name='character_pioneers_female_asi_crew_01_macro']/properties/models/model[@type='torso']">
        <model type="torso" selection="random">
            <select index="1" weight="25" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_pilot_suit_01"/>
            <select index="2" weight="25" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_crew_uniform_01"/>
            <select index="3" weight="25" ref="extensions/z_df_template_mod/extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_pilot_suit_02"/>
            <select index="4" weight="25" ref="extensions/z_df_template_mod/extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_crew_uniform_02"/>
        </model>
    </replace>

    <replace sel="//macro[@name='character_pioneers_female_cau_marine_01_macro']/properties/models/model[@type='torso']">
        <model type="torso" selection="random">
            <select index="1" weight="25" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_pilot_suit_01"/>
            <select index="2" weight="25" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_crew_uniform_01"/>
            <select index="3" weight="25" ref="extensions/z_df_template_mod/extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_pilot_suit_02"/>
            <select index="4" weight="25" ref="extensions/z_df_template_mod/extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_crew_uniform_02"/>
        </model>
    </replace>

    <replace sel="//macro[@name='character_pioneers_female_afr_marine_01_macro']/properties/models/model[@type='torso']">
        <model type="torso" selection="random">
            <select index="1" weight="25" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_pilot_suit_01"/>
            <select index="2" weight="25" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_crew_uniform_01"/>
            <select index="3" weight="25" ref="extensions/z_df_template_mod/extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_pilot_suit_02"/>
            <select index="4" weight="25" ref="extensions/z_df_template_mod/extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_crew_uniform_02"/>
        </model>
    </replace>

    <replace sel="//macro[@name='character_pioneers_female_asi_marine_01_macro']/properties/models/model[@type='torso']">
        <model type="torso" selection="random">
            <select index="1" weight="25" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_pilot_suit_01"/>
            <select index="2" weight="25" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_crew_uniform_01"/>
            <select index="3" weight="25" ref="extensions/z_df_template_mod/extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_pilot_suit_02"/>
            <select index="4" weight="25" ref="extensions/z_df_template_mod/extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_crew_uniform_02"/>
        </model>
    </replace>
</diff>
material_library.xml

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff>
    <add sel="/materiallibrary/collection[@name='terrancharacters']">
        <!-- pioneer female suit -->
        <material name="ter_p1_char_pio_f_pilot_suit_02" shader="P1_character.fx" blendmode="NONE" preview="none">
            <properties>
                <property type="Float" name="AnisoX" value="0.5"/>
                <property type="Float" name="AnisoY" value="0.5"/>
                <property type="BitMap" name="smooth_map" value="extensions\ego_dlc_terran\assets\characters\terran\textures\char_pio_f_pilot_suit_01_smooth"/>
                <property type="BitMap" name="metal_map" value="extensions\ego_dlc_terran\assets\characters\terran\textures\char_pio_f_pilot_suit_01_metal"/>
                <property type="BitMap" name="diffuse_map" value="extensions\z_df_template_mod\extensions\ego_dlc_terran\assets\characters\terran\textures\char_pio_f_pilot_suit_02_diff"/>
                <property type="BitMap" name="normal_map" value="extensions\ego_dlc_terran\assets\characters\terran\textures\char_ter_f_pilot_suit_01_normal"/>
                <property type="Float" name="diffuseStr" value="1.0"/>
                <property type="Float" name="normalStr" value="1.0"/>
                <property type="Float" name="specularStr" value="1.0"/>
                <property type="Float" name="Smoothness" value="1.0"/>
                <property type="Float" name="Metallness" value="1.0"/>
                <property type="Float" name="environmentStr" value="1.0"/>
            </properties>
        </material>
        <!-- pioneer female uniforms -->
        <material name="ter_p1_char_pio_f_uniform_jacket_crew_02" shader="P1_character.fx" blendmode="NONE" preview="none">
            <properties>
                <property type="Float" name="AnisoX" value="0.5"/>
                <property type="Float" name="AnisoY" value="0.5"/>
                <property type="BitMap" name="smooth_map" value="extensions\ego_dlc_terran\assets\characters\terran\textures\char_ter_f_uniform_jacket_01_smooth"/>
                <property type="BitMap" name="metal_map" value="extensions\ego_dlc_terran\assets\characters\terran\textures\char_pio_f_uniform_jacket_01_metal"/>
                <property type="BitMap" name="diffuse_map" value="extensions\z_df_template_mod\extensions\ego_dlc_terran\assets\characters\terran\textures\char_pio_f_uniform_jacket_02_diff"/>
                <property type="BitMap" name="normal_map" value="extensions\ego_dlc_terran\assets\characters\terran\textures\char_ter_f_uniform_jacket_01_normal"/>
                <property type="Float" name="diffuseStr" value="1.0"/>
                <property type="Float" name="normalStr" value="1.0"/>
                <property type="Float" name="specularStr" value="1.0"/>
                <property type="Float" name="Smoothness" value="1.0"/>
                <property type="Float" name="Metallness" value="1.0"/>
                <property type="Float" name="environmentStr" value="1.0"/>
            </properties>
        </material>
        <material name="ter_p1_char_pio_f_uniform_skirt_crew_02" shader="P1_character.fx" blendmode="NONE" preview="none">
            <properties>
                <property type="Float" name="AnisoX" value="0.5"/>
                <property type="Float" name="AnisoY" value="0.5"/>
                <property type="BitMap" name="smooth_map" value="extensions\ego_dlc_terran\assets\characters\terran\textures\char_ter_f_uniform_skirt_01_smooth"/>
                <property type="BitMap" name="diffuse_map" value="extensions\z_df_template_mod\extensions\ego_dlc_terran\assets\characters\terran\textures\char_pio_f_uniform_skirt_02_diff"/>
                <property type="BitMap" name="normal_map" value="extensions\ego_dlc_terran\assets\characters\terran\textures\char_ter_f_uniform_skirt_01_normal"/>
                <property type="BitMap" name="metal_map" value="extensions\ego_dlc_terran\assets\characters\terran\textures\char_ter_f_uniform_skirt_01_metal"/>
                <property type="Float" name="diffuseStr" value="1.0"/>
                <property type="Float" name="normalStr" value="1.0"/>
                <property type="Float" name="specularStr" value="1.0"/>
                <property type="Float" name="Smoothness" value="1.0"/>
                <property type="Float" name="Metallness" value="1.0"/>
                <property type="Float" name="environmentStr" value="1.0"/>
            </properties>
        </material>
    </add>
</diff>
├───bodies
change 01 for 02 with the hex editor:
char_pio_f_crew_uniform_02.xac
  • [ter_p1_char_pio_f_uniform_jacket_crew_01 ; ter_p1_char_pio_f_uniform_jacket_crew_02]
  • [ter_p1_char_pio_f_uniform_skirt_crew_01 ; ter_p1_char_pio_f_uniform_skirt_crew_02]
char_pio_f_pilot_suit_02.xac
  • [ter_p1_char_pio_f_pilot_suit_01 ; ter_p1_char_pio_f_pilot_suit_02]
└───textures
char_pio_f_pilot_suit_02_diff.gz
char_pio_f_uniform_jacket_02_diff.gz
char_pio_f_uniform_skirt_02_diff.gz

Now the pio females have two colours for their uniforms: https://imgur.com/a/WWZZm1a
I hope that my example will help you and that you will give the ladies better colours than I have given them for this test.
"All my contributions to the Technical Support and Public Beta Feedback sections will be concise and to the point, no diatribes, that's what the other sections are for".
Thank you for your efforts.

Return to “X4: Foundations - Scripts and Modding”