1
$\begingroup$

Well, I tried to export a model to UnrealEd 2 (the one from 1999). I tried to check the normals but I have no idea on how to do this conversion. They are all correct on Blender though. Maybe it isn't normals?

Buggy Suzanne Buggy Mushroom

As you can see above, some faces are black and Unreal Engine 1 typically adds some "colored salt" over the worst ones.

So if you have experience with UE1, could you help? :)

Oh, and before I forget, script I use to export to clipboard:

import operator
import functools
import bpy
import subprocess

scale = 64

brush_template = """
Begin Map
Begin Actor Class=Brush Name=Brush0
    CsgOper=CSG_Add
    MainScale=(SheerAxis=SHEER_ZX)
    PostScale=(SheerAxis=SHEER_ZX)
    Level=LevelInfo'MyLevel.LevelInfo0'
    Tag=Brush
    Region=(Zone=LevelInfo'MyLevel.LevelInfo0',iLeaf=-1)
    bSelected=False
    Begin Brush Name=BlenderExportedBrush
        Begin PolyList
            {polygons}
        End PolyList
    End Brush
    Brush=Model'MyLevel.BlenderExportedBrush'
    Name=Brush1
End Actor
End Map
"""

polygon_template = """
            Begin Polygon
                Origin   {origin}
                Normal   {normal}
                TextureU +00000.000000,+00001.000000,+00000.000000
                TextureV +00000.000000,+00000.000000,-00001.000000
                {vertices}
            End Polygon
"""

vertex_template = """
                Vertex {x},{y},{z}
"""

def flog(string):
    open("c:\\tmp\\ub.log", "a").write(string + "\n")

def generate_brush(polygons):
    return brush_template.format(polygons="\n   ".join(polygons))

def generate_polygon(vertices, normal, origin):
    normal = [int(x) for x in normal]
    origin = [int(x) for x in origin]

    nm = normal
    onm = nm
    nm[1] = nm[2]
    nm[2] = str(-int(onm[1]))

    og = origin
    oog = og
    og[1] = og[2]
    og[2] = str(-int(oog[1]))

    nm = [-int(y) for y in nm]

    if nm[0] > 0: nm[0] = "+" + str(nm[0])
    if nm[1] > 0: nm[1] = "+" + str(nm[1])
    if nm[2] > 0: nm[2] = "+" + str(nm[2])

    og = [-int(y) for y in og]

    if og[0] > 0: og[0] = "+" + str(og[0])
    if og[1] > 0: og[1] = "+" + str(og[1])
    if og[2] > 0: og[2] = "+" + str(og[2])

    flog(str(nm))
    return polygon_template.format(vertices="\n ".join(vertices), normal=",".join([str(x) for x in nm]), origin=",".join([str(y) for y in og]))

def generate_vertex(x, y, z):
    if x >= 0: x = "+" + str(x)
    if y >= 0: y = "+" + str(y)
    if z >= 0: z = "+" + str(z)

    return vertex_template.format(x=x, y=y, z=z)

def convert_mesh(object=bpy.context.object):
    mesh = object.data

    vertices = [x.co for x in mesh.vertices]
    polygons = mesh.polygons

    result = ""

    polys = []

    for poly in polygons:
        median = [functools.reduce(operator.add, x) for x in [vertices[i] for i in poly.vertices]]
        polygon_vertices = []

        for vi in poly.vertices:
            polygon_vertices.append(vertices[vi])

        polys.append(generate_polygon([generate_vertex(*[x * scale for x in v]) for v in polygon_vertices], poly.normal, (0, 0, 0)))

    return generate_brush(polys)

result = convert_mesh()

p = subprocess.Popen(["clip"], stdin=subprocess.PIPE)

res = result.splitlines()
result = ""

for l in res:
    if l.replace(" ", "").replace(" ", "") != "":
        result += "\n" + l

result = result[1:]

p.communicate(input=result.encode("utf-8"))

Clipboard result of the mushroom:

