Skip to content
This repository has been archived by the owner on Dec 26, 2018. It is now read-only.

[3.0] Tips

Yuya Matsuo edited this page Feb 22, 2017 · 7 revisions

Get world position of nested entities

Vector3f worldPos = entity.getWorldModelMatrix().getTranslation(new Vector3f());

Let Entity look at me

Quaternionf q = new Quaternionf();
Vector3f dir = new Vector3f();
Vector3f up = new Vector3f(0, 1, 0);

entity.getPosition().mul(-1, dir);
q.lookRotate(dir, up).invert();
entity.setRotation(q);

Set Entity's position by yaw, pitch, and distance

// note yaw and pitch are in radians
Vector3f position = new Vector3f(0, 0, distance);
Quaternionf rotation = new Quaternionf()
    .rotateY(yaw)
    .rotateX(pitch);
rotation.transform(position);

entity.setPosition(position);

Render video onto Entity's surface

SurfaceRendererComponent surfaceRenderer = new SurfaceRendererComponent();
surfaceRenderer.setContinuousUpdate(true);
mediaPlayer.setSurface(surfaceRenderer.getSurface());

entity.add(surfaceRenderer);