/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ #include #include using namespace osg; Material::Material() { _colorMode = OFF; _ambientFrontAndBack = true; _ambientFront.set(0.2f, 0.2f, 0.2f, 1.0f); _ambientBack.set(0.2f, 0.2f, 0.2f, 1.0f); _diffuseFrontAndBack = true; _diffuseFront.set(0.8f, 0.8f, 0.8f, 1.0f); _diffuseBack.set(0.8f, 0.8f, 0.8f, 1.0f); _specularFrontAndBack = true; _specularFront.set(0.0f, 0.0f, 0.0f, 1.0f); _specularBack.set(0.0f, 0.0f, 0.0f, 1.0f); _emissionFrontAndBack = true; _emissionFront.set(0.0f, 0.0f, 0.0f, 1.0f); _emissionBack.set(0.0f, 0.0f, 0.0f, 1.0f); _shininessFrontAndBack = true; _shininessFront = 0.0f; _shininessBack = 0.0f; } Material::~Material() { } Material& Material:: operator = (const Material& rhs) { if (&rhs==this) return *this; _colorMode= rhs._colorMode; _ambientFrontAndBack= rhs._ambientFrontAndBack; _ambientFront= rhs._ambientFront; _ambientBack= rhs._ambientBack; _diffuseFrontAndBack= rhs._diffuseFrontAndBack; _diffuseFront= rhs._diffuseFront; _diffuseBack= rhs._diffuseBack; _specularFrontAndBack= rhs._specularFrontAndBack; _specularFront= rhs._specularFront; _specularBack= rhs._specularBack; _emissionFrontAndBack= rhs._emissionFrontAndBack; _emissionFront= rhs._emissionFront; _emissionBack= rhs._emissionBack; _shininessFrontAndBack= rhs._shininessFrontAndBack; _shininessFront= rhs._shininessFront; _shininessBack= rhs._shininessBack; return *this; } void Material::setAmbient(Face face, const Vec4& ambient ) { switch(face) { case(FRONT): _ambientFrontAndBack = false; _ambientFront = ambient; //clampArray4BetweenRange(_ambientFront,0.0f,1.0f,"osg::Material::setAmbient(..)"); break; case(BACK): _ambientFrontAndBack = false; _ambientBack = ambient; //clampArray4BetweenRange(_ambientBack,0.0f,1.0f,"Material::setAmbient(..)"); break; case(FRONT_AND_BACK): _ambientFrontAndBack = true; _ambientFront = ambient; //clampArray4BetweenRange(_ambientFront,0.0f,1.0f,"Material::setAmbient(..)"); _ambientBack = _ambientFront; break; default: notify(NOTICE)<<"Notice: invalid Face passed to Material::setAmbient()."<