Eugene Veretennikov avatar Eugene Veretennikov committed 0dd38c5

missing base sources

Comments (0)

Files changed (4)

 syntax: glob
 out
+.idea
+*.iml

src-base/spine-libgdx/test/com/esotericsoftware/spine/AnimationStateTest.java

+/*******************************************************************************
+ * Copyright (c) 2013, Esoteric Software
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ *    list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ******************************************************************************/
+
+package com.esotericsoftware.spine;
+
+import com.badlogic.gdx.ApplicationAdapter;
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
+import com.badlogic.gdx.graphics.GL10;
+import com.badlogic.gdx.graphics.g2d.SpriteBatch;
+import com.badlogic.gdx.graphics.g2d.TextureAtlas;
+import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
+
+public class AnimationStateTest extends ApplicationAdapter {
+	SpriteBatch batch;
+	SkeletonRenderer renderer;
+	SkeletonRendererDebug debugRenderer;
+
+	TextureAtlas atlas;
+	Skeleton skeleton;
+	Bone root;
+	AnimationState state;
+
+	public void create () {
+		batch = new SpriteBatch();
+		renderer = new SkeletonRenderer();
+		debugRenderer = new SkeletonRendererDebug();
+
+		atlas = new TextureAtlas(Gdx.files.internal("spineboy.atlas"));
+		SkeletonJson json = new SkeletonJson(atlas);
+		SkeletonData skeletonData = json.readSkeletonData(Gdx.files.internal("spineboy.json"));
+
+		// Define mixing between animations.
+		AnimationStateData stateData = new AnimationStateData(skeletonData);
+		stateData.setMix("walk", "jump", 0.4f);
+		stateData.setMix("jump", "walk", 0.4f);
+
+		state = new AnimationState(stateData);
+		state.setAnimation("walk", true);
+
+		skeleton = new Skeleton(skeletonData);
+
+		root = skeleton.getRootBone();
+		root.setX(250);
+		root.setY(20);
+
+		skeleton.updateWorldTransform();
+	}
+
+	public void render () {
+		state.update(Gdx.graphics.getDeltaTime() / 3);
+
+		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
+
+		state.apply(skeleton);
+		if (state.getAnimation().getName().equals("walk")) {
+			// After one second, change the current animation. Mixing is done by AnimationState for you.
+			if (state.getTime() > 2) state.setAnimation("jump", false);
+		} else {
+			if (state.getTime() > 1) state.setAnimation("walk", true);
+		}
+		skeleton.updateWorldTransform();
+
+		batch.begin();
+		renderer.draw(batch, skeleton);
+		batch.end();
+
+		debugRenderer.draw(batch, skeleton);
+	}
+
+	public void resize (int width, int height) {
+		batch.getProjectionMatrix().setToOrtho2D(0, 0, width, height);
+		debugRenderer.getShapeRenderer().setProjectionMatrix(batch.getProjectionMatrix());
+	}
+
+	public void dispose () {
+		atlas.dispose();
+	}
+
+	public static void main (String[] args) throws Exception {
+		new LwjglApplication(new AnimationStateTest());
+	}
+}

src-base/spine-libgdx/test/com/esotericsoftware/spine/MixTest.java

+/*******************************************************************************
+ * Copyright (c) 2013, Esoteric Software
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ *    list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ******************************************************************************/
+
+package com.esotericsoftware.spine;
+
+import com.badlogic.gdx.ApplicationAdapter;
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
+import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
+import com.badlogic.gdx.graphics.Color;
+import com.badlogic.gdx.graphics.GL10;
+import com.badlogic.gdx.graphics.g2d.SpriteBatch;
+import com.badlogic.gdx.graphics.g2d.TextureAtlas;
+import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
+
+public class MixTest extends ApplicationAdapter {
+	SpriteBatch batch;
+	float time;
+	SkeletonRenderer renderer;
+	SkeletonRendererDebug debugRenderer;
+
+	SkeletonData skeletonData;
+	Skeleton skeleton;
+	Animation walkAnimation;
+	Animation jumpAnimation;
+
+	public void create () {
+		batch = new SpriteBatch();
+		renderer = new SkeletonRenderer();
+		debugRenderer = new SkeletonRendererDebug();
+
+		final String name = "spineboy";
+
+		TextureAtlas atlas = new TextureAtlas(Gdx.files.internal(name + ".atlas"));
+
+		if (true) {
+			SkeletonJson json = new SkeletonJson(atlas);
+			// json.setScale(2);
+			skeletonData = json.readSkeletonData(Gdx.files.internal(name + ".json"));
+		} else {
+			SkeletonBinary binary = new SkeletonBinary(atlas);
+			// binary.setScale(2);
+			skeletonData = binary.readSkeletonData(Gdx.files.internal(name + ".skel"));
+		}
+		walkAnimation = skeletonData.findAnimation("walk");
+		jumpAnimation = skeletonData.findAnimation("jump");
+
+		skeleton = new Skeleton(skeletonData);
+		skeleton.setToBindPose();
+
+		final Bone root = skeleton.getRootBone();
+		root.x = -50;
+		root.y = 20;
+		root.scaleX = 1f;
+		root.scaleY = 1f;
+		skeleton.updateWorldTransform();
+	}
+
+	public void render () {
+		float delta = Gdx.graphics.getDeltaTime() * 0.25f; // Reduced to make mixing easier to see.
+
+		float jump = jumpAnimation.getDuration();
+		float beforeJump = 1f;
+		float blendIn = 0.4f;
+		float blendOut = 0.4f;
+		float blendOutStart = beforeJump + jump - blendOut;
+		float total = 3.75f;
+
+		time += delta;
+
+		Bone root = skeleton.getRootBone();
+		float speed = 180;
+		if (time > beforeJump + blendIn && time < blendOutStart) speed = 360;
+		root.setX(root.getX() + speed * delta);
+
+		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
+
+		// This shows how to manage state manually. See AnimationStatesTest.
+		if (time > total) {
+			// restart
+			time = 0;
+			root.setX(-50);
+		} else if (time > beforeJump + jump) {
+			// just walk after jump
+			walkAnimation.apply(skeleton, time, true);
+		} else if (time > blendOutStart) {
+			// blend out jump
+			walkAnimation.apply(skeleton, time, true);
+			jumpAnimation.mix(skeleton, time - beforeJump, false, 1 - (time - blendOutStart) / blendOut);
+		} else if (time > beforeJump + blendIn) {
+			// just jump
+			jumpAnimation.apply(skeleton, time - beforeJump, false);
+		} else if (time > beforeJump) {
+			// blend in jump
+			walkAnimation.apply(skeleton, time, true);
+			jumpAnimation.mix(skeleton, time - beforeJump, false, (time - beforeJump) / blendIn);
+		} else {
+			// just walk before jump
+			walkAnimation.apply(skeleton, time, true);
+		}
+
+		skeleton.updateWorldTransform();
+		skeleton.update(Gdx.graphics.getDeltaTime());
+
+		batch.begin();
+		renderer.draw(batch, skeleton);
+		batch.end();
+
+		debugRenderer.draw(batch, skeleton);
+	}
+
+	public void resize (int width, int height) {
+		batch.getProjectionMatrix().setToOrtho2D(0, 0, width, height);
+		debugRenderer.getShapeRenderer().setProjectionMatrix(batch.getProjectionMatrix());
+	}
+
+	public static void main (String[] args) throws Exception {
+		new LwjglApplication(new MixTest());
+	}
+}

src-base/spine-libgdx/test/com/esotericsoftware/spine/SkeletonTest.java

+/*******************************************************************************
+ * Copyright (c) 2013, Esoteric Software
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ *    list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ******************************************************************************/
+
+package com.esotericsoftware.spine;
+
+import com.badlogic.gdx.ApplicationAdapter;
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.Input.Keys;
+import com.badlogic.gdx.InputAdapter;
+import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
+import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
+import com.badlogic.gdx.files.FileHandle;
+import com.badlogic.gdx.graphics.Color;
+import com.badlogic.gdx.graphics.GL10;
+import com.badlogic.gdx.graphics.Pixmap;
+import com.badlogic.gdx.graphics.Pixmap.Format;
+import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.g2d.SpriteBatch;
+import com.badlogic.gdx.graphics.g2d.TextureAtlas;
+import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
+import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData;
+import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
+
+public class SkeletonTest extends ApplicationAdapter {
+	SpriteBatch batch;
+	float time;
+	SkeletonRenderer renderer;
+	SkeletonRendererDebug debugRenderer;
+
+	SkeletonData skeletonData;
+	Skeleton skeleton;
+	Animation animation;
+
+	public void create () {
+		batch = new SpriteBatch();
+		renderer = new SkeletonRenderer();
+		debugRenderer = new SkeletonRendererDebug();
+
+		final String name = "goblins"; // "spineboy";
+
+		// A regular texture atlas would normally usually be used. This returns a white image for images not found in the atlas.
+		Pixmap pixmap = new Pixmap(32, 32, Format.RGBA8888);
+		pixmap.setColor(Color.WHITE);
+		pixmap.fill();
+		final AtlasRegion fake = new AtlasRegion(new Texture(pixmap), 0, 0, 32, 32);
+		pixmap.dispose();
+		FileHandle atlasFile = Gdx.files.internal(name + ".atlas");
+		TextureAtlasData data = !atlasFile.exists() ? null : new TextureAtlasData(atlasFile, atlasFile.parent(), false);
+		TextureAtlas atlas = new TextureAtlas(data) {
+			public AtlasRegion findRegion (String name) {
+				AtlasRegion region = super.findRegion(name);
+				return region != null ? region : fake;
+			}
+		};
+
+		if (true) {
+			SkeletonJson json = new SkeletonJson(atlas);
+			// json.setScale(2);
+			skeletonData = json.readSkeletonData(Gdx.files.internal(name + ".json"));
+		} else {
+			SkeletonBinary binary = new SkeletonBinary(atlas);
+			// binary.setScale(2);
+			skeletonData = binary.readSkeletonData(Gdx.files.internal(name + ".skel"));
+		}
+		animation = skeletonData.findAnimation("walk");
+
+		skeleton = new Skeleton(skeletonData);
+		if (name.equals("goblins")) skeleton.setSkin("goblin");
+		skeleton.setToBindPose();
+		skeleton = new Skeleton(skeleton);
+
+		Bone root = skeleton.getRootBone();
+		root.x = 50;
+		root.y = 20;
+		root.scaleX = 1f;
+		root.scaleY = 1f;
+		skeleton.updateWorldTransform();
+
+		Gdx.input.setInputProcessor(new InputAdapter() {
+			public boolean keyDown (int keycode) {
+				if (keycode == Keys.SPACE) {
+					if (name.equals("goblins")) {
+						skeleton.setSkin(skeleton.getSkin().getName().equals("goblin") ? "goblingirl" : "goblin");
+						skeleton.setSlotsToBindPose();
+					}
+				}
+				return true;
+			}
+		});
+	}
+
+	public void render () {
+		time += Gdx.graphics.getDeltaTime();
+
+		Bone root = skeleton.getRootBone();
+		float x = root.getX() + 160 * Gdx.graphics.getDeltaTime() * (skeleton.getFlipX() ? -1 : 1);
+		if (x > Gdx.graphics.getWidth()) skeleton.setFlipX(true);
+		if (x < 0) skeleton.setFlipX(false);
+		root.setX(x);
+
+		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
+
+		animation.apply(skeleton, time, true);
+		skeleton.updateWorldTransform();
+		skeleton.update(Gdx.graphics.getDeltaTime());
+
+		batch.begin();
+		renderer.draw(batch, skeleton);
+		batch.end();
+
+		debugRenderer.draw(batch, skeleton);
+	}
+
+	public void resize (int width, int height) {
+		batch.getProjectionMatrix().setToOrtho2D(0, 0, width, height);
+		debugRenderer.getShapeRenderer().setProjectionMatrix(batch.getProjectionMatrix());
+	}
+
+	public static void main (String[] args) throws Exception {
+		new LwjglApplication(new SkeletonTest());
+	}
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.