-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtil.cpp
More file actions
executable file
·35 lines (25 loc) · 789 Bytes
/
Util.cpp
File metadata and controls
executable file
·35 lines (25 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "Util.h"
#include <stdlib.h>
// -----------------------------------------------------------
int random_int(int min, int max) {
return rand() % (max - min) + min;
}
// -----------------------------------------------------------
float random_float(float min, float max) {
return(min + (float)rand() / ((float)RAND_MAX / ( max - min )));
}
// -----------------------------------------------------------
// reflection vector
// 2(NdotL)*N - L
Ogre::Vector3 vec3_reflect(const Ogre::Vector3 &v1, const Ogre::Vector3 &norm) {
return (v1.reflect(norm) );
/*
Ogre::Real dot = v1.dotProduct(norm);
if(dot < 0)
dot = 0.0f;
Ogre::Vector3 vReflect = (norm * 2.0f * dot);
vReflect -= v1;
vReflect.normalise();
return vReflect;
*/
}