Java 类com.badlogic.gdx.physics.box2d.Shape.Type 实例源码

项目:Entitas-Java    文件:Box2DUtils.java   
/**
 * @return the vertices of all fixtures of the given bodyA
 * @see #vertices(Shape)
 */
public static Vector2[] vertices(Body body, Vector2[] output) {
    Vector2[][] fixtureVertices = new Vector2[body.getFixtureList().size][]; // caching fixture vertices for performance
    for (int i = 0; i < fixtureVertices.length; i++)
        fixtureVertices[i] = vertices(body.getFixtureList().get(i), tmpVecArr);

    int vertexCount = 0;
    int fvi = -1;
    for (Fixture fixture : body.getFixtureList())
        if (fixture.getShape().getType() == Type.Circle) // for performance (doesn't call #vertices(Shape))
            vertexCount += 4;
        else
            vertexCount += fixtureVertices[++fvi].length;

    output = new Vector2[vertexCount];
    int vi = -1;
    for (Vector2[] verts : fixtureVertices)
        for (Vector2 vertice : verts)
            output[++vi] = vertice;

    return output;
}
项目:Entitas-Java    文件:Box2DUtils.java   
/**
 * @return the vertices of all fixtures of the given bodyA
 * @see #vertices(Shape)
 */
public static Vector2[] vertices(Body body, Vector2[] output) {
    Vector2[][] fixtureVertices = new Vector2[body.getFixtureList().size][]; // caching fixture vertices for performance
    for (int i = 0; i < fixtureVertices.length; i++)
        fixtureVertices[i] = vertices(body.getFixtureList().get(i), tmpVecArr);

    int vertexCount = 0;
    int fvi = -1;
    for (Fixture fixture : body.getFixtureList())
        if (fixture.getShape().getType() == Type.Circle) // for performance (doesn't call #vertices(Shape))
            vertexCount += 4;
        else
            vertexCount += fixtureVertices[++fvi].length;

    output = new Vector2[vertexCount];
    int vi = -1;
    for (Vector2[] verts : fixtureVertices)
        for (Vector2 vertice : verts)
            output[++vi] = vertice;

    return output;
}
项目:tilt-game-android    文件:DebugRenderer.java   
public RenderOfBody(Body pBody, VertexBufferObjectManager pVBO) {
    ArrayList<Fixture> fixtures = pBody.getFixtureList();

    /**
     * Spawn all IRenderOfFixture for this body that are out there,
     * and bind them to this RenderOfBody
     */
    for (Fixture fixture : fixtures) {
        IRenderOfFixture renderOfFixture;
        if (fixture.getShape().getType() == Type.Circle) {
            renderOfFixture = new RenderOfCircleFixture(fixture, pVBO);
        } else {
            renderOfFixture = new RenderOfPolyFixture(fixture, pVBO);
        }

        updateColor();
        mRenderFixtures.add(renderOfFixture);
        this.attachChild(renderOfFixture.getEntity());
    }
}
项目:libgdxcn    文件:Fixture.java   
/** Get the type of the child shape. You can use this to down cast to the concrete shape.
 * @return the shape type. */
public Type getType () {
    int type = jniGetType(addr);
    switch (type) {
    case 0:
        return Type.Circle;
    case 1:
        return Type.Edge;
    case 2:
        return Type.Polygon;
    case 3:
        return Type.Chain;
    default:
        throw new GdxRuntimeException("Unknown shape type!");
    }
}
项目:NationSoccer    文件:DebugRenderer.java   
public RenderOfBody(Body pBody, VertexBufferObjectManager pVBO) {
    ArrayList<Fixture> fixtures = pBody.getFixtureList();

    /**
     * Spawn all IRenderOfFixture for this body that are out there,
     * and bind them to this RenderOfBody
     */
    for (Fixture fixture : fixtures) {
        IRenderOfFixture renderOfFixture;
        if (fixture.getShape().getType() == Type.Circle) {
            renderOfFixture = new RenderOfCircleFixture(fixture, pVBO);
        } else {
            renderOfFixture = new RenderOfPolyFixture(fixture, pVBO);
        }

        updateColor();
        mRenderFixtures.add(renderOfFixture);
        this.attachChild(renderOfFixture.getEntity());
    }
}
项目:Entitas-Java    文件:Box2DUtils.java   
/**
 * @see #size(Shape)
 */
public static Vector2 size(Shape shape, Vector2 output) {
    if (shape.getType() == Type.Circle) // no call to #vertices(Shape) for performance
        return output.set(shape.getRadius() * 2, shape.getRadius() * 2);
    else if (shapeCache.containsKey(shape))
        return output.set(shapeCache.get(shape).width, shapeCache.get(shape).height);
    return output.set(width(shape), height(shape));
}
项目:Entitas-Java    文件:Box2DUtils.java   
/**
 * @see #size(Shape)
 */
public static Vector2 size(Shape shape, Vector2 output) {
    if (shape.getType() == Type.Circle) // no call to #vertices(Shape) for performance
        return output.set(shape.getRadius() * 2, shape.getRadius() * 2);
    else if (shapeCache.containsKey(shape))
        return output.set(shapeCache.get(shape).width, shapeCache.get(shape).height);
    return output.set(width(shape), height(shape));
}
项目:tilt-game-android    文件:Fixture.java   
/**
 * Get the type of the child shape. You can use this to down cast to the concrete shape.
 * @return the shape type.
 */
public Type getType () {
    int type = jniGetType(addr);
    if (type == 0)
        return Type.Circle;
    else
        return Type.Polygon;
}
项目:libgdxcn    文件:Fixture.java   
/** Get the type of the child shape. You can use this to down cast to the concrete shape.
 * @return the shape type. */
public Type getType () {
    ShapeType type = fixture.getType();
    if (type == ShapeType.CIRCLE) return Type.Circle;
    if (type == ShapeType.EDGE) return Type.Edge;
    if (type == ShapeType.POLYGON) return Type.Polygon;
    if (type == ShapeType.CHAIN) return Type.Chain;
    return Type.Circle;
}
项目:flixel-gdx-box2d    文件:B2FlxShape.java   
/**
 * Draws body lines and AABB.
 * @param camera    Specify which game camera you want.
 */
@Override
public void drawDebug(FlxCamera camera)
{               
    if(B2FlxDebug.drawBodies || B2FlxDebug.drawAABBs)
    {
        if (body.isActive() && B2FlxDebug.drawInactiveBodies)
            return;         
        Transform transform = body.getTransform();
        if(B2FlxDebug.drawBodies)
        {
            for(int i = 0; i < _fixtures.size; i++)
            {
                _fixtureDebug = _fixtures.get(i);
                if(body.isActive() == false)
                    drawShape(_fixtureDebug, transform, B2FlxDebug.SHAPE_NOT_ACTIVE);
                else if(body.getType() == BodyType.StaticBody)
                    drawShape(_fixtureDebug, transform, B2FlxDebug.SHAPE_STATIC);
                else if(body.getType() == BodyType.KinematicBody)
                    drawShape(_fixtureDebug, transform, B2FlxDebug.SHAPE_KINEMATIC);
                else if(body.isAwake() == false)
                    drawShape(_fixtureDebug, transform, B2FlxDebug.SHAPE_NOT_AWAKE);
                else
                    drawShape(_fixtureDebug, transform, B2FlxDebug.SHAPE_AWAKE);
                if(B2FlxDebug.drawAABBs)
                {
                    if(_fixtureDebug.getType() != Type.Edge && _fixtureDebug.getType() != Type.Chain)
                        drawAABB(_fixtureDebug, transform);
                }
            }
        }
    }
}
项目:NationSoccer    文件:Fixture.java   
/**
 * Get the type of the child shape. You can use this to down cast to the concrete shape.
 * @return the shape type.
 */
public Type getType () {
    int type = jniGetType(addr);
    if (type == 0)
        return Type.Circle;
    else
        return Type.Polygon;
}
项目:flixel-gdx-box2d    文件:B2FlxShape.java   
/**
 * Called by game loop, updates then blits or renders current frame of animation to the screen.
 * It's a modified version of FlxSprite::draw().
 */
@Override
public void draw()
{       
    if(_flicker)
        return;

    if(dirty)   //rarely 
        calcFrame();

    if(_newTextureData != null) //even more rarely
    {
        _pixels.getTexture().load(_newTextureData);
        _newTextureData = null;
    }

    FlxCamera camera = FlxG.getActiveCamera();

    if (cameras != null && !cameras.contains(camera, true))
        return;

    // Check whether it's outside the screen.
    if(!onScreen(camera))
        return;

    // Don't draw if the fixture is an edge or a chain.
    if(_fixtureDebug.getType() != Type.Edge || _fixtureDebug.getType() != Type.Chain)
    {
        _point.x = x - (camera.scroll.x * scrollFactor.x) - offset.x;
        _point.y = y - (camera.scroll.y * scrollFactor.y) - offset.y;
        _point.x += (_point.x > 0) ? 0.0000001f : -0.0000001f;
        _point.y += (_point.y > 0) ? 0.0000001f : -0.0000001f;

        //tinting
        int tintColor = FlxU.multiplyColors(_color, camera.getColor());
        framePixels.setColor(((tintColor >> 16) & 0xFF) * 0.00392f, ((tintColor >> 8) & 0xFF) * 0.00392f, (tintColor & 0xFF) * 0.00392f, _alpha);

        //rotate
        if(_pixels.rotate)
            framePixels.rotate90(false);

        if(isSimpleRender())
        {   //Simple render
            framePixels.setPosition(_point.x, _point.y);
            framePixels.draw(FlxG.batch);
        }
        else
        {   //Advanced render
            framePixels.setOrigin(origin.x, origin.y);
            framePixels.setScale(scale.x, scale.y);
            if((angle != 0) && (_bakedRotation <= 0))
                framePixels.setRotation(angle);
            framePixels.setPosition(_point.x, _point.y);
            if(blend != null && currentBlend != blend)
            {               
                currentBlend = blend;
                int[] blendFunc = BlendMode.getOpenGLBlendMode(blend);
                FlxG.batch.setBlendFunction(blendFunc[0], blendFunc[1]);
            }
            else if(FlxG.batchShader == null || ignoreBatchShader)
            {
                // OpenGL ES 2.0 shader render
                renderShader();
                // OpenGL ES 2.0 blend mode render
                renderBlend();
            }
            framePixels.draw(FlxG.batch);
        }           
    }

    //re-rotate 
    if(_pixels.rotate)
        framePixels.rotate90(true);

    if(FlxG.visualDebug && !ignoreDrawDebug)
        drawDebug(camera);
}