0
我正在嘗試在文本中使用ModelBatch在LibGDX中的場景。爲了更詳細地解釋,我們假設我有一個類MyOBJ。3D空間中的文本
class MyOBJ {
private Model model;
private ModelInstance modelInstance;
public MyOBJ() {
// initialize model, texture and modelInstance.
// for simplicity let's assume this is a sphere
ModelBuilder modelBuilder = new ModelBuilder();
model = modelBuilder.createSphere(...);
instance = new ModelInstance(model);
}
public void render(ModelBatch modelBatch) {
modelBatch.render(this.instance);
}
}
現在,我想在球體下面有一個文本(如標籤)。所以即使相機旋轉或移動,它仍然是可讀的,並在球體下面。
我知道使用SpriteBatch呈現文本,但是,我似乎無法將SpriteBatch(巫婆是2D)集成到3D模型中。任何建議/幫助表示讚賞。
你所要求的是一個非常複雜的話題,它需要比Stack Overflow提供的習慣更多的解釋。我建議在YouTube上搜索教程,特別是在ThinMatrix中搜索,他在lwjgl中有一個文本渲染教程,很可能很容易將其轉換爲LibGDX,因爲您試圖做的真正的肉會歸結爲沉重的數學。 – CraigR8806
我明白了。我雖然LibGDX已經提供了一些在文檔中找不到的2D和3D組合的機制。我會嘗試你的建議。謝謝。 –
真的不是那麼難。您可以將3D變換矩陣傳遞給SpriteBatch以更改繪製所有內容的平面。在這個網站有一個問題,這是解釋。 – Tenfour04