Jump to content

Recommended Posts

  • Engineer
Posted (edited)

edit: renamed .hgdata to .hg-bin (originally it's .bin, so .hg-bin to separate it from the dozens of .bin formats)

Patched the given script for FVFsize=24 (NOT tested with 20 and 40, will fail):

from inc_noesis import *
import noesis
import rapi
import os

def registerNoesisTypes():
    handle = noesis.register("Heroes and Generals", ".hg-bin")
    noesis.setHandlerTypeCheck(handle, noepyCheckType)
    noesis.setHandlerLoadModel(handle, noepyLoadModel)
    #noesis.logPopup()
    return 1

def noepyCheckType(data):
    return 1   

def noepyLoadModel(data, mdlList):
    ctx = rapi.rpgCreateContext()
    bs = NoeBitStream(data)
    bs.seek(len(data) - 0x80, NOESEEK_ABS)
    TMP = bs.tell()
    print(hex(bs.tell()), "here1")
    string = bs.readBytes(0x80) #set range of bytes to search
    index = string.find(b"\x02\x00") #search for 0x02 0x00
    print(hex(bs.tell()), index, "index")
    bs.seek(TMP + index - 2, NOESEEK_ABS)        
    print(hex(bs.tell()), "here3")
    checkVBytes = bs.readInt()
    print(hex(checkVBytes), hex(bs.tell()), "here4")
    if checkVBytes == 0x20018:
        VBytes = 24
    elif checkVBytes == 0x20014:
        VBytes = 20
    elif checkVBytes == 0x20028:
        VBytes = 40
    bs.seek(0x16, NOESEEK_ABS)
    print(hex(bs.tell()), "here5")
    print(VBytes, "vbytes")
    check = 0
    end = len(data)
    meshName = 0
    while check != end:
        meshName += 1
        rapi.rpgSetName(str(meshName))
        VCount = bs.readInt() // VBytes
        print(hex(bs.tell()-4), VCount, "vcount")
        FCount = bs.readInt() // 2
        print(hex(bs.tell()-4), FCount, "fcount")
        bs.seek(4, NOESEEK_REL)
        print(hex(bs.tell()), "VBuf")
        VBuf = bs.readBytes(VCount * VBytes)
        print(hex(bs.tell()), "IBuf")
        IBuf = bs.readBytes(FCount*2) 
        #print(IBuf)
        rapi.rpgBindPositionBufferOfs(VBuf, noesis.RPGEODATA_FLOAT, VBytes, 0)   #position of vertices
        rapi.rpgBindUV1BufferOfs(VBuf, noesis.RPGEODATA_HALFFLOAT, VBytes, 20)   #UVs    
        rapi.rpgCommitTriangles(IBuf, noesis.RPGEODATA_USHORT, FCount, noesis.RPGEO_TRIANGLE, 0) #SHORT for word indices
        TMP2 = bs.tell()
        checkint = bs.readInt(); print("Test sig at ", hex(TMP2), hex(checkint))
        if checkint != checkVBytes:
            TMP2 = bs.tell()
            print("error ")
            check = end
        bs.seek(0x3a, NOESEEK_REL)
        #if checkint == 0:
        #    bs.seek(TMP2, NOESEEK_ABS)
        #    skip = bs.readBytes(0x3e)
        check = bs.tell();
        if check + 1 > end:
            check = end
    mdl = rapi.rpgConstructModel()                                                          
    mdlList.append(mdl)
    rapi.rpgClearBufferBinds()
    return 1

 

Kuebelwagen.png

Edited by shak-otay
.hgdata -> .hg-bin (instead of .bin)
  • Like 2
Posted
5 hours ago, shak-otay said:

修补了 FVFsize=24 的给定脚本(未使用 20 和 40 进行测试,将失败):

from inc_noesis import *
import noesis
import rapi
import os

def registerNoesisTypes():
    handle = noesis.register("Heroes and Generals", ".hgdata")
    noesis.setHandlerTypeCheck(handle, noepyCheckType)
    noesis.setHandlerLoadModel(handle, noepyLoadModel)
    #noesis.logPopup()
    return 1

def noepyCheckType(data):
    return 1   

def noepyLoadModel(data, mdlList):
    ctx = rapi.rpgCreateContext()
    bs = NoeBitStream(data)
    bs.seek(len(data) - 0x80, NOESEEK_ABS)
    TMP = bs.tell()
    print(hex(bs.tell()), "here1")
    string = bs.readBytes(0x80) #set range of bytes to search
    index = string.find(b"\x02\x00") #search for 0x02 0x00
    print(hex(bs.tell()), index, "index")
    bs.seek(TMP + index - 2, NOESEEK_ABS)        
    print(hex(bs.tell()), "here3")
    checkVBytes = bs.readInt()
    print(hex(checkVBytes), hex(bs.tell()), "here4")
    if checkVBytes == 0x20018:
        VBytes = 24
    elif checkVBytes == 0x20014:
        VBytes = 20
    elif checkVBytes == 0x20028:
        VBytes = 40
    bs.seek(0x16, NOESEEK_ABS)
    print(hex(bs.tell()), "here5")
    print(VBytes, "vbytes")
    check = 0
    end = len(data)
    meshName = 0
    while check != end:
        meshName += 1
        rapi.rpgSetName(str(meshName))
        VCount = bs.readInt() // VBytes
        print(hex(bs.tell()-4), VCount, "vcount")
        FCount = bs.readInt() // 2
        print(hex(bs.tell()-4), FCount, "fcount")
        bs.seek(4, NOESEEK_REL)
        print(hex(bs.tell()), "VBuf")
        VBuf = bs.readBytes(VCount * VBytes)
        print(hex(bs.tell()), "IBuf")
        IBuf = bs.readBytes(FCount*2) 
        #print(IBuf)
        rapi.rpgBindPositionBufferOfs(VBuf, noesis.RPGEODATA_FLOAT, VBytes, 0)   #position of vertices
        rapi.rpgBindUV1BufferOfs(VBuf, noesis.RPGEODATA_HALFFLOAT, VBytes, 20)   #UVs    
        rapi.rpgCommitTriangles(IBuf, noesis.RPGEODATA_USHORT, FCount, noesis.RPGEO_TRIANGLE, 0) #SHORT for word indices
        TMP2 = bs.tell()
        checkint = bs.readInt(); print("Test sig at ", hex(TMP2), hex(checkint))
        if checkint != checkVBytes:
            TMP2 = bs.tell()
            print("error ")
            check = end
        bs.seek(0x3a, NOESEEK_REL)
        #if checkint == 0:
        #    bs.seek(TMP2, NOESEEK_ABS)
        #    skip = bs.readBytes(0x3e)
        check = bs.tell();
        if check + 1 > end:
            check = end
    mdl = rapi.rpgConstructModel()                                                          
    mdlList.append(mdl)
    rapi.rpgClearBufferBinds()
    return 1

 

Kuebelwagen.png

Thank you

Posted
On 12/28/2024 at 5:55 PM, Karpati said:

我已经下载并安装了“英雄与将军GC 14.12.17”以获取.hgdata文件。

我确实只找到了数百个 .bin 文件。

您能告诉我您是如何获得 .hgdata 文件的吗?

*:\Program Files (x86)\Steam\steamapps\common\Heroes & Generals\_packed\_objects\ZPrimMesh

This path contains a 3D model, but there was a conflict when I used the noesis script, so *. hgdata is my modified name

 

Heroes and Generals.zip

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...