Skip to content

Commit

Permalink
Merge PR #1939 by @msteiger - scaling text
Browse files Browse the repository at this point in the history
  • Loading branch information
Cervator committed Sep 20, 2015
2 parents 6d61633 + e34544c commit 6db26e0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ private void createOrUpdateNameTagFor(EntityRef entity, NameTagComponent nameTag
FloatingTextComponent floatingText = nameTag.getComponent(FloatingTextComponent.class);
floatingText.text = nameTagComponent.text;
floatingText.textColor = nameTagComponent.textColor;
floatingText.scale = nameTagComponent.scale;
nameTag.saveComponent(floatingText);
LocationComponent nameTagLoc = nameTag.getComponent(LocationComponent.class);
nameTagLoc.setLocalPosition(offset);
Expand All @@ -80,6 +81,7 @@ private void createOrUpdateNameTagFor(EntityRef entity, NameTagComponent nameTag
nameTagBuilder.addComponent(locationComponent);
floatingTextComponent.text = nameTagComponent.text;
floatingTextComponent.textColor = nameTagComponent.textColor;
floatingTextComponent.scale = nameTagComponent.scale;
nameTagBuilder.setOwner(entity);
nameTagBuilder.setPersistent(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.terasology.logic.nameTags;

import org.terasology.entitySystem.Component;
import org.terasology.module.sandbox.API;
import org.terasology.rendering.nui.Color;

/**
Expand All @@ -25,6 +26,7 @@
*
* The color of the name tag is based on the {@link org.terasology.network.ColorComponent} of this entity
*/
@API
public class NameTagComponent implements Component {

public float yOffset = 0.3f;
Expand All @@ -33,4 +35,5 @@ public class NameTagComponent implements Component {

public Color textColor = Color.WHITE;

public float scale = 1f;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ public class FloatingTextComponent implements Component {
public String text;
public Color textColor = Color.WHITE;
public Color textShadowColor = Color.BLACK;
public float scale = 1f;
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ private void render(Iterable<EntityRef> floatingTextEntities) {
}
glPushMatrix();

float scale = METER_PER_PIXEL * floatingText.scale;

glTranslated(worldPos.x - cameraPosition.x, worldPos.y - cameraPosition.y, worldPos.z - cameraPosition.z);
OpenGLUtil.applyBillboardOrientation();
glScaled(METER_PER_PIXEL, -METER_PER_PIXEL, METER_PER_PIXEL);
glScaled(scale, -scale, scale);
glTranslated(-textWidth / 2.0, 0.0, 0.0);
for (Map.Entry<Material, Mesh> meshMapEntry : meshMap.entrySet()) {
Mesh mesh = meshMapEntry.getValue();
Expand Down

0 comments on commit 6db26e0

Please sign in to comment.