OSDN Git Service

Add AndroidTGALoader
authorKazuhiko Kobayashi <chototsu_moushinp@yahoo.co.jp>
Tue, 27 Mar 2012 10:39:32 +0000 (19:39 +0900)
committerkobayasi <kobayasi@pscnet.co.jp>
Sat, 6 Jul 2013 01:36:58 +0000 (10:36 +0900)
30 files changed:
engine/lib/bullet/jME3-bullet-natives.jar
engine/lib/bullet/jarcontent/native/macosx/libbulletjme.jnilib
engine/src/android/com/jme3/app/AndroidHarness.java
engine/src/android/com/jme3/asset/AndroidAssetManager.java
engine/src/android/com/jme3/asset/plugins/AndroidLocator.java
engine/src/android/com/jme3/input/android/AndroidInput.java
engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java
engine/src/android/com/jme3/renderer/android/TextureUtil.java
engine/src/android/com/jme3/system/android/AndroidTimer.java
engine/src/android/com/jme3/system/android/OGLESContext.java
engine/src/android/com/jme3/texture/plugins/AndroidTGALoader.java [new file with mode: 0644]
engine/src/bullet/com/jme3/bullet/PhysicsSpace.java
engine/src/bullet/com/jme3/bullet/collision/PhysicsCollisionObject.java
engine/src/bullet/com/jme3/bullet/collision/shapes/BoxCollisionShape.java
engine/src/bullet/com/jme3/bullet/collision/shapes/CapsuleCollisionShape.java
engine/src/bullet/com/jme3/bullet/collision/shapes/CollisionShape.java
engine/src/bullet/com/jme3/bullet/collision/shapes/PlaneCollisionShape.java
engine/src/bullet/com/jme3/bullet/joints/PhysicsJoint.java
engine/src/bullet/com/jme3/bullet/joints/SixDofJoint.java
engine/src/bullet/com/jme3/bullet/objects/PhysicsRigidBody.java
engine/src/bullet/com/jme3/bullet/objects/infos/RigidBodyMotionState.java
engine/src/bullet/native/build.xml
engine/src/bullet/native/bullet.properties
engine/src/bullet/native/com_jme3_bullet_joints_PhysicsJoint.cpp
engine/src/core/com/jme3/animation/Bone.java
engine/src/core/com/jme3/material/Material.java
engine/src/core/com/jme3/renderer/RenderManager.java
engine/src/core/com/jme3/scene/Mesh.java
engine/src/core/com/jme3/scene/VertexBuffer.java
engine/src/desktop/com/jme3/asset/plugins/ClasspathLocator.java

index e34e3c9..aa9434f 100644 (file)
Binary files a/engine/lib/bullet/jME3-bullet-natives.jar and b/engine/lib/bullet/jME3-bullet-natives.jar differ
index 77f4424..a3185f1 100755 (executable)
Binary files a/engine/lib/bullet/jarcontent/native/macosx/libbulletjme.jnilib and b/engine/lib/bullet/jarcontent/native/macosx/libbulletjme.jnilib differ
index 083a777..2f575c3 100644 (file)
@@ -279,6 +279,7 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
      */\r
     public void onClick(DialogInterface dialog, int whichButton) {\r
         if (whichButton != -2) {\r
+            android.os.Process.killProcess(android.os.Process.myPid());\r
             if (app != null) {\r
                 app.stop(true);\r
             }\r
index 77734f1..cbadfff 100644 (file)
@@ -83,7 +83,7 @@ public class AndroidAssetManager extends DesktopAssetManager {
         this.registerLoader(com.jme3.texture.plugins.DDSLoader.class, "dds");
         this.registerLoader(com.jme3.texture.plugins.PFMLoader.class, "pfm");
         this.registerLoader(com.jme3.texture.plugins.HDRLoader.class, "hdr");
-        this.registerLoader(com.jme3.texture.plugins.TGALoader.class, "tga");
+        this.registerLoader(com.jme3.texture.plugins.AndroidTGALoader.class, "tga");
         this.registerLoader(com.jme3.export.binary.BinaryImporter.class, "j3o");
         this.registerLoader(com.jme3.scene.plugins.OBJLoader.class, "obj");
         this.registerLoader(com.jme3.scene.plugins.MTLLoader.class, "mtl");
index bc87d37..5c5086f 100644 (file)
@@ -19,17 +19,22 @@ public class AndroidLocator implements AssetLocator {
 
     private class AndroidAssetInfo extends AssetInfo {
 
-        private final InputStream in;
-
-        public AndroidAssetInfo(com.jme3.asset.AssetManager manager, AssetKey<?> key, InputStream in)
+//        private final InputStream in;
+        String sAssetPath;
+        public AndroidAssetInfo(com.jme3.asset.AssetManager manager, AssetKey<?> key, String sAssetPath)
         {
             super(manager, key);
-            this.in = in;
+//            this.in = in;
+            this.sAssetPath = sAssetPath;
         }
 
         @Override
         public InputStream openStream() {
-            return in;
+            try {
+                return androidManager.open(sAssetPath);
+            } catch (IOException ex) {
+                throw new RuntimeException(ex);
+            }
         }
     }
 
@@ -63,7 +68,7 @@ public class AndroidLocator implements AssetLocator {
             if (in == null)
                 return null;
 
-            return new AndroidAssetInfo(manager, key, in);
+            return new AndroidAssetInfo(manager, key, sAssetPath);
         } 
         catch (IOException ex) 
         {
index 09ca3d3..88f006f 100644 (file)
@@ -751,5 +751,6 @@ public class AndroidInput extends GLSurfaceView implements TouchInput,
        public void setMouseEventsInvertX(boolean mouseEventsInvertX) {
            this.mouseEventsInvertX = mouseEventsInvertX;
        }
+        
 
 }
index 822d9d5..18a079c 100644 (file)
@@ -36,6 +36,9 @@ import android.opengl.GLES10;
 import android.opengl.GLES11;
 import android.opengl.GLES20;
 import android.os.Build;
+import com.jme3.app.AndroidHarness;
+import com.jme3.asset.AssetManager;
+import com.jme3.asset.DesktopAssetManager;
 import com.jme3.asset.TextureKey;
 import com.jme3.light.LightList;
 import com.jme3.material.RenderState;
@@ -108,6 +111,7 @@ public class OGLESShaderRenderer implements Renderer {
     private boolean powerOf2 = false;
     private boolean verboseLogging = false;
     private boolean useVBO = false;
+    public boolean adreno_finish_bug = false;
 
     public OGLESShaderRenderer() {
     }
@@ -407,7 +411,10 @@ public class OGLESShaderRenderer implements Renderer {
         if (Build.VERSION.SDK_INT >= 9){
             useVBO = true;
         }
-        
+        // chekc Adreno200,205,220 bug
+        if (GLES20.glGetString(GLES20.GL_RENDERER).indexOf("Adreno") >=0) {
+            adreno_finish_bug = true;
+        }
         logger.log(Level.INFO, "Caps: {0}", caps);
     }
 
@@ -724,9 +731,9 @@ public class OGLESShaderRenderer implements Renderer {
 
     public void setClipRect(int x, int y, int width, int height) {
         if (!context.clipRectEnabled) {
-            if (verboseLogging) {
+//            if (verboseLogging) {
                 logger.info("GLES20.glEnable(GLES20.GL_SCISSOR_TEST)");
-            }
+//            }
             GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
             checkGLError();
             context.clipRectEnabled = true;
@@ -1974,6 +1981,7 @@ public class OGLESShaderRenderer implements Renderer {
     public void setTexture(int unit, Texture tex) {
         Image image = tex.getImage();
         if (image.isUpdateNeeded()) {
+//            logger.warning("setTexture: isUpdateNeeded");
             Bitmap bmp = (Bitmap)image.getEfficentData();
             if (bmp != null)
             {
@@ -1981,11 +1989,14 @@ public class OGLESShaderRenderer implements Renderer {
             if ( bmp.isRecycled() )
             {
             // We need to reload the bitmap
-            Texture textureReloaded = JmeSystem.newAssetManager().loadTexture((TextureKey)tex.getKey());
+            DesktopAssetManager assetManager = (DesktopAssetManager)((AndroidHarness)JmeSystem.getActivity()).getJmeApplication().getAssetManager();
+            assetManager.deleteFromCache((TextureKey)tex.getKey());
+            Texture textureReloaded = assetManager.loadTexture((TextureKey)tex.getKey());
             image.setEfficentData( textureReloaded.getImage().getEfficentData());
             }
             }
             updateTexImageData(image, tex.getType(), tex.getMinFilter().usesMipMapLevels());
+            setupTextureParams(tex);
         }
 
         int texId = image.getId();
@@ -2027,7 +2038,7 @@ public class OGLESShaderRenderer implements Renderer {
             statistics.onTextureUse(tex.getImage(), false);
         }
 
-        setupTextureParams(tex);
+//        setupTextureParams(tex);
     }
 
     public void clearTextureUnits() {
@@ -2419,7 +2430,7 @@ public class OGLESShaderRenderer implements Renderer {
                     context.boundArrayVBO = bufId;
                 }
 
-                vb.getData().clear();
+//                vb.getData().clear();
 
                 if (verboseLogging) {
                     logger.info("GLES20.glVertexAttribPointer("
@@ -2436,7 +2447,7 @@ public class OGLESShaderRenderer implements Renderer {
                                     convertFormat(vb.getFormat()),
                                     vb.isNormalized(),
                                     vb.getStride(),
-                                    0);
+                                    vb.getOffset());
 
                 attribs[loc] = vb;
             }
index 65a2f3a..2269eb2 100644 (file)
@@ -120,17 +120,17 @@ public class TextureUtil {
             int width = bitmap.getWidth();
             int height = bitmap.getHeight();
             if (!FastMath.isPowerOfTwo(width) || !FastMath.isPowerOfTwo(height)
-                    || width >= 512 || height >= 512)
+                    /*|| width >= 512 || height >= 512*/)
             {
                 // scale to power of two
                 width = FastMath.nearestPowerOfTwo(width);
                 height = FastMath.nearestPowerOfTwo(height);
-                while(width >= 512) {
-                    width = width / 2;
-                }
-                while(height >= 512) {
-                    height = height / 2;
-                }
+//                while(width >= 512) {
+//                    width = width / 2;
+//                }
+//                while(height >= 512) {
+//                    height = height / 2;
+//                }
             Logger.getLogger(TextureUtil.class.getName()).warning("texture size changed.");
                 Bitmap bitmap2 = Bitmap.createScaledBitmap(bitmap, width, height, true);
                 bitmap.recycle();
index 4cabc33..18e9944 100644 (file)
@@ -45,7 +45,7 @@ public class AndroidTimer extends Timer {
     private static final float INVERSE_TIMER_RESOLUTION = 1f/1000000000L;
     
     private long startTime;
-    private long previousTime;
+    private float previousTime;
     private float tpf;
     private float fps;
     
@@ -83,14 +83,15 @@ public class AndroidTimer extends Timer {
     }
 
     public void update() {
-        tpf = (getTime() - previousTime) * (1.0f / TIMER_RESOLUTION);
+        long timeNow = getTime();
+        tpf = (timeNow) * (1.0f / TIMER_RESOLUTION) - previousTime;
         fps = 1.0f / tpf;
-        previousTime = getTime();
+        previousTime = previousTime += tpf;
     }
     
     public void reset() {
         //startTime = System.currentTimeMillis();
         startTime = System.nanoTime();
-        previousTime = getTime();
+        previousTime = 0;//getTime();
     }
 }
index 4835467..e74091e 100644 (file)
@@ -442,8 +442,9 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer
             }
             
         }
-        
-        
+//        if (renderer.adreno_finish_bug) {
+//            GLES20.glFinish();
+//        }
     }
     
     @Override
diff --git a/engine/src/android/com/jme3/texture/plugins/AndroidTGALoader.java b/engine/src/android/com/jme3/texture/plugins/AndroidTGALoader.java
new file mode 100644 (file)
index 0000000..cf438fd
--- /dev/null
@@ -0,0 +1,551 @@
+/*
+ * Copyright (c) 2009-2010 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ *   may be used to endorse or promote products derived from this software
+ *   without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.jme3.texture.plugins;
+
+import android.graphics.Bitmap;
+import com.jme3.math.FastMath;
+import com.jme3.asset.AssetLoader;
+import com.jme3.texture.Image;
+import com.jme3.util.BufferUtils;
+import com.jme3.asset.AssetInfo;
+import com.jme3.asset.TextureKey;
+import com.jme3.texture.Image.Format;
+import java.io.BufferedInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+
+/**
+ * <code>TextureManager</code> provides static methods for building a
+ * <code>Texture</code> object. Typically, the information supplied is the
+ * filename and the texture properties.
+ * 
+ * @author Mark Powell
+ * @author Joshua Slack - cleaned, commented, added ability to read 16bit true color and color-mapped TGAs.
+ * @author Kirill Vainer - ported to jME3
+ * @version $Id: TGALoader.java 4131 2009-03-19 20:15:28Z blaine.dev $
+ */
+public final class AndroidTGALoader implements AssetLoader {
+
+    // 0 - no image data in file
+    public static final int TYPE_NO_IMAGE = 0;
+
+    // 1 - uncompressed, color-mapped image
+    public static final int TYPE_COLORMAPPED = 1;
+
+    // 2 - uncompressed, true-color image
+    public static final int TYPE_TRUECOLOR = 2;
+
+    // 3 - uncompressed, black and white image
+    public static final int TYPE_BLACKANDWHITE = 3;
+
+    // 9 - run-length encoded, color-mapped image
+    public static final int TYPE_COLORMAPPED_RLE = 9;
+
+    // 10 - run-length encoded, true-color image
+    public static final int TYPE_TRUECOLOR_RLE = 10;
+
+    // 11 - run-length encoded, black and white image
+    public static final int TYPE_BLACKANDWHITE_RLE = 11;
+
+    public Object load(AssetInfo info) throws IOException{
+        if (!(info.getKey() instanceof TextureKey))
+            throw new IllegalArgumentException("Texture assets must be loaded using a TextureKey");
+
+        boolean flip = ((TextureKey)info.getKey()).isFlipY();
+        InputStream in = null;
+        try {
+            in = info.openStream();
+            Image img = load(in, flip);
+            return img;
+        } finally {
+            if (in != null){
+                in.close();
+            }
+        }
+    }
+
+    /**
+     * <code>loadImage</code> is a manual image loader which is entirely
+     * independent of AWT. OUT: RGB888 or RGBA8888 Image object
+     * 
+     * @return <code>Image</code> object that contains the
+     *         image, either as a RGB888 or RGBA8888
+     * @param flip
+     *            Flip the image vertically
+     * @param exp32
+     *            Add a dummy Alpha channel to 24b RGB image.
+     * @param fis
+     *            InputStream of an uncompressed 24b RGB or 32b RGBA TGA
+     * @throws java.io.IOException
+     */
+    public static Image load(InputStream in, boolean flip) throws IOException {
+        boolean flipH = false;
+
+        // open a stream to the file
+        DataInputStream dis = new DataInputStream(new BufferedInputStream(in));
+
+        // ---------- Start Reading the TGA header ---------- //
+        // length of the image id (1 byte)
+        int idLength = dis.readUnsignedByte();
+
+        // Type of color map (if any) included with the image
+        // 0 - no color map data is included
+        // 1 - a color map is included
+        int colorMapType = dis.readUnsignedByte();
+
+        // Type of image being read:
+        int imageType = dis.readUnsignedByte();
+
+        // Read Color Map Specification (5 bytes)
+        // Index of first color map entry (if we want to use it, uncomment and remove extra read.)
+//        short cMapStart = flipEndian(dis.readShort());
+        dis.readShort();
+        // number of entries in the color map
+        short cMapLength = flipEndian(dis.readShort());
+        // number of bits per color map entry
+        int cMapDepth = dis.readUnsignedByte();
+
+        // Read Image Specification (10 bytes)
+        // horizontal coordinate of lower left corner of image. (if we want to use it, uncomment and remove extra read.)
+//        int xOffset = flipEndian(dis.readShort());
+        dis.readShort();
+        // vertical coordinate of lower left corner of image. (if we want to use it, uncomment and remove extra read.)
+//        int yOffset = flipEndian(dis.readShort());
+        dis.readShort();
+        // width of image - in pixels
+        int width = flipEndian(dis.readShort());
+        // height of image - in pixels
+        int height = flipEndian(dis.readShort());
+        // bits per pixel in image.
+        int pixelDepth = dis.readUnsignedByte();
+        int imageDescriptor = dis.readUnsignedByte();
+        if ((imageDescriptor & 32) != 0) // bit 5 : if 1, flip top/bottom ordering
+            flip = !flip;
+        if ((imageDescriptor & 16) != 0) // bit 4 : if 1, flip left/right ordering
+            flipH = !flipH;
+        
+        // ---------- Done Reading the TGA header ---------- //
+        
+        // Skip image ID
+        if (idLength > 0)
+            in.skip(idLength);
+        
+        ColorMapEntry[] cMapEntries = null;
+        if (colorMapType != 0) {
+            // read the color map.
+            int bytesInColorMap = (cMapDepth * cMapLength) >> 3;
+            int bitsPerColor = Math.min(cMapDepth/3 , 8);
+            
+            byte[] cMapData = new byte[bytesInColorMap];
+            in.read(cMapData);
+            
+            // Only go to the trouble of constructing the color map
+            // table if this is declared a color mapped image.
+            if (imageType == TYPE_COLORMAPPED || imageType == TYPE_COLORMAPPED_RLE) {
+                cMapEntries = new ColorMapEntry[cMapLength];
+                int alphaSize = cMapDepth - (3*bitsPerColor);
+                float scalar = 255f / (FastMath.pow(2, bitsPerColor) - 1);
+                float alphaScalar = 255f / (FastMath.pow(2, alphaSize) - 1);
+                for (int i = 0; i < cMapLength; i++) {
+                    ColorMapEntry entry = new ColorMapEntry();
+                    int offset = cMapDepth * i;
+                    entry.red = (byte)(int)(getBitsAsByte(cMapData, offset, bitsPerColor) * scalar);
+                    entry.green = (byte)(int)(getBitsAsByte(cMapData, offset+bitsPerColor, bitsPerColor) * scalar);
+                    entry.blue = (byte)(int)(getBitsAsByte(cMapData, offset+(2*bitsPerColor), bitsPerColor) * scalar);
+                    if (alphaSize <= 0)
+                        entry.alpha = (byte)255;
+                    else
+                        entry.alpha = (byte)(int)(getBitsAsByte(cMapData, offset+(3*bitsPerColor), alphaSize) * alphaScalar);
+                    
+                    cMapEntries[i] = entry;
+                }
+            }
+        }
+        
+        
+        // Allocate image data array
+        Format format;
+        byte[] rawData = null;
+        int dl;
+        if (pixelDepth == 32) {
+            rawData = new byte[width * height * 4];
+            dl = 4;
+        } else {
+            rawData = new byte[width * height * 4];
+            dl = 3;
+        }
+        int rawDataIndex = 0;
+
+        if (imageType == TYPE_TRUECOLOR) {
+            byte red = 0;
+            byte green = 0;
+            byte blue = 0;
+            byte alpha = 0;
+            
+            // Faster than doing a 16-or-24-or-32 check on each individual pixel,
+            // just make a seperate loop for each.
+            if (pixelDepth == 16) {
+                byte[] data = new byte[2];
+                float scalar = 255f/31f;
+                for (int i = 0; i <= (height - 1); i++) {
+                    if (!flip)
+                        rawDataIndex = (height - 1 - i) * width * dl;
+                    for (int j = 0; j < width; j++) {
+                        data[1] = dis.readByte();
+                        data[0] = dis.readByte();
+                        rawData[rawDataIndex++] = (byte)(int)(getBitsAsByte(data, 1, 5) * scalar);
+                        rawData[rawDataIndex++] = (byte)(int)(getBitsAsByte(data, 6, 5) * scalar);
+                        rawData[rawDataIndex++] = (byte)(int)(getBitsAsByte(data, 11, 5) * scalar);
+                        if (dl == 4) {
+                            // create an alpha channel
+                            alpha = getBitsAsByte(data, 0, 1);
+                            if (alpha == 1) alpha = (byte)255;
+                            rawData[rawDataIndex++] = alpha;
+                        } else {
+                            rawData[rawDataIndex++] = (byte)0xff;
+                        }
+                    }
+                }
+
+                format = dl == 4 ? Format.RGBA8 : Format.RGB8;
+            } else if (pixelDepth == 24){
+                for (int y = 0; y < height; y++) {
+                    if (!flip)
+                        rawDataIndex = (height - 1 - y) * width * dl;
+                    else
+                        rawDataIndex = y * width * dl;
+
+//                    dis.readFully(rawData, rawDataIndex, width * dl);
+                    for (int x = 0; x < width; x++) {
+//                        read scanline
+                        blue = dis.readByte();
+                        green = dis.readByte();
+                        red = dis.readByte();
+                        rawData[rawDataIndex++] = red;
+                        rawData[rawDataIndex++] = green;
+                        rawData[rawDataIndex++] = blue;
+                        rawData[rawDataIndex++] = (byte)0xff;
+                    }
+                }
+                format = Format.RGB8;
+            } else if (pixelDepth == 32){
+                for (int i = 0; i <= (height - 1); i++) {
+                    if (!flip)
+                        rawDataIndex = (height - 1 - i) * width * dl;
+
+                    for (int j = 0; j < width; j++) {
+                        blue = dis.readByte();
+                        green = dis.readByte();
+                        red = dis.readByte();
+                        alpha = dis.readByte();
+                        rawData[rawDataIndex++] = red;
+                        rawData[rawDataIndex++] = green;
+                        rawData[rawDataIndex++] = blue;
+                        rawData[rawDataIndex++] = alpha;
+                    }
+                }
+                format = Format.RGBA8;
+            }else{
+                throw new IOException("Unsupported TGA true color depth: "+pixelDepth);
+            }
+        } else if( imageType == TYPE_TRUECOLOR_RLE ) {
+            byte red = 0;
+            byte green = 0;
+            byte blue = 0;
+            byte alpha = 0;
+            // Faster than doing a 16-or-24-or-32 check on each individual pixel,
+            // just make a seperate loop for each.
+            if( pixelDepth == 32 ){
+                for( int i = 0; i <= ( height - 1 ); ++i ){
+                    if( !flip ){
+                        rawDataIndex = ( height - 1 - i ) * width * dl;
+                    }
+
+                    for( int j = 0; j < width; ++j ){
+                        // Get the number of pixels the next chunk covers (either packed or unpacked)
+                        int count = dis.readByte();
+                        if( ( count & 0x80 ) != 0 ){
+                            // Its an RLE packed block - use the following 1 pixel for the next <count> pixels
+                            count &= 0x07f;
+                            j += count;
+                            blue = dis.readByte();
+                            green = dis.readByte();
+                            red = dis.readByte();
+                            alpha = dis.readByte();
+                            while( count-- >= 0 ){
+                                rawData[rawDataIndex++] = red;
+                                rawData[rawDataIndex++] = green;
+                                rawData[rawDataIndex++] = blue;
+                                rawData[rawDataIndex++] = alpha;
+                            }
+                        } else{
+                            // Its not RLE packed, but the next <count> pixels are raw.
+                            j += count;
+                            while( count-- >= 0 ){
+                                blue = dis.readByte();
+                                green = dis.readByte();
+                                red = dis.readByte();
+                                alpha = dis.readByte();
+                                rawData[rawDataIndex++] = red;
+                                rawData[rawDataIndex++] = green;
+                                rawData[rawDataIndex++] = blue;
+                                rawData[rawDataIndex++] = alpha;
+                            }
+                        }
+                    }
+                }
+                format = Format.RGBA8;
+            } else if( pixelDepth == 24 ){
+                for( int i = 0; i <= ( height - 1 ); i++ ){
+                    if( !flip ){
+                        rawDataIndex = ( height - 1 - i ) * width * dl;
+                    }
+                    for( int j = 0; j < width; ++j ){
+                        // Get the number of pixels the next chunk covers (either packed or unpacked)
+                        int count = dis.readByte();
+                        if( ( count & 0x80 ) != 0 ){
+                            // Its an RLE packed block - use the following 1 pixel for the next <count> pixels
+                            count &= 0x07f;
+                            j += count;
+                            blue = dis.readByte();
+                            green = dis.readByte();
+                            red = dis.readByte();
+                            while( count-- >= 0 ){
+                                rawData[rawDataIndex++] = red;
+                                rawData[rawDataIndex++] = green;
+                                rawData[rawDataIndex++] = blue;
+                                rawData[rawDataIndex++] = (byte)0xff;
+                            }
+                        } else{
+                            // Its not RLE packed, but the next <count> pixels are raw.
+                            j += count;
+                            while( count-- >= 0 ){
+                                blue = dis.readByte();
+                                green = dis.readByte();
+                                red = dis.readByte();
+                                rawData[rawDataIndex++] = red;
+                                rawData[rawDataIndex++] = green;
+                                rawData[rawDataIndex++] = blue;
+                                rawData[rawDataIndex++] = (byte)0xff;
+                            }
+                        }
+                    }
+                }
+                format = Format.RGB8;
+            } else if( pixelDepth == 16 ){
+                byte[] data = new byte[ 2 ];
+                float scalar = 255f / 31f;
+                for( int i = 0; i <= ( height - 1 ); i++ ){
+                    if( !flip ){
+                        rawDataIndex = ( height - 1 - i ) * width * dl;
+                    }
+                    for( int j = 0; j < width; j++ ){
+                        // Get the number of pixels the next chunk covers (either packed or unpacked)
+                        int count = dis.readByte();
+                        if( ( count & 0x80 ) != 0 ){
+                            // Its an RLE packed block - use the following 1 pixel for the next <count> pixels
+                            count &= 0x07f;
+                            j += count;
+                            data[1] = dis.readByte();
+                            data[0] = dis.readByte();
+                            blue = (byte) (int) ( getBitsAsByte( data, 1, 5 ) * scalar );
+                            green = (byte) (int) ( getBitsAsByte( data, 6, 5 ) * scalar );
+                            red = (byte) (int) ( getBitsAsByte( data, 11, 5 ) * scalar );
+                            while( count-- >= 0 ){
+                                rawData[rawDataIndex++] = red;
+                                rawData[rawDataIndex++] = green;
+                                rawData[rawDataIndex++] = blue;
+                                rawData[rawDataIndex++] = (byte)0xff;
+                            }
+                        } else{
+                            // Its not RLE packed, but the next <count> pixels are raw.
+                            j += count;
+                            while( count-- >= 0 ){
+                                data[1] = dis.readByte();
+                                data[0] = dis.readByte();
+                                blue = (byte) (int) ( getBitsAsByte( data, 1, 5 ) * scalar );
+                                green = (byte) (int) ( getBitsAsByte( data, 6, 5 ) * scalar );
+                                red = (byte) (int) ( getBitsAsByte( data, 11, 5 ) * scalar );
+                                rawData[rawDataIndex++] = red;
+                                rawData[rawDataIndex++] = green;
+                                rawData[rawDataIndex++] = blue;
+                                rawData[rawDataIndex++] = (byte)0xff;
+                            }
+                        }
+                    }
+                }
+                format = Format.RGB8;
+            } else{
+                throw new IOException( "Unsupported TGA true color depth: " + pixelDepth );
+            }
+
+        } else if( imageType == TYPE_COLORMAPPED ){
+            int bytesPerIndex = pixelDepth / 8;
+            
+            if (bytesPerIndex == 1) {
+                for (int i = 0; i <= (height - 1); i++) {
+                    if (!flip)
+                        rawDataIndex = (height - 1 - i) * width * dl;
+                    for (int j = 0; j < width; j++) {
+                        int index = dis.readUnsignedByte();
+                        if (index >= cMapEntries.length || index < 0)
+                            throw new IOException("TGA: Invalid color map entry referenced: "+index);
+
+                        ColorMapEntry entry = cMapEntries[index];
+                        rawData[rawDataIndex++] = entry.red;
+                        rawData[rawDataIndex++] = entry.green;
+                        rawData[rawDataIndex++] = entry.blue;
+                        if (dl == 4) {
+                            rawData[rawDataIndex++] = entry.alpha;
+                        } else {
+                            rawData[rawDataIndex++] = (byte)0xff;
+                        }
+                    }
+                }
+            } else if (bytesPerIndex == 2) {
+                for (int i = 0; i <= (height - 1); i++) {
+                    if (!flip)
+                        rawDataIndex = (height - 1 - i) * width * dl;
+                    for (int j = 0; j < width; j++) {
+                        int index = flipEndian(dis.readShort());
+                        if (index >= cMapEntries.length || index < 0)
+                            throw new IOException("TGA: Invalid color map entry referenced: "+index);
+
+                        ColorMapEntry entry = cMapEntries[index];
+                        rawData[rawDataIndex++] = entry.red;
+                        rawData[rawDataIndex++] = entry.green;
+                        rawData[rawDataIndex++] = entry.blue;
+                        if (dl == 4) {
+                            rawData[rawDataIndex++] = entry.alpha;
+                        } else {
+                            rawData[rawDataIndex++] = (byte)0xff;
+                        }
+                    }
+                }
+            } else {
+                throw new IOException("TGA: unknown colormap indexing size used: "+bytesPerIndex);
+            }
+
+            format = dl == 4 ? Format.RGBA8 : Format.RGB8;
+        } else {
+            throw new IOException("Grayscale TGA not supported");
+        }
+        
+        
+        in.close();
+        // Get a pointer to the image memory
+//        ByteBuffer scratch = BufferUtils.createByteBuffer(rawData.length);
+        ByteBuffer scratch = ByteBuffer.wrap(rawData);
+        Bitmap.Config cfg;
+        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+        bitmap.copyPixelsFromBuffer(scratch);
+        rawData = null;
+        scratch = null;
+        if (!FastMath.isPowerOfTwo(width) || !FastMath.isPowerOfTwo(height)
+                || width >= 512 || height >= 512)
+        {
+            // scale to power of two
+            width = FastMath.nearestPowerOfTwo(width);
+            height = FastMath.nearestPowerOfTwo(height);
+            while(width >= 512) {
+                width = width / 2;
+            }
+            while(height >= 512) {
+                height = height / 2;
+            }
+            Bitmap bitmap2 = Bitmap.createScaledBitmap(bitmap, width, height, true);
+            bitmap.recycle();
+            bitmap = bitmap2;
+        }
+//        scratch.clear();
+//        scratch.put(rawData);
+//        scratch.rewind();
+        // Create the Image object
+        Image textureImage = new Image();
+        textureImage.setFormat(format);
+        textureImage.setWidth(width);
+        textureImage.setHeight(height);
+//        textureImage.setData(scratch);
+        textureImage.setEfficentData(bitmap);
+        return textureImage;
+    }
+
+    private static byte getBitsAsByte(byte[] data, int offset, int length) {
+        int offsetBytes = offset / 8;
+        int indexBits = offset % 8;
+        int rVal = 0;
+        
+        // start at data[offsetBytes]...  spill into next byte as needed.
+        for (int i = length; --i >=0;) {
+            byte b = data[offsetBytes];
+            int test = indexBits == 7 ? 1 : 2 << (6-indexBits);
+            if ((b & test) != 0) {
+                if (i == 0)
+                    rVal++;
+                else
+                    rVal += (2 << i-1);
+            }
+            indexBits++;
+            if (indexBits == 8) {
+                indexBits = 0;
+                offsetBytes++;
+            }
+        }
+        
+        return (byte)rVal;
+    }
+
+    /**
+     * <code>flipEndian</code> is used to flip the endian bit of the header
+     * file.
+     * 
+     * @param signedShort
+     *            the bit to flip.
+     * @return the flipped bit.
+     */
+    private static short flipEndian(short signedShort) {
+        int input = signedShort & 0xFFFF;
+        return (short) (input << 8 | (input & 0xFF00) >>> 8);
+    }
+
+    static class ColorMapEntry {
+        byte red, green, blue, alpha;
+        
+        @Override
+        public String toString() {
+            return "entry: "+red+","+green+","+blue+","+alpha;
+        }
+    }
+}
index a265236..86ecf18 100644 (file)
@@ -571,17 +571,17 @@ public class PhysicsSpace {
     private native void removeConstraint(long space, long id);
 
     private void addGhostObject(PhysicsGhostObject node) {
-        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Adding ghost object {0} to physics space.", Long.toHexString(node.getObjectId()));
+        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.FINE, "Adding ghost object {0} to physics space.", Long.toHexString(node.getObjectId()));
         addCollisionObject(physicsSpaceId, node.getObjectId());
     }
 
     private void removeGhostObject(PhysicsGhostObject node) {
-        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Removing ghost object {0} from physics space.", Long.toHexString(node.getObjectId()));
+        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.FINE, "Removing ghost object {0} from physics space.", Long.toHexString(node.getObjectId()));
         removeCollisionObject(physicsSpaceId, node.getObjectId());
     }
 
     private void addCharacter(PhysicsCharacter node) {
-        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Adding character {0} to physics space.", Long.toHexString(node.getObjectId()));
+        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.FINE, "Adding character {0} to physics space.", Long.toHexString(node.getObjectId()));
         addCharacterObject(physicsSpaceId, node.getObjectId());
         addAction(physicsSpaceId, node.getControllerId());
 //        dynamicsWorld.addCollisionObject(node.getObjectId(), CollisionFilterGroups.CHARACTER_FILTER, (short) (CollisionFilterGroups.STATIC_FILTER | CollisionFilterGroups.DEFAULT_FILTER));
@@ -589,7 +589,7 @@ public class PhysicsSpace {
     }
 
     private void removeCharacter(PhysicsCharacter node) {
-        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Removing character {0} from physics space.", Long.toHexString(node.getObjectId()));
+        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.FINE, "Removing character {0} from physics space.", Long.toHexString(node.getObjectId()));
         removeAction(physicsSpaceId, node.getControllerId());
         removeCharacterObject(physicsSpaceId, node.getObjectId());
 //        dynamicsWorld.removeAction(node.getControllerId());
@@ -612,9 +612,9 @@ public class PhysicsSpace {
             node.setKinematic(true);
         }
 
-        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Adding RigidBody {0} to physics space.", node.getObjectId());
+        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.FINE, "Adding RigidBody {0} to physics space.", node.getObjectId());
         if (node instanceof PhysicsVehicle) {
-            Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Adding vehicle constraint {0} to physics space.", Long.toHexString(((PhysicsVehicle) node).getVehicleId()));
+            Logger.getLogger(PhysicsSpace.class.getName()).log(Level.FINE, "Adding vehicle constraint {0} to physics space.", Long.toHexString(((PhysicsVehicle) node).getVehicleId()));
             ((PhysicsVehicle) node).createVehicle(this);
             addVehicle(physicsSpaceId, ((PhysicsVehicle) node).getVehicleId());
 //            dynamicsWorld.addVehicle(((PhysicsVehicle) node).getVehicleId());
@@ -623,25 +623,25 @@ public class PhysicsSpace {
 
     private void removeRigidBody(PhysicsRigidBody node) {
         if (node instanceof PhysicsVehicle) {
-            Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Removing vehicle constraint {0} from physics space.", Long.toHexString(((PhysicsVehicle) node).getVehicleId()));
+            Logger.getLogger(PhysicsSpace.class.getName()).log(Level.FINE, "Removing vehicle constraint {0} from physics space.", Long.toHexString(((PhysicsVehicle) node).getVehicleId()));
             removeVehicle(physicsSpaceId, ((PhysicsVehicle) node).getVehicleId());
             ((PhysicsVehicle) node).setPhysicsSpaceInternal(null);
 //            dynamicsWorld.removeVehicle(((PhysicsVehicle) node).getVehicleId());
         }
-        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Removing RigidBody {0} from physics space.", Long.toHexString(node.getObjectId()));
+        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.FINE, "Removing RigidBody {0} from physics space.", Long.toHexString(node.getObjectId()));
         physicsNodes.remove(node.getObjectId());
         removeRigidBody(physicsSpaceId, node.getObjectId());
     }
 
     private void addJoint(PhysicsJoint joint) {
-        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Adding Joint {0} to physics space.", Long.toHexString(joint.getObjectId()));
+        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.FINE, "Adding Joint {0} to physics space.", Long.toHexString(joint.getObjectId()));
         physicsJoints.add(joint);
         addConstraint(physicsSpaceId, joint.getObjectId());
 //        dynamicsWorld.addConstraint(joint.getObjectId(), !joint.isCollisionBetweenLinkedBodys());
     }
 
     private void removeJoint(PhysicsJoint joint) {
-        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Removing Joint {0} from physics space.", Long.toHexString(joint.getObjectId()));
+        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.FINE, "Removing Joint {0} from physics space.", Long.toHexString(joint.getObjectId()));
         physicsJoints.remove(joint);
         removeConstraint(physicsSpaceId, joint.getObjectId());
 //        dynamicsWorld.removeConstraint(joint.getObjectId());
@@ -920,8 +920,16 @@ public class PhysicsSpace {
 
     @Override
     protected void finalize() throws Throwable {
+        for(PhysicsJoint o : physicsJoints) {
+            remove(o);
+        }
+        physicsJoints.clear();
+        for(PhysicsCollisionObject o : physicsNodes.values()) {
+            remove(o);
+        }
+        physicsNodes.clear();
         super.finalize();
-        Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Finalizing PhysicsSpace {0}", Long.toHexString(physicsSpaceId));
+        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Finalizing PhysicsSpace {0}", Long.toHexString(physicsSpaceId));
         finalizeNative(physicsSpaceId);
     }
 
index 437a3a6..38b62db 100644 (file)
@@ -174,7 +174,7 @@ public abstract class PhysicsCollisionObject implements Savable {
     }
     
     protected void initUserPointer() {
-        Logger.getLogger(this.getClass().getName()).log(Level.INFO, "initUserPointer() objectId = {0}", Long.toHexString(objectId));
+        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "initUserPointer() objectId = {0}", Long.toHexString(objectId));
         initUserPointer(objectId, collisionGroup, collisionGroupsMask);
     }
     native void initUserPointer(long objectId, int group, int groups);
@@ -320,7 +320,7 @@ public abstract class PhysicsCollisionObject implements Savable {
     @Override
     protected void finalize() throws Throwable {
         super.finalize();
-        Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Finalizing CollisionObject {0}", Long.toHexString(objectId));
+        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Finalizing CollisionObject {0}", Long.toHexString(objectId));
         finalizeNative(objectId);
     }
 
index 94d6ea4..73198e2 100644 (file)
@@ -80,7 +80,7 @@ public class BoxCollisionShape extends CollisionShape {
 
     protected void createShape() {
         objectId = createShape(halfExtents);
-        Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Created Shape {0}", Long.toHexString(objectId));
+        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created Shape {0}", Long.toHexString(objectId));
 //        cShape = new BoxShape(Converter.convert(halfExtents));
         setScale(scale);
         setMargin(margin);
index 2f5ccc5..5bb3f73 100644 (file)
@@ -106,7 +106,7 @@ public class CapsuleCollisionShape extends CollisionShape{
 
     protected void createShape(){
         objectId = createShape(axis, radius, height);
-        Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Created Shape {0}", Long.toHexString(objectId));
+        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created Shape {0}", Long.toHexString(objectId));
         setScale(scale);
         setMargin(margin);
 //        switch(axis){
index 81454ea..f9f00ee 100644 (file)
@@ -126,7 +126,7 @@ public abstract class CollisionShape implements Savable {
     @Override
     protected void finalize() throws Throwable {
         super.finalize();
-        Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Finalizing CollisionShape {0}", Long.toHexString(objectId));
+        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Finalizing CollisionShape {0}", Long.toHexString(objectId));
         finalizeNative(objectId);
     }
 
index 3e949bd..d18c097 100644 (file)
@@ -53,7 +53,7 @@ public class PlaneCollisionShape extends CollisionShape{
 
     protected void createShape() {
         objectId = createShape(plane.getNormal(), plane.getConstant());
-        Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Created Shape {0}", Long.toHexString(objectId));
+        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created Shape {0}", Long.toHexString(objectId));
 //        objectId = new StaticPlaneShape(Converter.convert(plane.getNormal()),plane.getConstant());
 //        objectId.setLocalScaling(Converter.convert(getScale()));
 //        objectId.setMargin(margin);
index 53164ef..f6a9878 100644 (file)
@@ -143,7 +143,7 @@ public abstract class PhysicsJoint implements Savable {
     @Override
     protected void finalize() throws Throwable {
         super.finalize();
-        Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Finalizing Joint {0}", Long.toHexString(objectId));
+        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Finalizing Joint {0}", Long.toHexString(objectId));
         finalizeNative(objectId);
     }
 
index 05d75df..2d500a3 100644 (file)
@@ -82,7 +82,7 @@ public class SixDofJoint extends PhysicsJoint {
         this.rotB = rotB;
 
         objectId = createJoint(nodeA.getObjectId(), nodeB.getObjectId(), pivotA, rotA, pivotB, rotB, useLinearReferenceFrameA);
-        Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Created Joint {0}", Long.toHexString(objectId));
+        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created Joint {0}", Long.toHexString(objectId));
         gatherMotors();
     }
 
@@ -97,7 +97,7 @@ public class SixDofJoint extends PhysicsJoint {
         rotB = new Matrix3f();
 
         objectId = createJoint(nodeA.getObjectId(), nodeB.getObjectId(), pivotA, rotA, pivotB, rotB, useLinearReferenceFrameA);
-        Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Created Joint {0}", Long.toHexString(objectId));
+        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created Joint {0}", Long.toHexString(objectId));
         gatherMotors();
     }
 
@@ -168,7 +168,7 @@ public class SixDofJoint extends PhysicsJoint {
         InputCapsule capsule = im.getCapsule(this);
 
         objectId = createJoint(nodeA.getObjectId(), nodeB.getObjectId(), pivotA, rotA, pivotB, rotB, useLinearReferenceFrameA);
-        Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Created Joint {0}", Long.toHexString(objectId));
+        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created Joint {0}", Long.toHexString(objectId));
         gatherMotors();
 
         setAngularUpperLimit((Vector3f) capsule.readSavable("angularUpperLimit", new Vector3f(Vector3f.POSITIVE_INFINITY)));
index 21e9bfc..01357f7 100644 (file)
@@ -98,12 +98,12 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
                 PhysicsSpace.getPhysicsSpace().remove(this);
                 removed = true;
             }
-            Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Clearing RigidBody {0}", Long.toHexString(objectId));
+            Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Clearing RigidBody {0}", Long.toHexString(objectId));
             finalizeNative(objectId);
         }
         preRebuild();
         objectId = createRigidBody(mass, motionState.getObjectId(), collisionShape.getObjectId());
-        Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Created RigidBody {0}", Long.toHexString(objectId));
+        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created RigidBody {0}", Long.toHexString(objectId));
         postRebuild();
         if (removed) {
             PhysicsSpace.getPhysicsSpace().add(this);
index c60d6c5..51087b0 100644 (file)
@@ -56,7 +56,7 @@ public class RigidBodyMotionState {
 
     public RigidBodyMotionState() {
         this.motionStateId = createMotionState();
-        Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Created MotionState {0}", Long.toHexString(motionStateId));
+        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created MotionState {0}", Long.toHexString(motionStateId));
     }
 
     private native long createMotionState();
@@ -155,7 +155,7 @@ public class RigidBodyMotionState {
     @Override
     protected void finalize() throws Throwable {
         super.finalize();
-        Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Finalizing MotionState {0}", Long.toHexString(motionStateId));
+        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Finalizing MotionState {0}", Long.toHexString(motionStateId));
         finalizeNative(motionStateId);
     }
 
index faaeed8..555c082 100644 (file)
@@ -92,6 +92,7 @@
 
             <class name="com.jme3.bullet.util.NativeMeshUtil"/>
             <class name="com.jme3.bullet.util.DebugShapeFactory"/>
+            <class name="projectkyoto.jme3.mmd.nativelib.SkinUtil"/>
         </javah>
     </target>
 
             <includepath path="${bullet.osx.java.include}"/>
             <includepath path="${bullet.bullet.include}"/>
             <compilerarg value="-syslibroot ${bullet.osx.syslibroot}"/>
-            <compilerarg value="-arch"/>
-            <compilerarg value="ppc"/>
+<!--            <compilerarg value="-arch"/>-->
+<!--            <compilerarg value="ppc"/>-->
             <compilerarg value="-arch"/>
             <compilerarg value="i386"/>
             <compilerarg value="-arch"/>
                 <libset dir="${bullet.folder}/src/BulletDynamics" libs="BulletDynamics"/>
                 <libset dir="${bullet.folder}/src/BulletCollision" libs="BulletCollision"/>
                 <libset dir="${bullet.folder}/src/LinearMath" libs="LinearMath"/>
-                <linkerarg value="-arch"/>
-                <linkerarg value="ppc"/>
+<!--                <linkerarg value="-arch"/>-->
+<!--                <linkerarg value="ppc"/>-->
                 <linkerarg value="-arch"/>
                 <linkerarg value="i386"/>
                 <linkerarg value="-arch"/>
index 88c2232..cd85e8b 100644 (file)
@@ -1,18 +1,18 @@
 ####################################################
 # these are the ant build properties for bullet-jme #
 #####################################################
-bullet.library.name=bulletjme64
+bullet.library.name=bulletjme
 bullet.library.version=0.9
 
 # change if bullet folder has different location
 # bullet.folder=../bullet-trunk
 #bullet.folder=c:/tmp/bullet-trunk.win32
 # bullet.folder=../bullet-trunk.linux
-# bullet.folder=../bullet-trunk.mac
+bullet.folder=../bullet-trunk.macosx2
 #bullet.folder=../bullet-trunk.solaris
-bullet.folder=../bullet-trunk.solaris64
+bullet.folder=../bullet-trunk.solaris64
 # compile options
-bullet.compile.debug=false
+bullet.compile.debug=false=
 
 # native library compilation options
 bullet.osx.compiler=g++
@@ -26,8 +26,8 @@ bullet.solaris.compiler=g++
 bullet.java.include=${java.home}/../include:${java.home}/../include/solaris
 # bullet.java.include=${java.home}/../include:${java.home}/../include/linux
 # OSX has no JRE, only JDK
-bullet.osx.java.include=${java.home}/include
-
+bullet.osx.java.include=${java.home}/include
+bullet.osx.java.include=/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers
 # dont change these..
 bullet.bullet.include=${bullet.folder}/src
 bullet.build.dir=build/bullet/
index 3b2901b..3ba4fc3 100644 (file)
@@ -56,12 +56,11 @@ extern "C" {
         return joint->getAppliedImpulse();
     }
     JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_PhysicsJoint_finalizeNative
-      (JNIEnv *env, jobject object, jlongjointId) {
+      (JNIEnv *env, jobject object, jlong jointId) {
         btTypedConstraint* joint = reinterpret_cast<btTypedConstraint*>(jointId);
         if (joint == NULL) {
             jclass newExc = env->FindClass("java/lang/NullPointerException");
             env->ThrowNew(newExc, "The native object does not exist.");
-            return 0;
         }
         delete joint;
     }
index 8779e16..f1343a5 100644 (file)
@@ -332,7 +332,7 @@ public final class Bone implements Savable {
      * world transform with this bones' local transform.
      */
     public final void updateWorldVectors() {
-        if (!useModelSpaceVectors) {
+        if (true || !useModelSpaceVectors) {
             if (parent != null) {
                 //rotation
                 parent.worldRot.mult(localRot, worldRot);
index b2a9a5a..3275394 100644 (file)
@@ -391,7 +391,7 @@ public class Material implements Asset, Cloneable, Savable, Comparable<Material>
     }
     public int getParamIndex(String name) {
         for(int i=paramValues.size()-1;i>=0;i--) {
-            if (name.equals(paramValues.getValue(i))) {
+            if (name.equals(paramValues.getKey(i))) {
                 return i;
             }
         }
index ce898be..7e2dc96 100644 (file)
@@ -953,7 +953,7 @@ public class RenderManager {
             viewWidth = (int) ((cam.getViewPortRight() - cam.getViewPortLeft()) * cam.getWidth());
             viewHeight = (int) ((cam.getViewPortTop() - cam.getViewPortBottom()) * cam.getHeight());
             renderer.setViewPort(viewX, viewY, viewWidth, viewHeight);
-            renderer.setClipRect(viewX, viewY, viewWidth, viewHeight);
+//            renderer.setClipRect(viewX, viewY, viewWidth, viewHeight);
             cam.clearViewportChanged();
             prevCam = cam;
 
index 628358c..d16c463 100644 (file)
@@ -672,12 +672,11 @@ public class Mesh implements Savable, Cloneable {
      * {@link #setInterleaved() interleaved} format.
      */
     public void updateCounts(){
-        if (getBuffer(Type.InterleavedData) != null)
-            throw new IllegalStateException("Should update counts before interleave");
-
+//        if (getBuffer(Type.InterleavedData) != null)
+//            throw new IllegalStateException("Should update counts before interleave");
         VertexBuffer pb = getBuffer(Type.Position);
         VertexBuffer ib = getBuffer(Type.Index);
-        if (pb != null){
+        if (pb != null && pb.getData() != null){
             vertCount = pb.getData().capacity() / pb.getNumComponents();
         }
         if (ib != null){
@@ -732,7 +731,9 @@ public class Mesh implements Savable, Cloneable {
     public int getVertexCount(){
         return vertCount;
     }
-
+    public void setVertCount(int vertCount) {
+        this.vertCount = vertCount;
+    }
     /**
      * Gets the triangle vertex positions at the given triangle index 
      * and stores them into the v1, v2, v3 arguments.
index e1b100f..83d7125 100644 (file)
@@ -478,6 +478,25 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
         this.lastLimit = data.limit();
         setUpdateNeeded();
     }
+    public void setupData(Usage usage, int components, Format format, int offset, int stride){
+        if (id != -1)
+            throw new UnsupportedOperationException("Data has already been sent. Cannot setupData again.");
+
+        if (usage == null || format == null || data == null)
+            throw new IllegalArgumentException("None of the arguments can be null");
+            
+        if (components < 1 || components > 4)
+            throw new IllegalArgumentException("components must be between 1 and 4");
+
+        this.data = data;
+        this.components = components;
+        this.usage = usage;
+        this.format = format;
+        this.componentsLength = components * format.getComponentSize();
+        this.offset = offset;
+        this.stride = stride;
+        setUpdateNeeded();
+    }
 
     /**
      * Called to update the data in the buffer with new data. Can only
@@ -929,4 +948,8 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
         }
     }
 
+    public int getComponentsLength() {
+        return componentsLength;
+    }
+
 }
index 299ec70..cc7d984 100644 (file)
@@ -53,16 +53,21 @@ public class ClasspathLocator implements AssetLocator {
 
     private static class ClasspathAssetInfo extends AssetInfo {
 
-        private URLConnection conn;
-
-        public ClasspathAssetInfo(AssetManager manager, AssetKey key, URLConnection conn){
+//        private URLConnection conn;
+        URL url;
+        public ClasspathAssetInfo(AssetManager manager, AssetKey key, URL url) throws IOException{
             super(manager, key);
-            this.conn = conn;
+            this.url = url;
+//            URLConnection conn = url.openConnection();
+//            conn.setUseCaches(false);
+//            this.conn = conn;
         }
 
         @Override
         public InputStream openStream() {
             try{
+            URLConnection conn = url.openConnection();
+            conn.setUseCaches(false);
                 return conn.getInputStream();
             }catch (IOException ex){
                 return null; // failure..
@@ -127,9 +132,9 @@ public class ClasspathLocator implements AssetLocator {
         }
         
         try{
-            URLConnection conn = url.openConnection();
-            conn.setUseCaches(false);
-            return new ClasspathAssetInfo(manager, key, conn);
+//            URLConnection conn = url.openConnection();
+//            conn.setUseCaches(false);
+            return new ClasspathAssetInfo(manager, key, url);
         }catch (IOException ex){
             throw new AssetLoadException("Failed to read URL " + url, ex);
         }