本文整理匯總了Java中com.badlogic.gdx.math.Matrix4類的典型用法代碼示例。如果您正苦於以下問題:Java Matrix4類的具體用法?Java Matrix4怎麽用?Java Matrix4使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Matrix4類屬於com.badlogic.gdx.math包,在下文中一共展示了Matrix4類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Basic
import com.badlogic.gdx.math.Matrix4; //導入依賴的package包/類
public Basic(Matrix4 transform, double speeed, int hp, int health, int range, float coolDown, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance instance, btCollisionWorld world, IntMap<Entity> entities, List<Vector3> path, Map<String, Sound> sounds) {
super(transform, speeed, hp, health, range, coolDown, types, effects, instance, new btCompoundShape(), world, entities, ATTACK_ANIMATION, ATTACK_OFFSET, path, sounds);
((btCompoundShape)shape).addChildShape(new Matrix4(new Vector3(0, 30, 0), new Quaternion().setEulerAngles(0, 0, 0), new Vector3(1, 1, 1)), new btBoxShape(new Vector3(75, 30, 90)));
//System.out.println(getModelInstance().getAnimation("Spider_Armature|walk_ani_vor").id);
listener = new AnimationController.AnimationListener() {
@Override
public void onEnd(AnimationController.AnimationDesc animationDesc) {
}
@Override
public void onLoop(AnimationController.AnimationDesc animationDesc) {
}
};
//animation.setAnimation("Spider_Armature|walk_ani_vor");
//animation.animate("Spider_Armature|walk_ani_vor", -1);
//animation.action("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0);
//animation.animate("Spider_Armature|Attack", 0, 1000, 1, 1, listener, 0);
//animation.queue("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0);
}
示例2: tick
import com.badlogic.gdx.math.Matrix4; //導入依賴的package包/類
public void tick(float delta, GameScreen screen) {
if (!started && screen.isPaused()) {
started = true;
prevTime = System.currentTimeMillis();
}
if (spawns != null && enemyIndex < spawns.size() && System.currentTimeMillis() > prevTime + spawns.get(enemyIndex).getDelay()) {
prevTime = System.currentTimeMillis();
String name = spawns.get(enemyIndex).getName();
ModelInstance instance;
try {
Class<?> c = enemyClasses.get(name);
Constructor constructor = c.getConstructor(Matrix4.class, Map.class, btCollisionWorld.class, IntMap.class, List.class, Map.class);
enemies.add((Enemy) constructor.newInstance(new Matrix4().setToTranslation(pos), models, world, entity, path, sounds));
} catch (Exception e) {
Gdx.app.log("EnemySpawner spawn enemy", e.toString());
}
enemyIndex++;
}
//for (Enemy enemy : enemies)
// enemy.tick(delta, path);
}
示例3: GLToClipTransform
import com.badlogic.gdx.math.Matrix4; //導入依賴的package包/類
public static void GLToClipTransform(Matrix4 transformOut) {
if(null == transformOut) return;
Director director = Director.getInstance();
Matrix4 projection = director.getMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_PROJECTION);
Matrix4 modelview = director.getMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_MODELVIEW);
// System.out.println(projection);
// System.out.println(modelview);
//?
transformOut.set(projection);
transformOut.mul(modelview);
// *transformOut = projection * modelview;
}
示例4: getViewMatrix
import com.badlogic.gdx.math.Matrix4; //導入依賴的package包/類
/**
* Gets the camera's view matrix.
*
* @return The camera view matrix.
*/
public Matrix4 getViewMatrix() {
// Mat4 viewInv(getNodeToWorldTransform());
_viewInv.set(getNodeToWorldTransform());
// static int count = sizeof(float) * 16;
// if (memcmp(viewInv.m, _viewInv.m, count) != 0)
// {
_viewProjectionDirty = true;
_frustumDirty = true;
// _viewInv = viewInv;
// _view = viewInv.getInversed();
_view.set(_viewInv).inv();
// }
return _view;
// ViewPort vp;
// com.badlogic.gdx.graphics.glutils
}
示例5: drawBg
import com.badlogic.gdx.math.Matrix4; //導入依賴的package包/類
public void drawBg(Batch batch, float parentAlpha) {
batch.end();
Gdx.gl.glLineWidth(1.0f);
Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
shapeRenderer.setProjectionMatrix(getStage().getCamera().combined);
Matrix4 matrix = batch.getTransformMatrix();
shapeRenderer.setTransformMatrix(matrix);
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
BG.a = parentAlpha;
shapeRenderer.setColor(BG);
shapeRenderer.rect(getX(), getY(), getWidth(), getHeight());
shapeRenderer.end();
Gdx.gl.glDisable(GL20.GL_BLEND);
batch.begin();
batch.setColor(Color.WHITE.r, Color.WHITE.g, Color.WHITE.b, Color.WHITE.a * parentAlpha);
}
示例6: GameScreen
import com.badlogic.gdx.math.Matrix4; //導入依賴的package包/類
public GameScreen(){
spriteBatch = new SpriteBatch(); // buffer ok
texture = new Texture(Gdx.files.internal("bg/gameBG.jpg"));
viewMatrix = new Matrix4(); // matriz de visualização
tranMatrix = new Matrix4(); // matriz de escala
// camera
camera = new PerspectiveCamera(67.0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.near = 0.1f;
camera.far = 1000f;
camera.position.set(0, 5, 10);
camera.lookAt(0, 5, 0);
camera.update();
// ambiente
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1,1,1,1));
// renderizador
modelBatch = new ModelBatch();
p1 = new Player(1);
p2 = new Player(2);
}
示例7: LevelScreen
import com.badlogic.gdx.math.Matrix4; //導入依賴的package包/類
public LevelScreen(String mapName, float rot) {
this.rot = rot;
this.mapName = mapName;
this.inputMapper = new InputMapper(AL.getInputConfig());
inputMapper.registerInputHanlder(IInputConfig.InputKeys.up, new MoveEventHandler(new Vector2(0, 1)));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.down, new MoveEventHandler(new Vector2(0, -1)));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.right, new MoveEventHandler(new Vector2(1, 0)));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.left, new MoveEventHandler(new Vector2(-1, 0)));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.ability1, new AbillityEventHandler(Character.ABILITY_1));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.ability2, new AbillityEventHandler(Character.ABILITY_2));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.ability3, new AbillityEventHandler(Character.ABILITY_3));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.ability4, new AbillityEventHandler(Character.ABILITY_4));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.trait, new AbillityEventHandler(Character.TRAIT));
rotationMatrix = new Matrix4().rotate(Vector3.X, rot);
cameraVector = new Vector3(0, 1, 1);
cameraVector.mul(rotationMatrix);
invRotationMatrix = rotationMatrix.cpy().inv();
lastMousePos = new Vector2(Gdx.input.getX(), Gdx.input.getY());
tempVec = new Vector3();
}
示例8: UpdateViewMatrix
import com.badlogic.gdx.math.Matrix4; //導入依賴的package包/類
/**
* Update camera's matrix
*/
private void UpdateViewMatrix()
{
Matrix4 cameraRotation = new Matrix4();
cameraRotation = Utils.createRotate(updownRot, leftrightRot, 0f, cameraRotation);
Vector3 cameraOriginalTarget = new Vector3(0, 0, -1);
Vector3 cameraOriginalUpVector = new Vector3(0, 1, 0);
// cameraRotation.rotate(1, 0, 0, cameraOriginalTarget.x);
Vector3 cameraRotatedTarget = Utils.Transform(cameraOriginalTarget, cameraRotation);
Vector3 cameraFinalTarget = Utils.addVector(position,cameraRotatedTarget);
up.set(Utils.Transform(cameraOriginalUpVector, cameraRotation));
view.setToLookAt(position, cameraFinalTarget, up);
float aspect = viewportWidth / viewportHeight;
projection.setToProjection(Math.abs(near), Math.abs(far), fieldOfView, aspect);
combined.set(projection);
Matrix4.mul(combined.val, view.val);
invProjectionView.set(combined);
Matrix4.inv(invProjectionView.val);
frustum.update(invProjectionView);
}
示例9: updateFrustum
import com.badlogic.gdx.math.Matrix4; //導入依賴的package包/類
public void updateFrustum()
{
invProjectionView.set(combined);
Matrix4.inv(invProjectionView.val);
frustum.update(invProjectionView);
needUpdateFrustum = false;
}
示例10: IngameMenu
import com.badlogic.gdx.math.Matrix4; //導入依賴的package包/類
/**
* Initialisierung.
*
* @param game Zugriff auf die Spielinstanz
* @param level Zugriff auf die aktive Levelinstanz
*/
public IngameMenu(SchoolGame game, Level level)
{
this.game = game;
this.level = level;
titleFont = game.getTitleFont();
textFont = game.getDefaultFont();
smallFont = game.getLongTextFont();
selectSound = game.getAudioManager().createSound("menu", "select.wav", true);
changeSound = game.getAudioManager().createSound("menu", "change.wav", true);
batch = new SpriteBatch();
shapeRenderer = new ShapeRenderer();
localeBundle = level.getLocaleBundle();
fontLayout = new GlyphLayout();
projection = new Matrix4();
}
示例11: draw
import com.badlogic.gdx.math.Matrix4; //導入依賴的package包/類
@Override
public void draw(Batch batch) {
age += Gdx.graphics.getDeltaTime();
final float progress = age * INV_LIFETIME;
final float currentSize = Interpolation.pow2In.apply(size, 0, progress);
final float currentRotation = Interpolation.sine.apply(0, TOTAL_ROTATION, progress);
final Matrix4 original = batch.getTransformMatrix().cpy();
final Matrix4 rotated = batch.getTransformMatrix();
final float disp =
+ 0.5f * (size - currentSize) // the smaller, the more we need to "push" to center
+ currentSize * 0.5f; // center the cell for rotation
rotated.translate(pos.x + disp, pos.y + disp, 0);
rotated.rotate(0, 0, 1, currentRotation);
rotated.translate(currentSize * -0.5f, currentSize * -0.5f, 0); // revert centering for rotation
batch.setTransformMatrix(rotated);
Cell.draw(color, batch, 0, 0, currentSize);
batch.setTransformMatrix(original);
}
示例12: Transform
import com.badlogic.gdx.math.Matrix4; //導入依賴的package包/類
/**
* Transform a Vector3 using a Transformation Matrix
*
* @param vector
* Vector to transform
* @param transform
* The Transformation matrix
* @return
*/
public static Vector3 Transform(Vector3 vector, Matrix4 transform) {
Vector3 result = new Vector3((vector.x * transform.val[Matrix4.M00])
+ (vector.y * transform.val[Matrix4.M10])
+ (vector.z * transform.val[Matrix4.M20])
+ transform.val[Matrix4.M30],
(vector.x * transform.val[Matrix4.M01])
+ (vector.y * transform.val[Matrix4.M11])
+ (vector.z * transform.val[Matrix4.M21])
+ transform.val[Matrix4.M31],
(vector.x * transform.val[Matrix4.M02])
+ (vector.y * transform.val[Matrix4.M12])
+ (vector.z * transform.val[Matrix4.M22])
+ transform.val[Matrix4.M32]);
return result;
}
示例13: updateAxesAndPosition
import com.badlogic.gdx.math.Matrix4; //導入依賴的package包/類
public void updateAxesAndPosition() {
Matrix4 matrix = pose.transform;
matrix.getTranslation(position);
xAxis.set(matrix.val[Matrix4.M00], matrix.val[Matrix4.M10], matrix.val[Matrix4.M20]).nor();
yAxis.set(matrix.val[Matrix4.M01], matrix.val[Matrix4.M11], matrix.val[Matrix4.M21]).nor();
zAxis.set(matrix.val[Matrix4.M02], matrix.val[Matrix4.M12], matrix.val[Matrix4.M22]).nor().scl(-1);
matTmp.set(trackerSpaceToWorldspaceRotationOffset);
positionWorld.set(position).mul(matTmp);
positionWorld.add(trackerSpaceOriginToWorldSpaceTranslationOffset);
matTmp.set(trackerSpaceToWorldspaceRotationOffset);
xAxisWorld.set(xAxis).mul(matTmp);
yAxisWorld.set(yAxis).mul(matTmp);
zAxisWorld.set(zAxis).mul(matTmp);
}
示例14: hmdMat4toMatrix4
import com.badlogic.gdx.math.Matrix4; //導入依賴的package包/類
static void hmdMat4toMatrix4(HmdMatrix44 hdm, Matrix4 mat) {
float[] val = mat.val;
FloatBuffer m = hdm.m();
val[0] = m.get(0);
val[1] = m.get(4);
val[2] = m.get(8);
val[3] = m.get(12);
val[4] = m.get(1);
val[5] = m.get(5);
val[6] = m.get(9);
val[7] = m.get(13);
val[8] = m.get(2);
val[9] = m.get(6);
val[10] = m.get(10);
val[11] = m.get(14);
val[12] = m.get(3);
val[13] = m.get(7);
val[14] = m.get(11);
val[15] = m.get(15);
}
示例15: hmdMat34ToMatrix4
import com.badlogic.gdx.math.Matrix4; //導入依賴的package包/類
static void hmdMat34ToMatrix4(HmdMatrix34 hmd, Matrix4 mat) {
float[] val = mat.val;
FloatBuffer m = hmd.m();
val[0] = m.get(0);
val[1] = m.get(4);
val[2] = m.get(8);
val[3] = 0;
val[4] = m.get(1);
val[5] = m.get(5);
val[6] = m.get(9);
val[7] = 0;
val[8] = m.get(2);
val[9] = m.get(6);
val[10] = m.get(10);
val[11] = 0;
val[12] = m.get(3);
val[13] = m.get(7);
val[14] = m.get(11);
val[15] = 1;
}