本文整理了Java中com.badlogic.gdx.math.Matrix4.setToScaling()
方法的一些代码示例,展示了Matrix4.setToScaling()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix4.setToScaling()
方法的具体详情如下:
包路径:com.badlogic.gdx.math.Matrix4
类名称:Matrix4
方法名:setToScaling
[英]Sets this matrix to a scaling matrix
[中]将此矩阵设置为缩放矩阵
代码示例来源:origin: libgdx/libgdx
@Override
protected void onLoaded () {
super.onLoaded();
BoundingBox bounds = instances.get(0).calculateBoundingBox(new BoundingBox());
bounds.getCenter(center);
radius = bounds.getDimensions(tmpV).len() * .5f;
pointLight.position.set(0, radius, 0).add(transformedCenter.set(center).mul(transform));
pointLight.intensity = radius * radius;
((ColorAttribute)pLight.material.get(ColorAttribute.Diffuse)).color.set(pointLight.color);
final float s = 0.2f * radius;
pLight.worldTransform.setToScaling(s, s, s);
}
代码示例来源:origin: libgdx/libgdx
/** 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;
}
代码示例来源:origin: libgdx/libgdx
/** 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;
}
代码示例来源:origin: libgdx/libgdx
/** 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;
}
代码示例来源:origin: libgdx/libgdx
/** 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;
}
代码示例来源:origin: libgdx/libgdx
/** 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;
}
代码示例来源:origin: libgdx/libgdx
/** 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;
}
代码示例来源:origin: libgdx/libgdx
@Override
public void create () {
if (spriteBatch != null) return;
spriteBatch = new SpriteBatch();
Matrix4 transform = new Matrix4();
transform.setToTranslation(0, Gdx.graphics.getHeight(), 0);
transform.mul(new Matrix4().setToScaling(1, -1, 1));
spriteBatch.setTransformMatrix(transform);
pixS1 = new Pixmap(Gdx.files.getFileHandle("data/test4.png", Files.FileType.Internal));
pixS2 = new Pixmap(Gdx.files.getFileHandle("data/test3.png", Files.FileType.Internal));
pixD = new Pixmap(512, 1024, Pixmap.Format.RGBA8888);
pixD.setBlending(Pixmap.Blending.SourceOver);
pixD.setFilter(Pixmap.Filter.NearestNeighbour);
pixD.drawPixmap(pixS1, 0, 0, 38, 76, 0, 0, 512, 1024);
pixD.drawPixmap(pixS2, 0, 0, 38, 76, 0, 0, 512, 1024);
logoSprite = new Sprite(new Texture(pixD));
logoSprite.flip(false, true);
pixS1.dispose();
pixS2.dispose();
pixD.dispose();
}
代码示例来源:origin: langurmonkey/gaiasky
@Override
public void box(float width, float height, float depth) {
box(matTmp1.setToScaling(width, height, depth));
}
代码示例来源:origin: langurmonkey/gaiasky
@Override
public void box(float x, float y, float z, float width, float height, float depth) {
box(matTmp1.setToScaling(width, height, depth).trn(x, y, z));
}
代码示例来源:origin: com.harium.etyl/etyl-gdx-util
/** 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;
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
/** 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;
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
/** 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;
}
代码示例来源:origin: com.harium.etyl/etyl-gdx-util
/** 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;
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
/** 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;
}
代码示例来源:origin: com.harium.etyl/etyl-gdx-util
/** 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;
}
内容来源于网络,如有侵权,请联系作者删除!