def primitiveSetFromList(cls, primitiveType, vertexIndexList): primitiveSet = osg.DrawElementsUInt(primitiveType, len(vertexIndexList)) arrayPointer = pointer(c_uint.from_address(int(primitiveSet.getDataPointer()))) # pylint: disable=E1101 offset = 0 for vertex in vertexIndexList: arrayPointer[offset] = vertex offset += 1 return primitiveSet
def __init__(self, data): self.data = data self.start = cast(c_char_p(self.data), c_void_p).value self.header = Header.from_address(self.start) vertex_count = c_ushort.from_address(self.start + sizeof(Header)) self.vertices = Array( type=Vertex, address=self.start + sizeof(Header) + sizeof(c_ushort), amount=vertex_count.value, ) triangle_count = c_ushort.from_address(self.vertices.end) self.triangles = Array( type=Triangle, address=self.vertices.end + sizeof(c_ushort), amount=triangle_count.value, ) group_count = c_ushort.from_address(self.triangles.end) self.groups = [] addr = self.triangles.end + sizeof(c_ushort) for i in range(group_count.value): self.groups.append(Group(addr)) addr = self.groups[-1].end material_count = c_ushort.from_address(addr) self.materials = Array( type=Material, address=addr + sizeof(c_ushort), amount=material_count.value, ) addr = self.materials.end self.fps = c_float.from_address(addr) addr += sizeof(c_float) self.current_time = c_float.from_address(addr) addr += sizeof(c_float) self.frame_count = c_int.from_address(addr) addr += sizeof(c_int) joint_count = c_ushort.from_address(addr) addr += sizeof(c_ushort) self.joints = [] for i in range(joint_count.value): joint = Joint(addr) self.joints.append(joint) addr = joint.end sub_version = c_int.from_address(addr) # should be 1 addr += sizeof(c_int) group_comment_count = c_uint.from_address(addr) addr += sizeof(c_uint) #fixme implement group comments (count is currently 0) material_comment_count = c_int.from_address(addr) addr += sizeof(c_int) #fixme implement material comments (count is currently 0) joint_comment_count = c_int.from_address(addr) addr += sizeof(c_int) #fixme implement joint comments (count is currently 0) model_comment_count = c_int.from_address(addr) addr += sizeof(c_int) #fixme implement model comments (count is currently 0) sub_version = c_int.from_address(addr).value addr += sizeof(c_int) if sub_version == 1: extra_type = VertexExtra1 elif sub_version == 2: raise NotImplemented() self.vertex_extras = Array( type=extra_type, address=addr, amount=vertex_count.value, ) addr = self.vertex_extras.end assert addr - self.start == len(data)
def t_uint(address): return c_uint.from_address(address + sizeof(nlattr)).value
def getKBRowFromTableRow(self, row, n): address = c_void_p(KBSharedMemTableRowColon(self.KB_shm_p, row, n)) if address.value == None: return None else: return c_uint.from_address(address.value).value
def getTableRowLength(self, row): address = c_void_p(KBSharedMemTableRowLength(self.KB_shm_p, row)) if address.value == None: return None else: return c_uint.from_address(address.value).value
def __init__(self, data): self.data = data self.start = cast(c_char_p(self.data), c_void_p).value self.header = Header.from_address(self.start) vertex_count = c_ushort.from_address(self.start + sizeof(Header)) self.vertices = Array( type = Vertex, address = self.start + sizeof(Header) + sizeof(c_ushort), amount = vertex_count.value, ) triangle_count = c_ushort.from_address(self.vertices.end) self.triangles = Array( type = Triangle, address = self.vertices.end + sizeof(c_ushort), amount = triangle_count.value, ) group_count = c_ushort.from_address(self.triangles.end) self.groups = [] addr = self.triangles.end+sizeof(c_ushort) for i in range(group_count.value): self.groups.append(Group(addr)) addr = self.groups[-1].end material_count = c_ushort.from_address(addr) self.materials = Array( type = Material, address = addr + sizeof(c_ushort), amount = material_count.value, ) addr = self.materials.end self.fps = c_float.from_address(addr) addr += sizeof(c_float) self.current_time = c_float.from_address(addr) addr += sizeof(c_float) self.frame_count = c_int.from_address(addr) addr += sizeof(c_int) joint_count = c_ushort.from_address(addr) addr += sizeof(c_ushort) self.joints = [] for i in range(joint_count.value): joint = Joint(addr) self.joints.append(joint) addr = joint.end sub_version = c_int.from_address(addr) # should be 1 addr += sizeof(c_int) group_comment_count = c_uint.from_address(addr) addr += sizeof(c_uint) #fixme implement group comments (count is currently 0) material_comment_count = c_int.from_address(addr) addr += sizeof(c_int) #fixme implement material comments (count is currently 0) joint_comment_count = c_int.from_address(addr) addr += sizeof(c_int) #fixme implement joint comments (count is currently 0) model_comment_count = c_int.from_address(addr) addr += sizeof(c_int) #fixme implement model comments (count is currently 0) sub_version = c_int.from_address(addr).value addr += sizeof(c_int) if sub_version == 1: extra_type = VertexExtra1 elif sub_version == 2: raise NotImplemented() self.vertex_extras = Array( type = extra_type, address = addr, amount = vertex_count.value, ) addr = self.vertex_extras.end assert addr - self.start == len(data)