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

A small VRML viewer using OpenGL and MFC

, 30 Nov 1999
//********************************************
// Material.cpp
//********************************************
// pierre.alliez@cnet.francetelecom.fr
// Created : 24/02/98
// Modified : 24/02/98
//********************************************

#include "stdafx.h"
#include "Material.h"

//********************************************
// Constructor
//********************************************
CMaterial::CMaterial()
{
	// Default
	SetAmbient(0.0f,0.33f,0.5f,1.0f);
	SetDiffuse(0.5f,0.5f,0.5f,1.0f);
	SetSpecular(1.0f,1.0f,1.0f,1.0f);
	SetShininess(84.0f);
	SetEmission(0.0f,0.0f,0.0f,1.0f);
}

//////////////////////////////////////////////
// DATA SETTINGS
//////////////////////////////////////////////

//********************************************
// SetAmbient
//********************************************
void CMaterial::SetAmbient(float r,
													 float g,
													 float b,
													 float a)
{
	m_pAmbient[0] = r;
	m_pAmbient[1] = g;
	m_pAmbient[2] = b;
	m_pAmbient[3] = a;
}

//********************************************
// SetDiffuse
//********************************************
void CMaterial::SetDiffuse(float r,
													 float g,
													 float b,
													 float a)
{
	m_pDiffuse[0] = r;
	m_pDiffuse[1] = g;
	m_pDiffuse[2] = b;
	m_pDiffuse[3] = a;
}

//********************************************
// SetSpecular
//********************************************
void CMaterial::SetSpecular(float r,
														float g,
														float b,
														float a)
{
	m_pSpecular[0] = r;
	m_pSpecular[1] = g;
	m_pSpecular[2] = b;
	m_pSpecular[3] = a;
}

//********************************************
// SetEmission
//********************************************
void CMaterial::SetEmission(float r,
														float g,
														float b,
														float a)
{
	m_pEmission[0] = r;
	m_pEmission[1] = g;
	m_pEmission[2] = b;
	m_pEmission[3] = a;
}


//********************************************
// SetShininess
//********************************************
void CMaterial::SetShininess(float value)
{
	m_pShininess[0] = value;
}

//********************************************
// Copy
//********************************************
void CMaterial::Copy(CMaterial *pMaterial)
{
	SetSpecular(pMaterial->GetSpecular()[0],pMaterial->GetSpecular()[1],pMaterial->GetSpecular()[2],pMaterial->GetSpecular()[3]);
	SetAmbient(pMaterial->GetAmbient()[0],pMaterial->GetAmbient()[1],pMaterial->GetAmbient()[2],pMaterial->GetAmbient()[3]);
	SetDiffuse(pMaterial->GetDiffuse()[0],pMaterial->GetDiffuse()[1],pMaterial->GetDiffuse()[2],pMaterial->GetDiffuse()[3]);
	SetEmission(pMaterial->GetEmission()[0],pMaterial->GetEmission()[1],pMaterial->GetEmission()[2],pMaterial->GetEmission()[3]);
	SetShininess(pMaterial->GetShininess()[0]);
}


// ** 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

About the Author

Pierre Alliez

France France
No Biography provided

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 1 Dec 1999
Article Copyright 1999 by Pierre Alliez
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid