[eINFO] Altering Kumquat materials inside a 3d file

Note: The below method demonstrates how to change a Hair model from using the Hair material into using the Trans(parent) material. It can be used to alter it to any of the other materials available in the kumquat class. hkobject attribute name will obviously differ from file to file.

You'll need havok content tools 7.1 32-bit. No other version will work.

First, open up Havok Preview Tool and drag the hair model you want to use into it. The hair models are linked in the CoreClothes.xml file and look like this

    <GameItemType InternalName="Arielle_Head">
        <DisplayName>Arielle Hair</DisplayName>
        <Type>Head</Type>
        <Subtype>Hair</Subtype>
        <CanBeEquipped>1</CanBeEquipped>
        <ArtDef>Arielle_Head_ArtDef</ArtDef>
        <GameItemTypeArtDef InternalName="Arielle_Head_ArtDef">
            <GameItemTypeModelPack InternalName="Arielle_Head_Default">
                <IconFile>ArielleHair.png</IconFile>
                <SupportedUnitModelType>AmarianFemale</SupportedUnitModelType>
                <SupportedUnitModelType>EmpireFemale</SupportedUnitModelType>
                <SupportedUnitModelType>FallenFemale</SupportedUnitModelType>
                <SupportedUnitModelType>IroneerFemale</SupportedUnitModelType>
                <SupportedUnitModelType>KingdomFemale</SupportedUnitModelType>
                <SupportedUnitModelType>MancerFemale</SupportedUnitModelType>
                <SupportedUnitModelType>TarthanFemale</SupportedUnitModelType>
                <SupportedUnitModelType>UrxenFemale</SupportedUnitModelType>
                <SupportedUnitModelType>WraithFemale</SupportedUnitModelType>
                <GameItemTypeModel>
                    <ModelFile>Gfx\HKB\Hair\K_Female_Hair_Royal_Mesh_01.hkb</ModelFile>
                    <AttachmentType>Skinned</AttachmentType>
                    <Texture_Hair>Gfx\HKB\Hair\K_Female_Hair_Texture_02.png</Texture_Hair>
                </GameItemTypeModel>
            </GameItemTypeModelPack>
        </GameItemTypeArtDef>
    </GameItemType>
End of quote

Next, in Havok Preview Tool, click File->Save and select Format: XML (Cross Platform Text). Click Browse button and then in the next screen select "Save as type" -> XML Files. Give a filename (whatever). Click Save. Click OK. Close Havok Preview Tool.

Now you have converted the model into Havok XML. Now go into Explorer and open up the file you just saved.

