CCTile3DButton::CCTile3DButton(CCSceneBase *scene, const float width, const char *textureName) { construct( scene ); const CCTextureBase *texture = gEngine->textureManager->getTexture( textureName, Resource_Packaged ); const float aspectRatio = texture->getImageWidth() / texture->getImageHeight(); const float height = width / aspectRatio; setupBase( width, height ); setBaseTexture( textureName, Resource_Packaged ); }
CCTile3DButton::CCTile3DButton(CCSceneBase *scene, const float width, const float height, const char *text) { construct( scene ); setupBase( width, height ); if( text ) { textModel->setText( text, height ); } }
void CCTile3DScrollBar::resize(const float cameraY, const float cameraWidth, const float cameraHeight, const float sceneTopY, const float sceneBottomY) { const float cameraHHeight = cameraHeight * 0.5f; topY = sceneTopY; bottomY = sceneBottomY; const float sceneHeight = ( topY + cameraHHeight ) - ( bottomY - cameraHHeight ); const float viewPercentage = cameraHeight / sceneHeight; const float scrollBarHeight = viewPercentage * cameraHeight; setupBase( 1.0f, scrollBarHeight ); reposition( cameraY, cameraWidth, cameraHeight ); }
void TileSocialPhoto::setSize(const float inSize) { if( size != inSize ) { size = inSize; // Set our desired size setupBase( inSize, inSize ); // // If we've resized the photo based off the texture size, do it again // if( baseSquare->usesTexture != NULL ) // { // baseSquare->adjustTextureUVs(); // } } }
TileSocial::TileSocial(CCSceneBase *scene, const float width, const float height, const char *text) : CCTile3DButton( scene ) { drawOrder = 200; borderWidth = 1.0f; backgroundSquare = new CCPrimitiveSquare(); model->addPrimitive( backgroundSquare ); model->setColour( CCColour( 1.0f, 0.5f ) ); model->setOutline( CCColourInt( 232 ) ); setupBase( width, height ); textModel->setColour( CCColour() ); if( text != NULL ) { textModel->setText( text, collisionBoundsLength.y ); } rotationSpeed = 180.0f; }
template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar> int pcl::registration::FPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::selectBase ( std::vector <int> &base_indices, float (&ratio)[2]) { const float too_close_sqr = max_base_diameter_sqr_*0.01; Eigen::VectorXf coefficients (4); pcl::SampleConsensusModelPlane <PointTarget> plane (target_); plane.setIndices (target_indices_); Eigen::Vector4f centre_pt; float nearest_to_plane = FLT_MAX; // repeat base search until valid quadruple was found or ransac_iterations_ number of trys were unsuccessfull for (int i = 0; i < ransac_iterations_; i++) { // random select an appropriate point triple if (selectBaseTriangle (base_indices) < 0) continue; std::vector <int> base_triple (base_indices.begin (), base_indices.end () - 1); plane.computeModelCoefficients (base_triple, coefficients); pcl::compute3DCentroid (*target_, base_triple, centre_pt); // loop over all points in source cloud to find most suitable fourth point const PointTarget *pt1 = &(target_->points[base_indices[0]]); const PointTarget *pt2 = &(target_->points[base_indices[1]]); const PointTarget *pt3 = &(target_->points[base_indices[2]]); for (std::vector <int>::iterator it = target_indices_->begin (), it_e = target_indices_->end (); it != it_e; it++) { const PointTarget *pt4 = &(target_->points[*it]); float d1 = pcl::squaredEuclideanDistance (*pt4, *pt1); float d2 = pcl::squaredEuclideanDistance (*pt4, *pt2); float d3 = pcl::squaredEuclideanDistance (*pt4, *pt3); float d4 = (pt4->getVector3fMap () - centre_pt.head (3)).squaredNorm (); // check distance between points w.r.t minimum sampling distance; EDITED -> 4th point now also limited by max base line if (d1 < too_close_sqr || d2 < too_close_sqr || d3 < too_close_sqr || d4 < too_close_sqr || d1 > max_base_diameter_sqr_ || d2 > max_base_diameter_sqr_ || d3 > max_base_diameter_sqr_) continue; // check distance to plane to get point closest to plane float dist_to_plane = pcl::pointToPlaneDistance (*pt4, coefficients); if (dist_to_plane < nearest_to_plane) { base_indices[3] = *it; nearest_to_plane = dist_to_plane; } } // check if at least one point fullfilled the conditions if (nearest_to_plane != FLT_MAX) { // order points to build largest quadrangle and calcuate intersection ratios of diagonals setupBase (base_indices, ratio); return (0); } } // return unsuccessfull if no quadruple was selected return (-1); }