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

StL Data File Viewer

, 5 Mar 2003 GPL3
A simple StereoLithography data file viewer.
// GLTrihedron.cpp: implementation of the CGLTrihedron class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "GLTrihedron.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CGLTrihedron::CGLTrihedron()
{
	glObjType = GLTRIHEDRON;
}

CGLTrihedron::CGLTrihedron(GLfloat size)
{
	glObjType = GLTRIHEDRON;
	csSize = size;
	ComputeBoundLimits();
	glObjID = (int)glObjType + CGLObject::GetCount();
}

CGLTrihedron::~CGLTrihedron()
{
}

CGLObject* CGLTrihedron::Copy() const
{
	CGLTrihedron* T = new CGLTrihedron(csSize);
	T->glObjID = glObjID;
	return T;
}

void CGLTrihedron::DefineDisplay()
{
	glDisable(GL_LIGHTING);
	glDisable(GL_COLOR_MATERIAL);
	glEnable(GL_DEPTH_TEST);

	//Axes' label
	glColor3f(1.0f, 1.0f, 0.0f);
	glRasterPos3d(0.5*csSize, 0, 0);
	DrawText("X");
	glRasterPos3d(0, 0.5*csSize, 0);
	DrawText("Y");
	glRasterPos3d(0, 0, 0.5*csSize);
	DrawText("Z");

	glColor3f(0.70f, 0.70f, 1.70f);
	//X Axis
	glBegin(GL_LINES);
	glVertex3f(0.0f, 0.0f, 0.0f);
	glVertex3f(0.8*csSize*0.5, 0.0f, 0.0f);
	glEnd();
	glPushMatrix();	
	glTranslatef(0.8*csSize*0.5, 0.0f, 0.0f);
	glRotatef(90.0f,0.0f,1.0f,0.0f);
	glutWireCone(0.027*csSize,0.09*csSize,10,10);
	glPopMatrix();

	//Y Axis
	glBegin(GL_LINES);
	glVertex3f(0.0f, 0.0f, 0.0f);
	glVertex3f(0.0f, 0.8*csSize*0.5, 0.0f);
	glEnd();
	glPushMatrix();	
	glTranslatef(0.0f, 0.8*csSize*0.5, 0.0f);
	glRotatef(-90.0f,1.0f,0.0f,0.0f);
	glutWireCone(0.027*csSize,0.09*csSize,10,10);
	glPopMatrix();

	//Z Axis
	glBegin(GL_LINES);
	glVertex3f(0.0f, 0.0f, 0.0f);
	glVertex3f(0.0f, 0.0f, 0.8*csSize*0.5);
	glEnd();
	glPushMatrix();	
	glTranslatef(0.0f, 0.0f, 0.8*csSize*0.5);
	glutWireCone(0.027*csSize,0.09*csSize,10,10);
	glPopMatrix();

	glDisable(GL_DEPTH_TEST);
}

void CGLTrihedron::Display(const GLDisplayMode& dMode)
{
	DefineDisplay();
}

void CGLTrihedron::Hilight(const GLDisplayMode& dMode)
{
}

void CGLTrihedron::SetSize(GLfloat size)
{
	csSize = size;
}

void CGLTrihedron::DrawText(char* string)
{
    char* p = NULL;

    for (p = string; *p; p++)
	glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, *p);
}

void CGLTrihedron::ComputeBoundLimits()
{
	itsBox.SetLimits(-csSize, csSize, -csSize, csSize, -csSize, csSize);
}

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, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

Share

About the Author

Sharjith
Engineer Tata Technologies Ltd
India India
Sharjith is a Mechanical Engineer with strong passion for Automobiles, Aircrafts and Software development.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141223.1 | Last Updated 6 Mar 2003
Article Copyright 2003 by Sharjith
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid