I'm currently trying to write text over 3D models in a scene.
Of course, this involved projecting the models co-ordinates to screen co-ordinates.
Currently, my render code is like so:
- Code: Select all
public void render(PerspectiveCamera _camera, Array<ModelInstance> _modelInstances)
{
_spriteBatch.setProjectionMatrix(_interfaceCamera.combined);
_spriteBatch.begin();
Vector3 _vector = new Vector3();
_modelInstances.get(4).transform.getTranslation(_vector);
Vector3 _project = _camera.project(_vector);
_font.draw(_spriteBatch, "MARS", _project.x, _project.y);
_spriteBatch.end();
}
So, I'm picking the fourth model instance, getting its co-ordinates and supposedly projecting to screen co-ordinates.
Now, here's the problem.
The draw position is totally off!
The text I believe should be displayed over the fourth planet, yet it appears to float elsewhere.

Thanks for any help!


