Click here to Skip to main content
Click here to Skip to main content
Articles » Multimedia » OpenGL » General » Downloads
 
Add your own
alternative version

Achieving PostScript and Wmf outputs for OpenGL

, 9 Jun 2003
This article explains how to generate resolution independent versions of 3D meshes rendered by OpenGL/MFC programs, i.e. how to export the rendering results to vectorial formats such as encapsulated postscript (EPS) and Windows enhanced metafile (EMF) formats. The main goal consists of being able to
gl_export.zip
Src
Mesh.dsp
Mesh.dsw
Mesh.plg
Mesh.aps
Mesh.clw
Lib3D
res
Mesh.ico
MeshDoc.ico
Toolbar.bmp
Mesh.ncb
Mesh.opt
Bin
knot2.wrl
mnt.wrl
mannequin.wrl
venus.wrl
knot1.wrl
nefertiti.wrl
geosphere.wrl
metafile.emf
Mesh.exe
samples_eps.zip
nefertiti_flat.eps
nefertiti_line_light.eps
nefertiti_line.eps
nefertiti_line_color.eps
nefertiti_smooth_light.eps
nefertiti_line_smooth_light.eps
nefertiti_vertex_color.eps
sample_ppt.zip
sample.ppt
//********************************************
// Edge3d.cpp
//********************************************
// class CEdge3d
//********************************************
// alliez@usc.edu
// Created : 10/12/97
// Modified : 16/12/97
//********************************************

#include "stdafx.h"

#include "Base3d.h"
#include "Edge3d.h"

//////////////////////////////////////////////
//////////////////////////////////////////////
// CONSTRUCTORS
//////////////////////////////////////////////
//////////////////////////////////////////////

//********************************************
// Constructor
//********************************************
CEdge3d::CEdge3d()
{
	m_pVertex1 = NULL;
	m_pVertex2 = NULL;
	m_pFace1 = NULL;
	m_pFace2 = NULL;
	m_Flag = 0;
}


//********************************************
// Constructor
//********************************************
CEdge3d::CEdge3d(CVertex3d *pVertex1,
								 CVertex3d *pVertex2)
{
	Set(pVertex1,pVertex2);
	m_pFace1 = NULL;
	m_pFace2 = NULL;
	m_Flag = 0;
}

//********************************************
// Constructor
//********************************************
CEdge3d::CEdge3d(CVertex3d *pVertex1,
								 CVertex3d *pVertex2,
								 CFace3d *pFace1,
								 CFace3d *pFace2)
{
	Set(pVertex1,pVertex2);
	Set(pFace1,pFace2);
	m_Flag = 0;
}


//********************************************
// Constructor
//********************************************
CEdge3d::CEdge3d(CEdge3d *pEdge)
{
	Set(pEdge);
	m_Flag = 0;
}



//////////////////////////////////////////////
//////////////////////////////////////////////
// DATAS
//////////////////////////////////////////////
//////////////////////////////////////////////

//********************************************
// GetType
//********************************************
int CEdge3d::GetType()
{
	return TYPE_EDGE3D;
}

//********************************************
// Set
//********************************************
void CEdge3d::Set(CVertex3d *pVertex1,
									CVertex3d *pVertex2)
{
	m_pVertex1 = pVertex1;
	m_pVertex2 = pVertex2;
}

//********************************************
// Set
//********************************************
void CEdge3d::Set(CFace3d *pFace1,
									CFace3d *pFace2)
{
	m_pFace1 = pFace1;
	m_pFace2 = pFace2;
}


//********************************************
// Set
//********************************************
void CEdge3d::Set(CEdge3d *pEdge)
{
	Set(pEdge->v1(),pEdge->v2());
	Set(pEdge->f1(),pEdge->f2());
}

//////////////////////////////////////////////
//////////////////////////////////////////////
// PROCESSING
//////////////////////////////////////////////
//////////////////////////////////////////////

//********************************************
// sharp
// threshold : sin(angle)
//********************************************
int CEdge3d::sharp(float threshold)
{
	// Check
	if(m_pFace1 == NULL || 
	   m_pFace2 == NULL)
		return 0;

	return (SinAngle(m_pFace1,m_pFace2) >= threshold);
}

//********************************************
// Equal (order independant)
//********************************************
int CEdge3d::Equal(CEdge3d *pEdge)
{
	int success = 0;
	success += m_pVertex1 == pEdge->v1();
	success += m_pVertex1 == pEdge->v2();
	success += m_pVertex2 == pEdge->v1();
	success += m_pVertex2 == pEdge->v2();
	return (success >= 2);
}


//********************************************
// GetVertexDiff
//********************************************
CVertex3d *CEdge3d::GetVertexDiff(CVertex3d *pVertexDiff)
{
	if(m_pVertex1 != pVertexDiff)
		return m_pVertex1;
	else
	{
		ASSERT(m_pVertex2 != pVertexDiff);
		return m_pVertex2;
	}
}

//////////////////////////////////////////////
//////////////////////////////////////////////
// OPENGL
//////////////////////////////////////////////
//////////////////////////////////////////////

//********************************************
// glDrawHighlight
// Highlights edge
//********************************************
void CEdge3d::glDrawHighlight(unsigned char *color)
{
	// Color
	glColor3ub(color[0],color[1],color[2]);

	::glBegin(GL_LINES);
		::glVertex3f(m_pVertex1->x(),m_pVertex1->y(),m_pVertex1->z());
		::glVertex3f(m_pVertex2->x(),m_pVertex2->y(),m_pVertex2->z());
	::glEnd();
}

//********************************************
// glDrawHighlight
// Highlights edge and neighbors
//********************************************
void CEdge3d::glDrawHighlight(unsigned char *color,
															unsigned char *ColorNeighbor)
{
	// Color
	glColor3ub(color[0],color[1],color[2]);

	::glBegin(GL_LINES);
		::glVertex3f(m_pVertex1->x(),m_pVertex1->y(),m_pVertex1->z());
		::glVertex3f(m_pVertex2->x(),m_pVertex2->y(),m_pVertex2->z());
	::glEnd();

	m_pFace1->glDraw(ColorNeighbor);
	m_pFace2->glDraw(ColorNeighbor);
}




// ** EOF **



By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Pierre Alliez

France France
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.1411019.1 | Last Updated 10 Jun 2003
Article Copyright 2001 by Pierre Alliez
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid