Files
directx-plane-game/Graphics2/SharedMethods.cpp
iDunnoDev f6bba67897 Added follow cam
Added "Controlled" mesh classes
Added Global Lighting Class
Added Gamepad controls
Split terrain nodes into Height and Perlin classes
Fixed Splitmesh node stuff
2022-05-09 17:50:22 +01:00

29 lines
1.1 KiB
C++

#include "SharedMethods.h"
XMMATRIX SharedMethods::RotateFromPoint(const float x, const float y, const float z, const XMMATRIX rotationMatrix)
{
// Translates a matrix to a point, rotates and then returns back to where it was
return XMMatrixTranslation(x, y, z) * rotationMatrix * XMMatrixTranslation(-x, -y, -z);
}
// Method so i can use normal RGB values and hopefully hex values too since im use to those
float SharedMethods::RGBValueToIntensity(const int value)
{
return (float)value / 255.0f;
}
// Method to generate a random intensity rating between 2 floats
float SharedMethods::GenerateRandomIntensity(const float min, const float max)
{
float randNo = (float)rand() / (float)RAND_MAX;
float rangeDiff = max - min;
float actualNo = randNo * rangeDiff;
int roundedNo = (int)(actualNo * 100 + 0.5f);
return (float)roundedNo * 0.01f;
}
// Method for genering random UV's, maybe get rid of this in future
float SharedMethods::GenerateRandomUV(const float min, const float max)
{
return SharedMethods::Clamp<float>((float)(rand() % (int)(max * 100.0f)) * 0.01f, (float)min, (float)max);
}