void CShapeModule::InitParticleForBox(CVec3& localPos, CVec3& direction, float fParticleScale) const { CVec3 halfSize = m_boxSize * 0.5f * fParticleScale; localPos.Fill(RANGR_RANDOM_FLOAT(-halfSize.X(), halfSize.X()), RANGR_RANDOM_FLOAT(-halfSize.Y(), halfSize.Y()), RANGR_RANDOM_FLOAT(-halfSize.Z(), halfSize.Z())); direction = CVec3(0, 0, 1); if (m_bRandomDirection) { direction = GetRandomDirection(); } }
void CShapeModule::InitParticleForCone(CVec3& localPos, CVec3& direction, float fParticleScale) const { CVec3 finalPos, finalDirection; float fClipAngle = m_fAngle; BEATS_CLIP_VALUE(fClipAngle, 0, 89.99f); float fRadius = m_fRadius * fParticleScale; float fConeLength = m_fConeLength * fParticleScale; float fTopRadius = fRadius + fConeLength * tanf(DegreesToRadians(fClipAngle)); CVec3 randomDirection(PARTICLE_RAND_RANGE(-1, 1), PARTICLE_RAND_RANGE(-1, 1), 0); randomDirection.Normalize(); float fRadiusOnBase = m_bEmitFromShell ? fRadius : PARTICLE_RAND_RANGE(0, fRadius); finalPos = randomDirection * fRadiusOnBase; BEATS_ASSERT(!BEATS_FLOAT_EQUAL(fRadius, 0)); fTopRadius *= (fRadiusOnBase / fRadius); CVec3 topPos = (m_bRandomDirection ? GetRandomDirection() : randomDirection) * fTopRadius; topPos.Z() = fConeLength; finalDirection = topPos - finalPos; if (!m_bEmitFromBaseOrVolume) { finalPos += (finalDirection * PARTICLE_RAND_RANGE(0, 1)); if (m_bRandomDirection) { finalDirection = GetRandomDirection(); } } finalDirection.Normalize(); localPos = finalPos; direction = finalDirection; }
CVec4::CVec4(const CVec3& vec3, float w) { Fill(vec3.X(), vec3.Y(), vec3.Z(), w); }
void CShapeRenderer::DrawAABB(const CAABBBox& aabb, CColor color) { CVec3 tmin = aabb.m_minPos; CVec3 tmax = aabb.m_maxPos; CVec3 sub = tmax - tmin; CVertexPC startPos, endPos; startPos.color = color; endPos.color = color; startPos.position = tmin; endPos.position = CVec3(tmin.X(), tmin.Y(), tmin.Z() + sub.Z() * 0.2F);// Min CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmin.X(), tmin.Y() + sub.Y() * 0.2F, tmin.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmin.X() + sub.X() * 0.2F, tmin.Y(), tmin.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); startPos.position = tmax; endPos.position = CVec3(tmax.X(), tmax.Y(), tmax.Z() - sub.Z() * 0.2F);// Max CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmax.X(), tmax.Y() - sub.Y() * 0.2F, tmax.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmax.X() - sub.X() * 0.2F, tmax.Y(), tmax.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); startPos.position = CVec3(tmin.X(), tmin.Y(), tmax.Z());// x min, y min, z max endPos.position = CVec3(tmin.X(), tmin.Y(), tmax.Z() - sub.Z() * 0.2F); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmin.X(), tmin.Y() + sub.Y() * 0.2F, tmax.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmin.X() + sub.X() * 0.2F, tmin.Y(), tmax.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); startPos.position = CVec3(tmin.X(), tmax.Y(), tmin.Z());// x min, y max, z min endPos.position = CVec3(tmin.X(), tmax.Y(), tmin.Z() + sub.Z() * 0.2F); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmin.X(), tmax.Y() - sub.Y() * 0.2F, tmin.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmin.X() + sub.X() * 0.2F, tmax.Y(), tmin.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); startPos.position = CVec3(tmax.X(), tmin.Y(), tmin.Z());// x max, y min, z min endPos.position = CVec3(tmax.X(), tmin.Y(), tmin.Z() + sub.Z() * 0.2F); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmax.X(), tmin.Y() + sub.Y() * 0.2F, tmin.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmax.X() - sub.X() * 0.2F, tmin.Y(), tmin.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); startPos.position = CVec3(tmin.X(), tmax.Y(), tmax.Z());// x min, y max, z max endPos.position = CVec3(tmin.X(), tmax.Y(), tmax.Z() - sub.Z() * 0.2F); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmin.X(), tmax.Y() - sub.Y() * 0.2F, tmax.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmin.X() + sub.X() * 0.2F, tmax.Y(), tmax.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); startPos.position = CVec3(tmax.X(), tmax.Y(), tmin.Z());// x min, y max, z max endPos.position = CVec3(tmax.X(), tmax.Y(), tmin.Z() + sub.Z() * 0.2F); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmax.X(), tmax.Y() - sub.Y() * 0.2F, tmin.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmax.X() - sub.X() * 0.2F, tmax.Y(), tmin.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); startPos.position = CVec3(tmax.X(), tmin.Y(), tmax.Z());// x max, y min, z max endPos.position = CVec3(tmax.X(), tmin.Y(), tmax.Z() - sub.Z() * 0.2F); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmax.X(), tmin.Y() + sub.Y() * 0.2F, tmax.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); endPos.position = CVec3(tmax.X() - sub.X() * 0.2F, tmin.Y(), tmax.Z()); CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true); }