Skip to content

Commit

Permalink
Add: reflectiveRate to gramma, which is used to indicate specular suface
Browse files Browse the repository at this point in the history
  • Loading branch information
wjzhou-ep committed Apr 1, 2012
1 parent 63fd86a commit 48c70b1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
16 changes: 15 additions & 1 deletion src/Material.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
class PhongMaterial//: public Material
{
public:
PhongMaterial()
{
diffuse=math::zero;
specular=math::zero;
ambient=math::zero;
exponent=0.0f;
reflectiveRate=0.0f;
}

void setAmbient(Color* ambientp)
{
if (ambientp == NULL) {
Expand Down Expand Up @@ -55,11 +64,16 @@ class PhongMaterial//: public Material
} else {
diffuse = *diffusep;
}
}
}
void setReflectiveRate(float a_reflectiveRate)
{
reflectiveRate=a_reflectiveRate;
}
Color diffuse;
Color specular;
Color ambient;
float exponent;
float reflectiveRate;
private:
};
typedef PhongMaterial Material;
Expand Down
10 changes: 7 additions & 3 deletions src/gramma/SceneParser.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
%token OrthographicCamera center direction up PerspectiveCamera angle SimplePerspectiveCamera distance ViewPlane width height pixelsize Lights numLights ambientColor DirectionalLight position color power attenuation PointLight AreaLight Background

/*material*/
%token Materials numMaterials PhongMaterial diffuseColor specularColor exponent transparentColor reflextiveColor indexOfRefraction
%token Materials numMaterials PhongMaterial diffuseColor specularColor exponent transparentColor reflectiveColor indexOfRefraction reflectiveRate

/*transform*/

Expand All @@ -67,7 +67,7 @@
%type <vec3f> vec3f viewPlane optionAttenuation optionAmbientColor optionSpecularColor
%type <ival> materialIndex
%type <yTransformation> transformation
%type <fval> Float optionExponent
%type <fval> Float optionExponent optionReflectiveRate

%printer { debug_stream () << *$$; } <sval> <vval>
%destructor { delete $$; } <sval> <vval>
Expand Down Expand Up @@ -186,15 +186,19 @@ optionSpecularColor: specularColor vec3f {$$=$2;}
| /*empty*/{$$=NULL;};
optionExponent: exponent Float {$$=$2;}
| /*empty*/{$$=0.0f;};
optionReflectiveRate: reflectiveRate Float {$$=$2;}
| /*empty*/{$$=0.0f;};


phongMaterial: PhongMaterial '{' diffuseColor vec3f optionAmbientColor optionSpecularColor optionExponent
phongMaterial: PhongMaterial '{' diffuseColor vec3f optionAmbientColor optionSpecularColor optionExponent optionReflectiveRate
'}'
{
$$=new PhongMaterial();
$$->setDiffuse($4);
$$->setAmbient($5);
$$->setSpecular($6);
$$->setExponent($7);
$$->setReflectiveRate($8);
delete $4;
delete $5;
delete $6;
Expand Down
3 changes: 2 additions & 1 deletion src/gramma/SceneScanner.lpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ numMaterials return token::numMaterials;
PhongMaterial return token::PhongMaterial;
exponent return token::exponent;
transparentColor return token::transparentColor;
reflextiveColor return token::reflextiveColor;
reflectiveColor return token::reflectiveColor;
reflectiveRate return token::reflectiveRate;
indexOfRefraction return token::indexOfRefraction;

Group return token::Group;
Expand Down

0 comments on commit 48c70b1

Please sign in to comment.