// // RenderableDebugableEntityItem.cpp // libraries/entities-renderer/src/ // // Created by Brad Hefta-Gaub on 8/6/14. // Copyright 2014 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include #include #include #include "RenderableDebugableEntityItem.h" void RenderableDebugableEntityItem::renderBoundingBox(RenderArgs* args, bool puffedOut) { EntityItem* entity = dynamic_cast(this); glm::vec3 position = entity->getPosition(); glm::vec3 center = entity->getCenter(); glm::vec3 dimensions = entity->getDimensions(); glm::quat rotation = entity->getRotation(); // float size = glm::length(dimensions) / 2.0f; glm::vec4 greenColor(0.0f, 1.0f, 0.0f, 1.0f); glPushMatrix(); glTranslatef(position.x, position.y, position.z); glm::vec3 axis = glm::axis(rotation); glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); glPushMatrix(); glm::vec3 positionToCenter = center - position; glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z); glScalef(dimensions.x, dimensions.y, dimensions.z); if (puffedOut) { DependencyManager::get()->renderWireCube(1.2f, greenColor); } else { DependencyManager::get()->renderWireCube(1.0f, greenColor); } glPopMatrix(); glPopMatrix(); } void RenderableDebugableEntityItem::render(RenderArgs* args) { EntityItem* entity = dynamic_cast(this); bool debugSimulationOwnership = args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP; if (debugSimulationOwnership) { quint64 now = usecTimestampNow(); if (now - entity->getLastEditedFromRemote() < 0.1f * USECS_PER_SECOND) { renderBoundingBox(args, true); } } }