Пример #1
0
	std::ostream& Fixpoint::printTo(std::ostream& out, const Indent& indent) const {
		out << indent << "Fixpoint - max iterations: " << maxIterations << " - accepting approximation: " << ((acceptNonFixpoint) ? "true" : "false") << "\n";
		return getTransformation()->printTo(out, indent + 1);
	}
Пример #2
0
void PatternLayer::draw(Graphics* const TheGraphics, const Pnt2f& TopLeft, const Pnt2f& BottomRight, const Real32 Opacity) const
{
    glPushAttrib(GL_ENABLE_BIT | GL_TRANSFORM_BIT);
    GLdouble Plane0[4], Plane1[4], Plane2[4], Plane3[4];
    glGetClipPlane(GL_CLIP_PLANE0, Plane0);
    glGetClipPlane(GL_CLIP_PLANE1, Plane1);
    glGetClipPlane(GL_CLIP_PLANE2, Plane2);
    glGetClipPlane(GL_CLIP_PLANE3, Plane3);

    glEnable(GL_CLIP_PLANE0);
    glEnable(GL_CLIP_PLANE1);
    glEnable(GL_CLIP_PLANE2);
    glEnable(GL_CLIP_PLANE3);

    // The clipping plane for the background must get set to inside the
    // border of the component. It was the outside of the component,
    // so it has to be reset to the stored values from above at the end.
    Vec4d LeftPlaneEquation(1.0,0.0,0.0,-TopLeft.x()),
          RightPlaneEquation(-1.0,0.0,0.0,BottomRight.x()),
          TopPlaneEquation(0.0,1.0,0.0,-TopLeft.y()),
          BottomPlaneEquation(0.0,-1.0,0.0,BottomRight.y());
    
    glClipPlane(GL_CLIP_PLANE0,LeftPlaneEquation.getValues());
    glClipPlane(GL_CLIP_PLANE1,RightPlaneEquation.getValues());
    glClipPlane(GL_CLIP_PLANE2,TopPlaneEquation.getValues());
    glClipPlane(GL_CLIP_PLANE3,BottomPlaneEquation.getValues());

    //Activate the Texture Transformation
    if(getTransformation() != NULL)
    {
        getTransformation()->activate(TheGraphics->getDrawEnv());
    }

    Vec2f BackgroundSize (BottomRight - TopLeft);
    Vec2f TopLeftTexCoords(0.0f,0.0f);
    Vec2f BottomRightTexCoords(1.0f,1.0f);

    Real32 RepeatHorizontal;
    switch(getHorizontalRepeat())
    {
    case PATTERN_REPEAT_ABSOLUTE:
        RepeatHorizontal = getHorizontalRepeatValue();
        break;
    case PATTERN_REPEAT_BY_POINT:
    default:
        RepeatHorizontal = static_cast<Real32>(BottomRight.x() - TopLeft.x())/static_cast<Real32>(getCorrectedPatternSize().x());
        break;
    }

    TopLeftTexCoords[0] = -getHorizontalAlignment() * (RepeatHorizontal -1.0f);
    BottomRightTexCoords[0] = TopLeftTexCoords[0] + RepeatHorizontal;
    
    Real32 RepeatVertical;
    switch(getVerticalRepeat())
    {
    case PATTERN_REPEAT_ABSOLUTE:
        RepeatVertical = getVerticalRepeatValue();
        break;
    case PATTERN_REPEAT_BY_POINT:
    default:
        RepeatVertical = static_cast<Real32>(BottomRight.y() - TopLeft.y())/static_cast<Real32>(getCorrectedPatternSize().y());
        break;
    }
    
    TopLeftTexCoords[1] = -getVerticalAlignment() * (RepeatVertical - 1.0f);
    BottomRightTexCoords[1] = TopLeftTexCoords[1] + RepeatVertical;

    TheGraphics->drawQuad(TopLeft, Pnt2f(BottomRight.x(), TopLeft.y()),BottomRight, Pnt2f(TopLeft.x(), BottomRight.y()),
        TopLeftTexCoords, Vec2f(BottomRightTexCoords.x(), TopLeftTexCoords.y()), BottomRightTexCoords, Vec2f(TopLeftTexCoords.x(), BottomRightTexCoords.y()),
        getColor(), getTexture(), Opacity);

    //Deactivate the Texture Transformation
    if(getTransformation() != NULL)
    {
        getTransformation()->deactivate(TheGraphics->getDrawEnv());
    }

    glPopAttrib();
}
Пример #3
0
	/// @return SpotLight's data structured for GPU use.
	inline GPUData getGPUData() const { return GPUData{glm::vec4(getTransformation().getPosition(), _range),  
															glm::vec4(glm::vec3(getColor()), 0.0), 
															getBiasedMatrix()}; }
