void RenderableDebugableEntityItem::render(EntityItem* entity, RenderArgs* args) { if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) { Q_ASSERT(args->_batch); gpu::Batch& batch = *args->_batch; batch.setModelTransform(entity->getTransformToCenter()); // we want to include the scale as well auto nodeList = DependencyManager::get<NodeList>(); const QUuid& myNodeID = nodeList->getSessionUUID(); bool highlightSimulationOwnership = (entity->getSimulatorID() == myNodeID); if (highlightSimulationOwnership) { glm::vec4 greenColor(0.0f, 1.0f, 0.2f, 1.0f); renderBoundingBox(entity, args, 0.08f, greenColor); } quint64 now = usecTimestampNow(); if (now - entity->getLastEditedFromRemote() < 0.1f * USECS_PER_SECOND) { glm::vec4 redColor(1.0f, 0.0f, 0.0f, 1.0f); renderBoundingBox(entity, args, 0.16f, redColor); } if (now - entity->getLastBroadcast() < 0.2f * USECS_PER_SECOND) { glm::vec4 yellowColor(1.0f, 1.0f, 0.2f, 1.0f); renderBoundingBox(entity, args, 0.24f, yellowColor); } ObjectMotionState* motionState = static_cast<ObjectMotionState*>(entity->getPhysicsInfo()); if (motionState && motionState->isActive()) { glm::vec4 blueColor(0.0f, 0.0f, 1.0f, 1.0f); renderBoundingBox(entity, args, 0.32f, blueColor); } } }
void Model::onRender() { // set global OpenGL states glEnable(GL_DEPTH_TEST); glShadeModel(GL_SMOOTH); //// DEBUG: CLOTH SIM /* static CalVector spherePosition; spherePosition.set(Sphere.x, Sphere.y, Sphere.z); static float sphereRadius = 15.0f; // m_calModel->getSpringSystem()->setSphere(spherePosition.x, spherePosition.y, spherePosition.z, sphereRadius); glColor3f(1.0f, 1.0f, 1.0f); glBegin(GL_LINE_STRIP); glVertex3f(spherePosition.x + sphereRadius, spherePosition.y, spherePosition.z); glVertex3f(spherePosition.x, spherePosition.y + sphereRadius, spherePosition.z); glVertex3f(spherePosition.x - sphereRadius, spherePosition.y, spherePosition.z); glVertex3f(spherePosition.x, spherePosition.y - sphereRadius, spherePosition.z); glVertex3f(spherePosition.x + sphereRadius, spherePosition.y, spherePosition.z); glVertex3f(spherePosition.x, spherePosition.y, spherePosition.z + sphereRadius); glVertex3f(spherePosition.x - sphereRadius, spherePosition.y, spherePosition.z); glVertex3f(spherePosition.x, spherePosition.y, spherePosition.z - sphereRadius); glVertex3f(spherePosition.x + sphereRadius, spherePosition.y, spherePosition.z); glVertex3f(spherePosition.x, spherePosition.y + sphereRadius, spherePosition.z); glVertex3f(spherePosition.x, spherePosition.y, spherePosition.z + sphereRadius); glVertex3f(spherePosition.x, spherePosition.y - sphereRadius, spherePosition.z); glVertex3f(spherePosition.x, spherePosition.y, spherePosition.z - sphereRadius); glVertex3f(spherePosition.x, spherePosition.y + sphereRadius, spherePosition.z); glEnd(); */ //// DEBUG END //CalSkeleton *pCalSkeleton = m_calModel->getSkeleton(); // Note : // You have to call coreSkeleton.calculateBoundingBoxes(calCoreModel) // during the initialisation (before calModel.create(calCoreModel)) // if you want to use bounding boxes. m_calModel->getSkeleton()->calculateBoundingBoxes(); // Note: // Uncomment the next lines if you want to test the experimental collision system. // Also remember that you need to call calculateBoundingBoxes() //m_calModel->getSpringSystem()->setForceVector(CalVector(0.0f,0.0f,0.0f)); //m_calModel->getSpringSystem()->setCollisionDetection(true); // check if we need to render the skeleton if(theMenu.isSkeleton()==1) { renderSkeleton(); } else if(theMenu.isSkeleton()==2) { renderBoundingBox(); } // check if we need to render the mesh if(theMenu.isSkeleton()==0 || theMenu.isWireframe()) { renderMesh(theMenu.isWireframe(), theMenu.isLight()); } // clear global OpenGL states glDisable(GL_DEPTH_TEST); }