Changeset 7e10667 in opengl-game for new-game.cpp
- Timestamp:
- May 3, 2019, 7:53:55 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- c55614a
- Parents:
- dc19a39
- git-author:
- Dmitry Portnoy <dmitry.portnoy@…> (05/03/19 19:53:42)
- git-committer:
- Dmitry Portnoy <dmitry.portnoy@…> (05/03/19 19:53:55)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
new-game.cpp
rdc19a39 r7e10667 32 32 #include <map> 33 33 34 #include "utils.h" 35 34 36 using namespace std; 35 37 using namespace glm; … … 75 77 unsigned int id; 76 78 ObjectType type; 79 bool deleted; 77 80 78 81 // Currently, model_transform should only have translate, and rotation and scale need to be done in model_base since … … 90 93 vector<GLfloat> texcoords; 91 94 vector<GLfloat> normals; 92 bool deleted;93 95 vec3 bounding_center; 94 96 GLfloat bounding_radius; … … 106 108 vector<GLfloat> particleVelocities; 107 109 vector<GLfloat> particleTimes; 110 GLfloat startTime; 111 GLfloat duration; 108 112 }; 109 113 … … 127 131 128 132 struct BufferInfo { 129 unsigned int vbo_base;130 133 unsigned int ubo_base; 131 134 unsigned int ubo_offset; … … 182 185 unsigned char* loadImage(string file_name, int* x, int* y); 183 186 184 void printVector(string label, vec3& v); 185 void print4DVector(string label, vec4& v); 187 void printVec3(string label, const vec3& v); 188 void printVec4(string label, const vec4& v); 189 void printMat4(string label, const mat4& m); 186 190 187 191 void initObject(SceneObject* obj); … … 228 232 Asteroid* createAsteroid(vec3 pos); 229 233 Laser* createLaser(vec3 start, vec3 end, vec3 color, GLfloat width); 230 ParticleEffect* createExplosion( );234 ParticleEffect* createExplosion(mat4 model_mat); 231 235 232 236 void translateLaser(Laser* laser, const vec3& translation, GLuint ubo); … … 237 241 void renderMainMenuGui(); 238 242 239 void renderScene(map<GLuint, BufferInfo>& shaderBufferInfo, 240 map<ObjectType, ShaderModelGroup>& modelGroups, GLuint ubo); 241 243 void renderScene(map<ObjectType, ShaderModelGroup>& modelGroups, GLuint ubo); 242 244 void renderSceneGui(map<string, vector<UIValue>> valueLists); 243 245 … … 287 289 Laser* rightLaser = NULL; 288 290 EffectOverTime* rightLaserEffect = NULL; 289 290 SceneObject* objExplosion;291 291 292 292 map<string, vector<UIValue>> valueLists; … … 488 488 489 489 defineModelGroupAttrib(modelGroups[TYPE_SHIP], "vertex_position", ATTRIB_POINT_VARYING, 490 3, GL_FLOAT, offset of(SceneObject,points));490 3, GL_FLOAT, offset_of(&SceneObject::points)); 491 491 defineModelGroupAttrib(modelGroups[TYPE_SHIP], "vertex_color", ATTRIB_POINT_VARYING, 492 3, GL_FLOAT, offset of(SceneObject,colors));492 3, GL_FLOAT, offset_of(&SceneObject::colors)); 493 493 defineModelGroupAttrib(modelGroups[TYPE_SHIP], "vertex_normal", ATTRIB_POINT_VARYING, 494 3, GL_FLOAT, offset of(SceneObject,normals));494 3, GL_FLOAT, offset_of(&SceneObject::normals)); 495 495 defineModelGroupAttrib(modelGroups[TYPE_SHIP], "ubo_index", ATTRIB_OBJECT_VARYING, 496 1, GL_UNSIGNED_INT, offset of(SceneObject,ubo_offset));496 1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset)); 497 497 498 498 defineModelGroupUniform(modelGroups[TYPE_SHIP], "view", ATTRIB_UNIFORM, … … 508 508 509 509 defineModelGroupAttrib(modelGroups[TYPE_ASTEROID], "vertex_position", ATTRIB_POINT_VARYING, 510 3, GL_FLOAT, offset of(SceneObject,points));510 3, GL_FLOAT, offset_of(&SceneObject::points)); 511 511 defineModelGroupAttrib(modelGroups[TYPE_ASTEROID], "vertex_color", ATTRIB_POINT_VARYING, 512 3, GL_FLOAT, offset of(SceneObject,colors));512 3, GL_FLOAT, offset_of(&SceneObject::colors)); 513 513 defineModelGroupAttrib(modelGroups[TYPE_ASTEROID], "vertex_normal", ATTRIB_POINT_VARYING, 514 3, GL_FLOAT, offset of(SceneObject,normals));514 3, GL_FLOAT, offset_of(&SceneObject::normals)); 515 515 defineModelGroupAttrib(modelGroups[TYPE_ASTEROID], "ubo_index", ATTRIB_OBJECT_VARYING, 516 1, GL_UNSIGNED_INT, offset of(SceneObject,ubo_offset));516 1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset)); 517 517 518 518 defineModelGroupUniform(modelGroups[TYPE_ASTEROID], "view", ATTRIB_UNIFORM, … … 528 528 529 529 defineModelGroupAttrib(modelGroups[TYPE_LASER], "vertex_position", ATTRIB_POINT_VARYING, 530 3, GL_FLOAT, offset of(SceneObject,points));530 3, GL_FLOAT, offset_of(&SceneObject::points)); 531 531 defineModelGroupAttrib(modelGroups[TYPE_LASER], "vt", ATTRIB_POINT_VARYING, 532 2, GL_FLOAT, offset of(SceneObject,texcoords));532 2, GL_FLOAT, offset_of(&SceneObject::texcoords)); 533 533 defineModelGroupAttrib(modelGroups[TYPE_LASER], "ubo_index", ATTRIB_OBJECT_VARYING, 534 1, GL_UNSIGNED_INT, offset of(SceneObject,ubo_offset));534 1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset)); 535 535 536 536 defineModelGroupUniform(modelGroups[TYPE_LASER], "view", ATTRIB_UNIFORM, … … 547 547 shaderBufferInfo[modelGroups[TYPE_EXPLOSION].shaderProgram] = BufferInfo(); // temporary 548 548 549 // The last parameter (offset) is only used for populating the buffers since the distance550 // between each item is needed there. However, the explosion vbos are populated using different551 // code anyway and don't use that argument, so I may as well pass in 0 here.552 549 defineModelGroupAttrib(modelGroups[TYPE_EXPLOSION], "v_i", ATTRIB_POINT_VARYING, 553 3, GL_FLOAT, 0);550 3, GL_FLOAT, offset_of(&ParticleEffect::particleVelocities)); 554 551 defineModelGroupAttrib(modelGroups[TYPE_EXPLOSION], "start_time", ATTRIB_POINT_VARYING, 555 1, GL_FLOAT, 0);552 1, GL_FLOAT, offset_of(&ParticleEffect::particleTimes)); 556 553 defineModelGroupAttrib(modelGroups[TYPE_EXPLOSION], "ubo_index", ATTRIB_OBJECT_VARYING, 557 1, GL_UNSIGNED_INT, offsetof(SceneObject, ubo_offset)); 558 559 defineModelGroupUniform(modelGroups[TYPE_EXPLOSION], "explosion_start_time", ATTRIB_UNIFORM, 560 1, UNIFORM_1F, &curTime); 554 1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset)); 555 561 556 defineModelGroupUniform(modelGroups[TYPE_EXPLOSION], "cur_time", ATTRIB_UNIFORM, 562 557 1, UNIFORM_1F, &curTime); … … 577 572 vector<SceneObject>::iterator obj_it; 578 573 579 populateBuffers(objects, 580 shaderBufferInfo, modelGroups, 581 ubo); 574 populateBuffers(objects, shaderBufferInfo, modelGroups, ubo); 582 575 583 576 float cam_speed = 1.0f; … … 613 606 proj_mat = make_mat4(proj_arr); 614 607 615 initializeParticleEffectBuffers(shaderBufferInfo, modelGroups, ubo);616 617 608 /* TODO: Fix the UBO binding code based on the following forum post (in order to support multiple ubos): 609 (Also, I bookmarked a great explanation of this under ) 618 610 619 611 No, you're misunderstanding how this works. UBO binding works exactly like texture object binding. … … 689 681 690 682 glUseProgram(modelGroups[TYPE_EXPLOSION].shaderProgram); 683 bindUniformData(modelGroups[TYPE_EXPLOSION].attribs["view"]); 684 bindUniformData(modelGroups[TYPE_EXPLOSION].attribs["proj"]); 685 691 686 glUniformBlockBinding(modelGroups[TYPE_EXPLOSION].shaderProgram, explosion_sp_models_ub_index, ub_binding_point); 692 687 glBindBufferRange(GL_UNIFORM_BUFFER, ub_binding_point, ubo, 0, GL_MAX_UNIFORM_BLOCK_SIZE); … … 843 838 // this code moves the asteroids 844 839 for (unsigned int i = 0; i < objects.size(); i++) { 845 if (objects[i]->type == TYPE_ASTEROID && !objects[i]->deleted) { 846 transformObject(*objects[i], translate(mat4(1.0f), vec3(0.0f, 0.0f, 0.04f)), ubo); 847 848 vec3 obj_center = vec3(view_mat * vec4(objects[i]->bounding_center, 1.0f)); 849 850 if ((obj_center.z - objects[i]->bounding_radius) > -NEAR_CLIP) { 851 removeObjectFromScene(*objects[i], ubo); 852 } 853 if (((Asteroid*)objects[i])->hp <= 0) { 854 // TODO: Optimize this so I don't recalculate the camera rotation every time 855 float cam_pitch = -50.0f * 2.0f * 3.14159f / 360.0f; 856 mat4 pitch_mat = rotate(mat4(1.0f), cam_pitch, vec3(1.0f, 0.0f, 0.0f)); 857 mat4 model_mat = translate(mat4(1.0f), objects[i]->bounding_center + vec3(0.0f, 0.0f, 0.0f)) * pitch_mat; 858 859 removeObjectFromScene(*objects[i], ubo); 860 score++; 861 862 objExplosion->model_mat = model_mat; 863 864 // initiate an explosion 865 glUseProgram(modelGroups[TYPE_EXPLOSION].shaderProgram); 866 867 bindUniformData(modelGroups[TYPE_EXPLOSION].attribs["explosion_start_time"]); 868 869 glBindBuffer(GL_UNIFORM_BUFFER, ubo); 870 glBufferSubData(GL_UNIFORM_BUFFER, objExplosion->ubo_offset * sizeof(mat4), sizeof(mat4), value_ptr(objExplosion->model_mat)); 840 if (!objects[i]->deleted) { 841 if (objects[i]->type == TYPE_ASTEROID) { 842 transformObject(*objects[i], translate(mat4(1.0f), vec3(0.0f, 0.0f, 0.04f)), ubo); 843 844 vec3 obj_center = vec3(view_mat * vec4(objects[i]->bounding_center, 1.0f)); 845 846 if ((obj_center.z - objects[i]->bounding_radius) > -NEAR_CLIP) { 847 removeObjectFromScene(*objects[i], ubo); 848 } 849 if (((Asteroid*)objects[i])->hp <= 0) { 850 // TODO: Optimize this so I don't recalculate the camera rotation every time 851 float cam_pitch = -50.0f * 2.0f * 3.14159f / 360.0f; 852 mat4 pitch_mat = rotate(mat4(1.0f), cam_pitch, vec3(1.0f, 0.0f, 0.0f)); 853 mat4 model_mat = translate(mat4(1.0f), objects[i]->bounding_center) * pitch_mat; 854 855 removeObjectFromScene(*objects[i], ubo); 856 score++; 857 858 addObjectToScene(createExplosion(model_mat), shaderBufferInfo, modelGroups, ubo); 859 } 860 } else if (objects[i]->type == TYPE_EXPLOSION) { 861 ParticleEffect* explosion = (ParticleEffect*)objects[i]; 862 if (glfwGetTime() >= explosion->startTime + explosion->duration) { 863 removeObjectFromScene(*objects[i], ubo); 864 } 871 865 } 872 866 } … … 971 965 break; 972 966 case STATE_GAME: 973 renderScene( shaderBufferInfo,modelGroups, ubo);967 renderScene(modelGroups, ubo); 974 968 renderSceneGui(valueLists); 975 969 break; … … 1277 1271 } 1278 1272 1279 void printVec tor(string label,vec3& v) {1273 void printVec3(string label, const vec3& v) { 1280 1274 cout << label << " -> (" << v.x << "," << v.y << "," << v.z << ")" << endl; 1281 1275 } 1282 1276 1283 void print 4DVector(string label,vec4& v) {1277 void printVec4(string label, const vec4& v) { 1284 1278 cout << label << " -> (" << v.x << "," << v.y << "," << v.z << "," << v.w << ")" << endl; 1285 1279 } 1286 1280 1281 void printMat4(string label, const mat4& m) { 1282 cout << label << ": " << endl; 1283 cout << "[ " << m[0][0] << " " << m[1][0] << " " << m[2][0] << " " << m[3][0] << " ]" << endl; 1284 cout << "[ " << m[0][1] << " " << m[1][1] << " " << m[2][1] << " " << m[3][1] << " ]" << endl; 1285 cout << "[ " << m[0][2] << " " << m[1][2] << " " << m[2][2] << " " << m[3][2] << " ]" << endl; 1286 cout << "[ " << m[0][3] << " " << m[1][3] << " " << m[2][3] << " " << m[3][3] << " ]" << endl; 1287 } 1288 1289 // TODO: Pass a reference, not a pointer 1287 1290 void initObject(SceneObject* obj) { 1288 // Each objects must have at least 3 points, so the size of1289 // the points array must be a positive multiple of 91290 if (obj->points.size() == 0 || (obj->points.size() % 9) != 0) {1291 // TODO: Maybe throw some kind of error here instead1292 return;1293 }1294 1295 1291 obj->id = objects.size(); // currently unused 1296 1292 obj->num_points = obj->points.size() / 3; … … 1321 1317 } 1322 1318 1319 // TODO: Check if I can pass in a reference to obj instead (do this for all other functions as well) 1323 1320 void addObjectToScene(SceneObject* obj, 1324 1321 map<GLuint, BufferInfo>& shaderBufferInfo, … … 1331 1328 // Check if the buffers aren't large enough to fit the new object and, if so, call 1332 1329 // populateBuffers() to resize and repopupulate them 1333 if ( modelGroups[obj->type].vboCapacity < (modelGroups[obj->type].numPoints + obj->num_points) ||1334 bufferInfo->ubo_capacity < (bufferInfo->ubo_offset + 1)) {1330 if ((modelGroups[obj->type].vboCapacity < (modelGroups[obj->type].numPoints + obj->num_points) || 1331 bufferInfo->ubo_capacity <= bufferInfo->ubo_offset)) { 1335 1332 1336 1333 if (leftLaser != NULL && leftLaser->deleted) { … … 1356 1353 } 1357 1354 1355 // TODO: Pass a reference, not a pointer 1358 1356 void calculateObjectBoundingBox(SceneObject* obj) { 1359 1357 GLfloat min_x = obj->points[0]; … … 2025 2023 } 2026 2024 2027 void initializeParticleEffectBuffers(map<GLuint, BufferInfo>& shaderBufferInfo,2028 map<ObjectType, ShaderModelGroup>& modelGroups,2029 GLuint ubo) {2030 float vv[EXPLOSION_PARTICLE_COUNT * 3]; // initial velocities vec32031 float vt[EXPLOSION_PARTICLE_COUNT]; // initial times2032 float t_accum = 0.0f; // start time2033 2034 for (int i = 0; i < EXPLOSION_PARTICLE_COUNT; i++) {2035 vt[i] = t_accum;2036 t_accum += 0.01f;2037 2038 float randx = ((float)rand() / (float)RAND_MAX) - 0.5f;2039 float randy = ((float)rand() / (float)RAND_MAX) - 0.5f;2040 vv[i*3] = randx;2041 vv[i*3 + 1] = randy;2042 vv[i*3 + 2] = 0.0f;2043 }2044 2045 glUseProgram(modelGroups[TYPE_EXPLOSION].shaderProgram);2046 2047 bindUniformData(modelGroups[TYPE_EXPLOSION].attribs["proj"]);2048 bindUniformData(modelGroups[TYPE_EXPLOSION].attribs["view"]);2049 2050 // the glBufferData calls need to stay here while the corresponding arrays2051 // are local to this function. Once they're made part of the explosion object, I might be able2052 // to move this code out of here2053 2054 glBindBuffer(GL_ARRAY_BUFFER, modelGroups[TYPE_EXPLOSION].attribs["v_i"].buffer);2055 glBufferData(GL_ARRAY_BUFFER, sizeof(vv), vv, GL_STATIC_DRAW);2056 2057 glBindBuffer(GL_ARRAY_BUFFER, modelGroups[TYPE_EXPLOSION].attribs["start_time"].buffer);2058 glBufferData(GL_ARRAY_BUFFER, sizeof(vt), vt, GL_STATIC_DRAW);2059 2060 // TODO: createExplosion should take the velocities and times as arguments and copy them to the explosion object2061 // That way, this function could maybe be called every time a new explosion is created2062 objExplosion = createExplosion();2063 addObjectToScene(objExplosion, shaderBufferInfo, modelGroups, ubo);2064 }2065 2066 2025 void populateBuffers(vector<SceneObject*>& objects, 2067 2026 map<GLuint, BufferInfo>& shaderBufferInfo, … … 2122 2081 // When populating the buffers, leave as much empty space as space taken up by existing objects 2123 2082 // to allow new objects to be added without immediately having to resize the buffers 2124 shaderBufferInfo[shaderCountIt->first].vbo_base = lastShaderCount * 2;2125 2083 shaderBufferInfo[shaderCountIt->first].ubo_base = lastShaderUboCount * 2; 2126 2084 … … 2188 2146 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2189 2147 } else if (modelGroupIt->first == TYPE_EXPLOSION) { 2148 attrib = &smg->attribs["v_i"]; 2149 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2150 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2151 2152 attrib = &smg->attribs["start_time"]; 2153 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2154 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2155 2190 2156 attrib = &smg->attribs["ubo_index"]; 2191 2157 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2192 2158 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2193 2159 } 2194 2195 // TODO: I could move the glBufferData calls for explosions here and call glBufferSubData in copyObjectDataToBuffers2196 // To make this work, I would need to store the explosion points and times in the explosion object so I could then copy2197 // them to the buffers.2198 // Also, confirm that rendering multiple exxplosions would be feasible. They might need different curTimes2199 // Also, store the explosion model mat(s) in the global ubo, just like all other objects2200 // This should just require setting their ubo_offset correctly2201 // (This already seems to be happening. I think I just need to add a ubo index buffer to explosions)2202 2160 } 2203 2161 … … 2226 2184 glBindBuffer(GL_ARRAY_BUFFER, it->second.buffer); 2227 2185 2228 if (obj.type != TYPE_EXPLOSION || it->first == "ubo_index") { 2229 switch (it->second.attribType) { 2230 case ATTRIB_POINT_VARYING: 2231 glBufferSubData(GL_ARRAY_BUFFER, obj.vertex_vbo_offset * GLsizeof(it->second.type) * it->second.size, 2232 obj.num_points * GLsizeof(it->second.type) * it->second.size, getVectorAttribPtr(obj, it->second.fieldOffset)); 2233 break; 2234 case ATTRIB_OBJECT_VARYING: 2235 for (unsigned int i = 0; i < obj.num_points; i++) { 2236 glBufferSubData(GL_ARRAY_BUFFER, (obj.vertex_vbo_offset + i) * GLsizeof(it->second.type) * it->second.size, 2237 GLsizeof(it->second.type) * it->second.size, getScalarAttribPtr(obj, it->second.fieldOffset)); 2238 } 2239 break; 2240 case ATTRIB_UNIFORM: 2241 break; 2242 } 2243 } 2244 } 2245 2246 if (obj.type != TYPE_EXPLOSION) { 2247 obj.model_mat = obj.model_transform * obj.model_base; 2248 } 2186 switch (it->second.attribType) { 2187 case ATTRIB_POINT_VARYING: 2188 glBufferSubData(GL_ARRAY_BUFFER, obj.vertex_vbo_offset * GLsizeof(it->second.type) * it->second.size, 2189 obj.num_points * GLsizeof(it->second.type) * it->second.size, getVectorAttribPtr(obj, it->second.fieldOffset)); 2190 break; 2191 case ATTRIB_OBJECT_VARYING: 2192 for (unsigned int i = 0; i < obj.num_points; i++) { 2193 glBufferSubData(GL_ARRAY_BUFFER, (obj.vertex_vbo_offset + i) * GLsizeof(it->second.type) * it->second.size, 2194 GLsizeof(it->second.type) * it->second.size, getScalarAttribPtr(obj, it->second.fieldOffset)); 2195 } 2196 break; 2197 case ATTRIB_UNIFORM: 2198 break; 2199 } 2200 } 2201 2202 obj.model_mat = obj.model_transform * obj.model_base; 2249 2203 2250 2204 glBindBuffer(GL_UNIFORM_BUFFER, ubo); … … 2256 2210 ostringstream oss; 2257 2211 oss << "hp[" << obj.ubo_offset << "]"; 2258 glUniform1f(glGetUniformLocation(modelGroups[TYPE_ASTEROID].shaderProgram, oss.str().c_str()), ((Asteroid*)&obj)->hp); 2212 glUniform1f(glGetUniformLocation(modelGroups[TYPE_ASTEROID].shaderProgram, oss.str().c_str()), ((Asteroid&)obj).hp); 2213 } else if (obj.type == TYPE_EXPLOSION) { 2214 glUseProgram(modelGroups[TYPE_EXPLOSION].shaderProgram); 2215 2216 ostringstream oss; 2217 oss << "explosion_start_time[" << obj.ubo_offset << "]"; 2218 glUniform1f(glGetUniformLocation(modelGroups[TYPE_EXPLOSION].shaderProgram, oss.str().c_str()), ((ParticleEffect&)obj).startTime); 2259 2219 } 2260 2220 … … 2425 2385 } 2426 2386 2427 void renderScene(map<GLuint, BufferInfo>& shaderBufferInfo, 2428 map<ObjectType, ShaderModelGroup>& modelGroups, GLuint ubo) { 2387 void renderScene(map<ObjectType, ShaderModelGroup>& modelGroups, GLuint ubo) { 2429 2388 2430 2389 glUseProgram(modelGroups[TYPE_SHIP].shaderProgram); … … 2722 2681 } 2723 2682 2724 ParticleEffect* createExplosion() { 2683 // TODO: Maybe pass in startTime instead of calling glfwGetTime() here 2684 ParticleEffect* createExplosion(mat4 model_mat) { 2725 2685 ParticleEffect* obj = new ParticleEffect(); 2686 2726 2687 obj->type = TYPE_EXPLOSION; 2727 2688 2728 obj->points = {};2729 obj->colors = {};2730 2731 2689 initObject(obj); 2690 2732 2691 obj->num_points = EXPLOSION_PARTICLE_COUNT; 2692 obj->model_base = model_mat; 2693 obj->startTime = glfwGetTime(); 2694 obj->duration = 0.5f; // This is also hard-coded in the shader. TODO; Pass this to the shader in an indexable ubo. 2695 2696 obj->particleVelocities.clear(); 2697 obj->particleTimes.clear(); 2698 float t_accum = 0.0f; // start time 2699 2700 for (int i = 0; i < EXPLOSION_PARTICLE_COUNT; i++) { 2701 obj->particleTimes.push_back(t_accum); 2702 t_accum += 0.01f; 2703 2704 float randx = ((float)rand() / (float)RAND_MAX) - 0.5f; 2705 float randy = ((float)rand() / (float)RAND_MAX) - 0.5f; 2706 obj->particleVelocities.push_back(randx); 2707 obj->particleVelocities.push_back(randy); 2708 obj->particleVelocities.push_back(0.0f); 2709 } 2733 2710 2734 2711 return obj;
Note:
See TracChangeset
for help on using the changeset viewer.