ObjectNode

Billboard sprite node for game objects, using element.png.

Overview

ObjectNode is a thin wrapper that creates a Urho3D BillboardSet node in the scene and updates its UV coordinates to display a specific icon from the element.png sprite sheet. Used by Decor — one ObjectNode per active game object.

Header: src/GalaxyEggbert/Game/ObjectNode.hpp

Sprite Sheet

FileSizeTile sizeGridTotal icons
Content/Data/Image/element.png600×1740 px60×60 px10 cols × 29 rows290

Icon index → UV: col = iconIdx % 10; row = iconIdx / 10. UV coordinates: u = col/10.0, v = row/29.0, size 1/10 × 1/29.

BillboardSet Config

// Created in ObjectNode constructor:
Node* node = scene->CreateChild();
BillboardSet* bbSet = node->CreateComponent<BillboardSet>();
bbSet->SetNumBillboards(1);
bbSet->SetFaceCameraMode(FC_ROTATE_XYZ);
bbSet->SetMaterial(elementMaterial);  // element.png

API

class ObjectNode {
public:
    ObjectNode(Context* context, Scene* scene, Material* material);

    void SetIcon(int iconIdx);   // updates billboard UV
    void SetPosition(Vector3 pos);
    void Remove();               // removes scene node (permanent)

    Node* GetNode() const;
};

Usage by Decor

When Decor::PlaceObject() is called, a new ObjectNode is created and stored in Object::node. Each frame, Decor::Update() calls node->SetIcon(GetIcon(obj)) and node->SetPosition(obj.pos). When an object is collected or removed, node->Remove() is called and obj.active = false.