Beispiel #1
0
static void
Draw(void)
{
   if (Mode == FLICKER) {
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   }
   else {
      /* don't clear color buffer */
      glClear(GL_DEPTH_BUFFER_BIT);
      /* update Z buffer only */
      glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
   }

   glPushMatrix();
   glRotatef(Xrot, 1, 0, 0);
   glRotatef(Yrot, 0, 1, 0);
   glRotatef(Zrot, 0, 0, 1);

   DrawBoxes();

   if (Mode == NO_FLICKER) {
      /* update color buffer now */
      glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
      glDepthFunc(GL_EQUAL);
      DrawBoxes();
      glDepthFunc(GL_LESS);
   }

   glPopMatrix();

   if (Mode == NO_FLICKER) {
      /* "clear" the untouched pixels now.
       * Note: if you comment-out this code you'll see something interesting.
       */
      GLfloat x = FarClip / NearClip;
      GLfloat z = -(FarClip - ViewDist - 1.0);
      glDisable(GL_LIGHTING);
      glColor4fv(ClearColor);
      glBegin(GL_POLYGON);
      glVertex3f(-x, -x, z);
      glVertex3f( x, -x, z);
      glVertex3f( x,  x, z);
      glVertex3f(-x,  x, z);
      glEnd();
      glEnable(GL_LIGHTING);
   }

   /* This is where you'd normally do SwapBuffers */
   glFinish();
}
Beispiel #2
0
	void Level::Render()
	{
		//std::vector<Entity*>::iterator i;

		//for (i = m_Entities.begin(); i != m_Entities.end(); ++i)
		//{
		//	(*i)->Render();
		//}
		DrawBoxes();
	}
Beispiel #3
0
/**
 * Method used to make the repaints behave correctly on all 3 platforms
 */
void DecoratedTree::OnPaint(wxPaintEvent& ev)
{
    // wxGetApp().Yield();
    ev.Skip();
    
    wxTreeItemId id = GetRootItem();
    
    if (drawOutline) {
        lineNumber = 0;
        DrawOutline(id);
    }
        
    if (drawBoxes) {
        lineNumber = 0;
        DrawBoxes(id);
    }
}
Beispiel #4
0
void ShowAll()
{
	//double radious = 
	double rotate = ((rotate_control - 50) * 360 / 80);
	double c = sqrt(hookInitialStartX*hookInitialStartX + hookInitialStartZ*hookInitialStartZ);
	int delta = hookInitialStartY - ((stringLength - 2));

	//update rotate
	hook = updatePoint(c*sin(rotate*PI / 180), hookInitialStartY - delta, c*cos(rotate*PI / 180));

	glEnable(GL_DEPTH_TEST);
	// start of the transformations
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	//DrawGround();
	DrawCraneGround();
	DrawBoxes();

	glPushMatrix();
	glTranslated(4, 1, 0);
	glRotated(rotate, 0, 1, 0);
	glTranslated(-4, -1, 0);
	DrawCrane();
	glPopMatrix();

	// pick box when press hold
	if (hold)
		if (BoxInfocus != -1)
		{
			boxesData[BoxInfocus*dataLength +3] = hook.x+4;
			boxesData[BoxInfocus*dataLength +4] = hook.y+12;
			boxesData[BoxInfocus*dataLength +5] = hook.z;
		}
		else
			BoxInfocus = hookIntersects();

	if (realese)
	{
		if (BoxInfocus != -1)
		{
			boxFalling = BoxInfocus;
			BoxInfocus = -1;
		}
		realese = false;
	}
	if(boxFalling != -1)
	{
		if (boxesData[boxFalling*dataLength +4] > 1 && !BoxIntersects())
				boxesData[boxFalling*dataLength +4] -= fallSpeed;
		else
			boxFalling = -1;
	}
	// draw red point
	glColor3d(0, 0, 1);
	glPointSize(5);
	glBegin(GL_POINTS);
	glVertex3d(hook.x + 4, hook.y + 12, hook.z);
	glEnd();

}
Beispiel #5
0
/**
 * Method used to draw the box around the decorations
 * 
 * @param id    The node that needs the decoration box(es)
 */
