def read(io_stream):
     return AnimationHeader(
         version=Version.read(io_stream),
         name=read_fixed_string(io_stream),
         hierarchy_name=read_fixed_string(io_stream),
         num_frames=read_ulong(io_stream),
         frame_rate=read_ulong(io_stream))
Beispiel #2
0
 def __init__(self,
              version=Version(major=4, minor=2),
              attrs=GEOMETRY_TYPE_NORMAL,
              mesh_name='',
              container_name='',
              face_count=0,
              vert_count=0,
              matl_count=0,
              damage_stage_count=0,
              sort_level=0,
              prelit_version=0,
              future_count=0,
              vert_channel_flags=0,
              face_channel_flags=1,
              min_corner=Vector(),
              max_corner=Vector(),
              sph_center=Vector(),
              sph_radius=0.0):
     self.version = version
     self.attrs = attrs
     self.mesh_name = mesh_name
     self.container_name = container_name
     self.face_count = face_count
     self.vert_count = vert_count
     self.matl_count = matl_count
     self.damage_stage_count = damage_stage_count
     self.sort_level = sort_level
     self.prelit_version = prelit_version
     self.future_count = future_count
     self.vert_channel_flags = vert_channel_flags
     self.face_channel_flags = face_channel_flags
     self.min_corner = min_corner
     self.max_corner = max_corner
     self.sph_center = sph_center
     self.sph_radius = sph_radius
class CompressedAnimationHeader(Struct):
    version = Version()
    name = ""
    hierarchy_name = ""
    num_frames = 0
    frame_rate = 0
    flavor = 0

    @staticmethod
    def read(io_stream):
        return CompressedAnimationHeader(
            version=Version.read(io_stream),
            name=read_fixed_string(io_stream),
            hierarchy_name=read_fixed_string(io_stream),
            num_frames=read_ulong(io_stream),
            frame_rate=read_ushort(io_stream),
            flavor=read_ushort(io_stream))

    @staticmethod
    def size(include_head=True):
        return const_size(44, include_head)

    def write(self, io_stream):
        write_chunk_head(
            W3D_CHUNK_COMPRESSED_ANIMATION_HEADER, io_stream,
            self.size(False))
        self.version.write(io_stream)
        write_fixed_string(self.name, io_stream)
        write_fixed_string(self.hierarchy_name, io_stream)
        write_ulong(self.num_frames, io_stream)
        write_ushort(self.frame_rate, io_stream)
        write_ushort(self.flavor, io_stream)
Beispiel #4
0
 def read(io_stream):
     return CompressedAnimationHeader(
         version=Version.read(io_stream),
         name=read_fixed_string(io_stream),
         hierarchy_name=read_fixed_string(io_stream),
         num_frames=read_ulong(io_stream),
         frame_rate=read_ushort(io_stream),
         flavor=read_ushort(io_stream))
Beispiel #5
0
 def __init__(self,
              version=Version(major=1, minor=0),
              lod_count=1,
              model_name='',
              hierarchy_name=''):
     self.version = version
     self.lod_count = lod_count
     self.model_name = model_name
     self.hierarchy_name = hierarchy_name
Beispiel #6
0
 def __init__(self,
              version=Version(major=4, minor=1),
              name='',
              num_pivots=0,
              center_pos=Vector((0.0, 0.0, 0.0))):
     self.version = version
     self.name = name
     self.num_pivots = num_pivots
     self.center_pos = center_pos
 def read(io_stream):
     ver = Version.read(io_stream)
     flags = read_ulong(io_stream)
     return CollisionBox(version=ver,
                         box_type=(flags & ATTRIBUTE_MASK),
                         collision_types=(flags & COLLISION_TYPE_MASK),
                         name_=read_long_fixed_string(io_stream),
                         color=RGBA.read(io_stream),
                         center=read_vector(io_stream),
                         extend=read_vector(io_stream))
 def read(io_stream):
     ver = Version.read(io_stream)
     flags = read_ulong(io_stream)
     return Box(version=ver,
                box_type=(flags & 0b11),
                collision_types=(flags & 0xFF0),
                name_=read_long_fixed_string(io_stream),
                color=RGBA.read(io_stream),
                center=read_vector(io_stream),
                extend=read_vector(io_stream))
Beispiel #9
0
 def __init__(self,
              version=Version(major=4, minor=1),
              name='',
              hierarchy_name='',
              num_frames=0,
              frame_rate=0):
     self.version = version
     self.name = name
     self.hierarchy_name = hierarchy_name
     self.num_frames = num_frames
     self.frame_rate = frame_rate
Beispiel #10
0
 def __init__(
         self,
         version=Version(major=0, minor=1),  # is 1.0  for motion channels
         name='',
         hierarchy_name='',
         num_frames=0,
         frame_rate=0,
         flavor=0):
     self.version = version
     self.name = name
     self.hierarchy_name = hierarchy_name
     self.num_frames = num_frames
     self.frame_rate = frame_rate
     self.flavor = flavor
 def __init__(self,
              version=Version(),
              box_type=0,
              collision_types=0,
              name_='',
              color=RGBA(),
              center=Vector((0.0, 0.0, 0.0)),
              extend=Vector((0.0, 0.0, 0.0)),
              joypad_picking_only=False):
     self.version = version
     self.box_type = box_type
     self.collision_types = collision_types
     self.name_ = name_
     self.color = color
     self.center = center
     self.extend = extend
     self.joypad_picking_only = joypad_picking_only
Beispiel #12
0
 def read(io_stream):
     return MeshHeader(
         version=Version.read(io_stream),
         attrs=read_ulong(io_stream),
         mesh_name=read_fixed_string(io_stream),
         container_name=read_fixed_string(io_stream),
         face_count=read_ulong(io_stream),
         vert_count=read_ulong(io_stream),
         matl_count=read_ulong(io_stream),
         damage_stage_count=read_ulong(io_stream),
         sort_level=read_ulong(io_stream),
         prelit_version=read_ulong(io_stream),
         future_count=read_ulong(io_stream),
         vert_channel_flags=read_ulong(io_stream),
         face_channel_flags=read_ulong(io_stream),
         # bounding volumes
         min_corner=read_vector(io_stream),
         max_corner=read_vector(io_stream),
         sph_center=read_vector(io_stream),
         sph_radius=read_float(io_stream))
class Box(Struct):
    version = Version()
    box_type = 0
    collision_types = 0
    name_ = ""
    color = RGBA()
    center = Vector((0.0, 0.0, 0.0))
    extend = Vector((0.0, 0.0, 0.0))

    def name(self):
        if '.' in self.name_:
            return self.name_.split('.')[1]
        return self.name_

    @staticmethod
    def read(io_stream):
        ver = Version.read(io_stream)
        flags = read_ulong(io_stream)
        return Box(version=ver,
                   box_type=(flags & 0b11),
                   collision_types=(flags & 0xFF0),
                   name_=read_long_fixed_string(io_stream),
                   color=RGBA.read(io_stream),
                   center=read_vector(io_stream),
                   extend=read_vector(io_stream))

    @staticmethod
    def size():
        return 68

    def write(self, io_stream):
        write_chunk_head(W3D_CHUNK_BOX, io_stream, self.size())

        self.version.write(io_stream)
        write_ulong((self.collision_types & 0xFF)
                    | (self.box_type & 0b11), io_stream)
        write_long_fixed_string(self.name_, io_stream)
        self.color.write(io_stream)
        write_vector(self.center, io_stream)
        write_vector(self.extend, io_stream)
class HLodHeader(Struct):
    version = Version()
    lod_count = 1
    model_name = ""
    hierarchy_name = ""

    @staticmethod
    def read(io_stream):
        return HLodHeader(version=Version.read(io_stream),
                          lod_count=read_ulong(io_stream),
                          model_name=read_fixed_string(io_stream),
                          hierarchy_name=read_fixed_string(io_stream))

    @staticmethod
    def size(include_head=True):
        return const_size(40, include_head)

    def write(self, io_stream):
        write_chunk_head(W3D_CHUNK_HLOD_HEADER, io_stream, self.size(False))
        self.version.write(io_stream)
        write_ulong(self.lod_count, io_stream)
        write_fixed_string(self.model_name, io_stream)
        write_fixed_string(self.hierarchy_name, io_stream)
