Forráskód Böngészése

[sdl] Updated README, copying example files, fix gnu-sed macOS issue

Mario Zechner 3 éve
szülő
commit
787af434ff

+ 8 - 2
examples/export/runtimes.sh

@@ -155,6 +155,12 @@ cp -f ../../spine-unity/Assets/Spine\ Examples/Spine\ Skeletons/Raggedy\ Spinebo
 cp -f ../../spine-unity/Assets/Spine\ Examples/Spine\ Skeletons/Raggedy\ Spineboy/Raggedy\ Spineboy.atlas.txt "$ROOT/spine-godot/example-v4/assets/raggedyspineboy/Raggedy Spineboy.atlas"
 cp -f ../../spine-unity/Assets/Spine\ Examples/Spine\ Skeletons/Raggedy\ Spineboy/Raggedy\ Spineboy.png "$ROOT/spine-godot/example-v4/assets/raggedyspineboy/"
 
+echo "spine-sdl"
+rm -f "$ROOT/spine-sdl/data/"*
+cp -f ../spineboy/export/spineboy-pro.json "$ROOT/spine-sdl/data/"
+cp -f ../spineboy/export/spineboy.atlas "$ROOT/spine-sdl/data/"
+cp -f ../spineboy/export/spineboy.png "$ROOT/spine-sdl/data/"
+
 echo "spine-sfml-c"
 rm "$ROOT/spine-sfml/c/data/"*
 cp -f ../coin/export/coin-pro.json "$ROOT/spine-sfml/c/data/"
@@ -382,11 +388,11 @@ UNITY_SOURCE_DIR=../spine-unity
 # and error out otherwise.
 sed="sed"
 if [[ $OSTYPE == 'darwin'* ]]; then
-  if [ ! -f "/usr/local/bin/gsed" ]; then
+  if [ ! -f "/opt/homebrew/bin/gsed" ]; then
 	echo "macOS sed detected. Please install GNU sed via brew install gnu-sed"
 	exit -1
   fi
-  sed="/usr/local/bin/gsed"
+  sed="/opt/homebrew/bin/gsed"
 fi
 
 # Do not delete everything in unity dirs, especially not .meta files.

+ 9 - 0
spine-sdl/CMakeLists.txt

@@ -30,3 +30,12 @@ target_link_libraries(spine-sdl-c-example SDL2 spine-sdl-c)
 
 add_executable(spine-sdl-cpp-example example/main.cpp)
 target_link_libraries(spine-sdl-cpp-example SDL2 spine-sdl-cpp)
+
+# copy data to build directory
+add_custom_command(TARGET spine-sdl-c-example PRE_BUILD
+		COMMAND ${CMAKE_COMMAND} -E copy_directory
+		${CMAKE_CURRENT_LIST_DIR}/data $<TARGET_FILE_DIR:spine-sdl-c-example>/data)
+
+add_custom_command(TARGET spine-sdl-cpp-example PRE_BUILD
+		COMMAND ${CMAKE_COMMAND} -E copy_directory
+		${CMAKE_CURRENT_LIST_DIR}/data $<TARGET_FILE_DIR:spine-sdl-cpp-example>/data)

+ 64 - 0
spine-sdl/README.md

