Search in sources :

Example 36 with Vector3

use of com.badlogic.gdx.math.Vector3 in project Entitas-Java by Rubentxu.

the class ActuatorEntity method replaceCameraActuator.

public ActuatorEntity replaceCameraActuator(Camera camera, short height, float damping, float minDistanceX, float minDistanceY, String followTagEntity) {
    CameraActuator component = (CameraActuator) recoverComponent(ActuatorComponentsLookup.CameraActuator);
    if (component == null) {
        component = new CameraActuator(camera, height, damping, minDistanceX, minDistanceY, followTagEntity);
    } else {
        component.actuator = (indexOwner) -> {
            Set<GameEntity> followEntities = Indexed.getTagEntities(followTagEntity);
            for (GameEntity followEntity : followEntities) {
                RigidBody rc = followEntity.getRigidBody();
                Transform transform = rc.body.getTransform();
                Vector3 position = camera.position;
                position.x += (transform.getPosition().x + minDistanceX - position.x) * damping;
                position.y += (transform.getPosition().y + minDistanceY - position.y) * height;
            }
        };
    }
    replaceComponent(ActuatorComponentsLookup.CameraActuator, component);
    return this;
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) CameraActuator(ilargia.egdx.logicbricks.component.actuator.CameraActuator) Vector3(com.badlogic.gdx.math.Vector3) RigidBody(ilargia.egdx.logicbricks.component.game.RigidBody) Transform(com.badlogic.gdx.physics.box2d.Transform)

Example 37 with Vector3

use of com.badlogic.gdx.math.Vector3 in project myFirstGame by Juicebox47.

the class VerticalAsteroid method startOver.

@Override
public void startOver(int x) {
    position = new Vector3(random.nextInt(Configuration.WIDTH), x, 0);
    int startingSpeed = -random.nextInt(gameStateManager.getDifficulty().getAsteroidFluctuation()) + gameStateManager.getDifficulty().getMinimumAsteroidVelocity();
    velocity = new Vector3(0, startingSpeed, 0);
}
Also used : Vector3(com.badlogic.gdx.math.Vector3)

Example 38 with Vector3

use of com.badlogic.gdx.math.Vector3 in project myFirstGame by Juicebox47.

the class MyFirstGame method create.

@Override
public void create() {
    spriteBatch = new SpriteBatch();
    gameStateManager = new GameStateManager(new Stack<State>(), new OrthographicCamera(), new Vector3());
    Gdx.gl.glClearColor(0, 0, 0, 0);
    gameStateManager.push(new MenuState(gameStateManager));
}
Also used : OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) Vector3(com.badlogic.gdx.math.Vector3) MenuState(com.mygdx.game.states.MenuState) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) GameStateManager(com.mygdx.game.states.GameStateManager) Stack(java.util.Stack)

Example 39 with Vector3

use of com.badlogic.gdx.math.Vector3 in project bdx by GoranM.

the class GameObject method scale.

public void scale(float x, float y, float z, boolean updateLocal) {
    activate();
    // Set unit scale
    Matrix4 t = modelInstance.transform;
    Matrix4 mat_scale = new Matrix4();
    Vector3 s = new Vector3();
    t.getScale(s);
    mat_scale.scl(1 / s.x, 1 / s.y, 1 / s.z);
    t.mul(mat_scale);
    scale.set(x, y, z);
    // Set target scale
    mat_scale.idt();
    mat_scale.scl(x, y, z);
    t.mul(mat_scale);
    // Relevant bullet body update
    CollisionShape cs = body.getCollisionShape();
    cs.setLocalScaling(new Vector3f(x, y, z));
    if (body.isInWorld() && body.isStaticOrKinematicObject())
        scene.world.updateSingleAabb(body);
    // Child propagation
    Vector3f ps = scale();
    Matrix4f pt = transform();
    Matrix4f ct = new Matrix4f();
    Matrix4f ms = new Matrix4f();
    ms.setIdentity();
    ms.m00 = ps.x;
    ms.m11 = ps.y;
    ms.m22 = ps.z;
    pt.mul(ms);
    for (GameObject c : children) {
        c.scale(scale().mul(c.localScale), false);
        ct.mul(pt, c.localTransform);
        c.transform(ct, false);
    }
    if (parent != null && updateLocal) {
        updateLocalScale();
    }
}
Also used : Matrix4f(javax.vecmath.Matrix4f) CollisionShape(com.bulletphysics.collision.shapes.CollisionShape) Vector3f(javax.vecmath.Vector3f) Vector3(com.badlogic.gdx.math.Vector3) Matrix4(com.badlogic.gdx.math.Matrix4)

Example 40 with Vector3

use of com.badlogic.gdx.math.Vector3 in project bdx by GoranM.

the class Camera method screenPosition.

public Vector2f screenPosition(Vector3f p) {
    Viewport vp = scene.viewport;
    Vector3 out = data.project(new Vector3(p.x, p.y, p.z), vp.x, vp.y, vp.w, vp.h);
    return new Vector2f(Math.round(out.x), Math.round(out.y));
}
Also used : Vector2f(javax.vecmath.Vector2f) Viewport(com.nilunder.bdx.gl.Viewport) Vector3(com.badlogic.gdx.math.Vector3)

Aggregations

Vector3 (com.badlogic.gdx.math.Vector3)64 Matrix4 (com.badlogic.gdx.math.Matrix4)10 Quaternion (com.badlogic.gdx.math.Quaternion)9 Vector2 (com.badlogic.gdx.math.Vector2)6 Node (com.badlogic.gdx.graphics.g3d.model.Node)5 Texture (com.badlogic.gdx.graphics.Texture)4 Model (com.badlogic.gdx.graphics.g3d.Model)4 NodeKeyframe (com.badlogic.gdx.graphics.g3d.model.NodeKeyframe)4 BoundingBox (com.badlogic.gdx.math.collision.BoundingBox)4 VertexAttribute (com.badlogic.gdx.graphics.VertexAttribute)3 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)3 Material (com.badlogic.gdx.graphics.g3d.Material)3 ModelNode (com.badlogic.gdx.graphics.g3d.model.data.ModelNode)3 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)3 Mesh (com.badlogic.gdx.graphics.Mesh)2 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)2 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)2 Animation (com.badlogic.gdx.graphics.g3d.model.Animation)2 MeshPart (com.badlogic.gdx.graphics.g3d.model.MeshPart)2 NodeAnimation (com.badlogic.gdx.graphics.g3d.model.NodeAnimation)2