Jump to content

warhammer 40000 sanctus reach model .s4f


dibe91

Recommended Posts

  • Engineer
from inc_noesis import *
import noesis
import rapi
import os

def registerNoesisTypes():
    handle = noesis.register("Warhammer 40000 - Sanctus", ".s4f")
    noesis.setHandlerTypeCheck(handle, noepyCheckType)
    noesis.setHandlerLoadModel(handle, noepyLoadModel)
    noesis.logPopup()
    return 1
        
def noepyCheckType(data):
    bs = NoeBitStream(data)
    if len(data) < 20:
        return 0
    return 1
        
def noepyLoadModel(data, mdlList):
    ctx = rapi.rpgCreateContext()
    bs = NoeBitStream(data)   
    bs.read(1104)
    numMeshes = bs.readUInt()
    bs.read(364)
    Underline = "_"
    Increment = -1
    MeshNum = 0
    baseName = rapi.getExtensionlessName(rapi.getLocalFileName(rapi.getInputName()))
    for i in range(0, numMeshes):
        bs.read(368)
        VtxCount = bs.readUInt()
        IdxCount = bs.readUInt()
        bs.read(56)
        VertexBuffer = bs.readBytes(VtxCount * 12)
        NormalBuffer = bs.readBytes(VtxCount * 36)
        UVBuffer = bs.readBytes(VtxCount * 8)
        IndexBuffer = bs.readBytes(IdxCount * 12)
        IndexEnd = bs.tell()
        IndexCount = int(IdxCount * 3)
        Increment += 1
        MeshNum = Increment
        Digformat = "{:04d}".format(MeshNum)
        rapi.rpgSetName(baseName + Underline + Digformat)
        rapi.rpgBindPositionBufferOfs(VertexBuffer, noesis.RPGEODATA_FLOAT, 12, 0)
        rapi.rpgBindUV1BufferOfs(UVBuffer, noesis.RPGEODATA_FLOAT, 8, 0)
        rapi.rpgBindNormalBufferOfs(NormalBuffer, noesis.RPGEODATA_FLOAT, 36, 0)
        rapi.rpgCommitTriangles(IndexBuffer, noesis.RPGEODATA_UINT, IndexCount, noesis.RPGEO_TRIANGLE)
    mdl = rapi.rpgConstructModel()
    mdlList.append(mdl)
    return 1

 

Link to comment
Share on other sites

  • 3 weeks later...

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...