getPoints();
17 | public void addTriangle( DelaunayTriangle t );
18 | public void addTriangles( List list );
19 | public void clearTriangulation();
20 |
21 | public TriangulationMode getTriangulationMode();
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Application Model - MVC
3 | *
4 | *
5 | * Activity
6 | *
7 | *
8 | *
9 | * ModelViewModel (Model)
10 | * ModelFragment (View) --> GLSurface
11 | * PreferenceFragment (View-Controller)
12 | * ModelController (Controller)
13 | *
14 | *
15 | * MModelViewModel:
16 | *
17 | *
18 | * ModelEngine (Model)
19 | * GLSurfaceView (View)
20 | * GLTouchController (Controller)
21 | * TouchController (Controller)
22 | *
23 | *
24 | * Temporary Beans
25 | *
26 | *
27 | * GLSurfaceView (View)
28 | *
29 | *
30 | */
31 | package org.the3deer.android_3d_model_engine;
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/preferences/PreferenceAdapter.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.preferences;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 |
6 | import androidx.annotation.Nullable;
7 | import androidx.preference.PreferenceScreen;
8 |
9 | import java.util.Map;
10 |
11 | public interface PreferenceAdapter {
12 |
13 | default void onRestoreInstanceState(Bundle state) {
14 | }
15 |
16 | default void onSaveInstanceState(Bundle outState){
17 | }
18 |
19 | default void onRestorePreferences(@Nullable Map preferences){
20 | }
21 |
22 | default void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey, Context context, PreferenceScreen screen){
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/util/android/WebAppInterface.java:
--------------------------------------------------------------------------------
1 |
2 | package org.the3deer.util.android;
3 |
4 | import android.content.Context;
5 | import android.webkit.JavascriptInterface;
6 | import android.widget.Toast;
7 |
8 | public final class WebAppInterface {
9 | private Context mContext;
10 |
11 | public WebAppInterface(Context c) {
12 | mContext = c;
13 | }
14 |
15 | @JavascriptInterface
16 | public void log(String txt) {
17 | AndroidUtils.logd(txt);
18 | }
19 |
20 | @JavascriptInterface
21 | public void logd(String txt) {
22 | AndroidUtils.logd(txt);
23 | }
24 |
25 | @JavascriptInterface
26 | public void toast(String toast) {
27 | Toast.makeText(mContext, toast, Toast.LENGTH_LONG).show();
28 | }
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/src/main/res/raw/shader_f_depth_map.glsl:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | // data
4 | varying vec4 v_Position;
5 |
6 | // from Fabien Sangalard's DEngine
7 | vec4 pack (float depth)
8 | {
9 | const vec4 bitSh = vec4(256.0 * 256.0 * 256.0,
10 | 256.0 * 256.0,
11 | 256.0,
12 | 1.0);
13 | const vec4 bitMsk = vec4(0,
14 | 1.0 / 256.0,
15 | 1.0 / 256.0,
16 | 1.0 / 256.0);
17 | vec4 comp = fract(depth * bitSh);
18 | comp -= comp.xxyz * bitMsk;
19 | return comp;
20 | }
21 |
22 | void main() {
23 | // the depth
24 | float normalizedDistance = v_Position.z / v_Position.w;
25 | // scale -1.0;1.0 to 0.0;1.0
26 | normalizedDistance = (normalizedDistance + 1.0) / 2.0;
27 |
28 | // pack value into 32-bit RGBA texture
29 | gl_FragColor = pack(normalizedDistance);
30 | }
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/services/gltf/GltfLoaderTask.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.services.gltf;
2 |
3 | import android.app.Activity;
4 |
5 | import org.the3deer.android_3d_model_engine.model.Object3DData;
6 | import org.the3deer.android_3d_model_engine.services.LoadListener;
7 | import org.the3deer.android_3d_model_engine.services.LoaderTask;
8 |
9 | import java.io.IOException;
10 | import java.net.URI;
11 | import java.util.List;
12 |
13 | public class GltfLoaderTask extends LoaderTask {
14 |
15 | public GltfLoaderTask(Activity parent, URI uri, LoadListener callback) {
16 | super(parent, uri, callback);
17 | }
18 |
19 | @Override
20 | protected List build() throws IOException {
21 | return new GltfLoader().load(uri, this);
22 | }
23 | }
--------------------------------------------------------------------------------
/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/services/collada/ColladaLoaderTask.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.services.collada;
2 |
3 | import android.app.Activity;
4 |
5 | import org.the3deer.android_3d_model_engine.model.Object3DData;
6 | import org.the3deer.android_3d_model_engine.services.LoadListener;
7 | import org.the3deer.android_3d_model_engine.services.LoaderTask;
8 |
9 | import java.io.IOException;
10 | import java.net.URI;
11 | import java.util.List;
12 |
13 | public class ColladaLoaderTask extends LoaderTask {
14 |
15 | public ColladaLoaderTask(Activity parent, URI uri, LoadListener callback) {
16 | super(parent, uri, callback);
17 | }
18 |
19 | @Override
20 | protected List build() throws IOException {
21 | return new ColladaLoader().load(uri, this);
22 | }
23 | }
--------------------------------------------------------------------------------
/src/main/res/values-es/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Visor de modelos 3D
5 |
6 |
7 | Por favor seleccione
8 | Ok
9 | Cancelar
10 |
11 | Preferencias
12 |
13 |
14 | Cambiar Renderizado
15 | Cambiar Cámara
16 | Cambiar SkyBox
17 | Cambiar Vista
18 |
19 |
20 | gris
21 | blanco
22 | negro
23 |
24 |
--------------------------------------------------------------------------------
/src/main/java/org/poly2tri/geometry/polygon/PolygonPoint.java:
--------------------------------------------------------------------------------
1 | package org.poly2tri.geometry.polygon;
2 |
3 | import org.poly2tri.triangulation.point.TPoint;
4 |
5 | public class PolygonPoint extends TPoint
6 | {
7 | protected PolygonPoint _next;
8 | protected PolygonPoint _previous;
9 |
10 | public PolygonPoint( double x, double y )
11 | {
12 | super( x, y );
13 | }
14 |
15 | public PolygonPoint( double x, double y, double z )
16 | {
17 | super( x, y, z );
18 | }
19 |
20 | public void setPrevious( PolygonPoint p )
21 | {
22 | _previous = p;
23 | }
24 |
25 | public void setNext( PolygonPoint p )
26 | {
27 | _next = p;
28 | }
29 |
30 | public PolygonPoint getNext()
31 | {
32 | return _next;
33 | }
34 |
35 | public PolygonPoint getPrevious()
36 | {
37 | return _previous;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/collision/Collision.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.collision;
2 |
3 | import org.the3deer.android_3d_model_engine.model.Object3DData;
4 |
5 | public class Collision {
6 |
7 | private final Object3DData object;
8 | private final float[] point;
9 | private final float dx;
10 | private final float dy;
11 |
12 | public Collision(Object3DData object, float[] point, float dx, float dy) {
13 | this.object = object;
14 | this.point = point;
15 | this.dx = dx;
16 | this.dy = dy;
17 | }
18 |
19 | public Object getObject() {
20 | return object;
21 | }
22 |
23 | public float[] getPoint() {
24 | return point;
25 | }
26 |
27 | public float getDx() {
28 | return dx;
29 | }
30 |
31 | public float getDy() {
32 | return dy;
33 | }
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/poly2tri/triangulation/delaunay/sweep/DTSweepPointComparator.java:
--------------------------------------------------------------------------------
1 | package org.poly2tri.triangulation.delaunay.sweep;
2 |
3 | import org.poly2tri.triangulation.TriangulationPoint;
4 |
5 | import java.util.Comparator;
6 |
7 | public class DTSweepPointComparator implements Comparator
8 | {
9 | public int compare( TriangulationPoint p1, TriangulationPoint p2 )
10 | {
11 | if(p1.getY() < p2.getY() )
12 | {
13 | return -1;
14 | }
15 | else if( p1.getY() > p2.getY())
16 | {
17 | return 1;
18 | }
19 | else
20 | {
21 | if(p1.getX() < p2.getX())
22 | {
23 | return -1;
24 | }
25 | else if( p1.getX() > p2.getX() )
26 | {
27 | return 1;
28 | }
29 | else
30 | {
31 | return 0;
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/org/the3deer/util/math/QuaternionTest.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.util.math;
2 |
3 | import org.junit.Test;
4 |
5 | public class QuaternionTest {
6 |
7 | @Test
8 | public void testRotation1(){
9 | float[] matrix = new float[16];
10 |
11 | Math3DUtils.setRotateM(matrix,0,180,0,0,1);
12 | System.out.println(Math3DUtils.toString(matrix,0));
13 | Quaternion sut = Quaternion.fromMatrix(matrix);
14 | System.out.println(sut.toString());
15 |
16 | Math3DUtils.setRotateM(matrix,0,270,0,0,1);
17 | System.out.println(Math3DUtils.toString(matrix,0));
18 | sut = Quaternion.fromMatrix(matrix);
19 | System.out.println(sut.toString());
20 |
21 | Math3DUtils.setRotateM(matrix,0,-359,0,0,1);
22 | System.out.println(Math3DUtils.toString(matrix,0));
23 | sut = Quaternion.fromMatrix(matrix);
24 | System.out.println(sut.toString());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/gui/Layout.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.gui;
2 |
3 | /**
4 | * A layout is a transparent container that manager the structure of the user interface widgets
5 | */
6 | public class Layout extends Widget {
7 |
8 | public Layout(Widget parent) {
9 | super(parent, parent.contentDimensions.getWidth(), parent.contentDimensions.getHeight());
10 | setRender(false);
11 | }
12 |
13 | /**
14 | * A layout that arranges widgets either horizontally in a single column or vertically in a single row.
15 | */
16 | public static class LinearLayout extends Layout {
17 |
18 | public enum Orientation { Horizontal, Vertical}
19 |
20 | private final Orientation orientation;
21 |
22 | public LinearLayout(Widget parent, Orientation orientation) {
23 | super(parent);
24 | this.orientation = orientation;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/androidTest/java/org/the3deer/android_3d_model_engine/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine;
2 |
3 | import static org.junit.Assert.assertEquals;
4 |
5 | import android.content.Context;
6 |
7 | import androidx.test.ext.junit.runners.AndroidJUnit4;
8 | import androidx.test.platform.app.InstrumentationRegistry;
9 |
10 | import org.junit.Test;
11 | import org.junit.runner.RunWith;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 |
25 | assertEquals("org.the3deer.android_3d_model_engine.test", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/model/Screen.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.model;
2 |
3 | public class Screen {
4 |
5 | public int width;
6 | public int height;
7 |
8 | public float ratio;
9 | private Dimensions dimensions;
10 |
11 | public Screen(int width, int height) {
12 | this.setSize(width, height);
13 | }
14 |
15 | public void setSize(int width, int height) {
16 | this.width = width;
17 | this.height = height;
18 | // derived
19 | this.ratio = (float) width / height;
20 | this.dimensions = new Dimensions(0, width, 0, height, 0, 0);
21 | }
22 |
23 | public int getWidth() {
24 | return width;
25 | }
26 |
27 | public int getHeight() {
28 | return height;
29 | }
30 |
31 | /*public Dimensions getDimensions(){
32 | return dimensions;
33 | }*/
34 |
35 | public float getRatio() {
36 | return ratio;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/poly2tri/geometry/primitives/Point.java:
--------------------------------------------------------------------------------
1 | package org.poly2tri.geometry.primitives;
2 |
3 | public abstract class Point
4 | {
5 | public abstract double getX();
6 | public abstract double getY();
7 | public abstract double getZ();
8 |
9 | public abstract float getXf();
10 | public abstract float getYf();
11 | public abstract float getZf();
12 |
13 | public abstract void set( double x, double y, double z );
14 |
15 | protected static int calculateHashCode( double x, double y, double z)
16 | {
17 | int result = 17;
18 |
19 | final long a = Double.doubleToLongBits(x);
20 | result += 31 * result + (int) (a ^ (a >>> 32));
21 |
22 | final long b = Double.doubleToLongBits(y);
23 | result += 31 * result + (int) (b ^ (b >>> 32));
24 |
25 | final long c = Double.doubleToLongBits(z);
26 | result += 31 * result + (int) (c ^ (c >>> 32));
27 |
28 | return result;
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/shader/ShaderResource.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.shader;
2 |
3 |
4 | import org.the3deer.android_3d_model_engine.R;
5 |
6 | public enum ShaderResource {
7 |
8 | SKYBOX("skybox", R.raw.shader_skybox_vert, R.raw.shader_skybox_frag),
9 | BASIC("basic", R.raw.shader_basic_vert, R.raw.shader_basic_frag),
10 | ANIMATED("animated", R.raw.shader_animated_vert, R.raw.shader_animated_frag),
11 | SHADOW("shadow", R.raw.shader_v_depth_map, R.raw.shader_f_depth_map),
12 | SHADOWED("shadowed", R.raw.shader_v_with_shadow, R.raw.shader_f_with_simple_shadow);
13 |
14 | String id;
15 | int vertexShaderResourceId = -1;
16 | int fragmentShaderResourceId = -1;
17 |
18 | ShaderResource(String id, int vertexShaderCode, int fragmentShaderCode){
19 | this.id = id;
20 | this.vertexShaderResourceId = vertexShaderCode;
21 | this.fragmentShaderResourceId = fragmentShaderCode;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/collision/CollisionEvent.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.collision;
2 |
3 | import org.the3deer.android_3d_model_engine.model.Object3DData;
4 |
5 | import java.util.EventObject;
6 |
7 | public class CollisionEvent extends EventObject {
8 |
9 | private final Object3DData object;
10 | private final float x;
11 | private final float y;
12 | private final Object3DData point;
13 |
14 | public CollisionEvent(Object source, Object3DData object, float x, float y, Object3DData point) {
15 | super(source);
16 | this.object = object;
17 | this.x = x;
18 | this.y = y;
19 | this.point = point;
20 | }
21 |
22 | public Object3DData getObject() {
23 | return object;
24 | }
25 |
26 | public float getX() {
27 | return x;
28 | }
29 |
30 | public float getY() {
31 | return y;
32 | }
33 |
34 | public Object3DData getPoint() {
35 | return point;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/model/Materials.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.model;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | public class Materials {
7 |
8 | final String id;
9 |
10 | final Map materials = new HashMap<>();
11 |
12 | public Materials(String id) {
13 | this.id = id;
14 | }
15 |
16 | public void add(String name, Material material) {
17 | materials.put(name, material);
18 | }
19 |
20 | public Material get(String name) {
21 | return materials.get(name);
22 | }
23 |
24 | public boolean contains(String elementMaterial) {
25 | return materials.containsKey(elementMaterial);
26 | }
27 |
28 | public int size() {
29 | return materials.size();
30 | }
31 |
32 | @Override
33 | public String toString() {
34 | return "Materials{" +
35 | "id='" + id + '\'' +
36 | ", materials=" + materials +
37 | '}';
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/services/collada/entities/AnimatedModelData.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.services.collada.entities;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | /**
7 | * Contains the extracted data for an animated model, which includes the mesh data, and skeleton (joints heirarchy) data.
8 | * @author andresoviedo
9 | *
10 | */
11 | public class AnimatedModelData {
12 |
13 | private final SkeletonData joints;
14 | private final List mesh;
15 | private final Map skinningData;
16 |
17 | public AnimatedModelData(List mesh, SkeletonData joints, Map skinningData){
18 | this.joints = joints;
19 | this.mesh = mesh;
20 | this.skinningData = skinningData;
21 | }
22 |
23 | public SkeletonData getJointsData(){
24 | return joints;
25 | }
26 |
27 | public List getMeshData(){
28 | return mesh;
29 | }
30 |
31 | public Map getSkinningData() {
32 | return skinningData;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/util/android/AndroidURLConnection.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.util.android;
2 |
3 | import android.util.Log;
4 |
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 | import java.net.URISyntaxException;
8 | import java.net.URL;
9 | import java.net.URLConnection;
10 |
11 | public class AndroidURLConnection extends URLConnection {
12 |
13 | private InputStream stream;
14 |
15 | public AndroidURLConnection(URL url) {
16 | super(url);
17 | }
18 |
19 | @Override
20 | public void connect() throws IOException
21 | {
22 | if (stream == null) {
23 | try {
24 | stream = ContentUtils.getInputStream(url.toURI());
25 | } catch (URISyntaxException e) {
26 | Log.e("Handler", e.getMessage(), e);
27 | throw new IOException("Error opening stream " + url + ". " + e.getMessage());
28 | }
29 | }
30 | }
31 |
32 | @Override
33 | public InputStream getInputStream() throws IOException {
34 | connect();
35 | return stream;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/poly2tri/triangulation/delaunay/sweep/AdvancingFrontIndex.java:
--------------------------------------------------------------------------------
1 | package org.poly2tri.triangulation.delaunay.sweep;
2 |
3 | public class AdvancingFrontIndex
4 | {
5 | double _min,_max;
6 | IndexNode _root;
7 |
8 | public AdvancingFrontIndex( double min, double max, int depth )
9 | {
10 | if( depth > 5 ) depth = 5;
11 | _root = createIndex( depth );
12 | }
13 |
14 | private IndexNode createIndex( int n )
15 | {
16 | IndexNode node = null;
17 | if( n > 0 )
18 | {
19 | node = new IndexNode();
20 | node.bigger = createIndex( n-1 );
21 | node.smaller = createIndex( n-1 );
22 | }
23 | return node;
24 | }
25 |
26 | public A fetchAndRemoveIndex( A key )
27 | {
28 | return null;
29 | }
30 |
31 | public A fetchAndInsertIndex( A key )
32 | {
33 | return null;
34 | }
35 |
36 | class IndexNode
37 | {
38 | A value;
39 | IndexNode smaller;
40 | IndexNode bigger;
41 | double range;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/util/geometry/DelaunayConstraint.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.util.geometry;
2 |
3 | import org.the3deer.util.math.Math3DUtils;
4 |
5 | import java.util.Arrays;
6 |
7 | final class DelaunayConstraint {
8 | final float[] v1;
9 | final float[] v2;
10 |
11 | public DelaunayConstraint(float[] v1, float[] v2) {
12 | this.v1 = v1;
13 | this.v2 = v2;
14 | }
15 |
16 | @Override
17 | public boolean equals(Object o) {
18 | if (this == o) return true;
19 | if (o == null || getClass() != o.getClass()) return false;
20 | DelaunayConstraint that = (DelaunayConstraint) o;
21 | float[] sum = Math3DUtils.add(v1, v2);
22 | float[] thatSum = Math3DUtils.add(that.v1, that.v2);
23 | return Arrays.equals(sum, thatSum);
24 | }
25 |
26 | @Override
27 | public int hashCode() {
28 | float[] sum = Math3DUtils.add(v1, v2);
29 | return Arrays.hashCode(sum);
30 | }
31 |
32 | @Override
33 | public String toString() {
34 | return "DelaunayConstraint{" +
35 | "v1=" + Arrays.toString(v1) +
36 | ", v2=" + Arrays.toString(v2) +
37 | '}';
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/poly2tri/transform/coordinate/Matrix3Transform.java:
--------------------------------------------------------------------------------
1 | package org.poly2tri.transform.coordinate;
2 |
3 | import org.poly2tri.geometry.primitives.Point;
4 |
5 | import java.util.List;
6 |
7 | public abstract class Matrix3Transform implements CoordinateTransform
8 | {
9 | protected double m00,m01,m02,m10,m11,m12,m20,m21,m22;
10 |
11 | public void transform( Point p, Point store )
12 | {
13 | final double px = p.getX();
14 | final double py = p.getY();
15 | final double pz = p.getZ();
16 | store.set(m00 * px + m01 * py + m02 * pz,
17 | m10 * px + m11 * py + m12 * pz,
18 | m20 * px + m21 * py + m22 * pz );
19 | }
20 |
21 | public void transform( Point p )
22 | {
23 | final double px = p.getX();
24 | final double py = p.getY();
25 | final double pz = p.getZ();
26 | p.set(m00 * px + m01 * py + m02 * pz,
27 | m10 * px + m11 * py + m12 * pz,
28 | m20 * px + m21 * py + m22 * pz );
29 | }
30 |
31 | public void transform( List extends Point> list )
32 | {
33 | for( Point p : list )
34 | {
35 | transform( p );
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/impl/v1/GlTFChildOfRootProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * glTF JSON model
3 | *
4 | * Do not modify this class. It is automatically generated
5 | * with JsonModelGen (https://github.com/javagl/JsonModelGen)
6 | * Copyright (c) 2016 Marco Hutter - http://www.javagl.de
7 | */
8 |
9 | package de.javagl.jgltf.impl.v1;
10 |
11 |
12 |
13 | /**
14 | * Auto-generated for glTFChildOfRootProperty.schema.json
15 | *
16 | */
17 | public class GlTFChildOfRootProperty
18 | extends GlTFProperty
19 | {
20 |
21 | /**
22 | * The user-defined name of this object. (optional)
23 | *
24 | */
25 | private String name;
26 |
27 | /**
28 | * The user-defined name of this object. (optional)
29 | *
30 | * @param name The name to set
31 | *
32 | */
33 | public void setName(String name) {
34 | if (name == null) {
35 | this.name = name;
36 | return ;
37 | }
38 | this.name = name;
39 | }
40 |
41 | /**
42 | * The user-defined name of this object. (optional)
43 | *
44 | * @return The name
45 | *
46 | */
47 | public String getName() {
48 | return this.name;
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/impl/v2/GlTFChildOfRootProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * glTF JSON model
3 | *
4 | * Do not modify this class. It is automatically generated
5 | * with JsonModelGen (https://github.com/javagl/JsonModelGen)
6 | * Copyright (c) 2016-2021 Marco Hutter - http://www.javagl.de
7 | */
8 |
9 | package de.javagl.jgltf.impl.v2;
10 |
11 |
12 |
13 | /**
14 | * Auto-generated for glTFChildOfRootProperty.schema.json
15 | *
16 | */
17 | public class GlTFChildOfRootProperty
18 | extends GlTFProperty
19 | {
20 |
21 | /**
22 | * The user-defined name of this object. (optional)
23 | *
24 | */
25 | private String name;
26 |
27 | /**
28 | * The user-defined name of this object. (optional)
29 | *
30 | * @param name The name to set
31 | *
32 | */
33 | public void setName(String name) {
34 | if (name == null) {
35 | this.name = name;
36 | return ;
37 | }
38 | this.name = name;
39 | }
40 |
41 | /**
42 | * The user-defined name of this object. (optional)
43 | *
44 | * @return The name
45 | *
46 | */
47 | public String getName() {
48 | return this.name;
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/services/wavefront/WavefrontLoaderTask.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.services.wavefront;
2 |
3 | import android.app.Activity;
4 | import android.opengl.GLES20;
5 |
6 | import org.the3deer.android_3d_model_engine.model.Object3DData;
7 | import org.the3deer.android_3d_model_engine.services.LoadListener;
8 | import org.the3deer.android_3d_model_engine.services.LoaderTask;
9 |
10 | import java.net.URI;
11 | import java.util.List;
12 |
13 | /**
14 | * Wavefront loader implementation
15 | *
16 | * @author andresoviedo
17 | */
18 |
19 | public class WavefrontLoaderTask extends LoaderTask {
20 |
21 | public WavefrontLoaderTask(final Activity parent, final URI uri, final LoadListener callback) {
22 | super(parent, uri, callback);
23 | }
24 |
25 | @Override
26 | protected List build() {
27 |
28 | final WavefrontLoader wfl = new WavefrontLoader(GLES20.GL_TRIANGLE_FAN, this);
29 |
30 | super.publishProgress("Loading model...");
31 |
32 | final List load = wfl.load(uri);
33 |
34 | return load;
35 | }
36 |
37 | @Override
38 | public void onProgress(String progress) {
39 | super.publishProgress(progress);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/services/collada/entities/SkinningData.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.services.collada.entities;
2 |
3 | import java.util.List;
4 |
5 | public class SkinningData {
6 |
7 | private final String id;
8 | private final float[] bindShapeMatrix;
9 | public final List jointOrder;
10 | public final List verticesSkinData;
11 | private final float[] inverseBindMatrix;
12 |
13 | /**
14 | * @param skinId
15 | * @param bindShapeMatrix bind_shape_matrix or IDENTITY_MATRIX
16 | * @param jointOrder
17 | * @param verticesSkinData
18 | * @param inverseBindMatrix optional value
19 | */
20 | public SkinningData(String skinId, float[] bindShapeMatrix, List jointOrder, List verticesSkinData, float[] inverseBindMatrix){
21 | this.id = skinId;
22 | this.bindShapeMatrix = bindShapeMatrix;
23 | this.jointOrder = jointOrder;
24 | this.verticesSkinData = verticesSkinData;
25 | this.inverseBindMatrix = inverseBindMatrix;
26 | }
27 |
28 |
29 | public float[] getBindShapeMatrix() {
30 | return bindShapeMatrix;
31 | }
32 |
33 | public float[] getInverseBindMatrix() {
34 | return inverseBindMatrix;
35 | }
36 |
37 | public String getId() {
38 | return this.id;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/poly2tri/triangulation/util/PointGenerator.java:
--------------------------------------------------------------------------------
1 | package org.poly2tri.triangulation.util;
2 |
3 | import org.poly2tri.triangulation.TriangulationPoint;
4 | import org.poly2tri.triangulation.point.TPoint;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | public class PointGenerator
10 | {
11 | public static List uniformDistribution( int n, double scale )
12 | {
13 | ArrayList points = new ArrayList();
14 | for( int i=0; i uniformGrid( int n, double scale )
22 | {
23 | double x=0;
24 | double size = scale/n;
25 | double halfScale = 0.5*scale;
26 |
27 | ArrayList points = new ArrayList();
28 | for( int i=0; inull
34 | *
35 | */
36 | public void setUri(String uri) {
37 | if (uri == null) {
38 | throw new NullPointerException((("Invalid value for uri: "+ uri)+", may not be null"));
39 | }
40 | this.uri = uri;
41 | }
42 |
43 | /**
44 | * The uri of the image. (required)
45 | *
46 | * @return The uri
47 | *
48 | */
49 | public String getUri() {
50 | return this.uri;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/shadow/RenderConstants.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.shadow;
2 |
3 | public class RenderConstants {
4 |
5 | /** Identifiers for our uniforms and attributes inside the shaders. */
6 | public static final String MVP_MATRIX_UNIFORM = "uMVPMatrix";
7 | public static final String MV_MATRIX_UNIFORM = "uMVMatrix";
8 | public static final String NORMAL_MATRIX_UNIFORM = "uNormalMatrix";
9 | public static final String LIGHT_POSITION_UNIFORM = "u_LightPos";
10 | public static final String POSITION_ATTRIBUTE = "a_Position";
11 | public static final String NORMAL_ATTRIBUTE = "a_Normal";
12 | public static final String COLOR_ATTRIBUTE = "a_Color";
13 | public static final String TEX_COORDINATE = "aTexCoordinate";
14 |
15 | public static final String SHADOW_TEXTURE = "uShadowTexture";
16 | public static final String SHADOW_PROJ_MATRIX = "uShadowProjMatrix";
17 | public static final String SHADOW_X_PIXEL_OFFSET = "uxPixelOffset";
18 | public static final String SHADOW_Y_PIXEL_OFFSET = "uyPixelOffset";
19 |
20 | public static final String SHADOW_POSITION_ATTRIBUTE = "aShadowPosition";
21 |
22 | public static final String TEXTURE_UNIFORM = "uTexture";
23 |
24 | /** Additional constants. */
25 | public static final int FLOAT_SIZE_IN_BYTES = 4;
26 | public static final int SHORT_SIZE_IN_BYTES = 2;
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/model/CubeMap.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.model;
2 |
3 | /**
4 | * Cube with six textures used to implement the SkyBox
5 | */
6 | public final class CubeMap {
7 |
8 | private final byte[] posX;
9 | private final byte[] negX;
10 | private final byte[] posY;
11 | private final byte[] negY;
12 | private final byte[] posZ;
13 | private final byte[] negZ;
14 |
15 | private int textureId = -1;
16 |
17 | public CubeMap(byte[] posX, byte[] negX, byte[] posY, byte[] negY, byte[] posZ, byte[] negZ) {
18 | this.posX = posX;
19 | this.negX = negX;
20 | this.posY = posY;
21 | this.negY = negY;
22 | this.posZ = posZ;
23 | this.negZ = negZ;
24 | }
25 |
26 | public byte[] getNegx() {
27 | return negX;
28 | }
29 |
30 | public byte[] getNegy() {
31 | return negY;
32 | }
33 |
34 | public byte[] getNegz() {
35 | return negZ;
36 | }
37 |
38 | public byte[] getPoxx() {
39 | return posX;
40 | }
41 |
42 | public byte[] getPoxy() {
43 | return posY;
44 | }
45 |
46 | public byte[] getPoxz() {
47 | return posZ;
48 | }
49 |
50 | public int getTextureId() {
51 | return textureId;
52 | }
53 |
54 | public void setTextureId(int textureId) {
55 | this.textureId = textureId;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/res/layout/fragment_model.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
11 |
12 |
13 |
19 |
20 |
21 |
22 |
31 |
32 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/renderer/RenderEvent.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.renderer;
2 |
3 | import org.the3deer.android_3d_model_engine.model.Projection;
4 |
5 | import java.util.EventObject;
6 |
7 | public class RenderEvent extends EventObject {
8 |
9 | private final Code code;
10 |
11 | private int width;
12 | private int height;
13 | private Projection projection;
14 |
15 | public enum Code {SURFACE_CREATED, SURFACE_CHANGED, PROJECTION_CHANGED}
16 |
17 | public RenderEvent(Object source, Code code) {
18 | super(source);
19 | this.code = code;
20 | }
21 |
22 | public RenderEvent(Object source, Code code, int width, int height) {
23 | super(source);
24 | this.code = code;
25 | this.width = width;
26 | this.height = height;
27 | }
28 |
29 | public Code getCode() {
30 | return code;
31 | }
32 |
33 | public int getWidth() {
34 | return width;
35 | }
36 |
37 | public int getHeight() {
38 | return height;
39 | }
40 |
41 | public Projection getProjection() {
42 | return projection;
43 | }
44 |
45 | public void setProjection(Projection projection) {
46 | this.projection = projection;
47 | }
48 |
49 | @Override
50 | public String toString() {
51 | return "ViewEvent{" +
52 | "code=" + code +
53 | '}';
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/res/raw/shader_v_depth_map.glsl:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | const int MAX_JOINTS = 60;
4 | //const int MAX_WEIGHTS = 3;
5 |
6 | // MVP matrices
7 | uniform mat4 u_MMatrix;
8 | uniform mat4 u_VMatrix;
9 | uniform mat4 u_PMatrix;
10 |
11 | // mesh
12 | attribute vec3 a_Position;
13 | varying vec4 v_Position;
14 |
15 | // animation
16 | uniform bool u_Animated;
17 | attribute vec4 in_jointIndices;
18 | attribute vec4 in_weights;
19 | uniform mat4 u_BindShapeMatrix;
20 | uniform mat4 jointTransforms[MAX_JOINTS];
21 |
22 | void main(){
23 |
24 | vec4 animatedPos = vec4(a_Position,1.0);
25 | if (u_Animated) {
26 | vec4 bindPos = u_BindShapeMatrix * vec4(a_Position, 1.0);
27 | vec4 posePosition = jointTransforms[int(in_jointIndices[0])] * bindPos;
28 | animatedPos = posePosition * in_weights[0];
29 | posePosition = jointTransforms[int(in_jointIndices[1])] * bindPos;
30 | animatedPos += posePosition * in_weights[1];
31 | posePosition = jointTransforms[int(in_jointIndices[2])] * bindPos;
32 | animatedPos += posePosition * in_weights[2];
33 | posePosition = jointTransforms[int(in_jointIndices[3])] * bindPos;
34 | animatedPos += posePosition * in_weights[3];
35 | }
36 |
37 | // calculate MVP matrix
38 | mat4 u_MVMatrix = u_VMatrix * u_MMatrix;
39 | mat4 u_MVPMatrix = u_PMatrix * u_MVMatrix;
40 |
41 | // calculate rendered position
42 | gl_Position = u_MVPMatrix * animatedPos;
43 | v_Position = animatedPos;
44 | }
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/MaterialModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model;
28 |
29 | /**
30 | * Interface for a material model
31 | */
32 | public interface MaterialModel extends NamedModelElement
33 | {
34 | // No common methods
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/services/collada/entities/JointTransformData.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.services.collada.entities;
2 |
3 | /**
4 | * This contains the data for a transformation of one joint, at a certain time
5 | * in an animation. It has the name of the joint that it refers to, and the
6 | * local transform of the joint in the pose position.
7 | *
8 | * @author andresoviedo
9 | *
10 | */
11 | public class JointTransformData {
12 |
13 | public final String jointId;
14 |
15 | public final float[] matrix;
16 | public final Float[] location;
17 | public final Float[] rotation;
18 | public final Float[] scale;
19 |
20 | private JointTransformData(String jointId, float[] matrix, Float[] location, Float[] rotation, Float[] scale) {
21 | this.jointId = jointId;
22 | this.matrix = matrix;
23 | this.location = location;
24 | this.rotation = rotation;
25 | this.scale = scale;
26 | }
27 |
28 | public static JointTransformData ofMatrix(String jointId, float[] matrix) {
29 | return new JointTransformData(jointId, matrix, null, null, null);
30 | }
31 |
32 | public static JointTransformData ofLocation(String jointId, Float[] location) {
33 | return new JointTransformData(jointId, null, location, null, null);
34 | }
35 |
36 | public static JointTransformData ofRotation(String jointId, Float[] rotation) {
37 | return new JointTransformData(jointId, null, null, rotation, null);
38 | }
39 |
40 | public static JointTransformData ofScale(String jointId, Float[] scale) {
41 | return new JointTransformData(jointId, null, null, null, scale);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/gui/Axis.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.gui;
2 |
3 | import org.the3deer.android_3d_model_engine.model.Camera;
4 | import org.the3deer.android_3d_model_engine.model.Scene;
5 |
6 | import java.util.EventObject;
7 |
8 | import javax.inject.Inject;
9 |
10 | public class Axis extends Widget {
11 |
12 | @Inject
13 | private Scene scene;
14 | //private final float[] matrix = new float[16];
15 | //private final Quaternion orientation = new Quaternion(matrix);
16 |
17 | public Axis(){
18 | super(org.the3deer.android_3d_model_engine.objects.Axis.build());
19 | setId("gui_axis");
20 | setVisible(true);
21 | /*setRelativeScale(new float[]{0.1f, 0.1f, 0.1f});
22 |
23 | setRelativeLocation(Widget.POSITION_TOP_LEFT);*/
24 | /*setLocation(new float[]{-1,0,0});
25 | setScale(new float[]{0.5f, 0.5f, 0.5f});*/
26 | }
27 |
28 | public void setUp(){
29 | // this.sceneCamera = BeanFactory.getInstance().find(Camera.class, "scene_0");
30 | if (this.scene != null && this.scene.getCamera() != null) {
31 | this.scene.getCamera().addListener(this);
32 | }
33 | }
34 |
35 | public void dispose(){
36 | if (this.scene != null) {
37 | //this.camera.removeListener(this);
38 | }
39 | }
40 |
41 | @Override
42 | public boolean onEvent(EventObject event) {
43 | if (event instanceof Camera.CameraUpdatedEvent){
44 | setOrientation(this.scene.getCamera().getOrientation());
45 | }
46 | return super.onEvent(event);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/objects/Grid.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.objects;
2 |
3 | import android.opengl.GLES20;
4 |
5 | import org.the3deer.android_3d_model_engine.model.Object3DData;
6 | import org.the3deer.util.io.IOUtils;
7 |
8 | import java.nio.FloatBuffer;
9 |
10 | public class Grid {
11 |
12 | public static Object3DData build(float xStart, float yStart, float zStart, float xEnd, float yEnd, float zEnd,
13 | float step) {
14 | int nbLines = (int) ((xEnd - xStart) / step) + 1 + (int) ((zEnd - zStart) / step) + 1 + (int) ((yEnd -
15 | yStart) / step) + 1;
16 | int nbVertex = nbLines * 2;
17 | FloatBuffer vertexBuffer = IOUtils.createNativeByteBuffer(nbVertex * 3 * 4).asFloatBuffer();
18 | if (xStart < xEnd) {
19 | for (float x = xStart; x <= xEnd; x += step) {
20 | vertexBuffer.put(x).put(yStart).put(zStart);
21 | vertexBuffer.put(x).put(yEnd).put(zEnd);
22 | }
23 | }
24 | if (yStart < yEnd) {
25 | for (float y = yStart; y <= yEnd; y += step) {
26 | vertexBuffer.put(xStart).put(y).put(zStart);
27 | vertexBuffer.put(xEnd).put(y).put(zEnd);
28 | }
29 | }
30 | if (zStart < zEnd) {
31 | for (float z = zStart; z <= zEnd; z += step) {
32 | vertexBuffer.put(xStart).put(yStart).put(z);
33 | vertexBuffer.put(xEnd).put(yEnd).put(z);
34 | }
35 | }
36 | return new Object3DData(vertexBuffer).setDrawMode(GLES20.GL_LINES);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/animation/StepInterpolator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2016 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model.animation;
28 |
29 | /**
30 | * Implementation of an {@link Interpolator} that interpolates stepwise.
31 | */
32 | class StepInterpolator implements Interpolator
33 | {
34 | @Override
35 | public void interpolate(
36 | float[] a, float[] b, float alpha, float[] result)
37 | {
38 | System.arraycopy(a, 0, result, 0, a.length);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/impl/v2/MaterialNormalTextureInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * glTF JSON model
3 | *
4 | * Do not modify this class. It is automatically generated
5 | * with JsonModelGen (https://github.com/javagl/JsonModelGen)
6 | * Copyright (c) 2016-2021 Marco Hutter - http://www.javagl.de
7 | */
8 |
9 | package de.javagl.jgltf.impl.v2;
10 |
11 |
12 |
13 | /**
14 | * Auto-generated for material.normalTextureInfo.schema.json
15 | *
16 | */
17 | public class MaterialNormalTextureInfo
18 | extends TextureInfo
19 | {
20 |
21 | /**
22 | * The scalar parameter applied to each normal vector of the normal
23 | * texture. (optional)
24 | * Default: 1.0
25 | *
26 | */
27 | private Float scale;
28 |
29 | /**
30 | * The scalar parameter applied to each normal vector of the normal
31 | * texture. (optional)
32 | * Default: 1.0
33 | *
34 | * @param scale The scale to set
35 | *
36 | */
37 | public void setScale(Float scale) {
38 | if (scale == null) {
39 | this.scale = scale;
40 | return ;
41 | }
42 | this.scale = scale;
43 | }
44 |
45 | /**
46 | * The scalar parameter applied to each normal vector of the normal
47 | * texture. (optional)
48 | * Default: 1.0
49 | *
50 | * @return The scale
51 | *
52 | */
53 | public Float getScale() {
54 | return this.scale;
55 | }
56 |
57 | /**
58 | * Returns the default value of the scale
59 | * @see #getScale
60 | *
61 | * @return The default scale
62 | *
63 | */
64 | public Float defaultScale() {
65 | return 1.0F;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/org/poly2tri/transform/coordinate/AnyToXYTransform.java:
--------------------------------------------------------------------------------
1 | package org.poly2tri.transform.coordinate;
2 |
3 | /**
4 | * A transform that aligns given source normal with the XY plane normal [0,0,1]
5 | *
6 | * @author thahlen@gmail.com
7 | */
8 |
9 | public class AnyToXYTransform extends Matrix3Transform
10 | {
11 | /**
12 | * Assumes source normal is normalized
13 | */
14 | public AnyToXYTransform( double nx, double ny, double nz )
15 | {
16 | setSourceNormal( nx, ny, nz );
17 | }
18 |
19 | /**
20 | * Assumes source normal is normalized
21 | *
22 | * @param nx
23 | * @param ny
24 | * @param nz
25 | */
26 | public void setSourceNormal( double nx, double ny, double nz )
27 | {
28 | double h,f,c,vx,vy,hvx;
29 |
30 | vx = -ny;
31 | vy = nx;
32 | c = nz;
33 |
34 | h = (1-c)/(1-c*c);
35 | hvx = h*vx;
36 | f = (c < 0) ? -c : c;
37 |
38 | if( f < 1.0 - 1.0E-4 )
39 | {
40 | m00=c + hvx*vx;
41 | m01=hvx*vy;
42 | m02=-vy;
43 | m10=hvx*vy;
44 | m11=c + h*vy*vy;
45 | m12=vx;
46 | m20=vy;
47 | m21=-vx;
48 | m22=c;
49 | }
50 | else
51 | {
52 | // if "from" and "to" vectors are nearly parallel
53 | m00=1;
54 | m01=0;
55 | m02=0;
56 | m10=0;
57 | m11=1;
58 | m12=0;
59 | m20=0;
60 | m21=0;
61 | if( c > 0 )
62 | {
63 | m22=1;
64 | }
65 | else
66 | {
67 | m22=-1;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/model/Texture.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.model;
2 |
3 | import android.graphics.Bitmap;
4 |
5 | import java.util.Map;
6 |
7 | public class Texture {
8 |
9 | private String file;
10 |
11 | private int id = -1;
12 |
13 | private Bitmap bitmap;
14 |
15 | private byte[] data;
16 |
17 | private Map extensions;
18 |
19 | public Texture() {
20 | }
21 |
22 | public int getId() {
23 | return id;
24 | }
25 |
26 | public boolean hasId(){
27 | return id != -1;
28 | }
29 |
30 | public Texture setId(int id) {
31 | this.id = id;
32 | return this;
33 | }
34 |
35 | public String getFile() {
36 | return file;
37 | }
38 |
39 | public Texture setFile(String file) {
40 | this.file = file;
41 | return this;
42 | }
43 |
44 | public Bitmap getBitmap() {
45 | return bitmap;
46 | }
47 |
48 | public Texture setBitmap(Bitmap bitmap) {
49 | this.bitmap = bitmap;
50 | return this;
51 | }
52 |
53 | public byte[] getData() {
54 | return data;
55 | }
56 |
57 | public Texture setData(byte[] data) {
58 | this.data = data;
59 | return this;
60 | }
61 | public Texture setExtensions(Map extensions) {
62 | this.extensions = extensions;
63 | return this;
64 | }
65 |
66 | public Map getExtensions() {
67 | return extensions;
68 | }
69 |
70 | @Override
71 | public String toString() {
72 | return "Texture{" +
73 | "file='" + file + '\'' +
74 | ", glTextureId=" + id +
75 | ", data=" + data +
76 | ", bitmap=" + bitmap +
77 | '}';
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/animation/AnimationManagerListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2016 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model.animation;
28 |
29 | /**
30 | * Interface for classes that want to be informed about changes
31 | * in an {@link AnimationManager}
32 | */
33 | public interface AnimationManagerListener
34 | {
35 | /**
36 | * Will be called when the {@link Animation}s in the given
37 | * {@link AnimationManager} have been updated
38 | *
39 | * @param source The {@link AnimationManager}
40 | */
41 | void animationsUpdated(AnimationManager source);
42 | }
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/SceneModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model;
28 |
29 | import java.util.List;
30 |
31 | /**
32 | * Interface for a scene that was read from a glTF asset
33 | */
34 | public interface SceneModel extends NamedModelElement
35 | {
36 | /**
37 | * Returns an unmodifiable view on the the list of all root
38 | * {@link NodeModel} instances of the scene
39 | *
40 | * @return The {@link NodeModel} instances
41 | */
42 | List getNodeModels();
43 | }
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/src/main/java/org/poly2tri/triangulation/TriangulationAlgorithm.java:
--------------------------------------------------------------------------------
1 | /* Poly2Tri
2 | * Copyright (c) 2009-2010, Poly2Tri Contributors
3 | * http://code.google.com/p/poly2tri/
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without modification,
8 | * are permitted provided that the following conditions are met:
9 | *
10 | * * Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | * * Redistributions in binary form must reproduce the above copyright notice,
13 | * this list of conditions and the following disclaimer in the documentation
14 | * and/or other materials provided with the distribution.
15 | * * Neither the name of Poly2Tri nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific
17 | * prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 | package org.poly2tri.triangulation;
32 |
33 | public enum TriangulationAlgorithm
34 | {
35 | DTSweep
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/animation/AnimationController.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.animation;
2 |
3 | import android.util.Log;
4 |
5 | import org.the3deer.android_3d_model_engine.model.Animation;
6 | import org.the3deer.android_3d_model_engine.renderer.RenderListener;
7 |
8 | import java.util.ArrayList;
9 | import java.util.Iterator;
10 | import java.util.List;
11 |
12 | public class AnimationController implements RenderListener {
13 |
14 | // state
15 | private boolean enabled = true;
16 |
17 | // vars
18 | private final List> animations = new ArrayList<>();
19 | private final List> animations_new = new ArrayList<>();
20 |
21 | public void add(Animation> animation) {
22 | synchronized (animations_new) {
23 | Log.i("AnimationController", "New animation...." + animation);
24 | this.animations_new.add(animation);
25 | }
26 | }
27 |
28 | public boolean isEnabled() {
29 | return enabled;
30 | }
31 |
32 | public void setEnabled(boolean enabled) {
33 | this.enabled = enabled;
34 | }
35 |
36 | @Override
37 | public void onPrepareFrame() {
38 | animate();
39 | }
40 |
41 | private void animate() {
42 |
43 | // copy
44 | if (!animations_new.isEmpty()){
45 | animations.addAll(animations_new);
46 | synchronized (animations_new){
47 | animations_new.clear();
48 | }
49 | }
50 |
51 | // check
52 | if (animations.isEmpty()) return;
53 |
54 | // perform
55 | for (Iterator> iter = animations.iterator(); iter.hasNext(); ) {
56 | Animation> a = iter.next();
57 | a.animate();
58 | if (a.isFinished())
59 | iter.remove();
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/util/xml/XmlParser.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.util.xml;
2 |
3 | import android.util.Xml;
4 |
5 | import org.xmlpull.v1.XmlPullParser;
6 | import org.xmlpull.v1.XmlPullParserException;
7 |
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 |
11 | /**
12 | * Created by andres on 9/12/17.
13 | */
14 | public class XmlParser {
15 |
16 |
17 | public static XmlNode parse(InputStream in) {
18 | try {
19 | XmlPullParser xpp = Xml.newPullParser();
20 | xpp.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
21 | xpp.setInput(in, null);
22 | int eventType = xpp.getEventType();
23 | if (eventType == XmlPullParser.START_DOCUMENT) {
24 | XmlNode parent = new XmlNode("xml");
25 | loadNode(xpp, parent);
26 | return parent.getChild("COLLADA");
27 | }
28 | } catch (XmlPullParserException e) {
29 | throw new RuntimeException(e);
30 | } catch (IOException e) {
31 | throw new RuntimeException(e);
32 | } finally {
33 | try {
34 | in.close();
35 | } catch (IOException e) {
36 | throw new RuntimeException(e);
37 | }
38 | }
39 | return null;
40 | }
41 |
42 | private static void loadNode(XmlPullParser xpp, XmlNode parentNode) throws XmlPullParserException, IOException {
43 | int eventType = xpp.next();
44 | while(eventType != XmlPullParser.END_DOCUMENT) {
45 | if (eventType == XmlPullParser.START_TAG) {
46 | XmlNode childNode = new XmlNode(xpp.getName());
47 | for (int i=0; iGlTFChildOfRootProperty
32 | * of the original glTF asset.
33 | */
34 | public interface NamedModelElement extends ModelElement
35 | {
36 | /**
37 | * Returns the name of this element, or null if this element
38 | * does not have an associated name.
39 | *
40 | * @return The optional name
41 | */
42 | String getName();
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/poly2tri/transform/coordinate/XYToAnyTransform.java:
--------------------------------------------------------------------------------
1 | package org.poly2tri.transform.coordinate;
2 |
3 | /**
4 | * A transform that aligns the XY plane normal [0,0,1] with any given target normal
5 | *
6 | * http://www.cs.brown.edu/~jfh/papers/Moller-EBA-1999/paper.pdf
7 | *
8 | * @author thahlen@gmail.com
9 | *
10 | */
11 | public class XYToAnyTransform extends Matrix3Transform
12 | {
13 | /**
14 | * Assumes target normal is normalized
15 | */
16 | public XYToAnyTransform( double nx, double ny, double nz )
17 | {
18 | setTargetNormal( nx, ny, nz );
19 | }
20 |
21 | /**
22 | * Assumes target normal is normalized
23 | *
24 | * @param nx
25 | * @param ny
26 | * @param nz
27 | */
28 | public void setTargetNormal( double nx, double ny, double nz )
29 | {
30 | double h,f,c,vx,vy,hvx;
31 |
32 | vx = ny;
33 | vy = -nx;
34 | c = nz;
35 |
36 | h = (1-c)/(1-c*c);
37 | hvx = h*vx;
38 | f = (c < 0) ? -c : c;
39 |
40 | if( f < 1.0 - 1.0E-4 )
41 | {
42 | m00=c + hvx*vx;
43 | m01=hvx*vy;
44 | m02=-vy;
45 | m10=hvx*vy;
46 | m11=c + h*vy*vy;
47 | m12=vx;
48 | m20=vy;
49 | m21=-vx;
50 | m22=c;
51 | }
52 | else
53 | {
54 | // if "from" and "to" vectors are nearly parallel
55 | m00=1;
56 | m01=0;
57 | m02=0;
58 | m10=0;
59 | m11=1;
60 | m12=0;
61 | m20=0;
62 | m21=0;
63 | if( c > 0 )
64 | {
65 | m22=1;
66 | }
67 | else
68 | {
69 | m22=-1;
70 | }
71 | }
72 |
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/animation/Animation.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.animation;
2 |
3 |
4 | import android.util.Log;
5 |
6 | /**
7 | *
8 | * Represents an animation that can applied to an {@link org.the3deer.android_3d_model_engine.model.AnimatedModel} . It
9 | * contains the length of the animation in seconds, and a list of
10 | * {@link KeyFrame}s.
11 | *
12 | * @author andresoviedo
13 | *
14 | *
15 | */
16 | public class Animation {
17 |
18 | private final float length;//in seconds
19 | private final KeyFrame[] keyFrames;
20 | private boolean initialized;
21 |
22 | /**
23 | * @param lengthInSeconds
24 | * - the total length of the animation in seconds.
25 | * @param frames
26 | * - all the keyframes for the animation, ordered by time of
27 | * appearance in the animation.
28 | */
29 | public Animation(float lengthInSeconds, KeyFrame[] frames) {
30 | this.keyFrames = frames;
31 | this.length = lengthInSeconds;
32 | }
33 |
34 | public void setInitialized(boolean initialized){
35 | this.initialized = initialized;
36 | }
37 |
38 | public boolean isInitialized(){
39 | return initialized;
40 | }
41 |
42 | /**
43 | * @return The length of the animation in seconds.
44 | */
45 | public float getLength() {
46 | return length;
47 | }
48 |
49 | /**
50 | * @return An array of the animation's keyframes. The array is ordered based
51 | * on the order of the keyframes in the animation (first keyframe of
52 | * the animation in array position 0).
53 | */
54 | public KeyFrame[] getKeyFrames() {
55 | return keyFrames;
56 | }
57 |
58 | public void debugKeyFrames(){
59 | if (keyFrames == null) return;
60 |
61 | for (int i=0; iGlTFProperty of the original glTF asset.
34 | */
35 | public interface ModelElement
36 | {
37 | /**
38 | * Returns the extensions of this element. This is a mapping from
39 | * property names to the JSON objects.
40 | *
41 | * @return The extensions
42 | */
43 | Map getExtensions();
44 |
45 | /**
46 | * Returns the extras of this element.
47 | *
48 | * @return The extras
49 | */
50 | Object getExtras();
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/animation/LinearInterpolator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2016 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model.animation;
28 |
29 | /**
30 | * Implementation of an {@link Interpolator} that interpolates linearly.
31 | * Hence the name.
32 | */
33 | class LinearInterpolator implements Interpolator
34 | {
35 | @Override
36 | public void interpolate(
37 | float[] a, float[] b, float alpha, float[] result)
38 | {
39 | for (int i=0; i jointIds = new ArrayList<>(3);
9 | public final List weights = new ArrayList<>(3);
10 |
11 | public void addJointEffect(int jointId, float weight){
12 | for(int i=0;i weights.get(i)){
14 | jointIds.add(i, jointId);
15 | weights.add(i, weight);
16 | return;
17 | }
18 | }
19 | jointIds.add(jointId);
20 | weights.add(weight);
21 | }
22 |
23 | public void limitJointNumber(int max){
24 | if(jointIds.size() > max){
25 | float[] topWeights = new float[max];
26 | float total = saveTopWeights(topWeights);
27 | refillWeightList(topWeights, total);
28 | removeExcessJointIds(max);
29 | }else if(jointIds.size() < max){
30 | fillEmptyWeights(max);
31 | }
32 | }
33 |
34 | private void fillEmptyWeights(int max){
35 | while(jointIds.size() < max){
36 | jointIds.add(0);
37 | weights.add(0f);
38 | }
39 | }
40 |
41 | private float saveTopWeights(float[] topWeightsArray){
42 | float total = 0;
43 | for(int i=0;i max){
59 | jointIds.remove(jointIds.size()-1);
60 | }
61 | }
62 |
63 | @Override
64 | public String toString() {
65 | return "VertexSkinData{" +
66 | "jointIds=" + jointIds +
67 | ", weights=" + weights +
68 | '}';
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/org/poly2tri/triangulation/util/Tuple2.java:
--------------------------------------------------------------------------------
1 | /* Poly2Tri
2 | * Copyright (c) 2009-2010, Poly2Tri Contributors
3 | * http://code.google.com/p/poly2tri/
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without modification,
8 | * are permitted provided that the following conditions are met:
9 | *
10 | * * Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | * * Redistributions in binary form must reproduce the above copyright notice,
13 | * this list of conditions and the following disclaimer in the documentation
14 | * and/or other materials provided with the distribution.
15 | * * Neither the name of Poly2Tri nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific
17 | * prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 | package org.poly2tri.triangulation.util;
32 |
33 | public class Tuple2
34 | {
35 | public A a;
36 | public B b;
37 |
38 | public Tuple2(A a,B b)
39 | {
40 | this.a = a;
41 | this.b = b;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/util/android/SystemUiHiderBase.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.util.android;
2 |
3 | import android.app.Activity;
4 | import android.view.View;
5 | import android.view.WindowManager;
6 |
7 | /**
8 | * A base implementation of {@link SystemUiHider}. Uses APIs available in all
9 | * API levels to show and hide the status bar.
10 | */
11 | public class SystemUiHiderBase extends SystemUiHider {
12 | /**
13 | * Whether or not the system UI is currently visible. This is a cached value
14 | * from calls to {@link #hide()} and {@link #show()}.
15 | */
16 | private boolean mVisible = true;
17 |
18 | /**
19 | * Constructor not intended to be called by clients. Use
20 | * {@link SystemUiHider#getInstance} to obtain an instance.
21 | */
22 | protected SystemUiHiderBase(Activity activity, View anchorView, int flags) {
23 | super(activity, anchorView, flags);
24 | }
25 |
26 | @Override
27 | public void setup() {
28 | if ((mFlags & FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES) == 0) {
29 | mActivity.getWindow().setFlags(
30 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
31 | | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
32 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
33 | | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
34 | }
35 | }
36 |
37 | @Override
38 | public boolean isVisible() {
39 | return mVisible;
40 | }
41 |
42 | @Override
43 | public void hide() {
44 | if ((mFlags & FLAG_FULLSCREEN) != 0) {
45 | mActivity.getWindow().setFlags(
46 | WindowManager.LayoutParams.FLAG_FULLSCREEN,
47 | WindowManager.LayoutParams.FLAG_FULLSCREEN);
48 | }
49 | mOnVisibilityChangeListener.onVisibilityChange(false);
50 | mVisible = false;
51 | }
52 |
53 | @Override
54 | public void show() {
55 | if ((mFlags & FLAG_FULLSCREEN) != 0) {
56 | mActivity.getWindow().setFlags(0,
57 | WindowManager.LayoutParams.FLAG_FULLSCREEN);
58 | }
59 | mOnVisibilityChangeListener.onVisibilityChange(true);
60 | mVisible = true;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/org/poly2tri/triangulation/util/Tuple3.java:
--------------------------------------------------------------------------------
1 | /* Poly2Tri
2 | * Copyright (c) 2009-2010, Poly2Tri Contributors
3 | * http://code.google.com/p/poly2tri/
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without modification,
8 | * are permitted provided that the following conditions are met:
9 | *
10 | * * Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | * * Redistributions in binary form must reproduce the above copyright notice,
13 | * this list of conditions and the following disclaimer in the documentation
14 | * and/or other materials provided with the distribution.
15 | * * Neither the name of Poly2Tri nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific
17 | * prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 | package org.poly2tri.triangulation.util;
32 |
33 | public class Tuple3
34 | {
35 | public A a;
36 | public B b;
37 | public C c;
38 |
39 | public Tuple3(A a,B b,C c)
40 | {
41 | this.a = a;
42 | this.b = b;
43 | this.c = c;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/view/GLSurfaceView.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.view;
2 |
3 | import android.content.Context;
4 | import android.util.Log;
5 | import android.view.MotionEvent;
6 | import android.widget.Toast;
7 |
8 | import org.the3deer.android_3d_model_engine.shader.ShaderFactory;
9 |
10 | import javax.inject.Inject;
11 |
12 | /**
13 | * This is the actual OpenGL surface.
14 | * It requires a @{@link android.opengl.GLSurfaceView.Renderer} implementation.
15 | * It requires a @{@link GLTouchListener} to listen for OpenGL screen touch events
16 | */
17 | public class GLSurfaceView extends android.opengl.GLSurfaceView {
18 |
19 | private final static String TAG = GLSurfaceView.class.getSimpleName();
20 |
21 | @Inject
22 | private GLTouchListener glTouchListener;
23 |
24 | @Inject
25 | private Renderer renderer;
26 |
27 | @Inject
28 | private ShaderFactory shaderFactory;
29 |
30 | /**
31 | * Construct a new renderer for the specified surface view
32 | */
33 | public GLSurfaceView(Context parent) {
34 | super(parent);
35 | try {
36 |
37 | // Create an OpenGL ES 2.0 context.
38 | Log.d(TAG, "Creating OpenGL 3 surface...");
39 | setEGLContextClientVersion(3);
40 |
41 | } catch (Exception e) {
42 | Log.e(TAG, e.getMessage(), e);
43 | Toast.makeText(parent, e.getMessage(), Toast.LENGTH_LONG).show();
44 | throw new RuntimeException(e);
45 | }
46 | }
47 |
48 | public void setUp() {
49 | if (this.renderer != null) {
50 | Log.i(TAG, "Configuring renderer: " + this.renderer.getClass().getName());
51 | setRenderer(this.renderer);
52 | } else {
53 | throw new IllegalStateException("Renderer is null");
54 | }
55 | }
56 |
57 | @Override
58 | public boolean onTouchEvent(MotionEvent event) {
59 | if (this.glTouchListener != null) {
60 | return glTouchListener.onSurfaceTouchEvent(event);
61 | }
62 | return false;
63 | }
64 | }
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/io/JsonErrorConsumers.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2016 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model.io;
28 |
29 | import java.util.function.Consumer;
30 |
31 | /**
32 | * Methods to create default consumers of {@link JsonError} instances
33 | */
34 | public class JsonErrorConsumers
35 | {
36 | /**
37 | * Create a consumer for {@link JsonError} instances that only prints
38 | * warning log messages for the errors.
39 | *
40 | * @return The consumer
41 | */
42 | public static Consumer createLogging()
43 | {
44 | return JacksonUtils.loggingJsonErrorConsumer();
45 | }
46 |
47 | /**
48 | * Private constructor to prevent instantiation
49 | */
50 | private JsonErrorConsumers()
51 | {
52 | // Private constructor to prevent instantiation
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/MeshModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model;
28 |
29 | import java.util.List;
30 |
31 | /**
32 | * Interface for a mesh that is part of a glTF asset
33 | */
34 | public interface MeshModel extends NamedModelElement
35 | {
36 | /**
37 | * Returns an unmodifiable view on the {@link MeshPrimitiveModel} objects
38 | * that this mesh consists of
39 | *
40 | * @return The {@link MeshPrimitiveModel} objects
41 | */
42 | List getMeshPrimitiveModels();
43 |
44 | /**
45 | * Returns a reference to the default morph target weights,
46 | * or null if no default morph target weights have
47 | * been defined
48 | *
49 | * @return The morph target weights
50 | */
51 | float[] getWeights();
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/AssetModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model;
28 |
29 | /**
30 | * Interface for an asset.
31 | *
32 | * Note that this model does not include the version information that
33 | * will eventually be written as the gltf.asset.version.
34 | * This version information is intentionally hidden in the
35 | * model, and will depend on the version in which the model will
36 | * be written.
37 | */
38 | public interface AssetModel extends NamedModelElement
39 | {
40 | /**
41 | * Returns the copyright message, suitable for display to credit
42 | * the content creator.
43 | *
44 | * @return The copyright message
45 | */
46 | String getCopyright();
47 |
48 | /**
49 | * Returns the tool that generated this glTF model
50 | *
51 | * @return The tool
52 | */
53 | String getGenerator();
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/image/PixelData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model.image;
28 |
29 | import java.nio.ByteBuffer;
30 |
31 | /**
32 | * An interface describing (RGBA) pixel data for an image.
33 | *
34 | * This class should not be considered to be part of the public API.
35 | */
36 | public interface PixelData
37 | {
38 | /**
39 | * Returns the width of the image
40 | *
41 | * @return The width
42 | */
43 | int getWidth();
44 |
45 | /**
46 | * Returns the height of the image
47 | *
48 | * @return The height
49 | */
50 | int getHeight();
51 |
52 | /**
53 | * Returns a new slice of the direct byte buffer containing the pixel
54 | * data, as RGBA values
55 | *
56 | * @return The pixels
57 | */
58 | ByteBuffer getPixelsRGBA();
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/animation/AnimationListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2016 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model.animation;
28 |
29 | /**
30 | * Interface for classes that want to be informed about the progress
31 | * of an {@link Animation}
32 | */
33 | public interface AnimationListener
34 | {
35 | /**
36 | * Will be called when the given {@link Animation} was updated.
37 | *
38 | * Note: The given array of interpolated output values MAY
39 | * be reused for multiple calls. Implementors of this method MUST NOT
40 | * store or modify the given array.
41 | *
42 | * @param source The source {@link Animation}
43 | * @param timeS The time, in seconds
44 | * @param values The interpolated values for the given time
45 | */
46 | void animationUpdated(
47 | Animation source, float timeS, float values[]);
48 | }
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/CameraPerspectiveModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model;
28 |
29 | /**
30 | * Interface for an perspective camera
31 | */
32 | public interface CameraPerspectiveModel
33 | {
34 | /**
35 | * Returns the aspect ratio
36 | *
37 | * @return The aspect ratio
38 | */
39 | Float getAspectRatio();
40 |
41 | /**
42 | * Returns the FOV, in y-direction, in radians
43 | *
44 | * @return The FOV
45 | */
46 | Float getYfov();
47 |
48 | /**
49 | * Returns the distance of the far clipping plane
50 | *
51 | * @return The distance
52 | */
53 | Float getZfar();
54 |
55 | /**
56 | * Returns the distance of the near clipping plane
57 | *
58 | * @return The distance
59 | */
60 | Float getZnear();
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/CameraOrthographicModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model;
28 |
29 | /**
30 | * Interface for an orthographic camera
31 | */
32 | public interface CameraOrthographicModel
33 | {
34 | /**
35 | * Returns the horizontal magnification
36 | *
37 | * @return The magnification
38 | */
39 | Float getXmag();
40 |
41 | /**
42 | * Returns the vertical magnification
43 | *
44 | * @return The magnification
45 | */
46 | Float getYmag();
47 |
48 | /**
49 | * Returns the distance of the far clipping plane
50 | *
51 | * @return The distance
52 | */
53 | Float getZfar();
54 |
55 | /**
56 | * Returns the distance of the near clipping plane
57 | *
58 | * @return The distance
59 | */
60 | Float getZnear();
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/impl/AbstractNamedModelElement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model.impl;
28 |
29 | import de.javagl.jgltf.model.NamedModelElement;
30 |
31 | /**
32 | * Abstract base implementation of the {@link NamedModelElement} interface.
33 | */
34 | public class AbstractNamedModelElement extends AbstractModelElement
35 | implements NamedModelElement
36 | {
37 | /**
38 | * The name
39 | */
40 | private String name;
41 |
42 | @Override
43 | public String getName()
44 | {
45 | return name;
46 | }
47 |
48 | /**
49 | * Set the name of this model element, or null if this
50 | * model element does not have a name.
51 | *
52 | * @param name The optional name
53 | */
54 | public void setName(String name)
55 | {
56 | this.name = name;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/ExtensionsModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model;
28 |
29 | import java.util.List;
30 |
31 | /**
32 | * An interface for the information about the extensions that are used in a
33 | * {@link GltfModel}.
34 | */
35 | public interface ExtensionsModel
36 | {
37 | /**
38 | * Returns the list of extension names that are declared as the
39 | * extensionsUsed in the glTF asset.
40 | *
41 | * The list should be assumed to be unmodifiable.
42 | *
43 | * @return The list of used extensions
44 | */
45 | List getExtensionsUsed();
46 |
47 | /**
48 | * Returns the list of extension names that are declared as the
49 | * extensionsRequired in the glTF asset.
50 | *
51 | * The list should be assumed to be unmodifiable.
52 | *
53 | * @return The list of required extensions
54 | */
55 | List getExtensionsRequired();
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/GltfException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2016 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model;
28 |
29 | /**
30 | * An exception that may be thrown to indicate an error inside a glTF asset.
31 | */
32 | public class GltfException extends RuntimeException
33 | {
34 | /**
35 | * Serial UID
36 | */
37 | private static final long serialVersionUID = -1052127064537015753L;
38 |
39 | /**
40 | * Creates a new exception with the given message
41 | *
42 | * @param message The message
43 | */
44 | public GltfException(String message)
45 | {
46 | super(message);
47 | }
48 |
49 | /**
50 | * Creates a new exception with the given message and cause
51 | *
52 | * @param message The message
53 | * @param cause The cause
54 | */
55 | public GltfException(String message, Throwable cause)
56 | {
57 | super(message, cause);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/animation/KeyFrame.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.animation;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | *
7 | * Represents one keyframe of an animation. This contains the timestamp of the
8 | * keyframe, which is the time (in seconds) from the start of the animation when
9 | * this keyframe occurs.
10 | *
11 | * It also contains the desired bone-space transforms of all of the joints in
12 | * the animated entity at this keyframe in the animation (i.e. it contains all
13 | * the joint transforms for the "pose" at this time of the animation.). The
14 | * joint transforms are stored in a map, indexed by the name of the joint that
15 | * they should be applied to.
16 | *
17 | * @author Karl,the3deer
18 | *
19 | */
20 | public class KeyFrame {
21 |
22 | private final float timeStamp;
23 | private final Map pose;
24 |
25 | /**
26 | * @param timeStamp
27 | * - the time (in seconds) that this keyframe occurs during the
28 | * animation.
29 | * @param jointKeyFrames
30 | * - the local-space transforms for all the joints at this
31 | * keyframe, indexed by the name of the joint that they should be
32 | * applied to.
33 | */
34 | public KeyFrame(float timeStamp, Map jointKeyFrames) {
35 | this.timeStamp = timeStamp;
36 | this.pose = jointKeyFrames;
37 | }
38 |
39 | public Map getPose() {
40 | return pose;
41 | }
42 |
43 | /**
44 | * @return The time in seconds of the keyframe in the animation.
45 | */
46 | protected float getTimeStamp() {
47 | return timeStamp;
48 | }
49 |
50 | /**
51 | * @return The desired bone-space transforms of all the joints at this
52 | * keyframe, of the animation, indexed by the name of the joint that
53 | * they correspond to. This basically represents the "pose" at this
54 | * keyframe.
55 | */
56 | protected Map getTransforms() {
57 | return pose;
58 | }
59 |
60 | @Override
61 | public String toString() {
62 | return "KeyFrame{" +
63 | "timeStamp=" + timeStamp +
64 | ", pose=" + pose +
65 | '}';
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/util/android/DialogFragment.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.util.android;
2 |
3 | import android.app.Dialog;
4 | import android.content.DialogInterface;
5 | import android.os.Bundle;
6 |
7 | import androidx.annotation.NonNull;
8 | import androidx.appcompat.app.AlertDialog;
9 | import androidx.fragment.app.FragmentActivity;
10 |
11 | public class DialogFragment extends androidx.fragment.app.DialogFragment implements DialogInterface.OnClickListener {
12 |
13 | // params
14 | protected int title;
15 | protected String[] items;
16 |
17 | // variables
18 | protected FragmentActivity activity;
19 |
20 | @Override
21 | public void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | this.activity = getActivity();
24 | this.title = getArguments().getInt("title");
25 | this.items = getResources().getStringArray(getArguments().getInt("items"));
26 |
27 | // this fragment will be displayed in a dialog
28 | //setShowsDialog(true);
29 | }
30 |
31 | @Override
32 | public Dialog onCreateDialog(Bundle savedInstanceState) {
33 |
34 | AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
35 | //.setIcon(R.drawable.ic_launcher)
36 | .setTitle(title)
37 | /*.setPositiveButton(R.string.dialog_ok,
38 | (dialog, whichButton) -> onOk()
39 | )
40 | .setNegativeButton(R.string.dialog_cancel,
41 | (dialog, whichButton) -> onCancel()
42 | )*/
43 | .setItems(items, this);
44 |
45 |
46 | return builder
47 | .create();
48 | }
49 |
50 | protected void onOk(){
51 |
52 | }
53 |
54 | protected void onCancel(){
55 |
56 | }
57 |
58 | @Override
59 | public void onClick(DialogInterface dialogI, int position) {
60 | }
61 |
62 | @Override
63 | public void onDismiss(@NonNull DialogInterface dialog) {
64 | super.onDismiss(dialog);
65 | if (getActivity() instanceof DialogInterface.OnDismissListener) {
66 | ((DialogInterface.OnDismissListener) getActivity()).onDismiss(dialog);
67 | }
68 | }
69 |
70 | }
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/gl/ProgramModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model.gl;
28 |
29 | import java.util.List;
30 |
31 | import de.javagl.jgltf.model.NamedModelElement;
32 |
33 | /**
34 | * Interface for a program that consists of a vertex- and fragment
35 | * {@link ShaderModel}
36 | */
37 | public interface ProgramModel extends NamedModelElement
38 | {
39 | /**
40 | * Return the {@link ShaderModel} for the vertex shader
41 | *
42 | * @return The {@link ShaderModel}
43 | */
44 | ShaderModel getVertexShaderModel();
45 |
46 | /**
47 | * Return the {@link ShaderModel} for the fragment shader
48 | *
49 | * @return The {@link ShaderModel}
50 | */
51 | ShaderModel getFragmentShaderModel();
52 |
53 | /**
54 | * Returns an unmodifiable list of the program attribute names
55 | *
56 | * @return The attributes
57 | */
58 | List getAttributes();
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/view/GLFragment.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.view;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import androidx.annotation.Nullable;
9 | import androidx.fragment.app.Fragment;
10 |
11 | import javax.inject.Inject;
12 |
13 | /**
14 | * This is the OpenGL fragment of the engine.
15 | *
16 | * It requires a @{@link android.opengl.GLSurfaceView} implementation
17 | *
18 | */
19 | public class GLFragment extends Fragment
20 | {
21 | @Inject
22 | private GLSurfaceView glSurfaceView;
23 |
24 | public GLFragment() {
25 | }
26 |
27 | @Override
28 | public void onCreate(@Nullable Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 |
31 | }
32 |
33 | @Override
34 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
35 | Bundle savedInstanceState) {
36 | return glSurfaceView;
37 | }
38 |
39 | /*@Override
40 | public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey, Context context, PreferenceScreen screen) {
41 |
42 | SwitchPreference immersiveSwitch = new SwitchPreference(context);
43 | immersiveSwitch.setKey("activity.immersive");
44 | immersiveSwitch.setTitle("Immersive View");
45 | immersiveSwitch.setIconSpaceReserved(screen.isIconSpaceReserved());
46 | immersiveSwitch.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
47 | @Override
48 | public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
49 | // FIXME:
50 | //toggleImmersive();
51 | return true;
52 | }
53 | });
54 | screen.addPreference(immersiveSwitch);
55 | }*/
56 |
57 | @Override
58 | public void onPause() {
59 | super.onPause();
60 | if (glSurfaceView != null) {
61 | glSurfaceView.onPause();
62 | }
63 | }
64 |
65 | @Override
66 | public void onResume() {
67 | super.onResume();
68 | if (glSurfaceView != null) {
69 | glSurfaceView.onResume();
70 | }
71 |
72 | }
73 | }
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/Utils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model;
28 |
29 | /**
30 | * Utility methods. These should not be considered as part of the public API.
31 | */
32 | public class Utils
33 | {
34 | /**
35 | * Validate that the given array is not null and has the
36 | * given length. If this is not the case, return a new array with the
37 | * specified length.
38 | *
39 | * @param array The array
40 | * @param length The length
41 | * @return The array, or a new array with the desired length
42 | */
43 | public static float[] validate(float array[], int length)
44 | {
45 | if (array != null && array.length == length)
46 | {
47 | return array;
48 | }
49 | return new float[length];
50 | }
51 |
52 | /**
53 | * Private constructor to prevent instantiation
54 | */
55 | private Utils()
56 | {
57 | // Private constructor to prevent instantiation
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/BufferModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model;
28 |
29 | import java.nio.ByteBuffer;
30 |
31 | /**
32 | * Interface for a buffer of a glTF asset
33 | */
34 | public interface BufferModel extends NamedModelElement
35 | {
36 | /**
37 | * Returns the URI of the buffer data
38 | *
39 | * @return The URI
40 | */
41 | String getUri();
42 |
43 | /**
44 | * Returns the length, in bytes, of the {@link #getBufferData() buffer data}
45 | *
46 | * @return The buffer length, in bytes
47 | */
48 | int getByteLength();
49 |
50 | /**
51 | * Returns the actual buffer data. This will return a slice of the buffer
52 | * that is stored internally. Thus, changes to the contents of this buffer
53 | * will affect this model, but modifications of the position and limit of
54 | * the returned buffer will not affect this model.
55 | *
56 | * @return The buffer data
57 | */
58 | ByteBuffer getBufferData();
59 |
60 | }
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/services/collada/entities/Vertex.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.services.collada.entities;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | public class Vertex implements Cloneable {
6 |
7 | private static final int NO_INDEX = -1;
8 |
9 | private final int vertexIndex;
10 | private int textureIndex = NO_INDEX;
11 | private int normalIndex = NO_INDEX;
12 | private int colorIndex = NO_INDEX;
13 |
14 | private VertexSkinData weightsData;
15 |
16 | public Vertex(int vertexIndex) {
17 | this.vertexIndex = vertexIndex;
18 | }
19 |
20 | public int getVertexIndex() {
21 | return vertexIndex;
22 | }
23 |
24 | public VertexSkinData getWeightsData() {
25 | return weightsData;
26 | }
27 |
28 | public void setTextureIndex(int textureIndex) {
29 | this.textureIndex = textureIndex;
30 | }
31 |
32 | public void setNormalIndex(int normalIndex) {
33 | this.normalIndex = normalIndex;
34 | }
35 |
36 | public int getTextureIndex() {
37 | return textureIndex;
38 | }
39 |
40 | public int getNormalIndex() {
41 | return normalIndex;
42 | }
43 |
44 | public void setWeightsData(VertexSkinData weightsData) {
45 | this.weightsData = weightsData;
46 | }
47 |
48 | public void setColorIndex(int colorIndex) {
49 | this.colorIndex = colorIndex;
50 | }
51 |
52 | public int getColorIndex() {
53 | return colorIndex;
54 | }
55 |
56 | @Override
57 | public boolean equals(Object o) {
58 | if (this == o) return true;
59 | if (o == null || getClass() != o.getClass()) return false;
60 |
61 | Vertex vertex = (Vertex) o;
62 |
63 | if (vertexIndex != vertex.vertexIndex) return false;
64 | if (textureIndex != vertex.textureIndex) return false;
65 | return normalIndex == vertex.normalIndex;
66 | }
67 |
68 | @Override
69 | public int hashCode() {
70 | int result = vertexIndex;
71 | result = 31 * result + textureIndex;
72 | result = 31 * result + normalIndex;
73 | return result;
74 | }
75 |
76 | @NonNull
77 | @Override
78 | protected Vertex clone() throws CloneNotSupportedException {
79 | return (Vertex) super.clone();
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/org/poly2tri/geometry/polygon/PolygonSet.java:
--------------------------------------------------------------------------------
1 | /* Poly2Tri
2 | * Copyright (c) 2009-2010, Poly2Tri Contributors
3 | * http://code.google.com/p/poly2tri/
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without modification,
8 | * are permitted provided that the following conditions are met:
9 | *
10 | * * Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | * * Redistributions in binary form must reproduce the above copyright notice,
13 | * this list of conditions and the following disclaimer in the documentation
14 | * and/or other materials provided with the distribution.
15 | * * Neither the name of Poly2Tri nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific
17 | * prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 | package org.poly2tri.geometry.polygon;
32 |
33 | import java.util.ArrayList;
34 | import java.util.List;
35 |
36 | public class PolygonSet
37 | {
38 | protected ArrayList _polygons = new ArrayList();
39 |
40 | public PolygonSet()
41 | {
42 | }
43 |
44 | public PolygonSet( Polygon poly )
45 | {
46 | _polygons.add( poly );
47 | }
48 |
49 | public void add( Polygon p )
50 | {
51 | _polygons.add( p );
52 | }
53 |
54 | public List getPolygons()
55 | {
56 | return _polygons;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/TextureModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model;
28 |
29 | /**
30 | * Interface for a texture in a glTF asset
31 | */
32 | public interface TextureModel extends NamedModelElement
33 | {
34 | /**
35 | * Return the magnification filter constant
36 | *
37 | * @return The constant
38 | */
39 | Integer getMagFilter();
40 |
41 | /**
42 | * Return the minification filter constant
43 | *
44 | * @return The constant
45 | */
46 | Integer getMinFilter();
47 |
48 | /**
49 | * Return the wrapping constant for S-direction
50 | *
51 | * @return The constant
52 | */
53 | Integer getWrapS();
54 |
55 | /**
56 | * Return the wrapping constant for T-direction
57 | *
58 | * @return The constant
59 | */
60 | Integer getWrapT();
61 |
62 | /**
63 | * Returns the {@link ImageModel} that backs this texture
64 | *
65 | * @return The {@link ImageModel}
66 | */
67 | ImageModel getImageModel();
68 | }
--------------------------------------------------------------------------------
/src/main/java/org/poly2tri/triangulation/TriangulationConstraint.java:
--------------------------------------------------------------------------------
1 | /* Poly2Tri
2 | * Copyright (c) 2009-2010, Poly2Tri Contributors
3 | * http://code.google.com/p/poly2tri/
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without modification,
8 | * are permitted provided that the following conditions are met:
9 | *
10 | * * Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | * * Redistributions in binary form must reproduce the above copyright notice,
13 | * this list of conditions and the following disclaimer in the documentation
14 | * and/or other materials provided with the distribution.
15 | * * Neither the name of Poly2Tri nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific
17 | * prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 | package org.poly2tri.triangulation;
32 |
33 | /**
34 | * Forces a triangle edge between two points p and q
35 | * when triangulating. For example used to enforce
36 | * Polygon Edges during a polygon triangulation.
37 | *
38 | * @author Thomas ?hl?n, thahlen@gmail.com
39 | */
40 | public class TriangulationConstraint
41 | {
42 | protected TriangulationPoint p;
43 | protected TriangulationPoint q;
44 |
45 | public TriangulationPoint getP()
46 | {
47 | return p;
48 | }
49 |
50 | public TriangulationPoint getQ()
51 | {
52 | return q;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/animation/Interpolator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2016 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model.animation;
28 |
29 | /**
30 | * Package-private interface for classes that can interpolate between
31 | * (equal-length) arrays of float values
32 | */
33 | interface Interpolator
34 | {
35 | /**
36 | * Interpolate between a and b, based on
37 | * the given alpha value (that is usually in [0,1]), and place the
38 | * results in the given result array. None of the given arrays may
39 | * be null, and they must all have the same length.
40 | *
41 | * @param a The first array
42 | * @param b The second array
43 | * @param alpha The interpolation value
44 | * @param result The array that will store the result
45 | * @throws NullPointerException If any argument is null
46 | * @throws IndexOutOfBoundsException May be thrown if the arrays do not
47 | * have the same length
48 | */
49 | void interpolate(float a[], float b[], float alpha, float result[]);
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/impl/v2/MaterialOcclusionTextureInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * glTF JSON model
3 | *
4 | * Do not modify this class. It is automatically generated
5 | * with JsonModelGen (https://github.com/javagl/JsonModelGen)
6 | * Copyright (c) 2016-2021 Marco Hutter - http://www.javagl.de
7 | */
8 |
9 | package de.javagl.jgltf.impl.v2;
10 |
11 |
12 |
13 | /**
14 | * Auto-generated for material.occlusionTextureInfo.schema.json
15 | *
16 | */
17 | public class MaterialOcclusionTextureInfo
18 | extends TextureInfo
19 | {
20 |
21 | /**
22 | * A scalar multiplier controlling the amount of occlusion applied.
23 | * (optional)
24 | * Default: 1.0
25 | * Minimum: 0.0 (inclusive)
26 | * Maximum: 1.0 (inclusive)
27 | *
28 | */
29 | private Float strength;
30 |
31 | /**
32 | * A scalar multiplier controlling the amount of occlusion applied.
33 | * (optional)
34 | * Default: 1.0
35 | * Minimum: 0.0 (inclusive)
36 | * Maximum: 1.0 (inclusive)
37 | *
38 | * @param strength The strength to set
39 | * @throws IllegalArgumentException If the given value does not meet
40 | * the given constraints
41 | *
42 | */
43 | public void setStrength(Float strength) {
44 | if (strength == null) {
45 | this.strength = strength;
46 | return ;
47 | }
48 | if (strength > 1.0D) {
49 | throw new IllegalArgumentException("strength > 1.0");
50 | }
51 | if (strength< 0.0D) {
52 | throw new IllegalArgumentException("strength < 0.0");
53 | }
54 | this.strength = strength;
55 | }
56 |
57 | /**
58 | * A scalar multiplier controlling the amount of occlusion applied.
59 | * (optional)
60 | * Default: 1.0
61 | * Minimum: 0.0 (inclusive)
62 | * Maximum: 1.0 (inclusive)
63 | *
64 | * @return The strength
65 | *
66 | */
67 | public Float getStrength() {
68 | return this.strength;
69 | }
70 |
71 | /**
72 | * Returns the default value of the strength
73 | * @see #getStrength
74 | *
75 | * @return The default strength
76 | *
77 | */
78 | public Float defaultStrength() {
79 | return 1.0F;
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/impl/DefaultAssetModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model.impl;
28 |
29 | import de.javagl.jgltf.model.AssetModel;
30 |
31 | /**
32 | * Default implementation of an {@link AssetModel}
33 | */
34 | public class DefaultAssetModel extends AbstractNamedModelElement
35 | implements AssetModel
36 | {
37 | /**
38 | * The copyright
39 | */
40 | private String copyright;
41 |
42 | /**
43 | * The generator
44 | */
45 | private String generator;
46 |
47 | /**
48 | * Set the copyright
49 | *
50 | * @param copyright The copyright
51 | */
52 | public void setCopyright(String copyright)
53 | {
54 | this.copyright = copyright;
55 | }
56 |
57 | @Override
58 | public String getCopyright()
59 | {
60 | return copyright;
61 | }
62 |
63 | /**
64 | * Set the generator
65 | *
66 | * @param generator The generator
67 | */
68 | public void setGenerator(String generator)
69 | {
70 | this.generator = generator;
71 | }
72 |
73 | @Override
74 | public String getGenerator()
75 | {
76 | return generator;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/impl/DefaultSceneModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model.impl;
28 |
29 | import java.util.ArrayList;
30 | import java.util.Collections;
31 | import java.util.List;
32 |
33 | import de.javagl.jgltf.model.NodeModel;
34 | import de.javagl.jgltf.model.SceneModel;
35 |
36 | /**
37 | * Implementation of a {@link SceneModel}
38 | */
39 | public class DefaultSceneModel extends AbstractNamedModelElement
40 | implements SceneModel
41 | {
42 | /**
43 | * The list of root nodes
44 | */
45 | private final List nodeModels;
46 |
47 | /**
48 | * Creates a new instance
49 | */
50 | public DefaultSceneModel()
51 | {
52 | this.nodeModels = new ArrayList();
53 | }
54 |
55 | /**
56 | * Add the given (root) {@link NodeModel} to this scene
57 | *
58 | * @param node The {@link NodeModel}
59 | */
60 | public void addNode(NodeModel node)
61 | {
62 | nodeModels.add(node);
63 | }
64 |
65 | @Override
66 | public List getNodeModels()
67 | {
68 | return Collections.unmodifiableList(nodeModels);
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/util/android/AssetUtils.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.util.android;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.Context;
5 | import android.content.DialogInterface;
6 | import android.widget.Toast;
7 |
8 | import java.io.File;
9 | import java.io.IOException;
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | /**
14 | * Created by coco on 6/7/15.
15 | */
16 | public class AssetUtils {
17 |
18 | @FunctionalInterface
19 | public interface Callback {
20 | void onClick(String asset);
21 | }
22 |
23 | public static void createChooserDialog(Context context, String title, CharSequence message, String folder,
24 | String fileRegex, Callback callback) {
25 | final AlertDialog.Builder builder = new AlertDialog.Builder(context);
26 | builder.setTitle(title);
27 | builder.setMessage(message);
28 | builder.setNegativeButton("Cancel", (DialogInterface dialog, int which) -> {
29 | callback.onClick(null);
30 | });
31 | try {
32 | final String[] fileList = listFiles(context, folder, fileRegex);
33 | builder.setItems(fileList, (DialogInterface dialog, int which) -> {
34 | String selectedFile = fileList[which];
35 | callback.onClick(folder+"/"+selectedFile);
36 | });
37 | } catch (IOException ex) {
38 | Toast.makeText(context,"Error listing assets from "+folder, Toast.LENGTH_LONG).show();
39 | }
40 | builder.create().show();
41 | }
42 |
43 | private static String[] listFiles(Context context, String folder, String fileRegex) throws IOException {
44 | List ret = new ArrayList<>();
45 | String[] list = context.getAssets().list(folder);
46 | for (String asset : list){
47 | if (asset.matches(fileRegex)) {
48 | ret.add(asset);
49 | }
50 | }
51 | return ret.toArray(new String[0]);
52 | }
53 |
54 | private static String[] getFilenames(File upLevelFile, List files) {
55 | String[] filenames = new String[files.size()];
56 | for (int i = 0; i < files.size(); i++) {
57 | if (files.get(i) == null || upLevelFile == files.get(i)) {
58 | filenames[i] = "..";
59 | } else {
60 | filenames[i] = files.get(i).getName();
61 | }
62 | }
63 | return filenames;
64 | }
65 |
66 | }
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/impl/v2/Buffer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * glTF JSON model
3 | *
4 | * Do not modify this class. It is automatically generated
5 | * with JsonModelGen (https://github.com/javagl/JsonModelGen)
6 | * Copyright (c) 2016-2021 Marco Hutter - http://www.javagl.de
7 | */
8 |
9 | package de.javagl.jgltf.impl.v2;
10 |
11 |
12 |
13 | /**
14 | * A buffer points to binary geometry, animation, or skins.
15 | *
16 | * Auto-generated for buffer.schema.json
17 | *
18 | */
19 | public class Buffer
20 | extends GlTFChildOfRootProperty
21 | {
22 |
23 | /**
24 | * The URI (or IRI) of the buffer. (optional)
25 | *
26 | */
27 | private String uri;
28 | /**
29 | * The length of the buffer in bytes. (required)
30 | * Minimum: 1 (inclusive)
31 | *
32 | */
33 | private Integer byteLength;
34 |
35 | /**
36 | * The URI (or IRI) of the buffer. (optional)
37 | *
38 | * @param uri The uri to set
39 | *
40 | */
41 | public void setUri(String uri) {
42 | if (uri == null) {
43 | this.uri = uri;
44 | return ;
45 | }
46 | this.uri = uri;
47 | }
48 |
49 | /**
50 | * The URI (or IRI) of the buffer. (optional)
51 | *
52 | * @return The uri
53 | *
54 | */
55 | public String getUri() {
56 | return this.uri;
57 | }
58 |
59 | /**
60 | * The length of the buffer in bytes. (required)
61 | * Minimum: 1 (inclusive)
62 | *
63 | * @param byteLength The byteLength to set
64 | * @throws NullPointerException If the given value is null
65 | * @throws IllegalArgumentException If the given value does not meet
66 | * the given constraints
67 | *
68 | */
69 | public void setByteLength(Integer byteLength) {
70 | if (byteLength == null) {
71 | throw new NullPointerException((("Invalid value for byteLength: "+ byteLength)+", may not be null"));
72 | }
73 | if (byteLength< 1) {
74 | throw new IllegalArgumentException("byteLength < 1");
75 | }
76 | this.byteLength = byteLength;
77 | }
78 |
79 | /**
80 | * The length of the buffer in bytes. (required)
81 | * Minimum: 1 (inclusive)
82 | *
83 | * @return The byteLength
84 | *
85 | */
86 | public Integer getByteLength() {
87 | return this.byteLength;
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/impl/v1/Shader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * glTF JSON model
3 | *
4 | * Do not modify this class. It is automatically generated
5 | * with JsonModelGen (https://github.com/javagl/JsonModelGen)
6 | * Copyright (c) 2016 Marco Hutter - http://www.javagl.de
7 | */
8 |
9 | package de.javagl.jgltf.impl.v1;
10 |
11 |
12 |
13 | /**
14 | * A vertex or fragment shader.
15 | *
16 | * Auto-generated for shader.schema.json
17 | *
18 | */
19 | public class Shader
20 | extends GlTFChildOfRootProperty
21 | {
22 |
23 | /**
24 | * The uri of the GLSL source. (required)
25 | *
26 | */
27 | private String uri;
28 | /**
29 | * The shader stage. (required)
30 | * Valid values: [35632, 35633]
31 | *
32 | */
33 | private Integer type;
34 |
35 | /**
36 | * The uri of the GLSL source. (required)
37 | *
38 | * @param uri The uri to set
39 | * @throws NullPointerException If the given value is null
40 | *
41 | */
42 | public void setUri(String uri) {
43 | if (uri == null) {
44 | throw new NullPointerException((("Invalid value for uri: "+ uri)+", may not be null"));
45 | }
46 | this.uri = uri;
47 | }
48 |
49 | /**
50 | * The uri of the GLSL source. (required)
51 | *
52 | * @return The uri
53 | *
54 | */
55 | public String getUri() {
56 | return this.uri;
57 | }
58 |
59 | /**
60 | * The shader stage. (required)
61 | * Valid values: [35632, 35633]
62 | *
63 | * @param type The type to set
64 | * @throws NullPointerException If the given value is null
65 | * @throws IllegalArgumentException If the given value does not meet
66 | * the given constraints
67 | *
68 | */
69 | public void setType(Integer type) {
70 | if (type == null) {
71 | throw new NullPointerException((("Invalid value for type: "+ type)+", may not be null"));
72 | }
73 | if ((type!= 35632)&&(type!= 35633)) {
74 | throw new IllegalArgumentException((("Invalid value for type: "+ type)+", valid: [35632, 35633]"));
75 | }
76 | this.type = type;
77 | }
78 |
79 | /**
80 | * The shader stage. (required)
81 | * Valid values: [35632, 35633]
82 | *
83 | * @return The type
84 | *
85 | */
86 | public Integer getType() {
87 | return this.type;
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/impl/v1/AnimationChannel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * glTF JSON model
3 | *
4 | * Do not modify this class. It is automatically generated
5 | * with JsonModelGen (https://github.com/javagl/JsonModelGen)
6 | * Copyright (c) 2016 Marco Hutter - http://www.javagl.de
7 | */
8 |
9 | package de.javagl.jgltf.impl.v1;
10 |
11 |
12 |
13 | /**
14 | * Targets an animation's sampler at a node's property.
15 | *
16 | * Auto-generated for animation.channel.schema.json
17 | *
18 | */
19 | public class AnimationChannel
20 | extends GlTFProperty
21 | {
22 |
23 | /**
24 | * The ID of a sampler in this animation used to compute the value for
25 | * the target. (required)
26 | *
27 | */
28 | private String sampler;
29 | /**
30 | * The ID of the node and TRS property to target. (required)
31 | *
32 | */
33 | private AnimationChannelTarget target;
34 |
35 | /**
36 | * The ID of a sampler in this animation used to compute the value for
37 | * the target. (required)
38 | *
39 | * @param sampler The sampler to set
40 | * @throws NullPointerException If the given value is null
41 | *
42 | */
43 | public void setSampler(String sampler) {
44 | if (sampler == null) {
45 | throw new NullPointerException((("Invalid value for sampler: "+ sampler)+", may not be null"));
46 | }
47 | this.sampler = sampler;
48 | }
49 |
50 | /**
51 | * The ID of a sampler in this animation used to compute the value for
52 | * the target. (required)
53 | *
54 | * @return The sampler
55 | *
56 | */
57 | public String getSampler() {
58 | return this.sampler;
59 | }
60 |
61 | /**
62 | * The ID of the node and TRS property to target. (required)
63 | *
64 | * @param target The target to set
65 | * @throws NullPointerException If the given value is null
66 | *
67 | */
68 | public void setTarget(AnimationChannelTarget target) {
69 | if (target == null) {
70 | throw new NullPointerException((("Invalid value for target: "+ target)+", may not be null"));
71 | }
72 | this.target = target;
73 | }
74 |
75 | /**
76 | * The ID of the node and TRS property to target. (required)
77 | *
78 | * @return The target
79 | *
80 | */
81 | public AnimationChannelTarget getTarget() {
82 | return this.target;
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/ImageModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2017 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model;
28 |
29 | import java.nio.ByteBuffer;
30 |
31 | /**
32 | * Interface for an image in a glTF asset
33 | */
34 | public interface ImageModel extends NamedModelElement
35 | {
36 | /**
37 | * Returns the URI of the image data (optional)
38 | *
39 | * @return The URI
40 | */
41 | String getUri();
42 |
43 | /**
44 | * Returns the MIME type of the image data that is contained in
45 | * the buffer view
46 | *
47 | * @return The MIME type
48 | */
49 | String getMimeType();
50 |
51 | /**
52 | * Returns the (optional) {@link BufferViewModel} that contains
53 | * the image data
54 | *
55 | * @return The {@link BufferViewModel}
56 | */
57 | BufferViewModel getBufferViewModel();
58 |
59 | /**
60 | * Returns the actual image data. This will return a slice of the
61 | * buffer that is stored internally. Thus, changes to the contents
62 | * of this buffer will affect this model, but modifications of the
63 | * position and limit of the returned buffer will not affect this
64 | * model.
65 | *
66 | * @return The image data
67 | */
68 | ByteBuffer getImageData();
69 | }
--------------------------------------------------------------------------------
/src/main/res/raw/shader_animated_vert.glsl:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | const int MAX_JOINTS = 60;
4 | //const int MAX_WEIGHTS = 3;
5 |
6 | // MVP matrices
7 | uniform mat4 u_MMatrix;
8 | uniform mat4 u_VMatrix;
9 | uniform mat4 u_PMatrix;
10 |
11 | // mesh
12 | attribute vec3 a_Position;
13 | varying vec3 v_Position;
14 |
15 | // colors
16 | uniform bool u_Coloured;
17 | attribute vec4 a_Color;
18 | varying vec4 v_Color;
19 |
20 | // texture
21 | uniform bool u_Textured;
22 | attribute vec2 a_TexCoordinate;
23 | varying vec2 v_TexCoordinate;
24 |
25 | // light
26 | uniform bool u_Lighted;
27 | attribute vec3 a_Normal;
28 | varying vec3 v_Normal;
29 |
30 | // normalMap
31 | uniform bool u_NormalTextured;
32 | //uniform sampler2D u_NormalTexture;
33 | attribute vec3 a_Tangent;
34 | varying vec3 v_Tangent;
35 |
36 | // emissiveMap
37 | //uniform bool u_EmissiveTextured;
38 | //uniform sampler2D u_EmissiveTexture;
39 |
40 | // animation
41 | uniform bool u_Animated;
42 | attribute vec4 in_jointIndices;
43 | attribute vec4 in_weights;
44 | uniform mat4 u_BindShapeMatrix;
45 | uniform mat4 jointTransforms[MAX_JOINTS];
46 |
47 | void main(){
48 |
49 | vec4 animatedPos = vec4(a_Position,1.0);
50 | if (u_Animated) {
51 | vec4 bindPos = u_BindShapeMatrix * vec4(a_Position, 1.0);
52 | vec4 posePosition = jointTransforms[int(in_jointIndices[0])] * bindPos;
53 | animatedPos = posePosition * in_weights[0];
54 | posePosition = jointTransforms[int(in_jointIndices[1])] * bindPos;
55 | animatedPos += posePosition * in_weights[1];
56 | posePosition = jointTransforms[int(in_jointIndices[2])] * bindPos;
57 | animatedPos += posePosition * in_weights[2];
58 | posePosition = jointTransforms[int(in_jointIndices[3])] * bindPos;
59 | animatedPos += posePosition * in_weights[3];
60 | }
61 |
62 | // calculate MVP matrix
63 | mat4 u_MVMatrix = u_VMatrix * u_MMatrix;
64 | mat4 u_MVPMatrix = u_PMatrix * u_MVMatrix;
65 |
66 | // calculate rendered position
67 | gl_Position = u_MVPMatrix * animatedPos;
68 | v_Position = vec3(animatedPos);
69 |
70 | // colour
71 | if (u_Coloured){
72 | v_Color = a_Color;
73 | }
74 |
75 | // texture
76 | if (u_Textured) {
77 | v_TexCoordinate = a_TexCoordinate;
78 | }
79 |
80 | // normal
81 | if (u_Lighted){
82 | // Normal = mat3(transpose(inverse(model))) * aNormal;
83 | //v_Normal = u_MMatrix_Normal * a_Normal;
84 | v_Normal = a_Normal;
85 | }
86 |
87 | // texture normal
88 | if (u_NormalTextured) {
89 | v_Tangent = a_Tangent;
90 | }
91 | }
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/impl/v2/AnimationChannel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * glTF JSON model
3 | *
4 | * Do not modify this class. It is automatically generated
5 | * with JsonModelGen (https://github.com/javagl/JsonModelGen)
6 | * Copyright (c) 2016-2021 Marco Hutter - http://www.javagl.de
7 | */
8 |
9 | package de.javagl.jgltf.impl.v2;
10 |
11 |
12 |
13 | /**
14 | * An animation channel combines an animation sampler with a target
15 | * property being animated.
16 | *
17 | * Auto-generated for animation.channel.schema.json
18 | *
19 | */
20 | public class AnimationChannel
21 | extends GlTFProperty
22 | {
23 |
24 | /**
25 | * The index of a sampler in this animation used to compute the value for
26 | * the target. (required)
27 | *
28 | */
29 | private Integer sampler;
30 | /**
31 | * The descriptor of the animated property. (required)
32 | *
33 | */
34 | private AnimationChannelTarget target;
35 |
36 | /**
37 | * The index of a sampler in this animation used to compute the value for
38 | * the target. (required)
39 | *
40 | * @param sampler The sampler to set
41 | * @throws NullPointerException If the given value is null
42 | *
43 | */
44 | public void setSampler(Integer sampler) {
45 | if (sampler == null) {
46 | throw new NullPointerException((("Invalid value for sampler: "+ sampler)+", may not be null"));
47 | }
48 | this.sampler = sampler;
49 | }
50 |
51 | /**
52 | * The index of a sampler in this animation used to compute the value for
53 | * the target. (required)
54 | *
55 | * @return The sampler
56 | *
57 | */
58 | public Integer getSampler() {
59 | return this.sampler;
60 | }
61 |
62 | /**
63 | * The descriptor of the animated property. (required)
64 | *
65 | * @param target The target to set
66 | * @throws NullPointerException If the given value is null
67 | *
68 | */
69 | public void setTarget(AnimationChannelTarget target) {
70 | if (target == null) {
71 | throw new NullPointerException((("Invalid value for target: "+ target)+", may not be null"));
72 | }
73 | this.target = target;
74 | }
75 |
76 | /**
77 | * The descriptor of the animated property. (required)
78 | *
79 | * @return The target
80 | *
81 | */
82 | public AnimationChannelTarget getTarget() {
83 | return this.target;
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/v1/gl/Materials.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2016 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model.v1.gl;
28 |
29 | import java.util.Arrays;
30 |
31 | import de.javagl.jgltf.impl.v1.Material;
32 | import de.javagl.jgltf.impl.v1.Technique;
33 |
34 | /**
35 | * Utility methods for {@link Material}s
36 | */
37 | class Materials
38 | {
39 | /**
40 | * Create a default {@link Material} with the given {@link Technique} ID,
41 | * that is assumed to refer to a {@link Techniques#createDefaultTechnique(
42 | * String) default technique}.
43 | *
44 | * The returned {@link Material} is the default {@link Material}, as
45 | * described in "Appendix A" of the glTF 1.0 specification.
46 | *
47 | * @param techniqueId The {@link Technique} ID
48 | * @return The default {@link Material}
49 | */
50 | static Material createDefaultMaterial(String techniqueId)
51 | {
52 | Material material = new Material();
53 | material.addValues("emission", Arrays.asList(0.5, 0.5, 0.5, 1.0));
54 | material.setTechnique(techniqueId);
55 | return material;
56 | }
57 |
58 | /**
59 | * Private constructor to prevent instantiation
60 | */
61 | private Materials()
62 | {
63 | // Private constructor to prevent instantiation
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/org/the3deer/android_3d_model_engine/services/collada/entities/SkeletonData.java:
--------------------------------------------------------------------------------
1 | package org.the3deer.android_3d_model_engine.services.collada.entities;
2 |
3 | import java.util.List;
4 |
5 | public class SkeletonData {
6 |
7 | private JointData headJoint;
8 | private int jointCount;
9 | private int boneCount = 0;
10 |
11 | private List joints;
12 | private List bones;
13 | private float[] bindShapeMatrix;
14 |
15 |
16 | public SkeletonData(List joints, List bones, JointData headJoint) {
17 | this.joints = joints;
18 | this.bones = bones;
19 | this.headJoint = headJoint;
20 | }
21 |
22 | public List getJoints() {
23 | return joints;
24 | }
25 |
26 | public List getBones() {
27 | return bones;
28 | }
29 |
30 | public SkeletonData(int jointCount, JointData headJoint) {
31 | this.jointCount = jointCount;
32 | this.headJoint = headJoint;
33 | }
34 |
35 | public SkeletonData(int jointCount, int boneCount, JointData headJoint) {
36 | this.jointCount = jointCount;
37 | this.boneCount = boneCount;
38 | this.headJoint = headJoint;
39 | }
40 |
41 | public void incrementBoneCount() {
42 | this.boneCount++;
43 | }
44 |
45 | public void setBoneCount(int boneCount) {
46 | this.boneCount = boneCount;
47 | }
48 |
49 | public int getBoneCount() {
50 | if (bones != null){
51 | return bones.size();
52 | } else {
53 | return boneCount;
54 | }
55 | }
56 |
57 | public JointData getHeadJoint() {
58 | return headJoint;
59 | }
60 |
61 | public int getJointCount() {
62 | if (joints != null){
63 | return joints.size();
64 | } else {
65 | return jointCount;
66 | }
67 | }
68 |
69 | public float[] getBindShapeMatrix() {
70 | return bindShapeMatrix;
71 | }
72 |
73 | public SkeletonData setBindShapeMatrix(float[] bindShapeMatrix) {
74 | this.bindShapeMatrix = bindShapeMatrix;
75 | return this;
76 | }
77 |
78 | public JointData find(String geometryId) {
79 | if (joints != null){
80 | for (int i=0; i
31 | *
32 | * This class is only supposed to be used internally, and not part of
33 | * the public API!
34 | */
35 | public class BufferBuilderStrategies
36 | {
37 | /**
38 | * Create an unspecified default {@link BufferBuilderStrategy}
39 | *
40 | * @return The {@link BufferBuilderStrategy}
41 | */
42 | public static BufferBuilderStrategy createDefault()
43 | {
44 | DefaultBufferBuilderStrategy.Config config =
45 | new DefaultBufferBuilderStrategy.Config();
46 | return new DefaultBufferBuilderStrategy(config);
47 | }
48 |
49 | /**
50 | * Create a default {@link BufferBuilderStrategy} with the given
51 | * configuration.
52 | *
53 | * @param config The configuration
54 | * @return The {@link BufferBuilderStrategy}
55 | */
56 | static BufferBuilderStrategy create(
57 | DefaultBufferBuilderStrategy.Config config)
58 | {
59 | return new DefaultBufferBuilderStrategy(config);
60 | }
61 |
62 | /**
63 | * Private constructor to prevent instantiation
64 | */
65 | private BufferBuilderStrategies()
66 | {
67 | // Private constructor to prevent instantiation
68 | }
69 |
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/de/javagl/jgltf/model/GltfUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * www.javagl.de - JglTF
3 | *
4 | * Copyright 2015-2016 Marco Hutter - http://www.javagl.de
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 | * OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package de.javagl.jgltf.model;
28 |
29 | import java.util.Objects;
30 |
31 | import de.javagl.jgltf.impl.v1.Asset;
32 | import de.javagl.jgltf.impl.v1.GlTF;
33 |
34 | /**
35 | * Utility methods related to {@link GlTF} instances
36 | */
37 | public class GltfUtils
38 | {
39 | /**
40 | * Returns the version string that is reported by the {@link Asset} in
41 | * the given {@link GlTF}. If it does not have an {@link Asset}, or
42 | * the version string in the asset is null, then
43 | * this method will return the string "1.0.0".
44 | *
45 | * @param gltf The {@link GlTF}
46 | * @return The version string
47 | */
48 | public static String getVersion(GlTF gltf)
49 | {
50 | Objects.requireNonNull(gltf, "The gltf is null");
51 | Asset asset = gltf.getAsset();
52 | if (asset == null)
53 | {
54 | return "1.0";
55 | }
56 | String version = asset.getVersion();
57 | if (version == null)
58 | {
59 | return "1.0";
60 | }
61 | return version;
62 | }
63 |
64 | /**
65 | * Private constructor to prevent instantiation
66 | */
67 | private GltfUtils()
68 | {
69 | // Private constructor to prevent instantiation
70 | }
71 | }
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/src/main/java/org/poly2tri/triangulation/point/TPoint.java:
--------------------------------------------------------------------------------
1 | /* Poly2Tri
2 | * Copyright (c) 2009-2010, Poly2Tri Contributors
3 | * http://code.google.com/p/poly2tri/
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without modification,
8 | * are permitted provided that the following conditions are met:
9 | *
10 | * * Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | * * Redistributions in binary form must reproduce the above copyright notice,
13 | * this list of conditions and the following disclaimer in the documentation
14 | * and/or other materials provided with the distribution.
15 | * * Neither the name of Poly2Tri nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific
17 | * prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 | package org.poly2tri.triangulation.point;
32 |
33 | import org.poly2tri.triangulation.TriangulationPoint;
34 |
35 | public class TPoint extends TriangulationPoint
36 | {
37 | private double _x;
38 | private double _y;
39 | private double _z;
40 |
41 | public TPoint( double x, double y )
42 | {
43 | this( x, y, 0 );
44 | }
45 |
46 | public TPoint( double x, double y, double z )
47 | {
48 | _x = x;
49 | _y = y;
50 | _z = z;
51 | }
52 |
53 | public double getX() { return _x; }
54 | public double getY() { return _y; }
55 | public double getZ() { return _z; }
56 |
57 | public float getXf() { return (float)_x; }
58 | public float getYf() { return (float)_y; }
59 | public float getZf() { return (float)_z; }
60 |
61 | @Override
62 | public void set( double x, double y, double z )
63 | {
64 | _x = x;
65 | _y = y;
66 | _z = z;
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------