KcRobin9 / MM1-Map-Editor

A Map Editor for Midtown Madness 1

Home Page:https://kcrobin9.github.io/MM1-Map-Editor/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New Mesh Rotation Wrong During Script Compile.

xrxk1ngx opened this issue · comments

When adding a fresh polygon from blender, that isn't already in the standard example map included in the script, the rotations dont match the values that midtown madness has, causing them to rotate incorrectly when compiling a level with new polygons, based on blenders' coordinate values, and not midtown madness'.

You're right, thanks for pointing it out.

When polygons are imported into Blender, they are rotated -90 degrees along the x-axis to match Blender's coordinate system (where z is up in 3D, instead of y, like in Midtown Madness). Since we do this rotation when importing, do not apply (additional) rotation when exporting, i.e.:

bpy.ops.object.transform_apply(location = True, rotation = False, scale = True)

However, newly created polygons immediately "match" Blender's coordinate system. So when exporting, their coordinates must be transformed to match MM's system.

A solution would be to give new polygons a different prefix (e.g. Q instead of P), and then apply the additional transformation to Q-polygons, but not to P-polygons.

I have fixed the issue. Instead of making separate polygon types, transform the vertices when importing and exporting (thus no model rotation). This way we can also enable the rotation feature:

bpy.ops.object.transform_apply(location = True, rotation = True, scale = True)

Which eases design of Maps, as applying rotation to a polygon is a straightforward way to make hills and walls.

FYI:

    # Convert Game's (x, y, z) to Blender's (x, z, -y)
    transformed_vertices = [(x, -z, y) for x, y, z in script_vertices]