Пример #4
0
void	Pan::draw(Shader *shader)
{
    sf::Texture::bind(_texture);
    shader->setUniform("gColor", glm::vec4(1));
    _geometry->draw(shader, getTransformation(), GL_TRIANGLES);
}
Пример #5
0
void		Skybox::draw(gdl::AShader &shader, gdl::Clock const &clock)
{
  (void)clock;
  _texture->bind();
  _geometry.draw(shader, getTransformation(), GL_QUADS);
}
Пример #6
0
void MeshBuilder::transform(const Geometry::Matrix4x4 & m) {
	setTransformation(getTransformation() * m);
}
Пример #7
0
void		GameBackground::draw(gdl::AShader& shader, const gdl::Clock& clock)
{
    (void)clock;
    _texture.bind();
    _geometry.draw(shader, getTransformation(), GL_QUADS);
}
Пример #8
0
aiMatrix4x4 repo::core::RepoNodeMesh::getTransformation() const
{
    return getTransformation(this);
}
Пример #9
0
aiMatrix4x4 repo::core::RepoNodeMesh::getBoundingBoxTransformation() const
{
    return getTransformation() * boundingBox.getTranslationMatrix();
}
Пример #10
0
 //! Sets the final world matrix used in the render system.
 inline void setupTransformation(bool isGlobal)
 {
     FinalWorldMatrix_ = getTransformation(isGlobal).getMatrix();
 }
Пример #11
0
 inline dim::matrix4f getTransformMatrix(bool isGlobal = false) const
 {
     return getTransformation(isGlobal).getMatrix();
 }
Пример #12
0
void		IA::draw(gdl::AShader &shader, gdl::Clock const& clock)
{
  this->_ia.draw(shader, getTransformation(), clock.getElapsed());
}
Пример #13
0
void	Egg::draw(gdl::AShader& shader, gdl::Clock const & clock)
{
  _model->draw(shader, getTransformation(), clock.getElapsed());
}
Пример #14
0
void		Bomb::draw(gdl::AShader &shader, int x, int y)
{
  _position = glm::vec3(x, y, 0);
  _texture.bind();
  _geometry.draw(shader, getTransformation(), GL_QUADS);
}
Пример #15
0
	std::ostream& ForEach::printTo(std::ostream& out, const Indent& indent) const {
		out << indent << "For " << filter << " in " << ((preorder) ? "preorder" : "postorder") << " within " << maxDepth << " levels do\n";
		return getTransformation()->printTo(out, indent + 1);
	}
Пример #16
0
bool Features::featuresBasedTransform(IplImage* object, IplImage* image, IplImage* img1, IplImage* img2, QTransform &transform)
{    
    CvMemStorage* storage = cvCreateMemStorage(0);

    //Búsqueda de features para ambas imágenes.
    CvSeq *objectKeypoints = 0, *objectDescriptors = 0;
    CvSeq *imageKeypoints = 0, *imageDescriptors = 0;
    CvSURFParams params = cvSURFParams(500, 1);
    double tt = (double)cvGetTickCount();
    cvExtractSURF( object, 0, &objectKeypoints, &objectDescriptors, storage, params );
    cvExtractSURF( image, 0, &imageKeypoints, &imageDescriptors, storage, params );    
    tt = (double)cvGetTickCount() - tt;
    if(VERBOSE){
        qDebug() << "Features hallados en la imagen 1:" << objectDescriptors->total;
        qDebug() << "Features hallados en la imagen 2:" << imageDescriptors->total;
        qDebug() << "Tiempo de extraccion:" << tt/(cvGetTickFrequency()*1000.) << "ms." << endl;
    }

    //En caso de ser insuficiente la cantidad de features para alguna de las imágenes, se retorna sin resultado.
    if(objectKeypoints->total < MINPAIRS || imageKeypoints->total < MINPAIRS){
        if(VERBOSE)
            qDebug() << "La cantidad de features encontrados es insuficiente para calcular una transformacion." << endl;       
        cvReleaseMemStorage(&storage);
        return false;
    }

    //Busqueda de correspondencia entre puntos característicos (features).
    vector<int> ptpairs;
    #ifdef USE_FLANN
        Features::flannFindPairs( objectKeypoints, objectDescriptors, imageKeypoints, imageDescriptors, ptpairs );
    #else
        Features::findPairs( objectKeypoints, objectDescriptors, imageKeypoints, imageDescriptors, ptpairs );
    #endif

    //Utils::printPairsInfo(objectKeypoints, imageKeypoints, ptpairs);
    /**************************************************************************************************************/
    Features::filterByDirection(objectKeypoints, imageKeypoints, ptpairs);
    /**************************************************************************************************************/

    //En caso de ser insuficiente la cantidad de puntos de correspondencia, se retorna sin resultado.
    if(VERBOSE)
        qDebug() << "Cantidad de puntos de correspondencia:" << (int)(ptpairs.size()/2) << endl;
    if(ptpairs.size()/2 < MINPAIRS){
        if(VERBOSE)
            qDebug() << "La cantidad de puntos de correspondencia entre las imagenes es insuficiente para calcular una transformacion." << endl;        
        cvReleaseMemStorage(&storage);
        return false;
    }    

    //Búsqueda de los triángulos que determinarán la transformación a realizar.
    vector<int> objTri, imgTri, objSize;
    objTri.reserve(3);
    imgTri.reserve(3);
    objSize.push_back(object->width);
    objSize.push_back(object->height);

    bool goodTriangle = Features::findGoodTriangles(objectKeypoints, imageKeypoints, ptpairs, objSize, objTri, imgTri);
    //En caso de no hallarse los triángulos de manera satisfactoria, se retorna sin resultado.
    if(!goodTriangle){
        if(VERBOSE)
            qDebug() << "Los triangulos de correspondencia hallados no permiten realizar una transformacion correcta." << endl;        
        cvReleaseMemStorage(&storage);
        return false;
    }

    //Se procede a calcular la transformación.
    transform = getTransformation(objectKeypoints, imageKeypoints, objTri, imgTri);

    //EIGENVALUES**************************************************************************************************************
    //Features::checkEigenvalues(QTransform(0.0, 1.5, -1.0, 1.5, 1.0, 0.0, -1.0, 0.0, 1.0));
    if(!Features::checkEigenvalues(transform)){
        if(VERBOSE)
            qDebug() << "Los triangulos de correspondencia hallados no permiten realizar una transformacion correcta." << endl;        
        cvReleaseMemStorage(&storage);
        return false;
    }

    if(GRAPHIC){
        IplImage* result = Utils::drawResultImage(img1, img2, objectKeypoints, imageKeypoints, objTri, imgTri, ptpairs);
        cvNamedWindow("Imagen de correspondencia", 1);
        cvMoveWindow("Imagen de correspondencia", 100, 100);
        cvShowImage("Imagen de correspondencia", result);
        cvWaitKey(0);        
        cvDestroyAllWindows();
        cvReleaseImage(&result);
    }

    cvReleaseMemStorage(&storage);

    return true;
}
Пример #17
0
void QEmitterNode::addRepresentation()
{	
	m_matResource = h3dAddResource(H3DResTypes::Material, qPrintable(m_xmlNode.attribute("material")), 0);

	// Load resource immediately since a later call to loadResourceFromDisk results in a bad behaviour of the Horde3D engine
	QString resourceName = h3dutGetResourcePath(H3DResTypes::Material);
	if( !resourceName.isEmpty() && !resourceName.endsWith('/') && !resourceName.endsWith('\\') )
		resourceName += '/';
	resourceName += m_xmlNode.attribute("material");

	QFile matFile(QFileInfo(resourceName).absoluteFilePath());
	if (!matFile.open(QIODevice::ReadOnly))
		qWarning("Error opening resource %s", qPrintable(m_xmlNode.attribute("material")));

	// Stupid return value, if false it can also be the case that the resource was loaded before instead of that their was an error



	h3dLoadResource(m_matResource, matFile.readAll().append('\0').constData(), matFile.size() + 1);
	matFile.close();

	m_effectResource = h3dAddResource(H3DResTypes::ParticleEffect, qPrintable(m_xmlNode.attribute("particleEffect")), 0);

	// Load resource immediately since a later call to loadResourceFromDisk results in a bad behaviour of the Horde3D engine
	resourceName = h3dutGetResourcePath(H3DResTypes::ParticleEffect);
	if (!resourceName.isEmpty() && !resourceName.endsWith('/') && !resourceName.endsWith('\\'))
		resourceName += '/';
	resourceName += m_xmlNode.attribute("particleEffect");

	QFile effectFile(QFileInfo(resourceName).absoluteFilePath());
	if (!effectFile.open(QIODevice::ReadOnly))
		qWarning("Error opening resource %s", qPrintable(m_xmlNode.attribute("particleEffect")));

	// Stupid return value, if false it can also be the case that the resource was loaded before instead of that their was an error
	h3dLoadResource(m_effectResource, effectFile.readAll().append('\0').constData(), effectFile.size()+1);
	effectFile.close();

	QSceneNode* parentNode = static_cast<QSceneNode*>(parent());
	unsigned int rootID = parentNode ? parentNode->hordeId() : H3DRootNode;

	m_hordeID = h3dAddEmitterNode(
		rootID, 
		qPrintable(m_xmlNode.attribute("name", "ATTENTION No Node Name")), 
		m_matResource, 
		m_effectResource, 
		m_xmlNode.attribute("maxCount").toUInt(),
		m_xmlNode.attribute("respawnCount").toInt()
	);

	h3dSetNodeParamF(m_hordeID, H3DEmitter::ForceF3, 0, m_xmlNode.attribute("forceX", "0.0").toFloat());
	h3dSetNodeParamF(m_hordeID, H3DEmitter::ForceF3, 1, m_xmlNode.attribute("forceY", "0.0").toFloat());
	h3dSetNodeParamF(m_hordeID, H3DEmitter::ForceF3, 2, m_xmlNode.attribute("forceZ", "0.0").toFloat());
	h3dSetNodeParamF(m_hordeID, H3DEmitter::DelayF, 0, m_xmlNode.attribute("delay", "0.0").toFloat());
	h3dSetNodeParamF(m_hordeID, H3DEmitter::SpreadAngleF, 0, m_xmlNode.attribute("spreadAngle", "0.0").toFloat());
	h3dSetNodeParamF(m_hordeID, H3DEmitter::EmissionRateF, 0, m_xmlNode.attribute("emissionRate", "0.0").toFloat());

	// load transformation from file...
	float x, y, z, rx, ry, rz, sx, sy, sz;
	getTransformation(x,y,z,rx,ry,rz,sx,sy,sz);
	// ...and update scene representation
	h3dSetNodeTransform(m_hordeID, x, y, z, rx, ry, rz, sx, sy, sz);
	
	// Attachment
	QDomElement attachment = m_xmlNode.firstChildElement("Attachment");	
	SceneTreeModel* model = static_cast<SceneTreeModel*>(m_model);
	AttachmentPlugIn* plugIn = model->nodeFactory()->attachmentPlugIn();
	if (!attachment.isNull() &&  plugIn != 0)
		plugIn->initNodeAttachment(this);

	startTimer(100);
}
Пример #18
0
 void	animatedVertex::draw(gdl::AShader &shader, gdl::Clock const& clock) {
   _model.draw(shader, getTransformation(), clock.getElapsed());
 }
Пример #19
0
void Cube::draw(gdl::AShader &s, gdl::Clock const &)
{
  this->texture->bind();
  this->geometry->draw(s, getTransformation(), GL_QUADS);
}
Пример #20
0
inline void          Egg::draw(gdl::AShader &shader)
{
  this->_model.draw(shader, getTransformation(), GL_TRIANGLES);
}
Пример #21
0
void Button::draw(gdl::AShader &shader, gdl::Clock const &clock)
{
  static_cast<void>(clock);
  _texture.bind();
  _geometry.draw(shader, getTransformation(), GL_QUADS);
}
Пример #22
0
void		BombLvlBonus::draw(gdl::AShader& shader, gdl::Clock const&)
{
  _texture.bind();
  _geometry.draw(shader, getTransformation(), GL_QUADS);
}
Пример #23
0
    void
    NormalHoughProposer::houghVote(Entry &query, Entry &target, bin_t& bins)
    {
      // Compute the reference point for the R-table
      Eigen::Vector4f centroid4;
      compute3DCentroid(*(target.cloud), centroid4);
      Eigen::Vector3f centroid(centroid4[0], centroid4[1], centroid4[2]);

      assert(query.keypoints->size() == query.features->size());
      assert(target.keypoints->size() == target.features->size());

      // Figure out bin dimension
      Eigen::Vector4f query_min4, query_max4;
      getMinMax3D(*query.cloud, query_min4, query_max4);
      Eigen::Vector3f query_min(query_min4[0], query_min4[1], query_min4[2]);
      Eigen::Vector3f query_max(query_max4[0], query_max4[1], query_max4[2]);

      Eigen::Affine3f t;
      getTransformation(0, 0, 0, M_PI, 0.5, 1.5, t);

      int correctly_matched = 0;
      for (unsigned int i = 0; i < query.keypoints->size(); i++)
      {
        std::vector<int> feature_indices;
        std::vector<float> sqr_distances;

        int num_correspondences = 2;
        if (!pcl_isfinite (query.features->points.row(i)(0)))
          continue;
        int num_found = target.tree->nearestKSearch(*query.features, i, num_correspondences, feature_indices, sqr_distances);

        for (int j = 0; j < num_found; j++)
        {
          // For each one of the feature correspondences
          int feature_index = feature_indices[j];

          Eigen::Vector3f query_keypoint = query.keypoints->at(i).getVector3fMap();
          Eigen::Vector3f target_keypoint = target.keypoints->at(feature_index).getVector3fMap();

          target_keypoint = t * target_keypoint;
          if ((query_keypoint - target_keypoint).norm() < 0.05)
          {
            correctly_matched++;
          }

          // Get corresponding target keypoint, and calculate its r to its centroid
          PointNormal correspondence = target.keypoints->at(feature_index); // Since features correspond to the keypoints
          Eigen::Vector3f r = correspondence.getVector3fMap() - centroid;

          // Calculate the rotation transformation from the target normal to the query normal
          Eigen::Vector3f target_normal = correspondence.getNormalVector3fMap();
          target_normal.normalize();
          Eigen::Vector3f query_normal = query.keypoints->at(i).getNormalVector3fMap();
          query_normal.normalize();
          double angle = acos( target_normal.dot(query_normal) / (target_normal.norm() * query_normal.norm()) );
          Eigen::Vector3f axis = target_normal.normalized().cross(query_normal.normalized());
          axis.normalize();
          Eigen::Affine3f rot_transform;
          rot_transform = Eigen::AngleAxisf (angle, axis);

          // Check that the rotation matrix is correct
          Eigen::Vector3f projected = rot_transform * target_normal;
          projected.normalize();

          // Transform r based on the difference between the normals
          Eigen::Vector3f transformed_r = rot_transform * r;

          for (int k = 0; k < num_angles_; k++)
          {
            float query_angle = (float(k) / num_angles_) * 2.0f * float (M_PI);
            Eigen::Affine3f query_rot;
            query_rot = Eigen::AngleAxisf(query_angle, query_normal.normalized());

            Eigen::Vector3f guess_r = query_rot * transformed_r;

            Eigen::Vector3f centroid_est = query.keypoints->at(i).getVector3fMap() - guess_r;

            Eigen::Vector3f region = query_max - query_min;
            Eigen::Vector3f bin_size = region / float (bins_);
            Eigen::Vector3f diff = (centroid_est - query_min);
            Eigen::Vector3f indices = diff.cwiseQuotient(bin_size);

            castVotes(indices, bins);
          }

        }

      }
    }
Пример #24
0
void Scene::setup(View& view) {
  view.transform(getTransformation());
}
Пример #25
0
void ItemRange::draw(gdl::AShader& shader, const gdl::Clock& clock) {
    _model.draw(shader, getTransformation(), clock.getElapsed());
}
Пример #26
0
	std::ostream& ForAll::printTo(std::ostream& out, const Indent& indent) const {
		out << indent << "For " << filter << " do\n";
		return getTransformation()->printTo(out, indent + 1);
	}
Пример #27
0
long Tracker::getX(){
	return getTransformation().trans().x();
}
Пример #28
0
	AABoundingBox ModelInstance::getBoundingBox() const {
		return getNonTransformedBoundingBox().transform(getTransformation());
	}