Last active
May 28, 2024 18:03
-
-
Save yibojiang/907b22f4b4049e53481d95de5b249ea5 to your computer and use it in GitHub Desktop.
Revisions
-
yibojiang revised this gist
Nov 30, 2016 . 1 changed file with 79 additions and 74 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ function list { echo " Support model formats: Autodesk ( fbx ) @@ -46,104 +46,108 @@ Support export formats: Assimp Binary ( assbin ) Assxml Document ( xml ) Extensible 3D ( x3d ) " exit 1 } function install_assimp { LIB=$HOME/"lib" FILE="libassimp.3.3.1 3.dylib" ALIAS_FILE="libassimp.3.dylib" ALIAS_FILE2="libassimp.dylib" FILE_PATH=$LIB/$FILE # echo $FILE_PATH if [ -f $FILE_PATH ]; then echo "No need to cp the libassimp.3.dylib, already exists." echo "" else if [[ -d ${LIB} ]]; then # echo "${LIB} exists" echo "" else echo "${LIB} doesn't exists, create one." mkdir ${LIB} fi ln "$FILE" "$LIB/$ALIAS_FILE" ln "$FILE" "$LIB/$ALIAS_FILE2" ln "$FILE" "$LIB/$FILE" echo "ln $FILE $LIB/$ALIAS_FILE" echo "ln $FILE $LIB/$ALIAS_FILE2" echo "ln $FILE $LIB/$FILE" fi } function usage { cat << EOF Usage: ./converter.sh -i = Install assimp library. ./converter.sh -l = List all supported model formats. ./converter.sh -f <export_format> -s <src_folder> -r <dist_folder> = Batch Export the models with specific format. Example: ./converter.sh -f obj -s test/ -d export/ EOF say "check the usage" # exit 1 } if [[ "$#" -eq 0 ]]; then echo " This is a program for batch model to a specific format. Contact Yibo Jiang or sent email to [email protected] if you meet any problems. Before using the shell, you have to install by calling ./converter.sh -i " usage say "Contact Yibo Jiang or sent email to [email protected] if you meet any problems." exit 1 fi while getopts “ilf:s:d:” OPTION do case $OPTION in i) install_assimp exit 1 ;; l) list exit 1 ;; f) FORMAT=$OPTARG ;; s) SRC=$OPTARG ;; d) DEST=$OPTARG ;; ?) usage exit ;; esac done install_assimp if [[ -d ${SRC} ]]; then echo "Reading models from ${SRC}" say "Reading models from ${SRC}" else echo "Invalid src Path ${SRC}" say "Invalid src Path ${SRC}" exit 1 fi if [[ -d ${DEST} ]]; then echo "Exporting models to ${DEST}" say "Exporting models to ${DEST}" else echo "Invalid dest Path ${DEST}" exit 1 fi @@ -155,7 +159,8 @@ do xpref=${xbase%.*} # echo;echo path=${xpath};echo pref=${xpref};echo ext=${xfext} echo "export to $DEST/$xpref.$FORMAT " # say "export to $DEST/$xpref.$FORMAT " ./assimp export $f $DEST/$xpref.$FORMAT -f$FORMAT # rm $DEST/$xpref.$FORMAT.mtl done -
yibojiang revised this gist
Nov 28, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -158,4 +158,4 @@ do assimp export $f $DEST/$xpref.$FORMAT -f$FORMAT rm $DEST/$xpref.$FORMAT.mtl done -
yibojiang created this gist
Nov 28, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,161 @@ #!/bin/bash # Author Yibo Jiang # Contact: [email protected] # Assimp # License 3-clause BSD-License. Copyright (c) 2006-2015 assimp team All rights reserved.. function list { cat << EOF Support model formats: Autodesk ( fbx ) Collada ( dae ) glTF ( gltf, glb ) Blender 3D ( blend ) 3ds Max 3DS ( 3ds ) 3ds Max ASE ( ase ) Wavefront Object ( obj ) Industry Foundation Classes (IFC/Step) ( ifc ) XGL ( xgl,zgl ) Stanford Polygon Library ( ply ) AutoCAD DXF ( dxf ) LightWave ( lwo ) LightWave Scene ( lws ) Modo ( lxo ) Stereolithography ( stl ) DirectX X ( x ) AC3D ( ac ) Milkshape 3D ( ms3d ) TrueSpace ( cob, scn ) Support export formats: Collada ( dae ) X Files ( x ) Step Files ( stp ) Wavefront OBJ format ( obj ) Stereolithography ( binary) ( stl ) Stanford Polygon Library ( stp ) Stanford Polygon Library ( binary ) ( plyb ) Autodesk 3DS ( legacy) ( 3ds ) GL Transmission Format ( gltf ) GL Transmission Format ( binary ) ( glb ) Assimp Binary ( assbin ) Assxml Document ( xml ) Extensible 3D ( x3d ) EOF exit 1 } function usage { cat << EOF Usage: converter.sh -l = List all supported model formats. converter.sh -e <export_format> <src_folder> <dist_folder> = Batch Export the models with specific format. EOF exit 1 } if [[ "$#" -eq 0 ]]; then echo "This is a program for batch model to a specific format. " usage exit 1 fi for i in "$@" do case $i in -l|--list) list shift # past argument=value exit 1 ;; -e|--export) # shift break echo "" ;; --default) DEFAULT=YES shift # past argument with no value ;; *) echo "Unknown Options $i" echo usage exit 1 ;; esac done while [[ $# -gt 1 ]] do key="$1" case $key in -e|--export) FORMAT="$2" SRC="$3" DEST="$4" shift # past argument ;; --default) DEFAULT=YES shift # past argument with no value ;; # *) # exit 1 # unknown option # ;; esac shift # past argument or value done # echo dest:$DEST case $FORMAT in dae|x|stp|obj|stl|stp|plyb|3ds|gltf|binary|glb|assbin|xml|x3d) shift ;; *) echo "Format $FORMAT unsupported. try ( dae, x, stp, obj, stl, stp, plyb, 3ds, gltf, binary, glb, assbin, xml, x3d )." echo usage exit 1 ;; esac if [[ -d ${SRC} ]]; then echo "Read models from ${SRC}" else echo "Invalid Path ${SRC}" exit 1 fi if [[ -d ${DEST} ]]; then echo "Export models to ${DEST}" else echo "Invalid Path ${DEST}" exit 1 fi for f in $SRC/*; do xpath=${f%/*} xbase=${f##*/} xfext=${xbase##*.} xpref=${xbase%.*} # echo;echo path=${xpath};echo pref=${xpref};echo ext=${xfext} echo "export to $DEST/$xpref.$FORMAT " assimp export $f $DEST/$xpref.$FORMAT -f$FORMAT rm $DEST/$xpref.$FORMAT.mtl done # assimp export test/COLLADA.dae ~/Desktop/1.obj -fobj