1 Star 0 Fork 0

codeblack/ParticleEngine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ParticleNode.cpp 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
synFireCloud 提交于 2015-07-21 15:18 . 提交版本1.0
#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;
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/blackland/ParticleEngine.git
git@gitee.com:blackland/ParticleEngine.git
blackland
ParticleEngine
ParticleEngine
master

搜索帮助