void DecoratedTree::DrawBoxes(wxTreeItemId id)
{
//    MessageInterface::ShowMessage("DecoratedTree::DrawBoxes() entered\n");

    // Add the new decorations
    wxRect bound;
    int w, h;
    int lft, rt, top, btm;
    bool visible;
    wxTreeItemIdValue cookie;
    wxTreeItemId current = GetFirstChild(id, cookie);
    
    GetSize(&w, &h);

    wxClientDC dc(this);

    //wxWidgets-2.6.3:deprecated->dc.BeginDrawing();
    
    while (current > (wxTreeItemId)0) {
       visible = GetBoundingRect(current, bound, TRUE);
       dc.SetPen(wxPen(wxColour(0xaf, 0xaf, 0xaf), 1, wxSOLID));

       if ((visible)) {                // Draw decorations on visible nodes
          for (int i = 0; i < boxCount; ++i) {
             //lft = w-20-boxWidth*(i+1);
             //rt  = w-20-boxWidth*i;
             lft = w-offset-boxWidth*(i+1);
             rt  = w-offset-boxWidth*i;
             top = bound.y;
             btm = bound.y + rowHeight;
                
             dc.DrawLine(lft, top, lft, btm);
             dc.DrawLine(rt, top, rt, btm);
             dc.DrawLine(lft, top, rt, top);
             dc.DrawLine(lft, btm, rt, btm);
             if (!boxData.empty())
             {
                //MessageInterface::ShowMessage("Box not empty\n");
                // Should be DrawText, but the wx build for Dev-C++ has a
                // bug with that method
                //dc.DrawRotatedText("Ready", lft+2, top, 0);
                int boxDataNumber = i+lineNumber*boxCount;
                //MessageInterface::ShowMessage("Box data number %d\n", boxDataNumber);
                    
                if (boxDataNumber < (int)boxData.size())
                {
                   if (boxData[boxDataNumber])
                   {
                      dc.DrawRotatedText(boxData[i+lineNumber*boxCount]->c_str(),
                                         lft+2, top, 0);
                      //MessageInterface::ShowMessage
                      //("Drew text\nline number=%d\nboxcount=%d\ni=%d\n", lineNumber, boxCount, i);
                   }
                }
             }
          }
       }
       
       if (GetChildrenCount(current) > 0) {
          ++lineNumber;
          DrawBoxes(current);
          --lineNumber;
       }
       
        current = GetNextChild(id, cookie);
        ++lineNumber;
    }

    //MessageInterface::ShowMessage("end drawing\n");
    //wxWidgets-2.6.3:deprecated->dc.EndDrawing();
}
Beispiel #6
0
static void Test(void) {
  DrawFont();
  DrawLines();
  DrawRectangles();
  DrawBoxes();
}
Beispiel #7
0
void main(int argc, char *argv[])
{
	ParseCommandLine (argc, argv);

	StereoPosData out_data, out_data_dominant;
	
	YARPImageOf<YarpPixelMono> out_image;
	YARPImageOf<YarpPixelMono> out_image_dominant;
	YARPImageOf<YarpPixelMono> old_image;
	out_image.Resize (Size, Size);
	out_image_dominant.Resize (Size, Size);
	old_image.Resize (Size, Size);
	memset (old_image.GetRawBuffer(), 0, Size * Size);

	// register names.
	for (int i = 0; i < NUMBEROFCHANNELS; i++)
	{
		channels[i].Register (portnames[i]);
	}

	out_saliency.Register (out_saliency_name);
	out.Register (out_pos_data_name);
	out_dominant.Register (out_pos_data_name_dominant);
	
	FiveBoxesInARow boxes[NUMBEROFCHANNELS];

	for (i = 0; i < NUMBEROFCHANNELS; i++)
	{
		memset (boxes+i, 0, sizeof(FiveBoxesInARow));
		boxes[i].box1.valid = false;
		boxes[i].box2.valid = false;
		boxes[i].box3.valid = false;
		boxes[i].box4.valid = false;
		boxes[i].box5.valid = false;
	}

	// compute saliency scale factor.
	int scalefactor = 0;
	for (i = 0; i < NUMBEROFCHANNELS; i++)
		scalefactor += relative_weight[i];

	scalefactor = 255 / scalefactor;
	if (scalefactor == 0)
		scalefactor = 1;

	YARPTime::DelayInSeconds(1.0);

	while (1)
	{
		// read all the valid boxes and try to fuse them...
		for (int i = 0; i < NUMBEROFCHANNELS; i++)
		{
			if (channels[i].Read(0))
			{
				boxes[i] = channels[i].Content();
			}
		}

		out_image.Zero ();
		out_image_dominant.Zero ();

		// add channel boxes (5) to out_image.
		for (i = 0; i < NUMBEROFCHANNELS; i++)
			DrawBoxes (boxes[i], out_image, relative_weight[i], scalefactor);
		for (i = 0; i < NUMBEROFCHANNELS; i++)
	          {
		    if (source_retina[i] == RETINA_DOMINANT)
		      {
			DrawBoxes (boxes[i], out_image_dominant, relative_weight[i], scalefactor);
		      }
		  }

		//TmpFilter (old_image, out_image);

		int xx = 0, yy = 0;
		int xx_dom = 0, yy_dom = 0;
		bool valid = FindCentroid (out_image, &xx, &yy);
		FindCentroid (out_image_dominant, &xx_dom, &yy_dom);

		out_data.valid = valid;
		out_data.xl = xx;
		out_data.yl = yy;
		out_data.xr = xx;
		out_data.yr = yy;

		out_data_dominant.valid = true;
		out_data_dominant.xl = xx_dom;
		out_data_dominant.yl = yy_dom;
		out_data_dominant.xr = xx_dom;
		out_data_dominant.yr = yy_dom;

		YARPGenericImage& outImg = out_saliency.Content(); // Lasts until next Write()
		outImg.PeerCopy(out_image);
		out_saliency.Write();					

		out.Content() = out_data;
		out.Write();
		out_dominant.Content() = out_data_dominant;
		out_dominant.Write();
		delay(30);
	}
}