Files
directx-plane-game/Graphics2/SharedMethods.cpp
iDunnoDev 616f68bf8b Added Comments
Added ability to hold shift and skip the terrain generation when loading
Added ability for the perlin terrain to save a raw image of the terrain to use as a cache
2022-06-13 16:41:25 +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);
}
// Function 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;
}
// Function 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;
}
// Function 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);
}