Skip to content

Commit 3939423

Browse files
committed
Collada parser fixes
1 parent 4aceb18 commit 3939423

32 files changed

+5696
-240
lines changed

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,11 @@ The purpose of this application is to learn and share how to draw using OpenGL l
1212
* STereoLithography format (STL): https://en.wikipedia.org/wiki/STL_(file_format)
1313
* Collada format (DAE): https://en.wikipedia.org/wiki/COLLADA
1414

15-
News (24/11/2017)
15+
News (08/12/2017)
1616
=================
1717

1818
* Support for collada files with skeletal animations :)
1919
* Fixed #28: Load texture feature is now available
20-
* Fixed #18: Removed asReadOnlyBuffer() - not working on Android 7
21-
* Enhancement #17: Added support for TLS format
22-
* Fixed #16: Toogle point drawing
23-
* Fixed #15: Toggle rotating light
24-
* Fixed #1: Cpu Performance problems
25-
* Fixed #5: Memory Performance problems
2620

2721

2822
Android Market
@@ -52,16 +46,16 @@ Whats next
5246

5347
* Stabilize app performance
5448
* Code refactoring
55-
* Carboard support
56-
* Chromecast support
49+
* Carboard support?
50+
* Chromecast support?
5751
* ...
5852

5953

6054
Features
6155
========
6256

6357
- OpenGL ES 2.0 API
64-
- Formats: OBJ (wavefront) & STL (STereoLithography)
58+
- Formats: OBJ (wavefront), STL (STereoLithography) & DAE (Collada-BETA)
6559
- calculation of normals
6660
- transformations: scaling, rotation, translation
6761
- colors
@@ -75,9 +69,9 @@ Features
7569
- drag to move camera
7670
- rotate with 2 fingers to rotate camera
7771
- pinch & spread to zoom in/out the camera
72+
- skeletal animations
7873
- moving of objects (not yet!)
7974
- primitive collision detection (not yet!)
80-
- animation of sprites (not yet!)
8175

8276
Try it
8377
======
@@ -127,6 +121,10 @@ ChangeLog
127121

128122
(f) fixed, (i) improved, (n) new feature
129123

124+
- 2.0.1 (08/12/2017)
125+
- (f) Multiple Collada parser fixes
126+
- (f) Camera now can look inside objects
127+
130128
- 2.0.0 (24/11/2017)
131129
- (n) Support for collada files with skeletal animations :)
132130

app/build/outputs/apk/app-release.apk

780 KB
Binary file not shown.

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="org.andresoviedo.dddmodel2"
4-
android:versionCode="14"
5-
android:versionName="2.0.0" >
4+
android:versionCode="15"
5+
android:versionName="2.0.1" >
66

77
<uses-sdk
88
android:minSdkVersion="8"
269 KB
Loading

app/src/main/assets/models/cowboy.dae

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</library_cameras>
3434
<library_images>
3535
<image id="character_Texture_png" name="character_Texture_png">
36-
<init_from>character%20Texture.png</init_from>
36+
<init_from>cowboy.png</init_from>
3737
</image>
3838
</library_images>
3939
<library_effects>

app/src/main/assets/models/spider.dae

Lines changed: 2148 additions & 0 deletions
Large diffs are not rendered by default.

app/src/main/assets/models/stormtrooper.dae

Lines changed: 2455 additions & 0 deletions
Large diffs are not rendered by default.

app/src/main/java/org/andresoviedo/app/model3D/animation/Animator.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.os.SystemClock;
55
import android.util.Log;
66

7+
import java.util.Arrays;
78
import java.util.HashMap;
89
import java.util.Map;
910

@@ -69,7 +70,7 @@ public void update(Object3DData obj) {
6970
* reset, causing the animation to loop.
7071
*/
7172
private void increaseAnimationTime(AnimatedModel obj) {
72-
animationTime += 0.01; // System.nanoTime();
73+
animationTime += 0.01;
7374
if (animationTime > obj.getAnimation().getLength()) {
7475
this.animationTime %= obj.getAnimation().getLength();
7576
}
@@ -136,7 +137,11 @@ private Map<String, float[]> calculateCurrentAnimationPose(AnimatedModel obj) {
136137
private void applyPoseToJoints(Map<String, float[]> currentPose, Joint joint, float[] parentTransform) {
137138
float[] currentLocalTransform = currentPose.get(joint.name);
138139
float[] currentTransform = new float[16];
139-
Matrix.multiplyMM(currentTransform,0,parentTransform,0,currentLocalTransform,0);
140+
if (currentLocalTransform == null) {
141+
currentLocalTransform = new float[16];
142+
Matrix.setIdentityM(currentLocalTransform,0);
143+
}
144+
Matrix.multiplyMM(currentTransform, 0, parentTransform, 0, currentLocalTransform, 0);
140145
for (Joint childJoint : joint.children) {
141146
applyPoseToJoints(currentPose, childJoint, currentTransform);
142147
}

app/src/main/java/org/andresoviedo/app/model3D/animation/JointTransform.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public JointTransform(Vector3f position, Quaternion rotation) {
5252
* transform as represented by the position and rotation in this
5353
* instance, just in matrix form.
5454
*/
55-
protected float[] getLocalTransform() {
55+
public float[] getLocalTransform() {
5656
float[] matrix = new float[16];
5757
Matrix.setIdentityM(matrix,0);
5858
Matrix.translateM(matrix,0,matrix,0,position.x,position.y,position.z);

app/src/main/java/org/andresoviedo/app/model3D/controller/LoaderTask.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
import java.io.IOException;
1414
import java.io.InputStream;
1515
import java.net.URL;
16+
import java.util.List;
1617

1718
/**
1819
* This component allows loading the model without blocking the UI.
1920
*
2021
* @author andresoviedo
2122
*/
22-
public abstract class LoaderTask extends AsyncTask<Void, Integer, Object3DData> {
23+
public abstract class LoaderTask extends AsyncTask<Void, Integer, List<Object3DData>> {
2324

2425
/**
2526
* URL to the 3D model
@@ -85,9 +86,9 @@ protected void onPreExecute() {
8586

8687

8788
@Override
88-
protected Object3DData doInBackground(Void... params) {
89+
protected List<Object3DData> doInBackground(Void... params) {
8990
try {
90-
Object3DData data = build();
91+
List<Object3DData> data = build();
9192
callback.onLoadComplete(data);
9293
build(data);
9394
return data;
@@ -97,9 +98,9 @@ protected Object3DData doInBackground(Void... params) {
9798
}
9899
}
99100

100-
protected abstract Object3DData build() throws Exception;
101+
protected abstract List<Object3DData> build() throws Exception;
101102

102-
protected abstract void build(Object3DData data) throws Exception;
103+
protected abstract void build(List<Object3DData> data) throws Exception;
103104

104105
@Override
105106
protected void onProgressUpdate(Integer... values) {
@@ -127,7 +128,7 @@ protected void onProgressUpdate(Integer... values) {
127128
}
128129

129130
@Override
130-
protected void onPostExecute(Object3DData data) {
131+
protected void onPostExecute(List<Object3DData> data) {
131132
super.onPostExecute(data);
132133
if (dialog.isShowing()) {
133134
dialog.dismiss();

0 commit comments

Comments
 (0)