Exemple #1
0
def Chunk0x1000(hndl):
	print("Chunk 0x1000: Decals")
	num = read4u(hndl)
	for i in range(num):
		 read4u(hndl) #SKIP
		 readNstr(hndl) #SKIP
		 readXYZ(hndl)
		 readMt33(hndl)
		 readNstr(hndl) #SKIP
		 read1u(hndl) #SKIP
		 readflt(hndl)
		 readflt(hndl)
		 readflt(hndl)
		 readNstr(hndl)
		 read4u(hndl)
		 read1u(hndl)
		 if (LVLVersion >= 265 ):
		    read1u(hndl)
		 if (LVLVersion >= 294 ):
		    read1u(hndl)
		 if (LVLVersion >= 280 ):
		    read1u(hndl)
		    read1u(hndl)
		 read4u(hndl)
		 readflt(hndl)
		 if (LVLVersion >= 261 ):
		    read4u(hndl)
		 if (LVLVersion >= 262 ):
		    read4u(hndl)
Exemple #2
0
def Chunk0x7680(hndl):
	print("Chunk 0x7680: Related to effects??")
	num = read4u(hndl)
	for i in range(num):
		read4u(hndl)
		readNstr(hndl)
		readXYZ(hndl)
		readMt33(hndl)
		readNstr(hndl)
		read1u(hndl)
		read4u(hndl)
		read4u(hndl) #SKIP
		read4u(hndl)
		if (LVLVersion >= 260):
			read4u(hndl)
		read4u(hndl)
		read4u(hndl)
		if (LVLVersion >= 228):
			read4u(hndl)
			read1u(hndl)
			read1u(hndl)
		if (LVLVersion >= 240):
			readflt(hndl)
			readflt(hndl)
			readNstr(hndl)
			read1u(hndl)
Exemple #3
0
def Chunk0x400(hndl): ##Cutscene and camera related
	print("Chunk 0x400: Cutscene and camera related")
	num = read4u(hndl)
	for i in range(num):
		 read4u(hndl)
		 readNstr(hndl)
		 readXYZ(hndl)
		 readMt33(hndl)
		 readNstr(hndl)
		 read1u(hndl)
Exemple #4
0
def Chunk0xD00(hndl):
	print("Chunk 0xD00:")
	num = read4u(hndl)
	for i in range(num):
		 read4u(hndl)
		 readNstr(hndl)
		 readXYZ(hndl)
		 readMt33(hndl)
		 readNstr(hndl)
		 read1u(hndl)
		 read4u(hndl)
		 readXYZ(hndl)
Exemple #5
0
def Chunk0x7677(hndl):
	print("Chunk 0x7677: ??")
	num = read4u(hndl)
	for i in range(num):
		read4u(hndl)
		readNstr(hndl)
		readXYZ(hndl)
		readMt33(hndl)
		readNstr(hndl)
		read1u(hndl)
		readXYZ(hndl)
		readflt(hndl)
		read1u(hndl)
		readflt(hndl)
		read1u(hndl)
Exemple #6
0
def Chunk0x2000(hndl):
	print("Chunk 0x2000: Level Geometry")
	num = read4u(hndl)
	tmp = list()
	
	for i in range(num):
		mvr = MoverBrush()
		mvr.ID = read4u(hndl)
		mvr.Pos = readXYZ(hndl)
		mvr.Mt33 = readMt33(hndl)
		mvr.Geom = GeomReader(hndl)
		
		tmp.append(mvr)
		
		v5 = read4u(hndl)
		read4u(hndl)
		read4u(hndl)
		
		if (v5 & 8):
			read4u(hndl)
			read4u(hndl)
			read4u(hndl)
			read4u(hndl)
			readflt(hndl)
			readflt(hndl)
			readflt(hndl)
			readflt(hndl)
			read4u(hndl)
			readflt(hndl)
			read1u(hndl)
	### i in range(num)
	
	return tmp
