MODEL_NAME=cat20131026
BODY_NAME=Cat
WK_SVG=texture.svg

dist/.haishiro20131026: $(MODEL_NAME).blend textures/haishiro20131026.svg
	mkdir dist; echo
	cd dist; cp ../textures/haishiro20131026.svg $(WK_SVG)
	make dist/.tex256
	mkdir dist/haishiro20131026; echo
	cp $(MODEL_NAME).blend dist/haishiro20131026
	cp $(BODY_NAME).png dist/haishiro20131026
	mv dist/texture.svg dist/haishiro20131026
	touch dist/.haishiro20131026

dist/.hai20131026: $(MODEL_NAME).blend textures/hai20131026.svg
	mkdir dist; echo
	cd dist; cp ../textures/hai20131026.svg $(WK_SVG)
	make dist/.tex256
	mkdir dist/hai20131026; echo
	cp $(MODEL_NAME).blend dist/hai20131026
	cp $(BODY_NAME).png dist/hai20131026
	mv dist/texture.svg dist/hai20131026
	touch dist/.hai20131026

dist/.kuroshiro20131026: $(MODEL_NAME).blend textures/kuroshiro20131026.svg
	mkdir dist; echo
	cd dist; cp ../textures/kuroshiro20131026.svg $(WK_SVG)
	make dist/.tex256
	mkdir dist/kuroshiro20131026; echo
	cp $(MODEL_NAME).blend dist/kuroshiro20131026
	cp $(BODY_NAME).png dist/kuroshiro20131026
	mv dist/texture.svg dist/kuroshiro20131026
	touch dist/.kuroshiro20131026

dist/.shiro20131026: $(MODEL_NAME).blend textures/shiro20131026.svg
	mkdir dist; echo
	cd dist; cp ../textures/shiro20131026.svg $(WK_SVG)
	make dist/.tex256
	mkdir dist/shiro20131026; echo
	cp $(MODEL_NAME).blend dist/shiro20131026
	cp $(BODY_NAME).png dist/shiro20131026
	mv dist/texture.svg dist/shiro20131026
	touch dist/.shiro20131026

dist/.kuro20131026: $(MODEL_NAME).blend textures/kuro20131026.svg
	mkdir dist; echo
	cd dist; cp ../textures/kuro20131026.svg $(WK_SVG)
	make dist/.tex256
	mkdir dist/kuro20131026; echo
	cp $(MODEL_NAME).blend dist/kuro20131026
	cp $(BODY_NAME).png dist/kuro20131026
	mv dist/texture.svg dist/kuro20131026
	touch dist/.kuro20131026

dist/.tex256:
	cd dist; xqilla -u -i $(WK_SVG) ../texture.xq
	cd dist; inkscape --export-png=../$(BODY_NAME).png --export-area=0:0:256:256 --export-dpi=90 --export-background-opacity=0.0 $(WK_SVG)

dist/.tex512:
	cd dist; xqilla -u -i $(WK_SVG) ../texture512.xq
	cd dist; xqilla -u -i $(WK_SVG) ../texture.xq
	cd dist; inkscape --export-png=../$(BODY_NAME).png --export-area=0:0:512:512 --export-dpi=90 --export-background-opacity=0.0 $(WK_SVG)

dist/.obj: $(MODEL_NAME).blend $(BODY_NAME).png
	make dist/.kuro20131026
	mkdir dist/obj ; echo
	cp $(MODEL_NAME).blend dist/obj
	cp $(BODY_NAME).png dist/obj
	cd dist/obj; sh $(DEVUTIL)/blend2obj.sh $(MODEL_NAME).blend $(MODEL_NAME).obj ; echo
	cd dist/obj; zip $(MODEL_NAME).zip $(MODEL_NAME).mtl $(MODEL_NAME).obj $(BODY_NAME).png
	touch dist/.obj

dist/.ogre: $(MODEL_NAME).blend $(BODY_NAME).png
	make dist/.kuro20131026
	mkdir dist/ogre ; echo
	cd dist/ogre; sh $(DEVUTIL)/blend2ogre.sh $(DEVDATA)/$(MODEL_NAME)/$(MODEL_NAME).blend ./$(MODEL_NAME).scene ; echo
	if [ ! -f dist/ogre/$(BODY_NAME).mesh.xml ]; then exit -1; fi
	if [ ! -f dist/ogre/$(BODY_NAME).skeleton.xml ]; then exit -1; fi
	if [ ! -f dist/ogre/$(BODY_NAME).material ]; then exit -1; fi
	if [ ! -f dist/ogre/$(BODY_NAME).png ]; then exit -1; fi
	touch dist/.ogre

clean:
	rm -rf dist