Search for the "kumquat" text inside the file. There may be multiple occurrences. What you are looking for is what looks something like this

       <hkobject name="#0154" class="hkxEnum" signature="0xc4e1211">
            <!-- memSizeAndFlags SERIALIZE_IGNORED -->
            <!-- referenceCount SERIALIZE_IGNORED -->
            <hkparam name="items" numelements="14">
                <hkobject>
                    <hkparam name="value">0</hkparam>
                    <hkparam name="name">Skin</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">1</hkparam>
                    <hkparam name="name">Hair</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">2</hkparam>
                    <hkparam name="name">Clothing1</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">3</hkparam>
                    <hkparam name="name">Clothing2</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">4</hkparam>
                    <hkparam name="name">Metal</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">5</hkparam>
                    <hkparam name="name">Trans</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">6</hkparam>
                    <hkparam name="name">Primary</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">7</hkparam>
                    <hkparam name="name">Secondary</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">8</hkparam>
                    <hkparam name="name">Roof</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">9</hkparam>
                    <hkparam name="name">TerrainBlend</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">10</hkparam>
                    <hkparam name="name">TerrainOnly</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">11</hkparam>
                    <hkparam name="name">SCROLLTRANSMASK</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">12</hkparam>
                    <hkparam name="name">Eyes</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">13</hkparam>
                    <hkparam name="name">Crest</hkparam>
                </hkobject>
            </hkparam>
        </hkobject>

        <hkobject name="#0155" class="hkxSparselyAnimatedEnum" signature="0x68a47b64">
            <!-- memSizeAndFlags SERIALIZE_IGNORED -->
            <!-- referenceCount SERIALIZE_IGNORED -->
            <hkparam name="ints" numelements="1">
                1
            </hkparam>
            <hkparam name="times" numelements="1">
                0.000000
            </hkparam>
            <hkparam name="enum">#0154</hkparam>
        </hkobject>

        <hkobject name="#0156" class="hkxMaterial" signature="0x2a30cda">
            <!-- memSizeAndFlags SERIALIZE_IGNORED -->
            <!-- referenceCount SERIALIZE_IGNORED -->
            <hkparam name="attributeGroups" numelements="1">
                <hkobject>
                    <hkparam name="name">Kumquat3DSetings</hkparam>
                    <hkparam name="attributes" numelements="1">
                        <hkobject>
                            <hkparam name="name">Kumquat3DMaterialID</hkparam>
                            <hkparam name="value">#0155</hkparam>
                        </hkobject>
                    </hkparam>
                </hkobject>
            </hkparam>
            <hkparam name="name">paradin:lambert29SG</hkparam>
            <hkparam name="stages" numelements="1">
                <hkobject>
                    <hkparam name="texture">#0149</hkparam>
                    <hkparam name="usageHint">TEX_DIFFUSE</hkparam>
                    <hkparam name="tcoordChannel">0</hkparam>
                </hkobject>
            </hkparam>
            <hkparam name="diffuseColor">(1.000000 1.000000 1.000000 1.000000)</hkparam>
            <hkparam name="ambientColor">(0.000000 0.000000 0.000000 1.000000)</hkparam>
            <hkparam name="specularColor">(0.000000 0.000000 0.000000 0.000000)</hkparam>
            <hkparam name="emissiveColor">(0.000000 0.000000 0.000000 1.000000)</hkparam>
            <hkparam name="subMaterials" numelements="0"></hkparam>
            <hkparam name="extraData">null</hkparam>
        </hkobject>
End of quote

in the above XML, change

       <hkobject name="#0155" class="hkxSparselyAnimatedEnum" signature="0x68a47b64">
            <!-- memSizeAndFlags SERIALIZE_IGNORED -->
            <!-- referenceCount SERIALIZE_IGNORED -->
            <hkparam name="ints" numelements="1">
                1
            </hkparam>
            <hkparam name="times" numelements="1">
                0.000000
            </hkparam>
            <hkparam name="enum">#0154</hkparam>
        </hkobject>
End of quote

into

       <hkobject name="#0155" class="hkxSparselyAnimatedEnum" signature="0x68a47b64">
            <!-- memSizeAndFlags SERIALIZE_IGNORED -->
            <!-- referenceCount SERIALIZE_IGNORED -->
            <hkparam name="ints" numelements="1">
                5
            </hkparam>
            <hkparam name="times" numelements="1">
                0.000000
            </hkparam>
            <hkparam name="enum">#0154</hkparam>
        </hkobject>
End of quote

if the number was already 5 (or anything else) you are at the wrong material. Search for another kumquat material entry like above until you find the right one. The number corresponds to the material entry in the XML above it - 5 = trans. 1 = Hair.

When you have changed the right number, save the XML file and close it.

Open Havok Preview Tool and drag your .xml file into it. Go to File->Save and select Format: Win32:MSVC (4101). Then click Browse and select "save as type" "binary HKX files". Enter a filename that is something like YourNewHair.HKB. Click Save. In the pop-up make sure that .HKX was not appended to your Filename. If it was, remove it. Your file should be named YourNewHair.HKB, nothing else. Click OK.

Now you have converted your file back from Havok XML into the format the game uses. Hook up your new 3d model as you normally would in the XML but note the differences below (bolded)

   <GameItemType InternalName="NewHairStyle">
        <DisplayName>Arielle Hair</DisplayName>
        <Type>Head</Type>
        <Subtype>Hair</Subtype>
        <CanBeEquipped>1</CanBeEquipped>
        <ArtDef>NewHairStyle</ArtDef>
        <GameItemTypeArtDef InternalName="NewHairStyle">
            <GameItemTypeModelPack InternalName="NewHairStyle">
                <IconFile>ArielleHair.png</IconFile>
                <SupportedUnitModelType>ShadowMale</SupportedUnitModelType>
                <SupportedUnitModelType>ShadowFemale</SupportedUnitModelType>
                  <GameItemTypeModel>
                    <ModelFile>YourNewHair.hkb</ModelFile>
                    <AttachmentType>Skinned</AttachmentType>
                    <Texture_Trans>Gfx\HKB\Hair\K_Female_Hair_Texture_02.png</Texture_Trans>
                </GameItemTypeModel>
            </GameItemTypeModelPack>
        </GameItemTypeArtDef>
    </GameItemType>
