本文整理了Java中com.badlogic.gdx.math.Matrix4.setToRotation()
方法的一些代码示例,展示了Matrix4.setToRotation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix4.setToRotation()
方法的具体详情如下:
包路径:com.badlogic.gdx.math.Matrix4
类名称:Matrix4
方法名:setToRotation
[英]Sets the matrix to a rotation matrix around the given axis.
[中]将矩阵设置为围绕给定轴的旋转矩阵。
代码示例来源:origin: libgdx/libgdx
/** Rotates this vector by the given angle in degrees around the given axis.
*
* @param degrees the angle in degrees
* @param axisX the x-component of the axis
* @param axisY the y-component of the axis
* @param axisZ the z-component of the axis
* @return This vector for chaining */
public Vector3 rotate (float degrees, float axisX, float axisY, float axisZ) {
return this.mul(tmpMat.setToRotation(axisX, axisY, axisZ, degrees));
}
代码示例来源:origin: libgdx/libgdx
/** Rotates this vector by the given angle in degrees around the given axis.
*
* @param axis the axis
* @param degrees the angle in degrees
* @return This vector for chaining */
public Vector3 rotate (final Vector3 axis, float degrees) {
tmpMat.setToRotation(axis, degrees);
return this.mul(tmpMat);
}
代码示例来源:origin: libgdx/libgdx
/** Rotates this vector by the given angle in degrees around the given axis.
*
* @param degrees the angle in degrees
* @param axisX the x-component of the axis
* @param axisY the y-component of the axis
* @param axisZ the z-component of the axis
* @return This vector for chaining */
public Vector3 rotate (float degrees, float axisX, float axisY, float axisZ) {
return this.mul(tmpMat.setToRotation(axisX, axisY, axisZ, degrees));
}
代码示例来源:origin: libgdx/libgdx
/** Rotates this vector by the given angle in degrees around the given axis.
*
* @param axis the axis
* @param degrees the angle in degrees
* @return This vector for chaining */
public Vector3 rotate (final Vector3 axis, float degrees) {
tmpMat.setToRotation(axis, degrees);
return this.mul(tmpMat);
}
代码示例来源:origin: libgdx/libgdx
/** 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;
}
代码示例来源:origin: libgdx/libgdx
@Override
public boolean touchDragged (int x, int y, int pointer) {
if (pointer != 0) return false;
delta.set(x, y).sub(last);
if (mode == TransformMode.Rotate) {
point.set(cam.position).sub(lookAt);
if (tmpV.set(point).nor().dot(yAxis) < 0.9999f) {
xAxis.set(cam.direction).crs(yAxis).nor();
rotMatrix.setToRotation(xAxis, delta.y / 5);
point.mul(rotMatrix);
}
rotMatrix.setToRotation(yAxis, -delta.x / 5);
point.mul(rotMatrix);
cam.position.set(point.add(lookAt));
cam.lookAt(lookAt.x, lookAt.y, lookAt.z);
}
if (mode == TransformMode.Zoom) {
cam.fieldOfView -= -delta.y / 10;
}
if (mode == TransformMode.Translate) {
tCurr.set(x, y);
translated = true;
}
cam.update();
last.set(x, y);
return true;
}
代码示例来源:origin: libgdx/libgdx
/** 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;
}
代码示例来源:origin: libgdx/libgdx
@Override
public void render () {
angle += Gdx.graphics.getDeltaTime() * 45;
matrix.setToRotation(axis, angle);
Mesh meshToDraw = Gdx.input.isButtonPressed(0) ? meshCustomVA : mesh;
Gdx.gl20.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
Gdx.gl20.glClearColor(0.2f, 0.2f, 0.2f, 1);
Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
Gdx.gl20.glEnable(GL20.GL_TEXTURE_2D);
Gdx.gl20.glEnable(GL20.GL_BLEND);
Gdx.gl20.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
texture.bind();
shader.begin();
shader.setUniformMatrix("u_worldView", matrix);
shader.setUniformi("u_texture", 0);
meshToDraw.render(shader, GL20.GL_TRIANGLES);
shader.end();
}
代码示例来源:origin: libgdx/libgdx
float[] fvecs = {1, 2, 3, 0, 0, 1, 2, 3, 0, 0, 1, 2, 3, 0, 0};
mat1.setToRotation(0, 1, 0, 45);
mat2.setToRotation(1, 0, 0, 45);
代码示例来源:origin: libgdx/libgdx
@Override
public void render () {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);
angle += Gdx.graphics.getDeltaTime() * 20.0f;
cubeTrans.setToRotation(Vector3.Y, angle);
cam.update();
projector.update();
texture.bind();
projTexShader.begin();
if (camera.getSelectedIndex() == 0) {
renderMesh(projTexShader, cam.combined, projector.combined, planeTrans, plane, Color.WHITE);
/*
* TODO: Fix method rendering renderMesh(projTexShader, cam.combined, projector.combined, cubeTrans, cube, Color.WHITE);
*/
} else {
renderMesh(projTexShader, projector.combined, projector.combined, planeTrans, plane, Color.WHITE);
/*
* TODO: Fix method rendering renderMesh(projTexShader, projector.combined, projector.combined, cubeTrans, cube,
* Color.WHITE);
*/
}
projTexShader.end();
fps.setText("fps: " + Gdx.graphics.getFramesPerSecond());
ui.act();
ui.draw();
}
代码示例来源:origin: libgdx/libgdx
@Override
public void render () {
angle += Gdx.graphics.getDeltaTime() * 40.0f;
float aspect = Gdx.graphics.getWidth() / (float)Gdx.graphics.getHeight();
projection.setToProjection(1.0f, 20.0f, 60.0f, aspect);
view.idt().trn(0, 0, -2.0f);
model.setToRotation(axis, angle);
combined.set(projection).mul(view).mul(model);
Gdx.gl20.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
shader.begin();
shader.setUniformMatrix("u_mvpMatrix", combined);
mesh.render(shader, GL20.GL_TRIANGLES);
shader.end();
Gdx.app.log("angle", "" + angle);
}
}
代码示例来源:origin: libgdx/libgdx
public void render () {
angle += 45 * Gdx.graphics.getDeltaTime();
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
cam.update();
matrix.setToRotation(0, 1, 0, angle);
cam.combined.mul(matrix);
fbo.begin();
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);
modelBatch.begin(cam);
modelBatch.render(sceneInstance);
modelBatch.end();
fbo.end();
batch.begin();
batch.disableBlending();
batchShader.setUniformi("u_filterSize", filter.length);
batchShader.setUniform1fv("u_filter", filter, 0, filter.length);
batchShader.setUniform2fv("u_offsets", offsets, 0, offsets.length);
batch.draw(fboRegion, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
batch.end();
logger.log();
}
}
代码示例来源:origin: libgdx/libgdx
BoundingBox bbox = new BoundingBox();
character.calculateBoundingBox(bbox);
character.transform.setToRotation(Vector3.Y, 180).trn(0, -bbox.min.y, 0);
instances.add(character);
animation = new AnimationController(character);
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
private void lookat(float angle) {
((ModelCacheEntry) currentSource).modelInstance.transform.setToRotation(Vector3.Y, angle);
modelRotation = angle;
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
/** Rotates this vector by the given angle in degrees around the given axis.
*
* @param axis the axis
* @param degrees the angle in degrees
* @return This vector for chaining */
public Vector3 rotate (final Vector3 axis, float degrees) {
tmpMat.setToRotation(axis, degrees);
return this.mul(tmpMat);
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
/** Rotates this vector by the given angle in degrees around the given axis.
*
* @param degrees the angle in degrees
* @param axisX the x-component of the axis
* @param axisY the y-component of the axis
* @param axisZ the z-component of the axis
* @return This vector for chaining */
public Vector3 rotate (float degrees, float axisX, float axisY, float axisZ) {
return this.mul(tmpMat.setToRotation(axisX, axisY, axisZ, degrees));
}
代码示例来源:origin: com.harium.etyl/etyl-gdx-util
/** Rotates this vector by the given angle in degrees around the given axis.
*
* @param axis the axis
* @param degrees the angle in degrees
* @return This vector for chaining */
public Vector3 rotate (final Vector3 axis, float degrees) {
tmpMat.setToRotation(axis, degrees);
return this.mul(tmpMat);
}
代码示例来源:origin: com.harium.etyl/etyl-gdx-util
/** Rotates this vector by the given angle in degrees around the given axis.
*
* @param degrees the angle in degrees
* @param axisX the x-component of the axis
* @param axisY the y-component of the axis
* @param axisZ the z-component of the axis
* @return This vector for chaining */
public Vector3 rotate (float degrees, float axisX, float axisY, float axisZ) {
return this.mul(tmpMat.setToRotation(axisX, axisY, axisZ, degrees));
}
代码示例来源:origin: stackoverflow.com
Matrix4 mx4Font = new Matrix4();
BitmapFont font;
SpriteBatch spriteFont;
font = new BitmapFont(Gdx.files.internal("data/font/agencyFB.fnt"), Gdx.files.internal("data/font/agencyFB.png"), true); //must be set true to be flipped
mx4Font.setToRotation(new Vector3(200, 200, 0), 180);
spriteFont.setTransformMatrix(mx4Font);
spriteFont.begin();
font.setColor(1.0f, 1.0f, 1.0f, 1.0f);
font.draw(spriteFont, "The quick brown fox jumped over the lazy dog", 100, 110);
spriteFont.end();
代码示例来源:origin: jsjolund/GdxDemo3D
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;
hasStick = false;
}
内容来源于网络,如有侵权,请联系作者删除!