Skip to content

Commit e34544c

Browse files
committed
Support scale in NameTag and FloatingText
1 parent d5861d2 commit e34544c

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

engine/src/main/java/org/terasology/logic/nameTags/NameTagClientSystem.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ private void createOrUpdateNameTagFor(EntityRef entity, NameTagComponent nameTag
6868
FloatingTextComponent floatingText = nameTag.getComponent(FloatingTextComponent.class);
6969
floatingText.text = nameTagComponent.text;
7070
floatingText.textColor = nameTagComponent.textColor;
71+
floatingText.scale = nameTagComponent.scale;
7172
nameTag.saveComponent(floatingText);
7273
LocationComponent nameTagLoc = nameTag.getComponent(LocationComponent.class);
7374
nameTagLoc.setLocalPosition(offset);
@@ -80,6 +81,7 @@ private void createOrUpdateNameTagFor(EntityRef entity, NameTagComponent nameTag
8081
nameTagBuilder.addComponent(locationComponent);
8182
floatingTextComponent.text = nameTagComponent.text;
8283
floatingTextComponent.textColor = nameTagComponent.textColor;
84+
floatingTextComponent.scale = nameTagComponent.scale;
8385
nameTagBuilder.setOwner(entity);
8486
nameTagBuilder.setPersistent(false);
8587

engine/src/main/java/org/terasology/logic/nameTags/NameTagComponent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ public class NameTagComponent implements Component {
3535

3636
public Color textColor = Color.WHITE;
3737

38+
public float scale = 1f;
3839
}

engine/src/main/java/org/terasology/rendering/logic/FloatingTextComponent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ public class FloatingTextComponent implements Component {
2525
public String text;
2626
public Color textColor = Color.WHITE;
2727
public Color textShadowColor = Color.BLACK;
28+
public float scale = 1f;
2829
}

engine/src/main/java/org/terasology/rendering/logic/FloatingTextRenderer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,11 @@ private void render(Iterable<EntityRef> floatingTextEntities) {
116116
}
117117
glPushMatrix();
118118

119+
float scale = METER_PER_PIXEL * floatingText.scale;
119120

120121
glTranslated(worldPos.x - cameraPosition.x, worldPos.y - cameraPosition.y, worldPos.z - cameraPosition.z);
121122
OpenGLUtil.applyBillboardOrientation();
122-
glScaled(METER_PER_PIXEL, -METER_PER_PIXEL, METER_PER_PIXEL);
123+
glScaled(scale, -scale, scale);
123124
glTranslated(-textWidth / 2.0, 0.0, 0.0);
124125
for (Map.Entry<Material, Mesh> meshMapEntry : meshMap.entrySet()) {
125126
Mesh mesh = meshMapEntry.getValue();

0 commit comments

Comments
 (0)