Пример #1
0
void PMTorus::createViewStructure( )
{
   if( !m_pViewStructure )
   {
      m_pViewStructure = new PMViewStructure( defaultViewStructure( ) );
      m_pViewStructure->points( ).detach( );
   }

   int uStep = (int)( ( (float)s_uStep / 2 ) * ( displayDetail( ) + 1 ) );
   int vStep = (int)( ( (float)s_vStep / 2 ) * ( displayDetail( ) + 1 ) );
   unsigned ptsSize = vStep * uStep;
   unsigned lineSize = vStep * uStep * 2;

   if( ptsSize != m_pViewStructure->points( ).size( ) )
      m_pViewStructure->points( ).resize( ptsSize );

   createPoints( m_pViewStructure->points( ), m_minorRadius, m_majorRadius, uStep, vStep );

   if( lineSize != m_pViewStructure->lines( ).size( ) )
   {
      m_pViewStructure->lines( ).detach( );
      m_pViewStructure->lines( ).resize( lineSize );
      createLines( m_pViewStructure->lines( ), uStep, vStep );
   }
}
Пример #2
0
void PMSuperquadricEllipsoid::createViewStructure( )
{
   if( !m_pViewStructure )
   {
      m_pViewStructure = new PMViewStructure( defaultViewStructure( ) );
      m_pViewStructure->points( ).detach( );
   }

   int uStep = (int)( ( (float)s_uStep / 2 ) * ( displayDetail( ) + 1 ) );
   int vStep = (int)( ( (float)s_vStep / 2 ) * ( displayDetail( ) + 1 ) );
   int uStep2 = uStep * 4;
   int vStep2 = vStep * 8;
   unsigned ptsSize = vStep2 * ( uStep2 - 1 ) + 2;
   unsigned lineSize = vStep2 * ( uStep2 - 1 ) * 2 + vStep2;

   if( ptsSize != m_pViewStructure->points( ).size( ) )
      m_pViewStructure->points( ).resize( ptsSize );

   createPoints( m_pViewStructure->points( ), m_eastWestExponent,
                 m_northSouthExponent, uStep, vStep );

   if( lineSize != m_pViewStructure->lines( ).size( ) )
   {
      m_pViewStructure->lines( ).detach( );
      m_pViewStructure->lines( ).resize( lineSize );
      createLines( m_pViewStructure->lines( ), uStep2, vStep2 );
   }
}
Пример #3
0
int main( int argc, char **argv )
{
    int success = 0;
    GLcharARB *VertexShaderSource, *FragmentShaderSource;

    int error = 0;

    if (Args(argc, argv) == FALSE)
        exit(0);

    glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
    glutInitWindowSize(500, 500);
    window = glutCreateWindow( "Fire and Smoke" );

    glutIdleFunc( play );
    glutDisplayFunc( display );
    glutKeyboardFunc( key );
    glutReshapeFunc( reshape );

    printOpenGLError();

    if ( !isExtensionSupported( "GL_ARB_shader_objects" )   ||
         !isExtensionSupported( "GL_ARB_fragment_shader" )  ||
         !isExtensionSupported( "GL_ARB_vertex_shader" )    ||
         !isExtensionSupported( "GL_ARB_shading_language_100" ) )
    {
        printf("OpenGL Shading Language extensions not available\n" );
        return 1;
    }

    if( error )
    {
        printf( "ERROR from wglGetProcAddress\n" );
    }

    createPoints( numParticles );

    glDepthFunc( GL_LESS );
    glEnable( GL_DEPTH_TEST );
	glClearColor( 0.0f, 0.67f, 0.94f, 1.0f );

	ParticleTime = 0.0f;

    readShaderSource( "smoke", &VertexShaderSource, &FragmentShaderSource );
    success = installParticleShaders( VertexShaderSource, FragmentShaderSource );

    if ( success )
	{
		glutMainLoop();
	}
	else
	{
		printf( "Error installing particle shaders" );
		scanf( "%d", ParticleTime );
	}

    return 0;
}
const Foam::pointField& Foam::block::points() const
{
    if (vertices_.empty())
    {
        createPoints();
    }

    return vertices_;
}
IcoSphereGeometry::IcoSphereGeometry( unsigned int uiRecursionLevel )
{
	_uiRecursionLevel = uiRecursionLevel;
	_uiIndex = 0;

	_pvVertexs = new std::vector<osg::Vec3f*>();
	_pvIndexCash = new std::map<string, unsigned int>();
	_pvTriangleIndexes = new std::vector<osg::Vec3f*>();	

	createPoints();
}
Пример #6
0
void Spawner::spawn() {
	createPoints();
	bSpawning = true;
	randGenerate();
	for (int i = 0; i < iSpawnCount; i++) {
		entitiesSpawned.push_back(spawnEntity);
		entitiesSpawned.back().setPosition(Points[randomPosition[i]]);
		entitiesSpawned.back().setTargetPos(sf::Vector2f(640, 360));
	}
	std::cout << entitiesSpawned.size() << std::endl;
}									//Start Spawning
Пример #7
0
void KoStarShape::updatePath( const QSizeF &size )
{
    Q_UNUSED(size);
    qreal radianStep = M_PI / static_cast<qreal>(m_cornerCount);

    createPoints( m_convex ? m_cornerCount : 2*m_cornerCount );

    KoSubpath &points = *m_subpaths[0];

    uint index = 0;
    for( uint i = 0; i < 2*m_cornerCount; ++i )
    {
        uint cornerType = i % 2;
        if( cornerType == base && m_convex )
            continue;
        qreal radian = static_cast<qreal>( (i+1)*radianStep ) + m_angles[cornerType];
        QPointF cornerPoint = QPointF( m_zoomX * m_radius[cornerType] * cos( radian ), m_zoomY * m_radius[cornerType] * sin( radian ) );

        points[index]->setPoint( m_center + cornerPoint );
        points[index]->unsetProperty( KoPathPoint::StopSubpath );
        points[index]->unsetProperty( KoPathPoint::CloseSubpath );
        if( m_roundness[cornerType] > 1e-10 || m_roundness[cornerType] < -1e-10 )
        {
            // normalized cross product to compute tangential vector for handle point
            QPointF tangentVector( cornerPoint.y()/m_radius[cornerType], -cornerPoint.x()/m_radius[cornerType] );
            points[index]->setControlPoint2( points[index]->point() - m_roundness[cornerType] * tangentVector );
            points[index]->setControlPoint1( points[index]->point() + m_roundness[cornerType] * tangentVector );
        }
        else
        {
            points[index]->removeControlPoint1();
            points[index]->removeControlPoint2();
        }
        index++;
    }

    // first path starts and closes path
    points[0]->setProperty( KoPathPoint::StartSubpath );
    points[0]->setProperty( KoPathPoint::CloseSubpath );
    // last point stops and closes path
    points.last()->setProperty( KoPathPoint::StopSubpath );
    points.last()->setProperty( KoPathPoint::CloseSubpath );

    normalize();

    m_handles.clear();
    m_handles.push_back( points.at(tip)->point() );
    if( ! m_convex )
        m_handles.push_back( points.at(base)->point() );

    m_center = computeCenter();
}
Пример #8
0
    vector<pair<int, int>> getSkyline(vector<vector<int>>& buildings) {
        if (buildings.empty()) return vector<pair<int, int>>();

        createPoints(buildings);
        lineExists = vector<bool>(IDCTR, false);

        for (Point& pt : crds) {
            if (pt.typ == START) { //starting a building's contour
                handleBuildingStart(pt);
            } else {                //ending a building's contour
                handleBuildingEnd(pt);
            }
        }
        return results;
    }
