Example #1
0
//--------------------------------------------------------------
void trackingManager::update(){
	//--- update video/camera input
	IM.update();
	
	//--- eye tracking (on new frames)	
	if (IM.bIsFrameNew){									// check new frame.
		trackEyes();
	}
	
	//only update the point if the vector was found
	//the function returns a 0,0 point if vector was not found
	ofPoint pt = tracker.getVectorGlintToPupil(GLINT_BOTTOM_LEFT);
		
	if( pt.x != 0.0 || pt.y != 0.0 ){
		glintPupilVector = pt;
	}
	
	// to make trail
	//	currentdrawPoint.x = currentdrawPoint.x * 0.80 + glintPupilVector.x * 0.20;
	//	currentdrawPoint.y = currentdrawPoint.y * 0.80 + glintPupilVector.y * 0.20;
	
	ofPoint	tempPoint(glintPupilVector.x, glintPupilVector.y);
	trail.push_back(tempPoint);
	if (trail.size() > 200) trail.erase(trail.begin());
	
	//--- gui
	panel.update();
	updateGui();
	
}
Example #2
0
 const Point operator-(const Point &point, const Point &point1) {
     Point tempPoint(point.__dim);
     for (int i = 0; i < point.__dim; i++) {
         tempPoint.__values[i] = point.__values[i] - point1.__values[i];
     }
     return tempPoint;
 }
