static void redraw_handler(struct widget *widget, void *data) { struct smoke *smoke = data; uint32_t time = smoke->time; struct wl_callback *callback; cairo_surface_t *surface; diffuse(smoke, time / 30, smoke->b[0].u, smoke->b[1].u); diffuse(smoke, time / 30, smoke->b[0].v, smoke->b[1].v); project(smoke, time / 30, smoke->b[1].u, smoke->b[1].v, smoke->b[0].u, smoke->b[0].v); advect(smoke, time / 30, smoke->b[1].u, smoke->b[1].v, smoke->b[1].u, smoke->b[0].u); advect(smoke, time / 30, smoke->b[1].u, smoke->b[1].v, smoke->b[1].v, smoke->b[0].v); project(smoke, time / 30, smoke->b[0].u, smoke->b[0].v, smoke->b[1].u, smoke->b[1].v); diffuse(smoke, time / 30, smoke->b[0].d, smoke->b[1].d); advect(smoke, time / 30, smoke->b[0].u, smoke->b[0].v, smoke->b[1].d, smoke->b[0].d); surface = window_get_surface(smoke->window); render(smoke, surface); window_damage(smoke->window, 0, 0, smoke->width, smoke->height); cairo_surface_destroy(surface); callback = wl_surface_frame(window_get_wl_surface(smoke->window)); wl_callback_add_listener(callback, &listener, smoke); wl_surface_commit(window_get_wl_surface(smoke->window)); }
vector3f get_diffuse(double *dif, primitive *pri, ray &r, kdtree &kdtree, int depth, double &spc_alpha) { vector3f diffuse(0.0, 0.0, 0.0); if (pri->get_material().is_transparent()) { vector3f surface_normal = pri->get_normal(r.origin); double cos_value = surface_normal * r.direction; double sin_value = sqrt(1 - cos_value * cos_value); ray fraction_ray(r.origin + 5 * eps2 * r.direction, r.direction); double cos_value_pow = (1 - abs(cos_value)) * (1 - abs(cos_value)); double normal_t = (cos_value > 0) ? (1.0 / n_t) : n_t; double r0 = (normal_t - 1) / (normal_t + 1); r0 = r0 * r0; spc_alpha = r0 + (1 - r0) * cos_value_pow; // entering slow material if (cos_value < 0) { if (abs(sin_value) > eps) { vector3f base = (r.direction + (surface_normal * abs(cos_value))).normal(); double sin_frac = sin_value / n_t; double cos_frac = sqrt(1 - sin_frac * sin_frac); fraction_ray.direction = ((sin_frac * base) - (cos_frac * surface_normal)).normal(); } diffuse = dif[3] * map_mul(vector3f(dif), get_light_distribution(pri, r, kdtree)) + (1 - dif[3]) * get_ray_trace(fraction_ray, kdtree, depth + 1); } // exit slow material else { if (abs(sin_value) > eps) { vector3f base = (r.direction - (surface_normal * abs(cos_value))).normal(); double sin_frac = sin_value * n_t; if (sin_frac > 1.0) { //total reflection spc_alpha += diffuse[3]; return diffuse; } double cos_frac = sqrt(1 - sin_frac * sin_frac); fraction_ray.direction = ((sin_frac * base) + (cos_frac * surface_normal)).normal(); } diffuse = dif[3] * map_mul(vector3f(dif), get_light_distribution(pri, r, kdtree)) + (1 - dif[3]) * get_ray_trace(fraction_ray, kdtree, depth + 1); } } else { diffuse = map_mul(vector3f(dif), get_light_distribution(pri, r, kdtree)); } return diffuse; }
//=========================================================================== void cDirectionalLight::renderLightSource(cRenderOptions& a_options) { // check if light sources should be rendered if ((!a_options.m_enable_lighting) || (!m_enabled)) { // disable OpenGL light source glDisable(m_glLightNumber); return; } // compute global position of current light in world computeGlobalPositionsFromRoot(); // enable this light in OpenGL glEnable(m_glLightNumber); // enable or disable two side light model glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, m_useTwoSideLightModel); // set lighting components if (a_options.m_rendering_shadow) { cColorf diffuse((GLfloat)(a_options.m_shadow_light_level * m_diffuse.getR()), (GLfloat)(a_options.m_shadow_light_level * m_diffuse.getG()), (GLfloat)(a_options.m_shadow_light_level * m_diffuse.getB())); cColorf specular(0.0, 0.0, 0.0); glLightfv(m_glLightNumber, GL_AMBIENT, m_ambient.pColor()); glLightfv(m_glLightNumber, GL_DIFFUSE, diffuse.pColor() ); glLightfv(m_glLightNumber, GL_SPECULAR, specular.pColor()); } else { glLightfv(m_glLightNumber, GL_AMBIENT, m_ambient.pColor()); glLightfv(m_glLightNumber, GL_DIFFUSE, m_diffuse.pColor() ); glLightfv(m_glLightNumber, GL_SPECULAR, m_specular.pColor()); } // disable cutoff angle glLightf(m_glLightNumber, GL_SPOT_CUTOFF, 180); // define the direction of the light beam. this is a little counter intuitive, // but the direction is actually specified with the GL_POSITION command. // OpenGL recognizes the light being a directional light source by detecting that // value position[3] is equal to zero cVector3d dir = getDir(); float position[4]; position[0] = (float)-dir(0) ; position[1] = (float)-dir(1) ; position[2] = (float)-dir(2) ; position[3] = 0.0f; // defines light to be of type directional glLightfv(m_glLightNumber, GL_POSITION, (const float *)&position); }
PetscErrorCode IFunction(TS ts,PetscReal t,Vec X,Vec Xdot,Vec F,void *ctx) { PetscErrorCode ierr; AppCtx *user=(AppCtx*)ctx; DM cda; DMDACoor2d **coors; PetscScalar **p,**f,**pdot; PetscInt i,j; PetscInt xs,ys,xm,ym,M,N; Vec localX,gc,localXdot; PetscScalar p_adv1,p_adv2,p_diff; PetscFunctionBeginUser; ierr = DMDAGetInfo(user->da,NULL,&M,&N,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); ierr = DMGetCoordinateDM(user->da,&cda);CHKERRQ(ierr); ierr = DMDAGetCorners(cda,&xs,&ys,0,&xm,&ym,0);CHKERRQ(ierr); ierr = DMGetLocalVector(user->da,&localX);CHKERRQ(ierr); ierr = DMGetLocalVector(user->da,&localXdot);CHKERRQ(ierr); ierr = DMGlobalToLocalBegin(user->da,X,INSERT_VALUES,localX);CHKERRQ(ierr); ierr = DMGlobalToLocalEnd(user->da,X,INSERT_VALUES,localX);CHKERRQ(ierr); ierr = DMGlobalToLocalBegin(user->da,Xdot,INSERT_VALUES,localXdot);CHKERRQ(ierr); ierr = DMGlobalToLocalEnd(user->da,Xdot,INSERT_VALUES,localXdot);CHKERRQ(ierr); ierr = DMGetCoordinatesLocal(user->da,&gc);CHKERRQ(ierr); ierr = DMDAVecGetArray(cda,gc,&coors);CHKERRQ(ierr); ierr = DMDAVecGetArray(user->da,localX,&p);CHKERRQ(ierr); ierr = DMDAVecGetArray(user->da,localXdot,&pdot);CHKERRQ(ierr); ierr = DMDAVecGetArray(user->da,F,&f);CHKERRQ(ierr); user->disper_coe = PetscPowScalar((user->lambda*user->ws)/(2*user->H),2)*user->q*(1.0-PetscExpScalar(-t/user->lambda)); for (i=xs; i < xs+xm; i++) { for (j=ys; j < ys+ym; j++) { ierr = adv1(p,coors[j][i].y,i,j,M,&p_adv1,user);CHKERRQ(ierr); ierr = adv2(p,coors[j][i].x,i,j,N,&p_adv2,user);CHKERRQ(ierr); ierr = diffuse(p,i,j,t,&p_diff,user);CHKERRQ(ierr); f[j][i] = -p_adv1 - p_adv2 + p_diff - pdot[j][i]; } } ierr = DMDAVecRestoreArray(user->da,localX,&p);CHKERRQ(ierr); ierr = DMDAVecRestoreArray(user->da,localX,&pdot);CHKERRQ(ierr); ierr = DMRestoreLocalVector(user->da,&localX);CHKERRQ(ierr); ierr = DMRestoreLocalVector(user->da,&localXdot);CHKERRQ(ierr); ierr = DMDAVecRestoreArray(user->da,F,&f);CHKERRQ(ierr); ierr = DMDAVecRestoreArray(cda,gc,&coors);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*************************************************************** * Solves the navier stokes equations for density.. * i.e. satisfies: ∂d/∂t = -(div u)d + k Lap d + S ***************************************************************/ void FGS_Fluid_Solver2DS :: density_step(){ // Add density sources from the old grid (+S) add_source(DENSITY, OLD_DENSITY); // Compute diffusion of cells' densities into neighbours // If diffusion > 0 then densities will diffuse (+ k Lap d) diffuse (SET_FOR_NON_VELOCITY_COMPONENT, OLD_DENSITY, DENSITY, diffusion); // Advect the densities based on the velocities in the cell (-(div u)d) computing_density = true; advect (SET_FOR_NON_VELOCITY_COMPONENT, DENSITY, OLD_DENSITY, UX, UY); computing_density = false; }
void HeaterMOO::animationStep ( bool& isNeedUpdateView ) { for ( int i = 0; i < _blindItr; i++ ) { diffuse ( _imgA, _imgB ); erase ( _imgHeater, _imgB ); double** tmp = _imgA; // swapping _imgA = _imgB; _imgB = tmp; } fillImage ( _imgA ); isNeedUpdateView = true; // A devient B, B devient A // tester a chaque fois isNeedUpdateView pour faire en sorte qu'il update une fois sur blindItr! }
void ciMsaFluidSolver::update() { addSourceUV(); if( doVorticityConfinement ) { vorticityConfinement(uvOld); addSourceUV(); } swapUV(); diffuseUV( viscocity ); project(uv, uvOld); swapUV(); advect2d(uv, uvOld); project(uv, uvOld); if(doRGB) { addSourceRGB(); swapRGB(); if( colorDiffusion!=0. && _dt!=0. ) { diffuseRGB(0, colorDiffusion ); swapRGB(); } advectRGB(0, uv); fadeRGB(); } else { addSource(r, rOld); swapR(); if( colorDiffusion!=0. && _dt!=0. ) { diffuse(0, r, rOld, colorDiffusion ); swapRGB(); } advect(0, r, rOld, uv); fadeR(); } }
int main (int argc, char** argv) { long order = 20; //default if (argc > 1) { order = atoi(argv[1]); } std::cout << "defining random graph with 2^" << order << " vertices." << std::endl; set_up_graph(1<<order); float stepsize; do { std::cout << float(clock())/CLOCKS_PER_SEC << "\tdiffusing, "; stepsize = diffuse (); std::cout << "stepsize = " << stepsize << std::endl; } while (stepsize > 1e-6); }
void Fluid::vel_step(float dt) { add_source(su, u, dt); add_source(sv, v, dt); add_source(sw, w, dt); add_buoyancy(dt); vorticity_confinement(dt); #ifdef DIFFUSE SWAPFPTR(u0, u); SWAPFPTR(v0, v); SWAPFPTR(w0, w); diffuse(1, u0, u, viscosity, dt); diffuse(2, v0, v, viscosity, dt); diffuse(3, w0, w, viscosity, dt); project(); #endif #ifdef ADVECT SWAPFPTR(u0, u); SWAPFPTR(v0, v); SWAPFPTR(w0, w); advect(1, u0, u, u0, v0, w0, dt); advect(2, v0, v, u0, v0, w0, dt); advect(3, w0, w, u0, v0, w0, dt); project(); #endif }
static void redraw_handler(struct widget *widget, void *data) { struct smoke *smoke = data; uint32_t time = widget_get_last_time(smoke->widget); cairo_surface_t *surface; diffuse(smoke, time / 30, smoke->b[0].u, smoke->b[1].u); diffuse(smoke, time / 30, smoke->b[0].v, smoke->b[1].v); project(smoke, time / 30, smoke->b[1].u, smoke->b[1].v, smoke->b[0].u, smoke->b[0].v); advect(smoke, time / 30, smoke->b[1].u, smoke->b[1].v, smoke->b[1].u, smoke->b[0].u); advect(smoke, time / 30, smoke->b[1].u, smoke->b[1].v, smoke->b[1].v, smoke->b[0].v); project(smoke, time / 30, smoke->b[0].u, smoke->b[0].v, smoke->b[1].u, smoke->b[1].v); diffuse(smoke, time / 30, smoke->b[0].d, smoke->b[1].d); advect(smoke, time / 30, smoke->b[0].u, smoke->b[0].v, smoke->b[1].d, smoke->b[0].d); surface = window_get_surface(smoke->window); render(smoke, surface); window_damage(smoke->window, 0, 0, smoke->width, smoke->height); cairo_surface_destroy(surface); widget_schedule_redraw(smoke->widget); }
void FluidSolver::update() { addSource(uv, uvOld); if( doVorticityConfinement ) { vorticityConfinement(uvOld); addSource(uv, uvOld); } SWAP(uv, uvOld); diffuseUV( viscocity ); project(uv, uvOld); SWAP(uv, uvOld); advect2d(uv, uvOld); project(uv, uvOld); if(doRGB) { addSource(color, colorOld); SWAP(color, colorOld); if( colorDiffusion!=0. && deltaT!=0. ) { diffuseRGB(0, colorDiffusion ); SWAP(color, colorOld); } advectRGB(0, uv); fadeRGB(); } else { addSource(density, densityOld); SWAP(density, densityOld); if( colorDiffusion!=0. && deltaT!=0. ) { diffuse(0, density, densityOld, colorDiffusion ); SWAP(density, densityOld); } advect(0, density, densityOld, uv); fadeDensity(); } }
void Fluid::update() { //fprintf(stderr, "\n--- Diffuse 1 ---\n"); /*diffuse ( 1, vx0, vx, viscosity ); //fprintf(stderr, "\n--- Diffuse 2 ---\n"); diffuse ( 2, vy0, vy, viscosity ); //fprintf(stderr, "\n--- Project 1 ---\n"); project ( vx0, vy0, vx, vy ); //fprintf(stderr, "\n--- Advect 1 ---\n"); advect ( 1, vx, vx0, vx0, vy0 ); //fprintf(stderr, "\n--- Advect 2 ---\n"); advect ( 2, vy, vy0, vx0, vy0 ); //fprintf(stderr, "\n--- Project 2 ---\n"); project ( vx, vy, vx0, vy0 ); //fprintf(stderr, "\n--- Diffuse 1 ---\n"); diffuse ( 0, s, dens, diffusion ); advect ( 0, dens, s, vx, vy );*/ std::thread d1(&Fluid::diffuse, this, 1, vx0, vx, viscosity); std::thread d2(&Fluid::diffuse, this, 2, vy0, vy, viscosity); std::thread d3(&Fluid::diffuse, this, 3, vz0, vz, viscosity); //diffuse(1, vx0, vx, viscosity); //diffuse(2, vy0, vy, viscosity); //diffuse(3, vz0, vz, viscosity); d1.join(); d2.join(); d3.join(); project3D (vx0, vy0, vz0, vx, vy); std::thread a1(&Fluid::advect3D, this, 1, vx, vx0, vx0, vy0, vz0); std::thread a2(&Fluid::advect3D, this, 2, vy, vy0, vx0, vy0, vz0); std::thread a3(&Fluid::advect3D, this, 3, vz, vz0, vx0, vy0, vz0); a1.join(); a2.join(); a3.join(); /*advect3D(1, vx, vx0, vx0, vy0, vz0); advect3D(2, vy, vy0, vx0, vy0, vz0); advect3D(3, vz, vz0, vx0, vy0, vz0);*/ project3D(vx, vy, vz, vx0, vy0); diffuse(0, s, dens, diffusion); advect3D(0, dens, s, vx, vy, vz); }
void RenderingEngine::Render(const vector<Visual>& visuals) const { glClearColor(0.5f, 0.5f, 0.5f, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); vector<Visual>::const_iterator visual = visuals.begin(); for (int visualIndex = 0; visual != visuals.end(); ++visual, ++visualIndex) { // 뷰포트 변환을 설정한다. ivec2 size = visual->ViewportSize; ivec2 lowerLeft = visual->LowerLeft; glViewport(lowerLeft.x, lowerLeft.y, size.x, size.y); // 조명 위치를 설정한다. glMatrixMode(GL_MODELVIEW); glLoadIdentity(); vec4 lightPosition(0.25, 0.25, 1, 0); glLightfv(GL_LIGHT0, GL_POSITION, lightPosition.Pointer()); // 모델-뷰 변환을 설정한다. mat4 rotation = visual->Orientation.ToMatrix(); mat4 modelview = rotation * m_traslation; glLoadMatrixf(modelview.Pointer()); // 투상 행렬을 설정한다. float h = 4.0f * size.y / size.x; mat4 projection = mat4::Frustum(-2, 2, -h/2, h/2, 5, 10); glMatrixMode(GL_PROJECTION); glLoadMatrixf(projection.Pointer()); // 확산 색상을 설정한다. vec3 color = visual->Color * 0.75f; vec4 diffuse(color.x, color.y, color.z, 1); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse.Pointer()); // 표면을 그린다. int stride = 2 * sizeof(vec3); const Drawable& drawalbe = m_drawables[visualIndex]; glBindBuffer(GL_ARRAY_BUFFER, drawable.VertexBuffer); glVertexPointer(3, GL_FLOAT, stride, 0); const GLvoid* normalOffset = (const GLvoid*) sizeof(vec3); glNormalPointer(GL_FLOAT, stride, normalOffset); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, drawable.IndexBuffer); glDrawElements(GL_LINES, drawable.IndexCount, GL_UNSIGNED_SHORT, 0); } }
void SetOpenGlDefaultMaterial() { glm::vec4 ambient( 0.2, 0.2, 0.2, 1.0 ); glm::vec4 specular( 0.0, 0.0, 0.0, 1.0 ); glm::vec4 emissive( 0.0, 0.0, 0.0, 1.0 ); glm::vec4 diffuse( 0.0, 0.0, 0.0, 1.0 ); GLint shininess_value = 0; glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); glMateriali ( GL_FRONT_AND_BACK, GL_SHININESS, shininess_value ); glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.x ); glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.x ); glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.x ); glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.x ); }
// -- Steps ------------------------------------------------------------------- void dens_step ( int step , int method , int iters, int N , float* x, float* x0 , float* u, float* v , float diff, float dt) { add_source (N, x, x0, dt ); SWAP (x0, x); diffuse (method, iters, N, 0, x, x0, diff, dt); SWAP (x0, x); advect (N, 0, x, x0, u, v, dt); }
void CGUITextureBase::Render(float left, float top, float right, float bottom, float u1, float v1, float u2, float v2, float u3, float v3) { CRect diffuse(u1, v1, u2, v2); CRect texture(u1, v1, u2, v2); CRect vertex(left, top, right, bottom); g_graphicsContext.ClipRect(vertex, texture, m_diffuse.size() ? &diffuse : NULL); if (vertex.IsEmpty()) return; // nothing to render int orientation = GetOrientation(); OrientateTexture(texture, u3, v3, orientation); if (m_diffuse.size()) { // flip the texture as necessary. Diffuse just gets flipped according to m_info.orientation. // Main texture gets flipped according to GetOrientation(). diffuse.x1 *= m_diffuseScaleU / u3; diffuse.x2 *= m_diffuseScaleU / u3; diffuse.y1 *= m_diffuseScaleV / v3; diffuse.y2 *= m_diffuseScaleV / v3; diffuse += m_diffuseOffset; OrientateTexture(diffuse, m_diffuseU, m_diffuseV, m_info.orientation); } float x[4], y[4], z[4]; #define ROUND_TO_PIXEL(x) (float)(MathUtils::round_int(x)) x[0] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalXCoord(vertex.x1, vertex.y1)); y[0] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalYCoord(vertex.x1, vertex.y1)); z[0] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalZCoord(vertex.x1, vertex.y1)); x[1] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalXCoord(vertex.x2, vertex.y1)); y[1] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalYCoord(vertex.x2, vertex.y1)); z[1] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalZCoord(vertex.x2, vertex.y1)); x[2] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalXCoord(vertex.x2, vertex.y2)); y[2] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalYCoord(vertex.x2, vertex.y2)); z[2] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalZCoord(vertex.x2, vertex.y2)); x[3] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalXCoord(vertex.x1, vertex.y2)); y[3] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalYCoord(vertex.x1, vertex.y2)); z[3] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalZCoord(vertex.x1, vertex.y2)); if (y[2] == y[0]) y[2] += 1.0f; if (x[2] == x[0]) x[2] += 1.0f; if (y[3] == y[1]) y[3] += 1.0f; if (x[3] == x[1]) x[3] += 1.0f; Draw(x, y, z, texture, diffuse, orientation); }
VType *CopyMesh(INDICES &indices, LptaSkin::ID &skinId, const aiScene *scene, MANAGERS &managers) { VType *vertices = new VType(); vector<LptaSkin::ID> skinIds; for (unsigned int matIdx = 0; matIdx < scene->mNumMaterials; ++matIdx) { aiMaterial *mat = scene->mMaterials[matIdx]; aiColor4D diffuse(0.0f, 0.0f, 0.0f, 0.0f); aiColor4D ambient(0.0f, 0.0f, 0.0f, 0.0f); aiColor4D specular(0.0f, 0.0f, 0.0f, 0.0f); aiColor4D emissive(0.0f, 0.0f, 0.0f, 0.0f); float specularPower = 0.0f; mat->Get(AI_MATKEY_COLOR_DIFFUSE, diffuse); mat->Get(AI_MATKEY_COLOR_AMBIENT, ambient); mat->Get(AI_MATKEY_COLOR_SPECULAR, specular); mat->Get(AI_MATKEY_COLOR_EMISSIVE, emissive); mat->Get(AI_MATKEY_SHININESS, specularPower); aiGetMaterialColor(mat, AI_MATKEY_COLOR_EMISSIVE, &emissive); LptaMaterial::ID materialId = managers.material.AddOrRetrieveMaterial( LptaColor(diffuse.r, diffuse.g, diffuse.b, diffuse.a), LptaColor(ambient.r, ambient.g, ambient.b, diffuse.a), LptaColor(specular.r, specular.g, specular.b, specular.a), LptaColor(emissive.r, emissive.g, emissive.b, emissive.a), specularPower ); LptaSkin::TEXTURE_IDS textureIds; // only diffuse texture is supported for now for (unsigned int texIdx = 0; texIdx < mat->GetTextureCount(aiTextureType_DIFFUSE) && texIdx < LptaSkin::MAX_TEXTURES; ++texIdx) { aiString filepath; mat->GetTexture(aiTextureType_DIFFUSE, texIdx, &filepath); LptaTexture::ID textureId = managers.texture.AddOrRetrieveTexture(filepath.C_Str()); textureIds.push_back(textureId); } LptaSkin::ID skinId = managers.skin.AddSkin(materialId, textureIds, false); skinIds.push_back(skinId); } for (unsigned int meshIdx = 0; meshIdx < scene->mNumMeshes; ++meshIdx) { const aiMesh *mesh = scene->mMeshes[meshIdx]; CopyAlgorithm::Copy(*vertices, indices, *mesh, vertices->GetNumVertices()); skinId = skinIds.at(mesh->mMaterialIndex); } return vertices; }
/*! SLLightRect::drawRec sets the light states and calls then the SLNode::drawRec method of its node. */ void SLLightRect::drawRec(SLSceneView* sv) { if (_id!=-1) { // Set the OpenGL light states setState(); _stateGL->numLightsUsed = (SLint)SLScene::current->lights().size(); // Set emissive light material to the lights diffuse color if (_meshes.size() > 0) if (_meshes[0]->mat) _meshes[0]->mat->emission(_on ? diffuse() : SLCol4f::BLACK); // now draw the inherited object SLNode::drawRec(sv); } }
/*! SLLightRect::init sets the light id, the light states & creates an emissive mat. @todo properly remove this function and find a clean way to init lights in a scene */ void SLLightRect::init() { // Check if OpenGL lights are available if (SLScene::current->lights().size() >= SL_MAX_LIGHTS) SL_EXIT_MSG("Max. NO. of lights is exceeded!"); // Add the light to the lights array of the scene if (_id==-1) { _id = (SLint)SLScene::current->lights().size(); SLScene::current->lights().push_back(this); } // Set the OpenGL light states setState(); _stateGL->numLightsUsed = (SLint)SLScene::current->lights().size(); // Set emissive light material to the lights diffuse color if (_meshes.size() > 0) if (_meshes[0]->mat) _meshes[0]->mat->emission(_on ? diffuse() : SLCol4f::BLACK); }
void SurfacePropertiesCS::parsePhong( TiXmlElement* techniqueRoot ) { // create a material float power = 2; if ( techniqueRoot->FirstChildElement( "shininess" ) ) { const char* valStr = techniqueRoot->FirstChildElement( "shininess" )->FirstChildElement( "float" )->GetText(); sscanf_s( valStr, "%f", &power ); } Color ambient( 0.7f, 0.7f, 0.7f, 1 ); if ( techniqueRoot->FirstChildElement( "ambient" ) ) { const char* valStr = techniqueRoot->FirstChildElement( "ambient" )->FirstChildElement( "color" )->GetText(); sscanf_s( valStr, "%f %f %f %f", &ambient.r, &ambient.g, &ambient.b, &ambient.a ); } Color diffuse( 0.7f, 0.7f, 0.7f, 1 ); if ( techniqueRoot->FirstChildElement( "diffuse" ) ) { const char* valStr = techniqueRoot->FirstChildElement( "diffuse" )->FirstChildElement( "color" )->GetText(); sscanf_s( valStr, "%f %f %f %f", &diffuse.r, &diffuse.g, &diffuse.b, &diffuse.a ); } Color specular( 0.9f, 0.9f, 0.9f, 1 ); if ( techniqueRoot->FirstChildElement( "specular" ) ) { const char* valStr = techniqueRoot->FirstChildElement( "specular" )->FirstChildElement( "color" )->GetText(); sscanf_s( valStr, "%f %f %f %f", &specular.r, &specular.g, &specular.b, &specular.a ); } Color emissive( 0, 0, 0 ); if ( techniqueRoot->FirstChildElement( "emission" ) ) { const char* valStr = techniqueRoot->FirstChildElement( "emission" )->FirstChildElement( "color" )->GetText(); sscanf_s( valStr, "%f %f %f %f", &emissive.r, &emissive.g, &emissive.b, &emissive.a ); } m_surfaceProperties = new SurfaceProperties( ambient, diffuse, specular, emissive, power ); }
int AF_merge(char *src, char *dst, size_t blocksize, unsigned int blocknumbers, const char *hash) { unsigned int i; char *bufblock; int r = -EINVAL; if((bufblock = calloc(blocksize, 1)) == NULL) return -ENOMEM; memset(bufblock,0,blocksize); for(i=0; i<blocknumbers-1; i++) { XORblock(src+(blocksize*i),bufblock,bufblock,blocksize); if(diffuse(bufblock, bufblock, blocksize, hash)) goto out; } XORblock(src + blocksize * i, bufblock, dst, blocksize); r = 0; out: free(bufblock); return r; }
void Scene::_parsePhongMaterial(uint id){ float vec[4]; _checkToken( "PhongMaterial"); _nextToken( ); _checkToken( "{"); _nextToken( ); _checkToken("ambientColor"); for( int i = 0; i < 4; i++ ){ _nextToken( ); vec[i] = _parseFloat( ); } RGBAColor ambient(vec); _nextToken( ); _checkToken( "diffuseColor"); for( int i = 0; i < 4; i++ ){ _nextToken( ); vec[i] = _parseFloat( ); } RGBAColor diffuse(vec); _nextToken( ); _checkToken("specularColor"); for( int i = 0; i < 4; i++ ){ _nextToken( ); vec[i] = _parseFloat( ); } RGBAColor specular(vec); _nextToken( ); _checkToken("shininess"); float shininess = _parseFloat( ); _nextToken( ); float indexOfRefraction = 10; if( std::strcmp(_currentToken, "indexOfRefraction") == 0 ){ indexOfRefraction = _parseFloat( ); } _nextToken( ); _checkToken( "}"); // Fill me in! }
vector<vector<double > > spectralDecomposition(CSCMat mat, int nev, double diffuse_t) { /* Compute Eigenvectors and Eigenvalues of lower Laplacian matrix */ int n = mat.pCol.size() -1; // dimension (number of rows or cols od similiar matrix) int nconv; // number of "converged" eigenvalues. int nnz = mat.val.size(); double* eigVal = new double[n]; // Eigenvalues. double* eigVec = new double[n*nev]; // Eigenvectors stored sequentially. char uplo = 'L'; #ifdef DEBUG printf("Spectral decomposition started \n"); unsigned int start_time = time(NULL); #endif nconv = AREig(eigVal, eigVec, n, nnz, &mat.val[0], &mat.iRow[0], &mat.pCol[0], uplo, nev, "SM", 0, 0.0, 1000000); #ifdef DEBUG unsigned int end_time = time(NULL); printf("Spectral decomposition finished in %u s\n", end_time-start_time); #endif Solution(nconv, n, nnz, &mat.val[0], &mat.iRow[0], &mat.pCol[0], uplo, eigVal, eigVec); vector<vector<double > > dataPoints = getDataPoints(eigVec,nev,n); // unnormalized data point for clustering eigenvectors in columns //vector<vector<double > > dataPointsTrans = getDataPointsTrans(eigVec,nev,n); diffuse(dataPoints, eigVal, diffuse_t); //print2DVecArray(dataPoints); //vecSave2DArray("eigvec.txt", dataPoints); vecNormalize(dataPoints); //vecSave2DArray("eigvecnorm.txt", dataPoints); return dataPoints; }
MainWindow::MainWindow() : QMainWindow(), m_ParticleFilter(250, &m_ObservationModel, &m_MovementModel), m_RunFilter(true) { setupUi(this); this->grabKeyboard(); m_frontDown = m_backDown = m_rightDown = m_leftDown = 0; m_RenderWidget->setParticleFilter(&m_ParticleFilter); connect(m_ParticleWeightPlotCheckBox, SIGNAL(stateChanged(int)), this, SLOT(changeDisplaySettings())); connect(m_LoopModeRadioButton, SIGNAL(toggled(bool)), this, SLOT(changeRunMode())); connect(m_ResampleButton, SIGNAL(clicked()), this, SLOT(resample())); connect(m_DriftButton, SIGNAL(clicked()), this, SLOT(drift())); connect(m_DiffuseButton, SIGNAL(clicked()), this, SLOT(diffuse())); connect(m_MeasureButton, SIGNAL(clicked()), this, SLOT(measure())); connect(m_RedrawParticlesButton, SIGNAL(clicked()), this, SLOT(redrawParticles())); connect(m_ResamplingModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setResamplingMode())); // read standard values into spin boxes m_XSpinBox->setValue(m_MovementModel.getXStdDev()); m_YSpinBox->setValue(m_MovementModel.getYStdDev()); m_ThetaSpinBox->setValue(m_MovementModel.getThetaStdDev() / M_PI * 180.0); m_SpeedSpinBox->setValue(m_MovementModel.getSpeedStdDev()); m_RotationSpeedSpinBox->setValue(m_MovementModel.getRotationSpeedStdDev() / M_PI * 180.0); // connect spin boxes connect(m_XSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setMovementModelParameters())); connect(m_YSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setMovementModelParameters())); connect(m_ThetaSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setMovementModelParameters())); connect(m_SpeedSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setMovementModelParameters())); connect(m_RotationSpeedSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setMovementModelParameters())); QTimer::singleShot(50, this, SLOT(initStates())); // start the loop QTimer::singleShot(100, this, SLOT(gameLoop())); }
void HeaterMOO::initImages () { int h = getH (); int w = getW (); alloc ( _imgHeater, w, h ); alloc ( _imgInit, w, h ); alloc ( _imgA, w, h ); alloc ( _imgB, w, h ); init ( _imgHeater, w, h, .0 ); init ( _imgInit, w, h, .0 ); init ( _imgA, w, h, .0 ); init ( _imgB, w, h, .0 ); //_imgHeater[w / 2][h / 2] = 1.0; // TODO: Faire une initialisation du heater propre! for ( int i = ( w / 2 ) - GRID_HEATER; i < ( w / 2 ) + GRID_HEATER; i += SPACE_HEATER ) { for ( int j = ( w / 2 ) - GRID_HEATER; j < ( w / 2 ) + GRID_HEATER; j += SPACE_HEATER ) { _imgHeater[i][j] = 1.0; } } erase ( _imgHeater, _imgInit ); diffuse ( _imgInit, _imgA ); erase ( _imgHeater, _imgA ); fillImage ( _imgA ); }
void FluidSystem::stepVelocity(Scalar dt, const VelocityField &addedVelocity) { velocity += addedVelocity * dt; std::array<BoundarySetter, velocity.coords> boundarySetters; if (horizontalNeumann) { boundarySetters[0] = std::bind(&setHorizontalNeumannBoundaries, std::placeholders::_1, dim); } else { boundarySetters[0] = std::bind(&setContinuityBoundaries, std::placeholders::_1, dim); } if (verticalNeumann) { boundarySetters[1] = std::bind(&setVerticalNeumannBoundaries, std::placeholders::_1, dim); } else { boundarySetters[1] = std::bind(&setContinuityBoundaries, std::placeholders::_1, dim); } boundarySetters[2] = std::bind(&setDepthNeumannBoundaries, std::placeholders::_1, dim); std::swap(velocity, velocityPrev); diffuse(velocity, velocityPrev, viscosity, dt, staggeredDim, boundarySetters); project(velocity); std::swap(velocity, velocityPrev); advect(velocity, velocityPrev, velocityPrev, dt, staggeredDim, boundarySetters); project(velocity); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->tab_2->setEnabled(false); ui->pushButton_3->setEnabled(false); ui->btnSmooth->setEnabled(false); ui->menuExperimenta->setEnabled(false); ui->actionSave_Laplace_Matrix->setEnabled(false); connect(ui->glWidget, SIGNAL(faceCount(int)), ui->faceCount, SLOT(display(int))); connect(ui->glWidget, SIGNAL(vertexCount(int)), ui->vertexCount, SLOT(display(int))); connect(ui->radioButton, SIGNAL(toggled(bool)), ui->glWidget, SLOT(Light0State(bool))); connect(ui->radioButton_2, SIGNAL(toggled(bool)), ui->glWidget, SLOT(Light1State(bool))); connect(ui->radioButton_3, SIGNAL(toggled(bool)), ui->glWidget, SLOT(Light2State(bool))); connect(ui->glWidget,SIGNAL(SendVector(VectorXd)), &plotWin, SLOT(getVector(VectorXd))); connect(&posLight, SIGNAL(posX(int)), ui->glWidget, SLOT(LightPosX(int))); connect(&posLight, SIGNAL(posY(int)), ui->glWidget, SLOT(LightPosY(int))); connect(&posLight, SIGNAL(posZ(int)), ui->glWidget, SLOT(LightPosZ(int))); connect(&matWin, SIGNAL(amb(QColor)), ui->glWidget, SLOT(glAmb(QColor))); connect(&matWin, SIGNAL(diffuse(QColor)), ui->glWidget, SLOT(glDiffuse(QColor))); connect(&matWin, SIGNAL(spec(QColor)), ui->glWidget, SLOT(glSpec(QColor))); connect(&posLight, SIGNAL(sendLightColor(QColor)), ui->glWidget, SLOT(LightColor(QColor))); connect(&selectLaplacian, SIGNAL(selectKind(int)), ui->glWidget, SLOT(SelectLaplace(int))); connect(this, SIGNAL(sendEigenIndex(int)), ui->glWidget, SLOT(SeekEigen(int))); connect(this, SIGNAL(sendCompressionVolume(int)), ui->glWidget, SLOT(AdjustCompression(int))); connect(this, SIGNAL(analyseCurve()), ui->glWidget, SLOT(AnalyseCurve())); connect(ui->glWidget, SIGNAL(Status(QString)), this, SLOT(setStatus(QString))); connect(this, SIGNAL(shadingMode(int)), ui->glWidget, SLOT(selectShade(int))); }
void drawMesh(const Gm::TriangleMesh& mesh, bool wireframe = false) { Gs::Vector4 diffuse(1.0f, 1.0f, 1.0f, 1.0f); Gs::Vector4 ambient(0.4f, 0.4f, 0.4f, 1.0f); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse.Ptr()); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient.Ptr()); glEnable(GL_LIGHTING); glPolygonMode(GL_FRONT_AND_BACK, wireframe ? GL_LINE : GL_FILL); if (texturedMode) texture->bind(); glBegin(GL_TRIANGLES); for (std::size_t i = 0; i < mesh.triangles.size(); ++i) { const auto& tri = mesh.triangles[i]; const auto& v0 = mesh.vertices[tri.a]; const auto& v1 = mesh.vertices[tri.b]; const auto& v2 = mesh.vertices[tri.c]; emitVertex(v0); emitVertex(v1); emitVertex(v2); } glEnd(); if (texturedMode) texture->unbind(); glDisable(GL_LIGHTING); }
void Grid::iterate( float time ) { new_grid = new Particle*[size]; for( int i = 0; i < size; ++i ) { new_grid[i] = new Particle[size]; } for( int i = 0; i < size; ++i ) { for( int k = 0; k < size; ++k ) { Particle *p = &particle_grid[i][k]; //if( p->x_velocity != 0 || p->y_velocity != 0 ) { float move_x = (p->x_velocity * time); float move_y = (p->y_velocity * time); double temp_x; double temp_y; double new_x = i + move_x; double new_y = k + move_y; int x; int y; float x_ratio[2]; float y_ratio[2]; x_ratio[1] = modf( new_x, &temp_x ); x = (int) temp_x; x_ratio[0] = 1 - x_ratio[1]; y_ratio[1] = modf( new_y, &temp_y ); y = (int) temp_y; y_ratio[0] = 1 - y_ratio[1]; /* *-----------* | | | | | | | | | |-------X---| | | | *-----------* */ float ratios[2][2]; ratios[0][0] = x_ratio[0] * y_ratio[0]; // maybe use heirustics for this instead ratios[0][1] = x_ratio[0] * y_ratio[1]; ratios[1][0] = x_ratio[1] * y_ratio[0]; ratios[1][1] = x_ratio[1] * y_ratio[1]; if( x < (size-1) && y < (size-1) && x > 0 && y > 0 ) { new_grid[x][y].x_velocity += p->x_velocity * ratios[0][0]; new_grid[x][y].y_velocity += p->y_velocity * ratios[0][0]; new_grid[x][y].density += p->density * ratios[0][0]; #ifdef COLOR new_grid[x][y].R += p->R * ratios[0][0]; new_grid[x][y].G += p->G * ratios[0][0]; new_grid[x][y].B += p->B * ratios[0][0]; #endif //if( (x+1) < size ) { new_grid[x+1][y].x_velocity += p->x_velocity * ratios[1][0]; new_grid[x+1][y].y_velocity += p->y_velocity * ratios[1][0]; new_grid[x+1][y].density += p->density * ratios[1][0]; #ifdef COLOR new_grid[x+1][y].R += p->R * ratios[1][0]; new_grid[x+1][y].G += p->G * ratios[1][0]; new_grid[x+1][y].B += p->B * ratios[1][0]; #endif //if( (y+1) < size ) { new_grid[x][y+1].x_velocity += p->x_velocity * ratios[0][1]; // duplicated below new_grid[x][y+1].y_velocity += p->y_velocity * ratios[0][1]; new_grid[x][y+1].density += p->density * ratios[0][1]; #ifdef COLOR new_grid[x][y+1].R += p->R * ratios[0][1]; new_grid[x][y+1].G += p->G * ratios[0][1]; new_grid[x][y+1].B += p->B * ratios[0][1]; #endif new_grid[x+1][y+1].x_velocity += p->x_velocity * ratios[1][1]; new_grid[x+1][y+1].y_velocity += p->y_velocity * ratios[1][1]; new_grid[x+1][y+1].density += p->density * ratios[1][1]; #ifdef COLOR new_grid[x+1][y+1].R += p->R * ratios[1][1]; new_grid[x+1][y+1].G += p->G * ratios[1][1]; new_grid[x+1][y+1].B += p->B * ratios[1][1]; #endif //} /*} else { if( (y+1) < size ) { new_grid[x][y+1].x_velocity += p->x_velocity * ratios[0][1]; // duplicated above new_grid[x][y+1].y_velocity += p->y_velocity * ratios[0][1]; new_grid[x][y+1].density += p->density * ratios[0][1]; new_grid[x][y+1].R += p->R * ratios[0][1]; new_grid[x][y+1].G += p->G * ratios[0][1]; new_grid[x][y+1].B += p->B * ratios[0][1]; } }*/ } //} else { // This particle did not move // new_grid[i][k].x_velocity = 0; // new_grid[i][k].y_velocity = 0; // new_grid[i][k].density += p->density; #ifdef COLOR new_grid[i][k].R += p->R; new_grid[i][k].G += p->G; new_grid[i][k].B += p->B; #endif //} } } refresh_borders(); diffuse(); for( int i = 0; i < size; ++i ) { delete[] particle_grid[i]; } delete[] particle_grid; particle_grid = new_grid; }
void RenderSystem::update(double time, SystemMessageSender* msgSender) { std::vector<c_handle<NewRenderComponent>> renderComps = GameObjectFactory::getComponentHandlesOfType<NewRenderComponent>(); std::vector<c_handle<CameraComponent>> cameraHandles = GameObjectFactory::getComponentHandlesOfType<CameraComponent>(); c_handle<CameraComponent> cameraHandle; if (cameraHandles.size() > 0) { cameraHandle = cameraHandles[0]; } _ASSERT(cameraHandle); float shininess = 50; float attenuation = 0.00009f; glm::vec4 ambient(0.15f, 0.15f, 0.15f, 1.0f); glm::vec4 diffuse(0.9f, 0.9f, 0.9f, 1.0f); glm::mat4 projMat = cameraHandle->projectionMatrix; glm::mat4 viewMat = cameraHandle->getViewMatrix(cameraHandle); skyBox.draw(viewMat, projMat); glm::vec4 lightPosV = viewMat * glm::vec4(-60.0f, 8.0f, -20.0f, 1.0f); //shadowFBO.renderShadowPass(compHandles, lightPosV.xyz); //intt totalRenders = GameStateMachine::getCaptureFrames()? 2: 1; int totalRenders = 1; for (int count = 0; count < totalRenders; count++) { // TODO: set viewport on canvas if (count == 1) { glViewport(0,0, frameFBO.resWidth, frameFBO.resHeight); glBindFramebuffer(GL_FRAMEBUFFER, frameFBO.fbo); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //skyBox.draw(viewMat, projMat); } else { glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(0, 0, GLsizei(cameraHandle->width), GLsizei(cameraHandle->height)); } static int debug = 0; if (debug++ < 60) { logGLError("Draw:"); } //glEnable (GL_BLEND); for (c_handle<NewRenderComponent> &renderH : renderComps) { c_handle<GameEntity> parentP = renderH->getParentEntity(); if (renderH && renderH->getParentEntity()){ c_handle<TransformComponent> transformHandle = GameObjectFactory::getComponentBrother<TransformComponent>(renderH); c_handle<ShaderComponent> shaderH = GameObjectFactory::getComponentBrother<ShaderComponent>(renderH); c_handle<NewTextureComponent> texHandle = GameObjectFactory::getComponentBrother<NewTextureComponent>(renderH); if(transformHandle && shaderH) { TransformComponent& transform = transformHandle.get(); std::vector<UniformBind> uniforms; uniforms.push_back(UniformsFuncs::createUniform<float>( UniformsFuncs::set1f, "shininess", shininess)); uniforms.push_back(UniformsFuncs::createUniform<float, float, float, float>( UniformsFuncs::set4f, "specularColor", 1.0f, 1.0f, 1.0f, 1.0f)); uniforms.push_back(UniformsFuncs::createUniform<int, const float*>( UniformsFuncs::set3fv, "lightpos", 1, &lightPosV[0])); //TODO: check why not &lightPosV[0] uniforms.push_back(UniformsFuncs::createUniform<int, bool, const float*>( UniformsFuncs::setMat4fv, "viewMatrix", 1, false, &viewMat[0][0])); uniforms.push_back(UniformsFuncs::createUniform<int, bool, const float*>( UniformsFuncs::setMat4fv, "projectionMatrix", 1, false, &cameraHandle->projectionMatrix[0][0])); glm::vec3 offset=glm::vec3(); glm::vec3 offsetRot=glm::vec3(); float signo = 1.0f; c_handle<OffsetComponent> offsetH = GameObjectFactory::getComponentBrother<OffsetComponent>(renderH); if(offsetH) { offset = offsetH->offsetMov; offsetRot = offsetH->offsetRot; glm::mat4 identity; } glm::vec3 orient = signo * (glm::eulerAngles(transform.orientation) + offsetRot.xyz); glm::quat quaternion = glm::quat(orient); glm::mat4 rotationTranslate = glm::translate(offset); glm::mat4 rotation = glm::mat4_cast(quaternion); glm::mat4 mat = glm::translate(transform.position) * rotation * rotationTranslate * glm::scale(transform.scale); uniforms.push_back(UniformsFuncs::createUniform<int, bool, const float*>( UniformsFuncs::setMat4fv, "modelMatrix", 1, false, &transform.worldModelMat[0][0])); std::vector<Texture2D> texs; if (texHandle) { glm::vec4& Kd = texHandle->mKd; glm::vec4& Ka = texHandle->mKa; uniforms.push_back(UniformsFuncs::createUniform<float, float, float, float>( UniformsFuncs::set4f, "lightIntensity", diffuse.x * Kd.x, diffuse.y * Kd.y, diffuse.z * Kd.z, diffuse.w * Kd.w)); uniforms.push_back(UniformsFuncs::createUniform<float, float, float, float>( UniformsFuncs::set4f, "ambientIntensity", ambient.x*Ka.x, ambient.y*Ka.y, ambient.z*Ka.z, ambient.w*Ka.w)); uniforms.push_back(UniformsFuncs::createUniform<float>(UniformsFuncs::set1f, "lightAttenuation", attenuation * texHandle->mLightAttenuation)); texs = std::vector<Texture2D>(texHandle->mTexs); } else { uniforms.push_back(UniformsFuncs::createUniform<int, const float*>( UniformsFuncs::set4fv, "lightIntensity", 1, &diffuse[0])); uniforms.push_back(UniformsFuncs::createUniform<int, const float*>( UniformsFuncs::set4fv, "ambientIntensity", 1, &ambient[0])); uniforms.push_back(UniformsFuncs::createUniform<float>(UniformsFuncs::set1f, "lightAttenuation", attenuation)); } // agregar las uniforms de cada render component for (auto it = renderH->mProperties.begin(); it != renderH->mProperties.end(); ++it) { UniformBind uni = it->second->bind(it->first); uniforms.push_back(uni); } this->mCanvas.draw(shaderH->shaderProgramId, renderH->mPrimitive, renderH->mData.mVAO, renderH->mData.mUsedIndices, (void*)renderH->mDrawOffset, texs, uniforms); } } } //glDisable(GL_BLEND); if (count == 1) { frameFBO.saveFrame("frame"); } } c_handle<TransformComponent> camPosH = GameObjectFactory::getComponentBrother<TransformComponent>(cameraHandle); bool flag = true; glBindFramebuffer(GL_FRAMEBUFFER, 0); }