Пример #9
0
PMViewStructure* PMCone::defaultViewStructure( ) const
{
   if( !s_pDefaultViewStructure || s_pDefaultViewStructure->parameterKey( ) != viewStructureParameterKey( ) )
   {
      delete s_pDefaultViewStructure;
      s_pDefaultViewStructure = 0;
      int steps = (int)( ( (float)s_numSteps / 2 ) * ( globalDetailLevel( ) + 1 ) );
      s_pDefaultViewStructure = new PMViewStructure( steps  * 2,  steps * 3 );

      createPoints( s_pDefaultViewStructure->points( ), defaultEnd1,
            defaultEnd2,defaultConeRadius1,defaultConeRadius2, steps );

      createLines( s_pDefaultViewStructure->lines( ), steps );
   }
   return s_pDefaultViewStructure;
}
Пример #10
0
/* neglectible % of execution time */
static void
animateLMorph(struct state *st)
{
    int i;
    if (st->currGamma > st->maxGamma) {
        st->currGamma = 0.0;
        st->nFrom = st->nTo;
        st->nTo = st->nNext;
        st->aFrom = st->a[st->nFrom];
	st->aTo = st->a[st->nTo];
        do {
            st->nNext = RND(st->numFigs);
        } while (st->nNext == st->nTo);
	st->aNext = st->a[st->nNext];

	st->shift = RND(st->numPoints);
        if (RND(2)) {
            /* reverse the array to get more variation. */
            int    i1, i2;
            XPoint p;
            
            for (i1 = 0, i2 = st->numPoints - 1; i1 < st->numPoints / 2; i1++, i2--) {
                p = st->aNext[i1];
                st->aNext[i1] = st->aNext[i2];
                st->aNext[i2] = p;
            }
        }

	/* calculate the slopes */
	for (i = 0; i < st->numPoints ; i++) {
            st->aSlopeFrom[i].x = st->aSlopeTo[i].x;
            st->aSlopeFrom[i].y = st->aSlopeTo[i].y;
            st->aSlopeTo[i].x = st->aNext[i].x - st->aTo[i].x;
            st->aSlopeTo[i].y = (st->aNext[i].y - st->aTo[i].y);
	}
    }

    createPoints(st);
    drawImage(st);
    st->aPrev = st->aCurr;
    st->aCurr = st->aWork[st->nWork ^= 1];

    st->currGamma += st->deltaGamma;
}
Пример #11
0
//--------------------------------------------------------------
void testApp::update(){
	ofBackground(100,100,100);

    bool bNewFrame = false;

	#ifdef _USE_LIVE_VIDEO
       vidGrabber.grabFrame();
	   bNewFrame = vidGrabber.isFrameNew();
    #else
        vidPlayer.idleMovie();
        bNewFrame = vidPlayer.isFrameNew();
	#endif

	if (bNewFrame){

		#ifdef _USE_LIVE_VIDEO
            colorImg.setFromPixels(vidGrabber.getPixels(), 320,240);
	    #else
            colorImg.setFromPixels(vidPlayer.getPixels(), 320,240);
        #endif

        grayImage = colorImg;
		if (bLearnBakground == true){
			grayBg = grayImage;		// the = sign copys the pixels from grayImage into grayBg (operator overloading)
			bLearnBakground = false;
		}

		// take the abs value of the difference between background and incoming and then threshold:
		grayDiff.absDiff(grayBg, grayImage);
		grayDiff.threshold(threshold);

		// find contours which are between the size of 20 pixels and 1/3 the w*h pixels.
		// also, find holes is set to true so we will get interior contours as well....
//		contourFinder.findContours(grayDiff, 20, (340*240)/3, 1, true);	// find holes
        
        
        findEdges( &colorImg, low_threshold, high_threshold, aperature );
        createPoints();
        
	}
    
}
void voronoiMeshExtractor::createMesh()
{
    Info << "Extracting voronoi mesh" << endl;

    //- copy tet points into the mesh
    createPoints();

    //- create the mesh
    createPolyMesh();

    polyMeshGenModifier(mesh_).reorderBoundaryFaces();
    polyMeshGenModifier(mesh_).removeUnusedVertices();

    Info << "Mesh has :" << nl
        << mesh_.points().size() << " vertices " << nl
        << mesh_.faces().size() << " faces" << nl
        << mesh_.cells().size() << " cells" << endl;

    Info << "Finished extracting voronoi mesh" << endl;
}
Пример #13
0
PMViewStructure* PMTorus::defaultViewStructure( ) const
{
   if( !s_pDefaultViewStructure || s_pDefaultViewStructure->parameterKey( ) != viewStructureParameterKey( ) )
   {
      delete s_pDefaultViewStructure;
      s_pDefaultViewStructure = 0;
      int uStep = (int)( ( (float)s_uStep / 2 ) * ( globalDetailLevel( ) + 1 ) );
      int vStep = (int)( ( (float)s_vStep / 2 ) * ( globalDetailLevel( ) + 1 ) );

      s_pDefaultViewStructure =
         new PMViewStructure(  vStep * uStep ,
                               vStep * uStep * 2 );

      createPoints( s_pDefaultViewStructure->points( ), c_defaultminorRadius,
                    c_defaultmajorRadius, uStep, vStep );

      createLines( s_pDefaultViewStructure->lines( ), uStep, vStep );
   }
   return s_pDefaultViewStructure;
}
Пример #14
0
  Obj(
    const std::string& fname, 
    const glm::mat4& modelMatrix, 
    const std::string& texfname,
    btDiscreteDynamicsWorld* btworld,
    Shape shape=None
    )
    : rigidbody(NULL), bco(NULL), tex(NULL)
  {

    //modelMatrix = glm::scale(glm::vec4(1.0f,1.0), glm::vec3(10.0f));

    gWVP = modelMatrix; 
    xPos = 0;
    zPos = 0;

    // load mesh object
    createPoints(fname);
    // colorizeByVertexPosition();

    // create ogl vbo
    glGenBuffers(1, &vbo);
    glBindBuffer(GL_ARRAY_BUFFER, vbo);
    glBufferData(GL_ARRAY_BUFFER, data.size()*sizeof(Point), data.data(), GL_STATIC_DRAW);

    // physics object
    createBulletObject(shape);

    // texture

    if ( ! set_texture(texfname) )
    {
      std::cout << texfname << " could not be opened." << std::endl;   
    }

    // data.clear();

  }
