package tools;

import static org.anddev.andengine.extension.physics.box2d.util.constants.PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT;

import org.anddev.andengine.entity.shape.Shape;
import org.anddev.andengine.extension.physics.box2d.PhysicsFactory;
import org.anddev.andengine.extension.physics.box2d.PhysicsWorld;

import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
/** Utility class for creating physical shapes for the tiles **/
public class ShapeCreator {
	
	
	public static Body createShape(final PhysicsWorld mPhysicsWorld, final Shape tile, final BodyType pBodyType, final FixtureDef fixtureDef, final String tileProperty)
	{
		Body bodyResult = null;
		
		if( tileProperty.equals("box"))        	               
			bodyResult = PhysicsFactory.createBoxBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        /* MID-BOXES */
        if( tileProperty.equals("midboxBottom"))        	               
        	bodyResult = ShapeCreator.createMidBoxBottomBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("midboxLeft"))        	               
        	bodyResult = ShapeCreator.createMidBoxLeftBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("midboxUp"))        	               
        	bodyResult = ShapeCreator.createMidBoxUpBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("midboxRight"))        	               
        	bodyResult = ShapeCreator.createMidBoxRightBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
               	                        
        
        /* 45 degree ramps */
        if( tileProperty.equals("45r-d"))        	               
        	bodyResult = ShapeCreator.create45rightDownBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
       
        if( tileProperty.equals("45l-d"))        	               
        	bodyResult = ShapeCreator.create45leftDownBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("45l-u"))        	               
        	bodyResult = ShapeCreator.create45leftUpBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("45r-u"))        	               
        	bodyResult = ShapeCreator.create45rightUpBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
       
    
        /* 30 degree ramps */
        if( tileProperty.equals("301r-d"))        	               
        	bodyResult = ShapeCreator.create301rightDownBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("302r-d"))        	               
        	bodyResult = ShapeCreator.create302rightDownBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("301l-d"))        	               
        	bodyResult = ShapeCreator.create301leftDownBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("302l-d"))        	               
        	bodyResult = ShapeCreator.create302leftDownBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("301l-u"))        	               
        	bodyResult = ShapeCreator.create301leftUpBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("302l-u"))        	               
        	bodyResult = ShapeCreator.create302leftUpBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("301r-u"))        	               
        	bodyResult = ShapeCreator.create301rightUpBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("302r-u"))        	               
        	bodyResult = ShapeCreator.create302rightUpBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        /* 60 degree ramps */
        if( tileProperty.equals("601r-d"))        	               
        	bodyResult = ShapeCreator.create601rightDownBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("602r-d"))        	               
        	bodyResult = ShapeCreator.create602rightDownBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("601l-d"))        	               
        	bodyResult = ShapeCreator.create601leftDownBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("602l-d"))        	               
        	bodyResult = ShapeCreator.create602leftDownBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("601l-u"))        	               
        	bodyResult = ShapeCreator.create601leftUpBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("602l-u"))        	               
        	bodyResult = ShapeCreator.create602leftUpBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("601r-u"))        	               
        	bodyResult = ShapeCreator.create601rightUpBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("602r-u"))        	               
        	bodyResult = ShapeCreator.create602rightUpBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        // Triangles (use for spikes for instance)
        
        if( tileProperty.equals("triangledown"))        	               
        	bodyResult = ShapeCreator.createTriangleDownBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("triangleup"))        	               
        	bodyResult = ShapeCreator.createTriangleUpBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("triangleleft"))        	               
        	bodyResult = ShapeCreator.createTriangleLeftBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
        
        if( tileProperty.equals("triangleright"))        	               
        	bodyResult = ShapeCreator.createTriangleRightBody(mPhysicsWorld, tile, BodyType.StaticBody, fixtureDef);
		
		return bodyResult;
	}

	/**
     * Creates a {@link Body} based on a {@link PolygonShape} in the form of a triangle:
     * <pre>
     *  /\
     * /__\
     * </pre>
     */
    public static Body createTriangleBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
            /* Remember that the vertices are relative to the center-coordinates of the Shape. */
    		/********************tocado el valor del float, era 0.5f******/
            final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
            final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

            final float top = -halfHeight;
            final float bottom = halfHeight;
            final float left = -halfHeight;
            final float centerX = 0;
            final float right = halfWidth;

            final Vector2[] vertices = {
                            new Vector2(centerX, top),
                            new Vector2(right, bottom),
                            new Vector2(left, bottom)
            };

            Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
            aux.setUserData(pFixtureDef);

            return aux;
    }
    
    /**
     * Creates a {@link Body} based on a {@link PolygonShape} in the form of a hexagon:
     * <pre>
     *  /\
     * /  \
     * |  |
     * |  |
     * \  /
     *  \/
     * </pre>
     */
    public static Body createHexagonBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
            /* Remember that the vertices are relative to the center-coordinates of the Shape. */
    		/********************tocado el valor del float, era 0.5f******/
            final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
            final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

            /* The top and bottom vertex of the hexagon are on the bottom and top of hexagon-sprite. */
            final float top = -halfHeight;
            final float bottom = halfHeight;

            final float centerX = 0;

            /* The left and right vertices of the heaxgon are not on the edge of the hexagon-sprite, so we need to inset them a little. */
            final float left = -halfWidth + 2.5f / PIXEL_TO_METER_RATIO_DEFAULT;
            final float right = halfWidth - 2.5f / PIXEL_TO_METER_RATIO_DEFAULT;
            final float higher = top + 8.25f / PIXEL_TO_METER_RATIO_DEFAULT;
            final float lower = bottom - 8.25f / PIXEL_TO_METER_RATIO_DEFAULT;

            final Vector2[] vertices = {
                            new Vector2(centerX, top),
                            new Vector2(right, higher),
                            new Vector2(right, lower),
                            new Vector2(centerX, bottom),
                            new Vector2(left, lower),
                            new Vector2(left, higher)
            };
            
            Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
            aux.setUserData(pFixtureDef);

            return aux;
    }
    
    /** 45º **/
    private static Body create45leftDownBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************45 degree ramp to the left and down******/
    	/**
    	 *       /| 
    	 *     /  |
    	 *   /____|
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        
        final Vector2[] vertices = {
                new Vector2(right, top),
                new Vector2(right, bottom),
                new Vector2(left, bottom)
        };

        

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }
          
    private static Body create45rightUpBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************Create a 45 degree ramp to the right and up******/
    	/** -------
    	 *  |    /
    	 *  |  /
    	 *  |/
    	 */	
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        
        final Vector2[] vertices = {
                new Vector2(left, top),
                new Vector2(right, top),
                new Vector2(left, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }
    
    private static Body create45leftUpBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************Create a 45 degree ramp to the left and up******/
    	/** ------
    	 *  \    |
    	 *    \	 |
    	 *      \|
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        
        final Vector2[] vertices = {
                new Vector2(left, top),
                new Vector2(right, top),
                new Vector2(right, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }
    
    private static Body create45rightDownBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************Create a 45 degree ramp to the right and down******/
    	/** |\ 
    	 * 	|  \
    	 * 	|____\
    	 */	
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        
        final Vector2[] vertices = {
                new Vector2(left, top),
                new Vector2(right, bottom),
                new Vector2(left, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }
    
    /** MIX-BOXES **/
    private static Body createMidBoxBottomBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************Create a mid box from the bottom******/
    	/**  
    	 * 	|-----|
    	 * 	|_____|
    	 */	
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        final float centerY = 0;
                    
        final Vector2[] vertices = {
                new Vector2(left, centerY),
                new Vector2(right, centerY),
                new Vector2(right, bottom), 
                new Vector2(left, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }        
    private static Body createMidBoxLeftBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************Create a mid box from the left******/
    	/**  ______
    	 *  |    |
    	 *  |    |
    	 * 	|    |
    	 * 	|____|_
    	 */	
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float centerX = 0;
                    
        final Vector2[] vertices = {
                new Vector2(left, top),
                new Vector2(centerX, top),
                new Vector2(centerX, bottom), 
                new Vector2(left, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }        
    private static Body createMidBoxUpBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************Create a mid box from the roof******/
    	/**  ________
    	 *  |        |
    	 *  |________|
    	 * 	|        |
    	 * 	        
    	 */	
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        final float centerY = 0;
                    
        final Vector2[] vertices = {
                new Vector2(left, top),
                new Vector2(right, top),
                new Vector2(right, centerY), 
                new Vector2(left, centerY)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }        
    private static Body createMidBoxRightBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************Create a mid box from the right******/
    	/**    ______
    	 *      |    |
    	 *      |    |
    	 * 	    |    |
    	 * 	   _|____|
    	 */	
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float right = halfWidth;
        final float centerX = 0;
                    
        final Vector2[] vertices = {
                new Vector2(centerX, top),
                new Vector2(right, top),
                new Vector2(right, bottom), 
                new Vector2(centerX, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }
    
    /** 30º **/
    private static Body create301leftDownBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************first of 30 degree ramp to the left/down******/
    	/**
    	 *          <
    	 *    <      |
    	 *   |       |
    	 *   |_______|
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        final float centerY = 0;
        
        final Vector2[] vertices = {
                new Vector2(right, top),
                new Vector2(right, bottom),
                new Vector2(left, bottom), 
                new Vector2(left, centerY)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }        
    private static Body create302leftDownBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************second of 30 degree ramp to the left/down******/
    	/**
    	 *     
    	 *         
    	 *         <|
    	 *   <______|
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        final float centerY = 0;
        
        final Vector2[] vertices = {
                new Vector2(right, centerY),
                new Vector2(right, bottom),
                new Vector2(left, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }        
    private static Body create301rightDownBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************first of 30 degree ramp to the right/down******/
    	/**
    	 *   |>
    	 *   |      >
    	 *   |       |
    	 *   |_______|
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        final float centerY = 0;
        
        final Vector2[] vertices = {
                new Vector2(left, top),
                new Vector2(right, centerY),
                new Vector2(right, bottom), 
                new Vector2(left, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }     
    private static Body create302rightDownBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************second of 30 degree ramp to the right/down******/
    	/**
    	 *     
    	 *   |>    
    	 *   |______>
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        final float centerY = 0;
        
        final Vector2[] vertices = {
                new Vector2(left, centerY),
                new Vector2(right, bottom),
                new Vector2(left, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }        
    
    
    private static Body create301leftUpBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************first of 30 degree ramp to the left/up******/
    	/** _______
    	 *  |     |
    	 *  <     |
    	 *        <
    	 */
    	
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        final float centerY = 0;
        
        final Vector2[] vertices = {
                new Vector2(right, top),
                new Vector2(right, bottom),
                new Vector2(left, centerY), 
                new Vector2(left, top)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }        
    private static Body create302leftUpBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************second of 30 degree ramp to the left/up******/
    	/**
    	 *     _______
    	 *     <     |
    	 *           <      
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        final float centerY = 0;
        
        final Vector2[] vertices = {
                new Vector2(left, top),
                new Vector2(right, top),
                new Vector2(right, centerY)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }        
    private static Body create301rightUpBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************first of 30 degree ramp to the right/up******/
    	/** ______
    	 * |      |
    	 * |      >
    	 *  >
    	 *   
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        final float centerY = 0;
        
        final Vector2[] vertices = {
                new Vector2(left, top),
                new Vector2(right, top),
                new Vector2(right, centerY), 
                new Vector2(left, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }        
    private static Body create302rightUpBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************second of 30 degree ramp to the right/up******/
    	/**  _______
    	 *  |      >
    	 *  |>
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        final float centerY = 0;
        
        final Vector2[] vertices = {
                new Vector2(left, top),
                new Vector2(right, top),
                new Vector2(left, centerY)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }
    
    
    
    /** 60º **/
    private static Body create601leftDownBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************first of 60 degree ramp to the left/down******/
    	/**       ____
    	 *   	 /    |
    	 *      /     | 
    	 *     /      | 
    	 *    /_______|
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        final float centerX = 0;
        
        final Vector2[] vertices = {
                new Vector2(centerX, top),
                new Vector2(right, top),
                new Vector2(right, bottom), 
                new Vector2(left, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }
    private static Body create602leftDownBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************second of 60 degree ramp to the left/down******/
    	/**
    	 *         /|
    	 *        / |
    	 *       /  |
    	 *      /___|
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float right = halfWidth;
        final float centerX = 0;
        
        final Vector2[] vertices = {
                new Vector2(right, top),
                new Vector2(right, bottom),
                new Vector2(centerX, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }
    private static Body create601rightDownBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************first of 60 degree ramp to the right/down******/
    	/**   ____
    	 *   |    \
    	 *   |     \      
    	 *   |      \
    	 *   |_______\
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        final float centerX = 0;
        
        final Vector2[] vertices = {
                new Vector2(left, top),
                new Vector2(centerX, top),
                new Vector2(right, bottom), 
                new Vector2(left, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }
    private static Body create602rightDownBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {        
    	 /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************second of 60 degree ramp to the right/down******/
    	/**  |\
    	 *   | \
    	 *   |  \
    	 *   |___\
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float centerX = 0;
        
        final Vector2[] vertices = {
                new Vector2(left, top),
                new Vector2(centerX, bottom),
                new Vector2(left, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }
    private static Body create601leftUpBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************first of 60 degree ramp to the left/up******/
    	/**  _________
    	 *   \        |
    	 *    \       |
    	 *     \      |
    	 *      \_____|
    	 *    
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        final float centerX = 0;
        
        final Vector2[] vertices = {
                new Vector2(left, top),
                new Vector2(right, top),
                new Vector2(right, bottom), 
                new Vector2(centerX, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }
    private static Body create602leftUpBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************second of 60 degree ramp to the left/up******/
    	/**     ____
    	 *      \   |
    	 *       \  |
    	 *        \ |
    	 *         \|     
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float right = halfWidth;
        final float centerX = 0;
        
        final Vector2[] vertices = {
                new Vector2(centerX, top),
                new Vector2(right, top),
                new Vector2(right, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }
    private static Body create601rightUpBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
        /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************first of 60 degree ramp to the right/up******/
    	/**    ______
    	 *    |     /
    	 *    |    /
    	 *    |___/
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;
        final float centerX = 0;
        
        final Vector2[] vertices = {
                new Vector2(left, top),
                new Vector2(right, top),
                new Vector2(centerX, bottom), 
                new Vector2(left, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }
    private static Body create602rightUpBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {        
    	 /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		/********************second of 60 degree ramp to the right/down******/
    	/**  ____
    	 *   |  /
    	 *   | /
    	 *   |/
    	 */
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float centerX = 0;
        
        final Vector2[] vertices = {
                new Vector2(left, top),
                new Vector2(centerX, top),
                new Vector2(left, bottom)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }
    
    
    private static Body createTriangleUpBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {        
   	 /* Remember that the vertices are relative to the center-coordinates of the Shape. */
		
   	/**     /\
   	 *     /  \
   	 *    /    \
   	 *   /______\
   	 */
       final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
       final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

       final float top = -halfHeight;
       final float bottom = halfHeight;
       final float left = -halfWidth;
       final float right = halfWidth;
       final float centerX = 0;
       
       final Vector2[] vertices = {
               new Vector2(centerX, top),
               new Vector2(right, bottom),
               new Vector2(left, bottom)
       };

       Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
       aux.setUserData(pFixtureDef);

       return aux;
   }
    
    private static Body createTriangleDownBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {        
      	 /* Remember that the vertices are relative to the center-coordinates of the Shape. */
   		
      	/**    _________
      	 *     \       /
      	 *      \     /
      	 *       \   /
      	 *        \ /
      	 */        
    	
          final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
          final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

          final float top = -halfHeight;
          final float bottom = halfHeight;
          final float left = -halfWidth;
          final float right = halfWidth;
          final float centerX = 0;
          
          final Vector2[] vertices = {
                  new Vector2(left, top),
                  new Vector2(right, top),
                  new Vector2(centerX, bottom)
          };

          Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
          aux.setUserData(pFixtureDef);

          return aux;
      }
    
    private static Body createTriangleRightBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {        
     	 /* Remember that the vertices are relative to the center-coordinates of the Shape. */
  		
     	/**    1 
     	 *     1 1 
     	 *     1 1 1    
     	 *     1 1   
     	 *     1 
     	 *     
     	 */       
   	
         final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
         final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

         final float top = -halfHeight;
         final float bottom = halfHeight;
         final float left = -halfWidth;
         final float right = halfWidth;   
         final float centerY = 0;
         
         final Vector2[] vertices = {
                 new Vector2(left, top),
                 new Vector2(right, centerY),
                 new Vector2(left, bottom)
         };

         Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
         aux.setUserData(pFixtureDef);

         return aux;
     }
    
    private static Body createTriangleLeftBody(final PhysicsWorld pPhysicsWorld, final Shape pShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {        
    	 /* Remember that the vertices are relative to the center-coordinates of the Shape. */
 		
    	/**     
    	 *         1
    	 *       1 1 
    	 *     1 1 1
    	 *       1 1
    	 *         1
    	 */       
  	
        final float halfWidth = pShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
        final float halfHeight = pShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;

        final float top = -halfHeight;
        final float bottom = halfHeight;
        final float left = -halfWidth;
        final float right = halfWidth;   
        final float centerY = 0;
        
        final Vector2[] vertices = {
                new Vector2(right, top),
                new Vector2(right, bottom),
                new Vector2(left, centerY)
        };

        Body aux = PhysicsFactory.createPolygonBody(pPhysicsWorld, pShape, vertices, pBodyType, pFixtureDef);
        aux.setUserData(pFixtureDef);

        return aux;
    }
    
    
	
}
