Examples of PolygonShape


Examples of com.badlogic.gdx.physics.box2d.PolygonShape

    boxBodyDef.position.x = pCenterX / pPixelToMeterRatio;
    boxBodyDef.position.y = pCenterY / pPixelToMeterRatio;

    final Body boxBody = pPhysicsWorld.createBody(boxBodyDef);

    final PolygonShape boxPoly = new PolygonShape();

    final float halfWidth = pWidth * 0.5f / pPixelToMeterRatio;
    final float halfHeight = pHeight * 0.5f / pPixelToMeterRatio;

    boxPoly.setAsBox(halfWidth, halfHeight);
    pFixtureDef.shape = boxPoly;

    boxBody.createFixture(pFixtureDef);

    boxPoly.dispose();

    boxBody.setTransform(boxBody.getWorldCenter(), MathUtils.degToRad(pRotation));

    return boxBody;
  }
View Full Code Here

Examples of com.badlogic.gdx.physics.box2d.PolygonShape

    final BodyDef lineBodyDef = new BodyDef();
    lineBodyDef.type = BodyType.StaticBody;
   
    final Body boxBody = pPhysicsWorld.createBody(lineBodyDef);
   
    final PolygonShape linePoly = new PolygonShape();
   
    linePoly.setAsEdge(new Vector2(pX1 / pPixelToMeterRatio, pY1 / pPixelToMeterRatio), new Vector2(pX2 / pPixelToMeterRatio, pY2 / pPixelToMeterRatio));
    pFixtureDef.shape = linePoly;
   
    boxBody.createFixture(pFixtureDef);
   
    linePoly.dispose();
   
    return boxBody;
  }
View Full Code Here

Examples of com.badlogic.gdx.physics.box2d.PolygonShape

    boxBodyDef.position.x = sceneCenterCoordinates[Constants.VERTEX_INDEX_X] / pPixelToMeterRatio;
    boxBodyDef.position.y = sceneCenterCoordinates[Constants.VERTEX_INDEX_Y] / pPixelToMeterRatio;

    final Body boxBody = pPhysicsWorld.createBody(boxBodyDef);

    final PolygonShape boxPoly = new PolygonShape();

    boxPoly.set(pVertices);
    pFixtureDef.shape = boxPoly;

    boxBody.createFixture(pFixtureDef);

    boxPoly.dispose();

    return boxBody;
  }
View Full Code Here

Examples of com.badlogic.gdx.physics.box2d.PolygonShape

    final Body boxBody = pPhysicsWorld.createBody(boxBodyDef);

    final int vertexCount = pTriangleVertices.size();
    for(int i = 0; i < vertexCount; /* */) {
      final PolygonShape boxPoly = new PolygonShape();

      TMP_TRIANGLE[2] = pTriangleVertices.get(i++);
      TMP_TRIANGLE[1] = pTriangleVertices.get(i++);
      TMP_TRIANGLE[0] = pTriangleVertices.get(i++);

      boxPoly.set(TMP_TRIANGLE);
      pFixtureDef.shape = boxPoly;

      boxBody.createFixture(pFixtureDef);

      boxPoly.dispose();
    }

    return boxBody;
  }
View Full Code Here

Examples of org.apache.poi.hssf.model.PolygonShape

        HSSFPatriarch patriarch = sh.createDrawingPatriarch();

        HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());
        polygon.setPolygonDrawArea( 100, 100 );
        polygon.setPoints( new int[]{0, 90, 50}, new int[]{5, 5, 44} );
        PolygonShape polygonShape = HSSFTestModelHelper.createPolygonShape(1024, polygon);
        polygon.setShapeId(1024);

        assertEquals(polygon.getEscherContainer().getChildRecords().size(), 4);
        assertEquals(polygonShape.getSpContainer().getChildRecords().size(), 4);

        //sp record
        byte[] expected = polygonShape.getSpContainer().getChild(0).serialize();
        byte[] actual = polygon.getEscherContainer().getChild(0).serialize();

        assertEquals(expected.length, actual.length);
        assertArrayEquals(expected, actual);

        expected = polygonShape.getSpContainer().getChild(2).serialize();
        actual = polygon.getEscherContainer().getChild(2).serialize();

        assertEquals(expected.length, actual.length);
        assertArrayEquals(expected, actual);

        expected = polygonShape.getSpContainer().getChild(3).serialize();
        actual = polygon.getEscherContainer().getChild(3).serialize();

        assertEquals(expected.length, actual.length);
        assertArrayEquals(expected, actual);

        ObjRecord obj = polygon.getObjRecord();
        ObjRecord objShape = polygonShape.getObjRecord();

        expected = obj.serialize();
        actual = objShape.serialize();

        assertEquals(expected.length, actual.length);
View Full Code Here

Examples of org.apache.poi.hssf.model.PolygonShape

        HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());
        polygon.setPolygonDrawArea( 100, 100 );
        polygon.setPoints( new int[]{0, 90, 50, 90}, new int[]{5, 5, 44, 88} );

        PolygonShape polygonShape = HSSFTestModelHelper.createPolygonShape(0, polygon);

        EscherArrayProperty verticesProp1 = polygon.getOptRecord().lookup(EscherProperties.GEOMETRY__VERTICES);
        EscherArrayProperty verticesProp2 = ((EscherOptRecord)polygonShape.getSpContainer().getChildById(EscherOptRecord.RECORD_ID))
                .lookup(EscherProperties.GEOMETRY__VERTICES);

        assertEquals(verticesProp1.getNumberOfElementsInArray(), verticesProp2.getNumberOfElementsInArray());
        assertEquals(verticesProp1.toXml(""), verticesProp2.toXml(""));
       
        polygon.setPoints(new int[]{1,2,3}, new int[] {4,5,6});
        assertArrayEquals(polygon.getXPoints(), new int[]{1, 2, 3});
        assertArrayEquals(polygon.getYPoints(), new int[]{4, 5, 6});

        polygonShape = HSSFTestModelHelper.createPolygonShape(0, polygon);
        verticesProp1 = polygon.getOptRecord().lookup(EscherProperties.GEOMETRY__VERTICES);
        verticesProp2 = ((EscherOptRecord)polygonShape.getSpContainer().getChildById(EscherOptRecord.RECORD_ID))
                .lookup(EscherProperties.GEOMETRY__VERTICES);

        assertEquals(verticesProp1.getNumberOfElementsInArray(), verticesProp2.getNumberOfElementsInArray());
        assertEquals(verticesProp1.toXml(""), verticesProp2.toXml(""));
    }
View Full Code Here

Examples of org.apache.poi.hssf.model.PolygonShape

        HSSFPatriarch patriarch = sh.createDrawingPatriarch();

        HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());
        polygon.setPolygonDrawArea( 100, 100 );
        polygon.setPoints( new int[]{0, 90, 50}, new int[]{5, 5, 44} );
        PolygonShape polygonShape = HSSFTestModelHelper.createPolygonShape(1024, polygon);
        polygon.setShapeId(1024);

        assertEquals(polygon.getEscherContainer().getChildRecords().size(), 4);
        assertEquals(polygonShape.getSpContainer().getChildRecords().size(), 4);

        //sp record
        byte[] expected = polygonShape.getSpContainer().getChild(0).serialize();
        byte[] actual = polygon.getEscherContainer().getChild(0).serialize();

        assertEquals(expected.length, actual.length);
        assertTrue(Arrays.equals(expected, actual));

        expected = polygonShape.getSpContainer().getChild(2).serialize();
        actual = polygon.getEscherContainer().getChild(2).serialize();

        assertEquals(expected.length, actual.length);
        assertTrue(Arrays.equals(expected, actual));

        expected = polygonShape.getSpContainer().getChild(3).serialize();
        actual = polygon.getEscherContainer().getChild(3).serialize();

        assertEquals(expected.length, actual.length);
        assertTrue(Arrays.equals(expected, actual));

        ObjRecord obj = polygon.getObjRecord();
        ObjRecord objShape = polygonShape.getObjRecord();

        expected = obj.serialize();
        actual = objShape.serialize();

        assertEquals(expected.length, actual.length);
View Full Code Here

Examples of org.apache.poi.hssf.model.PolygonShape

        HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());
        polygon.setPolygonDrawArea( 100, 100 );
        polygon.setPoints( new int[]{0, 90, 50, 90}, new int[]{5, 5, 44, 88} );

        PolygonShape polygonShape = HSSFTestModelHelper.createPolygonShape(0, polygon);

        EscherArrayProperty verticesProp1 = polygon.getOptRecord().lookup(EscherProperties.GEOMETRY__VERTICES);
        EscherArrayProperty verticesProp2 = ((EscherOptRecord)polygonShape.getSpContainer().getChildById(EscherOptRecord.RECORD_ID))
                .lookup(EscherProperties.GEOMETRY__VERTICES);

        assertEquals(verticesProp1.getNumberOfElementsInArray(), verticesProp2.getNumberOfElementsInArray());
        assertEquals(verticesProp1.toXml(""), verticesProp2.toXml(""));
       
        polygon.setPoints(new int[]{1,2,3}, new int[] {4,5,6});
        assertTrue(Arrays.equals(polygon.getXPoints(), new int[]{1, 2, 3}));
        assertTrue(Arrays.equals(polygon.getYPoints(), new int[]{4, 5, 6}));

        polygonShape = HSSFTestModelHelper.createPolygonShape(0, polygon);
        verticesProp1 = polygon.getOptRecord().lookup(EscherProperties.GEOMETRY__VERTICES);
        verticesProp2 = ((EscherOptRecord)polygonShape.getSpContainer().getChildById(EscherOptRecord.RECORD_ID))
                .lookup(EscherProperties.GEOMETRY__VERTICES);

        assertEquals(verticesProp1.getNumberOfElementsInArray(), verticesProp2.getNumberOfElementsInArray());
        assertEquals(verticesProp1.toXml(""), verticesProp2.toXml(""));
    }
View Full Code Here

Examples of org.jbox2d.collision.shapes.PolygonShape

                    case Keyboard.KEY_C:
                        Vec2 bodyPosition = new Vec2(Mouse.getX(), Mouse.getY()).mul(0.5f).mul(1 / 30f);
                        BodyDef boxDef = new BodyDef();
                        boxDef.position.set(bodyPosition);
                        boxDef.type = BodyType.DYNAMIC;
                        PolygonShape boxShape = new PolygonShape();
                        boxShape.setAsBox(0.75f, 0.75f);
                        Body box = world.createBody(boxDef);
                        FixtureDef boxFixture = new FixtureDef();
                        boxFixture.density = 0.1f;
                        boxFixture.shape = boxShape;
                        box.createFixture(boxFixture);
View Full Code Here

Examples of org.jbox2d.collision.shapes.PolygonShape

    private static void setUpObjects() {
        BodyDef boxDef = new BodyDef();
        boxDef.position.set(320 / 30 / 2f, 240 / 30 / 2f);
        boxDef.type = BodyType.DYNAMIC;
        PolygonShape boxShape = new PolygonShape();
        boxShape.setAsBox(0.75f, 0.75f);
        Body box = world.createBody(boxDef);
        FixtureDef boxFixture = new FixtureDef();
        boxFixture.density = 0.1f;
        boxFixture.shape = boxShape;
        box.createFixture(boxFixture);
        bodies.add(box);

        BodyDef groundDef = new BodyDef();
        groundDef.position.set(0, 0);
        groundDef.type = BodyType.STATIC;
        PolygonShape groundShape = new PolygonShape();
        groundShape.setAsBox(1000, 0);
        Body ground = world.createBody(groundDef);
        FixtureDef groundFixture = new FixtureDef();
        groundFixture.density = 1;
        groundFixture.restitution = 0.3f;
        groundFixture.shape = groundShape;
        ground.createFixture(groundFixture);

        BodyDef leftWallDef = new BodyDef();
        leftWallDef.position.set(0, 0);
        leftWallDef.type = BodyType.STATIC;
        PolygonShape leftWallShape = new PolygonShape();
        leftWallShape.setAsBox(0, 1000);
        Body leftWall = world.createBody(leftWallDef);
        FixtureDef leftWallFixture = new FixtureDef();
        leftWallFixture.density = 1;
        leftWallFixture.restitution = 0.3f;
        leftWallFixture.shape = leftWallShape;
        leftWall.createFixture(leftWallFixture);

        BodyDef rightWallDef = new BodyDef();
        rightWallDef.position.set(320f / 30, 0);
        rightWallDef.type = BodyType.STATIC;
        PolygonShape rightWallShape = new PolygonShape();
        rightWallShape.setAsBox(0, 1000);
        Body rightWall = world.createBody(rightWallDef);
        FixtureDef rightWallFixture = new FixtureDef();
        rightWallFixture.density = 1;
        rightWallFixture.restitution = 0.3f;
        rightWallFixture.shape = rightWallShape;
        rightWall.createFixture(rightWallFixture);

        BodyDef topWallDef = new BodyDef();
        topWallDef.position.set(0, 240f / 30);
        topWallDef.type = BodyType.STATIC;
        PolygonShape topWallShape = new PolygonShape();
        topWallShape.setAsBox(1000, 0);
        Body topWall = world.createBody(topWallDef);
        FixtureDef topWallFixture = new FixtureDef();
        topWallFixture.density = 1;
        topWallFixture.restitution = 0.3f;
        topWallFixture.shape = topWallShape;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.