Пример #15
0
static void
animateAnemone(struct state *st, Drawable curr_window)
{
  int i;
  double sint = sin(st->turn),cost = cos(st->turn);

  st->aCurr = st->appD;
  for (i = 0; i< st->arms; i++) {
    st->vCurr = st->vPendage + (st->finpoints + 1) * i;
    if (RND(25)<st->aCurr->rate) {
      if (st->aCurr->growth<0) {
	st->aCurr->numpt -= st->aCurr->numpt>1;
	if (!(++st->aCurr->growth)) st->aCurr->growth = RND(st->finpoints - st->aCurr->numpt) + 1;
      }
    }
    drawImage(st, curr_window, sint, cost);
    st->turn += st->turndelta;
    st->aCurr++;
  }
  createPoints(st);

  if (st->turn >= TWO_PI) st->turn -= TWO_PI;
}
Пример #16
0
void PMCone::createViewStructure( )
{
   if( !m_pViewStructure )
   {
      m_pViewStructure = new PMViewStructure(defaultViewStructure ( ) );
      m_pViewStructure->points( ).detach( );
   }

   int steps = (int)( ( (float)s_numSteps / 2 ) * ( displayDetail( ) + 1 ) );
   unsigned ptsSize = steps * 2;
   unsigned lineSize = steps * 3;

   if( ptsSize != m_pViewStructure->points( ).size( ) )
      m_pViewStructure->points( ).resize( ptsSize );

   createPoints( m_pViewStructure->points( ), m_end1, m_end2, m_radius1, m_radius2, steps );

   if( lineSize != m_pViewStructure->lines( ).size( ) )
   {
      m_pViewStructure->lines( ).detach( );
      m_pViewStructure->lines( ).resize( lineSize );
      createLines( m_pViewStructure->lines( ), steps );
   }
}
Пример #17
0
	FileIOXmlGml()
	{
		createPoints();
		createPolylines();
		createSurfaces();
	}
Пример #18
0
void RectangleShape::updatePath(const QSizeF &size)
{
    qreal rx = 0;
    qreal ry = 0;
    if (m_cornerRadiusX > 0 && m_cornerRadiusY > 0) {
        rx = size.width() / 200.0 * m_cornerRadiusX;
        ry = size.height() / 200.0 * m_cornerRadiusY;
    }

    qreal x2 = size.width() - rx;
    qreal y2 = size.height() - ry;

    QPointF curvePoints[12];

    int requiredCurvePointCount = 4;
    if (rx && m_cornerRadiusX < 100)
        requiredCurvePointCount += 2;
    if (ry && m_cornerRadiusY < 100)
        requiredCurvePointCount += 2;

    createPoints(requiredCurvePointCount);

    KoSubpath &points = *m_subpaths[0];

    int cp = 0;

    // first path starts and closes path
    points[cp]->setProperty(KoPathPoint::StartSubpath);
    points[cp]->setProperty(KoPathPoint::CloseSubpath);
    points[cp]->setPoint(QPointF(rx, 0));
    points[cp]->removeControlPoint1();
    points[cp]->removeControlPoint2();

    if (m_cornerRadiusX < 100 || m_cornerRadiusY == 0) {
        // end point of the top edge
        points[++cp]->setPoint(QPointF(x2, 0));
        points[cp]->removeControlPoint1();
        points[cp]->removeControlPoint2();
    }

    if (rx) {
        // the top right radius
        arcToCurve(rx, ry, 90, -90, points[cp]->point(), curvePoints);
        points[cp]->setControlPoint2(curvePoints[0]);
        points[++cp]->setControlPoint1(curvePoints[1]);
        points[cp]->setPoint(curvePoints[2]);
        points[cp]->removeControlPoint2();
    }

    if (m_cornerRadiusY < 100 || m_cornerRadiusX == 0) {
        // the right edge
        points[++cp]->setPoint(QPointF(size.width(), y2));
        points[cp]->removeControlPoint1();
        points[cp]->removeControlPoint2();
    }

    if (rx) {
        // the bottom right radius
        arcToCurve(rx, ry, 0, -90, points[cp]->point(), curvePoints);
        points[cp]->setControlPoint2(curvePoints[0]);
        points[++cp]->setControlPoint1(curvePoints[1]);
        points[cp]->setPoint(curvePoints[2]);
        points[cp]->removeControlPoint2();
    }

    if (m_cornerRadiusX < 100 || m_cornerRadiusY == 0) {
        // the bottom edge
        points[++cp]->setPoint(QPointF(rx, size.height()));
        points[cp]->removeControlPoint1();
        points[cp]->removeControlPoint2();
    }

    if (rx) {
        // the bottom left radius
        arcToCurve(rx, ry, 270, -90, points[cp]->point(), curvePoints);
        points[cp]->setControlPoint2(curvePoints[0]);
        points[++cp]->setControlPoint1(curvePoints[1]);
        points[cp]->setPoint(curvePoints[2]);
        points[cp]->removeControlPoint2();
    }

    if ((m_cornerRadiusY < 100 || m_cornerRadiusX == 0) && ry) {
        // the right edge
        points[++cp]->setPoint(QPointF(0, ry));
        points[cp]->removeControlPoint1();
        points[cp]->removeControlPoint2();
    }

    if (rx) {
        // the top left radius
        arcToCurve(rx, ry, 180, -90, points[cp]->point(), curvePoints);
        points[cp]->setControlPoint2(curvePoints[0]);
        points[0]->setControlPoint1(curvePoints[1]);
        points[0]->setPoint(curvePoints[2]);
    }

    // unset all stop/close path properties
    for (int i = 1; i < cp; ++i) {
        points[i]->unsetProperty(KoPathPoint::StopSubpath);
        points[i]->unsetProperty(KoPathPoint::CloseSubpath);
    }

    // last point stops and closes path
    points.last()->setProperty(KoPathPoint::StopSubpath);
    points.last()->setProperty(KoPathPoint::CloseSubpath);
}
Пример #19
0
void Test::testSideCalc(){
	
	createPoints();

	
}
Пример #20
0
ParticleSystem::Ptr ParticleSystem::create(Particle::Type type, MessageBus& mb)
{
    auto ps = std::make_unique<ParticleSystem>(mb);

    switch (type)
    {
    case Particle::Type::Trail:
    {
        const float scale = Util::Random::value(2.f, 4.f);
        ScaleAffector sa({ scale, scale });
        ps->addAffector<ScaleAffector>(sa);

        ForceAffector fa({ 0.f, -190.f });
        ps->addAffector<ForceAffector>(fa);

        ps->setEmitRate(Util::Random::value(0.5f, 2.5f));
        ps->setBlendMode(sf::BlendAdd);
        ps->setEmitRate(3.f);
        ps->setRandomInitialVelocity(trailVelocities);
        ps->start(1u, Util::Random::value(0.2f, 1.f));
    }
        break;

    case Particle::Type::Echo:
    {
        ScaleAffector sa({ 1.6f, 1.6f });
        ps->addAffector<ScaleAffector>(sa);

        ps->setBlendMode(sf::BlendAdd);
        ps->setParticleLifetime(0.95f);
        ps->followParent(true);
    }
        break;

    case Particle::Type::Sparkle:
    {
        sparkPositions = createPoints(sf::Vector2f(), 20, 18.f);

        ps->setParticleLifetime(0.6f);
        ps->setParticleSize({ 10.f, 10.f });
        ps->setRandomInitialVelocity(sparkVelocities);
        ps->setRandomInitialPosition(sparkPositions);
        ps->setBlendMode(sf::BlendAdd);

        ScaleAffector sa({ 2.f, 2.f });
        ps->addAffector(sa);

        RotateAffector ra(140.f);
        ps->addAffector(ra);
    }
    break;
    case Particle::Type::Ident:
    {
        identPositions = createPoints({}, 20, 20.f);

        ps->setParticleLifetime(0.6f);
        ps->setParticleSize({ 20.f, 20.f });
        ps->setInitialVelocity({ 0.f, 0.f });
        ps->setRandomInitialPosition(identPositions);
        ps->setBlendMode(sf::BlendAdd);
        ps->followParent(true);
        ps->setEmitRate(7.f);
        ps->start();
    }
    default: break;
    }


    return std::move(ps);
}