#include "InteractiveObject.h"
#include "render/Renderer.h"
#include "render/TextureManager.h"
#include <iostream>
#include <string>

namespace ZL {
    extern const std::string textureUniformName;
}

namespace ZL {

    void InteractiveObject::draw(Renderer& renderer) const {
        if (!isActive || !texture) return;

        std::cout << "[DRAW] InteractiveObject::draw() called" << std::endl;
        std::cout << "[DRAW] Object: " << name << std::endl;
        std::cout << "[DRAW] Position: (" << position.x() << ", " << position.y() << ", " << position.z() << ")" << std::endl;
        
        // Check mesh bounds
        if (!mesh.data.PositionData.empty()) {
            std::cout << "[DRAW] First vertex: (" << mesh.data.PositionData[0].x() << ", " 
                      << mesh.data.PositionData[0].y() << ", " << mesh.data.PositionData[0].z() << ")" << std::endl;
        }

        // Apply position transformation
        renderer.PushMatrix();
        renderer.TranslateMatrix(position);

        renderer.RenderUniform1i(textureUniformName, 0);
        glBindTexture(GL_TEXTURE_2D, texture->getTexID());
        renderer.DrawVertexRenderStruct(mesh);

        renderer.PopMatrix();
    }

} // namespace ZL