Beispiel #15
0
class HierarchyHeader(Struct):
    version = Version()
    name = ""
    num_pivots = 0
    center_pos = Vector((0.0, 0.0, 0.0))

    @staticmethod
    def read(io_stream):
        return HierarchyHeader(version=Version.read(io_stream),
                               name=read_fixed_string(io_stream),
                               num_pivots=read_ulong(io_stream),
                               center_pos=read_vector(io_stream))

    @staticmethod
    def size(include_head=True):
        return const_size(36, include_head)

    def write(self, io_stream):
        write_chunk_head(W3D_CHUNK_HIERARCHY_HEADER, io_stream,
                         self.size(False))
        self.version.write(io_stream)
        write_fixed_string(self.name, io_stream)
        write_ulong(self.num_pivots, io_stream)
        write_vector(self.center_pos, io_stream)
Beispiel #16
0
 def read(io_stream):
     return HLodHeader(
         version=Version.read(io_stream),
         lod_count=read_ulong(io_stream),
         model_name=read_fixed_string(io_stream),
         hierarchy_name=read_fixed_string(io_stream))
Beispiel #17
0
class MeshHeader(Struct):
    version = Version()
    attrs = GEOMETRY_TYPE_NORMAL
    mesh_name = ""
    container_name = ""
    face_count = 0
    vert_count = 0
    matl_count = 0
    damage_stage_count = 0
    sort_level = 0
    prelit_version = 0
    future_count = 0
    vert_channel_flags = 0
    face_channel_flags = 1
    min_corner = Vector((0.0, 0.0, 0.0))
    max_corner = Vector((0.0, 0.0, 0.0))
    sph_center = Vector((0.0, 0.0, 0.0))
    sph_radius = 0.0

    @staticmethod
    def read(io_stream):
        return MeshHeader(
            version=Version.read(io_stream),
            attrs=read_ulong(io_stream),
            mesh_name=read_fixed_string(io_stream),
            container_name=read_fixed_string(io_stream),
            face_count=read_ulong(io_stream),
            vert_count=read_ulong(io_stream),
            matl_count=read_ulong(io_stream),
            damage_stage_count=read_ulong(io_stream),
            sort_level=read_ulong(io_stream),
            prelit_version=read_ulong(io_stream),
            future_count=read_ulong(io_stream),
            vert_channel_flags=read_ulong(io_stream),
            face_channel_flags=read_ulong(io_stream),
            # bounding volumes
            min_corner=read_vector(io_stream),
            max_corner=read_vector(io_stream),
            sph_center=read_vector(io_stream),
            sph_radius=read_float(io_stream))

    @staticmethod
    def size(include_head=True):
        return const_size(116, include_head)

    def write(self, io_stream):
        write_chunk_head(W3D_CHUNK_MESH_HEADER, io_stream, self.size(False))
        self.version.write(io_stream)
        write_ulong(self.attrs, io_stream)
        write_fixed_string(self.mesh_name, io_stream)
        write_fixed_string(self.container_name, io_stream)
        write_ulong(self.face_count, io_stream)
        write_ulong(self.vert_count, io_stream)
        write_ulong(self.matl_count, io_stream)
        write_ulong(self.damage_stage_count, io_stream)
        write_ulong(self.sort_level, io_stream)
        write_ulong(self.prelit_version, io_stream)
        write_ulong(self.future_count, io_stream)
        write_ulong(self.vert_channel_flags, io_stream)
        write_ulong(self.face_channel_flags, io_stream)
        write_vector(self.min_corner, io_stream)
        write_vector(self.max_corner, io_stream)
        write_vector(self.sph_center, io_stream)
        write_float(self.sph_radius, io_stream)
Beispiel #18
0
 def read(io_stream):
     return HierarchyHeader(version=Version.read(io_stream),
                            name=read_fixed_string(io_stream),
                            num_pivots=read_ulong(io_stream),
                            center_pos=read_vector(io_stream))
def get_version(major=5, minor=0):
    return Version(major=major, minor=minor)