Subversion Repositories AndroidProjects

Rev

Rev 1111 | Rev 1120 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.gebauz.bauzoid.math.collision;

import java.util.Vector;

import com.gebauz.bauzoid.game.Game;
import com.gebauz.bauzoid.game.GameObject;
import com.gebauz.bauzoid.graphics.Graphics;
import com.gebauz.bauzoid.graphics.sprite.SpriteTransform;
import com.gebauz.bauzoid.math.Vector2;

/** Collection of shape elements that form a complex shape. */
public class Shape extends GameObject
{

        // Constants========================================================================================

        // Embedded Types===================================================================================

        // Fields===========================================================================================
       
        private ShapeData mShapeData = null;
       
        private String mShapeFile = null;
        private boolean mIsAsync = false;
       
        public SpriteTransform transform = new SpriteTransform();

        // Methods==========================================================================================

        public Shape(Game game, String shapeFile)
        {
                super(game);
                mShapeFile = shapeFile;
        }
       
        public void initAsync()
        {
                mIsAsync = true;
               
                getAssetManager().load(mShapeFile, ShapeData.class, new ShapeDataAsyncLoader.ShapeDataParameter(this));
        }
       
        public void init()
        {
                if (!mIsAsync)
                {
                        mShapeData = ShapeUtil.createShapeFromFile(this, mShapeFile);
                }
                else
                {
                        mShapeData = getAssetManager().get(mShapeFile, ShapeData.class);
                }
        }
       
        /** Calculate the untransformed convex hull of the shape element group. */
        public void calculateConvexHull()
        {
                Vector<Vector2> points = new Vector<Vector2>();
               
               
        }
       
        /** Render debug output. */
        public void renderDebug(Graphics graphics, SpriteTransform t)
        {
                for (int i = 0; i < mShapeData.getShapeElementCount(); i++)
                {
                        mShapeData.getShapeElement(i).renderDebug(graphics, t);
                }
        }
       
        // Getters/Setters==================================================================================
       
        public final BaseShapeElement getShapeElement(int i)
        {
                return mShapeData.getShapeElement(i);
        }
       
        public final int getShapeElementCount()
        {
                return mShapeData.getShapeElementCount();
        }
       
}