def extract(self, dg, shallow=False, verbose=False):
        # First get the common Node header
        super(LGHTData, self).extract(dg, verbose)

        # A load of mostly pointless nodes
        self.standard_light_base = cStandardLightBase(dg)
        self.sgres1 = cSGResource(dg)

        # Got name so terminate early if shallow
        if shallow:
            return

        self.light = cLightT(dg)
        self.sgres2 = cSGResource(dg)
        self.refer = cReferentNode(dg)
        self.objgraphnode = cObjectGraphNode(dg)

        # Name
        self.light_name = ParseName(dg)

        # Parameters
        data = dg.get_floats(5)
        self.far_attenuation = data[0]
        self.near_attenuation = data[1]
        self.red = data[2]
        self.green = data[3]
        self.blue = data[4]
Example #2
0
    def extract(self, dg, shallow=False, verbose=False):
        # First get the common RCOLDataBlock header
        super(CRESData, self).extract(dg)

        # Now the Typecode, which radically changes the structure
        self.typecode = dg.get_byte()
        if verbose:
            print("Typecode: %d" % self.typecode)
        if self.typecode == 1:
            # A couple of Nodes
            self.sgres = cSGResource(dg)

            # Got name so terminate early if shallow
            if shallow:
                return

            self.comptreenode = cCompositionTreeNode(dg)
            self.objgraphnode = cObjectGraphNode(dg)

            # A section of Chains
            self.chains = []
            count = dg.get_dword()
            for _ in range(0, count):
                self.chains.append(Chain(dg))

            # Subnode flag and purpose
            self.subnode = ParseBool(dg)
            self.purpose = struct.unpack('I', dg.read(4))[0]
        elif self.typecode == 0:
            self.objgraphnode = cObjectGraphNode(dg)
            self.chains.append(Chain(dg))
            self.objectcount = struct.unpack('I', dg.read(4))[0]
        else:
            raise ValueError("Invalid typecode: %s" %
                             format(self.typecode, '#010x'))

        if verbose:
            print("CRES name: %s" % self.get_name)
Example #3
0
    def extract(self, dg, shallow=False, verbose=False):
        # First get the common RCOLDataBlock header
        super(GMNDData, self).extract(dg)

        # Some nodes
        self.objgraphnode = cObjectGraphNode(dg)
        self.sgres = cSGResource(dg)

        # Got name so terminate early if shallow
        if shallow:
            return

        # Forced relocation?
        if self.version == 11:
            tmp = dg.get_word()
            if tmp == 2:
                self.forced_relocation = True
            elif tmp == 512:
                self.forced_relocation = False
            else:
                raise ValueError("Unexpected forced relocation value %d" % tmp)

        # Assisted geometry
        if self.version == 11 or self.version == 12:
            tmp = dg.get_word()
            if tmp == 1:
                self.assisted_geometry = True
            elif tmp == 256:
                self.assisted_geometry = False
            else:
                raise ValueError("Unexpected assisted geometry value %d" % tmp)
            # Unknown
            tmp = dg.get_byte()
            if tmp != 1:
                raise ValueError("Expected unknown parameter value 1, got %d" %
                                 tmp)

        # Attached RCOLs
        count = dg.get_dword()
        self.attached_RCOLs = []
        for _ in range(count):
            rcol_type = PackedFileType(dg.get_dword())
            if rcol_type.is_rcol():
                rcol_type.RCOLConstructor()(dg, verbose)
            else:
                raise ValueError("%s is not an RCOL type" % str(rcol_type))
    def extract(self, dg, shallow=False, verbose=False):
        # First get the common RCOLDataBlock header
        super(SHPEData, self).extract(dg)

        # Some nodes
        self.sgres = cSGResource(dg)

        # Got name so terminate early if shallow
        if shallow:
            return

        self.refer = cReferentNode(dg)
        self.objgraphnode = cObjectGraphNode(dg)

        # LOD values, if version is at least 6
        if self.version > 6:
            count = dg.get_dword()
            if verbose:
                print("LOD value count = %d" % count)
            #if count > 0:
            self.lod_values = dg.get_dwords(count)

        # Now get LOD blocks
        count = dg.get_dword()
        if verbose:
            print("LOD count = %d" % count)
        self.lods = []
        for _ in range(count):
            self.lods.append(LOD(dg, self.version))

        # Material definitions
        self.matdefs = []
        count = dg.get_dword()
        if verbose:
            print("Matdef count = %d" % count)
        for _ in range(count):
            self.matdefs.append(MaterialDef(dg))