add border in bme

This commit is contained in:
yyc12345 2023-12-27 16:05:35 +08:00
parent 9315ff723d
commit c5ce6e8a2c
4 changed files with 553 additions and 7 deletions

View File

@ -293,11 +293,11 @@ def create_bme_struct(
# if NOT skip, add into valid list
valid_vec_idx: list[int] = []
for vec_idx, proto_vec in enumerate(proto[TOKEN_VERTICES]):
if not _eval_others(proto_vec[TOKEN_VERTICES_SKIP], params):
if _eval_others(proto_vec[TOKEN_VERTICES_SKIP], params) == False:
valid_vec_idx.append(vec_idx)
valid_face_idx: list[int] = []
for face_idx, proto_face in enumerate(proto[TOKEN_FACES]):
if not _eval_others(proto_face[TOKEN_FACES_SKIP], params):
if _eval_others(proto_face[TOKEN_FACES_SKIP], params) == False:
valid_face_idx.append(face_idx)
# create mtl slot remap to help following mesh adding
@ -395,6 +395,10 @@ def create_bme_struct(
# add current face indices count to internal counter
face_counter += indices_count
# fill texture data
mtl_name: str = _eval_others(face_data[TOKEN_FACES_TEXTURE], params)
f.mMtlIdx = mtl_remap[mtl_name]
# return data once
yield f
mesh_part.mFace = face_iterator()
@ -403,6 +407,10 @@ def create_bme_struct(
# then we incursively process instance creation
for proto_instance in proto[TOKEN_INSTANCES]:
# check whether skip this instance
if _eval_others(proto_instance[TOKEN_INSTANCES_SKIP], params) == True:
continue
# calc instance params
instance_params: dict[str, typing.Any] = {}
proto_instance_params: dict[str, str] = proto_instance[TOKEN_INSTANCES_PARAMS]
@ -414,6 +422,7 @@ def create_bme_struct(
proto_instance[TOKEN_INSTANCES_IDENTIFIER],
writer,
bmemtl,
# left-mul transform, because self transform should be applied first, the apply parent's transform
transform @ _eval_others(proto_instance[TOKEN_INSTANCES_TRANSFORM], params),
instance_params
)

View File

@ -0,0 +1,331 @@
[
{
"identifier": "raw_floor_border",
"showcase": null,
"params": [
{
"field": "length",
"data": "5.0"
},
{
"field": "height",
"data": "5.0"
},
{
"field": "face",
"data": "(True, False, False, False, True, False)"
},
{
"field": "is_sink",
"data": "False"
},
{
"field": "border_texture",
"data": "\"FloorTopBorderless\""
},
{
"field": "is_ribbon",
"data": "False"
}
],
"skip": "length == 0.0",
"vars": [
{
"field": "uv_length",
"data": "length / 5.0"
},
{
"field": "uv_border_texture",
"data": "1.0 if is_ribbon else 0.5"
},
{
"field": "sink",
"data": "0.7 if is_sink else 0.0"
}
],
"vertices": [
{
"skip": "False",
"data": "(0, 0, 0)"
},
{
"skip": "False",
"data": "(0, 2.5, -sink)"
},
{
"skip": "False",
"data": "(length, 0, 0)"
},
{
"skip": "False",
"data": "(length, 2.5, -sink)"
}
],
"faces": [
{
"skip": "not face[0]",
"texture": "border_texture",
"indices": [0, 2, 3, 1],
"uvs": [
"(0, 0)",
"(0, uv_length)",
"(uv_border_texture, uv_length)",
"(uv_border_texture, 0)"
],
"normals": [
"(0, sink, 2.5)",
"(0, sink, 2.5)",
"(0, sink, 2.5)",
"(0, sink, 2.5)"
]
}
],
"instances": [
{
"identifier": "raw_floor_side",
"skip": "not face[4]",
"params": {
"height": "height",
"length": "length",
"is_left_sink": "False",
"is_right_sink": "False"
},
"transform": "ident()"
},
{
"identifier": "raw_floor_side",
"skip": "not face[2]",
"params": {
"height": "height",
"length": "2.5",
"is_left_sink": "is_sink",
"is_right_sink": "False"
},
"transform": "move(0, 2.5, 0) @ rot(0, 0, -90)"
},
{
"identifier": "raw_floor_side",
"skip": "not face[3]",
"params": {
"height": "height",
"length": "2.5",
"is_left_sink": "False",
"is_right_sink": "is_sink"
},
"transform": "move(length, 0, 0) @ rot(0, 0, 90)"
},
{
"identifier": "raw_floor_side",
"skip": "not face[5]",
"params": {
"height": "height",
"length": "length",
"is_left_sink": "is_sink",
"is_right_sink": "is_sink"
},
"transform": "move(length, 2.5, 0) @ rot(0, 0, 180)"
},
{
"identifier": "floor_bottom",
"skip": "not face[1]",
"params": {
"length": "length",
"width": "2.5"
},
"transform": "move(0, 0, -height)"
}
]
},
{
"identifier": "floor_normal_border",
"showcase": {
"title": "Normal Border",
"icon": "NormalBorder",
"type": "floor",
"cfgs": [
{
"field": "length_",
"type": "float",
"title": "Length",
"desc": "The length of block.",
"default": "2.5"
},
{
"field": "height_",
"type": "float",
"title": "Height",
"desc": "The height of block.",
"default": "5.0"
},
{
"field": "face_",
"type": "face",
"title": "Face",
"desc": "Whether has some faces.",
"default": "(True, False, False, False, True, False)"
}
]
},
"params": [
{
"field": "length",
"data": "length_"
},
{
"field": "height",
"data": "height_"
},
{
"field": "face",
"data": "face_"
}
],
"skip": "False",
"vars": [],
"vertices": [],
"faces": [],
"instances": [
{
"identifier": "raw_floor_border",
"skip": "False",
"params": {
"length": "length",
"height": "height",
"face": "face",
"is_sink": "False",
"border_texture": "\"FloorTopBorder\"",
"is_ribbon": "False"
},
"transform": "ident()"
}
]
},
{
"identifier": "floor_sink_border",
"showcase": {
"title": "Sink Border",
"icon": "SinkBorder",
"type": "floor",
"cfgs": [
{
"field": "length_",
"type": "float",
"title": "Length",
"desc": "The length of block.",
"default": "2.5"
},
{
"field": "height_",
"type": "float",
"title": "Height",
"desc": "The height of block.",
"default": "5.0"
},
{
"field": "face_",
"type": "face",
"title": "Face",
"desc": "Whether has some faces.",
"default": "(True, False, False, False, True, False)"
}
]
},
"params": [
{
"field": "length",
"data": "length_"
},
{
"field": "height",
"data": "height_"
},
{
"field": "face",
"data": "face_"
}
],
"skip": "False",
"vars": [],
"vertices": [],
"faces": [],
"instances": [
{
"identifier": "raw_floor_border",
"skip": "False",
"params": {
"length": "length",
"height": "height",
"face": "face",
"is_sink": "True",
"border_texture": "\"FloorTopProfil\"",
"is_ribbon": "False"
},
"transform": "ident()"
}
]
},
{
"identifier": "floor_ribbon_border",
"showcase": {
"title": "Ribbon Border",
"icon": "RibbonBorder",
"type": "floor",
"cfgs": [
{
"field": "length_",
"type": "float",
"title": "Length",
"desc": "The length of block.",
"default": "2.5"
},
{
"field": "height_",
"type": "float",
"title": "Height",
"desc": "The height of block.",
"default": "5.0"
},
{
"field": "face_",
"type": "face",
"title": "Face",
"desc": "Whether has some faces.",
"default": "(True, False, False, False, True, False)"
}
]
},
"params": [
{
"field": "length",
"data": "length_"
},
{
"field": "height",
"data": "height_"
},
{
"field": "face",
"data": "face_"
}
],
"skip": "False",
"vars": [],
"vertices": [],
"faces": [],
"instances": [
{
"identifier": "raw_floor_border",
"skip": "False",
"params": {
"length": "length",
"height": "height",
"face": "face",
"is_sink": "True",
"border_texture": "\"FloorTopFlat\"",
"is_ribbon": "True"
},
"transform": "ident()"
}
]
}
]

202
bbp_ng/raw_jsons/sides.json Normal file
View File

@ -0,0 +1,202 @@
[
{
"identifier": "raw_floor_side",
"showcase": null,
"params": [
{
"field": "height",
"data": "5.0"
},
{
"field": "length",
"data": "5.0"
},
{
"field": "is_left_sink",
"data": "False"
},
{
"field": "is_right_sink",
"data": "False"
}
],
"skip": "height <= (0.7 if (is_left_sink or is_right_sink) else 0.0) or length == 0.0",
"vars": [
{
"field": "skip_long_side",
"data": "height <= 5.0"
},
{
"field": "skip_short_side",
"data": "height > 5.0"
},
{
"field": "uv_height",
"data": "height / 5.0"
},
{
"field": "uv_length",
"data": "length / 5.0"
},
{
"field": "left_sink",
"data": "0.7 if is_left_sink else 0.0"
},
{
"field": "right_sink",
"data": "0.7 if is_right_sink else 0.0"
},
{
"field": "uv_left_sink",
"data": "left_sink / 5.0"
},
{
"field": "uv_right_sink",
"data": "right_sink / 5.0"
}
],
"vertices": [
{
"skip": "False",
"data": "(0, 0, -left_sink)"
},
{
"skip": "False",
"data": "(length, 0, -right_sink)"
},
{
"skip": "skip_long_side",
"data": "(0, 0, -5.0)"
},
{
"skip": "skip_long_side",
"data": "(length, 0, -5.0)"
},
{
"skip": "False",
"data": "(0, 0, -height)"
},
{
"skip": "False",
"data": "(length, 0, -height)"
}
],
"faces": [
{
"skip": "skip_short_side",
"texture": "\"FloorSide\"",
"indices": [0, 2, 3, 1],
"uvs": [
"(0, 0)",
"(uv_height - uv_left_sink, 0)",
"(uv_height - uv_right_sink, uv_length)",
"(0, uv_length)"
],
"normals": [
"(0, -1, 0)",
"(0, -1, 0)",
"(0, -1, 0)",
"(0, -1, 0)"
]
},
{
"skip": "skip_long_side",
"texture": "\"LightingFloorTopBorder\"",
"indices": [0, 2, 3, 1],
"uvs": [
"(0, 0)",
"(1 - uv_left_sink, 0)",
"(1 - uv_left_sink, uv_length)",
"(0, uv_length)"
],
"normals": [
"(0, -1, 0)",
"(0, -1, 0)",
"(0, -1, 0)",
"(0, -1, 0)"
]
},
{
"skip": "skip_long_side",
"texture": "\"LightingFloorTopBorderless\"",
"indices": [2, 4, 5, 3],
"uvs": [
"(0, 0)",
"(uv_height - 1.0, 0)",
"(uv_height - 1.0, uv_length)",
"(0, uv_length)"
],
"normals": [
"(0, -1, 0)",
"(0, -1, 0)",
"(0, -1, 0)",
"(0, -1, 0)"
]
}
],
"instances": []
},
{
"identifier": "floor_bottom",
"showcase": null,
"params": [
{
"field": "length",
"data": "5.0"
},
{
"field": "width",
"data": "5.0"
}
],
"skip": "length == 0.0 or width == 0.0",
"vars": [
{
"field": "uv_length",
"data": "length / 5.0"
},
{
"field": "uv_width",
"data": "width / 5.0"
}
],
"vertices": [
{
"skip": "False",
"data": "(0, 0, 0)"
},
{
"skip": "False",
"data": "(0, width, 0)"
},
{
"skip": "False",
"data": "(length, 0, 0)"
},
{
"skip": "False",
"data": "(length, width, 0)"
}
],
"faces": [
{
"skip": "False",
"texture": "\"FloorTopBorderless\"",
"indices": [0, 1, 3, 2],
"uvs": [
"(0, 0)",
"(uv_width, 0)",
"(uv_width, uv_length)",
"(0, uv_length)"
],
"normals": [
"(0, 0, -1)",
"(0, 0, -1)",
"(0, 0, -1)",
"(0, 0, -1)"
]
}
],
"instances": []
}
]

View File

@ -16,6 +16,7 @@
"data": "(True, False, True, True, True, True)"
}
],
"skip": "False",
"vars": [
{
"field": "uv_height",
@ -75,7 +76,7 @@
]
},
{
"skip": "not face[1]",
"skip": "(not face[1]) or height == 0.0",
"texture": "trafo_texture",
"indices": [5, 4, 7, 6],
"uvs": [
@ -92,7 +93,7 @@
]
},
{
"skip": "not face[2]",
"skip": "(not face[2]) or height == 0.0",
"texture": "trafo_texture",
"indices": [3, 7, 4, 0],
"uvs": [
@ -109,7 +110,7 @@
]
},
{
"skip": "not face[3]",
"skip": "(not face[3]) or height == 0.0",
"texture": "trafo_texture",
"indices": [1, 5, 6, 2],
"uvs": [
@ -126,7 +127,7 @@
]
},
{
"skip": "not face[4]",
"skip": "(not face[4]) or height == 0.0",
"texture": "trafo_texture",
"indices": [0, 4, 5, 1],
"uvs": [
@ -143,7 +144,7 @@
]
},
{
"skip": "not face[5]",
"skip": "(not face[5]) or height == 0.0",
"texture": "trafo_texture",
"indices": [2, 6, 7, 3],
"uvs": [
@ -195,6 +196,7 @@
"data": "face_"
}
],
"skip": "False",
"vars": [],
"vertices": [],
"faces": [],
@ -244,6 +246,7 @@
"data": "face_"
}
],
"skip": "False",
"vars": [],
"vertices": [],
"faces": [],
@ -293,6 +296,7 @@
"data": "face_"
}
],
"skip": "False",
"vars": [],
"vertices": [],
"faces": [],