Exemple #7
0
def Chunk0x7678(hndl):
	print("Chunk 0x7678: Lights glare/corona/beams")
	num = read4u(hndl)
	for i in range(num):
		read4u(hndl)
		readNstr(hndl)
		readXYZ(hndl)
		readMt33(hndl)
		readNstr(hndl)
		read1u(hndl)
		read4u(hndl)
		if (LVLVersion >= 259 ):
		    read1u(hndl)
		if (LVLVersion >= 288 ):
		    read1u(hndl)
		if (LVLVersion >= 289 ):
		    read1u(hndl)
		if (LVLVersion >= 292 ):
		    read1u(hndl)
		if (LVLVersion < 232 ):
			read4u(hndl)
		if (LVLVersion >= 232 ):
			read1u(hndl)
			
		s = readNstr(hndl)
		if (s != ""):
			readflt(hndl)
			readflt(hndl)
			readflt(hndl)
			readflt(hndl)
			readflt(hndl)
			
		s = readNstr(hndl)
		if (s != ""):
			readflt(hndl)
			readflt(hndl)
			readflt(hndl)
			
		if (LVLVersion >= 276 ):
			read1u(hndl)
		
		for j in range( read4u(hndl) ):
			read4u(hndl)
Exemple #8
0
def Chunk0x1100(hndl):
	print("Chunk 0x1100: Push Region???")
	num = read4u(hndl)
	for i in range(num):
		read4u(hndl)
		readNstr(hndl)
		readXYZ(hndl)
		readMt33(hndl)
		readNstr(hndl)
		read1u(hndl)
		a = read4u(hndl)
		if (a == 3):
			readXYZ(hndl)
		elif (a == 2):
			readXYZ(hndl)
		else:
			readflt(hndl)
		readflt(hndl)
		read4u(hndl)
Exemple #9
0
def Chunk0x7777(hndl):
	print("Chunk 0x7777: Event - conversation")
	num = read4u(hndl)
	for i in range(num):
		read4u(hndl)
		readNstr(hndl)
		readXYZ(hndl)
		readMt33(hndl)
		readNstr(hndl)
		read1u(hndl)
		for j in range(read4u(hndl)):
			read4u(hndl)
			read4u(hndl)
			readflt(hndl)
			readFixNstr(hndl, 0x18)
			read4u(hndl)
			read4u(hndl)
			read4u(hndl)
			readFixNstr(hndl, 0x10)
		readflt(hndl)
Exemple #10
0
def Chunk0x30000(hndl):
	print("Chunk 0x30000: Entities")
	EntLst = list()
	num = read4u(hndl)
	for i in range(num):
		ent = Entity()
		EntLst.append(ent)
		
		read4u(hndl)
		ent.Tp = readNstr(hndl) # Type
		ent.Pos = readXYZ(hndl)
		ent.Mt33 = readMt33(hndl)
		readNstr(hndl)  # Name
		read1u(hndl)
		read4u(hndl)
		read4u(hndl)
		if (LVLVersion >= 274):
			read4u(hndl)
		read4u(hndl)
		readNstr(hndl)
		readNstr(hndl)
		
		v65 = 0
		 ### Read flags
		if (LVLVersion >= 248):
			flg = read4u(hndl)
			if (LVLVersion >= 263):
				read4u(hndl)
			
			if (flg & (1 << 17)) != 0:
				v65 = 1
		else:
			read1u(hndl) ##SKIP
			read1u(hndl)
			read1u(hndl)
			read1u(hndl)
			read1u(hndl) ##SKIP
			read1u(hndl)
		
		read4u(hndl)
		read4u(hndl)
		if (LVLVersion < 248):
			read1u(hndl)
			read1u(hndl)
			read1u(hndl)
		
		readflt(hndl)
		readflt(hndl)
		if (LVLVersion >= 242):
			readflt(hndl)
			readflt(hndl)
		
		read4u(hndl)
		
		readNstr(hndl)
		readNstr(hndl)
		readNstr(hndl)
		readNstr(hndl)
		readNstr(hndl)
		readNstr(hndl)
		readNstr(hndl)
		if (LVLVersion >= 254):
			readNstr(hndl)
		
		read1u(hndl)
		read1u(hndl)
		
		if (LVLVersion < 232):
			for j in range( read4u(hndl) ):
				readNstr(hndl)
				read4u(hndl)
		
		read4u(hndl)
		read4u(hndl)
		read4u(hndl) #SKIP
		
		if (LVLVersion < 248):
			read1u(hndl)
			read1u(hndl)
			read1u(hndl) #SKIP
			read1u(hndl)
			read1u(hndl)
			read1u(hndl)
			read1u(hndl)
			read1u(hndl)
			read1u(hndl)
			read1u(hndl)
			read1u(hndl)
			read1u(hndl)
			read1u(hndl)
			read1u(hndl)
			if (LVLVersion >= 246):
				read1u(hndl)
			read1u(hndl)
			read1u(hndl)
			v65 = read1u(hndl)
		
		if (v65):
			readflt(hndl)
			if (LVLVersion >= 214):
				readflt(hndl)
				
		if (LVLVersion < 254):
			readNstr(hndl)
			readNstr(hndl)
		
		if (LVLVersion >= 218):
			read4u(hndl)
			read1u(hndl)
		
		if (LVLVersion >= 253):
			readflt(hndl)
		
		if (LVLVersion >= 255):
			readflt(hndl)
			
		if (LVLVersion >= 281):
			readflt(hndl)
		
		if (LVLVersion >= 241 and LVLVersion < 248):
			read1u(hndl)
		
		n = 18
		if (LVLVersion >= 267):
			n = 19
		
		for j in range(n):
			readNstr(hndl)
			readNstr(hndl)
	
	return EntLst
Exemple #11
0
def LoadRfc(fname):
    global FVER
    rfc = RFC()

    fl = open(fname, "rb")

    fl.seek(0, 2)
    SZ = fl.tell()
    fl.seek(0, 0)

    if (read4u(fl) != 0x87128712):
        print("Not a RFC")
        exit(-1)

    pegname = fname
    if (pegname.rfind(".") >= 0):
        if pegname.rfind(".rfc") >= 0:
            pegname = pegname[:pegname.rfind(".")] + "_vcm.peg"
        else:
            pegname = pegname[:pegname.rfind(".")] + "_v3d.peg"
        if os.path.exists(pegname):
            rfc.Peg = ReadPeg(pegname)

    FVER = read4u(fl)  # RFC valid version == 0x114

    flg1 = read1u(fl)

    num = read4u(fl)
    for i in range(num):
        sub = RFC_s1()
        sub.Name = readCstr(fl)
        sub.field_18 = read4u(fl)
        sub.pos = readXYZ(fl)
        sub.field_28 = readflt(fl)

        rfc.Lst1.append(sub)

    num = read4u(fl)
    for i in range(num):
        sub = RFC_s2()
        sub.Name = readCstr(fl)
        sub.field_40 = read4u(fl)
        sub.pos = readXYZ(fl)
        sub.field_50 = readFLT4(fl)

        rfc.Lst2.append(sub)
        #print(sub.Name)

    num = read4u(fl)
    if flg1:
        for i in range(num):
            bon = Bone()
            bon.Name = readCstr(fl)
            bon.field_4C = read4u(fl)
            bon.mtx = readMt33(fl)
            bon.pos = readXYZ(fl)

            rfc.Bones.append(bon)

    rfc.ObjNum = read4u(fl)

    ### Pre allocate
    for i in range(rfc.ObjNum):
        rfc.ObjList.append(Object())

    LodNum = read4u(fl)
    rfc.rfc4num = LodNum * rfc.ObjNum

    ### Pre allocate
    for i in range(rfc.rfc4num):
        rfc.LodHeap.append(LodObj())

    jj = 0

    for i in range(rfc.ObjNum):
        obj = rfc.ObjList[i]
        obj.numFlt = read4u(fl)  # Seems always == LodNum

        for j in range(obj.numFlt):
            obj.LodList.append(rfc.LodHeap[jj])
            obj.flts.append(readflt(fl))
            jj += 1

    for i in range(rfc.ObjNum):
        obj = rfc.ObjList[i]
        for j in range(LodNum):
            lodObj = obj.LodList[j]
            lodObj.name1 = readCstr(fl)
            lodObj.name2 = readCstr(fl)
            lodObj.dword1 = read4u(fl)
            lodObj.dword2 = read4u(fl)

    for i in range(rfc.rfc4num):  ## Load LODs
        sub = rfc.LodHeap[i]

        num = read4u(fl)
        for j in range(num):
            sub.skin.Textures.append(readCstr(fl))

        sub.dword2 = read4u(fl)
        for j in range(sub.dword2):
            t42 = RFC_s42()
            sub.t42lst.append(t42)

            read4u(fl)  #SKIP
            read4u(fl)  #SKIP
            t42.Bt1 = read1u(fl)
            read1u(fl)  #SKIP
            read1u(fl)  #SKIP
            read1u(fl)  #SKIP
            read1u(fl)  #SKIP
            read4u(fl)  #SKIP

            for k in range(2):
                if (read1u(fl)):
                    read4u(fl)  #SKIP
                    readNstr(fl)  #SKIP
                    read4u(fl)  #SKIP
                    readflt(fl)  #SKIP
                    read4u(fl)  #SKIP

            read4u(fl)  #SKIP
            for k in range(read4u(fl)):
                readflt(fl)  #SKIP

            readflt(fl)  #SKIP
            readflt(fl)  #SKIP
            readflt(fl)  #SKIP

            t42.nstr = readNstr(fl)

            read4u(fl)  #SKIP

            for k in range(read4u(fl)):
                readflt(fl)  #SKIP

            readflt(fl)  #SKIP

            for k in range(read4u(fl)):
                readflt(fl)  #SKIP

        sub.numGeom = read4u(fl)
        for j in range(sub.numGeom):
            g = Geom()
            sub.skin.GeomList.append(g)

            if (len(rfc.Bones) == 0):  #In some RFM only?
                g.numSimpleVertex = read4u(fl)
                for k in range(g.numSimpleVertex):
                    sv = SimpleVertex()
                    sv.pos = readXYZ(fl)
                    sv.normal = readXYZ(fl)
                    g.SimpleVertexes.append(sv)

            g.TrianglesCount = read4u(fl)
            for k in range(g.TrianglesCount):
                FCvtxEs = (FaceVtx(read4u(fl), readflt(fl), readflt(fl)),
                           FaceVtx(read4u(fl), readflt(fl), readflt(fl)),
                           FaceVtx(read4u(fl), readflt(fl), readflt(fl)))
                g.Triangles.append(FCvtxEs)

            g.TexID = read4u(fl)  #TexID
            g.unk = read4u(fl)
            g.fl1 = readflt(fl)
            if (len(rfc.Bones) != 0):
                g.bts = (read1u(fl), read1u(fl), read1u(fl), read1u(fl))

        sub.skin.Pos = readXYZ(fl)
        sub.skin.fl1 = readflt(fl)
        sub.skin.Bounds = (readXYZ(fl), readXYZ(fl))

        if (len(rfc.Bones) != 0):
            sub.skin.vtxCount = read4u(fl)
            sub.skin.field_40 = read4S(fl)  #Signed!

            for k in range(sub.skin.vtxCount):
                vtx = Vertex()
                sub.skin.vtxList.append(vtx)

                vtx.pos = readXYZ(fl)  ## Vertex
                vtx.normal = readXYZ(fl)  ## Normal
                #print("v {:f} {:f} {:f}".format(vtx.pos.x, vtx.pos.y, vtx.pos.z))

                if (sub.skin.field_40 > 0):
                    vtx.sh1 = read2u(fl)

                for l in range(4):
                    wght = VtxWeights()
                    vtx.Weights.append(wght)

                    wght.boneID = read4u(
                        fl)  #Really it's 1 Signed BYTE, so 255 == -1
                    wght.w = readflt(fl)

                    if (wght.boneID & 0x80):  # Fix it
                        wght.boneID = -128 + (wght.boneID & 0x7F
                                              )  # (255 -> -1)
    return rfc