Example #1
0
def make_fog_plane_jms_models(fog_planes,
                              nodes,
                              make_fans=True,
                              optimize=False):
    jms_models = []
    materials = [JmsMaterial("+unused$", "<none>", "+unused$")]

    plane_index = 0
    for fog_plane in fog_planes:
        tris = edge_loop_to_tris(len(fog_plane.vertices.STEPTREE),
                                 make_fan=make_fans)
        verts = [
            JmsVertex(0,
                      vert[0] * 100,
                      vert[1] * 100,
                      vert[2] * 100,
                      tex_v=1.0) for vert in fog_plane.vertices.STEPTREE
        ]

        jms_model = JmsModel("bsp", 0, nodes, materials, (),
                             ("fog_plane_%s" % plane_index, ), verts, tris)

        if optimize:
            jms_model.optimize_geometry(True)

        jms_models.append(jms_model)
        plane_index += 1

    return jms_models
Example #2
0
def make_cluster_portal_jms_models(planes,
                                   clusters,
                                   cluster_portals,
                                   nodes,
                                   make_fans=True,
                                   optimize=False):
    jms_models = []
    materials = [
        JmsMaterial("+portal", "<none>", "+portal"),
        JmsMaterial("+portal&", "<none>", "+portal&")
    ]
    materials[1].properties = ""

    cluster_index = 0
    portals_seen = set()
    verts = []
    tris = []
    for cluster in clusters:
        for portal_index in cluster.portals.STEPTREE:
            if portal_index[0] in portals_seen:
                continue

            portals_seen.add(portal_index[0])
            portal = cluster_portals[portal_index[0]]
            shader = 1 if portal.flags.ai_cant_hear_through_this else 0
            portal_plane = planes[portal.plane_index]

            tris.extend(
                edge_loop_to_tris(len(portal.vertices.STEPTREE),
                                  mat_id=shader,
                                  base=len(verts),
                                  make_fan=make_fans))
            verts.extend(
                JmsVertex(
                    0, vert[0] * 100, vert[1] * 100, vert[2] * 100, tex_v=1.0)
                for vert in portal.vertices.STEPTREE)

    jms_model = JmsModel("bsp", 0, nodes, materials, (), ("cluster_portals", ),
                         verts, tris)

    if optimize:
        jms_model.optimize_geometry(True)

    jms_models.append(jms_model)
    return jms_models