Example #3
0
void NGLScene::initializeGL ()
{
    ngl::NGLInit::instance();
    glClearColor (0.4,0.4,0.4,1);
    std::cout<<"Initializing NGL\n";

    ngl::Vec3 from(2,0.4,1);ngl::Vec3 to(0.5,0.4,0);ngl::Vec3 up(0,1,0);
    m_cam = new ngl::Camera(from,to,up);
    m_cam->setShape(45,(float)720/576,0.05,350);

    m_text=new ngl::Text(QFont("Arial",14));
    m_text->setScreenSize (width (),height ());

    // now to load the shader and set the values
    // grab an instance of shader manager
    ngl::ShaderLib *shader=ngl::ShaderLib::instance();
    (*shader)["nglDiffuseShader"]->use();

    shader->setShaderParam4f("Colour",1,0,0,1);
    shader->setShaderParam3f("lightPos",1,1,1);
    shader->setShaderParam4f("lightDiffuse",1,1,1,1);



    glEnable(GL_DEPTH_TEST);
    // enable multisampling for smoother drawing
    glEnable(GL_MULTISAMPLE);

    // as re-size is not explicitly called we need to do this.
   glViewport(0,0,width(),height());



    //Fill random 2D Values to Quatree
    for(int i=0;i<totalCollisionObjects;i++)
    {
       ngl::Random *rng=ngl::Random::instance ();
       int x = (int)rng->randomPositiveNumber (totalCollisionObjects);
       int y = (int)rng->randomPositiveNumber (totalCollisionObjects);

       //save positions
       Point t(x,y);
       treePositions.push_back (t);

       Point tempPoint(x,y);//or insert x,y instead of i,i to create some randomness
       tree.addPoint(tempPoint);
    }


    //find & get the collision neighbours of Point a(8,8), if (8,8) is in the tree
//    Point a(3,3);
    //Point a(2530,7399);    
//    getPointCollisions(a,&tree);

    currenttime.start ();
    tmpTimeElapsed = 0;
    fps= 0;
}
Example #4
0
void Rock :: draw()
{
   // We need to draw 5!! For screen wrapping
   // One where it is
   drawAsteroid(tempPoint(v.getX(), v.getY()), size, numSides, rotation);

   // One to the right
   drawAsteroid(tempPoint(v.getX() + 2*POINT_MAX, v.getY()), size, numSides, rotation);

   // One to the left
   drawAsteroid(tempPoint(v.getX() - 2*POINT_MAX, v.getY()), size, numSides, rotation);

   // One above it
   drawAsteroid(tempPoint(v.getX(), v.getY() + 2*POINT_MAX), size, numSides, rotation);

   // One below it
   drawAsteroid(tempPoint(v.getX(), v.getY() - 2*POINT_MAX), size, numSides, rotation);
}
Example #5
0
void CBTGView::pageSizePDraw(CDC *pDC)
{
	CBTGDoc *pDoc = GetDocument();
	CPoint tempPoint(pDoc->pageWidth, pDoc->pageHeight);
	CPoint basePoint(0, 0);

	pDoc->CalculateScreenCoordinates(&tempPoint);
	pDoc->CalculateScreenCoordinates(&basePoint);

	pDC->SelectStockObject(WHITE_PEN);
	pDC->SelectStockObject(NULL_BRUSH);

	pDC->Rectangle(basePoint.x, basePoint.y, tempPoint.x, tempPoint.y);
}
Example #6
0
void world::init(char* inputFile)
{
	int n;
	char ele;
	int cost;
	std::ifstream inputStream(inputFile, std::ios::in);
	if (inputStream.is_open()) {
		// gets the total terrains in the map
		inputStream >> n;
		for (int i=0; i< n; i++)
		{
			inputStream >> ele >> cost;
			terrainTypes.insert(std::make_pair(ele,cost));
		}
		//------------------------------------//
		
		// reads the world
		inputStream >> rows>>columns;
		for (int i = 0; i < rows; i++)
		{
			for (int j = 0; j < columns; j++)
			{
				inputStream >> ele;
				if (ele == 's') {
					startPoint = Point(i, j, 1);
					startPoint.setDisplayCharacter(ele);
					startPoint.set_positionInWorld(_world.size());
					_world.push_back(startPoint);
				}
				else if (ele == 'g') {
					goalPoint = Point(i, j, 1);
					goalPoint.setDisplayCharacter(ele);
					goalPoint.set_positionInWorld(_world.size());
					_world.push_back(goalPoint);
				}
				else
				{
					Point tempPoint(i, j, terrainTypes.at(ele));
					tempPoint.setDisplayCharacter(ele);
					tempPoint.set_positionInWorld(_world.size());
					_world.push_back(tempPoint);

				}
			}
		}
		inputStream.close();
	}
Example #7
0
void mitk::WiiMoteThread::WiiMoteIRInput()
{
  if( m_WiiMotes[0].IR.Dot[0].bVisible 
  /*  && m_WiiMotes[0].IR.Dot[1].bVisible*/ )
  {
    m_Command = ReceptorCommand::New(); 
    m_Command->SetCallbackFunction
      ( mitk::WiiMoteAddOn::GetInstance()
      , &mitk::WiiMoteAddOn::WiiMoteInput );

    double tempTime(itksys::SystemTools::GetTime());
    float inputCoordinates[2] = {m_WiiMotes[0].IR.Dot[0].RawX, m_WiiMotes[0].IR.Dot[0].RawY};
    mitk::Point2D tempPoint(inputCoordinates);

    int sliceValue = 0;

    if(m_WiiMotes[0].IR.Dot[1].bVisible)
    {
      sliceValue = ( m_WiiMotes[0].IR.Dot[1].RawY  );
    }
    // if the last read data is not valid,
    // because the thread was not started
    if(!m_ReadDataOnce)
    {
      m_ReadDataOnce = true;  
    }
    else // there is old data available - calculate the movement and send event
    {
      // this time constraint allows the user to move the camera
      // with the IR sender (by switching the IR source on and off) 
      // similiar to a mouse (e.g. if you lift the mouse from the 
      // surface and put it down again on another position, there 
      // was no input. Now the input starts again and the movement 
      // will begin from the last location of the mouse, although 
      // the physical position of the mouse changed.)
      if ((tempTime-m_LastRecordTime) < TIMELIMIT) 
      {
        mitk::Vector2D resultingVector(m_LastReadData-tempPoint);
        mitk::WiiMoteIREvent e(resultingVector, tempTime, sliceValue);
        mitk::CallbackFromGUIThread::GetInstance()
          ->CallThisFromGUIThread(m_Command, e.MakeObject());
      }
    }
    m_LastRecordTime = tempTime;
    m_LastReadData = tempPoint;
  } 
}
Example #8
0
void mitk::WiiMoteThread::MultiWiiMoteIRInput()
{
  // testing multiple wiimotes 
  if(m_WiiMotes[0].IR.Dot[0].bVisible 
    && m_WiiMotes[1].IR.Dot[0].bVisible)
  {
    float inputCoordinates[2] = {m_WiiMotes[0].IR.Dot[0].RawX, m_WiiMotes[0].IR.Dot[0].RawY};
    mitk::Point2D tempPoint(inputCoordinates);

    float inputCoordinates2[2] = {m_WiiMotes[1].IR.Dot[0].RawX, m_WiiMotes[1].IR.Dot[0].RawY};
    mitk::Point2D tempPoint2(inputCoordinates2);

    mitk::Vector2D result = (tempPoint2 - tempPoint);
    MITK_INFO << "IR1 :: X: " << tempPoint[0];
    MITK_INFO << "IR1 :: Y: " << tempPoint[1];

    MITK_INFO << "IR2 :: X: " << tempPoint2[0];
    MITK_INFO << "IR2 :: Y: " << tempPoint2[1];
  }
}
//--------------------------------------------------------------
void trackingManager::update(){
	//--- update video/camera input
	IM.update();
	
	//--- eye tracking (on new frames)	
	if (IM.bIsFrameNew){									// check new frame.
		trackEyes();
	}
	
	glintPupilVector = tracker.getVectorGlintToPupil(GLINT_BOTTOM_LEFT);
	
	// to make trail
	//	currentdrawPoint.x = currentdrawPoint.x * 0.80 + glintPupilVector.x * 0.20;
	//	currentdrawPoint.y = currentdrawPoint.y * 0.80 + glintPupilVector.y * 0.20;
	
	ofPoint	tempPoint(glintPupilVector.x, glintPupilVector.y);
	trail.push_back(tempPoint);
	if (trail.size() > 200) trail.erase(trail.begin());
	
	//--- gui
	panel.update();
	updateGui();
	
}
Example #10
0
Point CPetGlyphs::getPosition(int index) const {
	Point tempPoint(37 + index * 70, 375);
	return tempPoint;
}