00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00021
00022
00023 #ifndef H_SPK_DEF
00024 #define H_SPK_DEF
00025
00026
00027 #include <cstdlib>
00028 #include <cmath>
00029 #include <algorithm>
00030 #include <deque>
00031 #include <list>
00032 #include <iostream>
00033 #include <vector>
00034 #include <limits>
00035 #include <map>
00036 #include <set>
00037 #include <string>
00038 #include <cstring>
00039
00040
00041 #ifdef SPK_DLL
00042 #define SPK_CORE_IMPORT
00043 #endif
00044
00045 #ifdef SPK_CORE_EXPORT
00046 #define SPK_PREFIX __declspec(dllexport)
00047 #elif defined(SPK_IMPORT) || defined(SPK_CORE_IMPORT)
00048 #define SPK_PREFIX __declspec(dllimport)
00049 #else
00050 #define SPK_PREFIX
00051 #endif
00052
00053 #ifdef _MSC_VER
00054 #pragma warning(disable : 4251) // disables the warning about exporting STL classes in DLLs
00055 #endif
00056
00057
00058
00059
00060 #ifdef SPK_DEBUG
00061 #define SPK_TRACE(text) std::cout << text << std::endl;
00062 #else
00063 #define SPK_TRACE(text)
00064 #endif
00065
00099 namespace SPK
00100 {
00102 extern SPK_PREFIX unsigned int randomSeed;
00103
00114 template<typename T>
00115 T random(T min,T max)
00116 {
00117
00118 long tmp0 = 16807L * (randomSeed & 0xFFFFL);
00119 long tmp1 = 16807L * (randomSeed >> 16);
00120 long tmp2 = (tmp0 >> 16) + tmp1;
00121 tmp0 = ((tmp0 & 0xFFFF)|((tmp2 & 0x7FFF) << 16)) + (tmp2 >> 15);
00122
00123
00124 if ((tmp0 & 0x80000000L) != 0)
00125 tmp0 = (tmp0 + 1) & 0x7FFFFFFFL;
00126
00127 randomSeed = tmp0;
00128
00129
00130 return static_cast<T>(min + ((randomSeed - 1) / 2147483646.0) * (max - min));
00131 }
00132
00134
00136
00141 enum ModelParam
00142 {
00143 PARAM_RED = 0,
00144 PARAM_GREEN = 1,
00145 PARAM_BLUE = 2,
00146 PARAM_ALPHA = 3,
00147 PARAM_SIZE = 4,
00148 PARAM_MASS = 5,
00149 PARAM_ANGLE = 6,
00150 PARAM_TEXTURE_INDEX = 7,
00151 PARAM_ROTATION_SPEED = 8,
00152 PARAM_CUSTOM_0 = 9,
00153 PARAM_CUSTOM_1 = 10,
00154 PARAM_CUSTOM_2 = 11,
00155 };
00156 }
00157
00158 #endif