Adjusted the orientation for cube tokens.

Before, the top and bottom faces would face away from the player when
cube tokens were spawned in-game.

This has been fixed by having the cube mesh instance rotated around
the y-axis by 180 degrees, and adjusting the cube uv mapping template
in the docs accordingly.

This commit fixes #122.
This commit is contained in:
drwhut 2022-11-30 20:35:13 +00:00
parent d458f973fd
commit cba668e57e
4 changed files with 65 additions and 62 deletions

View File

@ -2,23 +2,23 @@
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="900"
height="600"
viewBox="0 0 238.12499 158.75"
version="1.1"
id="svg8"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
sodipodi:docname="Template.svg"
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
sodipodi:docname="cube.svg"
inkscape:export-filename="/home/drwhut/Documents/open-tabletop/assets/OpenTabletop/pieces/cube/Template.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
inkscape:export-ydpi="96"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<defs
id="defs2">
<marker
@ -180,14 +180,14 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.3376936"
inkscape:cx="355.6955"
inkscape:cy="297.43944"
inkscape:cx="355.83634"
inkscape:cy="292.29414"
inkscape:document-units="mm"
inkscape:current-layer="layer2"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:pagecheckerboard="true"
inkscape:window-width="1920"
inkscape:window-height="1016"
inkscape:window-height="1003"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
@ -195,7 +195,9 @@
showguides="false"
inkscape:snap-bbox="true"
inkscape:snap-bbox-midpoints="true"
inkscape:snap-bbox-edge-midpoints="true" />
inkscape:snap-bbox-edge-midpoints="true"
inkscape:showpageshadow="0"
inkscape:deskcolor="#d1d1d1" />
<metadata
id="metadata5">
<rdf:RDF>
@ -204,7 +206,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@ -271,40 +273,40 @@
style="fill:#800080;fill-opacity:1;stroke:#fffff9;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="21.434843"
y="183.02454"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.1111px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="22.951738"
y="183.46198"
id="text915"><tspan
sodipodi:role="line"
id="tspan913"
x="21.434843"
y="183.02454"
style="font-size:14.11111069px;fill:#ffffff;stroke-width:0.26458332">Front</tspan></text>
x="22.951738"
y="183.46198"
style="font-size:14.1111px;fill:#ffffff;stroke-width:0.264583">Back</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="26.479525"
y="262.92871"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.1111px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="21.738186"
y="261.16483"
id="text915-8"><tspan
sodipodi:role="line"
id="tspan913-8"
x="26.479525"
y="262.92871"
style="font-size:14.11111069px;fill:#ffffff;stroke-width:0.26458332">Left</tspan></text>
x="21.738186"
y="261.16483"
style="font-size:14.1111px;fill:#ffffff;stroke-width:0.264583">Right</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="101.11318"
y="181.78983"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.1111px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="105.85451"
y="183.5537"
id="text915-8-9"><tspan
sodipodi:role="line"
id="tspan913-8-7"
x="101.11318"
y="181.78983"
style="font-size:14.11111069px;fill:#000000;stroke-width:0.26458332">Right</tspan></text>
x="105.85451"
y="183.5537"
style="font-size:14.1111px;fill:#000000;stroke-width:0.264583">Left</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.1111px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="106.86346"
y="260.87555"
id="text915-8-9-7"><tspan
@ -312,21 +314,21 @@
id="tspan913-8-7-6"
x="106.86346"
y="260.87555"
style="font-size:14.11111069px;fill:#000000;stroke-width:0.26458332">Top</tspan></text>
style="font-size:14.1111px;fill:#000000;stroke-width:0.264583">Top</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="181.70174"
y="183.46199"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.1111px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="180.18477"
y="183.02454"
id="text915-4"><tspan
sodipodi:role="line"
id="tspan913-3"
x="181.70174"
y="183.46199"
style="font-size:14.11111069px;fill:#ffffff;stroke-width:0.26458332">Back</tspan></text>
x="180.18477"
y="183.02454"
style="font-size:14.1111px;fill:#ffffff;stroke-width:0.264583">Front</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.1111px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="173.68668"
y="262.39954"
id="text915-4-0"><tspan
@ -334,7 +336,7 @@
id="tspan913-3-3"
x="173.68668"
y="262.39954"
style="font-size:14.11111069px;fill:#ffffff;stroke-width:0.26458332">Bottom</tspan></text>
style="font-size:14.1111px;fill:#ffffff;stroke-width:0.264583">Bottom</tspan></text>
</g>
<g
inkscape:groupmode="layer"
@ -347,7 +349,7 @@
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05555534px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05556px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="32.557922"
y="154.65276"
id="text6606"><tspan
@ -355,7 +357,7 @@
id="tspan6604"
x="32.557922"
y="154.65276"
style="font-size:7.05555534px;fill:#ffffff;stroke-width:0.26458332">33%</tspan></text>
style="font-size:7.05556px;fill:#ffffff;stroke-width:0.264583">33%</tspan></text>
<path
style="fill:#000000;stroke:#000000;stroke-width:0.52809536;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart-2);marker-end:url(#Arrow1Lend-4)"
d="M 80.400225,156.0682 H 157.72483"
@ -363,7 +365,7 @@
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05555534px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332;"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05556px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="111.93289"
y="154.65295"
id="text6606-9"><tspan
@ -371,7 +373,7 @@
id="tspan6604-4"
x="111.93289"
y="154.65295"
style="font-size:7.05555534px;fill:#000000;stroke-width:0.26458332;">33%</tspan></text>
style="font-size:7.05556px;fill:#000000;stroke-width:0.264583">33%</tspan></text>
<path
style="fill:#ffffff;stroke:#fffff1;stroke-width:0.52809536;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart-2-6);marker-end:url(#Arrow1Lend-4-2)"
d="m 159.77522,156.0682 h 77.32461"
@ -379,7 +381,7 @@
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05555534px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05556px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="191.30789"
y="154.65295"
id="text6606-9-7"><tspan
@ -387,7 +389,7 @@
id="tspan6604-4-7"
x="191.30789"
y="154.65295"
style="font-size:7.05555534px;fill:#ffffff;stroke-width:0.26458332">33%</tspan></text>
style="font-size:7.05556px;fill:#ffffff;stroke-width:0.264583">33%</tspan></text>
<path
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.52899396;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#marker7244);marker-end:url(#marker7314)"
d="M 2.6863604,1.0262979 V 78.348031"
@ -395,7 +397,7 @@
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05555534px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05556px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="5.1751652"
y="42.276554"
id="text6606-5"><tspan
@ -403,7 +405,7 @@
id="tspan6604-48"
x="5.1751652"
y="42.276554"
style="font-size:7.05555534px;fill:#ffffff;stroke-width:0.26458332">50%</tspan></text>
style="font-size:7.05556px;fill:#ffffff;stroke-width:0.264583">50%</tspan></text>
<path
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.52899396;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#marker7244-1);marker-end:url(#marker7314-8)"
d="M 2.6863604,80.401296 V 157.72303"
@ -411,7 +413,7 @@
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05555534px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05556px;line-height:1.25;font-family:'Noto Sans CJK JP';-inkscape-font-specification:'Noto Sans CJK JP';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="5.1751657"
y="121.65155"
id="text6606-5-6"><tspan
@ -419,6 +421,6 @@
id="tspan6604-48-8"
x="5.1751657"
y="121.65155"
style="font-size:7.05555534px;fill:#ffffff;stroke-width:0.26458332">50%</tspan></text>
style="font-size:7.05556px;fill:#ffffff;stroke-width:0.264583">50%</tspan></text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -27,5 +27,6 @@ table_collide_slow_sounds = ExtResource( 2 )
shape = SubResource( 3 )
[node name="MeshInstance" type="MeshInstance" parent="CollisionShape"]
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0 )
mesh = SubResource( 4 )
material/0 = null