@@ -0,0 +1,64 @@
+# spine-sdl
+
+The spine-sdl runtime provides functionality to load, manipulate and render [Spine](http://esotericsoftware.com) skeletal animation data using [SDL](https://www.libsdl.org/). spine-sdl is based on [spine-c](../../spine-c) and [spine-cpp](../spine-cpp), depending on whether you want to use a C or C++ implementation.
+
+## Licensing
+
+You are welcome to evaluate the Spine Runtimes and the examples we provide in this repository free of charge.
+
+You can integrate the Spine Runtimes into your software free of charge, but users of your software must have their own [Spine license](https://esotericsoftware.com/spine-purchase). Please make your users aware of this requirement! This option is often chosen by those making development tools, such as an SDK, game toolkit, or software library.
+
+In order to distribute your software containing the Spine Runtimes to others that don't have a Spine license, you need a [Spine license](https://esotericsoftware.com/spine-purchase) at the time of integration. Then you can distribute your software containing the Spine Runtimes however you like, provided others don't modify it or use it to create new software. If others want to do that, they'll need their own Spine license.
+
+For the official legal terms governing the Spine Runtimes, please read the [Spine Runtimes License Agreement](http://esotericsoftware.com/spine-runtimes-license) and Section 2 of the [Spine Editor License Agreement](http://esotericsoftware.com/spine-editor-license#s2).
+
+## Spine version
+
+spine-sdl works with data exported from Spine 4.1.xx.
+
+spine-sdl supports all Spine features except premultiplied alpha, screen blend mode, and two color tinting.
+
+## Usage
+1. Create a new SDL project. See the [SDL documentation](https://wiki.libsdl.org/FrontPage) or have a look at the example in this repository.
+2. Download the Spine Runtimes source using git (`git clone https://github.com/esotericsoftware/spine-runtimes`) or download it as a zip via the download button above.
+3. If you are using C, add the sources from `spine-c/spine-c/src/spine` and `spine-sdl/src/spine-sdl-c.c` to your project, and add the folder `spine-c/spine-c/include` and `spine-sdl/src/spine-sdl-c.h` to your header search path. Note that includes are specified as `#inclue <spine/file.h>`, so the `spine` directory cannot be omitted when copying the source files.
+3. If you are using C++, add the sources from `spine-cpp/spine-cpp/src/spine` and `spine-sdl/src/spine-sdl-cpp.cpp` to your project, and add the folder `spine-cpp/spine-cpp/include` and `spine-sdl/src/spine-sdl-cpp.h` to your header search path. Note that includes are specified as `#inclue <spine/file.h>`, so the `spine` directory cannot be omitted when copying the source files.
+
+See the [Spine Runtimes documentation](http://esotericsoftware.com/spine-documentation#runtimesTitle) on how to use the APIs or check out the Spine SDL example in this repository.
+
+## Example
+The Spine SFML example works on Windows, Linux and Mac OS X. For a spine-c based example, see [example/main.c](example/main.c), for a spine-cpp example see [example/main.cpp](example/main.cpp).
+
+### Windows
+1. Install [Visual Studio Community](https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx). Make sure you install support for C++ as well as th Windows SDK for XP/7/8.
+2. Install CMake via the [Windows installer package](https://cmake.org/download/).
+3. Download the Spine Runtimes repository using git (`git clone https://github.com/esotericsoftware/spine-runtimes`) or download it as a zip via the download button above.
+4. Run CMake GUI from the start menu
+5. Click `Browse Source` and select the directory `spine-runtimes`
+6. Click `Browse Build` and select the `spine-runtimes/spine-sdl/build` directory. You can create the `build` folder directly in the file dialog via `New Folder`.
+7. Click `Configure`. Then click `Generate`. This will create a Visual Studio solution file called `spine.sln` in `spine-runtimes/spine-sdl/build` and also download the SDL dependencies.
+8. Open the `spine.sln` file in Visual Studio
+9. Right click the `spine-sfml-example` project in the solution explorer and select `Set as Startup Project` from the context menu
+10. Right click the `spine-sfml-example` project in the solution explorer and select `Properties` from the context menu
+11. Select `Debugging` in the left-hand list, then set `Working Directory` to `$(OutputPath)`
+12. Click `Local Windows Debugger` to run the example
+
+The entire example code is contained in [main.cpp](example/main.cpp#L61)
+
+### Linux
+1. Install the [SDL build dependencies](https://github.com/libsdl-org/SDL/blob/main/docs/README-linux.md)
+3. Download the Spine Runtimes repository using git (`git clone https://github.com/esotericsoftware/spine-runtimes`) or download it as a zip via the download button above.
+4. Open a terminal, and `cd` into the `spine-runtimes/spine-sdl` folder
+5. Type `mkdir build && cd build && cmake ../..` to generate Make files
+6. Type `make` to compile the example
+7. Run the example by `cd spine-sdl && ./spine-sdl-c-example` (C) or by `cd spine-sdl && ./spine-sdl-cpp-example` (C++)
+
+### Mac OS X
+1. Install [Xcode](https://developer.apple.com/xcode/)
+2. Install [Homebrew](http://brew.sh/)
+3. Open a terminal and install CMake via `brew install cmake`
+3. Download the Spine Runtimes repository using git (`git clone https://github.com/esotericsoftware/spine-runtimes`) or download it as a zip via the download button above.
+4. Open a terminal, and `cd` into the `spine-runtimes/spine-sdl` folder
+5. Type `mkdir build && cd build && cmake ../..` to generate Make files
+6. Type `make` to compile the example
+7. Run the example by `cd spine-sdl && ./spine-sdl-c-example` (C) or by `cd spine-sdl && ./spine-sdl-cpp-example` (C++)

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 541 - 0
spine-sdl/data/spineboy-pro.json


+ 101 - 0
spine-sdl/data/spineboy.atlas

@@ -0,0 +1,101 @@
+spineboy.png
+	size: 1024, 256
+	filter: Linear, Linear
+	scale: 0.5
+crosshair
+	bounds: 813, 160, 45, 45
+eye-indifferent
+	bounds: 569, 2, 47, 45
+eye-surprised
+	bounds: 643, 7, 47, 45
+	rotate: 90
+front-bracer
+	bounds: 811, 51, 29, 40
+front-fist-closed
+	bounds: 807, 93, 38, 41
+front-fist-open
+	bounds: 815, 210, 43, 44
+front-foot
+	bounds: 706, 64, 63, 35
+	rotate: 90
+front-shin
+	bounds: 80, 11, 41, 92
+front-thigh
+	bounds: 754, 12, 23, 56
+front-upper-arm
+	bounds: 618, 5, 23, 49
+goggles
+	bounds: 214, 20, 131, 83
+gun
+	bounds: 347, 14, 105, 102
+	rotate: 90
+head
+	bounds: 80, 105, 136, 149
+hoverboard-board
+	bounds: 2, 8, 246, 76
+	rotate: 90
+hoverboard-thruster
+	bounds: 478, 2, 30, 32
+hoverglow-small
+	bounds: 218, 117, 137, 38
+	rotate: 90
+mouth-grind
+	bounds: 775, 80, 47, 30
+	rotate: 90
+mouth-oooo
+	bounds: 779, 31, 47, 30
+	rotate: 90
+mouth-smile
+	bounds: 783, 207, 47, 30
+	rotate: 90
+muzzle-glow
+	bounds: 779, 4, 25, 25
+muzzle-ring
+	bounds: 451, 14, 25, 105
+muzzle01
+	bounds: 664, 60, 67, 40
+	rotate: 90
+muzzle02
+	bounds: 580, 56, 68, 42
+	rotate: 90
+muzzle03
+	bounds: 478, 36, 83, 53
+	rotate: 90
+muzzle04
+	bounds: 533, 49, 75, 45
+	rotate: 90
+muzzle05
+	bounds: 624, 56, 68, 38
+	rotate: 90
+neck
+	bounds: 806, 8, 18, 21
+portal-bg
+	bounds: 258, 121, 133, 133
+portal-flare1
+	bounds: 690, 2, 56, 30
+	rotate: 90
+portal-flare2
+	bounds: 510, 3, 57, 31
+portal-flare3
+	bounds: 722, 4, 58, 30
+	rotate: 90
+portal-shade
+	bounds: 393, 121, 133, 133
+portal-streaks1
+	bounds: 528, 126, 126, 128
+portal-streaks2
+	bounds: 656, 129, 125, 125
+rear-bracer
+	bounds: 826, 13, 28, 36
+rear-foot
+	bounds: 743, 70, 57, 30
+	rotate: 90
+rear-shin
+	bounds: 174, 14, 38, 89
+rear-thigh
+	bounds: 783, 158, 28, 47
+rear-upper-arm
+	bounds: 783, 136, 20, 44
+	rotate: 90
+torso
+	bounds: 123, 13, 49, 90

BIN
spine-sdl/data/spineboy.png


+ 5 - 4
spine-sdl/example/main.c

@@ -46,18 +46,19 @@ int main() {
 		return -1;
 	}
 
-	spAtlas *atlas = spAtlas_createFromFile("/Users/badlogic/workspaces/spine-runtimes/examples/spineboy/export/spineboy.atlas", renderer);
+	spAtlas *atlas = spAtlas_createFromFile("data/spineboy.atlas", renderer);
 	spSkeletonJson *json = spSkeletonJson_create(atlas);
 	json->scale = 0.5f;
-	spSkeletonData *skeletonData = spSkeletonJson_readSkeletonDataFile(json, "/Users/badlogic/workspaces/spine-runtimes/examples/spineboy/export/spineboy-pro.json");
+	spSkeletonData *skeletonData = spSkeletonJson_readSkeletonDataFile(json, "data/spineboy-pro.json");
 	spAnimationStateData *animationStateData = spAnimationStateData_create(skeletonData);
+    animationStateData->defaultMix = 0.2f;
 	spSkeletonDrawable *drawable = spSkeletonDrawable_create(skeletonData, animationStateData);
-
 	drawable->skeleton->x = 400;
 	drawable->skeleton->y = 500;
 	spSkeleton_setToSetupPose(drawable->skeleton);
 	spSkeletonDrawable_update(drawable, 0);
-	spAnimationState_setAnimationByName(drawable->animationState, 0, "run", -1);
+	spAnimationState_setAnimationByName(drawable->animationState, 0, "portal", 0);
+    spAnimationState_addAnimationByName(drawable->animationState, 0, "run", -1, 0);
 
 	int quit = 0;
 	uint64_t lastFrameTime = SDL_GetPerformanceCounter();

+ 5 - 3
spine-sdl/example/main.cpp

@@ -47,16 +47,18 @@ int main() {
 	}
 
 	spine::SDLTextureLoader textureLoader(renderer);
-	spine::Atlas atlas("/Users/badlogic/workspaces/spine-runtimes/examples/spineboy/export/spineboy.atlas", &textureLoader);
+	spine::Atlas atlas("data/spineboy.atlas", &textureLoader);
 	spine::AtlasAttachmentLoader attachmentLoader(&atlas);
 	spine::SkeletonJson json(&attachmentLoader);
 	json.setScale(0.5f);
-	spine::SkeletonData *skeletonData = json.readSkeletonDataFile("/Users/badlogic/workspaces/spine-runtimes/examples/spineboy/export/spineboy-pro.json");
+	spine::SkeletonData *skeletonData = json.readSkeletonDataFile("data/spineboy-pro.json");
 	spine::SkeletonDrawable drawable(skeletonData);
+    drawable.animationState->getData()->setDefaultMix(0.2f);
 	drawable.skeleton->setPosition(400, 500);
 	drawable.skeleton->setToSetupPose();
 	drawable.update(0);
-	drawable.animationState->setAnimation(0, "run", true);
+    drawable.animationState->setAnimation(0, "portal", true);
+	drawable.animationState->addAnimation(0, "run", true, 0);
 
 	bool quit = false;
 	uint64_t lastFrameTime = SDL_GetPerformanceCounter();

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott