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;
}
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);
}
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));
}
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();
}
}
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));
}
Aggregations