End of quote

Now your hair should appear in-game, transparent instead of using the hair material.

8,856 views 2 replies
Reply #1 Top

Inserting Kumquat materials into files without kumquat materials below: (this part assumes you have a lot more experience than the above post, which just needs you to do some XML editing. In this part I assume you already know how to convert 3d files between Havok XML and other types using Havok Standalone Filter Manager, and that you have everything set up already for your 3d file.)

Let's say you export from Blender or 3ds Max and create a 3d file that you want to give kumquat materials.

Export it as havok XML instead of saving it as .hkb.

Open the .XML file you exported.

Search for ""hkxmesh"" and ""hkxmeshsection"". It should look something like this:

       <hkobject name="#0152" class="hkxMeshSection" signature="0xe2286cf8">
            <!-- memSizeAndFlags SERIALIZE_IGNORED -->
            <!-- referenceCount SERIALIZE_IGNORED -->
            <hkparam name="vertexBuffer">#0151</hkparam>
            <hkparam name="indexBuffers" numelements="1">
                #0150
            </hkparam>
            <hkparam name="material">#0149</hkparam>
            <hkparam name="userChannels" numelements="1">
                #0142
            </hkparam>
        </hkobject>

        <hkobject name="#0153" class="hkxMesh" signature="0xf2edcc5f">
            <!-- memSizeAndFlags SERIALIZE_IGNORED -->
            <!-- referenceCount SERIALIZE_IGNORED -->
            <hkparam name="sections" numelements="10">
                #0152
            </hkparam>
            <hkparam name="userChannelInfos" numelements="1">
                #0059
            </hkparam>
        </hkobject>
End of quote

Note how the hkxMesh references the hkxMeshSection which has a Material assigned to it (bolded above).

