
Added terrainBuffer struct Added shared methods to genereate random UV's and intensities Added water to the terrain Added random UV's to the shader Removed the vector3d class since DX can deal with that stuff...
49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
#include "SharedMethods.h"
|
|
|
|
XMMATRIX SharedMethods::RotateFromPoint(float x, float y, float z, 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(int value)
|
|
{
|
|
return (float)value / 255.0f;
|
|
}
|
|
|
|
float SharedMethods::Lerp(int a, int b, int p)
|
|
{
|
|
return Lerp((float)a, (float)b, (float)p);
|
|
}
|
|
|
|
float SharedMethods::Lerp(float a, float b, float p)
|
|
{
|
|
return a + p * (b - a);
|
|
}
|
|
|
|
float SharedMethods::GenerateRandomIntensity(float min, 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;
|
|
}
|
|
|
|
float SharedMethods::GenerateRandomUV(int min, int max)
|
|
{
|
|
int randNo = rand() % ((max - min) + 1) + min;
|
|
float finalNo;
|
|
if (randNo < max)
|
|
{
|
|
int randMan = rand() % 90;
|
|
finalNo = (float)(randNo * 0.1f) + (randMan * 0.01f);
|
|
}
|
|
else
|
|
{
|
|
finalNo = (float)randNo * 0.1f;
|
|
}
|
|
|
|
return finalNo;
|
|
} |