vmg_float Particle::Interpolation::EvaluatePotentialLR(const Particle& p) { vmg_float result = 0.0; Vector prod, offset; Index i; const Vector& pos = p.Pos(); prod[0] = 1.0; offset[0] = pos[0] - pos_begin[0]; for (i[0]=0; i[0]<deg_1; ++i[0]) { prod[1] = prod[0]; offset[1] = pos[1] - pos_begin[1]; for (i[1]=0; i[1]<deg_1; ++i[1]) { prod[2] = prod[1]; offset[2] = pos[2] - pos_begin[2]; for (i[2]=0; i[2]<deg_1; ++i[2]) { result += _access_coeff(i) * prod[2]; prod[2] *= offset[2]; offset[2] -= h[2]; } prod[1] *= offset[1]; offset[1] -= h[1]; } prod[0] *= offset[0]; offset[0] -= h[0]; } return result; }
void RenderingEngine::DrawParticles(simlist<Particle>* particles, long particlesLength, PointArrays* arrays){ if(_currentTexture->Name != Factory::Instance->TextureParticle->Name){ glBindTexture(GL_TEXTURE_2D, Factory::Instance->TextureParticle->Name); glEnableVertexAttribArray(_attributes.Position); glDisableVertexAttribArray(_attributes.TextureCoord); glUniform1i(_uniforms.IsParticle, GL_TRUE); glUniform1i(_uniforms.HasColorChange, GL_TRUE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); //glBlendFunc(GL_SRC_ALPHA, GL_ONE); _currentTexture = Factory::Instance->TextureParticle; } int v = 0; int c = 0; simnode<Particle>* node = particles->head; while (node != NULL) { Particle* p = node->data; vec2 pos = p->Pos(); vec4 color = p->Color(); arrays->vertices[v++] = pos.x; arrays->vertices[v++] = pos.y; arrays->colors[c++] = color.x; arrays->colors[c++] = color.y; arrays->colors[c++] = color.z; arrays->colors[c++] = color.w; node = node->next; } glVertexAttribPointer(_attributes.Position, 2, GL_FLOAT, GL_FALSE, 0, arrays->vertices); glVertexAttribPointer(_attributes.Color, 4, GL_FLOAT, GL_FALSE, 0, arrays->colors); glDrawArrays(GL_POINTS, 0, particlesLength); }
void Particle::Interpolation::Evaluate(Particle& p) { const Vector& pos = p.Pos(); vmg_float& pot = p.Pot(); Vector& field = p.Field(); pot = 0.0; field = 0.0; Vector offset = pos - pos_begin; buffer[0] = 1.0; for (int i=0; i<deg; ++i) { buffer[i+1] = buffer[i] * offset; for (int j=0; j<i; ++j) buffer_diff[i][j] = buffer_diff[i-1][j] * offset; buffer_diff[i][i] = buffer[i]; offset -= h; } for (int i=1; i<deg; ++i) for (int j=1; j<=i; ++j) buffer_diff[i][0] += buffer_diff[i][j]; for (int i=0; i<deg_1; ++i) for (int j=0; j<deg_1; ++j) for (int k=0; k<deg_1; ++k) pot += _access_coeff(i,j,k) * buffer[i][0] * buffer[j][1] * buffer[k][2]; for (int i=0; i<deg_1; ++i) for (int j=0; j<deg_1; ++j) for (int k=0; k<deg; ++k) { field[0] -= _access_coeff(k+1, i, j) * buffer[i][1] * buffer[j][2] * buffer_diff[k][0][0]; field[1] -= _access_coeff(i, k+1, j) * buffer[i][0] * buffer[j][2] * buffer_diff[k][0][1]; field[2] -= _access_coeff(i, j, k+1) * buffer[i][0] * buffer[j][1] * buffer_diff[k][0][2]; } }