Starting the refactoring for the new particle system

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12990 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
samuncle 2013-06-27 00:58:59 +00:00
parent 13d84ce4f4
commit b08fcc7801
2 changed files with 40 additions and 34 deletions

View File

@ -337,40 +337,7 @@ void CParticleSystemSceneNode::render()
{
const SParticle& particle = Particles[i];
#if 0
core::vector3df horizontal = camera->getUpVector().crossProduct(view);
horizontal.normalize();
horizontal *= 0.5f * particle.size.Width;
core::vector3df vertical = horizontal.crossProduct(view);
vertical.normalize();
vertical *= 0.5f * particle.size.Height;
#else
f32 f;
f = 0.5f * particle.size.Width;
const core::vector3df horizontal ( m[0] * f, m[4] * f, m[8] * f );
f = -0.5f * particle.size.Height;
const core::vector3df vertical ( m[1] * f, m[5] * f, m[9] * f );
#endif
Buffer->Vertices[0+idx].Pos = particle.pos + horizontal + vertical;
Buffer->Vertices[0+idx].Color = particle.color;
Buffer->Vertices[0+idx].Normal = view;
Buffer->Vertices[1+idx].Pos = particle.pos + horizontal - vertical;
Buffer->Vertices[1+idx].Color = particle.color;
Buffer->Vertices[1+idx].Normal = view;
Buffer->Vertices[2+idx].Pos = particle.pos - horizontal - vertical;
Buffer->Vertices[2+idx].Color = particle.color;
Buffer->Vertices[2+idx].Normal = view;
Buffer->Vertices[3+idx].Pos = particle.pos - horizontal + vertical;
Buffer->Vertices[3+idx].Color = particle.color;
Buffer->Vertices[3+idx].Normal = view;
drawBillboardParticle(idx, particle, view, m);
idx +=4;
}
@ -397,6 +364,38 @@ void CParticleSystemSceneNode::render()
}
}
//! Draw billboard particle
void CParticleSystemSceneNode::drawBillboardParticle(const irr::s32 &idx,
const SParticle &particle, const core::vector3df &view, const irr::core::matrix4 &m)
{
f32 f;
f = 0.5f * particle.size.Width;
const core::vector3df horizontal ( m[0] * f, m[4] * f, m[8] * f );
f = -0.5f * particle.size.Height;
const core::vector3df vertical ( m[1] * f, m[5] * f, m[9] * f );
Buffer->Vertices[0+idx].Pos = particle.pos + horizontal + vertical;
Buffer->Vertices[0+idx].Color = particle.color;
Buffer->Vertices[0+idx].Normal = view;
Buffer->Vertices[1+idx].Pos = particle.pos + horizontal - vertical;
Buffer->Vertices[1+idx].Color = particle.color;
Buffer->Vertices[1+idx].Normal = view;
Buffer->Vertices[2+idx].Pos = particle.pos - horizontal - vertical;
Buffer->Vertices[2+idx].Color = particle.color;
Buffer->Vertices[2+idx].Normal = view;
Buffer->Vertices[3+idx].Pos = particle.pos - horizontal + vertical;
Buffer->Vertices[3+idx].Color = particle.color;
Buffer->Vertices[3+idx].Normal = view;
}
//! returns the axis aligned bounding box of this node
const core::aabbox3d<f32>& CParticleSystemSceneNode::getBoundingBox() const

View File

@ -60,6 +60,13 @@ public:
//! render
virtual void render();
//! Draw billboard particle
void drawBillboardParticle(
const irr::s32 &idx,
const scene::SParticle &particle,
const core::vector3df &view,
const irr::core::matrix4 &m);
//! returns the axis aligned bounding box of this node
virtual const core::aabbox3d<f32>& getBoundingBox() const;