void	WED_TCEDebugLayer::DrawStructure			(bool inCurrent, GUI_GraphState * g)
{
	WED_MapZoomerNew * z = GetZoomer();
	#if DEV
		g->SetState(false, 0, false,    false, false,   false, false);

		for(int n = 0; n < gMeshPolygons.size(); ++n)
		{
			glColor4f(gMeshPolygons[n].second.x,gMeshPolygons[n].second.y,gMeshPolygons[n].second.z, 0.3);			
			glPolygon2(&*gMeshPolygons[n].first.begin(), false, NULL, gMeshPolygons[n].first.size());
		}
		

		glBegin(GL_LINES);
		for(int n = 0; n < gMeshLines.size(); ++n)
		{
			glColor3f(gMeshLines[n].second.x,gMeshLines[n].second.y,gMeshLines[n].second.z);
			glVertex2(z->LLToPixel(gMeshLines[n].first));
		}
		glEnd();
		glPointSize(5);
		glBegin(GL_POINTS);
		for(int n = 0; n < gMeshPoints.size(); ++n)
		{
			glColor3f(gMeshPoints[n].second.x,gMeshPoints[n].second.y,gMeshPoints[n].second.z);
			glVertex2(z->LLToPixel(gMeshPoints[n].first));
		}
		glEnd();
		
		glPointSize(1);

	#endif
}
Example #2
0
static gboolean
gv_rect_tool_draw(GvRectTool *tool)
{
    if (tool->drawing)
    {
        /* Color is set when the layer is drawn,
           so we don't need to repeat it here */

        glBegin(GL_LINE_LOOP);
        glVertex2(tool->v_head.x, tool->v_head.y);
        glVertex2(tool->v_head.x, tool->v_tail.y);
        glVertex2(tool->v_tail.x, tool->v_tail.y);
        glVertex2(tool->v_tail.x, tool->v_head.y);
        glVertex2(tool->v_head.x, tool->v_head.y);
        glEnd();
    }
    return FALSE;
}
Example #3
0
static void
gv_rotate_tool_draw(GvRotateTool *tool)
{
/* -------------------------------------------------------------------- */
/*      If we have a selected shape, we need to draw the                */
/*      rotate/resize arrow handles.                                    */
/* -------------------------------------------------------------------- */
    if (tool->shape_id != -1 )
    {
        GvVertex v_up, v_right;
        double rad_rot;

        /*
        ** In display mode recompute the pivot, up and right vector each
        ** redraw. 
        */
        if( tool->rrmode == RRMODE_DISPLAY )
        {
            if( !gv_rotate_tool_setup_arrows( tool ) )
                return;
        }

        /* 
        ** Apply scaling and rotation.
        */

        rad_rot = (tool->rotation / 180.0) * M_PI;
        v_up.x = tool->v_up.x*cos(rad_rot) + tool->v_up.y*sin(rad_rot);
        v_up.y = - tool->v_up.x*sin(rad_rot) + tool->v_up.y*cos(rad_rot);
        v_right.x = tool->v_right.x*cos(rad_rot) + tool->v_right.y*sin(rad_rot);
        v_right.y = -tool->v_right.x*sin(rad_rot) + tool->v_right.y*cos(rad_rot);

        v_up.x *= tool->scaling;
        v_up.y *= tool->scaling;
        v_right.x *= tool->scaling;
        v_right.y *= tool->scaling;

        glColor4f( 1.0, 0.0, 0.0, 1.0 );

        if( tool->rrmode != RRMODE_SCALE )
        {
            /** Upward line with left/right rotate arrow heads **/
            glBegin( GL_LINES );
            glVertex2( tool->v_pivot.x, tool->v_pivot.y );
            glVertex2( tool->v_pivot.x + v_up.x * ARROW_SIZE, 
                       tool->v_pivot.y + v_up.y * ARROW_SIZE );

            /* left pointing arrow */
            glVertex2( tool->v_pivot.x 
                       + v_up.x * ARROW_SIZE
                       - v_right.x * HEAD_SIZE*2, 
                       tool->v_pivot.y 
                       + v_up.y * ARROW_SIZE
                       - v_right.y * HEAD_SIZE*2 );
            glVertex2( tool->v_pivot.x + v_up.x * ARROW_SIZE, 
                       tool->v_pivot.y + v_up.y * ARROW_SIZE );

            glVertex2( tool->v_pivot.x 
                       + v_up.x * ARROW_SIZE
                       - v_right.x * HEAD_SIZE*2, 
                       tool->v_pivot.y 
                       + v_up.y * ARROW_SIZE
                       - v_right.y * HEAD_SIZE*2 );
            glVertex2( tool->v_pivot.x 
                       + v_up.x * (ARROW_SIZE+HEAD_SIZE)
                       - v_right.x * HEAD_SIZE, 
                       tool->v_pivot.y 
                       + v_up.y * (ARROW_SIZE+HEAD_SIZE)
                       - v_right.y * HEAD_SIZE );

            glVertex2( tool->v_pivot.x 
                       + v_up.x * ARROW_SIZE
                       - v_right.x * HEAD_SIZE*2, 
                       tool->v_pivot.y 
                       + v_up.y * ARROW_SIZE
                       - v_right.y * HEAD_SIZE*2 );
            glVertex2( tool->v_pivot.x 
                       + v_up.x * (ARROW_SIZE-HEAD_SIZE)
                       - v_right.x * HEAD_SIZE, 
                       tool->v_pivot.y 
                       + v_up.y * (ARROW_SIZE-HEAD_SIZE)
                       - v_right.y * HEAD_SIZE );

            /* rightward  pointing arrow */
            glVertex2( tool->v_pivot.x 
                       + v_up.x * ARROW_SIZE
                       + v_right.x * HEAD_SIZE*2, 
                       tool->v_pivot.y 
                       + v_up.y * ARROW_SIZE
                       + v_right.y * HEAD_SIZE*2 );
            glVertex2( tool->v_pivot.x + v_up.x * ARROW_SIZE, 
                       tool->v_pivot.y + v_up.y * ARROW_SIZE );

            glVertex2( tool->v_pivot.x 
                       + v_up.x * ARROW_SIZE
                       + v_right.x * HEAD_SIZE*2, 
                       tool->v_pivot.y 
                       + v_up.y * ARROW_SIZE
                       + v_right.y * HEAD_SIZE*2 );
            glVertex2( tool->v_pivot.x 
                       + v_up.x * (ARROW_SIZE+HEAD_SIZE)
                       + v_right.x * HEAD_SIZE, 
                       tool->v_pivot.y 
                       + v_up.y * (ARROW_SIZE+HEAD_SIZE)
                       + v_right.y * HEAD_SIZE );

            glVertex2( tool->v_pivot.x 
                       + v_up.x * ARROW_SIZE
                       + v_right.x * HEAD_SIZE*2, 
                       tool->v_pivot.y 
                       + v_up.y * ARROW_SIZE
                       + v_right.y * HEAD_SIZE*2 );
            glVertex2( tool->v_pivot.x 
                       + v_up.x * (ARROW_SIZE-HEAD_SIZE)
                       + v_right.x * HEAD_SIZE, 
                       tool->v_pivot.y 
                       + v_up.y * (ARROW_SIZE-HEAD_SIZE)
                       + v_right.y * HEAD_SIZE );

            glEnd();
        }

        if( tool->rrmode != RRMODE_ROTATE )
        {

            /** Rightward arrow for resizing. **/
            glBegin( GL_LINES );
            glVertex2( tool->v_pivot.x, tool->v_pivot.y );
            glVertex2( tool->v_pivot.x + v_right.x * ARROW_SIZE, 
                       tool->v_pivot.y + v_right.y * ARROW_SIZE );

            glVertex2( tool->v_pivot.x 
                       + v_right.x * (ARROW_SIZE-HEAD_SIZE)
                       + v_up.x * HEAD_SIZE, 
                       tool->v_pivot.y 
                       + v_right.y * (ARROW_SIZE-HEAD_SIZE)
                       + v_up.y * HEAD_SIZE );
            glVertex2( tool->v_pivot.x + v_right.x * ARROW_SIZE, 
                       tool->v_pivot.y + v_right.y * ARROW_SIZE );

            glVertex2( tool->v_pivot.x 
                       + v_right.x * (ARROW_SIZE-HEAD_SIZE)
                       - v_up.x * HEAD_SIZE, 
                       tool->v_pivot.y 
                       + v_right.y * (ARROW_SIZE-HEAD_SIZE)
                       - v_up.y * HEAD_SIZE );
            glVertex2( tool->v_pivot.x + v_right.x * ARROW_SIZE, 
                       tool->v_pivot.y + v_right.y * ARROW_SIZE );

            glEnd();
        }
    }
}
Example #4
0
void IndexedFaceSet2D::Draw(X3DDrawContext* pDC, X3DTextureNodeImplImpl* pTextureNode)
{
	ASSERT(0);
#if 0
	if (pDC->m_pGraphics2D)
	{
		Coordinate2D* coordinate2D = dynamic_cast<Coordinate2D*>(m_coord->m_value);
		if (coordinate2D)
		{
			MFVec2f* point = coordinate2D->getPoint();

			//MFVec2f* texpoint;

			//MFInt32* useTexCoordIndex;

			/*
			if (texcoordinate)
			{
				texpoint = static_cast<MFVec2f*>(static_cast<CLTextureCoordinate*>(texcoordinate.p)->m_point);

				if (texCoordIndex->m_items.GetSize() > 0)
				{
					if (texCoordIndex->m_items.GetSize() != coordIndex->m_items.GetSize())
					{
						// TODO, mark this object with some kind of error flag
						// m_bError = TRUE
						return;	// Error
					}
					useTexCoordIndex = texCoordIndex;
				}
				else
				{
					useTexCoordIndex = coordIndex;
				}
			}
			*/

			LDraw::Brush* pBrush = pDC->m_pBrush;

			if (m_convex->m_value != false)
			{
				if (m_coordIndex->m_items.GetSize() == 0)
				{
				//	LDraw::GraphicsPath path;

					/*
					for (int i = 0; i < point->m_items.GetSize(); i++)
					{
						gmVector2& v = point->m_items[i];
						glVertex2(v);
					}
					*/

					pDC->m_pGraphics2D->FillPolygon(pBrush, (LDraw::PointF*)point->m_items.GetData(), point->m_items.GetSize());
				}
				else
				{
					int i = 0;
					while (i < m_coordIndex->m_items.GetSize())
					{
						//CArray<gmVector3,gmVector3&> vertices;

						int j = i;
						int count = 0;
						while (j < m_coordIndex->m_items.GetSize())
						{
							long index = m_coordIndex->m_items[j];
							if (index == -1)
							{
								j++;
								break;
							}

							count++;
							//glVertex3(static_cast<SFVec3f*>(<ILSFVec3f>(point->m_items[index]).p)->m_v);
						//	vertices.Add(static_cast<SFVec3f*>(<ILSFVec3f>(point->m_items[index]).p)->m_v);
							j++;
						}
						//int count = j-i;

						ASSERT(count >= 3);

						pDC->m_pGraphics2D->FillPolygon(pBrush, (LDraw::PointD*)point->m_items.GetData() + i, count);

#if 0
						glBegin(GL_POLYGON);

						/*
						LDraw::gmVector3f v2 = point->m_items[coordIndex->m_items[i+2]];
						LDraw::gmVector3f v1 = point->m_items[coordIndex->m_items[i+1]];
						LDraw::gmVector3f v0 = point->m_items[coordIndex->m_items[i]];
						lglNormal(v2, v1, v0);
						*/

						if (TRUE)
						{
							for (int k = count-1; k >= 0; k--)
							{
								/*
								if (texcoordinate)
								{
									long texIndex = useTexCoordIndex->m_items[i+k];
									gmVector2& texvec = texpoint->m_items[texIndex];
									glTexCoord2f(texvec[0], texvec[1]);
								}
								*/
								gmVector2& v = point->m_items[m_coordIndex->m_items[i+k]];
								glVertex2(v);
							}
						}
						else
						{
							/*
							for (int k = 0; k < count; k++)
							{
								if (texcoordinate)
								{
									long texIndex = useTexCoordIndex->m_items[i+k];
									gmVector2& texvec = texpoint->m_items[texIndex];
									glTexCoord2f(texvec[0], texvec[1]);
								}
								LDraw::gmVector3f& v = point->m_items[coordIndex->m_items[i+k]];
								glVertex3(v);
							}
							*/
						}

						i = j;

						glEnd();
#endif
					}
				}
			}
			else
			{
				int i = 0;
				while (i < m_coordIndex->m_items.GetSize())
				{
					//CArray<gmVector3,gmVector3&> vertices;

					int j = i;
					int count = 0;
					while (j < m_coordIndex->m_items.GetSize())
					{
						long index = m_coordIndex->m_items[j];
						if (index == -1)
						{
							j++;
							break;
						}

						count++;
						//glVertex3(static_cast<SFVec3f*>(<ILSFVec3f>(point->m_items[index]).p)->m_v);
					//	vertices.Add(static_cast<SFVec3f*>(<ILSFVec3f>(point->m_items[index]).p)->m_v);
						j++;
					}
					//int count = j-i;

					ASSERT(count >= 3);

					pDC->m_pGraphics3D->glBegin(GL_LINE_STRIP);

					/*
					LDraw::gmVector3f v2 = point->m_items[coordIndex->m_items[i+2]];
					LDraw::gmVector3f v1 = point->m_items[coordIndex->m_items[i+1]];
					LDraw::gmVector3f v0 = point->m_items[coordIndex->m_items[i]];
					lglNormal(v2, v1, v0);
					*/

					if (true)
					{
						for (int k = count-1; k >= 0; k--)
						{
							/*
							if (texcoordinate)
							{
								long texIndex = useTexCoordIndex->m_items[i+k];
								gmVector2& texvec = texpoint->m_items[texIndex];
								glTexCoord2f(texvec[0], texvec[1]);
							}
							*/
							LDraw::vector2f& v = point->m_items[m_coordIndex->m_items[i+k]];
							pDC->m_pGraphics3D->glVertex(v);
						}
					}
					else
					{
						/*
						for (int k = 0; k < count; k++)
						{
							if (texcoordinate)
							{
								long texIndex = useTexCoordIndex->m_items[i+k];
								gmVector2& texvec = texpoint->m_items[texIndex];
								glTexCoord2f(texvec[0], texvec[1]);
							}
							LDraw::gmVector3f& v = point->m_items[coordIndex->m_items[i+k]];
							glVertex3(v);
						}
						*/
					}

					i = j;

					pDC->m_pGraphics3D->glEnd();
				}
			}
		}

		return;
	}

	Coordinate2D* coordinate2D = dynamic_cast<Coordinate2D*>(m_coord->m_value);
	if (coordinate2D)
	{
		MFVec2f* point = coordinate2D->getPoint();

		//MFVec2f* texpoint;

		//MFInt32* useTexCoordIndex;

		/*
		if (texcoordinate)
		{
			texpoint = static_cast<MFVec2f*>(static_cast<CLTextureCoordinate*>(texcoordinate.p)->m_point);

			if (texCoordIndex->m_items.GetSize() > 0)
			{
				if (texCoordIndex->m_items.GetSize() != coordIndex->m_items.GetSize())
				{
					// TODO, mark this object with some kind of error flag
					// m_bError = TRUE
					return;	// Error
				}
				useTexCoordIndex = texCoordIndex;
			}
			else
			{
				useTexCoordIndex = coordIndex;
			}
		}
		*/

		if (m_convex->m_value != false)
		{
			if (m_coordIndex->m_items.GetSize() == 0)
			{
				pDC->m_pGraphics3D->glBegin(GL_POLYGON);

				for (int i = 0; i < point->m_items.GetSize(); i++)
				{
					LDraw::vector2f& v = point->m_items[i];
					pDC->m_pGraphics3D->glVertex(v);
				}

				pDC->m_pGraphics3D->glEnd();
			}
			else
			{
				int i = 0;
				while (i < m_coordIndex->m_items.GetSize())
				{
					//CArray<gmVector3,gmVector3&> vertices;

					int j = i;
					int count = 0;
					while (j < m_coordIndex->m_items.GetSize())
					{
						long index = m_coordIndex->m_items[j];
						if (index == -1)
						{
							j++;
							break;
						}

						count++;
						//glVertex3(static_cast<SFVec3f*>(<ILSFVec3f>(point->m_items[index]).p)->m_v);
					//	vertices.Add(static_cast<SFVec3f*>(<ILSFVec3f>(point->m_items[index]).p)->m_v);
						j++;
					}
					//int count = j-i;

					ASSERT(count >= 3);

					pDC->m_pGraphics3D->glBegin(GL_POLYGON);

					/*
					LDraw::gmVector3f v2 = point->m_items[coordIndex->m_items[i+2]];
					LDraw::gmVector3f v1 = point->m_items[coordIndex->m_items[i+1]];
					LDraw::gmVector3f v0 = point->m_items[coordIndex->m_items[i]];
					lglNormal(v2, v1, v0);
					*/

					if (true)
					{
						for (int k = count-1; k >= 0; k--)
						{
							/*
							if (texcoordinate)
							{
								long texIndex = useTexCoordIndex->m_items[i+k];
								gmVector2& texvec = texpoint->m_items[texIndex];
								glTexCoord2f(texvec[0], texvec[1]);
							}
							*/
							LDraw::vector2f& v = point->m_items[m_coordIndex->m_items[i+k]];
							pDC->m_pGraphics3D->glVertex(v);
						}
					}
					else
					{
						/*
						for (int k = 0; k < count; k++)
						{
							if (texcoordinate)
							{
								long texIndex = useTexCoordIndex->m_items[i+k];
								gmVector2& texvec = texpoint->m_items[texIndex];
								glTexCoord2f(texvec[0], texvec[1]);
							}
							LDraw::gmVector3f& v = point->m_items[coordIndex->m_items[i+k]];
							glVertex3(v);
						}
						*/
					}

					i = j;

					pDC->m_pGraphics3D->glEnd();
				}
			}
		}
		else
		{
			int i = 0;
			while (i < m_coordIndex->m_items.GetSize())
			{
				//CArray<gmVector3,gmVector3&> vertices;

				int j = i;
				int count = 0;
				while (j < m_coordIndex->m_items.GetSize())
				{
					long index = m_coordIndex->m_items[j];
					if (index == -1)
					{
						j++;
						break;
					}

					count++;
					//glVertex3(static_cast<SFVec3f*>(<ILSFVec3f>(point->m_items[index]).p)->m_v);
				//	vertices.Add(static_cast<SFVec3f*>(<ILSFVec3f>(point->m_items[index]).p)->m_v);
					j++;
				}
				//int count = j-i;

				ASSERT(count >= 3);

				pDC->m_pGraphics3D->glBegin(GL_LINE_STRIP);

				/*
				LDraw::gmVector3f v2 = point->m_items[coordIndex->m_items[i+2]];
				LDraw::gmVector3f v1 = point->m_items[coordIndex->m_items[i+1]];
				LDraw::gmVector3f v0 = point->m_items[coordIndex->m_items[i]];
				lglNormal(v2, v1, v0);
				*/

				if (true)
				{
					for (int k = count-1; k >= 0; k--)
					{
						/*
						if (texcoordinate)
						{
							long texIndex = useTexCoordIndex->m_items[i+k];
							gmVector2& texvec = texpoint->m_items[texIndex];
							glTexCoord2f(texvec[0], texvec[1]);
						}
						*/
						LDraw::vector2f& v = point->m_items[m_coordIndex->m_items[i+k]];
						pDC->m_pGraphics3D->glVertex(v);
					}
				}
				else
				{
					/*
					for (int k = 0; k < count; k++)
					{
						if (texcoordinate)
						{
							long texIndex = useTexCoordIndex->m_items[i+k];
							gmVector2& texvec = texpoint->m_items[texIndex];
							glTexCoord2f(texvec[0], texvec[1]);
						}
						LDraw::gmVector3f& v = point->m_items[coordIndex->m_items[i+k]];
						glVertex3(v);
					}
					*/
				}

				i = j;

				pDC->m_pGraphics3D->glEnd();
			}
		}
	}
#endif
}