Mesh3DS Class Usage Notes

There are only 3 public methods to the Mesh3DS Class:

An example of each method follows below. In addition, I've provided Display3DS - a sample Visual C++ application which demonstrates usage of the Mesh3DS class.

Display3DS and all the code within it is provided freely and without warrantees or restrictions of any kind in order to help others form a minimal MFC compliant codebase onto which new features and functionality can be prototyped.


Code fragment to instantiate a Mesh3DS object and Parse a named 3DS mesh file:
#include "Mesh3DS\Mesh3DS.h"
	.
	.
	.
	Mesh3DS	*mesh;					// Pointer to 3D Studio MAX mesh object
	
BOOL LoadNewMesh (CString filename)
	{
	if	(mesh) delete mesh;			// Delete any mesh object

	mesh	= new Mesh3DS (filename, 90, force2sided)); 	// Instantiate mesh object

	if	(!mesh->Parse3DS(filename))
		{
		delete		mesh;
		mesh		= NULL:
		CString		error;
		error.Format	("Failed to Decode 3D Studio MAX file!: %s", filename);
		AfxMessageBox	(error, MB_OK);
		error.Empty	();			// Prevents false CMemoryState memory leak traps 
		return false;
		}

	return true;
 	}

Code fragment to scale the 3DS Mesh. Use 0.50 to Halve, 2.00 to Double, etc.:
void Zoom (GLfloat zoom)
	{
	mesh->Zoom (zoom);
	}

Code fragment to display the 3DS Mesh onto your current OpenGL Rendering Context:
void DrawMeshes()
	{
	if	(AfxIsMemoryBlock (mesh, sizeof(Mesh3DS)))		// We have a valid mesh?
		{
		glPushMatrix	();
		glPushAttrib	(GL_ALL_ATTRIB_BITS);

		glEnable	(GL_TEXTURE_2D);		 	// Enable Texturing
		glEnable	(GL_LIGHTING);				// Enable Lighting
		glEnable	(GL_LIGHT0);				// Enable Default Light
		glEnable	(GL_BLEND);				// Enable Blending functions

		glBlendFunc	(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);	// Handle transparent surfaces
		glMateriali	(GL_FRONT, GL_SHININESS, 128);		// Maximize material shininess
		glEnable	(GL_DEPTH_TEST);		 	// Enable depth testing for graphic element
		glEnable	(GL_CULL_FACE);				// Enable culling of unused faces
		glCullFace	(GL_BACK);				// Cull backwards facing surfaces
		glFrontFace	(GL_CCW);				// Specify Counter-clockwise faces as backwards facing

		mesh->ExecuteDisplayList ();				// Display the mesh onto the OpenGL RC

		glPopAttrib	();
		glPopMatrix	();
		}
	}