@ -29,7 +29,6 @@
* NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
* /
package com.jme3.scene.plugins.ogre ;
import com.jme3.animation.Bone ;
@ -42,13 +41,12 @@ import com.jme3.asset.AssetManager;
import com.jme3.math.Quaternion ;
import com.jme3.math.Vector3f ;
import com.jme3.util.xml.SAXUtil ;
import java.io.File ;
import java.io.FileInputStream ;
import java.io.IOException ;
import java.io.InputStream ;
import java.io.InputStreamReader ;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.Iterator ;
import java.util.Map ;
import java.util.Stack ;
import java.util.logging.Logger ;
@ -62,31 +60,24 @@ import org.xml.sax.helpers.XMLReaderFactory;
public class SkeletonLoader extends DefaultHandler implements AssetLoader {
private static final Logger logger = Logger . getLogger ( SceneLoader . class . getName ( ) ) ;
private AssetManager assetManager ;
private Stack < String > elementStack = new Stack < String > ( ) ;
private HashMap < Integer , Bone > indexToBone = new HashMap < Integer , Bone > ( ) ;
private HashMap < String , Bone > nameToBone = new HashMap < String , Bone > ( ) ;
private BoneTrack track ;
private ArrayList < BoneTrack > tracks = new ArrayList < BoneTrack > ( ) ;
private BoneAnimation animation ;
private ArrayList < BoneAnimation > animations ;
private Bone bone ;
private Skeleton skeleton ;
private ArrayList < Float > times = new ArrayList < Float > ( ) ;
private ArrayList < Vector3f > translations = new ArrayList < Vector3f > ( ) ;
private ArrayList < Quaternion > rotations = new ArrayList < Quaternion > ( ) ;
private ArrayList < Vector3f > scales = new ArrayList < Vector3f > ( ) ;
private float time = - 1 ;
private Vector3f position ;
private Quaternion rotation ;
private Vector3f scale ;
private float angle ;
private Vector3f axis ;
@ -149,7 +140,7 @@ public class SkeletonLoader extends DefaultHandler implements AssetLoader {
}
public void endElement ( String uri , String name , String qName ) {
if ( qName . equals ( "translate" ) | | qName . equals ( "position" ) ) {
if ( qName . equals ( "translate" ) | | qName . equals ( "position" ) | | qName . equals ( "scale" ) ) {
} else if ( qName . equals ( "axis" ) ) {
} else if ( qName . equals ( "rotate" ) | | qName . equals ( "rotation" ) ) {
rotation = new Quaternion ( ) ;
@ -193,6 +184,11 @@ public class SkeletonLoader extends DefaultHandler implements AssetLoader {
times . add ( time ) ;
translations . add ( position ) ;
rotations . add ( rotation ) ;
if ( scale ! = null ) {
scales . add ( scale ) ;
} else {
scales . add ( new Vector3f ( 1 , 1 , 1 ) ) ;
}
time = - 1 ;
position = null ;
@ -201,12 +197,16 @@ public class SkeletonLoader extends DefaultHandler implements AssetLoader {
} else if ( qName . equals ( "keyframes" ) ) {
if ( times . size ( ) > 0 ) {
float [ ] timesArray = new float [ times . size ( ) ] ;
for ( int i = 0 ; i < timesArray . length ; i + + )
for ( int i = 0 ; i < timesArray . length ; i + + ) {
timesArray [ i ] = times . get ( i ) ;
}
Vector3f [ ] transArray = translations . toArray ( new Vector3f [ translations . size ( ) ] ) ;
Quaternion [ ] rotArray = rotations . toArray ( new Quaternion [ rotations . size ( ) ] ) ;
track . setKeyframes ( timesArray , transArray , rotArray ) ;
Vector3f [ ] scalesArray = scales . toArray ( new Vector3f [ scales . size ( ) ] ) ;
track . setKeyframes ( timesArray , transArray , rotArray , scalesArray ) ;
//track.setKeyframes(timesArray, transArray, rotArray);
} else {
track = null ;
}
@ -214,6 +214,7 @@ public class SkeletonLoader extends DefaultHandler implements AssetLoader {
times . clear ( ) ;
translations . clear ( ) ;
rotations . clear ( ) ;
scales . clear ( ) ;
} else if ( qName . equals ( "skeleton" ) ) {
nameToBone . clear ( ) ;
}
@ -232,8 +233,9 @@ public class SkeletonLoader extends DefaultHandler implements AssetLoader {
track = null ;
tracks . clear ( ) ;
animation = null ;
if ( animations ! = null )
if ( animations ! = null ) {
animations . clear ( ) ;
}
bone = null ;
skeleton = null ;
@ -277,5 +279,4 @@ public class SkeletonLoader extends DefaultHandler implements AssetLoader {
in . close ( ) ;
return obj ;
}
}