View File

@ -119,7 +119,7 @@ func _add_piece_at_pos(piece_entry: Dictionary, pos: int, flip_y: bool) -> void:
# somewhere else, so to the pieces node it goes!
_get_pieces_node().scale.y = collision_shape_scale.y
var basis = Basis.IDENTITY
var basis = mesh_instance.transform.basis
if flip_y:
basis = basis.rotated(Vector3.BACK, PI)
@ -148,9 +148,13 @@ func _remove_piece_at_pos(pos: int) -> Dictionary:
_set_piece_heights()
var piece_transform = Transform.IDENTITY
if piece.transform.basis.y.y < 0.0: # Was the piece flipped?
piece_transform = piece_transform.rotated(Vector3.BACK, PI)
var out = {
"piece_entry": piece.get_meta("piece_entry"),
"transform": piece.transform
"transform": piece_transform
}
ResourceManager.queue_free_object(piece)

View File

@ -222,13 +222,9 @@ func get_piece_meshes(piece: Piece) -> Array:
for mesh_instance in piece.get_mesh_instances():
var piece_mesh = MeshInstance.new()
piece_mesh.name = piece.name
piece_mesh.transform = piece.transform
piece_mesh.set_meta("piece_entry", piece.piece_entry)
piece_mesh.transform = mesh_instance.transform
# Get the scale from the mesh instance (since the rigid body itself
# won't be scaled).
piece_mesh.scale = mesh_instance.scale
piece_mesh.set_meta("piece_entry", piece.piece_entry)
piece_mesh.mesh = mesh_instance.mesh
for surface in range(mesh_instance.get_surface_material_count()):