////////////////////////////////////////////////////////////////////////////////
// ModelViewNormalTransformer.cpp
// Header for matrix operations
// Copyright Björn Ganster, written in 2020 (Corona year 1)
////////////////////////////////////////////////////////////////////////////////

#include "ModelViewNormalTransformer.h"

// Constructor
ModelViewNormalTransformer::ModelViewNormalTransformer()
: VirtualClass("ModelViewNormalTransformer", ModelViewNormalTransformerID)
{
}

// Destructor
ModelViewNormalTransformer::~ModelViewNormalTransformer()
{
}

// Scale transform
void ModelViewNormalTransformer::scale(double sx, double sy, double sz)
{
	mModelView = mModelView * ScaleMatrix(sx, sy, sz);
	mNormal = mNormal * ScaleMatrix(1.0 / sx, 1.0 / sy, 1.0 / sz);
}

void ModelViewNormalTransformer::translate(double tx, double ty, double tz)
{
	mModelView = mModelView * TranslationMatrix(tx, ty, tz);
	// mNormal is not affected by this transform
}

void ModelViewNormalTransformer::rotate(double angle, double ax, double ay, double az)
{
	RotationMatrix r(angle, ax, ay, az);
	mModelView = mModelView * r;
	mNormal = mNormal * r;
}
