Example usage for com.badlogic.gdx.math Vector3 Y

List of usage examples for com.badlogic.gdx.math Vector3 Y

Introduction

In this page you can find the example usage for com.badlogic.gdx.math Vector3 Y.

Prototype

Vector3 Y

To view the source code for com.badlogic.gdx.math Vector3 Y.

Click Source Link

Usage

From source file:br.com.abby.linear.OrientedBoundingBox.java

License:Apache License

public void rotateY(float angle) {
    transform.rotate(Vector3.Y.mul(transform), angle);
}

From source file:br.com.raphaelbruno.game.zombieinvaders.vr.model.GameObject.java

License:Apache License

public void rotateTo(float angle) {
    Vector3 position = transform.getTranslation(new Vector3());
    transform.setToRotation(Vector3.Y, angle).setTranslation(position);
}

From source file:br.com.raphaelbruno.game.zombieinvaders.vr.tween.GameObjectAccessor.java

License:Apache License

@Override
public void setValues(GameObject target, int tweenType, float[] newValues) {
    Vector3 position = target.transform.getTranslation(new Vector3());

    switch (tweenType) {
    case XYZ:/*from   ww  w  .ja  v a2s  .  c o m*/
        target.transform.setTranslation(new Vector3(newValues[0], newValues[1], newValues[2]));
        break;

    case ROTATION:
        target.transform.setToRotation(Vector3.Y, newValues[0]).setTranslation(position);
        break;

    case ALPHA:
        target.blending.opacity = newValues[0];
        break;

    default:
        assert false;
    }

}

From source file:com.andgate.ikou.controller.CameraInputController.java

License:Open Source License

protected boolean process(float deltaX, float deltaY, int button) {
    tmpV1.set(camera.direction).crs(camera.up).y = 0f;

    float deltaAngleX = deltaX * -ROTATE_ANGLE;
    angleX += deltaAngleX;/*from   w ww.  ja  v  a  2 s  .  c  o  m*/

    float deltaAngleY = deltaY * ROTATE_ANGLE;
    float tmpAngleY = angleY + deltaAngleY;
    if (!MathExtra.inRangeInclusive(tmpAngleY, ANGLE_Y_MIN, ANGLE_Y_MAX)) {
        tmpAngleY = MathExtra.pickClosestBound(tmpAngleY, ANGLE_Y_MIN, ANGLE_Y_MAX);
        deltaAngleY = tmpAngleY - angleY;
    }
    angleY = tmpAngleY;

    camera.rotateAround(target, tmpV1.nor(), deltaAngleY);
    camera.rotateAround(target, Vector3.Y, deltaAngleX);
    camera.update();
    return true;
}

From source file:com.badlogic.gdx.tests.dragome.examples.GearsDemo.java

@Override
public void render() {
    Gdx.gl.glClearColor(0, 0, 0, 1);/*from ww w  .j  a  v  a  2 s .  co m*/
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

    cam.update();

    if (modelBatch != null) {
        angle += 1.0f;

        gear1.transform.setToTranslation(-3.0f, -2.0f, 0.0f);
        gear2.transform.setToTranslation(3.1f, -2.0f, 0.0f);
        gear3.transform.setToTranslation(-3.1f, 4.2f, 0.0f);
        gear1.transform.rotate(Vector3.Z, angle);
        gear2.transform.rotate(Vector3.Z, -2.0f * angle - 9.0f);
        gear3.transform.rotate(Vector3.Z, -2.0f * angle - 25.0f);

        final float delta = Gdx.graphics.getDeltaTime();

        sl.position.sub(transformedCenter);
        sl.position.rotate(Vector3.X, delta * 50f);
        sl.position.rotate(Vector3.Y, delta * 13f);
        sl.position.rotate(Vector3.Z, delta * 3f);
        sl.position.add(transformedCenter.set(center).mul(transform));

        modelBatch.begin(cam);
        modelBatch.render(gear1, environment);
        modelBatch.render(gear2, environment);
        modelBatch.render(gear3, environment);
        pLight.worldTransform.setTranslation(sl.position);
        modelBatch.render(pLight);
        modelBatch.end();

        float timeSec = TimeUtils.millis() - time;

        if (timeSec > 1000) {
            time = TimeUtils.millis();
            fps = Gdx.graphics.getFramesPerSecond();
        }
        batch.begin();
        font.draw(batch, "FPS: " + fps, 15, Gdx.graphics.getHeight() - 15);
        batch.end();
    }
}

From source file:com.bladecoder.engine.model.Sprite3DRenderer.java

License:Apache License

private void lookat(float angle) {
    currentSource.modelInstance.transform.setToRotation(Vector3.Y, angle);
    modelRotation = angle;
}

From source file:com.cyphercove.doublehelix.MainRenderer.java

License:Apache License

@Override
public void draw(float deltaTime, float xOffsetFake, float xOffsetLooping, float xOffsetSmooth, float yOffset) {
    deltaTime = Math.min(deltaTime, MAX_FRAME_TIME);
    if (screenshotPause)
        deltaTime = 0;//  www .ja  v  a 2 s.c  om

    float _xOffset = isPreview ? 0.5f
            : (Settings.pseudoScrolling ? xOffsetFake
                    : (Settings.smoothScrolling ? xOffsetSmooth : xOffsetLooping));

    GL20 gl = Gdx.gl;

    if (!firstFrameDrawn) {
        gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        gl.glClearColor(0, 0, 0, 1);
        gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
        firstFrameDrawn = true;
        return;
    }

    if (needFinishCreate) {
        finishCreate();
        //film grain wasn't created til now so need to initialize its size
        filmGrain.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        filmGrainForBloom.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    }

    if (settingsAdapter != null)
        settingsAdapter.updateInLoop(deltaTime);

    //UPDATES
    Texture.TextureFilter particleMinFilter = Settings.trilinearParticles
            ? Texture.TextureFilter.MipMapLinearLinear
            : Texture.TextureFilter.MipMapLinearNearest;
    particleATexture.setFilter(particleMinFilter, Texture.TextureFilter.Linear);
    particlePointTexture.setFilter(particleMinFilter, Texture.TextureFilter.Linear);

    mainHelixTransformManager.localEulers.z += deltaTime * MAIN_HELIX_ROTATION_DPS * Settings.speed;
    mainHelixTransformManager.apply();
    rearHelixTransformManager.localEulers.z += deltaTime * 0.5f * MAIN_HELIX_ROTATION_DPS * Settings.speed;
    rearHelixTransformManager.apply();

    cam.up.set(0, 1, 0);
    cam.direction.set(0, 0, -1);
    cam.rotate(-41.998f, 1, 0, 0);
    cam.rotate(146.964f, 0, 1, 0);
    cam.rotate(18.503f, 0, 0, 1);

    camPosition.set(0.45617f, 4.11359f, 0.14467f); //set it here and reapply when needed.
    if (cam.viewportWidth > cam.viewportHeight) {//landscape
        camPosition.rotate(Vector3.Z, -(_xOffset - 0.5f) * 47.5f - 15.0f);
    } else {//portrait
        camPosition.rotate(Vector3.Z, -(_xOffset - 0.5f) * 65f);
    }
    cam.position.set(camPosition); //temporarily apply it to get correct direction with lookAt
    cam.lookAt(-.4703f, 0f, 3.5032f);

    sssShader.lightDirection.set(1, 0, 0).rotate(Vector3.Y, lightH).rotate(Vector3.X, lightV);

    particles.update(deltaTime, sssShader.lightDirection); //MUST BE DONE WHILE CAM IS IN POSITION

    backgroundShader.color.set(Settings.backgroundColor);

    //BLOOM SURFACE DRAWING
    if (Settings.bloom) {
        bloom.begin();
        cam.position.set(0, 0, 0);
        cam.update();
        modelBatch.begin(cam);
        modelBatch.render(backgroundBloomModelInstance, unlitShader);
        modelBatch.end();

        cam.position.set(camPosition);
        cam.update();
        modelBatch.begin(cam);
        modelBatch.render(mainHelixModelInstance, blackShader);
        modelBatch.render(rearHelixModelInstance, blackShader);
        modelBatch.end();

        bloom.end();
    }

    //BLUR SURFACE DRAWING
    if (Settings.dof) {
        rearDOFBlur.setClearColor(tmpColor.set(Settings.backgroundColor).mul(AMBIENT_BRIGHTNESS));
        rearDOFBlur.begin();
        modelBatch.begin(cam);
        modelBatch.render(backgroundModelInstance, backgroundShader);
        modelBatch.end();

        cam.position.set(camPosition);
        cam.update();

        sssShader.setShouldFadeEnds(true);
        modelBatch.begin(cam);
        modelBatch.render(rearHelixModelInstance, sssShader);
        modelBatch.end();
        rearDOFBlur.end();
    }

    //MAIN DRAWING
    Gdx.gl.glClearColor(Settings.backgroundColor.r, Settings.backgroundColor.g, Settings.backgroundColor.b, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

    if (Settings.dof) {
        rearDOFBlur.render();
    } else {
        modelBatch.begin(cam);
        modelBatch.render(backgroundModelInstance, backgroundShader);
        modelBatch.end();
    }

    cam.position.set(camPosition);
    cam.update();

    sssShader.setShouldFadeEnds(false);
    modelBatch.begin(cam);
    modelBatch.render(mainHelixModelInstance, sssShader);
    modelBatch.end();

    if (!Settings.dof) {
        sssShader.setShouldFadeEnds(true);
        modelBatch.begin(cam);
        modelBatch.render(rearHelixModelInstance, sssShader);
        modelBatch.end();
    }

    boolean doFilmGrain = Settings.filmGrain || Settings.scanLines || Settings.vignette;

    if (Settings.bloom) {
        if (doFilmGrain) {
            bloom.setCustomShaderPreparer(filmGrainForBloom);
            bloom.render(filmGrainForBloom.filmGrainShaderProgram);
        } else {
            bloom.setCustomShaderPreparer(null);
            bloom.render(bloomShaderProgram);
        }
    } else if (doFilmGrain) {
        filmGrain.render();
    }

    particles.draw(decalBatch, billboardDecalBatch);

    fader.render(deltaTime);
}

From source file:com.cyphercove.doublehelix.TransformManager.java

License:Apache License

public void apply() {
    modelInstance.transform.idt().translate(position).rotate(Vector3.X, eulers.x).rotate(Vector3.Y, eulers.y)
            .rotate(Vector3.Z, eulers.z);
    tmp.idt().rotate(Vector3.X, localEulers.x).rotate(Vector3.Y, localEulers.y).rotate(Vector3.Z,
            localEulers.z);//from  w  w  w  .j a va  2 s.  c o  m
    modelInstance.transform.mul(tmp);
}

From source file:com.mbrlabs.demo.MundusDemo.java

License:Apache License

@Override
public void create() {
    batch = new ModelBatch();
    fpsLogger = new FPSLogger();

    // setup mundus & load our scene
    mundus = new Mundus(Gdx.files.internal("mundus"));
    mundus.init();//from w w w .  j  ava 2s .c  o  m
    scene = mundus.loadScene("Main Scene.mundus");
    scene.sceneGraph.batch = batch;

    // position cam
    scene.cam.position.set(230, 150, 190);
    scene.cam.direction.rotate(Vector3.Y, 70);
    scene.cam.direction.rotate(Vector3.Z, -20);

    // setup input
    controller = new FirstPersonCameraController(scene.cam);
    controller.setVelocity(200f);
    Gdx.input.setInputProcessor(controller);
}

From source file:com.mbrlabs.mundus.commons.terrain.Terrain.java

License:Apache License

/**
 * Get normal at world coordinates. The methods calculates exact point
 * position in terrain coordinates and returns normal at that point. If
 * point doesn't belong to terrain -- it returns default
 * <code>Vector.Y<code> normal.
 * //from  www  .  j a  va  2s . c om
 * @param worldX
 *            the x coord in world
 * @param worldZ
 *            the z coord in world
 * @return normal at that point. If point doesn't belong to terrain -- it
 *         returns default <code>Vector.Y<code> normal.
 */
public Vector3 getNormalAtWordCoordinate(float worldX, float worldZ) {
    transform.getTranslation(c00);
    float terrainX = worldX - c00.x;
    float terrainZ = worldZ - c00.z;

    float gridSquareSize = terrainWidth / ((float) vertexResolution - 1);
    int gridX = (int) Math.floor(terrainX / gridSquareSize);
    int gridZ = (int) Math.floor(terrainZ / gridSquareSize);

    if (gridX >= vertexResolution - 1 || gridZ >= vertexResolution - 1 || gridX < 0 || gridZ < 0) {
        return Vector3.Y.cpy();
    }

    return getNormalAt(gridX, gridZ);
}