List of usage examples for com.badlogic.gdx.math Vector3 Z
Vector3 Z
To view the source code for com.badlogic.gdx.math Vector3 Z.
Click Source Link
From source file:br.com.abby.linear.OrientedBoundingBox.java
License:Apache License
public void rotateZ(float angle) { transform.rotate(Vector3.Z.mul(transform), angle); }
From source file:com.badlogic.gdx.tests.dragome.examples.GearsDemo.java
@Override public void render() { Gdx.gl.glClearColor(0, 0, 0, 1);/*from w w w. j a v a2 s . com*/ 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.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;/*w w w . j a va 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.Particle.java
License:Apache License
private void updateCommon(float delta, boolean haveTouchVelocity, Vector3 touchPosition, Vector3 touchVelocity, float cameraDistance) { age += delta;/*from w w w . j a v a2s . c o m*/ if (age < LIFE_FADE_TIME) ageFade = Interpolation.fade.apply(age / LIFE_FADE_TIME); else if (age > LIFE_FADE_OUT_TIME) ageFade = Interpolation.fade.apply((LIFE_TIME - age) / LIFE_FADE_TIME); else ageFade = 1; TMPV.set(center.x, center.y, 0); float distFromAccelerationCenter = TMPV.len() - RADIAL_ACCELERATION_MAX_CENTER; float radialAcceleration = RADIAL_ACCELERATION_MAX * (1F - Math.min(1f, Interpolation.fade .apply(Math.abs(distFromAccelerationCenter) / RADIAL_ACCELERATION_EFFECT_EXTENT))); TMPV.nor().rotate(Vector3.Z, 90f - (distFromAccelerationCenter * DEGREES_ACCLERATION_PER_DIST)); //motion direction TMPV.scl(radialAcceleration); //acceleration baseVelocity.add(TMPV.scl(delta)); //apply acceleration float dampenAmount = DAMPENING * baseVelocity.len() * delta; if (dampenAmount >= 1f) baseVelocity.set(0, 0, 0); else baseVelocity.add(TMPV.set(baseVelocity).scl(-dampenAmount)); velocity.set(baseVelocity); if (haveTouchVelocity && cameraDistance <= TOUCH_CHECK_DISTANCE) { float dst = TMPV.set(center).sub(touchPosition).len(); if (dst < TOUCH_INFLUENCE) { float mag = 1f - Math.min(1f, dst / TOUCH_INFLUENCE); if (mag > touchMagnitude) { touchMagnitude = mag; //float radialDst = distanceToAxis(center, touchPosition, touchVelocity); touchAge = 0; touchRotationVelocity.set(touchVelocity).scl(TOUCH_SPEED_RATIO * mag); touchRotationAxis.set(TMPV).crs(touchVelocity).nor(); } } } if (touchMagnitude > 0) { touchAge += delta; if (touchAge > TOUCH_DAMPEN_TIME) { touchMagnitude = 0; TMPV.set(touchRotationVelocity).scl(0.5f); TMPV.rotate(touchRotationAxis, -45); baseVelocity.add(TMPV); velocity.set(baseVelocity); } else { float lerp = touchAge / TOUCH_DAMPEN_TIME; TMPV.set(touchRotationVelocity).scl(1f - 0.5f * Interpolation.pow2Out.apply(lerp)); TMPV.rotate(touchRotationAxis, -Interpolation.pow3In.apply(lerp) * 45); velocity.add(TMPV); } } if (age >= LIFE_TIME) { center.set(originalCenter); age = 0; } else { center.add(TMPV.set(velocity).scl(delta)); } }
From source file:com.cyphercove.doublehelix.Particles.java
License:Apache License
public Particles(Texture pointTexture, TextureRegion textureRegion, DepthOfFieldCamera camera) { this.camera = camera; for (int i = 0; i < MAX_PARTICLES; i++) { Particle particle = new Particle(textureRegion, pointTexture); //in wedge of a cylinder in the viewable area: particle.originalCenter.set(random.nextFloat() * 18f, 0, random.nextFloat() * 8f + 1f) .rotateRad(Vector3.Z, -(0.225f + 0.75f * random.nextFloat()) * MathUtils.PI).add(0, 2f, 0); particle.reset();/*w ww. j a v a 2 s . c o m*/ particles.add(particle); } setInputAdapterResolution(); }
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 . jav a 2 s .c om*/ 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();/* w w w . j a v a 2 s . 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.mygdx.game.objects.GameModel.java
License:Apache License
public static void applyTransform(Vector3 location, Vector3 rotation, Vector3 scale, ModelInstance modelInstance) {//from w ww .j av a 2 s . com for (Node node : modelInstance.nodes) { node.scale.set(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z)); } modelInstance.transform.rotate(Vector3.X, rotation.x); modelInstance.transform.rotate(Vector3.Z, rotation.z); modelInstance.transform.rotate(Vector3.Y, rotation.y); modelInstance.transform.setTranslation(location); modelInstance.calculateTransforms(); }
From source file:com.mygdx.game.objects.HumanCharacter.java
License:Apache License
public void throwStick() { GameScreen.screen.engine.addEntity(stick); stick.body.setLinearVelocity(Vector3.Zero); stick.body.setAngularVelocity(Vector3.Zero); Vector3 rightHandPos = getBoneMidpointWorldPosition(HumanArmature.RIGHT_HAND.id, TMP_V1); stick.modelTransform.setToRotation(Vector3.Z, 90); stick.modelTransform.rotate(Constants.V3_UP, getOrientation() * MathUtils.radiansToDegrees); stick.modelTransform.setTranslation(rightHandPos); stick.body.setWorldTransform(stick.modelTransform); Vector3 humanDirection = getDirection(TMP_V1); TMP_Q.setFromAxis(TMP_V2.set(humanDirection).crs(Constants.V3_UP), STICK_THROW_ANGLE); Vector3 impulse = TMP_Q.transform(humanDirection).nor(); impulse.scl(STICK_THROW_IMPULSE_SCL); stick.body.applyImpulse(impulse, TMP_V2.set(Constants.V3_UP).scl(0.005f)); stick.hasLanded = false;/*from w ww . ja v a 2 s . c om*/ hasStick = false; }
From source file:com.mygdx.game.objects.InvisibleBody.java
License:Apache License
public InvisibleBody(String id, btCollisionShape shape, float mass, Vector3 location, Vector3 rotation, short belongsToFlag, short collidesWithFlag, boolean callback, boolean noDeactivate) { this(id, shape, mass, new Matrix4().rotate(Vector3.X, rotation.x).rotate(Vector3.Z, rotation.z) .rotate(Vector3.Y, rotation.y).setTranslation(location), belongsToFlag, collidesWithFlag, callback, noDeactivate); }