void XnVPointDrawer::Draw() const
{
	std::map<XnUInt32, std::list<XnPoint3D> >::const_iterator PointIterator;

	// Go over each existing hand
	for (PointIterator = m_History.begin();
		PointIterator != m_History.end();
		++PointIterator)
	{
		// Clear buffer
		XnUInt32 nPoints = 0;
		XnUInt32 i = 0;
		XnUInt32 Id = PointIterator->first;

		// Go over all previous positions of current hand
		std::list<XnPoint3D>::const_iterator PositionIterator;
		for (PositionIterator = PointIterator->second.begin();
			PositionIterator != PointIterator->second.end();
			++PositionIterator, ++i)
		{
			// Add position to buffer
			XnPoint3D pt(*PositionIterator);
			m_pfPositionBuffer[3*i] = pt.X;
			m_pfPositionBuffer[3*i + 1] = pt.Y;
			m_pfPositionBuffer[3*i + 2] = 0;//pt.Z();
		}

		//glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
		// Set color
		XnUInt32 nColor = Id % nColors;
		XnUInt32 nSingle = GetPrimaryID();
		if (Id == GetPrimaryID())
			nColor = 6;
		// Draw buffer:
//		glColor4f(0,
//				1,
//				1,
//				1.0f);
		glPointSize(2);
		glVertexPointer(3, GL_FLOAT, 0, m_pfPositionBuffer);
		glDrawArrays(GL_LINE_STRIP, 0, i);


//		if (IsTouching(Id))
//		{
//			glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
//		}
		glPointSize(8);
		glDrawArrays(GL_POINTS, 0, 1);
		glFlush();
	}
}
Beispiel #2
0
void XnVPointDrawer::Draw() const
{
	std::map<XnUInt32, std::list<XnPoint3D> >::const_iterator PointIterator;
	std::map<XnUInt32, XnPoint3D>::const_iterator holeIterator;
	holeIterator = m_hole.begin();
	// Go over each existing hand
	for (PointIterator = m_History.begin();
		PointIterator != m_History.end();
		++PointIterator, ++holeIterator)
	{
		// Clear buffer
		XnUInt32 nPoints = 0;
		XnUInt32 i = 0;
		XnUInt32 Id = PointIterator->first;
        XnFloat x, y;
        XnFloat z = 0;
		// Go over all previous positions of current hand
		std::list<XnPoint3D>::const_iterator PositionIterator;
		for (PositionIterator = PointIterator->second.begin();
			PositionIterator != PointIterator->second.end();
			++PositionIterator, ++i)
		{
			// Add position to buffer
			XnPoint3D pt(*PositionIterator);
			m_pfPositionBuffer[3*i] = pt.X;
			m_pfPositionBuffer[3*i + 1] = pt.Y;
			m_pfPositionBuffer[3*i + 2] = 0;//pt.Z();
            z = pt.Z;
		}
		// Set color
		XnUInt32 nColor = Id % nColors;
		XnUInt32 nSingle = GetPrimaryID();
		if (Id == GetPrimaryID())
			nColor = 0;
		// Draw buffer:
		glColor4f(Colors[nColor][0], Colors[nColor][1], Colors[nColor][2], 1.0f);
		glPointSize(2);
		glVertexPointer(3, GL_FLOAT, 0, m_pfPositionBuffer);
		glDrawArrays(GL_LINE_STRIP, 0, i);
		glPointSize(4);
		glDrawArrays(GL_POINTS, 0, 1);
		if (i > 0 && z != 0){
			x = m_pfPositionBuffer[3*i - 3];
			y = m_pfPositionBuffer[3*i - 2];
			XnFloat size = m_box_size * m_distance / z;
			XnFloat offset = m_offset * m_distance / z;
			XnFloat points[15] = { x - size, y - size, 0,
								x - size, y + size + offset, 0,
								x + size, y + size + offset, 0,
								x + size, y - size, 0,
								x - size, y - size, 0 };
			glPointSize(2);
			glVertexPointer(3, GL_FLOAT, 0, points);
			glDrawArrays(GL_LINE_STRIP, 0, 5);
		}
		
		XnPoint3D hole = holeIterator->second;
		if (hole.X != -1 && hole.Y != -1){
			XnFloat h[3] = {hole.X, hole.Y, hole.Z};
			glVertexPointer(3, GL_FLOAT, 0, h);
			glPointSize(8);
			glDrawArrays(GL_POINTS, 0, 1);
		}
		
		glFlush();
	}
}