Begin Map
Begin Actor Class=Brush Name=Brush0
    CsgOper=CSG_Add
    MainScale=(SheerAxis=SHEER_ZX)
    PostScale=(SheerAxis=SHEER_ZX)
    Level=LevelInfo'MyLevel.LevelInfo0'
    Tag=Brush
    Region=(Zone=LevelInfo'MyLevel.LevelInfo0',iLeaf=-1)
    bSelected=False
    Begin Brush Name=BlenderExportedBrush
        Begin PolyList
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.9723204970359802,-0.08801952749490738,-0.08801952749490738
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -118.52799987792969,-128.0,+82.3888168334961
    Vertex -139.83999633789062,+0.0,+75.91569519042969
    Vertex -128.0,+0.0,-127.72618103027344
    Vertex -96.42666625976562,-112.21333312988281,-127.72618103027344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   +0.05548539012670517,-0.09262502938508987,-0.09262502938508987
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -118.52799987792969,+128.0,+82.3888168334961
    Vertex +120.1066665649414,+120.1066665649414,+86.70423126220703
    Vertex +96.42666625976562,+96.42666625976562,-127.72618103027344
    Vertex -96.42666625976562,+112.21333312988281,-127.72618103027344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   +0.99395751953125,-0.10976480692625046,-0.10976480692625046
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +120.1066665649414,+120.1066665649414,+86.70423126220703
    Vertex +120.1066665649414,-120.1066665649414,+86.70423126220703
    Vertex +96.42666625976562,-96.42666625976562,-127.72618103027344
    Vertex +96.42666625976562,+96.42666625976562,-127.72618103027344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   +0.05548539012670517,-0.09262502938508987,-0.09262502938508987
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +120.1066665649414,-120.1066665649414,+86.70423126220703
    Vertex -118.52799987792969,-128.0,+82.3888168334961
    Vertex -96.42666625976562,-112.21333312988281,-127.72618103027344
    Vertex +96.42666625976562,-96.42666625976562,-127.72618103027344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -4.461240266095956e-08,-1.0,-1.0
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -96.42666625976562,-112.21333312988281,-127.72618103027344
    Vertex -128.0,+0.0,-127.72618103027344
    Vertex -96.42666625976562,+112.21333312988281,-127.72618103027344
    Vertex +96.42666625976562,+96.42666625976562,-127.72618103027344
    Vertex +96.42666625976562,-96.42666625976562,-127.72618103027344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.030650785192847252,+0.9995301961898804,+0.9995301961898804
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +120.1066665649414,-120.1066665649414,+86.70423126220703
    Vertex +120.1066665649414,+120.1066665649414,+86.70423126220703
    Vertex -118.52799987792969,+128.0,+82.3888168334961
    Vertex -139.83999633789062,+0.0,+75.91569519042969
    Vertex -118.52799987792969,-128.0,+82.3888168334961
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.03878017142415047,-0.9099699258804321,-0.9099699258804321
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -118.52799987792969,+128.0,+82.3888168334961
    Vertex -94.8479995727539,+227.58399963378906,+144.62783813476562
    Vertex +96.42666625976562,+240.2133331298828,+124.13972473144531
    Vertex +120.1066665649414,+120.1066665649414,+86.70423126220703
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.05260470137000084,-0.8988032937049866,-0.8988032937049866
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +120.1066665649414,-120.1066665649414,+86.70423126220703
    Vertex +96.42666625976562,-240.2133331298828,+124.13972473144531
    Vertex -110.23999786376953,-220.47999572753906,+148.7847900390625
    Vertex -118.52799987792969,-128.0,+82.3888168334961
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.7732755541801453,+0.5755140781402588,+0.5755140781402588
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +120.1066665649414,-120.1066665649414,+86.70423126220703
    Vertex +96.42666625976562,-240.2133331298828,+124.13972473144531
    Vertex +133.9199981689453,-220.47999572753906,+151.67999267578125
    Vertex +139.83999633789062,-116.16000366210938,+125.10479736328125
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.8505507707595825,+0.4358569085597992,+0.4358569085597992
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +96.42666625976562,+240.2133331298828,+124.13972473144531
    Vertex +120.1066665649414,+120.1066665649414,+86.70423126220703
    Vertex +139.83999633789062,+116.16000366210938,+125.10479736328125
    Vertex +113.79199981689453,+227.58399963378906,+146.94400024414062
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.8894340991973877,+0.4570634961128235,+0.4570634961128235
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +120.1066665649414,+120.1066665649414,+86.70423126220703
    Vertex +120.1066665649414,-120.1066665649414,+86.70423126220703
    Vertex +139.83999633789062,-116.16000366210938,+125.10479736328125
    Vertex +139.83999633789062,+116.16000366210938,+125.10479736328125
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.24201105535030365,+0.970273494720459,+0.970273494720459
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +139.83999633789062,+116.16000366210938,+125.10479736328125
    Vertex +139.83999633789062,-116.16000366210938,+125.10479736328125
    Vertex +218.11199951171875,-113.79199981689453,+144.62783813476562
    Vertex +218.11199951171875,+113.79199981689453,+144.62783813476562
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.5814716815948486,-0.8076440691947937,-0.8076440691947937
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -118.52799987792969,-128.0,+82.3888168334961
    Vertex -220.47999572753906,-122.08000183105469,+148.7847900390625
    Vertex -232.32000732421875,+0.0,+148.7847900390625
    Vertex -139.83999633789062,+0.0,+75.91569519042969
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.24174341559410095,+0.9399987459182739,+0.9399987459182739
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +139.83999633789062,+116.16000366210938,+125.10479736328125
    Vertex +218.11199951171875,+113.79199981689453,+144.62783813476562
    Vertex +113.79199981689453,+227.58399963378906,+146.94400024414062
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.24135722219944,+0.9370373487472534,+0.9370373487472534
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +139.83999633789062,-116.16000366210938,+125.10479736328125
    Vertex +133.9199981689453,-220.47999572753906,+151.67999267578125
    Vertex +218.11199951171875,-113.79199981689453,+144.62783813476562
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.4813399910926819,-0.6910233497619629,-0.6910233497619629
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -118.52799987792969,-128.0,+82.3888168334961
    Vertex -110.23999786376953,-220.47999572753906,+148.7847900390625
    Vertex -220.47999572753906,-122.08000183105469,+148.7847900390625
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.47979408502578735,-0.688207745552063,-0.688207745552063
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -118.52799987792969,+128.0,+82.3888168334961
    Vertex -220.47999572753906,+122.08000183105469,+148.7847900390625
    Vertex -94.8479995727539,+227.58399963378906,+144.62783813476562
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.6040775179862976,+0.42923009395599365,+0.42923009395599365
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -110.23999786376953,-220.47999572753906,+148.7847900390625
    Vertex -60.82833480834961,-127.57667541503906,+364.8721618652344
    Vertex -127.57667541503906,-66.74833679199219,+364.8721618652344
    Vertex -220.47999572753906,-122.08000183105469,+148.7847900390625
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   +0.6577453017234802,+0.43105629086494446,+0.43105629086494446
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +113.79199981689453,+227.58399963378906,+146.94400024414062
    Vertex +60.82833480834961,+127.57667541503906,+364.8721618652344
    Vertex +127.57667541503906,+60.82833480834961,+364.8721618652344
    Vertex +218.11199951171875,+113.79199981689453,+144.62783813476562
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.5890870094299316,+0.41763779520988464,+0.41763779520988464
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -220.47999572753906,+122.08000183105469,+148.7847900390625
    Vertex -127.57667541503906,+66.74833679199219,+364.8721618652344
    Vertex -60.82833480834961,+127.57667541503906,+364.8721618652344
    Vertex -94.8479995727539,+227.58399963378906,+144.62783813476562
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   +0.682200014591217,+0.4511701166629791,+0.4511701166629791
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +218.11199951171875,-113.79199981689453,+144.62783813476562
    Vertex +127.57667541503906,-60.82833480834961,+364.8721618652344
    Vertex +60.82833480834961,-127.57667541503906,+364.8721618652344
    Vertex +133.9199981689453,-220.47999572753906,+151.67999267578125
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   +0.9249049425125122,+0.38019853830337524,+0.38019853830337524
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +218.11199951171875,-113.79199981689453,+144.62783813476562
    Vertex +218.11199951171875,+113.79199981689453,+144.62783813476562
    Vertex +127.57667541503906,+60.82833480834961,+364.8721618652344
    Vertex +127.57667541503906,-60.82833480834961,+364.8721618652344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.0034842712339013815,+0.41460251808166504,+0.41460251808166504
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +96.42666625976562,-240.2133331298828,+124.13972473144531
    Vertex +133.9199981689453,-220.47999572753906,+151.67999267578125
    Vertex +60.82833480834961,-127.57667541503906,+364.8721618652344
    Vertex -60.82833480834961,-127.57667541503906,+364.8721618652344
    Vertex -110.23999786376953,-220.47999572753906,+148.7847900390625
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.9066645503044128,+0.41314348578453064,+0.41314348578453064
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -220.47999572753906,+122.08000183105469,+148.7847900390625
    Vertex -232.32000732421875,+0.0,+148.7847900390625
    Vertex -133.49667358398438,+0.0,+364.8721618652344
    Vertex -127.57667541503906,+66.74833679199219,+364.8721618652344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.002911187708377838,+0.41515102982521057,+0.41515102982521057
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +60.82833480834961,+127.57667541503906,+364.8721618652344
    Vertex +113.79199981689453,+227.58399963378906,+146.94400024414062
    Vertex -94.8479995727539,+227.58399963378906,+144.62783813476562
    Vertex -60.82833480834961,+127.57667541503906,+364.8721618652344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   +0.0,+0.7132090330123901,+0.7132090330123901
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +60.82833480834961,-127.57667541503906,+364.8721618652344
    Vertex +30.276165008544922,-64.2167739868164,+427.14312744140625
    Vertex -30.276165008544922,-64.2167739868164,+427.14312744140625
    Vertex -60.82833480834961,-127.57667541503906,+364.8721618652344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -1.3525801989544561e-07,+1.0,+1.0
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +30.276165008544922,+64.2167739868164,+427.14312744140625
    Vertex -30.276165008544922,+64.2167739868164,+427.14312744140625
    Vertex -64.2167739868164,+33.94061279296875,+427.14312744140625
    Vertex -67.8812255859375,+0.0,+427.14312744140625
    Vertex -64.21678161621094,-33.94061279296875,+427.14312744140625
    Vertex -30.276165008544922,-64.2167739868164,+427.14312744140625
    Vertex +30.276165008544922,-64.2167739868164,+427.14312744140625
    Vertex +64.2167739868164,-30.276165008544922,+427.14312744140625
    Vertex +64.2167739868164,+30.276165008544922,+427.14312744140625
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.4561781585216522,+0.733290433883667,+0.733290433883667
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -60.82833480834961,-127.57667541503906,+364.8721618652344
    Vertex -30.276165008544922,-64.2167739868164,+427.14312744140625
    Vertex -64.21678161621094,-33.94061279296875,+427.14312744140625
    Vertex -127.57667541503906,-66.74833679199219,+364.8721618652344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   +0.48368340730667114,+0.7294524312019348,+0.7294524312019348
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +60.82833480834961,+127.57667541503906,+364.8721618652344
    Vertex +30.276165008544922,+64.2167739868164,+427.14312744140625
    Vertex +64.2167739868164,+30.276165008544922,+427.14312744140625
    Vertex +127.57667541503906,+60.82833480834961,+364.8721618652344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.684532105922699,+0.7260647416114807,+0.7260647416114807
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -127.57667541503906,-66.74833679199219,+364.8721618652344
    Vertex -64.21678161621094,-33.94061279296875,+427.14312744140625
    Vertex -67.8812255859375,+0.0,+427.14312744140625
    Vertex -133.49667358398438,+0.0,+364.8721618652344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.4561781585216522,+0.733290433883667,+0.733290433883667
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -127.57667541503906,+66.74833679199219,+364.8721618652344
    Vertex -64.2167739868164,+33.94061279296875,+427.14312744140625
    Vertex -30.276165008544922,+64.2167739868164,+427.14312744140625
    Vertex -60.82833480834961,+127.57667541503906,+364.8721618652344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   +0.7009514570236206,+0.7132090330123901,+0.7132090330123901
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +127.57667541503906,+60.82833480834961,+364.8721618652344
    Vertex +64.2167739868164,+30.276165008544922,+427.14312744140625
    Vertex +64.2167739868164,-30.276165008544922,+427.14312744140625
    Vertex +127.57667541503906,-60.82833480834961,+364.8721618652344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   +0.48368340730667114,+0.7294524312019348,+0.7294524312019348
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +127.57667541503906,-60.82833480834961,+364.8721618652344
    Vertex +64.2167739868164,-30.276165008544922,+427.14312744140625
    Vertex +30.276165008544922,-64.2167739868164,+427.14312744140625
    Vertex +60.82833480834961,-127.57667541503906,+364.8721618652344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   +0.0,+0.7132090330123901,+0.7132090330123901
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -60.82833480834961,+127.57667541503906,+364.8721618652344
    Vertex -30.276165008544922,+64.2167739868164,+427.14312744140625
    Vertex +30.276165008544922,+64.2167739868164,+427.14312744140625
    Vertex +60.82833480834961,+127.57667541503906,+364.8721618652344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   +0.5088033676147461,-0.8608828186988831,-0.8608828186988831
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +120.1066665649414,+120.1066665649414,+86.70423126220703
    Vertex +218.11199951171875,+113.79199981689453,+144.62783813476562
    Vertex +218.11199951171875,-113.79199981689453,+144.62783813476562
    Vertex +120.1066665649414,-120.1066665649414,+86.70423126220703
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   +0.5424513220787048,-0.7373111844062805,-0.7373111844062805
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +133.9199981689453,-220.47999572753906,+151.67999267578125
    Vertex +96.42666625976562,-240.2133331298828,+124.13972473144531
    Vertex +120.1066665649414,-120.1066665649414,+86.70423126220703
    Vertex +218.11199951171875,-113.79199981689453,+144.62783813476562
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   +0.5641618967056274,-0.7056682109832764,-0.7056682109832764
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex +218.11199951171875,+113.79199981689453,+144.62783813476562
    Vertex +120.1066665649414,+120.1066665649414,+86.70423126220703
    Vertex +96.42666625976562,+240.2133331298828,+124.13972473144531
    Vertex +113.79199981689453,+227.58399963378906,+146.94400024414062
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.5814716815948486,-0.8076440691947937,-0.8076440691947937
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -232.32000732421875,+0.0,+148.7847900390625
    Vertex -220.47999572753906,+122.08000183105469,+148.7847900390625
    Vertex -118.52799987792969,+128.0,+82.3888168334961
    Vertex -139.83999633789062,+0.0,+75.91569519042969
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.684532105922699,+0.7260647416114807,+0.7260647416114807
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -67.8812255859375,+0.0,+427.14312744140625
    Vertex -64.2167739868164,+33.94061279296875,+427.14312744140625
    Vertex -127.57667541503906,+66.74833679199219,+364.8721618652344
    Vertex -133.49667358398438,+0.0,+364.8721618652344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.9066645503044128,+0.41314348578453064,+0.41314348578453064
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -232.32000732421875,+0.0,+148.7847900390625
    Vertex -220.47999572753906,-122.08000183105469,+148.7847900390625
    Vertex -127.57667541503906,-66.74833679199219,+364.8721618652344
    Vertex -133.49667358398438,+0.0,+364.8721618652344
End Polygon
Begin Polygon
    Origin   +0,+0,+0
    Normal   -0.9723204970359802,-0.08801952749490738,-0.08801952749490738
    TextureU +00000.000000,+00001.000000,+00000.000000
    TextureV +00000.000000,+00000.000000,-00001.000000
    Vertex -128.0,+0.0,-127.72618103027344
    Vertex -139.83999633789062,+0.0,+75.91569519042969
    Vertex -118.52799987792969,+128.0,+82.3888168334961
    Vertex -96.42666625976562,+112.21333312988281,-127.72618103027344
End Polygon
        End PolyList
    End Brush
    Brush=Model'MyLevel.BlenderExportedBrush'
    Name=Brush1
End Actor
End Map

And here is the mushroom's model.

EDIT 2: I'd also like to point out that some faces displays buggily. For example:

enter image description here

EDIT 3: And, for the blend file of a spike I tried as well:

It's result as seen (with and without lightning; that buggy face won't work with lightning, which makes me think the problem can be with normals. Can someone please point me out to it?): Spikey! Spikey (lightning won't work for that buggy face)

EDIT 4: And finally more info in the Brush Specification.

$\endgroup$
6
  • 1
    $\begingroup$ maybe if you apply the triangulate modifier before exporting? $\endgroup$
    – eromod
    Aug 18, 2016 at 0:59
  • 1
    $\begingroup$ might also be clipping artifacts $\endgroup$
    – eromod
    Aug 18, 2016 at 1:00
  • $\begingroup$ @eromod Tried triangulating, no effect. As for clipping artifacts I'm not sure. Also, I tried with a manifold version of the mushroom, same thing. $\endgroup$
    – wallabra
    Aug 18, 2016 at 17:58
  • $\begingroup$ so the last image at least indicates that there is something terribly wrong with your uv map. You might want to upload the file to blend-exchange.giantcowfilms.com . Before you do that, save your file under a different name, then go to "File - External Data - Pack all into .blend" and save it again. $\endgroup$ Aug 18, 2016 at 19:02
  • $\begingroup$ @metaphor_set Unreal does not uses UV maps per brush. It uses instead textures per face and scales and rotates them individually. I only exported the geometry. $\endgroup$
    – wallabra
    Aug 18, 2016 at 19:21

1 Answer 1

1
$\begingroup$

Unreal Engine 1's normal calculation involves having the vertices in a counter-clockwise direction from the origin.

In this case, I were inserting the origin always at 0,0,0. Which meant these calculations would not work for all of the faces.

The solution was simply placing no Origin section in the template (Unreal defaults it to the position of the first vert on the list) and subtracting the coordinates of all vertices by the coordinates of the first vertex in the list.

Such as this:

import operator
import bpy
import subprocess

scale = 64

brush_template = """
Begin Map
Begin Actor Class=Brush Name=Brush0
    CsgOper=CSG_Add
    MainScale=(SheerAxis=SHEER_ZX)
    PostScale=(SheerAxis=SHEER_ZX)
    Level=LevelInfo'MyLevel.LevelInfo0'
    Tag=Brush
    Region=(Zone=LevelInfo'MyLevel.LevelInfo0',iLeaf=-1)
    bSelected=False
    Begin Brush Name=BlenderExportedBrush
        Begin PolyList
            {polygons}
        End PolyList
    End Brush
    Brush=Model'MyLevel.BlenderExportedBrush'
    Name=Brush1
End Actor
End Map
"""

polygon_template = """
            Begin Polygon Texture=BKGND
                {vertices}
            End Polygon
"""

vertex_template = """
                Vertex {x},{y},{z}
"""

def flog(string):
    open("c:\\tmp\\ub.log", "a").write(string + "\n")

def generate_brush(polygons):
    return brush_template.format(polygons="\n   ".join(polygons))

def generate_polygon(vertices):
    return polygon_template.format(vertices="\n ".join(vertices))

def generate_vertex(x, y, z):
    if x >= 0: x = "+" + str(x)
    if y >= 0: y = "+" + str(y)
    if z >= 0: z = "+" + str(z)

    return vertex_template.format(x=x, y=y, z=z)

def convert_mesh(object=bpy.context.object):
    mesh = object.data

    vertices = [x.co for x in mesh.vertices]
    polygons = mesh.polygons

    result = ""

    polys = []

    for poly in polygons:
        polygon_vertices = []

        for vi in poly.vertices:
            polygon_vertices.append([x - vertices[0][tuple(vertices[vi]).index(x)] for x in vertices[vi]])

        flog("{}: ".format(tuple(polygons).index(poly)) + str(tuple(poly.vertices)))
        polys.append(generate_polygon([generate_vertex(*[x * scale for x in v]) for v in polygon_vertices]))

    return generate_brush(polys)

result = convert_mesh()

p = subprocess.Popen(["clip"], stdin=subprocess.PIPE)

res = result.splitlines()
result = ""

for l in res:
    if l.replace(" ", "").replace(" ", "") != "":
        result += "\n" + l

result = result[1:]

p.communicate(input=result.encode("utf-8"))
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .