
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
29 lines
1.1 KiB
C++
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);
|
|
} |