Package pyffi :: Package utils :: Module mopp
[hide private]
[frames] | no frames]

Module mopp

source code

Create mopps using mopper.exe
Functions [hide private]
 
_skip_terminal_chars(stream)
Skip initial terminal characters (happens when mopper runs via wine).
source code
str
getMopperPath()
Get path to the mopper.
source code
str
getMopperCredits()
Get info about mopper, and credit havok.
source code
tuple of floats, float, list of ints, and list of ints
getMopperOriginScaleCodeWelding(vertices, triangles, material_indices=None)
Generate mopp code and welding info for given geometry.
source code
Variables [hide private]
  __package__ = 'pyffi.utils'
Function Details [hide private]

getMopperPath()

source code 

Get path to the mopper.

>>> path = getMopperPath()
>>> path.endswith("mopper.exe")
True
Returns: str
Path to mopper.exe.
Raises:
  • OSError - If mopper.exe is not found.

getMopperCredits()

source code 

Get info about mopper, and credit havok.

>>> print(getMopperCredits())
Mopper. Copyright (c) 2008, NIF File Format Library and Tools.
All rights reserved.
<BLANKLINE>
Options:
  --help      for usage help
  --license   for licensing details
<BLANKLINE>
Mopper uses havok. Copyright 1999-2008 Havok.com Inc. (and its Licensors).
All Rights Reserved. See www.havok.com for details.
<BLANKLINE>
<BLANKLINE>
Returns: str
Credits string.
Raises:
  • OSError - If mopper.exe is not found or cannot run.

getMopperOriginScaleCodeWelding(vertices, triangles, material_indices=None)

source code 

Generate mopp code and welding info for given geometry. Raises RuntimeError if something goes wrong (e.g. if mopp generator fails, or if mopper.exe cannot be run on the current platform).

Call L{getMopperCredits} before calling this function if you need to credit havok in a console application that uses this function.

For example, creating a mopp for the standard cube:

>>> expected_moppcode = [
...     40, 0, 255, 39, 0, 255, 38, 0, 255, 19, 129, 125, 41, 22, 130,
...     125, 12, 24, 130, 125, 4, 38, 0, 5, 51, 39, 0, 5, 50, 24, 130,
...     125, 4, 40, 0, 5, 59, 16, 255, 249, 12, 20, 130, 125, 4, 39,
...     0, 5, 53, 40, 0, 5, 49, 54, 22, 130, 125, 25, 24, 130, 125, 17,
...     17, 255, 249, 12, 21, 129, 125, 4, 38, 0, 5, 57, 40, 249, 255,
...     58, 56, 40, 249, 255, 52, 24, 130, 125, 4, 39, 249, 255, 55, 38,
...     249, 255, 48]
>>> orig, scale, moppcode, welding_info = getMopperOriginScaleCodeWelding(
...     [(1, 1, 1), (0, 0, 0), (0, 0, 1), (0, 1, 0),
...      (1, 0, 1), (0, 1, 1), (1, 1, 0), (1, 0, 0)],
...     [(0, 4, 6), (1, 6, 7), (2, 1, 4), (3, 1, 2),
...      (0, 2, 4), (4, 1, 7), (6, 4, 7), (3, 0, 6),
...      (0, 3, 5), (3, 2, 5), (2, 0, 5), (1, 3, 6)])
>>> scale
16319749.0
>>> ["%6.3f" % value for value in orig]
['-0.010', '-0.010', '-0.010']
>>> moppcode == expected_moppcode
True
>>> welding_info
[23030, 23247, 23030, 16086, 23247, 23247, 23247, 23247, 23247, 23247, 23247, 16086]
Parameters:
  • vertices (list of tuples of floats) - List of vertices.
  • triangles (list of tuples of ints) - List of triangles (indices referring back to vertex list).
  • material_indices (list of ints) - List of material indices (optional).
Returns: tuple of floats, float, list of ints, and list of ints
The origin as a tuple of floats, the mopp scale as a float, the mopp code as a list of ints, and the welding info as a list of ints.
Raises:
  • RuntimeError - If the mopper has bad output.
  • OSError - If the mopper is not found or cannot run.