What you want to do is change this. Insert the XML below to your file just above the hkxmeshsection hkobject (this is the XML necessary to hook it up to Kumquat classes in-game:

        <hkobject name="#0301" class="hkxEnum" signature="0xc4e1211">
            <!-- memSizeAndFlags SERIALIZE_IGNORED -->
            <!-- referenceCount SERIALIZE_IGNORED -->
            <hkparam name="items" numelements="14">
                <hkobject>
                    <hkparam name="value">0</hkparam>
                    <hkparam name="name">Skin</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">1</hkparam>
                    <hkparam name="name">Hair</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">2</hkparam>
                    <hkparam name="name">Clothing1</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">3</hkparam>
                    <hkparam name="name">Clothing2</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">4</hkparam>
                    <hkparam name="name">Metal</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">5</hkparam>
                    <hkparam name="name">Trans</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">6</hkparam>
                    <hkparam name="name">Primary</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">7</hkparam>
                    <hkparam name="name">Secondary</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">8</hkparam>
                    <hkparam name="name">Roof</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">9</hkparam>
                    <hkparam name="name">TerrainBlend</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">10</hkparam>
                    <hkparam name="name">TerrainOnly</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">11</hkparam>
                    <hkparam name="name">SCROLLTRANSMASK</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">12</hkparam>
                    <hkparam name="name">Eyes</hkparam>
                </hkobject>
                <hkobject>
                    <hkparam name="value">13</hkparam>
                    <hkparam name="name">Crest</hkparam>
                </hkobject>
            </hkparam>
        </hkobject>

        <hkobject name="#0302" class="hkxSparselyAnimatedEnum" signature="0x68a47b64">
            <!-- memSizeAndFlags SERIALIZE_IGNORED -->
            <!-- referenceCount SERIALIZE_IGNORED -->
            <hkparam name="ints" numelements="1">
                0
            </hkparam>
            <hkparam name="times" numelements="1">
                0.041667
            </hkparam>
            <hkparam name="enum">#0301</hkparam>
        </hkobject>

        <hkobject name="#0303" class="hkxMaterial" signature="0x2a30cda">
            <!-- memSizeAndFlags SERIALIZE_IGNORED -->
            <!-- referenceCount SERIALIZE_IGNORED -->
            <hkparam name="attributeGroups" numelements="1">
                <hkobject>
                    <hkparam name="name">Kumquat3DSetings</hkparam>
                    <hkparam name="attributes" numelements="1">
                        <hkobject>
                            <hkparam name="name">Kumquat3DMaterialID</hkparam>
                            <hkparam name="value">#0302</hkparam>
                        </hkobject>
                    </hkparam>
                </hkobject>
            </hkparam>
            <hkparam name="name">lambert2SG</hkparam>
                        <hkparam name="stages" numelements="1">
                <hkobject>
                    <hkparam name="texture">#0083</hkparam>
                    <hkparam name="usageHint">TEX_DIFFUSE</hkparam>
                    <hkparam name="tcoordChannel">0</hkparam>
                </hkobject>
                    </hkparam>
            <hkparam name="diffuseColor">(0.500000 0.500000 0.500000 1.000000)</hkparam>
            <hkparam name="ambientColor">(0.000000 0.000000 0.000000 1.000000)</hkparam>
            <hkparam name="specularColor">(0.000000 0.000000 0.000000 0.000000)</hkparam>
            <hkparam name="emissiveColor">(0.000000 0.000000 0.000000 1.000000)</hkparam>
            <hkparam name="subMaterials" numelements="0"></hkparam>
            <hkparam name="extraData">null</hkparam>
        </hkobject>
End of quote

then alter the hkxMeshSection so it links to Material 0303 instead of its previous material.

<hkparam name="material">#0303</hkparam>
End of quote

The red number above tells the game what material you are actually using (it references the material list in 0301).

 

Note that the numbering of the objects above have to be unique in the file (you can't have two with the same name=""), but you can choose any number between 0000 and 9999. If you need to insert multiple kumquat classes (if you want part of a mesh to be Skin and another Metal for example) you need to alter the XML above so you can insert it in front of every hkxMeshSection. Note how 0303, 0302 and 0301 link to each other so you need to alter their names AND how they link to each other.

Edit: Also note that Havok rearranges the name numbers when you convert from XML to HKB or other types. Do not be surprised if you insert the kumquat class references above into a file, convert it, then convert it back to XML and see your names="" have changed.

Reply #2 Top

You can also use the material to insert a default texture for the model. The model will use that texture if none is assigned from the game. This can be invaluable if you want to insert multiple textures onto the same mesh and use the same material. Multiple Metal textures on the same mesh for example, which you obviously can't do from within the game's XML since each modelfile can only have one <Texture_Metal>.

In the above XML it is already hooked up through this bit

 

               <hkobject>
                    <hkparam name="texture">#0083</hkparam>
                    <hkparam name="usageHint">TEX_DIFFUSE</hkparam>
                    <hkparam name="tcoordChannel">0</hkparam>
                </hkobject> 
End of quote

which would link to a texture object (if its not a hkxTextureFile object the conversion progress nullifies it so no errors)

 

        <hkobject name="#0083" class="hkxTextureFile" signature="0x1e289259">
            <!-- memSizeAndFlags SERIALIZE_IGNORED -->
            <!-- referenceCount SERIALIZE_IGNORED -->
            <hkparam name="filename">Q:\CPELF\FALLEN_ENCHANTRESS\ryzom\Stuff\Tryker\Agents\_textures\monster\ZO_MO_Gibbai_visage.png</hkparam>
            <hkparam name="name">Map #28</hkparam>
            <hkparam name="originalFilename">Q:\CPELF\FALLEN_ENCHANTRESS\ryzom\Stuff\Tryker\Agents\_textures\monster\ZO_MO_Gibbai_visage.png</hkparam>
        </hkobject> 
End of quote

What matters here is the final filename which the game will search for in the /gfx/ folders.