void ClippingShader::setClipPlaneParamsNormal(unsigned int id, Geom::Vec3f normal) { // Check if the given id is valid if (errorRaiseWrongId(!isClipPlaneIdValid(id), "ClippingShader::setClipPlaneParamsFirstVec")) return; // Get the corresponding plane index int planeIndex = m_clipPlanesIds[id].index; // Normalize Geom::Vec3f normalNormalized = normal; normalNormalized.normalize(); // Check if it is worth updating values ! if (normalNormalized == m_clipPlanes[planeIndex].normal) return; // Copy the given clipping plane parameter m_clipPlanes[planeIndex].normal = normalNormalized; // Update the plane arrays updateClipPlaneUniformsArray(id); // Send again the whole planes equations array to shader sendClipPlanesEquationsUniform(); }
ClippingPresetAnimatedSpheresCubeCollision::ClippingPresetAnimatedSpheresCubeCollision(Geom::Vec3f center, float size, int spheresCount, float radius) { // Store animation settings m_cubeCenter = center; m_cubeSize = size; int usedSpheresCount = spheresCount; if (usedSpheresCount < 1) usedSpheresCount = 1; // Add spheres to preset for (int i = 0; i < usedSpheresCount; i++) addClipSphere(m_cubeCenter, radius); // Store spheres random directions m_spheresDirections.resize(usedSpheresCount); srand(time(NULL)); for (size_t i = 0; i < m_spheresDirections.size(); i++) { Geom::Vec3f dir ((rand() % 1000) - 500, (rand() % 1000) - 500, (rand() % 1000) - 500); dir.normalize(); m_spheresDirections[i] = dir; } // Set clipping mode setClippingMode(ClippingShader::CLIPPING_MODE_AND); }