Example #1
0
TEST(Transformable_objects, can_be_scaled)
{
	Transformable t;

	EXPECT_EQ(vec3(1,1,1), t.scaling());
	t.scaleTo(vec3(2,3,4));
	EXPECT_EQ(vec3(2,3,4), t.scaling());
	t.scaleTo(-2,-5,-9);
	EXPECT_EQ(vec3(-2,-5,-9), t.scaling());
	t.scaleTo(2,3,4);
	t.scale(4,2,3);
	EXPECT_EQ(vec3(8,6,12), t.scaling());
	t.scale(vec3(1.0f/4.0f, 1.0f/2.0f, 1.0f/3.0f));
	EXPECT_EQ(vec3(2,3,4), t.scaling());
}
Example #2
0
TEST(Transformable_objects, have_a_scaling_matrix_to_move_from_model_space_to_world_space)
{
	Transformable model;
	vec3 pInModelSpace(1,1,1), pInWorldSpace(1,2,3);
	vec3 qInModelSpace(0,0,0), qInWorldSpace(0,0,0);
	vec3 rInModelSpace(2,2,2), rInWorldSpace(2,4,6);

	model.scaleTo(1,2,3);

	EXPECT_EQ(pInWorldSpace, (model.scalingMatrix() * vec4(pInModelSpace,1)).xyz());
	EXPECT_EQ(qInWorldSpace, (model.scalingMatrix() * vec4(qInModelSpace,1)).xyz());
	EXPECT_EQ(rInWorldSpace, (model.scalingMatrix() * vec4(rInModelSpace,1)).xyz());
}