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.
|