代码拉取完成,页面将自动刷新
#include "ParticleNode.h"
namespace FireCloud{
ParticleNode::ParticleNode(GLvector speed,GLcolor start_color,
GLcolor end_color,GLfloat start_size,
GLfloat end_size,GLuint life){
m_pos.x = 0;m_pos.y = 0;m_pos.z = 0;
m_speed = speed;
m_start_color = start_color;
m_end_color = end_color;
m_start_size = start_size;
m_end_size = end_size;
m_life = life;
m_age = 0;
m_diff_size = m_end_size-m_start_size;
ParticleTools::diff_glcolor(m_start_color,m_end_color,m_diff_color);
}
GLboolean ParticleNode::draw(GLvector a){
static GLfloat pos_array[] = {1.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,0.0f};
static GLubyte face_array[] = {3,0,1,0,2,1,3,1,2,3,0,2};
GLfloat age_div_life = (GLfloat)m_age/(GLfloat)m_life;
GLcolor cur_color;
GLfloat cur_size = ParticleTools::ratio_glfloat(m_start_size,m_diff_size,age_div_life);
ParticleTools::ratio_glcolor(m_start_color,m_diff_color,cur_color,age_div_life);
ParticleTools::add_glvector(m_pos,m_speed);
ParticleTools::add_glvector(m_speed,a);
glPushMatrix();
glTranslatef(m_pos.x,m_pos.y,m_pos.z);
glScalef(cur_size,cur_size,cur_size);
glColor4f(cur_color.r,cur_color.g,cur_color.b,cur_color.a);
glVertexPointer(3,GL_FLOAT,0,pos_array);
glDrawElements(GL_TRIANGLES,12,GL_UNSIGNED_BYTE,face_array);
glPopMatrix();
++m_age;
if(m_age>m_life){
return GL_TRUE;
}else{
return GL_FALSE;
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。