Prefab


// Contains one or more lights, cameras, static meshes, animated meshes and collision shapes. 
// Items on stack are referenced starting from -1 down.
class RVAPI Prefab
{
public:
    // Check if item exists at stack position [n]. 
    bool IsItem(int n = -1) const;

    // Check if item name matches [name] at stack position [n].
    bool IsItemName(wcstr name, int n = -1) const;

    // Check if item type matches [type] at stack position [n].
    bool IsItemType(wcstr type, int n = -1) const;

    // Check if item is a collision shape at stack position [n].
    bool IsCollShape(int n = -1) const;
        
    // Get item name at stack position [n].
    wcstr GetItemName(int n = -1) const;

    // Get item path at stack position [n].
    wcstr GetItemPath(int n = -1) const;

    // Get item type at stack position [n].
    wcstr GetItemType(int n = -1) const;

    // Get local item position at stack position [n].
    const M4f &GetItemPos(int n = -1) const;

    // Get item child count at stack position [n].
    uint GetItemChildCount(int n = -1) const;

    // Add collision shape at stack position [n] to [body].
    void AddCollShape(Body &body, int n = -1);

    // Push next item onto stack.
    void Push();

    // Pop item from stack.
    void Pop();

    // Open prefab file at [path] from data root, using [pos] as the base position.
    void Open(wcstr path, const M4f &pos = M4fIdent());

    // Close prefab file.
    void Close();

    // Constructor. Open prefab file at [path] from data root, using [pos] as the base position.
    Prefab(wcstr path, const M4f &pos = M4fIdent());

    // Constructor.
    Prefab();

    // Destructor.
    virtual ~Prefab();

private:
    byte wobj[256];
};