public void setTranslation (Vector3 translation) { this.transform.setTranslation(translation); }
public void setTranslation (Vector3 translation) { this.transform.setTranslation(translation); }
/** Adds an occluder entity of specified type * * @param type Type name * @param rotationY Rotation on Y axis in degrees * @param position The world position * @return The added entity */ private BulletEntity addOccluder (String type, float rotationY, Vector3 position) { BulletEntity e = world.add(type, 0, 0, 0); e.body.setWorldTransform(e.transform.setToRotation(Vector3.Y, rotationY).setTranslation(position)); e.body.setCollisionFlags(e.body.getCollisionFlags() | CF_OCCLUDER_OBJECT); e.setColor(Color.RED); return e; }
/** Adds an occludee entity of random type at a random place on the ground. * * @param dynamic If true, entity body will be dynamic (mass > 0) * @return The added entity */ private BulletEntity addRandomOccludee (boolean dynamic) { // Add occludee to world BulletEntity entity = world.add(getRandomOccludeeType(dynamic), 0, 0, 0); entity.setColor(Color.WHITE); // Random rotation float rotationY = rng.nextFloat() * 360f; // Random ground position Vector3 position = tmpV1; int maxDstX = (int)(GROUND_DIM.x * 0.49f); position.x = rng.nextInt(maxDstX) * ((rng.nextBoolean()) ? 1 : -1); position.z = rng.nextInt(maxDstX) * ((rng.nextBoolean()) ? 1 : -1); position.y = entity.boundingBox.getDimensions(tmpV2).y * 0.5f; entity.modelInstance.transform.setToRotation(Vector3.Y, rotationY).setTranslation(position); entity.body.setWorldTransform(entity.modelInstance.transform); return entity; }
@Override protected void render (ModelBatch batch, Array<ModelInstance> instances) { final float delta = Gdx.graphics.getDeltaTime(); dirLight.direction.rotate(Vector3.X, delta * 45f); dirLight.direction.rotate(Vector3.Y, delta * 25f); dirLight.direction.rotate(Vector3.Z, delta * 33f); pointLight.position.sub(transformedCenter); pointLight.position.rotate(Vector3.X, delta * 50f); pointLight.position.rotate(Vector3.Y, delta * 13f); pointLight.position.rotate(Vector3.Z, delta * 3f); pointLight.position.add(transformedCenter.set(center).mul(transform)); pLight.worldTransform.setTranslation(pointLight.position); batch.render(pLight); super.render(batch, instances); }
/** Averages the given transform with this one and stores the result in this matrix. Translations and scales are lerped while * rotations are slerped. * @param other The other transform * @param w Weight of this transform; weight of the other transform is (1 - w) * @return This matrix for chaining */ public Matrix4 avg (Matrix4 other, float w) { getScale(tmpVec); other.getScale(tmpForward); getRotation(quat); other.getRotation(quat2); getTranslation(tmpUp); other.getTranslation(right); setToScaling(tmpVec.scl(w).add(tmpForward.scl(1 - w))); rotate(quat.slerp(quat2, 1 - w)); setTranslation(tmpUp.scl(w).add(right.scl(1 - w))); return this; }
/** Averages the given transform with this one and stores the result in this matrix. Translations and scales are lerped while * rotations are slerped. * @param other The other transform * @param w Weight of this transform; weight of the other transform is (1 - w) * @return This matrix for chaining */ public Matrix4 avg (Matrix4 other, float w) { getScale(tmpVec); other.getScale(tmpForward); getRotation(quat); other.getRotation(quat2); getTranslation(tmpUp); other.getTranslation(right); setToScaling(tmpVec.scl(w).add(tmpForward.scl(1 - w))); rotate(quat.slerp(quat2, 1 - w)); setTranslation(tmpUp.scl(w).add(right.scl(1 - w))); return this; }
@Override public void update () { super.update(); // Transform the frustum camera if ((state & PAUSE_FRUSTUM_CAM) == PAUSE_FRUSTUM_CAM) return; final float dt = Gdx.graphics.getDeltaTime(); frustumInstance.transform.idt().rotate(Vector3.Y, frustumCamAngleY = (frustumCamAngleY + dt * FRUSTUM_ANG_SPEED) % 360); frustumCam.direction.set(0, 0, -1); frustumCam.up.set(Vector3.Y); frustumCam.position.set(Vector3.Zero); frustumCam.rotate(frustumInstance.transform); float frustumCamPosY = frustumCamPos.y; frustumCamPos.add(tmpV1.set(Vector3.Y).crs(tmpV2.set(frustumCamPos).nor()).scl(dt * FRUSTUM_LIN_SPEED)).nor() .scl(FRUSTUM_MOVE_RADIUS); frustumCamPos.y = frustumCamPosY; frustumCam.position.set(frustumCamPos); frustumInstance.transform.setTranslation(frustumCamPos); frustumCam.update(); }
/** Averages the given transforms with the given weights and stores the result in this matrix. Translations and scales are * lerped while rotations are slerped. Does not destroy the data contained in t or w; Sum of w_i must be equal to 1, or * unexpected results will occur. * @param t List of transforms * @param w List of weights * @return This matrix for chaining */ public Matrix4 avg (Matrix4[] t, float[] w) { tmpVec.set(t[0].getScale(tmpUp).scl(w[0])); quat.set(t[0].getRotation(quat2).exp(w[0])); tmpForward.set(t[0].getTranslation(tmpUp).scl(w[0])); for (int i = 1; i < t.length; i++) { tmpVec.add(t[i].getScale(tmpUp).scl(w[i])); quat.mul(t[i].getRotation(quat2).exp(w[i])); tmpForward.add(t[i].getTranslation(tmpUp).scl(w[i])); } quat.nor(); setToScaling(tmpVec); rotate(quat); setTranslation(tmpForward); return this; }
/** Averages the given transforms with the given weights and stores the result in this matrix. Translations and scales are * lerped while rotations are slerped. Does not destroy the data contained in t or w; Sum of w_i must be equal to 1, or * unexpected results will occur. * @param t List of transforms * @param w List of weights * @return This matrix for chaining */ public Matrix4 avg (Matrix4[] t, float[] w) { tmpVec.set(t[0].getScale(tmpUp).scl(w[0])); quat.set(t[0].getRotation(quat2).exp(w[0])); tmpForward.set(t[0].getTranslation(tmpUp).scl(w[0])); for (int i = 1; i < t.length; i++) { tmpVec.add(t[i].getScale(tmpUp).scl(w[i])); quat.mul(t[i].getRotation(quat2).exp(w[i])); tmpForward.add(t[i].getTranslation(tmpUp).scl(w[i])); } quat.nor(); setToScaling(tmpVec); rotate(quat); setTranslation(tmpForward); return this; }
/** Averages the given transforms and stores the result in this matrix. Translations and scales are lerped while rotations are * slerped. Does not destroy the data contained in t. * @param t List of transforms * @return This matrix for chaining */ public Matrix4 avg (Matrix4[] t) { final float w = 1.0f / t.length; tmpVec.set(t[0].getScale(tmpUp).scl(w)); quat.set(t[0].getRotation(quat2).exp(w)); tmpForward.set(t[0].getTranslation(tmpUp).scl(w)); for (int i = 1; i < t.length; i++) { tmpVec.add(t[i].getScale(tmpUp).scl(w)); quat.mul(t[i].getRotation(quat2).exp(w)); tmpForward.add(t[i].getTranslation(tmpUp).scl(w)); } quat.nor(); setToScaling(tmpVec); rotate(quat); setTranslation(tmpForward); return this; }
/** Averages the given transforms and stores the result in this matrix. Translations and scales are lerped while rotations are * slerped. Does not destroy the data contained in t. * @param t List of transforms * @return This matrix for chaining */ public Matrix4 avg (Matrix4[] t) { final float w = 1.0f / t.length; tmpVec.set(t[0].getScale(tmpUp).scl(w)); quat.set(t[0].getRotation(quat2).exp(w)); tmpForward.set(t[0].getTranslation(tmpUp).scl(w)); for (int i = 1; i < t.length; i++) { tmpVec.add(t[i].getScale(tmpUp).scl(w)); quat.mul(t[i].getRotation(quat2).exp(w)); tmpForward.add(t[i].getTranslation(tmpUp).scl(w)); } quat.nor(); setToScaling(tmpVec); rotate(quat); setTranslation(tmpForward); return this; }
transform.setTranslation(obtainV3().set(direction).scl(stemLength / 2).add(x1, y1, z1)); builder.setVertexTransform(temp.set(transform).mul(userTransform)); CylinderShapeBuilder.build(builder, stemDiameter, stemLength, stemDiameter, divisions); transform.setTranslation(obtainV3().set(direction).scl(stemLength).add(x1, y1, z1)); builder.setVertexTransform(temp.set(transform).mul(userTransform)); ConeShapeBuilder.build(builder, coneDiameter, coneHeight, coneDiameter, divisions);
transform.setTranslation(obtainV3().set(direction).scl(stemLength / 2).add(x1, y1, z1)); builder.setVertexTransform(temp.set(transform).mul(userTransform)); CylinderShapeBuilder.build(builder, stemDiameter, stemLength, stemDiameter, divisions); transform.setTranslation(obtainV3().set(direction).scl(stemLength).add(x1, y1, z1)); builder.setVertexTransform(temp.set(transform).mul(userTransform)); ConeShapeBuilder.build(builder, coneDiameter, coneHeight, coneDiameter, divisions);
public void setTranslation (Vector3 translation) { this.transform.setTranslation(translation); }
private void checkNextLevel () { if (invaders.size() == 0 && ship.lives > 0) { blocks.clear(); shots.clear(); shipShot = null; ship.transform.getTranslation(tmpV1); int lives = ship.lives; populate(); ship.transform.setTranslation(tmpV1); ship.lives = lives; multiplier += 0.2f; wave++; } }
public static void applyTransform(Vector3 location, Vector3 rotation, Vector3 scale, ModelInstance modelInstance) { 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(); }
@Override public void update(float deltaTime) { super.update(deltaTime); // Step the tree either directly or through the editor // // TODO: handle this in a better way // Ideally the dog should not know of the tree editor GameScreen.screen.stage.btreeController.step(this, deltaTime); if (stickCarried) { Vector3 mouthPos = getBoneMidpointWorldPosition(DogArmature.HEAD.id, TMP_V1); Vector3 headDirection = getBoneDirection(DogArmature.HEAD.id, TMP_V2); human.stick.modelTransform.setToLookAt(headDirection, TMP_V3.set(Constants.V3_UP).scl(-1)); human.stick.modelTransform.setTranslation(mouthPos); human.stick.body.setWorldTransform(human.stick.modelTransform); } }
@Override public void update(float deltaTime) { super.update(deltaTime); followTransform.getTranslation(worldPos); camera.view.getRotation(quat).conjugate(); if (faceUp) { modelInstance.transform.setFromEulerAngles(quat.getYaw(), -90, quat.getRoll()); } else { modelInstance.transform.set(quat); } modelInstance.transform.setTranslation(worldPos.add(offset)); } }
/** Averages the given transform with this one and stores the result in this matrix. Translations and scales are lerped while * rotations are slerped. * @param other The other transform * @param w Weight of this transform; weight of the other transform is (1 - w) * @return This matrix for chaining */ public Matrix4 avg (Matrix4 other, float w) { getScale(tmpVec); other.getScale(tmpForward); getRotation(quat); other.getRotation(quat2); getTranslation(tmpUp); other.getTranslation(right); setToScaling(tmpVec.scl(w).add(tmpForward.scl(1 - w))); rotate(quat.slerp(quat2, 1 - w)); setTranslation(tmpUp.scl(w).add(right.scl(1 - w))); return this; }