Browse Source

improve scripts, add generate_collision_box

prepatch: for meld option, also display basis and patch; install-mts:
run custom script after install
master
poikilos 5 years ago
committed by Jacob Gustafson
parent
commit
83cf034825
  1. 16
      patches/prepatch.sh
  2. 111
      utilities/generate_collision_box.py
  3. 61
      webapp/install-mts.sh

16
patches/prepatch.sh

@ -63,6 +63,10 @@ if [ "@$enable_meld" = "@true" ]; then
customDie "You must specify a branch name after --meld."
fi
subgame=
branch_basis=
if [ -d "$patches/$branch/basis/mods" ]; then
branch_basis="$patches/$branch/basis"
fi
if [ -d "$patches/$branch/mods" ]; then
patch_game_src="$patches/$branch"
elif [ -d "$patches/$branch/patched/mods" ]; then
@ -79,6 +83,18 @@ if [ "@$enable_meld" = "@true" ]; then
echo "* install nohup to prevent programs from dumping output to console..."
fi
fi
if [ ! -z "$branch_basis" ]; then
echo "meld $branch_basis $patch_game_src/..."
if [ -f "`command -v meld`" ]; then
if [ -f "`command -v nohup`" ]; then
nohup meld "$branch_basis" "$patch_game_src" &
else
meld "$patch_game_src/" "$HOME/minetest/games/ENLIVEN" &
echo "* install nohup to prevent programs from dumping output to console..."
fi
fi
fi
echo
echo
exit 0

111
utilities/generate_collision_box.py

@ -0,0 +1,111 @@
print("How to use: paste into a Blender Text Editor panel, select object, Run Script")
y_up = True
enable_minetest = True
import bpy
#from mathutils import Matrix
from mathutils import Vector
#from mathutils import Euler
ob1 = None
try:
ob1 = obj.select_get()
except:
# < 2.8
ob1 = bpy.context.scene.objects.active
#print(str(thisO))
#extents1 = ob1.dimensions.copy()
#if (extents1.x == 0.0) and (extents1.y == 0.0) and (extents1.z == 0.0) and (ob1.scale.x > 0.0):
#extents1.x = extents1.x / 10.0
#extents1.y = extents1.y / 10.0
#extents1.z = extents1.z / 10.0
loc1 = ob1.location
#loc1 = ob1.matrix_world.translation
#print(str(extents1))
#see https://blender.stackexchange.com/questions/8459/get-blender-x-y-z-and-bounding-box-with-script
#bbox_corners = [ob1.matrix_world * Vector(corner) for corner in ob1.bound_box]
#use ground as bottom
#if zMin < 0.0:
# yMax -= yMin
# yMin = 0.0
#print(
# " collisionbox = {{{:.2f}, {:.2f}, {:.2f}, {:.2f}, {:.2f}, {:.2f}}}".format(xMin, yMin, zMin, xMax, yMax, zMax)
#)
#see https://blender.stackexchange.com/questions/6139/how-to-iterate-through-all-vertices-of-an-object-that-contains-multiple-meshes
mesh = ob1.data
#print("mesh:" + str(mesh))
#print("hasattr(mesh, 'vertices'):" + str(hasattr(mesh, 'vertices')))]
xMin = None
if (mesh is not None) and (not hasattr(mesh, 'vertices')):
print("--can't calculate collisionbox for skeleton")
elif mesh is not None:
xMin = None
yMin = None
zMin = None
xMax = None
yMax = None
zMax = None
for vert in mesh.vertices:
# switch y and z for Minetest (y-up)
if (xMin is None) or (vert.co.x < xMin):
xMin = vert.co.x
if (xMax is None) or (vert.co.x > xMax):
xMax = vert.co.x
if (yMin is None) or (vert.co.y < yMin):
yMin = vert.co.y
if (yMax is None) or (vert.co.y > yMax):
yMax = vert.co.y
if (zMin is None) or (vert.co.z < zMin):
zMin = vert.co.z
if (zMax is None) or (vert.co.z > zMax):
zMax = vert.co.z
#print(str(extents1))
#print("--by vertices (raw):")
#print(
# " collisionbox = {{{:.2f}, {:.2f}, {:.2f}, {:.2f}, {:.2f}, {:.2f}}}".format(xMin, yMin, zMin, xMax, yMax, zMax)
#)
xMax += ob1.location.x
xMin += ob1.location.x
yMax += ob1.location.y
yMin += ob1.location.y
zMax += ob1.location.z
zMin += ob1.location.z
print("--by vertices:")
else:
extents1 = ob1.scale.copy()
# Object is an empty, so scale up for Minetest
extents1.x = extents1.x * 2.0
extents1.y = extents1.y * 2.0
extents1.z = extents1.z * 2.0
xMin = loc1.x - extents1.x / 2.0
xMax = loc1.x + extents1.x / 2.0
yMin = loc1.y - extents1.y / 2.0
yMax = loc1.y + extents1.y / 2.0
zMin = loc1.z - extents1.z / 2.0
zMax = loc1.z + extents1.z / 2.0
print("--using empty object:")
#switch y and z for Minetest (y-up):
if enable_minetest:
xMin /= 10.0
xMax /= 10.0
yMin /= 10.0
yMax /= 10.0
zMin /= 10.0
zMax /= 10.0
if xMin is not None:
if y_up:
tmp = yMin
yMin = zMin
zMin = tmp
tmp = yMax
yMax = zMax
zMax = tmp
print(
" collisionbox = {{{:.2f}, {:.2f}, {:.2f}, {:.2f}, {:.2f}, {:.2f}}}".format(xMin, yMin, zMin, xMax, yMax, zMax)
)

61
webapp/install-mts.sh

@ -15,14 +15,36 @@ $1
END
exit 1
}
dest_programs="$HOME"
#NOTE: $HOME is still used further down, for $HOME/.* and $HOME/i_am_dedicated_minetest_server flag file (which can be empty)
#TODO: change $HOME/i_am_dedicated_minetest_server to $HOME/.config/EnlivenMinetest/i_am_dedicated_minetest_server or rc file
extracted_name=linux-minetest-kit
flag_dir_rel="$extracted_name/mtsrc"
flag_dir="`pwd`/$flag_dir_rel"
pushd "$extracted_name"
enable_client=false
custom_scripts_dir="$HOME"
custom_script_name="mts.sh"
if [ -f "$custom_scripts_dir/mts-CenterOfTheSun.sh" ]; then
custom_script_name="mts-CenterOfTheSun.sh"
fi
scripting_rc_path=~/.config/EnlivenMinetest/scripting.rc
if [ -f ~/.config/EnlivenMinetest/scripting.rc ]; then
echo "Running $scripting_rc_path..."
source $scripting_rc_path
# may contain any variables above, plus:
# * enable_run_after_compile: if true, then run the server, such as
# ~/mts-CenterOfTheSun.sh
else
echo "* skipping $scripting_rc_path (not present)"
echo " (can contain settings such as enable_run_after_compile)"
fi
pushd "$extracted_name"
extra_options=""
for var in "$@"
do
@ -387,7 +409,40 @@ else
echo "* $settings_types_list was already created"
fi
popd
echo "Done."
echo "* finished compiling."
if [ "@$enable_run_after_compile" = "@true" ]; then
echo "Trying to run minetest or other custom post-install script"
echo "(enable_run_after_compile is true in '$scripting_rc_path')."
if [ -d "$custom_scripts_dir" ]; then
pushd "$custom_scripts_dir"
if [ -f archive-minetestserver-debug.sh ]; then
./archive-minetestserver-debug.sh
echo "NOTE: if you put archive-minetestserver-debug.sh"
echo " in `pwd`, it would run at this point if"
echo " marked executable."
fi
if [ -f "$custom_script_name" ]; then
./$custom_script_name
echo "$custom_script_name finished (exit code $?)"
else
cat <<END
ERROR: enable_run_after_compile is true, but
'$custom_script_name' is not in
'$custom_scripts_dir'.
Try setting custom_scripts_dir and custom_script_name in
'$scripting_rc_path'
END
fi
popd
else
cat <<END
ERROR: enable_run_after_compile is true, but
'$custom_scripts_dir'
does not exist. Try setting custom_scripts_dir in
'$scripting_rc_path'.
END
fi
fi
echo
echo

Loading…
Cancel
Save