00001
00002 #include <cfloat>
00003
00004 #include "defines.h"
00005 #include "TexCoordinate.h"
00006 #include "Vec3f.h"
00007 #include "RGBAColor.h"
00008
00009
00011 const float EPSILON = 1e-6f;
00012
00013 const int RESX = 800;
00014
00015 const int RESY = 600;
00016 const float MIN_INFLUENCE = 1.0f/256.0f;
00017 const int MAX_RECURSION_DEEP = 100;
00018 const unsigned int FRAMES = 24*6;
00019
00020
00021 const float BALL_RADIUS = 0.034f;
00022 const Vec3f WORLD_UP = Vec3f(0, 1, 0);
00023 const Vec3f WORLD_UP_MASK = Vec3f(1, 0, 1);
00024 const Vec3f TABLE_MIN = Vec3f(-0.701, 1.0, -1.452);
00025 const Vec3f TABLE_MAX = Vec3f( 0.679, 1.0 + 2*BALL_RADIUS, 1.438);
00026
00027
00028 const float PHYS_EPS = 0.00005;
00029 const float MUE_SLIDING = 0.3f;
00030 const float MUE_ROLLING = 0.01f;
00031 const float MUE_BALLS = 0.1f;
00032 const float COLLISION_LOSS = 0.99f;
00033 const float T_IMPULSE = 0.005;
00034 const float GRAVITY = 9.81f;
00035 const float CONTACT_RADIUS = 0.005f;
00036 const float BALL_MASS = 0.16f;
00037 const float SPREAD_POW = 0.6f;
00038 const float SPREAD_MAX_V = 2.0f;
00039 const float FRAME_LENGTH = 1.0f/24;
00040
00041
00046 float frand()
00047 {
00048
00049 return drand48();
00050
00051
00052 }
00053
00054
00062 float lerp(float a, float b, float f)
00063 {
00064 return a * (1-f) + b * f;
00065 }
00066
00067
00075 Vec3f lerp(const Vec3f & a, const Vec3f & b, float f)
00076 {
00077 return Vec3f(a.x() * (1-f) + b.x() * f,
00078 a.y() * (1-f) + b.y() * f,
00079 a.z() * (1-f) + b.z() * f);
00080 }
00081
00082
00090 RGBAColor lerp(const RGBAColor & a, const RGBAColor & b, float f)
00091 {
00092 return RGBAColor(a.r() * (1-f) + b.r() * f,
00093 a.g() * (1-f) + b.g() * f,
00094 a.b() * (1-f) + b.b() * f,
00095 a.a() * (1-f) + b.a() * f);
00096 }
00097
00098