Advertisement
dermetfan

xtend-gen/net/dermetfan/libgdx/box2d/Box2DUtils.java

Aug 23rd, 2013
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 20.35 KB | None | 0 0
  1. /**
  2.  * Copyright 2013 Robin Stumm (serverkorken@googlemail.com, http://dermetfan.bplaced.net)
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *     http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */
  16. package net.dermetfan.libgdx.box2d;
  17.  
  18. import com.badlogic.gdx.math.Vector2;
  19. import com.badlogic.gdx.physics.box2d.Body;
  20. import com.badlogic.gdx.physics.box2d.ChainShape;
  21. import com.badlogic.gdx.physics.box2d.CircleShape;
  22. import com.badlogic.gdx.physics.box2d.EdgeShape;
  23. import com.badlogic.gdx.physics.box2d.Fixture;
  24. import com.badlogic.gdx.physics.box2d.PolygonShape;
  25. import com.badlogic.gdx.physics.box2d.Shape;
  26. import com.badlogic.gdx.physics.box2d.Shape.Type;
  27. import com.badlogic.gdx.physics.box2d.Transform;
  28. import com.google.common.base.Objects;
  29. import java.io.Serializable;
  30. import java.util.ArrayList;
  31. import net.dermetfan.libgdx.math.GeometryUtils;
  32. import org.eclipse.xtext.xbase.lib.Conversions;
  33. import org.eclipse.xtext.xbase.lib.ExclusiveRange;
  34.  
  35. /**
  36.  * provides methods for geometric operations with Box2D fodies, fixtures and shapes
  37.  */
  38. @SuppressWarnings("all")
  39. public class Box2DUtils {
  40.   /**
  41.    * @return the vertices of all fixtures of the given body
  42.    *  @see {@link #vertices(Shape)}
  43.    */
  44.   public static Vector2[] vertices(final Body body) {
  45.     Vector2[] _xblockexpression = null;
  46.     {
  47.       ArrayList<Fixture> _fixtureList = body.getFixtureList();
  48.       int _length = ((Object[])Conversions.unwrapArray(_fixtureList, Object.class)).length;
  49.       final Serializable[] fixtureVertices = new Serializable[_length];
  50.       int _length_1 = fixtureVertices.length;
  51.       ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _length_1, true);
  52.       for (final Integer it : _doubleDotLessThan) {
  53.         ArrayList<Fixture> _fixtureList_1 = body.getFixtureList();
  54.         Fixture _get = _fixtureList_1.get((it).intValue());
  55.         Vector2[] _vertices = Box2DUtils.vertices(_get);
  56.         fixtureVertices[(it).intValue()] = _vertices;
  57.       }
  58.       int vertexCount = 0;
  59.       int fvi = (-1);
  60.       ArrayList<Fixture> _fixtureList_2 = body.getFixtureList();
  61.       for (final Fixture fixture : _fixtureList_2) {
  62.         Shape _shape = fixture.getShape();
  63.         Type _type = _shape.getType();
  64.         boolean _equals = Objects.equal(_type, Type.Circle);
  65.         if (_equals) {
  66.           int _plus = (vertexCount + 4);
  67.           vertexCount = _plus;
  68.         } else {
  69.           int _plus_1 = (fvi + 1);
  70.           int _fvi = fvi = _plus_1;
  71.           Serializable _get_1 = fixtureVertices[_fvi];
  72.           int _length_2 = ((Vector2[]) _get_1).length;
  73.           int _plus_2 = (vertexCount + _length_2);
  74.           vertexCount = _plus_2;
  75.         }
  76.       }
  77.       final Vector2[] vertices = new Vector2[vertexCount];
  78.       fvi = 0;
  79.       int vi = (-1);
  80.       ArrayList<Fixture> _fixtureList_3 = body.getFixtureList();
  81.       for (final Fixture fixture_1 : _fixtureList_3) {
  82.         int _plus_3 = (fvi + 1);
  83.         int _fvi_1 = fvi = _plus_3;
  84.         Serializable _get_2 = fixtureVertices[_fvi_1];
  85.         for (final Vector2 vertice : ((Vector2[]) _get_2)) {
  86.           int _plus_4 = (vi + 1);
  87.           int _vi = vi = _plus_4;
  88.           vertices[_vi] = vertice;
  89.         }
  90.       }
  91.       _xblockexpression = (vertices);
  92.     }
  93.     return _xblockexpression;
  94.   }
  95.  
  96.   /**
  97.    * @see {@link #vertices(Shape)}
  98.    */
  99.   public static Vector2[] vertices(final Fixture fixture) {
  100.     Shape _shape = fixture.getShape();
  101.     Vector2[] _vertices = Box2DUtils.vertices(_shape);
  102.     return _vertices;
  103.   }
  104.  
  105.   /**
  106.    * @return the vertices of the given Shape
  107.    */
  108.   public static Vector2[] vertices(final Shape shape) {
  109.     Vector2[] _xblockexpression = null;
  110.     {
  111.       Vector2[] vertices = null;
  112.       Type _type = shape.getType();
  113.       final Type _switchValue = _type;
  114.       boolean _matched = false;
  115.       if (!_matched) {
  116.         if (Objects.equal(_switchValue,Type.Polygon)) {
  117.           _matched=true;
  118.           final PolygonShape polygonShape = ((PolygonShape) shape);
  119.           int _vertexCount = polygonShape.getVertexCount();
  120.           Vector2[] _newArrayOfSize = new Vector2[_vertexCount];
  121.           vertices = _newArrayOfSize;
  122.           int _length = vertices.length;
  123.           ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _length, true);
  124.           for (final Integer it : _doubleDotLessThan) {
  125.             {
  126.               Vector2 _vector2 = new Vector2();
  127.               vertices[(it).intValue()] = _vector2;
  128.               Vector2 _get = vertices[(it).intValue()];
  129.               polygonShape.getVertex((it).intValue(), _get);
  130.             }
  131.           }
  132.         }
  133.       }
  134.       if (!_matched) {
  135.         if (Objects.equal(_switchValue,Type.Edge)) {
  136.           _matched=true;
  137.           final EdgeShape edgeShape = ((EdgeShape) shape);
  138.           Vector2 _vector2 = new Vector2();
  139.           final Vector2 vertex1 = _vector2;
  140.           Vector2 _vector2_1 = new Vector2();
  141.           final Vector2 vertex2 = _vector2_1;
  142.           edgeShape.getVertex1(vertex1);
  143.           edgeShape.getVertex2(vertex2);
  144.           vertices = new Vector2[] { vertex1, vertex2 };
  145.         }
  146.       }
  147.       if (!_matched) {
  148.         if (Objects.equal(_switchValue,Type.Chain)) {
  149.           _matched=true;
  150.           final ChainShape chainShape = ((ChainShape) shape);
  151.           int _vertexCount_1 = chainShape.getVertexCount();
  152.           Vector2[] _newArrayOfSize_1 = new Vector2[_vertexCount_1];
  153.           vertices = _newArrayOfSize_1;
  154.           int _length_1 = vertices.length;
  155.           ExclusiveRange _doubleDotLessThan_1 = new ExclusiveRange(0, _length_1, true);
  156.           for (final Integer it_1 : _doubleDotLessThan_1) {
  157.             {
  158.               Vector2 _vector2_2 = new Vector2();
  159.               vertices[(it_1).intValue()] = _vector2_2;
  160.               Vector2 _get = vertices[(it_1).intValue()];
  161.               chainShape.getVertex((it_1).intValue(), _get);
  162.             }
  163.           }
  164.         }
  165.       }
  166.       if (!_matched) {
  167.         if (Objects.equal(_switchValue,Type.Circle)) {
  168.           _matched=true;
  169.           final CircleShape circleShape = ((CircleShape) shape);
  170.           Vector2 _positionRelative = Box2DUtils.positionRelative(circleShape);
  171.           float _radius = circleShape.getRadius();
  172.           float _minus = (_positionRelative.x - _radius);
  173.           Vector2 _positionRelative_1 = Box2DUtils.positionRelative(circleShape);
  174.           float _radius_1 = circleShape.getRadius();
  175.           float _plus = (_positionRelative_1.y + _radius_1);
  176.           Vector2 _vector2_2 = new Vector2(_minus, _plus);
  177.           Vector2 _positionRelative_2 = Box2DUtils.positionRelative(circleShape);
  178.           float _radius_2 = circleShape.getRadius();
  179.           float _minus_1 = (_positionRelative_2.x - _radius_2);
  180.           Vector2 _positionRelative_3 = Box2DUtils.positionRelative(circleShape);
  181.           float _radius_3 = circleShape.getRadius();
  182.           float _minus_2 = (_positionRelative_3.y - _radius_3);
  183.           Vector2 _vector2_3 = new Vector2(_minus_1, _minus_2);
  184.           Vector2 _positionRelative_4 = Box2DUtils.positionRelative(circleShape);
  185.           float _radius_4 = circleShape.getRadius();
  186.           float _plus_1 = (_positionRelative_4.x + _radius_4);
  187.           Vector2 _positionRelative_5 = Box2DUtils.positionRelative(circleShape);
  188.           float _radius_5 = circleShape.getRadius();
  189.           float _minus_3 = (_positionRelative_5.y - _radius_5);
  190.           Vector2 _vector2_4 = new Vector2(_plus_1, _minus_3);
  191.           Vector2 _positionRelative_6 = Box2DUtils.positionRelative(circleShape);
  192.           float _radius_6 = circleShape.getRadius();
  193.           float _plus_2 = (_positionRelative_6.x + _radius_6);
  194.           Vector2 _positionRelative_7 = Box2DUtils.positionRelative(circleShape);
  195.           float _radius_7 = circleShape.getRadius();
  196.           float _plus_3 = (_positionRelative_7.y + _radius_7);
  197.           Vector2 _vector2_5 = new Vector2(_plus_2, _plus_3);
  198.           vertices = new Vector2[] { _vector2_2, _vector2_3, _vector2_4, _vector2_5 };
  199.         }
  200.       }
  201.       if (!_matched) {
  202.         Type _type_1 = shape.getType();
  203.         String _name = _type_1.name();
  204.         String _plus_4 = ("Shapes of the type \'" + _name);
  205.         String _plus_5 = (_plus_4 + "\' are not supported");
  206.         IllegalArgumentException _illegalArgumentException = new IllegalArgumentException(_plus_5);
  207.         throw _illegalArgumentException;
  208.       }
  209.       _xblockexpression = (vertices);
  210.     }
  211.     return _xblockexpression;
  212.   }
  213.  
  214.   /**
  215.    * @return the minimal x value of the vertices of all fixtures of the the given Body
  216.    */
  217.   public static float minX(final Body body) {
  218.     float _xblockexpression = (float) 0;
  219.     {
  220.       float x = Float.POSITIVE_INFINITY;
  221.       float tmp = 0;
  222.       ArrayList<Fixture> _fixtureList = body.getFixtureList();
  223.       for (final Fixture fixture : _fixtureList) {
  224.         float _xifexpression = (float) 0;
  225.         float _minX = Box2DUtils.minX(fixture);
  226.         float _tmp = tmp = _minX;
  227.         boolean _lessThan = (_tmp < x);
  228.         if (_lessThan) {
  229.           _xifexpression = tmp;
  230.         } else {
  231.           _xifexpression = x;
  232.         }
  233.         x = _xifexpression;
  234.       }
  235.       _xblockexpression = (x);
  236.     }
  237.     return _xblockexpression;
  238.   }
  239.  
  240.   /**
  241.    * @return the minimal y value of the vertices of all fixtures of the the given Body
  242.    */
  243.   public static float minY(final Body body) {
  244.     float _xblockexpression = (float) 0;
  245.     {
  246.       float y = Float.POSITIVE_INFINITY;
  247.       float tmp = 0;
  248.       ArrayList<Fixture> _fixtureList = body.getFixtureList();
  249.       for (final Fixture fixture : _fixtureList) {
  250.         float _xifexpression = (float) 0;
  251.         float _minY = Box2DUtils.minY(fixture);
  252.         float _tmp = tmp = _minY;
  253.         boolean _lessThan = (_tmp < y);
  254.         if (_lessThan) {
  255.           _xifexpression = tmp;
  256.         } else {
  257.           _xifexpression = y;
  258.         }
  259.         y = _xifexpression;
  260.       }
  261.       _xblockexpression = (y);
  262.     }
  263.     return _xblockexpression;
  264.   }
  265.  
  266.   /**
  267.    * @return the maximal x value of the vertices of all fixtures of the the given Body
  268.    */
  269.   public static float maxX(final Body body) {
  270.     float _xblockexpression = (float) 0;
  271.     {
  272.       float x = Float.NEGATIVE_INFINITY;
  273.       float tmp = 0;
  274.       ArrayList<Fixture> _fixtureList = body.getFixtureList();
  275.       for (final Fixture fixture : _fixtureList) {
  276.         float _xifexpression = (float) 0;
  277.         float _maxX = Box2DUtils.maxX(fixture);
  278.         float _tmp = tmp = _maxX;
  279.         boolean _greaterThan = (_tmp > x);
  280.         if (_greaterThan) {
  281.           _xifexpression = tmp;
  282.         } else {
  283.           _xifexpression = x;
  284.         }
  285.         x = _xifexpression;
  286.       }
  287.       _xblockexpression = (x);
  288.     }
  289.     return _xblockexpression;
  290.   }
  291.  
  292.   /**
  293.    * @return the maximal y value of the vertices of all fixtures of the the given Body
  294.    */
  295.   public static float maxY(final Body body) {
  296.     float _xblockexpression = (float) 0;
  297.     {
  298.       float y = Float.NEGATIVE_INFINITY;
  299.       float tmp = 0;
  300.       ArrayList<Fixture> _fixtureList = body.getFixtureList();
  301.       for (final Fixture fixture : _fixtureList) {
  302.         float _xifexpression = (float) 0;
  303.         float _maxY = Box2DUtils.maxY(fixture);
  304.         float _tmp = tmp = _maxY;
  305.         boolean _greaterThan = (_tmp > y);
  306.         if (_greaterThan) {
  307.           _xifexpression = tmp;
  308.         } else {
  309.           _xifexpression = y;
  310.         }
  311.         y = _xifexpression;
  312.       }
  313.       _xblockexpression = (y);
  314.     }
  315.     return _xblockexpression;
  316.   }
  317.  
  318.   /**
  319.    * @return the minimal x value of the vertices of the given Fixture
  320.    */
  321.   public static float minX(final Fixture fixture) {
  322.     Vector2[] _vertices = Box2DUtils.vertices(fixture);
  323.     float[] _filterX = GeometryUtils.filterX(_vertices);
  324.     float _min = GeometryUtils.min(_filterX);
  325.     return _min;
  326.   }
  327.  
  328.   /**
  329.    * @return the minimal y value of the vertices of the given Fixture
  330.    */
  331.   public static float minY(final Fixture fixture) {
  332.     Vector2[] _vertices = Box2DUtils.vertices(fixture);
  333.     float[] _filterY = GeometryUtils.filterY(_vertices);
  334.     float _min = GeometryUtils.min(_filterY);
  335.     return _min;
  336.   }
  337.  
  338.   /**
  339.    * @return the maximal x value of the vertices of the given Fixture
  340.    */
  341.   public static float maxX(final Fixture fixture) {
  342.     Vector2[] _vertices = Box2DUtils.vertices(fixture);
  343.     float[] _filterX = GeometryUtils.filterX(_vertices);
  344.     float _max = GeometryUtils.max(_filterX);
  345.     return _max;
  346.   }
  347.  
  348.   /**
  349.    * @return the maximal y value of the vertices of the given Fixture
  350.    */
  351.   public static float maxY(final Fixture fixture) {
  352.     Vector2[] _vertices = Box2DUtils.vertices(fixture);
  353.     float[] _filterY = GeometryUtils.filterY(_vertices);
  354.     float _max = GeometryUtils.max(_filterY);
  355.     return _max;
  356.   }
  357.  
  358.   /**
  359.    * @return the width of the given Body
  360.    */
  361.   public static float width(final Body body) {
  362.     float _xblockexpression = (float) 0;
  363.     {
  364.       float min = Float.POSITIVE_INFINITY;
  365.       float max = Float.NEGATIVE_INFINITY;
  366.       float tmp = 0;
  367.       ArrayList<Fixture> _fixtureList = body.getFixtureList();
  368.       for (final Fixture fixture : _fixtureList) {
  369.         {
  370.           float _xifexpression = (float) 0;
  371.           float _minX = Box2DUtils.minX(fixture);
  372.           float _tmp = tmp = _minX;
  373.           boolean _lessThan = (_tmp < min);
  374.           if (_lessThan) {
  375.             _xifexpression = tmp;
  376.           } else {
  377.             _xifexpression = min;
  378.           }
  379.           min = _xifexpression;
  380.           float _xifexpression_1 = (float) 0;
  381.           float _maxX = Box2DUtils.maxX(fixture);
  382.           float _tmp_1 = tmp = _maxX;
  383.           boolean _greaterThan = (_tmp_1 > max);
  384.           if (_greaterThan) {
  385.             _xifexpression_1 = tmp;
  386.           } else {
  387.             _xifexpression_1 = max;
  388.           }
  389.           max = _xifexpression_1;
  390.         }
  391.       }
  392.       float _minus = (max - min);
  393.       float _abs = Math.abs(_minus);
  394.       _xblockexpression = (_abs);
  395.     }
  396.     return _xblockexpression;
  397.   }
  398.  
  399.   /**
  400.    * @return the height of the given Body
  401.    */
  402.   public static float height(final Body body) {
  403.     float _xblockexpression = (float) 0;
  404.     {
  405.       float min = Float.POSITIVE_INFINITY;
  406.       float max = Float.NEGATIVE_INFINITY;
  407.       float tmp = 0;
  408.       ArrayList<Fixture> _fixtureList = body.getFixtureList();
  409.       for (final Fixture fixture : _fixtureList) {
  410.         {
  411.           float _xifexpression = (float) 0;
  412.           float _minY = Box2DUtils.minY(fixture);
  413.           float _tmp = tmp = _minY;
  414.           boolean _lessThan = (_tmp < min);
  415.           if (_lessThan) {
  416.             _xifexpression = tmp;
  417.           } else {
  418.             _xifexpression = min;
  419.           }
  420.           min = _xifexpression;
  421.           float _xifexpression_1 = (float) 0;
  422.           float _maxY = Box2DUtils.maxY(fixture);
  423.           float _tmp_1 = tmp = _maxY;
  424.           boolean _greaterThan = (_tmp_1 > max);
  425.           if (_greaterThan) {
  426.             _xifexpression_1 = tmp;
  427.           } else {
  428.             _xifexpression_1 = max;
  429.           }
  430.           max = _xifexpression_1;
  431.         }
  432.       }
  433.       float _minus = (max - min);
  434.       float _abs = Math.abs(_minus);
  435.       _xblockexpression = (_abs);
  436.     }
  437.     return _xblockexpression;
  438.   }
  439.  
  440.   /**
  441.    * @return the width of the given Fixture
  442.    */
  443.   public static float width(final Fixture fixture) {
  444.     Shape _shape = fixture.getShape();
  445.     float _width = Box2DUtils.width(_shape);
  446.     return _width;
  447.   }
  448.  
  449.   /**
  450.    * @return the height of the given Fixture
  451.    */
  452.   public static float height(final Fixture fixture) {
  453.     Shape _shape = fixture.getShape();
  454.     float _height = Box2DUtils.height(_shape);
  455.     return _height;
  456.   }
  457.  
  458.   /**
  459.    * @return the width of the given Shape
  460.    */
  461.   public static float width(final Shape shape) {
  462.     Vector2[] _vertices = Box2DUtils.vertices(shape);
  463.     float[] _filterX = GeometryUtils.filterX(_vertices);
  464.     float _amplitude = GeometryUtils.amplitude(_filterX);
  465.     return _amplitude;
  466.   }
  467.  
  468.   /**
  469.    * @return the height of the given Shape
  470.    */
  471.   public static float height(final Shape shape) {
  472.     Vector2[] _vertices = Box2DUtils.vertices(shape);
  473.     float[] _filterY = GeometryUtils.filterY(_vertices);
  474.     float _amplitude = GeometryUtils.amplitude(_filterY);
  475.     return _amplitude;
  476.   }
  477.  
  478.   /**
  479.    * @return the size of the given Shape
  480.    */
  481.   public static Vector2 size(final Shape shape) {
  482.     Vector2 _xblockexpression = null;
  483.     {
  484.       Type _type = shape.getType();
  485.       boolean _equals = Objects.equal(_type, Type.Circle);
  486.       if (_equals) {
  487.         float _radius = shape.getRadius();
  488.         float _multiply = (_radius * 2);
  489.         float _radius_1 = shape.getRadius();
  490.         float _multiply_1 = (_radius_1 * 2);
  491.         new Vector2(_multiply, _multiply_1);
  492.       }
  493.       float _width = Box2DUtils.width(shape);
  494.       float _height = Box2DUtils.height(shape);
  495.       Vector2 _vector2 = new Vector2(_width, _height);
  496.       _xblockexpression = (_vector2);
  497.     }
  498.     return _xblockexpression;
  499.   }
  500.  
  501.   /**
  502.    * @return the relative position of the given CircleShape to its Body
  503.    */
  504.   public static Vector2 positionRelative(final CircleShape shape) {
  505.     Vector2 _position = shape.getPosition();
  506.     return _position;
  507.   }
  508.  
  509.   /**
  510.    * @return the relative position of the given Shape to its Body
  511.    *  @param rotation the rotation of the body in radians
  512.    */
  513.   public static Vector2 positionRelative(final Shape shape, final float rotation) {
  514.     Vector2 _xblockexpression = null;
  515.     {
  516.       Vector2 _vector2 = new Vector2();
  517.       final Vector2 position = _vector2;
  518.       final Vector2[] vertices = Box2DUtils.vertices(shape);
  519.       float[] _filterX = GeometryUtils.filterX(vertices);
  520.       float _max = GeometryUtils.max(_filterX);
  521.       float[] _filterX_1 = GeometryUtils.filterX(vertices);
  522.       float _amplitude = GeometryUtils.amplitude(_filterX_1);
  523.       float _divide = (_amplitude / 2);
  524.       float _minus = (_max - _divide);
  525.       float[] _filterY = GeometryUtils.filterY(vertices);
  526.       float _max_1 = GeometryUtils.max(_filterY);
  527.       float[] _filterY_1 = GeometryUtils.filterY(vertices);
  528.       float _amplitude_1 = GeometryUtils.amplitude(_filterY_1);
  529.       float _divide_1 = (_amplitude_1 / 2);
  530.       float _minus_1 = (_max_1 - _divide_1);
  531.       position.set(_minus, _minus_1);
  532.       float xx = position.x;
  533.       float xy = position.y;
  534.       float yx = position.x;
  535.       float yy = position.y;
  536.       double _cos = Math.cos(rotation);
  537.       float _multiply = (xx * ((float) _cos));
  538.       double _sin = Math.sin(rotation);
  539.       float _multiply_1 = (xy * ((float) _sin));
  540.       float _minus_2 = (_multiply - _multiply_1);
  541.       xx = _minus_2;
  542.       double _sin_1 = Math.sin(rotation);
  543.       float _multiply_2 = (yx * ((float) _sin_1));
  544.       double _cos_1 = Math.cos(rotation);
  545.       float _multiply_3 = (yy * ((float) _cos_1));
  546.       float _plus = (_multiply_2 + _multiply_3);
  547.       yy = _plus;
  548.       Vector2 _set = position.set(xx, yy);
  549.       _xblockexpression = (_set);
  550.     }
  551.     return _xblockexpression;
  552.   }
  553.  
  554.   /**
  555.    * @return the position of the given Fixture in world coordinates
  556.    */
  557.   public static Vector2 position(final Fixture fixture) {
  558.     Shape _shape = fixture.getShape();
  559.     Body _body = fixture.getBody();
  560.     Vector2 _position = Box2DUtils.position(_shape, _body);
  561.     return _position;
  562.   }
  563.  
  564.   /**
  565.    * @return the position of the given Shape in world coordinates
  566.    *  @param body the Body the given Shape is attached to
  567.    */
  568.   public static Vector2 position(final Shape shape, final Body body) {
  569.     Vector2 _position = body.getPosition();
  570.     Transform _transform = body.getTransform();
  571.     float _rotation = _transform.getRotation();
  572.     Vector2 _positionRelative = Box2DUtils.positionRelative(shape, _rotation);
  573.     Vector2 _add = _position.add(_positionRelative);
  574.     return _add;
  575.   }
  576. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement