Skip to content

Commit

Permalink
Add in and migrate material forward ports
Browse files Browse the repository at this point in the history
Signed-off-by: methylDragon <[email protected]>
  • Loading branch information
methylDragon committed May 26, 2022
1 parent 7159850 commit 422058f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Material.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ Errors Material::Load(sdf::ElementPtr _sdf)
this->dataPtr->specular = _sdf->Get<gz::math::Color>("specular",
this->dataPtr->specular).first;

this->dataPtr->shininess = _sdf->Get<double>("shininess",
this->dataPtr->shininess).first;

this->dataPtr->emissive = _sdf->Get<gz::math::Color>("emissive",
this->dataPtr->emissive).first;

Expand Down Expand Up @@ -237,6 +240,18 @@ void Material::SetSpecular(const gz::math::Color &_color)
this->dataPtr->specular = _color;
}

//////////////////////////////////////////////////
double Material::Shininess() const
{
return this->dataPtr->shininess;
}

//////////////////////////////////////////////////
void Material::SetShininess(const double _shininess)
{
this->dataPtr->shininess = _shininess;
}

//////////////////////////////////////////////////
gz::math::Color Material::Emissive() const
{
Expand Down
13 changes: 13 additions & 0 deletions src/Material_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ TEST(DOMMaterial, Construction)
EXPECT_EQ(gz::math::Color(0, 0, 0, 1), material.Ambient());
EXPECT_EQ(gz::math::Color(0, 0, 0, 1), material.Diffuse());
EXPECT_EQ(gz::math::Color(0, 0, 0, 1), material.Specular());
EXPECT_DOUBLE_EQ(0.0, material.Shininess());
EXPECT_EQ(gz::math::Color(0, 0, 0, 1), material.Emissive());
EXPECT_TRUE(material.Lighting());
EXPECT_FLOAT_EQ(0, material.RenderOrder());
Expand All @@ -48,6 +49,7 @@ TEST(DOMMaterial, MoveConstructor)
material.SetAmbient(gz::math::Color(0.1f, 0.2f, 0.3f, 0.5f));
material.SetDiffuse(gz::math::Color(0.2f, 0.3f, 0.4f, 0.6f));
material.SetSpecular(gz::math::Color(0.3f, 0.4f, 0.5f, 0.7f));
material.SetShininess(5.0);
material.SetEmissive(gz::math::Color(0.4f, 0.5f, 0.6f, 0.8f));
material.SetLighting(false);
material.SetRenderOrder(2);
Expand All @@ -63,6 +65,7 @@ TEST(DOMMaterial, MoveConstructor)
EXPECT_EQ(gz::math::Color(0.2f, 0.3f, 0.4f, 0.6f), material2.Diffuse());
EXPECT_EQ(gz::math::Color(0.3f, 0.4f, 0.5f, 0.7f),
material2.Specular());
EXPECT_DOUBLE_EQ(5.0, material2.Shininess());
EXPECT_EQ(gz::math::Color(0.4f, 0.5f, 0.6f, 0.8f),
material2.Emissive());
EXPECT_FALSE(material2.Lighting());
Expand All @@ -83,6 +86,7 @@ TEST(DOMMaterial, CopyConstructor)
material.SetAmbient(gz::math::Color(0.1f, 0.2f, 0.3f, 0.5f));
material.SetDiffuse(gz::math::Color(0.2f, 0.3f, 0.4f, 0.6f));
material.SetSpecular(gz::math::Color(0.3f, 0.4f, 0.5f, 0.7f));
material.SetShininess(5.0);
material.SetEmissive(gz::math::Color(0.4f, 0.5f, 0.6f, 0.8f));
material.SetLighting(false);
material.SetRenderOrder(4);
Expand All @@ -98,6 +102,7 @@ TEST(DOMMaterial, CopyConstructor)
EXPECT_EQ(gz::math::Color(0.2f, 0.3f, 0.4f, 0.6f), material2.Diffuse());
EXPECT_EQ(gz::math::Color(0.3f, 0.4f, 0.5f, 0.7f),
material2.Specular());
EXPECT_DOUBLE_EQ(5.0, material2.Shininess());
EXPECT_EQ(gz::math::Color(0.4f, 0.5f, 0.6f, 0.8f),
material2.Emissive());
EXPECT_FALSE(material2.Lighting());
Expand All @@ -118,6 +123,7 @@ TEST(DOMMaterial, AssignmentOperator)
material.SetAmbient(gz::math::Color(0.1f, 0.2f, 0.3f, 0.5f));
material.SetDiffuse(gz::math::Color(0.2f, 0.3f, 0.4f, 0.6f));
material.SetSpecular(gz::math::Color(0.3f, 0.4f, 0.5f, 0.7f));
material.SetShininess(5.0);
material.SetEmissive(gz::math::Color(0.4f, 0.5f, 0.6f, 0.8f));
material.SetLighting(false);
material.SetRenderOrder(4);
Expand All @@ -134,6 +140,7 @@ TEST(DOMMaterial, AssignmentOperator)
EXPECT_EQ(gz::math::Color(0.2f, 0.3f, 0.4f, 0.6f), material2.Diffuse());
EXPECT_EQ(gz::math::Color(0.3f, 0.4f, 0.5f, 0.7f),
material2.Specular());
EXPECT_DOUBLE_EQ(5.0, material2.Shininess());
EXPECT_EQ(gz::math::Color(0.4f, 0.5f, 0.6f, 0.8f),
material2.Emissive());
EXPECT_FALSE(material2.Lighting());
Expand All @@ -154,6 +161,7 @@ TEST(DOMMaterial, MoveAssignmentOperator)
material.SetAmbient(gz::math::Color(0.1f, 0.2f, 0.3f, 0.5f));
material.SetDiffuse(gz::math::Color(0.2f, 0.3f, 0.4f, 0.6f));
material.SetSpecular(gz::math::Color(0.3f, 0.4f, 0.5f, 0.7f));
material.SetShininess(5.0);
material.SetEmissive(gz::math::Color(0.4f, 0.5f, 0.6f, 0.8f));
material.SetLighting(false);
material.SetRenderOrder(4);
Expand All @@ -169,6 +177,7 @@ TEST(DOMMaterial, MoveAssignmentOperator)
EXPECT_EQ(gz::math::Color(0.2f, 0.3f, 0.4f, 0.6f), material2.Diffuse());
EXPECT_EQ(gz::math::Color(0.3f, 0.4f, 0.5f, 0.7f),
material2.Specular());
EXPECT_DOUBLE_EQ(5.0, material2.Shininess());
EXPECT_EQ(gz::math::Color(0.4f, 0.5f, 0.6f, 0.8f),
material2.Emissive());
EXPECT_FALSE(material2.Lighting());
Expand Down Expand Up @@ -216,6 +225,10 @@ TEST(DOMMaterial, Set)
material.SetSpecular(gz::math::Color(0.3f, 0.4f, 0.5f, 0.7f));
EXPECT_EQ(gz::math::Color(0.3f, 0.4f, 0.5f, 0.7f), material.Specular());

EXPECT_DOUBLE_EQ(0.0, material.Shininess());
material.SetShininess(5.0);
EXPECT_DOUBLE_EQ(5.0, material.Shininess());

EXPECT_EQ(gz::math::Color(0, 0, 0, 1), material.Emissive());
material.SetEmissive(gz::math::Color(0.4f, 0.5f, 0.6f, 0.8f));
EXPECT_EQ(gz::math::Color(0.4f, 0.5f, 0.6f, 0.8f), material.Emissive());
Expand Down

0 comments on commit 422058f

Please sign in to comment.